toon-memory 2.4.3 → 2.4.5
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/bin/toon-memory.js +1 -0
- package/dist/cli/setup.js +101 -11
- package/package.json +1 -1
- package/src/bin/toon-memory.ts +1 -0
- package/src/cli/setup.ts +149 -14
package/bin/toon-memory.js
CHANGED
|
@@ -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
|
@@ -126,6 +126,10 @@ Persistent memory for this project. Use it to avoid re-investigating things.
|
|
|
126
126
|
## At the END of every session
|
|
127
127
|
- Save important decisions, bugs resolved, and patterns observed.
|
|
128
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
|
+
`;
|
|
129
133
|
function detectAgents() {
|
|
130
134
|
const agents = [];
|
|
131
135
|
agents.push({
|
|
@@ -271,19 +275,20 @@ function installMemoryDir() {
|
|
|
271
275
|
}
|
|
272
276
|
function ensureGitignore() {
|
|
273
277
|
const gitignorePath = join2(projectRoot, ".gitignore");
|
|
274
|
-
const
|
|
278
|
+
const entries = [".toon-memory/memory/", ".opencode/instructions/memory-autoload.md"];
|
|
275
279
|
if (!existsSync2(gitignorePath)) {
|
|
276
|
-
writeFileSync(gitignorePath, `${
|
|
280
|
+
writeFileSync(gitignorePath, `${entries.join("\n")}
|
|
277
281
|
`);
|
|
278
282
|
console.log(" Created .gitignore with memory exclusion");
|
|
279
283
|
return;
|
|
280
284
|
}
|
|
281
285
|
const content = readFileSync2(gitignorePath, "utf-8");
|
|
282
|
-
|
|
286
|
+
const missing = entries.filter((e) => !content.includes(e));
|
|
287
|
+
if (missing.length > 0) {
|
|
283
288
|
writeFileSync(gitignorePath, `${content.trim()}
|
|
284
|
-
${
|
|
289
|
+
${missing.join("\n")}
|
|
285
290
|
`);
|
|
286
|
-
console.log(
|
|
291
|
+
console.log(` Added to .gitignore: ${missing.join(", ")}`);
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
function installJSONConfig(agent, scope) {
|
|
@@ -372,6 +377,7 @@ function installInstructions(agent) {
|
|
|
372
377
|
const filePath = agent.instructionFile;
|
|
373
378
|
const fileDir = dirname(filePath);
|
|
374
379
|
if (!existsSync2(fileDir)) mkdirSync(fileDir, { recursive: true });
|
|
380
|
+
const content = agent.name === "opencode" ? OPENCODE_PASSIVE_INSTRUCTION : INSTRUCTION_CONTENT;
|
|
375
381
|
if (existsSync2(filePath)) {
|
|
376
382
|
const existing = readFileSync2(filePath, "utf-8");
|
|
377
383
|
if (existing.includes("toon-memory") || existing.includes("memory_recall")) {
|
|
@@ -380,10 +386,10 @@ function installInstructions(agent) {
|
|
|
380
386
|
}
|
|
381
387
|
writeFileSync(filePath, `${existing.trim()}
|
|
382
388
|
|
|
383
|
-
${
|
|
389
|
+
${content}`);
|
|
384
390
|
console.log(` Appended toon-memory instructions to ${filePath}`);
|
|
385
391
|
} else {
|
|
386
|
-
writeFileSync(filePath,
|
|
392
|
+
writeFileSync(filePath, content);
|
|
387
393
|
console.log(` Created ${filePath}`);
|
|
388
394
|
}
|
|
389
395
|
}
|
|
@@ -470,15 +476,35 @@ command = "${hookPath}"
|
|
|
470
476
|
console.log(` Hook registered in ${configPath}`);
|
|
471
477
|
}
|
|
472
478
|
function opencodePluginContent() {
|
|
473
|
-
return `
|
|
474
|
-
|
|
475
|
-
|
|
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
|
+
}
|
|
476
492
|
return {
|
|
477
493
|
"session.created": async () => {
|
|
478
|
-
try {
|
|
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 {}
|
|
479
504
|
},
|
|
480
505
|
"tool.execute.after": async (input) => {
|
|
481
506
|
if (!process.env.TOON_MEMORY_CAPTURE) return
|
|
507
|
+
const cap = directory + "/bin/cli/capture.js"
|
|
482
508
|
try {
|
|
483
509
|
const payload = JSON.stringify({
|
|
484
510
|
session_id: input?.session?.id ?? "",
|
|
@@ -498,6 +524,11 @@ function installOpenCodePlugin(agent) {
|
|
|
498
524
|
const dest = join2(pluginsDir, "toon-memory.ts");
|
|
499
525
|
writeFileSync(dest, opencodePluginContent());
|
|
500
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}`);
|
|
501
532
|
const configPath = agent.local || agent.global;
|
|
502
533
|
if (configPath && existsSync2(configPath)) {
|
|
503
534
|
try {
|
|
@@ -906,6 +937,61 @@ ${newLines}
|
|
|
906
937
|
console.log(`Skipped ${importData.entries.length - newEntries.length} duplicates
|
|
907
938
|
`);
|
|
908
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
|
+
if (e.file) out.push(`- file: ${e.file}`);
|
|
979
|
+
if (e.tags.length) out.push(`- tags: ${e.tags.join(", ")}`);
|
|
980
|
+
if (e.date) 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
|
+
}
|
|
909
995
|
function parseWatchOptions(args2) {
|
|
910
996
|
const opts = {
|
|
911
997
|
interval: 5,
|
|
@@ -1076,6 +1162,10 @@ if (args[0] === "stats") {
|
|
|
1076
1162
|
stats();
|
|
1077
1163
|
process.exit(0);
|
|
1078
1164
|
}
|
|
1165
|
+
if (args[0] === "dump") {
|
|
1166
|
+
dumpMemory();
|
|
1167
|
+
process.exit(0);
|
|
1168
|
+
}
|
|
1079
1169
|
if (args[0] === "export") {
|
|
1080
1170
|
exportMemory();
|
|
1081
1171
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.5",
|
|
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": {
|
package/src/bin/toon-memory.ts
CHANGED
|
@@ -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
|
@@ -106,6 +106,18 @@ Persistent memory for this project. Use it to avoid re-investigating things.
|
|
|
106
106
|
- Save important decisions, bugs resolved, and patterns observed.
|
|
107
107
|
`
|
|
108
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
|
+
|
|
109
121
|
/**
|
|
110
122
|
* Detect all supported AI coding agents on the system.
|
|
111
123
|
*
|
|
@@ -303,18 +315,19 @@ function installMemoryDir(): void {
|
|
|
303
315
|
*/
|
|
304
316
|
function ensureGitignore(): void {
|
|
305
317
|
const gitignorePath = join(projectRoot, ".gitignore")
|
|
306
|
-
const
|
|
318
|
+
const entries = [".toon-memory/memory/", ".opencode/instructions/memory-autoload.md"]
|
|
307
319
|
|
|
308
320
|
if (!existsSync(gitignorePath)) {
|
|
309
|
-
writeFileSync(gitignorePath, `${
|
|
321
|
+
writeFileSync(gitignorePath, `${entries.join("\n")}\n`)
|
|
310
322
|
console.log(" Created .gitignore with memory exclusion")
|
|
311
323
|
return
|
|
312
324
|
}
|
|
313
325
|
|
|
314
326
|
const content = readFileSync(gitignorePath, "utf-8")
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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(", ")}`)
|
|
318
331
|
}
|
|
319
332
|
}
|
|
320
333
|
|
|
@@ -454,6 +467,10 @@ function installInstructions(agent: Agent): void {
|
|
|
454
467
|
|
|
455
468
|
if (!existsSync(fileDir)) mkdirSync(fileDir, { recursive: true })
|
|
456
469
|
|
|
470
|
+
const content = agent.name === "opencode"
|
|
471
|
+
? OPENCODE_PASSIVE_INSTRUCTION
|
|
472
|
+
: INSTRUCTION_CONTENT
|
|
473
|
+
|
|
457
474
|
if (existsSync(filePath)) {
|
|
458
475
|
const existing = readFileSync(filePath, "utf-8")
|
|
459
476
|
if (existing.includes("toon-memory") || existing.includes("memory_recall")) {
|
|
@@ -461,10 +478,10 @@ function installInstructions(agent: Agent): void {
|
|
|
461
478
|
return
|
|
462
479
|
}
|
|
463
480
|
// Append to existing file
|
|
464
|
-
writeFileSync(filePath, `${existing.trim()}\n\n${
|
|
481
|
+
writeFileSync(filePath, `${existing.trim()}\n\n${content}`)
|
|
465
482
|
console.log(` Appended toon-memory instructions to ${filePath}`)
|
|
466
483
|
} else {
|
|
467
|
-
writeFileSync(filePath,
|
|
484
|
+
writeFileSync(filePath, content)
|
|
468
485
|
console.log(` Created ${filePath}`)
|
|
469
486
|
}
|
|
470
487
|
}
|
|
@@ -571,20 +588,48 @@ function registerHookTOML(agent: Agent, hookPath: string): void {
|
|
|
571
588
|
}
|
|
572
589
|
|
|
573
590
|
/**
|
|
574
|
-
* OpenCode plugin source
|
|
575
|
-
* plugins
|
|
576
|
-
* `.opencode/plugins/`.
|
|
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.
|
|
577
602
|
*/
|
|
578
603
|
function opencodePluginContent(): string {
|
|
579
|
-
return `
|
|
580
|
-
|
|
581
|
-
|
|
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
|
+
}
|
|
582
617
|
return {
|
|
583
618
|
"session.created": async () => {
|
|
584
|
-
try {
|
|
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 {}
|
|
585
629
|
},
|
|
586
630
|
"tool.execute.after": async (input) => {
|
|
587
631
|
if (!process.env.TOON_MEMORY_CAPTURE) return
|
|
632
|
+
const cap = directory + "/bin/cli/capture.js"
|
|
588
633
|
try {
|
|
589
634
|
const payload = JSON.stringify({
|
|
590
635
|
session_id: input?.session?.id ?? "",
|
|
@@ -611,6 +656,14 @@ function installOpenCodePlugin(agent: Agent): void {
|
|
|
611
656
|
writeFileSync(dest, opencodePluginContent())
|
|
612
657
|
console.log(` Plugin created at ${dest}`)
|
|
613
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
|
+
|
|
614
667
|
const configPath = agent.local || agent.global
|
|
615
668
|
if (configPath && existsSync(configPath)) {
|
|
616
669
|
try {
|
|
@@ -1159,6 +1212,83 @@ function importMemory(): void {
|
|
|
1159
1212
|
console.log(`Skipped ${importData.entries.length - newEntries.length} duplicates\n`)
|
|
1160
1213
|
}
|
|
1161
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
|
+
if (e.file) out.push(`- file: ${e.file}`)
|
|
1268
|
+
if (e.tags.length) out.push(`- tags: ${e.tags.join(", ")}`)
|
|
1269
|
+
if (e.date) 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
|
+
|
|
1162
1292
|
/** Watch mode options */
|
|
1163
1293
|
interface WatchOptions {
|
|
1164
1294
|
interval: number
|
|
@@ -1392,6 +1522,11 @@ if (args[0] === "stats") {
|
|
|
1392
1522
|
process.exit(0)
|
|
1393
1523
|
}
|
|
1394
1524
|
|
|
1525
|
+
if (args[0] === "dump") {
|
|
1526
|
+
dumpMemory()
|
|
1527
|
+
process.exit(0)
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1395
1530
|
if (args[0] === "export") {
|
|
1396
1531
|
exportMemory()
|
|
1397
1532
|
process.exit(0)
|