toon-memory 2.4.4 → 2.5.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/README.md +192 -41
- package/bin/toon-memory.js +17 -14
- package/dist/cli/setup.js +92 -134
- package/mcp/server.js +226 -33
- package/package.json +8 -2
- package/src/bin/toon-memory.ts +17 -14
- package/src/cli/setup.ts +102 -154
- package/src/lib/quality.ts +221 -0
- package/src/mcp/server.ts +98 -31
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 {
|
|
5
|
+
import { checkbox, select, confirm } from "@inquirer/prompts";
|
|
6
6
|
import { gzipSync } from "zlib";
|
|
7
7
|
|
|
8
8
|
// src/lib/vocab.ts
|
|
@@ -624,7 +624,17 @@ function updateMemoryConfig(patch) {
|
|
|
624
624
|
Object.assign(cfg, patch);
|
|
625
625
|
writeFileSync(CAPTURE_CONFIG, JSON.stringify(cfg, null, 2));
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
async function promptAgentSelection(agents) {
|
|
628
|
+
return checkbox({
|
|
629
|
+
message: "\xBFQu\xE9 agentes quieres configurar?",
|
|
630
|
+
choices: agents.map((a) => ({
|
|
631
|
+
name: `${a.name} (${a.format === "none" ? "instrucciones" : a.global ? "local/global" : "solo local"})`,
|
|
632
|
+
value: a,
|
|
633
|
+
checked: true
|
|
634
|
+
}))
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
async function init(scope, agentFilter) {
|
|
628
638
|
console.log("\n\u{1F9E0} toon-memory init\n");
|
|
629
639
|
installMemoryDir();
|
|
630
640
|
const deps = extractProjectDeps(projectRoot);
|
|
@@ -634,8 +644,42 @@ function init(scope = "local") {
|
|
|
634
644
|
console.log(` Detected ${depCount} dependencies \u2192 auto-tag vocabulary written to config.json`);
|
|
635
645
|
}
|
|
636
646
|
const agents = detectAgents();
|
|
637
|
-
|
|
638
|
-
|
|
647
|
+
let selected;
|
|
648
|
+
let finalScope = scope || "local";
|
|
649
|
+
if (agentFilter && agentFilter.length > 0) {
|
|
650
|
+
selected = agents.filter((a) => agentFilter.includes(a.name.toLowerCase()));
|
|
651
|
+
if (selected.length === 0) {
|
|
652
|
+
console.log(`Agentes no encontrados: ${agentFilter.join(", ")}`);
|
|
653
|
+
console.log(`Disponibles: ${agents.map((a) => a.name).join(", ")}`);
|
|
654
|
+
process.exit(1);
|
|
655
|
+
}
|
|
656
|
+
} else if (process.stdin.isTTY) {
|
|
657
|
+
selected = await promptAgentSelection(agents);
|
|
658
|
+
if (selected.length === 0) {
|
|
659
|
+
console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
finalScope = await select({
|
|
663
|
+
message: "Alcance:",
|
|
664
|
+
choices: [
|
|
665
|
+
{ name: "Local (proyecto)", value: "local" },
|
|
666
|
+
{ name: "Global (~home)", value: "global" }
|
|
667
|
+
],
|
|
668
|
+
default: finalScope
|
|
669
|
+
});
|
|
670
|
+
const ok = await confirm({ message: "\xBFProceder?", default: true });
|
|
671
|
+
if (!ok) {
|
|
672
|
+
console.log("\nInstalaci\xF3n cancelada.\n");
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
} else {
|
|
676
|
+
selected = agents;
|
|
677
|
+
}
|
|
678
|
+
console.log(`
|
|
679
|
+
Instalando (${finalScope}) \u2014 ${selected.map((a) => a.name).join(", ")}...
|
|
680
|
+
`);
|
|
681
|
+
for (const agent of selected) {
|
|
682
|
+
installForAgent(agent, finalScope);
|
|
639
683
|
console.log("");
|
|
640
684
|
}
|
|
641
685
|
ensureGitignore();
|
|
@@ -947,13 +991,13 @@ function dumpMemoryMarkdown() {
|
|
|
947
991
|
const entries = lines.map((line) => {
|
|
948
992
|
const parts = line.trim().split("|");
|
|
949
993
|
return {
|
|
950
|
-
id: parts[0],
|
|
951
|
-
category: parts[1],
|
|
952
|
-
key: parts[2],
|
|
953
|
-
content: parts[3],
|
|
954
|
-
file: parts[4],
|
|
994
|
+
id: parts[0] ?? "",
|
|
995
|
+
category: parts[1] ?? "",
|
|
996
|
+
key: parts[2] ?? "",
|
|
997
|
+
content: parts[3] ?? "",
|
|
998
|
+
file: parts[4] ?? "",
|
|
955
999
|
tags: parts[5] ? parts[5].split(";").filter(Boolean) : [],
|
|
956
|
-
date: parts[6]
|
|
1000
|
+
date: parts[6] ?? ""
|
|
957
1001
|
};
|
|
958
1002
|
});
|
|
959
1003
|
const allLines = data.split("\n");
|
|
@@ -975,9 +1019,9 @@ function dumpMemoryMarkdown() {
|
|
|
975
1019
|
for (const e of entries) {
|
|
976
1020
|
out.push(`## ${e.category}: ${e.key}`);
|
|
977
1021
|
out.push(e.content);
|
|
978
|
-
out.push(`- file: ${e.file}`);
|
|
979
|
-
out.push(`- tags: ${e.tags.join(", ")}`);
|
|
980
|
-
out.push(`- date: ${e.date}`);
|
|
1022
|
+
if (e.file) out.push(`- file: ${e.file}`);
|
|
1023
|
+
if (e.tags.length) out.push(`- tags: ${e.tags.join(", ")}`);
|
|
1024
|
+
if (e.date) out.push(`- date: ${e.date}`);
|
|
981
1025
|
out.push("");
|
|
982
1026
|
}
|
|
983
1027
|
if (summaries.length > 0) {
|
|
@@ -1147,7 +1191,25 @@ if (args[0] === "uninstall") {
|
|
|
1147
1191
|
process.exit(0);
|
|
1148
1192
|
}
|
|
1149
1193
|
if (args[0] === "init") {
|
|
1150
|
-
|
|
1194
|
+
const rest = args.slice(1);
|
|
1195
|
+
const agentNames = [];
|
|
1196
|
+
let scope;
|
|
1197
|
+
let i = 0;
|
|
1198
|
+
while (i < rest.length) {
|
|
1199
|
+
if (rest[i] === "--agent" && rest[i + 1]) {
|
|
1200
|
+
agentNames.push(rest[i + 1].toLowerCase());
|
|
1201
|
+
i += 2;
|
|
1202
|
+
} else if (rest[i] === "--scope" && rest[i + 1]) {
|
|
1203
|
+
scope = rest[i + 1];
|
|
1204
|
+
i += 2;
|
|
1205
|
+
} else if (rest[i] !== "--agent" && rest[i] !== "--scope") {
|
|
1206
|
+
scope = rest[i];
|
|
1207
|
+
i++;
|
|
1208
|
+
} else {
|
|
1209
|
+
i++;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
await init(scope, agentNames.length > 0 ? agentNames : void 0);
|
|
1151
1213
|
process.exit(0);
|
|
1152
1214
|
}
|
|
1153
1215
|
if (args[0] === "status") {
|
|
@@ -1187,66 +1249,40 @@ console.log(`Comando desconocido: '${args[0]}'
|
|
|
1187
1249
|
printUsage();
|
|
1188
1250
|
process.exit(1);
|
|
1189
1251
|
function printUsage() {
|
|
1190
|
-
console.log(`Uso: toon-memory <comando> [
|
|
1252
|
+
console.log(`Uso: toon-memory <comando> [opciones]
|
|
1191
1253
|
Comandos: init, status, stats, export, import, watch, uninstall, capture, upgrade, mcp
|
|
1254
|
+
Init: toon-memory init [--agent <nombre> --agent <nombre>...] [--scope local|global]
|
|
1255
|
+
Sin --agent: selector interactivo de agentes y scope.
|
|
1256
|
+
Con --agent: instalaci\xF3n no interactiva (default: scope local).
|
|
1192
1257
|
Opciones: -v/--version, -h/--help
|
|
1193
1258
|
Sin argumentos inicia el instalador interactivo.`);
|
|
1194
1259
|
}
|
|
1195
|
-
function ask(rl, prompt) {
|
|
1196
|
-
return new Promise((resolve) => rl.question(prompt, resolve));
|
|
1197
|
-
}
|
|
1198
1260
|
async function interactiveInstall() {
|
|
1199
1261
|
if (!process.stdin.isTTY) {
|
|
1200
1262
|
console.log("\n\u{1F9E0} toon-memory \u2014 la instalaci\xF3n interactiva requiere una terminal.");
|
|
1201
|
-
console.log("Ejecuta 'toon-memory init [
|
|
1263
|
+
console.log("Ejecuta 'toon-memory init [--agent <nombre>]' para instalaci\xF3n no interactiva.\n");
|
|
1202
1264
|
return;
|
|
1203
1265
|
}
|
|
1204
1266
|
const agents = detectAgents();
|
|
1205
|
-
const selected = await
|
|
1206
|
-
if (selected === null) {
|
|
1207
|
-
console.log("\nInstalaci\xF3n cancelada.\n");
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1267
|
+
const selected = await promptAgentSelection(agents);
|
|
1210
1268
|
if (selected.length === 0) {
|
|
1211
1269
|
console.log("\nNo se seleccionaron agentes. Nada instalado.\n");
|
|
1212
1270
|
return;
|
|
1213
1271
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
break;
|
|
1224
|
-
}
|
|
1225
|
-
if (scopeAnswer === "2") {
|
|
1226
|
-
scope = "global";
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
console.log("Escribe 1 (local) o 2 (global).\n");
|
|
1230
|
-
}
|
|
1231
|
-
console.log("\nSe instalar\xE1:");
|
|
1232
|
-
for (const a of selected) {
|
|
1233
|
-
const resolved = scope === "global" && a.global ? "global" : "local";
|
|
1234
|
-
const parts = [];
|
|
1235
|
-
if (a.format !== "none") parts.push("MCP");
|
|
1236
|
-
if (a.needsPlugin) parts.push("plugin");
|
|
1237
|
-
else if (a.needsHooks) parts.push("hooks");
|
|
1238
|
-
if (a.needsInstructions) parts.push("instrucciones");
|
|
1239
|
-
const target = resolved === "global" && a.global ? a.global : a.local || "(instrucciones)";
|
|
1240
|
-
console.log(` \u2022 ${a.name} [${resolved}] \u2192 ${target}${parts.length ? ` (${parts.join(", ")})` : ""}`);
|
|
1241
|
-
}
|
|
1242
|
-
const confirm = (await ask(rl, "\n\xBFProceder? [Y/n]: ")).trim().toLowerCase();
|
|
1243
|
-
if (confirm === "n" || confirm === "no") {
|
|
1272
|
+
const scope = await select({
|
|
1273
|
+
message: "Alcance:",
|
|
1274
|
+
choices: [
|
|
1275
|
+
{ name: "Local (proyecto)", value: "local" },
|
|
1276
|
+
{ name: "Global (~home)", value: "global" }
|
|
1277
|
+
]
|
|
1278
|
+
});
|
|
1279
|
+
const ok = await confirm({ message: "\xBFProceder?", default: true });
|
|
1280
|
+
if (!ok) {
|
|
1244
1281
|
console.log("\nInstalaci\xF3n cancelada.\n");
|
|
1245
|
-
rl.close();
|
|
1246
1282
|
return;
|
|
1247
1283
|
}
|
|
1248
1284
|
console.log(`
|
|
1249
|
-
Instalando (${scope})...
|
|
1285
|
+
Instalando (${scope}) \u2014 ${selected.map((a) => a.name).join(", ")}...
|
|
1250
1286
|
`);
|
|
1251
1287
|
installMemoryDir();
|
|
1252
1288
|
const deps = extractProjectDeps(projectRoot);
|
|
@@ -1261,82 +1297,4 @@ Instalando (${scope})...
|
|
|
1261
1297
|
ensureGitignore();
|
|
1262
1298
|
console.log("Done! Restart your agent to use memory tools.");
|
|
1263
1299
|
console.log("Run 'npx toon-memory uninstall' to remove.\n");
|
|
1264
|
-
rl.close();
|
|
1265
|
-
}
|
|
1266
|
-
async function runAgentChecklist(agents) {
|
|
1267
|
-
const n = agents.length;
|
|
1268
|
-
let cursor = 0;
|
|
1269
|
-
const selected = /* @__PURE__ */ new Set();
|
|
1270
|
-
let prevLines = 0;
|
|
1271
|
-
const render = () => {
|
|
1272
|
-
let out = "";
|
|
1273
|
-
if (prevLines > 0) out += `\x1B[${prevLines}A\x1B[J`;
|
|
1274
|
-
const lines = [];
|
|
1275
|
-
lines.push("\n\u{1F9E0} toon-memory installer");
|
|
1276
|
-
lines.push("");
|
|
1277
|
-
lines.push("Agentes detectados:");
|
|
1278
|
-
agents.forEach((a, i) => {
|
|
1279
|
-
const isCursor = i === cursor;
|
|
1280
|
-
const isSel = selected.has(i);
|
|
1281
|
-
const box = isSel ? "[x]" : "[ ]";
|
|
1282
|
-
const cur = isCursor ? ">" : " ";
|
|
1283
|
-
const hasConfig = a.format !== "none" && (a.local && existsSync2(a.local) || a.global && existsSync2(a.global));
|
|
1284
|
-
const indicator = hasConfig ? "\u2713" : "\xB7";
|
|
1285
|
-
const scopeNote = a.format === "none" ? "(instrucciones)" : a.global ? "(local/global)" : "(solo local)";
|
|
1286
|
-
lines.push(` ${cur} ${box} ${indicator} ${i + 1}. ${a.name} ${scopeNote}`);
|
|
1287
|
-
});
|
|
1288
|
-
lines.push("");
|
|
1289
|
-
lines.push(" \u2191/\u2193 mover \xB7 espacio marcar \xB7 'a' todos \xB7 Enter confirmar \xB7 'q' salir");
|
|
1290
|
-
process.stdout.write(out + lines.join("\n") + "\n");
|
|
1291
|
-
prevLines = lines.length;
|
|
1292
|
-
};
|
|
1293
|
-
return new Promise((resolve) => {
|
|
1294
|
-
emitKeypressEvents(process.stdin);
|
|
1295
|
-
process.stdin.setRawMode(true);
|
|
1296
|
-
process.stdin.resume();
|
|
1297
|
-
const finish = (result) => {
|
|
1298
|
-
process.stdin.setRawMode(false);
|
|
1299
|
-
process.stdin.removeListener("keypress", onKey);
|
|
1300
|
-
process.stdout.write("\n");
|
|
1301
|
-
resolve(result);
|
|
1302
|
-
};
|
|
1303
|
-
const onKey = (_str, key) => {
|
|
1304
|
-
if (!key) return;
|
|
1305
|
-
if (key.ctrl && key.name === "c") {
|
|
1306
|
-
finish(null);
|
|
1307
|
-
return;
|
|
1308
|
-
}
|
|
1309
|
-
switch (key.name) {
|
|
1310
|
-
case "up":
|
|
1311
|
-
case "k":
|
|
1312
|
-
cursor = (cursor - 1 + n) % n;
|
|
1313
|
-
break;
|
|
1314
|
-
case "down":
|
|
1315
|
-
case "j":
|
|
1316
|
-
cursor = (cursor + 1) % n;
|
|
1317
|
-
break;
|
|
1318
|
-
case "space":
|
|
1319
|
-
if (selected.has(cursor)) selected.delete(cursor);
|
|
1320
|
-
else selected.add(cursor);
|
|
1321
|
-
break;
|
|
1322
|
-
case "a":
|
|
1323
|
-
if (selected.size === n) selected.clear();
|
|
1324
|
-
else for (let i = 0; i < n; i++) selected.add(i);
|
|
1325
|
-
break;
|
|
1326
|
-
case "return":
|
|
1327
|
-
finish(agents.filter((_, i) => selected.has(i)));
|
|
1328
|
-
return;
|
|
1329
|
-
case "q":
|
|
1330
|
-
case "c":
|
|
1331
|
-
finish(null);
|
|
1332
|
-
return;
|
|
1333
|
-
default:
|
|
1334
|
-
render();
|
|
1335
|
-
return;
|
|
1336
|
-
}
|
|
1337
|
-
render();
|
|
1338
|
-
};
|
|
1339
|
-
process.stdin.on("keypress", onKey);
|
|
1340
|
-
render();
|
|
1341
|
-
});
|
|
1342
1300
|
}
|