Index
axm_ast
axm-ast — AST introspection CLI for AI agents, powered by tree-sitter.
This package provides deterministic, fast parsing of Python libraries to extract structured information (functions, classes, imports, docstrings, call graphs) at multiple granularity levels.
Example
from axm_ast import analyze_package from pathlib import Path
pkg = analyze_package(Path("src/mylib")) [m.path.name for m in pkg.modules]['__init__.py', 'core.py', 'utils.py']
ClassInfo
Bases: BaseModel
Metadata for a single class.
Example
cls = ClassInfo(name="Parser", line_start=1, line_end=50) cls.is_public True
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
is_public
property
Whether this class is part of the public API.
FunctionInfo
Bases: BaseModel
Metadata for a single function or method.
Example
fn = FunctionInfo(name="parse", line_start=10, line_end=25) fn.is_public True
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
is_public
property
Whether this function is part of the public API.
signature
property
Human-readable signature string.
FunctionKind
Bases: StrEnum
Classification of a callable based on its decorators.
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
ImportInfo
Bases: BaseModel
A single import statement.
Example
imp = ImportInfo(module="pathlib", names=["Path"]) imp.is_relative False
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
ModuleInfo
Bases: BaseModel
Full introspection result for a single Python module.
Example
mod = ModuleInfo(path=Path("foo.py")) len(mod.functions) 0
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
public_classes
property
Classes that are part of the public API.
public_functions
property
Functions that are part of the public API.
PackageInfo
Bases: BaseModel
Full introspection result for a Python package.
Example
pkg = PackageInfo(name="mylib", root=Path("src/mylib")) len(pkg.modules) 0
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
module_names
property
List of dotted module names.
public_api
property
All public functions and classes across the package.
ParameterInfo
Bases: BaseModel
A single function/method parameter.
Example
p = ParameterInfo(name="path", annotation="Path", default="None") p.name 'path'
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
VariableInfo
Bases: BaseModel
A module-level variable or constant.
Example
v = VariableInfo(name="all", line=5) v.name 'all'
Source code in packages/axm-ast/src/axm_ast/models/nodes.py
analyze_package(path)
Analyze a Python package directory.
Discovers all .py files, parses them with tree-sitter, and
builds a complete PackageInfo with dependency edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the package root directory. |
required |
Returns:
| Type | Description |
|---|---|
PackageInfo
|
PackageInfo with all modules and dependency edges. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If path is not a directory. |
Example
pkg = analyze_package(Path("src/mylib")) pkg.name 'mylib'
Source code in packages/axm-ast/src/axm_ast/core/analyzer.py
search_symbols(pkg, *, name=None, returns=None, kind=None, inherits=None)
Search for symbols across a package with filters.
All filters are AND-combined. A symbol must match all provided filters to be included in results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg
|
PackageInfo
|
Analyzed package info. |
required |
name
|
str | None
|
Filter by symbol name (substring match). |
None
|
returns
|
str | None
|
Filter functions by return type (substring match). |
None
|
kind
|
SymbolKind | None
|
Filter by SymbolKind (function, method, property, classmethod, staticmethod, abstract, class, variable). |
None
|
inherits
|
str | None
|
Filter classes by base class name. |
None
|
Returns:
| Type | Description |
|---|---|
list[FunctionInfo | ClassInfo | VariableInfo]
|
List of matching symbols. |
Example
results = search_symbols(pkg, returns="str") [r.name for r in results]['greet', 'version']