toon-memory 3.5.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,7 +65,7 @@ Read [How toon-memory Makes Your AI Agent Smarter](https://luiggival08.github.io
65
65
 
66
66
  ## Features
67
67
 
68
- - **35 MCP tools** — Full memory management via Model Context Protocol, including `memory_smart_recall` (unified recall with session bias), `memory_sessions` for multi-session coordination, `context_*` tools for one-call context generation (briefing, diff, focus, health audit, export), `memory_compress` (LLM-powered compression), `memory_compress_all` (batch compression), `memory_primer` (auto-injected context), `memory_merge_sessions` (cross-session merge), `memory_pin`/`memory_unpin` (pin important entries with priority 1-5), `memory_checkpoint` (session snapshot with 7d TTL), `memory_search` (unified search with tag filters + session bias), `memory_tag` (batch tag operations), and `memory_export_gist`/`memory_import_gist` (GitHub Gist sync)
68
+ - **37 MCP tools** — Full memory management via Model Context Protocol, including `memory_smart_recall` (unified recall with session bias), `memory_sessions` for multi-session coordination, `context_*` tools for one-call context generation (briefing, diff, focus, health audit, export), `memory_compress` (LLM-powered compression), `memory_compress_all` (batch compression), `memory_primer` (auto-injected context), `memory_merge_sessions` (cross-session merge), `memory_pin`/`memory_unpin` (pin important entries with priority 1-5), `memory_checkpoint` (session snapshot with 7d TTL), `memory_search` (unified search with tag filters + session bias), `memory_tag` (batch tag operations), `memory_export_gist`/`memory_import_gist` (GitHub Gist sync), `memory_resolve` (restore soft-deleted entries), and `memory_suppress` (mark entries as obsolete)
69
69
  - **MCP Resources** — Read memory as context without tool invocations, including a System Primer (auto-generated knowledge map)
70
70
  - **15 agents supported** — OpenCode, VS Code, Claude Code, Cursor, Windsurf, Cline, Continue, Codex CLI, Gemini CLI, Zed, Antigravity, Aider, KiloCode, OpenClaw, Kiro
71
71
  - **Interactive installer** — Select which agents to configure from a menu
@@ -97,6 +97,11 @@ Read [How toon-memory Makes Your AI Agent Smarter](https://luiggival08.github.io
97
97
  - **Verbatim mode** — `config.verbatim` preserves original entries instead of overwriting on save
98
98
  - **Context generation tools** — `context_generate` (full briefing), `context_diff` (incremental), `context_focus` (targeted), `context_health` (audit), `context_export` (markdown) — each replaces 5-6 manual tool calls. Zero LLM, pure deterministic aggregation
99
99
  - **System Primer** — Auto-injected at session start via `systemPrimer()`, showing top 5 memories for instant context
100
+ - **Path Scoping** — Entries can be scoped to file paths via glob patterns (`path_scope`); recall filters by scope automatically
101
+ - **Budget Control** — Three output levels: `budget: "tiny"` (key+1 line, ~50 tokens), `"normal"` (compact with tags/edges), `"deep"` (all fields with origin/scope/status). Backward compatible with `compact: true`
102
+ - **Origin Tracking** — Each entry tracks its origin (`human`, `agent`, `inferred`); human assertions get a quality boost
103
+ - **Soft Delete** — `memory_forget` soft-deletes by default (sets `status=obsolete`). Use `memory_resolve` to restore, `memory_suppress` to hide. Permanent deletion via `hard: true`
104
+ - **Enhanced Health Audit** — `context_health` now detects missing-evidence (path_scope without file) and stale-claims (overlapping content in same category)
100
105
 
101
106
  ---
102
107
 
@@ -219,10 +224,10 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
219
224
  | Tool | Description |
220
225
  |------|-------------|
221
226
  | `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) |
222
- | `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. `sessionBias` boosts entries from the current git branch. Quality-weighted ranking |
227
+ | `memory_recall` | Search memory (use BEFORE reading files, filters expired TTL). `mode: "graph"` expands a relationship-aware subgraph for higher precision. `budget: "tiny"|"normal"|"deep"` controls output verbosity (backward compat with `compact: true`). `path_scope` filters by glob pattern. `sessionBias` boosts entries from the current git branch. Quality-weighted ranking |
223
228
  | `memory_smart_recall` | **Unified recall**: BM25 + graph + decay + quality in one call. `sessionBias` boosts entries from the current git branch. Use at the START of every task. Returns compact, token-efficient output |
224
- | `memory_forget` | Remove an entry by key or id |
225
- | `memory_stats` | View memory state (including TTL stats, quality distribution, and cold memories below quality/access thresholds) |
229
+ | `memory_forget` | Remove an entry by key or id. Soft-deletes by default (sets `status=obsolete`); use `hard: true` for permanent removal. Restore with `memory_resolve` |
230
+ | `memory_stats` | View memory state (including TTL stats, quality distribution, origin/status breakdown, and cold memories below quality/access thresholds) |
226
231
  | `memory_summary` | Save/retrieve file summaries |
227
232
  | `memory_archive` | Archive old entries (>30 days) and expired TTL entries |
228
233
  | `memory_diff` | Show changes since a date (24h, 7d, or exact date) |
@@ -250,7 +255,9 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
250
255
  | `context_export` | **Export memory as markdown**: injectable context for system prompts (full or compact) |
251
256
  | `memory_pin` | **Pin an entry with priority 1-5**: pinned entries always appear first in recall results sorted by priority, even without a keyword match |
252
257
  | `memory_unpin` | **Unpin an entry**: remove the priority flag |
253
- | `memory_search` | **Unified search with filters**: same as `memory_recall` plus `category`, `tags`, `from_date`, `to_date` filters. Tag filter uses AND logic — all specified tags must match. `sessionBias` boosts entries from the current git branch |
258
+ | `memory_resolve` | **Restore a soft-deleted entry**: sets `status=active`. Reverses `memory_forget` or `memory_suppress` |
259
+ | `memory_suppress` | **Hide an entry**: marks as `status=obsolete`, filtered from normal recalls. Restore with `memory_resolve` |
260
+ | `memory_search` | **Unified search with filters**: same as `memory_recall` plus `category`, `tags`, `from_date`, `to_date` filters. Tag filter uses AND logic — all specified tags must match. `budget` controls output verbosity. `path_scope` filters by glob pattern. `sessionBias` boosts entries from the current git branch |
254
261
  | `memory_tag` | **Batch tag operations**: `add`, `remove`, or `set` tags on one or more entries by key or id |
255
262
 
256
263
  ### MCP Resources
@@ -452,7 +459,7 @@ context_health({})
452
459
  // - src/legacy.ts (deleted, 2 refs)
453
460
  ```
454
461
 
455
- > **Tip:** Run `context_health` when memory feels cluttered. Shows orphan links, duplicates, expired TTL entries, and broken file references.
462
+ > **Tip:** Run `context_health` when memory feels cluttered. Shows orphan links, duplicates, expired TTL entries, broken file references, missing-evidence entries (path_scope without file), and stale claims (overlapping content).
456
463
 
457
464
  #### Merge-dedup (automatic)
458
465
 
@@ -493,6 +500,7 @@ Every entry gets an automatic quality score (0–1) based on structure:
493
500
  | Content length | 0.3 max | Detailed > vague |
494
501
  | Recency | 0.1 max | Recent entries score higher |
495
502
  | Specificity | 0.1 max | Unique words vs repeated words |
503
+ | Origin | +0.1/−0.05 | Human assertions boosted, inferred slightly penalized |
496
504
 
497
505
  High-quality entries surface first in recall. Check quality with `memory_stats`:
498
506
 
@@ -672,7 +680,7 @@ How `compact` changes the output:
672
680
  - Quality-weighted ranking ensures the most useful entries appear first.
673
681
  - The stored `.toon` file is **never** mutated — `compact` only reshapes the response.
674
682
 
675
- > **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.
683
+ > **Tip:** Combine `compact: true` with `mode: "graph"` for the smallest possible context window when recalling from a large, interconnected memory. For proactive/background recall, use `budget: "tiny"` which returns just the key + one line (~50 tokens). Or just use `memory_smart_recall` which does this automatically.
676
684
 
677
685
  ### How recall ranks results
678
686
 
@@ -1041,10 +1049,10 @@ Add to `~/.config/zed/settings.json`:
1041
1049
 
1042
1050
  ```
1043
1051
  version: 1
1044
- entries[3|]{id|category|key|content|file|tags|date|ttl|accessed|links|quality|confidence}:
1045
- a1b2c3d4|decision|use-zod|Use Zod for validation|src/types.ts|validation;types|2026-07-10||0||0.65|1.0
1046
- e5f6g7h8|pattern|pydantic-configs|Project uses Pydantic v2|config.py|python;patterns|2026-07-10||0||0.55|1.0
1047
- 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
1052
+ entries[3|]{id|category|key|content|file|tags|date|ttl|accessed|links|quality|confidence|lastAccessed|priority|path_scope|origin|status}:
1053
+ a1b2c3d4|decision|use-zod|Use Zod for validation|src/types.ts|validation;types|2026-07-10||0||0.65|1.0||0||agent|active
1054
+ e5f6g7h8|pattern|pydantic-configs|Project uses Pydantic v2|config.py|python;patterns|2026-07-10||0||0.55|1.0||0||agent|active
1055
+ 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||0||agent|active
1048
1056
  summaries:
1049
1057
  src/services/redis.ts: Redis connection pool with retry logic
1050
1058
  ```
package/dist/cli/setup.js CHANGED
@@ -740,14 +740,15 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
740
740
  return await $\`npx -y toon-memory dump\`.cwd(root).text()
741
741
  }
742
742
 
743
- const recall = async (query) => {
743
+ const recall = async (query, opts = {}) => {
744
744
  try {
745
+ const args = { query, mode: "flat", budget: opts.budget || "tiny", path_scope: opts.path_scope || "" }
745
746
  const result = await $\`npx -y toon-memory mcp\`.cwd(root)
746
747
  .stdin(JSON.stringify({
747
748
  jsonrpc: "2.0",
748
749
  id: 1,
749
750
  method: "tools/call",
750
- params: { name: "memory_recall", arguments: { query, mode: "flat", compact: true } }
751
+ params: { name: "memory_recall", arguments: args }
751
752
  }))
752
753
  .text()
753
754
  const parsed = JSON.parse(result)
@@ -776,6 +777,7 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
776
777
  "tool.execute.after": async (input) => {
777
778
  // Intelligent auto-loading: extract file path from tool result,
778
779
  // recall only memory relevant to that file, inject as context.
780
+ // Also proactively recalls entries scoped to the matched paths.
779
781
  try {
780
782
  const toolName = input?.tool || ""
781
783
  const args = input?.args || {}
@@ -785,6 +787,7 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
785
787
  if (args.file) filePath = args.file
786
788
  else if (args.path) filePath = args.path
787
789
  else if (args.filePath) filePath = args.filePath
790
+ else if (args.target) filePath = args.target
788
791
 
789
792
  // Also try to extract from tool output text
790
793
  if (!filePath && input?.output) {
@@ -793,19 +796,40 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
793
796
  if (fileMatch) filePath = fileMatch[1]
794
797
  }
795
798
 
796
- if (!filePath) return
797
-
798
- // Build recall query from file path components
799
- const basename = path.basename(filePath, path.extname(filePath))
800
- const dirParts = path.dirname(filePath).split(path.sep).filter(Boolean)
801
- const query = [basename, ...dirParts.slice(-2)].join(" ")
802
-
803
- const text = await recall(query)
804
- if (!text || text.includes("(empty)") || text.includes("No results")) return
799
+ if (filePath) {
800
+ // Build recall query from file path components
801
+ const basename = path.basename(filePath, path.extname(filePath))
802
+ const dirParts = path.dirname(filePath).split(path.sep).filter(Boolean)
803
+ const query = [basename, ...dirParts.slice(-2)].join(" ")
804
+
805
+ const text = await recall(query, { budget: "tiny", path_scope: filePath })
806
+ if (text && !text.includes("(empty)") && !text.includes("No results")) {
807
+ if (typeof input?.setContext === "function") {
808
+ input.setContext("toon-memory:" + filePath, text)
809
+ }
810
+ }
811
+ }
805
812
 
806
- // Inject as context for the next agent turn
807
- if (typeof input?.setContext === "function") {
808
- input.setContext("toon-memory:" + filePath, text)
813
+ // Proactive recall: if no file was found, try tool-name-based recall
814
+ // for common tool patterns that may have relevant memory entries
815
+ if (!filePath && toolName) {
816
+ const toolKeywords = toolName
817
+ .replace(/^memory_/, "")
818
+ .replace(/^context_/, "")
819
+ .replace(/^file_/, "")
820
+ .replace(/^text_document_/, "")
821
+ .split("_")
822
+ .filter(Boolean)
823
+ .join(" ")
824
+
825
+ if (toolKeywords.length > 3) {
826
+ const text = await recall(toolKeywords, { budget: "tiny" })
827
+ if (text && !text.includes("(empty)") && !text.includes("No results")) {
828
+ if (typeof input?.setContext === "function") {
829
+ input.setContext("toon-memory:" + toolName, text)
830
+ }
831
+ }
832
+ }
809
833
  }
810
834
  } catch {}
811
835
  },
@@ -1579,7 +1603,10 @@ function parseEntries(data) {
1579
1603
  accessed: accessedRaw ? parseInt(accessedRaw) || 0 : 0,
1580
1604
  links: (linksRaw || "").split(/[\s;]+/).map((t) => t.trim()).filter(Boolean),
1581
1605
  lastAccessed: parts.length > 12 ? parts[12] || "" : "",
1582
- priority: parts.length > 13 ? parseInt(parts[13]) || 0 : 0
1606
+ priority: parts.length > 13 ? parseInt(parts[13]) || 0 : 0,
1607
+ path_scope: parts.length > 14 ? parts[14] || "" : "",
1608
+ origin: parts.length > 15 && parts[15] ? parts[15] : "agent",
1609
+ status: parts.length > 16 && parts[16] ? parts[16] : "active"
1583
1610
  });
1584
1611
  }
1585
1612
  return out;