toon-memory 2.3.0 → 2.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/dist/cli/setup.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync, unlinkSync, readdirSync, statSync, chmodSync, rmSync } from "fs";
3
3
  import { basename, dirname, join as join2 } from "path";
4
4
  import { fileURLToPath } from "url";
5
- import { createInterface } from "readline";
5
+ import { createInterface, emitKeypressEvents } from "readline";
6
6
  import { gzipSync } from "zlib";
7
7
 
8
8
  // src/lib/vocab.ts
@@ -111,19 +111,19 @@ Persistent memory for this project. Use it to avoid re-investigating things.
111
111
  - Save important decisions, bugs resolved, and patterns observed.
112
112
  `;
113
113
  function detectAgents() {
114
- const agents2 = [];
115
- agents2.push({
114
+ const agents = [];
115
+ agents.push({
116
116
  name: "opencode",
117
117
  global: join2(HOME, ".config", "opencode", "opencode.json"),
118
118
  local: join2(projectRoot, ".opencode", "opencode.json"),
119
119
  mcpKey: "mcp",
120
120
  format: "json",
121
- needsHooks: true,
121
+ needsHooks: false,
122
+ needsPlugin: true,
122
123
  needsInstructions: true,
123
- instructionFile: join2(projectRoot, "AGENTS.md"),
124
- captureJson: ["PostToolUse", "Stop"]
124
+ instructionFile: join2(projectRoot, "AGENTS.md")
125
125
  });
126
- agents2.push({
126
+ agents.push({
127
127
  name: "vscode/copilot",
128
128
  local: join2(projectRoot, ".vscode", "mcp.json"),
129
129
  mcpKey: "servers",
@@ -131,7 +131,7 @@ function detectAgents() {
131
131
  needsHooks: false,
132
132
  needsInstructions: false
133
133
  });
134
- agents2.push({
134
+ agents.push({
135
135
  name: "claude",
136
136
  global: join2(HOME, ".claude", "settings.json"),
137
137
  local: join2(projectRoot, ".claude", "settings.json"),
@@ -142,7 +142,7 @@ function detectAgents() {
142
142
  instructionFile: join2(projectRoot, ".claude", "AGENTS.md"),
143
143
  captureJson: ["PostToolUse", "Stop"]
144
144
  });
145
- agents2.push({
145
+ agents.push({
146
146
  name: "cursor",
147
147
  local: join2(projectRoot, ".cursor", "mcp.json"),
148
148
  mcpKey: "mcpServers",
@@ -150,7 +150,7 @@ function detectAgents() {
150
150
  needsHooks: false,
151
151
  needsInstructions: false
152
152
  });
153
- agents2.push({
153
+ agents.push({
154
154
  name: "windsurf",
155
155
  global: join2(HOME, ".codeium", "windsurf", "mcp_config.json"),
156
156
  mcpKey: "mcpServers",
@@ -158,7 +158,7 @@ function detectAgents() {
158
158
  needsHooks: false,
159
159
  needsInstructions: false
160
160
  });
161
- agents2.push({
161
+ agents.push({
162
162
  name: "cline",
163
163
  local: join2(projectRoot, ".cline", "mcp.json"),
164
164
  mcpKey: "mcpServers",
@@ -166,7 +166,7 @@ function detectAgents() {
166
166
  needsHooks: false,
167
167
  needsInstructions: false
168
168
  });
169
- agents2.push({
169
+ agents.push({
170
170
  name: "continue",
171
171
  local: join2(projectRoot, ".continue", "config.json"),
172
172
  mcpKey: "mcpServers",
@@ -174,7 +174,7 @@ function detectAgents() {
174
174
  needsHooks: false,
175
175
  needsInstructions: false
176
176
  });
177
- agents2.push({
177
+ agents.push({
178
178
  name: "codex",
179
179
  local: join2(projectRoot, ".codex", "config.toml"),
180
180
  mcpKey: "mcpServers",
@@ -182,9 +182,9 @@ function detectAgents() {
182
182
  needsHooks: true,
183
183
  needsInstructions: true,
184
184
  instructionFile: join2(projectRoot, ".codex", "AGENTS.md"),
185
- captureToml: ["post_tool_use", "stop"]
185
+ captureToml: ["PostToolUse", "Stop"]
186
186
  });
187
- agents2.push({
187
+ agents.push({
188
188
  name: "gemini",
189
189
  local: join2(projectRoot, ".gemini", "settings.json"),
190
190
  mcpKey: "mcpServers",
@@ -193,7 +193,7 @@ function detectAgents() {
193
193
  needsInstructions: true,
194
194
  instructionFile: join2(projectRoot, ".gemini", "GEMINI.md")
195
195
  });
196
- agents2.push({
196
+ agents.push({
197
197
  name: "zed",
198
198
  global: join2(HOME, ".config", "zed", "settings.json"),
199
199
  mcpKey: "mcp_servers",
@@ -201,7 +201,7 @@ function detectAgents() {
201
201
  needsHooks: false,
202
202
  needsInstructions: false
203
203
  });
204
- agents2.push({
204
+ agents.push({
205
205
  name: "antigravity",
206
206
  local: join2(projectRoot, ".gemini", "config", "mcp_config.json"),
207
207
  mcpKey: "mcpServers",
@@ -210,7 +210,7 @@ function detectAgents() {
210
210
  needsInstructions: true,
211
211
  instructionFile: join2(projectRoot, "antigravity-cli", "AGENTS.md")
212
212
  });
213
- agents2.push({
213
+ agents.push({
214
214
  name: "aider",
215
215
  mcpKey: "",
216
216
  format: "none",
@@ -218,7 +218,7 @@ function detectAgents() {
218
218
  needsInstructions: true,
219
219
  instructionFile: join2(projectRoot, "CONVENTIONS.md")
220
220
  });
221
- agents2.push({
221
+ agents.push({
222
222
  name: "kilocode",
223
223
  global: join2(HOME, ".kilocode", "mcp_settings.json"),
224
224
  mcpKey: "mcpServers",
@@ -227,7 +227,7 @@ function detectAgents() {
227
227
  needsInstructions: true,
228
228
  instructionFile: join2(HOME, ".kilocode", "rules", "toon-memory.md")
229
229
  });
230
- agents2.push({
230
+ agents.push({
231
231
  name: "openclaw",
232
232
  local: join2(projectRoot, ".openclaw.json"),
233
233
  mcpKey: "mcpServers",
@@ -235,7 +235,7 @@ function detectAgents() {
235
235
  needsHooks: false,
236
236
  needsInstructions: false
237
237
  });
238
- agents2.push({
238
+ agents.push({
239
239
  name: "kiro",
240
240
  local: join2(projectRoot, ".kiro", "settings", "mcp.json"),
241
241
  mcpKey: "mcpServers",
@@ -243,7 +243,7 @@ function detectAgents() {
243
243
  needsHooks: false,
244
244
  needsInstructions: false
245
245
  });
246
- return agents2;
246
+ return agents;
247
247
  }
248
248
  function installMemoryDir() {
249
249
  const memoryFile = join2(MEMORY_DIR, "data.toon");
@@ -427,9 +427,10 @@ function registerCaptureHookTOML(agent, scriptPath) {
427
427
  if (!configPath || !existsSync2(configPath)) return;
428
428
  let content = readFileSync2(configPath, "utf-8");
429
429
  for (const event of agent.captureToml || []) {
430
- if (content.includes(`[hooks.${event}]`)) continue;
430
+ if (content.includes(`event = "${event}"`)) continue;
431
431
  content += `
432
- [hooks.${event}]
432
+ [[hooks]]
433
+ event = "${event}"
433
434
  command = "${scriptPath}"
434
435
  `;
435
436
  }
@@ -440,17 +441,91 @@ function registerHookTOML(agent, hookPath) {
440
441
  const configPath = agent.local;
441
442
  if (!configPath || !existsSync2(configPath)) return;
442
443
  let content = readFileSync2(configPath, "utf-8");
443
- if (content.includes("session_start")) {
444
+ if (content.includes('event = "SessionStart"')) {
444
445
  console.log(` Hook already registered in ${configPath}`);
445
446
  return;
446
447
  }
447
448
  content += `
448
- [hooks.session_start]
449
+ [[hooks]]
450
+ event = "SessionStart"
449
451
  command = "${hookPath}"
450
452
  `;
451
453
  writeFileSync(configPath, content);
452
454
  console.log(` Hook registered in ${configPath}`);
453
455
  }
456
+ function opencodePluginContent() {
457
+ return `export const ToonMemory = async ({ $, directory }) => {
458
+ const ss = directory + "/bin/cli/session-start.js"
459
+ const cap = directory + "/bin/cli/capture.js"
460
+ return {
461
+ "session.created": async () => {
462
+ try { await $\`node \${ss} opencode\`.quiet() } catch {}
463
+ },
464
+ "tool.execute.after": async (input) => {
465
+ if (!process.env.TOON_MEMORY_CAPTURE) return
466
+ try {
467
+ const payload = JSON.stringify({
468
+ session_id: input?.session?.id ?? "",
469
+ tool_name: input?.tool ?? "",
470
+ tool_input: input?.args ?? {},
471
+ })
472
+ await $\`node \${cap} opencode\`.stdin(payload).quiet()
473
+ } catch {}
474
+ },
475
+ }
476
+ }
477
+ `;
478
+ }
479
+ function installOpenCodePlugin(agent) {
480
+ const pluginsDir = join2(projectRoot, ".opencode", "plugins");
481
+ if (!existsSync2(pluginsDir)) mkdirSync(pluginsDir, { recursive: true });
482
+ const dest = join2(pluginsDir, "toon-memory.ts");
483
+ writeFileSync(dest, opencodePluginContent());
484
+ console.log(` Plugin created at ${dest}`);
485
+ const configPath = agent.local || agent.global;
486
+ if (configPath && existsSync2(configPath)) {
487
+ try {
488
+ const config = JSON.parse(readFileSync2(configPath, "utf-8"));
489
+ if (config.hooks) {
490
+ delete config.hooks;
491
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
492
+ console.log(` Removed stale "hooks" key from ${configPath}`);
493
+ }
494
+ } catch {
495
+ }
496
+ }
497
+ }
498
+ var ANTIGRAVITY_HOOK_NAME = "toon-memory";
499
+ function registerAntigravityHooks(agent) {
500
+ const hookDir = join2(projectRoot, ".toon-memory", "hooks");
501
+ if (!existsSync2(hookDir)) mkdirSync(hookDir, { recursive: true });
502
+ const sessionPath = join2(hookDir, "session-start-antigravity.sh");
503
+ writeFileSync(sessionPath, sessionStartHookContent("antigravity"));
504
+ chmodSync(sessionPath, 493);
505
+ console.log(` Hook script created at ${sessionPath}`);
506
+ const capPath = join2(hookDir, "capture-antigravity.sh");
507
+ writeFileSync(capPath, captureHookContent("antigravity"));
508
+ chmodSync(capPath, 493);
509
+ console.log(` Capture hook created at ${capPath}`);
510
+ const base = agent.local ? dirname(agent.local) : projectRoot;
511
+ const hooksFile = join2(base, "hooks.json");
512
+ mkdirSync(base, { recursive: true });
513
+ let cfg = {};
514
+ if (existsSync2(hooksFile)) {
515
+ try {
516
+ cfg = JSON.parse(readFileSync2(hooksFile, "utf-8"));
517
+ } catch {
518
+ cfg = {};
519
+ }
520
+ }
521
+ cfg[ANTIGRAVITY_HOOK_NAME] = {
522
+ PreInvocation: [{ type: "command", command: sessionPath }],
523
+ PostToolUse: [{ matcher: "*", hooks: [{ type: "command", command: capPath }] }],
524
+ Stop: [{ type: "command", command: capPath }]
525
+ };
526
+ writeFileSync(hooksFile, JSON.stringify(cfg, null, 2));
527
+ console.log(` Antigravity hooks registered in ${hooksFile}`);
528
+ }
454
529
  function registerHookJSON(agent, hookPath) {
455
530
  const configPath = agent.format === "jsonc" ? agent.global : agent.local || agent.global;
456
531
  if (!configPath) return;
@@ -470,7 +545,7 @@ function registerHookJSON(agent, hookPath) {
470
545
  config = {};
471
546
  }
472
547
  }
473
- if (agent.name === "claude" || agent.name === "opencode") {
548
+ if (agent.name === "claude" || agent.name === "gemini") {
474
549
  if (!config.hooks) config.hooks = {};
475
550
  if (!config.hooks.SessionStart) config.hooks.SessionStart = [];
476
551
  if (!config.hooks.SessionStart.some((h) => h.command === hookPath)) {
@@ -480,18 +555,14 @@ function registerHookJSON(agent, hookPath) {
480
555
  }
481
556
  return;
482
557
  }
483
- if (!config.session_start_hooks) config.session_start_hooks = [];
484
- if (!config.session_start_hooks.includes(hookPath)) {
485
- config.session_start_hooks.push(hookPath);
486
- writeFileSync(configPath, JSON.stringify(config, null, 2));
487
- console.log(` Hook registered in ${configPath}`);
488
- }
489
558
  }
490
559
  function installForAgent(agent, scope) {
491
560
  console.log(`${agent.name}:`);
492
561
  installMCPConfig(agent, scope);
493
562
  installInstructions(agent);
494
- installHooks(agent);
563
+ if (agent.needsPlugin) installOpenCodePlugin(agent);
564
+ else if (agent.name === "antigravity") registerAntigravityHooks(agent);
565
+ else installHooks(agent);
495
566
  }
496
567
  function updateMemoryConfig(patch) {
497
568
  if (!existsSync2(MEMORY_DIR)) mkdirSync(MEMORY_DIR, { recursive: true });
@@ -515,8 +586,8 @@ function init(scope = "local") {
515
586
  updateMemoryConfig({ vocab: deps });
516
587
  console.log(` Detected ${depCount} dependencies \u2192 auto-tag vocabulary written to config.json`);
517
588
  }
518
- const agents2 = detectAgents();
519
- for (const agent of agents2) {
589
+ const agents = detectAgents();
590
+ for (const agent of agents) {
520
591
  installForAgent(agent, scope);
521
592
  console.log("");
522
593
  }
@@ -525,8 +596,8 @@ function init(scope = "local") {
525
596
  }
526
597
  function uninstall() {
527
598
  console.log("\n\u{1F9E0} toon-memory uninstaller\n");
528
- const agents2 = detectAgents();
529
- for (const agent of agents2) {
599
+ const agents = detectAgents();
600
+ for (const agent of agents) {
530
601
  if (agent.format === "json" || agent.format === "jsonc") {
531
602
  const configs = [agent.global, agent.local].filter(Boolean);
532
603
  for (const configPath of configs) {
@@ -560,7 +631,7 @@ function uninstall() {
560
631
  }
561
632
  }
562
633
  }
563
- for (const agent of agents2) {
634
+ for (const agent of agents) {
564
635
  if (agent.instructionFile && existsSync2(agent.instructionFile)) {
565
636
  try {
566
637
  const content = readFileSync2(agent.instructionFile, "utf-8");
@@ -582,6 +653,30 @@ function uninstall() {
582
653
  unlinkSync(toolsFile);
583
654
  console.log(" Removed .opencode/tools/memory.ts");
584
655
  }
656
+ const ocPlugin = join2(projectRoot, ".opencode", "plugins", "toon-memory.ts");
657
+ if (existsSync2(ocPlugin)) {
658
+ unlinkSync(ocPlugin);
659
+ console.log(" Removed .opencode/plugins/toon-memory.ts");
660
+ }
661
+ const agyHooks = join2(projectRoot, ".gemini", "config", "hooks.json");
662
+ if (existsSync2(agyHooks)) {
663
+ try {
664
+ const agyCfg = JSON.parse(readFileSync2(agyHooks, "utf-8"));
665
+ if (agyCfg[ANTIGRAVITY_HOOK_NAME]) {
666
+ delete agyCfg[ANTIGRAVITY_HOOK_NAME];
667
+ if (Object.keys(agyCfg).length === 0) {
668
+ unlinkSync(agyHooks);
669
+ console.log(" Removed .gemini/config/hooks.json");
670
+ } else {
671
+ writeFileSync(agyHooks, JSON.stringify(agyCfg, null, 2));
672
+ console.log(" Removed toon-memory hook from .gemini/config/hooks.json");
673
+ }
674
+ }
675
+ } catch {
676
+ unlinkSync(agyHooks);
677
+ console.log(" Removed .gemini/config/hooks.json");
678
+ }
679
+ }
585
680
  console.log("\n\u2705 toon-memory uninstalled from all agents\n");
586
681
  }
587
682
  function status() {
@@ -610,9 +705,9 @@ function status() {
610
705
  }
611
706
  }
612
707
  console.log(`Capture: ${capture ? "enabled" : "disabled (opt-in)"}`);
613
- const agents2 = detectAgents();
708
+ const agents = detectAgents();
614
709
  console.log("\nAgent configs:");
615
- for (const agent of agents2) {
710
+ for (const agent of agents) {
616
711
  let configured = false;
617
712
  if (agent.format === "json" || agent.format === "jsonc") {
618
713
  const configs = [agent.global, agent.local].filter(Boolean);
@@ -640,13 +735,16 @@ function status() {
640
735
  }
641
736
  const hasInstructions = agent.instructionFile ? existsSync2(agent.instructionFile) : false;
642
737
  const hookPath = join2(projectRoot, ".toon-memory", "hooks", `session-start-${agent.name}.sh`);
643
- const hasHooks = existsSync2(hookPath);
738
+ let hasHooks = existsSync2(hookPath);
739
+ if (agent.needsPlugin) {
740
+ hasHooks = existsSync2(join2(projectRoot, ".opencode", "plugins", "toon-memory.ts"));
741
+ }
644
742
  if (agent.format === "none") {
645
743
  console.log(` ${hasInstructions ? "\u2705" : "\u274C"} ${agent.name} (instructions only)`);
646
744
  } else {
647
745
  const mcpStatus = configured ? "\u2705" : "\u274C";
648
746
  const instrStatus = agent.needsInstructions ? hasInstructions ? " \u{1F4DD}" : "" : "";
649
- const hookStatus = agent.needsHooks ? hasHooks ? " \u{1FA9D}" : "" : "";
747
+ const hookStatus = agent.needsHooks || agent.needsPlugin ? hasHooks ? " \u{1FA9D}" : "" : "";
650
748
  console.log(` ${mcpStatus} ${agent.name}${instrStatus}${hookStatus}`);
651
749
  }
652
750
  }
@@ -971,48 +1069,165 @@ if (args[0] === "watch") {
971
1069
  watch();
972
1070
  process.exit(0);
973
1071
  }
974
- var agents = detectAgents();
975
- console.log("\n\u{1F9E0} toon-memory installer\n");
976
- console.log("Available agents:");
977
- agents.forEach((a, i) => {
978
- const hasConfig = a.format !== "none" && (a.local && existsSync2(a.local) || a.global && existsSync2(a.global));
979
- const indicator = hasConfig ? "\u2713" : "\xB7";
980
- console.log(` ${indicator} ${i + 1}. ${a.name}`);
981
- });
982
- console.log("");
983
- var rl = createInterface({ input: process.stdin, output: process.stdout });
984
- rl.question("Select agents (numbers separated by commas, 'all', or Enter for all): ", (answer) => {
985
- let selected;
986
- const trimmed = answer.trim().toLowerCase();
987
- if (trimmed === "all" || trimmed === "") {
988
- selected = agents;
989
- } else if (trimmed === "none") {
990
- selected = [];
991
- } else {
992
- const indices = trimmed.split(",").map((s) => parseInt(s.trim(), 10) - 1).filter((i) => i >= 0 && i < agents.length);
993
- selected = indices.map((i) => agents[i]);
1072
+ if (args.length === 0) {
1073
+ await interactiveInstall();
1074
+ process.exit(0);
1075
+ }
1076
+ console.log(`Comando desconocido: '${args[0]}'
1077
+ `);
1078
+ printUsage();
1079
+ process.exit(1);
1080
+ function printUsage() {
1081
+ console.log(`Uso: toon-memory <comando> [alcance]
1082
+ Comandos: init, status, stats, export, import, watch, uninstall, capture, upgrade, mcp
1083
+ Opciones: -v/--version, -h/--help
1084
+ Sin argumentos inicia el instalador interactivo.`);
1085
+ }
1086
+ function ask(rl, prompt) {
1087
+ return new Promise((resolve) => rl.question(prompt, resolve));
1088
+ }
1089
+ async function interactiveInstall() {
1090
+ if (!process.stdin.isTTY) {
1091
+ console.log("\n\u{1F9E0} toon-memory \u2014 la instalaci\xF3n interactiva requiere una terminal.");
1092
+ console.log("Ejecuta 'toon-memory init [local|global]' para instalaci\xF3n no interactiva.\n");
1093
+ return;
1094
+ }
1095
+ const agents = detectAgents();
1096
+ const selected = await runAgentChecklist(agents);
1097
+ if (selected === null) {
1098
+ console.log("\nInstalaci\xF3n cancelada.\n");
1099
+ return;
994
1100
  }
995
1101
  if (selected.length === 0) {
996
- console.log("\nNo agents selected. Nothing installed.\n");
997
- rl.close();
1102
+ console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
998
1103
  return;
999
1104
  }
1000
1105
  console.log(`
1001
- Selected: ${selected.map((a) => a.name).join(", ")}
1002
- `);
1003
- rl.question("Installation scope \u2014 (1) Local or (2) Global? [1/2]: ", (scopeAnswer) => {
1004
- const scope = scopeAnswer === "2" ? "global" : "local";
1005
- console.log(`
1006
- Installing ${scope}ly...
1106
+ Seleccionados: ${selected.map((a) => a.name).join(", ")}
1007
1107
  `);
1008
- installMemoryDir();
1009
- for (const agent of selected) {
1010
- installForAgent(agent, scope);
1011
- console.log("");
1108
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1109
+ let scope = "local";
1110
+ while (true) {
1111
+ const scopeAnswer = (await ask(rl, "Alcance \u2014 (1) Local (proyecto) o (2) Global (~home)? [1/2]: ")).trim();
1112
+ if (scopeAnswer === "" || scopeAnswer === "1") {
1113
+ scope = "local";
1114
+ break;
1115
+ }
1116
+ if (scopeAnswer === "2") {
1117
+ scope = "global";
1118
+ break;
1012
1119
  }
1013
- ensureGitignore();
1014
- console.log("Done! Restart your agent to use memory tools.");
1015
- console.log("Run 'npx toon-memory uninstall' to remove.\n");
1120
+ console.log("Escribe 1 (local) o 2 (global).\n");
1121
+ }
1122
+ console.log("\nSe instalar\xE1:");
1123
+ for (const a of selected) {
1124
+ const resolved = scope === "global" && a.global ? "global" : "local";
1125
+ const parts = [];
1126
+ if (a.format !== "none") parts.push("MCP");
1127
+ if (a.needsPlugin) parts.push("plugin");
1128
+ else if (a.needsHooks) parts.push("hooks");
1129
+ if (a.needsInstructions) parts.push("instrucciones");
1130
+ const target = resolved === "global" && a.global ? a.global : a.local || "(instrucciones)";
1131
+ console.log(` \u2022 ${a.name} [${resolved}] \u2192 ${target}${parts.length ? ` (${parts.join(", ")})` : ""}`);
1132
+ }
1133
+ const confirm = (await ask(rl, "\n\xBFProceder? [Y/n]: ")).trim().toLowerCase();
1134
+ if (confirm === "n" || confirm === "no") {
1135
+ console.log("\nInstalaci\xF3n cancelada.\n");
1016
1136
  rl.close();
1137
+ return;
1138
+ }
1139
+ console.log(`
1140
+ Instalando (${scope})...
1141
+ `);
1142
+ installMemoryDir();
1143
+ const deps = extractProjectDeps(projectRoot);
1144
+ if (Object.keys(deps).length > 0) {
1145
+ updateMemoryConfig({ vocab: deps });
1146
+ console.log(` Detected ${Object.keys(deps).length} dependencies \u2192 auto-tag vocabulary written to config.json`);
1147
+ }
1148
+ for (const agent of selected) {
1149
+ installForAgent(agent, scope);
1150
+ console.log("");
1151
+ }
1152
+ ensureGitignore();
1153
+ console.log("Done! Restart your agent to use memory tools.");
1154
+ console.log("Run 'npx toon-memory uninstall' to remove.\n");
1155
+ rl.close();
1156
+ }
1157
+ async function runAgentChecklist(agents) {
1158
+ const n = agents.length;
1159
+ let cursor = 0;
1160
+ const selected = /* @__PURE__ */ new Set();
1161
+ let prevLines = 0;
1162
+ const render = () => {
1163
+ let out = "";
1164
+ if (prevLines > 0) out += `\x1B[${prevLines}A\x1B[J`;
1165
+ const lines = [];
1166
+ lines.push("\n\u{1F9E0} toon-memory installer");
1167
+ lines.push("");
1168
+ lines.push("Agentes detectados:");
1169
+ agents.forEach((a, i) => {
1170
+ const isCursor = i === cursor;
1171
+ const isSel = selected.has(i);
1172
+ const box = isSel ? "[x]" : "[ ]";
1173
+ const cur = isCursor ? ">" : " ";
1174
+ const hasConfig = a.format !== "none" && (a.local && existsSync2(a.local) || a.global && existsSync2(a.global));
1175
+ const indicator = hasConfig ? "\u2713" : "\xB7";
1176
+ const scopeNote = a.format === "none" ? "(instrucciones)" : a.global ? "(local/global)" : "(solo local)";
1177
+ lines.push(` ${cur} ${box} ${indicator} ${i + 1}. ${a.name} ${scopeNote}`);
1178
+ });
1179
+ lines.push("");
1180
+ lines.push(" \u2191/\u2193 mover \xB7 espacio marcar \xB7 'a' todos \xB7 Enter confirmar \xB7 'q' salir");
1181
+ process.stdout.write(out + lines.join("\n") + "\n");
1182
+ prevLines = lines.length;
1183
+ };
1184
+ return new Promise((resolve) => {
1185
+ emitKeypressEvents(process.stdin);
1186
+ process.stdin.setRawMode(true);
1187
+ process.stdin.resume();
1188
+ const finish = (result) => {
1189
+ process.stdin.setRawMode(false);
1190
+ process.stdin.removeListener("keypress", onKey);
1191
+ process.stdout.write("\n");
1192
+ resolve(result);
1193
+ };
1194
+ const onKey = (_str, key) => {
1195
+ if (!key) return;
1196
+ if (key.ctrl && key.name === "c") {
1197
+ finish(null);
1198
+ return;
1199
+ }
1200
+ switch (key.name) {
1201
+ case "up":
1202
+ case "k":
1203
+ cursor = (cursor - 1 + n) % n;
1204
+ break;
1205
+ case "down":
1206
+ case "j":
1207
+ cursor = (cursor + 1) % n;
1208
+ break;
1209
+ case "space":
1210
+ if (selected.has(cursor)) selected.delete(cursor);
1211
+ else selected.add(cursor);
1212
+ break;
1213
+ case "a":
1214
+ if (selected.size === n) selected.clear();
1215
+ else for (let i = 0; i < n; i++) selected.add(i);
1216
+ break;
1217
+ case "return":
1218
+ finish(agents.filter((_, i) => selected.has(i)));
1219
+ return;
1220
+ case "q":
1221
+ case "c":
1222
+ finish(null);
1223
+ return;
1224
+ default:
1225
+ render();
1226
+ return;
1227
+ }
1228
+ render();
1229
+ };
1230
+ process.stdin.on("keypress", onKey);
1231
+ render();
1017
1232
  });
1018
- });
1233
+ }
package/mcp/server.js CHANGED
@@ -28398,7 +28398,7 @@ function consolidateEntries() {
28398
28398
  return { removed: duplicates.length, kept: order.length, duplicates };
28399
28399
  }
28400
28400
  var server = new McpServer(
28401
- { name: "toon-memory", version: "2.3.0" },
28401
+ { name: "toon-memory", version: "2.4.1" },
28402
28402
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
28403
28403
  );
28404
28404
  server.registerResource(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "2.3.0",
4
- "description": "Persistent memory system for AI coding agents using TOON format (22% fewer tokens than JSON, measured)",
3
+ "version": "2.4.1",
4
+ "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — recall decisions, patterns, and bugs across sessions with 68.5% fewer tokens than re-reading context. No LLM, no server; works with 15+ agents.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "toon-memory": "./bin/toon-memory.js"
@@ -24,6 +24,7 @@
24
24
  "test": "vitest run",
25
25
  "test:watch": "vitest",
26
26
  "bench": "node scripts/benchmark-toon.mjs",
27
+ "bench:impact": "node scripts/benchmark-impact.mjs",
27
28
  "prepublishOnly": "npm run build && npm test"
28
29
  },
29
30
  "dependencies": {
@@ -8,17 +8,17 @@ A persistent memory system for AI coding agents. It remembers decisions, pattern
8
8
 
9
9
  | Agent | Config File | Format | Hooks |
10
10
  |-------|-------------|--------|-------|
11
- | OpenCode | `.opencode/opencode.json` | MCP server | — |
11
+ | OpenCode | `.opencode/opencode.json` + `.opencode/plugins/toon-memory.ts` | Plugin | SessionStart (plugin, no top-level `hooks`) |
12
12
  | VS Code / Copilot | `.vscode/mcp.json` | MCP server | — |
13
- | Claude Code | `.claude/settings.json` | MCP server | SessionStart |
13
+ | Claude Code | `.claude/settings.json` | MCP server | SessionStart + PostToolUse + Stop |
14
14
  | Cursor | `.cursor/mcp.json` | MCP server | — |
15
15
  | Windsurf | `~/.codeium/windsurf/mcp_config.json` | MCP server | — |
16
16
  | Cline | `.cline/mcp.json` | MCP server | — |
17
17
  | Continue | `.continue/config.json` | MCP server | — |
18
- | Codex CLI | `.codex/config.toml` | TOML | SessionStart |
19
- | Gemini CLI | `.gemini/settings.json` | MCP server | SessionStart |
18
+ | Codex CLI | `.codex/config.toml` | TOML | SessionStart + PostToolUse + Stop (`[[hooks]] event=`) |
19
+ | Gemini CLI | `.gemini/settings.json` | MCP server | SessionStart + PostToolUse + Stop (`hooks.*`) |
20
20
  | Zed | `~/.config/zed/settings.json` | JSONC | — |
21
- | Antigravity | `.gemini/config/mcp_config.json` | MCP server | SessionStart |
21
+ | Antigravity | `.gemini/config/mcp_config.json` + `.gemini/config/hooks.json` | hooks.json | PreInvocation + PostToolUse + Stop (no SessionStart event) |
22
22
  | Aider | — | Instructions only | — |
23
23
  | KiloCode | `~/.kilocode/mcp_settings.json` | MCP server | — |
24
24
  | OpenClaw | `.openclaw.json` | MCP server | — |