Skip to main content

Export codebase structure and contents for AI/LLM context

Project description

TreeMapper

Extends ../CLAUDE.md

PyPI Downloads License

Export your codebase for AI/LLM context in one command.

pip install treemapper
treemapper . -o context.yaml   # paste into ChatGPT/Claude

Why TreeMapper?

Unlike tree or find, TreeMapper exports structure + file contents in a format optimized for LLM context windows:

name: myproject
type: directory
children:
  - name: main.py
    type: file
    content: |
      def hello():
          print("Hello, World!")
  - name: utils/
    type: directory
    children:
      - name: helpers.py
        type: file
        content: |
          def add(a, b):
              return a + b

Usage

treemapper .                          # YAML to stdout
treemapper . -o tree.yaml             # save to file
treemapper . --format json            # JSON format
treemapper . --format text            # tree-style text
treemapper . --no-content             # structure only (no file contents)
treemapper . --max-depth 3            # limit directory depth
treemapper . --max-file-bytes 10000   # skip files larger than 10KB
treemapper . -i custom.ignore         # custom ignore patterns

Python API

from treemapper import map_directory, to_yaml, to_json, to_text

# Get tree as dict
tree = map_directory("./myproject")
tree = map_directory("./src", max_depth=2, no_content=True)

# Serialize to string
yaml_str = to_yaml(tree)
json_str = to_json(tree)
text_str = to_text(tree)

Ignore Patterns

Respects .gitignore and .treemapperignore automatically. Use --no-default-ignores to include everything.

Development

pip install -e ".[dev]"
pytest
pre-commit run --all-files

Testing

Integration tests only - test against real filesystem. No mocking.

Architecture

src/treemapper/
├── cli.py        # argument parsing
├── ignore.py     # gitignore/treemapperignore handling
├── tree.py       # directory traversal
├── writer.py     # YAML/JSON/text output
└── treemapper.py # main entry point

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treemapper-1.1.2.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treemapper-1.1.2-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file treemapper-1.1.2.tar.gz.

File metadata

  • Download URL: treemapper-1.1.2.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for treemapper-1.1.2.tar.gz
Algorithm Hash digest
SHA256 91529969e23d7f8a13d28e294aa0c75129fec3c1f8db0eb1441268c84e075597
MD5 283b48688062cba707ca64ad276c7d74
BLAKE2b-256 88b2a8e91382d7485782a1db70a61485b40b05492b627c2c0d7c60082a54a6a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for treemapper-1.1.2.tar.gz:

Publisher: cd.yml on nikolay-e/treemapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file treemapper-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: treemapper-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for treemapper-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cfe9f8b1b67716a109964dc7aac026ecbd8f335c45155e15a654336a069d8e6a
MD5 cb26a731289bb910578fa567c7de8519
BLAKE2b-256 0900a92a2b8bff755b38a4abc24cbbe1e2a47c24787614cfc3fbd710f9df29ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for treemapper-1.1.2-py3-none-any.whl:

Publisher: cd.yml on nikolay-e/treemapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page