In a pnpm project, run:
pnpm install @ast-grep/lang-python
pnpm install @ast-grep/napi
# install the tree-sitter-cli if no prebuild is available
pnpm install @tree-sitter/cli --save-dev
import python from '@ast-grep/lang-python'
import { registerDynamicLanguage, parse } from '@ast-grep/napi'
registerDynamicLanguage({ python })
const sg = parse('python', `your code`)
sg.root().kind()