toon-memory 3.0.0 → 3.1.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/dist/cli/setup.js CHANGED
@@ -165,7 +165,8 @@ function detectAgents() {
165
165
  agents.push({
166
166
  name: "claude",
167
167
  global: join3(HOME, ".claude", "settings.json"),
168
- local: join3(projectRoot, ".claude", "settings.json"),
168
+ local: join3(projectRoot, ".mcp.json"),
169
+ hookPath: join3(projectRoot, ".claude", "settings.json"),
169
170
  mcpKey: "mcpServers",
170
171
  format: "json",
171
172
  needsHooks: true,
@@ -202,8 +203,8 @@ function detectAgents() {
202
203
  agents.push({
203
204
  name: "continue",
204
205
  local: join3(projectRoot, ".continue", "config.json"),
205
- mcpKey: "mcpServers",
206
- format: "json",
206
+ mcpKey: "experimental.modelContextProtocolServers",
207
+ format: "continue",
207
208
  needsHooks: false,
208
209
  needsInstructions: false
209
210
  });
@@ -230,14 +231,14 @@ function detectAgents() {
230
231
  agents.push({
231
232
  name: "zed",
232
233
  global: join3(HOME, ".config", "zed", "settings.json"),
233
- mcpKey: "mcp_servers",
234
+ mcpKey: "context_servers",
234
235
  format: "jsonc",
235
236
  needsHooks: false,
236
237
  needsInstructions: false
237
238
  });
238
239
  agents.push({
239
240
  name: "antigravity",
240
- local: join3(projectRoot, ".gemini", "config", "mcp_config.json"),
241
+ local: join3(projectRoot, ".agents", "mcp_config.json"),
241
242
  mcpKey: "mcpServers",
242
243
  format: "json",
243
244
  needsHooks: true,
@@ -255,7 +256,7 @@ function detectAgents() {
255
256
  agents.push({
256
257
  name: "kilocode",
257
258
  global: join3(HOME, ".kilocode", "mcp_settings.json"),
258
- mcpKey: "mcpServers",
259
+ mcpKey: "mcp",
259
260
  format: "json",
260
261
  needsHooks: false,
261
262
  needsInstructions: true,
@@ -263,9 +264,9 @@ function detectAgents() {
263
264
  });
264
265
  agents.push({
265
266
  name: "openclaw",
266
- local: join3(projectRoot, ".openclaw.json"),
267
- mcpKey: "mcpServers",
268
- format: "json",
267
+ global: join3(HOME, ".openclaw", "openclaw.json"),
268
+ mcpKey: "mcp.servers",
269
+ format: "openclaw",
269
270
  needsHooks: false,
270
271
  needsInstructions: false
271
272
  });
@@ -389,6 +390,11 @@ function installJSONConfig(agent, scope) {
389
390
  type: "local",
390
391
  command: ["npx", "-y", "toon-memory", "mcp"]
391
392
  };
393
+ } else if (agent.name === "kilocode") {
394
+ config[mcpKey]["toon-memory"] = {
395
+ type: "local",
396
+ command: ["npx", "-y", "toon-memory", "mcp"]
397
+ };
392
398
  } else {
393
399
  config[mcpKey]["toon-memory"] = {
394
400
  command: "npx",
@@ -425,11 +431,69 @@ function installZedConfig(agent) {
425
431
  config = {};
426
432
  }
427
433
  }
428
- if (!config.mcp_servers) config.mcp_servers = {};
429
- config.mcp_servers["toon-memory"] = {
434
+ if (!config.context_servers) config.context_servers = {};
435
+ config.context_servers["toon-memory"] = {
436
+ command: "npx",
437
+ args: ["-y", "toon-memory", "mcp"],
438
+ source: "custom"
439
+ };
440
+ writeFileSync3(configPath, JSON.stringify(config, null, 2));
441
+ console.log(` MCP server added to ${configPath}`);
442
+ }
443
+ function installContinueConfig(agent) {
444
+ const configPath = agent.local;
445
+ if (!configPath) return;
446
+ const configDir = dirname3(configPath);
447
+ if (!existsSync5(configDir)) mkdirSync3(configDir, { recursive: true });
448
+ let config = {};
449
+ if (existsSync5(configPath)) {
450
+ try {
451
+ config = JSON.parse(readFileSync5(configPath, "utf-8"));
452
+ } catch {
453
+ config = {};
454
+ }
455
+ }
456
+ if (!config.experimental) config.experimental = {};
457
+ if (!config.experimental.modelContextProtocolServers) {
458
+ config.experimental.modelContextProtocolServers = [];
459
+ }
460
+ const servers = config.experimental.modelContextProtocolServers;
461
+ const existing = servers.findIndex(
462
+ (s) => s.name === "toon-memory"
463
+ );
464
+ const entry = {
465
+ name: "toon-memory",
430
466
  command: "npx",
431
467
  args: ["-y", "toon-memory", "mcp"]
432
468
  };
469
+ if (existing >= 0) {
470
+ servers[existing] = entry;
471
+ } else {
472
+ servers.push(entry);
473
+ }
474
+ writeFileSync3(configPath, JSON.stringify(config, null, 2));
475
+ console.log(` MCP server added to ${configPath}`);
476
+ }
477
+ function installOpenClawConfig(agent) {
478
+ const configPath = agent.global;
479
+ if (!configPath) return;
480
+ const configDir = dirname3(configPath);
481
+ if (!existsSync5(configDir)) mkdirSync3(configDir, { recursive: true });
482
+ let config = {};
483
+ if (existsSync5(configPath)) {
484
+ try {
485
+ config = JSON.parse(readFileSync5(configPath, "utf-8"));
486
+ } catch {
487
+ config = {};
488
+ }
489
+ }
490
+ if (!config.mcp) config.mcp = {};
491
+ if (!config.mcp.servers) config.mcp.servers = {};
492
+ config.mcp.servers["toon-memory"] = {
493
+ command: "npx",
494
+ args: ["-y", "toon-memory", "mcp"],
495
+ enabled: true
496
+ };
433
497
  writeFileSync3(configPath, JSON.stringify(config, null, 2));
434
498
  console.log(` MCP server added to ${configPath}`);
435
499
  }
@@ -442,6 +506,10 @@ function installMCPConfig(agent, scope) {
442
506
  installTOMLConfig(agent);
443
507
  } else if (agent.format === "jsonc") {
444
508
  installZedConfig(agent);
509
+ } else if (agent.format === "continue") {
510
+ installContinueConfig(agent);
511
+ } else if (agent.format === "openclaw") {
512
+ installOpenClawConfig(agent);
445
513
  } else {
446
514
  installJSONConfig(agent, scope);
447
515
  }
@@ -534,7 +602,7 @@ function installHooks(agent) {
534
602
  }
535
603
  }
536
604
  function registerCaptureHookJSON(agent, scriptPath) {
537
- const configPath = agent.local || agent.global;
605
+ const configPath = agent.hookPath || agent.local || agent.global;
538
606
  if (!configPath) return;
539
607
  const configDir = dirname5(configPath);
540
608
  if (!existsSync7(configDir)) mkdirSync5(configDir, { recursive: true });
@@ -588,7 +656,7 @@ command = "${hookPath}"
588
656
  console.log(` Hook registered in ${configPath}`);
589
657
  }
590
658
  function registerHookJSON(agent, hookPath) {
591
- const configPath = agent.format === "jsonc" ? agent.global : agent.local || agent.global;
659
+ const configPath = agent.hookPath || (agent.format === "jsonc" ? agent.global : agent.local || agent.global);
592
660
  if (!configPath) return;
593
661
  const configDir = dirname5(configPath);
594
662
  if (!existsSync7(configDir)) mkdirSync5(configDir, { recursive: true });
@@ -653,18 +721,37 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as rea
653
721
  import { join as join6 } from "path";
654
722
  function opencodePluginContent() {
655
723
  return `import * as fs from "fs"
724
+ import * as path from "path"
656
725
 
657
726
  export const ToonMemory = async ({ $, directory, worktree }) => {
658
727
  const root = worktree || directory
659
728
  const INS = root + "/.opencode/instructions"
660
729
  const OUT = INS + "/memory-autoload.md"
730
+
661
731
  const dump = async () => {
662
732
  return await $\`npx -y toon-memory dump\`.cwd(root).text()
663
733
  }
734
+
735
+ const recall = async (query) => {
736
+ try {
737
+ const result = await $\`npx -y toon-memory mcp\`.cwd(root)
738
+ .stdin(JSON.stringify({
739
+ jsonrpc: "2.0",
740
+ id: 1,
741
+ method: "tools/call",
742
+ params: { name: "memory_recall", arguments: { query, mode: "flat", compact: true } }
743
+ }))
744
+ .text()
745
+ const parsed = JSON.parse(result)
746
+ return parsed?.result?.content?.[0]?.text || ""
747
+ } catch { return "" }
748
+ }
749
+
664
750
  const write = (text) => {
665
751
  fs.mkdirSync(INS, { recursive: true })
666
752
  fs.writeFileSync(OUT, text)
667
753
  }
754
+
668
755
  return {
669
756
  "session.created": async () => {
670
757
  try {
@@ -679,15 +766,39 @@ export const ToonMemory = async ({ $, directory, worktree }) => {
679
766
  } catch {}
680
767
  },
681
768
  "tool.execute.after": async (input) => {
682
- if (!process.env.TOON_MEMORY_CAPTURE) return
683
- const cap = directory + "/bin/cli/capture.js"
769
+ // Intelligent auto-loading: extract file path from tool result,
770
+ // recall only memory relevant to that file, inject as context.
684
771
  try {
685
- const payload = JSON.stringify({
686
- session_id: input?.session?.id ?? "",
687
- tool_name: input?.tool ?? "",
688
- tool_input: input?.args ?? {},
689
- })
690
- await $\`node \${cap} opencode\`.stdin(payload).quiet()
772
+ const toolName = input?.tool || ""
773
+ const args = input?.args || {}
774
+
775
+ // Extract file path from tool arguments or output
776
+ let filePath = ""
777
+ if (args.file) filePath = args.file
778
+ else if (args.path) filePath = args.path
779
+ else if (args.filePath) filePath = args.filePath
780
+
781
+ // Also try to extract from tool output text
782
+ if (!filePath && input?.output) {
783
+ const outputText = typeof input.output === "string" ? input.output : ""
784
+ const fileMatch = outputText.match(/(?:file|path|source):s*([\\w/.\\-]+)/i)
785
+ if (fileMatch) filePath = fileMatch[1]
786
+ }
787
+
788
+ if (!filePath) return
789
+
790
+ // Build recall query from file path components
791
+ const basename = path.basename(filePath, path.extname(filePath))
792
+ const dirParts = path.dirname(filePath).split(path.sep).filter(Boolean)
793
+ const query = [basename, ...dirParts.slice(-2)].join(" ")
794
+
795
+ const text = await recall(query)
796
+ if (!text || text.includes("(empty)") || text.includes("No results")) return
797
+
798
+ // Inject as context for the next agent turn
799
+ if (typeof input?.setContext === "function") {
800
+ input.setContext("toon-memory:" + filePath, text)
801
+ }
691
802
  } catch {}
692
803
  },
693
804
  }
@@ -863,7 +974,7 @@ function uninstall() {
863
974
  unlinkSync(ocPlugin);
864
975
  console.log(" Removed .opencode/plugins/toon-memory.ts");
865
976
  }
866
- const agyHooks = join7(projectRoot, ".gemini", "config", "hooks.json");
977
+ const agyHooks = join7(projectRoot, ".agents", "hooks.json");
867
978
  if (existsSync9(agyHooks)) {
868
979
  try {
869
980
  const agyCfg = JSON.parse(readFileSync9(agyHooks, "utf-8"));
package/mcp/server.js CHANGED
@@ -418,7 +418,15 @@ function qualityScore(tags, links, content, date5, accessed = 0, lastAccessed =
418
418
  else if (daysSinceAccess < 7) score += 0.07;
419
419
  else if (daysSinceAccess < 30) score += 0.03;
420
420
  }
421
- return Math.min(1, score);
421
+ if (date5) {
422
+ const daysSinceCreation = (Date.now() - (/* @__PURE__ */ new Date(`${date5}T00:00:00`)).getTime()) / 864e5;
423
+ const daysSinceLastAccess = lastAccessed ? (Date.now() - new Date(lastAccessed).getTime()) / 864e5 : daysSinceCreation;
424
+ if (daysSinceCreation > 30 && daysSinceLastAccess > 30) {
425
+ const staleness = Math.min(1, (daysSinceLastAccess - 30) / 90);
426
+ score -= staleness * 0.2;
427
+ }
428
+ }
429
+ return Math.max(0, Math.min(1, score));
422
430
  }
423
431
  function mergeEntries(existingLine, newLine) {
424
432
  const ep = existingLine.trim().split("|");
@@ -31351,6 +31359,155 @@ To import later: memory_import_gist(gist_id: "${gist.id}")`
31351
31359
  return { content: [{ type: "text", text: sections.join("\n") }] };
31352
31360
  }
31353
31361
  );
31362
+ server2.registerTool(
31363
+ "memory_merge_similar",
31364
+ {
31365
+ title: "Merge Similar Entries",
31366
+ description: "Find entries with overlapping content (>50% word similarity) and merge them. Deterministic, no LLM. Keeps the longer content and combines tags.",
31367
+ inputSchema: {
31368
+ dryRun: external_exports.boolean().optional().default(false).describe("If true, show what would be merged without making changes.")
31369
+ }
31370
+ },
31371
+ async ({ dryRun }) => {
31372
+ const data = readMemory();
31373
+ const entries = data.split("\n").filter((l) => l.startsWith(" ") && l.includes("|") && !l.startsWith(" summaries:"));
31374
+ if (entries.length < 2) {
31375
+ return { content: [{ type: "text", text: "\u2705 Not enough entries to compress." }] };
31376
+ }
31377
+ const parsed = entries.map((line) => {
31378
+ const parts = line.trim().split("|");
31379
+ if (parts.length < 7) return null;
31380
+ const [id, cat, key, content, file2, tags, date5, ttl, accessedRaw] = parts;
31381
+ const words = new Set(normalize(`${key} ${content} ${tags}`).split(" ").filter(Boolean));
31382
+ return { id, cat, key, content, file: file2, tags, date: date5, ttl, accessed: parseInt(accessedRaw) || 0, words, line };
31383
+ }).filter(Boolean);
31384
+ const mergePairs = [];
31385
+ for (let i = 0; i < parsed.length; i++) {
31386
+ for (let j = i + 1; j < parsed.length; j++) {
31387
+ const a = parsed[i], b = parsed[j];
31388
+ const intersection2 = new Set([...a.words].filter((w) => b.words.has(w)));
31389
+ const union2 = /* @__PURE__ */ new Set([...a.words, ...b.words]);
31390
+ const similarity = union2.size > 0 ? intersection2.size / union2.size : 0;
31391
+ if (similarity > 0.5) {
31392
+ mergePairs.push({ a: i, b: j, similarity });
31393
+ }
31394
+ }
31395
+ }
31396
+ if (mergePairs.length === 0) {
31397
+ return { content: [{ type: "text", text: "\u2705 No similar entries found to merge." }] };
31398
+ }
31399
+ mergePairs.sort((x, y) => y.similarity - x.similarity);
31400
+ const merged = /* @__PURE__ */ new Set();
31401
+ const mergeActions = [];
31402
+ for (const pair of mergePairs) {
31403
+ if (merged.has(pair.a) || merged.has(pair.b)) continue;
31404
+ const a = parsed[pair.a], b = parsed[pair.b];
31405
+ const mergedTags = [.../* @__PURE__ */ new Set([...a.tags.split(";"), ...b.tags.split(";")])].filter(Boolean).join(";");
31406
+ const longer = a.content.length >= b.content.length ? a : b;
31407
+ const shorter = a.content.length < b.content.length ? a : b;
31408
+ const newContent = longer.content;
31409
+ const newDate = a.date > b.date ? a.date : b.date;
31410
+ const newAccessed = a.accessed + b.accessed;
31411
+ mergeActions.push(` [${longer.cat}] ${longer.key} \u2190 ${shorter.key} (similarity: ${(pair.similarity * 100).toFixed(0)}%)`);
31412
+ if (!dryRun) {
31413
+ const mergedLine = ` ${longer.id}|${longer.cat}|${longer.key}|${newContent}|${longer.file}|${mergedTags}|${newDate}|${longer.ttl}|${newAccessed}|${longer.line.split("|")[9] || ""}|${longer.line.split("|")[10] || ""}|${longer.line.split("|")[11] || ""}|${longer.line.split("|")[12] || ""}`;
31414
+ entries[entries.indexOf(longer.line)] = mergedLine;
31415
+ merged.add(pair.b);
31416
+ }
31417
+ }
31418
+ if (dryRun) {
31419
+ return {
31420
+ content: [{
31421
+ type: "text",
31422
+ text: `\u{1F50D} Dry run \u2014 would merge ${merged.size} entries:
31423
+
31424
+ ${mergeActions.join("\n")}
31425
+
31426
+ Run with dryRun: false to apply.`
31427
+ }]
31428
+ };
31429
+ }
31430
+ const newLines = entries.filter((_, i) => !merged.has(i));
31431
+ const headerIdx = newLines.findIndex((l) => l.startsWith("entries[") || /^\[\d+\|]/.test(l));
31432
+ if (headerIdx !== -1) {
31433
+ const count = newLines.filter((l) => l.startsWith(" ") && l.includes("|") && !l.startsWith(" summaries:")).length;
31434
+ newLines[headerIdx] = newLines[headerIdx].replace(/\[\d+\|/, `[${count}|`);
31435
+ }
31436
+ writeMemory(newLines.join("\n"));
31437
+ return {
31438
+ content: [{
31439
+ type: "text",
31440
+ text: `\u2705 Merged ${merged.size} entries into ${entries.length - merged.size} entries.
31441
+
31442
+ ${mergeActions.join("\n")}`
31443
+ }]
31444
+ };
31445
+ }
31446
+ );
31447
+ server2.registerTool(
31448
+ "memory_graph_path",
31449
+ {
31450
+ title: "Find Graph Path",
31451
+ description: "Find the shortest path between two memory entries in the knowledge graph. Shows how two concepts are connected through related entries.",
31452
+ inputSchema: {
31453
+ from: external_exports.string().describe("Starting entry key"),
31454
+ to: external_exports.string().describe("Target entry key")
31455
+ }
31456
+ },
31457
+ async ({ from, to }) => {
31458
+ const data = readMemory();
31459
+ const entries = parseEntries(data);
31460
+ const graph = buildGraph(entries);
31461
+ if (!graph.byKey.has(from)) {
31462
+ return { content: [{ type: "text", text: `\u274C Entry "${from}" not found in memory.` }] };
31463
+ }
31464
+ if (!graph.byKey.has(to)) {
31465
+ return { content: [{ type: "text", text: `\u274C Entry "${to}" not found in memory.` }] };
31466
+ }
31467
+ const visited = /* @__PURE__ */ new Set();
31468
+ const parent = /* @__PURE__ */ new Map();
31469
+ const queue = [from];
31470
+ visited.add(from);
31471
+ while (queue.length > 0) {
31472
+ const current2 = queue.shift();
31473
+ if (current2 === to) break;
31474
+ for (const neighbor of graph.adjacency.get(current2) || []) {
31475
+ if (!visited.has(neighbor)) {
31476
+ visited.add(neighbor);
31477
+ parent.set(neighbor, current2);
31478
+ queue.push(neighbor);
31479
+ }
31480
+ }
31481
+ }
31482
+ if (!visited.has(to)) {
31483
+ return {
31484
+ content: [{
31485
+ type: "text",
31486
+ text: `\u{1F517} No path found between "${from}" and "${to}". They may be in disconnected parts of the memory graph.`
31487
+ }]
31488
+ };
31489
+ }
31490
+ const path = [];
31491
+ let current = to;
31492
+ while (current !== null) {
31493
+ path.unshift(current);
31494
+ current = parent.get(current) || null;
31495
+ }
31496
+ const pathStr = path.map((key, i) => {
31497
+ const entry = graph.byKey.get(key);
31498
+ const arrow = i < path.length - 1 ? ` \u2192 ` : "";
31499
+ return `[${entry.category}] ${key}${arrow}`;
31500
+ }).join("\n ");
31501
+ return {
31502
+ content: [{
31503
+ type: "text",
31504
+ text: `\u{1F517} Path (${path.length} hops):
31505
+
31506
+ ${pathStr}`
31507
+ }]
31508
+ };
31509
+ }
31510
+ );
31354
31511
  }
31355
31512
  function parseRelativeMs(s) {
31356
31513
  const match = s.match(/^(\d+)(h|d|m)$/i);
@@ -31424,7 +31581,7 @@ function registerResources(server2) {
31424
31581
 
31425
31582
  // src/mcp/server.ts
31426
31583
  var server = new McpServer(
31427
- { name: "toon-memory", version: "3.0.0" },
31584
+ { name: "toon-memory", version: "3.1.0" },
31428
31585
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
31429
31586
  );
31430
31587
  registerResources(server);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "3.0.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.",
3
+ "version": "3.1.0",
4
+ "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 29 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"
@@ -27,6 +27,8 @@
27
27
  "bench:impact": "node scripts/benchmark-impact.mjs",
28
28
  "bench:context": "node scripts/bench-context-tools.mjs",
29
29
  "bench:full": "node scripts/bench-full-impact.mjs",
30
+ "bench:compress-all": "node scripts/bench-compress-all.mjs",
31
+ "bench:primer": "node scripts/bench-primer.mjs",
30
32
  "inspect": "npm run build && npx @modelcontextprotocol/inspector node bin/toon-memory.js mcp",
31
33
  "prepublishOnly": "npm run build && npm test"
32
34
  },
package/src/cli/agents.ts CHANGED
@@ -58,7 +58,8 @@ export function detectAgents(): Agent[] {
58
58
  agents.push({
59
59
  name: "claude",
60
60
  global: join(HOME, ".claude", "settings.json"),
61
- local: join(projectRoot, ".claude", "settings.json"),
61
+ local: join(projectRoot, ".mcp.json"),
62
+ hookPath: join(projectRoot, ".claude", "settings.json"),
62
63
  mcpKey: "mcpServers",
63
64
  format: "json",
64
65
  needsHooks: true,
@@ -99,8 +100,8 @@ export function detectAgents(): Agent[] {
99
100
  agents.push({
100
101
  name: "continue",
101
102
  local: join(projectRoot, ".continue", "config.json"),
102
- mcpKey: "mcpServers",
103
- format: "json",
103
+ mcpKey: "experimental.modelContextProtocolServers",
104
+ format: "continue",
104
105
  needsHooks: false,
105
106
  needsInstructions: false
106
107
  })
@@ -130,7 +131,7 @@ export function detectAgents(): Agent[] {
130
131
  agents.push({
131
132
  name: "zed",
132
133
  global: join(HOME, ".config", "zed", "settings.json"),
133
- mcpKey: "mcp_servers",
134
+ mcpKey: "context_servers",
134
135
  format: "jsonc",
135
136
  needsHooks: false,
136
137
  needsInstructions: false
@@ -138,7 +139,7 @@ export function detectAgents(): Agent[] {
138
139
 
139
140
  agents.push({
140
141
  name: "antigravity",
141
- local: join(projectRoot, ".gemini", "config", "mcp_config.json"),
142
+ local: join(projectRoot, ".agents", "mcp_config.json"),
142
143
  mcpKey: "mcpServers",
143
144
  format: "json",
144
145
  needsHooks: true,
@@ -158,7 +159,7 @@ export function detectAgents(): Agent[] {
158
159
  agents.push({
159
160
  name: "kilocode",
160
161
  global: join(HOME, ".kilocode", "mcp_settings.json"),
161
- mcpKey: "mcpServers",
162
+ mcpKey: "mcp",
162
163
  format: "json",
163
164
  needsHooks: false,
164
165
  needsInstructions: true,
@@ -167,9 +168,9 @@ export function detectAgents(): Agent[] {
167
168
 
168
169
  agents.push({
169
170
  name: "openclaw",
170
- local: join(projectRoot, ".openclaw.json"),
171
- mcpKey: "mcpServers",
172
- format: "json",
171
+ global: join(HOME, ".openclaw", "openclaw.json"),
172
+ mcpKey: "mcp.servers",
173
+ format: "openclaw",
173
174
  needsHooks: false,
174
175
  needsInstructions: false
175
176
  })
@@ -187,7 +187,7 @@ export function uninstall(): void {
187
187
  console.log(" Removed .opencode/plugins/toon-memory.ts")
188
188
  }
189
189
 
190
- const agyHooks = join(projectRoot, ".gemini", "config", "hooks.json")
190
+ const agyHooks = join(projectRoot, ".agents", "hooks.json")
191
191
  if (existsSync(agyHooks)) {
192
192
  try {
193
193
  const agyCfg = JSON.parse(readFileSync(agyHooks, "utf-8"))
@@ -35,6 +35,11 @@ export function installJSONConfig(agent: Agent, scope: string): void {
35
35
  type: "local",
36
36
  command: ["npx", "-y", "toon-memory", "mcp"]
37
37
  }
38
+ } else if (agent.name === "kilocode") {
39
+ config[mcpKey]["toon-memory"] = {
40
+ type: "local",
41
+ command: ["npx", "-y", "toon-memory", "mcp"]
42
+ }
38
43
  } else {
39
44
  config[mcpKey]["toon-memory"] = {
40
45
  command: "npx",
@@ -86,19 +91,97 @@ export function installZedConfig(agent: Agent): void {
86
91
  }
87
92
  }
88
93
 
89
- if (!config.mcp_servers) config.mcp_servers = {}
94
+ if (!config.context_servers) config.context_servers = {}
95
+
96
+ config.context_servers["toon-memory"] = {
97
+ command: "npx",
98
+ args: ["-y", "toon-memory", "mcp"],
99
+ source: "custom"
100
+ }
101
+
102
+ writeFileSync(configPath, JSON.stringify(config, null, 2))
103
+ console.log(` MCP server added to ${configPath}`)
104
+ }
105
+
106
+ /**
107
+ * Install MCP server configuration for Continue (array-based format).
108
+ * Uses experimental.modelContextProtocolServers with name/command/args array.
109
+ */
110
+ export function installContinueConfig(agent: Agent): void {
111
+ const configPath = agent.local
112
+ if (!configPath) return
113
+
114
+ const configDir = dirname(configPath)
115
+ if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true })
116
+
117
+ let config: Record<string, any> = {}
118
+ if (existsSync(configPath)) {
119
+ try {
120
+ config = JSON.parse(readFileSync(configPath, "utf-8"))
121
+ } catch {
122
+ config = {}
123
+ }
124
+ }
125
+
126
+ if (!config.experimental) config.experimental = {}
127
+ if (!config.experimental.modelContextProtocolServers) {
128
+ config.experimental.modelContextProtocolServers = []
129
+ }
90
130
 
91
- config.mcp_servers["toon-memory"] = {
131
+ const servers = config.experimental.modelContextProtocolServers
132
+ const existing = servers.findIndex(
133
+ (s: any) => s.name === "toon-memory"
134
+ )
135
+ const entry = {
136
+ name: "toon-memory",
92
137
  command: "npx",
93
138
  args: ["-y", "toon-memory", "mcp"]
94
139
  }
95
140
 
141
+ if (existing >= 0) {
142
+ servers[existing] = entry
143
+ } else {
144
+ servers.push(entry)
145
+ }
146
+
147
+ writeFileSync(configPath, JSON.stringify(config, null, 2))
148
+ console.log(` MCP server added to ${configPath}`)
149
+ }
150
+
151
+ /**
152
+ * Install MCP server configuration for OpenClaw (nested mcp.servers format).
153
+ */
154
+ export function installOpenClawConfig(agent: Agent): void {
155
+ const configPath = agent.global
156
+ if (!configPath) return
157
+
158
+ const configDir = dirname(configPath)
159
+ if (!existsSync(configDir)) mkdirSync(configDir, { recursive: true })
160
+
161
+ let config: Record<string, any> = {}
162
+ if (existsSync(configPath)) {
163
+ try {
164
+ config = JSON.parse(readFileSync(configPath, "utf-8"))
165
+ } catch {
166
+ config = {}
167
+ }
168
+ }
169
+
170
+ if (!config.mcp) config.mcp = {}
171
+ if (!config.mcp.servers) config.mcp.servers = {}
172
+
173
+ config.mcp.servers["toon-memory"] = {
174
+ command: "npx",
175
+ args: ["-y", "toon-memory", "mcp"],
176
+ enabled: true
177
+ }
178
+
96
179
  writeFileSync(configPath, JSON.stringify(config, null, 2))
97
180
  console.log(` MCP server added to ${configPath}`)
98
181
  }
99
182
 
100
183
  /**
101
- * Install MCP config for an agent based on its format.
184
+ * Install MCP server configuration for an agent based on its format.
102
185
  */
103
186
  export function installMCPConfig(agent: Agent, scope: string): void {
104
187
  if (agent.format === "none") {
@@ -110,6 +193,10 @@ export function installMCPConfig(agent: Agent, scope: string): void {
110
193
  installTOMLConfig(agent)
111
194
  } else if (agent.format === "jsonc") {
112
195
  installZedConfig(agent)
196
+ } else if (agent.format === "continue") {
197
+ installContinueConfig(agent)
198
+ } else if (agent.format === "openclaw") {
199
+ installOpenClawConfig(agent)
113
200
  } else {
114
201
  installJSONConfig(agent, scope)
115
202
  }
package/src/cli/hooks.ts CHANGED
@@ -66,7 +66,7 @@ export function installHooks(agent: Agent): void {
66
66
 
67
67
  /** Register activity-capture hooks (PostToolUse/Stop) in a JSON agent config. */
68
68
  export function registerCaptureHookJSON(agent: Agent, scriptPath: string): void {
69
- const configPath = agent.local || agent.global
69
+ const configPath = agent.hookPath || agent.local || agent.global
70
70
  if (!configPath) return
71
71
 
72
72
  const configDir = dirname(configPath)
@@ -126,7 +126,7 @@ export function registerHookTOML(agent: Agent, hookPath: string): void {
126
126
 
127
127
  /** Register SessionStart hook in JSON config (Claude Code / Gemini CLI). */
128
128
  export function registerHookJSON(agent: Agent, hookPath: string): void {
129
- const configPath = agent.format === "jsonc" ? agent.global : (agent.local || agent.global)
129
+ const configPath = agent.hookPath || (agent.format === "jsonc" ? agent.global : (agent.local || agent.global))
130
130
  if (!configPath) return
131
131
 
132
132
  const configDir = dirname(configPath)