본문으로 건너뛰기
cccskills
무료GitHub에 공개

tree-sitter-language-pack-extracting-code-structure

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack스타 478(GitHub 478 + cccskills 0)

실행 점수 미검증

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.0 KB
  • index.md579 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

<!-- AI-RULEZ :: GENERATED FILE — DO NOT EDIT Content-Hash: blake3:134c19e688f04cc2315c2ffa5fc4c6a567c9166258bc1cc5b1f19f4acfcbddb7 Source-Hash: blake3:f6af1693d7e3d301871730c180582f140a9c6aeee0d040ba3edbfb33b5d38409 Schema-Version: v1 -->

Extracting code structure

ts-pack process <file> runs the code-intelligence pipeline over a source file and prints JSON. Use it when the user wants structured metadata — "list the functions", "what does this file import", "find the exported symbols", "pull the docstrings" — rather than a raw syntax tree.

Quick recipe

# Default features: structure + imports + exports
ts-pack process src/app.ts

# Pick features explicitly (only what you ask for is computed)
ts-pack process src/app.ts --structure --imports --symbols --docstrings

# Everything
ts-pack process src/app.ts --all

When no feature flags are given, process defaults to --structure --imports --exports. Passing any single extraction flag (--structure --imports --exports --comments --docstrings --symbols --diagnostics) turns off that default set, so list every feature you want. --chunk-size and --language are modifiers, not extraction flags: they do not disable the defaults (e.g. --chunk-size 500 alone still emits structure+imports+exports and adds chunks).

Feature flags

FlagExtracts
--structureFunctions, classes, methods, modules (spans, nesting, visibility).
--importsImport statements and their sources.
--exportsExported symbols and their kinds.
--commentsInline and block comments.
--docstringsDocstrings attached to definitions.
--symbolsAll identifiers (for search/indexing).
--diagnosticsSyntax errors and error nodes with positions.
--allEnable every feature above.
--chunk-size <bytes>Syntax-aware chunks — see tree-sitter-language-pack-chunking-for-llms.
--language <name> (-l)Override language (auto-detected from extension otherwise).

Result shape

process always prints JSON. Top-level keys:

{
  "language": "python",
  "metrics": { "total_lines": 0, "code_lines": 0, "comment_lines": 0, "blank_lines": 0, "total_bytes": 0, "node_count": 0, "error_count": 0, "max_depth": 0 },
  "structure": [],
  "imports": [],
  "exports": [],
  "comments": [],
  "docstrings": [],
  "symbols": [],
  "diagnostics": [],
  "chunks": []
}

metrics is populated whenever any processing runs. chunks appears only when --chunk-size is set. Empty collections are omitted from the JSON (the skip_serializing_if wire contract), so absent keys mean "nothing found", not an error.

Structure items

Each structure entry has kind (a capitalized string — "Function", "Class", "Method", "Module", "Struct", "Trait", …; language-specific kinds serialize as {"Other": "<kind>"}), name, visibility, and a nested span object with start_byte/end_byte and zero-indexed start_line/start_column/end_line/end_column. Nesting is expressed via children (e.g. methods inside a class), not a parent pointer. Optional fields: decorators, doc_comment (the attached doc comment), signature, and body_span.

Examples

# Function and class names with line numbers
ts-pack process src/service.py --structure \
  | jq '.structure[] | {kind, name, line: .span.start_line}'

# Import sources only
ts-pack process src/app.ts --imports \
  | jq '.imports[].source'

# Syntax error count (also available via metrics.error_count)
ts-pack process broken.go --diagnostics \
  | jq '.diagnostics | length'

# Build a symbol index across a tree of files
for f in $(git ls-files '*.rs'); do
  ts-pack process "$f" --symbols | jq -c --arg f "$f" '{file: $f, symbols: .symbols}'
done

SDK equivalent

from tree_sitter_language_pack import process, ProcessConfig

# ProcessConfig is a frozen dataclass — set fields in the constructor.
# structure/imports/exports default to True; add the rest you want.
config = ProcessConfig("python", symbols=True, docstrings=True)
result = process(source_code, config)
for item in result.structure:                 # ProcessResult is an object, not a dict
    print(item.kind, item.name, item.span.start_line)

The SDK also exposes the parsed tree (get_parser(...) → Parser/Tree/ Node) for running your own tree-sitter queries, and a data_extraction config flag that pulls a hierarchical key/value tree from data-format files (JSON, YAML, TOML, …) into the result's data field — neither is exposed on the CLI.

When to reach for parse instead

If the user wants the raw syntax tree rather than extracted metadata, use ts-pack parse — see the tree-sitter-language-pack-parsing-source skill.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

api

무료

Use tree-sitter-language-pack api reference documentation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

cli

무료

Use tree-sitter-language-pack cli reference documentation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

mcp

무료

Use tree-sitter-language-pack mcp reference documentation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

xberg-io/tree-sitter-language-pack4782026년 10월 26일 업데이트

xberg-io의 스킬 모두 보기

이 스킬의 문제 신고