Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

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

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

Wyciąga z pliku źródłowego strukturę kodu: funkcje, klasy, importy, eksporty, docstringi i błędy składni w formacie JSON.

Licencja
MIT
Ostatnia zmiana repozytorium
07.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
1
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • SKILL.md zawiera komentarze HTML (1). Nie widać ich w podglądzie Markdown, a model je czyta.

Co robi i kiedy

Wyciąga z pliku źródłowego strukturę kodu: funkcje, klasy, importy, eksporty, docstringi i błędy składni w formacie JSON.

Oryginalny opis (EN)

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.

Jak działa

  1. Quick recipe
  2. Feature flags
  3. Result shape
  4. Examples
  5. SDK equivalent
  6. When to reach for parse instead
Sekcje z nagłówków SKILL.md, w oryginale · 131 linii, 634 słów
Podgląd SKILL.md
---
description: 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.
name: tree-sitter-language-pack-extracting-code-structure
---

<!--
AI-RULEZ :: GENERATED FILE — DO NOT EDIT
Content-Hash: blake3:134c19e688f04cc2315c2ffa5fc4c6a567c9166258bc1cc5b1f19f4acfcbddb7
Source-Hash: blake3:b8687cf31ac8c66a5ecc15c4f11520ff201d8db14467b7528d5120124e9753a4
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

```bash
# 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

| Flag | Extracts |
| ---- | -------- |
| `--structure` | Functions, classes, methods, modules (spans, nesting, visibility). |
| `--imports` | Import statements and their sources. |
| `--exports` | Exported symbols and their kinds. |
| `--comments` | Inline and block comments. |
| `--docstrings` | Docstrings attached to definitions. |
| `--symbols` | All identifiers (for search/indexing). |
| `--diagnostics` | Syntax errors and error nodes with positions. |
| `--all` | Enable 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:

```json
{
  "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

```bash
# 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

```python
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.
Pliki w paczce (2)
  • SKILL.md 5 KB
  • index.md 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · xberg-io/tree-sitter-language-pack95MIT
xberg-io/tree-sitter-language-pack95MIT

Migawka bazy z 13.11.2026 · wersja paczki 49bd0978719e (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 84tree-sitter-language-pack
    Parsuje kod w 372 językach przez gramatyki tree-sitter i wydobywa strukturę, importy, symbole oraz diagnostykę składni.
  • 95tree-sitter-language-pack-parsing-source
    Tworzy drzewo składni tree-sitter dla pliku źródłowego w postaci S-wyrażeń lub JSON i sprawdza, czy zawiera błędy.
  • 100srgn-cli
    Buduje bezpieczne polecenia srgn do wyszukiwania i przekształcania kodu z uwzględnieniem składni, w tym refaktoryzacje ograniczone do komentarzy, importów czy funkcji oraz kontrole w CI.
  • 95html-to-markdown-extracting-metadata
    Wyciąga metadane z HTML: tytuł, opis, język, Open Graph, JSON-LD, nagłówki, linki i obrazy, w formacie JSON.
  • 96add-language
    Dodaje obsługę nowego języka programowania do narzędzia Acai: zależność Tree-sitter, parser i rejestrację w katalogu głównym.
  • 95html-to-markdown-extracting-metadata
    Wyciąga metadane z HTML, takie jak tytuł, opis, język, Open Graph, JSON-LD, nagłówki, linki i obrazy, w formacie JSON.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.