kiro-memory 1.2.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-memory",
3
- "version": "1.2.1",
3
+ "version": "1.3.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",
@@ -1082,10 +1082,11 @@ function createContextKit(config) {
1082
1082
 
1083
1083
  // src/cli/contextkit.ts
1084
1084
  import { execSync } from "child_process";
1085
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync } from "fs";
1085
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync, appendFileSync as appendFileSync2 } from "fs";
1086
1086
  import { join as join3, dirname as dirname2 } from "path";
1087
1087
  import { homedir as homedir3, platform, release } from "os";
1088
1088
  import { fileURLToPath as fileURLToPath2 } from "url";
1089
+ import { createInterface } from "readline";
1089
1090
  var args = process.argv.slice(2);
1090
1091
  var command = args[0];
1091
1092
  var __filename = fileURLToPath2(import.meta.url);
@@ -1201,6 +1202,17 @@ function runEnvironmentChecks() {
1201
1202
  message: "Unable to determine npm prefix"
1202
1203
  });
1203
1204
  }
1205
+ try {
1206
+ const npmPath = execSync("which npm", { encoding: "utf8" }).trim();
1207
+ const npmOnWindows = isWindowsPath(npmPath);
1208
+ checks.push({
1209
+ name: "WSL: npm binary",
1210
+ ok: !npmOnWindows,
1211
+ message: npmOnWindows ? `npm is the Windows version: ${npmPath}` : `Native Linux npm: ${npmPath}`,
1212
+ fix: npmOnWindows ? "Your npm binary is the Windows version running inside WSL.\n This causes EPERM/UNC errors when installing packages.\n Install Node.js (includes npm) natively in WSL:\n curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash\n source ~/.bashrc\n nvm install 22\n Or:\n curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -\n sudo apt-get install -y nodejs" : void 0
1213
+ });
1214
+ } catch {
1215
+ }
1204
1216
  }
1205
1217
  const nodeVersion = parseInt(process.versions.node.split(".")[0]);
1206
1218
  checks.push({
@@ -1260,15 +1272,169 @@ function printChecks(checks) {
1260
1272
  console.log("");
1261
1273
  return { hasErrors };
1262
1274
  }
1275
+ function askUser(question) {
1276
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1277
+ return new Promise((resolve) => {
1278
+ rl.question(question, (answer) => {
1279
+ rl.close();
1280
+ resolve(answer.trim().toLowerCase());
1281
+ });
1282
+ });
1283
+ }
1284
+ function detectShellRc() {
1285
+ const shell = process.env.SHELL || "/bin/bash";
1286
+ if (shell.includes("zsh")) return { name: "zsh", rcFile: join3(homedir3(), ".zshrc") };
1287
+ if (shell.includes("fish")) return { name: "fish", rcFile: join3(homedir3(), ".config/fish/config.fish") };
1288
+ return { name: "bash", rcFile: join3(homedir3(), ".bashrc") };
1289
+ }
1290
+ var AUTOFIXABLE_CHECKS = /* @__PURE__ */ new Set([
1291
+ "WSL: npm global prefix",
1292
+ "WSL: npm binary",
1293
+ "Build tools (native modules)",
1294
+ "better-sqlite3"
1295
+ ]);
1296
+ async function tryAutoFix(failedChecks) {
1297
+ const fixable = failedChecks.filter((c) => !c.ok && AUTOFIXABLE_CHECKS.has(c.name));
1298
+ if (fixable.length === 0) return { fixed: false, needsRestart: false };
1299
+ const { rcFile } = detectShellRc();
1300
+ let anyFixed = false;
1301
+ let needsRestart = false;
1302
+ console.log(` \x1B[36mFound ${fixable.length} issue(s) that can be fixed automatically:\x1B[0m
1303
+ `);
1304
+ for (const check of fixable) {
1305
+ console.log(` - ${check.name}: ${check.message}`);
1306
+ }
1307
+ console.log("");
1308
+ const answer = await askUser(" Fix automatically? [Y/n] ");
1309
+ if (answer !== "" && answer !== "y" && answer !== "yes") {
1310
+ console.log("\n Skipped auto-fix. Fix manually and run: kiro-memory install\n");
1311
+ return { fixed: false, needsRestart: false };
1312
+ }
1313
+ console.log("");
1314
+ const prefixCheck = fixable.find((c) => c.name === "WSL: npm global prefix");
1315
+ if (prefixCheck) {
1316
+ console.log(" Fixing npm global prefix...");
1317
+ try {
1318
+ const npmGlobalDir = join3(homedir3(), ".npm-global");
1319
+ mkdirSync3(npmGlobalDir, { recursive: true });
1320
+ execSync(`npm config set prefix "${npmGlobalDir}"`, { stdio: "ignore" });
1321
+ const exportLine = 'export PATH="$HOME/.npm-global/bin:$PATH"';
1322
+ let alreadyInRc = false;
1323
+ if (existsSync3(rcFile)) {
1324
+ const content = readFileSync2(rcFile, "utf8");
1325
+ alreadyInRc = content.includes(".npm-global/bin");
1326
+ }
1327
+ if (!alreadyInRc) {
1328
+ appendFileSync2(rcFile, `
1329
+ # npm global prefix (added by kiro-memory)
1330
+ ${exportLine}
1331
+ `);
1332
+ }
1333
+ process.env.PATH = `${npmGlobalDir}/bin:${process.env.PATH}`;
1334
+ console.log(` \x1B[32m\u2713\x1B[0m npm prefix set to ${npmGlobalDir}`);
1335
+ console.log(` \x1B[32m\u2713\x1B[0m PATH updated in ${rcFile}`);
1336
+ anyFixed = true;
1337
+ } catch (err) {
1338
+ console.log(` \x1B[31m\u2717\x1B[0m Could not fix npm prefix: ${err.message}`);
1339
+ }
1340
+ }
1341
+ const npmBinaryCheck = fixable.find((c) => c.name === "WSL: npm binary");
1342
+ if (npmBinaryCheck) {
1343
+ console.log("\n Fixing npm binary (installing nvm + Node.js 22)...");
1344
+ const nvmDir = join3(homedir3(), ".nvm");
1345
+ try {
1346
+ if (existsSync3(nvmDir)) {
1347
+ console.log(` nvm already installed at ${nvmDir}`);
1348
+ } else {
1349
+ console.log(" Downloading nvm...");
1350
+ execSync("curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash", {
1351
+ stdio: "inherit",
1352
+ timeout: 6e4
1353
+ });
1354
+ console.log(` \x1B[32m\u2713\x1B[0m nvm installed`);
1355
+ }
1356
+ console.log(" Installing Node.js 22 via nvm...");
1357
+ execSync('bash -c "source $HOME/.nvm/nvm.sh && nvm install 22"', {
1358
+ stdio: "inherit",
1359
+ timeout: 12e4
1360
+ });
1361
+ console.log(` \x1B[32m\u2713\x1B[0m Node.js 22 installed`);
1362
+ anyFixed = true;
1363
+ needsRestart = true;
1364
+ } catch (err) {
1365
+ console.log(` \x1B[31m\u2717\x1B[0m Could not install nvm/Node: ${err.message}`);
1366
+ console.log(" Install manually:");
1367
+ console.log(" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash");
1368
+ console.log(" source ~/.bashrc");
1369
+ console.log(" nvm install 22");
1370
+ }
1371
+ }
1372
+ const buildCheck = fixable.find((c) => c.name === "Build tools (native modules)");
1373
+ if (buildCheck) {
1374
+ console.log("\n Fixing build tools (requires sudo)...");
1375
+ try {
1376
+ execSync("sudo apt-get update -qq && sudo apt-get install -y build-essential python3", {
1377
+ stdio: "inherit",
1378
+ timeout: 12e4
1379
+ });
1380
+ console.log(` \x1B[32m\u2713\x1B[0m Build tools installed`);
1381
+ anyFixed = true;
1382
+ } catch (err) {
1383
+ console.log(` \x1B[31m\u2717\x1B[0m Could not install build tools: ${err.message}`);
1384
+ console.log(" Install manually: sudo apt-get install -y build-essential python3");
1385
+ }
1386
+ }
1387
+ const sqliteCheck = fixable.find((c) => c.name === "better-sqlite3");
1388
+ if (sqliteCheck) {
1389
+ console.log("\n Rebuilding better-sqlite3...");
1390
+ try {
1391
+ const globalDir = execSync("npm prefix -g", { encoding: "utf8" }).trim();
1392
+ const sqlitePkg = join3(globalDir, "lib", "node_modules", "kiro-memory");
1393
+ if (existsSync3(sqlitePkg)) {
1394
+ execSync(`cd "${sqlitePkg}" && npm rebuild better-sqlite3`, {
1395
+ stdio: "inherit",
1396
+ timeout: 6e4
1397
+ });
1398
+ } else {
1399
+ execSync("npm rebuild better-sqlite3", { stdio: "inherit", timeout: 6e4 });
1400
+ }
1401
+ console.log(` \x1B[32m\u2713\x1B[0m better-sqlite3 rebuilt`);
1402
+ anyFixed = true;
1403
+ } catch (err) {
1404
+ console.log(` \x1B[31m\u2717\x1B[0m Could not rebuild: ${err.message}`);
1405
+ console.log(" Try: npm install -g kiro-memory --build-from-source");
1406
+ }
1407
+ }
1408
+ console.log("");
1409
+ return { fixed: anyFixed, needsRestart };
1410
+ }
1263
1411
  async function installKiro() {
1264
1412
  console.log("\n=== Kiro Memory - Installation ===\n");
1265
- console.log("[1/3] Running environment checks...");
1266
- const checks = runEnvironmentChecks();
1267
- const { hasErrors } = printChecks(checks);
1413
+ console.log("[1/4] Running environment checks...");
1414
+ let checks = runEnvironmentChecks();
1415
+ let { hasErrors } = printChecks(checks);
1268
1416
  if (hasErrors) {
1269
- console.log("\x1B[31mInstallation aborted.\x1B[0m Fix the issues above and retry.");
1270
- console.log("After fixing, run: kiro-memory install\n");
1271
- process.exit(1);
1417
+ const { fixed, needsRestart } = await tryAutoFix(checks);
1418
+ if (needsRestart) {
1419
+ console.log(" \x1B[33m\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\x1B[0m");
1420
+ console.log(" \x1B[33m\u2502\x1B[0m Node.js was installed via nvm. To activate it: \x1B[33m\u2502\x1B[0m");
1421
+ console.log(" \x1B[33m\u2502\x1B[0m \x1B[33m\u2502\x1B[0m");
1422
+ console.log(" \x1B[33m\u2502\x1B[0m 1. Close and reopen your terminal \x1B[33m\u2502\x1B[0m");
1423
+ console.log(" \x1B[33m\u2502\x1B[0m 2. Run: \x1B[1mnpm install -g kiro-memory\x1B[0m \x1B[33m\u2502\x1B[0m");
1424
+ console.log(" \x1B[33m\u2502\x1B[0m 3. Run: \x1B[1mkiro-memory install\x1B[0m \x1B[33m\u2502\x1B[0m");
1425
+ console.log(" \x1B[33m\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\x1B[0m\n");
1426
+ process.exit(0);
1427
+ }
1428
+ if (fixed) {
1429
+ console.log(" Re-running checks...\n");
1430
+ checks = runEnvironmentChecks();
1431
+ ({ hasErrors } = printChecks(checks));
1432
+ }
1433
+ if (hasErrors) {
1434
+ console.log("\x1B[31mInstallation aborted.\x1B[0m Fix the remaining issues and retry.");
1435
+ console.log("After fixing, run: kiro-memory install\n");
1436
+ process.exit(1);
1437
+ }
1272
1438
  }
1273
1439
  const distDir = DIST_DIR;
1274
1440
  const kiroDir = process.env.KIRO_CONFIG_DIR || join3(homedir3(), ".kiro");
@@ -1276,7 +1442,7 @@ async function installKiro() {
1276
1442
  const settingsDir = join3(kiroDir, "settings");
1277
1443
  const steeringDir = join3(kiroDir, "steering");
1278
1444
  const dataDir = process.env.CONTEXTKIT_DATA_DIR || join3(homedir3(), ".contextkit");
1279
- console.log("[2/3] Installing Kiro configuration...\n");
1445
+ console.log("[2/4] Installing Kiro configuration...\n");
1280
1446
  for (const dir of [agentsDir, settingsDir, steeringDir, dataDir]) {
1281
1447
  mkdirSync3(dir, { recursive: true });
1282
1448
  }
@@ -1303,14 +1469,57 @@ async function installKiro() {
1303
1469
  writeFileSync(steeringDestPath, STEERING_CONTENT, "utf8");
1304
1470
  console.log(` \u2192 Steering: ${steeringDestPath}`);
1305
1471
  console.log(` \u2192 Data dir: ${dataDir}`);
1306
- console.log("\n[3/3] Installation complete!\n");
1307
- console.log("To use Kiro with persistent memory:");
1308
- console.log(" kiro-cli --agent contextkit-memory\n");
1309
- console.log("To create a permanent alias:");
1310
- console.log(` echo 'alias kiro="kiro-cli --agent contextkit-memory"' >> ~/.bashrc`);
1311
- console.log(" source ~/.bashrc\n");
1312
- console.log("The worker starts automatically when a Kiro session begins.");
1313
- console.log(`Web dashboard: http://localhost:3001
1472
+ console.log("\n[3/4] Shell alias setup\n");
1473
+ const { rcFile } = detectShellRc();
1474
+ const aliasLine = 'alias kiro="kiro-cli --agent contextkit-memory"';
1475
+ let aliasAlreadySet = false;
1476
+ if (existsSync3(rcFile)) {
1477
+ const rcContent = readFileSync2(rcFile, "utf8");
1478
+ aliasAlreadySet = rcContent.includes("alias kiro=") && rcContent.includes("contextkit-memory");
1479
+ }
1480
+ if (aliasAlreadySet) {
1481
+ console.log(` \x1B[32m\u2713\x1B[0m Alias already configured in ${rcFile}`);
1482
+ } else {
1483
+ console.log(" \x1B[36m\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\x1B[0m");
1484
+ console.log(" \x1B[36m\u2502\x1B[0m Without an alias, you must type every time: \x1B[36m\u2502\x1B[0m");
1485
+ console.log(" \x1B[36m\u2502\x1B[0m \x1B[2mkiro-cli --agent contextkit-memory\x1B[0m \x1B[36m\u2502\x1B[0m");
1486
+ console.log(" \x1B[36m\u2502\x1B[0m \x1B[36m\u2502\x1B[0m");
1487
+ console.log(" \x1B[36m\u2502\x1B[0m With the alias, just type: \x1B[36m\u2502\x1B[0m");
1488
+ console.log(" \x1B[36m\u2502\x1B[0m \x1B[1m\x1B[32mkiro\x1B[0m \x1B[36m\u2502\x1B[0m");
1489
+ console.log(" \x1B[36m\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\x1B[0m");
1490
+ console.log("");
1491
+ const answer = await askUser(` Add alias to ${rcFile}? [Y/n] `);
1492
+ if (answer === "" || answer === "y" || answer === "yes") {
1493
+ try {
1494
+ appendFileSync2(rcFile, `
1495
+ # Kiro Memory \u2014 persistent memory alias
1496
+ ${aliasLine}
1497
+ `);
1498
+ console.log(`
1499
+ \x1B[32m\u2713\x1B[0m Alias added to ${rcFile}`);
1500
+ console.log(` \x1B[33m\u2192\x1B[0m Run \x1B[1msource ${rcFile}\x1B[0m or open a new terminal to activate it.`);
1501
+ } catch (err) {
1502
+ console.log(`
1503
+ \x1B[31m\u2717\x1B[0m Could not write to ${rcFile}: ${err.message}`);
1504
+ console.log(` \x1B[33m\u2192\x1B[0m Add manually: ${aliasLine}`);
1505
+ }
1506
+ } else {
1507
+ console.log(`
1508
+ Skipped. You can add it manually later:`);
1509
+ console.log(` echo '${aliasLine}' >> ${rcFile}`);
1510
+ }
1511
+ }
1512
+ console.log("\n[4/4] Done!\n");
1513
+ console.log(" \x1B[32m\u2550\u2550\u2550 Installation complete! \u2550\u2550\u2550\x1B[0m\n");
1514
+ console.log(" Start Kiro with memory:");
1515
+ if (aliasAlreadySet) {
1516
+ console.log(" \x1B[1mkiro\x1B[0m");
1517
+ } else {
1518
+ console.log(" \x1B[1mkiro-cli --agent contextkit-memory\x1B[0m");
1519
+ }
1520
+ console.log("");
1521
+ console.log(" The worker starts automatically when a Kiro session begins.");
1522
+ console.log(` Web dashboard: \x1B[4mhttp://localhost:3001\x1B[0m
1314
1523
  `);
1315
1524
  }
1316
1525
  async function runDoctor() {