toon-memory 2.4.0 → 2.4.2
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/capture.js +18 -8
- package/dist/cli/session-start.js +18 -8
- package/dist/cli/setup.js +83 -50
- package/mcp/server.js +19 -9
- package/package.json +1 -1
- package/src/cli/setup.ts +95 -55
- package/src/lib/sessions.ts +20 -8
- package/src/mcp/server.ts +1 -1
package/dist/cli/capture.js
CHANGED
|
@@ -91,9 +91,8 @@ function atomicWrite(file, content) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// src/lib/sessions.ts
|
|
94
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
94
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2, statSync as statSync2 } from "fs";
|
|
95
95
|
import { join } from "path";
|
|
96
|
-
import { execSync } from "child_process";
|
|
97
96
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
98
97
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
99
98
|
function sessionDir() {
|
|
@@ -119,12 +118,23 @@ function currentBranch() {
|
|
|
119
118
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
120
119
|
}
|
|
121
120
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
let gitDir = join(process.cwd(), ".git");
|
|
122
|
+
if (existsSync2(gitDir) && !statSync2(gitDir).isDirectory()) {
|
|
123
|
+
const pointer = readFileSync2(gitDir, "utf-8").trim();
|
|
124
|
+
if (pointer.startsWith("gitdir:")) {
|
|
125
|
+
const target = pointer.slice(7).trim();
|
|
126
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const headPath = join(gitDir, "HEAD");
|
|
130
|
+
if (!existsSync2(headPath)) return "unknown";
|
|
131
|
+
const head = readFileSync2(headPath, "utf-8").trim();
|
|
132
|
+
if (head.startsWith("ref:")) {
|
|
133
|
+
const ref = head.slice(4).trim();
|
|
134
|
+
const parts = ref.split("/");
|
|
135
|
+
return parts[parts.length - 1] || "unknown";
|
|
136
|
+
}
|
|
137
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
128
138
|
} catch {
|
|
129
139
|
return "unknown";
|
|
130
140
|
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3
3
|
|
|
4
4
|
// src/lib/sessions.ts
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync } from "fs";
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync, statSync } from "fs";
|
|
6
6
|
import { join } from "path";
|
|
7
|
-
import { execSync } from "child_process";
|
|
8
7
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
9
8
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
10
9
|
function isAlive(pid) {
|
|
@@ -39,12 +38,23 @@ function currentBranch() {
|
|
|
39
38
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
40
39
|
}
|
|
41
40
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
let gitDir = join(process.cwd(), ".git");
|
|
42
|
+
if (existsSync(gitDir) && !statSync(gitDir).isDirectory()) {
|
|
43
|
+
const pointer = readFileSync(gitDir, "utf-8").trim();
|
|
44
|
+
if (pointer.startsWith("gitdir:")) {
|
|
45
|
+
const target = pointer.slice(7).trim();
|
|
46
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const headPath = join(gitDir, "HEAD");
|
|
50
|
+
if (!existsSync(headPath)) return "unknown";
|
|
51
|
+
const head = readFileSync(headPath, "utf-8").trim();
|
|
52
|
+
if (head.startsWith("ref:")) {
|
|
53
|
+
const ref = head.slice(4).trim();
|
|
54
|
+
const parts = ref.split("/");
|
|
55
|
+
return parts[parts.length - 1] || "unknown";
|
|
56
|
+
}
|
|
57
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
48
58
|
} catch {
|
|
49
59
|
return "unknown";
|
|
50
60
|
}
|
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
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
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
|
@@ -27739,9 +27739,8 @@ function readUnderLock(file2, encoding = "utf-8") {
|
|
|
27739
27739
|
}
|
|
27740
27740
|
|
|
27741
27741
|
// src/lib/sessions.ts
|
|
27742
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
27742
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2, statSync as statSync2 } from "fs";
|
|
27743
27743
|
import { join } from "path";
|
|
27744
|
-
import { execSync } from "child_process";
|
|
27745
27744
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
27746
27745
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
27747
27746
|
function isAlive2(pid) {
|
|
@@ -27769,12 +27768,23 @@ function currentBranch() {
|
|
|
27769
27768
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
27770
27769
|
}
|
|
27771
27770
|
try {
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27771
|
+
let gitDir = join(process.cwd(), ".git");
|
|
27772
|
+
if (existsSync2(gitDir) && !statSync2(gitDir).isDirectory()) {
|
|
27773
|
+
const pointer = readFileSync2(gitDir, "utf-8").trim();
|
|
27774
|
+
if (pointer.startsWith("gitdir:")) {
|
|
27775
|
+
const target = pointer.slice(7).trim();
|
|
27776
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
27777
|
+
}
|
|
27778
|
+
}
|
|
27779
|
+
const headPath = join(gitDir, "HEAD");
|
|
27780
|
+
if (!existsSync2(headPath)) return "unknown";
|
|
27781
|
+
const head = readFileSync2(headPath, "utf-8").trim();
|
|
27782
|
+
if (head.startsWith("ref:")) {
|
|
27783
|
+
const ref = head.slice(4).trim();
|
|
27784
|
+
const parts = ref.split("/");
|
|
27785
|
+
return parts[parts.length - 1] || "unknown";
|
|
27786
|
+
}
|
|
27787
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
27778
27788
|
} catch {
|
|
27779
27789
|
return "unknown";
|
|
27780
27790
|
}
|
|
@@ -28398,7 +28408,7 @@ function consolidateEntries() {
|
|
|
28398
28408
|
return { removed: duplicates.length, kept: order.length, duplicates };
|
|
28399
28409
|
}
|
|
28400
28410
|
var server = new McpServer(
|
|
28401
|
-
{ name: "toon-memory", version: "2.4.
|
|
28411
|
+
{ name: "toon-memory", version: "2.4.2" },
|
|
28402
28412
|
{ capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
|
|
28403
28413
|
);
|
|
28404
28414
|
server.registerResource(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
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
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
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/lib/sessions.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync, statSync } from "fs"
|
|
2
2
|
import { join } from "path"
|
|
3
|
-
import { execSync } from "child_process"
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* File-based multi-session coordination — no server, no network, no LLM.
|
|
@@ -74,18 +73,31 @@ export function resolveSessionId(payload: Record<string, unknown> = {}): string
|
|
|
74
73
|
return `proc-${process.pid}-${Math.random().toString(36).slice(2, 10)}`
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
/** Detect the current git branch
|
|
76
|
+
/** Detect the current git branch by reading .git/HEAD directly (no shell). */
|
|
78
77
|
export function currentBranch(): string {
|
|
79
78
|
if (process.env.TOON_MEMORY_BRANCH && process.env.TOON_MEMORY_BRANCH.trim()) {
|
|
80
79
|
return process.env.TOON_MEMORY_BRANCH.trim()
|
|
81
80
|
}
|
|
82
81
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
let gitDir = join(process.cwd(), ".git")
|
|
83
|
+
// .git may be a file pointing at the real git dir (worktrees).
|
|
84
|
+
if (existsSync(gitDir) && !statSync(gitDir).isDirectory()) {
|
|
85
|
+
const pointer = readFileSync(gitDir, "utf-8").trim()
|
|
86
|
+
if (pointer.startsWith("gitdir:")) {
|
|
87
|
+
const target = pointer.slice(7).trim()
|
|
88
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const headPath = join(gitDir, "HEAD")
|
|
92
|
+
if (!existsSync(headPath)) return "unknown"
|
|
93
|
+
const head = readFileSync(headPath, "utf-8").trim()
|
|
94
|
+
if (head.startsWith("ref:")) {
|
|
95
|
+
const ref = head.slice(4).trim()
|
|
96
|
+
const parts = ref.split("/")
|
|
97
|
+
return parts[parts.length - 1] || "unknown"
|
|
98
|
+
}
|
|
99
|
+
// Detached HEAD: HEAD holds a commit hash.
|
|
100
|
+
return head ? head.slice(0, 7) : "unknown"
|
|
89
101
|
} catch {
|
|
90
102
|
return "unknown"
|
|
91
103
|
}
|
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.
|
|
602
|
+
{ name: "toon-memory", version: "2.4.2" },
|
|
603
603
|
{ capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
|
|
604
604
|
)
|
|
605
605
|
|