kiro-memory 1.1.4 → 1.2.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 CHANGED
@@ -308,6 +308,105 @@ npm run test:context
308
308
  npm run test:server
309
309
  ```
310
310
 
311
+ ## Troubleshooting
312
+
313
+ ### `invalid ELF header` (WSL)
314
+
315
+ ```
316
+ Error: .../better_sqlite3.node: invalid ELF header
317
+ ```
318
+
319
+ This happens when the native module was compiled for Windows but you're running inside WSL (Linux). Common cause: npm installed to the Windows filesystem (`/mnt/c/...`) instead of the Linux one.
320
+
321
+ **Fix:**
322
+
323
+ ```bash
324
+ # Check which node you're using
325
+ which node
326
+ # If it shows /mnt/c/... you're using Windows Node inside WSL
327
+
328
+ # Install Node.js natively in WSL
329
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
330
+ sudo apt-get install -y nodejs
331
+
332
+ # Or use nvm (recommended)
333
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
334
+ nvm install 22
335
+
336
+ # Verify
337
+ which node # Should be /home/... or /root/.nvm/...
338
+
339
+ # Reinstall
340
+ npm install -g kiro-memory
341
+ ```
342
+
343
+ ### `npm prefix` pointing to Windows (WSL)
344
+
345
+ If `npm prefix -g` returns a `/mnt/c/...` path, npm installs global packages on the Windows filesystem, causing native module issues.
346
+
347
+ **Fix:**
348
+
349
+ ```bash
350
+ mkdir -p ~/.npm-global
351
+ npm config set prefix ~/.npm-global
352
+ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
353
+ source ~/.bashrc
354
+
355
+ # Reinstall
356
+ npm install -g kiro-memory
357
+ ```
358
+
359
+ ### Missing build tools (Linux/WSL)
360
+
361
+ ```
362
+ gyp ERR! find Python
363
+ gyp ERR! stack Error: Could not find any Python installation to use
364
+ ```
365
+
366
+ Native modules like `better-sqlite3` need compilation tools.
367
+
368
+ **Fix:**
369
+
370
+ ```bash
371
+ sudo apt-get update && sudo apt-get install -y build-essential python3
372
+ npm install -g kiro-memory --build-from-source
373
+ ```
374
+
375
+ ### `no agent with name kiro-memory found`
376
+
377
+ The agent configuration was not installed. Run the install command:
378
+
379
+ ```bash
380
+ kiro-memory install
381
+ ```
382
+
383
+ This creates the agent config at `~/.kiro/agents/contextkit.json`. Note: the agent name is `contextkit-memory`, so start Kiro with:
384
+
385
+ ```bash
386
+ kiro-cli --agent contextkit-memory
387
+ ```
388
+
389
+ ### Port 3001 already in use
390
+
391
+ ```bash
392
+ # Find what's using the port
393
+ lsof -i :3001
394
+
395
+ # Kill the process
396
+ kill -9 <PID>
397
+
398
+ # Or use a different port
399
+ export KIRO_MEMORY_WORKER_PORT=3002
400
+ ```
401
+
402
+ ### Quick diagnostics
403
+
404
+ Run the built-in doctor command to check your environment:
405
+
406
+ ```bash
407
+ kiro-memory doctor
408
+ ```
409
+
311
410
  ## Contributing
312
411
 
313
412
  Contributions are welcome. Please open an issue to discuss proposed changes before submitting a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-memory",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "Persistent cross-session memory for Kiro CLI. Automatically tracks context, observations, and summaries across coding sessions.",
5
5
  "keywords": [
6
6
  "kiro",
@@ -900,8 +900,8 @@ var ContextKitSDK = class {
900
900
  }
901
901
  detectProject() {
902
902
  try {
903
- const { execSync } = __require("child_process");
904
- const gitRoot = execSync("git rev-parse --show-toplevel", {
903
+ const { execSync: execSync2 } = __require("child_process");
904
+ const gitRoot = execSync2("git rev-parse --show-toplevel", {
905
905
  cwd: process.cwd(),
906
906
  encoding: "utf8",
907
907
  stdio: ["pipe", "pipe", "ignore"]
@@ -1081,9 +1081,264 @@ function createContextKit(config) {
1081
1081
  }
1082
1082
 
1083
1083
  // src/cli/contextkit.ts
1084
+ import { execSync } from "child_process";
1085
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync, copyFileSync } from "fs";
1086
+ import { join as join3, dirname as dirname2 } from "path";
1087
+ import { homedir as homedir3, platform, release } from "os";
1088
+ import { fileURLToPath as fileURLToPath2 } from "url";
1084
1089
  var args = process.argv.slice(2);
1085
1090
  var command = args[0];
1091
+ var __filename = fileURLToPath2(import.meta.url);
1092
+ var __dirname2 = dirname2(__filename);
1093
+ var DIST_DIR = dirname2(__dirname2);
1094
+ var PROJECT_ROOT = dirname2(dirname2(DIST_DIR));
1095
+ function isWSL() {
1096
+ try {
1097
+ const rel = release().toLowerCase();
1098
+ if (rel.includes("microsoft") || rel.includes("wsl")) return true;
1099
+ if (existsSync3("/proc/version")) {
1100
+ const proc = readFileSync2("/proc/version", "utf8").toLowerCase();
1101
+ return proc.includes("microsoft") || proc.includes("wsl");
1102
+ }
1103
+ return false;
1104
+ } catch {
1105
+ return false;
1106
+ }
1107
+ }
1108
+ function commandExists(cmd) {
1109
+ try {
1110
+ execSync(`which ${cmd}`, { stdio: "ignore" });
1111
+ return true;
1112
+ } catch {
1113
+ return false;
1114
+ }
1115
+ }
1116
+ function runEnvironmentChecks() {
1117
+ const checks = [];
1118
+ const wsl = isWSL();
1119
+ const os = platform();
1120
+ checks.push({
1121
+ name: "Sistema operativo",
1122
+ ok: os === "linux" || os === "darwin",
1123
+ message: os === "linux" ? wsl ? "Linux (WSL)" : "Linux" : os === "darwin" ? "macOS" : `${os} (non supportato ufficialmente)`
1124
+ });
1125
+ if (wsl) {
1126
+ const nodePath = process.execPath;
1127
+ const nodeOnWindows = nodePath.startsWith("/mnt/c") || nodePath.startsWith("/mnt/d");
1128
+ checks.push({
1129
+ name: "WSL: Node.js nativo",
1130
+ ok: !nodeOnWindows,
1131
+ message: nodeOnWindows ? `Node.js punta a Windows: ${nodePath}` : `Node.js nativo Linux: ${nodePath}`,
1132
+ fix: nodeOnWindows ? "Installa Node.js dentro WSL:\n curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -\n sudo apt-get install -y nodejs\n Oppure usa nvm: https://github.com/nvm-sh/nvm" : void 0
1133
+ });
1134
+ try {
1135
+ const npmPrefix = execSync("npm prefix -g", { encoding: "utf8" }).trim();
1136
+ const prefixOnWindows = npmPrefix.startsWith("/mnt/c") || npmPrefix.startsWith("/mnt/d");
1137
+ checks.push({
1138
+ name: "WSL: npm global prefix",
1139
+ ok: !prefixOnWindows,
1140
+ message: prefixOnWindows ? `npm global prefix punta a Windows: ${npmPrefix}` : `npm global prefix: ${npmPrefix}`,
1141
+ fix: prefixOnWindows ? `Correggi il prefix npm:
1142
+ mkdir -p ~/.npm-global
1143
+ npm config set prefix ~/.npm-global
1144
+ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
1145
+ source ~/.bashrc
1146
+ Poi reinstalla: npm install -g kiro-memory` : void 0
1147
+ });
1148
+ } catch {
1149
+ checks.push({
1150
+ name: "WSL: npm global prefix",
1151
+ ok: false,
1152
+ message: "Impossibile determinare npm prefix"
1153
+ });
1154
+ }
1155
+ }
1156
+ const nodeVersion = parseInt(process.versions.node.split(".")[0]);
1157
+ checks.push({
1158
+ name: "Node.js >= 18",
1159
+ ok: nodeVersion >= 18,
1160
+ message: `Node.js v${process.versions.node}`,
1161
+ fix: nodeVersion < 18 ? "Aggiorna Node.js:\n nvm install 22 && nvm use 22\n Oppure: https://nodejs.org/" : void 0
1162
+ });
1163
+ let sqliteOk = false;
1164
+ let sqliteMsg = "";
1165
+ try {
1166
+ __require("better-sqlite3");
1167
+ sqliteOk = true;
1168
+ sqliteMsg = "Modulo nativo caricato correttamente";
1169
+ } catch (err) {
1170
+ sqliteMsg = err.code === "ERR_DLOPEN_FAILED" ? "Binario nativo incompatibile (ELF header invalido \u2014 probabile mismatch piattaforma)" : `Errore: ${err.message}`;
1171
+ }
1172
+ checks.push({
1173
+ name: "better-sqlite3",
1174
+ ok: sqliteOk,
1175
+ message: sqliteMsg,
1176
+ fix: !sqliteOk ? wsl ? "In WSL, ricompila il modulo nativo:\n npm rebuild better-sqlite3\n Se non funziona, reinstalla:\n npm install -g kiro-memory --build-from-source" : "Reinstalla il modulo nativo:\n npm rebuild better-sqlite3" : void 0
1177
+ });
1178
+ if (os === "linux") {
1179
+ const hasMake = commandExists("make");
1180
+ const hasGcc = commandExists("g++") || commandExists("gcc");
1181
+ const hasPython = commandExists("python3") || commandExists("python");
1182
+ const allPresent = hasMake && hasGcc && hasPython;
1183
+ const missing = [];
1184
+ if (!hasMake || !hasGcc) missing.push("build-essential");
1185
+ if (!hasPython) missing.push("python3");
1186
+ checks.push({
1187
+ name: "Build tools (moduli nativi)",
1188
+ ok: allPresent,
1189
+ message: allPresent ? "make, g++, python3 disponibili" : `Mancanti: ${missing.join(", ")}`,
1190
+ fix: !allPresent ? `Installa i pacchetti richiesti:
1191
+ sudo apt-get update && sudo apt-get install -y ${missing.join(" ")}
1192
+ Poi reinstalla: npm install -g kiro-memory --build-from-source` : void 0
1193
+ });
1194
+ }
1195
+ return checks;
1196
+ }
1197
+ function printChecks(checks) {
1198
+ let hasErrors = false;
1199
+ console.log("");
1200
+ for (const check of checks) {
1201
+ const icon = check.ok ? "\x1B[32m\u2713\x1B[0m" : "\x1B[31m\u2717\x1B[0m";
1202
+ console.log(` ${icon} ${check.name}: ${check.message}`);
1203
+ if (!check.ok && check.fix) {
1204
+ console.log(` \x1B[33m\u2192 Fix:\x1B[0m`);
1205
+ for (const line of check.fix.split("\n")) {
1206
+ console.log(` ${line}`);
1207
+ }
1208
+ }
1209
+ if (!check.ok) hasErrors = true;
1210
+ }
1211
+ console.log("");
1212
+ return { hasErrors };
1213
+ }
1214
+ async function installKiro() {
1215
+ console.log("\n=== Kiro Memory - Installazione ===\n");
1216
+ console.log("[1/3] Diagnostica ambiente...");
1217
+ const checks = runEnvironmentChecks();
1218
+ const { hasErrors } = printChecks(checks);
1219
+ if (hasErrors) {
1220
+ console.log("\x1B[31mInstallazione annullata.\x1B[0m Risolvi i problemi sopra e riprova.");
1221
+ console.log("Dopo aver risolto, esegui: kiro-memory install\n");
1222
+ process.exit(1);
1223
+ }
1224
+ const distDir = DIST_DIR;
1225
+ const agentTemplatePath = join3(PROJECT_ROOT, "kiro-agent", "contextkit.json");
1226
+ const steeringSourcePath = join3(PROJECT_ROOT, "kiro-agent", "steering.md");
1227
+ if (!existsSync3(agentTemplatePath)) {
1228
+ console.error(`\x1B[31mErrore:\x1B[0m Template agent non trovato: ${agentTemplatePath}`);
1229
+ console.error("Prova a reinstallare: npm install -g kiro-memory");
1230
+ process.exit(1);
1231
+ }
1232
+ const kiroDir = process.env.KIRO_CONFIG_DIR || join3(homedir3(), ".kiro");
1233
+ const agentsDir = join3(kiroDir, "agents");
1234
+ const settingsDir = join3(kiroDir, "settings");
1235
+ const steeringDir = join3(kiroDir, "steering");
1236
+ const dataDir = process.env.CONTEXTKIT_DATA_DIR || join3(homedir3(), ".contextkit");
1237
+ console.log("[2/3] Installazione configurazione Kiro...\n");
1238
+ for (const dir of [agentsDir, settingsDir, steeringDir, dataDir]) {
1239
+ mkdirSync3(dir, { recursive: true });
1240
+ }
1241
+ const agentTemplate = readFileSync2(agentTemplatePath, "utf8");
1242
+ const agentConfig = agentTemplate.replace(/__CONTEXTKIT_DIST__/g, distDir);
1243
+ const agentDestPath = join3(agentsDir, "contextkit.json");
1244
+ writeFileSync(agentDestPath, agentConfig, "utf8");
1245
+ console.log(` \u2192 Agent config: ${agentDestPath}`);
1246
+ const mcpFilePath = join3(settingsDir, "mcp.json");
1247
+ let mcpConfig = { mcpServers: {} };
1248
+ if (existsSync3(mcpFilePath)) {
1249
+ try {
1250
+ mcpConfig = JSON.parse(readFileSync2(mcpFilePath, "utf8"));
1251
+ if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
1252
+ } catch {
1253
+ }
1254
+ }
1255
+ mcpConfig.mcpServers.contextkit = {
1256
+ command: "node",
1257
+ args: [join3(distDir, "servers", "mcp-server.js")]
1258
+ };
1259
+ writeFileSync(mcpFilePath, JSON.stringify(mcpConfig, null, 2), "utf8");
1260
+ console.log(` \u2192 MCP config: ${mcpFilePath}`);
1261
+ const steeringDestPath = join3(steeringDir, "contextkit.md");
1262
+ if (existsSync3(steeringSourcePath)) {
1263
+ copyFileSync(steeringSourcePath, steeringDestPath);
1264
+ console.log(` \u2192 Steering: ${steeringDestPath}`);
1265
+ }
1266
+ console.log(` \u2192 Data dir: ${dataDir}`);
1267
+ console.log("\n[3/3] Installazione completata!\n");
1268
+ console.log("Per usare Kiro con memoria persistente:");
1269
+ console.log(" kiro-cli --agent contextkit-memory\n");
1270
+ console.log("Per creare un alias permanente:");
1271
+ console.log(` echo 'alias kiro="kiro-cli --agent contextkit-memory"' >> ~/.bashrc`);
1272
+ console.log(" source ~/.bashrc\n");
1273
+ console.log("Il worker si avvia automaticamente alla prima sessione.");
1274
+ console.log(`Dashboard web: http://localhost:3001
1275
+ `);
1276
+ }
1277
+ async function runDoctor() {
1278
+ console.log("\n=== Kiro Memory - Diagnostica ===");
1279
+ const checks = runEnvironmentChecks();
1280
+ const kiroDir = process.env.KIRO_CONFIG_DIR || join3(homedir3(), ".kiro");
1281
+ const agentPath = join3(kiroDir, "agents", "contextkit.json");
1282
+ const mcpPath = join3(kiroDir, "settings", "mcp.json");
1283
+ const dataDir = process.env.CONTEXTKIT_DATA_DIR || join3(homedir3(), ".contextkit");
1284
+ checks.push({
1285
+ name: "Agent config Kiro",
1286
+ ok: existsSync3(agentPath),
1287
+ message: existsSync3(agentPath) ? agentPath : "Non trovato",
1288
+ fix: !existsSync3(agentPath) ? "Esegui: kiro-memory install" : void 0
1289
+ });
1290
+ let mcpOk = false;
1291
+ if (existsSync3(mcpPath)) {
1292
+ try {
1293
+ const mcp = JSON.parse(readFileSync2(mcpPath, "utf8"));
1294
+ mcpOk = !!mcp.mcpServers?.contextkit;
1295
+ } catch {
1296
+ }
1297
+ }
1298
+ checks.push({
1299
+ name: "MCP server configurato",
1300
+ ok: mcpOk,
1301
+ message: mcpOk ? "contextkit registrato in mcp.json" : "Non configurato",
1302
+ fix: !mcpOk ? "Esegui: kiro-memory install" : void 0
1303
+ });
1304
+ checks.push({
1305
+ name: "Data directory",
1306
+ ok: existsSync3(dataDir),
1307
+ message: existsSync3(dataDir) ? dataDir : "Non creata (verr\xE0 creata al primo uso)"
1308
+ });
1309
+ let workerOk = false;
1310
+ try {
1311
+ const port = process.env.KIRO_MEMORY_WORKER_PORT || "3001";
1312
+ execSync(`curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:${port}/api/health`, {
1313
+ timeout: 2e3,
1314
+ encoding: "utf8"
1315
+ });
1316
+ workerOk = true;
1317
+ } catch {
1318
+ }
1319
+ checks.push({
1320
+ name: "Worker service",
1321
+ ok: true,
1322
+ // Non bloccante: si avvia automaticamente
1323
+ message: workerOk ? "Attivo su porta 3001" : "Non in esecuzione (si avvia automaticamente con Kiro)"
1324
+ });
1325
+ const { hasErrors } = printChecks(checks);
1326
+ if (hasErrors) {
1327
+ console.log("Alcuni check sono falliti. Risolvi i problemi indicati sopra.\n");
1328
+ process.exit(1);
1329
+ } else {
1330
+ console.log("Tutto OK! Kiro Memory \xE8 pronto.\n");
1331
+ }
1332
+ }
1086
1333
  async function main() {
1334
+ if (command === "install") {
1335
+ await installKiro();
1336
+ return;
1337
+ }
1338
+ if (command === "doctor") {
1339
+ await runDoctor();
1340
+ return;
1341
+ }
1087
1342
  const contextkit = createContextKit();
1088
1343
  try {
1089
1344
  switch (command) {
@@ -1238,7 +1493,11 @@ async function addSummary(contextkit, content) {
1238
1493
  `);
1239
1494
  }
1240
1495
  function showHelp() {
1241
- console.log(`Usage: contextkit <command> [options]
1496
+ console.log(`Usage: kiro-memory <command> [options]
1497
+
1498
+ Setup:
1499
+ install Install hooks, MCP server, and agent config into Kiro CLI
1500
+ doctor Run environment diagnostics (checks Node, build tools, WSL, etc.)
1242
1501
 
1243
1502
  Commands:
1244
1503
  context, ctx Show current project context
@@ -1250,10 +1509,11 @@ Commands:
1250
1509
  help Show this help message
1251
1510
 
1252
1511
  Examples:
1253
- contextkit context
1254
- contextkit search "authentication"
1255
- contextkit observations 20
1256
- contextkit add-observation "Bug Fix" "Fixed the login issue"
1512
+ kiro-memory install
1513
+ kiro-memory doctor
1514
+ kiro-memory context
1515
+ kiro-memory search "authentication"
1516
+ kiro-memory observations 20
1257
1517
  `);
1258
1518
  }
1259
1519
  main().catch(console.error);