engram-mcp-server 1.2.0
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/README.md +645 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.js +81 -0
- package/dist/database.d.ts +30 -0
- package/dist/database.js +134 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +67 -0
- package/dist/migrations.d.ts +4 -0
- package/dist/migrations.js +342 -0
- package/dist/scripts/install-hooks.d.ts +3 -0
- package/dist/scripts/install-hooks.js +89 -0
- package/dist/tools/intelligence.d.ts +3 -0
- package/dist/tools/intelligence.js +427 -0
- package/dist/tools/maintenance.d.ts +3 -0
- package/dist/tools/maintenance.js +646 -0
- package/dist/tools/memory.d.ts +3 -0
- package/dist/tools/memory.js +446 -0
- package/dist/tools/scheduler.d.ts +3 -0
- package/dist/tools/scheduler.js +363 -0
- package/dist/tools/sessions.d.ts +3 -0
- package/dist/tools/sessions.js +355 -0
- package/dist/tools/tasks.d.ts +3 -0
- package/dist/tools/tasks.js +206 -0
- package/dist/types.d.ts +170 -0
- package/dist/types.js +5 -0
- package/dist/utils.d.ts +58 -0
- package/dist/utils.js +190 -0
- package/docs/scheduled-events.md +150 -0
- package/package.json +43 -0
- package/scripts/install-mcp.js +175 -0
- package/src/constants.ts +86 -0
- package/src/database.ts +162 -0
- package/src/index.ts +79 -0
- package/src/migrations.ts +367 -0
- package/src/scripts/install-hooks.ts +96 -0
- package/src/tools/intelligence.ts +469 -0
- package/src/tools/maintenance.ts +783 -0
- package/src/tools/memory.ts +543 -0
- package/src/tools/scheduler.ts +413 -0
- package/src/tools/sessions.ts +430 -0
- package/src/tools/tasks.ts +215 -0
- package/src/types.ts +267 -0
- package/src/utils.ts +216 -0
- package/tsconfig.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
# Engram
|
|
2
|
+
|
|
3
|
+
### Persistent Memory Cortex for AI Coding Agents
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Engram** is an MCP (Model Context Protocol) 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: what happened last time, what changed since, what decisions are active, what conventions to follow, and what tasks are pending.
|
|
8
|
+
|
|
9
|
+
Named after the [engram](https://en.wikipedia.org/wiki/Engram_(neuropsychology)) — the hypothetical means by which memory traces are stored in the brain — this server acts as the agent's long-term memory cortex.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Why Engram Exists
|
|
14
|
+
|
|
15
|
+
Every AI coding agent — GitHub Copilot, Claude Code, Cursor, Windsurf, Cline — is **stateless by default**. Each new session starts from scratch:
|
|
16
|
+
|
|
17
|
+
- The agent re-reads file structures and re-discovers architecture
|
|
18
|
+
- Architectural decisions made in previous sessions are forgotten
|
|
19
|
+
- The agent doesn't know what changed since it last worked
|
|
20
|
+
- Conventions agreed upon are lost
|
|
21
|
+
- Work-in-progress tasks have no continuity
|
|
22
|
+
- **Time, tokens, and patience are wasted on repeated discovery**
|
|
23
|
+
|
|
24
|
+
### The Vision
|
|
25
|
+
|
|
26
|
+
Engram was born out of a real frustration: watching AI agents in Visual Studio and other IDEs **review the same files over and over**, burning tokens and time on rediscovery instead of actual work. The idea is simple but powerful:
|
|
27
|
+
|
|
28
|
+
> **An AI agent should only need to deeply review a file once.** After that, it should *remember* — what the file does, how it's structured, what decisions shaped it, and exactly where things are. When the user asks to change something, the agent shouldn't re-read the entire codebase. It should already know where to go, review the specific area in detail, make the change, and remember how it left things for next time.
|
|
29
|
+
|
|
30
|
+
This is what Engram provides: a **persistent brain** that makes every session after the first one dramatically faster and more efficient.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Session 1 Session 2
|
|
34
|
+
┌──────────────────┐ ┌──────────────────────────────┐
|
|
35
|
+
│ Agent scans files │ │ engram_start_session() │
|
|
36
|
+
│ Agent reads code │ │ → "Last session: refactored │
|
|
37
|
+
│ Agent asks you │ Engram │ auth flow. 3 files │
|
|
38
|
+
│ about conventions │ ──────────→ │ changed since. Decision: │
|
|
39
|
+
│ Agent works... │ remembers │ use Compose Navigation. │
|
|
40
|
+
│ engram_end_session│ │ 2 tasks pending." │
|
|
41
|
+
│ "Refactored auth" │ │ │
|
|
42
|
+
└──────────────────┘ │ Agent already knows context. │
|
|
43
|
+
│ Starts working immediately. │
|
|
44
|
+
└──────────────────────────────┘
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## What's New in v1.2.0
|
|
50
|
+
|
|
51
|
+
### ⏰ Scheduled Events
|
|
52
|
+
Defer work to specific triggers — agents can now schedule events for the next session, a specific time, or after a task completes:
|
|
53
|
+
- **5 new tools**: `schedule_event`, `get_scheduled_events`, `update_scheduled_event`, `acknowledge_event`, `check_events`
|
|
54
|
+
- **4 trigger types**: `next_session`, `datetime`, `task_complete`, `manual`
|
|
55
|
+
- **Recurrence**: `every_session`, `daily`, `weekly` — fire repeatedly
|
|
56
|
+
- **Approval flow**: Events surface at session start → user reviews → agent executes
|
|
57
|
+
- See [`docs/scheduled-events.md`](docs/scheduled-events.md) for full documentation
|
|
58
|
+
|
|
59
|
+
### 🏷️ Precise Tag Filtering
|
|
60
|
+
Replaced imprecise `LIKE '%tag%'` matching with `json_each()` — searching for `auth` no longer matches `authentication` or `oauth`.
|
|
61
|
+
|
|
62
|
+
### 📦 Full Import/Export
|
|
63
|
+
`engram_import` now includes **sessions and changes** (previously skipped) with session ID mapping for FK consistency.
|
|
64
|
+
|
|
65
|
+
### 🚫 `.engramignore` Support
|
|
66
|
+
Create `.engramignore` in your project root to exclude custom directories from scanning (same format as `.gitignore`).
|
|
67
|
+
|
|
68
|
+
### 🔄 Auto-Scan on Session Start
|
|
69
|
+
`start_session` now automatically includes a cached project snapshot — agents no longer need to call `scan_project` manually.
|
|
70
|
+
|
|
71
|
+
### 📋 Git Hook Log Ingestion
|
|
72
|
+
Changes from `.engram/git-changes.log` (written by the post-commit hook) are now automatically parsed and surfaced at session start.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary><strong>v1.1.0 Changelog</strong></summary>
|
|
78
|
+
|
|
79
|
+
### 🚀 Native SQLite Engine (better-sqlite3)
|
|
80
|
+
Replaced the in-memory sql.js (WASM) engine with **better-sqlite3** — a native, file-backed SQLite driver with Write-Ahead Logging (WAL). This means:
|
|
81
|
+
- **No more loading the entire database into RAM** — reads and writes go directly to disk
|
|
82
|
+
- **WAL mode** enables concurrent reads while writing, dramatically improving responsiveness
|
|
83
|
+
- **No more full-database re-serialization** on every save — writes are incremental
|
|
84
|
+
- **3-5x faster** for typical operations
|
|
85
|
+
|
|
86
|
+
### 🔄 Schema Migration System
|
|
87
|
+
Version-aware, incremental database migrations that run automatically on startup:
|
|
88
|
+
- Safely evolves the schema without data loss
|
|
89
|
+
- Each migration runs in a transaction — if it fails, nothing changes
|
|
90
|
+
- Enables future features to add new tables/indexes without breaking existing databases
|
|
91
|
+
|
|
92
|
+
### 🔍 FTS5 Full-Text Search
|
|
93
|
+
Replaced slow `LIKE '%term%'` pattern matching with **FTS5** (SQLite's Full-Text Search 5):
|
|
94
|
+
- **10-100x faster** searches across sessions, changes, decisions, notes, conventions, and tasks
|
|
95
|
+
- Ranked results by relevance
|
|
96
|
+
- Auto-sync triggers keep FTS indexes current — zero maintenance
|
|
97
|
+
- Falls back to LIKE for backward compatibility
|
|
98
|
+
|
|
99
|
+
### 🛡️ Auto-Backup Before Destructive Operations
|
|
100
|
+
Before compaction or clearing memory, Engram automatically creates a backup copy of the database using SQLite's native backup API. No more accidental data loss.
|
|
101
|
+
|
|
102
|
+
### 💾 Backup & Restore System
|
|
103
|
+
New tools for cross-machine portability:
|
|
104
|
+
- **`engram_backup`** — Create timestamped backups to any path (including cloud-synced folders)
|
|
105
|
+
- **`engram_restore`** — Restore from a backup with automatic safety backup
|
|
106
|
+
- **`engram_list_backups`** — Browse available backups
|
|
107
|
+
- Auto-pruning keeps backup count under control
|
|
108
|
+
|
|
109
|
+
### 📊 Enhanced Statistics
|
|
110
|
+
`engram_stats` now reports schema version, database engine, and more detailed metrics.
|
|
111
|
+
|
|
112
|
+
### ⚙️ Configuration Table
|
|
113
|
+
Per-project settings for auto-compact threshold, data retention days, and max backup count.
|
|
114
|
+
|
|
115
|
+
### 📈 Better Indexing
|
|
116
|
+
Additional composite indexes for common query patterns — faster queries as data grows.
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Features
|
|
123
|
+
|
|
124
|
+
### 🧠 Session Continuity
|
|
125
|
+
Start and end sessions with summaries. Each new session automatically receives the previous session's summary, all changes since, and full project context.
|
|
126
|
+
|
|
127
|
+
### 📝 Change Tracking
|
|
128
|
+
Record every file modification with context. Combines agent-recorded changes with git history for a complete picture of what happened between sessions.
|
|
129
|
+
|
|
130
|
+
### 🏗️ Architectural Decision Records
|
|
131
|
+
Log design decisions with rationale, affected files, and tags. Decisions persist forever and are surfaced at session start. Supersede old decisions when architecture evolves.
|
|
132
|
+
|
|
133
|
+
### 📁 File Intelligence
|
|
134
|
+
Store per-file notes: purpose, dependencies, dependents, architectural layer, complexity rating, and gotchas. Eliminates the need to re-read and re-analyze files.
|
|
135
|
+
|
|
136
|
+
### 📐 Convention Tracking
|
|
137
|
+
Record project conventions (naming, architecture, styling, testing, etc.) that the agent should always follow. Enforced conventions are automatically surfaced at session start.
|
|
138
|
+
|
|
139
|
+
### ✅ Task Management
|
|
140
|
+
Create, update, and track work items across sessions. Tasks persist until completed — nothing falls through the cracks between sessions. Supports priorities, blocking relationships, and file assignments.
|
|
141
|
+
|
|
142
|
+
### 🔍 Full-Text Search (FTS5)
|
|
143
|
+
High-performance ranked search across everything: sessions, changes, decisions, file notes, conventions, and tasks. Find anything the agent has ever recorded — instantly.
|
|
144
|
+
|
|
145
|
+
### 🗺️ Project Scanning
|
|
146
|
+
Cached filesystem scanning with automatic architectural layer detection. The agent gets a structural overview without re-walking the directory tree.
|
|
147
|
+
|
|
148
|
+
### ⏰ Scheduled Events
|
|
149
|
+
Defer work to specific triggers — next session, a datetime, task completion, or manual check. Events fire automatically and require user approval before execution. Supports recurrence (daily, weekly, every session).
|
|
150
|
+
|
|
151
|
+
### 📊 Dependency Mapping
|
|
152
|
+
Track file dependencies and dependents. Understand the impact radius of changes before making them.
|
|
153
|
+
|
|
154
|
+
### 🏆 Milestones
|
|
155
|
+
Record major project achievements — feature completions, releases, major refactors. Build a project timeline.
|
|
156
|
+
|
|
157
|
+
### 💾 Backup & Restore
|
|
158
|
+
Create and restore database backups to any location. Save to cloud-synced folders for cross-machine portability.
|
|
159
|
+
|
|
160
|
+
### 📦 Export & Import
|
|
161
|
+
Export the entire memory as portable JSON. Import into another project or share knowledge with teammates. Sessions, changes, decisions, conventions, file notes, tasks, and milestones — all included.
|
|
162
|
+
|
|
163
|
+
### 🗜️ Memory Compaction
|
|
164
|
+
Automatically summarize old session data to keep the database lean while preserving important context. Now with auto-backup and age-based retention.
|
|
165
|
+
|
|
166
|
+
### 📈 Statistics Dashboard
|
|
167
|
+
See total sessions, changes, decisions, most-changed files, layer distribution, task status, schema version, and database size at a glance.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Tool Reference
|
|
172
|
+
|
|
173
|
+
| Tool | Purpose | Read-Only |
|
|
174
|
+
|------|---------|-----------|
|
|
175
|
+
| `engram_start_session` | Begin a session, get full context from previous session | No |
|
|
176
|
+
| `engram_end_session` | End session with summary for next time | No |
|
|
177
|
+
| `engram_get_session_history` | Browse past sessions | Yes |
|
|
178
|
+
| `engram_record_change` | Record file changes (supports bulk) | No |
|
|
179
|
+
| `engram_get_file_history` | Get a file's complete change history | Yes |
|
|
180
|
+
| `engram_record_decision` | Log an architectural decision | No |
|
|
181
|
+
| `engram_get_decisions` | Retrieve decisions by status/tag/file | Yes |
|
|
182
|
+
| `engram_update_decision` | Change decision status | No |
|
|
183
|
+
| `engram_set_file_notes` | Store per-file intelligence | No |
|
|
184
|
+
| `engram_get_file_notes` | Query file notes by path/layer/complexity | Yes |
|
|
185
|
+
| `engram_add_convention` | Record a project convention | No |
|
|
186
|
+
| `engram_get_conventions` | Get all active conventions | Yes |
|
|
187
|
+
| `engram_toggle_convention` | Enable/disable a convention | No |
|
|
188
|
+
| `engram_create_task` | Create a persistent work item | No |
|
|
189
|
+
| `engram_update_task` | Update task status/priority | No |
|
|
190
|
+
| `engram_get_tasks` | Query tasks with filters | Yes |
|
|
191
|
+
| `engram_scan_project` | Scan and cache project structure | No |
|
|
192
|
+
| `engram_search` | FTS5-powered search across all memory | Yes |
|
|
193
|
+
| `engram_what_changed` | Comprehensive diff report since a timestamp | Yes |
|
|
194
|
+
| `engram_get_dependency_map` | File dependency graph | Yes |
|
|
195
|
+
| `engram_record_milestone` | Record a project milestone | No |
|
|
196
|
+
| `engram_get_milestones` | Browse milestone timeline | Yes |
|
|
197
|
+
| `engram_stats` | Memory statistics dashboard | Yes |
|
|
198
|
+
| `engram_compact` | Compress old session data (auto-backup) | No |
|
|
199
|
+
| `engram_backup` | Create a database backup | No |
|
|
200
|
+
| `engram_restore` | Restore from a backup file | No |
|
|
201
|
+
| `engram_list_backups` | List available backups | Yes |
|
|
202
|
+
| `engram_export` | Export memory as JSON | Yes |
|
|
203
|
+
| `engram_import` | Import memory from JSON (full: sessions, changes, decisions, notes, etc.) | No |
|
|
204
|
+
| `engram_clear` | Clear memory (auto-backup, safety confirm) | No |
|
|
205
|
+
| `engram_schedule_event` | Schedule deferred work with a trigger | No |
|
|
206
|
+
| `engram_get_scheduled_events` | List/filter scheduled events | Yes |
|
|
207
|
+
| `engram_update_scheduled_event` | Cancel, snooze, or reschedule events | No |
|
|
208
|
+
| `engram_acknowledge_event` | Approve or decline a triggered event | No |
|
|
209
|
+
| `engram_check_events` | Mid-session check for triggered events | Yes |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Installation
|
|
214
|
+
|
|
215
|
+
### Prerequisites
|
|
216
|
+
- Node.js 18+ installed
|
|
217
|
+
- npm or yarn
|
|
218
|
+
|
|
219
|
+
### Setup
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Clone the repository
|
|
223
|
+
git clone git@github.com:keggan-std/Engram.git
|
|
224
|
+
cd Engram
|
|
225
|
+
|
|
226
|
+
# Install dependencies
|
|
227
|
+
npm install
|
|
228
|
+
|
|
229
|
+
# Build
|
|
230
|
+
npm run build
|
|
231
|
+
|
|
232
|
+
# (Optional) Install git hooks for automatic change tracking
|
|
233
|
+
npm run install-hooks
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Add to Your IDE — One Command
|
|
237
|
+
|
|
238
|
+
Run this after building to automatically add Engram to all supported IDEs detected on your machine:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npm run install-mcp
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
This detects and updates the MCP config for **Antigravity IDE, Cursor, VS Code, Cline, and Windsurf** — no manual path editing required. Just restart your IDE after.
|
|
245
|
+
|
|
246
|
+
To preview which IDEs were detected before installing:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
npm run install-mcp:list
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
To add to a specific IDE only:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
node scripts/install-mcp.js --ide antigravity
|
|
256
|
+
node scripts/install-mcp.js --ide cursor
|
|
257
|
+
node scripts/install-mcp.js --ide vscode
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Verify it works
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Test with MCP Inspector
|
|
264
|
+
npm run inspect
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Configuration
|
|
270
|
+
|
|
271
|
+
> [!TIP]
|
|
272
|
+
> **Quickest way**: Run `npm run install-mcp` after building — it auto-detects your IDEs and writes the config for you. Restart your IDE after.
|
|
273
|
+
|
|
274
|
+
If you prefer to configure manually, find your IDE below and paste the config snippet.
|
|
275
|
+
|
|
276
|
+
### Antigravity IDE
|
|
277
|
+
|
|
278
|
+
1. Click the **`...`** menu at the top of the Agent panel
|
|
279
|
+
2. Select **MCP Servers → Manage MCP Servers**
|
|
280
|
+
3. Click **"View raw config"**
|
|
281
|
+
4. Add the `engram` block inside `"mcpServers"`:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"mcpServers": {
|
|
286
|
+
"engram": {
|
|
287
|
+
"command": "node",
|
|
288
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"],
|
|
289
|
+
"env": {}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
5. Save and **restart Antigravity IDE**
|
|
296
|
+
|
|
297
|
+
> Replace `/absolute/path/to/Engram/dist/index.js` with the actual path on your machine — or just run `npm run install-mcp` and it's done automatically.
|
|
298
|
+
|
|
299
|
+
### Claude Code
|
|
300
|
+
|
|
301
|
+
Add to `~/.claude.json` or your project's `.claude/settings.json`:
|
|
302
|
+
|
|
303
|
+
```json
|
|
304
|
+
{
|
|
305
|
+
"mcpServers": {
|
|
306
|
+
"engram": {
|
|
307
|
+
"command": "node",
|
|
308
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Cursor
|
|
315
|
+
|
|
316
|
+
In Cursor Settings → Features → MCP Servers, add:
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"engram": {
|
|
321
|
+
"command": "node",
|
|
322
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### VS Code (with GitHub Copilot)
|
|
328
|
+
|
|
329
|
+
Create `.vscode/mcp.json` in your project root:
|
|
330
|
+
|
|
331
|
+
```json
|
|
332
|
+
{
|
|
333
|
+
"servers": {
|
|
334
|
+
"engram": {
|
|
335
|
+
"type": "stdio",
|
|
336
|
+
"command": "node",
|
|
337
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Or add to your user `settings.json` to make Engram available across all workspaces:
|
|
344
|
+
|
|
345
|
+
```json
|
|
346
|
+
{
|
|
347
|
+
"mcp": {
|
|
348
|
+
"servers": {
|
|
349
|
+
"engram": {
|
|
350
|
+
"type": "stdio",
|
|
351
|
+
"command": "node",
|
|
352
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Visual Studio 2022/2026
|
|
360
|
+
|
|
361
|
+
Create `.vs/mcp.json` in your solution root:
|
|
362
|
+
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"servers": {
|
|
366
|
+
"engram": {
|
|
367
|
+
"type": "stdio",
|
|
368
|
+
"command": "node",
|
|
369
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Or create a global config at `%USERPROFILE%\.mcp.json` (makes Engram available in all solutions):
|
|
376
|
+
|
|
377
|
+
```json
|
|
378
|
+
{
|
|
379
|
+
"servers": {
|
|
380
|
+
"engram": {
|
|
381
|
+
"type": "stdio",
|
|
382
|
+
"command": "node",
|
|
383
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
> **Note:** Server names in Visual Studio must not contain spaces.
|
|
390
|
+
|
|
391
|
+
### Cline / Roo Code
|
|
392
|
+
|
|
393
|
+
In the Cline extension settings → MCP Servers:
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"engram": {
|
|
398
|
+
"command": "node",
|
|
399
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"],
|
|
400
|
+
"disabled": false
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Windsurf
|
|
406
|
+
|
|
407
|
+
In Settings → MCP:
|
|
408
|
+
|
|
409
|
+
```json
|
|
410
|
+
{
|
|
411
|
+
"mcpServers": {
|
|
412
|
+
"engram": {
|
|
413
|
+
"command": "node",
|
|
414
|
+
"args": ["/absolute/path/to/Engram/dist/index.js"]
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## How It Works
|
|
423
|
+
|
|
424
|
+
### First Session
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
You: "Set up the project memory"
|
|
428
|
+
Agent: [calls engram_start_session]
|
|
429
|
+
→ "First session — no prior memory."
|
|
430
|
+
Agent: [calls engram_scan_project]
|
|
431
|
+
→ Builds file tree, detects layers
|
|
432
|
+
Agent: [calls engram_add_convention] × N
|
|
433
|
+
→ Records your project conventions
|
|
434
|
+
Agent: [calls engram_set_file_notes] × N
|
|
435
|
+
→ Documents key files
|
|
436
|
+
Agent: [works on your task...]
|
|
437
|
+
Agent: [calls engram_record_change] × N
|
|
438
|
+
→ Records what it changed
|
|
439
|
+
Agent: [calls engram_record_decision]
|
|
440
|
+
→ Logs architectural choices
|
|
441
|
+
Agent: [calls engram_end_session]
|
|
442
|
+
→ "Implemented auth flow with biometric support.
|
|
443
|
+
Pending: unit tests for BiometricViewModel."
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Every Session After
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
You: "Continue working on the auth feature"
|
|
450
|
+
Agent: [calls engram_start_session]
|
|
451
|
+
→ Receives:
|
|
452
|
+
- Previous summary: "Implemented auth flow..."
|
|
453
|
+
- Changes since: 2 files modified via git
|
|
454
|
+
- Decisions: "Use Compose Navigation", "MVVM pattern"
|
|
455
|
+
- Conventions: "All strings in strings.xml", etc.
|
|
456
|
+
- Open tasks: "Write unit tests for BiometricViewModel"
|
|
457
|
+
|
|
458
|
+
Agent already knows everything. No file scanning needed.
|
|
459
|
+
Starts working immediately on the pending tests.
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Moving to a New Machine
|
|
463
|
+
|
|
464
|
+
```
|
|
465
|
+
Old machine:
|
|
466
|
+
Agent: [calls engram_backup output_path="/path/to/cloud-sync/engram-backup.db"]
|
|
467
|
+
→ Backup saved to your cloud-synced folder
|
|
468
|
+
|
|
469
|
+
New machine:
|
|
470
|
+
Agent: [calls engram_restore input_path="/path/to/cloud-sync/engram-backup.db" confirm="yes-restore"]
|
|
471
|
+
→ Database restored. All memory intact.
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## Migration from v1.0.0
|
|
477
|
+
|
|
478
|
+
If you're upgrading from the original sql.js version:
|
|
479
|
+
|
|
480
|
+
1. **Your existing `.engram/memory.db` files are fully compatible** — the SQLite format is the same
|
|
481
|
+
2. **Run `npm install` to get the new dependencies** (better-sqlite3 replaces sql.js)
|
|
482
|
+
3. **Run `npm run build`**
|
|
483
|
+
4. The migration system will automatically upgrade your schema on first startup — adding FTS5 indexes, config table, and composite indexes
|
|
484
|
+
5. Your existing data is preserved and immediately searchable via FTS5
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## Environment Variables
|
|
489
|
+
|
|
490
|
+
| Variable | Purpose | Default |
|
|
491
|
+
|----------|---------|---------|
|
|
492
|
+
| `ENGRAM_PROJECT_ROOT` | Explicit project root path | Auto-detected |
|
|
493
|
+
| `PROJECT_ROOT` | Fallback project root path | Auto-detected |
|
|
494
|
+
| `ENGRAM_TRANSPORT` | Transport type (`stdio`) | `stdio` |
|
|
495
|
+
|
|
496
|
+
### Project Root Auto-Detection
|
|
497
|
+
|
|
498
|
+
If no environment variable is set, Engram walks up the directory tree from `cwd` looking for these markers: `.git`, `package.json`, `build.gradle`, `Cargo.toml`, `go.mod`, `pom.xml`, `.sln`, `pyproject.toml`, and others.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## Data Storage
|
|
503
|
+
|
|
504
|
+
All data is stored in `.engram/memory.db` (SQLite with WAL mode) inside your project root. This directory is automatically added to `.gitignore`.
|
|
505
|
+
|
|
506
|
+
### Database Engine
|
|
507
|
+
|
|
508
|
+
**v1.1.0+** uses `better-sqlite3` — a native, synchronous SQLite driver with:
|
|
509
|
+
- **WAL (Write-Ahead Logging)** — reads don't block writes
|
|
510
|
+
- **Direct file I/O** — no in-memory database or manual persistence
|
|
511
|
+
- **Native backup API** — consistent, safe backup copies
|
|
512
|
+
- **Full FTS5 support** — high-performance full-text search
|
|
513
|
+
|
|
514
|
+
### Schema
|
|
515
|
+
|
|
516
|
+
- **sessions** — Session lifecycle (start, end, summary, agent name)
|
|
517
|
+
- **changes** — File modifications with type, description, and impact scope
|
|
518
|
+
- **decisions** — Architectural decisions with rationale, tags, and status
|
|
519
|
+
- **file_notes** — Per-file intelligence (purpose, deps, layer, complexity)
|
|
520
|
+
- **conventions** — Project rules and coding standards
|
|
521
|
+
- **tasks** — Work items with priority, status, and assignments
|
|
522
|
+
- **milestones** — Project achievements and version markers
|
|
523
|
+
- **scheduled_events** — Deferred work items with trigger conditions
|
|
524
|
+
- **config** — Per-project settings
|
|
525
|
+
- **snapshot_cache** — Cached computed data with TTL
|
|
526
|
+
- **fts_*** — FTS5 virtual tables for full-text search (auto-maintained)
|
|
527
|
+
|
|
528
|
+
### Backup
|
|
529
|
+
|
|
530
|
+
**Native backup**: Use `engram_backup` to create timestamped copies using SQLite's backup API. Save to cloud-synced folders (Dropbox, OneDrive, Google Drive) for cross-machine portability.
|
|
531
|
+
|
|
532
|
+
**JSON export**: Use `engram_export` for a portable, human-readable JSON dump.
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
## System Prompt for AI Agents
|
|
537
|
+
|
|
538
|
+
To get the most out of Engram, **add this to your agent's system prompt** (or custom instructions). This tells the agent to use Engram automatically — without this, the agent won't know Engram exists.
|
|
539
|
+
|
|
540
|
+
```
|
|
541
|
+
You have access to Engram, a persistent memory MCP server. Follow these rules:
|
|
542
|
+
|
|
543
|
+
1. ALWAYS call engram_start_session at the very beginning of each conversation.
|
|
544
|
+
This loads your context: previous session summary, changes, decisions, conventions, and tasks.
|
|
545
|
+
|
|
546
|
+
2. After deeply reading a file for the first time, call engram_set_file_notes with:
|
|
547
|
+
purpose, dependencies, layer, and complexity. This means you won't need to re-read it next time.
|
|
548
|
+
|
|
549
|
+
3. After modifying files, call engram_record_change with file path, change type, and description.
|
|
550
|
+
Use bulk recording when changing multiple files.
|
|
551
|
+
|
|
552
|
+
4. When making architectural decisions, call engram_record_decision with the decision,
|
|
553
|
+
rationale, and affected files. This preserves the "why" for future sessions.
|
|
554
|
+
|
|
555
|
+
5. Before ending a conversation, call engram_end_session with a detailed summary
|
|
556
|
+
of what was accomplished and what's pending. This summary is the first thing
|
|
557
|
+
the next session will see.
|
|
558
|
+
|
|
559
|
+
6. If work is interrupted or partially complete, call engram_create_task to ensure
|
|
560
|
+
continuity. The next session will see open tasks automatically.
|
|
561
|
+
|
|
562
|
+
7. Use engram_search to find anything previously recorded — it uses fast full-text search.
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
You can paste this into your IDE's custom instructions:
|
|
566
|
+
- **Cursor**: Settings → Rules → User Rules
|
|
567
|
+
- **Claude Code**: `CLAUDE.md` or `~/.claude/CLAUDE.md`
|
|
568
|
+
- **Cline**: Custom instructions field in extension settings
|
|
569
|
+
- **VS Code Copilot**: `.github/copilot-instructions.md` or `.copilot-instructions.md`
|
|
570
|
+
- **Visual Studio**: `.github/copilot-instructions.md` or your GitHub Copilot custom instructions settings
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## Backup & Restore Guide
|
|
575
|
+
|
|
576
|
+
### Quick Backup (default location)
|
|
577
|
+
|
|
578
|
+
The agent calls `engram_backup` — creates a timestamped copy at `.engram/backups/memory-{timestamp}.db`. Old backups are auto-pruned to keep the 10 most recent.
|
|
579
|
+
|
|
580
|
+
### Backup to Cloud-Synced Folder
|
|
581
|
+
|
|
582
|
+
For cross-machine portability, back up to a folder that auto-syncs:
|
|
583
|
+
|
|
584
|
+
```
|
|
585
|
+
engram_backup output_path="C:/Users/you/Dropbox/engram-backups/myproject.db"
|
|
586
|
+
engram_backup output_path="C:/Users/you/OneDrive/engram-backups/myproject.db"
|
|
587
|
+
engram_backup output_path="/Users/you/Google Drive/engram-backups/myproject.db"
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### Restore on Another Machine
|
|
591
|
+
|
|
592
|
+
```
|
|
593
|
+
engram_restore input_path="C:/Users/you/Dropbox/engram-backups/myproject.db" confirm="yes-restore"
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
A safety backup of the current database is created automatically before overwriting. Restart the MCP server after restoring.
|
|
597
|
+
|
|
598
|
+
### List Available Backups
|
|
599
|
+
|
|
600
|
+
```
|
|
601
|
+
engram_list_backups
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
Shows all backup files with sizes and timestamps.
|
|
605
|
+
|
|
606
|
+
### JSON Export (Human-Readable)
|
|
607
|
+
|
|
608
|
+
```
|
|
609
|
+
engram_export output_path="./project-memory.json"
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
Produces a portable JSON dump you can inspect, share, or import into another project with `engram_import`.
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## Tips for Best Results
|
|
617
|
+
|
|
618
|
+
### What the agent does automatically
|
|
619
|
+
|
|
620
|
+
These happen without you doing anything, as long as the system prompt above is configured:
|
|
621
|
+
|
|
622
|
+
- **Session management** — starts and ends sessions with context and summaries
|
|
623
|
+
- **Change tracking** — records file modifications as it works
|
|
624
|
+
- **Decision logging** — captures "why" behind architectural choices
|
|
625
|
+
- **File intelligence** — stores notes about files it reads deeply
|
|
626
|
+
- **Convention tracking** — remembers project rules you agree on
|
|
627
|
+
- **Auto-compaction** — when completed sessions exceed the threshold (default: 50), Engram automatically compacts old data at session start, with a backup first
|
|
628
|
+
|
|
629
|
+
### What you should do
|
|
630
|
+
|
|
631
|
+
- **Add the system prompt** — without it, the agent won't use Engram at all. This is the single most important step.
|
|
632
|
+
- **Install git hooks** — run `npm run install-hooks` once. This tracks git commits even when the agent forgets to record changes.
|
|
633
|
+
- **Tell the agent to create tasks** — if you're stopping mid-work, say "create a task for what's pending" so the next session picks it up.
|
|
634
|
+
- **Set your backup destination** — tell the agent where to back up: "back up engram to my Dropbox folder." This enables cross-machine portability.
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
## License
|
|
639
|
+
|
|
640
|
+
MIT
|
|
641
|
+
|
|
642
|
+
---
|
|
643
|
+
|
|
644
|
+
*Engram: Because your AI agent shouldn't have amnesia.*
|
|
645
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const SERVER_NAME = "engram-mcp-server";
|
|
2
|
+
export declare const SERVER_VERSION = "1.2.0";
|
|
3
|
+
export declare const TOOL_PREFIX = "engram";
|
|
4
|
+
export declare const DB_DIR_NAME = ".engram";
|
|
5
|
+
export declare const DB_FILE_NAME = "memory.db";
|
|
6
|
+
export declare const DB_VERSION = 4;
|
|
7
|
+
export declare const MAX_FILE_TREE_DEPTH = 5;
|
|
8
|
+
export declare const MAX_FILE_TREE_ENTRIES = 500;
|
|
9
|
+
export declare const MAX_SEARCH_RESULTS = 50;
|
|
10
|
+
export declare const MAX_GIT_LOG_ENTRIES = 50;
|
|
11
|
+
export declare const MAX_RESPONSE_LENGTH = 50000;
|
|
12
|
+
export declare const DEFAULT_PAGINATION_LIMIT = 20;
|
|
13
|
+
export declare const SNAPSHOT_TTL_MINUTES = 30;
|
|
14
|
+
export declare const COMPACTION_THRESHOLD_SESSIONS = 50;
|
|
15
|
+
export declare const BACKUP_DIR_NAME = "backups";
|
|
16
|
+
export declare const DEFAULT_RETENTION_DAYS = 90;
|
|
17
|
+
export declare const MAX_BACKUP_COUNT = 10;
|
|
18
|
+
export declare const EXCLUDED_DIRS: Set<string>;
|
|
19
|
+
export declare const PROJECT_MARKERS: string[];
|
|
20
|
+
export declare const LAYER_PATTERNS: Record<string, RegExp[]>;
|
|
21
|
+
//# sourceMappingURL=constants.d.ts.map
|