eagle-mem 4.9.6 → 4.9.8
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 +31 -4
- package/architecture.html +1791 -0
- package/bin/eagle-mem +1 -0
- package/db/migrate.sh +13 -2
- package/docs/visible-surface-ux-contract.md +53 -0
- package/hooks/post-tool-use.sh +2 -2
- package/hooks/pre-tool-use.sh +6 -6
- package/hooks/session-start.sh +216 -9
- package/hooks/user-prompt-submit.sh +72 -15
- package/lib/common.sh +485 -35
- package/lib/db-mirrors.sh +9 -18
- package/lib/db-sessions.sh +22 -15
- package/lib/db-summaries.sh +19 -7
- package/lib/hooks-posttool.sh +44 -10
- package/lib/updater.sh +12 -0
- package/package.json +4 -2
- package/scripts/doctor.sh +262 -0
- package/scripts/feature.sh +37 -11
- package/scripts/health.sh +10 -7
- package/scripts/help.sh +1 -0
- package/scripts/install.sh +9 -3
- package/scripts/memories.sh +258 -65
- package/scripts/orchestrate.sh +2 -2
- package/scripts/search.sh +240 -56
- package/scripts/statusline-em.sh +130 -26
- package/scripts/uninstall.sh +67 -0
- package/scripts/update.sh +8 -1
package/scripts/search.sh
CHANGED
|
@@ -34,6 +34,7 @@ show_help() {
|
|
|
34
34
|
echo -e " ${CYAN}-n, --limit${RESET} <N> Max results (default: 10)"
|
|
35
35
|
echo -e " ${CYAN}-a, --all${RESET} Search across all projects"
|
|
36
36
|
echo -e " ${CYAN}-j, --json${RESET} Output as JSON"
|
|
37
|
+
echo -e " ${CYAN}--raw, --debug${RESET} Show raw IDs and detailed observation rows"
|
|
37
38
|
echo ""
|
|
38
39
|
exit 0
|
|
39
40
|
}
|
|
@@ -42,9 +43,13 @@ show_help() {
|
|
|
42
43
|
|
|
43
44
|
mode="keyword"
|
|
44
45
|
project=""
|
|
46
|
+
project_was_explicit=false
|
|
47
|
+
project_scope=""
|
|
48
|
+
project_label=""
|
|
45
49
|
limit=10
|
|
46
50
|
session_id=""
|
|
47
51
|
json_output=false
|
|
52
|
+
raw_output=false
|
|
48
53
|
query=""
|
|
49
54
|
cross_project=false
|
|
50
55
|
|
|
@@ -57,10 +62,11 @@ while [ $# -gt 0 ]; do
|
|
|
57
62
|
--overview|-o) mode="overview"; shift ;;
|
|
58
63
|
--memories|-m) mode="memories"; shift ;;
|
|
59
64
|
--tasks) mode="tasks"; shift ;;
|
|
60
|
-
--project|-p) project="$2"; shift 2 ;;
|
|
65
|
+
--project|-p) project="$2"; project_was_explicit=true; shift 2 ;;
|
|
61
66
|
--limit|-n) limit="$2"; shift 2 ;;
|
|
62
67
|
--all|-a) cross_project=true; shift ;;
|
|
63
68
|
--json|-j) json_output=true; shift ;;
|
|
69
|
+
--raw|--debug) raw_output=true; shift ;;
|
|
64
70
|
--help|-h) show_help ;;
|
|
65
71
|
-*)
|
|
66
72
|
eagle_err "Unknown option: $1"
|
|
@@ -72,6 +78,12 @@ while [ $# -gt 0 ]; do
|
|
|
72
78
|
done
|
|
73
79
|
|
|
74
80
|
[ -z "$project" ] && project=$(eagle_project_from_cwd "$(pwd)")
|
|
81
|
+
project_scope="$project"
|
|
82
|
+
if [ "$cross_project" = false ] && [ "$project_was_explicit" = false ]; then
|
|
83
|
+
project_scope=$(eagle_recall_project_scope_from_cwd "$(pwd)" "$project")
|
|
84
|
+
fi
|
|
85
|
+
project_label=$(eagle_project_scope_label "$project_scope")
|
|
86
|
+
[ -z "$project_label" ] && project_label="$project"
|
|
75
87
|
limit=$(eagle_sql_int "$limit")
|
|
76
88
|
[ "$limit" -eq 0 ] && limit=10
|
|
77
89
|
|
|
@@ -85,31 +97,66 @@ search_keyword() {
|
|
|
85
97
|
exit 1
|
|
86
98
|
fi
|
|
87
99
|
local q; q=$(eagle_sql_escape "$sanitized_q")
|
|
88
|
-
local
|
|
100
|
+
local project_condition
|
|
101
|
+
project_condition=$(eagle_sql_project_scope_condition "s.project" "$project_scope")
|
|
89
102
|
|
|
90
103
|
local where_project=""
|
|
91
104
|
if [ "$cross_project" = false ]; then
|
|
92
|
-
where_project="AND
|
|
105
|
+
where_project="AND $project_condition"
|
|
93
106
|
fi
|
|
94
107
|
|
|
95
108
|
if [ "$json_output" = true ]; then
|
|
96
|
-
eagle_db_json "SELECT s.id, s.project, s.agent, s.request, s.completed, s.learned, s.created_at
|
|
109
|
+
eagle_db_json "SELECT s.id, s.project, s.agent, s.request, s.completed, s.learned, s.created_at,
|
|
110
|
+
CASE
|
|
111
|
+
WHEN julianday('now') - julianday(s.created_at) <= 14 THEN 'Fresh'
|
|
112
|
+
WHEN julianday('now') - julianday(s.created_at) <= 45 THEN 'Recent'
|
|
113
|
+
ELSE 'Older'
|
|
114
|
+
END AS freshness
|
|
97
115
|
FROM summaries s
|
|
98
116
|
JOIN summaries_fts f ON f.rowid = s.id
|
|
99
117
|
WHERE summaries_fts MATCH '$q'
|
|
118
|
+
AND COALESCE(s.request, '') NOT LIKE '%<local-command-caveat>%'
|
|
119
|
+
AND COALESCE(s.request, '') NOT LIKE '# AGENTS.md instructions%'
|
|
120
|
+
AND COALESCE(s.request, '') NOT LIKE '<environment_context>%'
|
|
121
|
+
AND COALESCE(s.request, '') NOT LIKE '<subagent_notification>%'
|
|
122
|
+
AND COALESCE(s.request, '') NOT LIKE '</subagent_notification>%'
|
|
100
123
|
$where_project
|
|
101
|
-
ORDER BY
|
|
124
|
+
ORDER BY
|
|
125
|
+
CASE
|
|
126
|
+
WHEN julianday('now') - julianday(s.created_at) <= 14 THEN 0
|
|
127
|
+
WHEN julianday('now') - julianday(s.created_at) <= 45 THEN 1
|
|
128
|
+
ELSE 2
|
|
129
|
+
END,
|
|
130
|
+
s.created_at DESC,
|
|
131
|
+
rank
|
|
102
132
|
LIMIT $limit;"
|
|
103
133
|
return
|
|
104
134
|
fi
|
|
105
135
|
|
|
106
136
|
local results
|
|
107
|
-
results=$(eagle_db "SELECT s.id, s.project, s.agent, s.request, s.completed, s.learned, s.created_at
|
|
137
|
+
results=$(eagle_db "SELECT s.id, s.project, s.agent, s.request, s.completed, s.learned, s.created_at,
|
|
138
|
+
CASE
|
|
139
|
+
WHEN julianday('now') - julianday(s.created_at) <= 14 THEN 'Fresh'
|
|
140
|
+
WHEN julianday('now') - julianday(s.created_at) <= 45 THEN 'Recent'
|
|
141
|
+
ELSE 'Older'
|
|
142
|
+
END AS freshness
|
|
108
143
|
FROM summaries s
|
|
109
144
|
JOIN summaries_fts f ON f.rowid = s.id
|
|
110
145
|
WHERE summaries_fts MATCH '$q'
|
|
146
|
+
AND COALESCE(s.request, '') NOT LIKE '%<local-command-caveat>%'
|
|
147
|
+
AND COALESCE(s.request, '') NOT LIKE '# AGENTS.md instructions%'
|
|
148
|
+
AND COALESCE(s.request, '') NOT LIKE '<environment_context>%'
|
|
149
|
+
AND COALESCE(s.request, '') NOT LIKE '<subagent_notification>%'
|
|
150
|
+
AND COALESCE(s.request, '') NOT LIKE '</subagent_notification>%'
|
|
111
151
|
$where_project
|
|
112
|
-
ORDER BY
|
|
152
|
+
ORDER BY
|
|
153
|
+
CASE
|
|
154
|
+
WHEN julianday('now') - julianday(s.created_at) <= 14 THEN 0
|
|
155
|
+
WHEN julianday('now') - julianday(s.created_at) <= 45 THEN 1
|
|
156
|
+
ELSE 2
|
|
157
|
+
END,
|
|
158
|
+
s.created_at DESC,
|
|
159
|
+
rank
|
|
113
160
|
LIMIT $limit;")
|
|
114
161
|
|
|
115
162
|
if [ -z "$results" ]; then
|
|
@@ -118,29 +165,31 @@ search_keyword() {
|
|
|
118
165
|
fi
|
|
119
166
|
|
|
120
167
|
echo ""
|
|
121
|
-
|
|
168
|
+
local idx=1
|
|
169
|
+
while IFS='|' read -r sid sproj sagent req completed learned created_at freshness; do
|
|
122
170
|
[ -z "$sid" ] && continue
|
|
123
|
-
echo -e " ${BOLD}
|
|
171
|
+
echo -e " ${BOLD}${idx}. ${req:-Memory match}${RESET}"
|
|
172
|
+
echo -e " ${DIM}source:${RESET} $(eagle_agent_label "$sagent") ${DIM}date:${RESET} $created_at ${DIM}freshness:${RESET} $freshness"
|
|
124
173
|
if [ "$cross_project" = true ]; then
|
|
125
174
|
echo -e " ${DIM}project:${RESET} $sproj"
|
|
126
175
|
fi
|
|
127
|
-
echo -e " ${DIM}source:${RESET} $(eagle_agent_label "$sagent")"
|
|
128
|
-
[ -n "$req" ] && echo -e " ${CYAN}Request:${RESET} $req"
|
|
129
176
|
[ -n "$completed" ] && echo -e " ${GREEN}Done:${RESET} $completed"
|
|
130
177
|
[ -n "$learned" ] && echo -e " ${YELLOW}Learned:${RESET} $learned"
|
|
131
178
|
echo ""
|
|
179
|
+
idx=$((idx + 1))
|
|
132
180
|
done <<< "$results"
|
|
133
181
|
}
|
|
134
182
|
|
|
135
183
|
# ─── Timeline ────────────────────────────────────────────
|
|
136
184
|
|
|
137
185
|
search_timeline() {
|
|
138
|
-
local
|
|
186
|
+
local project_condition
|
|
187
|
+
project_condition=$(eagle_sql_project_scope_condition "s.project" "$project_scope")
|
|
139
188
|
|
|
140
189
|
if [ "$json_output" = true ]; then
|
|
141
190
|
eagle_db_json "SELECT s.id, s.agent, s.request, s.completed, s.learned, s.next_steps, s.created_at
|
|
142
191
|
FROM summaries s
|
|
143
|
-
WHERE
|
|
192
|
+
WHERE $project_condition
|
|
144
193
|
ORDER BY s.created_at DESC
|
|
145
194
|
LIMIT $limit;"
|
|
146
195
|
return
|
|
@@ -149,7 +198,7 @@ search_timeline() {
|
|
|
149
198
|
local results
|
|
150
199
|
results=$(eagle_db "SELECT s.id, s.agent, s.request, s.completed, s.learned, s.next_steps, s.created_at
|
|
151
200
|
FROM summaries s
|
|
152
|
-
WHERE
|
|
201
|
+
WHERE $project_condition
|
|
153
202
|
ORDER BY s.created_at DESC
|
|
154
203
|
LIMIT $limit;")
|
|
155
204
|
|
|
@@ -159,25 +208,49 @@ search_timeline() {
|
|
|
159
208
|
fi
|
|
160
209
|
|
|
161
210
|
echo ""
|
|
162
|
-
echo -e " ${BOLD}Recent sessions${RESET} ${DIM}($
|
|
211
|
+
echo -e " ${BOLD}Recent sessions${RESET} ${DIM}($project_label)${RESET}"
|
|
163
212
|
echo -e " ${DIM}─────────────────────────────────────${RESET}"
|
|
164
213
|
echo ""
|
|
165
214
|
|
|
215
|
+
local idx=1
|
|
166
216
|
while IFS='|' read -r sid sagent req completed learned next_steps created_at; do
|
|
167
217
|
[ -z "$sid" ] && continue
|
|
168
|
-
|
|
218
|
+
if [ "$raw_output" = true ]; then
|
|
219
|
+
echo -e " ${BOLD}#$sid${RESET} ${DIM}$created_at${RESET}"
|
|
220
|
+
else
|
|
221
|
+
echo -e " ${BOLD}${idx}. Session summary${RESET} ${DIM}$created_at${RESET}"
|
|
222
|
+
fi
|
|
169
223
|
echo -e " ${DIM}source:${RESET} $(eagle_agent_label "$sagent")"
|
|
170
224
|
[ -n "$req" ] && echo -e " ${CYAN}Request:${RESET} $req"
|
|
171
225
|
[ -n "$completed" ] && echo -e " ${GREEN}Done:${RESET} $completed"
|
|
172
226
|
[ -n "$learned" ] && echo -e " ${YELLOW}Learned:${RESET} $learned"
|
|
173
227
|
[ -n "$next_steps" ] && echo -e " ${DIM}Next:${RESET} $next_steps"
|
|
174
228
|
echo ""
|
|
229
|
+
idx=$((idx + 1))
|
|
175
230
|
done <<< "$results"
|
|
231
|
+
if [ "$raw_output" = false ]; then
|
|
232
|
+
eagle_dim "Run with --raw to show summary IDs."
|
|
233
|
+
fi
|
|
176
234
|
}
|
|
177
235
|
|
|
178
236
|
# ─── Session details ──────────────────────────────────────
|
|
179
237
|
|
|
180
238
|
search_session() {
|
|
239
|
+
if [ -z "$session_id" ]; then
|
|
240
|
+
eagle_err "Usage: eagle-mem search --session <session-id-or-summary-id>"
|
|
241
|
+
exit 1
|
|
242
|
+
fi
|
|
243
|
+
|
|
244
|
+
local lookup_sql resolved_session
|
|
245
|
+
lookup_sql=$(eagle_sql_escape "$session_id")
|
|
246
|
+
case "$session_id" in
|
|
247
|
+
*[!0-9]*) ;;
|
|
248
|
+
*)
|
|
249
|
+
resolved_session=$(eagle_db "SELECT session_id FROM summaries WHERE id = '$lookup_sql' LIMIT 1;" 2>/dev/null | awk 'NF { print; exit }')
|
|
250
|
+
[ -n "$resolved_session" ] && session_id="$resolved_session"
|
|
251
|
+
;;
|
|
252
|
+
esac
|
|
253
|
+
|
|
181
254
|
local sid_sql; sid_sql=$(eagle_sql_escape "$session_id")
|
|
182
255
|
|
|
183
256
|
if [ "$json_output" = true ]; then
|
|
@@ -188,33 +261,111 @@ search_session() {
|
|
|
188
261
|
return
|
|
189
262
|
fi
|
|
190
263
|
|
|
191
|
-
local
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
264
|
+
local results_json
|
|
265
|
+
results_json=$(eagle_db_json "SELECT o.agent, o.tool_name, o.tool_input_summary, o.files_read, o.files_modified, o.created_at
|
|
266
|
+
FROM observations o
|
|
267
|
+
WHERE o.session_id = '$sid_sql'
|
|
268
|
+
ORDER BY o.created_at ASC;")
|
|
196
269
|
|
|
197
|
-
if [ -z "$
|
|
270
|
+
if [ -z "$results_json" ] || [ "$(printf '%s' "$results_json" | jq 'length' 2>/dev/null)" = "0" ]; then
|
|
198
271
|
eagle_dim "No observations found for session '$session_id'"
|
|
199
272
|
return
|
|
200
273
|
fi
|
|
201
274
|
|
|
275
|
+
if [ "$raw_output" = true ]; then
|
|
276
|
+
echo ""
|
|
277
|
+
echo -e " ${BOLD}Session${RESET} ${DIM}$session_id${RESET}"
|
|
278
|
+
echo -e " ${DIM}─────────────────────────────────────${RESET}"
|
|
279
|
+
echo ""
|
|
280
|
+
|
|
281
|
+
printf '%s' "$results_json" | jq -c '.[]' | while IFS= read -r row; do
|
|
282
|
+
oagent=$(printf '%s' "$row" | jq -r '.agent // ""')
|
|
283
|
+
tool_name=$(printf '%s' "$row" | jq -r '.tool_name // ""')
|
|
284
|
+
summary=$(printf '%s' "$row" | jq -r '.tool_input_summary // ""')
|
|
285
|
+
created_at=$(printf '%s' "$row" | jq -r '.created_at // ""')
|
|
286
|
+
[ -z "$tool_name" ] && continue
|
|
287
|
+
local icon="$DOT"
|
|
288
|
+
case "$tool_name" in
|
|
289
|
+
Read) icon="${CYAN}R${RESET}" ;;
|
|
290
|
+
Write) icon="${GREEN}W${RESET}" ;;
|
|
291
|
+
Edit) icon="${YELLOW}E${RESET}" ;;
|
|
292
|
+
Bash|exec_command|shell_command|unified_exec) icon="${BLUE}\$${RESET}" ;;
|
|
293
|
+
esac
|
|
294
|
+
echo -e " ${icon} ${DIM}$created_at $(eagle_agent_label "$oagent")${RESET} $summary"
|
|
295
|
+
done
|
|
296
|
+
echo ""
|
|
297
|
+
return
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
local first_seen last_seen total_obs agent_counts tool_counts
|
|
301
|
+
first_seen=$(eagle_db "SELECT MIN(created_at) FROM observations WHERE session_id = '$sid_sql';")
|
|
302
|
+
last_seen=$(eagle_db "SELECT MAX(created_at) FROM observations WHERE session_id = '$sid_sql';")
|
|
303
|
+
total_obs=$(printf '%s' "$results_json" | jq 'length' 2>/dev/null)
|
|
304
|
+
agent_counts=$(eagle_db "SELECT agent || ':' || COUNT(*) FROM observations WHERE session_id = '$sid_sql' GROUP BY agent ORDER BY COUNT(*) DESC;")
|
|
305
|
+
tool_counts=$(eagle_db "SELECT tool_name || ':' || COUNT(*) FROM observations WHERE session_id = '$sid_sql' GROUP BY tool_name ORDER BY COUNT(*) DESC LIMIT 8;")
|
|
306
|
+
|
|
202
307
|
echo ""
|
|
203
|
-
echo -e " ${BOLD}Session
|
|
308
|
+
echo -e " ${BOLD}Session Activity${RESET}"
|
|
204
309
|
echo -e " ${DIM}─────────────────────────────────────${RESET}"
|
|
205
310
|
echo ""
|
|
206
|
-
|
|
207
|
-
|
|
311
|
+
eagle_kv "Observations:" "${total_obs:-0}"
|
|
312
|
+
[ -n "$first_seen" ] && eagle_kv "Started:" "$first_seen"
|
|
313
|
+
[ -n "$last_seen" ] && eagle_kv "Last seen:" "$last_seen"
|
|
314
|
+
if [ -n "$agent_counts" ]; then
|
|
315
|
+
local agents_display=""
|
|
316
|
+
while IFS=':' read -r a count; do
|
|
317
|
+
[ -z "$a" ] && continue
|
|
318
|
+
[ -n "$agents_display" ] && agents_display+=", "
|
|
319
|
+
agents_display+="$(eagle_agent_label "$a") $count"
|
|
320
|
+
done <<< "$agent_counts"
|
|
321
|
+
[ -n "$agents_display" ] && eagle_kv "Agents:" "$agents_display"
|
|
322
|
+
fi
|
|
323
|
+
if [ -n "$tool_counts" ]; then
|
|
324
|
+
local tools_display=""
|
|
325
|
+
while IFS=':' read -r t count; do
|
|
326
|
+
[ -z "$t" ] && continue
|
|
327
|
+
[ -n "$tools_display" ] && tools_display+=", "
|
|
328
|
+
tools_display+="$t $count"
|
|
329
|
+
done <<< "$tool_counts"
|
|
330
|
+
[ -n "$tools_display" ] && eagle_kv "Tools:" "$tools_display"
|
|
331
|
+
fi
|
|
332
|
+
echo ""
|
|
333
|
+
echo -e " ${BOLD}Recent activity${RESET}"
|
|
334
|
+
|
|
335
|
+
printf '%s' "$results_json" | jq -c --argjson limit "$limit" '.[-$limit:][]' | while IFS= read -r row; do
|
|
336
|
+
oagent=$(printf '%s' "$row" | jq -r '.agent // ""')
|
|
337
|
+
tool_name=$(printf '%s' "$row" | jq -r '.tool_name // ""')
|
|
338
|
+
summary=$(printf '%s' "$row" | jq -r '.tool_input_summary // ""')
|
|
339
|
+
files_r=$(printf '%s' "$row" | jq -r '.files_read // "[]"')
|
|
340
|
+
files_m=$(printf '%s' "$row" | jq -r '.files_modified // "[]"')
|
|
341
|
+
created_at=$(printf '%s' "$row" | jq -r '.created_at // ""')
|
|
208
342
|
[ -z "$tool_name" ] && continue
|
|
209
|
-
local
|
|
343
|
+
local label detail
|
|
344
|
+
label="$tool_name"
|
|
345
|
+
detail=$(eagle_trim_text "$summary" 120)
|
|
210
346
|
case "$tool_name" in
|
|
211
|
-
Read)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
347
|
+
Read)
|
|
348
|
+
label="Read"
|
|
349
|
+
detail=$(printf '%s' "$files_r" | jq -r 'fromjson? | .[0] // empty' 2>/dev/null)
|
|
350
|
+
[ -n "$detail" ] && detail=$(basename "$detail")
|
|
351
|
+
;;
|
|
352
|
+
Write|Edit)
|
|
353
|
+
label="$tool_name"
|
|
354
|
+
detail=$(printf '%s' "$files_m" | jq -r 'fromjson? | .[0] // empty' 2>/dev/null)
|
|
355
|
+
[ -n "$detail" ] && detail=$(basename "$detail")
|
|
356
|
+
;;
|
|
357
|
+
apply_patch)
|
|
358
|
+
label="Patch"
|
|
359
|
+
;;
|
|
360
|
+
Bash|exec_command|shell_command|unified_exec)
|
|
361
|
+
label="Command"
|
|
362
|
+
;;
|
|
215
363
|
esac
|
|
216
|
-
|
|
217
|
-
|
|
364
|
+
[ -z "$detail" ] && detail="$(eagle_agent_label "$oagent") activity"
|
|
365
|
+
echo -e " ${DOT} ${DIM}$created_at${RESET} ${BOLD}$label:${RESET} $detail"
|
|
366
|
+
done
|
|
367
|
+
echo ""
|
|
368
|
+
eagle_dim "Run with --raw for full observation rows and session ID."
|
|
218
369
|
echo ""
|
|
219
370
|
}
|
|
220
371
|
|
|
@@ -261,20 +412,25 @@ search_files() {
|
|
|
261
412
|
# ─── Stats ────────────────────────────────────────────────
|
|
262
413
|
|
|
263
414
|
search_stats() {
|
|
264
|
-
local
|
|
415
|
+
local sessions_condition summaries_condition observations_condition tasks_condition chunks_condition
|
|
416
|
+
sessions_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
417
|
+
summaries_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
418
|
+
observations_condition=$(eagle_sql_project_scope_condition "s.project" "$project_scope")
|
|
419
|
+
tasks_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
420
|
+
chunks_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
265
421
|
|
|
266
422
|
local sessions sessions_claude sessions_codex summaries observations tasks
|
|
267
|
-
sessions=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE
|
|
268
|
-
sessions_claude=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE
|
|
269
|
-
sessions_codex=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE
|
|
270
|
-
summaries=$(eagle_db "SELECT COUNT(*) FROM summaries WHERE
|
|
271
|
-
observations=$(eagle_db "SELECT COUNT(*) FROM observations o JOIN sessions s ON s.id = o.session_id WHERE
|
|
272
|
-
tasks=$(eagle_db "SELECT COUNT(*) FROM agent_tasks WHERE
|
|
423
|
+
sessions=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE $sessions_condition;")
|
|
424
|
+
sessions_claude=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE $sessions_condition AND agent = 'claude-code';")
|
|
425
|
+
sessions_codex=$(eagle_db "SELECT COUNT(*) FROM sessions WHERE $sessions_condition AND agent = 'codex';")
|
|
426
|
+
summaries=$(eagle_db "SELECT COUNT(*) FROM summaries WHERE $summaries_condition;")
|
|
427
|
+
observations=$(eagle_db "SELECT COUNT(*) FROM observations o JOIN sessions s ON s.id = o.session_id WHERE $observations_condition;")
|
|
428
|
+
tasks=$(eagle_db "SELECT COUNT(*) FROM agent_tasks WHERE $tasks_condition;")
|
|
273
429
|
local chunks
|
|
274
|
-
chunks=$(eagle_db "SELECT COUNT(*) FROM code_chunks WHERE
|
|
430
|
+
chunks=$(eagle_db "SELECT COUNT(*) FROM code_chunks WHERE $chunks_condition;")
|
|
275
431
|
|
|
276
432
|
if [ "$json_output" = true ]; then
|
|
277
|
-
jq -nc --arg project "$
|
|
433
|
+
jq -nc --arg project "$project_label" \
|
|
278
434
|
--argjson sessions "${sessions:-0}" \
|
|
279
435
|
--argjson sessions_claude "${sessions_claude:-0}" \
|
|
280
436
|
--argjson sessions_codex "${sessions_codex:-0}" \
|
|
@@ -287,7 +443,7 @@ search_stats() {
|
|
|
287
443
|
fi
|
|
288
444
|
|
|
289
445
|
echo ""
|
|
290
|
-
echo -e " ${BOLD}Stats${RESET} ${DIM}($
|
|
446
|
+
echo -e " ${BOLD}Stats${RESET} ${DIM}($project_label)${RESET}"
|
|
291
447
|
echo -e " ${DIM}─────────────────────────────────────${RESET}"
|
|
292
448
|
echo ""
|
|
293
449
|
eagle_kv "Sessions:" "${sessions:-0}"
|
|
@@ -334,11 +490,13 @@ search_overview() {
|
|
|
334
490
|
# ─── Memories ────────────────────────────────────────────
|
|
335
491
|
|
|
336
492
|
search_memories() {
|
|
337
|
-
local
|
|
493
|
+
local project_condition memory_condition
|
|
494
|
+
project_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
495
|
+
memory_condition=$(eagle_sql_project_scope_condition "m.project" "$project_scope")
|
|
338
496
|
|
|
339
497
|
local where_project=""
|
|
340
498
|
if [ "$cross_project" = false ]; then
|
|
341
|
-
where_project="WHERE
|
|
499
|
+
where_project="WHERE $project_condition"
|
|
342
500
|
fi
|
|
343
501
|
|
|
344
502
|
if [ -n "$query" ]; then
|
|
@@ -351,25 +509,49 @@ search_memories() {
|
|
|
351
509
|
local q; q=$(eagle_sql_escape "$sanitized_mq")
|
|
352
510
|
local where_match="WHERE agent_memories_fts MATCH '$q'"
|
|
353
511
|
if [ "$cross_project" = false ]; then
|
|
354
|
-
where_match="$where_match AND
|
|
512
|
+
where_match="$where_match AND $memory_condition"
|
|
355
513
|
fi
|
|
356
514
|
|
|
357
515
|
if [ "$json_output" = true ]; then
|
|
358
|
-
eagle_db_json "SELECT m.memory_name, m.memory_type, m.description, m.project, m.updated_at, m.origin_agent
|
|
516
|
+
eagle_db_json "SELECT m.memory_name, m.memory_type, m.description, m.project, m.updated_at, m.origin_agent,
|
|
517
|
+
CASE
|
|
518
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 14 THEN 'Fresh'
|
|
519
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 45 THEN 'Recent'
|
|
520
|
+
ELSE 'Older'
|
|
521
|
+
END AS freshness
|
|
359
522
|
FROM agent_memories m
|
|
360
523
|
JOIN agent_memories_fts f ON f.rowid = m.id
|
|
361
524
|
$where_match
|
|
362
|
-
ORDER BY
|
|
525
|
+
ORDER BY
|
|
526
|
+
CASE
|
|
527
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 14 THEN 0
|
|
528
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 45 THEN 1
|
|
529
|
+
ELSE 2
|
|
530
|
+
END,
|
|
531
|
+
m.updated_at DESC,
|
|
532
|
+
rank
|
|
363
533
|
LIMIT $limit;"
|
|
364
534
|
return
|
|
365
535
|
fi
|
|
366
536
|
|
|
367
537
|
local results
|
|
368
|
-
results=$(eagle_db "SELECT m.memory_name, m.memory_type, m.description, m.project, m.updated_at, m.origin_agent
|
|
538
|
+
results=$(eagle_db "SELECT m.memory_name, m.memory_type, m.description, m.project, m.updated_at, m.origin_agent,
|
|
539
|
+
CASE
|
|
540
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 14 THEN 'Fresh'
|
|
541
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 45 THEN 'Recent'
|
|
542
|
+
ELSE 'Older'
|
|
543
|
+
END AS freshness
|
|
369
544
|
FROM agent_memories m
|
|
370
545
|
JOIN agent_memories_fts f ON f.rowid = m.id
|
|
371
546
|
$where_match
|
|
372
|
-
ORDER BY
|
|
547
|
+
ORDER BY
|
|
548
|
+
CASE
|
|
549
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 14 THEN 0
|
|
550
|
+
WHEN julianday('now') - julianday(m.updated_at) <= 45 THEN 1
|
|
551
|
+
ELSE 2
|
|
552
|
+
END,
|
|
553
|
+
m.updated_at DESC,
|
|
554
|
+
rank
|
|
373
555
|
LIMIT $limit;")
|
|
374
556
|
|
|
375
557
|
if [ -z "$results" ]; then
|
|
@@ -378,9 +560,9 @@ search_memories() {
|
|
|
378
560
|
fi
|
|
379
561
|
|
|
380
562
|
echo ""
|
|
381
|
-
while IFS='|' read -r mname mtype mdesc mproj mupdated morigin; do
|
|
563
|
+
while IFS='|' read -r mname mtype mdesc mproj mupdated morigin freshness; do
|
|
382
564
|
[ -z "$mname" ] && continue
|
|
383
|
-
echo -e " ${BOLD}$mname${RESET} ${DIM}[$mtype][$(eagle_agent_label "$morigin")]${RESET}"
|
|
565
|
+
echo -e " ${BOLD}$mname${RESET} ${DIM}[$mtype][$(eagle_agent_label "$morigin")][$freshness]${RESET}"
|
|
384
566
|
[ "$cross_project" = true ] && echo -e " ${DIM}project:${RESET} $mproj"
|
|
385
567
|
[ -n "$mdesc" ] && echo -e " $mdesc"
|
|
386
568
|
echo ""
|
|
@@ -406,7 +588,7 @@ search_memories() {
|
|
|
406
588
|
fi
|
|
407
589
|
|
|
408
590
|
echo ""
|
|
409
|
-
echo -e " ${BOLD}Memories${RESET} ${DIM}($
|
|
591
|
+
echo -e " ${BOLD}Memories${RESET} ${DIM}($project_label)${RESET}"
|
|
410
592
|
echo -e " ${DIM}─────────────────────────────────────${RESET}"
|
|
411
593
|
echo ""
|
|
412
594
|
|
|
@@ -421,13 +603,15 @@ search_memories() {
|
|
|
421
603
|
# ─── Tasks ───────────────────────────────────────────────
|
|
422
604
|
|
|
423
605
|
search_tasks() {
|
|
424
|
-
local
|
|
606
|
+
local task_condition bare_task_condition
|
|
607
|
+
task_condition=$(eagle_sql_project_scope_condition "t.project" "$project_scope")
|
|
608
|
+
bare_task_condition=$(eagle_sql_project_scope_condition "project" "$project_scope")
|
|
425
609
|
|
|
426
610
|
local where_project=""
|
|
427
611
|
local where_task_project=""
|
|
428
612
|
if [ "$cross_project" = false ]; then
|
|
429
|
-
where_project="AND
|
|
430
|
-
where_task_project="AND
|
|
613
|
+
where_project="AND $bare_task_condition"
|
|
614
|
+
where_task_project="AND $task_condition"
|
|
431
615
|
fi
|
|
432
616
|
|
|
433
617
|
if [ -n "$query" ]; then
|
|
@@ -498,7 +682,7 @@ search_tasks() {
|
|
|
498
682
|
LIMIT $limit;")
|
|
499
683
|
|
|
500
684
|
if [ -z "$results" ]; then
|
|
501
|
-
eagle_dim "No active tasks for project '$
|
|
685
|
+
eagle_dim "No active tasks for project '$project_label'"
|
|
502
686
|
return
|
|
503
687
|
fi
|
|
504
688
|
|