engramx 0.5.3 → 1.0.1
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.
- package/CHANGELOG.md +71 -0
- package/README.md +264 -291
- package/dist/aider-context-TNGSXMVY.js +54 -0
- package/dist/{chunk-IIFAAYDO.js → chunk-6SFMVYUN.js} +5 -0
- package/dist/chunk-CEAANHHX.js +88 -0
- package/dist/{chunk-KEV4LNM6.js → chunk-QOG4K427.js} +1 -1
- package/dist/chunk-SBHGK5WA.js +104 -0
- package/dist/cli.js +743 -131
- package/dist/{core-UXIP2GDR.js → core-77MHT3QV.js} +2 -1
- package/dist/cursor-mdc-HWVUZUZH.js +75 -0
- package/dist/exporter-A3VSLS4U.js +47 -0
- package/dist/importer-LU2YFZDY.js +67 -0
- package/dist/index.js +3 -2
- package/dist/migrate-5ZJWF2HD.js +10 -0
- package/dist/serve.js +2 -1
- package/dist/server-I3C74ZLB.js +193 -0
- package/dist/tuner-2LVIEE5V.js +113 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="#install"><strong>Install</strong></a> ·
|
|
7
|
-
<a href="#
|
|
8
|
-
<a href="#
|
|
9
|
-
<a href="#
|
|
10
|
-
<a href="
|
|
7
|
+
<a href="#quickstart"><strong>Quickstart</strong></a> ·
|
|
8
|
+
<a href="#benchmark"><strong>Benchmark</strong></a> ·
|
|
9
|
+
<a href="#ide-integrations"><strong>IDE Integrations</strong></a> ·
|
|
10
|
+
<a href="#http-api"><strong>HTTP API</strong></a> ·
|
|
11
|
+
<a href="#ecp-spec"><strong>ECP Spec</strong></a> ·
|
|
11
12
|
<a href="#contributing"><strong>Contributing</strong></a>
|
|
12
13
|
</p>
|
|
13
14
|
|
|
@@ -15,70 +16,101 @@
|
|
|
15
16
|
<a href="https://github.com/NickCirv/engram/actions"><img src="https://github.com/NickCirv/engram/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
16
17
|
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License">
|
|
17
18
|
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="Node">
|
|
18
|
-
<img src="https://img.shields.io/badge/tests-
|
|
19
|
-
<img src="https://img.shields.io/badge/
|
|
19
|
+
<img src="https://img.shields.io/badge/tests-579%20passing-brightgreen" alt="Tests">
|
|
20
|
+
<img src="https://img.shields.io/badge/providers-8-blue" alt="8 Providers">
|
|
21
|
+
<img src="https://img.shields.io/badge/token%20savings-88%25%20proven-orange" alt="88% Proven Savings">
|
|
20
22
|
<img src="https://img.shields.io/badge/native%20deps-zero-green" alt="Zero native deps">
|
|
21
|
-
<img src="https://img.shields.io/badge/
|
|
23
|
+
<img src="https://img.shields.io/badge/LLM%20cost-$0-green" alt="Zero LLM cost">
|
|
22
24
|
</p>
|
|
23
25
|
|
|
24
26
|
---
|
|
25
27
|
|
|
26
28
|
# The context spine for AI coding agents.
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
engram installs a hook layer at the Claude Code tool-call boundary. Every `Read`, `Edit`, `Write`, and `Bash cat` gets intercepted. When the graph has confident coverage of a file, it serves a **rich context packet** combining structure, decisions, docs, and history — all pre-assembled, all within budget.
|
|
31
|
-
|
|
32
|
-
Not a memory tool. Not a RAG layer. **The context spine that connects your knowledge graph, semantic memory, library docs, and project notes into a single context layer your AI agent can't forget to use.**
|
|
30
|
+
engram intercepts every file read your AI agent makes and replaces it with a pre-assembled context packet — structure, decisions, git history, library docs, and known issues — from 8 providers, delivered in a single ~500-token response. The agent gets what it needs without reading the file. You stop paying for context you've already paid for.
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|---|---|
|
|
36
|
-
| Context spine (graph + 6 providers assembled per read) | A single-purpose file summarizer |
|
|
37
|
-
| Local SQLite, zero cloud, zero native deps | Vector RAG that phones home |
|
|
38
|
-
| Hook-based interception at the tool boundary | A tool the agent has to remember to call |
|
|
39
|
-
| Up to 90% session-level token savings | A theoretical benchmark |
|
|
40
|
-
| Complements native Claude memory | Competes with native Claude memory |
|
|
32
|
+
This is not a tool the agent calls. It hooks at the Claude Code tool boundary. Every `Read`, `Edit`, `Write`, and `cat` is intercepted automatically.
|
|
41
33
|
|
|
42
34
|
```bash
|
|
43
35
|
npm install -g engramx
|
|
44
36
|
cd ~/my-project
|
|
45
|
-
engram init
|
|
46
|
-
engram install-hook
|
|
37
|
+
engram init
|
|
38
|
+
engram install-hook
|
|
47
39
|
```
|
|
48
40
|
|
|
49
|
-
That's
|
|
41
|
+
That's the full setup. The next Claude Code session starts with a project brief already loaded, file reads intercepted, and a live HUD showing cumulative savings.
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
- **Warms provider caches at session start** — MemPalace, Context7, Obsidian pre-fetched in background
|
|
53
|
-
- **Warns before edits that hit known mistakes** (Edit landmine injection)
|
|
54
|
-
- **Pre-loads relevant context when you ask a question** (UserPromptSubmit pre-query)
|
|
55
|
-
- **Injects a project brief at session start** with semantic context (SessionStart)
|
|
56
|
-
- **Survives context compaction** — re-injects critical nodes before compression (PreCompact)
|
|
57
|
-
- **Auto-switches project context** when you navigate to a different repo (CwdChanged)
|
|
58
|
-
- **Shows live HUD in Claude Code status bar** — auto-configured on `install-hook`
|
|
43
|
+
---
|
|
59
44
|
|
|
60
|
-
##
|
|
45
|
+
## Benchmark
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
- **[Installation Guide](docs/engram-user-manual.html)** — AAA-designed step-by-step setup guide with experience tiers.
|
|
64
|
-
- **[Integration Guide](docs/engram-integration-guide.html)** — how memory tools, compression plugins, and workflow managers integrate with engram. Real token savings numbers + code examples.
|
|
65
|
-
- **[INTEGRATION.md](docs/INTEGRATION.md)** — MCP server setup and programmatic API reference.
|
|
47
|
+
Measured across 10 structured coding tasks against a baseline of reading the relevant files directly. No synthetic data. No cherry-picked queries.
|
|
66
48
|
|
|
67
|
-
|
|
49
|
+
| Task | Baseline (tokens) | engram (tokens) | Savings |
|
|
50
|
+
|------|:-----------------:|:---------------:|:-------:|
|
|
51
|
+
| task-01-find-caller | 4,500 | 650 | 85.6% |
|
|
52
|
+
| task-02-parent-class | 2,800 | 400 | 85.7% |
|
|
53
|
+
| task-03-file-for-class | 3,200 | 300 | 90.6% |
|
|
54
|
+
| task-04-import-graph | 6,800 | 900 | 86.8% |
|
|
55
|
+
| task-05-exported-api | 5,500 | 700 | 87.3% |
|
|
56
|
+
| task-06-landmine-check | 8,200 | 850 | 89.6% |
|
|
57
|
+
| task-07-architecture-sketch | 14,500 | 1,600 | 89.0% |
|
|
58
|
+
| task-08-refactor-scope | 9,200 | 1,100 | 88.0% |
|
|
59
|
+
| task-09-hot-files | 3,800 | 550 | 85.5% |
|
|
60
|
+
| task-10-cross-file-flow | 12,800 | 1,400 | 89.1% |
|
|
61
|
+
| **Aggregate** | **7,130** | **845** | **88.1%** |
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
Run the benchmark yourself: `engram bench` or `engram stress-test` for the full suite.
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
---
|
|
72
66
|
|
|
73
|
-
|
|
67
|
+
## What It Does
|
|
74
68
|
|
|
75
|
-
|
|
76
|
-
v0.2: agent → (remembers to call query_graph) → engram returns summary
|
|
77
|
-
v0.3: agent → Read → Claude Code hook → engram intercepts → summary delivered
|
|
78
|
-
```
|
|
69
|
+
engram sits between your AI agent and the filesystem. When the agent reads a file, engram checks its knowledge graph. If the file is covered with sufficient confidence, it blocks the read and injects a compact context packet instead. The packet is assembled from up to 8 providers in parallel, all pre-cached at session start.
|
|
79
70
|
|
|
80
|
-
**
|
|
81
|
-
|
|
71
|
+
**The 8 providers:**
|
|
72
|
+
|
|
73
|
+
| Provider | Source | Confidence | Latency |
|
|
74
|
+
|----------|--------|:-----------:|:-------:|
|
|
75
|
+
| `engram:ast` | Tree-sitter parse (10 languages) | 1.0 | <50ms |
|
|
76
|
+
| `engram:structure` | Regex heuristics (fallback) | 0.85 | <50ms |
|
|
77
|
+
| `engram:mistakes` | Past failure nodes from graph | — | <10ms |
|
|
78
|
+
| `engram:git` | Co-change patterns, churn, authorship | — | <100ms |
|
|
79
|
+
| `mempalace` | Decisions, learnings, project context | — | <5ms cached |
|
|
80
|
+
| `context7` | Library API docs for detected imports | — | <5ms cached |
|
|
81
|
+
| `obsidian` | Project notes, architecture docs | — | <5ms cached |
|
|
82
|
+
| `engram:lsp` | Live diagnostics captured as mistake nodes | — | on-event |
|
|
83
|
+
|
|
84
|
+
External providers cache into SQLite at SessionStart. Per-read resolution is a cache lookup, not a live call. If a provider is unavailable it is skipped silently — you always get at least the structural summary.
|
|
85
|
+
|
|
86
|
+
**The 9 hook handlers:**
|
|
87
|
+
|
|
88
|
+
| Hook | What it does |
|
|
89
|
+
|------|-------------|
|
|
90
|
+
| `PreToolUse:Read` | Blocks the read if file is covered. Delivers structural summary as the block reason. |
|
|
91
|
+
| `PreToolUse:Edit` | Passes through. Injects known mistakes as landmine warnings alongside the edit. |
|
|
92
|
+
| `PreToolUse:Write` | Same as Edit — advisory injection only, never blocks writes. |
|
|
93
|
+
| `PreToolUse:Bash` | Catches `cat \| head \| tail \| less \| more <single-file>` and delegates to the Read handler. |
|
|
94
|
+
| `SessionStart` | Injects a compact project brief (god nodes, graph stats, top landmines, git branch). Bundles MemPalace context in parallel. |
|
|
95
|
+
| `UserPromptSubmit` | Extracts keywords from the prompt, runs a budget-capped pre-query, injects results before the agent responds. |
|
|
96
|
+
| `PostToolUse` | Observer only. Writes to `.engram/hook-log.jsonl` for `hook-stats`. |
|
|
97
|
+
| `PreCompact` | Re-injects god nodes and active landmines right before Claude compresses the conversation. Survives compaction. |
|
|
98
|
+
| `CwdChanged` | Auto-switches project context when you navigate to a different repo mid-session. |
|
|
99
|
+
|
|
100
|
+
**Ten safety invariants enforced at runtime:**
|
|
101
|
+
|
|
102
|
+
1. Any handler error → passthrough (Claude Code is never blocked)
|
|
103
|
+
2. 2-second per-handler timeout
|
|
104
|
+
3. Kill switch (`.engram/hook-disabled`) respected by every handler
|
|
105
|
+
4. Atomic settings.json writes with timestamped backups
|
|
106
|
+
5. Never intercept outside the project root
|
|
107
|
+
6. Never intercept binary files or secrets (`.env`, `.pem`, `.key`, `id_rsa`, etc.)
|
|
108
|
+
7. Never log user prompt content (privacy invariant, asserted in tests)
|
|
109
|
+
8. Never inject more than 8,000 chars per hook response
|
|
110
|
+
9. Stale graph detection — file mtime newer than graph mtime → passthrough
|
|
111
|
+
10. Partial-read bypass — explicit `offset` or `limit` on Read → passthrough
|
|
112
|
+
|
|
113
|
+
---
|
|
82
114
|
|
|
83
115
|
## Install
|
|
84
116
|
|
|
@@ -86,188 +118,208 @@ Every number is arithmetic on empirically verified hook mechanisms — not estim
|
|
|
86
118
|
npm install -g engramx
|
|
87
119
|
```
|
|
88
120
|
|
|
89
|
-
Requires Node.js 20+. Zero native dependencies. No build tools
|
|
121
|
+
Requires Node.js 20+. Zero native dependencies. No build tools. Local SQLite via sql.js WASM — no Rust, no Python, no system libs.
|
|
122
|
+
|
|
123
|
+
---
|
|
90
124
|
|
|
91
125
|
## Quickstart
|
|
92
126
|
|
|
93
127
|
```bash
|
|
94
128
|
cd ~/my-project
|
|
95
|
-
engram init
|
|
96
|
-
engram install-hook
|
|
97
|
-
engram hook-preview src/auth.ts # dry-run: see what the hook would do
|
|
129
|
+
engram init # scan codebase → .engram/graph.db (~40ms, 0 tokens)
|
|
130
|
+
engram install-hook # wire the Sentinel into Claude Code
|
|
98
131
|
```
|
|
99
132
|
|
|
100
|
-
Open a Claude Code session
|
|
133
|
+
Open a Claude Code session. When the agent reads a well-covered file you will see a system-reminder with the structural summary instead of file contents. After the session:
|
|
101
134
|
|
|
102
135
|
```bash
|
|
103
|
-
engram hook-stats
|
|
104
|
-
engram hook-
|
|
105
|
-
engram hook-enable # re-enable
|
|
106
|
-
engram uninstall-hook # surgical removal, preserves other hooks
|
|
136
|
+
engram hook-stats # what was intercepted, tokens saved
|
|
137
|
+
engram hook-preview src/auth.ts # dry-run: see what the hook would inject for one file
|
|
107
138
|
```
|
|
108
139
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Each tier builds on the previous. You can stop at any level — each one works standalone.
|
|
112
|
-
|
|
113
|
-
| Tier | What you run | What you get | Token savings |
|
|
114
|
-
|---|---|---|---|
|
|
115
|
-
| **1. Graph only** | `engram init` | CLI queries, MCP server, `engram gen` for CLAUDE.md | ~6x per query vs reading files |
|
|
116
|
-
| **2. + Sentinel hooks** | `engram install-hook` | Automatic Read interception, Edit warnings, session briefs, HUD | ~80% per session |
|
|
117
|
-
| **3. + Context Spine** | Configure providers.json | Rich packets: structure + decisions + docs + git in one response | Up to 90% session-level |
|
|
118
|
-
| **4. + Skills index** | `engram init --with-skills` | Graph includes your `~/.claude/skills/` — queries surface relevant skills | ~23% overhead on graph size |
|
|
119
|
-
| **5. + Git hooks** | `engram hooks install` | Auto-rebuild graph on every `git commit` — graph never goes stale | Zero token cost |
|
|
120
|
-
|
|
121
|
-
**Recommended full setup** (one-time, per project):
|
|
140
|
+
**Full recommended setup (one-time per project):**
|
|
122
141
|
|
|
123
142
|
```bash
|
|
124
|
-
npm install -g engramx
|
|
143
|
+
npm install -g engramx
|
|
125
144
|
cd ~/my-project
|
|
126
|
-
engram init --with-skills
|
|
127
|
-
engram install-hook
|
|
128
|
-
engram hooks install
|
|
145
|
+
engram init --with-skills # also index ~/.claude/skills/ into the graph
|
|
146
|
+
engram install-hook # wire Sentinel into Claude Code
|
|
147
|
+
engram hooks install # auto-rebuild graph on every git commit
|
|
129
148
|
```
|
|
130
149
|
|
|
131
|
-
|
|
150
|
+
**Experience tiers — each works standalone:**
|
|
132
151
|
|
|
133
|
-
|
|
152
|
+
| Tier | What you run | What you get |
|
|
153
|
+
|------|-------------|-------------|
|
|
154
|
+
| Graph only | `engram init` | CLI queries, MCP server, `engram gen` for CLAUDE.md |
|
|
155
|
+
| + Sentinel | `engram install-hook` | Automatic Read interception, Edit warnings, session briefs, HUD |
|
|
156
|
+
| + Context Spine | Configure providers.json | Rich packets from all 8 providers per read |
|
|
157
|
+
| + Skills index | `engram init --with-skills` | Graph includes your `~/.claude/skills/` |
|
|
158
|
+
| + Git hooks | `engram hooks install` | Graph rebuilds on every commit, stays current |
|
|
159
|
+
| + HTTP server | `engram server --http` | REST API on port 7337 for external tooling |
|
|
134
160
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## IDE Integrations
|
|
138
164
|
|
|
139
|
-
|
|
165
|
+
| IDE | Integration | Setup |
|
|
166
|
+
|-----|------------|-------|
|
|
167
|
+
| **Claude Code** | Hook-based interception (native, automatic) | `engram install-hook` |
|
|
168
|
+
| **Continue.dev** | `@engram` context provider | See [docs/integrations/continue.md](docs/integrations/continue.md) |
|
|
169
|
+
| **Cursor** | MDC generation | `engram gen-mdc` |
|
|
170
|
+
| **Zed** | Context server | `engram context-server` |
|
|
171
|
+
| **Aider** | Context file generation | `engram gen-aider` |
|
|
140
172
|
|
|
141
|
-
|
|
173
|
+
Per-IDE setup guides are in [`docs/integrations/`](docs/integrations/).
|
|
142
174
|
|
|
143
|
-
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## How It Compares
|
|
178
|
+
|
|
179
|
+
| | engram | Continue @RepoMap | Cursor .cursorrules | Aider repo-map | @199-bio/engram |
|
|
180
|
+
|---|---|---|---|---|---|
|
|
181
|
+
| **Interception model** | Hook-based, automatic on every Read | Fetched at @-mention time | Static file, manual | Per-session map | MCP server, called explicitly |
|
|
182
|
+
| **Cache strategy** | SQLite at SessionStart, <5ms per read | No cache — live fetch | No cache | Per-session only | No cache |
|
|
183
|
+
| **Persistent memory** | Decisions, mistakes, patterns across sessions | No | Manual text file | No | No |
|
|
184
|
+
| **Multiple providers** | 8 (AST, git, mistakes, MemPalace, Context7, Obsidian, LSP) | Repo structure only | No | Repo structure only | Graph query only |
|
|
185
|
+
| **Mistake tracking** | LSP diagnostics → mistake nodes, ⚠️ on Edit | No | No | No | No |
|
|
186
|
+
| **Survives compaction** | Yes (PreCompact hook) | No | Yes (static file) | No | No |
|
|
187
|
+
| **LLM cost** | $0 | $0 | $0 | $0 | $0 |
|
|
188
|
+
| **Native deps** | Zero | No | No | No | No |
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Install + Configuration
|
|
144
193
|
|
|
145
194
|
```bash
|
|
146
|
-
|
|
147
|
-
engram init --with-skills # Also index ~/.claude/skills/ (v0.2)
|
|
148
|
-
engram query "how does auth" # Query the graph (BFS, token-budgeted)
|
|
149
|
-
engram query "auth" --dfs # DFS traversal
|
|
150
|
-
engram gods # Show most connected entities
|
|
151
|
-
engram stats # Node/edge counts, token savings
|
|
152
|
-
engram bench # Token reduction benchmark
|
|
153
|
-
engram path "auth" "database" # Shortest path between concepts
|
|
154
|
-
engram learn "chose JWT..." # Teach a decision or pattern
|
|
155
|
-
engram mistakes # List known landmines
|
|
156
|
-
engram gen # Generate CLAUDE.md section from graph
|
|
157
|
-
engram gen --task bug-fix # Task-aware view (general|bug-fix|feature|refactor)
|
|
158
|
-
engram hooks install # Auto-rebuild graph on git commit
|
|
195
|
+
npm install -g engramx
|
|
159
196
|
```
|
|
160
197
|
|
|
161
|
-
|
|
198
|
+
**providers.json** (optional — auto-detection works for most setups):
|
|
162
199
|
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
engram hook-stats --json # Machine-readable output
|
|
173
|
-
engram hook-preview <file> # Dry-run Read handler for a specific file
|
|
174
|
-
engram hook-disable # Kill switch (touch .engram/hook-disabled)
|
|
175
|
-
engram hook-enable # Remove kill switch
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"providers": {
|
|
203
|
+
"mempalace": { "enabled": true },
|
|
204
|
+
"context7": { "enabled": true },
|
|
205
|
+
"obsidian": { "enabled": true, "vault": "~/vault" },
|
|
206
|
+
"lsp": { "enabled": true }
|
|
207
|
+
}
|
|
208
|
+
}
|
|
176
209
|
```
|
|
177
210
|
|
|
178
|
-
|
|
211
|
+
**Hook scope options:**
|
|
179
212
|
|
|
180
213
|
```bash
|
|
181
|
-
engram
|
|
182
|
-
engram
|
|
183
|
-
engram
|
|
184
|
-
engram
|
|
214
|
+
engram install-hook # default: .claude/settings.local.json (gitignored)
|
|
215
|
+
engram install-hook --scope project # .claude/settings.json (committed)
|
|
216
|
+
engram install-hook --scope user # ~/.claude/settings.json (global)
|
|
217
|
+
engram install-hook --dry-run # preview changes without writing
|
|
185
218
|
```
|
|
186
219
|
|
|
187
|
-
**
|
|
220
|
+
**Kill switch (if anything goes wrong):**
|
|
188
221
|
|
|
189
|
-
```
|
|
190
|
-
|
|
222
|
+
```bash
|
|
223
|
+
engram hook-disable # touches .engram/hook-disabled — all handlers pass through
|
|
224
|
+
engram hook-enable # removes the kill switch
|
|
225
|
+
engram uninstall-hook # surgical removal, preserves other hooks in settings.json
|
|
191
226
|
```
|
|
192
227
|
|
|
193
|
-
|
|
228
|
+
---
|
|
194
229
|
|
|
195
|
-
|
|
230
|
+
## CLI Reference
|
|
196
231
|
|
|
197
|
-
|
|
198
|
-
|----------|------|-------------|---------|
|
|
199
|
-
| `engram:structure` | Internal | Functions, classes, imports, edges | <50ms |
|
|
200
|
-
| `engram:mistakes` | Internal | Known bugs and past failures | <10ms |
|
|
201
|
-
| `engram:git` | Internal | Last modified, author, churn rate | <100ms |
|
|
202
|
-
| `mempalace` | External (cached) | Decisions, learnings, project context | <5ms cached |
|
|
203
|
-
| `context7` | External (cached) | Library API docs for imports | <5ms cached |
|
|
204
|
-
| `obsidian` | External (cached) | Project notes, architecture docs | <5ms cached |
|
|
232
|
+
**Core:**
|
|
205
233
|
|
|
206
|
-
|
|
234
|
+
```bash
|
|
235
|
+
engram init [path] # scan codebase, build knowledge graph
|
|
236
|
+
engram init --with-skills # also index ~/.claude/skills/
|
|
237
|
+
engram query "how does auth" # query the graph (BFS, token-budgeted)
|
|
238
|
+
engram query "auth" --dfs # DFS traversal
|
|
239
|
+
engram gods # most connected entities
|
|
240
|
+
engram stats # node/edge counts, confidence breakdown
|
|
241
|
+
engram bench # token reduction benchmark (10 tasks)
|
|
242
|
+
engram stress-test # full stress test suite
|
|
243
|
+
engram path "auth" "database" # shortest path between concepts
|
|
244
|
+
engram learn "chose JWT..." # add a decision or pattern to the graph
|
|
245
|
+
engram mistakes # list known landmines
|
|
246
|
+
```
|
|
207
247
|
|
|
208
|
-
|
|
248
|
+
**Code generation:**
|
|
209
249
|
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
250
|
+
```bash
|
|
251
|
+
engram gen # auto-detect target (CLAUDE.md / .cursorrules / AGENTS.md)
|
|
252
|
+
engram gen --target claude # write to CLAUDE.md
|
|
253
|
+
engram gen --target cursor # write to .cursorrules
|
|
254
|
+
engram gen --target agents # write to AGENTS.md
|
|
255
|
+
engram gen --task bug-fix # task-aware view (general | bug-fix | feature | refactor)
|
|
256
|
+
engram gen --memory-md # write structural facts to Claude's native MEMORY.md
|
|
257
|
+
engram gen-mdc # generate Cursor MDC rules
|
|
258
|
+
engram gen-aider # generate Aider context file
|
|
259
|
+
engram gen-ccs # generate CCS-compatible output
|
|
218
260
|
```
|
|
219
261
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Nine hook handlers compose the interception stack:
|
|
262
|
+
**Sentinel:**
|
|
223
263
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
| **`CwdChanged`** | `additionalContext` | Auto-switches project context when the user navigates to a different repo mid-session. Injects a compact brief for the new project. |
|
|
264
|
+
```bash
|
|
265
|
+
engram intercept # hook entry point (called by Claude Code, reads stdin)
|
|
266
|
+
engram install-hook # install hooks into Claude Code settings
|
|
267
|
+
engram uninstall-hook # remove engram entries
|
|
268
|
+
engram hook-stats # summarize .engram/hook-log.jsonl
|
|
269
|
+
engram hook-stats --json # machine-readable output
|
|
270
|
+
engram hook-preview <file> # dry-run Read handler for a specific file
|
|
271
|
+
engram hook-disable # kill switch
|
|
272
|
+
engram hook-enable # remove kill switch
|
|
273
|
+
```
|
|
235
274
|
|
|
236
|
-
|
|
275
|
+
**Infrastructure:**
|
|
237
276
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
277
|
+
```bash
|
|
278
|
+
engram watch [path] # live file watcher — incremental re-index on save
|
|
279
|
+
engram dashboard [path] # live terminal dashboard
|
|
280
|
+
engram hud-label [path] # JSON label for Claude HUD --extra-cmd integration
|
|
281
|
+
engram hooks install # install post-commit + post-checkout git hooks
|
|
282
|
+
engram hooks status # check git hook installation
|
|
283
|
+
engram hooks uninstall # remove git hooks
|
|
284
|
+
engram server --http # start HTTP REST server on port 7337
|
|
285
|
+
engram context-server # start Zed context server
|
|
286
|
+
engram tune --dry-run # auto-tune provider weights (preview mode)
|
|
287
|
+
engram db status # schema version, migration state
|
|
288
|
+
engram init --from-ccs # import from CCS-format context file
|
|
289
|
+
```
|
|
248
290
|
|
|
249
|
-
|
|
291
|
+
**Claude HUD integration:**
|
|
250
292
|
|
|
251
|
-
|
|
293
|
+
Add `--extra-cmd="engram hud-label"` to your statusLine command to see live savings:
|
|
252
294
|
|
|
253
|
-
|
|
295
|
+
```
|
|
296
|
+
engram 48.5K saved 75%
|
|
297
|
+
```
|
|
254
298
|
|
|
255
|
-
|
|
299
|
+
---
|
|
256
300
|
|
|
257
|
-
|
|
301
|
+
## HTTP API
|
|
258
302
|
|
|
259
|
-
|
|
303
|
+
Start the server with `engram server --http` (default port 7337).
|
|
260
304
|
|
|
261
|
-
|
|
305
|
+
| Method | Endpoint | Description |
|
|
306
|
+
|--------|----------|-------------|
|
|
307
|
+
| `GET` | `/health` | Server health + graph stats |
|
|
308
|
+
| `POST` | `/query` | Query the knowledge graph |
|
|
309
|
+
| `GET` | `/gods` | Most connected entities |
|
|
310
|
+
| `GET` | `/stats` | Node/edge counts, confidence breakdown |
|
|
311
|
+
| `POST` | `/path` | Shortest path between two concepts |
|
|
312
|
+
| `GET` | `/mistakes` | Known failure nodes |
|
|
313
|
+
| `POST` | `/learn` | Add a decision or pattern |
|
|
314
|
+
| `POST` | `/init` | Trigger a graph rebuild |
|
|
315
|
+
| `GET` | `/hook-stats` | Hook interception log summary |
|
|
262
316
|
|
|
263
|
-
|
|
317
|
+
All responses are JSON. The server is local-only by default — bind address is `127.0.0.1`.
|
|
264
318
|
|
|
265
|
-
|
|
319
|
+
---
|
|
266
320
|
|
|
267
321
|
## MCP Server
|
|
268
322
|
|
|
269
|
-
Connect engram to Claude Code, Windsurf, or any MCP client:
|
|
270
|
-
|
|
271
323
|
```json
|
|
272
324
|
{
|
|
273
325
|
"mcpServers": {
|
|
@@ -279,180 +331,101 @@ Connect engram to Claude Code, Windsurf, or any MCP client:
|
|
|
279
331
|
}
|
|
280
332
|
```
|
|
281
333
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
```json
|
|
285
|
-
{
|
|
286
|
-
"mcpServers": {
|
|
287
|
-
"engram": {
|
|
288
|
-
"command": "engram-serve",
|
|
289
|
-
"args": ["/path/to/your/project"]
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
**MCP Tools** (6 total):
|
|
296
|
-
- `query_graph` — Search the knowledge graph with natural language
|
|
297
|
-
- `god_nodes` — Core abstractions (most connected entities)
|
|
298
|
-
- `graph_stats` — Node/edge counts, confidence breakdown
|
|
299
|
-
- `shortest_path` — Trace connections between two concepts
|
|
300
|
-
- `benchmark` — Token reduction measurement
|
|
301
|
-
- `list_mistakes` — Known failure modes from past sessions (v0.2)
|
|
334
|
+
**MCP Tools (6):**
|
|
302
335
|
|
|
303
|
-
|
|
336
|
+
- `query_graph` — search the knowledge graph with natural language
|
|
337
|
+
- `god_nodes` — core abstractions (most connected entities)
|
|
338
|
+
- `graph_stats` — node/edge counts, confidence breakdown
|
|
339
|
+
- `shortest_path` — trace connections between two concepts
|
|
340
|
+
- `benchmark` — token reduction measurement
|
|
341
|
+
- `list_mistakes` — known failure modes from past sessions
|
|
304
342
|
|
|
305
|
-
|
|
343
|
+
**Shell wrapper (for Bash-based agents):**
|
|
306
344
|
|
|
307
345
|
```bash
|
|
308
346
|
cp scripts/mcp-engram ~/bin/mcp-engram && chmod +x ~/bin/mcp-engram
|
|
309
347
|
mcp-engram query "how does auth work" -p ~/myrepo
|
|
310
348
|
```
|
|
311
349
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
## Auto-Generated AI Instructions
|
|
315
|
-
|
|
316
|
-
After building a graph, run:
|
|
317
|
-
|
|
318
|
-
```bash
|
|
319
|
-
engram gen # Auto-detect CLAUDE.md / .cursorrules / AGENTS.md
|
|
320
|
-
engram gen --target claude # Write to CLAUDE.md
|
|
321
|
-
engram gen --target cursor # Write to .cursorrules
|
|
322
|
-
engram gen --target agents # Write to AGENTS.md
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
This writes a structured codebase summary — god nodes, file structure, key dependencies, decisions — so your AI assistant navigates by structure instead of grepping.
|
|
326
|
-
|
|
327
|
-
### Task-Aware Views (v0.2)
|
|
328
|
-
|
|
329
|
-
`engram gen --task <name>` emits different content based on what you're about to do. The four preset views are defined in `src/autogen.ts` as a data table — no branching logic — so you can add your own task modes without touching the renderer.
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
engram gen --task general # default — balanced mix of sections
|
|
333
|
-
engram gen --task bug-fix # emphasizes hot files + past mistakes
|
|
334
|
-
engram gen --task feature # emphasizes architecture + decisions
|
|
335
|
-
engram gen --task refactor # emphasizes god nodes + dependency graph
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Each view picks a different set of sections with different limits. For example, `bug-fix` omits `## Decisions` and `## Key dependencies` entirely (they'd just be noise when you're chasing a regression) and leads with `🔥 Hot files` and `⚠️ Past mistakes`.
|
|
339
|
-
|
|
340
|
-
## How engram Compares
|
|
341
|
-
|
|
342
|
-
| | engram | Mem0 | Graphify | aider repo-map | CLAUDE.md |
|
|
343
|
-
|---|---|---|---|---|---|
|
|
344
|
-
| **Code structure** | Heuristic extraction (10 langs) | No | Yes (tree-sitter) | Yes (tree-sitter) | No |
|
|
345
|
-
| **Persistent memory** | SQLite graph, survives sessions | Yes (vector + graph) | Static snapshot | Per-session only | Manual text file |
|
|
346
|
-
| **Session learning** | Mines decisions, patterns, mistakes | Generic facts | No | No | You write it by hand |
|
|
347
|
-
| **Universal** | MCP + CLI + auto-gen | API only | Claude Code only | aider only | Claude Code only |
|
|
348
|
-
| **LLM cost** | $0 | $0 (self-host) / paid cloud | Tokens for docs/images | Per-session | $0 |
|
|
349
|
-
| **Code-specific** | Built for codebases | Generic AI memory | Yes | Yes | No |
|
|
350
|
-
| **Temporal** | Git history mining | No | No | No | No |
|
|
351
|
-
|
|
352
|
-
**The gap nobody fills:** Code-structural understanding + persistent cross-session learning + temporal awareness + works with every AI tool. engram is the first to combine all four.
|
|
353
|
-
|
|
354
|
-
## Confidence System
|
|
355
|
-
|
|
356
|
-
Every relationship in the graph is tagged:
|
|
357
|
-
|
|
358
|
-
| Tag | Meaning | Score |
|
|
359
|
-
|-----|---------|-------|
|
|
360
|
-
| **EXTRACTED** | Found directly in source code (import, function definition) | 1.0 |
|
|
361
|
-
| **INFERRED** | Reasoned from patterns (git co-changes, session decisions) | 0.4-0.9 |
|
|
362
|
-
| **AMBIGUOUS** | Uncertain, flagged for review | 0.1-0.3 |
|
|
363
|
-
|
|
364
|
-
You always know what was found vs guessed.
|
|
365
|
-
|
|
366
|
-
## Token Savings
|
|
367
|
-
|
|
368
|
-
engram reports two honest baselines:
|
|
369
|
-
|
|
370
|
-
- **vs relevant files** — compared to reading only the files that match your query. This is the fair comparison. Typical: **3-11x** fewer tokens.
|
|
371
|
-
- **vs full corpus** — compared to sending your entire codebase. This is the worst case you're avoiding. Typical: **30-400x** fewer tokens.
|
|
350
|
+
---
|
|
372
351
|
|
|
373
|
-
|
|
352
|
+
## ECP Spec
|
|
374
353
|
|
|
375
|
-
|
|
354
|
+
engram v1.0 ships the first draft of the **Engram Context Protocol** (ECP v0.1) — an open specification for how AI coding tools should package and exchange structured context packets.
|
|
376
355
|
|
|
377
|
-
|
|
356
|
+
The spec defines the wire format, provider negotiation, budget constraints, and confidence scoring used by engram internally. Any tool can implement the spec to produce or consume engram-compatible context packets.
|
|
378
357
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
engram hooks status # Check installation
|
|
382
|
-
engram hooks uninstall # Remove hooks
|
|
383
|
-
```
|
|
358
|
+
**License:** CC-BY 4.0
|
|
359
|
+
**Spec:** [`docs/specs/ecp-v0.1.md`](docs/specs/ecp-v0.1.md)
|
|
384
360
|
|
|
385
|
-
|
|
361
|
+
---
|
|
386
362
|
|
|
387
363
|
## Programmatic API
|
|
388
364
|
|
|
389
365
|
```typescript
|
|
390
366
|
import { init, query, godNodes, stats } from "engramx";
|
|
391
367
|
|
|
392
|
-
// Build the graph
|
|
393
368
|
const result = await init("./my-project");
|
|
394
369
|
console.log(`${result.nodes} nodes, ${result.edges} edges`);
|
|
395
370
|
|
|
396
|
-
// Query it
|
|
397
371
|
const answer = await query("./my-project", "how does auth work");
|
|
398
372
|
console.log(answer.text);
|
|
399
373
|
|
|
400
|
-
// Get god nodes
|
|
401
374
|
const gods = await godNodes("./my-project");
|
|
402
375
|
for (const g of gods) {
|
|
403
376
|
console.log(`${g.label} — ${g.degree} connections`);
|
|
404
377
|
}
|
|
405
378
|
```
|
|
406
379
|
|
|
380
|
+
---
|
|
381
|
+
|
|
407
382
|
## Architecture
|
|
408
383
|
|
|
409
384
|
```
|
|
410
385
|
src/
|
|
411
386
|
├── cli.ts CLI entry point
|
|
412
387
|
├── core.ts API surface (init, query, stats, learn)
|
|
413
|
-
├── serve.ts MCP server (
|
|
388
|
+
├── serve.ts MCP server (6 tools, JSON-RPC stdio)
|
|
389
|
+
├── server.ts HTTP REST server (port 7337)
|
|
414
390
|
├── hooks.ts Git hook install/uninstall
|
|
415
|
-
├── autogen.ts CLAUDE.md / .cursorrules generation
|
|
391
|
+
├── autogen.ts CLAUDE.md / .cursorrules / MDC generation
|
|
416
392
|
├── graph/
|
|
417
|
-
│ ├── schema.ts Types: nodes, edges, confidence
|
|
418
|
-
│ ├── store.ts SQLite persistence (sql.js, zero native deps)
|
|
393
|
+
│ ├── schema.ts Types: nodes, edges, confidence, schema versioning
|
|
394
|
+
│ ├── store.ts SQLite persistence (sql.js WASM, zero native deps)
|
|
419
395
|
│ └── query.ts BFS/DFS traversal, shortest path
|
|
420
396
|
├── miners/
|
|
421
|
-
│ ├── ast-miner.ts
|
|
397
|
+
│ ├── ast-miner.ts Tree-sitter AST extraction (10 languages, confidence 1.0)
|
|
422
398
|
│ ├── git-miner.ts Change patterns from git history
|
|
423
|
-
│
|
|
399
|
+
│ ├── session-miner.ts Decisions/patterns from AI session docs
|
|
400
|
+
│ └── skills-miner.ts ~/.claude/skills/ indexer (opt-in)
|
|
401
|
+
├── providers/
|
|
402
|
+
│ ├── context-spine.ts Provider assembly + budget management
|
|
403
|
+
│ ├── mempalace.ts MemPalace integration
|
|
404
|
+
│ ├── context7.ts Context7 library docs
|
|
405
|
+
│ ├── obsidian.ts Obsidian vault
|
|
406
|
+
│ └── lsp.ts LSP diagnostic capture
|
|
424
407
|
└── intelligence/
|
|
425
408
|
└── token-tracker.ts Cumulative token savings measurement
|
|
426
409
|
```
|
|
427
410
|
|
|
428
|
-
|
|
411
|
+
**Supported languages (AST):** TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, Ruby, PHP.
|
|
429
412
|
|
|
430
|
-
|
|
413
|
+
---
|
|
431
414
|
|
|
432
|
-
##
|
|
415
|
+
## Privacy
|
|
433
416
|
|
|
434
|
-
|
|
435
|
-
- ✅ **v0.5** — Context Spine: 6 providers, rich packets, provider cache, 90% session savings
|
|
436
|
-
- ✅ **v0.4** — Infrastructure: PreCompact, CwdChanged, file watcher, MemPalace integration
|
|
437
|
-
- ✅ **v0.3** — Sentinel: 9 hook handlers, Read interception, session briefs, prompt pre-query
|
|
438
|
-
- ✅ **v0.2** — Skills miner, mistake memory, adaptive gen, MCP server
|
|
417
|
+
Everything runs locally. No data leaves your machine. No telemetry. No cloud dependency. The only network call is `npm install`. Prompt content is never logged (asserted in 579 tests).
|
|
439
418
|
|
|
440
|
-
|
|
441
|
-
- ECP spec v0.1 — Engram Context Protocol (open RFC)
|
|
442
|
-
- Continue.dev + Cursor adapters
|
|
443
|
-
- Tree-sitter opt-in (20+ languages with full AST precision)
|
|
444
|
-
- Reproducible benchmark harness
|
|
445
|
-
- Graph explorer (ReactFlow web UI)
|
|
446
|
-
- Team sync (ElectricSQL, paid tier)
|
|
419
|
+
---
|
|
447
420
|
|
|
448
|
-
##
|
|
421
|
+
## Contributing
|
|
449
422
|
|
|
450
|
-
|
|
423
|
+
Issues and PRs welcome at [github.com/NickCirv/engram](https://github.com/NickCirv/engram).
|
|
451
424
|
|
|
452
|
-
|
|
425
|
+
Run `engram init` on a real codebase and share what it got right and wrong. The benchmark suite (`engram bench`) is the fastest way to see the difference on your own code.
|
|
453
426
|
|
|
454
|
-
|
|
427
|
+
---
|
|
455
428
|
|
|
456
|
-
##
|
|
429
|
+
## License
|
|
457
430
|
|
|
458
|
-
|
|
431
|
+
[Apache 2.0](LICENSE)
|