engramkit 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- engramkit-0.1.1/LICENSE +21 -0
- engramkit-0.1.1/PKG-INFO +504 -0
- engramkit-0.1.1/README.md +462 -0
- engramkit-0.1.1/engramkit/__init__.py +8 -0
- engramkit-0.1.1/engramkit/__main__.py +4 -0
- engramkit-0.1.1/engramkit/api/__init__.py +0 -0
- engramkit-0.1.1/engramkit/api/helpers.py +85 -0
- engramkit-0.1.1/engramkit/api/routes_chat.py +183 -0
- engramkit-0.1.1/engramkit/api/routes_kg.py +116 -0
- engramkit-0.1.1/engramkit/api/routes_memory.py +112 -0
- engramkit-0.1.1/engramkit/api/routes_search.py +50 -0
- engramkit-0.1.1/engramkit/api/routes_vaults.py +110 -0
- engramkit-0.1.1/engramkit/api/server.py +106 -0
- engramkit-0.1.1/engramkit/cli.py +363 -0
- engramkit-0.1.1/engramkit/config.py +89 -0
- engramkit-0.1.1/engramkit/dashboard_static/404/index.html +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/404.html +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next.$oc$slug.__PAGE__.txt +6 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next.$oc$slug.txt +5 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next._full.txt +20 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next._head.txt +6 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next._index.txt +6 -0
- engramkit-0.1.1/engramkit/dashboard_static/__next._tree.txt +4 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/UXdTcQ7rNV_suRXmc42PU/_buildManifest.js +11 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/UXdTcQ7rNV_suRXmc42PU/_clientMiddlewareManifest.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/UXdTcQ7rNV_suRXmc42PU/_ssgManifest.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/01xlw8hd842-c.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/03f8vq.h4g94f.js +31 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/03~yq9q893hmn.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/0e9pzjo74aj_r.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/0h4a4y-~puu.x.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/0idm9aj5df4bj.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/0t2xr05rlu96l.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/0wtesm2ne~5-y.js +5 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/14fvgqz8fzs66.css +3 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/chunks/turbopack-0i4hupr16-8uz.js +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/4fa387ec64143e14-s.0q3udbd2bu5yp.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/7178b3e590c64307-s.11.cyxs5p-0z~.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/797e433ab948586e-s.p.0.q-h669a_dqa.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/8a480f0b521d4e75-s.06d3mdzz5bre_.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/bbc41e54d2fcbd21-s.0gw~uztddq1df.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/caa3a2e1cccd8315-s.p.16t1db8_9y2o~.woff2 +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_next/static/media/favicon.0x3dzn~oxb6tn.ico +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._full.txt +17 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._head.txt +6 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._index.txt +6 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._not-found.__PAGE__.txt +5 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._not-found.txt +5 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/__next._tree.txt +2 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/index.html +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/_not-found/index.txt +17 -0
- engramkit-0.1.1/engramkit/dashboard_static/favicon.ico +0 -0
- engramkit-0.1.1/engramkit/dashboard_static/file.svg +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/globe.svg +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/index.html +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/index.txt +20 -0
- engramkit-0.1.1/engramkit/dashboard_static/next.svg +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/vercel.svg +1 -0
- engramkit-0.1.1/engramkit/dashboard_static/window.svg +1 -0
- engramkit-0.1.1/engramkit/entities/__init__.py +0 -0
- engramkit-0.1.1/engramkit/graph/__init__.py +0 -0
- engramkit-0.1.1/engramkit/graph/knowledge_graph.py +182 -0
- engramkit-0.1.1/engramkit/hooks/__init__.py +0 -0
- engramkit-0.1.1/engramkit/hooks/claude_hook_handler.py +174 -0
- engramkit-0.1.1/engramkit/hooks/git_hooks.py +147 -0
- engramkit-0.1.1/engramkit/hooks/hook_manager.py +123 -0
- engramkit-0.1.1/engramkit/ingest/__init__.py +0 -0
- engramkit-0.1.1/engramkit/ingest/chunker.py +82 -0
- engramkit-0.1.1/engramkit/ingest/git_differ.py +89 -0
- engramkit-0.1.1/engramkit/ingest/pipeline.py +315 -0
- engramkit-0.1.1/engramkit/ingest/secret_scanner.py +40 -0
- engramkit-0.1.1/engramkit/mcp/__init__.py +0 -0
- engramkit-0.1.1/engramkit/mcp/server.py +484 -0
- engramkit-0.1.1/engramkit/memory/__init__.py +0 -0
- engramkit-0.1.1/engramkit/memory/layers.py +171 -0
- engramkit-0.1.1/engramkit/memory/token_budget.py +170 -0
- engramkit-0.1.1/engramkit/search/__init__.py +0 -0
- engramkit-0.1.1/engramkit/search/fts.py +78 -0
- engramkit-0.1.1/engramkit/search/hybrid.py +126 -0
- engramkit-0.1.1/engramkit/storage/__init__.py +0 -0
- engramkit-0.1.1/engramkit/storage/chromadb_backend.py +72 -0
- engramkit-0.1.1/engramkit/storage/gc.py +73 -0
- engramkit-0.1.1/engramkit/storage/schema.py +111 -0
- engramkit-0.1.1/engramkit/storage/vault.py +242 -0
- engramkit-0.1.1/engramkit.egg-info/PKG-INFO +504 -0
- engramkit-0.1.1/engramkit.egg-info/SOURCES.txt +109 -0
- engramkit-0.1.1/engramkit.egg-info/dependency_links.txt +1 -0
- engramkit-0.1.1/engramkit.egg-info/entry_points.txt +3 -0
- engramkit-0.1.1/engramkit.egg-info/requires.txt +19 -0
- engramkit-0.1.1/engramkit.egg-info/top_level.txt +1 -0
- engramkit-0.1.1/pyproject.toml +75 -0
- engramkit-0.1.1/setup.cfg +4 -0
- engramkit-0.1.1/tests/test_api.py +528 -0
- engramkit-0.1.1/tests/test_chromadb_backend.py +171 -0
- engramkit-0.1.1/tests/test_chunker.py +65 -0
- engramkit-0.1.1/tests/test_config.py +197 -0
- engramkit-0.1.1/tests/test_fts.py +167 -0
- engramkit-0.1.1/tests/test_gc.py +156 -0
- engramkit-0.1.1/tests/test_git_differ.py +185 -0
- engramkit-0.1.1/tests/test_hooks.py +52 -0
- engramkit-0.1.1/tests/test_hybrid_search.py +241 -0
- engramkit-0.1.1/tests/test_knowledge_graph.py +66 -0
- engramkit-0.1.1/tests/test_layers.py +283 -0
- engramkit-0.1.1/tests/test_mcp.py +32 -0
- engramkit-0.1.1/tests/test_mcp_server.py +393 -0
- engramkit-0.1.1/tests/test_pipeline.py +265 -0
- engramkit-0.1.1/tests/test_schema.py +171 -0
- engramkit-0.1.1/tests/test_search.py +63 -0
- engramkit-0.1.1/tests/test_secret_scanner.py +51 -0
- engramkit-0.1.1/tests/test_token_budget.py +83 -0
- engramkit-0.1.1/tests/test_vault.py +91 -0
engramkit-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EngramKit Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
engramkit-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: engramkit
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: AI memory system with hybrid search, git-aware ingestion, and garbage collection
|
|
5
|
+
Author: EngramKit Contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/user/engramkit
|
|
8
|
+
Project-URL: Repository, https://github.com/user/engramkit
|
|
9
|
+
Project-URL: Issues, https://github.com/user/engramkit/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/user/engramkit/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: ai,memory,search,rag,mcp,chromadb,embeddings,knowledge-graph,cli,developer-tools
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: chromadb<0.7,>=0.5.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: tiktoken>=0.5
|
|
28
|
+
Requires-Dist: fastapi>=0.100
|
|
29
|
+
Requires-Dist: uvicorn>=0.20
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff; extra == "dev"
|
|
34
|
+
Requires-Dist: httpx; extra == "dev"
|
|
35
|
+
Requires-Dist: build; extra == "dev"
|
|
36
|
+
Requires-Dist: twine; extra == "dev"
|
|
37
|
+
Provides-Extra: chat
|
|
38
|
+
Requires-Dist: claude-agent-sdk>=0.1; extra == "chat"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: engramkit[chat]; extra == "all"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<img src="assets/engramkit_logo.svg" alt="EngramKit" width="200" />
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<h1 align="center">EngramKit</h1>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<strong>AI memory system with hybrid search, git-aware ingestion, and garbage collection.</strong>
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
EngramKit gives AI assistants long-term memory over your codebase. Mine a repository once, then search it with sub-200ms hybrid queries that combine semantic understanding with exact keyword matching. Built as a next-generation replacement for [MemPalace](https://github.com/milla-jovovich/mempalace), keeping what works and fixing what doesn't.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Standing on MemPalace's Shoulders
|
|
58
|
+
|
|
59
|
+
MemPalace proved several important ideas:
|
|
60
|
+
|
|
61
|
+
- **Verbatim storage works.** Never summarize, always store raw text. Let semantic search find what's relevant.
|
|
62
|
+
- **4-layer memory stack** (L0 identity, L1 essential, L2 on-demand, L3 deep search) is a sound architecture for token-budgeted context.
|
|
63
|
+
- **MCP integration** makes the memory system usable from Claude, ChatGPT, and other assistants.
|
|
64
|
+
|
|
65
|
+
> **Note on benchmarks:** MemPalace's headline 96.6% R@5 on LongMemEval actually measures ChromaDB's embedding model (all-MiniLM-L6-v2), not the palace architecture. The test bypasses wings, rooms, and AAAK compression entirely. Any app using ChromaDB with the same model would get the same score. See the [community discussion](https://github.com/milla-jovovich/mempalace/issues/29) for details.
|
|
66
|
+
|
|
67
|
+
EngramKit preserves MemPalace's core ideas. What it changes is the engineering underneath.
|
|
68
|
+
|
|
69
|
+
## What EngramKit Fixes
|
|
70
|
+
|
|
71
|
+
| Problem in MemPalace | EngramKit's Solution |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Positional chunk IDs (`MD5(path+index)`) break when files are edited | Content-addressed IDs: `SHA256(content)[:24]` |
|
|
74
|
+
| No garbage collection -- orphaned chunks stay forever | Generation-based mark-and-sweep GC with configurable retention |
|
|
75
|
+
| Sequential 1-at-a-time ChromaDB upserts | Per-file streaming upserts (94s vs MemPalace 115s, same repo) |
|
|
76
|
+
| Semantic-only search | Hybrid search: semantic + BM25 via SQLite FTS5, fused with RRF |
|
|
77
|
+
| No git awareness -- full rescan every time | `git diff` incremental mining; re-mine in 0.1s when nothing changed |
|
|
78
|
+
| `.env` files indexed with secrets | Auto-filters secret files and scans chunks for credential patterns |
|
|
79
|
+
| Dumb hooks (count to 15, then save) | Content-aware importance scoring with signal detection |
|
|
80
|
+
| Importance-only L1 scoring | Recency decay + importance + access frequency |
|
|
81
|
+
| `len // 4` token counting | Exact counting via `tiktoken` (cl100k_base) |
|
|
82
|
+
| No deduplication | Deduplication by content hash + near-duplicate prefix detection |
|
|
83
|
+
| 10k drawer status cap (in-memory dict) | SQLite metadata spine -- no cap, survives restarts |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Features
|
|
88
|
+
|
|
89
|
+
- **Hybrid search** -- Semantic (ChromaDB) + lexical (SQLite FTS5 BM25), fused with Reciprocal Rank Fusion. 15x faster than semantic-only.
|
|
90
|
+
- **Git-aware mining** -- Uses `git diff` to detect changed files. Only re-processes what actually changed.
|
|
91
|
+
- **Content-addressed storage** -- Chunks are keyed by `SHA256(content)`. Edit a file and only the changed chunks get updated.
|
|
92
|
+
- **Generation-based GC** -- Stale chunks are marked, not deleted. GC sweeps them after a configurable retention period.
|
|
93
|
+
- **Secret filtering** -- `.env`, `.pem`, credential files are auto-excluded. Individual chunks are scanned for API keys, tokens, and passwords.
|
|
94
|
+
- **4-layer memory stack** -- L0 identity, L1 essential context (recency + importance scored), L2 on-demand recall, L3 hybrid search.
|
|
95
|
+
- **Token budgets** -- Each layer has a configurable token budget. Chunks are scored, deduplicated, and packed greedily.
|
|
96
|
+
- **Knowledge graph** -- Temporal entity-relationship graph with `valid_from`/`valid_to` for tracking how things change over time.
|
|
97
|
+
- **MCP server** -- 12 tools for Claude, ChatGPT, and other MCP-compatible assistants.
|
|
98
|
+
- **REST API** -- FastAPI backend powering the dashboard (search, chat, vaults, KG, memory).
|
|
99
|
+
- **Next.js dashboard** -- Web UI with RAG chat, search, vault management, knowledge graph explorer, and GC controls.
|
|
100
|
+
- **Git hooks** -- Auto-mine on commit and pull with `engramkit hooks install`.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Architecture
|
|
105
|
+
|
|
106
|
+
<p align="center">
|
|
107
|
+
<img src="assets/engramkit_architecture_v2.svg" alt="EngramKit Architecture" width="100%" />
|
|
108
|
+
</p>
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
~/.engramkit/
|
|
112
|
+
├── config.toml (optional global config)
|
|
113
|
+
├── identity.txt (L0 identity context)
|
|
114
|
+
└── vaults/<repo-hash>/
|
|
115
|
+
├── meta.sqlite3 (chunks + FTS5 + files + GC log)
|
|
116
|
+
├── vectors/ (ChromaDB embeddings)
|
|
117
|
+
└── knowledge_graph.sqlite3
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Each repository gets its own vault, identified by a deterministic hash of the repo path. The SQLite database is the metadata spine: it stores chunk content, file tracking, generation counters, access stats, and a full-text search index. ChromaDB handles the vector embeddings. The knowledge graph lives in a separate SQLite database per vault.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Quick Start
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Install (core: CLI, MCP, REST API, dashboard, hybrid search)
|
|
128
|
+
pipx install engramkit
|
|
129
|
+
|
|
130
|
+
# Optional — enables the RAG chat feature inside the dashboard
|
|
131
|
+
pipx install 'engramkit[chat]' --force # requires Python 3.10+
|
|
132
|
+
|
|
133
|
+
# Mine a project
|
|
134
|
+
engramkit mine ~/my-project
|
|
135
|
+
|
|
136
|
+
# Search it
|
|
137
|
+
engramkit search "how does auth work"
|
|
138
|
+
|
|
139
|
+
# Open the web dashboard
|
|
140
|
+
engramkit dashboard
|
|
141
|
+
|
|
142
|
+
# Check status
|
|
143
|
+
engramkit status
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
> **What's in each install?**
|
|
147
|
+
> - `engramkit` — everything except RAG chat: CLI, MCP server, REST API, web dashboard, hybrid search, knowledge graph, GC.
|
|
148
|
+
> - `engramkit[chat]` — adds the [Claude Agent SDK](https://pypi.org/project/claude-agent-sdk/) so the dashboard's chat panel can answer questions over your vault. Needs Python ≥ 3.10.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## CLI Reference
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
engramkit init <directory> [--wing NAME]
|
|
156
|
+
```
|
|
157
|
+
Initialize a vault for a repository. Sets up SQLite schema, ChromaDB collection, and stores the wing name.
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
engramkit mine <directory> [--wing NAME] [--room NAME] [--full] [--dry-run]
|
|
161
|
+
```
|
|
162
|
+
Mine a project into its vault. Uses git diff for incremental mining when available. `--full` forces a complete rescan. `--dry-run` previews without storing.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
engramkit search <query> [-d DIRECTORY] [--wing NAME] [--room NAME] [-n COUNT]
|
|
166
|
+
```
|
|
167
|
+
Hybrid search across a vault. Returns ranked results with file paths, scores, and source indicators (semantic, lexical, or both).
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
engramkit status [-d DIRECTORY] [--all]
|
|
171
|
+
```
|
|
172
|
+
Show vault statistics: chunk counts, wings, rooms, generation number, stale/secret counts. `--all` lists every vault.
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
engramkit wake-up [-d DIRECTORY] [--wing NAME] [--l0-tokens N] [--l1-tokens N]
|
|
176
|
+
```
|
|
177
|
+
Load L0 + L1 wake-up context for a session. Token-budgeted and deduplicated.
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
engramkit gc [-d DIRECTORY] [--dry-run] [--retention DAYS]
|
|
181
|
+
```
|
|
182
|
+
Garbage collection. Removes stale chunks older than the retention period (default: 30 days). Logs all removals.
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
engramkit hooks install [-d DIRECTORY]
|
|
186
|
+
```
|
|
187
|
+
Install git hooks (post-commit, post-merge) for automatic mining on commit and pull.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Dashboard
|
|
192
|
+
|
|
193
|
+
The Next.js dashboard provides a web UI for interacting with EngramKit:
|
|
194
|
+
|
|
195
|
+
<p align="center">
|
|
196
|
+
<img src="assets/dashboard.png" alt="EngramKit Dashboard" width="100%" />
|
|
197
|
+
<br />
|
|
198
|
+
<em>Dashboard — vault overview with stats, chunk counts, and wing/room breakdown</em>
|
|
199
|
+
</p>
|
|
200
|
+
|
|
201
|
+
<p align="center">
|
|
202
|
+
<img src="assets/chat.png" alt="EngramKit Chat" width="100%" />
|
|
203
|
+
<br />
|
|
204
|
+
<em>RAG Chat — search your codebase and ask questions with cited sources, token usage, and tool tracking</em>
|
|
205
|
+
</p>
|
|
206
|
+
|
|
207
|
+
### Features
|
|
208
|
+
|
|
209
|
+
- **Chat** — RAG-powered chat with Claude. Searches your vaults for context, streams responses with source references. Toggle between RAG (pre-searched context) and Direct (Claude explores on its own) to compare cost and speed.
|
|
210
|
+
- **Search** — Hybrid search with filters by wing, room, and result count. Shows which path found each result (semantic, lexical, or both).
|
|
211
|
+
- **Vaults** — Browse all vaults, view chunks, files, and statistics. Mine repos, run GC, install git hooks.
|
|
212
|
+
- **Knowledge Graph** — Explore entities, relationships, and timelines. Add and expire facts.
|
|
213
|
+
- **Settings** — Global configuration, token budgets, search weights.
|
|
214
|
+
|
|
215
|
+
### Quick Start
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Install dashboard dependencies
|
|
219
|
+
cd dashboard && npm install
|
|
220
|
+
|
|
221
|
+
# Start both servers
|
|
222
|
+
python -m engramkit.api.server # API on :8000
|
|
223
|
+
npm run dev # Dashboard on :3000
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Open [http://localhost:3000](http://localhost:3000)
|
|
227
|
+
|
|
228
|
+
The dashboard runs at `http://localhost:3000` and talks to the API at `http://localhost:8000`.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Benchmark Results
|
|
233
|
+
|
|
234
|
+
### Retrieval Accuracy (ConvoMem, 250 QA pairs)
|
|
235
|
+
|
|
236
|
+
Tested on the same [ConvoMem](https://huggingface.co/datasets/Salesforce/ConvoMem) dataset used by MemPalace. Three search modes compared:
|
|
237
|
+
|
|
238
|
+
| Mode | Avg R@10 | Perfect | Zero |
|
|
239
|
+
|---|---|---|---|
|
|
240
|
+
| **EngramKit Hybrid** (semantic + BM25) | **94.5%** | 235/250 | 13/250 |
|
|
241
|
+
| Raw ChromaDB (semantic only) | 92.9% | 230/250 | 16/250 |
|
|
242
|
+
| BM25 only (keyword) | 84.3% | 210/250 | 38/250 |
|
|
243
|
+
|
|
244
|
+
Per-category breakdown:
|
|
245
|
+
|
|
246
|
+
| Category | Hybrid | Raw | BM25 |
|
|
247
|
+
|---|---|---|---|
|
|
248
|
+
| Assistant Facts | **100%** | 100% | 100% |
|
|
249
|
+
| User Facts | **98.0%** | 98.0% | 98.0% |
|
|
250
|
+
| Preferences | **92.0%** | 86.0% | 68.0% |
|
|
251
|
+
| Implicit Connections | **91.3%** | 89.3% | 65.7% |
|
|
252
|
+
| Abstention | **91.0%** | 91.0% | 90.0% |
|
|
253
|
+
|
|
254
|
+
Hybrid search adds +1.6% over raw semantic on conversation data. On code search (function names, variable names), the gap is much larger.
|
|
255
|
+
|
|
256
|
+
> **Note:** MemPalace reports 96.6% R@5 on LongMemEval, but that score measures ChromaDB's all-MiniLM-L6-v2 model — the palace architecture is not involved. Our benchmark tests the actual search pipeline end-to-end.
|
|
257
|
+
|
|
258
|
+
### Mining & Search Performance
|
|
259
|
+
|
|
260
|
+
Head-to-head on the same repository (102 files):
|
|
261
|
+
|
|
262
|
+
| Metric | EngramKit | MemPalace | Delta |
|
|
263
|
+
|---|---|---|---|
|
|
264
|
+
| First mine | 94s | 115s | 1.2x faster |
|
|
265
|
+
| Re-mine (no changes) | 0.1s | 115s | 1,150x faster |
|
|
266
|
+
| Avg search latency | 153ms | 2,378ms | **15.6x faster** |
|
|
267
|
+
| Search modes | Semantic + BM25 | Semantic only | -- |
|
|
268
|
+
| Content-addressed IDs | Yes (SHA256) | No (MD5+pos) | -- |
|
|
269
|
+
| Garbage collection | Yes | No | -- |
|
|
270
|
+
| Git-aware mining | Yes | No | -- |
|
|
271
|
+
| Secret filtering | Yes | No | -- |
|
|
272
|
+
| Token counting | tiktoken (exact) | len//4 (approx) | -- |
|
|
273
|
+
|
|
274
|
+
### Run Benchmarks Yourself
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Retrieval accuracy (ConvoMem dataset)
|
|
278
|
+
python benchmarks/convomem_bench.py --limit 50 --mode all
|
|
279
|
+
|
|
280
|
+
# Mining & search performance
|
|
281
|
+
python benchmarks/compare_mempalace.py /path/to/repo
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Claude Code Integration
|
|
287
|
+
|
|
288
|
+
### Quick Setup
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
cd ~/your-project
|
|
292
|
+
|
|
293
|
+
# 1. Mine your codebase
|
|
294
|
+
engramkit mine .
|
|
295
|
+
|
|
296
|
+
# 2. Install auto-save hooks
|
|
297
|
+
engramkit hooks install -d .
|
|
298
|
+
|
|
299
|
+
# 3. Register MCP server for your AI tool
|
|
300
|
+
claude mcp add engramkit -- engramkit-mcp # Claude Code
|
|
301
|
+
# codex mcp add engramkit -- python3 -m engramkit.mcp.server # Codex (coming soon)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
What each step does:
|
|
305
|
+
- **Step 1** — indexes your code into a searchable vault
|
|
306
|
+
- **Step 2** — installs git hooks (auto re-mine on commit/pull) + Claude Code hooks (auto-save conversations)
|
|
307
|
+
- **Step 3** — gives your AI tool access to 12 EngramKit memory tools
|
|
308
|
+
|
|
309
|
+
Now start Claude Code:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
claude
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Claude will:
|
|
316
|
+
1. Call `engramkit_wake_up` on session start → loads identity + recent context (L0 + L1)
|
|
317
|
+
2. Call `engramkit_search` before answering code questions → finds relevant chunks
|
|
318
|
+
3. Auto-save important decisions/insights via the Stop hook
|
|
319
|
+
4. Emergency-save everything before context compression
|
|
320
|
+
|
|
321
|
+
### Available Tools (12)
|
|
322
|
+
|
|
323
|
+
**Read tools:**
|
|
324
|
+
| Tool | Description |
|
|
325
|
+
|---|---|
|
|
326
|
+
| `engramkit_status` | Vault overview: chunks, wings, rooms, generation |
|
|
327
|
+
| `engramkit_search` | Hybrid search (semantic + BM25) across the vault |
|
|
328
|
+
| `engramkit_wake_up` | Load L0 + L1 wake-up context for session start |
|
|
329
|
+
| `engramkit_recall` | L2 on-demand recall filtered by wing/room |
|
|
330
|
+
| `engramkit_kg_query` | Query knowledge graph for entity relationships |
|
|
331
|
+
| `engramkit_kg_timeline` | Chronological timeline of knowledge graph facts |
|
|
332
|
+
|
|
333
|
+
**Write tools:**
|
|
334
|
+
| Tool | Description |
|
|
335
|
+
|---|---|
|
|
336
|
+
| `engramkit_save` | Save content to vault with auto content-hash dedup |
|
|
337
|
+
| `engramkit_kg_add` | Add a fact: subject -> predicate -> object |
|
|
338
|
+
| `engramkit_kg_invalidate` | Mark a knowledge graph fact as no longer valid |
|
|
339
|
+
| `engramkit_diary_write` | Write a diary entry (agent's personal journal) |
|
|
340
|
+
|
|
341
|
+
**Admin tools:**
|
|
342
|
+
| Tool | Description |
|
|
343
|
+
|---|---|
|
|
344
|
+
| `engramkit_gc` | Run garbage collection on stale chunks |
|
|
345
|
+
| `engramkit_config` | Get or set vault configuration |
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## How It Works
|
|
350
|
+
|
|
351
|
+
### Smart Chunking
|
|
352
|
+
|
|
353
|
+
Files are split into ~800 character chunks with boundary-aware splitting. The chunker prefers to break at blank lines (paragraph/function boundaries), then `def`/`class` definitions, then any newline. Chunks overlap by 100 characters to preserve context across boundaries.
|
|
354
|
+
|
|
355
|
+
### Content-Addressed Storage
|
|
356
|
+
|
|
357
|
+
Every chunk is identified by `SHA256(content)[:24]`. This means:
|
|
358
|
+
- Identical content always maps to the same ID (deduplication for free).
|
|
359
|
+
- Editing a file only invalidates chunks whose content actually changed.
|
|
360
|
+
- Moving or renaming a file doesn't orphan its chunks.
|
|
361
|
+
|
|
362
|
+
### Hybrid Search
|
|
363
|
+
|
|
364
|
+
Queries hit two indexes in parallel:
|
|
365
|
+
1. **Semantic search** via ChromaDB (embedding similarity)
|
|
366
|
+
2. **Lexical search** via SQLite FTS5 (BM25 ranking)
|
|
367
|
+
|
|
368
|
+
Results are merged using Reciprocal Rank Fusion (RRF) with configurable weights (default: 0.7 semantic, 0.3 lexical), then deduplicated by content hash and enriched with metadata from SQLite.
|
|
369
|
+
|
|
370
|
+
### Generation-Based GC
|
|
371
|
+
|
|
372
|
+
Each mining run increments a generation counter. When a file changes, its old chunks are marked stale (not deleted). GC runs separately, removing stale chunks older than the retention period and logging every removal to the `gc_log` table.
|
|
373
|
+
|
|
374
|
+
### Git-Aware Change Detection
|
|
375
|
+
|
|
376
|
+
On `engramkit mine`, if the repository is a git repo and a previous commit hash is stored:
|
|
377
|
+
1. Run `git diff --name-status <last_commit> HEAD`
|
|
378
|
+
2. Only process files with status A (added), M (modified), or R (renamed)
|
|
379
|
+
3. Mark files with status D (deleted) as deleted in the vault
|
|
380
|
+
4. Store the new HEAD commit for next time
|
|
381
|
+
|
|
382
|
+
If nothing changed, re-mining completes in ~0.1 seconds.
|
|
383
|
+
|
|
384
|
+
### Token Budget with Recency Scoring
|
|
385
|
+
|
|
386
|
+
L1 context loading scores each chunk by:
|
|
387
|
+
- **Importance** (1-5 scale, default 3)
|
|
388
|
+
- **Recency decay** (exponential, half-life ~7 days)
|
|
389
|
+
- **Access frequency** (logarithmic boost)
|
|
390
|
+
|
|
391
|
+
Chunks are sorted by score, near-duplicates are removed (Jaccard similarity on character trigrams), and the top chunks are greedily packed into the token budget.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## Project Structure
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
engramkit/
|
|
399
|
+
├── engramkit/ # Python package (~3,400 lines)
|
|
400
|
+
│ ├── cli.py # CLI: init, mine, search, status, gc, hooks
|
|
401
|
+
│ ├── config.py # Configuration and defaults
|
|
402
|
+
│ ├── api/ # FastAPI REST API
|
|
403
|
+
│ │ ├── server.py # App setup with CORS
|
|
404
|
+
│ │ ├── routes_search.py # /search endpoint
|
|
405
|
+
│ │ ├── routes_vaults.py # /vaults CRUD
|
|
406
|
+
│ │ ├── routes_memory.py # /memory wake-up and recall
|
|
407
|
+
│ │ ├── routes_kg.py # /kg knowledge graph
|
|
408
|
+
│ │ ├── routes_chat.py # /chat RAG endpoint
|
|
409
|
+
│ │ └── helpers.py # Shared utilities
|
|
410
|
+
│ ├── ingest/ # Mining pipeline
|
|
411
|
+
│ │ ├── pipeline.py # Orchestrator: scan, chunk, diff, store
|
|
412
|
+
│ │ ├── chunker.py # Smart 800-char chunker
|
|
413
|
+
│ │ ├── git_differ.py # Git-aware change detection
|
|
414
|
+
│ │ └── secret_scanner.py # Credential detection
|
|
415
|
+
│ ├── search/ # Search engines
|
|
416
|
+
│ │ ├── hybrid.py # Semantic + BM25 with RRF fusion
|
|
417
|
+
│ │ └── fts.py # SQLite FTS5 wrapper
|
|
418
|
+
│ ├── storage/ # Data layer
|
|
419
|
+
│ │ ├── vault.py # Vault + VaultManager
|
|
420
|
+
│ │ ├── schema.py # SQLite schema with FTS5 triggers
|
|
421
|
+
│ │ ├── chromadb_backend.py# ChromaDB wrapper
|
|
422
|
+
│ │ └── gc.py # Garbage collection
|
|
423
|
+
│ ├── memory/ # Memory stack
|
|
424
|
+
│ │ ├── layers.py # L0-L3 memory layers
|
|
425
|
+
│ │ └── token_budget.py # tiktoken counting, scoring, dedup
|
|
426
|
+
│ ├── graph/ # Knowledge graph
|
|
427
|
+
│ │ └── knowledge_graph.py # Temporal KG with SQLite
|
|
428
|
+
│ ├── hooks/ # Git integration
|
|
429
|
+
│ │ ├── hook_manager.py # Content-aware importance scoring
|
|
430
|
+
│ │ └── git_hooks.py # Post-commit/merge hook installer
|
|
431
|
+
│ └── mcp/ # MCP server
|
|
432
|
+
│ └── server.py # 12-tool JSON-RPC MCP server
|
|
433
|
+
├── tests/ # Test suite (69 tests, ~500 lines)
|
|
434
|
+
│ ├── test_vault.py
|
|
435
|
+
│ ├── test_chunker.py
|
|
436
|
+
│ ├── test_search.py
|
|
437
|
+
│ ├── test_token_budget.py
|
|
438
|
+
│ ├── test_knowledge_graph.py
|
|
439
|
+
│ ├── test_hooks.py
|
|
440
|
+
│ ├── test_mcp.py
|
|
441
|
+
│ └── test_secret_scanner.py
|
|
442
|
+
├── benchmarks/
|
|
443
|
+
│ └── compare_mempalace.py # Head-to-head benchmark script
|
|
444
|
+
├── dashboard/ # Next.js web UI
|
|
445
|
+
│ └── src/
|
|
446
|
+
│ ├── app/ # Pages: chat, search, vaults, KG, settings
|
|
447
|
+
│ ├── components/ # Sidebar, badges, stat cards
|
|
448
|
+
│ └── lib/ # API client and types
|
|
449
|
+
└── pyproject.toml
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Configuration
|
|
455
|
+
|
|
456
|
+
EngramKit works out of the box with sensible defaults. To customize, create `~/.engramkit/config.toml`:
|
|
457
|
+
|
|
458
|
+
```toml
|
|
459
|
+
chunk_size = 800
|
|
460
|
+
chunk_overlap = 100
|
|
461
|
+
min_chunk_size = 50
|
|
462
|
+
search_n_results = 5
|
|
463
|
+
semantic_weight = 0.7
|
|
464
|
+
lexical_weight = 0.3
|
|
465
|
+
gc_retention_days = 30
|
|
466
|
+
|
|
467
|
+
[token_budget]
|
|
468
|
+
l0_max_tokens = 150
|
|
469
|
+
l1_max_tokens = 1000
|
|
470
|
+
l2_max_tokens = 2000
|
|
471
|
+
l3_max_tokens = 4000
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Development
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
# Clone and install in dev mode
|
|
480
|
+
git clone https://github.com/user/engramkit.git
|
|
481
|
+
cd engramkit
|
|
482
|
+
pip install -e ".[dev]"
|
|
483
|
+
|
|
484
|
+
# Run tests
|
|
485
|
+
pytest
|
|
486
|
+
|
|
487
|
+
# Lint
|
|
488
|
+
ruff check engramkit/
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## Credits
|
|
494
|
+
|
|
495
|
+
- **[MemPalace](https://github.com/milla-jovovich/mempalace)** for the original architecture, proving that verbatim storage with a 4-layer memory stack works, and inspiring this project.
|
|
496
|
+
- **[ChromaDB](https://github.com/chroma-core/chroma)** for embedding storage and semantic search.
|
|
497
|
+
- **[SQLite](https://sqlite.org/)** for the metadata spine, FTS5, and knowledge graph.
|
|
498
|
+
- **[tiktoken](https://github.com/openai/tiktoken)** for accurate token counting.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## License
|
|
503
|
+
|
|
504
|
+
MIT License. See [LICENSE](LICENSE).
|