Static code analysis CLI tool optimized for AI agent context windows - Python, JavaScript, TypeScript, and Go analysis with intelligent clustering and AI-friendly output
Project description
IntentGraph
Static code analysis for Python, JavaScript, TypeScript, and Go — with a machine-queryable cache layer designed for AI agents.
pip install intentgraph
What it does
IntentGraph analyses a repository's AST, dependency graph, and code metrics and writes the result to a local cache. You can then query that cache without re-running analysis:
# One-time analysis pass
intentgraph cache warm --repo .
# Query without re-analysing
intentgraph query context src/app/models.py
intentgraph query deps src/app/cli.py
intentgraph query path src/app/cli.py src/app/models.py
Everything outputs JSON to stdout, exits 0 on success, exits 1 with {"error": "..."} to stderr on failure. No side effects, no network calls.
CLI reference
intentgraph — analysis
intentgraph [OPTIONS] REPO_PATH
Options:
--level [minimal|medium|full] Detail level (default: minimal)
--lang TEXT Languages: py,js,ts,go
--output FILE Write to file instead of stdout
--include-tests Include test files
--show-cycles Print dependency cycles, exit 2
--cluster Cluster large repos into chunks
--cluster-mode [analysis|refactoring|navigation]
--workers INTEGER Parallel workers (default: cpu count)
Output levels:
| Level | Size | Contents |
|---|---|---|
minimal |
~10 KB | paths, deps, imports, basic metrics |
medium |
~70 KB | + key symbols, exports, maintainability scores |
full |
~340 KB | everything, including all signatures and docstrings |
For repos that exceed token limits even at minimal, --cluster splits output into ~15 KB chunks with an index.json navigation map.
intentgraph cache — cache management
intentgraph cache warm --repo PATH # analyse and cache (idempotent)
intentgraph cache status --repo PATH # {exists, stale, file_count, cache_path}
intentgraph cache clear --repo PATH # delete cache
Cache is stored at <repo>/.intentgraph/cache.json. Staleness is detected by comparing SHA-256 digests of tracked files.
intentgraph query — structured queries
All commands accept --repo PATH (default: .).
# Symbols defined in a file
intentgraph query symbols src/app/models.py
# Full context: language, loc, sha256, symbols, exports, deps, dependents
intentgraph query context src/app/models.py
# Direct dependencies
intentgraph query deps src/app/cli.py
# Reverse dependencies (who imports this file)
intentgraph query dependents src/app/models.py
# Shortest dependency path between two files (BFS)
intentgraph query path src/app/cli.py src/app/models.py
# Call sites for a named symbol
intentgraph query callers RepositoryAnalyzer
# Filter files by name pattern, language, symbol, complexity
intentgraph query search --name-matches ".*parser.*"
intentgraph query search --has-symbol CacheManager
intentgraph query search --lang python --complexity-gt 10
AI agent pattern
Warm once, query many times — no re-analysis overhead:
# In your agent's setup step
intentgraph cache warm --repo /path/to/repo
# Per-query (fast — reads from cache)
intentgraph query context src/app/models.py | jq .
intentgraph query deps src/app/cli.py | jq .deps[].file
intentgraph query search --complexity-gt 15 | jq .results[].file
Because every output is stable JSON, an AI agent can pipe results directly into its context window at the level of detail it needs, without loading the entire codebase.
Programmatic API
from pathlib import Path
from intentgraph import RepositoryAnalyzer
from intentgraph.cache import CacheManager
from intentgraph.query_engine import QueryEngine
# Analysis
analyzer = RepositoryAnalyzer()
result = analyzer.analyze(Path("/path/to/repo"))
# Or use the cache layer
cm = CacheManager(Path("/path/to/repo"))
result = cm.load_or_analyze() # uses cache if fresh, re-analyses if stale
# Query
engine = QueryEngine(result)
print(engine.context("src/app/models.py"))
print(engine.deps("src/app/cli.py"))
print(engine.search(name_pattern=r".*parser.*", lang="python"))
RepoSnapshot v1 — deterministic snapshots
from intentgraph.snapshot import RepoSnapshotBuilder
builder = RepoSnapshotBuilder(Path.cwd())
snapshot = builder.build()
# SHA256-based stable UUIDs — same path always produces same UUID
print(snapshot.structure.files[0].uuid)
# Runtime detection (static, no code execution)
print(snapshot.runtime.package_manager) # pip, pnpm, poetry, ...
print(snapshot.runtime.python_version)
print(snapshot.runtime.tooling) # pytest, ruff, mypy, ...
json_output = builder.build_json(indent=2)
Snapshot UUIDs are SHA256-derived — deterministic across machines and operating systems. Suitable for version-controlling snapshots or diffing them in CI.
Language support
| Language | Analysis depth |
|---|---|
| Python | Full AST — symbols, complexity, maintainability, exports, function-level deps |
| JavaScript | Full AST — ES6+, classes, CommonJS/ESM, complexity |
| TypeScript | Full AST — interfaces, generics, decorators, type imports |
| Go | File-level dependencies |
The ai/ module provides a natural-language query interface and agent context management. Query parsing and intent detection work; deep semantic execution is still evolving — use the structured query CLI for reliable agent integration.
Development
git clone https://github.com/Raytracer76/IntentGraph.git
cd IntentGraph
pip install -e ".[dev]"
pytest # run all tests
ruff format . && ruff check --fix . # format + lint
mypy . # type check
Coverage threshold: 90%. Strict mypy is enforced.
License
MIT — see LICENSE.
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 intentgraph-0.5.4.tar.gz.
File metadata
- Download URL: intentgraph-0.5.4.tar.gz
- Upload date:
- Size: 101.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a7420caea797cd5946b5d362fb7d6ee920422db2a35c064a7fb5cb3158150ad
|
|
| MD5 |
026549e8fcd85231390f7b242728b248
|
|
| BLAKE2b-256 |
77a0f85a92673e9de8bc156758283da62d1fb444f28fd95a40a0f05fab980900
|
Provenance
The following attestation bundles were made for intentgraph-0.5.4.tar.gz:
Publisher:
publish.yml on Raytracer76/IntentGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
intentgraph-0.5.4.tar.gz -
Subject digest:
1a7420caea797cd5946b5d362fb7d6ee920422db2a35c064a7fb5cb3158150ad - Sigstore transparency entry: 1154946101
- Sigstore integration time:
-
Permalink:
Raytracer76/IntentGraph@082e0ec677954655e22f5470e23f93fdb789d7f0 -
Branch / Tag:
refs/tags/v0.5.4 - Owner: https://github.com/Raytracer76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@082e0ec677954655e22f5470e23f93fdb789d7f0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file intentgraph-0.5.4-py3-none-any.whl.
File metadata
- Download URL: intentgraph-0.5.4-py3-none-any.whl
- Upload date:
- Size: 86.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
250cef4bc13aafd20163da5d11d691920450172887332d8dda078c64e3b9d72b
|
|
| MD5 |
c661417dc6fa525abd9c03d6d7c83e10
|
|
| BLAKE2b-256 |
600b4cc9e38dbf4b356057ef803b80a2919294698d08068889d94141e6e28d45
|
Provenance
The following attestation bundles were made for intentgraph-0.5.4-py3-none-any.whl:
Publisher:
publish.yml on Raytracer76/IntentGraph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
intentgraph-0.5.4-py3-none-any.whl -
Subject digest:
250cef4bc13aafd20163da5d11d691920450172887332d8dda078c64e3b9d72b - Sigstore transparency entry: 1154946105
- Sigstore integration time:
-
Permalink:
Raytracer76/IntentGraph@082e0ec677954655e22f5470e23f93fdb789d7f0 -
Branch / Tag:
refs/tags/v0.5.4 - Owner: https://github.com/Raytracer76
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@082e0ec677954655e22f5470e23f93fdb789d7f0 -
Trigger Event:
release
-
Statement type: