api
免费Use tree-sitter-language-pack api reference documentation.
中文简介正在准备中。当前显示原文说明。
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.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
tree-sitter-language-pack maps a file to one of 372 supported languages. Detection works from a file path, a bare extension, or — via the SDK — the file content itself.
There is no standalone ts-pack detect command. parse and process
auto-detect the language from the file extension and act on it:
ts-pack parse src/app.ts # detects "typescript", parses
ts-pack process app.py # detects "python", extracts
When detection fails (no extension, ambiguous, or stdin), pass --language:
cat snippet | ts-pack parse - --language go
To check whether a language name is supported and cached without parsing
anything, use list and info:
ts-pack list --filter type # languages whose name contains "type"
ts-pack list --manifest # every language in the remote manifest
ts-pack info typescript # is it known? is it downloaded? cache path?
The core exposes three detection functions, including content-based detection that the CLI does not surface:
| Function | Detects from |
|---|---|
detect_language_from_path(path) | Full path (uses the extension). |
detect_language_from_extension(ext) | A bare extension like "rs". |
detect_language_from_content(content) | Raw source text — no path needed. |
Each returns the language name or null/None when no grammar matches.
from tree_sitter_language_pack import (
detect_language_from_path,
detect_language_from_extension,
detect_language_from_content,
)
detect_language_from_path("src/app.py") # "python"
detect_language_from_extension("rs") # "rust"
detect_language_from_content(open("x").read()) # from the shebang line, if present
import { detectLanguageFromPath, detectLanguageFromContent } from "@xberg-io/tree-sitter-language-pack";
const lang = detectLanguageFromPath("src/app.ts") ?? detectLanguageFromContent(source);
ts-pack parse/process
and let it auto-detect.detect_language_from_content, then pass the result as
--language to the CLI if needed.Once the language is known, hand off to tree-sitter-language-pack-parsing-source (syntax tree) or
tree-sitter-language-pack-extracting-code-structure (metadata). To see or prefetch the parser for a
detected language, see tree-sitter-language-pack-managing-parsers.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
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 structured code metadata from a source file — functions, classes, imports, exports, symbols, docstrings, comments, or syntax diagnostics. Covers `ts-pack process` feature flags, the JSON result shape, and the default feature set.
中文简介正在准备中。当前显示原文说明。