@hbarefoot/engram 1.0.0 โ 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 +174 -425
- package/bin/engram.js +275 -90
- package/dashboard/dist/assets/index-D0xT6oKC.css +1 -0
- package/dashboard/dist/assets/index-D3bysGhj.js +45 -0
- package/dashboard/dist/engram-logo.png +0 -0
- package/dashboard/dist/favicon.png +0 -0
- package/dashboard/dist/index.html +3 -3
- package/package.json +19 -10
- package/src/embed/index.js +116 -16
- package/src/extract/secrets.js +1 -1
- package/src/import/index.js +259 -0
- package/src/import/parsers/claude.js +208 -0
- package/src/import/parsers/cursorrules.js +153 -0
- package/src/import/parsers/env.js +129 -0
- package/src/import/parsers/git.js +194 -0
- package/src/import/parsers/obsidian.js +219 -0
- package/src/import/parsers/package.js +177 -0
- package/src/import/parsers/shell.js +256 -0
- package/src/import/parsers/ssh.js +132 -0
- package/src/import/wizard.js +280 -0
- package/src/server/mcp.js +5 -1
- package/src/server/rest.js +152 -1
- package/src/utils/format.js +224 -0
- package/dashboard/dist/assets/index-BHkLa5w_.css +0 -1
- package/dashboard/dist/assets/index-D9QR_Cnu.js +0 -45
package/README.md
CHANGED
|
@@ -1,535 +1,284 @@
|
|
|
1
|
-
# Engram
|
|
1
|
+
# ๐ง Engram
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/HBarefoot/engram/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@hbarefoot/engram)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
[](https://modelcontextprotocol.io)
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
**Give your AI agents persistent memory. Zero cloud. Zero API keys. Two-minute setup.**
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
[](LICENSE)
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
- ๐ง **Hybrid Memory Retrieval** - Combines semantic similarity, recency, confidence, and access patterns
|
|
13
|
-
- ๐ **Full-Text Search** - SQLite FTS5 for fast keyword search
|
|
14
|
-
- ๐ฏ **Vector Embeddings** - Local embeddings with Xenova/all-MiniLM-L6-v2 (~23MB)
|
|
15
|
-
- ๐ **Secret Detection** - Automatic detection and redaction of API keys and credentials
|
|
16
|
-
- ๐งน **Auto-Consolidation** - Duplicate detection, contradiction flagging, confidence decay
|
|
17
|
-
- ๐ **Web Dashboard** - Modern React UI for visualizing and managing memories
|
|
18
|
-
- ๐ **MCP Server** - Model Context Protocol integration for Claude Desktop/Code
|
|
19
|
-
- ๐ **REST API** - Full-featured HTTP API with CORS support
|
|
20
|
-
- ๐ฆ **Zero Config** - Works out of the box with sensible defaults
|
|
21
|
-
|
|
22
|
-
## Quick Start
|
|
23
|
-
|
|
24
|
-
### Installation
|
|
11
|
+
Engram is a local-first memory server that lets AI agents like Claude, Cursor, Cline, and Windsurf remember things across sessions. It runs entirely on your machine โ no external services, no data leaving your device, no monthly bills.
|
|
25
12
|
|
|
26
13
|
```bash
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cd engram
|
|
30
|
-
|
|
31
|
-
# Install dependencies
|
|
32
|
-
npm install
|
|
33
|
-
|
|
34
|
-
# Start the server
|
|
35
|
-
npm start
|
|
14
|
+
npm install -g @hbarefoot/engram
|
|
15
|
+
engram start
|
|
36
16
|
```
|
|
37
17
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Basic Usage
|
|
18
|
+
That's it. Your AI agent now has long-term memory.
|
|
41
19
|
|
|
42
|
-
|
|
43
|
-
# Store a memory
|
|
44
|
-
engram remember "User prefers Fastify over Express for APIs" --category preference
|
|
45
|
-
|
|
46
|
-
# Search for memories
|
|
47
|
-
engram recall "What framework does the user prefer?"
|
|
20
|
+
---
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
engram list
|
|
22
|
+
## Why Engram?
|
|
51
23
|
|
|
52
|
-
|
|
53
|
-
engram status
|
|
54
|
-
```
|
|
24
|
+
Most AI memory solutions require cloud infrastructure, API keys, and external vector databases. Engram takes a different approach:
|
|
55
25
|
|
|
56
|
-
|
|
26
|
+
| | **Engram** | **Mem0** | **Zep** |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| **Setup time** | 2 minutes | Requires API keys + cloud setup | Requires Docker + API keys |
|
|
29
|
+
| **Dependencies** | None โ SQLite + local embeddings | OpenAI API, vector DB (Qdrant/Pinecone) | PostgreSQL, OpenAI API |
|
|
30
|
+
| **Data location** | Your machine only | Cloud (or self-hosted with infra) | Cloud (or self-hosted with infra) |
|
|
31
|
+
| **Cost** | Free forever | Pay per API call | Pay per API call |
|
|
32
|
+
| **Privacy** | Complete โ nothing leaves your device | Data sent to external APIs | Data sent to external APIs |
|
|
33
|
+
| **MCP native** | โ
First-class | โ REST only | โ REST only |
|
|
57
34
|
|
|
58
|
-
|
|
35
|
+
Engram is built for developers who want AI memory without the overhead.
|
|
59
36
|
|
|
60
|
-
|
|
37
|
+
---
|
|
61
38
|
|
|
62
|
-
|
|
63
|
-
# Remember something
|
|
64
|
-
node bin/engram.js remember "Project uses PostgreSQL 15" --category fact --entity postgresql
|
|
39
|
+
## Features
|
|
65
40
|
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
- ๐ **Fully Local** โ SQLite database + local embeddings ([all-MiniLM-L6-v2](https://huggingface.co/Xenova/all-MiniLM-L6-v2), 23 MB). No network calls, ever
|
|
42
|
+
- ๐ค **MCP Native** โ First-class Model Context Protocol integration. Works with Claude Desktop, Claude Code, Cline, Cursor, Windsurf, and any MCP client
|
|
43
|
+
- ๐ **Hybrid Search** โ Combines vector similarity with full-text search (FTS5) for accurate recall
|
|
44
|
+
- ๐งน **Smart Deduplication** โ Automatically detects and merges similar memories (>0.92 similarity threshold)
|
|
45
|
+
- ๐ **Feedback Loop** โ Rate memory usefulness to improve future recall accuracy
|
|
46
|
+
- ๐ **Secret Detection** โ Automatically blocks API keys, passwords, and tokens from being stored
|
|
47
|
+
- โฐ **Temporal Queries** โ Filter memories by time: "last week", "3 days ago", or exact dates
|
|
48
|
+
- ๐ฆ **Namespace Isolation** โ Organize memories by project, client, or any scope you need
|
|
49
|
+
- ๐ **REST API** โ Full HTTP API with CORS support for custom integrations
|
|
50
|
+
- ๐ฅ๏ธ **Web Dashboard** โ React-based UI for browsing, searching, and managing memories
|
|
51
|
+
- ๐พ **Export** โ Export memories to Markdown, JSON, or plain text for documentation
|
|
68
52
|
|
|
69
|
-
|
|
70
|
-
node bin/engram.js list --namespace project-alpha
|
|
53
|
+
---
|
|
71
54
|
|
|
72
|
-
|
|
73
|
-
node bin/engram.js forget <memory-id>
|
|
55
|
+
## Quick Start
|
|
74
56
|
|
|
75
|
-
|
|
76
|
-
node bin/engram.js consolidate
|
|
57
|
+
### 1. Install
|
|
77
58
|
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
```bash
|
|
60
|
+
npm install -g @hbarefoot/engram
|
|
80
61
|
```
|
|
81
62
|
|
|
82
|
-
### 2.
|
|
63
|
+
### 2. Start the server
|
|
83
64
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
```bash
|
|
66
|
+
engram start
|
|
67
|
+
```
|
|
87
68
|
|
|
88
|
-
|
|
89
|
-
2. Open http://localhost:5173 and go to the **Agents** tab
|
|
90
|
-
3. Click **Quick Setup** โ **Launch Setup Wizard**
|
|
91
|
-
4. Select your platform and copy the auto-generated configuration
|
|
69
|
+
### 3. Connect to your AI agent
|
|
92
70
|
|
|
93
|
-
|
|
71
|
+
Add Engram to your MCP client config:
|
|
94
72
|
|
|
95
|
-
**
|
|
73
|
+
**Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
96
74
|
|
|
97
75
|
```json
|
|
98
76
|
{
|
|
99
77
|
"mcpServers": {
|
|
100
78
|
"engram": {
|
|
101
|
-
"command": "
|
|
102
|
-
"args": [
|
|
103
|
-
"/path/to/engram/bin/engram.js",
|
|
104
|
-
"start",
|
|
105
|
-
"--mcp-only"
|
|
106
|
-
]
|
|
79
|
+
"command": "engram",
|
|
80
|
+
"args": ["start", "--mcp-only"]
|
|
107
81
|
}
|
|
108
82
|
}
|
|
109
83
|
}
|
|
110
84
|
```
|
|
111
85
|
|
|
112
|
-
**
|
|
113
|
-
- `engram_remember` - Store a memory
|
|
114
|
-
- `engram_recall` - Search for relevant memories
|
|
115
|
-
- `engram_forget` - Delete a memory
|
|
116
|
-
- `engram_status` - Get system status
|
|
117
|
-
|
|
118
|
-
See [docs/mcp-setup.md](docs/mcp-setup.md) for detailed configuration.
|
|
119
|
-
|
|
120
|
-
### 3. REST API
|
|
121
|
-
|
|
122
|
-
Full HTTP API for programmatic access:
|
|
86
|
+
**Claude Code:**
|
|
123
87
|
|
|
124
88
|
```bash
|
|
125
|
-
|
|
126
|
-
curl -X POST http://localhost:3838/api/memories \
|
|
127
|
-
-H "Content-Type: application/json" \
|
|
128
|
-
-d '{
|
|
129
|
-
"content": "User prefers Svelte for frontend",
|
|
130
|
-
"category": "preference",
|
|
131
|
-
"entity": "svelte",
|
|
132
|
-
"confidence": 0.9
|
|
133
|
-
}'
|
|
134
|
-
|
|
135
|
-
# Search memories
|
|
136
|
-
curl -X POST http://localhost:3838/api/memories/search \
|
|
137
|
-
-H "Content-Type: application/json" \
|
|
138
|
-
-d '{
|
|
139
|
-
"query": "frontend preferences",
|
|
140
|
-
"limit": 5
|
|
141
|
-
}'
|
|
142
|
-
|
|
143
|
-
# Get system status
|
|
144
|
-
curl http://localhost:3838/api/status
|
|
145
|
-
|
|
146
|
-
# List memories with filters
|
|
147
|
-
curl "http://localhost:3838/api/memories?namespace=default&limit=10"
|
|
148
|
-
|
|
149
|
-
# Delete a memory
|
|
150
|
-
curl -X DELETE http://localhost:3838/api/memories/<memory-id>
|
|
89
|
+
claude mcp add engram -- engram start --mcp-only
|
|
151
90
|
```
|
|
152
91
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
### 4. Web Dashboard
|
|
156
|
-
|
|
157
|
-
Visual interface for managing memories:
|
|
92
|
+
**Cline / Cursor / Windsurf:** Add the same MCP config to your editor's settings. Engram's built-in Integration Wizard can auto-detect your setup:
|
|
158
93
|
|
|
159
94
|
```bash
|
|
160
|
-
|
|
95
|
+
engram connect
|
|
161
96
|
```
|
|
162
97
|
|
|
163
|
-
|
|
98
|
+
### 4. Use it
|
|
164
99
|
|
|
165
|
-
|
|
166
|
-
- ๐ System overview with statistics
|
|
167
|
-
- ๐ Browse and filter memories
|
|
168
|
-
- ๐ Semantic search with score visualization
|
|
169
|
-
- โ Create new memories
|
|
170
|
-
- ๐๏ธ Delete memories
|
|
171
|
-
- ๐ View category and namespace distributions
|
|
172
|
-
- โ ๏ธ Detect and resolve conflicts
|
|
173
|
-
- ๐ Run consolidation
|
|
100
|
+
Once connected, your AI agent can store and recall memories naturally:
|
|
174
101
|
|
|
175
|
-
|
|
102
|
+
> **You:** "Remember that our API uses JWT tokens with 24-hour expiry"
|
|
103
|
+
>
|
|
104
|
+
> **Claude:** *stores the memory via `engram_remember`*
|
|
105
|
+
>
|
|
106
|
+
> **You:** (next day) "What authentication approach are we using?"
|
|
107
|
+
>
|
|
108
|
+
> **Claude:** *recalls via `engram_recall`* โ "Your API uses JWT tokens with 24-hour expiry."
|
|
176
109
|
|
|
177
|
-
|
|
110
|
+
Memories persist across sessions, restarts, and even different AI clients sharing the same Engram instance.
|
|
178
111
|
|
|
179
|
-
|
|
180
|
-
# Install PM2 globally (if not already installed)
|
|
181
|
-
npm install -g pm2
|
|
112
|
+
---
|
|
182
113
|
|
|
183
|
-
|
|
184
|
-
npm run pm2:start
|
|
114
|
+
## MCP Tools
|
|
185
115
|
|
|
186
|
-
|
|
187
|
-
npm run pm2:status
|
|
116
|
+
Engram exposes 6 tools to AI agents via the Model Context Protocol:
|
|
188
117
|
|
|
189
|
-
|
|
190
|
-
|
|
118
|
+
| Tool | Description |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `engram_remember` | Store a memory with category, entity, confidence, namespace, and tags |
|
|
121
|
+
| `engram_recall` | Retrieve relevant memories by semantic query with optional filters |
|
|
122
|
+
| `engram_forget` | Delete a specific memory by ID |
|
|
123
|
+
| `engram_feedback` | Rate a memory as helpful or unhelpful to improve future recall |
|
|
124
|
+
| `engram_context` | Generate a pre-formatted context block (markdown/xml/json) with token budget |
|
|
125
|
+
| `engram_status` | Health check with memory count, model status, and configuration info |
|
|
191
126
|
|
|
192
|
-
|
|
193
|
-
npm run pm2:restart
|
|
127
|
+
### Memory Categories
|
|
194
128
|
|
|
195
|
-
|
|
196
|
-
npm run pm2:stop
|
|
129
|
+
Memories are organized by type for better retrieval:
|
|
197
130
|
|
|
198
|
-
|
|
199
|
-
|
|
131
|
+
- **fact** โ Objective truths about setup, architecture, or configuration
|
|
132
|
+
- **preference** โ User likes, dislikes, and style choices
|
|
133
|
+
- **pattern** โ Recurring workflows and habits
|
|
134
|
+
- **decision** โ Choices made and the reasoning behind them
|
|
135
|
+
- **outcome** โ Results of actions taken
|
|
200
136
|
|
|
201
|
-
|
|
202
|
-
npm run pm2:monit
|
|
203
|
-
```
|
|
137
|
+
---
|
|
204
138
|
|
|
205
|
-
|
|
139
|
+
## CLI Reference
|
|
206
140
|
|
|
207
141
|
```bash
|
|
208
|
-
#
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
142
|
+
engram start # Start MCP + REST server
|
|
143
|
+
engram start --mcp-only # MCP server only (for agent integration)
|
|
144
|
+
engram start --port 3838 # Custom port for REST API
|
|
145
|
+
|
|
146
|
+
engram remember "content" # Store a memory from the command line
|
|
147
|
+
engram recall "query" # Search memories
|
|
148
|
+
engram forget <id> # Delete a memory
|
|
149
|
+
engram list # List all memories
|
|
150
|
+
engram status # Health check and stats
|
|
151
|
+
|
|
152
|
+
engram export # Export memories to JSON
|
|
153
|
+
engram import <file> # Import memories from file
|
|
154
|
+
engram consolidate # Run deduplication and cleanup
|
|
155
|
+
|
|
156
|
+
engram agents # List detected AI agents on your system
|
|
157
|
+
engram connect # Interactive setup wizard for MCP clients
|
|
213
158
|
```
|
|
214
159
|
|
|
215
|
-
|
|
160
|
+
---
|
|
216
161
|
|
|
217
|
-
##
|
|
162
|
+
## REST API
|
|
218
163
|
|
|
219
|
-
|
|
164
|
+
The REST API runs on `http://localhost:3838` by default.
|
|
220
165
|
|
|
221
|
-
|
|
166
|
+
| Endpoint | Method | Description |
|
|
167
|
+
|---|---|---|
|
|
168
|
+
| `/health` | GET | Health check |
|
|
169
|
+
| `/api/status` | GET | System status with stats |
|
|
170
|
+
| `/api/memories` | POST | Create a memory |
|
|
171
|
+
| `/api/memories` | GET | List memories (with pagination, category/namespace filters) |
|
|
172
|
+
| `/api/memories/search` | POST | Semantic search |
|
|
173
|
+
| `/api/memories/:id` | GET | Get a single memory |
|
|
174
|
+
| `/api/memories/:id` | DELETE | Delete a memory |
|
|
175
|
+
| `/api/consolidate` | POST | Run deduplication and cleanup |
|
|
176
|
+
| `/api/conflicts` | GET | Get detected memory conflicts |
|
|
222
177
|
|
|
223
|
-
|
|
224
|
-
- **fact** - Objective truth about their setup ("uses PostgreSQL 15")
|
|
225
|
-
- **pattern** - Recurring workflow ("always runs tests before commit")
|
|
226
|
-
- **decision** - Choice they made and why ("chose React for its ecosystem")
|
|
227
|
-
- **outcome** - Result of an action ("deployment succeeded after fixing port")
|
|
178
|
+
---
|
|
228
179
|
|
|
229
|
-
|
|
180
|
+
## Web Dashboard
|
|
230
181
|
|
|
231
|
-
|
|
182
|
+
Engram includes a built-in web dashboard at `http://localhost:3838` when running the full server:
|
|
232
183
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
184
|
+
- **Dashboard** โ Overview of memory stats and recent activity
|
|
185
|
+
- **Memory Browser** โ Browse, filter, and manage all stored memories
|
|
186
|
+
- **Search** โ Semantic search with similarity scores
|
|
187
|
+
- **Statistics** โ Charts and breakdowns by category, namespace, and time
|
|
188
|
+
- **Agents** โ Integration hub with a setup wizard for connecting MCP clients
|
|
236
189
|
|
|
237
|
-
|
|
238
|
-
- **Recency**: Time-based decay using last access time
|
|
239
|
-
- **Confidence**: User-specified or auto-calculated confidence (0-1)
|
|
240
|
-
- **Access**: Normalized access count (0-1, capped at 10 accesses)
|
|
241
|
-
- **FTS Boost**: +0.1 if found via full-text search
|
|
242
|
-
|
|
243
|
-
### Database Schema
|
|
244
|
-
|
|
245
|
-
```sql
|
|
246
|
-
CREATE TABLE memories (
|
|
247
|
-
id TEXT PRIMARY KEY,
|
|
248
|
-
content TEXT NOT NULL,
|
|
249
|
-
entity TEXT,
|
|
250
|
-
category TEXT DEFAULT 'fact',
|
|
251
|
-
confidence REAL DEFAULT 0.8,
|
|
252
|
-
embedding BLOB,
|
|
253
|
-
source TEXT,
|
|
254
|
-
namespace TEXT DEFAULT 'default',
|
|
255
|
-
tags TEXT, -- JSON array
|
|
256
|
-
access_count INTEGER DEFAULT 0,
|
|
257
|
-
decay_rate REAL DEFAULT 0.01,
|
|
258
|
-
created_at INTEGER NOT NULL,
|
|
259
|
-
updated_at INTEGER NOT NULL,
|
|
260
|
-
last_accessed INTEGER
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
-- FTS5 virtual table for full-text search
|
|
264
|
-
CREATE VIRTUAL TABLE memories_fts USING fts5(
|
|
265
|
-
content, entity, category, namespace,
|
|
266
|
-
content='memories', content_rowid='rowid'
|
|
267
|
-
);
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Configuration
|
|
271
|
-
|
|
272
|
-
Engram uses a YAML configuration file at `~/.engram/config.yml`:
|
|
190
|
+
---
|
|
273
191
|
|
|
274
|
-
|
|
275
|
-
dataDir: ~/.engram
|
|
276
|
-
port: 3838
|
|
192
|
+
## How It Works
|
|
277
193
|
|
|
278
|
-
|
|
279
|
-
namespace: default
|
|
280
|
-
recallLimit: 5
|
|
281
|
-
confidenceThreshold: 0.3
|
|
194
|
+
1. **Store**: When an AI agent calls `engram_remember`, the memory text is embedded locally using [all-MiniLM-L6-v2](https://huggingface.co/Xenova/all-MiniLM-L6-v2) (a 23 MB model that runs on CPU). The embedding and metadata are stored in a local SQLite database at `~/.engram/memory.db`.
|
|
282
195
|
|
|
283
|
-
|
|
284
|
-
secretDetection: true
|
|
196
|
+
2. **Recall**: When `engram_recall` is called, the query is embedded with the same model and matched against stored memories using cosine similarity. FTS5 keyword matching runs in parallel, and results are merged using a hybrid scoring algorithm.
|
|
285
197
|
|
|
286
|
-
|
|
287
|
-
duplicateThreshold: 0.92
|
|
288
|
-
decayEnabled: true
|
|
289
|
-
staleCleanupDays: 90
|
|
290
|
-
```
|
|
198
|
+
3. **Deduplicate**: Before storing, Engram checks existing memories for similarity. Exact duplicates (>0.95) are rejected. Near-duplicates (0.92โ0.95) are merged intelligently.
|
|
291
199
|
|
|
292
|
-
|
|
200
|
+
4. **Learn**: The `engram_feedback` tool lets agents mark memories as helpful or unhelpful. This adjusts confidence scores and influences future recall ranking.
|
|
293
201
|
|
|
294
|
-
|
|
202
|
+
5. **Protect**: Every memory passes through secret detection before storage. API keys, passwords, tokens, and other sensitive data are automatically blocked.
|
|
295
203
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
- OpenAI API keys (`sk-...`)
|
|
299
|
-
- Stripe keys (`pk_...`, `sk_live_...`)
|
|
300
|
-
- AWS keys (`AKIA...`)
|
|
301
|
-
- GitHub tokens (`ghp_...`, `gho_...`)
|
|
302
|
-
- Slack tokens (`xoxb-...`, `xoxp-...`)
|
|
303
|
-
- Google API keys (`AIza...`)
|
|
304
|
-
- Private keys (`BEGIN PRIVATE KEY`)
|
|
305
|
-
- Database connection strings
|
|
306
|
-
- JWT tokens
|
|
204
|
+
---
|
|
307
205
|
|
|
308
|
-
|
|
206
|
+
## Configuration
|
|
309
207
|
|
|
310
|
-
|
|
208
|
+
Engram stores its data and config in `~/.engram/`:
|
|
311
209
|
|
|
312
|
-
```bash
|
|
313
|
-
node bin/engram.js consolidate
|
|
314
210
|
```
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
- Applies confidence decay to old, unused memories
|
|
320
|
-
- Marks stale memories for review
|
|
321
|
-
|
|
322
|
-
### Namespaces
|
|
323
|
-
|
|
324
|
-
Organize memories by project or context:
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
# Create memories in different namespaces
|
|
328
|
-
engram remember "Uses Docker" --namespace project-alpha
|
|
329
|
-
engram remember "Prefers Kubernetes" --namespace project-beta
|
|
330
|
-
|
|
331
|
-
# Filter by namespace
|
|
332
|
-
engram list --namespace project-alpha
|
|
333
|
-
engram recall "container tech" --namespace project-alpha
|
|
211
|
+
~/.engram/
|
|
212
|
+
โโโ memory.db # SQLite database (memories + embeddings)
|
|
213
|
+
โโโ config.json # Server configuration
|
|
214
|
+
โโโ models/ # Cached embedding model (~23 MB)
|
|
334
215
|
```
|
|
335
216
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
### Project Structure
|
|
217
|
+
Default settings work out of the box. To customize:
|
|
339
218
|
|
|
340
|
-
```
|
|
341
|
-
engram/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
โ โ โโโ recall.js # Hybrid search
|
|
350
|
-
โ โ โโโ consolidate.js # Memory consolidation
|
|
351
|
-
โ โโโ embed/
|
|
352
|
-
โ โ โโโ index.js # Embedding generation
|
|
353
|
-
โ โโโ extract/
|
|
354
|
-
โ โ โโโ rules.js # Category/entity extraction
|
|
355
|
-
โ โ โโโ secrets.js # Secret detection
|
|
356
|
-
โ โโโ server/
|
|
357
|
-
โ โ โโโ mcp.js # MCP server
|
|
358
|
-
โ โ โโโ rest.js # REST API server
|
|
359
|
-
โ โโโ utils/
|
|
360
|
-
โ โโโ id.js # UUID generation
|
|
361
|
-
โ โโโ logger.js # Structured logging
|
|
362
|
-
โโโ dashboard/ # React web UI
|
|
363
|
-
โโโ test/ # Test suites
|
|
364
|
-
โโโ docs/ # Documentation
|
|
365
|
-
โโโ examples/ # Usage examples
|
|
219
|
+
```json
|
|
220
|
+
// ~/.engram/config.json
|
|
221
|
+
{
|
|
222
|
+
"port": 3838,
|
|
223
|
+
"defaultNamespace": "default",
|
|
224
|
+
"recallLimit": 5,
|
|
225
|
+
"confidenceThreshold": 0.3,
|
|
226
|
+
"secretDetection": true
|
|
227
|
+
}
|
|
366
228
|
```
|
|
367
229
|
|
|
368
|
-
|
|
230
|
+
---
|
|
369
231
|
|
|
370
|
-
|
|
371
|
-
# Run all tests
|
|
372
|
-
npm test
|
|
232
|
+
## Advanced Usage
|
|
373
233
|
|
|
374
|
-
|
|
375
|
-
npm run test:run
|
|
234
|
+
### Namespace Isolation
|
|
376
235
|
|
|
377
|
-
|
|
378
|
-
npx vitest test/memory/store.test.js
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Building
|
|
236
|
+
Organize memories by project or client:
|
|
382
237
|
|
|
383
238
|
```bash
|
|
384
|
-
#
|
|
385
|
-
|
|
386
|
-
|
|
239
|
+
# Store memories in different namespaces
|
|
240
|
+
engram remember "Uses Next.js 14 with app router" --namespace my-saas
|
|
241
|
+
engram remember "WordPress multisite with Redis cache" --namespace client-site
|
|
387
242
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
See [docs/api.md](docs/api.md) for complete REST API documentation.
|
|
391
|
-
|
|
392
|
-
### Key Endpoints
|
|
393
|
-
|
|
394
|
-
- `POST /api/memories` - Create memory
|
|
395
|
-
- `GET /api/memories` - List memories
|
|
396
|
-
- `POST /api/memories/search` - Search memories
|
|
397
|
-
- `GET /api/memories/:id` - Get single memory
|
|
398
|
-
- `DELETE /api/memories/:id` - Delete memory
|
|
399
|
-
- `POST /api/consolidate` - Run consolidation
|
|
400
|
-
- `GET /api/conflicts` - Get detected conflicts
|
|
401
|
-
- `GET /api/status` - System status
|
|
402
|
-
- `GET /health` - Health check
|
|
403
|
-
|
|
404
|
-
## Examples
|
|
405
|
-
|
|
406
|
-
### Example 1: Project Context Memory
|
|
407
|
-
|
|
408
|
-
```javascript
|
|
409
|
-
// Store project decisions
|
|
410
|
-
await api.createMemory({
|
|
411
|
-
content: "Chose Fastify over Express because of better TypeScript support and performance",
|
|
412
|
-
category: "decision",
|
|
413
|
-
entity: "fastify",
|
|
414
|
-
confidence: 1.0,
|
|
415
|
-
namespace: "project-api",
|
|
416
|
-
tags: ["backend", "framework"]
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
// Later, recall why you chose it
|
|
420
|
-
const results = await api.searchMemories("why did we choose Fastify?", {
|
|
421
|
-
namespace: "project-api",
|
|
422
|
-
limit: 3
|
|
423
|
-
});
|
|
243
|
+
# Recall searches within a namespace
|
|
244
|
+
engram recall "what framework?" --namespace my-saas
|
|
424
245
|
```
|
|
425
246
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
```javascript
|
|
429
|
-
// Store user preferences
|
|
430
|
-
await api.createMemory({
|
|
431
|
-
content: "User prefers compact code without unnecessary comments",
|
|
432
|
-
category: "preference",
|
|
433
|
-
entity: "coding-style",
|
|
434
|
-
confidence: 0.9
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
// Recall preferences before generating code
|
|
438
|
-
const prefs = await api.searchMemories("coding style preferences", {
|
|
439
|
-
category: "preference",
|
|
440
|
-
limit: 5
|
|
441
|
-
});
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
### Example 3: Infrastructure Facts
|
|
445
|
-
|
|
446
|
-
```javascript
|
|
447
|
-
// Document infrastructure
|
|
448
|
-
await api.createMemory({
|
|
449
|
-
content: "Production database is PostgreSQL 15 on AWS RDS (db.t3.medium)",
|
|
450
|
-
category: "fact",
|
|
451
|
-
entity: "postgresql",
|
|
452
|
-
namespace: "production"
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// Quick lookup
|
|
456
|
-
const infra = await api.searchMemories("production database", {
|
|
457
|
-
namespace: "production"
|
|
458
|
-
});
|
|
459
|
-
```
|
|
247
|
+
AI agents can use namespaces automatically โ just include the namespace parameter in `engram_remember` and `engram_recall` calls.
|
|
460
248
|
|
|
461
|
-
|
|
249
|
+
### Temporal Queries
|
|
462
250
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
- **Memory Storage**: ~1ms per memory (with embedding)
|
|
466
|
-
- **Recall Search**: ~10-50ms for 5 results (depends on database size)
|
|
467
|
-
- **Database Size**: ~2KB per memory (including embedding)
|
|
468
|
-
- **Embedding Model**: 23MB (downloaded on first use)
|
|
469
|
-
- **Memory Usage**: ~50MB base + loaded model
|
|
470
|
-
|
|
471
|
-
## Troubleshooting
|
|
472
|
-
|
|
473
|
-
### Embedding model not downloading
|
|
251
|
+
Filter memories by time:
|
|
474
252
|
|
|
475
253
|
```bash
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
ls -lh ~/.engram/models/
|
|
479
|
-
|
|
480
|
-
# Manual download if needed
|
|
481
|
-
mkdir -p ~/.engram/models
|
|
482
|
-
# The model will auto-download on first use
|
|
254
|
+
engram recall "deployment changes" --after "last week"
|
|
255
|
+
engram recall "API decisions" --after "2025-01-01" --before "2025-06-01"
|
|
483
256
|
```
|
|
484
257
|
|
|
485
|
-
###
|
|
258
|
+
### Export for Documentation
|
|
259
|
+
|
|
260
|
+
Export your project's memory as documentation:
|
|
486
261
|
|
|
487
262
|
```bash
|
|
488
|
-
|
|
489
|
-
|
|
263
|
+
engram export --format markdown --namespace my-project > PROJECT_CONTEXT.md
|
|
264
|
+
engram export --format json > memories-backup.json
|
|
490
265
|
```
|
|
491
266
|
|
|
492
|
-
|
|
267
|
+
---
|
|
493
268
|
|
|
494
|
-
|
|
495
|
-
# SQLite WAL mode should prevent this, but if it happens:
|
|
496
|
-
# Close all connections and restart
|
|
497
|
-
pkill -f "node bin/engram.js"
|
|
498
|
-
node bin/engram.js start
|
|
499
|
-
```
|
|
269
|
+
## Contributing
|
|
500
270
|
|
|
501
|
-
|
|
271
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
502
272
|
|
|
503
273
|
```bash
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
npm test
|
|
274
|
+
git clone https://github.com/HBarefoot/engram.git
|
|
275
|
+
cd engram
|
|
276
|
+
npm install
|
|
277
|
+
npm run dev
|
|
509
278
|
```
|
|
510
279
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
280
|
+
---
|
|
514
281
|
|
|
515
282
|
## License
|
|
516
283
|
|
|
517
|
-
MIT
|
|
518
|
-
|
|
519
|
-
## Acknowledgments
|
|
520
|
-
|
|
521
|
-
- Built with [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) for fast SQLite access
|
|
522
|
-
- Embeddings powered by [@xenova/transformers](https://github.com/xenova/transformers.js)
|
|
523
|
-
- REST API built with [Fastify](https://www.fastify.io/)
|
|
524
|
-
- Dashboard built with [React](https://react.dev/) and [Tailwind CSS](https://tailwindcss.com/)
|
|
525
|
-
- MCP integration via [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk)
|
|
526
|
-
|
|
527
|
-
## Support
|
|
528
|
-
|
|
529
|
-
- ๐ [Documentation](docs/)
|
|
530
|
-
- ๐ [Issue Tracker](https://github.com/your-username/engram/issues)
|
|
531
|
-
- ๐ฌ [Discussions](https://github.com/your-username/engram/discussions)
|
|
532
|
-
|
|
533
|
-
---
|
|
534
|
-
|
|
535
|
-
**Made with โค๏ธ for the AI agent community**
|
|
284
|
+
MIT ยฉ 2026 [HBarefoot](https://github.com/HBarefoot)
|