api
免费Use tree-sitter-language-pack api reference documentation.
中文简介正在准备中。当前显示原文说明。
Use when the user wants a tree-sitter syntax tree for a source file — an s-expression dump or JSON tree. Covers `ts-pack parse`, language auto-detection vs `--language`, stdin input, and reading `has_errors`.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
ts-pack parse <file> parses one source file with the matching
tree-sitter grammar and prints the resulting concrete syntax tree. Use it
when the user wants the tree itself — to inspect node structure, debug a
grammar, or feed an s-expression to another tool.
# S-expression (default) — auto-detects language from the file extension
ts-pack parse src/main.rs
# JSON form: { "language", "sexp", "has_errors" }
ts-pack parse src/main.rs --format json
| Flag | Short | Default | Purpose |
|---|---|---|---|
--language <name> | -l | auto | Override the language (skip extension detection). |
--format <fmt> | -f | sexp | sexp or json. |
The parser library for the language downloads on first use and is cached.
The language is auto-detected from the file extension. Override it when the extension is missing, misleading, or you are reading from stdin:
# Misleading extension or no extension:
ts-pack parse script --language bash
# stdin (use "-" as the file):
cat snippet.py | ts-pack parse - --language python
stdin cannot be auto-detected by path; always pass --language with -.
For content-based detection without a path, use the SDK
(detect_language_from_content) — see the tree-sitter-language-pack-detecting-languages skill.
A nested (node_type child ...) tree. Compact, good for eyeballing
structure or piping to a grammar tool.
{
"language": "rust",
"sexp": "(source_file (function_item ...))",
"has_errors": false
}
Read has_errors to know whether the parse produced any error nodes — a
fast syntax check. For positioned, per-error detail use
ts-pack process <file> --diagnostics (see tree-sitter-language-pack-extracting-code-structure).
# Inspect a TypeScript file's tree
ts-pack parse src/app.ts
# Machine-readable, then check for syntax errors with jq
ts-pack parse src/app.ts --format json | jq '.has_errors'
# Parse a heredoc as Python
printf 'def f():\n return 1\n' | ts-pack parse - -l python
parse gives you the raw tree. If the user wants structured metadata
(functions, imports, exports, symbols, docstrings) rather than the tree,
use ts-pack process — see the tree-sitter-language-pack-extracting-code-structure skill.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Use tree-sitter-language-pack api reference documentation.
中文简介正在准备中。当前显示原文说明。
Use tree-sitter-language-pack cli reference documentation.
中文简介正在准备中。当前显示原文说明。
Use tree-sitter-language-pack mcp reference documentation.
中文简介正在准备中。当前显示原文说明。
Parse and extract code intelligence from 372 programming languages using tree-sitter grammars. Use when writing code that parses source, extracts structure/imports/exports/symbols/docstrings/comments, detects a language, runs syntax diagnostics, or produces syntax-aware chunks for LLMs — in Rust, Python, Node.js/TypeScript, or the ts-pack CLI. Covers installation, the CLI surface, the SDK surface, and parser-cache management.
中文简介正在准备中。当前显示原文说明。
Use when the user wants to split source code into chunks for an LLM context window without breaking syntax mid-construct. Covers `ts-pack process --chunk-size`, why syntax-aware splits beat fixed-byte splits, picking a size, and the chunk JSON shape.
中文简介正在准备中。当前显示原文说明。
Use when the user wants to know which programming language a file or snippet is. Covers implicit detection in `ts-pack parse`/`process`, confirming support with `ts-pack list`/`info`, and the SDK detection functions for path, extension, and raw content.
中文简介正在准备中。当前显示原文说明。