Self-updating codebase knowledge graph for AI-powered IDEs
Project description
AI-Memory
Stop burning API tokens on file-by-file exploration. AI-Memory builds a self-updating knowledge graph of your entire codebase so your AI assistant answers instantly — with full context — instead of asking "can you show me that file?" repeatedly.
Before: You ask AI a question → AI opens 5 files → 8,000 tokens → still confused
After: AI-Memory knows your code → AI queries the graph → 500 tokens → precise answer
The Problem (You Know This Pain)
You ask your AI assistant: "How do I add pagination to the user list?"
| Step | What AI Does | Tokens |
|---|---|---|
| 1 | Opens routes.py, reads 200 lines |
1,500 |
| 2 | Opens models.py, reads 150 lines |
1,200 |
| 3 | Opens controllers.py, reads 300 lines |
2,400 |
| 4 | Asks "Can you show me the User model?" | — |
| 5 | You paste it | 500 |
| 6 | Re-reads everything again | 2,500 |
| Total | ~8,000 tokens |
With AI-Memory: AI runs one internal query and gets list_users(self, db, skip=0, limit=100) with full body, types, and callers. 500 tokens. One shot. Correct answer.
How It Works
| Engine | What It Does |
|---|---|
| Scan | Tree-sitter parses Python, JS/TS, Ruby, Go, Rust, Java, C#, C/C++, SQL |
| Graph | Functions, classes, imports, calls, inheritance in SQLite |
| Import Resolution | Cross-file imports resolved to real symbol definitions |
| Execution Flows | Pre-computed call chains from every entry point |
| Communities | Auto-detected code modules by directory + graph coupling |
| Semantic Search | sentence-transformers embeddings: find login_user from "auth" |
| Type & Body Storage | Full function bodies and type annotations cached |
| Watch | Incremental updates on every file save |
Supported Languages
| Backend | Frontend | Systems | Data & Config | Manifests |
|---|---|---|---|---|
| Python | JavaScript | C | SQL | requirements.txt |
| Go | TypeScript | C++ | YAML | package.json |
| Rust | JSX | C# | JSON | Cargo.toml |
| Java | TSX | TOML | pyproject.toml |
|
| Ruby | Protobuf | go.mod |
||
| GraphQL |
DB Schemas: Table, index, column extraction from SQL and migration files.
Supported IDEs
| IDE | Integration | Setup Required |
|---|---|---|
| Windsurf | .windsurfrules auto-generated |
None — AI reads instructions automatically |
| Cursor | .cursorrules auto-generated |
None — AI reads instructions automatically |
| Claude Desktop | MCP server ai-memory-mcp |
One JSON config |
| VS Code | MCP server or CLI | Terminal or extension |
After ai-memory init, your AI already knows about the graph. Zero IDE configuration.
Get Started (3 Commands)
# 1. Install
cd your-project
pip install ai-memory
# 2. Initialize — config, DB, gitignore, IDE rule files
ai-memory init
# 3. Scan your codebase — one time
ai-memory scan
Optional:
# Enable semantic search (~2 min one-time)
ai-memory embed
# Auto-update on file changes (background daemon)
ai-memory watch
What Happens After Init
your-project/
├── .ai-memory/ # Graph database (gitignored automatically)
│ └── graph.db # SQLite: ~380 symbols, ~1850 relations, 34 deps
├── .ai-memory.toml # Your project config
├── .windsurfrules # Windsurf: "Use ai-memory for context"
├── .cursorrules # Cursor: "Use ai-memory for context"
└── .gitignore # Auto-added: .ai-memory/
CLI Commands
Core Workflow
| Command | Description |
|---|---|
init |
Create config, DB, gitignore entry, IDE rule files |
scan |
Full codebase scan + post-processing |
watch |
Auto-incremental update on file changes |
embed |
Build semantic embeddings for all symbols |
embed --incremental |
Only new/changed symbols |
Symbol Context
| Command | Description |
|---|---|
context <symbol> |
Symbol + body + types + neighbors |
callers <symbol> |
Reverse call graph — who calls this |
inherits <class> |
Full inheritance chain |
Search & Discovery
| Command | Description |
|---|---|
ask "<question>" |
Natural language → compact context |
semantic "<query>" |
Embedding-based semantic search |
search "<query>" |
Full-text search over names, signatures, docstrings |
find <name> |
Search symbols by name |
Analysis
| Command | Description |
|---|---|
stats |
Project overview (files, nodes, edges, top hubs) |
flows |
Pre-computed execution flows from entry points |
communities |
Detected code modules/clusters |
cycles |
Circular dependencies |
dead-code |
Unused symbols (zero incoming references) |
api |
Public API surface from __init__.py, index.js, lib.rs |
todos |
TODO, FIXME, HACK, XXX markers |
test-map |
Map tests to implementation |
Dependencies & Coverage
| Command | Description |
|---|---|
deps |
List dependencies from manifests |
coverage |
Load coverage data and show summary |
coverage-detail |
Per-symbol coverage status |
Export
| Command | Description |
|---|---|
graph [symbol] |
Mermaid or DOT call graph |
file <path> |
Summary of a single file |
schemas |
All DB schemas / migrations |
review |
Git diff impact analysis |
MCP Server (Native IDE Integration)
For Claude Desktop, Windsurf, Cursor:
ai-memory-mcp --root /path/to/project
20 exposed tools: ai_memory_scan, ai_memory_stats, ai_memory_context, ai_memory_ask, ai_memory_semantic, ai_memory_flows, ai_memory_communities, ai_memory_schemas, ai_memory_find, ai_memory_dead_code, ai_memory_callers, ai_memory_todos, ai_memory_test_map, ai_memory_graph, ai_memory_cycles, ai_memory_inherits, ai_memory_api, ai_memory_search, ai_memory_coverage, ai_memory_deps.
Configuration
Edit .ai-memory.toml to customize:
scan_dirs = ["src", "app", "lib"]
extensions = [".py", ".js", ".ts", ".go", ".rs"]
ignore_patterns = ["node_modules", "venv", "__pycache__"]
output_format = "markdown"
max_context_tokens = 4000
Architecture
Source Code
│
▼
Tree-sitter Parsers (Python, JS/TS, Go, Rust, Java, C#, C/C++, Ruby)
│
▼
Symbol Extractor ──→ Symbols (functions, classes, imports)
│ Body Extractor ──→ Full function bodies
│ Type Extractor ──→ Type annotations
│
Relation Extractor ──→ Calls, Inherits, Imports
│
▼
Import Resolver ──→ Cross-file links resolved
│
▼
SQLite Graph DB ──→ nodes, edges, files, schemas, flows, communities
│
▼
┌─────────────────┬─────────────────┬─────────────────┐
│ Semantic │ Execution │ Community │
│ Embeddings │ Flows │ Detection │
│ (MiniLM) │ (BFS from │ (Leiden │
│ │ entry points) │ algorithm) │
└─────────────────┴─────────────────┴─────────────────┘
│
▼
CLI / MCP Server / Watch Daemon
│
▼
AI Assistant (Windsurf, Cursor, Claude Desktop)
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 codebase_memory-0.1.2.tar.gz.
File metadata
- Download URL: codebase_memory-0.1.2.tar.gz
- Upload date:
- Size: 54.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20353edfda27b3dc6f2cc5e0773e26fe656c26faf3f5ee38494745d27b53f098
|
|
| MD5 |
2db5f002023ade0f09afb1b3ca508061
|
|
| BLAKE2b-256 |
68363b18212746f0a270ea9a0ef5fdd5439e37662afc366d88761218a25a18bc
|
Provenance
The following attestation bundles were made for codebase_memory-0.1.2.tar.gz:
Publisher:
publish.yml on Arbaznazir/AI-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codebase_memory-0.1.2.tar.gz -
Subject digest:
20353edfda27b3dc6f2cc5e0773e26fe656c26faf3f5ee38494745d27b53f098 - Sigstore transparency entry: 1396727946
- Sigstore integration time:
-
Permalink:
Arbaznazir/AI-memory@bf42685896f4a8c1ad409844041bbd29cee61be4 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Arbaznazir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf42685896f4a8c1ad409844041bbd29cee61be4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file codebase_memory-0.1.2-py3-none-any.whl.
File metadata
- Download URL: codebase_memory-0.1.2-py3-none-any.whl
- Upload date:
- Size: 63.4 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 |
9662de6a68f18286e68cc9174e9b5dde7d93bd2b60bc65b11eeff9472a9d5858
|
|
| MD5 |
4e09e9c0d8c637f60e2b89d66feaa9eb
|
|
| BLAKE2b-256 |
1aa0690211b353d7e993784eb1bd127aae1cb7ae83f5a700cefc59f465f90df4
|
Provenance
The following attestation bundles were made for codebase_memory-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on Arbaznazir/AI-memory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codebase_memory-0.1.2-py3-none-any.whl -
Subject digest:
9662de6a68f18286e68cc9174e9b5dde7d93bd2b60bc65b11eeff9472a9d5858 - Sigstore transparency entry: 1396727960
- Sigstore integration time:
-
Permalink:
Arbaznazir/AI-memory@bf42685896f4a8c1ad409844041bbd29cee61be4 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Arbaznazir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bf42685896f4a8c1ad409844041bbd29cee61be4 -
Trigger Event:
release
-
Statement type: