@aman_asmuei/amem 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +272 -483
- package/dist/database.d.ts +51 -0
- package/dist/database.js +289 -0
- package/dist/database.js.map +1 -1
- package/dist/index.js +80 -7
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +321 -28
- package/dist/schemas.js +93 -0
- package/dist/schemas.js.map +1 -1
- package/dist/tools.js +787 -15
- package/dist/tools.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,637 +1,426 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="amem" width="160" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">amem</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Give your AI a memory it never forgets.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@aman_asmuei/amem"><img src="https://img.shields.io/npm/v/@aman_asmuei/amem?style=for-the-badge&logo=npm&logoColor=white&color=cb3837" alt="npm version" /></a>
|
|
13
|
+
|
|
14
|
+
<a href="https://github.com/amanasmuei/amem/actions"><img src="https://img.shields.io/github/actions/workflow/status/amanasmuei/amem/ci.yml?style=for-the-badge&logo=github&label=CI" alt="CI status" /></a>
|
|
15
|
+
|
|
16
|
+
<a href="https://github.com/amanasmuei/amem/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=for-the-badge" alt="MIT License" /></a>
|
|
17
|
+
|
|
18
|
+
<img src="https://img.shields.io/badge/MCP-compatible-8A2BE2?style=for-the-badge" alt="MCP compatible" />
|
|
19
|
+
|
|
20
|
+
<img src="https://img.shields.io/badge/node-%E2%89%A518-brightgreen?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js 18+" />
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<b>amem</b> (<b>A</b>man's <b>Mem</b>ory) is a persistent memory layer for AI coding tools.<br/>
|
|
25
|
+
Local-first · Semantic · Lossless · Works with Claude Code, Cursor, Windsurf & any MCP client.
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="#-quick-start">Quick Start</a> •
|
|
30
|
+
<a href="#-features">Features</a> •
|
|
31
|
+
<a href="#-tools-reference">Tools</a> •
|
|
32
|
+
<a href="#-usage-examples">Examples</a> •
|
|
33
|
+
<a href="#-architecture">Architecture</a> •
|
|
34
|
+
<a href="#-contributing">Contributing</a>
|
|
35
|
+
</p>
|
|
19
36
|
|
|
20
37
|
---
|
|
21
38
|
|
|
22
39
|
## The Problem
|
|
23
40
|
|
|
24
|
-
Every time you start a new conversation with an AI coding assistant, it starts from zero.
|
|
41
|
+
Every time you start a new conversation with an AI coding assistant, it starts from zero.
|
|
25
42
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
> *"Don't use `any` in TypeScript"* — told it **three times**, still does it.
|
|
44
|
+
>
|
|
45
|
+
> *"We chose PostgreSQL over MongoDB"* — doesn't remember why.
|
|
46
|
+
>
|
|
47
|
+
> *"I prefer early returns and pnpm"* — explained again. And again.
|
|
48
|
+
>
|
|
49
|
+
> A critical decision from **last week**? Gone.
|
|
30
50
|
|
|
31
|
-
You
|
|
51
|
+
**You repeat yourself. Every. Single. Session.**
|
|
32
52
|
|
|
33
53
|
## The Solution
|
|
34
54
|
|
|
35
|
-
**amem**
|
|
55
|
+
**amem** plugs into any MCP-compatible AI tool and gives it persistent, searchable, lossless memory.
|
|
36
56
|
|
|
37
57
|
```
|
|
38
58
|
You: "Don't use any type in TypeScript"
|
|
39
59
|
|
|
40
|
-
amem
|
|
41
|
-
|
|
60
|
+
amem stores this as a correction (priority 1.0)
|
|
61
|
+
next session, your AI already knows
|
|
42
62
|
```
|
|
43
63
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## What Gets Remembered
|
|
47
|
-
|
|
48
|
-
amem organizes memories into six types, ranked by importance:
|
|
49
|
-
|
|
50
|
-
| Priority | Type | What it captures | Example |
|
|
51
|
-
|:--------:|------|-----------------|---------|
|
|
52
|
-
| 1.0 | **Correction** | Mistakes to never repeat | *"Don't mock the database in integration tests"* |
|
|
53
|
-
| 0.85 | **Decision** | Architectural choices + why | *"Chose Postgres over MongoDB for ACID compliance"* |
|
|
54
|
-
| 0.7 | **Pattern** | Coding style & habits | *"Prefers early returns over nested conditionals"* |
|
|
55
|
-
| 0.7 | **Preference** | Tool & workflow choices | *"Uses pnpm, not npm"* |
|
|
56
|
-
| 0.5 | **Topology** | Where things are | *"Auth module lives in src/auth/, uses JWT"* |
|
|
57
|
-
| 0.4 | **Fact** | General project knowledge | *"API uses REST, launched January 2025"* |
|
|
58
|
-
|
|
59
|
-
Corrections always surface first. They're the "never do this" rules your AI should always follow.
|
|
64
|
+
No cloud. No API keys. Everything stays on your machine.
|
|
60
65
|
|
|
61
66
|
---
|
|
62
67
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
### Step 1: Install
|
|
68
|
+
## Quick Start
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
### 1. Install
|
|
68
71
|
|
|
69
72
|
```bash
|
|
70
73
|
npm install -g @aman_asmuei/amem
|
|
71
74
|
```
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
### 2. Connect
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
<details open>
|
|
79
|
+
<summary><strong>Claude Code</strong> (one command)</summary>
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Add to `~/.claude/settings.json`:
|
|
81
|
-
|
|
82
|
-
```json
|
|
83
|
-
{
|
|
84
|
-
"mcpServers": {
|
|
85
|
-
"amem": {
|
|
86
|
-
"command": "amem"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
81
|
+
```bash
|
|
82
|
+
claude mcp add amem -- npx -y @aman_asmuei/amem
|
|
90
83
|
```
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
</details>
|
|
95
|
-
|
|
96
|
-
<details>
|
|
97
|
-
<summary><strong>Cursor</strong></summary>
|
|
98
|
-
|
|
99
|
-
Add to `.cursor/mcp.json` in your project:
|
|
85
|
+
Or add to `~/.claude/settings.json`:
|
|
100
86
|
|
|
101
87
|
```json
|
|
102
88
|
{
|
|
103
89
|
"mcpServers": {
|
|
104
90
|
"amem": {
|
|
105
|
-
"command": "
|
|
91
|
+
"command": "npx",
|
|
92
|
+
"args": ["-y", "@aman_asmuei/amem"]
|
|
106
93
|
}
|
|
107
94
|
}
|
|
108
95
|
}
|
|
109
96
|
```
|
|
110
97
|
|
|
111
|
-
Restart Cursor.
|
|
112
|
-
|
|
113
98
|
</details>
|
|
114
99
|
|
|
115
100
|
<details>
|
|
116
|
-
<summary><strong>Windsurf</strong></summary>
|
|
117
|
-
|
|
118
|
-
Add to your MCP configuration:
|
|
101
|
+
<summary><strong>Cursor / Windsurf / Other MCP Clients</strong></summary>
|
|
119
102
|
|
|
120
103
|
```json
|
|
121
104
|
{
|
|
122
105
|
"mcpServers": {
|
|
123
|
-
"amem": {
|
|
124
|
-
"command": "amem"
|
|
125
|
-
}
|
|
106
|
+
"amem": { "command": "amem" }
|
|
126
107
|
}
|
|
127
108
|
}
|
|
128
109
|
```
|
|
129
110
|
|
|
130
111
|
</details>
|
|
131
112
|
|
|
132
|
-
|
|
133
|
-
<summary><strong>Any other MCP client</strong></summary>
|
|
113
|
+
### 3. Use
|
|
134
114
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
npx @aman_asmuei/amem
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
</details>
|
|
142
|
-
|
|
143
|
-
### Step 3: Start talking
|
|
144
|
-
|
|
145
|
-
That's it. Your AI now has memory tools. Ask it to remember something:
|
|
146
|
-
|
|
147
|
-
> *"Remember that we use Tailwind with a custom theme in this project."*
|
|
148
|
-
|
|
149
|
-
Next conversation, ask:
|
|
150
|
-
|
|
151
|
-
> *"What CSS framework do we use?"*
|
|
152
|
-
|
|
153
|
-
It knows.
|
|
115
|
+
Restart your AI tool — you'll see **15 tools**, **6 resources**, and **2 prompts** ready to go.
|
|
154
116
|
|
|
155
117
|
---
|
|
156
118
|
|
|
157
|
-
##
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
┌──────────────────────────────────┐
|
|
161
|
-
│ Your AI Tool │
|
|
162
|
-
│ Claude · Cursor · Windsurf │
|
|
163
|
-
└──────────┬───────────────────────┘
|
|
164
|
-
│
|
|
165
|
-
MCP Protocol (stdio)
|
|
166
|
-
│
|
|
167
|
-
┌──────────▼───────────────────────┐
|
|
168
|
-
│ amem-mcp-server │
|
|
169
|
-
│ │
|
|
170
|
-
│ 9 Tools · 4 Resources · 2 Prompts
|
|
171
|
-
│ │
|
|
172
|
-
│ Store → Score → Deduplicate │
|
|
173
|
-
│ Recall → Rank → Surface │
|
|
174
|
-
│ │
|
|
175
|
-
│ ┌────────────────────────────┐ │
|
|
176
|
-
│ │ SQLite + Local Embeddings │ │
|
|
177
|
-
│ │ ~/.amem/memory.db │ │
|
|
178
|
-
│ └────────────────────────────┘ │
|
|
179
|
-
└──────────────────────────────────┘
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
**Everything stays on your machine.** No cloud. No API keys. No data leaving your laptop.
|
|
183
|
-
|
|
184
|
-
### Smart ranking
|
|
119
|
+
## Features
|
|
185
120
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
score = relevance × recency × confidence × importance
|
|
190
|
-
```
|
|
121
|
+
### v0.4.0
|
|
191
122
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
123
|
+
| | Feature | Description |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| **NEW** | Lossless conversation log | `memory_log` / `memory_log_recall` — append-only raw turns, nothing summarized or lost |
|
|
126
|
+
| **NEW** | Patch system | `memory_patch` — surgical field-level edits with auto-versioning |
|
|
127
|
+
| **NEW** | Version history | `memory_versions` — immutable snapshots, restore any past state |
|
|
128
|
+
| **NEW** | Knowledge graph | `memory_relate` — typed bidirectional relations between memories |
|
|
129
|
+
| **NEW** | Temporal queries | `memory_since` — natural language time ranges (`7d`, `2w`, `1h`) |
|
|
130
|
+
| **NEW** | Full-text search | `memory_search` — FTS5 exact match, auto-synced on every write |
|
|
196
131
|
|
|
197
|
-
|
|
132
|
+
<details>
|
|
133
|
+
<summary><strong>View all features across versions</strong></summary>
|
|
198
134
|
|
|
199
|
-
|
|
135
|
+
### v0.3.0
|
|
200
136
|
|
|
201
|
-
-
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
- **No match** — Stores as new
|
|
137
|
+
- Memory consolidation engine (merge, prune, promote)
|
|
138
|
+
- Project detection and scope-aware filtering
|
|
139
|
+
- Auto-migration for scope fields
|
|
205
140
|
|
|
206
|
-
###
|
|
141
|
+
### v0.2.0
|
|
207
142
|
|
|
208
|
-
|
|
143
|
+
- Structured output with Zod schemas
|
|
144
|
+
- `memory_inject` for proactive context surfacing
|
|
145
|
+
- Evaluation suite
|
|
209
146
|
|
|
210
|
-
###
|
|
147
|
+
### v0.1.0
|
|
211
148
|
|
|
212
|
-
|
|
149
|
+
- Core memory store/recall with semantic search
|
|
150
|
+
- Local embeddings (HuggingFace all-MiniLM-L6-v2)
|
|
151
|
+
- SQLite persistence with WAL mode
|
|
152
|
+
- MCP resources and prompts
|
|
213
153
|
|
|
214
|
-
|
|
215
|
-
- **Prune** — Stale memories (>60 days inactive, low confidence, rarely accessed) are removed. Corrections are **never** pruned.
|
|
216
|
-
- **Promote** — Memories accessed 5+ times with low confidence get promoted to 90% confidence.
|
|
217
|
-
- **Health score** — After consolidation, you get a 0-100 health score (signal-to-noise ratio).
|
|
154
|
+
</details>
|
|
218
155
|
|
|
219
|
-
|
|
156
|
+
---
|
|
220
157
|
|
|
221
|
-
|
|
158
|
+
## Memory Types
|
|
222
159
|
|
|
223
|
-
Memories
|
|
160
|
+
Memories are scored and prioritized automatically:
|
|
224
161
|
|
|
225
|
-
|
|
226
|
-
|
|
162
|
+
| Priority | Type | Example |
|
|
163
|
+
|:---:|---|---|
|
|
164
|
+
| `1.0` | **correction** | *"Don't mock the DB in integration tests"* |
|
|
165
|
+
| `0.85` | **decision** | *"Chose Postgres over Mongo for ACID compliance"* |
|
|
166
|
+
| `0.7` | **pattern** | *"Prefers early returns over nested conditionals"* |
|
|
167
|
+
| `0.7` | **preference** | *"Uses pnpm, not npm"* |
|
|
168
|
+
| `0.5` | **topology** | *"Auth module lives in src/auth/, uses JWT"* |
|
|
169
|
+
| `0.4` | **fact** | *"API uses REST, launched January 2025"* |
|
|
227
170
|
|
|
228
|
-
|
|
171
|
+
> **Corrections always surface first.** They are your AI's hard constraints.
|
|
229
172
|
|
|
230
173
|
---
|
|
231
174
|
|
|
232
|
-
## Tools
|
|
175
|
+
## Tools Reference
|
|
233
176
|
|
|
234
|
-
|
|
177
|
+
### Core Memory
|
|
235
178
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
179
|
+
| Tool | Description |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `memory_store` | Store a memory with type, tags, and confidence |
|
|
182
|
+
| `memory_recall` | Semantic search — natural language, ranked by relevance |
|
|
183
|
+
| `memory_context` | Load all relevant context for a topic, organized by type |
|
|
184
|
+
| `memory_extract` | Batch-save multiple memories from a conversation |
|
|
185
|
+
| `memory_forget` | Delete memories by ID or query (confirmation required) |
|
|
186
|
+
| `memory_inject` | Proactively surface corrections + decisions before coding |
|
|
239
187
|
|
|
240
|
-
###
|
|
188
|
+
### Precision & History
|
|
241
189
|
|
|
242
|
-
| Tool |
|
|
243
|
-
|
|
244
|
-
| `
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `memory_inject` | Proactively inject corrections + decisions for a topic (use before coding) | read-only, idempotent |
|
|
190
|
+
| Tool | Description |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `memory_patch` | Surgical field-level edit with auto-snapshot |
|
|
193
|
+
| `memory_versions` | View full edit history or restore any version |
|
|
194
|
+
| `memory_search` | Exact full-text search via FTS5 |
|
|
195
|
+
| `memory_since` | Temporal query with natural language ranges |
|
|
196
|
+
| `memory_relate` | Build a knowledge graph between memories |
|
|
250
197
|
|
|
251
|
-
### Maintenance
|
|
198
|
+
### Log & Maintenance
|
|
252
199
|
|
|
253
|
-
| Tool |
|
|
254
|
-
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
200
|
+
| Tool | Description |
|
|
201
|
+
|---|---|
|
|
202
|
+
| `memory_log` | Append raw conversation turns (lossless, append-only) |
|
|
203
|
+
| `memory_log_recall` | Search or replay log by session, keyword, or recency |
|
|
204
|
+
| `memory_stats` | Memory count, type breakdown, confidence stats |
|
|
205
|
+
| `memory_export` | Export all memories as Markdown |
|
|
206
|
+
| `memory_consolidate` | Merge duplicates, prune stale, promote frequent memories |
|
|
258
207
|
|
|
259
|
-
|
|
208
|
+
---
|
|
260
209
|
|
|
261
|
-
|
|
210
|
+
## Usage Examples
|
|
262
211
|
|
|
263
|
-
|
|
212
|
+
<details open>
|
|
213
|
+
<summary><strong>Store & Recall</strong></summary>
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
// Store a correction — highest priority, always surfaces first
|
|
264
217
|
memory_store({
|
|
265
218
|
content: "Never use 'any' type — always define proper interfaces",
|
|
266
219
|
type: "correction",
|
|
267
220
|
tags: ["typescript", "types"],
|
|
268
221
|
confidence: 1.0
|
|
269
222
|
})
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
> Stored correction memory (a1b2c3d4). Confidence: 1. Tags: [typescript, types]. Total memories: 42.
|
|
273
223
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
```
|
|
224
|
+
// Semantic search
|
|
277
225
|
memory_recall({ query: "TypeScript best practices", limit: 5 })
|
|
278
226
|
```
|
|
279
227
|
|
|
280
|
-
|
|
281
|
-
Found 2 memories for "TypeScript best practices":
|
|
228
|
+
</details>
|
|
282
229
|
|
|
283
|
-
|
|
284
|
-
|
|
230
|
+
<details>
|
|
231
|
+
<summary><strong>Patch a memory (surgical, versioned)</strong></summary>
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
memory_patch({
|
|
235
|
+
id: "a1b2c3d4",
|
|
236
|
+
field: "content",
|
|
237
|
+
value: "Never use 'any' — define interfaces, use 'unknown' for unknown types",
|
|
238
|
+
reason: "added unknown guidance"
|
|
239
|
+
})
|
|
285
240
|
|
|
286
|
-
|
|
287
|
-
|
|
241
|
+
// Every patch auto-snapshots. Restore any version:
|
|
242
|
+
memory_versions({ memory_id: "a1b2c3d4" })
|
|
288
243
|
```
|
|
289
244
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
```
|
|
293
|
-
memory_context({ topic: "authentication system", max_tokens: 2000 })
|
|
294
|
-
```
|
|
245
|
+
</details>
|
|
295
246
|
|
|
296
|
-
|
|
297
|
-
|
|
247
|
+
<details>
|
|
248
|
+
<summary><strong>Lossless conversation log</strong></summary>
|
|
298
249
|
|
|
299
|
-
|
|
300
|
-
|
|
250
|
+
```js
|
|
251
|
+
// Preserve raw turns verbatim
|
|
252
|
+
memory_log({ session_id: "2025-03-25", role: "user", content: "Let's use OAuth2 with PKCE" })
|
|
253
|
+
memory_log({ session_id: "2025-03-25", role: "assistant", content: "Good call — removes token storage risk..." })
|
|
301
254
|
|
|
302
|
-
|
|
303
|
-
|
|
255
|
+
// Replay a session
|
|
256
|
+
memory_log_recall({ session_id: "2025-03-25" })
|
|
304
257
|
|
|
305
|
-
|
|
306
|
-
|
|
258
|
+
// Search across all sessions
|
|
259
|
+
memory_log_recall({ query: "OAuth PKCE", limit: 10 })
|
|
307
260
|
```
|
|
308
261
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
Your AI can extract multiple memories from a single conversation:
|
|
262
|
+
</details>
|
|
312
263
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
264
|
+
<details>
|
|
265
|
+
<summary><strong>Knowledge graph</strong></summary>
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
memory_relate({
|
|
269
|
+
action: "relate",
|
|
270
|
+
from_id: "decision-abc",
|
|
271
|
+
to_id: "pattern-xyz",
|
|
272
|
+
relation_type: "supports",
|
|
273
|
+
strength: 0.9
|
|
319
274
|
})
|
|
320
|
-
```
|
|
321
275
|
|
|
276
|
+
// View connections
|
|
277
|
+
memory_relate({ action: "graph", memory_id: "decision-abc" })
|
|
322
278
|
```
|
|
323
|
-
Extraction complete: 2 stored, 0 reinforced.
|
|
324
|
-
Total memories: 44.
|
|
325
279
|
|
|
326
|
-
|
|
327
|
-
+ Stored [decision]: "Chose event sourcing for audit trail" (e5f6g7h8)
|
|
328
|
-
```
|
|
280
|
+
Relation types: `supports`, `contradicts`, `depends_on`, `supersedes`, `related_to`, `caused_by`, `implements` — or define your own.
|
|
329
281
|
|
|
330
|
-
|
|
282
|
+
</details>
|
|
331
283
|
|
|
332
|
-
|
|
284
|
+
<details>
|
|
285
|
+
<summary><strong>Temporal queries</strong></summary>
|
|
333
286
|
|
|
334
|
-
```
|
|
335
|
-
|
|
287
|
+
```js
|
|
288
|
+
memory_since({ since: "7d" }) // last 7 days
|
|
289
|
+
memory_since({ since: "1w", type: "decision" }) // decisions this week
|
|
290
|
+
memory_since({ since: "2025-03-01", until: "2025-03-15" }) // date range
|
|
336
291
|
```
|
|
337
292
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
293
|
+
</details>
|
|
294
|
+
|
|
295
|
+
<details>
|
|
296
|
+
<summary><strong>Full-text search (FTS5)</strong></summary>
|
|
342
297
|
|
|
343
|
-
|
|
298
|
+
```js
|
|
299
|
+
memory_search({ query: "OAuth PKCE" }) // exact terms
|
|
300
|
+
memory_search({ query: '"event sourcing"' }) // phrase match
|
|
301
|
+
memory_search({ query: "auth* NOT legacy" }) // FTS5 boolean syntax
|
|
344
302
|
```
|
|
345
303
|
|
|
346
|
-
|
|
304
|
+
</details>
|
|
347
305
|
|
|
348
|
-
|
|
306
|
+
---
|
|
349
307
|
|
|
350
|
-
|
|
308
|
+
## Architecture
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
┌──────────────────────────────────────────────┐
|
|
312
|
+
│ Your AI Tool │
|
|
313
|
+
│ Claude Code · Cursor · Windsurf · any │
|
|
314
|
+
└─────────────────┬────────────────────────────┘
|
|
315
|
+
│ MCP Protocol (stdio)
|
|
316
|
+
┌─────────────────▼────────────────────────────┐
|
|
317
|
+
│ amem MCP Server │
|
|
318
|
+
│ │
|
|
319
|
+
│ 15 Tools · 6 Resources · 2 Prompts │
|
|
320
|
+
│ │
|
|
321
|
+
│ ┌────────────────────────────────────┐ │
|
|
322
|
+
│ │ SQLite + WAL + FTS5 │ │
|
|
323
|
+
│ │ ~/.amem/memory.db │ │
|
|
324
|
+
│ │ │ │
|
|
325
|
+
│ │ memories (scored) │ │
|
|
326
|
+
│ │ conversation_log (lossless) │ │
|
|
327
|
+
│ │ memory_versions (history) │ │
|
|
328
|
+
│ │ memory_relations (graph) │ │
|
|
329
|
+
│ │ memories_fts (FTS5 index) │ │
|
|
330
|
+
│ └────────────────────────────────────┘ │
|
|
331
|
+
│ │
|
|
332
|
+
│ Local Embeddings (all-MiniLM-L6-v2, 80MB) │
|
|
333
|
+
└──────────────────────────────────────────────┘
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Ranking Formula
|
|
351
337
|
|
|
352
|
-
|
|
338
|
+
```
|
|
339
|
+
score = relevance × recency × confidence × importance
|
|
340
|
+
```
|
|
353
341
|
|
|
354
|
-
|
|
|
355
|
-
|
|
356
|
-
|
|
|
357
|
-
|
|
|
358
|
-
|
|
|
359
|
-
|
|
|
342
|
+
| Factor | How it works |
|
|
343
|
+
|---|---|
|
|
344
|
+
| **Relevance** | Cosine similarity via local embeddings, keyword fallback |
|
|
345
|
+
| **Recency** | Exponential decay (`0.995^hours`) |
|
|
346
|
+
| **Confidence** | Reinforced by repeated confirmation |
|
|
347
|
+
| **Importance** | Type-based: corrections `1.0` → facts `0.4` |
|
|
360
348
|
|
|
361
|
-
|
|
349
|
+
---
|
|
362
350
|
|
|
363
|
-
|
|
351
|
+
## MCP Resources
|
|
364
352
|
|
|
365
|
-
|
|
|
366
|
-
|
|
367
|
-
| `
|
|
368
|
-
| `
|
|
353
|
+
| URI | Description |
|
|
354
|
+
|---|---|
|
|
355
|
+
| `amem://corrections` | All active corrections (hard constraints) |
|
|
356
|
+
| `amem://decisions` | Architectural decisions |
|
|
357
|
+
| `amem://profile` | Preferences and coding patterns |
|
|
358
|
+
| `amem://summary` | Memory count and type breakdown |
|
|
359
|
+
| `amem://log/recent` | Last 50 raw conversation log entries |
|
|
360
|
+
| `amem://graph` | Knowledge graph overview |
|
|
369
361
|
|
|
370
362
|
---
|
|
371
363
|
|
|
372
364
|
## CLI
|
|
373
365
|
|
|
374
|
-
amem includes a standalone command-line interface for managing memories directly:
|
|
375
|
-
|
|
376
366
|
```bash
|
|
377
|
-
amem-cli recall "authentication"
|
|
378
|
-
amem-cli stats
|
|
379
|
-
amem-cli list
|
|
380
|
-
amem-cli list --type correction
|
|
381
|
-
amem-cli export
|
|
382
|
-
amem-cli
|
|
383
|
-
amem-cli forget abc12345 # Delete by ID (short IDs supported)
|
|
367
|
+
amem-cli recall "authentication" # Semantic search
|
|
368
|
+
amem-cli stats # Statistics
|
|
369
|
+
amem-cli list # List all memories
|
|
370
|
+
amem-cli list --type correction # Filter by type
|
|
371
|
+
amem-cli export --file memories.md # Export to file
|
|
372
|
+
amem-cli forget abc12345 # Delete by short ID
|
|
384
373
|
```
|
|
385
374
|
|
|
386
375
|
---
|
|
387
376
|
|
|
388
377
|
## Configuration
|
|
389
378
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
|
393
|
-
|
|
394
|
-
| `
|
|
395
|
-
| `AMEM_DB` | `~/.amem/memory.db` | Database file path |
|
|
396
|
-
| `AMEM_PROJECT` | *(auto-detected from git)* | Project name for scoping (e.g., `my-app`) |
|
|
397
|
-
|
|
398
|
-
Project scoping is automatic — amem detects your git repo name. Override with `AMEM_PROJECT`:
|
|
399
|
-
|
|
400
|
-
```json
|
|
401
|
-
{
|
|
402
|
-
"mcpServers": {
|
|
403
|
-
"amem": {
|
|
404
|
-
"command": "amem",
|
|
405
|
-
"env": { "AMEM_PROJECT": "my-project" }
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
```
|
|
379
|
+
| Variable | Default | Description |
|
|
380
|
+
|---|---|---|
|
|
381
|
+
| `AMEM_DIR` | `~/.amem` | Storage directory |
|
|
382
|
+
| `AMEM_DB` | `~/.amem/memory.db` | Database path |
|
|
383
|
+
| `AMEM_PROJECT` | *(auto from git)* | Project scope |
|
|
410
384
|
|
|
411
385
|
---
|
|
412
386
|
|
|
413
|
-
##
|
|
414
|
-
|
|
415
|
-
### Stack
|
|
387
|
+
## Tech Stack
|
|
416
388
|
|
|
417
389
|
| Layer | Technology |
|
|
418
|
-
|
|
419
|
-
| Protocol |
|
|
420
|
-
| Language | TypeScript 5.6
|
|
421
|
-
| Database | SQLite
|
|
422
|
-
| Embeddings | HuggingFace
|
|
423
|
-
| Validation | Zod 3.25+
|
|
424
|
-
| Testing | Vitest —
|
|
425
|
-
| CI/CD | GitHub Actions
|
|
426
|
-
|
|
427
|
-
### MCP Best Practices
|
|
428
|
-
|
|
429
|
-
amem follows the [MCP best practices](https://modelcontextprotocol.io/) checklist:
|
|
430
|
-
|
|
431
|
-
- All 9 tools use `server.registerTool()` with `title`, `description`, `inputSchema`, `outputSchema`, and `annotations`
|
|
432
|
-
- All tool handlers wrapped in `try-catch` with `isError: true` on failures
|
|
433
|
-
- All Zod schemas use `.strict()` to reject unknown fields
|
|
434
|
-
- All error messages are actionable (suggest next steps)
|
|
435
|
-
- Server name follows convention: `amem-mcp-server`
|
|
436
|
-
- Transport: stdio (correct for local-first tool)
|
|
437
|
-
- Logging to stderr (not stdout)
|
|
438
|
-
- Graceful shutdown on SIGINT/SIGTERM
|
|
439
|
-
|
|
440
|
-
### Architecture
|
|
441
|
-
|
|
442
|
-
```
|
|
443
|
-
src/
|
|
444
|
-
├── index.ts Entry point — server, prompts, resources, transport
|
|
445
|
-
├── tools.ts 10 MCP tools with annotations, validation, structured output
|
|
446
|
-
├── schemas.ts Zod output schemas for structuredContent responses
|
|
447
|
-
├── memory.ts Scoring engine, conflict detection, recall algorithm
|
|
448
|
-
├── database.ts SQLite schema, prepared statements, CRUD interface
|
|
449
|
-
├── embeddings.ts Local embedding pipeline + cosine similarity
|
|
450
|
-
└── cli.ts Standalone CLI for direct memory management
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
**~1,300 lines of TypeScript.** Clean separation of concerns, no circular dependencies.
|
|
454
|
-
|
|
455
|
-
---
|
|
456
|
-
|
|
457
|
-
## FAQ
|
|
458
|
-
|
|
459
|
-
<details>
|
|
460
|
-
<summary><strong>Is my data sent to the cloud?</strong></summary>
|
|
461
|
-
|
|
462
|
-
No. Everything stays on your machine. amem uses a local SQLite database at `~/.amem/memory.db` and generates embeddings locally using an 80MB model that runs on your CPU. No internet connection required after the first model download.
|
|
463
|
-
|
|
464
|
-
</details>
|
|
465
|
-
|
|
466
|
-
<details>
|
|
467
|
-
<summary><strong>Does it work offline?</strong></summary>
|
|
468
|
-
|
|
469
|
-
Yes. After the first run (which downloads the embedding model), amem works completely offline. If the model isn't available, amem falls back to keyword matching — it never crashes.
|
|
470
|
-
|
|
471
|
-
</details>
|
|
472
|
-
|
|
473
|
-
<details>
|
|
474
|
-
<summary><strong>What AI tools does it work with?</strong></summary>
|
|
475
|
-
|
|
476
|
-
Any tool that supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) — including Claude Code, Cursor, Windsurf, and many others. The list is growing rapidly.
|
|
477
|
-
|
|
478
|
-
</details>
|
|
479
|
-
|
|
480
|
-
<details>
|
|
481
|
-
<summary><strong>How much memory/disk does it use?</strong></summary>
|
|
482
|
-
|
|
483
|
-
The embedding model is ~80MB (downloaded once, cached locally). The SQLite database grows with your memories — typically a few MB even after months of use. CPU usage is minimal; the server idles at near-zero when not processing requests.
|
|
484
|
-
|
|
485
|
-
</details>
|
|
486
|
-
|
|
487
|
-
<details>
|
|
488
|
-
<summary><strong>Can I see what's stored?</strong></summary>
|
|
489
|
-
|
|
490
|
-
Yes! Use `amem-cli list` to see all memories, `amem-cli stats` for a visual overview, or `amem-cli export --file backup.md` to export everything as readable markdown. You can also ask your AI to call `memory_stats` or `memory_export`.
|
|
491
|
-
|
|
492
|
-
</details>
|
|
493
|
-
|
|
494
|
-
<details>
|
|
495
|
-
<summary><strong>Can I delete specific memories?</strong></summary>
|
|
496
|
-
|
|
497
|
-
Yes. Use `amem-cli forget <id>` (short IDs work — just the first 8 characters) or ask your AI to call `memory_forget`. Query-based deletion requires a confirmation step to prevent accidents: `memory_forget({ query: "old project", confirm: true })`.
|
|
498
|
-
|
|
499
|
-
</details>
|
|
500
|
-
|
|
501
|
-
<details>
|
|
502
|
-
<summary><strong>Does it slow down my AI?</strong></summary>
|
|
503
|
-
|
|
504
|
-
No. Memory operations typically take under 50ms. Embedding generation for new memories takes ~200ms. The server runs as a lightweight background process over stdio.
|
|
505
|
-
|
|
506
|
-
</details>
|
|
507
|
-
|
|
508
|
-
<details>
|
|
509
|
-
<summary><strong>Can I use it across multiple projects?</strong></summary>
|
|
510
|
-
|
|
511
|
-
Yes. By default, amem stores memories globally at `~/.amem/memory.db` — all your AI conversations across all projects share the same memory. Set `AMEM_DB` per-project for isolated memories.
|
|
512
|
-
|
|
513
|
-
</details>
|
|
514
|
-
|
|
515
|
-
<details>
|
|
516
|
-
<summary><strong>What happens if the embedding model isn't available?</strong></summary>
|
|
517
|
-
|
|
518
|
-
amem gracefully falls back to keyword-based matching. Semantic search won't work, but storing, recalling (by keyword), and all other operations continue normally. The server never crashes due to missing embeddings.
|
|
519
|
-
|
|
520
|
-
</details>
|
|
521
|
-
|
|
522
|
-
<details>
|
|
523
|
-
<summary><strong>How does conflict detection work?</strong></summary>
|
|
524
|
-
|
|
525
|
-
When you store a new memory, amem computes cosine similarity against all existing memories. If a match exceeds 85% similarity but the content is different, it flags a conflict and updates the existing memory's confidence instead of creating a duplicate. You get a clear message explaining what happened and how to rephrase if the memories are genuinely different.
|
|
526
|
-
|
|
527
|
-
</details>
|
|
390
|
+
|---|---|
|
|
391
|
+
| Protocol | MCP SDK ^1.25 |
|
|
392
|
+
| Language | TypeScript 5.6+, strict mode, zero `any` |
|
|
393
|
+
| Database | SQLite + WAL + FTS5 |
|
|
394
|
+
| Embeddings | HuggingFace Xenova/all-MiniLM-L6-v2 (local, 80MB) |
|
|
395
|
+
| Validation | Zod 3.25+ with `.strict()` schemas |
|
|
396
|
+
| Testing | Vitest — 92 tests across 7 suites |
|
|
397
|
+
| CI/CD | GitHub Actions → npm publish on release |
|
|
528
398
|
|
|
529
399
|
---
|
|
530
400
|
|
|
531
401
|
## Contributing
|
|
532
402
|
|
|
533
|
-
Contributions are welcome! Here's how to get involved.
|
|
534
|
-
|
|
535
|
-
### Development setup
|
|
536
|
-
|
|
537
403
|
```bash
|
|
538
404
|
git clone https://github.com/amanasmuei/amem.git
|
|
539
|
-
cd amem
|
|
540
|
-
npm
|
|
541
|
-
npm
|
|
542
|
-
npm test
|
|
405
|
+
cd amem && npm install
|
|
406
|
+
npm run build # zero TS errors
|
|
407
|
+
npm test # 92 tests pass
|
|
543
408
|
```
|
|
544
409
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
| Script | What it does |
|
|
548
|
-
|--------|-------------|
|
|
549
|
-
| `npm run build` | Compile TypeScript to `dist/` |
|
|
550
|
-
| `npm run dev` | Watch mode — recompile on save |
|
|
551
|
-
| `npm test` | Run all 33 tests with Vitest |
|
|
552
|
-
| `npm run test:watch` | Run tests in watch mode |
|
|
553
|
-
| `npm start` | Start the MCP server (`node dist/index.js`) |
|
|
554
|
-
|
|
555
|
-
### Project structure
|
|
556
|
-
|
|
557
|
-
```
|
|
558
|
-
amem/
|
|
559
|
-
├── src/
|
|
560
|
-
│ ├── index.ts # MCP server entry point, prompts, resources
|
|
561
|
-
│ ├── tools.ts # 7 tool definitions with validation & error handling
|
|
562
|
-
│ ├── memory.ts # Scoring engine, conflict detection, recall
|
|
563
|
-
│ ├── database.ts # SQLite schema, prepared statements, CRUD
|
|
564
|
-
│ ├── embeddings.ts # Local embedding pipeline + cosine similarity
|
|
565
|
-
│ └── cli.ts # Standalone CLI
|
|
566
|
-
├── tests/
|
|
567
|
-
│ ├── database.test.ts
|
|
568
|
-
│ ├── embeddings.test.ts
|
|
569
|
-
│ ├── memory.test.ts
|
|
570
|
-
│ └── tools.test.ts
|
|
571
|
-
├── .github/
|
|
572
|
-
│ └── workflows/
|
|
573
|
-
│ ├── ci.yml # Test on push/PR (Node 18/20/22)
|
|
574
|
-
│ └── publish.yml # Publish to npm on GitHub Release
|
|
575
|
-
├── package.json
|
|
576
|
-
├── tsconfig.json
|
|
577
|
-
└── vitest.config.ts
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
### Making changes
|
|
581
|
-
|
|
582
|
-
1. Fork the repository
|
|
583
|
-
2. Create a feature branch: `git checkout -b feature/your-feature`
|
|
584
|
-
3. Make your changes
|
|
585
|
-
4. Ensure the build is clean: `npm run build`
|
|
586
|
-
5. Ensure all tests pass: `npm test`
|
|
587
|
-
6. Commit and push your branch
|
|
588
|
-
7. Open a Pull Request against `main`
|
|
589
|
-
|
|
590
|
-
### CI/CD
|
|
591
|
-
|
|
592
|
-
**GitHub Actions** runs automatically on every push and pull request:
|
|
593
|
-
|
|
594
|
-
- **CI workflow** (`ci.yml`) — builds and tests against Node.js 18, 20, and 22 on Ubuntu
|
|
595
|
-
- **Publish workflow** (`publish.yml`) — triggered on GitHub Release, builds, tests, and publishes to npm with `--access public`
|
|
596
|
-
|
|
597
|
-
All PRs must pass the CI pipeline before merging.
|
|
598
|
-
|
|
599
|
-
### Reporting issues
|
|
600
|
-
|
|
601
|
-
Found a bug or have a feature idea?
|
|
602
|
-
|
|
603
|
-
- **Bug reports**: [Open an issue](https://github.com/amanasmuei/amem/issues/new) with steps to reproduce, expected vs. actual behavior, and your Node.js version
|
|
604
|
-
- **Feature requests**: [Open an issue](https://github.com/amanasmuei/amem/issues/new) describing the use case and how it would improve the memory system
|
|
605
|
-
- **Questions**: [Start a discussion](https://github.com/amanasmuei/amem/discussions) (or open an issue)
|
|
410
|
+
PRs must pass CI before merge. See [Issues](https://github.com/amanasmuei/amem/issues) for open tasks.
|
|
606
411
|
|
|
607
412
|
---
|
|
608
413
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
- [x] Semantic search with local embeddings (graceful fallback to keywords)
|
|
613
|
-
- [x] Smart conflict detection and deduplication
|
|
614
|
-
- [x] Memory evolution (related memories reinforce each other)
|
|
615
|
-
- [x] CLI for direct memory management
|
|
616
|
-
- [x] MCP prompts and resources for proactive context
|
|
617
|
-
- [x] Published on npm
|
|
618
|
-
- [x] `outputSchema` + `structuredContent` for machine-readable tool responses
|
|
619
|
-
- [x] Proactive context injection (`memory_inject` tool)
|
|
620
|
-
- [x] Evaluation suite (10 standardized eval questions)
|
|
621
|
-
- [x] Memory consolidation — merge, prune, promote (the first MCP memory server with this)
|
|
622
|
-
- [x] Project scoping — auto-detect project, scope memories global vs project
|
|
623
|
-
- [ ] Memory verification against filesystem
|
|
624
|
-
- [ ] Knowledge graph with entity relationships
|
|
625
|
-
- [ ] Team memory (shared context across developers)
|
|
626
|
-
|
|
627
|
-
---
|
|
628
|
-
|
|
629
|
-
<div align="center">
|
|
630
|
-
|
|
631
|
-
**Built by [Aman Asmuei](https://github.com/amanasmuei)**
|
|
632
|
-
|
|
633
|
-
[GitHub](https://github.com/amanasmuei/amem) · [npm](https://www.npmjs.com/package/@aman_asmuei/amem) · [Report Bug](https://github.com/amanasmuei/amem/issues) · [Request Feature](https://github.com/amanasmuei/amem/issues)
|
|
414
|
+
<p align="center">
|
|
415
|
+
Built by <a href="https://github.com/amanasmuei"><strong>Aman Asmuei</strong></a>
|
|
416
|
+
</p>
|
|
634
417
|
|
|
635
|
-
|
|
418
|
+
<p align="center">
|
|
419
|
+
<a href="https://github.com/amanasmuei/amem">GitHub</a> ·
|
|
420
|
+
<a href="https://www.npmjs.com/package/@aman_asmuei/amem">npm</a> ·
|
|
421
|
+
<a href="https://github.com/amanasmuei/amem/issues">Issues</a>
|
|
422
|
+
</p>
|
|
636
423
|
|
|
637
|
-
|
|
424
|
+
<p align="center">
|
|
425
|
+
<sub>MIT License</sub>
|
|
426
|
+
</p>
|