kiro-memory 1.1.2 → 1.1.4

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
@@ -64,11 +64,31 @@ npm install && npm run build
64
64
  npm run install:kiro
65
65
  ```
66
66
 
67
- Use Kiro as usual -- Kiro Memory runs entirely in the background. The worker auto-starts when a session begins, and the web dashboard is available at `http://localhost:3001`.
67
+ ### Start Kiro with memory enabled
68
+
69
+ Kiro Memory works as a **custom agent**. You must start Kiro with the `--agent` flag:
70
+
71
+ ```bash
72
+ kiro-cli --agent kiro-memory
73
+ ```
74
+
75
+ > **Why?** Kiro Memory uses hooks (`agentSpawn`, `postToolUse`, `userPromptSubmit`, `stop`) to capture context automatically. Hooks are defined inside the agent configuration, so they only run when the `kiro-memory` agent is active.
76
+
77
+ To avoid typing the flag every time, add an alias to your shell:
78
+
79
+ ```bash
80
+ # Bash
81
+ echo 'alias kiro="kiro-cli --agent kiro-memory"' >> ~/.bashrc && source ~/.bashrc
82
+
83
+ # Zsh
84
+ echo 'alias kiro="kiro-cli --agent kiro-memory"' >> ~/.zshrc && source ~/.zshrc
85
+ ```
86
+
87
+ Once running, the worker auto-starts and the web dashboard is available at `http://localhost:3001`.
68
88
 
69
89
  ## Kiro Integration
70
90
 
71
- Kiro Memory registers **4 hooks** and an **MCP server** with Kiro CLI. The agent configuration is installed to `~/.kiro/agents/kiro-memory.json`:
91
+ Kiro Memory registers **4 hooks** and an **MCP server** with Kiro CLI via a custom agent. The agent configuration is installed to `~/.kiro/agents/kiro-memory.json` and is activated with `kiro --agent kiro-memory`:
72
92
 
73
93
  ```json
74
94
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-memory",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
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",
@@ -384,6 +384,22 @@ var init_Search = __esm({
384
384
  });
385
385
 
386
386
  // src/hooks/utils.ts
387
+ import { writeFileSync, mkdirSync, existsSync } from "fs";
388
+ import { join } from "path";
389
+ function debugLog(hookName, label, data) {
390
+ if ((process.env.KIRO_MEMORY_LOG_LEVEL || "").toUpperCase() !== "DEBUG") return;
391
+ try {
392
+ const dataDir = process.env.KIRO_MEMORY_DATA_DIR || join(process.env.HOME || "/tmp", ".kiro-memory");
393
+ const logDir = join(dataDir, "logs");
394
+ if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });
395
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
396
+ const line = `[${ts}] [${hookName}] ${label}: ${JSON.stringify(data)}
397
+ `;
398
+ const logFile = join(logDir, `hooks-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
399
+ writeFileSync(logFile, line, { flag: "a" });
400
+ } catch {
401
+ }
402
+ }
387
403
  async function readStdin() {
388
404
  return new Promise((resolve, reject) => {
389
405
  let data = "";
@@ -457,10 +473,13 @@ function formatContext(data) {
457
473
  async function runHook(name, handler) {
458
474
  try {
459
475
  const input = await readStdin();
476
+ debugLog(name, "stdin", input);
460
477
  await handler(input);
478
+ debugLog(name, "completato", { success: true });
461
479
  process.exit(0);
462
480
  } catch (error) {
463
- process.stderr.write(`[contextkit:${name}] Errore: ${error}
481
+ debugLog(name, "errore", { error: String(error) });
482
+ process.stderr.write(`[kiro-memory:${name}] Errore: ${error}
464
483
  `);
465
484
  process.exit(0);
466
485
  }
@@ -534,14 +553,14 @@ var BunQueryCompat = class {
534
553
  };
535
554
 
536
555
  // src/shared/paths.ts
537
- import { join as join2, dirname, basename } from "path";
556
+ import { join as join3, dirname, basename } from "path";
538
557
  import { homedir as homedir2 } from "os";
539
- import { mkdirSync as mkdirSync2 } from "fs";
558
+ import { mkdirSync as mkdirSync3 } from "fs";
540
559
  import { fileURLToPath } from "url";
541
560
 
542
561
  // src/utils/logger.ts
543
- import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
544
- import { join } from "path";
562
+ import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync } from "fs";
563
+ import { join as join2 } from "path";
545
564
  import { homedir } from "os";
546
565
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
547
566
  LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
@@ -551,7 +570,7 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
551
570
  LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
552
571
  return LogLevel2;
553
572
  })(LogLevel || {});
554
- var DEFAULT_DATA_DIR = join(homedir(), ".contextkit");
573
+ var DEFAULT_DATA_DIR = join2(homedir(), ".contextkit");
555
574
  var Logger = class {
556
575
  level = null;
557
576
  useColor;
@@ -567,12 +586,12 @@ var Logger = class {
567
586
  if (this.logFileInitialized) return;
568
587
  this.logFileInitialized = true;
569
588
  try {
570
- const logsDir = join(DEFAULT_DATA_DIR, "logs");
571
- if (!existsSync(logsDir)) {
572
- mkdirSync(logsDir, { recursive: true });
589
+ const logsDir = join2(DEFAULT_DATA_DIR, "logs");
590
+ if (!existsSync2(logsDir)) {
591
+ mkdirSync2(logsDir, { recursive: true });
573
592
  }
574
593
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
575
- this.logFilePath = join(logsDir, `contextkit-${date}.log`);
594
+ this.logFilePath = join2(logsDir, `contextkit-${date}.log`);
576
595
  } catch (error) {
577
596
  console.error("[LOGGER] Failed to initialize log file:", error);
578
597
  this.logFilePath = null;
@@ -584,8 +603,8 @@ var Logger = class {
584
603
  getLevel() {
585
604
  if (this.level === null) {
586
605
  try {
587
- const settingsPath = join(DEFAULT_DATA_DIR, "settings.json");
588
- if (existsSync(settingsPath)) {
606
+ const settingsPath = join2(DEFAULT_DATA_DIR, "settings.json");
607
+ if (existsSync2(settingsPath)) {
589
608
  const settingsData = readFileSync(settingsPath, "utf-8");
590
609
  const settings = JSON.parse(settingsData);
591
610
  const envLevel = (settings.CONTEXTKIT_LOG_LEVEL || "INFO").toUpperCase();
@@ -766,22 +785,22 @@ function getDirname() {
766
785
  return dirname(fileURLToPath(import.meta.url));
767
786
  }
768
787
  var _dirname = getDirname();
769
- var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join2(homedir2(), ".contextkit");
770
- var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join2(homedir2(), ".kiro");
771
- var PLUGIN_ROOT = join2(KIRO_CONFIG_DIR, "plugins", "contextkit");
772
- var ARCHIVES_DIR = join2(DATA_DIR, "archives");
773
- var LOGS_DIR = join2(DATA_DIR, "logs");
774
- var TRASH_DIR = join2(DATA_DIR, "trash");
775
- var BACKUPS_DIR = join2(DATA_DIR, "backups");
776
- var MODES_DIR = join2(DATA_DIR, "modes");
777
- var USER_SETTINGS_PATH = join2(DATA_DIR, "settings.json");
778
- var DB_PATH = join2(DATA_DIR, "contextkit.db");
779
- var VECTOR_DB_DIR = join2(DATA_DIR, "vector-db");
780
- var OBSERVER_SESSIONS_DIR = join2(DATA_DIR, "observer-sessions");
781
- var KIRO_SETTINGS_PATH = join2(KIRO_CONFIG_DIR, "settings.json");
782
- var KIRO_CONTEXT_PATH = join2(KIRO_CONFIG_DIR, "context.md");
788
+ var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join3(homedir2(), ".contextkit");
789
+ var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join3(homedir2(), ".kiro");
790
+ var PLUGIN_ROOT = join3(KIRO_CONFIG_DIR, "plugins", "contextkit");
791
+ var ARCHIVES_DIR = join3(DATA_DIR, "archives");
792
+ var LOGS_DIR = join3(DATA_DIR, "logs");
793
+ var TRASH_DIR = join3(DATA_DIR, "trash");
794
+ var BACKUPS_DIR = join3(DATA_DIR, "backups");
795
+ var MODES_DIR = join3(DATA_DIR, "modes");
796
+ var USER_SETTINGS_PATH = join3(DATA_DIR, "settings.json");
797
+ var DB_PATH = join3(DATA_DIR, "contextkit.db");
798
+ var VECTOR_DB_DIR = join3(DATA_DIR, "vector-db");
799
+ var OBSERVER_SESSIONS_DIR = join3(DATA_DIR, "observer-sessions");
800
+ var KIRO_SETTINGS_PATH = join3(KIRO_CONFIG_DIR, "settings.json");
801
+ var KIRO_CONTEXT_PATH = join3(KIRO_CONFIG_DIR, "context.md");
783
802
  function ensureDir(dirPath) {
784
- mkdirSync2(dirPath, { recursive: true });
803
+ mkdirSync3(dirPath, { recursive: true });
785
804
  }
786
805
 
787
806
  // src/services/sqlite/Database.ts
@@ -1165,7 +1184,7 @@ function createContextKit(config) {
1165
1184
 
1166
1185
  // src/hooks/agentSpawn.ts
1167
1186
  import { spawn } from "child_process";
1168
- import { dirname as dirname2, join as join3 } from "path";
1187
+ import { dirname as dirname2, join as join4 } from "path";
1169
1188
  import { fileURLToPath as fileURLToPath2 } from "url";
1170
1189
  var __filename_hook = fileURLToPath2(import.meta.url);
1171
1190
  var __dirname_hook = dirname2(__filename_hook);
@@ -1181,7 +1200,7 @@ async function ensureWorkerRunning() {
1181
1200
  if (resp.ok) return;
1182
1201
  } catch {
1183
1202
  }
1184
- const workerPath = join3(__dirname_hook, "..", "worker-service.js");
1203
+ const workerPath = join4(__dirname_hook, "..", "worker-service.js");
1185
1204
  const child = spawn("node", [workerPath], {
1186
1205
  detached: true,
1187
1206
  stdio: "ignore",
@@ -384,6 +384,22 @@ var init_Search = __esm({
384
384
  });
385
385
 
386
386
  // src/hooks/utils.ts
387
+ import { writeFileSync, mkdirSync, existsSync } from "fs";
388
+ import { join } from "path";
389
+ function debugLog(hookName, label, data) {
390
+ if ((process.env.KIRO_MEMORY_LOG_LEVEL || "").toUpperCase() !== "DEBUG") return;
391
+ try {
392
+ const dataDir = process.env.KIRO_MEMORY_DATA_DIR || join(process.env.HOME || "/tmp", ".kiro-memory");
393
+ const logDir = join(dataDir, "logs");
394
+ if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });
395
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
396
+ const line = `[${ts}] [${hookName}] ${label}: ${JSON.stringify(data)}
397
+ `;
398
+ const logFile = join(logDir, `hooks-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
399
+ writeFileSync(logFile, line, { flag: "a" });
400
+ } catch {
401
+ }
402
+ }
387
403
  async function readStdin() {
388
404
  return new Promise((resolve, reject) => {
389
405
  let data = "";
@@ -448,10 +464,13 @@ async function notifyWorker(event, data) {
448
464
  async function runHook(name, handler) {
449
465
  try {
450
466
  const input = await readStdin();
467
+ debugLog(name, "stdin", input);
451
468
  await handler(input);
469
+ debugLog(name, "completato", { success: true });
452
470
  process.exit(0);
453
471
  } catch (error) {
454
- process.stderr.write(`[contextkit:${name}] Errore: ${error}
472
+ debugLog(name, "errore", { error: String(error) });
473
+ process.stderr.write(`[kiro-memory:${name}] Errore: ${error}
455
474
  `);
456
475
  process.exit(0);
457
476
  }
@@ -525,14 +544,14 @@ var BunQueryCompat = class {
525
544
  };
526
545
 
527
546
  // src/shared/paths.ts
528
- import { join as join2, dirname, basename } from "path";
547
+ import { join as join3, dirname, basename } from "path";
529
548
  import { homedir as homedir2 } from "os";
530
- import { mkdirSync as mkdirSync2 } from "fs";
549
+ import { mkdirSync as mkdirSync3 } from "fs";
531
550
  import { fileURLToPath } from "url";
532
551
 
533
552
  // src/utils/logger.ts
534
- import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
535
- import { join } from "path";
553
+ import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync } from "fs";
554
+ import { join as join2 } from "path";
536
555
  import { homedir } from "os";
537
556
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
538
557
  LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
@@ -542,7 +561,7 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
542
561
  LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
543
562
  return LogLevel2;
544
563
  })(LogLevel || {});
545
- var DEFAULT_DATA_DIR = join(homedir(), ".contextkit");
564
+ var DEFAULT_DATA_DIR = join2(homedir(), ".contextkit");
546
565
  var Logger = class {
547
566
  level = null;
548
567
  useColor;
@@ -558,12 +577,12 @@ var Logger = class {
558
577
  if (this.logFileInitialized) return;
559
578
  this.logFileInitialized = true;
560
579
  try {
561
- const logsDir = join(DEFAULT_DATA_DIR, "logs");
562
- if (!existsSync(logsDir)) {
563
- mkdirSync(logsDir, { recursive: true });
580
+ const logsDir = join2(DEFAULT_DATA_DIR, "logs");
581
+ if (!existsSync2(logsDir)) {
582
+ mkdirSync2(logsDir, { recursive: true });
564
583
  }
565
584
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
566
- this.logFilePath = join(logsDir, `contextkit-${date}.log`);
585
+ this.logFilePath = join2(logsDir, `contextkit-${date}.log`);
567
586
  } catch (error) {
568
587
  console.error("[LOGGER] Failed to initialize log file:", error);
569
588
  this.logFilePath = null;
@@ -575,8 +594,8 @@ var Logger = class {
575
594
  getLevel() {
576
595
  if (this.level === null) {
577
596
  try {
578
- const settingsPath = join(DEFAULT_DATA_DIR, "settings.json");
579
- if (existsSync(settingsPath)) {
597
+ const settingsPath = join2(DEFAULT_DATA_DIR, "settings.json");
598
+ if (existsSync2(settingsPath)) {
580
599
  const settingsData = readFileSync(settingsPath, "utf-8");
581
600
  const settings = JSON.parse(settingsData);
582
601
  const envLevel = (settings.CONTEXTKIT_LOG_LEVEL || "INFO").toUpperCase();
@@ -757,22 +776,22 @@ function getDirname() {
757
776
  return dirname(fileURLToPath(import.meta.url));
758
777
  }
759
778
  var _dirname = getDirname();
760
- var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join2(homedir2(), ".contextkit");
761
- var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join2(homedir2(), ".kiro");
762
- var PLUGIN_ROOT = join2(KIRO_CONFIG_DIR, "plugins", "contextkit");
763
- var ARCHIVES_DIR = join2(DATA_DIR, "archives");
764
- var LOGS_DIR = join2(DATA_DIR, "logs");
765
- var TRASH_DIR = join2(DATA_DIR, "trash");
766
- var BACKUPS_DIR = join2(DATA_DIR, "backups");
767
- var MODES_DIR = join2(DATA_DIR, "modes");
768
- var USER_SETTINGS_PATH = join2(DATA_DIR, "settings.json");
769
- var DB_PATH = join2(DATA_DIR, "contextkit.db");
770
- var VECTOR_DB_DIR = join2(DATA_DIR, "vector-db");
771
- var OBSERVER_SESSIONS_DIR = join2(DATA_DIR, "observer-sessions");
772
- var KIRO_SETTINGS_PATH = join2(KIRO_CONFIG_DIR, "settings.json");
773
- var KIRO_CONTEXT_PATH = join2(KIRO_CONFIG_DIR, "context.md");
779
+ var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join3(homedir2(), ".contextkit");
780
+ var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join3(homedir2(), ".kiro");
781
+ var PLUGIN_ROOT = join3(KIRO_CONFIG_DIR, "plugins", "contextkit");
782
+ var ARCHIVES_DIR = join3(DATA_DIR, "archives");
783
+ var LOGS_DIR = join3(DATA_DIR, "logs");
784
+ var TRASH_DIR = join3(DATA_DIR, "trash");
785
+ var BACKUPS_DIR = join3(DATA_DIR, "backups");
786
+ var MODES_DIR = join3(DATA_DIR, "modes");
787
+ var USER_SETTINGS_PATH = join3(DATA_DIR, "settings.json");
788
+ var DB_PATH = join3(DATA_DIR, "contextkit.db");
789
+ var VECTOR_DB_DIR = join3(DATA_DIR, "vector-db");
790
+ var OBSERVER_SESSIONS_DIR = join3(DATA_DIR, "observer-sessions");
791
+ var KIRO_SETTINGS_PATH = join3(KIRO_CONFIG_DIR, "settings.json");
792
+ var KIRO_CONTEXT_PATH = join3(KIRO_CONFIG_DIR, "context.md");
774
793
  function ensureDir(dirPath) {
775
- mkdirSync2(dirPath, { recursive: true });
794
+ mkdirSync3(dirPath, { recursive: true });
776
795
  }
777
796
 
778
797
  // src/services/sqlite/Database.ts
@@ -1157,8 +1176,28 @@ function createContextKit(config) {
1157
1176
  // src/hooks/postToolUse.ts
1158
1177
  runHook("postToolUse", async (input) => {
1159
1178
  if (!input.tool_name) return;
1160
- const ignoredTools = ["glob", "grep", "fs_read", "read", "introspect", "thinking", "todo"];
1179
+ const ignoredTools = ["introspect", "thinking", "todo"];
1161
1180
  if (ignoredTools.includes(input.tool_name)) return;
1181
+ const readOnlyTools = ["glob", "grep", "fs_read", "read"];
1182
+ if (readOnlyTools.includes(input.tool_name)) {
1183
+ const project2 = detectProject(input.cwd);
1184
+ const sdk2 = createContextKit({ project: project2 });
1185
+ try {
1186
+ const files = extractFiles(input.tool_input, input.tool_response);
1187
+ const query = input.tool_input?.pattern || input.tool_input?.regex || input.tool_input?.query || "";
1188
+ const title = input.tool_name === "grep" || input.tool_name === "glob" ? `Cercato: ${query}`.substring(0, 100) : `Letto: ${files[0] || input.tool_input?.path || input.tool_input?.file_path || "file"}`;
1189
+ await sdk2.storeObservation({
1190
+ type: "file-read",
1191
+ title,
1192
+ content: files.length > 0 ? `File: ${files.join(", ")}` : `Tool ${input.tool_name} eseguito`,
1193
+ files
1194
+ });
1195
+ await notifyWorker("observation-created", { project: project2, title, type: "file-read" });
1196
+ } finally {
1197
+ sdk2.close();
1198
+ }
1199
+ return;
1200
+ }
1162
1201
  const project = detectProject(input.cwd);
1163
1202
  const sdk = createContextKit({ project });
1164
1203
  try {
@@ -1214,6 +1253,10 @@ function categorizeToolUse(toolName) {
1214
1253
  const categories = {
1215
1254
  "fs_write": "file-write",
1216
1255
  "write": "file-write",
1256
+ "fs_read": "file-read",
1257
+ "read": "file-read",
1258
+ "glob": "file-read",
1259
+ "grep": "file-read",
1217
1260
  "execute_bash": "command",
1218
1261
  "shell": "command",
1219
1262
  "web_search": "research",
@@ -384,6 +384,22 @@ var init_Search = __esm({
384
384
  });
385
385
 
386
386
  // src/hooks/utils.ts
387
+ import { writeFileSync, mkdirSync, existsSync } from "fs";
388
+ import { join } from "path";
389
+ function debugLog(hookName, label, data) {
390
+ if ((process.env.KIRO_MEMORY_LOG_LEVEL || "").toUpperCase() !== "DEBUG") return;
391
+ try {
392
+ const dataDir = process.env.KIRO_MEMORY_DATA_DIR || join(process.env.HOME || "/tmp", ".kiro-memory");
393
+ const logDir = join(dataDir, "logs");
394
+ if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });
395
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
396
+ const line = `[${ts}] [${hookName}] ${label}: ${JSON.stringify(data)}
397
+ `;
398
+ const logFile = join(logDir, `hooks-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
399
+ writeFileSync(logFile, line, { flag: "a" });
400
+ } catch {
401
+ }
402
+ }
387
403
  async function readStdin() {
388
404
  return new Promise((resolve, reject) => {
389
405
  let data = "";
@@ -448,10 +464,13 @@ async function notifyWorker(event, data) {
448
464
  async function runHook(name, handler) {
449
465
  try {
450
466
  const input = await readStdin();
467
+ debugLog(name, "stdin", input);
451
468
  await handler(input);
469
+ debugLog(name, "completato", { success: true });
452
470
  process.exit(0);
453
471
  } catch (error) {
454
- process.stderr.write(`[contextkit:${name}] Errore: ${error}
472
+ debugLog(name, "errore", { error: String(error) });
473
+ process.stderr.write(`[kiro-memory:${name}] Errore: ${error}
455
474
  `);
456
475
  process.exit(0);
457
476
  }
@@ -525,14 +544,14 @@ var BunQueryCompat = class {
525
544
  };
526
545
 
527
546
  // src/shared/paths.ts
528
- import { join as join2, dirname, basename } from "path";
547
+ import { join as join3, dirname, basename } from "path";
529
548
  import { homedir as homedir2 } from "os";
530
- import { mkdirSync as mkdirSync2 } from "fs";
549
+ import { mkdirSync as mkdirSync3 } from "fs";
531
550
  import { fileURLToPath } from "url";
532
551
 
533
552
  // src/utils/logger.ts
534
- import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
535
- import { join } from "path";
553
+ import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync } from "fs";
554
+ import { join as join2 } from "path";
536
555
  import { homedir } from "os";
537
556
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
538
557
  LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
@@ -542,7 +561,7 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
542
561
  LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
543
562
  return LogLevel2;
544
563
  })(LogLevel || {});
545
- var DEFAULT_DATA_DIR = join(homedir(), ".contextkit");
564
+ var DEFAULT_DATA_DIR = join2(homedir(), ".contextkit");
546
565
  var Logger = class {
547
566
  level = null;
548
567
  useColor;
@@ -558,12 +577,12 @@ var Logger = class {
558
577
  if (this.logFileInitialized) return;
559
578
  this.logFileInitialized = true;
560
579
  try {
561
- const logsDir = join(DEFAULT_DATA_DIR, "logs");
562
- if (!existsSync(logsDir)) {
563
- mkdirSync(logsDir, { recursive: true });
580
+ const logsDir = join2(DEFAULT_DATA_DIR, "logs");
581
+ if (!existsSync2(logsDir)) {
582
+ mkdirSync2(logsDir, { recursive: true });
564
583
  }
565
584
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
566
- this.logFilePath = join(logsDir, `contextkit-${date}.log`);
585
+ this.logFilePath = join2(logsDir, `contextkit-${date}.log`);
567
586
  } catch (error) {
568
587
  console.error("[LOGGER] Failed to initialize log file:", error);
569
588
  this.logFilePath = null;
@@ -575,8 +594,8 @@ var Logger = class {
575
594
  getLevel() {
576
595
  if (this.level === null) {
577
596
  try {
578
- const settingsPath = join(DEFAULT_DATA_DIR, "settings.json");
579
- if (existsSync(settingsPath)) {
597
+ const settingsPath = join2(DEFAULT_DATA_DIR, "settings.json");
598
+ if (existsSync2(settingsPath)) {
580
599
  const settingsData = readFileSync(settingsPath, "utf-8");
581
600
  const settings = JSON.parse(settingsData);
582
601
  const envLevel = (settings.CONTEXTKIT_LOG_LEVEL || "INFO").toUpperCase();
@@ -757,22 +776,22 @@ function getDirname() {
757
776
  return dirname(fileURLToPath(import.meta.url));
758
777
  }
759
778
  var _dirname = getDirname();
760
- var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join2(homedir2(), ".contextkit");
761
- var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join2(homedir2(), ".kiro");
762
- var PLUGIN_ROOT = join2(KIRO_CONFIG_DIR, "plugins", "contextkit");
763
- var ARCHIVES_DIR = join2(DATA_DIR, "archives");
764
- var LOGS_DIR = join2(DATA_DIR, "logs");
765
- var TRASH_DIR = join2(DATA_DIR, "trash");
766
- var BACKUPS_DIR = join2(DATA_DIR, "backups");
767
- var MODES_DIR = join2(DATA_DIR, "modes");
768
- var USER_SETTINGS_PATH = join2(DATA_DIR, "settings.json");
769
- var DB_PATH = join2(DATA_DIR, "contextkit.db");
770
- var VECTOR_DB_DIR = join2(DATA_DIR, "vector-db");
771
- var OBSERVER_SESSIONS_DIR = join2(DATA_DIR, "observer-sessions");
772
- var KIRO_SETTINGS_PATH = join2(KIRO_CONFIG_DIR, "settings.json");
773
- var KIRO_CONTEXT_PATH = join2(KIRO_CONFIG_DIR, "context.md");
779
+ var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join3(homedir2(), ".contextkit");
780
+ var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join3(homedir2(), ".kiro");
781
+ var PLUGIN_ROOT = join3(KIRO_CONFIG_DIR, "plugins", "contextkit");
782
+ var ARCHIVES_DIR = join3(DATA_DIR, "archives");
783
+ var LOGS_DIR = join3(DATA_DIR, "logs");
784
+ var TRASH_DIR = join3(DATA_DIR, "trash");
785
+ var BACKUPS_DIR = join3(DATA_DIR, "backups");
786
+ var MODES_DIR = join3(DATA_DIR, "modes");
787
+ var USER_SETTINGS_PATH = join3(DATA_DIR, "settings.json");
788
+ var DB_PATH = join3(DATA_DIR, "contextkit.db");
789
+ var VECTOR_DB_DIR = join3(DATA_DIR, "vector-db");
790
+ var OBSERVER_SESSIONS_DIR = join3(DATA_DIR, "observer-sessions");
791
+ var KIRO_SETTINGS_PATH = join3(KIRO_CONFIG_DIR, "settings.json");
792
+ var KIRO_CONTEXT_PATH = join3(KIRO_CONFIG_DIR, "context.md");
774
793
  function ensureDir(dirPath) {
775
- mkdirSync2(dirPath, { recursive: true });
794
+ mkdirSync3(dirPath, { recursive: true });
776
795
  }
777
796
 
778
797
  // src/services/sqlite/Database.ts
@@ -384,6 +384,22 @@ var init_Search = __esm({
384
384
  });
385
385
 
386
386
  // src/hooks/utils.ts
387
+ import { writeFileSync, mkdirSync, existsSync } from "fs";
388
+ import { join } from "path";
389
+ function debugLog(hookName, label, data) {
390
+ if ((process.env.KIRO_MEMORY_LOG_LEVEL || "").toUpperCase() !== "DEBUG") return;
391
+ try {
392
+ const dataDir = process.env.KIRO_MEMORY_DATA_DIR || join(process.env.HOME || "/tmp", ".kiro-memory");
393
+ const logDir = join(dataDir, "logs");
394
+ if (!existsSync(logDir)) mkdirSync(logDir, { recursive: true });
395
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
396
+ const line = `[${ts}] [${hookName}] ${label}: ${JSON.stringify(data)}
397
+ `;
398
+ const logFile = join(logDir, `hooks-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
399
+ writeFileSync(logFile, line, { flag: "a" });
400
+ } catch {
401
+ }
402
+ }
387
403
  async function readStdin() {
388
404
  return new Promise((resolve, reject) => {
389
405
  let data = "";
@@ -448,10 +464,13 @@ async function notifyWorker(event, data) {
448
464
  async function runHook(name, handler) {
449
465
  try {
450
466
  const input = await readStdin();
467
+ debugLog(name, "stdin", input);
451
468
  await handler(input);
469
+ debugLog(name, "completato", { success: true });
452
470
  process.exit(0);
453
471
  } catch (error) {
454
- process.stderr.write(`[contextkit:${name}] Errore: ${error}
472
+ debugLog(name, "errore", { error: String(error) });
473
+ process.stderr.write(`[kiro-memory:${name}] Errore: ${error}
455
474
  `);
456
475
  process.exit(0);
457
476
  }
@@ -525,14 +544,14 @@ var BunQueryCompat = class {
525
544
  };
526
545
 
527
546
  // src/shared/paths.ts
528
- import { join as join2, dirname, basename } from "path";
547
+ import { join as join3, dirname, basename } from "path";
529
548
  import { homedir as homedir2 } from "os";
530
- import { mkdirSync as mkdirSync2 } from "fs";
549
+ import { mkdirSync as mkdirSync3 } from "fs";
531
550
  import { fileURLToPath } from "url";
532
551
 
533
552
  // src/utils/logger.ts
534
- import { appendFileSync, existsSync, mkdirSync, readFileSync } from "fs";
535
- import { join } from "path";
553
+ import { appendFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync } from "fs";
554
+ import { join as join2 } from "path";
536
555
  import { homedir } from "os";
537
556
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
538
557
  LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
@@ -542,7 +561,7 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
542
561
  LogLevel2[LogLevel2["SILENT"] = 4] = "SILENT";
543
562
  return LogLevel2;
544
563
  })(LogLevel || {});
545
- var DEFAULT_DATA_DIR = join(homedir(), ".contextkit");
564
+ var DEFAULT_DATA_DIR = join2(homedir(), ".contextkit");
546
565
  var Logger = class {
547
566
  level = null;
548
567
  useColor;
@@ -558,12 +577,12 @@ var Logger = class {
558
577
  if (this.logFileInitialized) return;
559
578
  this.logFileInitialized = true;
560
579
  try {
561
- const logsDir = join(DEFAULT_DATA_DIR, "logs");
562
- if (!existsSync(logsDir)) {
563
- mkdirSync(logsDir, { recursive: true });
580
+ const logsDir = join2(DEFAULT_DATA_DIR, "logs");
581
+ if (!existsSync2(logsDir)) {
582
+ mkdirSync2(logsDir, { recursive: true });
564
583
  }
565
584
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
566
- this.logFilePath = join(logsDir, `contextkit-${date}.log`);
585
+ this.logFilePath = join2(logsDir, `contextkit-${date}.log`);
567
586
  } catch (error) {
568
587
  console.error("[LOGGER] Failed to initialize log file:", error);
569
588
  this.logFilePath = null;
@@ -575,8 +594,8 @@ var Logger = class {
575
594
  getLevel() {
576
595
  if (this.level === null) {
577
596
  try {
578
- const settingsPath = join(DEFAULT_DATA_DIR, "settings.json");
579
- if (existsSync(settingsPath)) {
597
+ const settingsPath = join2(DEFAULT_DATA_DIR, "settings.json");
598
+ if (existsSync2(settingsPath)) {
580
599
  const settingsData = readFileSync(settingsPath, "utf-8");
581
600
  const settings = JSON.parse(settingsData);
582
601
  const envLevel = (settings.CONTEXTKIT_LOG_LEVEL || "INFO").toUpperCase();
@@ -757,22 +776,22 @@ function getDirname() {
757
776
  return dirname(fileURLToPath(import.meta.url));
758
777
  }
759
778
  var _dirname = getDirname();
760
- var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join2(homedir2(), ".contextkit");
761
- var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join2(homedir2(), ".kiro");
762
- var PLUGIN_ROOT = join2(KIRO_CONFIG_DIR, "plugins", "contextkit");
763
- var ARCHIVES_DIR = join2(DATA_DIR, "archives");
764
- var LOGS_DIR = join2(DATA_DIR, "logs");
765
- var TRASH_DIR = join2(DATA_DIR, "trash");
766
- var BACKUPS_DIR = join2(DATA_DIR, "backups");
767
- var MODES_DIR = join2(DATA_DIR, "modes");
768
- var USER_SETTINGS_PATH = join2(DATA_DIR, "settings.json");
769
- var DB_PATH = join2(DATA_DIR, "contextkit.db");
770
- var VECTOR_DB_DIR = join2(DATA_DIR, "vector-db");
771
- var OBSERVER_SESSIONS_DIR = join2(DATA_DIR, "observer-sessions");
772
- var KIRO_SETTINGS_PATH = join2(KIRO_CONFIG_DIR, "settings.json");
773
- var KIRO_CONTEXT_PATH = join2(KIRO_CONFIG_DIR, "context.md");
779
+ var DATA_DIR = process.env.CONTEXTKIT_DATA_DIR || join3(homedir2(), ".contextkit");
780
+ var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join3(homedir2(), ".kiro");
781
+ var PLUGIN_ROOT = join3(KIRO_CONFIG_DIR, "plugins", "contextkit");
782
+ var ARCHIVES_DIR = join3(DATA_DIR, "archives");
783
+ var LOGS_DIR = join3(DATA_DIR, "logs");
784
+ var TRASH_DIR = join3(DATA_DIR, "trash");
785
+ var BACKUPS_DIR = join3(DATA_DIR, "backups");
786
+ var MODES_DIR = join3(DATA_DIR, "modes");
787
+ var USER_SETTINGS_PATH = join3(DATA_DIR, "settings.json");
788
+ var DB_PATH = join3(DATA_DIR, "contextkit.db");
789
+ var VECTOR_DB_DIR = join3(DATA_DIR, "vector-db");
790
+ var OBSERVER_SESSIONS_DIR = join3(DATA_DIR, "observer-sessions");
791
+ var KIRO_SETTINGS_PATH = join3(KIRO_CONFIG_DIR, "settings.json");
792
+ var KIRO_CONTEXT_PATH = join3(KIRO_CONFIG_DIR, "context.md");
774
793
  function ensureDir(dirPath) {
775
- mkdirSync2(dirPath, { recursive: true });
794
+ mkdirSync3(dirPath, { recursive: true });
776
795
  }
777
796
 
778
797
  // src/services/sqlite/Database.ts
@@ -1156,13 +1175,13 @@ function createContextKit(config) {
1156
1175
 
1157
1176
  // src/hooks/userPromptSubmit.ts
1158
1177
  runHook("userPromptSubmit", async (input) => {
1178
+ const promptText = input.prompt || input.user_prompt || input.tool_input?.prompt || input.tool_input?.content;
1179
+ if (!promptText || typeof promptText !== "string" || promptText.trim().length === 0) return;
1159
1180
  const project = detectProject(input.cwd);
1160
1181
  const sdk = createContextKit({ project });
1161
1182
  try {
1162
- const promptText = input.tool_input?.prompt || input.tool_input?.content || input.tool_input?.message || JSON.stringify(input.tool_input || "").substring(0, 500);
1163
- if (!promptText || promptText === '""') return;
1164
- const sessionId = `kiro-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}-${project}`;
1165
- await sdk.storePrompt(sessionId, Date.now(), promptText);
1183
+ const sessionId = input.session_id || `kiro-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}-${project}`;
1184
+ await sdk.storePrompt(sessionId, Date.now(), promptText.trim());
1166
1185
  await notifyWorker("prompt-created", { project });
1167
1186
  } finally {
1168
1187
  sdk.close();
@@ -1202,6 +1202,22 @@ function createContextKit(config) {
1202
1202
  init_Search();
1203
1203
 
1204
1204
  // src/hooks/utils.ts
1205
+ import { writeFileSync, mkdirSync as mkdirSync3, existsSync as existsSync3 } from "fs";
1206
+ import { join as join3 } from "path";
1207
+ function debugLog(hookName, label, data) {
1208
+ if ((process.env.KIRO_MEMORY_LOG_LEVEL || "").toUpperCase() !== "DEBUG") return;
1209
+ try {
1210
+ const dataDir = process.env.KIRO_MEMORY_DATA_DIR || join3(process.env.HOME || "/tmp", ".kiro-memory");
1211
+ const logDir = join3(dataDir, "logs");
1212
+ if (!existsSync3(logDir)) mkdirSync3(logDir, { recursive: true });
1213
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
1214
+ const line = `[${ts}] [${hookName}] ${label}: ${JSON.stringify(data)}
1215
+ `;
1216
+ const logFile = join3(logDir, `hooks-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.log`);
1217
+ writeFileSync(logFile, line, { flag: "a" });
1218
+ } catch {
1219
+ }
1220
+ }
1205
1221
  async function readStdin() {
1206
1222
  return new Promise((resolve, reject) => {
1207
1223
  let data = "";
@@ -1275,10 +1291,13 @@ function formatContext(data) {
1275
1291
  async function runHook(name, handler) {
1276
1292
  try {
1277
1293
  const input = await readStdin();
1294
+ debugLog(name, "stdin", input);
1278
1295
  await handler(input);
1296
+ debugLog(name, "completato", { success: true });
1279
1297
  process.exit(0);
1280
1298
  } catch (error) {
1281
- process.stderr.write(`[contextkit:${name}] Errore: ${error}
1299
+ debugLog(name, "errore", { error: String(error) });
1300
+ process.stderr.write(`[kiro-memory:${name}] Errore: ${error}
1282
1301
  `);
1283
1302
  process.exit(0);
1284
1303
  }
@@ -32,6 +32,8 @@
32
32
  --pink-muted: rgba(244, 114, 182, 0.15);
33
33
  --red: #f87171;
34
34
  --red-muted: rgba(248, 113, 113, 0.15);
35
+ --teal: #2dd4bf;
36
+ --teal-muted: rgba(45, 212, 191, 0.15);
35
37
  --sidebar-width: 260px;
36
38
  --header-height: 56px;
37
39
  --radius: 8px;
@@ -415,6 +417,7 @@
415
417
  .card--summary { border-left-color: var(--violet); }
416
418
  .card--prompt { border-left-color: var(--pink); }
417
419
  .card--delegation { border-left-color: var(--accent); }
420
+ .card--file-read { border-left-color: var(--teal); }
418
421
  .card--tool-use { border-left-color: var(--text-muted); }
419
422
  .card--default { border-left-color: var(--text-muted); }
420
423
 
@@ -445,6 +448,7 @@
445
448
  .badge--summary { background: var(--violet-muted); color: var(--violet); }
446
449
  .badge--prompt { background: var(--pink-muted); color: var(--pink); }
447
450
  .badge--delegation { background: var(--accent-muted); color: var(--accent); }
451
+ .badge--file-read { background: var(--teal-muted); color: var(--teal); }
448
452
  .badge--tool-use { background: var(--bg-tertiary); color: var(--text-secondary); }
449
453
  .badge--default { background: var(--bg-tertiary); color: var(--text-secondary); }
450
454
 
@@ -23597,6 +23597,7 @@ var import_react = __toESM(require_react(), 1);
23597
23597
  function getBadgeClass(type) {
23598
23598
  const map = {
23599
23599
  "file-write": "badge--file-write",
23600
+ "file-read": "badge--file-read",
23600
23601
  "command": "badge--command",
23601
23602
  "research": "badge--research",
23602
23603
  "delegation": "badge--delegation",