eagle-mem 1.6.3 → 2.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.
@@ -1,92 +1,139 @@
1
1
  ---
2
2
  name: eagle-mem-tasks
3
3
  description: >
4
- TaskAware Compact Loop — break complex work into Claude Code tasks with dependencies,
5
- compact between each. Use when: 'eagle tasks', 'break this into tasks', 'create task plan',
6
- 'task loop', 'compact loop', 'eagle mem tasks'. Uses Claude Code's native TaskCreate/TaskUpdate.
4
+ TaskAware Compact Loop — break complex work into tasks that survive context
5
+ compaction. Use when: 'break this into tasks', 'create task plan', 'task loop',
6
+ 'compact loop', work is too large for one context window, multi-step implementation.
7
7
  ---
8
8
 
9
9
  # Eagle Mem — TaskAware Compact Loop
10
10
 
11
- Break complex work into subtasks using Claude Code's native task system. Execute one task at a time, compact between each, and let Eagle Mem re-inject task state for the next task.
11
+ ## Purpose
12
12
 
13
- ## How it works
13
+ **For the user:** Multi-step work doesn't get lost when Claude Code compacts. A 6-task implementation plan survives intact across compactions — no re-explaining what was decided, no drift from the original direction.
14
14
 
15
- 1. **Plan**: Break the user's request into ordered subtasks
16
- 2. **Create**: Add each subtask via `TaskCreate` with dependencies via `addBlockedBy`
17
- 3. **Execute**: Work on the current task (mark `in_progress` with `TaskUpdate`)
18
- 4. **Complete**: Mark done with `TaskUpdate(completed)`, emit `<eagle-summary>`
19
- 5. **Compact**: Tell the user to run `/compact`
20
- 6. **Resume**: After compact, SessionStart re-injects memory + loads task state from Eagle Mem's mirror
21
- 7. **Repeat**: Until all tasks are done
15
+ **For you (Claude Code):** Each task description is a message to a future context window with ZERO memory of what happened before. After compaction, SessionStart re-injects pending/in-progress tasks from Eagle Mem's `claude_tasks` table. That re-injected text is all the next context window gets. If the description says "implement auth middleware," the next window has nothing to work with. If it says "implement auth middleware — JWT with RS256, sessions in Redis, errors use RFC 7807 format (decided in task 1)," the next window can execute immediately.
22
16
 
23
- ## Creating tasks
17
+ ## Judgment
24
18
 
25
- Use Claude Code's `TaskCreate` tool. Each task gets `pending` status automatically.
19
+ **Use the task loop when:**
20
+ - Work requires 4+ distinct steps
21
+ - You'll likely need to `/compact` mid-way
22
+ - The user says "break this into tasks" or "create a plan"
23
+ - Different steps touch different parts of the codebase (schema, API, UI)
26
24
 
27
- For tasks that depend on earlier work, use `addBlockedBy` in `TaskUpdate`:
25
+ **Don't use when:**
26
+ - The work fits in one context window — just do it directly
27
+ - It's a single-file fix or a quick question
28
+ - The user is exploring, not building (use search/overview instead)
28
29
 
29
- ```
30
- TaskCreate({ subject: "Set up project structure", description: "Install deps, create folders, init config" })
31
- TaskCreate({ subject: "Implement auth middleware", description: "JWT validation, role checks, error responses" })
32
- TaskCreate({ subject: "Build CRUD endpoints", description: "Users and posts REST API with validation" })
30
+ ## Steps
33
31
 
34
- // Then set dependencies:
35
- TaskUpdate({ taskId: "3", addBlockedBy: ["1", "2"] })
36
- ```
32
+ ### 1. Plan — decompose into 3-8 tasks
37
33
 
38
- ## Working on a task
34
+ Break the request into tasks that are each completable in one context window. Think about what a fresh context window needs to execute each task independently.
39
35
 
40
- 1. Call `TaskUpdate({ taskId: "N", status: "in_progress" })` before starting work
41
- 2. Do the work
42
- 3. Call `TaskUpdate({ taskId: "N", status: "completed" })` when done
43
- 4. Emit your `<eagle-summary>` block
44
- 5. Tell the user: **"Task complete. Run `/compact` to save progress and load the next task."**
36
+ **Sizing rules:**
37
+ - If a task would touch more than ~10 files or require reading large code to understand, split it
38
+ - If a task is "change one line," merge it into an adjacent task
39
+ - Each task should produce a testable or verifiable result
45
40
 
46
- ## Viewing tasks
41
+ **Ordering:** Foundational work first — schema before API, API before UI, config before features.
47
42
 
48
- Use `TaskList` to see all tasks, or the CLI for cross-session history:
43
+ ### 2. Create write self-contained descriptions
49
44
 
50
- ```bash
51
- eagle-mem tasks # pending/in-progress (from mirror)
52
- eagle-mem tasks list # all tasks
53
- eagle-mem tasks search <q> # FTS5 search across task history
45
+ Use `TaskCreate` for each task. The description is the most important field — it must carry forward every decision from the planning conversation.
46
+
47
+ **Context transfer pattern:** For each task, ask: "If I read only this description with zero prior context, can I execute it?" If not, add what's missing.
48
+
49
+ ```
50
+ TaskCreate:
51
+ subject: "Add JWT auth middleware"
52
+ description: "Add Express middleware that validates JWT tokens on protected
53
+ routes. Decisions: RS256 algorithm, public key from env JWT_PUBLIC_KEY,
54
+ sessions stored in Redis (connection config already in lib/redis.ts from
55
+ task 1). Error responses use RFC 7807 format. Protect all /api/* routes
56
+ except /api/auth/login and /api/health."
54
57
  ```
55
58
 
56
- ## Cross-session context
59
+ **Dependencies:** Use `addBlockedBy` when a task genuinely can't start without another's output. Don't over-chain — most tasks in a plan can run in declared order without formal blocking.
57
60
 
58
- When a task depends on decisions made in earlier tasks, put that context in the task's `description` field — it persists across compactions via Eagle Mem's mirror.
61
+ ### 3. Execute one task at a time
59
62
 
60
- For example, if task 1 decides to use JWT with RS256:
63
+ `TaskUpdate(in_progress)` on the current task. Do the work. Stay focused on that task — don't drift into adjacent tasks.
61
64
 
65
+ ### 4. Complete — record what happened
66
+
67
+ `TaskUpdate(completed)`. Emit `<eagle-summary>` so Eagle Mem captures what was accomplished.
68
+
69
+ If the task produced decisions that downstream tasks need, update those task descriptions now:
62
70
  ```
63
- TaskUpdate({ taskId: "2", description: "Implement auth middleware. Decision from task 1: using JWT with RS256, sessions stored in Redis." })
71
+ TaskUpdate:
72
+ taskId: "3"
73
+ description: "...original description... Note from task 2: the user table
74
+ uses UUID primary keys, not auto-increment. Auth tokens table FKs to
75
+ users.id (UUID)."
64
76
  ```
65
77
 
66
- ## Task design guidelines
78
+ ### 5. Compact — hand off to the next context window
79
+
80
+ Tell the user: "Task complete. Run `/compact` to free context for the next task."
81
+
82
+ ### 6. Resume — pick up where you left off
83
+
84
+ After compaction, SessionStart re-injects all pending/in-progress tasks. Pick the next unblocked task and continue.
67
85
 
68
- - Each task should be **self-contained** — completable in one context window
69
- - Include enough detail in `description` that a fresh context window can pick it up
70
- - Use `addBlockedBy` for tasks that depend on earlier tasks
71
- - Order tasks so foundational work comes first (schema before API, API before UI)
72
- - Keep tasks focused: 3-8 tasks per plan
86
+ ## Handling scope changes and failures
73
87
 
74
- ## The compact cycle
88
+ **User changes direction mid-plan:** Update the remaining task descriptions to reflect the new direction. Delete tasks that no longer apply. Don't start over unless the change invalidates everything.
89
+
90
+ **A task fails or produces unexpected results:** Update the task description with what was learned and what went wrong. Don't just retry blindly — the description should carry the failure context so the next attempt (or the next context window) doesn't repeat the same mistake.
75
91
 
76
92
  ```
77
- User request -> Plan tasks (TaskCreate) -> Execute task 1 (TaskUpdate: in_progress)
78
- -> Complete task 1 (TaskUpdate: completed) -> /compact
79
- -> Eagle Mem saves summary -> Context cleared -> Task state re-injected
80
- -> Execute task 2 -> /compact
81
- -> ... repeat until all tasks done ...
82
- -> Final summary: "All N tasks complete."
93
+ TaskUpdate:
94
+ taskId: "4"
95
+ description: "...original description... FAILED ATTEMPT: Prisma migrate
96
+ errored because the users table already has a conflicting unique
97
+ constraint on email. Need to drop the old constraint first. See
98
+ migration 003_auth.sql for the current state."
83
99
  ```
84
100
 
85
- ## Status reference
101
+ **Partial completion:** If a task is half-done when you need to compact, update the description with exactly what's done and what remains. Mark it as still `in_progress`, not completed.
102
+
103
+ ## The compact cycle — how task state survives
104
+
105
+ 1. You call `TaskCreate`/`TaskUpdate` (Claude Code's native task tools)
106
+ 2. Claude Code writes task JSON to `~/.claude/tasks/$session_id/*.json`
107
+ 3. Eagle Mem's PostToolUse hook fires, mirrors the task into the `claude_tasks` FTS5 table
108
+ 4. SessionEnd hook does a final sweep to catch any status changes missed by hooks
109
+ 5. On compaction (or new session), SessionStart queries `claude_tasks` for pending/in-progress tasks from the last 7 days and injects them into context
110
+
111
+ The task descriptions you write ARE the context that survives. Everything else — your reasoning, the conversation, the files you read — gets compacted away.
112
+
113
+ ## What makes a good task plan
114
+
115
+ **Good:**
116
+ > Task 1: "Set up database schema for auth. Create users table (id UUID PK, email unique, password_hash, created_at) and sessions table (id UUID PK, user_id FK, token, expires_at). Use Prisma migration. Add seed script for test user."
117
+ >
118
+ > Task 2: "Implement login endpoint POST /api/auth/login. Accepts {email, password}, returns {token, expires_at}. Hash comparison with bcrypt (already in deps). Session created in DB. Error: 401 with RFC 7807 body. Schema from task 1: users.email is unique, sessions.token is the JWT."
86
119
 
87
- | Status | Meaning |
88
- |---|---|
89
- | `pending` | Not started yet |
90
- | `in_progress` | Currently being worked on |
91
- | `completed` | Done |
92
- | `deleted` | Removed |
120
+ **Bad:**
121
+ > Task 1: "Set up the database"
122
+ > Task 2: "Add authentication"
123
+
124
+ The bad version forces the next context window to re-discover every decision. The good version carries decisions forward — the next window can start coding immediately.
125
+
126
+ ## Reference
127
+
128
+ ```bash
129
+ # Viewing tasks (read-only — Eagle Mem mirrors, doesn't manage)
130
+ eagle-mem tasks # pending/in-progress for current project
131
+ eagle-mem tasks list # all tasks (including completed)
132
+ eagle-mem tasks completed # completed tasks only
133
+ eagle-mem tasks search <q> # FTS5 search across task history
134
+ eagle-mem tasks --json # JSON output for scripting
135
+
136
+ # Claude Code task tools (these are what you actually use)
137
+ TaskCreate # create a new task
138
+ TaskUpdate # update status, description, dependencies
139
+ ```