eagle-mem 3.3.0 → 4.0.0
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 +34 -132
- package/bin/eagle-mem +2 -11
- package/hooks/session-start.sh +50 -70
- package/lib/hooks-sessionstart.sh +89 -0
- package/lib/provider.sh +2 -2
- package/package.json +1 -1
- package/scripts/help.sh +8 -20
- package/skills/eagle-mem-overview/SKILL.md +8 -8
- package/skills/eagle-mem-index/SKILL.md +0 -120
- package/skills/eagle-mem-prune/SKILL.md +0 -131
- package/skills/eagle-mem-scan/SKILL.md +0 -116
package/README.md
CHANGED
|
@@ -12,150 +12,49 @@ Persistent memory for [Claude Code](https://docs.anthropic.com/en/docs/claude-co
|
|
|
12
12
|
|
|
13
13
|
## Getting started
|
|
14
14
|
|
|
15
|
-
**1. Install** (once — this is the only setup step):
|
|
16
|
-
|
|
17
15
|
```bash
|
|
18
16
|
npm install -g eagle-mem
|
|
19
17
|
eagle-mem install
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
That's it. Open Claude Code in any project directory. Eagle Mem activates automatically:
|
|
23
21
|
|
|
24
22
|
```
|
|
25
23
|
======================================
|
|
26
24
|
Eagle Mem Loaded
|
|
27
25
|
======================================
|
|
28
26
|
Project | my-app
|
|
29
|
-
Sessions | 42
|
|
27
|
+
Sessions | 42 (18 with summaries)
|
|
30
28
|
Memories | 7 stored
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Code Index | 156 chunks indexed
|
|
34
|
-
Observations | 340 captured
|
|
35
|
-
Last Active | 2026-04-28
|
|
29
|
+
Tasks | 1 in progress, 3 pending
|
|
30
|
+
Code Index | 156 chunks
|
|
36
31
|
Last Work | Added auth middleware with JWT validation
|
|
37
32
|
======================================
|
|
38
33
|
```
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
**3. Already have Claude Code history on a project?** Run this inside the project directory:
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
cd ~/projects/my-app
|
|
46
|
-
eagle-mem refresh
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This backfills everything into Eagle Mem:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
Eagle Mem Refresh
|
|
53
|
-
─────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
Step 1/4: Scanning codebase structure...
|
|
56
|
-
✓ 120 files found
|
|
57
|
-
✓ Languages: TypeScript (15k lines), CSS (2k lines)
|
|
58
|
-
✓ Frameworks: Next.js, React, Tailwind, Prisma
|
|
59
|
-
✓ Scan complete
|
|
60
|
-
|
|
61
|
-
Step 2/4: Indexing source files...
|
|
62
|
-
✓ Index complete
|
|
63
|
-
|
|
64
|
-
Step 3/4: Syncing Claude Code memories, plans, and tasks...
|
|
65
|
-
✓ Memory sync complete
|
|
66
|
-
|
|
67
|
-
Step 4/4: Verifying...
|
|
68
|
-
Sessions: 12
|
|
69
|
-
Code chunks: 340
|
|
70
|
-
Memories: 8
|
|
71
|
-
Tasks: 15
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Now open Claude Code in that project — it sees your full history from the start.
|
|
35
|
+
Everything is automatic from here. Eagle Mem scans your codebase, indexes source files, captures session summaries, mirrors Claude's memories and tasks, learns which commands are noisy, and prunes stale data — all in the background via hooks.
|
|
75
36
|
|
|
76
37
|
## Commands
|
|
77
38
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
### Search past sessions
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
eagle-mem search "auth middleware"
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Searches across session summaries, Claude memories, and indexed code using FTS5. Use this when you know you worked on something last week but can't remember the details.
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
eagle-mem search --timeline
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Shows your most recent sessions in chronological order — useful for catching up after a break.
|
|
93
|
-
|
|
94
|
-
### View or set your project overview
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
eagle-mem overview
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Shows the overview that gets injected into every Claude Code session. This is what Claude reads first to understand your project.
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
eagle-mem overview set "My app is a Next.js dashboard for monitoring API health..."
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
Set a custom overview. You can also let Claude write one for you by running `/eagle-mem-overview` inside a Claude Code session — it reads your README, entry points, and git history to synthesize one.
|
|
107
|
-
|
|
108
|
-
### Sync everything
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
eagle-mem refresh
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Run this inside a project directory after major changes (new packages, restructured directories, pulling a large branch). It re-scans the codebase, re-indexes source files, and syncs any new Claude Code memories and tasks.
|
|
115
|
-
|
|
116
|
-
### Other commands
|
|
39
|
+
Six commands. Three for lifecycle, three for when you need to look something up or troubleshoot.
|
|
117
40
|
|
|
118
|
-
| Command |
|
|
119
|
-
|
|
120
|
-
| `eagle-mem
|
|
121
|
-
| `eagle-mem
|
|
122
|
-
| `eagle-mem
|
|
123
|
-
| `eagle-mem
|
|
124
|
-
| `eagle-mem
|
|
41
|
+
| Command | What it does |
|
|
42
|
+
|---------|-------------|
|
|
43
|
+
| `eagle-mem install` | First-time setup: hooks, database, skills |
|
|
44
|
+
| `eagle-mem update` | Re-deploy hooks and run migrations after `npm update` |
|
|
45
|
+
| `eagle-mem uninstall` | Remove hooks and optionally delete data |
|
|
46
|
+
| `eagle-mem search "query"` | Search past sessions, memories, and code (FTS5) |
|
|
47
|
+
| `eagle-mem health` | Diagnose pipeline health and background automation |
|
|
48
|
+
| `eagle-mem config` | View or change LLM provider settings |
|
|
125
49
|
|
|
126
50
|
## Skills (inside Claude Code)
|
|
127
51
|
|
|
128
|
-
Inside a Claude Code session, you have slash commands that let Claude do the work for you:
|
|
129
|
-
|
|
130
|
-
### `/eagle-mem-search`
|
|
131
|
-
|
|
132
|
-
Search past sessions from within Claude Code. Claude interprets results and connects them to your current work — better than raw terminal search when you need context, not just a match.
|
|
133
|
-
|
|
134
|
-
### `/eagle-mem-overview`
|
|
135
|
-
|
|
136
|
-
Build a rich project briefing. Claude reads your README, entry points, recent git history, and current codebase to write a 2-3 paragraph overview that captures what the project *does*, not just its file counts. This overview is injected at every session start.
|
|
137
|
-
|
|
138
|
-
### `/eagle-mem-tasks`
|
|
139
|
-
|
|
140
|
-
Break complex work into tasks that survive `/compact`. Uses Claude Code's native `TaskCreate`/`TaskUpdate` with dependency support. When context fills up and you compact, Eagle Mem re-injects the task state so Claude picks up where it left off.
|
|
141
|
-
|
|
142
|
-
### Other skills
|
|
143
|
-
|
|
144
52
|
| Skill | What it does |
|
|
145
53
|
|-------|-------------|
|
|
146
|
-
| `/eagle-mem-
|
|
147
|
-
| `/eagle-mem-
|
|
148
|
-
| `/eagle-mem-memories` | View
|
|
149
|
-
| `/eagle-mem-
|
|
150
|
-
|
|
151
|
-
## Updating
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
npm update -g eagle-mem
|
|
155
|
-
eagle-mem update
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
The `update` command copies new files, runs any pending database migrations, and re-registers hooks. Your data is preserved.
|
|
54
|
+
| `/eagle-mem-search` | Search memory and past sessions — Claude interprets results in context |
|
|
55
|
+
| `/eagle-mem-overview` | Build a rich project briefing from README, entry points, and git history |
|
|
56
|
+
| `/eagle-mem-memories` | View and search mirrored Claude Code memories and plans |
|
|
57
|
+
| `/eagle-mem-tasks` | TaskAware Compact Loop — break complex work into tasks that survive `/compact` |
|
|
159
58
|
|
|
160
59
|
## How it works
|
|
161
60
|
|
|
@@ -163,44 +62,47 @@ Six hooks fire automatically at different points in Claude Code's lifecycle:
|
|
|
163
62
|
|
|
164
63
|
| Hook | Fires when | What it does |
|
|
165
64
|
|------|-----------|--------------|
|
|
166
|
-
| **SessionStart** | startup, resume, clear, compact | Injects overview, summaries, memories, tasks |
|
|
65
|
+
| **SessionStart** | startup, resume, clear, compact | Injects overview, summaries, memories, tasks. Auto-provisions new projects (scan, index). |
|
|
167
66
|
| **PreToolUse** | before Bash and Read calls | Rewrites noisy commands (learned rules), detects redundant reads |
|
|
168
67
|
| **UserPromptSubmit** | user sends a message | FTS5 search for relevant past context |
|
|
169
68
|
| **PostToolUse** | after tool calls | Records file touches, mirrors memory/plan/task writes, tracks modifications |
|
|
170
69
|
| **Stop** | Claude's turn ends | Extracts `<eagle-summary>`, strips `<private>` tags |
|
|
171
70
|
| **SessionEnd** | session closes | Re-syncs tasks, marks session completed |
|
|
172
71
|
|
|
72
|
+
### Background automation
|
|
73
|
+
|
|
74
|
+
These run automatically via SessionStart — no commands needed:
|
|
75
|
+
|
|
76
|
+
- **Auto-scan** — new project with no overview triggers a codebase scan
|
|
77
|
+
- **Auto-index** — new or stale project triggers FTS5 source indexing
|
|
78
|
+
- **Auto-prune** — observations over 10K rows trigger cleanup
|
|
79
|
+
- **Auto-curate** — the self-learning curator analyzes observation data and generates project-specific command rules (requires LLM provider)
|
|
80
|
+
|
|
173
81
|
### Token savings
|
|
174
82
|
|
|
175
83
|
Eagle Mem actively reduces token consumption:
|
|
176
84
|
|
|
177
|
-
- **
|
|
178
|
-
- **
|
|
179
|
-
- **Read
|
|
85
|
+
- **Injection compression** — zero-value stats are elided from the banner, overview is capped, compact reloads get 1 recent session instead of 3
|
|
86
|
+
- **Command rewriting** — PreToolUse rewrites noisy Bash commands to pipe through `head -N` via `updatedInput`. Rules are learned by the curator from real usage, not hardcoded.
|
|
87
|
+
- **Read-after-modify detection** — detects when you read a file that was just edited or written, nudges that the diff is already in context
|
|
88
|
+
- **Read dedup tracking** — files read 3+ times in a session get a soft nudge
|
|
180
89
|
|
|
181
90
|
### Data
|
|
182
91
|
|
|
183
|
-
|
|
92
|
+
Single SQLite database at `~/.eagle-mem/memory.db` (WAL mode, FTS5 full-text search):
|
|
184
93
|
|
|
185
94
|
| Table | What it stores |
|
|
186
95
|
|-------|---------------|
|
|
187
96
|
| sessions | Active/completed sessions per project |
|
|
188
97
|
| summaries | Per-session summaries (FTS5-indexed) |
|
|
189
98
|
| observations | Per-tool-use file touch records |
|
|
190
|
-
| overviews | One overview per project (scan or manual) |
|
|
99
|
+
| overviews | One overview per project (auto-scan or manual) |
|
|
191
100
|
| code_chunks | FTS5-indexed source file chunks |
|
|
192
101
|
| command_rules | Curator-learned command output rules |
|
|
193
102
|
| claude_memories | Mirror of Claude Code auto-memories |
|
|
194
103
|
| claude_plans | Mirror of Claude Code plans |
|
|
195
104
|
| claude_tasks | Mirror of Claude Code tasks |
|
|
196
105
|
|
|
197
|
-
## Uninstall
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
eagle-mem uninstall
|
|
201
|
-
npm uninstall -g eagle-mem
|
|
202
|
-
```
|
|
203
|
-
|
|
204
106
|
## Prerequisites
|
|
205
107
|
|
|
206
108
|
- `sqlite3` with FTS5 support (ships with macOS; the installer offers to install if missing)
|
package/bin/eagle-mem
CHANGED
|
@@ -17,20 +17,11 @@ shift 2>/dev/null || true
|
|
|
17
17
|
|
|
18
18
|
case "$command" in
|
|
19
19
|
install) bash "$SCRIPTS_DIR/install.sh" "$PACKAGE_DIR" "$@" ;;
|
|
20
|
-
uninstall) bash "$SCRIPTS_DIR/uninstall.sh" "$@" ;;
|
|
21
20
|
update) bash "$SCRIPTS_DIR/update.sh" "$PACKAGE_DIR" "$@" ;;
|
|
22
|
-
|
|
23
|
-
index) bash "$SCRIPTS_DIR/index.sh" "$@" ;;
|
|
21
|
+
uninstall) bash "$SCRIPTS_DIR/uninstall.sh" "$@" ;;
|
|
24
22
|
search) bash "$SCRIPTS_DIR/search.sh" "$@" ;;
|
|
25
|
-
tasks) bash "$SCRIPTS_DIR/tasks.sh" "$@" ;;
|
|
26
|
-
overview) bash "$SCRIPTS_DIR/overview.sh" "$@" ;;
|
|
27
|
-
refresh) bash "$SCRIPTS_DIR/refresh.sh" "$@" ;;
|
|
28
|
-
prune) bash "$SCRIPTS_DIR/prune.sh" "$@" ;;
|
|
29
|
-
memories) bash "$SCRIPTS_DIR/memories.sh" "$@" ;;
|
|
30
|
-
config) bash "$SCRIPTS_DIR/config.sh" "$@" ;;
|
|
31
|
-
curate) bash "$SCRIPTS_DIR/curate.sh" "$@" ;;
|
|
32
|
-
feature) bash "$SCRIPTS_DIR/feature.sh" "$@" ;;
|
|
33
23
|
health) bash "$SCRIPTS_DIR/health.sh" "$@" ;;
|
|
24
|
+
config) bash "$SCRIPTS_DIR/config.sh" "$@" ;;
|
|
34
25
|
help|--help|-h)
|
|
35
26
|
bash "$SCRIPTS_DIR/help.sh" ;;
|
|
36
27
|
version|--version|-v|-V)
|
package/hooks/session-start.sh
CHANGED
|
@@ -13,6 +13,7 @@ SCRIPTS_DIR="$SCRIPT_DIR/../scripts"
|
|
|
13
13
|
. "$LIB_DIR/common.sh"
|
|
14
14
|
. "$LIB_DIR/db.sh"
|
|
15
15
|
. "$LIB_DIR/provider.sh"
|
|
16
|
+
. "$LIB_DIR/hooks-sessionstart.sh"
|
|
16
17
|
|
|
17
18
|
eagle_ensure_db
|
|
18
19
|
|
|
@@ -27,8 +28,6 @@ model=$(echo "$input" | jq -r '.model // empty')
|
|
|
27
28
|
[ -z "$session_id" ] && exit 0
|
|
28
29
|
|
|
29
30
|
project=$(eagle_project_from_cwd "$cwd")
|
|
30
|
-
|
|
31
|
-
# Skip ephemeral directories (tmp, Downloads, etc.) — no tracking
|
|
32
31
|
[ -z "$project" ] && exit 0
|
|
33
32
|
|
|
34
33
|
p_esc=$(eagle_sql_escape "$project")
|
|
@@ -36,36 +35,18 @@ p_esc=$(eagle_sql_escape "$project")
|
|
|
36
35
|
eagle_log "INFO" "SessionStart: session=$session_id project=$project source=$source_type"
|
|
37
36
|
|
|
38
37
|
eagle_upsert_session "$session_id" "$project" "$cwd" "$model" "$source_type"
|
|
39
|
-
|
|
40
|
-
# ─── Sweep stuck sessions (no activity for 7 days) ─────────
|
|
41
|
-
# Uses last_activity_at (updated by trigger on every observation insert)
|
|
42
|
-
# so long-lived sessions with regular compactions aren't falsely abandoned
|
|
43
38
|
eagle_abandon_stale_sessions "$session_id"
|
|
44
39
|
|
|
45
|
-
# ───
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_curator_provider=$(eagle_config_get "provider" "type" "none")
|
|
51
|
-
if [ "$_curator_provider" != "none" ]; then
|
|
52
|
-
_min_sessions=$(eagle_config_get "curator" "min_sessions" "5")
|
|
53
|
-
_min_sessions=$(eagle_sql_int "$_min_sessions")
|
|
54
|
-
_last_curated=$(eagle_meta_get "last_curated_at" "$project")
|
|
55
|
-
_since="${_last_curated:-1970-01-01T00:00:00Z}"
|
|
56
|
-
_sessions_since=$(eagle_count_sessions_since "$project" "$_since")
|
|
57
|
-
if [ "${_sessions_since:-0}" -ge "$_min_sessions" ]; then
|
|
58
|
-
eagle_log "INFO" "SessionStart: auto-curate triggered (${_sessions_since} sessions since last curate)"
|
|
59
|
-
nohup bash "$SCRIPTS_DIR/curate.sh" -p "$project" >> "$EAGLE_MEM_LOG" 2>&1 &
|
|
60
|
-
fi
|
|
61
|
-
fi
|
|
62
|
-
fi
|
|
40
|
+
# ─── Background automation (non-blocking) ────────────────
|
|
41
|
+
|
|
42
|
+
eagle_sessionstart_auto_provision "$project" "$cwd" "$SCRIPTS_DIR"
|
|
43
|
+
eagle_sessionstart_auto_prune "$project" "$SCRIPTS_DIR" "$(eagle_db "SELECT COUNT(*) FROM observations WHERE session_id IN (SELECT id FROM sessions WHERE project='$p_esc');")"
|
|
44
|
+
eagle_sessionstart_auto_curate "$project" "$SCRIPTS_DIR"
|
|
63
45
|
|
|
64
|
-
# ─── Cleanup stale tracker files (non-blocking) ─────────────
|
|
65
46
|
find "$EAGLE_MEM_DIR/read-tracker" -type f -mtime +1 -delete 2>/dev/null &
|
|
66
47
|
find "$EAGLE_MEM_DIR/mod-tracker" -type f -mtime +1 -delete 2>/dev/null &
|
|
67
48
|
|
|
68
|
-
# ─── Version check (non-blocking)
|
|
49
|
+
# ─── Version check (non-blocking) ────────────────────────
|
|
69
50
|
|
|
70
51
|
update_notice=""
|
|
71
52
|
version_file="$EAGLE_MEM_DIR/.version"
|
|
@@ -93,7 +74,7 @@ if [ -f "$version_file" ] && [ -s "$version_file" ]; then
|
|
|
93
74
|
fi
|
|
94
75
|
fi
|
|
95
76
|
|
|
96
|
-
# ─── Gather stats
|
|
77
|
+
# ─── Gather stats ────────────────────────────────────────
|
|
97
78
|
|
|
98
79
|
stat_sessions=0; stat_summaries=0; stat_with_summaries=0; stat_memories=0
|
|
99
80
|
stat_tasks_pending=0; stat_tasks_progress=0; stat_tasks_done=0
|
|
@@ -117,7 +98,8 @@ while IFS='|' read -r key val; do
|
|
|
117
98
|
esac
|
|
118
99
|
done <<< "$(eagle_get_project_stats "$project")"
|
|
119
100
|
|
|
120
|
-
# Build
|
|
101
|
+
# ─── Build compressed banner (elide zero-value lines) ────
|
|
102
|
+
|
|
121
103
|
task_parts=""
|
|
122
104
|
[ "$stat_tasks_progress" -gt 0 ] && task_parts="${stat_tasks_progress} in progress"
|
|
123
105
|
if [ "$stat_tasks_pending" -gt 0 ]; then
|
|
@@ -128,27 +110,26 @@ if [ "$stat_tasks_done" -gt 0 ]; then
|
|
|
128
110
|
[ -n "$task_parts" ] && task_parts+=", "
|
|
129
111
|
task_parts+="${stat_tasks_done} completed"
|
|
130
112
|
fi
|
|
131
|
-
[ -z "$task_parts" ] && task_parts="none"
|
|
132
113
|
|
|
133
|
-
# Truncate last summary for display
|
|
134
114
|
stat_last_display="${stat_last_summary:0:60}"
|
|
135
115
|
[ ${#stat_last_summary} -gt 60 ] && stat_last_display+="..."
|
|
136
|
-
[ -z "$stat_last_display" ] && stat_last_display="(no sessions yet)"
|
|
137
|
-
|
|
138
|
-
# ─── Build context injection ────────────────────────────────
|
|
139
116
|
|
|
140
117
|
eagle_banner="======================================
|
|
141
118
|
Eagle Mem Loaded
|
|
142
119
|
======================================
|
|
143
120
|
Project | $project
|
|
144
|
-
Sessions | $stat_sessions
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
121
|
+
Sessions | $stat_sessions ($stat_with_summaries with summaries)"
|
|
122
|
+
[ "$stat_memories" -gt 0 ] && eagle_banner+="
|
|
123
|
+
Memories | $stat_memories stored"
|
|
124
|
+
[ "$stat_plans" -gt 0 ] && eagle_banner+="
|
|
125
|
+
Plans | $stat_plans saved"
|
|
126
|
+
[ -n "$task_parts" ] && eagle_banner+="
|
|
127
|
+
Tasks | $task_parts"
|
|
128
|
+
[ "$stat_chunks" -gt 0 ] && eagle_banner+="
|
|
129
|
+
Code Index | $stat_chunks chunks"
|
|
130
|
+
[ -n "$stat_last_display" ] && eagle_banner+="
|
|
131
|
+
Last Work | $stat_last_display"
|
|
132
|
+
eagle_banner+="
|
|
152
133
|
======================================"
|
|
153
134
|
|
|
154
135
|
context="$eagle_banner
|
|
@@ -160,22 +141,33 @@ if [ -n "$update_notice" ]; then
|
|
|
160
141
|
"
|
|
161
142
|
fi
|
|
162
143
|
|
|
163
|
-
# Project overview
|
|
144
|
+
# ─── Project overview (capped at 500 chars) ──────────────
|
|
145
|
+
|
|
164
146
|
overview=$(eagle_get_overview "$project")
|
|
165
147
|
if [ -n "$overview" ]; then
|
|
148
|
+
if [ ${#overview} -gt 500 ]; then
|
|
149
|
+
overview="${overview:0:497}..."
|
|
150
|
+
fi
|
|
166
151
|
context+="
|
|
167
|
-
===
|
|
152
|
+
=== Overview ===
|
|
168
153
|
$overview
|
|
169
154
|
"
|
|
170
155
|
else
|
|
171
156
|
context+="
|
|
172
|
-
===
|
|
173
|
-
No overview
|
|
157
|
+
=== New Project ===
|
|
158
|
+
No overview yet — auto-scan is running. Run /eagle-mem-overview for a richer briefing.
|
|
174
159
|
"
|
|
175
160
|
fi
|
|
176
161
|
|
|
177
|
-
# Recent
|
|
178
|
-
|
|
162
|
+
# ─── Recent sessions (1 on compact, 3 on startup) ────────
|
|
163
|
+
|
|
164
|
+
if [ "$source_type" = "compact" ] || [ "$source_type" = "clear" ]; then
|
|
165
|
+
_summary_limit=1
|
|
166
|
+
else
|
|
167
|
+
_summary_limit=3
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
recent=$(eagle_get_recent_summaries "$project" "$_summary_limit")
|
|
179
171
|
|
|
180
172
|
if [ -n "$recent" ]; then
|
|
181
173
|
context+="
|
|
@@ -204,7 +196,7 @@ Next steps: $next_steps"
|
|
|
204
196
|
"
|
|
205
197
|
fi
|
|
206
198
|
|
|
207
|
-
# ───
|
|
199
|
+
# ─── Memories (skip if none) ─────────────────────────────
|
|
208
200
|
|
|
209
201
|
memories=$(eagle_db "SELECT memory_name, memory_type, description, file_path, updated_at,
|
|
210
202
|
CAST(julianday('now') - julianday(updated_at) AS INTEGER) as days_ago
|
|
@@ -233,7 +225,7 @@ if [ -n "$memories" ]; then
|
|
|
233
225
|
done <<< "$memories"
|
|
234
226
|
fi
|
|
235
227
|
|
|
236
|
-
# ───
|
|
228
|
+
# ─── Plans (skip if none) ────────────────────────────────
|
|
237
229
|
|
|
238
230
|
plans=$(eagle_list_claude_plans "$project" 3)
|
|
239
231
|
if [ -n "$plans" ]; then
|
|
@@ -247,7 +239,7 @@ if [ -n "$plans" ]; then
|
|
|
247
239
|
done <<< "$plans"
|
|
248
240
|
fi
|
|
249
241
|
|
|
250
|
-
# ───
|
|
242
|
+
# ─── Tasks (skip if none) ────────────────────────────────
|
|
251
243
|
|
|
252
244
|
synced_tasks=$(eagle_db "SELECT subject, status, blocked_by FROM claude_tasks
|
|
253
245
|
WHERE project = '$p_esc'
|
|
@@ -272,39 +264,27 @@ if [ -n "$synced_tasks" ]; then
|
|
|
272
264
|
done <<< "$synced_tasks"
|
|
273
265
|
fi
|
|
274
266
|
|
|
275
|
-
# ─── Instructions (
|
|
267
|
+
# ─── Instructions (compressed) ───────────────────────────
|
|
276
268
|
|
|
277
269
|
if [ "$source_type" = "compact" ] || [ "$source_type" = "clear" ]; then
|
|
278
270
|
context+="
|
|
279
|
-
=== Eagle Mem
|
|
280
|
-
|
|
271
|
+
=== Eagle Mem ===
|
|
272
|
+
Memory active. Attribute recalled context to Eagle Mem. Do not revert PostToolUse-surfaced decisions without asking. Emit <eagle-summary> before final response.
|
|
281
273
|
"
|
|
282
274
|
else
|
|
283
275
|
context+="
|
|
284
276
|
=== Eagle Mem ===
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
Emit an <eagle-summary> block before your FINAL response:
|
|
277
|
+
Memory active for '$project'. Scan, index, prune, and self-learning run automatically — never ask the user to run these. Attribute recalled context: \"Eagle Mem recalls:\" Do not revert PostToolUse-surfaced decisions without user request. No raw secrets in summaries. If you contradict a loaded memory, update the memory file.
|
|
288
278
|
|
|
279
|
+
Before your final response, emit:
|
|
289
280
|
<eagle-summary>
|
|
290
|
-
request: [what
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
completed: [what shipped — be specific]
|
|
294
|
-
next_steps: [concrete actions for next session]
|
|
295
|
-
decisions:
|
|
296
|
-
- [choice] Why: [reason]
|
|
297
|
-
gotchas:
|
|
298
|
-
- [what failed or surprised — \"X doesn't work because Y\"]
|
|
299
|
-
key_files:
|
|
300
|
-
- [path] — [role in this work]
|
|
301
|
-
files_read: [file1, file2]
|
|
302
|
-
files_modified: [file1, file2]
|
|
281
|
+
request: [what user asked] | completed: [what shipped] | learned: [non-obvious discoveries]
|
|
282
|
+
next_steps: [concrete actions] | decisions: [choice — why] | gotchas: [what surprised]
|
|
283
|
+
key_files: [path — role] | files_read: [...] | files_modified: [...]
|
|
303
284
|
</eagle-summary>
|
|
304
285
|
"
|
|
305
286
|
fi
|
|
306
287
|
|
|
307
|
-
# Output context (plain text stdout = additionalContext for SessionStart)
|
|
308
288
|
if [ -n "$context" ]; then
|
|
309
289
|
echo "$context"
|
|
310
290
|
fi
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ═══════════════════════════════════════════════════════════
|
|
3
|
+
# Eagle Mem — SessionStart extracted automation
|
|
4
|
+
# Source from hooks/session-start.sh after common.sh + db.sh
|
|
5
|
+
# ═══════════════════════════════════════════════════════════
|
|
6
|
+
[ -n "${_EAGLE_HOOKS_SESSIONSTART_LOADED:-}" ] && return 0
|
|
7
|
+
_EAGLE_HOOKS_SESSIONSTART_LOADED=1
|
|
8
|
+
|
|
9
|
+
_state_dir="$EAGLE_MEM_DIR/state"
|
|
10
|
+
|
|
11
|
+
_eagle_state_fresh() {
|
|
12
|
+
local key="$1" project="$2" max_age_days="${3:-1}"
|
|
13
|
+
local state_file="$_state_dir/${key}-${project}"
|
|
14
|
+
[ -f "$state_file" ] && [ -z "$(find "$state_file" -mtime +${max_age_days} 2>/dev/null)" ]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_eagle_state_touch() {
|
|
18
|
+
local key="$1" project="$2"
|
|
19
|
+
mkdir -p "$_state_dir" 2>/dev/null
|
|
20
|
+
touch "$_state_dir/${key}-${project}"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
eagle_sessionstart_auto_provision() {
|
|
24
|
+
local project="$1" cwd="$2" scripts_dir="$3"
|
|
25
|
+
local needs_scan=false needs_index=false
|
|
26
|
+
|
|
27
|
+
# Auto-scan: no overview exists
|
|
28
|
+
local overview
|
|
29
|
+
overview=$(eagle_get_overview "$project")
|
|
30
|
+
if [ -z "$overview" ] && ! _eagle_state_fresh "scan" "$project" 1; then
|
|
31
|
+
needs_scan=true
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# Auto-index: 0 chunks or stale > 7 days
|
|
35
|
+
local chunk_count
|
|
36
|
+
chunk_count=$(eagle_db "SELECT COUNT(*) FROM code_chunks WHERE project = '$(eagle_sql_escape "$project")';" 2>/dev/null)
|
|
37
|
+
chunk_count=${chunk_count:-0}
|
|
38
|
+
if [ "$chunk_count" -eq 0 ] && ! _eagle_state_fresh "index" "$project" 1; then
|
|
39
|
+
needs_index=true
|
|
40
|
+
elif [ "$chunk_count" -gt 0 ] && ! _eagle_state_fresh "index" "$project" 7; then
|
|
41
|
+
needs_index=true
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
if [ "$needs_scan" = true ] && [ "$needs_index" = true ]; then
|
|
45
|
+
eagle_log "INFO" "SessionStart: first-session provision — scan then index"
|
|
46
|
+
_eagle_state_touch "scan" "$project"
|
|
47
|
+
_eagle_state_touch "index" "$project"
|
|
48
|
+
nohup bash -c "bash '$scripts_dir/scan.sh' '$cwd' >> '$EAGLE_MEM_LOG' 2>&1; bash '$scripts_dir/index.sh' '$cwd' >> '$EAGLE_MEM_LOG' 2>&1" &
|
|
49
|
+
elif [ "$needs_scan" = true ]; then
|
|
50
|
+
eagle_log "INFO" "SessionStart: auto-scan triggered"
|
|
51
|
+
_eagle_state_touch "scan" "$project"
|
|
52
|
+
nohup bash "$scripts_dir/scan.sh" "$cwd" >> "$EAGLE_MEM_LOG" 2>&1 &
|
|
53
|
+
elif [ "$needs_index" = true ]; then
|
|
54
|
+
eagle_log "INFO" "SessionStart: auto-index triggered"
|
|
55
|
+
_eagle_state_touch "index" "$project"
|
|
56
|
+
nohup bash "$scripts_dir/index.sh" "$cwd" >> "$EAGLE_MEM_LOG" 2>&1 &
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
eagle_sessionstart_auto_prune() {
|
|
61
|
+
local project="$1" scripts_dir="$2" observation_count="$3"
|
|
62
|
+
if [ "${observation_count:-0}" -gt 10000 ] && ! _eagle_state_fresh "prune" "$project" 1; then
|
|
63
|
+
eagle_log "INFO" "SessionStart: auto-prune triggered (${observation_count} observations)"
|
|
64
|
+
_eagle_state_touch "prune" "$project"
|
|
65
|
+
nohup bash "$scripts_dir/prune.sh" -p "$project" >> "$EAGLE_MEM_LOG" 2>&1 &
|
|
66
|
+
fi
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
eagle_sessionstart_auto_curate() {
|
|
70
|
+
local project="$1" scripts_dir="$2"
|
|
71
|
+
local curator_schedule
|
|
72
|
+
curator_schedule=$(eagle_config_get "curator" "schedule" "manual")
|
|
73
|
+
if [ "$curator_schedule" = "auto" ]; then
|
|
74
|
+
local _provider
|
|
75
|
+
_provider=$(eagle_config_get "provider" "type" "none")
|
|
76
|
+
if [ "$_provider" != "none" ]; then
|
|
77
|
+
local _min_sessions _last_curated _since _sessions_since
|
|
78
|
+
_min_sessions=$(eagle_config_get "curator" "min_sessions" "5")
|
|
79
|
+
_min_sessions=$(eagle_sql_int "$_min_sessions")
|
|
80
|
+
_last_curated=$(eagle_meta_get "last_curated_at" "$project")
|
|
81
|
+
_since="${_last_curated:-1970-01-01T00:00:00Z}"
|
|
82
|
+
_sessions_since=$(eagle_count_sessions_since "$project" "$_since")
|
|
83
|
+
if [ "${_sessions_since:-0}" -ge "$_min_sessions" ]; then
|
|
84
|
+
eagle_log "INFO" "SessionStart: auto-curate triggered (${_sessions_since} sessions since last curate)"
|
|
85
|
+
nohup bash "$scripts_dir/curate.sh" -p "$project" >> "$EAGLE_MEM_LOG" 2>&1 &
|
|
86
|
+
fi
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
}
|
package/lib/provider.sh
CHANGED
|
@@ -151,8 +151,8 @@ model = "claude-haiku-4-5-20251001"
|
|
|
151
151
|
model = "gpt-4o-mini"
|
|
152
152
|
|
|
153
153
|
[curator]
|
|
154
|
-
# "auto" = triggers at session
|
|
155
|
-
schedule = "
|
|
154
|
+
# "auto" = triggers at session start after min_sessions; "manual" = CLI only
|
|
155
|
+
schedule = "auto"
|
|
156
156
|
min_sessions = 5
|
|
157
157
|
|
|
158
158
|
[redaction]
|
package/package.json
CHANGED
package/scripts/help.sh
CHANGED
|
@@ -16,38 +16,26 @@ echo -e " ${BOLD}Eagle Mem${RESET} ${DIM}v${version}${RESET}"
|
|
|
16
16
|
echo -e " ${DIM}Persistent memory for Claude Code${RESET}"
|
|
17
17
|
echo ""
|
|
18
18
|
echo -e " ${BOLD}Commands:${RESET}"
|
|
19
|
-
echo -e " ${CYAN}search${RESET} Search past sessions, memories, and code"
|
|
20
|
-
echo -e " ${CYAN}overview${RESET} View or set project overview"
|
|
21
|
-
echo -e " ${CYAN}scan${RESET} Analyze codebase structure"
|
|
22
|
-
echo -e " ${CYAN}index${RESET} Index source files for FTS5 code search"
|
|
23
|
-
echo -e " ${CYAN}memories${RESET} View/sync mirrored Claude Code memories"
|
|
24
|
-
echo -e " ${CYAN}tasks${RESET} View mirrored Claude Code tasks"
|
|
25
|
-
echo -e " ${CYAN}refresh${RESET} Full project sync: scan (if needed) + index + memories"
|
|
26
|
-
echo -e " ${CYAN}prune${RESET} Remove old observations and orphaned chunks"
|
|
27
|
-
echo -e " ${CYAN}config${RESET} View or change LLM provider settings"
|
|
28
|
-
echo -e " ${CYAN}curate${RESET} Run the self-learning curator (LLM-powered analysis)"
|
|
29
|
-
echo -e " ${CYAN}feature${RESET} Manage feature graph (list/show/verify/add)"
|
|
30
|
-
echo -e " ${CYAN}health${RESET} Diagnose self-learning pipeline health"
|
|
31
19
|
echo -e " ${CYAN}install${RESET} First-time setup: hooks, database, skills"
|
|
32
20
|
echo -e " ${CYAN}update${RESET} Re-deploy hooks and run migrations"
|
|
33
21
|
echo -e " ${CYAN}uninstall${RESET} Remove hooks and optionally delete data"
|
|
22
|
+
echo -e " ${CYAN}search${RESET} Search past sessions, memories, and code"
|
|
23
|
+
echo -e " ${CYAN}health${RESET} Diagnose pipeline health and background automation"
|
|
24
|
+
echo -e " ${CYAN}config${RESET} View or change LLM provider settings"
|
|
34
25
|
echo ""
|
|
35
26
|
echo -e " ${BOLD}Examples:${RESET}"
|
|
36
|
-
echo -e " ${DIM}\$${RESET} eagle-mem search \"auth bug\" ${DIM}# keyword search${RESET}"
|
|
37
|
-
echo -e " ${DIM}\$${RESET} eagle-mem search --timeline ${DIM}# recent sessions${RESET}"
|
|
38
|
-
echo -e " ${DIM}\$${RESET} eagle-mem refresh ${DIM}# full project sync${RESET}"
|
|
39
|
-
echo -e " ${DIM}\$${RESET} eagle-mem overview ${DIM}# view overview${RESET}"
|
|
40
|
-
echo -e " ${DIM}\$${RESET} eagle-mem prune --dry-run ${DIM}# preview cleanup${RESET}"
|
|
41
27
|
echo -e " ${DIM}\$${RESET} eagle-mem install ${DIM}# first-time setup${RESET}"
|
|
28
|
+
echo -e " ${DIM}\$${RESET} eagle-mem search \"auth bug\" ${DIM}# keyword search${RESET}"
|
|
29
|
+
echo -e " ${DIM}\$${RESET} eagle-mem health ${DIM}# check pipeline${RESET}"
|
|
42
30
|
echo ""
|
|
43
31
|
echo -e " ${BOLD}Skills${RESET} ${DIM}(inside Claude Code sessions):${RESET}"
|
|
44
32
|
echo -e " ${CYAN}/eagle-mem-search${RESET} Search memory and past sessions"
|
|
45
33
|
echo -e " ${CYAN}/eagle-mem-overview${RESET} Build or update project overview"
|
|
46
|
-
echo -e " ${CYAN}/eagle-mem-scan${RESET} Analyze codebase structure"
|
|
47
|
-
echo -e " ${CYAN}/eagle-mem-index${RESET} Index source files for code search"
|
|
48
34
|
echo -e " ${CYAN}/eagle-mem-memories${RESET} View/sync Claude Code memories"
|
|
49
35
|
echo -e " ${CYAN}/eagle-mem-tasks${RESET} TaskAware Compact Loop for multi-step work"
|
|
50
|
-
echo
|
|
36
|
+
echo ""
|
|
37
|
+
echo -e " ${DIM}Everything else is automatic — scan, index, prune, and${RESET}"
|
|
38
|
+
echo -e " ${DIM}curator all run in the background via hooks.${RESET}"
|
|
51
39
|
echo ""
|
|
52
40
|
echo -e " ${DIM}https://github.com/eagleisbatman/eagle-mem${RESET}"
|
|
53
41
|
echo ""
|
|
@@ -17,11 +17,12 @@ description: >
|
|
|
17
17
|
## Judgment
|
|
18
18
|
|
|
19
19
|
**Build an overview when:**
|
|
20
|
-
- SessionStart
|
|
21
|
-
- The current overview reads like scan metadata (file counts, directory listings) — upgrade it
|
|
20
|
+
- SessionStart shows a scan-generated overview (file counts, directory listings) — upgrade it to a rich briefing
|
|
22
21
|
- The user asks: "update overview", "summarize this project", "what is this project"
|
|
23
22
|
- The project has changed significantly since the last overview (new major feature, architecture shift)
|
|
24
23
|
|
|
24
|
+
Note: New projects are auto-scanned at SessionStart. The scan produces structural metadata. This skill upgrades that into a briefing with intent, architecture, and current state.
|
|
25
|
+
|
|
25
26
|
**Don't rebuild when:**
|
|
26
27
|
- The overview is already rich and current — just use it
|
|
27
28
|
- The user needs help with a specific task — do the task first, update overview after if needed
|
|
@@ -64,11 +65,7 @@ If the output is empty or doesn't match what you wrote, the save failed. Retry o
|
|
|
64
65
|
|
|
65
66
|
### 4. Fallback for empty repos
|
|
66
67
|
|
|
67
|
-
If no readable source files exist (fresh repo, no README),
|
|
68
|
-
```bash
|
|
69
|
-
eagle-mem scan .
|
|
70
|
-
```
|
|
71
|
-
Then tell the user: "I've generated a structural overview from scan. Once you add a README or source code, re-run `/eagle-mem-overview` for a richer briefing."
|
|
68
|
+
If no readable source files exist (fresh repo, no README), Eagle Mem's auto-scan has already generated a structural overview in the background. Tell the user: "Auto-scan has captured the project structure. Once you add a README or source code, re-run `/eagle-mem-overview` for a richer briefing."
|
|
72
69
|
|
|
73
70
|
## What makes a good overview
|
|
74
71
|
|
|
@@ -86,6 +83,10 @@ A good overview lets a fresh Claude Code context window give useful answers with
|
|
|
86
83
|
**Bad:**
|
|
87
84
|
> eagle-mem: Node.js project (42 files, ~5k lines). Structure: bin/ (1), db/ (10), hooks/ (5), lib/ (3), scripts/ (13), skills/ (7). Entry: bin/eagle-mem. No tests detected.
|
|
88
85
|
|
|
86
|
+
## How automation works
|
|
87
|
+
|
|
88
|
+
Eagle Mem v4.0 auto-scans new projects at SessionStart — no user action needed. This skill exists to *upgrade* that scan into a rich, multi-paragraph briefing that captures intent, architecture, and current state.
|
|
89
|
+
|
|
89
90
|
## Reference
|
|
90
91
|
|
|
91
92
|
```bash
|
|
@@ -93,5 +94,4 @@ eagle-mem overview # view current overview
|
|
|
93
94
|
eagle-mem overview set "..." # save new overview
|
|
94
95
|
eagle-mem overview list # all projects with overviews
|
|
95
96
|
eagle-mem overview delete # remove current project's overview
|
|
96
|
-
eagle-mem scan . # structural scan (fallback only)
|
|
97
97
|
```
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: eagle-mem-index
|
|
3
|
-
description: >
|
|
4
|
-
Index source files into FTS5-searchable chunks. Use when: 'eagle index', 'index this project',
|
|
5
|
-
'make code searchable', 'reindex', 'update index', 'index after pull',
|
|
6
|
-
'code search setup'. Uses the eagle-mem CLI.
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Eagle Mem — Index
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
**For the user:** Claude Code can find code they wrote weeks ago -- across sessions, without needing to remember which file it was in. Every prompt automatically surfaces relevant code chunks from the index, so past work stays accessible.
|
|
14
|
-
|
|
15
|
-
**For you (Claude Code):** The UserPromptSubmit hook searches `code_chunks` on every user prompt and injects matching file references into your context. You don't call a search command for this -- it happens automatically. But the index must exist and be current for it to work. That's what this skill manages.
|
|
16
|
-
|
|
17
|
-
## Judgment
|
|
18
|
-
|
|
19
|
-
**Index when:**
|
|
20
|
-
- First time setting up Eagle Mem on a project (`eagle-mem index .`)
|
|
21
|
-
- After a `git pull` or branch switch that brought in significant changes
|
|
22
|
-
- After a major refactor (renamed files, moved directories, new modules)
|
|
23
|
-
- The user says "index this project" or "make code searchable"
|
|
24
|
-
- You notice the UserPromptSubmit hook isn't surfacing relevant code -- the index may be stale
|
|
25
|
-
|
|
26
|
-
**Don't index when:**
|
|
27
|
-
- You just need to read a specific file -- use Read directly
|
|
28
|
-
- The project was recently indexed and no files changed (mtime dedup handles this, but don't waste time running it)
|
|
29
|
-
- You're in the middle of a task -- index at session boundaries, not mid-work
|
|
30
|
-
|
|
31
|
-
**Decision rule:** Index is a maintenance task, not a search tool. Run it to *prepare* the database, then rely on the automatic hook to *use* it. If the hook isn't surfacing what you expect, the index is stale -- re-run.
|
|
32
|
-
|
|
33
|
-
## Steps
|
|
34
|
-
|
|
35
|
-
### 1. Run the indexer
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
eagle-mem index .
|
|
39
|
-
```
|
|
40
|
-
Indexes the current directory. The script:
|
|
41
|
-
- Collects source files (respects `.gitignore`, skips binaries/lockfiles)
|
|
42
|
-
- Filters to known source extensions (sh, js, ts, py, go, rs, java, etc.)
|
|
43
|
-
- Skips files over 1MB
|
|
44
|
-
- Compares mtime against stored mtime -- only re-indexes changed files
|
|
45
|
-
- Chunks each file into segments (default 80 lines) and inserts into `code_chunks` with FTS5
|
|
46
|
-
|
|
47
|
-
The mtime check makes re-running cheap. On a project with 200 files where 5 changed, it processes only those 5.
|
|
48
|
-
|
|
49
|
-
### 2. Understand chunk size
|
|
50
|
-
|
|
51
|
-
Default: 80 lines per chunk. Override with:
|
|
52
|
-
```bash
|
|
53
|
-
EAGLE_MEM_CHUNK_SIZE=40 eagle-mem index .
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Smaller chunks (30-50):** More precise search matches. Better for codebases with many small, distinct functions. Produces more chunks -- larger DB.
|
|
57
|
-
|
|
58
|
-
**Larger chunks (100-150):** More context per match. Better for files with long, cohesive blocks. Fewer chunks -- smaller DB.
|
|
59
|
-
|
|
60
|
-
**When to change:** If the hook is surfacing irrelevant matches (chunks too big, mixing unrelated code), shrink. If matches lack context (cutting functions in half), grow. The default of 80 works well for most projects.
|
|
61
|
-
|
|
62
|
-
### 3. Know what gets indexed
|
|
63
|
-
|
|
64
|
-
The indexer processes files matching these extensions:
|
|
65
|
-
`sh bash zsh js jsx mjs cjs ts tsx mts py rb go rs java kt kts swift c h cpp cc cxx hpp cs php sql html htm css scss vue svelte dart ex exs zig lua r scala yaml yml toml json md`
|
|
66
|
-
|
|
67
|
-
Silently skipped: images, binaries, lockfiles (`package-lock.json` etc. are over 1MB), `.git/` contents, anything in `.gitignore`.
|
|
68
|
-
|
|
69
|
-
### 4. Understand how indexed code reaches the user
|
|
70
|
-
|
|
71
|
-
The flow is:
|
|
72
|
-
1. You run `eagle-mem index .` -- code is chunked and stored in `code_chunks` table
|
|
73
|
-
2. User submits a prompt in any future session
|
|
74
|
-
3. UserPromptSubmit hook extracts keywords from the prompt
|
|
75
|
-
4. Hook searches `code_chunks` FTS5 index for matches
|
|
76
|
-
5. Matching file paths + line ranges are injected into your context as "EAGLE MEM — Relevant Code"
|
|
77
|
-
|
|
78
|
-
There is no manual "search code" CLI command. The index feeds the hook, and the hook feeds you. Your job is to keep the index current.
|
|
79
|
-
|
|
80
|
-
### 5. Verify the index
|
|
81
|
-
|
|
82
|
-
After indexing, confirm it worked:
|
|
83
|
-
```bash
|
|
84
|
-
eagle-mem search --stats
|
|
85
|
-
```
|
|
86
|
-
Check the "Code chunks" count. For a typical project:
|
|
87
|
-
- 50-file project ~ 200-500 chunks
|
|
88
|
-
- 200-file project ~ 800-2000 chunks
|
|
89
|
-
- 0 chunks after indexing = something went wrong (check file extensions, directory path)
|
|
90
|
-
|
|
91
|
-
Also verify the hook is using it: on the next user prompt with 3+ words, you should see "EAGLE MEM — Relevant Code" injected if any chunks match.
|
|
92
|
-
|
|
93
|
-
### 6. When indexing gets stale
|
|
94
|
-
|
|
95
|
-
The index reflects the state of files *when you last ran it*. It goes stale when:
|
|
96
|
-
- `git pull` brings in changes from others
|
|
97
|
-
- `git checkout` switches branches (different file contents, possibly different files)
|
|
98
|
-
- A major refactor renames or moves files (old paths stay in the index, new paths are missing)
|
|
99
|
-
- Dependencies are updated and source files regenerate
|
|
100
|
-
|
|
101
|
-
**After any of these, re-run `eagle-mem index .`** The mtime check ensures only changed files are re-processed. Old chunks for unchanged files are kept. Chunks for changed files are atomically replaced (DELETE + INSERT in a transaction).
|
|
102
|
-
|
|
103
|
-
## What makes a good indexing practice
|
|
104
|
-
|
|
105
|
-
**Good:**
|
|
106
|
-
> Indexed the project after pulling the team's changes from main. Stats show 1,247 chunks across 189 files. The UserPromptSubmit hook should now surface the new API routes the team added.
|
|
107
|
-
|
|
108
|
-
**Bad:**
|
|
109
|
-
> Indexed once when Eagle Mem was installed and never again. The hook keeps surfacing stale code from deleted files, and misses the 30 new files added over the past month.
|
|
110
|
-
|
|
111
|
-
## Reference
|
|
112
|
-
|
|
113
|
-
| Command / Flag | What it does |
|
|
114
|
-
|---|---|
|
|
115
|
-
| `eagle-mem index .` | Index current directory (incremental via mtime) |
|
|
116
|
-
| `eagle-mem index /path/to/dir` | Index a specific directory |
|
|
117
|
-
| `EAGLE_MEM_CHUNK_SIZE=N` | Override chunk size (default: 80 lines) |
|
|
118
|
-
| `eagle-mem search --stats` | Verify chunk count after indexing |
|
|
119
|
-
| Max file size | 1MB (larger files silently skipped) |
|
|
120
|
-
| Dedup | mtime-based -- re-running is cheap and safe |
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: eagle-mem-prune
|
|
3
|
-
description: >
|
|
4
|
-
Database hygiene — remove stale observations and orphaned code chunks. Use when:
|
|
5
|
-
'eagle prune', 'clean up memory', 'prune database', 'database too large',
|
|
6
|
-
'remove old data', 'memory maintenance', search feels slow.
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Eagle Mem — Prune
|
|
10
|
-
|
|
11
|
-
## Purpose
|
|
12
|
-
|
|
13
|
-
**For the user:** Keep Eagle Mem fast and focused. A database that accumulates months of observations without cleanup gets noisy — search results surface stale context, and queries slow down as row counts grow.
|
|
14
|
-
|
|
15
|
-
**For you (Claude Code):** Understand what data matters most and what's safe to remove. Pruning is a graduated operation — you're trimming low-value data, never touching the high-value records that give sessions continuity.
|
|
16
|
-
|
|
17
|
-
## Judgment
|
|
18
|
-
|
|
19
|
-
**Prune when:**
|
|
20
|
-
- `eagle-mem search --stats` shows high observation counts (1000+ for a single project is worth checking)
|
|
21
|
-
- The user says search feels slow or results are stale
|
|
22
|
-
- After removing a project directory or completing a major refactor that invalidated old code paths
|
|
23
|
-
- Periodic maintenance — monthly is enough for most projects
|
|
24
|
-
|
|
25
|
-
**Don't prune when:**
|
|
26
|
-
- The database is small and search is fast — pruning a clean database is pointless
|
|
27
|
-
- You're unsure what the observations contain — run `--dry-run` first
|
|
28
|
-
- The user is mid-task — prune between work sessions, not during
|
|
29
|
-
|
|
30
|
-
**Start conservative.** Default 90 days is right for routine cleanup. Only go aggressive (30 days) when there's a clear reason: project was deleted, architecture was overhauled, or the user explicitly asks for it.
|
|
31
|
-
|
|
32
|
-
## Data hierarchy — what's protected, what's pruned
|
|
33
|
-
|
|
34
|
-
**Never pruned (high-value):**
|
|
35
|
-
- `sessions` — your session history, parent rows for everything else
|
|
36
|
-
- `summaries` + `summaries_fts` — what was accomplished each session
|
|
37
|
-
- `claude_tasks` — task state that survives compaction
|
|
38
|
-
- `claude_memories` — mirrored auto-memories
|
|
39
|
-
- `claude_plans` — mirrored plans
|
|
40
|
-
- `overviews` — project overviews injected at SessionStart
|
|
41
|
-
|
|
42
|
-
**Pruned by age (medium-value):**
|
|
43
|
-
- `observations` — per-tool-use records (which files were read/written). Useful for recent context, but stale observations from 3 months ago rarely help. Default threshold: 90 days.
|
|
44
|
-
|
|
45
|
-
**Pruned by orphan check (low-value when stale):**
|
|
46
|
-
- `code_chunks` — indexed source code. Chunks for files that no longer exist on disk are orphaned and safe to remove. The prune script checks each file path against the project directory.
|
|
47
|
-
|
|
48
|
-
## Steps
|
|
49
|
-
|
|
50
|
-
### 1. Assess — understand the current state
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
eagle-mem search --stats
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Look at: total observations, total code chunks, project breakdown. This tells you whether pruning is even needed.
|
|
57
|
-
|
|
58
|
-
### 2. Preview — always dry-run first
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
eagle-mem prune --dry-run
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
The output shows:
|
|
65
|
-
- Current counts: "Database: N observations, N chunks"
|
|
66
|
-
- What would be removed: "Would prune N observations older than 90 days"
|
|
67
|
-
- Orphaned chunks: "Would prune N orphaned files from 'project-name'"
|
|
68
|
-
|
|
69
|
-
**What the numbers mean:**
|
|
70
|
-
- 0 observations to prune: database is already clean, nothing to do
|
|
71
|
-
- 50-200 observations: normal cleanup, proceed
|
|
72
|
-
- 500+ observations: significant cleanup — review the project name to make sure it's correct
|
|
73
|
-
- Orphaned chunks: always safe to remove (the source files don't exist anymore)
|
|
74
|
-
|
|
75
|
-
### 3. Execute — prune with the right threshold
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
# Standard cleanup (90 days)
|
|
79
|
-
eagle-mem prune
|
|
80
|
-
|
|
81
|
-
# Conservative (only very old data)
|
|
82
|
-
eagle-mem prune --days 180
|
|
83
|
-
|
|
84
|
-
# Aggressive (use only with good reason)
|
|
85
|
-
eagle-mem prune --days 30
|
|
86
|
-
|
|
87
|
-
# Target one project
|
|
88
|
-
eagle-mem prune --project my-app
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### 4. Verify — confirm the result
|
|
92
|
-
|
|
93
|
-
The prune output shows before/after counts:
|
|
94
|
-
```
|
|
95
|
-
Observations: 342 (was 891)
|
|
96
|
-
Code chunks: 45 (was 72)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
If the numbers look wrong (pruned too much or too little), there's no undo — but sessions, summaries, tasks, and memories are intact. Observations will rebuild naturally as you keep working.
|
|
100
|
-
|
|
101
|
-
## When aggressive cleanup is safe
|
|
102
|
-
|
|
103
|
-
- **Project removed entirely:** The directory is gone, all observations and chunks for it are orphaned. Use `--project <name>` to target just that project.
|
|
104
|
-
- **Major refactor:** You renamed half the files, restructured directories. Old observations reference paths that no longer exist. Prune orphaned chunks, then re-index with `eagle-mem index`.
|
|
105
|
-
- **Fresh start:** The user explicitly wants to clear old noise. `--days 30` removes everything except the last month.
|
|
106
|
-
|
|
107
|
-
## What makes a good prune decision
|
|
108
|
-
|
|
109
|
-
**Good:**
|
|
110
|
-
> "eagle-mem search --stats shows 2,400 observations for this project, most from 4 months ago when the architecture was different. I'll dry-run first, then prune with default 90 days."
|
|
111
|
-
|
|
112
|
-
**Bad:**
|
|
113
|
-
> "Let me clean up the database" [runs `eagle-mem prune --days 7` without checking stats or dry-running first]
|
|
114
|
-
|
|
115
|
-
The good version assesses before acting. The bad version risks removing recent, useful observations with no preview.
|
|
116
|
-
|
|
117
|
-
## Reference
|
|
118
|
-
|
|
119
|
-
| Flag | What it does |
|
|
120
|
-
|------|-------------|
|
|
121
|
-
| `--dry-run`, `-n` | Preview what would be removed, no changes |
|
|
122
|
-
| `--days N`, `-d N` | Age threshold in days (default: 90) |
|
|
123
|
-
| `--project <name>`, `-p` | Target a single project |
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
eagle-mem prune --dry-run # always start here
|
|
127
|
-
eagle-mem prune # standard 90-day cleanup
|
|
128
|
-
eagle-mem prune --days 30 # aggressive (with good reason)
|
|
129
|
-
eagle-mem prune -p my-app -n # dry-run for one project
|
|
130
|
-
eagle-mem search --stats # check database health first
|
|
131
|
-
```
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: eagle-mem-scan
|
|
3
|
-
description: >
|
|
4
|
-
Structural codebase analysis — language breakdown, framework detection, entry
|
|
5
|
-
points, tests, dependencies. Use when: 'eagle scan', 'scan this project',
|
|
6
|
-
'analyze codebase structure', 'what is this project made of', bootstrapping
|
|
7
|
-
a new project's overview, empty repo with no README.
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Eagle Mem — Scan
|
|
11
|
-
|
|
12
|
-
## Purpose
|
|
13
|
-
|
|
14
|
-
**For the user:** Machine-readable project analysis. Answers "what is this project made of?" with hard numbers — languages, line counts, frameworks, entry points, test presence, monorepo structure. No interpretation, just structure.
|
|
15
|
-
|
|
16
|
-
**For you (Claude Code):** Scan is the structural foundation that overview builds on. It tells you what languages and frameworks are present, how the project is organized, and whether tests exist — all without reading any source files. Use it when you need facts about project composition, not understanding of project purpose.
|
|
17
|
-
|
|
18
|
-
## Judgment
|
|
19
|
-
|
|
20
|
-
**Scan when:**
|
|
21
|
-
- No overview exists and the project has no README (scan is the best starting point)
|
|
22
|
-
- You need structural facts: "how many TypeScript files?", "is this a monorepo?", "what test framework?"
|
|
23
|
-
- Bootstrapping a brand-new project in Eagle Mem for the first time
|
|
24
|
-
- After major restructuring — added new packages, new languages, reorganized directories
|
|
25
|
-
|
|
26
|
-
**Don't scan when:**
|
|
27
|
-
- A rich overview already exists -- scan auto-skips when the overview exceeds 300 chars (use `--force` to override)
|
|
28
|
-
- You need to understand what the project does or why it's built a certain way -- that's overview's job
|
|
29
|
-
- You just want to look at the project -- use `ls` and `Read` instead
|
|
30
|
-
|
|
31
|
-
**Scan vs overview -- they complement each other:**
|
|
32
|
-
- `eagle-mem scan .` = machine analysis. Counts files, detects frameworks, finds entry points. Fast, no model reasoning. Produces a factual one-liner stored as the overview. Auto-skips if a rich overview exists.
|
|
33
|
-
- `/eagle-mem-overview` = model-driven analysis. You read source files, understand architecture, write a multi-paragraph briefing. Slower, much richer.
|
|
34
|
-
|
|
35
|
-
The typical flow for a new project: scan first (get the structural snapshot), then build a proper overview on top of it (which replaces the scan output with something richer).
|
|
36
|
-
|
|
37
|
-
## What scan detects
|
|
38
|
-
|
|
39
|
-
**Language breakdown:** Top 5 languages by line count. Maps file extensions to language names (`.ts`/`.tsx` = TypeScript, `.py` = Python, etc.). Reports file counts and line counts per language.
|
|
40
|
-
|
|
41
|
-
**Framework detection:** Checks `package.json` dependencies (React, Next.js, Express, Hono, Prisma, Tailwind, etc.), Python markers (Django, Flask, FastAPI), and ecosystem files (Cargo.toml, go.mod, Gemfile, pubspec.yaml, mix.exs, etc.).
|
|
42
|
-
|
|
43
|
-
**Structure:** Top-level directories with file counts. Uses `git ls-files` in git repos, falls back to `find` otherwise.
|
|
44
|
-
|
|
45
|
-
**Entry points:** Looks for `bin/*`, `src/index.*`, `src/main.*`, `src/app.*`, `index.*`, `main.*`, `app.*`, `server.*`, `cli.*`.
|
|
46
|
-
|
|
47
|
-
**Tests:** Counts files matching test patterns (`test/`, `tests/`, `__tests__/`, `.test.`, `.spec.`, `_test.`). Detects test frameworks (Jest, Vitest, Mocha, pytest).
|
|
48
|
-
|
|
49
|
-
**Config files:** Finds Dockerfile, docker-compose, tsconfig, ESLint, Biome, Tailwind config, Vite/Next/Webpack config, railway.json, CLAUDE.md, and others.
|
|
50
|
-
|
|
51
|
-
**Dependencies:** Counts npm deps/devDeps from package.json, Go modules from go.mod.
|
|
52
|
-
|
|
53
|
-
**Monorepo:** Detects npm workspaces, pnpm-workspace.yaml, Lerna, Turborepo.
|
|
54
|
-
|
|
55
|
-
## Steps
|
|
56
|
-
|
|
57
|
-
### 1. Run the scan
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
eagle-mem scan . # current directory
|
|
61
|
-
eagle-mem scan /path/to/project # specific path
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 2. Read the output
|
|
65
|
-
|
|
66
|
-
Scan prints each detection as it goes:
|
|
67
|
-
```
|
|
68
|
-
+ 47 files found
|
|
69
|
-
+ Languages: TypeScript (12k lines, 35 files), Bash (2k lines, 8 files)
|
|
70
|
-
+ Frameworks: Hono, Prisma, Tailwind
|
|
71
|
-
+ Structure: src/ (28), db/ (10), scripts/ (8), hooks/ (5)
|
|
72
|
-
+ Entry points: bin/eagle-mem, src/index.ts
|
|
73
|
-
+ Tests: 6 test files (Vitest)
|
|
74
|
-
+ Config: tsconfig.json, CLAUDE.md, railway.json
|
|
75
|
-
+ Dependencies: npm: 12 deps, 8 devDeps
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**What to look for:**
|
|
79
|
-
- "No tests detected" — notable, worth mentioning to the user
|
|
80
|
-
- 0 entry points — unusual, might mean non-standard project structure
|
|
81
|
-
- Missing framework detection — scan only checks known patterns; niche frameworks won't appear
|
|
82
|
-
- Very high file counts with few lines — lots of config/generated files
|
|
83
|
-
|
|
84
|
-
### 3. Decide what's next
|
|
85
|
-
|
|
86
|
-
**If this is a new project with no overview:** The scan output is now stored as the overview. Tell the user: "Structural overview saved. Run `/eagle-mem-overview` for a richer briefing once you're ready."
|
|
87
|
-
|
|
88
|
-
**If a rich overview already existed:** You just overwrote it. Re-run `/eagle-mem-overview` immediately to rebuild the semantic understanding on top of the new structural data.
|
|
89
|
-
|
|
90
|
-
## What makes a good scan decision
|
|
91
|
-
|
|
92
|
-
**Good:**
|
|
93
|
-
> Fresh repo, no README, no overview in Eagle Mem. Running `eagle-mem scan .` to get a structural baseline, then building a proper overview from the source code.
|
|
94
|
-
|
|
95
|
-
**Bad:**
|
|
96
|
-
> The project already has a detailed 4-paragraph overview from last session. Running `eagle-mem scan --force .` to "refresh the data." [This replaces the rich overview with a one-liner.]
|
|
97
|
-
|
|
98
|
-
The scan is a starting point, not a maintenance tool. Once a proper overview exists, update it with `/eagle-mem-overview` -- don't overwrite it with scan.
|
|
99
|
-
|
|
100
|
-
## Reference
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
eagle-mem scan . # scan current directory (skips if rich overview exists)
|
|
104
|
-
eagle-mem scan --force . # scan and overwrite even if rich overview exists
|
|
105
|
-
eagle-mem scan /path/to/project # scan specific path
|
|
106
|
-
eagle-mem overview # view the current overview
|
|
107
|
-
eagle-mem overview set "..." # manually set overview (what /eagle-mem-overview does)
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
| Detail | Notes |
|
|
111
|
-
|--------|-------|
|
|
112
|
-
| Output stored in | `overviews` table (same as `overview set`) |
|
|
113
|
-
| Overwrites existing overview | Only with `--force` -- auto-skips if overview > 300 chars |
|
|
114
|
-
| Respects .gitignore | Yes, uses `git ls-files` in git repos |
|
|
115
|
-
| Requires model reasoning | No -- pure bash + awk analysis |
|
|
116
|
-
| Typical runtime | Under 2 seconds for most projects |
|