eagle-mem 4.2.0 → 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/user-prompt-submit.sh +35 -33
- package/package.json +1 -1
|
@@ -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
|
"
|
|
@@ -87,35 +118,6 @@ if [ "${has_chunks:-0}" -gt 0 ]; then
|
|
|
87
118
|
fi
|
|
88
119
|
fi
|
|
89
120
|
|
|
90
|
-
# ─── Context pressure detection (turn counter since last compact) ──
|
|
91
|
-
|
|
92
|
-
if [ -n "$session_id" ] && eagle_validate_session_id "$session_id"; then
|
|
93
|
-
counter_file="$EAGLE_MEM_DIR/.turn-counter.${session_id}"
|
|
94
|
-
turn_count=0
|
|
95
|
-
[ -f "$counter_file" ] && turn_count=$(cat "$counter_file" 2>/dev/null | tr -d '[:space:]')
|
|
96
|
-
turn_count=${turn_count:-0}
|
|
97
|
-
turn_count=$((turn_count + 1))
|
|
98
|
-
echo "$turn_count" > "$counter_file" 2>/dev/null
|
|
99
|
-
|
|
100
|
-
if [ "$turn_count" -ge 30 ]; then
|
|
101
|
-
context+="
|
|
102
|
-
=== EAGLE MEM — Context Pressure: CRITICAL ($turn_count turns since compact) ===
|
|
103
|
-
IMMEDIATELY emit a detailed <eagle-summary> covering ALL work this session.
|
|
104
|
-
Tell the user to run /compact NOW to avoid losing context.
|
|
105
|
-
"
|
|
106
|
-
echo "$turn_count" > "$EAGLE_MEM_DIR/.context-pressure"
|
|
107
|
-
elif [ "$turn_count" -ge 20 ]; then
|
|
108
|
-
context+="
|
|
109
|
-
=== EAGLE MEM — Context Pressure: HIGH ($turn_count turns since compact) ===
|
|
110
|
-
Include a thorough <eagle-summary> in your next response — capture all decisions, gotchas, and learned context before compaction.
|
|
111
|
-
Suggest the user run /compact to free context for continued work.
|
|
112
|
-
"
|
|
113
|
-
echo "$turn_count" > "$EAGLE_MEM_DIR/.context-pressure"
|
|
114
|
-
else
|
|
115
|
-
rm -f "$EAGLE_MEM_DIR/.context-pressure" 2>/dev/null
|
|
116
|
-
fi
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
121
|
[ -z "$context" ] && exit 0
|
|
120
122
|
|
|
121
123
|
context+="
|