Silice Codebase Mapper is a local, AI-powered documentation and dependency mapping suite. It transforms a messy codebase into a Structured Knowledge Graph specifically optimized for ingestion by Large Language Models (LLMs) via Ollama.
By breaking down code into atomic JSON "neurons" and a central "synapse" (index.json), it allows AI agents to understand your project's architecture, intent, and impact without exceeding context windows.
- Atomic Ingestion: Generates a unique JSON map for every source file.
- AI Enrichment: Uses Ollama + Instructor to extract logic summaries and conceptual relations.
- Static & Dynamic Analysis: Combines Python's
astfor reliable structure with LLMs for "intent" analysis. - Impact Analysis: Query-tool to see how changing one function ripples through the graph.
- AI Bridge: A RAG (Retrieval-Augmented Generation) chat interface to talk to your code locally.
- Requirement: Ensure you have Ollama installed and running.
- Model: Pull a compatible model (Llama 3 is recommended):
ollama pull llama3
- Dependencies:
pip install ollama instructor pydantic
The "Worker." It crawls your directories, performs static analysis, and asks the AI to document the logic of every file.
- Output:
silice_output/*.jsonandindex.json. - Usage:
python silice_file_mapper.py ./src ./lib
The "Analyst." Use this to traverse the graph and check dependencies.
- Usage:
# See what depends on a specific class or function
python silice_query.py --impact AuthService
# Get a quick AI-generated summary of a file
python silice_query.py --info models/user.py
The "Interface." An interactive chat that uses the generated JSON maps as a local brain to answer complex architectural questions.
- Usage:
python silice_bridge.py
The system uses Pydantic to enforce strict adherence to the Silice Protocol. Every file is mapped into a FileNode:
| Field | Description |
|---|---|
file_path |
Absolute location for reference. |
functions |
List of names, signatures, and AI-summarized logic. |
dependencies |
Graph-edges (imports, calls, inheritance). |
summary |
A high-level overview of the file's "Reason for Being." |
- Scan: Run the Mapper to build your JSON library.
- Index: The
index.jsoncreates a master map of all file relations. - Consult: Use the Bridge or Query tool to navigate the project without ever reading the raw source code.
- Context Control: This suite is designed to avoid "Context Bloat." The Bridge only feeds the AI the specific JSON maps relevant to your current question.
- Performance: For faster mapping, you can edit the script to use
model="phi3"ormodel="mistral"in the Ollama client.