Map a codebase to YAML/JSON/Markdown/text and select smart git-diff context for LLMs
Project description
TreeMapper
Map a codebase into LLM-ready context. TreeMapper serializes an entire directory tree — structure plus file contents — to YAML, JSON, Markdown, or text, and selects the minimal smart git-diff context needed to understand a change. Paste the output into Claude, ChatGPT, or any LLM.
TreeMapper is a thin command-line product built on the
diffctx engine. All traversal,
serialization, and diff-context selection live in diffctx; TreeMapper
re-exposes them under the treemapper name so there is a single source of
truth and no duplicated logic.
Installation
pipx install treemapper # recommended: isolated, no venv needed
pip install treemapper # or with pip
pip install 'treemapper[tree-sitter]' # + AST parsing for smarter diff context
pip install 'treemapper[mcp]' # + MCP server for AI assistants
Usage
treemapper . # map current directory to YAML (stdout)
treemapper /path/to/project # map a specific directory
treemapper . -f json # output as JSON
treemapper . -f md --save # save as tree.md
treemapper . --no-content # structure only, no file contents
treemapper . -c # copy output to clipboard
treemapper . --diff HEAD~1 # smart context for the last commit
treemapper . --diff main..HEAD # smart context for a branch range
treemapper graph . # project dependency graph (mermaid)
Two modes
- Tree mapping (
treemapper .) — walks the directory tree, respects hierarchical ignore patterns (.gitignore,.diffctx/ignore), reads file contents with binary/encoding detection, and serializes the result. - Diff context (
treemapper . --diff) — analyzes a git diff and selects the minimal set of code fragments needed to understand the change, instead of dumping whole files.
Run treemapper --help for the full flag reference.
Python API
import treemapper
tree = treemapper.map_directory(".", no_content=False)
print(treemapper.to_yaml(tree))
context = treemapper.build_diff_context(root_dir=".", diff_range="HEAD~1")
# treemapper.run drives the full branded CLI from Python (same surface as the command)
treemapper.run(["graph", "."], prog="treemapper", version=treemapper.__version__)
Every run reports an exact tiktoken token count (not a chars / 4
estimate), so you know the real context cost before you paste.
Relationship to diffctx
TreeMapper is the user-facing distribution; diffctx is the reusable engine.
Pin compatibility is diffctx>=1.10.0,<2.0. If you are embedding the engine in
your own tool, depend on diffctx directly.
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treemapper-2.2.0.tar.gz.
File metadata
- Download URL: treemapper-2.2.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a90ee01685e4b205ddc929b76ac8d1a7d3dfc300fe1a857515a4380bbc3a14
|
|
| MD5 |
73d1b25dba52942fc7f0767117b72ff0
|
|
| BLAKE2b-256 |
252cebf2bfd60bb544b1bb52dc37de8058ce00b291d4f8a9f06f9868f5f62fdf
|
Provenance
The following attestation bundles were made for treemapper-2.2.0.tar.gz:
Publisher:
cd.yml on nikolay-e/treemapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
treemapper-2.2.0.tar.gz -
Subject digest:
a8a90ee01685e4b205ddc929b76ac8d1a7d3dfc300fe1a857515a4380bbc3a14 - Sigstore transparency entry: 1900986905
- Sigstore integration time:
-
Permalink:
nikolay-e/treemapper@64eb9b9345176c7dd81a5d6575155b5cff7169a1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikolay-e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@64eb9b9345176c7dd81a5d6575155b5cff7169a1 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file treemapper-2.2.0-py3-none-any.whl.
File metadata
- Download URL: treemapper-2.2.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a0732454a6c19493dcd1c403517e471b95071bfa7c5f469f2f364b39cc5edbf
|
|
| MD5 |
f374d82cc643ded8f1eb60c11c2bdbb5
|
|
| BLAKE2b-256 |
60c4f624eedbe93ed4009d2a80da9ba1f4d4209c20e17375d759a47a8563d8af
|
Provenance
The following attestation bundles were made for treemapper-2.2.0-py3-none-any.whl:
Publisher:
cd.yml on nikolay-e/treemapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
treemapper-2.2.0-py3-none-any.whl -
Subject digest:
1a0732454a6c19493dcd1c403517e471b95071bfa7c5f469f2f364b39cc5edbf - Sigstore transparency entry: 1900987071
- Sigstore integration time:
-
Permalink:
nikolay-e/treemapper@64eb9b9345176c7dd81a5d6575155b5cff7169a1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nikolay-e
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@64eb9b9345176c7dd81a5d6575155b5cff7169a1 -
Trigger Event:
workflow_dispatch
-
Statement type: