AIC (aic) is a semantic dependency graph manager designed to help AI agents understand and navigate your codebase efficiently. It "compiles" your code into Rich Skeletons—lightweight, token-efficient representations that preserve signatures, docstrings, and side-effects while discarding implementation details.
When working with Large Language Models (LLMs) on brownfield applications, context is expensive. Feeding raw source code wastes tokens on implementation logic when the AI often just needs the "API Contract" and dependency graph.
AIC solves this by:
- Reducing Token Usage: Compresses files into skeletons (often 90% smaller than source).
- Preserving Intent: Keeps docstrings, type hints, and critical effects (e.g.,
RAISES,CALLS). - Mapping Dependencies: Automatically tracks internal imports to help agents trace logic across files.
- Fast & Local: Uses strict static analysis (AST) with zero AI latency for indexing.
- Python 3.8+
Clone the repository and install in editable mode:
git clone https://github.com/your-org/aic.git
cd aic
pip install -e .Note: If you encounter build issues with hatchling, this project uses setuptools fallback. Ensure you have setuptools>=61.0 installed.
Run the indexer from the root of your project. This will scan for Python files, generate skeletons, and build the dependency graph in .aic/graph.db.
aic indexOutput:
Indexed: src/main.py
Indexed: src/utils/db.py
Finished indexing. Processed 12 files.
When an agent needs to understand a file, fetch its "Rich Skeleton" plus the skeletons of its immediate dependencies.
aic context <filepath>Example:
aic context src/main.pyOutput (Markdown):
# Context for src/main.py
def process_data(data) -> bool:
"""Validates and saves data."""
# CALLS: validate, save | RAISES: ValueError | RETURNS: value
## Dependencies
### src/utils/db.py
def save(record):
"""Writes record to database."""
# CALLS: execute, commitAIC is built on three core pillars: Deterministic Indexing, Relational Storage, and Rich Skeletonization.
We use SQLite to store the dependency graph, ensuring the index is portable and zero-dependency.
nodestable: Stores the state of each file.path(PK): Relative file path.hash: SHA256 of the source code to detect changes.skeleton: The compressed "Rich Skeleton" (context for LLMs).status:CLEAN|DIRTY(Dirty = dependencies changed).
edgestable: Represents the dependency graph.source: File importing the dependency.target: The dependency file being imported.
The indexer uses Python's ast module to strip implementation details while preserving the "API Contract".
Key Extraction Logic:
- Signatures: Preserves function/class definitions and type hints (reconstructed for clarity).
- Docstrings: Keeps 100% of docstrings to capture intent.
- Effect Analysis: Analyzes function bodies to detect:
RAISES: Exceptions raised.CALLS: External functions called (top 5).RETURNS: Specific return values (e.g.,None,<variable>,True) or expressions.
- Compression: Logic bodies are replaced with summary comments (e.g.,
# CALLS: db.save | RAISES: ValueError), typically reducing context size by 90%+.
- MapReduce Indexing:
aic indexscans files, computes a diff based on SHA256 hashes, and only re-processes changed files. - Propagated Updates: When a file changes, its status is updated, and we can identify dependent nodes (reverse edges) that may need re-contextualization (future feature).
- Context Retrieval:
aic contextcreates a concatenated view of the target file's skeleton + its immediate dependencies' skeletons.
aic/skeleton.py: TheRichSkeletonizerAST visitor.aic/db.py: SQLite database operations.aic/cli.py: CLI entry point and orchestration.
To run the test suite, install the test dependencies and run pytest:
pip install -e ".[test]"
PYTHONPATH=. pytest tests/This project was inspired by ideas from @rodydavis. For more information, please refer to the following patent: System and method for semantic dependency graph management.
This project is licensed under the MIT License. See the LICENSE file for details.