engram-mcp-server 1.4.0 → 1.6.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.
Files changed (128) hide show
  1. package/README.md +521 -172
  2. package/dist/constants.d.ts +4 -1
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +5 -1
  5. package/dist/constants.js.map +1 -1
  6. package/dist/database.d.ts +7 -1
  7. package/dist/database.d.ts.map +1 -1
  8. package/dist/database.js +66 -2
  9. package/dist/database.js.map +1 -1
  10. package/dist/global-db.d.ts +29 -0
  11. package/dist/global-db.d.ts.map +1 -0
  12. package/dist/global-db.js +130 -0
  13. package/dist/global-db.js.map +1 -0
  14. package/dist/index.js +68 -28
  15. package/dist/index.js.map +1 -1
  16. package/dist/installer/ide-configs.d.ts.map +1 -1
  17. package/dist/installer/ide-configs.js +61 -10
  18. package/dist/installer/ide-configs.js.map +1 -1
  19. package/dist/installer/ide-detector.d.ts +18 -0
  20. package/dist/installer/ide-detector.d.ts.map +1 -1
  21. package/dist/installer/ide-detector.js +55 -8
  22. package/dist/installer/ide-detector.js.map +1 -1
  23. package/dist/installer/index.d.ts.map +1 -1
  24. package/dist/installer/index.js +166 -59
  25. package/dist/installer/index.js.map +1 -1
  26. package/dist/migrations.d.ts.map +1 -1
  27. package/dist/migrations.js +211 -0
  28. package/dist/migrations.js.map +1 -1
  29. package/dist/repositories/agents.repo.d.ts +13 -0
  30. package/dist/repositories/agents.repo.d.ts.map +1 -0
  31. package/dist/repositories/agents.repo.js +32 -0
  32. package/dist/repositories/agents.repo.js.map +1 -0
  33. package/dist/repositories/broadcasts.repo.d.ts +13 -0
  34. package/dist/repositories/broadcasts.repo.d.ts.map +1 -0
  35. package/dist/repositories/broadcasts.repo.js +49 -0
  36. package/dist/repositories/broadcasts.repo.js.map +1 -0
  37. package/dist/repositories/decisions.repo.d.ts +8 -1
  38. package/dist/repositories/decisions.repo.d.ts.map +1 -1
  39. package/dist/repositories/decisions.repo.js +55 -6
  40. package/dist/repositories/decisions.repo.js.map +1 -1
  41. package/dist/repositories/file-notes.repo.d.ts +8 -0
  42. package/dist/repositories/file-notes.repo.d.ts.map +1 -1
  43. package/dist/repositories/file-notes.repo.js +17 -5
  44. package/dist/repositories/file-notes.repo.js.map +1 -1
  45. package/dist/repositories/index.d.ts +6 -0
  46. package/dist/repositories/index.d.ts.map +1 -1
  47. package/dist/repositories/index.js +6 -0
  48. package/dist/repositories/index.js.map +1 -1
  49. package/dist/repositories/sessions.repo.d.ts +6 -0
  50. package/dist/repositories/sessions.repo.d.ts.map +1 -1
  51. package/dist/repositories/sessions.repo.js +15 -0
  52. package/dist/repositories/sessions.repo.js.map +1 -1
  53. package/dist/repositories/tasks.repo.d.ts +5 -0
  54. package/dist/repositories/tasks.repo.d.ts.map +1 -1
  55. package/dist/repositories/tasks.repo.js +21 -0
  56. package/dist/repositories/tasks.repo.js.map +1 -1
  57. package/dist/services/agent-rules.service.d.ts +31 -0
  58. package/dist/services/agent-rules.service.d.ts.map +1 -0
  59. package/dist/services/agent-rules.service.js +114 -0
  60. package/dist/services/agent-rules.service.js.map +1 -0
  61. package/dist/services/index.d.ts +1 -0
  62. package/dist/services/index.d.ts.map +1 -1
  63. package/dist/services/index.js +1 -0
  64. package/dist/services/index.js.map +1 -1
  65. package/dist/tools/changes.d.ts.map +1 -1
  66. package/dist/tools/changes.js +56 -2
  67. package/dist/tools/changes.js.map +1 -1
  68. package/dist/tools/conventions.d.ts.map +1 -1
  69. package/dist/tools/conventions.js +15 -5
  70. package/dist/tools/conventions.js.map +1 -1
  71. package/dist/tools/coordination.d.ts +3 -0
  72. package/dist/tools/coordination.d.ts.map +1 -0
  73. package/dist/tools/coordination.js +420 -0
  74. package/dist/tools/coordination.js.map +1 -0
  75. package/dist/tools/decisions.d.ts.map +1 -1
  76. package/dist/tools/decisions.js +31 -10
  77. package/dist/tools/decisions.js.map +1 -1
  78. package/dist/tools/dispatcher-admin.d.ts +3 -0
  79. package/dist/tools/dispatcher-admin.d.ts.map +1 -0
  80. package/dist/tools/dispatcher-admin.js +330 -0
  81. package/dist/tools/dispatcher-admin.js.map +1 -0
  82. package/dist/tools/dispatcher-memory.d.ts +3 -0
  83. package/dist/tools/dispatcher-memory.d.ts.map +1 -0
  84. package/dist/tools/dispatcher-memory.js +1119 -0
  85. package/dist/tools/dispatcher-memory.js.map +1 -0
  86. package/dist/tools/file-notes.d.ts.map +1 -1
  87. package/dist/tools/file-notes.js +248 -13
  88. package/dist/tools/file-notes.js.map +1 -1
  89. package/dist/tools/find.d.ts +9 -0
  90. package/dist/tools/find.d.ts.map +1 -0
  91. package/dist/tools/find.js +206 -0
  92. package/dist/tools/find.js.map +1 -0
  93. package/dist/tools/intelligence.d.ts.map +1 -1
  94. package/dist/tools/intelligence.js +180 -3
  95. package/dist/tools/intelligence.js.map +1 -1
  96. package/dist/tools/knowledge.d.ts +3 -0
  97. package/dist/tools/knowledge.d.ts.map +1 -0
  98. package/dist/tools/knowledge.js +165 -0
  99. package/dist/tools/knowledge.js.map +1 -0
  100. package/dist/tools/milestones.d.ts.map +1 -1
  101. package/dist/tools/milestones.js +2 -1
  102. package/dist/tools/milestones.js.map +1 -1
  103. package/dist/tools/report.d.ts +3 -0
  104. package/dist/tools/report.d.ts.map +1 -0
  105. package/dist/tools/report.js +159 -0
  106. package/dist/tools/report.js.map +1 -0
  107. package/dist/tools/scheduler.d.ts.map +1 -1
  108. package/dist/tools/scheduler.js +142 -10
  109. package/dist/tools/scheduler.js.map +1 -1
  110. package/dist/tools/sessions.d.ts +1 -0
  111. package/dist/tools/sessions.d.ts.map +1 -1
  112. package/dist/tools/sessions.js +557 -14
  113. package/dist/tools/sessions.js.map +1 -1
  114. package/dist/tools/stats.d.ts.map +1 -1
  115. package/dist/tools/stats.js +19 -0
  116. package/dist/tools/stats.js.map +1 -1
  117. package/dist/tools/tasks.d.ts.map +1 -1
  118. package/dist/tools/tasks.js +5 -4
  119. package/dist/tools/tasks.js.map +1 -1
  120. package/dist/types.d.ts +37 -0
  121. package/dist/types.d.ts.map +1 -1
  122. package/dist/utils.d.ts +31 -0
  123. package/dist/utils.d.ts.map +1 -1
  124. package/dist/utils.js +70 -0
  125. package/dist/utils.js.map +1 -1
  126. package/package.json +2 -2
  127. package/scripts/fix-mcp-config.js +23 -0
  128. package/scripts/inject-release-notes.js +2 -1
package/README.md CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  # 🧠 Engram
4
4
 
5
- > **Persistent Memory Cortex for AI coding agents. Gives agents session continuity, change tracking, and decision logging across sessions.**
5
+ > **Persistent Memory Cortex for AI coding agents. Gives agents session continuity, change tracking, decision logging, and multi-agent coordination across sessions.**
6
6
 
7
7
  ![npm](https://img.shields.io/npm/v/engram-mcp-server?style=flat-square&logo=npm)
8
8
  ![Build](https://img.shields.io/github/actions/workflow/status/keggan-std/Engram/ci.yml?style=flat-square)
9
9
  ![Claude Compatible](https://img.shields.io/badge/Claude-Compatible-D97706?style=flat-square&logo=anthropic)
10
+ ![Multi-Agent](https://img.shields.io/badge/Multi--Agent-Ready-22C55E?style=flat-square)
10
11
  ![VS Code Support](https://img.shields.io/badge/VS%20Code-Supported-007ACC?style=flat-square&logo=visualstudiocode)
11
12
  ![Visual Studio Support](https://img.shields.io/badge/Visual%20Studio-Supported-5C2D91?style=flat-square&logo=visualstudio)
12
13
  ![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)
@@ -16,14 +17,16 @@
16
17
  ---
17
18
 
18
19
  ## 📋 Table of Contents
20
+
19
21
  - [Overview](#overview)
20
22
  - [Why Engram?](#why-engram)
21
23
  - [Installation (Auto & Manual)](#installation)
22
- - [✨ What's New in v1.4.0](#-whats-new-in-v140)
24
+ - [✨ What's New in v1.6.0](#-whats-new-in-v160)
23
25
  - [Features](#features)
24
26
  - [Architecture](#architecture)
25
27
  - [Tools Reference](#tools-reference)
26
28
  - [Using with AI Agents](#using-with-ai-agents)
29
+ - [Multi-Agent Workflows](#multi-agent-workflows)
27
30
  - [Contributing](#contributing)
28
31
  - [License](#license)
29
32
 
@@ -31,7 +34,7 @@
31
34
 
32
35
  ## Overview
33
36
 
34
- **Engram** is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI coding agents persistent memory across sessions. Instead of re-reading files, re-discovering architecture, and re-learning conventions every time a session starts, the agent calls `engram_start_session` and instantly receives everything it needs.
37
+ **Engram** is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI coding agents persistent memory across sessions. Instead of re-reading files, re-discovering architecture, and re-learning conventions every time a session starts, the agent calls `engram_session(action:"start")` and instantly receives everything it needs.
35
38
 
36
39
  It operates seamlessly as a background brain for popular AI tools like **Claude Code**, **Claude Desktop**, **Cursor**, **Windsurf**, **Cline**, **Trae IDE**, and **GitHub Copilot** (VS Code & Visual Studio).
37
40
 
@@ -40,6 +43,7 @@ It operates seamlessly as a background brain for popular AI tools like **Claude
40
43
  ## Why Engram?
41
44
 
42
45
  Every AI coding agent is **stateless by default**. Each new session starts from scratch:
46
+
43
47
  - The agent re-reads file structures and re-discovers architecture.
44
48
  - Architectural decisions made in previous sessions are forgotten.
45
49
  - Conventions agreed upon are lost.
@@ -50,16 +54,78 @@ Engram solves this by providing a **persistent brain** using a native SQLite (WA
50
54
 
51
55
  ---
52
56
 
53
- ## ✨ What's New in v1.4.0
57
+ ## ✨ What's New in v1.6.0
58
+
59
+ **v1.6.0** is the largest Engram release to date — fourteen feature tracks covering a complete lean-surface rearchitecture, deeper memory intelligence, smarter multi-agent coordination, and a new thin-client proxy.
60
+
61
+ ### ⚡ Lean 4-Tool Dispatcher Surface — ~95% Fewer Schema Tokens
62
+
63
+ The MCP surface collapsed from 50+ individual tools to **4 dispatcher tools**: `engram_session`, `engram_memory`, `engram_admin`, `engram_find`. Every previous operation is still available — routed via `action` parameter. Token overhead drops from ~32,500 to ~1,600 per API call. Every AI agent benefits automatically with no configuration change.
64
+
65
+ ### 📸 Checkpoints — Offload Working Memory Mid-Session
66
+
67
+ `engram_memory(action:"checkpoint")` saves current understanding, progress, and relevant files to a persistent `checkpoints` table. `get_checkpoint` restores it. Use when approaching context limits without ending the session.
68
+
69
+ ### 🔬 Hash-Based Staleness Detection
70
+
71
+ File notes now store a **SHA-256 content hash** alongside `file_mtime`. When mtime matches but the hash differs, confidence is downgraded to `stale` — catching silent edits from formatters, git merges, and auto-saves that preserve timestamps.
72
+
73
+ ### 📊 Tiered Verbosity — `nano` Mode
74
+
75
+ Four verbosity levels: `full`, `summary`, `minimal`, and the new **`nano`** — returns only session ID, counts, agent rules, and tool catalog. Under 100 tokens total. For ultra-lean session starts in constrained contexts.
76
+
77
+ ### 🗂️ Executive Summary on File Notes
78
+
79
+ File notes now support an `executive_summary` field — a 2-3 sentence micro summary for Tier-1 reads. Agents can write it once; future sessions get instant context without opening the file.
80
+
81
+ ### 🛡️ Agent Rules — Live-Loaded from GitHub
82
+
83
+ `start_session` now returns `agent_rules` fetched dynamically from the Engram README (7-day local cache at `.engram/agent_rules_cache.json`). Rules update automatically when the README changes — no agent reinstall required.
84
+
85
+ ### 🔍 Convention Linting in `engram_find`
86
+
87
+ `engram_find(action:"lint", content:"...")` checks any code snippet against all active conventions and returns a `violations[]` array — useful before committing or during code review.
88
+
89
+ ### 🔧 Git Hook Install/Remove via `engram_admin`
90
+
91
+ `engram_admin(action:"install_hooks")` and `remove_hooks` write/remove the Engram post-commit hook directly from within the MCP tool — no CLI needed.
92
+
93
+ ### 🌐 Multi-Agent Specialization Routing
94
+
95
+ `engram_memory(action:"agent_sync", specializations:["typescript","database"])` stores agent skill tags. `claim_task` returns an advisory `match_score` comparing agent specializations vs task tags. New `route_task` action finds the best-matched agent for any task.
96
+
97
+ ### 🔒 Agent Safety — File Locking & Pending Work
98
+
99
+ `engram_memory(action:"lock_file")` / `unlock_file` prevent concurrent write conflicts. `engram_memory(action:"begin_work")` / `end_work` declare intent before touching files. Abandoned work surfaces in `start_session` as `abandoned_work`.
100
+
101
+ ### 🌡️ Context Pressure Detection
102
+
103
+ `check_events` fires `context_pressure` at 50%/70%/85% so agents know when to wrap up before hitting the context wall.
104
+
105
+ ### 🤝 Session Handoffs
106
+
107
+ `engram_session(action:"handoff")` packages open tasks, last file touched, git branch, and instructions for the next agent. Auto-surfaced in `start_session` as `handoff_pending`.
108
+
109
+ ### 🎬 Session Replay & Diagnostics
110
+
111
+ Every MCP tool call is logged to `tool_call_log`. Session Replay reconstructs the complete chronological timeline of any session.
112
+
113
+ ### 📦 `engram-thin-client` Package
54
114
 
55
- - **Version-Tracked Installs:** Every IDE config entry is now stamped with `_engram_version`. The installer detects four distinct states fresh install, already up to date, upgrade from a known version, and legacy adoption (pre-tracking era entries) — and reports each one clearly.
56
- - **Background Auto-Update Check:** Engram silently checks for new versions after server startup using a fire-and-forget async check (never blocks startup or any tool call). If a newer version is found, the agent is notified via `engram_start_session` and can tell the user.
57
- - **User-Controlled Update Flow:** Users choose how to act on an update via agent commands — update now, skip this version forever, postpone for N days (`7d`, `2w`, `1m`), or disable checks entirely. Nothing is automatic; the user is always in control.
58
- - **Two-Source Changelog Delivery:** Update notifications include the release changelog fetched from the npm registry (primary) or GitHub Releases API (fallback). Both sources are tried with a 5-second timeout; network failures are silent.
59
- - **`--check` CLI Flag:** `npx -y engram-mcp-server install --check` shows the installed version for each detected IDE, compares against npm latest, and correctly handles pre-release scenarios (running ahead of the published version).
60
- - **`engram_stats` Version & Update Status:** Stats now include `server_version`, `update_status` (available version + releases URL if an update is pending), `auto_update_check` state, and `last_update_check` timestamp.
61
- - **`engram_config` Update Keys:** Four new configurable keys — `auto_update_check`, `auto_update_skip_version`, `auto_update_remind_after` (accepts durations like `7d`, `2w`, `1m`), and `auto_update_notify_level` (`"major"` | `"minor"` | `"patch"`).
62
- - **Pre-publish Release Notes Injection:** A new `scripts/inject-release-notes.js` script runs automatically before every `npm publish`. It extracts the current version's section from `RELEASE_NOTES.md` and injects it into `package.json`, enabling single-HTTP-call changelog delivery via the npm registry API.
115
+ New `packages/engram-thin-client/` proxy enables Anthropic's `defer_loading` beta tools are defined with `defer_loading: true` so **zero** schema tokens are consumed upfront. Claude discovers tools on demand via BM25 search. For agents using the Anthropic API directly.
116
+
117
+ ### 📦 `engram-universal-client` Package
118
+
119
+ New `packages/engram-universal-thin-client/` proxy exposes Engram as a **single MCP tool** with an ~80-token schema works with **every** MCP-compatible agent (Cursor, VS Code Copilot, Windsurf, Gemini CLI, GPT-based IDEs, Claude). BM25 routing maps free-text or near-miss action strings to the correct dispatcher. No Anthropic API required.
120
+
121
+ | Approach | Schema tokens/call | Works universally |
122
+ |---|---|---|
123
+ | v1.5 (50+ tools) | ~32,500 | ✅ |
124
+ | v1.6 dispatcher (4 tools) | ~1,600 | ✅ |
125
+ | `engram-thin-client` | ~0 (deferred) | ⚠️ Anthropic only |
126
+ | **`engram-universal-client`** | **~80** | ✅ **All agents** |
127
+
128
+ > Full changelog: [RELEASE_NOTES.md](RELEASE_NOTES.md) · Previous release: **v1.5.0** — Multi-Agent Coordination, Trustworthy Context & Knowledge Intelligence.
63
129
 
64
130
  ---
65
131
 
@@ -72,14 +138,15 @@ Engram is published to the npm registry. **You do not need to download or compil
72
138
  Engram uses **SQLite** for persistent storage via the `better-sqlite3` library, which includes a native C++ addon. On most systems this is handled automatically via prebuilt binaries. However, if no prebuilt binary matches your platform, npm will attempt to compile from source — which requires:
73
139
 
74
140
  - **Windows:** [Node.js](https://nodejs.org) (v18+) and [Windows Build Tools](https://github.com/nodejs/node-gyp#on-windows) (Visual C++ Build Tools + Python). Install them with:
75
- ```bash
76
- npm install -g windows-build-tools
77
- ```
78
- Or install **"Desktop development with C++"** via the [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/).
141
+ ```bash
142
+ npm install -g windows-build-tools
143
+ ```
144
+ Or install **"Desktop development with C++"** via the [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/).
79
145
  - **Mac:** Xcode Command Line Tools (`xcode-select --install`)
80
146
  - **Linux:** `build-essential` and `python3` (`sudo apt install build-essential python3`)
81
147
 
82
148
  ### Option 1: The Magic Installer (Interactive)
149
+
83
150
  Run this single command in your terminal. It will automatically detect your IDE and safely inject the configuration:
84
151
 
85
152
  ```bash
@@ -87,18 +154,21 @@ npx -y engram-mcp-server --install
87
154
  ```
88
155
 
89
156
  **Non-interactive mode (CI/CD / Scripting):**
157
+
90
158
  ```bash
91
159
  npx -y engram-mcp-server install --ide vscode --yes
92
160
  ```
93
161
 
94
162
  **Clean removal:**
163
+
95
164
  ```bash
96
165
  npx -y engram-mcp-server install --remove --ide claudecode
97
166
  ```
98
167
 
99
168
  **Check installed version vs npm latest:**
169
+
100
170
  ```bash
101
- npx -y engram-mcp-server install --check
171
+ npx -y engram-mcp-server --check
102
172
  ```
103
173
 
104
174
  ### Option 2: Global Install (Windows Fallback)
@@ -112,7 +182,40 @@ engram install --ide <your-ide>
112
182
 
113
183
  > **Note:** During install you may see `npm warn deprecated prebuild-install@7.1.3`. This is a cosmetic warning from a transitive dependency used to download SQLite prebuilt binaries. It does not affect functionality and is safe to ignore.
114
184
 
115
- ### Option 3: Manual Configuration
185
+ ### Option 3: Universal Thin Client (All Agents — ~80 Token Schema)
186
+
187
+ For maximum token efficiency across **any** MCP-compatible agent, use the universal thin client. It wraps Engram in a single `engram` tool with an ~80-token schema. BM25 routing handles action resolution internally.
188
+
189
+ **Cursor** (`~/.cursor/mcp.json`):
190
+ ```json
191
+ {
192
+ "mcpServers": {
193
+ "engram": {
194
+ "command": "npx",
195
+ "args": ["-y", "engram-universal-client", "--project-root", "/absolute/path/to/project"]
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ **VS Code Copilot** (`.vscode/mcp.json`):
202
+ ```json
203
+ {
204
+ "servers": {
205
+ "engram": {
206
+ "type": "stdio",
207
+ "command": "npx",
208
+ "args": ["-y", "engram-universal-client", "--project-root", "${workspaceFolder}"]
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ **Windsurf / Gemini CLI / any MCP agent** — same pattern, replace `--project-root` with your project path.
215
+
216
+ > The agent should call `engram({"action":"start"})` first. The response includes `tool_catalog` with all available actions.
217
+
218
+ ### Option 4: Manual Configuration
116
219
 
117
220
  If you prefer to configure manually, find your IDE below:
118
221
 
@@ -120,142 +223,166 @@ If you prefer to configure manually, find your IDE below:
120
223
  <summary><strong>Claude Code (CLI)</strong></summary>
121
224
 
122
225
  Run this in your terminal:
226
+
123
227
  ```bash
124
228
  claude mcp add-json --scope=user engram '{"type":"stdio","command":"cmd","args":["/c","npx","-y","engram-mcp-server"]}'
125
229
  ```
126
- *(Omit `"command":"cmd"` and `"args":["/c", ...]` on Mac/Linux, use just `"command":"npx"`).*
230
+
231
+ _(Omit `"command":"cmd"` and `"args":["/c", ...]` on Mac/Linux, use just `"command":"npx"`)._
232
+
127
233
  </details>
128
234
 
129
235
  <details>
130
236
  <summary><strong>Claude Desktop</strong></summary>
131
237
 
132
238
  Add to your `claude_desktop_config.json`:
239
+
133
240
  - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
134
241
  - **Mac:** `~/Library/Application Support/Claude/claude_desktop_config.json`
135
242
 
136
243
  ```json
137
244
  {
138
- "mcpServers": {
139
- "engram": {
140
- "command": "npx",
141
- "args": ["-y", "engram-mcp-server"]
245
+ "mcpServers": {
246
+ "engram": {
247
+ "command": "npx",
248
+ "args": ["-y", "engram-mcp-server"]
249
+ }
142
250
  }
143
- }
144
251
  }
145
252
  ```
253
+
146
254
  </details>
147
255
 
148
256
  <details>
149
257
  <summary><strong>VS Code (GitHub Copilot)</strong></summary>
150
258
 
151
259
  Create `.vscode/mcp.json` in your project root, or add to your global user `settings.json`:
260
+
152
261
  ```json
153
262
  {
154
- "servers": {
155
- "engram": {
156
- "type": "stdio",
157
- "command": "npx",
158
- "args": ["-y", "engram-mcp-server"]
263
+ "servers": {
264
+ "engram": {
265
+ "type": "stdio",
266
+ "command": "npx",
267
+ "args": ["-y", "engram-mcp-server"]
268
+ }
159
269
  }
160
- }
161
270
  }
162
271
  ```
272
+
163
273
  </details>
164
274
 
165
275
  <details>
166
276
  <summary><strong>Cursor & Windsurf</strong></summary>
167
277
 
168
278
  For Cursor, edit `~/.cursor/mcp.json`. For Windsurf, edit `~/.codeium/windsurf/mcp_config.json`:
279
+
169
280
  ```json
170
281
  {
171
- "mcpServers": {
172
- "engram": {
173
- "command": "npx",
174
- "args": ["-y", "engram-mcp-server"]
282
+ "mcpServers": {
283
+ "engram": {
284
+ "command": "npx",
285
+ "args": ["-y", "engram-mcp-server"]
286
+ }
175
287
  }
176
- }
177
288
  }
178
289
  ```
290
+
179
291
  </details>
180
292
 
181
293
  <details>
182
294
  <summary><strong>Visual Studio 2022/2026</strong></summary>
183
295
 
184
296
  Create `.vs/mcp.json` in your solution root:
297
+
185
298
  ```json
186
299
  {
187
- "mcpServers": {
188
- "engram": {
189
- "command": "npx",
190
- "args": ["-y", "engram-mcp-server"]
300
+ "mcpServers": {
301
+ "engram": {
302
+ "command": "npx",
303
+ "args": ["-y", "engram-mcp-server"]
304
+ }
191
305
  }
192
- }
193
306
  }
194
307
  ```
308
+
195
309
  </details>
196
310
 
197
311
  <details>
198
312
  <summary><strong>Trae IDE</strong></summary>
199
313
 
200
314
  For Trae IDE, edit `.trae/mcp.json` in your project root:
315
+
201
316
  ```json
202
317
  {
203
- "mcpServers": {
204
- "engram": {
205
- "type": "stdio",
206
- "command": "npx",
207
- "args": ["-y", "engram-mcp-server"]
318
+ "mcpServers": {
319
+ "engram": {
320
+ "type": "stdio",
321
+ "command": "npx",
322
+ "args": ["-y", "engram-mcp-server"]
323
+ }
208
324
  }
209
- }
210
325
  }
211
326
  ```
327
+
212
328
  </details>
213
329
 
214
330
  <details>
215
331
  <summary><strong>JetBrains (Copilot Plugin)</strong></summary>
216
332
 
217
333
  Edit `~/.config/github-copilot/intellij/mcp.json` or use the built-in Settings → MCP Server:
334
+
218
335
  ```json
219
336
  {
220
- "mcpServers": {
221
- "engram": {
222
- "command": "npx",
223
- "args": ["-y", "engram-mcp-server"]
337
+ "mcpServers": {
338
+ "engram": {
339
+ "command": "npx",
340
+ "args": ["-y", "engram-mcp-server"]
341
+ }
224
342
  }
225
- }
226
343
  }
227
344
  ```
345
+
228
346
  </details>
229
347
 
230
348
  <details>
231
349
  <summary><strong>Cline / Roo Code</strong></summary>
232
350
 
233
351
  In the extension settings → MCP Servers:
352
+
234
353
  ```json
235
354
  {
236
- "mcpServers": {
237
- "engram": {
238
- "command": "npx",
239
- "args": ["-y", "engram-mcp-server"]
355
+ "mcpServers": {
356
+ "engram": {
357
+ "command": "npx",
358
+ "args": ["-y", "engram-mcp-server"]
359
+ }
240
360
  }
241
- }
242
361
  }
243
362
  ```
363
+
244
364
  </details>
245
365
 
246
366
  ---
247
367
 
248
368
  ## Features
249
369
 
250
- - 🧠 **Session Continuity:** Each session automatically receives the previous session's summary, changes, decision, and full project context.
251
- - **Scheduled Events:** You can tell Engram to postpone tasks or remind you of things. Triggers include `next_session`, `datetime`, or `task_complete`.
252
- - 📝 **Change Tracking:** Records every file modification with context. Combines agent-recorded changes with `git` history. You can also set up Git hooks to auto-commit logs directly into Engram.
253
- - 🏗️ **Architectural Decision Records:** Logs design decisions with rationale, affected files, and tags forever.
254
- - 📁 **File Intelligence:** Stores per-file notes (purpose, deps, layer, complexity) preventing endless re-reads.
370
+ - 🧠 **Session Continuity:** Each session automatically receives the previous session's summary, changes, decisions, and full project context. Use the `focus` parameter to FTS5-rank all context around the topic you're about to work on. `suggested_focus` is returned automatically when no focus is provided.
371
+ - 🔐 **Trustworthy Context:** File notes track `file_mtime` and `git_branch` at write time. Returns `confidence` (`high`, `medium`, `stale`, `unknown`) and a `branch_warning` when the current branch differs from when notes were stored.
372
+ - 🔒 **Agent Safety:** `engram_memory(action:"lock_file")` / `unlock_file` prevent concurrent write conflicts. `begin_work` / `end_work` declare intent before touching files. Abandoned work from prior sessions surfaces in `start_session`.
373
+ - 🤖 **Multi-Agent Coordination:** Multiple agents collaborate simultaneously. Atomic task claiming prevents duplicates. `route_task` finds the best-matched agent. `agent_sync` tracks who is alive and their specializations.
374
+ - 🤝 **Session Handoffs:** `engram_session(action:"handoff")` packages context (tasks, files, git branch, instructions) for graceful agent-to-agent transfers. `acknowledge_handoff` clears the pending handoff.
375
+ - 🌡️ **Context Pressure Detection:** `engram_memory(action:"check_events")` fires at 50%/70%/85% context fill — giving agents advance warning before hitting the context wall.
376
+ - ⏰ **Scheduled Events:** Postpone tasks or set reminders. Triggers include `next_session`, `datetime`, or `task_complete`.
377
+ - 📝 **Change Tracking:** Records every file modification with context. Combines agent-recorded changes with `git` history. Git hook integration (`--install-hooks`) auto-records commits.
378
+ - 🏗️ **Architectural Decision Records:** Logs design decisions with rationale, affected files, and tags forever. `depends_on` field models prerequisite decision chains. FTS5 deduplication warns on similar existing decisions.
379
+ - 📁 **File Intelligence:** Stores per-file notes (purpose, deps, layer, complexity) with branch-aware staleness detection preventing endless re-reads.
255
380
  - 📐 **Convention Tracking:** Records and enforces project conventions (naming, testing, styling).
256
- - ✅ **Task Management:** Work items persist across sessions. Ask the agent to create a task for what's pending when you end a session.
257
- - 🔍 **Precise Full-Text Search (FTS5):** High-performance ranked search across all memory, with precise tag filtering using `json_each()`.
258
- - 💾 **Backup & Restore:** `engram_backup` creates timestamped SQLite copies to any path (like Dropbox/OneDrive) for seamless cross-machine portability.
381
+ - ✅ **Task Management:** Work items persist across sessions with priority, status, and multi-agent claiming. End-session warns on unclosed claimed tasks.
382
+ - 🔍 **Precise Full-Text Search (FTS5):** High-performance ranked search across all memory, with `context_chars` enrichment and per-result `confidence` levels for file note results.
383
+ - 🎬 **Session Replay:** Reconstructs the complete tool-call + change + decision timeline for any session via the `tool_call_log` table.
384
+ - 💾 **Backup & Restore:** `engram_admin(action:"backup")` creates timestamped SQLite copies to any path (like Dropbox/OneDrive) for cross-machine portability.
385
+ - 📊 **Reports, Stats & Commit Suggestions:** Generate Markdown project reports, per-agent activity metrics, and conventional commit messages from session data.
259
386
 
260
387
  ---
261
388
 
@@ -263,7 +390,9 @@ In the extension settings → MCP Servers:
263
390
 
264
391
  ```mermaid
265
392
  graph TB
266
- AI([AI Agent / IDE])
393
+ A1([Agent 1])
394
+ A2([Agent 2])
395
+ A3([Agent N])
267
396
  MCP([MCP Protocol Server])
268
397
  NPM([npm Registry / GitHub])
269
398
 
@@ -273,168 +402,388 @@ graph TB
273
402
  GS[Git Tracking Service]
274
403
  ES[Event Trigger Service]
275
404
  US[Update Service]
405
+ CO[Coordination Service]
276
406
  end
277
407
 
278
408
  subgraph Data Layer
279
- DB[(SQLite WAL)]
409
+ DB[(SQLite WAL\nProject DB)]
280
410
  FTS[FTS5 Search Index]
411
+ GDB[(Global KB\n~/.engram/global.db)]
281
412
  end
282
413
 
283
- AI <-->|JSON-RPC| MCP
284
- MCP --> TS & CS & GS & ES & US
285
- TS & CS & GS & ES --> DB
414
+ A1 & A2 & A3 <-->|JSON-RPC| MCP
415
+ MCP --> TS & CS & GS & ES & US & CO
416
+ TS & CS & GS & ES & CO --> DB
286
417
  US -->|async, fire-and-forget| NPM
287
418
  US --> DB
288
419
  DB --> FTS
420
+ MCP -->|export_global| GDB
421
+ MCP -->|get_global_knowledge| GDB
289
422
  ```
290
423
 
291
424
  ---
292
425
 
293
426
  ## Tools Reference
294
427
 
295
- Engram exposes 30+ tools. Here are the core highlights of what an agent can do for you:
296
-
297
- ### Core Memory Tools
298
- | Tool | Purpose |
299
- |------|---------|
300
- | `engram_start_session` | Begin a session, getting full context from previous work. |
301
- | `engram_end_session` | End session, providing a summary for the next time. |
302
- | `engram_record_change` | Record file changes with descriptions. |
303
- | `engram_set_file_notes` | Store intelligence about a file's purpose and complexity. |
304
- | `engram_record_decision` | Log an architectural decision and its rationale. |
305
-
306
- ### Tasks & Scheduling
307
- | Tool | Purpose |
308
- |------|---------|
309
- | `engram_create_task` | Create a persistent work item between sessions. |
310
- | `engram_schedule_event` | Schedule deferred work with a trigger (`next_session`, `datetime`, etc). |
311
- | `engram_check_events` | Mid-session check for triggered events that require attention. |
312
-
313
- ### Utilities
314
- | Tool | Purpose |
315
- |------|---------|
316
- | `engram_search` | FTS5-powered full-text search across all memories. |
317
- | `engram_scan_project` | Scan and cache project structure automatically. |
318
- | `engram_backup` | Create a database backup to any synced folder. |
319
- | `engram_config` | Read or update runtime configuration values. |
320
- | `engram_health` | Run database health checks and report diagnostics. |
321
-
322
- *(Run the agent and ask to list available tools for the complete reference).*
428
+ Engram v1.6.0 exposes **4 dispatcher tools**. Every operation routes through one of them via an `action` parameter. Token overhead is ~1,600 tokens — a ~95% reduction from the previous 50-tool surface.
429
+
430
+ > **Use `engram_find`** when you don't know the exact `action` name. It returns parameter schemas and descriptions for any operation.
431
+
432
+ ### `engram_session` — Session Lifecycle
433
+
434
+ | Action | Purpose |
435
+ | --------------------- | -------------------------------------------------------------------------------------------------------------- |
436
+ | `start` | Begin a session. Returns context, agent rules, tool catalog, handoff_pending, abandoned_work, suggested_focus. |
437
+ | `end` | End session with a summary. Warns on unclosed claimed tasks. |
438
+ | `get_history` | Retrieve past session summaries. |
439
+ | `handoff` | Package open tasks, git branch, and instructions for the next agent. |
440
+ | `acknowledge_handoff` | Clear a pending handoff from future start responses. |
441
+
442
+ ### `engram_memory` All Memory Operations
443
+
444
+ | Action | Purpose |
445
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
446
+ | `get_file_notes` | Retrieve file notes with `confidence` (hash-based staleness), `branch_warning`, `lock_status`, `executive_summary`. |
447
+ | `set_file_notes` | Store file intelligence (purpose, layer, complexity, dependencies, `executive_summary`, `content_hash`). |
448
+ | `set_file_notes_batch` | Store notes for multiple files atomically. |
449
+ | `record_change` | Log file changes with `change_type`, `description`, `impact_scope`, `diff_summary`. |
450
+ | `get_file_history` | Change history for a file. |
451
+ | `record_decision` | Log architectural decisions with `rationale`, `tags`, `affected_files`, `depends_on`, `supersedes`. |
452
+ | `record_decisions_batch` | Record multiple decisions atomically. |
453
+ | `get_decisions` | Retrieve decisions by status, tag, file, or dependency chain. |
454
+ | `update_decision` | Change decision status. Returns `cascade_warning` if dependents exist. |
455
+ | `add_convention` | Record a project convention. |
456
+ | `get_conventions` | Retrieve active conventions. |
457
+ | `create_task` | Create a persistent work item with priority, tags, and blocking chains. |
458
+ | `update_task` | Update task status, priority, description, or blocking. |
459
+ | `get_tasks` | Retrieve tasks by status, priority, or tag. |
460
+ | `checkpoint` | Save current understanding + progress to a persistent checkpoint. |
461
+ | `get_checkpoint` | Restore the last saved checkpoint. |
462
+ | `search` | FTS5-ranked full-text search across all memory. Results include `confidence`. |
463
+ | `what_changed` | Diff report of all changes since a given time or session. |
464
+ | `get_dependency_map` | File dependency graph for a module. |
465
+ | `record_milestone` | Log a project milestone. |
466
+ | `schedule_event` | Schedule deferred work with a trigger type. |
467
+ | `check_events` | Check triggered events including `context_pressure` at 50%/70%/85%. |
468
+ | `agent_sync` | Heartbeat — registers agent with optional `specializations[]`. Returns unread broadcasts. |
469
+ | `claim_task` | Atomically claim a task. Returns advisory `match_score` vs agent specializations. |
470
+ | `release_task` | Release a claimed task back to the pool. |
471
+ | `get_agents` | List all registered agents with status, last-seen, and specializations. |
472
+ | `route_task` | Find the best-matched agent for a task based on specialization scoring. |
473
+ | `broadcast` | Send a message to all agents. |
474
+ | `dump` | Auto-classify unstructured text into decisions, tasks, conventions, findings. |
475
+
476
+ ### `engram_admin` — Maintenance & Git Hooks
477
+
478
+ | Action | Purpose |
479
+ | --------------- | ---------------------------------------------------------- |
480
+ | `backup` | Create a database backup. |
481
+ | `restore` | Restore from a backup. |
482
+ | `list_backups` | List available backup files. |
483
+ | `export` | Export all memory to JSON. |
484
+ | `import` | Import from exported JSON. |
485
+ | `compact` | Compress old session data. |
486
+ | `clear` | Clear memory tables (destructive — requires confirmation). |
487
+ | `stats` | Project stats with per-agent contribution metrics. |
488
+ | `health` | Database health check and diagnostics. |
489
+ | `config` | Read or update runtime config values. |
490
+ | `scan_project` | Scan and cache project filesystem structure. |
491
+ | `install_hooks` | Write Engram post-commit git hook to `.git/hooks/`. |
492
+ | `remove_hooks` | Remove Engram hook from `.git/hooks/post-commit`. |
493
+
494
+ ### `engram_find` — Discovery & Linting
495
+
496
+ | Action | Purpose |
497
+ | -------------------- | --------------------------------------------------------------------------------------- |
498
+ | `search` _(default)_ | Search the tool catalog by keyword. Returns action name, description, and param schema. |
499
+ | `lint` | Check a code/text snippet against all active conventions. Returns `violations[]`. |
323
500
 
324
501
  ---
325
502
 
326
503
  ## Using with AI Agents
327
504
 
328
- Add the following to your agent's system prompt or custom instructions (Cursor Rules, `.github/copilot-instructions.md`, `CLAUDE.md`, etc.). The goal is to ensure the agent consults Engram *before* doing work not just after which is where most of the token and time savings come from.
505
+ Add the following to your agent's system prompt or custom instructions Cursor Rules, `.github/copilot-instructions.md`, `CLAUDE.md`, or whichever file your IDE reads. The goal is to make the agent consult Engram **before** doing work, not just after. That's where most of the token and time savings come from.
506
+
507
+ > You have access to **Engram**, a persistent memory MCP server. It stores everything learned about this project across all sessions: file notes, architectural decisions, conventions, tasks, and change history. Use it to avoid re-reading files already analysed, re-debating settled decisions, and re-discovering known context.
508
+
509
+ ---
510
+
511
+ ### 🟢 Session Start
329
512
 
330
- ```text
331
- You have access to Engram, a persistent memory MCP server. It stores everything
332
- learned about this project across all sessions: file notes, architectural decisions,
333
- conventions, tasks, and change history. Use it to avoid re-reading files you have
334
- already analysed, re-debating settled decisions, and re-discovering known context.
513
+ **Always call `engram_session(action:"start")` first** — before reading any file or taking any action. Pass `focus` when you know what you're about to work on — it FTS5-ranks returned context around that topic.
335
514
 
336
- ━━━ SESSION START ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
515
+ ```js
516
+ engram_session({
517
+ action: "start",
518
+ agent_name: "claude",
519
+ verbosity: "summary",
520
+ focus: "authentication refactor",
521
+ });
522
+ ```
337
523
 
338
- ALWAYS call engram_start_session first — before reading any file or taking any action.
339
524
  Act on everything it returns:
340
525
 
341
- previous_session.summary → Read this immediately. Do not re-explore what is already known.
342
- active_decisions → These are binding. Follow them; do not re-debate them.
343
- To change one, supersede it with a new engram_record_decision call.
344
- active_conventions → Enforce these in every file you touch this session.
345
- open_tasks → These are pending work items. Ask the user which to focus on if unclear.
346
- update_available (if set) Immediately tell the user:
347
- "Engram v{available_version} is available (you have {installed_version}).
348
- Changes: {changelog}
349
- Would you like to update, skip this version, or postpone?"
350
- Then act on their choice:
351
- Update → instruct them to run: npx -y engram-mcp-server install
352
- Skip → engram_config action=set key=auto_update_skip_version value={version}
353
- Postpone 7d engram_config action=set key=auto_update_remind_after value=7d
354
- Disable → engram_config action=set key=auto_update_check value=false
526
+ | Field | What to do |
527
+ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
528
+ | `previous_session.summary` | Read immediately. Do not re-explore what is already known. |
529
+ | `active_decisions` | Binding. Follow them; do not re-debate. Supersede with `engram_memory(action:"record_decision")` if they must change. |
530
+ | `active_conventions` | Enforce in every file you touch this session. |
531
+ | `open_tasks` | Pending work items. Ask the user which to focus on if unclear. |
532
+ | `abandoned_work` | Work items left open by a previous session that ended unexpectedly. Review and resume or close. |
533
+ | `handoff_pending` | A structured handoff from the previous agent. Read instructions, then call `engram_session(action:"acknowledge_handoff")`. |
534
+ | `suggested_focus` | Auto-derived topic hint. Pass as `focus` on the next `start` call for filtered context. |
535
+ | `triggered_events` | Scheduled reminders or deferred work now triggered. Act on them. |
536
+ | `agent_rules` | Live-loaded rules from the Engram README. Treat as binding session instructions. |
537
+ | `tool_catalog` | Full list of available `engram_memory` and `engram_admin` actions with schemas. |
538
+ | `update_available` | Tell the user: _"Engram v{available_version} is available. Update, skip, or postpone?"_ |
539
+
540
+ If `update_available` is set, respond to the user's choice:
541
+
542
+ - **Update** → `npx -y engram-mcp-server install`
543
+ - **Skip** → `engram_admin({ action: "config", op: "set", key: "auto_update_skip_version", value: "{version}" })`
544
+ - **Postpone** → `engram_admin({ action: "config", op: "set", key: "auto_update_remind_after", value: "7d" })`
545
+ - **Disable** → `engram_admin({ action: "config", op: "set", key: "auto_update_check", value: "false" })`
355
546
 
356
- ━━━ BEFORE READING OR REVIEWING ANY FILE ━━━━━━━━━━━━━━━━━━━
547
+ ---
357
548
 
358
- ALWAYS check Engram before opening a file:
549
+ ### 📂 Before Reading Any File
359
550
 
360
- engram_get_file_notes({ file_paths: ["path/to/file.ts"] })
551
+ Always check Engram before opening a file:
361
552
 
362
- If notes EXIST:
363
- Use the stored purpose, dependencies, layer, and complexity to answer
364
- questions or orient yourself WITHOUT reading the file.
365
- Only open the file when you need the actual source code for editing or
366
- a detailed line-by-line analysis.
553
+ ```js
554
+ engram_memory({ action: "get_file_notes", file_path: "path/to/file.ts" });
555
+ ```
367
556
 
368
- If notes DO NOT EXIST:
369
- 1. Read the file.
370
- 2. Immediately call engram_set_file_notes with:
371
- file_path, purpose, dependencies, dependents, layer, complexity, notes
372
- 3. For multiple files reviewed in one pass, batch them in a single call.
557
+ - **`confidence: "high"`** → Use stored notes. Only open the file if you need to edit it.
558
+ - **`confidence: "medium"`** → Notes exist but the file may have minor changes. Use as a guide; open if precision matters.
559
+ - **`confidence: "stale"`** → The file has changed significantly since notes were stored. Re-read and update notes.
560
+ - **No notes** → Read the file, then immediately call `engram_memory(action:"set_file_notes")` with `file_path`, `purpose`, `dependencies`, `dependents`, `layer`, `complexity`, `notes`. Batch multiple files with `set_file_notes_batch`.
373
561
 
374
- If notes are STALE (you see evidence the file changed significantly since
375
- the notes were last recorded — e.g., from git log or change history):
376
- Re-read the file and update the notes.
562
+ > **Rule:** Never read a file already analysed in a previous session without checking Engram first.
377
563
 
378
- Rule: Never read a file you have already analysed in a previous session
379
- without first checking whether Engram already knows it.
564
+ ---
380
565
 
381
- ━━━ BEFORE MAKING ANY DESIGN DECISION ━━━━━━━━━━━━━━━━━━━━━━
566
+ ### 🏛️ Before Making Any Design Decision
382
567
 
383
568
  Before choosing an implementation approach, search for an existing decision:
384
569
 
385
- engram_search({ query: "relevant keywords", scope: "decisions" })
570
+ ```js
571
+ engram_memory({
572
+ action: "search",
573
+ query: "relevant keywords",
574
+ scope: "decisions",
575
+ });
576
+ ```
386
577
 
387
- If a matching decision EXISTS follow it.
388
- If you believe it should change → explain why, then supersede it:
389
- engram_record_decision({ decision: "...", supersedes: <id> })
578
+ - **Decision exists**Follow it.
579
+ - **Should change**Explain why, then supersede:
580
+ ```js
581
+ engram_memory({ action: "record_decision", decision: "...", supersedes: <id> })
582
+ ```
583
+ - **No decision exists** → Make the call and record it:
584
+ ```js
585
+ engram_memory({
586
+ action: "record_decision",
587
+ decision,
588
+ rationale,
589
+ affected_files,
590
+ tags,
591
+ });
592
+ ```
390
593
 
391
- If NO decision exists → make the call and record it:
392
- engram_record_decision({ decision, rationale, affected_files, tags })
594
+ ---
393
595
 
394
- ━━━ WHEN MODIFYING FILES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
596
+ ### ✏️ When Modifying Files
395
597
 
396
598
  After every meaningful change, record it. Batch where possible:
397
599
 
398
- engram_record_change({ changes: [{
399
- file_path,
400
- change_type, // created | modified | refactored | deleted | renamed | moved | config_changed
401
- description, // What changed AND why — not just the action. Future sessions read this.
402
- impact_scope // local | module | cross_module | global
403
- }]})
600
+ ```js
601
+ engram_memory({
602
+ action: "record_change",
603
+ changes: [
604
+ {
605
+ file_path,
606
+ change_type, // created | modified | refactored | deleted | renamed | moved | config_changed
607
+ description, // What changed AND why — not just the action. Future sessions read this.
608
+ impact_scope, // local | module | cross_module | global
609
+ },
610
+ ],
611
+ });
612
+ ```
404
613
 
405
- ━━━ WHEN YOU DON'T KNOW SOMETHING ━━━━━━━━━━━━━━━━━━━━━━━━━━
614
+ ---
615
+
616
+ ### 🔍 When You Don't Know Something
406
617
 
407
- Before asking the user, search Engram first. The user may have already explained
408
- this to a previous session:
618
+ Search Engram before asking the user they may have already explained it to a previous session:
409
619
 
410
- engram_search({ query: "keywords" }) ← general search
411
- engram_scan_project() ← project structure questions
412
- engram_get_decisions() architecture / approach questions
413
- engram_get_conventions() style / pattern questions
414
- engram_get_file_notes({ file_paths: [] }) what is known about specific files
620
+ ```js
621
+ engram_memory({ action: "search", query: "keywords", context_chars: 200 });
622
+ engram_admin({ action: "scan_project" }); // project structure
623
+ engram_memory({ action: "get_decisions" }); // architecture questions
624
+ engram_memory({ action: "get_conventions" }); // style / pattern questions
625
+ engram_memory({ action: "get_file_notes", file_path: "..." }); // what is known about a file
626
+ engram_find({ query: "what I want to do" }); // discover the right action
627
+ ```
415
628
 
416
- ━━━ SESSION END ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
629
+ ---
630
+
631
+ ### 🔴 Session End
417
632
 
418
633
  Before ending every session:
419
634
 
420
- 1. Record all file changes not yet recorded (engram_record_change).
421
- 2. Create tasks for anything incomplete or blocked:
422
- engram_create_task({ title, description, priority })
423
- 3. Call engram_end_session with a summary that includes:
424
- • Exactly what was done — file names, function names, specific changes made
425
- What is pending or blocked, and why
426
- Any new patterns, gotchas, or constraints discovered this session
427
- Which tasks were completed or partially done
428
-
429
- A precise summary is what allows the next session to start immediately
430
- without re-reading files or re-asking the user for context.
635
+ 1. Record all file changes not yet recorded.
636
+ 2. Create tasks for anything incomplete or blocked:
637
+ ```js
638
+ engram_memory({ action: "create_task", title, description, priority });
639
+ ```
640
+ 3. Call `engram_session({ action: "end", summary: "..." })` with a summary that includes:
641
+ - Exactly what was done — file names, function names, specific changes
642
+ - What is pending or blocked, and why
643
+ - Any new patterns, gotchas, or constraints discovered
644
+ - Which tasks were completed or partially done
645
+
646
+ A precise summary is what allows the next session to start immediately without re-reading files or re-asking the user for context.
647
+
648
+ ---
649
+
650
+ ## Multi-Agent Workflows
651
+
652
+ When running multiple agents simultaneously on the same project, use the coordination tools to keep them in sync:
653
+
654
+ ### Agent Registration & Heartbeat
655
+
656
+ Each agent should call `agent_sync` periodically to stay visible and receive broadcasts:
657
+
658
+ ```js
659
+ // On startup and every ~2 minutes
660
+ engram_memory({
661
+ action: "agent_sync",
662
+ agent_id: "agent-frontend",
663
+ agent_name: "Frontend Specialist",
664
+ status: "working",
665
+ current_task_id: 42,
666
+ specializations: ["typescript", "react", "ui"], // ← new in v1.6.0
667
+ });
668
+ // Returns: { agent, unread_broadcasts: [...] }
431
669
  ```
432
670
 
671
+ ### Atomic Task Claiming
672
+
673
+ Use `claim_task` to safely grab a task without duplicating work. Returns advisory `match_score`:
674
+
675
+ ```js
676
+ engram_memory({
677
+ action: "claim_task",
678
+ task_id: 42,
679
+ agent_id: "agent-frontend",
680
+ });
681
+ // Returns: { task, match_score: 85, match_warning? }
682
+ ```
683
+
684
+ ### Find the Best Agent for a Task
685
+
686
+ ```js
687
+ engram_memory({ action: "route_task", task_id: 42 });
688
+ // Returns: { best_match: { agent_id, agent_name, match_score }, all_candidates: [...] }
689
+ ```
690
+
691
+ ### Broadcasting Between Agents
692
+
693
+ ```js
694
+ engram_memory({
695
+ action: "broadcast",
696
+ from_agent: "agent-backend",
697
+ message:
698
+ "⚠️ auth.ts API changed — agents touching auth endpoints need to update",
699
+ expires_in_minutes: 60,
700
+ });
701
+ ```
702
+
703
+ ### The `dump` Power Tool
704
+
705
+ ```js
706
+ engram_memory({
707
+ action: "dump",
708
+ raw_text: `
709
+ We decided to use JWT with 15-minute expiry.
710
+ TODO: add refresh token endpoint
711
+ Always use bcrypt cost factor 12.
712
+ `,
713
+ agent_id: "agent-research",
714
+ });
715
+ // Auto-classifies into decisions, tasks, conventions, findings
716
+ ```
717
+
718
+ ### Coordination Quick Reference
719
+
720
+ | Situation | Call |
721
+ | -------------------------- | --------------------------------------------------------- |
722
+ | Register / heartbeat | `engram_memory(action:"agent_sync")` |
723
+ | Find best agent for task | `engram_memory(action:"route_task", task_id)` |
724
+ | Claim a task atomically | `engram_memory(action:"claim_task", task_id, agent_id)` |
725
+ | Release a task | `engram_memory(action:"release_task", task_id, agent_id)` |
726
+ | List active agents | `engram_memory(action:"get_agents")` |
727
+ | Send a team message | `engram_memory(action:"broadcast", message, from_agent)` |
728
+ | Dump unstructured findings | `engram_memory(action:"dump", raw_text, agent_id)` |
729
+
730
+ ---
731
+
732
+ <!-- AGENT_RULES_START -->
733
+
734
+ ```json
735
+ [
736
+ {
737
+ "priority": "CRITICAL",
738
+ "rule": "Call engram_session(action:'start', verbosity:'summary') FIRST — before reading any file or taking any action."
739
+ },
740
+ {
741
+ "priority": "CRITICAL",
742
+ "rule": "Call engram_memory(action:'get_file_notes', file_path) before opening any file. Use notes to skip re-reading already-analysed files."
743
+ },
744
+ {
745
+ "priority": "CRITICAL",
746
+ "rule": "Call engram_memory(action:'record_change') after every file edit — changes, file_path, change_type, description, impact_scope."
747
+ },
748
+ {
749
+ "priority": "CRITICAL",
750
+ "rule": "Call engram_session(action:'end', summary) before terminating — be specific about what was done, what is pending, and any blockers."
751
+ },
752
+ {
753
+ "priority": "HIGH",
754
+ "rule": "Call engram_memory(action:'record_decision') for every architectural or design choice — even small ones."
755
+ },
756
+ {
757
+ "priority": "HIGH",
758
+ "rule": "Check engram_memory(action:'get_decisions') before starting any implementation to avoid contradicting existing decisions."
759
+ },
760
+ {
761
+ "priority": "HIGH",
762
+ "rule": "Use engram_find(query) when unsure which action to call — never guess parameter names."
763
+ },
764
+ {
765
+ "priority": "MEDIUM",
766
+ "rule": "Use engram_memory(action:'checkpoint') when approaching context limits — save current_understanding and progress before losing context."
767
+ },
768
+ {
769
+ "priority": "MEDIUM",
770
+ "rule": "Respect active_conventions returned by start_session — enforce them in every file touched this session."
771
+ },
772
+ {
773
+ "priority": "MEDIUM",
774
+ "rule": "Use verbosity:'nano' or 'minimal' for start_session when context is tight; use 'summary' (default) for normal sessions."
775
+ }
776
+ ]
777
+ ```
778
+
779
+ <!-- AGENT_RULES_END -->
780
+
433
781
  ---
434
782
 
435
783
  ## Contributing
436
784
 
437
785
  We welcome contributions!
786
+
438
787
  1. Fork the repo and create your branch (`git checkout -b feature/amazing-idea`).
439
788
  2. Install dependencies: `npm install`.
440
789
  3. Build the project: `npm run build`.
@@ -451,5 +800,5 @@ This project is licensed under the [MIT License](LICENSE).
451
800
 
452
801
  <div align="center">
453
802
  <em>Because your AI agent shouldn't have amnesia.</em><br/>
454
- <strong>Copyright &copy; 2026 Keggan Standard - Tanzania</strong>
803
+ <strong>Copyright &copy; 2026 Keggan Student - Tanzania</strong>
455
804
  </div>