Skip to main content

codetre

AST-based code structure tree tool.

Extracts classes, functions, methods and their call relationships into a clean hierarchical view. Uses ast-grep for AST-level accuracy across multiple languages.

Requirements

  • Python ≥ 3.10
  • ast-grep (sg) installed and on PATH

Installation

pip install codetre

Usage

# Scan current directory
codetre

# Scan specific directory
codetre src/

# Scan single file
codetre src/main.py

# Scan multiple files / directories
codetre src/main.py tests/

# JSON output
codetre --json src/

# Exclude patterns
codetre --exclude "test_*" --exclude "*_gen.py" src/

Supported Languages

Python, JavaScript, TypeScript, Go, C, C++, Java, Rust, Ruby, Kotlin, Scala, C#, PHP, Swift, Lua, Bash, and more.

Output Example

# format: name:start,count  -> [file-local ref, ...]

file: src/services/auth.py,84
  import hashlib
  import jwt

  class AuthService:9,76
    func __init__:14,7 -> [_load_secrets]
    func login:22,20  -> [_generate_token, _verify_password]
    func validate_token:43,20
    func _load_secrets:64,12
    func _generate_token:77,4
    func _verify_password:82,3
  func logout:32,8
  var SECRET_KEY:6

file: src/main.py,39
  import os
  from .services import AuthService

  class App:8,32
    func register_user:15,8
    func place_order:24,15 -> [validate_token, create_order]
  func create_app:4,3
  var VERSION:1

Each symbol shows kind name:start_line,line_count. Container symbols (class/struct/interface) have their children indented underneath. Call relationships appear as -> [callee, ...].

License

MIT

Metadata

Release files for codetre 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codetre 0.4.0
File Size Uploaded Provenance Actions
codetre-0.4.0.tar.gz 14.1 kB Without provenance Details for codetre-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codetre 0.4.0
File Interpreter ABI Platform Actions
codetre-0.4.0-py3-none-any.whl Python 3 none any Details for codetre-0.4.0-py3-none-any.whl

Total release size: 27.6 kB

Release files / codetre-0.4.0.tar.gz

Download URL codetre-0.4.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c1b6915a26a479d2378a0cd612169cfbd8d6268fb1d67bfac0a14c1beceb67e2
BLAKE2b-256 checksum
How to use checksums
66a88341d59357fdbc003d6cc08eb90bfd1a5126dad069a04df00a66a29a21e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / codetre-0.4.0-py3-none-any.whl

Download URL codetre-0.4.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d20ecdab2fdd7a9424a0ae488756cc656af43ee540139a0f7e267e7583a2678
BLAKE2b-256 checksum
How to use checksums
a8286290045aa8c9928437bfdbab56fb8ea6b6434f4601b06ef31cf667decec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for codetre 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page