memorix 0.9.6 → 0.9.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.9.7] — 2026-02-25
6
+
7
+ ### Fixed
8
+ - **Claude Code hooks never triggering auto-memory** — Claude Code sends `hook_event_name` (snake_case) but the normalizer expected `hookEventName` (camelCase). This caused **every event** (SessionStart, UserPromptSubmit, PostToolUse, PreCompact, Stop) to be misidentified as `post_tool`, breaking event routing, prompt extraction, memory injection, and session tracking. Also fixed `session_id` → `sessionId` and `tool_response` → `toolResult` field mappings.
9
+ - **Empty content extraction from Claude Code tool events** — `extractContent()` now unpacks `toolInput` fields (Bash commands, Write file content, etc.) when no other content is available. Previously tool events produced empty or near-empty content strings.
10
+ - **User prompts silently dropped** — `MIN_STORE_LENGTH=100` was too high for typical user prompts. Added `MIN_PROMPT_LENGTH=20` specifically for `user_prompt` events.
11
+ - **Post-tool events too aggressively filtered** — Tool events with substantial content (>200 chars) are now stored even without keyword pattern matches.
12
+
5
13
  ## [0.9.6] — 2026-02-25
6
14
 
7
15
  ### Fixed
package/dist/cli/index.js CHANGED
@@ -6894,9 +6894,8 @@ var init_sync = __esm({
6894
6894
  function detectAgent(payload) {
6895
6895
  if ("agent_action_name" in payload) return "windsurf";
6896
6896
  if ("hook_event_name" in payload && "conversation_id" in payload) return "cursor";
6897
- if ("hookEventName" in payload) {
6898
- return "copilot";
6899
- }
6897
+ if ("hook_event_name" in payload) return "claude";
6898
+ if ("hookEventName" in payload) return "copilot";
6900
6899
  if ("event_type" in payload) return "kiro";
6901
6900
  if ("hook_type" in payload) return "codex";
6902
6901
  return "claude";
@@ -6907,8 +6906,9 @@ function extractEventName(payload, agent) {
6907
6906
  return payload.agent_action_name ?? "";
6908
6907
  case "cursor":
6909
6908
  return payload.hook_event_name ?? "";
6910
- case "copilot":
6911
6909
  case "claude":
6910
+ return payload.hook_event_name ?? payload.hookEventName ?? "";
6911
+ case "copilot":
6912
6912
  return payload.hookEventName ?? "";
6913
6913
  case "kiro":
6914
6914
  return payload.event_type ?? "";
@@ -6920,7 +6920,7 @@ function extractEventName(payload, agent) {
6920
6920
  }
6921
6921
  function normalizeClaude(payload, event) {
6922
6922
  const result = {
6923
- sessionId: payload.sessionId ?? "",
6923
+ sessionId: payload.session_id ?? payload.sessionId ?? "",
6924
6924
  cwd: payload.cwd ?? "",
6925
6925
  transcriptPath: payload.transcript_path
6926
6926
  };
@@ -6928,10 +6928,18 @@ function normalizeClaude(payload, event) {
6928
6928
  if (toolName) {
6929
6929
  result.toolName = toolName;
6930
6930
  result.toolInput = payload.tool_input;
6931
- result.toolResult = payload.tool_result;
6932
- if (toolName === "write" || toolName === "edit" || toolName === "multi_edit") {
6933
- const input = payload.tool_input;
6934
- result.filePath = input?.file_path ?? input?.filePath;
6931
+ const toolResponse = payload.tool_response ?? payload.tool_result;
6932
+ if (typeof toolResponse === "string") {
6933
+ result.toolResult = toolResponse;
6934
+ } else if (toolResponse && typeof toolResponse === "object") {
6935
+ result.toolResult = JSON.stringify(toolResponse);
6936
+ }
6937
+ const toolInput = payload.tool_input;
6938
+ if (/^bash$/i.test(toolName) && toolInput?.command) {
6939
+ result.command = toolInput.command;
6940
+ }
6941
+ if (/^(write|edit|multi_edit|multiedittool)$/i.test(toolName)) {
6942
+ result.filePath = toolInput?.file_path ?? toolInput?.filePath;
6935
6943
  }
6936
6944
  }
6937
6945
  if (event === "user_prompt") {
@@ -7231,6 +7239,19 @@ function extractContent(input) {
7231
7239
  parts.push(`Edit: ${edit.oldString} \u2192 ${edit.newString}`);
7232
7240
  }
7233
7241
  }
7242
+ if (parts.length === 0 && input.toolInput && typeof input.toolInput === "object") {
7243
+ if (input.toolName) parts.push(`Tool: ${input.toolName}`);
7244
+ if (input.toolInput.command) parts.push(`Command: ${input.toolInput.command}`);
7245
+ if (input.toolInput.file_path) parts.push(`File: ${input.toolInput.file_path}`);
7246
+ if (input.toolInput.content) {
7247
+ const content = input.toolInput.content;
7248
+ parts.push(content.slice(0, 1e3));
7249
+ }
7250
+ if (parts.length <= 1) {
7251
+ const summary = JSON.stringify(input.toolInput).slice(0, 500);
7252
+ parts.push(summary);
7253
+ }
7254
+ }
7234
7255
  return parts.join("\n").slice(0, MAX_CONTENT_LENGTH);
7235
7256
  }
7236
7257
  function deriveEntityName(input) {
@@ -7421,7 +7442,7 @@ ${lines.join("\n")}`;
7421
7442
  return { observation: null, output: defaultOutput };
7422
7443
  }
7423
7444
  const toolPattern = detectBestPattern(toolContent);
7424
- if (!toolPattern) {
7445
+ if (!toolPattern && toolContent.length < 200) {
7425
7446
  return { observation: null, output: defaultOutput };
7426
7447
  }
7427
7448
  markTriggered(toolKey);
@@ -7437,7 +7458,8 @@ ${lines.join("\n")}`;
7437
7458
  return { observation: null, output: defaultOutput };
7438
7459
  }
7439
7460
  const content = extractContent(input);
7440
- if (content.length < MIN_STORE_LENGTH) {
7461
+ const minLen = input.event === "user_prompt" ? MIN_PROMPT_LENGTH : MIN_STORE_LENGTH;
7462
+ if (content.length < minLen) {
7441
7463
  return { observation: null, output: defaultOutput };
7442
7464
  }
7443
7465
  detectBestPattern(content);
@@ -7484,7 +7506,7 @@ async function runHook() {
7484
7506
  }
7485
7507
  process.stdout.write(JSON.stringify(output));
7486
7508
  }
7487
- var cooldowns, COOLDOWN_MS, MIN_STORE_LENGTH, MIN_EDIT_LENGTH, NOISE_COMMANDS, MAX_CONTENT_LENGTH;
7509
+ var cooldowns, COOLDOWN_MS, MIN_STORE_LENGTH, MIN_PROMPT_LENGTH, MIN_EDIT_LENGTH, NOISE_COMMANDS, MAX_CONTENT_LENGTH;
7488
7510
  var init_handler = __esm({
7489
7511
  "src/hooks/handler.ts"() {
7490
7512
  "use strict";
@@ -7494,6 +7516,7 @@ var init_handler = __esm({
7494
7516
  cooldowns = /* @__PURE__ */ new Map();
7495
7517
  COOLDOWN_MS = 3e4;
7496
7518
  MIN_STORE_LENGTH = 100;
7519
+ MIN_PROMPT_LENGTH = 20;
7497
7520
  MIN_EDIT_LENGTH = 30;
7498
7521
  NOISE_COMMANDS = [
7499
7522
  /^(ls|dir|cd|pwd|echo|cat|type|head|tail|wc|find|which|where|whoami)\b/i,