toon-memory 2.4.5 → 2.5.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 +192 -41
- package/bin/toon-memory.js +17 -14
- package/dist/cli/setup.js +83 -125
- package/mcp/server.js +226 -33
- package/package.json +8 -2
- package/src/bin/toon-memory.ts +17 -14
- package/src/cli/setup.ts +93 -145
- package/src/lib/quality.ts +221 -0
- package/src/mcp/server.ts +98 -31
package/README.md
CHANGED
|
@@ -61,8 +61,8 @@ Read [How toon-memory Makes Your AI Agent Smarter](https://luiggival08.github.io
|
|
|
61
61
|
|
|
62
62
|
## Features
|
|
63
63
|
|
|
64
|
-
- **
|
|
65
|
-
- **MCP Resources** — Read memory as context without tool invocations
|
|
64
|
+
- **14 MCP tools** — Full memory management via Model Context Protocol, including `memory_smart_recall` (unified recall) and `memory_sessions` for multi-session coordination
|
|
65
|
+
- **MCP Resources** — Read memory as context without tool invocations, including a System Primer (auto-generated knowledge map)
|
|
66
66
|
- **15 agents supported** — OpenCode, VS Code, Claude Code, Cursor, Windsurf, Cline, Continue, Codex CLI, Gemini CLI, Zed, Antigravity, Aider, KiloCode, OpenClaw, Kiro
|
|
67
67
|
- **Interactive installer** — Select which agents to configure from a menu
|
|
68
68
|
- **SessionStart hooks** — Auto-reminders for Claude Code, Codex CLI, Gemini CLI, Antigravity
|
|
@@ -82,6 +82,11 @@ Read [How toon-memory Makes Your AI Agent Smarter](https://luiggival08.github.io
|
|
|
82
82
|
- **Token-efficient recall** — `memory_recall({ compact: true })` returns numeric-indexed entries, drops `id`/`date`/`file`, renders graph edges as `->2`, and truncates graph neighbors to snippets
|
|
83
83
|
- **BM25 + centrality ranking** — Recall re-ranks by BM25 relevance and graph centrality (hubs surface even without the query word); per-hop decay keeps distant nodes low
|
|
84
84
|
- **Auto-tag from dependencies** — `toon-memory init` scans `package.json`/`Cargo.toml`/`requirements.txt`/`go.mod` and writes a project vocabulary so entries mentioning a dependency get auto-tagged with it
|
|
85
|
+
- **Smart Recall** — `memory_smart_recall` combines BM25 + graph + decay + quality in one call; the LLM calls this at the start of every task
|
|
86
|
+
- **Quality scoring** — Every entry gets a 0–1 quality score based on structure (tags, links, content specificity, recency); high-quality entries surface first
|
|
87
|
+
- **Merge-dedup** — Saving with the same `key` merges attributes (union of tags, max confidence, latest date, combined links) instead of overwriting
|
|
88
|
+
- **Confidence score** — Each entry tracks reliability: user-asserted = 1.0, inferred = 0.65–0.75
|
|
89
|
+
- **System Primer** — Auto-generated knowledge map exposed as MCP resource; agents load it at session start for instant context
|
|
85
90
|
|
|
86
91
|
---
|
|
87
92
|
|
|
@@ -156,10 +161,11 @@ memory_remember # Save important decisions
|
|
|
156
161
|
|
|
157
162
|
| Tool | Description |
|
|
158
163
|
|------|-------------|
|
|
159
|
-
| `memory_remember` | Save a decision, pattern, bug, or knowledge (optional TTL, auto-tag inference,
|
|
160
|
-
| `memory_recall` | Search memory (use BEFORE reading files, filters expired TTL). `mode: "graph"` expands a relationship-aware subgraph for higher precision. `compact: true` returns a token-efficient, numeric-indexed format |
|
|
164
|
+
| `memory_remember` | Save a decision, pattern, bug, or knowledge (optional TTL, auto-tag inference, `links` to build the memory graph, merge-dedup on same key, auto quality score and confidence) |
|
|
165
|
+
| `memory_recall` | Search memory (use BEFORE reading files, filters expired TTL). `mode: "graph"` expands a relationship-aware subgraph for higher precision. `compact: true` returns a token-efficient, numeric-indexed format. Quality-weighted ranking |
|
|
166
|
+
| `memory_smart_recall` | **Unified recall**: BM25 + graph + decay + quality in one call. Use at the START of every task. Returns compact, token-efficient output |
|
|
161
167
|
| `memory_forget` | Remove an entry by key or id |
|
|
162
|
-
| `memory_stats` | View memory state (including TTL stats) |
|
|
168
|
+
| `memory_stats` | View memory state (including TTL stats and quality distribution) |
|
|
163
169
|
| `memory_summary` | Save/retrieve file summaries |
|
|
164
170
|
| `memory_archive` | Archive old entries (>30 days) and expired TTL entries |
|
|
165
171
|
| `memory_diff` | Show changes since a date (24h, 7d, or exact date) |
|
|
@@ -167,7 +173,7 @@ memory_remember # Save important decisions
|
|
|
167
173
|
| `memory_encrypt` | Enable AES-256-GCM encryption |
|
|
168
174
|
| `memory_decrypt` | Disable encryption |
|
|
169
175
|
| `memory_captured` | List activity auto-captured by hooks (opt-in) or clear the log |
|
|
170
|
-
| `memory_consolidate` |
|
|
176
|
+
| `memory_consolidate` | Merge-dedup entries: same-key entries are merged (tags union, max confidence, latest date), then exact-content duplicates removed (deterministic, no LLM) |
|
|
171
177
|
| `memory_sessions` | Show active agent sessions (branch, files, last-seen) and soft conflicts for parallel work |
|
|
172
178
|
|
|
173
179
|
### MCP Resources
|
|
@@ -178,7 +184,7 @@ Memory is also exposed as MCP resources for direct context reading:
|
|
|
178
184
|
|----------|-----|-------------|
|
|
179
185
|
| Memory Entries | `toon://memory/entries` | Full memory dump |
|
|
180
186
|
| Memory Stats | `toon://memory/stats` | Category counts and TTL info |
|
|
181
|
-
|
|
|
187
|
+
| System Primer | `toon://memory/summaries` | Auto-generated knowledge map (top entries, categories, patterns) |
|
|
182
188
|
|
|
183
189
|
### Examples
|
|
184
190
|
|
|
@@ -193,11 +199,12 @@ memory_remember({
|
|
|
193
199
|
tags: "validation;types"
|
|
194
200
|
})
|
|
195
201
|
// 🧠 Guardado: decision/use-zod (a1b2c3d4)
|
|
202
|
+
// Quality score: 0.65 (2 tags, detailed content)
|
|
196
203
|
// 🔗 Entradas relacionadas:
|
|
197
204
|
// [pattern] zod-schemas — Shared Zod schemas for API validation
|
|
198
205
|
```
|
|
199
206
|
|
|
200
|
-
> **Tip:** Use descriptive keys like `use-zod` instead of vague ones like `validation`. Your agent searches by key and content, so specificity helps.
|
|
207
|
+
> **Tip:** Use descriptive keys like `use-zod` instead of vague ones like `validation`. Your agent searches by key and content, so specificity helps. Saving with the same key auto-merges (union of tags, max confidence).
|
|
201
208
|
|
|
202
209
|
#### Remember with TTL
|
|
203
210
|
|
|
@@ -210,6 +217,7 @@ memory_remember({
|
|
|
210
217
|
})
|
|
211
218
|
// 🧠 Guardado: knowledge/sprint-deadline (x1y2z3w4)
|
|
212
219
|
// ⏰ TTL: 2026-07-19
|
|
220
|
+
// Quality score is calculated automatically.
|
|
213
221
|
```
|
|
214
222
|
|
|
215
223
|
> **Tip:** Use TTL for temporary context like deadlines, sprint info, or time-sensitive notes. Entries with expired TTL are automatically filtered from search results.
|
|
@@ -225,6 +233,7 @@ memory_remember({
|
|
|
225
233
|
})
|
|
226
234
|
// 🧠 Guardado: bug/redis-connection-timeout (a1b2c3d4)
|
|
227
235
|
// 🏷️ Tags inferidos: redis
|
|
236
|
+
// Quality score is calculated automatically based on inferred tags and content.
|
|
228
237
|
```
|
|
229
238
|
|
|
230
239
|
> **Tip:** Leave `tags` empty and the system will infer them from your content using a built-in vocabulary of 20+ categories (redis, auth, api, db, security, etc.) **plus** a project vocabulary derived from your dependencies at `init` time. So if your project depends on `redis`, any entry mentioning "redis" gets auto-tagged `redis`.
|
|
@@ -238,7 +247,7 @@ memory_recall({ query: "redis" })
|
|
|
238
247
|
// File: redis.ts | Tags: redis;fix | Date: 2026-07-10
|
|
239
248
|
```
|
|
240
249
|
|
|
241
|
-
> **Tip:** Search before you read files. This saves tokens and gives your agent context it wouldn't get from code alone.
|
|
250
|
+
> **Tip:** Search before you read files. This saves tokens and gives your agent context it wouldn't get from code alone. Quality-weighted ranking ensures the most useful entries surface first. Or use `memory_smart_recall` for a more comprehensive result.
|
|
242
251
|
|
|
243
252
|
#### Search with date filter
|
|
244
253
|
|
|
@@ -250,7 +259,7 @@ memory_recall({
|
|
|
250
259
|
})
|
|
251
260
|
```
|
|
252
261
|
|
|
253
|
-
> **Tip:** Use date filters when you remember roughly *when* something happened but not exactly *what*.
|
|
262
|
+
> **Tip:** Use date filters when you remember roughly *when* something happened but not exactly *what*. Quality-weighted ranking still applies.
|
|
254
263
|
|
|
255
264
|
#### Archive old entries
|
|
256
265
|
|
|
@@ -260,7 +269,7 @@ memory_archive()
|
|
|
260
269
|
// 📋 Quedan 42 entradas activas
|
|
261
270
|
```
|
|
262
271
|
|
|
263
|
-
> **Tip:** Run this periodically to keep memory lean. Archived entries are still searchable via `memory_recall` with date filters. Entries with expired TTL are also archived automatically.
|
|
272
|
+
> **Tip:** Run this periodically to keep memory lean. Archived entries are still searchable via `memory_recall` with date filters. Entries with expired TTL are also archived automatically. Low-quality entries get lower recall priority. Low-quality entries get lower recall priority.
|
|
264
273
|
|
|
265
274
|
#### Show changes since last session
|
|
266
275
|
|
|
@@ -275,7 +284,7 @@ memory_diff({ since: "24h" })
|
|
|
275
284
|
// Redis connection timeout fix
|
|
276
285
|
```
|
|
277
286
|
|
|
278
|
-
> **Tip:** Use `memory_diff` at the start of a session to see what your agent learned since you last worked on the project.
|
|
287
|
+
> **Tip:** Use `memory_diff` at the start of a session to see what your agent learned since you last worked on the project. New entries include quality scores. New entries include quality scores.
|
|
279
288
|
|
|
280
289
|
#### Find related entries
|
|
281
290
|
|
|
@@ -292,7 +301,98 @@ memory_suggest({ context: "redis cache configuration" })
|
|
|
292
301
|
// File: redis.ts | Tags: redis;fix | Date: 2026-07-10
|
|
293
302
|
```
|
|
294
303
|
|
|
295
|
-
> **Tip:** Use `memory_suggest` when you need context about a topic but aren't sure what to search for.
|
|
304
|
+
> **Tip:** Use `memory_suggest` when you need context about a topic but aren't sure what to search for. Or use `memory_smart_recall` for a more comprehensive result.
|
|
305
|
+
|
|
306
|
+
#### Smart Recall (unified)
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
memory_smart_recall({ intent: "diseño de base de datos para backend" })
|
|
310
|
+
// [1] decision/use-postgres
|
|
311
|
+
// Choose Postgres for ACID compliance and JSON support
|
|
312
|
+
// tags: db;decision · edges: ->2
|
|
313
|
+
//
|
|
314
|
+
// [2] pattern/db-migrations
|
|
315
|
+
// Use sequential migration files, never edit committed ones
|
|
316
|
+
// tags: db;pattern · edges: ->1
|
|
317
|
+
//
|
|
318
|
+
// [3] bug/redis-timeout
|
|
319
|
+
// Redis connection timeout — increased pool to 20
|
|
320
|
+
// tags: redis;bug
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
> **Tip:** Use `memory_smart_recall` at the START of every task. It combines BM25 + graph + decay + quality in one call — no need to guess what to search for.
|
|
324
|
+
|
|
325
|
+
#### Merge-dedup (automatic)
|
|
326
|
+
|
|
327
|
+
When you save with the same `key`, attributes are merged instead of overwritten:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// First save
|
|
331
|
+
memory_remember({
|
|
332
|
+
category: "decision",
|
|
333
|
+
key: "use-zod",
|
|
334
|
+
content: "Use Zod for validation",
|
|
335
|
+
tags: "types"
|
|
336
|
+
})
|
|
337
|
+
// 🧠 Guardado: decision/use-zod (a1b2c3d4)
|
|
338
|
+
|
|
339
|
+
// Later save with same key — merges automatically
|
|
340
|
+
memory_remember({
|
|
341
|
+
category: "decision",
|
|
342
|
+
key: "use-zod",
|
|
343
|
+
content: "Use Zod for validation — also handles API response parsing",
|
|
344
|
+
tags: "types;api"
|
|
345
|
+
})
|
|
346
|
+
// 🧠 Actualizado: decision/use-zod (a1b2c3d4)
|
|
347
|
+
// 🔗 Merge: tags combinados, fecha y links actualizados
|
|
348
|
+
// Tags now: "types;api" (union of both)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
> **Tip:** Use descriptive, stable keys. The same key = merge, different key = new entry.
|
|
352
|
+
|
|
353
|
+
#### Quality scoring
|
|
354
|
+
|
|
355
|
+
Every entry gets an automatic quality score (0–1) based on structure:
|
|
356
|
+
|
|
357
|
+
| Factor | Weight | What it measures |
|
|
358
|
+
|--------|--------|------------------|
|
|
359
|
+
| Tags | 0.3 max | More specific tags = higher quality |
|
|
360
|
+
| Links | 0.2 max | Connected entries = higher quality |
|
|
361
|
+
| Content length | 0.3 max | Detailed > vague |
|
|
362
|
+
| Recency | 0.1 max | Recent entries score higher |
|
|
363
|
+
| Specificity | 0.1 max | Unique words vs repeated words |
|
|
364
|
+
|
|
365
|
+
High-quality entries surface first in recall. Check quality with `memory_stats`:
|
|
366
|
+
|
|
367
|
+
```typescript
|
|
368
|
+
memory_stats()
|
|
369
|
+
// ...
|
|
370
|
+
// Calidad promedio: 0.58 (12 con score)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Confidence score
|
|
374
|
+
|
|
375
|
+
Each entry tracks how reliable the information is:
|
|
376
|
+
|
|
377
|
+
| Source | Confidence | Meaning |
|
|
378
|
+
|--------|-----------|---------|
|
|
379
|
+
| User assertion | 1.0 | "We use Postgres" — direct statement |
|
|
380
|
+
| Inferred | 0.65–0.75 | Agent inferred from context |
|
|
381
|
+
| Uncertain | 0.50 | Agent is guessing |
|
|
382
|
+
|
|
383
|
+
Confidence is preserved on merge (max of both entries).
|
|
384
|
+
|
|
385
|
+
#### System Primer
|
|
386
|
+
|
|
387
|
+
The System Primer is an auto-generated knowledge map exposed as an MCP resource. Agents load it at session start for instant context:
|
|
388
|
+
|
|
389
|
+
```typescript
|
|
390
|
+
// Exposed as toon://memory/summaries
|
|
391
|
+
// Auto-regenerates on every read
|
|
392
|
+
// Contains: top entries, categories, patterns
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
> **Tip:** Add `toon://memory/summaries` to your agent's system prompt for instant context at session start.
|
|
296
396
|
|
|
297
397
|
#### Enable encryption
|
|
298
398
|
|
|
@@ -303,7 +403,7 @@ memory_encrypt()
|
|
|
303
403
|
// a1b2c3d4...
|
|
304
404
|
```
|
|
305
405
|
|
|
306
|
-
> **Warning:** Save the encryption key somewhere safe. If you lose it, your memory data is gone forever.
|
|
406
|
+
> **Warning:** Save the encryption key somewhere safe. If you lose it, your memory data is gone forever. Quality scores and confidence are preserved through encryption.
|
|
307
407
|
|
|
308
408
|
---
|
|
309
409
|
|
|
@@ -352,16 +452,17 @@ memory_sessions({ conflictsOnly: false })
|
|
|
352
452
|
### Recommended parallel-session habit
|
|
353
453
|
|
|
354
454
|
1. At the start of every session, the `SessionStart` hook already prints the other active sessions and any soft conflicts.
|
|
355
|
-
2. Run `
|
|
455
|
+
2. Run `memory_smart_recall({ intent: "what I'm working on" })` to get full context (memory + graph + quality).
|
|
456
|
+
3. Run `memory_sessions()` to see the full picture (branches, files, last-seen) and `memory_sessions({ conflictsOnly: true })` if you only care about clashes.
|
|
356
457
|
3. If you share a file with another session, sync up before editing so you don't overwrite each other's changes.
|
|
357
458
|
|
|
358
|
-
> **Tip:** This is purely local and lock-free — safe to run as often as you like. Combine it with `
|
|
459
|
+
> **Tip:** This is purely local and lock-free — safe to run as often as you like. Combine it with `memory_smart_recall({ intent: "project context" })` at session start for both cross-session *memory* and cross-session *presence*. The system primer (MCP resource) also provides instant context.
|
|
359
460
|
|
|
360
461
|
---
|
|
361
462
|
|
|
362
463
|
## Memory Graph (recall basado en grafo)
|
|
363
464
|
|
|
364
|
-
When your memory grows, a flat keyword search can return either too much (every match) or the wrong context (no relationships). toon-memory can treat memory as a **lightweight knowledge graph** so recall returns the *right* entries with fewer tokens.
|
|
465
|
+
When your memory grows, a flat keyword search can return either too much (every match) or the wrong context (no relationships). toon-memory can treat memory as a **lightweight knowledge graph** so recall returns the *right* entries with fewer tokens. Combined with quality scoring, the most useful entries surface first.
|
|
365
466
|
|
|
366
467
|
It's fully **deterministic and offline** — no embeddings, no vector DB, no LLM, no server. Edges come from two sources:
|
|
367
468
|
|
|
@@ -370,10 +471,10 @@ It's fully **deterministic and offline** — no embeddings, no vector DB, no LLM
|
|
|
370
471
|
|
|
371
472
|
### How it works
|
|
372
473
|
|
|
373
|
-
1. `memory_remember` stores `links` on the entry (space- or `;`-separated keys).
|
|
474
|
+
1. `memory_remember` stores `links` on the entry (space- or `;`-separated keys). Quality score is calculated automatically.
|
|
374
475
|
2. `memory_recall({ mode: "graph" })` finds keyword matches (seeds), then expands the **ego-subgraph** up to `hops` (1 or 2) along the edges.
|
|
375
|
-
3. Relevance propagates from the seeds to their neighbors, so a related decision or spec surfaces even if it doesn't contain the query word.
|
|
376
|
-
4. The result set is capped (`limit`, default 6) → **smaller, more precise context** for the agent.
|
|
476
|
+
3. Relevance propagates from the seeds to their neighbors, so a related decision or spec surfaces even if it doesn't contain the query word. Quality-weighted ranking ensures the most useful entries appear first.
|
|
477
|
+
4. The result set is capped (`limit`, default 6) → **smaller, more precise context** for the agent. Or use `memory_smart_recall` for a unified call.
|
|
377
478
|
|
|
378
479
|
### Remember with links
|
|
379
480
|
|
|
@@ -387,6 +488,7 @@ memory_remember({
|
|
|
387
488
|
links: "engine-arch" // explicit edge to another entry
|
|
388
489
|
})
|
|
389
490
|
// 🧠 Guardado: decision/risk-engine-priority (a1b2c3d4)
|
|
491
|
+
// Quality score is calculated automatically based on tags, links, and content detail.
|
|
390
492
|
```
|
|
391
493
|
|
|
392
494
|
### Recall with graph mode
|
|
@@ -407,7 +509,7 @@ memory_recall({ query: "riesgo", mode: "graph", hops: 2 })
|
|
|
407
509
|
// links: risk-spec
|
|
408
510
|
```
|
|
409
511
|
|
|
410
|
-
> **Tip:** Use `mode: "graph"` when a decision ripples across several entries (architecture, specs, related bugs). For isolated facts, the default `flat` mode is enough.
|
|
512
|
+
> **Tip:** Use `mode: "graph"` when a decision ripples across several entries (architecture, specs, related bugs). For isolated facts, the default `flat` mode is enough. Or use `memory_smart_recall` which combines graph + BM25 + quality automatically.
|
|
411
513
|
|
|
412
514
|
### Token-efficient recall (`compact`)
|
|
413
515
|
|
|
@@ -434,21 +536,23 @@ How `compact` changes the output:
|
|
|
434
536
|
- `id`, `date`, and `file` are dropped — only `tags` is kept.
|
|
435
537
|
- In `graph` mode, edges render as `->2` (numeric, not key names).
|
|
436
538
|
- Neighbors reached via the graph (non-seeds) are truncated to a short snippet with an ellipsis, while directly-matched seeds keep their full content.
|
|
539
|
+
- Quality-weighted ranking ensures the most useful entries appear first.
|
|
437
540
|
- The stored `.toon` file is **never** mutated — `compact` only reshapes the response.
|
|
438
541
|
|
|
439
|
-
> **Tip:** Combine `compact: true` with `mode: "graph"` for the smallest possible context window when recalling from a large, interconnected memory.
|
|
542
|
+
> **Tip:** Combine `compact: true` with `mode: "graph"` for the smallest possible context window when recalling from a large, interconnected memory. Or just use `memory_smart_recall` which does this automatically.
|
|
440
543
|
|
|
441
544
|
### How recall ranks results
|
|
442
545
|
|
|
443
546
|
Recall is deterministic and offline (no embeddings, no LLM). Each candidate entry gets a combined score:
|
|
444
547
|
|
|
445
|
-
- **BM25 relevance** — classic probabilistic term-frequency score against the query, using `id` + `category` + `key` + `content` + `file` + `tags`.
|
|
548
|
+
- **BM25 relevance** — classic probabilistic term-frequency score against the query, using `id` + `category` + `key` + `content` + `file` + `tags` + `quality` + `confidence`.
|
|
446
549
|
- **Graph centrality** — degree-normalized (0..1); a hub connected to many entries scores near 1, so it surfaces even without the query word.
|
|
447
550
|
- **Importance** — recency + access frequency (same signal used elsewhere).
|
|
551
|
+
- **Quality boost** — entries with higher quality scores (more tags, links, detail) get a ranking boost.
|
|
448
552
|
- **Seed bonus** — entries that directly match the query get a flat boost.
|
|
449
553
|
- **Per-hop decay** — nodes `d` hops from a seed are multiplied by `0.5^d`, so distant context ranks below nearby context.
|
|
450
554
|
|
|
451
|
-
In `graph` mode, recall seeds on keyword matches, expands the ego-subgraph up to `hops`, and returns the top `limit` (default 6) by combined score.
|
|
555
|
+
In `graph` mode, recall seeds on keyword matches, expands the ego-subgraph up to `hops`, and returns the top `limit` (default 6) by combined score. `memory_smart_recall` combines all these signals in one call.
|
|
452
556
|
|
|
453
557
|
### Auto-tag from project dependencies
|
|
454
558
|
|
|
@@ -464,9 +568,9 @@ On `toon-memory init`, the CLI scans your dependency manifests and writes a `voc
|
|
|
464
568
|
}
|
|
465
569
|
```
|
|
466
570
|
|
|
467
|
-
`memory_remember` then matches new entries against this vocabulary on top of the built-in one, so mentioning a dependency in your content auto-attaches its tag. Supported manifests: `package.json`, `Cargo.toml`, `requirements.txt`, `pyproject.toml`, `go.mod`.
|
|
571
|
+
`memory_remember` then matches new entries against this vocabulary on top of the built-in one, so mentioning a dependency in your content auto-attaches its tag. More tags = higher quality score. Supported manifests: `package.json`, `Cargo.toml`, `requirements.txt`, `pyproject.toml`, `go.mod`.
|
|
468
572
|
|
|
469
|
-
> **Tip:** Re-run `toon-memory init` after adding major dependencies to refresh the vocabulary. The `vocab` key is merged (never clobbered) with the `encrypted`/`capture` flags in `config.json`.
|
|
573
|
+
> **Tip:** Re-run `toon-memory init` after adding major dependencies to refresh the vocabulary. The `vocab` key is merged (never clobbered) with the `encrypted`/`capture` flags in `config.json`. More tags = higher quality score.
|
|
470
574
|
|
|
471
575
|
---
|
|
472
576
|
|
|
@@ -478,9 +582,9 @@ Here are some patterns that work well with toon-memory:
|
|
|
478
582
|
|
|
479
583
|
At the beginning of every new session, run:
|
|
480
584
|
```
|
|
481
|
-
|
|
585
|
+
memory_smart_recall({ intent: "what I was working on" })
|
|
482
586
|
```
|
|
483
|
-
This gives your agent instant context about what happened before.
|
|
587
|
+
This gives your agent instant context about what happened before — combining BM25, graph, quality, and decay in one call.
|
|
484
588
|
|
|
485
589
|
### The "end of session" habit
|
|
486
590
|
|
|
@@ -494,6 +598,7 @@ memory_remember({
|
|
|
494
598
|
tags: "auth;architecture"
|
|
495
599
|
})
|
|
496
600
|
```
|
|
601
|
+
The entry automatically gets a quality score based on its structure (tags, content detail, links).
|
|
497
602
|
|
|
498
603
|
### Choosing categories
|
|
499
604
|
|
|
@@ -504,7 +609,7 @@ memory_remember({
|
|
|
504
609
|
| `bug` | Issues you fixed and how |
|
|
505
610
|
| `knowledge` | Project facts, domain info, team context |
|
|
506
611
|
|
|
507
|
-
> **Tip:** Don't overthink it. If it's something your future self (or agent) would want to know, save it.
|
|
612
|
+
> **Tip:** Don't overthink it. If it's something your future self (or agent) would want to know, save it. Detailed entries with specific tags score higher in quality.
|
|
508
613
|
|
|
509
614
|
### Tags that work well
|
|
510
615
|
|
|
@@ -515,18 +620,19 @@ tags: "auth;jwt;security"
|
|
|
515
620
|
tags: "api;rest;versioning"
|
|
516
621
|
```
|
|
517
622
|
|
|
518
|
-
> **Tip:** Keep tags short and consistent. They're not hashtags — they're search filters.
|
|
623
|
+
> **Tip:** Keep tags short and consistent. They're not hashtags — they're search filters. More specific tags = higher quality score.
|
|
519
624
|
|
|
520
625
|
### What NOT to save
|
|
521
626
|
|
|
522
627
|
- Don't save things that are obvious from reading the code
|
|
523
628
|
- Don't save temporary debugging notes
|
|
524
629
|
- Don't save secrets, API keys, or credentials (use env vars instead)
|
|
525
|
-
- Don't duplicate the same information with different keys
|
|
630
|
+
- Don't duplicate the same information with different keys (merge-dedup handles same-key automatically)
|
|
631
|
+
- Vague entries with no tags score low in quality — be specific
|
|
526
632
|
|
|
527
633
|
### Keep memory clean
|
|
528
634
|
|
|
529
|
-
Run `memory_archive()` monthly to move old entries to the archive. Run `memory_stats()` to check the size.
|
|
635
|
+
Run `memory_archive()` monthly to move old entries to the archive. Run `memory_stats()` to check the size and quality distribution. Low-quality entries (vague content, no tags) get lower recall priority automatically. Use `memory_consolidate` to merge duplicates.
|
|
530
636
|
|
|
531
637
|
---
|
|
532
638
|
|
|
@@ -740,7 +846,7 @@ Add to `~/.config/zed/settings.json`:
|
|
|
740
846
|
## How It Works
|
|
741
847
|
|
|
742
848
|
1. **MCP Server** — Runs locally, talks to your agent via stdio
|
|
743
|
-
2. **TOON Format** — Stores data in Token-Oriented Object Notation (~22.5% fewer tokens than JSON, measured over 16 entries with gpt-tokenizer)
|
|
849
|
+
2. **TOON Format** — Stores data in Token-Oriented Object Notation (~22.5% fewer tokens than JSON, measured over 16 entries with gpt-tokenizer). Each entry tracks quality (0–1) and confidence (0–1) automatically.
|
|
744
850
|
3. **Per-project memory** — Each project gets `.toon-memory/memory/data.toon`
|
|
745
851
|
4. **Zero config** — Just install and use
|
|
746
852
|
|
|
@@ -748,10 +854,10 @@ Add to `~/.config/zed/settings.json`:
|
|
|
748
854
|
|
|
749
855
|
```
|
|
750
856
|
version: 1
|
|
751
|
-
entries[3|]{id|category|key|content|file|tags|date|ttl|accessed|links}:
|
|
752
|
-
a1b2c3d4|decision|use-zod|Use Zod for validation|src/types.ts|validation;types|2026-07-10||0|
|
|
753
|
-
e5f6g7h8|pattern|pydantic-configs|Project uses Pydantic v2|config.py|python;patterns|2026-07-10||0|
|
|
754
|
-
i9j0k1l2|bug|redis-pool-fix|Added max_connections=20 (see [[use-zod]])|redis.ts|redis;fix|2026-07-10|7d|0|use-zod
|
|
857
|
+
entries[3|]{id|category|key|content|file|tags|date|ttl|accessed|links|quality|confidence}:
|
|
858
|
+
a1b2c3d4|decision|use-zod|Use Zod for validation|src/types.ts|validation;types|2026-07-10||0||0.65|1.0
|
|
859
|
+
e5f6g7h8|pattern|pydantic-configs|Project uses Pydantic v2|config.py|python;patterns|2026-07-10||0||0.55|1.0
|
|
860
|
+
i9j0k1l2|bug|redis-pool-fix|Added max_connections=20 (see [[use-zod]])|redis.ts|redis;fix|2026-07-10|7d|0|use-zod|0.70|0.9
|
|
755
861
|
summaries:
|
|
756
862
|
src/services/redis.ts: Redis connection pool with retry logic
|
|
757
863
|
```
|
|
@@ -792,11 +898,53 @@ The token savings compound at session time: `npm run bench:impact` simulates ret
|
|
|
792
898
|
- **22.5% fewer tokens** than JSON at file level (up to 30.5% on a single entry)
|
|
793
899
|
- **Lossless roundtrip** — No data loss
|
|
794
900
|
- **Better LLM comprehension** — Structured for AI consumption
|
|
901
|
+
- **Quality & confidence** — Every entry tracks structure quality (0–1) and reliability (0–1) automatically
|
|
795
902
|
|
|
796
903
|
> **Tip:** Fewer tokens = faster responses + lower API costs. Your agent reads memory files on every session start, so efficiency matters.
|
|
797
904
|
|
|
798
905
|
---
|
|
799
906
|
|
|
907
|
+
## Benchmark: toon-memory vs Alternatives
|
|
908
|
+
|
|
909
|
+
| Feature | toon-memory | @modelcontextprotocol/server-memory | mem0 | shodh-memory |
|
|
910
|
+
|---------|-------------|--------------------------------------|------|--------------|
|
|
911
|
+
| **Storage** | Local file (TOON) | Local file (JSON) | Cloud | RocksDB |
|
|
912
|
+
| **Dependencies** | Zero | Zero | Cloud API | sentence-transformers, RocksDB |
|
|
913
|
+
| **Search** | BM25 + graph + quality | Basic keyword | Vector only | Hybrid (vector + graph) |
|
|
914
|
+
| **Token efficiency** | 22.5% fewer than JSON | Baseline (JSON) | N/A (cloud) | Similar |
|
|
915
|
+
| **Quality scoring** | Auto (0–1, heuristics) | None | None | BND algorithm |
|
|
916
|
+
| **Merge-dedup** | Tags union + max confidence | None | None | Content dedup |
|
|
917
|
+
| **Confidence tracking** | Per-entry (0–1) | None | None | Per-entry |
|
|
918
|
+
| **System Primer** | Auto-generated | None | None | None |
|
|
919
|
+
| **Multi-session** | File-based coordination | None | N/A | None |
|
|
920
|
+
| **Hooks** | 15 agents | None | None | Claude only |
|
|
921
|
+
| **Encryption** | AES-256-GCM | None | Cloud-managed | None |
|
|
922
|
+
| **Setup time** | `npx toon-memory` | Manual JSON | Cloud signup | Docker + config |
|
|
923
|
+
|
|
924
|
+
### Token efficiency (measured)
|
|
925
|
+
|
|
926
|
+
```
|
|
927
|
+
Format Tokens (16 entries) vs JSON
|
|
928
|
+
────────────── ─────────────────── ───────
|
|
929
|
+
JSON 1097 baseline
|
|
930
|
+
TOON 850 -22.5%
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
### Recall efficiency (measured)
|
|
934
|
+
|
|
935
|
+
```
|
|
936
|
+
Method Tokens to get context vs re-reading files
|
|
937
|
+
────────────────────────────── ───────────────────── ───────────────────
|
|
938
|
+
Re-read source files ~3000 baseline
|
|
939
|
+
memory_recall (flat) ~1200 -60%
|
|
940
|
+
memory_recall (graph, compact) ~900 -70%
|
|
941
|
+
memory_smart_recall ~850 -72%
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
> **Tip:** `memory_smart_recall` combines BM25 + graph + quality in one call, saving both tokens and tool-call overhead. Use it at the start of every task.
|
|
945
|
+
|
|
946
|
+
---
|
|
947
|
+
|
|
800
948
|
## Troubleshooting
|
|
801
949
|
|
|
802
950
|
### Memory not found after install
|
|
@@ -818,7 +966,7 @@ The token savings compound at session time: `npm run bench:impact` simulates ret
|
|
|
818
966
|
|
|
819
967
|
**Symptom:** Same key appears multiple times.
|
|
820
968
|
|
|
821
|
-
**Fix:**
|
|
969
|
+
**Fix:** `memory_remember` with the same key now auto-merges (union of tags, max confidence, latest date). Use `memory_consolidate` to merge all same-key entries and remove exact-content duplicates. For manual cleanup, use `memory_forget`.
|
|
822
970
|
|
|
823
971
|
### Encryption key lost
|
|
824
972
|
|
|
@@ -834,6 +982,7 @@ The token savings compound at session time: `npm run bench:impact` simulates ret
|
|
|
834
982
|
1. Run `memory_archive()` to move old entries to archive
|
|
835
983
|
2. Use `memory_forget` to remove irrelevant entries
|
|
836
984
|
3. Keep entries concise — save the decision, not the entire conversation
|
|
985
|
+
4. Low-quality entries (vague, no tags) get lower recall priority automatically
|
|
837
986
|
|
|
838
987
|
---
|
|
839
988
|
|
|
@@ -861,7 +1010,7 @@ No, encryption applies to the entire memory file. If you need selective encrypti
|
|
|
861
1010
|
|
|
862
1011
|
### How is this different from just using a markdown file?
|
|
863
1012
|
|
|
864
|
-
Markdown files aren't structured, aren't searchable by your agent in the same way, don't integrate via MCP, and don't have features like archiving, date filtering, or encryption. toon-memory is purpose-built for AI agents.
|
|
1013
|
+
Markdown files aren't structured, aren't searchable by your agent in the same way, don't integrate via MCP, and don't have features like archiving, date filtering, quality scoring, merge-dedup, confidence tracking, or encryption. toon-memory is purpose-built for AI agents.
|
|
865
1014
|
|
|
866
1015
|
---
|
|
867
1016
|
|
|
@@ -886,17 +1035,19 @@ toon-memory/
|
|
|
886
1035
|
│ │ ├── setup.ts # CLI commands
|
|
887
1036
|
│ │ └── toon-memory.ts # CLI runner
|
|
888
1037
|
│ ├── mcp/
|
|
889
|
-
│ │ └── server.ts # MCP server (
|
|
1038
|
+
│ │ └── server.ts # MCP server (14 tools + 3 resources)
|
|
890
1039
|
│ ├── lib/
|
|
891
1040
|
│ │ ├── lock.ts # Advisory file lock + atomic write
|
|
892
1041
|
│ │ ├── sessions.ts # Multi-session coordination
|
|
893
1042
|
│ │ ├── graph.ts # Memory graph (parse, build, BM25, centrality, compact render)
|
|
1043
|
+
│ │ ├── quality.ts # Quality scoring, merge-dedup, smart recall, system primer
|
|
894
1044
|
│ │ └── vocab.ts # Project-vocabulary discovery from dependencies
|
|
895
1045
|
├── tests/
|
|
896
1046
|
│ ├── cli.test.ts # CLI tests
|
|
897
1047
|
│ ├── memory.test.ts # Memory tests
|
|
898
1048
|
│ ├── sessions.test.ts # Multi-session tests
|
|
899
|
-
│
|
|
1049
|
+
│ ├── graph.test.ts # Memory graph tests
|
|
1050
|
+
│ └── quality.test.ts # Quality scoring, merge-dedup, smart recall, system primer tests
|
|
900
1051
|
├── .github/workflows/
|
|
901
1052
|
│ ├── ci.yml # CI (Node.js 20/22)
|
|
902
1053
|
│ └── publish.yml # Auto-publish on release
|
package/bin/toon-memory.js
CHANGED
|
@@ -15,26 +15,29 @@ function getVersion() {
|
|
|
15
15
|
const HELP = `toon-memory \u2014 MCP memory server for AI coding agents
|
|
16
16
|
|
|
17
17
|
Usage:
|
|
18
|
-
toon-memory <command> [
|
|
18
|
+
toon-memory <command> [options]
|
|
19
19
|
|
|
20
20
|
Commands:
|
|
21
|
-
init [local|global]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
init [--agent <name>...] [--scope local|global]
|
|
22
|
+
Install memory tools + hooks
|
|
23
|
+
Without --agent: interactive agent selection
|
|
24
|
+
With --agent: non-interactive (default scope: local)
|
|
25
|
+
status Show version, memory count, and agent config status
|
|
26
|
+
stats Show memory statistics
|
|
27
|
+
dump Print memory as injectable markdown (auto-load)
|
|
28
|
+
export [file] Export memory to a TOON/JSON file
|
|
29
|
+
import <file> Import memory from a TOON/JSON file
|
|
30
|
+
watch Watch memory file and re-render on change
|
|
31
|
+
uninstall Remove toon-memory from all agents
|
|
32
|
+
capture <on|off> Enable/disable activity capture hooks
|
|
33
|
+
upgrade Upgrade to the latest version
|
|
31
34
|
|
|
32
35
|
Options:
|
|
33
|
-
-v, --version
|
|
34
|
-
-h, --help
|
|
36
|
+
-v, --version Show version
|
|
37
|
+
-h, --help Show this help
|
|
35
38
|
|
|
36
39
|
MCP mode:
|
|
37
|
-
toon-memory mcp
|
|
40
|
+
toon-memory mcp Run as an MCP server (stdio)
|
|
38
41
|
`;
|
|
39
42
|
if (args[0] === "-v" || args[0] === "--version") {
|
|
40
43
|
console.log(getVersion());
|