eagle-mem 1.0.3 → 1.2.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.
@@ -0,0 +1,291 @@
1
+ #!/usr/bin/env bash
2
+ # ═══════════════════════════════════════════════════════════
3
+ # Eagle Mem — Tasks
4
+ # CLI wrapper for task management (replaces raw SQL in skills)
5
+ # ═══════════════════════════════════════════════════════════
6
+ set -euo pipefail
7
+
8
+ SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
9
+ LIB_DIR="$SCRIPTS_DIR/../lib"
10
+
11
+ . "$SCRIPTS_DIR/style.sh"
12
+ . "$LIB_DIR/common.sh"
13
+ . "$LIB_DIR/db.sh"
14
+
15
+ eagle_ensure_db
16
+
17
+ # ─── Parse arguments ──────────────────────────────────────
18
+
19
+ action="${1:-pending}"
20
+ shift 2>/dev/null || true
21
+
22
+ project=""
23
+ json_output=false
24
+
25
+ # Extract global options from remaining args
26
+ args=()
27
+ while [ $# -gt 0 ]; do
28
+ case "$1" in
29
+ --project|-p) project="$2"; shift 2 ;;
30
+ --json|-j) json_output=true; shift ;;
31
+ --help|-h)
32
+ echo -e " ${BOLD}eagle-mem tasks${RESET} — Manage tracked tasks"
33
+ echo ""
34
+ echo -e " ${BOLD}Usage:${RESET}"
35
+ echo -e " eagle-mem tasks ${DIM}# list pending tasks${RESET}"
36
+ echo -e " eagle-mem tasks ${CYAN}list${RESET} ${DIM}# list all tasks${RESET}"
37
+ echo -e " eagle-mem tasks ${CYAN}add${RESET} <title> [instructions] ${DIM}# add a task${RESET}"
38
+ echo -e " eagle-mem tasks ${CYAN}done${RESET} <id> ${DIM}# mark task complete${RESET}"
39
+ echo -e " eagle-mem tasks ${CYAN}block${RESET} <id> ${DIM}# mark task blocked${RESET}"
40
+ echo -e " eagle-mem tasks ${CYAN}context${RESET} <id> <snapshot> ${DIM}# set task context${RESET}"
41
+ echo -e " eagle-mem tasks ${CYAN}clear${RESET} ${DIM}# remove all done tasks${RESET}"
42
+ echo ""
43
+ echo -e " ${BOLD}Options:${RESET}"
44
+ echo -e " ${CYAN}-p, --project${RESET} <name> Project name (default: current dir)"
45
+ echo -e " ${CYAN}-j, --json${RESET} Output as JSON"
46
+ echo ""
47
+ exit 0
48
+ ;;
49
+ *) args+=("$1"); shift ;;
50
+ esac
51
+ done
52
+
53
+ [ -z "$project" ] && project=$(eagle_project_from_cwd "$(pwd)")
54
+ project_sql=$(eagle_sql_escape "$project")
55
+
56
+ # ─── List tasks ───────────────────────────────────────────
57
+
58
+ tasks_list() {
59
+ local filter="${1:-all}"
60
+
61
+ local where_status=""
62
+ case "$filter" in
63
+ pending) where_status="AND status IN ('pending', 'active')" ;;
64
+ done) where_status="AND status = 'done'" ;;
65
+ all) where_status="" ;;
66
+ esac
67
+
68
+ if [ "$json_output" = true ]; then
69
+ eagle_db_json "SELECT id, title, instructions, status, ordinal, context_snapshot, completed_at, created_at
70
+ FROM tasks
71
+ WHERE project = '$project_sql' $where_status
72
+ ORDER BY ordinal ASC, id ASC;"
73
+ return
74
+ fi
75
+
76
+ local results
77
+ results=$(eagle_db "SELECT id, title, status, ordinal, instructions
78
+ FROM tasks
79
+ WHERE project = '$project_sql' $where_status
80
+ ORDER BY ordinal ASC, id ASC;")
81
+
82
+ if [ -z "$results" ]; then
83
+ eagle_dim "No tasks for project '$project'"
84
+ return
85
+ fi
86
+
87
+ echo ""
88
+ echo -e " ${BOLD}Tasks${RESET} ${DIM}($project)${RESET}"
89
+ echo -e " ${DIM}─────────────────────────────────────${RESET}"
90
+ echo ""
91
+
92
+ while IFS='|' read -r tid title status ordinal instructions; do
93
+ [ -z "$tid" ] && continue
94
+ local icon marker
95
+ case "$status" in
96
+ active) icon="${CYAN}▶${RESET}"; marker=" ${CYAN}[ACTIVE]${RESET}" ;;
97
+ pending) icon="${DIM}○${RESET}"; marker="" ;;
98
+ done) icon="${GREEN}✓${RESET}"; marker=" ${DIM}[DONE]${RESET}" ;;
99
+ blocked) icon="${RED}✗${RESET}"; marker=" ${RED}[BLOCKED]${RESET}" ;;
100
+ *) icon="$DOT"; marker="" ;;
101
+ esac
102
+ echo -e " ${icon} ${BOLD}#$tid${RESET} $title$marker"
103
+ [ -n "$instructions" ] && echo -e " ${DIM}$instructions${RESET}"
104
+ done <<< "$results"
105
+ echo ""
106
+ }
107
+
108
+ # ─── Add task ─────────────────────────────────────────────
109
+
110
+ tasks_add() {
111
+ local title="${args[0]:-}"
112
+ local instructions="${args[1]:-}"
113
+
114
+ if [ -z "$title" ]; then
115
+ eagle_err "Usage: eagle-mem tasks add <title> [instructions]"
116
+ exit 1
117
+ fi
118
+
119
+ local title_sql; title_sql=$(eagle_sql_escape "$title")
120
+ local instr_sql; instr_sql=$(eagle_sql_escape "$instructions")
121
+
122
+ local max_ord
123
+ max_ord=$(eagle_db "SELECT COALESCE(MAX(ordinal), 0) FROM tasks WHERE project = '$project_sql';")
124
+ local next_ord=$((max_ord + 1))
125
+
126
+ local new_id
127
+ new_id=$(eagle_db "INSERT INTO tasks (project, title, instructions, ordinal)
128
+ VALUES ('$project_sql', '$title_sql', '$instr_sql', $next_ord);
129
+ SELECT last_insert_rowid();")
130
+
131
+ if [ "$json_output" = true ]; then
132
+ jq -nc --arg id "$new_id" --arg title "$title" --argjson ord "$next_ord" \
133
+ '{id: ($id | tonumber), title: $title, ordinal: $ord}'
134
+ return
135
+ fi
136
+
137
+ eagle_ok "Task #$new_id added: $title"
138
+ }
139
+
140
+ # ─── Done ─────────────────────────────────────────────────
141
+
142
+ tasks_done() {
143
+ local task_id="${args[0]:-}"
144
+
145
+ if [ -z "$task_id" ]; then
146
+ eagle_err "Usage: eagle-mem tasks done <id>"
147
+ exit 1
148
+ fi
149
+
150
+ if ! [[ "$task_id" =~ ^[0-9]+$ ]]; then
151
+ eagle_err "Task ID must be a number, got: $task_id"
152
+ exit 1
153
+ fi
154
+
155
+ local changed
156
+ changed=$(eagle_db "UPDATE tasks SET status = 'done', completed_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
157
+ WHERE id = $task_id AND project = '$project_sql';
158
+ SELECT changes();")
159
+
160
+ if [ "${changed:-0}" -eq 0 ]; then
161
+ eagle_err "Task #$task_id not found in project '$project'"
162
+ exit 1
163
+ fi
164
+
165
+ local title
166
+ title=$(eagle_db "SELECT title FROM tasks WHERE id = $task_id AND project = '$project_sql';")
167
+
168
+ if [ "$json_output" = true ]; then
169
+ jq -nc --arg id "$task_id" '{id: ($id | tonumber), status: "done"}'
170
+ return
171
+ fi
172
+
173
+ eagle_ok "Task #$task_id done: $title"
174
+ }
175
+
176
+ # ─── Block ────────────────────────────────────────────────
177
+
178
+ tasks_block() {
179
+ local task_id="${args[0]:-}"
180
+
181
+ if [ -z "$task_id" ]; then
182
+ eagle_err "Usage: eagle-mem tasks block <id>"
183
+ exit 1
184
+ fi
185
+
186
+ if ! [[ "$task_id" =~ ^[0-9]+$ ]]; then
187
+ eagle_err "Task ID must be a number, got: $task_id"
188
+ exit 1
189
+ fi
190
+
191
+ local changed
192
+ changed=$(eagle_db "UPDATE tasks SET status = 'blocked' WHERE id = $task_id AND project = '$project_sql';
193
+ SELECT changes();")
194
+
195
+ if [ "${changed:-0}" -eq 0 ]; then
196
+ eagle_err "Task #$task_id not found in project '$project'"
197
+ exit 1
198
+ fi
199
+
200
+ if [ "$json_output" = true ]; then
201
+ jq -nc --arg id "$task_id" '{id: ($id | tonumber), status: "blocked"}'
202
+ return
203
+ fi
204
+
205
+ eagle_ok "Task #$task_id blocked"
206
+ }
207
+
208
+ # ─── Context snapshot ─────────────────────────────────────
209
+
210
+ tasks_context() {
211
+ local task_id="${args[0]:-}"
212
+ local snapshot="${args[1]:-}"
213
+
214
+ if [ -z "$task_id" ] || [ -z "$snapshot" ]; then
215
+ eagle_err "Usage: eagle-mem tasks context <id> <snapshot>"
216
+ exit 1
217
+ fi
218
+
219
+ if ! [[ "$task_id" =~ ^[0-9]+$ ]]; then
220
+ eagle_err "Task ID must be a number, got: $task_id"
221
+ exit 1
222
+ fi
223
+
224
+ local snap_sql; snap_sql=$(eagle_sql_escape "$snapshot")
225
+ local changed
226
+ changed=$(eagle_db "UPDATE tasks SET context_snapshot = '$snap_sql' WHERE id = $task_id AND project = '$project_sql';
227
+ SELECT changes();")
228
+
229
+ if [ "${changed:-0}" -eq 0 ]; then
230
+ eagle_err "Task #$task_id not found in project '$project'"
231
+ exit 1
232
+ fi
233
+
234
+ if [ "$json_output" = true ]; then
235
+ jq -nc --arg id "$task_id" '{id: ($id | tonumber), context_snapshot: true}'
236
+ return
237
+ fi
238
+
239
+ eagle_ok "Context saved for task #$task_id"
240
+ }
241
+
242
+ # ─── Clear done tasks ────────────────────────────────────
243
+
244
+ tasks_clear() {
245
+ local count
246
+ count=$(eagle_db "SELECT COUNT(*) FROM tasks WHERE project = '$project_sql' AND status = 'done';")
247
+
248
+ eagle_db "DELETE FROM tasks WHERE project = '$project_sql' AND status = 'done';"
249
+
250
+ if [ "$json_output" = true ]; then
251
+ jq -nc --argjson cleared "${count:-0}" '{cleared: $cleared}'
252
+ return
253
+ fi
254
+
255
+ eagle_ok "Cleared ${count:-0} completed tasks"
256
+ }
257
+
258
+ # ─── Dispatch ─────────────────────────────────────────────
259
+
260
+ case "$action" in
261
+ list) tasks_list "all" ;;
262
+ pending) tasks_list "pending" ;;
263
+ add) tasks_add ;;
264
+ done) tasks_done ;;
265
+ block) tasks_block ;;
266
+ context) tasks_context ;;
267
+ clear) tasks_clear ;;
268
+ --help|-h)
269
+ echo -e " ${BOLD}eagle-mem tasks${RESET} — Manage tracked tasks"
270
+ echo ""
271
+ echo -e " ${BOLD}Usage:${RESET}"
272
+ echo -e " eagle-mem tasks ${DIM}# list pending tasks${RESET}"
273
+ echo -e " eagle-mem tasks ${CYAN}list${RESET} ${DIM}# list all tasks${RESET}"
274
+ echo -e " eagle-mem tasks ${CYAN}add${RESET} <title> [instructions] ${DIM}# add a task${RESET}"
275
+ echo -e " eagle-mem tasks ${CYAN}done${RESET} <id> ${DIM}# mark task complete${RESET}"
276
+ echo -e " eagle-mem tasks ${CYAN}block${RESET} <id> ${DIM}# mark task blocked${RESET}"
277
+ echo -e " eagle-mem tasks ${CYAN}context${RESET} <id> <snapshot> ${DIM}# set task context${RESET}"
278
+ echo -e " eagle-mem tasks ${CYAN}clear${RESET} ${DIM}# remove all done tasks${RESET}"
279
+ echo ""
280
+ echo -e " ${BOLD}Options:${RESET}"
281
+ echo -e " ${CYAN}-p, --project${RESET} <name> Project name (default: current dir)"
282
+ echo -e " ${CYAN}-j, --json${RESET} Output as JSON"
283
+ echo ""
284
+ exit 0
285
+ ;;
286
+ *)
287
+ eagle_err "Unknown action: $action"
288
+ eagle_dim " Run 'eagle-mem tasks --help' for options"
289
+ exit 1
290
+ ;;
291
+ esac
@@ -6,12 +6,12 @@
6
6
  set -euo pipefail
7
7
 
8
8
  SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
9
+ LIB_DIR="$SCRIPTS_DIR/../lib"
9
10
 
10
11
  . "$SCRIPTS_DIR/style.sh"
12
+ . "$LIB_DIR/common.sh"
11
13
 
12
- EAGLE_MEM_DIR="${EAGLE_MEM_DIR:-$HOME/.eagle-mem}"
13
- SETTINGS="$HOME/.claude/settings.json"
14
- SKILLS_DIR="$HOME/.claude/skills"
14
+ SETTINGS="$EAGLE_SETTINGS"
15
15
 
16
16
  eagle_header "Uninstall"
17
17
 
@@ -35,9 +35,9 @@ fi
35
35
 
36
36
  # ─── Remove skill symlinks ────────────────────────────────
37
37
 
38
- if [ -d "$SKILLS_DIR" ]; then
38
+ if [ -d "$EAGLE_SKILLS_DIR" ]; then
39
39
  for skill in eagle-mem-search eagle-mem-tasks eagle-mem-overview; do
40
- target="$SKILLS_DIR/$skill"
40
+ target="$EAGLE_SKILLS_DIR/$skill"
41
41
  if [ -L "$target" ]; then
42
42
  rm "$target"
43
43
  eagle_ok "Skill removed: $skill"
package/scripts/update.sh CHANGED
@@ -7,11 +7,12 @@ set -euo pipefail
7
7
 
8
8
  PACKAGE_DIR="${1:-.}"
9
9
  SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"
10
+ LIB_DIR="$SCRIPTS_DIR/../lib"
10
11
 
11
12
  . "$SCRIPTS_DIR/style.sh"
13
+ . "$LIB_DIR/common.sh"
12
14
 
13
- EAGLE_MEM_DIR="${EAGLE_MEM_DIR:-$HOME/.eagle-mem}"
14
- SETTINGS="$HOME/.claude/settings.json"
15
+ SETTINGS="$EAGLE_SETTINGS"
15
16
 
16
17
  eagle_header "Update"
17
18
 
@@ -87,13 +88,12 @@ fi
87
88
 
88
89
  # ─── Update skill symlinks ────────────────────────────────
89
90
 
90
- SKILLS_DIR="$HOME/.claude/skills"
91
91
  if [ -d "$PACKAGE_DIR/skills" ]; then
92
- mkdir -p "$SKILLS_DIR"
92
+ mkdir -p "$EAGLE_SKILLS_DIR"
93
93
  for skill_dir in "$PACKAGE_DIR"/skills/*/; do
94
94
  [ ! -d "$skill_dir" ] && continue
95
95
  skill_name=$(basename "$skill_dir")
96
- dst="$SKILLS_DIR/$skill_name"
96
+ dst="$EAGLE_SKILLS_DIR/$skill_name"
97
97
  [ -L "$dst" ] && rm "$dst"
98
98
  ln -sf "$skill_dir" "$dst"
99
99
  done
@@ -3,98 +3,78 @@ name: eagle-mem-overview
3
3
  description: >
4
4
  Generate or update a project overview for Eagle Mem. Use when: 'eagle overview',
5
5
  'project overview', 'summarize this project', 'eagle mem overview', 'what is this project',
6
- 'update overview'. Creates a persistent one-paragraph project summary injected at session start.
6
+ 'update overview'. Uses the eagle-mem CLI never run raw sqlite3 queries.
7
7
  ---
8
8
 
9
9
  # Eagle Mem — Project Overview
10
10
 
11
- Generate a concise project overview that Eagle Mem injects at the start of every session. This gives fresh context windows an instant understanding of what the project is and what's been happening.
11
+ Generate a concise project overview that Eagle Mem injects at the start of every session. This gives fresh context windows an instant understanding of what the project is.
12
12
 
13
13
  ## How it works
14
14
 
15
- 1. Query recent summaries and observations for the current project
16
- 2. Synthesize them into a concise overview (2-4 sentences)
17
- 3. Save to the `overviews` table — one row per project, updated in place
15
+ 1. Gather context about the project (recent sessions, file activity)
16
+ 2. Synthesize into a concise overview (2-4 sentences)
17
+ 3. Save via the CLI — one overview per project, updated in place
18
18
 
19
19
  The overview is automatically injected by the SessionStart hook.
20
20
 
21
- ## Generating an overview
21
+ ## Commands
22
22
 
23
- ### Step 1: Gather context
23
+ ### View current overview
24
24
 
25
25
  ```bash
26
- sqlite3 ~/.eagle-mem/memory.db "
27
- SELECT request, completed, learned, next_steps, created_at
28
- FROM summaries
29
- WHERE project = '<project>'
30
- ORDER BY created_at DESC
31
- LIMIT 10;
32
- "
26
+ eagle-mem overview
33
27
  ```
34
28
 
35
- Also check frequently modified files:
29
+ ### Auto-generate from code analysis
36
30
 
37
31
  ```bash
38
- sqlite3 ~/.eagle-mem/memory.db "
39
- PRAGMA trusted_schema=ON;
40
- SELECT json_each.value as file, COUNT(*) as times
41
- FROM observations, json_each(observations.files_modified)
42
- WHERE observations.project = '<project>'
43
- GROUP BY json_each.value
44
- ORDER BY times DESC
45
- LIMIT 10;
46
- "
32
+ eagle-mem scan .
47
33
  ```
48
34
 
49
- ### Step 2: Write the overview
35
+ This scans the project structure (files, languages, frameworks, entry points, tests) and saves an overview automatically.
50
36
 
51
- Synthesize the data into a concise overview covering:
52
- - **What** the project is (one sentence)
53
- - **Current state** — what's been worked on recently
54
- - **Key patterns** — tech stack, architecture decisions, active conventions
37
+ ### Set overview manually
55
38
 
56
- Keep it under 500 characters. This gets injected into every session start, so brevity matters.
57
-
58
- ### Step 3: Save to database
39
+ When you want to write a custom overview based on session history:
59
40
 
41
+ 1. First, gather recent context:
60
42
  ```bash
61
- sqlite3 ~/.eagle-mem/memory.db "
62
- PRAGMA trusted_schema=ON;
63
- INSERT INTO overviews (project, content, updated_at)
64
- VALUES ('<project>', '<overview text>', strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
65
- ON CONFLICT(project) DO UPDATE SET
66
- content = excluded.content,
67
- updated_at = excluded.updated_at;
68
- "
43
+ eagle-mem search --timeline --limit 10
44
+ eagle-mem search --files
69
45
  ```
70
46
 
71
- ## Viewing the current overview
47
+ 2. Synthesize the data into a concise overview covering:
48
+ - **What** the project is (one sentence)
49
+ - **Current state** — what's been worked on recently
50
+ - **Key patterns** — tech stack, architecture decisions
72
51
 
52
+ 3. Save it:
73
53
  ```bash
74
- sqlite3 ~/.eagle-mem/memory.db "
75
- SELECT project, content, updated_at FROM overviews
76
- WHERE project = '<project>';
77
- "
54
+ eagle-mem overview set "eagle-mem: Node.js CLI tool providing persistent memory for Claude Code via SQLite + FTS5. Currently at v1.0.3 with 5 hooks, 3 skills, and CLI subcommands for search/tasks/overview."
78
55
  ```
79
56
 
80
- ## Listing all project overviews
57
+ Keep it under 500 characters — this gets injected into every session start.
58
+
59
+ ### List all project overviews
81
60
 
82
61
  ```bash
83
- sqlite3 ~/.eagle-mem/memory.db "
84
- SELECT project, substr(content, 1, 80) || '...', updated_at
85
- FROM overviews
86
- ORDER BY updated_at DESC;
87
- "
62
+ eagle-mem overview list
88
63
  ```
89
64
 
90
- ## Deleting an overview
65
+ ### Delete an overview
91
66
 
92
67
  ```bash
93
- sqlite3 ~/.eagle-mem/memory.db "
94
- DELETE FROM overviews WHERE project = '<project>';
95
- "
68
+ eagle-mem overview delete
96
69
  ```
97
70
 
71
+ ## Options
72
+
73
+ | Flag | Description |
74
+ |------|-------------|
75
+ | `-p, --project <name>` | Target a specific project (default: current directory) |
76
+ | `-j, --json` | Output as JSON |
77
+
98
78
  ## Guidelines
99
79
 
100
80
  - Update the overview when the project direction changes significantly
@@ -3,124 +3,76 @@ name: eagle-mem-search
3
3
  description: >
4
4
  Search Eagle Mem's persistent memory database. Use when: 'eagle search', 'search memory',
5
5
  'what did I do', 'eagle mem search', 'find in memory', 'past sessions', 'what happened with',
6
- 'search my history'. Three-layer search: compact index (fast) timeline (chronological) →
7
- full details (complete observations).
6
+ 'search my history'. Uses the eagle-mem CLI never run raw sqlite3 queries.
8
7
  ---
9
8
 
10
9
  # Eagle Mem — Memory Search
11
10
 
12
- Search the Eagle Mem database for past session summaries, observations, and task history.
11
+ Search the Eagle Mem database for past session summaries, observations, and task history using the `eagle-mem` CLI.
13
12
 
14
- ## Three-layer search pattern
13
+ ## Search commands
15
14
 
16
- ### Layer 1: Compact search (default)
15
+ ### Keyword search (default)
17
16
 
18
- Fast keyword search across session summaries. Returns ~50-100 tokens per result.
17
+ Search past sessions by keyword. Returns matching summaries ranked by relevance.
19
18
 
20
19
  ```bash
21
- sqlite3 ~/.eagle-mem/memory.db "
22
- PRAGMA trusted_schema=ON;
23
- SELECT s.id, s.request, s.completed, s.created_at, s.project
24
- FROM summaries s
25
- JOIN summaries_fts f ON f.rowid = s.id
26
- WHERE summaries_fts MATCH '<query>'
27
- ORDER BY rank
28
- LIMIT 10;
29
- "
20
+ eagle-mem search "auth middleware"
30
21
  ```
31
22
 
32
- Use this first. If the user needs more detail, go to Layer 2 or 3.
23
+ Cross-project search:
24
+ ```bash
25
+ eagle-mem search "deploy issue" --all
26
+ ```
33
27
 
34
- ### Layer 2: Timeline (chronological context)
28
+ ### Timeline (chronological)
35
29
 
36
- Show recent sessions for a project in time order. Good for "what have I been working on?"
30
+ Show recent sessions for the current project in time order.
37
31
 
38
32
  ```bash
39
- sqlite3 ~/.eagle-mem/memory.db "
40
- SELECT s.request, s.completed, s.learned, s.next_steps, s.created_at
41
- FROM summaries s
42
- WHERE s.project = '<project>'
43
- ORDER BY s.created_at DESC
44
- LIMIT <N>;
45
- "
33
+ eagle-mem search --timeline
34
+ eagle-mem search --timeline --limit 20
46
35
  ```
47
36
 
48
- ### Layer 3: Full details (observations)
37
+ ### Session details
49
38
 
50
- When the user needs to know exactly what files were touched or what tools were used:
39
+ View all tool observations (files read/written, commands run) for a specific session.
51
40
 
52
41
  ```bash
53
- sqlite3 ~/.eagle-mem/memory.db "
54
- PRAGMA trusted_schema=ON;
55
- SELECT o.tool_name, o.tool_input_summary, o.files_read, o.files_modified, o.created_at
56
- FROM observations o
57
- WHERE o.session_id = '<session_id>'
58
- ORDER BY o.created_at ASC;
59
- "
42
+ eagle-mem search --session <session_id>
60
43
  ```
61
44
 
62
- ## Additional queries
45
+ ### Frequently modified files
63
46
 
64
- ### Cross-project search
47
+ Show which files are touched most often in this project.
65
48
 
66
49
  ```bash
67
- sqlite3 ~/.eagle-mem/memory.db "
68
- PRAGMA trusted_schema=ON;
69
- SELECT s.project, s.request, s.completed, s.created_at
70
- FROM summaries s
71
- JOIN summaries_fts f ON f.rowid = s.id
72
- WHERE summaries_fts MATCH '<query>'
73
- ORDER BY rank
74
- LIMIT 10;
75
- "
50
+ eagle-mem search --files
76
51
  ```
77
52
 
78
- ### Files frequently modified
53
+ ### Project stats
54
+
55
+ Get counts of sessions, summaries, observations, tasks, and code chunks.
79
56
 
80
57
  ```bash
81
- sqlite3 ~/.eagle-mem/memory.db "
82
- PRAGMA trusted_schema=ON;
83
- SELECT json_each.value as file, COUNT(*) as times
84
- FROM observations, json_each(observations.files_modified)
85
- WHERE observations.project = '<project>'
86
- GROUP BY json_each.value
87
- ORDER BY times DESC
88
- LIMIT 20;
89
- "
58
+ eagle-mem search --stats
90
59
  ```
91
60
 
92
- ### Task history
61
+ ## Options
93
62
 
94
- ```bash
95
- sqlite3 ~/.eagle-mem/memory.db "
96
- SELECT id, title, status, completed_at
97
- FROM tasks
98
- WHERE project = '<project>'
99
- ORDER BY ordinal ASC, id ASC;
100
- "
101
- ```
63
+ | Flag | Description |
64
+ |------|-------------|
65
+ | `-p, --project <name>` | Target a specific project (default: current directory) |
66
+ | `-n, --limit <N>` | Max results (default: 10) |
67
+ | `-a, --all` | Search across all projects |
68
+ | `-j, --json` | Output as JSON (for programmatic use) |
102
69
 
103
- ### Session count and stats
70
+ ## Three-layer pattern
104
71
 
105
- ```bash
106
- sqlite3 ~/.eagle-mem/memory.db "
107
- SELECT
108
- COUNT(DISTINCT s.id) as sessions,
109
- COUNT(DISTINCT su.id) as summaries,
110
- COUNT(DISTINCT o.id) as observations,
111
- COUNT(DISTINCT t.id) as tasks
112
- FROM sessions s
113
- LEFT JOIN summaries su ON su.project = s.project
114
- LEFT JOIN observations o ON o.session_id = s.id
115
- LEFT JOIN tasks t ON t.project = s.project
116
- WHERE s.project = '<project>';
117
- "
118
- ```
72
+ Start with **keyword search** — it's fast and usually sufficient. If the user needs chronological context, use **--timeline**. If they need exact file-level detail, use **--session** with a specific session ID from a previous search result.
119
73
 
120
74
  ## Usage tips
121
75
 
122
- - Start with Layer 1 (compact search) it's fast and usually sufficient
123
- - Use FTS5 query syntax: `word1 AND word2`, `"exact phrase"`, `word1 OR word2`, `word1 NOT word2`
124
- - The `project` column maps to the directory name (basename of cwd)
125
- - Cross-project search omits the WHERE project clause
126
- - Observations are high-volume — query by session_id, not full table scans
76
+ - Keyword search supports FTS5 syntax: `word1 AND word2`, `"exact phrase"`, `word1 OR word2`
77
+ - The `--json` flag is useful when you need to parse results programmatically
78
+ - Project name defaults to the basename of the current working directory