toon-memory 2.7.0 → 2.9.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "2.7.0",
4
- "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 20 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
3
+ "version": "2.9.0",
4
+ "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 21 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "toon-memory": "./bin/toon-memory.js"
@@ -31,13 +31,9 @@
31
31
  "prepublishOnly": "npm run build && npm test"
32
32
  },
33
33
  "dependencies": {
34
- "@ffmpeg-installer/ffmpeg": "^1.1.0",
35
34
  "@inquirer/prompts": "^8.5.2",
36
35
  "@modelcontextprotocol/server": "^2.0.0-beta.3",
37
36
  "@toon-format/toon": "^2.3.0",
38
- "ffmpeg-static": "^5.3.0",
39
- "hyperframes": "^0.7.59",
40
- "yauzl": "^3.4.0",
41
37
  "zod": "^4.4.3"
42
38
  },
43
39
  "devDependencies": {
package/src/cli/agents.ts CHANGED
@@ -72,8 +72,9 @@ export function detectAgents(): Agent[] {
72
72
  local: join(projectRoot, ".cursor", "mcp.json"),
73
73
  mcpKey: "mcpServers",
74
74
  format: "json",
75
- needsHooks: false,
76
- needsInstructions: false
75
+ needsHooks: true,
76
+ needsInstructions: false,
77
+ captureJson: ["PostToolUse", "Stop"]
77
78
  })
78
79
 
79
80
  agents.push({
@@ -81,8 +82,9 @@ export function detectAgents(): Agent[] {
81
82
  global: join(HOME, ".codeium", "windsurf", "mcp_config.json"),
82
83
  mcpKey: "mcpServers",
83
84
  format: "json",
84
- needsHooks: false,
85
- needsInstructions: false
85
+ needsHooks: true,
86
+ needsInstructions: false,
87
+ captureJson: ["PostToolUse", "Stop"]
86
88
  })
87
89
 
88
90
  agents.push({
@@ -121,7 +123,8 @@ export function detectAgents(): Agent[] {
121
123
  format: "json",
122
124
  needsHooks: true,
123
125
  needsInstructions: true,
124
- instructionFile: join(projectRoot, ".gemini", "GEMINI.md")
126
+ instructionFile: join(projectRoot, ".gemini", "GEMINI.md"),
127
+ captureJson: ["PostToolUse", "Stop"]
125
128
  })
126
129
 
127
130
  agents.push({
@@ -20,10 +20,10 @@ export function captureToggle(enable: boolean): void {
20
20
  writeFileSync(CAPTURE_CONFIG, JSON.stringify(config, null, 2))
21
21
 
22
22
  if (enable) {
23
- console.log("\n🔴 Captura de actividad HABILITADA.")
24
- console.log("Los hooks grabarán observaciones en .toon-memory/memory/observations.toon.")
25
- console.log("Revisa con `memory_captured` y promuévelas con `memory_remember`.\n")
23
+ console.log("\n🔴 Activity capture ENABLED.")
24
+ console.log("Hooks will write observations to .toon-memory/memory/observations.toon.")
25
+ console.log("Review with `memory_captured` and promote with `memory_remember`.\n")
26
26
  } else {
27
- console.log("\n⚪ Captura de actividad DESHABILITADA.\n")
27
+ console.log("\n⚪ Activity capture DISABLED.\n")
28
28
  }
29
29
  }
@@ -3,6 +3,7 @@ import { join } from "path"
3
3
  import { createHash } from "crypto"
4
4
  import { withLockSync, atomicWrite } from "../lib/lock"
5
5
  import { heartbeat, endSession, resolveSessionId, currentBranch } from "../lib/sessions"
6
+ import { pruneObservations } from "../mcp/observations"
6
7
 
7
8
  /**
8
9
  * Hook capture script for toon-memory.
@@ -181,6 +182,10 @@ function main(): void {
181
182
  if (!isStop && !toolName) process.exit(0)
182
183
 
183
184
  appendObservation(`${ts}|${sessionId}|${agent}|${branch}|${effectiveTool}|${hash}|${file}|${summary}`)
185
+
186
+ // Auto-prune observations log to prevent unbounded growth
187
+ pruneObservations()
188
+
184
189
  process.exit(0)
185
190
  }
186
191
 
@@ -17,9 +17,9 @@ const CAPTURE_CONFIG = join(MEMORY_DIR, "config.json")
17
17
  /** Interactive multi-select for agents using @inquirer/prompts. */
18
18
  export async function promptAgentSelection(agents: Agent[]): Promise<Agent[]> {
19
19
  return checkbox({
20
- message: "¿Qué agentes quieres configurar?",
20
+ message: "Which agents do you want to configure?",
21
21
  choices: agents.map((a) => ({
22
- name: `${a.name} (${a.format === "none" ? "instrucciones" : a.global ? "local/global" : "solo local"})`,
22
+ name: `${a.name} (${a.format === "none" ? "instructions" : a.global ? "local/global" : "local only"})`,
23
23
  value: a,
24
24
  checked: true
25
25
  }))
@@ -75,23 +75,23 @@ export async function init(scope?: string, agentFilter?: string[]): Promise<void
75
75
  return
76
76
  }
77
77
  finalScope = await select({
78
- message: "Alcance:",
78
+ message: "Scope:",
79
79
  choices: [
80
- { name: "Local (proyecto)", value: "local" },
80
+ { name: "Local (project)", value: "local" },
81
81
  { name: "Global (~home)", value: "global" }
82
82
  ],
83
83
  default: finalScope as "local" | "global"
84
84
  })
85
- const ok = await confirm({ message: "¿Proceder?", default: true })
85
+ const ok = await confirm({ message: "Proceed?", default: true })
86
86
  if (!ok) {
87
- console.log("\nInstalación cancelada.\n")
87
+ console.log("\nInstallation cancelled.\n")
88
88
  return
89
89
  }
90
90
  } else {
91
91
  selected = agents
92
92
  }
93
93
 
94
- console.log(`\nInstalando (${finalScope}) — ${selected.map((a) => a.name).join(", ")}...\n`)
94
+ console.log(`\nInstalling (${finalScope}) — ${selected.map((a) => a.name).join(", ")}...\n`)
95
95
 
96
96
  for (const agent of selected) {
97
97
  installForAgent(agent, finalScope)
@@ -485,33 +485,33 @@ export function dumpMemory(): void {
485
485
  */
486
486
  export async function interactiveInstall(): Promise<void> {
487
487
  if (!process.stdin.isTTY) {
488
- console.log("\n🧠 toon-memory — la instalación interactiva requiere una terminal.")
489
- console.log("Ejecuta 'toon-memory init [--agent <nombre>]' para instalación no interactiva.\n")
488
+ console.log("\n🧠 toon-memory — interactive installation requires a terminal.")
489
+ console.log("Run 'toon-memory init [--agent <name>]' for non-interactive installation.\n")
490
490
  return
491
491
  }
492
492
 
493
493
  const agents = detectAgents()
494
494
  const selected = await promptAgentSelection(agents)
495
495
  if (selected.length === 0) {
496
- console.log("\nNo se seleccionaron agentes. Nada instalado.\n")
496
+ console.log("\nNo agents selected. Nothing installed.\n")
497
497
  return
498
498
  }
499
499
 
500
500
  const scope = await select({
501
- message: "Alcance:",
501
+ message: "Scope:",
502
502
  choices: [
503
- { name: "Local (proyecto)", value: "local" },
503
+ { name: "Local (project)", value: "local" },
504
504
  { name: "Global (~home)", value: "global" }
505
505
  ]
506
506
  })
507
507
 
508
- const ok = await confirm({ message: "¿Proceder?", default: true })
508
+ const ok = await confirm({ message: "Proceed?", default: true })
509
509
  if (!ok) {
510
- console.log("\nInstalación cancelada.\n")
510
+ console.log("\nInstallation cancelled.\n")
511
511
  return
512
512
  }
513
513
 
514
- console.log(`\nInstalando (${scope}) — ${selected.map((a) => a.name).join(", ")}...\n`)
514
+ console.log(`\nInstalling (${scope}) — ${selected.map((a) => a.name).join(", ")}...\n`)
515
515
  installMemoryDir()
516
516
 
517
517
  const deps = extractProjectDeps(projectRoot)
@@ -52,5 +52,5 @@ Persistent memory for this project. Use it to avoid re-investigating things.
52
52
  */
53
53
  export const OPENCODE_PASSIVE_INSTRUCTION = `# toon-memory
54
54
 
55
- La memoria se auto-inyecta vía .opencode/instructions/memory-autoload.md; usa memory_recall solo como fallback.
55
+ Memory auto-injects via .opencode/instructions/memory-autoload.md; use memory_recall only as fallback.
56
56
  `
@@ -41,28 +41,28 @@ function main(): void {
41
41
  const others = view.active.filter((s) => s.id !== sessionId && !s.ended)
42
42
  const lines: string[] = []
43
43
  lines.push("toon-memory:")
44
- lines.push(` Esta sesión: ${agent} @ ${currentBranch()} (ventana ${Math.round(SESSION_TTL_MS / 60000)} min)`)
44
+ lines.push(` This session: ${agent} @ ${currentBranch()} (window ${Math.round(SESSION_TTL_MS / 60000)} min)`)
45
45
 
46
46
  if (others.length > 0) {
47
- lines.push(` Otras sesiones activas (${others.length}):`)
47
+ lines.push(` Other active sessions (${others.length}):`)
48
48
  for (const s of others) {
49
49
  const files = Object.keys(s.files).slice(0, 5).join(", ") || "—"
50
50
  lines.push(` • ${s.agent} @ ${s.branch} — ${files}`)
51
51
  }
52
52
  } else {
53
- lines.push(" Sin otras sesiones activas.")
53
+ lines.push(" No other active sessions.")
54
54
  }
55
55
 
56
56
  if (view.conflicts.length > 0) {
57
- lines.push(` ⚠️ Conflictos suaves (${view.conflicts.length}): usa memory_sessions para ver detalle.`)
57
+ lines.push(` ⚠️ Soft conflicts (${view.conflicts.length}): use memory_sessions for details.`)
58
58
  for (const c of view.conflicts) {
59
59
  lines.push(` • ${c.file}`)
60
60
  }
61
61
  } else {
62
- lines.push(" Sin conflictos de archivos detectados.")
62
+ lines.push(" No file conflicts detected.")
63
63
  }
64
64
 
65
- lines.push(" Usa memory_recall antes de leer archivos y memory_sessions para coordinar.")
65
+ lines.push(" Use memory_recall before reading files and memory_sessions to coordinate.")
66
66
  console.log(lines.join("\n"))
67
67
  process.exit(0)
68
68
  }
package/src/cli/setup.ts CHANGED
@@ -78,17 +78,17 @@ if (args.length === 0) {
78
78
  process.exit(0)
79
79
  }
80
80
 
81
- console.log(`Comando desconocido: '${args[0]}'\n`)
81
+ console.log(`Unknown command: '${args[0]}'\n`)
82
82
  printUsage()
83
83
  process.exit(1)
84
84
 
85
85
  /** Minimal usage string for unknown commands. */
86
86
  function printUsage(): void {
87
- console.log(`Uso: toon-memory <comando> [opciones]
88
- Comandos: init, status, stats, export, import, watch, uninstall, capture, upgrade, mcp
89
- Init: toon-memory init [--agent <nombre> --agent <nombre>...] [--scope local|global]
90
- Sin --agent: selector interactivo de agentes y scope.
91
- Con --agent: instalación no interactiva (default: scope local).
92
- Opciones: -v/--version, -h/--help
93
- Sin argumentos inicia el instalador interactivo.`)
87
+ console.log(`Usage: toon-memory <command> [options]
88
+ Commands: init, status, stats, export, import, watch, uninstall, capture, upgrade, mcp
89
+ Init: toon-memory init [--agent <name> --agent <name>...] [--scope local|global]
90
+ Without --agent: interactive agent and scope selector.
91
+ With --agent: non-interactive installation (default: scope local).
92
+ Options: -v/--version, -h/--help
93
+ No arguments starts the interactive installer.`)
94
94
  }
@@ -17,31 +17,12 @@ import { existsSync, readFileSync } from "fs"
17
17
  import { join } from "path"
18
18
  import { parseEntries, buildGraph, bm25Scores, centrality, renderCompact, type GraphEntry } from "./graph"
19
19
  import { qualityScore } from "./quality"
20
+ import { normalize, isExpiredLocal, tokenize, importance } from "./utils"
20
21
  import { coordinationView, currentBranch, pruneSessions, listSessions } from "./sessions"
21
22
  import { readRecentCommits, gitStatusSummary, readGitIndex } from "./git"
22
23
  import { scanProjectStructure, readManifest, readEnvExample } from "./project-scan"
23
24
  import { findFilesByPattern, searchCode, findCallers } from "./code-search"
24
25
 
25
- const normalize = (s: string): string =>
26
- s.toLowerCase().replace(/[-_]/g, " ").replace(/\s+/g, " ").trim()
27
-
28
- const tokenize = (s: string): string[] => normalize(s).split(" ").filter(Boolean)
29
-
30
- const isExpiredLocal = (ttl: string): boolean => {
31
- if (!ttl) return false
32
- const today = new Date().toISOString().split("T")[0]
33
- return ttl <= today
34
- }
35
-
36
- const importance = (e: GraphEntry): number => {
37
- const today = new Date().toISOString().split("T")[0]
38
- const days =
39
- (Date.now() - new Date(`${e.date || today}T00:00:00`).getTime()) / 86400000
40
- const recency = Math.max(0, 30 - days) / 30
41
- const freq = Math.min(1, e.accessed / 5)
42
- return recency * 0.6 + freq * 0.4
43
- }
44
-
45
26
  // ── Section builders ────────────────────────────────────────────────
46
27
 
47
28
  /**
@@ -50,7 +31,7 @@ const importance = (e: GraphEntry): number => {
50
31
  */
51
32
  function formatOverview(data: string): string {
52
33
  const entries = parseEntries(data)
53
- if (entries.length === 0) return "Memoria: vacía"
34
+ if (entries.length === 0) return "Memory: empty"
54
35
 
55
36
  const byCategory: Record<string, number> = {}
56
37
  let expired = 0
@@ -62,9 +43,9 @@ function formatOverview(data: string): string {
62
43
  const cats = Object.entries(byCategory)
63
44
  .map(([k, v]) => `${k}:${v}`)
64
45
  .join(" ")
65
- const ttlNote = expired > 0 ? ` | ${expired} expiradas` : ""
46
+ const ttlNote = expired > 0 ? ` | ${expired} expired` : ""
66
47
 
67
- return `## Memoria (${entries.length} entradas)${ttlNote}\n${cats}`
48
+ return `## Memory (${entries.length} entries)${ttlNote}\n${cats}`
68
49
  }
69
50
 
70
51
  /**
@@ -114,7 +95,7 @@ function formatRelevantEntries(data: string, task: string, limit: number = 6): s
114
95
  { adjacency: subAdj, seeds, snippetLen: 80 }
115
96
  )
116
97
 
117
- return `## Entradas relevantes\n${rendered}`
98
+ return `## Relevant entries\n${rendered}`
118
99
  }
119
100
 
120
101
  /**
@@ -133,7 +114,7 @@ function formatPatterns(data: string): string {
133
114
  const lines = patterns.map(
134
115
  (e) => `- **${e.key}**: ${e.content.slice(0, 120)}`
135
116
  )
136
- return `## Patrones establecidos\n${lines.join("\n")}`
117
+ return `## Established patterns\n${lines.join("\n")}`
137
118
  }
138
119
 
139
120
  /**
@@ -145,19 +126,19 @@ function formatSessions(): string {
145
126
  const branch = currentBranch()
146
127
 
147
128
  if (active.length === 0 && conflicts.length === 0) {
148
- return `## Sesiones\nRama: ${branch} | Sin otras sesiones activas`
129
+ return `## Sessions\nBranch: ${branch} | No other active sessions`
149
130
  }
150
131
 
151
- const lines: string[] = [`## Sesiones (${active.length} activa${active.length !== 1 ? "s" : ""}) —rama: ${branch}`]
132
+ const lines: string[] = [`## Sessions (${active.length} active) — branch: ${branch}`]
152
133
 
153
134
  for (const s of active.slice(0, 5)) {
154
135
  const mins = Math.max(0, Math.round(s.ageMs / 60000))
155
136
  const files = Object.keys(s.files).length
156
- lines.push(`- ${s.agent}@${s.branch} (${mins}min, ${files} archivos)`)
137
+ lines.push(`- ${s.agent}@${s.branch} (${mins}min, ${files} files)`)
157
138
  }
158
139
 
159
140
  if (conflicts.length > 0) {
160
- lines.push("", `**Conflictos suaves (${conflicts.length}):**`)
141
+ lines.push("", `**Soft conflicts (${conflicts.length}):**`)
161
142
  for (const c of conflicts.slice(0, 3)) {
162
143
  const who = c.sessions.map((s) => s.agent).join(" + ")
163
144
  lines.push(`- ${c.file} ↔ ${who}`)
@@ -177,21 +158,21 @@ function formatHealth(data: string): string {
177
158
 
178
159
  const expired = entries.filter((e) => e.ttl && isExpiredLocal(e.ttl))
179
160
  if (expired.length > 0) {
180
- warnings.push(`${expired.length} entradas con TTL expirado (ejecutar memory_archive)`)
161
+ warnings.push(`${expired.length} entries with expired TTL (run memory_archive)`)
181
162
  }
182
163
 
183
164
  if (entries.length > 80) {
184
- warnings.push(`${entries.length} entradas (cerca del límite de 100, auto-archive se activará)`)
165
+ warnings.push(`${entries.length} entries (near limit of 100, auto-archive will trigger)`)
185
166
  }
186
167
 
187
168
  const orphanLinks = findOrphanLinks(entries)
188
169
  if (orphanLinks.length > 0) {
189
- warnings.push(`${orphanLinks.length} links huérfanos: ${orphanLinks.slice(0, 3).join(", ")}`)
170
+ warnings.push(`${orphanLinks.length} orphan links: ${orphanLinks.slice(0, 3).join(", ")}`)
190
171
  }
191
172
 
192
173
  if (warnings.length === 0) return ""
193
174
 
194
- return `## Salud\n⚠️ ${warnings.join("\n⚠️ ")}`
175
+ return `## Health\n⚠️ ${warnings.join("\n⚠️ ")}`
195
176
  }
196
177
 
197
178
  /**
@@ -271,7 +252,7 @@ function formatTopEntries(data: string, limit: number): string {
271
252
  if (top.length === 0) return ""
272
253
 
273
254
  const rendered = renderCompact(top)
274
- return `## Top memorias\n${rendered}`
255
+ return `## Top memories\n${rendered}`
275
256
  }
276
257
 
277
258
  // ── context_generate ─────────────────────────────────────────────────
@@ -291,9 +272,9 @@ export function generateContextGenerate(data: string, root: string, opts: Contex
291
272
  // 1. Project manifest
292
273
  const manifest = readManifest(root)
293
274
  if (manifest) {
294
- const deps = manifest.deps.length > 0 ? manifest.deps.slice(0, 15).join(", ") : "ninguna"
275
+ const deps = manifest.deps.length > 0 ? manifest.deps.slice(0, 15).join(", ") : "none"
295
276
  const version = manifest.version ? ` v${manifest.version}` : ""
296
- sections.push(`## Proyecto\n${manifest.name}${version} (${manifest.language})\nDeps: ${deps}`)
277
+ sections.push(`## Project\n${manifest.name}${version} (${manifest.language})\nDeps: ${deps}`)
297
278
  }
298
279
 
299
280
  // 2. Structure
@@ -306,9 +287,9 @@ export function generateContextGenerate(data: string, root: string, opts: Contex
306
287
  .slice(0, 5)
307
288
  .map(([k, v]) => `${k}:${v}`)
308
289
  .join(" ")
309
- const src = `${structure.sourceFileCount} archivos fuente`
290
+ const src = `${structure.sourceFileCount} source files`
310
291
  const parts = [dirs, files, `${src} ${exts ? `(${exts})` : ""}`].filter(Boolean)
311
- if (parts.length > 0) sections.push(`## Estructura\n${parts.join("\n")}`)
292
+ if (parts.length > 0) sections.push(`## Structure\n${parts.join("\n")}`)
312
293
  }
313
294
 
314
295
  // 3. Environment variables
@@ -323,8 +304,8 @@ export function generateContextGenerate(data: string, root: string, opts: Contex
323
304
  if (git.branch !== "unknown") {
324
305
  const recent = git.recentCommits.slice(0, 3)
325
306
  const commitLines = recent.map((c) => `- ${c.shortHash} ${c.subject}`)
326
- const parts = [`Rama: ${git.branch}`, `Archivos tracked: ${git.trackedFiles}`]
327
- if (commitLines.length > 0) parts.push(`Últimos commits:\n${commitLines.join("\n")}`)
307
+ const parts = [`Branch: ${git.branch}`, `Tracked files: ${git.trackedFiles}`]
308
+ if (commitLines.length > 0) parts.push(`Recent commits:\n${commitLines.join("\n")}`)
328
309
  sections.push(`## Git\n${parts.join("\n")}`)
329
310
  }
330
311
 
@@ -351,7 +332,7 @@ export function generateContextGenerate(data: string, root: string, opts: Contex
351
332
  // ── context_diff ─────────────────────────────────────────────────────
352
333
 
353
334
  /**
354
- * What changed since the last session: git commits + memory changes + touched files.
335
+ * What changed since the last session: git commits + memory changes + touched files + session activity.
355
336
  * ~200-400 tokens. Zero LLM.
356
337
  */
357
338
  export function generateContextDiff(data: string, root: string, since?: string): string {
@@ -373,7 +354,7 @@ export function generateContextDiff(data: string, root: string, since?: string):
373
354
  // 2. Modified files from git index
374
355
  const tracked = readGitIndex(root)
375
356
  if (tracked.length > 0) {
376
- sections.push(`## Archivos tracked (${tracked.length})\n${tracked.slice(0, 20).join("\n")}`)
357
+ sections.push(`## Tracked files (${tracked.length})\n${tracked.slice(0, 20).join("\n")}`)
377
358
  }
378
359
 
379
360
  // 3. Memory changes (reuse existing diff logic)
@@ -385,19 +366,33 @@ export function generateContextDiff(data: string, root: string, since?: string):
385
366
  const created = recentEntries.filter((e) => e.date === today)
386
367
  const updated = recentEntries.filter((e) => e.date !== today)
387
368
  const parts: string[] = []
388
- if (created.length > 0) parts.push(`Nuevas: ${created.map((e) => e.key).join(", ")}`)
389
- if (updated.length > 0) parts.push(`Actualizadas: ${updated.map((e) => e.key).join(", ")}`)
390
- if (parts.length > 0) sections.push(`## Memoria (${recentEntries.length} cambios)\n${parts.join("\n")}`)
369
+ if (created.length > 0) parts.push(`New: ${created.map((e) => e.key).join(", ")}`)
370
+ if (updated.length > 0) parts.push(`Updated: ${updated.map((e) => e.key).join(", ")}`)
371
+ if (parts.length > 0) sections.push(`## Memory (${recentEntries.length} changes)\n${parts.join("\n")}`)
391
372
  }
392
373
 
393
- // 4. Active sessions
394
- const sessions = listSessions().filter((s) => s.active)
395
- if (sessions.length > 0) {
396
- const lines = sessions.slice(0, 5).map((s) => `- ${s.agent}@${s.branch} (${Object.keys(s.files).length} archivos)`)
397
- sections.push(`## Sesiones activas (${sessions.length})\n${lines.join("\n")}`)
374
+ // 4. Session activity with file details
375
+ const { active, conflicts } = coordinationView()
376
+ if (active.length > 0) {
377
+ const lines = active.slice(0, 5).map((s) => {
378
+ const mins = Math.max(0, Math.round(s.ageMs / 60000))
379
+ const files = Object.keys(s.files)
380
+ const fileList = files.length > 0 ? ` — ${files.slice(0, 3).join(", ")}${files.length > 3 ? ` +${files.length - 3}` : ""}` : ""
381
+ return `- ${s.agent}@${s.branch} (${mins}min ago)${fileList}`
382
+ })
383
+ sections.push(`## Active sessions (${active.length})\n${lines.join("\n")}`)
384
+ }
385
+
386
+ // 5. Soft conflicts between sessions
387
+ if (conflicts.length > 0) {
388
+ const lines = conflicts.slice(0, 3).map((c) => {
389
+ const who = c.sessions.map((s) => s.agent).join(" + ")
390
+ return `- ${c.file} ↔ ${who}`
391
+ })
392
+ sections.push(`## Session conflicts (${conflicts.length})\n${lines.join("\n")}`)
398
393
  }
399
394
 
400
- if (sections.length === 0) return "Sin cambios recientes."
395
+ if (sections.length === 0) return "No recent changes."
401
396
  return sections.filter(Boolean).join("\n\n")
402
397
  }
403
398
 
@@ -420,17 +415,23 @@ export function generateContextFocus(data: string, root: string, task: string, o
420
415
  const relevant = formatRelevantEntries(data, task, limit)
421
416
  if (relevant) sections.push(relevant)
422
417
 
423
- // 2. Extract keywords from task for file/code search
418
+ // 2. Extract keywords and filenames from task
424
419
  const keywords = task.toLowerCase().split(/\s+/).filter((w) => w.length > 2)
425
420
 
426
- // 3. Related files
421
+ // Also extract file-like patterns (e.g. "auth.ts", "src/index.js")
422
+ const filePatterns = task.toLowerCase().match(/[\w/.-]+\.[a-z]{1,4}/g) || []
423
+ // Extract path-like patterns (e.g. "src/auth", "lib/utils")
424
+ const pathPatterns = task.toLowerCase().match(/[\w/.-]+\/[\w/.-]+/g) || []
425
+
426
+ // 3. Related files - search by keywords, file patterns, and path patterns
427
427
  const allFiles: string[] = []
428
- for (const kw of keywords) {
428
+ const searchTerms = [...keywords, ...filePatterns, ...pathPatterns]
429
+ for (const kw of searchTerms) {
429
430
  allFiles.push(...findFilesByPattern(root, kw))
430
431
  }
431
432
  const uniqueFiles = [...new Set(allFiles)].slice(0, 10)
432
433
  if (uniqueFiles.length > 0) {
433
- sections.push(`## Archivos relacionados\n${uniqueFiles.join("\n")}`)
434
+ sections.push(`## Related files\n${uniqueFiles.join("\n")}`)
434
435
  }
435
436
 
436
437
  // 4. Code references (callers and matches)
@@ -438,23 +439,24 @@ export function generateContextFocus(data: string, root: string, task: string, o
438
439
  const callers = findCallers(root, kw)
439
440
  if (callers.length > 0) {
440
441
  const lines = callers.slice(0, 5).map((c) => `${c.file}:${c.line} — ${c.content.slice(0, 80)}`)
441
- sections.push(`## Referencias: ${kw}\n${lines.join("\n")}`)
442
+ sections.push(`## References: ${kw}\n${lines.join("\n")}`)
442
443
  }
443
444
  }
444
445
 
445
- // 5. Related tests
446
+ // 5. Related tests - search by keywords and file patterns
446
447
  const testFiles: string[] = []
447
- for (const kw of keywords.slice(0, 2)) {
448
+ const testSearchTerms = [...keywords.slice(0, 2), ...filePatterns]
449
+ for (const kw of testSearchTerms) {
448
450
  const tests = findFilesByPattern(root, ".test.")
449
451
  .filter((f) => f.toLowerCase().includes(kw))
450
452
  testFiles.push(...tests)
451
453
  }
452
454
  const uniqueTests = [...new Set(testFiles)].slice(0, 5)
453
455
  if (uniqueTests.length > 0) {
454
- sections.push(`## Tests existentes\n${uniqueTests.join("\n")}`)
456
+ sections.push(`## Existing tests\n${uniqueTests.join("\n")}`)
455
457
  }
456
458
 
457
- if (sections.length === 0) return `Sin contexto encontrado para "${task}".`
459
+ if (sections.length === 0) return `No context found for "${task}".`
458
460
  return sections.filter(Boolean).join("\n\n")
459
461
  }
460
462
 
@@ -487,7 +489,7 @@ export function generateContextHealth(data: string, root: string): { report: Hea
487
489
  }
488
490
  }
489
491
  if (orphanLinks.length > 0) {
490
- warnings.push(`${orphanLinks.length} links huérfanos: ${orphanLinks.slice(0, 5).join(", ")}`)
492
+ warnings.push(`${orphanLinks.length} orphan links: ${orphanLinks.slice(0, 5).join(", ")}`)
491
493
  score -= 5
492
494
  }
493
495
 
@@ -503,24 +505,22 @@ export function generateContextHealth(data: string, root: string): { report: Hea
503
505
  if (keys.length > 1) duplicates.push(keys.join(" = "))
504
506
  }
505
507
  if (duplicates.length > 0) {
506
- warnings.push(`${duplicates.length} entradas duplicadas: ${duplicates.slice(0, 3).join("; ")}`)
508
+ warnings.push(`${duplicates.length} duplicate entries: ${duplicates.slice(0, 3).join("; ")}`)
507
509
  score -= 5
508
510
  }
509
511
 
510
- // 3. Missing quality scores
511
- const missingQuality = entries.filter((e) => {
512
- // Quality is at index 10, check if it's missing or zero
513
- return !e.accessed && e.accessed !== 0
514
- })
515
- if (missingQuality.length > 0) {
516
- info.push(`${missingQuality.length} entradas sin quality score`)
512
+ // 3. Never-accessed old entries (created >7d ago but never recalled = possibly stale)
513
+ const weekAgo = new Date(Date.now() - 7 * 86400000).toISOString().split("T")[0]
514
+ const staleNeverAccessed = entries.filter((e) => e.accessed === 0 && e.date < weekAgo)
515
+ if (staleNeverAccessed.length > 0) {
516
+ info.push(`${staleNeverAccessed.length} old entries never recalled (possibly stale)`)
517
517
  score -= 2
518
518
  }
519
519
 
520
520
  // 4. Expired TTL
521
521
  const expired = entries.filter((e) => e.ttl && isExpiredLocal(e.ttl))
522
522
  if (expired.length > 0) {
523
- info.push(`${expired.length} entradas con TTL expirado (auto-prune en próximo inicio)`)
523
+ info.push(`${expired.length} entries with expired TTL (auto-prune on next startup)`)
524
524
  score -= 3
525
525
  }
526
526
 
@@ -535,7 +535,7 @@ export function generateContextHealth(data: string, root: string): { report: Hea
535
535
  }
536
536
  }
537
537
  if (brokenFiles.length > 0) {
538
- warnings.push(`${brokenFiles.length} refs a archivos inexistentes: ${brokenFiles.slice(0, 3).join("; ")}`)
538
+ warnings.push(`${brokenFiles.length} refs to non-existent files: ${brokenFiles.slice(0, 3).join("; ")}`)
539
539
  score -= 5
540
540
  }
541
541
 
@@ -543,15 +543,15 @@ export function generateContextHealth(data: string, root: string): { report: Hea
543
543
  const sessions = listSessions()
544
544
  const stale = sessions.filter((s) => !s.active && !s.ended)
545
545
  if (stale.length > 0) {
546
- info.push(`${stale.length} sesiones stale (serán pruned automáticamente)`)
546
+ info.push(`${stale.length} stale sessions (will be pruned automatically)`)
547
547
  }
548
548
 
549
549
  // 7. Entry count
550
550
  if (entries.length > 80) {
551
- warnings.push(`${entries.length} entradas (cerca del límite de 100)`)
551
+ warnings.push(`${entries.length} entries (near limit of 100)`)
552
552
  score -= 3
553
553
  } else if (entries.length === 0) {
554
- info.push("Memoria vacía")
554
+ info.push("Empty memory")
555
555
  }
556
556
 
557
557
  score = Math.max(0, score)
@@ -562,7 +562,7 @@ export function generateContextHealth(data: string, root: string): { report: Hea
562
562
  const parts: string[] = [`## Memory Health: ${score >= 90 ? "✅" : score >= 70 ? "⚠️" : "❌"} ${score}/100`]
563
563
 
564
564
  if (critical.length > 0) {
565
- parts.push("", "### Crítico", ...critical.map((w) => `- ${w}`))
565
+ parts.push("", "### Critical", ...critical.map((w) => `- ${w}`))
566
566
  }
567
567
  if (warnings.length > 0) {
568
568
  parts.push("", "### Warnings", ...warnings.map((w) => `- ${w}`))
@@ -588,10 +588,10 @@ export function generateContextExport(data: string, format: ExportFormat = "full
588
588
 
589
589
  // Header
590
590
  const today = new Date().toISOString().split("T")[0]
591
- sections.push(`# toon-memory export\nFecha: ${today} | Entradas: ${entries.length}\n`)
591
+ sections.push(`# toon-memory export\nDate: ${today} | Entries: ${entries.length}\n`)
592
592
 
593
593
  if (entries.length === 0) {
594
- sections.push("Memoria vacía.")
594
+ sections.push("Empty memory.")
595
595
  return sections.join("\n")
596
596
  }
597
597
 
@@ -603,10 +603,10 @@ export function generateContextExport(data: string, format: ExportFormat = "full
603
603
  }
604
604
 
605
605
  const categoryLabels: Record<string, string> = {
606
- decision: "Decisiones",
607
- pattern: "Patrones",
606
+ decision: "Decisions",
607
+ pattern: "Patterns",
608
608
  bug: "Bugs",
609
- knowledge: "Conocimiento",
609
+ knowledge: "Knowledge",
610
610
  }
611
611
 
612
612
  for (const [cat, items] of Object.entries(byCategory)) {
@@ -636,8 +636,8 @@ export function generateContextExport(data: string, format: ExportFormat = "full
636
636
  if (key < n) edges.push(`${key} -> ${n}`)
637
637
  }
638
638
  }
639
- if (edges.length > 0) {
640
- sections.push(`## Grafo (${edges.length} edges)`)
639
+ if (edges.length > 0) {
640
+ sections.push(`## Graph (${edges.length} edges)`)
641
641
  sections.push(edges.slice(0, 20).join("\n"))
642
642
  }
643
643
  }
@@ -647,7 +647,7 @@ export function generateContextExport(data: string, format: ExportFormat = "full
647
647
  const sessions = listSessions()
648
648
  if (sessions.length > 0) {
649
649
  const active = sessions.filter((s) => s.active)
650
- sections.push(`## Sesiones (${active.length} activas / ${sessions.length} total)`)
650
+ sections.push(`## Sessions (${active.length} active / ${sessions.length} total)`)
651
651
  for (const s of sessions.slice(0, 5)) {
652
652
  const status = s.active ? "🟢" : "⚪"
653
653
  sections.push(`- ${status} ${s.agent}@${s.branch} (${s.id})`)