toon-memory 2.4.2 → 2.4.4

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.
@@ -21,6 +21,7 @@ Commands:
21
21
  init [local|global] Install memory tools + hooks for detected agents
22
22
  status Show version, memory count, and agent config status
23
23
  stats Show memory statistics
24
+ dump Print memory as injectable markdown (auto-load)
24
25
  export [file] Export memory to a TOON/JSON file
25
26
  import <file> Import memory from a TOON/JSON file
26
27
  watch Watch memory file and re-render on change
package/dist/cli/setup.js CHANGED
@@ -72,6 +72,22 @@ function extractProjectDeps(root) {
72
72
  var __dirname = dirname(fileURLToPath(import.meta.url));
73
73
  var projectRoot = process.cwd();
74
74
  var sourceDir = join2(__dirname, "..", "..", "src");
75
+ function resolvePackageJson() {
76
+ let dir = __dirname;
77
+ while (true) {
78
+ const candidate = join2(dir, "package.json");
79
+ if (existsSync2(candidate)) {
80
+ try {
81
+ const p = JSON.parse(readFileSync2(candidate, "utf-8"));
82
+ if (p && p.name === "toon-memory") return candidate;
83
+ } catch {
84
+ }
85
+ }
86
+ const parent = dirname(dir);
87
+ if (parent === dir) return null;
88
+ dir = parent;
89
+ }
90
+ }
75
91
  var HOME = process.env.HOME || process.env.USERPROFILE || "~";
76
92
  var MEMORY_DIR = join2(projectRoot, ".toon-memory", "memory");
77
93
  var CAPTURE_JS = join2(__dirname, "capture.js");
@@ -110,6 +126,10 @@ Persistent memory for this project. Use it to avoid re-investigating things.
110
126
  ## At the END of every session
111
127
  - Save important decisions, bugs resolved, and patterns observed.
112
128
  `;
129
+ var OPENCODE_PASSIVE_INSTRUCTION = `# toon-memory
130
+
131
+ La memoria se auto-inyecta v\xEDa .opencode/instructions/memory-autoload.md; usa memory_recall solo como fallback.
132
+ `;
113
133
  function detectAgents() {
114
134
  const agents = [];
115
135
  agents.push({
@@ -255,19 +275,20 @@ function installMemoryDir() {
255
275
  }
256
276
  function ensureGitignore() {
257
277
  const gitignorePath = join2(projectRoot, ".gitignore");
258
- const entry = ".toon-memory/memory/";
278
+ const entries = [".toon-memory/memory/", ".opencode/instructions/memory-autoload.md"];
259
279
  if (!existsSync2(gitignorePath)) {
260
- writeFileSync(gitignorePath, `${entry}
280
+ writeFileSync(gitignorePath, `${entries.join("\n")}
261
281
  `);
262
282
  console.log(" Created .gitignore with memory exclusion");
263
283
  return;
264
284
  }
265
285
  const content = readFileSync2(gitignorePath, "utf-8");
266
- if (!content.includes(entry)) {
286
+ const missing = entries.filter((e) => !content.includes(e));
287
+ if (missing.length > 0) {
267
288
  writeFileSync(gitignorePath, `${content.trim()}
268
- ${entry}
289
+ ${missing.join("\n")}
269
290
  `);
270
- console.log(" Added .toon-memory/memory/ to .gitignore");
291
+ console.log(` Added to .gitignore: ${missing.join(", ")}`);
271
292
  }
272
293
  }
273
294
  function installJSONConfig(agent, scope) {
@@ -356,6 +377,7 @@ function installInstructions(agent) {
356
377
  const filePath = agent.instructionFile;
357
378
  const fileDir = dirname(filePath);
358
379
  if (!existsSync2(fileDir)) mkdirSync(fileDir, { recursive: true });
380
+ const content = agent.name === "opencode" ? OPENCODE_PASSIVE_INSTRUCTION : INSTRUCTION_CONTENT;
359
381
  if (existsSync2(filePath)) {
360
382
  const existing = readFileSync2(filePath, "utf-8");
361
383
  if (existing.includes("toon-memory") || existing.includes("memory_recall")) {
@@ -364,10 +386,10 @@ function installInstructions(agent) {
364
386
  }
365
387
  writeFileSync(filePath, `${existing.trim()}
366
388
 
367
- ${INSTRUCTION_CONTENT}`);
389
+ ${content}`);
368
390
  console.log(` Appended toon-memory instructions to ${filePath}`);
369
391
  } else {
370
- writeFileSync(filePath, INSTRUCTION_CONTENT);
392
+ writeFileSync(filePath, content);
371
393
  console.log(` Created ${filePath}`);
372
394
  }
373
395
  }
@@ -454,15 +476,35 @@ command = "${hookPath}"
454
476
  console.log(` Hook registered in ${configPath}`);
455
477
  }
456
478
  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"
479
+ return `import * as fs from "fs"
480
+
481
+ export const ToonMemory = async ({ $, directory, worktree }) => {
482
+ const root = worktree || directory
483
+ const INS = root + "/.opencode/instructions"
484
+ const OUT = INS + "/memory-autoload.md"
485
+ const dump = async () => {
486
+ return await $\`npx -y toon-memory dump\`.cwd(root).text()
487
+ }
488
+ const write = (text) => {
489
+ fs.mkdirSync(INS, { recursive: true })
490
+ fs.writeFileSync(OUT, text)
491
+ }
460
492
  return {
461
493
  "session.created": async () => {
462
- try { await $\`node \${ss} opencode\`.quiet() } catch {}
494
+ try {
495
+ const out = await dump()
496
+ write(out)
497
+ } catch {}
498
+ },
499
+ "experimental.session.compacting": async ({ output }) => {
500
+ try {
501
+ const out = await dump()
502
+ if (Array.isArray(output?.context)) output.context.push(out)
503
+ } catch {}
463
504
  },
464
505
  "tool.execute.after": async (input) => {
465
506
  if (!process.env.TOON_MEMORY_CAPTURE) return
507
+ const cap = directory + "/bin/cli/capture.js"
466
508
  try {
467
509
  const payload = JSON.stringify({
468
510
  session_id: input?.session?.id ?? "",
@@ -482,6 +524,11 @@ function installOpenCodePlugin(agent) {
482
524
  const dest = join2(pluginsDir, "toon-memory.ts");
483
525
  writeFileSync(dest, opencodePluginContent());
484
526
  console.log(` Plugin created at ${dest}`);
527
+ const instrDir = join2(projectRoot, ".opencode", "instructions");
528
+ if (!existsSync2(instrDir)) mkdirSync(instrDir, { recursive: true });
529
+ const instrFile = join2(instrDir, "memory-autoload.md");
530
+ writeFileSync(instrFile, dumpMemoryMarkdown());
531
+ console.log(` Seeded ${instrFile}`);
485
532
  const configPath = agent.local || agent.global;
486
533
  if (configPath && existsSync2(configPath)) {
487
534
  try {
@@ -681,12 +728,15 @@ function uninstall() {
681
728
  }
682
729
  function status() {
683
730
  console.log("\n\u{1F9E0} toon-memory status\n");
684
- try {
685
- const pkg = JSON.parse(readFileSync2(join2(__dirname, "..", "package.json"), "utf-8"));
686
- console.log(`Version: ${pkg.version}`);
687
- } catch {
688
- console.log("Version: unknown");
731
+ const pkgPath = resolvePackageJson();
732
+ let version = "unknown";
733
+ if (pkgPath) {
734
+ try {
735
+ version = JSON.parse(readFileSync2(pkgPath, "utf-8")).version;
736
+ } catch {
737
+ }
689
738
  }
739
+ console.log(`Version: ${version}`);
690
740
  const memoryFile = join2(MEMORY_DIR, "data.toon");
691
741
  if (existsSync2(memoryFile)) {
692
742
  const data = readFileSync2(memoryFile, "utf-8");
@@ -753,8 +803,8 @@ function status() {
753
803
  function upgrade() {
754
804
  console.log("\n\u{1F9E0} toon-memory upgrade\n");
755
805
  try {
756
- const pkg = JSON.parse(readFileSync2(join2(__dirname, "..", "package.json"), "utf-8"));
757
- const currentVersion = pkg.version;
806
+ const pkgPath = resolvePackageJson();
807
+ const currentVersion = pkgPath ? JSON.parse(readFileSync2(pkgPath, "utf-8")).version : "unknown";
758
808
  console.log(`Current version: ${currentVersion}`);
759
809
  console.log("\nTo upgrade, run:");
760
810
  console.log(" npm install -g toon-memory@latest");
@@ -887,6 +937,61 @@ ${newLines}
887
937
  console.log(`Skipped ${importData.entries.length - newEntries.length} duplicates
888
938
  `);
889
939
  }
940
+ function dumpMemoryMarkdown() {
941
+ const memoryFile = join2(MEMORY_DIR, "data.toon");
942
+ if (!existsSync2(memoryFile)) {
943
+ return "# toon-memory\n(empty)\n";
944
+ }
945
+ const data = readFileSync2(memoryFile, "utf-8");
946
+ const lines = data.split("\n").filter((l) => l.startsWith(" ") && l.includes("|"));
947
+ const entries = lines.map((line) => {
948
+ const parts = line.trim().split("|");
949
+ return {
950
+ id: parts[0],
951
+ category: parts[1],
952
+ key: parts[2],
953
+ content: parts[3],
954
+ file: parts[4],
955
+ tags: parts[5] ? parts[5].split(";").filter(Boolean) : [],
956
+ date: parts[6]
957
+ };
958
+ });
959
+ const allLines = data.split("\n");
960
+ const summaryIdx = allLines.findIndex((l) => l.trim().startsWith("summaries:"));
961
+ const summaries = [];
962
+ if (summaryIdx !== -1) {
963
+ for (const sl of allLines.slice(summaryIdx + 1)) {
964
+ if (!sl.includes(":") || !sl.startsWith(" ")) continue;
965
+ const idx = sl.indexOf(":");
966
+ const file = sl.slice(0, idx).trim();
967
+ const summary = sl.slice(idx + 1).trim();
968
+ if (file && summary) summaries.push({ file, summary });
969
+ }
970
+ }
971
+ if (entries.length === 0 && summaries.length === 0) {
972
+ return "# toon-memory\n(empty)\n";
973
+ }
974
+ const out = ["# toon-memory (auto-loaded)", ""];
975
+ for (const e of entries) {
976
+ out.push(`## ${e.category}: ${e.key}`);
977
+ out.push(e.content);
978
+ out.push(`- file: ${e.file}`);
979
+ out.push(`- tags: ${e.tags.join(", ")}`);
980
+ out.push(`- date: ${e.date}`);
981
+ out.push("");
982
+ }
983
+ if (summaries.length > 0) {
984
+ out.push("## file summaries");
985
+ for (const s of summaries) {
986
+ out.push(`- ${s.file}: ${s.summary}`);
987
+ }
988
+ out.push("");
989
+ }
990
+ return out.join("\n").trimEnd() + "\n";
991
+ }
992
+ function dumpMemory() {
993
+ console.log(dumpMemoryMarkdown());
994
+ }
890
995
  function parseWatchOptions(args2) {
891
996
  const opts = {
892
997
  interval: 5,
@@ -1057,6 +1162,10 @@ if (args[0] === "stats") {
1057
1162
  stats();
1058
1163
  process.exit(0);
1059
1164
  }
1165
+ if (args[0] === "dump") {
1166
+ dumpMemory();
1167
+ process.exit(0);
1168
+ }
1060
1169
  if (args[0] === "export") {
1061
1170
  exportMemory();
1062
1171
  process.exit(0);
package/mcp/server.js CHANGED
@@ -28408,7 +28408,7 @@ function consolidateEntries() {
28408
28408
  return { removed: duplicates.length, kept: order.length, duplicates };
28409
28409
  }
28410
28410
  var server = new McpServer(
28411
- { name: "toon-memory", version: "2.4.2" },
28411
+ { name: "toon-memory", version: "2.4.3" },
28412
28412
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
28413
28413
  );
28414
28414
  server.registerResource(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
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": {
@@ -24,6 +24,7 @@ Commands:
24
24
  init [local|global] Install memory tools + hooks for detected agents
25
25
  status Show version, memory count, and agent config status
26
26
  stats Show memory statistics
27
+ dump Print memory as injectable markdown (auto-load)
27
28
  export [file] Export memory to a TOON/JSON file
28
29
  import <file> Import memory from a TOON/JSON file
29
30
  watch Watch memory file and re-render on change
package/src/cli/setup.ts CHANGED
@@ -8,6 +8,26 @@ import { extractProjectDeps } from "../lib/vocab"
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url))
9
9
  const projectRoot = process.cwd()
10
10
  const sourceDir = join(__dirname, "..", "..", "src")
11
+
12
+ /** Resolve this package's package.json by walking up from the module location.
13
+ * Setup logic may run from dist/cli/setup.js, so a fixed relative path is wrong. */
14
+ function resolvePackageJson(): string | null {
15
+ let dir = __dirname
16
+ while (true) {
17
+ const candidate = join(dir, "package.json")
18
+ if (existsSync(candidate)) {
19
+ try {
20
+ const p = JSON.parse(readFileSync(candidate, "utf-8"))
21
+ if (p && p.name === "toon-memory") return candidate
22
+ } catch {
23
+ // ignore and keep walking
24
+ }
25
+ }
26
+ const parent = dirname(dir)
27
+ if (parent === dir) return null
28
+ dir = parent
29
+ }
30
+ }
11
31
  const HOME = process.env.HOME || process.env.USERPROFILE || "~"
12
32
 
13
33
  /** Shared memory directory (agent-agnostic) */
@@ -86,6 +106,18 @@ Persistent memory for this project. Use it to avoid re-investigating things.
86
106
  - Save important decisions, bugs resolved, and patterns observed.
87
107
  `
88
108
 
109
+ /**
110
+ * Passive instruction note for OpenCode. Unlike other agents, OpenCode gets its
111
+ * memory auto-injected via `.opencode/instructions/memory-autoload.md` (written
112
+ * by the plugin on session.created), so the agent should NOT be told to actively
113
+ * run memory_recall — that would duplicate context. memory_recall is only a
114
+ * fallback for deep/semantic queries beyond the auto-loaded dump.
115
+ */
116
+ const OPENCODE_PASSIVE_INSTRUCTION = `# toon-memory
117
+
118
+ La memoria se auto-inyecta vía .opencode/instructions/memory-autoload.md; usa memory_recall solo como fallback.
119
+ `
120
+
89
121
  /**
90
122
  * Detect all supported AI coding agents on the system.
91
123
  *
@@ -283,18 +315,19 @@ function installMemoryDir(): void {
283
315
  */
284
316
  function ensureGitignore(): void {
285
317
  const gitignorePath = join(projectRoot, ".gitignore")
286
- const entry = ".toon-memory/memory/"
318
+ const entries = [".toon-memory/memory/", ".opencode/instructions/memory-autoload.md"]
287
319
 
288
320
  if (!existsSync(gitignorePath)) {
289
- writeFileSync(gitignorePath, `${entry}\n`)
321
+ writeFileSync(gitignorePath, `${entries.join("\n")}\n`)
290
322
  console.log(" Created .gitignore with memory exclusion")
291
323
  return
292
324
  }
293
325
 
294
326
  const content = readFileSync(gitignorePath, "utf-8")
295
- if (!content.includes(entry)) {
296
- writeFileSync(gitignorePath, `${content.trim()}\n${entry}\n`)
297
- console.log(" Added .toon-memory/memory/ to .gitignore")
327
+ const missing = entries.filter((e) => !content.includes(e))
328
+ if (missing.length > 0) {
329
+ writeFileSync(gitignorePath, `${content.trim()}\n${missing.join("\n")}\n`)
330
+ console.log(` Added to .gitignore: ${missing.join(", ")}`)
298
331
  }
299
332
  }
300
333
 
@@ -434,6 +467,10 @@ function installInstructions(agent: Agent): void {
434
467
 
435
468
  if (!existsSync(fileDir)) mkdirSync(fileDir, { recursive: true })
436
469
 
470
+ const content = agent.name === "opencode"
471
+ ? OPENCODE_PASSIVE_INSTRUCTION
472
+ : INSTRUCTION_CONTENT
473
+
437
474
  if (existsSync(filePath)) {
438
475
  const existing = readFileSync(filePath, "utf-8")
439
476
  if (existing.includes("toon-memory") || existing.includes("memory_recall")) {
@@ -441,10 +478,10 @@ function installInstructions(agent: Agent): void {
441
478
  return
442
479
  }
443
480
  // Append to existing file
444
- writeFileSync(filePath, `${existing.trim()}\n\n${INSTRUCTION_CONTENT}`)
481
+ writeFileSync(filePath, `${existing.trim()}\n\n${content}`)
445
482
  console.log(` Appended toon-memory instructions to ${filePath}`)
446
483
  } else {
447
- writeFileSync(filePath, INSTRUCTION_CONTENT)
484
+ writeFileSync(filePath, content)
448
485
  console.log(` Created ${filePath}`)
449
486
  }
450
487
  }
@@ -551,20 +588,48 @@ function registerHookTOML(agent: Agent, hookPath: string): void {
551
588
  }
552
589
 
553
590
  /**
554
- * OpenCode plugin source (hooks only). OpenCode 1.17+ delivers hooks via
555
- * plugins, not a top-level `hooks` config key, so `init` writes this file into
556
- * `.opencode/plugins/`. It reuses the compiled CLI commands for the actual logic.
591
+ * OpenCode plugin source with PASSIVE memory injection. OpenCode 1.17+ delivers
592
+ * hooks via plugins (not a top-level `hooks` config key), so `init` writes this
593
+ * file into `.opencode/plugins/`. The plugin:
594
+ * - on `session.created` runs `npx -y toon-memory dump` and writes the result to
595
+ * `.opencode/instructions/memory-autoload.md`, which OpenCode loads into every
596
+ * session automatically — no agent action required.
597
+ * - on `experimental.session.compacting` re-injects the dump into `output.context`
598
+ * so memory survives compaction.
599
+ * - on `tool.execute.after` keeps the opt-in activity capture (gated by
600
+ * TOON_MEMORY_CAPTURE).
601
+ * Uses `worktree || directory` as the project root.
557
602
  */
558
603
  function opencodePluginContent(): string {
559
- return `export const ToonMemory = async ({ $, directory }) => {
560
- const ss = directory + "/bin/cli/session-start.js"
561
- const cap = directory + "/bin/cli/capture.js"
604
+ return `import * as fs from "fs"
605
+
606
+ export const ToonMemory = async ({ $, directory, worktree }) => {
607
+ const root = worktree || directory
608
+ const INS = root + "/.opencode/instructions"
609
+ const OUT = INS + "/memory-autoload.md"
610
+ const dump = async () => {
611
+ return await $\`npx -y toon-memory dump\`.cwd(root).text()
612
+ }
613
+ const write = (text) => {
614
+ fs.mkdirSync(INS, { recursive: true })
615
+ fs.writeFileSync(OUT, text)
616
+ }
562
617
  return {
563
618
  "session.created": async () => {
564
- try { await $\`node \${ss} opencode\`.quiet() } catch {}
619
+ try {
620
+ const out = await dump()
621
+ write(out)
622
+ } catch {}
623
+ },
624
+ "experimental.session.compacting": async ({ output }) => {
625
+ try {
626
+ const out = await dump()
627
+ if (Array.isArray(output?.context)) output.context.push(out)
628
+ } catch {}
565
629
  },
566
630
  "tool.execute.after": async (input) => {
567
631
  if (!process.env.TOON_MEMORY_CAPTURE) return
632
+ const cap = directory + "/bin/cli/capture.js"
568
633
  try {
569
634
  const payload = JSON.stringify({
570
635
  session_id: input?.session?.id ?? "",
@@ -591,6 +656,14 @@ function installOpenCodePlugin(agent: Agent): void {
591
656
  writeFileSync(dest, opencodePluginContent())
592
657
  console.log(` Plugin created at ${dest}`)
593
658
 
659
+ // Seed the auto-loaded memory file at install time so the very first session
660
+ // already has memory in context (resolves session.created timing on first boot).
661
+ const instrDir = join(projectRoot, ".opencode", "instructions")
662
+ if (!existsSync(instrDir)) mkdirSync(instrDir, { recursive: true })
663
+ const instrFile = join(instrDir, "memory-autoload.md")
664
+ writeFileSync(instrFile, dumpMemoryMarkdown())
665
+ console.log(` Seeded ${instrFile}`)
666
+
594
667
  const configPath = agent.local || agent.global
595
668
  if (configPath && existsSync(configPath)) {
596
669
  try {
@@ -865,12 +938,16 @@ function status(): void {
865
938
  console.log("\n🧠 toon-memory status\n")
866
939
 
867
940
  // Check npm package
868
- try {
869
- const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"))
870
- console.log(`Version: ${pkg.version}`)
871
- } catch {
872
- console.log("Version: unknown")
941
+ const pkgPath = resolvePackageJson()
942
+ let version = "unknown"
943
+ if (pkgPath) {
944
+ try {
945
+ version = JSON.parse(readFileSync(pkgPath, "utf-8")).version
946
+ } catch {
947
+ // keep "unknown"
948
+ }
873
949
  }
950
+ console.log(`Version: ${version}`)
874
951
 
875
952
  // Check memory file
876
953
  const memoryFile = join(MEMORY_DIR, "data.toon")
@@ -960,8 +1037,8 @@ function upgrade(): void {
960
1037
  console.log("\n🧠 toon-memory upgrade\n")
961
1038
 
962
1039
  try {
963
- const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"))
964
- const currentVersion = pkg.version
1040
+ const pkgPath = resolvePackageJson()
1041
+ const currentVersion = pkgPath ? JSON.parse(readFileSync(pkgPath, "utf-8")).version : "unknown"
965
1042
 
966
1043
  console.log(`Current version: ${currentVersion}`)
967
1044
  console.log("\nTo upgrade, run:")
@@ -1135,6 +1212,83 @@ function importMemory(): void {
1135
1212
  console.log(`Skipped ${importData.entries.length - newEntries.length} duplicates\n`)
1136
1213
  }
1137
1214
 
1215
+ /**
1216
+ * Render the project memory as markdown ready to be injected into agent
1217
+ * context. Reads `.toon-memory/memory/data.toon` (projectRoot = cwd), parses
1218
+ * entries and file summaries, and returns a string. If there is no memory
1219
+ * yet, returns a minimal "(empty)" document.
1220
+ */
1221
+ function dumpMemoryMarkdown(): string {
1222
+ const memoryFile = join(MEMORY_DIR, "data.toon")
1223
+
1224
+ if (!existsSync(memoryFile)) {
1225
+ return "# toon-memory\n(empty)\n"
1226
+ }
1227
+
1228
+ const data = readFileSync(memoryFile, "utf-8")
1229
+ const lines = data.split("\n").filter((l: string) => l.startsWith(" ") && l.includes("|"))
1230
+
1231
+ const entries = lines.map((line: string) => {
1232
+ const parts = line.trim().split("|")
1233
+ return {
1234
+ id: parts[0],
1235
+ category: parts[1],
1236
+ key: parts[2],
1237
+ content: parts[3],
1238
+ file: parts[4],
1239
+ tags: parts[5] ? parts[5].split(";").filter(Boolean) : [],
1240
+ date: parts[6],
1241
+ }
1242
+ })
1243
+
1244
+ // File summaries live in the `summaries:` section as ` <file>: <summary>`.
1245
+ const allLines = data.split("\n")
1246
+ const summaryIdx = allLines.findIndex((l: string) => l.trim().startsWith("summaries:"))
1247
+ const summaries: { file: string; summary: string }[] = []
1248
+ if (summaryIdx !== -1) {
1249
+ for (const sl of allLines.slice(summaryIdx + 1)) {
1250
+ if (!sl.includes(":") || !sl.startsWith(" ")) continue
1251
+ const idx = sl.indexOf(":")
1252
+ const file = sl.slice(0, idx).trim()
1253
+ const summary = sl.slice(idx + 1).trim()
1254
+ if (file && summary) summaries.push({ file, summary })
1255
+ }
1256
+ }
1257
+
1258
+ if (entries.length === 0 && summaries.length === 0) {
1259
+ return "# toon-memory\n(empty)\n"
1260
+ }
1261
+
1262
+ const out: string[] = ["# toon-memory (auto-loaded)", ""]
1263
+
1264
+ for (const e of entries) {
1265
+ out.push(`## ${e.category}: ${e.key}`)
1266
+ out.push(e.content)
1267
+ out.push(`- file: ${e.file}`)
1268
+ out.push(`- tags: ${e.tags.join(", ")}`)
1269
+ out.push(`- date: ${e.date}`)
1270
+ out.push("")
1271
+ }
1272
+
1273
+ if (summaries.length > 0) {
1274
+ out.push("## file summaries")
1275
+ for (const s of summaries) {
1276
+ out.push(`- ${s.file}: ${s.summary}`)
1277
+ }
1278
+ out.push("")
1279
+ }
1280
+
1281
+ return out.join("\n").trimEnd() + "\n"
1282
+ }
1283
+
1284
+ /**
1285
+ * Print the project memory as injectable markdown (the `dump` CLI command).
1286
+ */
1287
+ function dumpMemory(): void {
1288
+ console.log(dumpMemoryMarkdown())
1289
+ }
1290
+
1291
+
1138
1292
  /** Watch mode options */
1139
1293
  interface WatchOptions {
1140
1294
  interval: number
@@ -1368,6 +1522,11 @@ if (args[0] === "stats") {
1368
1522
  process.exit(0)
1369
1523
  }
1370
1524
 
1525
+ if (args[0] === "dump") {
1526
+ dumpMemory()
1527
+ process.exit(0)
1528
+ }
1529
+
1371
1530
  if (args[0] === "export") {
1372
1531
  exportMemory()
1373
1532
  process.exit(0)
package/src/mcp/server.ts CHANGED
@@ -599,7 +599,7 @@ function consolidateEntries(): { removed: number; kept: number; duplicates: stri
599
599
  }
600
600
 
601
601
  const server = new McpServer(
602
- { name: "toon-memory", version: "2.4.2" },
602
+ { name: "toon-memory", version: "2.4.3" },
603
603
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
604
604
  )
605
605