eagle-mem 1.6.1 → 1.6.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/db/migrate.sh CHANGED
@@ -41,31 +41,14 @@ sqlite3 "$DB" "CREATE TABLE IF NOT EXISTS _migrations (
41
41
  # Set PRAGMAs (these must be set on every connection)
42
42
  sqlite3 "$DB" "PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA busy_timeout = 5000; PRAGMA foreign_keys = ON;"
43
43
 
44
- # ─── Migration 001: Initial schema ─────────────────────────
44
+ # ─── Migration 001: Initial schema (special name) ──────────
45
45
  run_migration "001_initial_schema" "$SCRIPT_DIR/schema.sql"
46
46
 
47
- # ─── Migration 002: Project overviews ──────────────────────
48
- run_migration "002_overviews" "$SCRIPT_DIR/002_overviews.sql"
49
-
50
- # ─── Migration 003: Code chunks ───────────────────────────
51
- run_migration "003_code_chunks" "$SCRIPT_DIR/003_code_chunks.sql"
52
-
53
- # ─── Migration 004: Observation indexes ──────────────────
54
- run_migration "004_observation_indexes" "$SCRIPT_DIR/004_observation_indexes.sql"
55
-
56
- # ─── Migration 005: Claude Code memory mirror ────────────
57
- run_migration "005_claude_memories" "$SCRIPT_DIR/005_claude_memories.sql"
58
-
59
- # ─── Migration 006: Claude Code plan mirror ──────────────
60
- run_migration "006_claude_plans" "$SCRIPT_DIR/006_claude_plans.sql"
61
-
62
- # ─── Migration 007: Claude Code task mirror ──────────────
63
- run_migration "007_claude_tasks" "$SCRIPT_DIR/007_claude_tasks.sql"
64
-
65
- # ─── Migration 008: Summary UPSERT (unique session_id) ───
66
- run_migration "008_summary_upsert" "$SCRIPT_DIR/008_summary_upsert.sql"
67
-
68
- # ─── Migration 009: Drop dead tasks table ────────────────
69
- run_migration "009_drop_dead_tasks" "$SCRIPT_DIR/009_drop_dead_tasks.sql"
47
+ # ─── Run numbered migrations (002+) via sorted glob ───────
48
+ for migration_file in "$SCRIPT_DIR"/[0-9][0-9][0-9]_*.sql; do
49
+ [ ! -f "$migration_file" ] && continue
50
+ migration_name=$(basename "$migration_file" .sql)
51
+ run_migration "$migration_name" "$migration_file"
52
+ done
70
53
 
71
54
  echo " Eagle Mem database ready: $DB"
package/lib/hooks.sh ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env bash
2
+ # ═══════════════════════════════════════════════════════════
3
+ # Eagle Mem — Hook registration helpers
4
+ # Shared by install.sh and update.sh
5
+ # ═══════════════════════════════════════════════════════════
6
+
7
+ eagle_patch_hook() {
8
+ local settings="$1"
9
+ local event="$2"
10
+ local matcher="$3"
11
+ local command="$4"
12
+ local description="${5:-}"
13
+
14
+ if jq -e ".hooks.${event}[]? | select(.hooks[]?.command == \"$command\")" "$settings" &>/dev/null; then
15
+ [ -n "$description" ] && eagle_ok "$description ${DIM}(already registered)${RESET}"
16
+ return
17
+ fi
18
+
19
+ local entry
20
+ if [ -n "$matcher" ]; then
21
+ entry=$(jq -nc --arg m "$matcher" --arg c "$command" '{matcher: $m, hooks: [{type: "command", command: $c}]}')
22
+ else
23
+ entry=$(jq -nc --arg c "$command" '{hooks: [{type: "command", command: $c}]}')
24
+ fi
25
+
26
+ local tmp
27
+ tmp=$(mktemp)
28
+ jq --argjson entry "$entry" ".hooks.${event} = ((.hooks.${event} // []) + [\$entry])" "$settings" > "$tmp" && mv "$tmp" "$settings"
29
+ [ -n "$description" ] && eagle_ok "$description"
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eagle-mem",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Lightweight persistent memory for Claude Code — SQLite + FTS5, no daemon, no bloat",
5
5
  "bin": {
6
6
  "eagle-mem": "bin/eagle-mem"
@@ -11,6 +11,7 @@ LIB_DIR="$SCRIPTS_DIR/../lib"
11
11
 
12
12
  . "$SCRIPTS_DIR/style.sh"
13
13
  . "$LIB_DIR/common.sh"
14
+ . "$LIB_DIR/hooks.sh"
14
15
 
15
16
  SETTINGS="$EAGLE_SETTINGS"
16
17
 
@@ -160,47 +161,23 @@ if [ ! -f "$SETTINGS" ]; then
160
161
  echo '{}' > "$SETTINGS"
161
162
  fi
162
163
 
163
- patch_hook() {
164
- local event="$1"
165
- local matcher="$2"
166
- local command="$3"
167
- local description="$4"
168
-
169
- if jq -e ".hooks.${event}[]? | select(.hooks[]?.command == \"$command\")" "$SETTINGS" &>/dev/null; then
170
- eagle_ok "$description ${DIM}(already registered)${RESET}"
171
- return
172
- fi
173
-
174
- local entry
175
- if [ -n "$matcher" ]; then
176
- entry="{\"matcher\": \"$matcher\", \"hooks\": [{\"type\": \"command\", \"command\": \"$command\"}]}"
177
- else
178
- entry="{\"hooks\": [{\"type\": \"command\", \"command\": \"$command\"}]}"
179
- fi
180
-
181
- local tmp
182
- tmp=$(mktemp)
183
- jq --argjson entry "$entry" ".hooks.${event} = ((.hooks.${event} // []) + [\$entry])" "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
184
- eagle_ok "$description"
185
- }
186
-
187
- patch_hook "SessionStart" "" \
164
+ eagle_patch_hook "$SETTINGS" "SessionStart" "" \
188
165
  "$EAGLE_MEM_DIR/hooks/session-start.sh" \
189
166
  "SessionStart hook"
190
167
 
191
- patch_hook "Stop" "" \
168
+ eagle_patch_hook "$SETTINGS" "Stop" "" \
192
169
  "$EAGLE_MEM_DIR/hooks/stop.sh" \
193
170
  "Stop hook"
194
171
 
195
- patch_hook "PostToolUse" "Read|Write|Edit|Bash|TaskCreate|TaskUpdate" \
172
+ eagle_patch_hook "$SETTINGS" "PostToolUse" "Read|Write|Edit|Bash|TaskCreate|TaskUpdate" \
196
173
  "$EAGLE_MEM_DIR/hooks/post-tool-use.sh" \
197
174
  "PostToolUse hook"
198
175
 
199
- patch_hook "SessionEnd" "" \
176
+ eagle_patch_hook "$SETTINGS" "SessionEnd" "" \
200
177
  "$EAGLE_MEM_DIR/hooks/session-end.sh" \
201
178
  "SessionEnd hook"
202
179
 
203
- patch_hook "UserPromptSubmit" "" \
180
+ eagle_patch_hook "$SETTINGS" "UserPromptSubmit" "" \
204
181
  "$EAGLE_MEM_DIR/hooks/user-prompt-submit.sh" \
205
182
  "UserPromptSubmit hook"
206
183
 
package/scripts/update.sh CHANGED
@@ -12,6 +12,7 @@ LIB_DIR="$SCRIPTS_DIR/../lib"
12
12
  . "$SCRIPTS_DIR/style.sh"
13
13
  . "$LIB_DIR/common.sh"
14
14
  . "$LIB_DIR/db.sh"
15
+ . "$LIB_DIR/hooks.sh"
15
16
 
16
17
  SETTINGS="$EAGLE_SETTINGS"
17
18
 
@@ -57,37 +58,17 @@ fi
57
58
  # ─── Re-register hooks (idempotent) ───────────────────────
58
59
 
59
60
  if [ -f "$SETTINGS" ] && command -v jq &>/dev/null; then
60
- patch_hook() {
61
- local event="$1"
62
- local matcher="$2"
63
- local command="$3"
64
-
65
- if jq -e ".hooks.${event}[]? | select(.hooks[]?.command == \"$command\")" "$SETTINGS" &>/dev/null; then
66
- return
67
- fi
68
-
69
- local entry
70
- if [ -n "$matcher" ]; then
71
- entry="{\"matcher\": \"$matcher\", \"hooks\": [{\"type\": \"command\", \"command\": \"$command\"}]}"
72
- else
73
- entry="{\"hooks\": [{\"type\": \"command\", \"command\": \"$command\"}]}"
74
- fi
75
-
76
- local tmp
77
- tmp=$(mktemp)
78
- jq --argjson entry "$entry" ".hooks.${event} = ((.hooks.${event} // []) + [\$entry])" "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
79
- }
80
-
81
- patch_hook "SessionStart" "" "$EAGLE_MEM_DIR/hooks/session-start.sh"
82
- patch_hook "Stop" "" "$EAGLE_MEM_DIR/hooks/stop.sh"
83
61
  # Update PostToolUse matcher if it has the old value (pre-v1.3.0)
84
62
  if jq -e '.hooks.PostToolUse[]? | select(.matcher == "Read|Write|Edit|Bash")' "$SETTINGS" &>/dev/null; then
85
63
  _tmp=$(mktemp)
86
64
  jq '(.hooks.PostToolUse[] | select(.matcher == "Read|Write|Edit|Bash")).matcher = "Read|Write|Edit|Bash|TaskCreate|TaskUpdate"' "$SETTINGS" > "$_tmp" && mv "$_tmp" "$SETTINGS"
87
65
  fi
88
- patch_hook "PostToolUse" "Read|Write|Edit|Bash|TaskCreate|TaskUpdate" "$EAGLE_MEM_DIR/hooks/post-tool-use.sh"
89
- patch_hook "SessionEnd" "" "$EAGLE_MEM_DIR/hooks/session-end.sh"
90
- patch_hook "UserPromptSubmit" "" "$EAGLE_MEM_DIR/hooks/user-prompt-submit.sh"
66
+
67
+ eagle_patch_hook "$SETTINGS" "SessionStart" "" "$EAGLE_MEM_DIR/hooks/session-start.sh"
68
+ eagle_patch_hook "$SETTINGS" "Stop" "" "$EAGLE_MEM_DIR/hooks/stop.sh"
69
+ eagle_patch_hook "$SETTINGS" "PostToolUse" "Read|Write|Edit|Bash|TaskCreate|TaskUpdate" "$EAGLE_MEM_DIR/hooks/post-tool-use.sh"
70
+ eagle_patch_hook "$SETTINGS" "SessionEnd" "" "$EAGLE_MEM_DIR/hooks/session-end.sh"
71
+ eagle_patch_hook "$SETTINGS" "UserPromptSubmit" "" "$EAGLE_MEM_DIR/hooks/user-prompt-submit.sh"
91
72
 
92
73
  eagle_ok "Hooks registered"
93
74
  fi