eagle-mem 4.1.2 → 4.2.1
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/hooks/session-start.sh +13 -0
- package/hooks/stop.sh +7 -1
- package/hooks/user-prompt-submit.sh +35 -4
- package/package.json +1 -1
package/hooks/session-start.sh
CHANGED
|
@@ -37,6 +37,18 @@ eagle_log "INFO" "SessionStart: session=$session_id project=$project source=$sou
|
|
|
37
37
|
eagle_upsert_session "$session_id" "$project" "$cwd" "$model" "$source_type"
|
|
38
38
|
eagle_abandon_stale_sessions "$session_id"
|
|
39
39
|
|
|
40
|
+
# ─── Reset turn counter on compact/clear ─────────────────
|
|
41
|
+
|
|
42
|
+
case "$source_type" in
|
|
43
|
+
compact|clear)
|
|
44
|
+
echo "0" > "$EAGLE_MEM_DIR/.turn-counter.${session_id}" 2>/dev/null
|
|
45
|
+
rm -f "$EAGLE_MEM_DIR/.context-pressure" 2>/dev/null
|
|
46
|
+
;;
|
|
47
|
+
startup)
|
|
48
|
+
echo "0" > "$EAGLE_MEM_DIR/.turn-counter.${session_id}" 2>/dev/null
|
|
49
|
+
;;
|
|
50
|
+
esac
|
|
51
|
+
|
|
40
52
|
# ─── Background automation (non-blocking) ────────────────
|
|
41
53
|
|
|
42
54
|
eagle_sessionstart_auto_provision "$project" "$cwd" "$SCRIPTS_DIR"
|
|
@@ -46,6 +58,7 @@ eagle_sessionstart_auto_curate "$project" "$SCRIPTS_DIR"
|
|
|
46
58
|
find "$EAGLE_MEM_DIR/read-tracker" -type f -mtime +1 -delete 2>/dev/null &
|
|
47
59
|
find "$EAGLE_MEM_DIR/mod-tracker" -type f -mtime +1 -delete 2>/dev/null &
|
|
48
60
|
find "$EAGLE_MEM_DIR/edit-tracker" -type f -mtime +1 -delete 2>/dev/null &
|
|
61
|
+
find "$EAGLE_MEM_DIR" -name ".turn-counter.*" -mtime +1 -delete 2>/dev/null &
|
|
49
62
|
|
|
50
63
|
# ─── Version check (non-blocking) ────────────────────────
|
|
51
64
|
|
package/hooks/stop.sh
CHANGED
|
@@ -127,6 +127,12 @@ fi
|
|
|
127
127
|
# ─── LLM enrichment: fill in decisions/gotchas/key_files ─────
|
|
128
128
|
# Check both local vars (from eagle-summary block) AND existing DB enrichment.
|
|
129
129
|
# Skip LLM call if either source already has enrichment data.
|
|
130
|
+
# Exception: under context pressure, force re-enrichment for richest summary.
|
|
131
|
+
|
|
132
|
+
context_pressure=0
|
|
133
|
+
if [ -f "$EAGLE_MEM_DIR/.context-pressure" ]; then
|
|
134
|
+
context_pressure=1
|
|
135
|
+
fi
|
|
130
136
|
|
|
131
137
|
existing_enrichment=""
|
|
132
138
|
if [ -z "$decisions" ] && [ -z "$gotchas" ] && [ -z "$key_files" ]; then
|
|
@@ -134,7 +140,7 @@ if [ -z "$decisions" ] && [ -z "$gotchas" ] && [ -z "$key_files" ]; then
|
|
|
134
140
|
existing_enrichment=$(eagle_db "SELECT decisions||gotchas||key_files FROM summaries WHERE session_id='$s_esc';")
|
|
135
141
|
fi
|
|
136
142
|
|
|
137
|
-
if [ -z "$decisions" ] && [ -z "$gotchas" ] && [ -z "$key_files" ] && [ -z "$existing_enrichment" ]; then
|
|
143
|
+
if [ -z "$decisions" ] && [ -z "$gotchas" ] && [ -z "$key_files" ] && { [ -z "$existing_enrichment" ] || [ "$context_pressure" -eq 1 ]; }; then
|
|
138
144
|
provider=$(eagle_config_get "provider" "type" "none" 2>/dev/null)
|
|
139
145
|
if [ "$provider" != "none" ] && [ -n "$text_content" ]; then
|
|
140
146
|
excerpt=$(echo "$text_content" | tail -c 2000)
|
|
@@ -25,9 +25,42 @@ user_prompt=$(echo "$input" | jq -r '.prompt // empty')
|
|
|
25
25
|
|
|
26
26
|
project=$(eagle_project_from_cwd "$cwd")
|
|
27
27
|
|
|
28
|
+
# ─── Context pressure detection (turn counter since last compact) ──
|
|
29
|
+
# Must run before any early exits so every prompt is counted
|
|
30
|
+
|
|
31
|
+
context=""
|
|
32
|
+
|
|
33
|
+
if [ -n "$session_id" ] && eagle_validate_session_id "$session_id"; then
|
|
34
|
+
counter_file="$EAGLE_MEM_DIR/.turn-counter.${session_id}"
|
|
35
|
+
turn_count=0
|
|
36
|
+
[ -f "$counter_file" ] && turn_count=$(cat "$counter_file" 2>/dev/null | tr -d '[:space:]')
|
|
37
|
+
turn_count=${turn_count:-0}
|
|
38
|
+
turn_count=$((turn_count + 1))
|
|
39
|
+
echo "$turn_count" > "$counter_file" 2>/dev/null
|
|
40
|
+
eagle_log "INFO" "UserPromptSubmit: turn=$turn_count session=$session_id"
|
|
41
|
+
|
|
42
|
+
if [ "$turn_count" -ge 30 ]; then
|
|
43
|
+
context+="
|
|
44
|
+
=== EAGLE MEM — Context Pressure: CRITICAL ($turn_count turns since compact) ===
|
|
45
|
+
IMMEDIATELY emit a detailed <eagle-summary> covering ALL work this session.
|
|
46
|
+
Tell the user to run /compact NOW to avoid losing context.
|
|
47
|
+
"
|
|
48
|
+
echo "$turn_count" > "$EAGLE_MEM_DIR/.context-pressure"
|
|
49
|
+
elif [ "$turn_count" -ge 20 ]; then
|
|
50
|
+
context+="
|
|
51
|
+
=== EAGLE MEM — Context Pressure: HIGH ($turn_count turns since compact) ===
|
|
52
|
+
Include a thorough <eagle-summary> in your next response — capture all decisions, gotchas, and learned context before compaction.
|
|
53
|
+
Suggest the user run /compact to free context for continued work.
|
|
54
|
+
"
|
|
55
|
+
echo "$turn_count" > "$EAGLE_MEM_DIR/.context-pressure"
|
|
56
|
+
else
|
|
57
|
+
rm -f "$EAGLE_MEM_DIR/.context-pressure" 2>/dev/null
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
|
|
28
61
|
# Skip short prompts — not enough signal for meaningful search
|
|
29
62
|
word_count=$(echo "$user_prompt" | wc -w | tr -d ' ')
|
|
30
|
-
[ "$word_count" -lt 3 ] && exit 0
|
|
63
|
+
[ "$word_count" -lt 3 ] && { [ -n "$context" ] && echo "$context"; exit 0; }
|
|
31
64
|
|
|
32
65
|
# Build FTS5 query from significant words (drop stop words, take first 6)
|
|
33
66
|
fts_query=$(echo "$user_prompt" | tr -cs '[:alnum:]' ' ' | tr '[:upper:]' '[:lower:]' | \
|
|
@@ -42,13 +75,11 @@ fts_query=$(echo "$user_prompt" | tr -cs '[:alnum:]' ' ' | tr '[:upper:]' '[:low
|
|
|
42
75
|
}
|
|
43
76
|
}')
|
|
44
77
|
|
|
45
|
-
[ -z "$fts_query" ] && exit 0
|
|
78
|
+
[ -z "$fts_query" ] && { [ -n "$context" ] && echo "$context"; exit 0; }
|
|
46
79
|
|
|
47
80
|
# Search for relevant past summaries (cross-session)
|
|
48
81
|
results=$(eagle_search_summaries "$fts_query" "$project" 3)
|
|
49
82
|
|
|
50
|
-
context=""
|
|
51
|
-
|
|
52
83
|
if [ -n "$results" ]; then
|
|
53
84
|
context+="=== EAGLE MEM — Relevant Memory ===
|
|
54
85
|
"
|