toon-memory 2.4.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
@@ -1093,63 +1093,19 @@ async function interactiveInstall() {
1093
1093
  return;
1094
1094
  }
1095
1095
  const agents = detectAgents();
1096
- console.log("\n\u{1F9E0} toon-memory installer\n");
1097
- console.log("Agentes detectados:");
1098
- agents.forEach((a, i) => {
1099
- const hasConfig = a.format !== "none" && (a.local && existsSync2(a.local) || a.global && existsSync2(a.global));
1100
- const indicator = hasConfig ? "\u2713" : "\xB7";
1101
- const scopeNote = a.format === "none" ? "(instrucciones)" : a.global ? "(local/global)" : "(solo local)";
1102
- console.log(` ${indicator} ${i + 1}. ${a.name} ${scopeNote}`);
1103
- });
1104
- console.log("");
1105
- const rl = createInterface({ input: process.stdin, output: process.stdout });
1106
- let selected = [];
1107
- while (true) {
1108
- const answer = (await ask(rl, "Selecciona agentes (n\xFAmeros separados por comas, nombres, 'all', o Enter para todos; 'q' para salir): ")).trim().toLowerCase();
1109
- if (answer === "q") {
1110
- console.log("\nInstalaci\xF3n cancelada.\n");
1111
- rl.close();
1112
- return;
1113
- }
1114
- if (answer === "all" || answer === "") {
1115
- selected = agents;
1116
- break;
1117
- }
1118
- if (answer === "none") {
1119
- selected = [];
1120
- break;
1121
- }
1122
- const tokens = answer.split(",").map((s) => s.trim()).filter(Boolean);
1123
- const matched = [];
1124
- let valid = true;
1125
- for (const tok of tokens) {
1126
- const num = parseInt(tok, 10);
1127
- if (!isNaN(num) && num >= 1 && num <= agents.length) {
1128
- matched.push(agents[num - 1]);
1129
- } else {
1130
- const found = agents.find((a) => a.name.toLowerCase() === tok);
1131
- if (found) matched.push(found);
1132
- else {
1133
- console.log(` \u26A0\uFE0F '${tok}' no coincide con ning\xFAn agente.`);
1134
- valid = false;
1135
- break;
1136
- }
1137
- }
1138
- }
1139
- if (valid && matched.length > 0) {
1140
- selected = matched;
1141
- break;
1142
- }
1143
- console.log("Intenta de nuevo.\n");
1096
+ const selected = await runAgentChecklist(agents);
1097
+ if (selected === null) {
1098
+ console.log("\nInstalaci\xF3n cancelada.\n");
1099
+ return;
1144
1100
  }
1145
1101
  if (selected.length === 0) {
1146
1102
  console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
1147
- rl.close();
1148
1103
  return;
1149
1104
  }
1150
1105
  console.log(`
1151
1106
  Seleccionados: ${selected.map((a) => a.name).join(", ")}
1152
1107
  `);
1108
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1153
1109
  let scope = "local";
1154
1110
  while (true) {
1155
1111
  const scopeAnswer = (await ask(rl, "Alcance \u2014 (1) Local (proyecto) o (2) Global (~home)? [1/2]: ")).trim();
@@ -1198,3 +1154,80 @@ Instalando (${scope})...
1198
1154
  console.log("Run 'npx toon-memory uninstall' to remove.\n");
1199
1155
  rl.close();
1200
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();
1232
+ });
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.4.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,6 +1,6 @@
1
1
  {
2
2
  "name": "toon-memory",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
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/cli/setup.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync, cpSync, unlinkSync, readdirSync, statSync, chmodSync, rmSync } from "fs"
2
2
  import { basename, dirname, join } from "path"
3
3
  import { fileURLToPath } from "url"
4
- import { createInterface } from "readline"
4
+ import { createInterface, emitKeypressEvents, type Key } from "readline"
5
5
  import { gzipSync, gunzipSync } from "zlib"
6
6
  import { extractProjectDeps } from "../lib/vocab"
7
7
 
@@ -1418,69 +1418,21 @@ async function interactiveInstall(): Promise<void> {
1418
1418
  }
1419
1419
 
1420
1420
  const agents = detectAgents()
1421
- console.log("\n🧠 toon-memory installer\n")
1422
- console.log("Agentes detectados:")
1423
- agents.forEach((a: Agent, i: number) => {
1424
- const hasConfig = a.format !== "none" && ((a.local && existsSync(a.local)) || (a.global && existsSync(a.global)))
1425
- const indicator = hasConfig ? "✓" : "·"
1426
- const scopeNote = a.format === "none" ? "(instrucciones)" : a.global ? "(local/global)" : "(solo local)"
1427
- console.log(` ${indicator} ${i + 1}. ${a.name} ${scopeNote}`)
1428
- })
1429
- console.log("")
1430
-
1431
- const rl = createInterface({ input: process.stdin, output: process.stdout })
1432
-
1433
- // 1) Agent selection
1434
- let selected: Agent[] = []
1435
- while (true) {
1436
- const answer = (await ask(rl, "Selecciona agentes (números separados por comas, nombres, 'all', o Enter para todos; 'q' para salir): "))
1437
- .trim()
1438
- .toLowerCase()
1439
- if (answer === "q") {
1440
- console.log("\nInstalación cancelada.\n")
1441
- rl.close()
1442
- return
1443
- }
1444
- if (answer === "all" || answer === "") {
1445
- selected = agents
1446
- break
1447
- }
1448
- if (answer === "none") {
1449
- selected = []
1450
- break
1451
- }
1452
- const tokens = answer.split(",").map((s) => s.trim()).filter(Boolean)
1453
- const matched: Agent[] = []
1454
- let valid = true
1455
- for (const tok of tokens) {
1456
- const num = parseInt(tok, 10)
1457
- if (!isNaN(num) && num >= 1 && num <= agents.length) {
1458
- matched.push(agents[num - 1])
1459
- } else {
1460
- const found = agents.find((a) => a.name.toLowerCase() === tok)
1461
- if (found) matched.push(found)
1462
- else {
1463
- console.log(` ⚠️ '${tok}' no coincide con ningún agente.`)
1464
- valid = false
1465
- break
1466
- }
1467
- }
1468
- }
1469
- if (valid && matched.length > 0) {
1470
- selected = matched
1471
- break
1472
- }
1473
- console.log("Intenta de nuevo.\n")
1421
+ const selected = await runAgentChecklist(agents)
1422
+ if (selected === null) {
1423
+ console.log("\nInstalación cancelada.\n")
1424
+ return
1474
1425
  }
1475
1426
 
1476
1427
  if (selected.length === 0) {
1477
1428
  console.log("\nNo se seleccionaron agentes. Nada instalado.\n")
1478
- rl.close()
1479
1429
  return
1480
1430
  }
1481
1431
 
1482
1432
  console.log(`\nSeleccionados: ${selected.map((a) => a.name).join(", ")}\n`)
1483
1433
 
1434
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
1435
+
1484
1436
  // 2) Scope
1485
1437
  let scope = "local"
1486
1438
  while (true) {
@@ -1536,3 +1488,91 @@ async function interactiveInstall(): Promise<void> {
1536
1488
  console.log("Run 'npx toon-memory uninstall' to remove.\n")
1537
1489
  rl.close()
1538
1490
  }
1491
+
1492
+ /**
1493
+ * Navigable multi-select checklist rendered in the terminal (no dependencies).
1494
+ * ↑/↓ (or k/j) move the cursor, space toggles a selection, 'a' toggles all,
1495
+ * Enter confirms, 'q'/'c'/Ctrl-C aborts. Requires a TTY.
1496
+ */
1497
+ async function runAgentChecklist(agents: Agent[]): Promise<Agent[] | null> {
1498
+ const n = agents.length
1499
+ let cursor = 0
1500
+ const selected = new Set<number>()
1501
+ let prevLines = 0
1502
+
1503
+ const render = (): void => {
1504
+ let out = ""
1505
+ if (prevLines > 0) out += `\x1b[${prevLines}A\x1b[J`
1506
+ const lines: string[] = []
1507
+ lines.push("\n🧠 toon-memory installer")
1508
+ lines.push("")
1509
+ lines.push("Agentes detectados:")
1510
+ agents.forEach((a: Agent, i: number) => {
1511
+ const isCursor = i === cursor
1512
+ const isSel = selected.has(i)
1513
+ const box = isSel ? "[x]" : "[ ]"
1514
+ const cur = isCursor ? ">" : " "
1515
+ const hasConfig = a.format !== "none" && ((a.local && existsSync(a.local)) || (a.global && existsSync(a.global)))
1516
+ const indicator = hasConfig ? "✓" : "·"
1517
+ const scopeNote = a.format === "none" ? "(instrucciones)" : a.global ? "(local/global)" : "(solo local)"
1518
+ lines.push(` ${cur} ${box} ${indicator} ${i + 1}. ${a.name} ${scopeNote}`)
1519
+ })
1520
+ lines.push("")
1521
+ lines.push(" ↑/↓ mover · espacio marcar · 'a' todos · Enter confirmar · 'q' salir")
1522
+ process.stdout.write(out + lines.join("\n") + "\n")
1523
+ prevLines = lines.length
1524
+ }
1525
+
1526
+ return new Promise<Agent[] | null>((resolve) => {
1527
+ emitKeypressEvents(process.stdin)
1528
+ process.stdin.setRawMode(true)
1529
+ process.stdin.resume()
1530
+
1531
+ const finish = (result: Agent[] | null): void => {
1532
+ process.stdin.setRawMode(false)
1533
+ process.stdin.removeListener("keypress", onKey)
1534
+ process.stdout.write("\n")
1535
+ resolve(result)
1536
+ }
1537
+
1538
+ const onKey = (_str: string, key: Key | undefined): void => {
1539
+ if (!key) return
1540
+ if (key.ctrl && key.name === "c") {
1541
+ finish(null)
1542
+ return
1543
+ }
1544
+ switch (key.name) {
1545
+ case "up":
1546
+ case "k":
1547
+ cursor = (cursor - 1 + n) % n
1548
+ break
1549
+ case "down":
1550
+ case "j":
1551
+ cursor = (cursor + 1) % n
1552
+ break
1553
+ case "space":
1554
+ if (selected.has(cursor)) selected.delete(cursor)
1555
+ else selected.add(cursor)
1556
+ break
1557
+ case "a":
1558
+ if (selected.size === n) selected.clear()
1559
+ else for (let i = 0; i < n; i++) selected.add(i)
1560
+ break
1561
+ case "return":
1562
+ finish(agents.filter((_: Agent, i: number) => selected.has(i)))
1563
+ return
1564
+ case "q":
1565
+ case "c":
1566
+ finish(null)
1567
+ return
1568
+ default:
1569
+ render()
1570
+ return
1571
+ }
1572
+ render()
1573
+ }
1574
+
1575
+ process.stdin.on("keypress", onKey)
1576
+ render()
1577
+ })
1578
+ }
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.0" },
602
+ { name: "toon-memory", version: "2.4.1" },
603
603
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
604
604
  )
605
605