Metadata-Version: 2.4
Name: treesitter-chunker
Version: 7.0.0
Summary: Semantic code chunker using Tree-sitter for intelligent code analysis
Author-email: ViperJuice <jenner@consiliency.io>
Maintainer-email: ViperJuice <jenner@consiliency.io>
License: MIT
Project-URL: Homepage, https://github.com/Consiliency/treesitter-chunker
Project-URL: Documentation, https://treesitter-chunker.readthedocs.io
Project-URL: Repository, https://github.com/Consiliency/treesitter-chunker
Project-URL: Issues, https://github.com/Consiliency/treesitter-chunker/issues
Project-URL: Changelog, https://github.com/Consiliency/treesitter-chunker/blob/main/CHANGELOG.md
Keywords: tree-sitter,code-analysis,chunking,parsing,ast,semantic-analysis,llm,embeddings,rag
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Typing :: Typed
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tree_sitter<0.27,>=0.26
Requires-Dist: tree-sitter-language-pack<1.21,>=1.20
Requires-Dist: tree-sitter-python==0.25.0
Requires-Dist: tree-sitter-javascript==0.25.0
Requires-Dist: packaging>=25.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.9.0
Requires-Dist: pyarrow>=22.0.0
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: pygments>=2.15.0
Requires-Dist: chardet>=5.0.0
Requires-Dist: python-dateutil>=2.9.0
Requires-Dist: gitpython>=3.1.40
Requires-Dist: pathspec>=0.11.0
Requires-Dist: tqdm>=4.66.0
Requires-Dist: tiktoken>=0.7.0
Requires-Dist: tomli-w>=1.0.0
Requires-Dist: networkx>=3.0
Requires-Dist: leidenalg>=0.10.0
Requires-Dist: igraph>=0.11.0
Requires-Dist: unicodedata2==16.0.0; python_version != "3.14" or platform_python_implementation != "CPython"
Provides-Extra: baml
Requires-Dist: treesitter-chunker-baml-grammar==0.1.0; extra == "baml"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: pytest-xdist>=3.3.1; extra == "dev"
Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
Requires-Dist: filelock>=3.12.0; extra == "dev"
Requires-Dist: black==25.12.0; extra == "dev"
Requires-Dist: ruff>=0.3.4; extra == "dev"
Requires-Dist: mypy>=1.9.0; extra == "dev"
Requires-Dist: isort>=5.13.0; extra == "dev"
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
Requires-Dist: bandit[toml]>=1.7.8; extra == "dev"
Requires-Dist: types-setuptools; extra == "dev"
Requires-Dist: types-pyyaml; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: toml>=0.10.2; extra == "dev"
Requires-Dist: httpx>=0.27.0; extra == "dev"
Requires-Dist: jsonschema>=4.0.0; extra == "dev"
Provides-Extra: viz
Requires-Dist: graphviz; extra == "viz"
Provides-Extra: profile
Requires-Dist: memory-profiler>=0.61.0; extra == "profile"
Requires-Dist: line-profiler>=4.1.0; extra == "profile"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
Provides-Extra: api
Requires-Dist: fastapi>=0.100.0; extra == "api"
Requires-Dist: uvicorn[standard]>=0.23.0; extra == "api"
Requires-Dist: pydantic>=2.0.0; extra == "api"
Provides-Extra: templates
Requires-Dist: jinja2>=3.0.0; extra == "templates"
Provides-Extra: advanced
Requires-Dist: numpy>=1.20.0; extra == "advanced"
Provides-Extra: full
Requires-Dist: jinja2>=3.0.0; extra == "full"
Requires-Dist: numpy>=1.20.0; extra == "full"
Provides-Extra: all
Requires-Dist: treesitter-chunker[advanced,api,dev,docs,profile,templates,viz]; extra == "all"
Dynamic: license-file

# Tree-sitter Chunker

[![PyPI](https://img.shields.io/pypi/v/treesitter-chunker.svg)](https://pypi.org/project/treesitter-chunker/)
[![Python 3.14+](https://img.shields.io/badge/python-3.14+-blue.svg)](https://www.python.org/downloads/)
[![Test Suite](https://github.com/Consiliency/treesitter-chunker/actions/workflows/test.yml/badge.svg)](https://github.com/Consiliency/treesitter-chunker/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/Consiliency/treesitter-chunker/branch/main/graph/badge.svg)](https://codecov.io/gh/Consiliency/treesitter-chunker)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

Split source code into functions, classes, and other syntax units for code
search, embeddings, and AI context. Tree-sitter provides the syntax tree;
Chunker returns source content, line and byte spans, and context metadata.

## Install

Development and 7.0.0 require Python 3.14 or newer.
Python 3.12 and 3.13 are no longer supported (treesitter-chunker#599). CI,
platform checks and release validation run on 3.14.

Published 6.0.0 retains Python 3.11 support.
The main package is a universal Python wheel.

```bash
pip install treesitter-chunker
```

The default parser stack uses Tree-sitter 0.26 and language-pack 1.20.
Parser libraries download on first use and are cached by pack version and
platform. The supported Linux wheel path requires glibc 2.34 or newer.
For offline use, prefetch the languages you need while online:

```bash
python -c "import tree_sitter_language_pack as p; p.prefetch(['python', 'javascript', 'typescript'])"
```

See [packaging and parser integrity](docs/packaging.md) for platform limits,
offline custody, and release procedures. Debian, RPM, and Homebrew packages
are currently suspended.

Optional extras include `viz` for visualization and `advanced` for additional
query dependencies. Graphviz visualization also requires the system `dot`
executable. The `api` extra installs REST API dependencies; the server under
`api/` runs from a source checkout and is not included in the main wheel.

## Chunk a file or source text

```python
from chunker import chunk_file, chunk_text

chunks = chunk_file("app.py", language="python")
for chunk in chunks:
    print(chunk.node_type, chunk.start_line, chunk.end_line)
    print(chunk.content)

source = "def greet(name):\n    return f'Hello, {name}'\n"
chunks = chunk_text(source, language="python", file_path="greet.py")
```

Pass a stable `file_path` when chunking text if you persist chunk identities.
See the [chunk identity contract](docs/chunk-identity.md) and
[Boundary IR specification](docs/interface-boundary-spec.md) for identity,
determinism, and relationship semantics.

The CLI can return JSON for use from other languages:

```bash
treesitter-chunker chunk app.py --lang python --json
printf 'def greet():\n    return "hello"\n' | treesitter-chunker chunk --stdin --lang python --json
treesitter-chunker boundary app.py --lang python --pretty
treesitter-chunker languages
treesitter-chunker --help
```

To check the installed version:

```bash
python -c "from importlib.metadata import version; print(version('treesitter-chunker'))"
```

## Language support

The pinned language pack contains 371 parsers: 370 pass the bounded load
gate, while COBOL is disabled after a native parser hang. Loading a parser
does not establish useful chunk extraction. The committed coverage report
records 28 extraction-verified languages and 12 languages with deterministic
Boundary IR golden fixtures.

See the [language coverage report](docs/language-coverage.md) for the
per-language results and remaining extraction gaps.

### BAML

Install the optional companion grammar for structural `.baml` chunking:

```bash
pip install 'treesitter-chunker[baml]'
treesitter-chunker chunk example.baml --json
```

The extra pins `treesitter-chunker-baml-grammar==0.1.0`. It uses BoundaryML's
official grammar with a temporary overlay for BAML 0.20.1 backtick prompts.
Published 0.1.0 has `cp311-abi3` wheels for Linux glibc x86_64/aarch64, macOS
x86_64/arm64, and Windows x86_64. The companion source now builds `cp312-abi3`
wheels and tests them on Python 3.12 and 3.14 for a future release. Source
installs require a C compiler.

Without the extra, main CLI BAML inputs give installation guidance and status 1;
implicit ZeroConfigAPI file chunking falls back to text, and automatic symbol
and Boundary repository scans skip BAML. Malformed BAML fails before
returning structural chunks. See the [companion grammar README](packages/baml-grammar/README.md).

## Documentation

- [Documentation site](https://consiliency.github.io/treesitter-chunker/)
- [Getting started](docs/getting-started.md) and [CLI reference](docs/cli-reference.md)
- [Python API](docs/api-reference.md), [configuration](docs/configuration.md), and [cookbook](docs/cookbook.md)
- [Export formats](docs/export-formats.md) and [GraphML](docs/graphml_export.md)
- [Architecture](docs/architecture.md) and [plugin development](docs/plugin-development.md)
- [Release history](CHANGELOG.md) and [contributing](CONTRIBUTING.md)

## Development

```bash
git clone https://github.com/Consiliency/treesitter-chunker.git
cd treesitter-chunker
uv sync --locked --all-extras
uv run --locked --with toml --all-extras python scripts/run_ci_smoke.py
```

[CONTRIBUTING.md](CONTRIBUTING.md) describes local validation, platform checks,
and Boundary IR changes. Coverage work remains in progress under
treesitter-chunker#69; the Codecov badge reports the CI measurement and is not
a claim that the full package meets a percentage target.

Report bugs through [GitHub issues](https://github.com/Consiliency/treesitter-chunker/issues).
Licensed under [MIT](LICENSE).
