AST introspection CLI for AI agents โ powered by tree-sitter
Project description
axm-ast
Python AST introspection CLI for AI agents, powered by tree-sitter.
Features
- ๐ฌ Describe โ Full package introspection: functions, classes, imports, variables
- ๐ Compress โ AI-friendly compressed view: signatures + docstrings +
__all__ - ๐ Graph โ Import dependency graph with Mermaid output
- ๐ Search โ Semantic symbol lookup by name, return type, kind, or base class
- ๐ Callers โ "Who calls this function?" via tree-sitter call-site detection
- ๐ Context โ One-shot project dump: stack, patterns, module ranking
- ๐ฅ Impact โ Change impact analysis: callers + graph + test mapping
- ๐ Doc Impact โ Documentation health: doc refs, undocumented symbols, stale signatures
- ๐ Docs โ One-shot documentation tree dump with progressive disclosure (toc/summary/full) and page filtering
- ๐ Dead code โ Detect unreferenced symbols with smart exemptions (dict dispatch, positional args, entry points, test callers, lazy imports)
- ๐ Flows โ Entry point detection (cyclopts, click, Flask, FastAPI, pytest,
__main__), BFS execution flow tracing with cross-module resolution and optional source code enrichment (detail=source) - ๐ Diff โ Structural branch diff at symbol level (added/modified/removed via git worktrees)
- ๐๏ธ Workspace โ Multi-package workspace support (auto-detects
uvworkspaces) - โญ Rank โ PageRank-based symbol importance scoring
Installation
uv add axm-ast
Quick Start
# One-shot project context for AI agents
axm-ast context src/mylib
axm-ast context src/mylib --depth none # full context (all modules + dependency graph)
axm-ast context src/mylib --depth 0 # compact top-5 overview
# Describe a package at different detail levels
axm-ast describe src/mylib
axm-ast describe src/mylib --detail full
axm-ast describe src/mylib --compress
axm-ast describe src/mylib --detail toc # table-of-contents
axm-ast describe src/mylib --modules core,tools # filter by module
axm-ast describe src/mylib --detail toc --modules core # combined
# Visualize import graph as Mermaid
axm-ast graph src/mylib --format mermaid
# Find all callers of a function
axm-ast callers src/mylib --symbol my_function
# Change impact analysis
axm-ast impact src/mylib --symbol my_function
# Workspace: cross-package analysis (auto-detected)
axm-ast context /path/to/workspace # all packages at once
axm-ast callers /path/to/workspace --symbol ToolResult
axm-ast graph /path/to/workspace --format mermaid
# Detect dead code
axm-ast dead-code src/mylib
axm-ast dead-code src/mylib --json
axm-ast dead-code src/mylib --include-tests # also scan test modules as targets
# Dump all project documentation in one shot
axm-ast docs .
axm-ast docs . --detail toc # heading scan (~500 tokens)
axm-ast docs . --detail summary # headings + first sentences
axm-ast docs . --pages architecture # filter by page name
axm-ast docs . --tree # tree only
axm-ast docs . --json # JSON output
# Structural diff between branches
axm-ast diff main..feature src/mylib
axm-ast diff main..feature src/mylib --json
# Detect entry points and trace execution flows
axm-ast flows src/mylib
axm-ast flows src/mylib --trace main # BFS flow from entry point
axm-ast flows src/mylib --trace main --detail source # include function source code
axm-ast flows tests/ --trace test_foo --cross-module # resolve sibling-package imports
axm-ast flows src/mylib --trace main --json
Example: axm-ast context
๐ mylib
layout: src (16 modules, 151 functions, 9 classes)
python: >=3.12
๐ง Stack
cli: cyclopts models: pydantic tests: pytest
lint: ruff types: mypy packaging: hatchling
๐ฆ Modules (ranked)
cli โ
โ
โ
โ
โ
(describe, inspect, graph, search, callers...)
core.analyzer โ
โ
โ
โ
โ (analyze_package, build_import_graph...)
core.context โ
โ
โ
โ
โ (detect_stack, build_context...)
core.docs โ
โ
โ
โโ (discover_docs, build_docs_tree...)
Example: axm-ast impact
๐ฅ Impact analysis for 'analyze_package' โ HIGH
๐ Defined in: core.analyzer (L38)
๐ Direct callers (7): cli, core.context, core.impact
๐ Affected modules (5): axm_ast, cli, core, core.context, core.impact
๐งช Tests to rerun (7): test_analyzer, test_callers, test_compress...
๐ฆ Re-exported in (5): axm_ast, cli, core, core.context, core.impact
CLI Commands
| Command | Description |
|---|---|
axm-ast describe |
Introspect a package (toc / summary / detailed / full / compress), optional --modules filter |
axm-ast inspect |
Inspect a symbol by name across a package (supports dotted paths, --source for source code) |
axm-ast graph |
Visualize import dependency graph (text / mermaid / json) |
axm-ast search |
Search symbols by name, return type, kind, or base class |
axm-ast callers |
Find all call-sites of a symbol |
axm-ast context |
One-shot project context dump for AI agents |
axm-ast impact |
Change impact analysis for a symbol |
axm-ast dead-code |
Detect unreferenced symbols with smart exemptions |
axm-ast flows |
Detect entry points and trace execution flows (--detail source for code enrichment) |
axm-ast diff |
Structural branch diff at symbol level (base..head) |
axm-ast docs |
One-shot documentation tree dump (README + mkdocs + docs/) |
axm-ast version |
Show version |
All commands support --json for machine-readable output.
Python API
from axm_ast import analyze_package, search_symbols
pkg = analyze_package("src/mylib")
results = search_symbols(pkg, returns="str")
for fn in results:
print(f"{fn.name}: {fn.signature}")
Use get_package instead of analyze_package to avoid re-parsing the same
package multiple times in a session:
from axm_ast.core import get_package, clear_cache
pkg = get_package("src/mylib") # parses on first call
pkg = get_package("src/mylib") # cache hit โ instant
clear_cache() # force re-parse on next call
Development
This package is part of the axm-forge workspace.
git clone https://github.com/axm-protocols/axm-forge.git
cd axm-forge
uv sync --all-groups
uv run --package axm-ast --directory packages/axm-ast pytest -x -q
๐ Full documentation
License
Apache-2.0 โ ยฉ 2026 axm-protocols
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 axm_ast-0.3.0.tar.gz.
File metadata
- Download URL: axm_ast-0.3.0.tar.gz
- Upload date:
- Size: 245.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f09d0fcc88c87d3082224a36ff854dbb9650fc218cdcbebd5562db1d4405afb9
|
|
| MD5 |
163f11cdb4e6cf9008686383c7e1be8b
|
|
| BLAKE2b-256 |
7263c2d4c35645680ba7d12228e8d5768b2cb6bc0238fca64ab26476b96a2c5a
|
Provenance
The following attestation bundles were made for axm_ast-0.3.0.tar.gz:
Publisher:
publish.yml on axm-protocols/axm-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axm_ast-0.3.0.tar.gz -
Subject digest:
f09d0fcc88c87d3082224a36ff854dbb9650fc218cdcbebd5562db1d4405afb9 - Sigstore transparency entry: 1280064084
- Sigstore integration time:
-
Permalink:
axm-protocols/axm-forge@b8995097940cb2423b9cad88e3a4a22dbd3be6b3 -
Branch / Tag:
refs/tags/ast/v0.3.0 - Owner: https://github.com/axm-protocols
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8995097940cb2423b9cad88e3a4a22dbd3be6b3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file axm_ast-0.3.0-py3-none-any.whl.
File metadata
- Download URL: axm_ast-0.3.0-py3-none-any.whl
- Upload date:
- Size: 125.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d430f385a133aaf3050dd7ee2f8dd93b49a54dc74234fb8c8caa5bc6419d0a7
|
|
| MD5 |
f0120426a2ba5d6c8242918537cbd740
|
|
| BLAKE2b-256 |
0115e5a454a0c67423693dad429e7fbde0a76ef79c1a35cdb00ef5b9fa41b866
|
Provenance
The following attestation bundles were made for axm_ast-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on axm-protocols/axm-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
axm_ast-0.3.0-py3-none-any.whl -
Subject digest:
1d430f385a133aaf3050dd7ee2f8dd93b49a54dc74234fb8c8caa5bc6419d0a7 - Sigstore transparency entry: 1280064088
- Sigstore integration time:
-
Permalink:
axm-protocols/axm-forge@b8995097940cb2423b9cad88e3a4a22dbd3be6b3 -
Branch / Tag:
refs/tags/ast/v0.3.0 - Owner: https://github.com/axm-protocols
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b8995097940cb2423b9cad88e3a4a22dbd3be6b3 -
Trigger Event:
push
-
Statement type: