toon-memory 2.9.4 → 2.9.6

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
@@ -760,23 +760,31 @@ async function init(scope, agentFilter) {
760
760
  process.exit(1);
761
761
  }
762
762
  } else if (process.stdin.isTTY) {
763
- selected = await promptAgentSelection(agents);
764
- if (selected.length === 0) {
765
- console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
766
- return;
767
- }
768
- finalScope = await select({
769
- message: "Scope:",
770
- choices: [
771
- { name: "Local (project)", value: "local" },
772
- { name: "Global (~home)", value: "global" }
773
- ],
774
- default: finalScope
775
- });
776
- const ok = await confirm({ message: "Proceed?", default: true });
777
- if (!ok) {
778
- console.log("\nInstallation cancelled.\n");
779
- return;
763
+ try {
764
+ selected = await promptAgentSelection(agents);
765
+ if (selected.length === 0) {
766
+ console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
767
+ return;
768
+ }
769
+ finalScope = await select({
770
+ message: "Scope:",
771
+ choices: [
772
+ { name: "Local (project)", value: "local" },
773
+ { name: "Global (~home)", value: "global" }
774
+ ],
775
+ default: finalScope
776
+ });
777
+ const ok = await confirm({ message: "Proceed?", default: true });
778
+ if (!ok) {
779
+ console.log("\nInstallation cancelled.\n");
780
+ return;
781
+ }
782
+ } catch (e) {
783
+ if (e?.name === "ExitPromptError" || e?.message?.includes("SIGINT")) {
784
+ console.log("\nInstallation cancelled.\n");
785
+ return;
786
+ }
787
+ throw e;
780
788
  }
781
789
  } else {
782
790
  selected = agents;
@@ -1096,23 +1104,34 @@ async function interactiveInstall() {
1096
1104
  console.log("Run 'toon-memory init [--agent <name>]' for non-interactive installation.\n");
1097
1105
  return;
1098
1106
  }
1099
- const agents = detectAgents();
1100
- const selected = await promptAgentSelection(agents);
1101
- if (selected.length === 0) {
1102
- console.log("\nNo agents selected. Nothing installed.\n");
1103
- return;
1104
- }
1105
- const scope = await select({
1106
- message: "Scope:",
1107
- choices: [
1108
- { name: "Local (project)", value: "local" },
1109
- { name: "Global (~home)", value: "global" }
1110
- ]
1111
- });
1112
- const ok = await confirm({ message: "Proceed?", default: true });
1113
- if (!ok) {
1114
- console.log("\nInstallation cancelled.\n");
1115
- return;
1107
+ let agents;
1108
+ let selected;
1109
+ let scope;
1110
+ try {
1111
+ agents = detectAgents();
1112
+ selected = await promptAgentSelection(agents);
1113
+ if (selected.length === 0) {
1114
+ console.log("\nNo agents selected. Nothing installed.\n");
1115
+ return;
1116
+ }
1117
+ scope = await select({
1118
+ message: "Scope:",
1119
+ choices: [
1120
+ { name: "Local (project)", value: "local" },
1121
+ { name: "Global (~home)", value: "global" }
1122
+ ]
1123
+ });
1124
+ const ok = await confirm({ message: "Proceed?", default: true });
1125
+ if (!ok) {
1126
+ console.log("\nInstallation cancelled.\n");
1127
+ return;
1128
+ }
1129
+ } catch (e) {
1130
+ if (e?.name === "ExitPromptError" || e?.message?.includes("SIGINT")) {
1131
+ console.log("\nInstallation cancelled.\n");
1132
+ return;
1133
+ }
1134
+ throw e;
1116
1135
  }
1117
1136
  console.log(`
1118
1137
  Installing (${scope}) \u2014 ${selected.map((a) => a.name).join(", ")}...
package/mcp/server.js CHANGED
@@ -27828,12 +27828,8 @@ function readMemory() {
27828
27828
  const data = readUnderLock(MEMORY_FILE);
27829
27829
  if (config2.encrypted) {
27830
27830
  const key = getKey();
27831
- if (!key) return "";
27832
- try {
27833
- return decrypt(data, key);
27834
- } catch {
27835
- return "";
27836
- }
27831
+ if (!key) throw new Error("Encryption enabled but TOON_MEMORY_KEY is not set. Run 'npx toon-memory init' or set the env var.");
27832
+ return decrypt(data, key);
27837
27833
  }
27838
27834
  return data;
27839
27835
  }
@@ -27842,7 +27838,7 @@ function writeMemory(content) {
27842
27838
  const config2 = loadConfig();
27843
27839
  if (config2.encrypted) {
27844
27840
  const key = getKey();
27845
- if (!key) return;
27841
+ if (!key) throw new Error("Encryption enabled but TOON_MEMORY_KEY is not set. Run 'npx toon-memory init' or set the env var.");
27846
27842
  const encrypted = encrypt(content, key);
27847
27843
  safeWrite(MEMORY_FILE, encrypted);
27848
27844
  return;
@@ -30184,7 +30180,7 @@ function registerResources(server2) {
30184
30180
 
30185
30181
  // src/mcp/server.ts
30186
30182
  var server = new McpServer(
30187
- { name: "toon-memory", version: "2.9.4" },
30183
+ { name: "toon-memory", version: "2.9.6" },
30188
30184
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
30189
30185
  );
30190
30186
  registerResources(server);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "2.9.4",
3
+ "version": "2.9.6",
4
4
  "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 21 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -69,23 +69,31 @@ export async function init(scope?: string, agentFilter?: string[]): Promise<void
69
69
  process.exit(1)
70
70
  }
71
71
  } else if (process.stdin.isTTY) {
72
- selected = await promptAgentSelection(agents)
73
- if (selected.length === 0) {
74
- console.log("\nNo se seleccionaron agentes. Nada instalado.\n")
75
- return
76
- }
77
- finalScope = await select({
78
- message: "Scope:",
79
- choices: [
80
- { name: "Local (project)", value: "local" },
81
- { name: "Global (~home)", value: "global" }
82
- ],
83
- default: finalScope as "local" | "global"
84
- })
85
- const ok = await confirm({ message: "Proceed?", default: true })
86
- if (!ok) {
87
- console.log("\nInstallation cancelled.\n")
88
- return
72
+ try {
73
+ selected = await promptAgentSelection(agents)
74
+ if (selected.length === 0) {
75
+ console.log("\nNo se seleccionaron agentes. Nada instalado.\n")
76
+ return
77
+ }
78
+ finalScope = await select({
79
+ message: "Scope:",
80
+ choices: [
81
+ { name: "Local (project)", value: "local" },
82
+ { name: "Global (~home)", value: "global" }
83
+ ],
84
+ default: finalScope as "local" | "global"
85
+ })
86
+ const ok = await confirm({ message: "Proceed?", default: true })
87
+ if (!ok) {
88
+ console.log("\nInstallation cancelled.\n")
89
+ return
90
+ }
91
+ } catch (e: any) {
92
+ if (e?.name === "ExitPromptError" || e?.message?.includes("SIGINT")) {
93
+ console.log("\nInstallation cancelled.\n")
94
+ return
95
+ }
96
+ throw e
89
97
  }
90
98
  } else {
91
99
  selected = agents
@@ -490,25 +498,36 @@ export async function interactiveInstall(): Promise<void> {
490
498
  return
491
499
  }
492
500
 
493
- const agents = detectAgents()
494
- const selected = await promptAgentSelection(agents)
495
- if (selected.length === 0) {
496
- console.log("\nNo agents selected. Nothing installed.\n")
497
- return
498
- }
501
+ let agents: ReturnType<typeof detectAgents>
502
+ let selected: Awaited<ReturnType<typeof promptAgentSelection>>
503
+ let scope: string
504
+ try {
505
+ agents = detectAgents()
506
+ selected = await promptAgentSelection(agents)
507
+ if (selected.length === 0) {
508
+ console.log("\nNo agents selected. Nothing installed.\n")
509
+ return
510
+ }
499
511
 
500
- const scope = await select({
501
- message: "Scope:",
502
- choices: [
503
- { name: "Local (project)", value: "local" },
504
- { name: "Global (~home)", value: "global" }
505
- ]
506
- })
512
+ scope = await select({
513
+ message: "Scope:",
514
+ choices: [
515
+ { name: "Local (project)", value: "local" },
516
+ { name: "Global (~home)", value: "global" }
517
+ ]
518
+ })
507
519
 
508
- const ok = await confirm({ message: "Proceed?", default: true })
509
- if (!ok) {
510
- console.log("\nInstallation cancelled.\n")
511
- return
520
+ const ok = await confirm({ message: "Proceed?", default: true })
521
+ if (!ok) {
522
+ console.log("\nInstallation cancelled.\n")
523
+ return
524
+ }
525
+ } catch (e: any) {
526
+ if (e?.name === "ExitPromptError" || e?.message?.includes("SIGINT")) {
527
+ console.log("\nInstallation cancelled.\n")
528
+ return
529
+ }
530
+ throw e
512
531
  }
513
532
 
514
533
  console.log(`\nInstalling (${scope}) — ${selected.map((a) => a.name).join(", ")}...\n`)
@@ -14,6 +14,7 @@ export function safeWrite(file: string, content: string): void {
14
14
  /**
15
15
  * Read memory file, decrypting if encryption is enabled.
16
16
  * Key is read from TOON_MEMORY_KEY env var.
17
+ * @throws if encryption is enabled but no key is available or decryption fails.
17
18
  */
18
19
  export function readMemory(): string {
19
20
  ensureMemoryFile()
@@ -22,12 +23,8 @@ export function readMemory(): string {
22
23
 
23
24
  if (config.encrypted) {
24
25
  const key = getKey()
25
- if (!key) return ""
26
- try {
27
- return decrypt(data, key)
28
- } catch {
29
- return ""
30
- }
26
+ if (!key) throw new Error("Encryption enabled but TOON_MEMORY_KEY is not set. Run 'npx toon-memory init' or set the env var.")
27
+ return decrypt(data, key)
31
28
  }
32
29
 
33
30
  return data
@@ -36,6 +33,7 @@ export function readMemory(): string {
36
33
  /**
37
34
  * Write content to memory file, encrypting if encryption is enabled.
38
35
  * Key is read from TOON_MEMORY_KEY env var.
36
+ * @throws if encryption is enabled but no key is available.
39
37
  */
40
38
  export function writeMemory(content: string): void {
41
39
  ensureMemoryFile()
@@ -43,7 +41,7 @@ export function writeMemory(content: string): void {
43
41
 
44
42
  if (config.encrypted) {
45
43
  const key = getKey()
46
- if (!key) return
44
+ if (!key) throw new Error("Encryption enabled but TOON_MEMORY_KEY is not set. Run 'npx toon-memory init' or set the env var.")
47
45
  const encrypted = encrypt(content, key)
48
46
  safeWrite(MEMORY_FILE, encrypted)
49
47
  return