trekoon 0.3.0 → 0.3.2

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.
Files changed (43) hide show
  1. package/.agents/skills/trekoon/SKILL.md +274 -26
  2. package/.agents/skills/trekoon/reference/execution-with-team.md +213 -0
  3. package/.agents/skills/trekoon/reference/execution.md +210 -0
  4. package/.agents/skills/trekoon/reference/planning.md +244 -0
  5. package/README.md +24 -10
  6. package/docs/ai-agents.md +108 -30
  7. package/docs/commands.md +81 -5
  8. package/docs/machine-contracts.md +120 -0
  9. package/docs/plans/r1-unified-skill-rewrite.md +290 -0
  10. package/docs/plans/r10-suggest-command-skill-integration.md +152 -0
  11. package/docs/plans/r9-task-done-diff-skill-integration.md +113 -0
  12. package/docs/quickstart.md +31 -0
  13. package/package.json +2 -2
  14. package/src/board/assets/app.js +5 -0
  15. package/src/board/assets/components/EpicsOverview.js +13 -0
  16. package/src/board/assets/components/Workspace.js +27 -12
  17. package/src/board/assets/components/helpers.js +3 -2
  18. package/src/board/assets/runtime/delegation.js +69 -1
  19. package/src/board/assets/state/actions.js +27 -1
  20. package/src/board/assets/state/store.js +37 -8
  21. package/src/board/assets/state/utils.js +42 -0
  22. package/src/board/assets/styles/board.css +68 -0
  23. package/src/board/routes.ts +2 -0
  24. package/src/commands/epic.ts +74 -3
  25. package/src/commands/session.ts +7 -75
  26. package/src/commands/skills.ts +39 -32
  27. package/src/commands/subtask.ts +7 -5
  28. package/src/commands/suggest.ts +283 -0
  29. package/src/commands/sync-helpers.ts +75 -0
  30. package/src/commands/task-readiness.ts +8 -20
  31. package/src/commands/task.ts +59 -3
  32. package/src/domain/mutation-service.ts +69 -42
  33. package/src/domain/tracker-domain.ts +151 -22
  34. package/src/domain/types.ts +12 -0
  35. package/src/index.ts +1 -1
  36. package/src/io/output.ts +4 -2
  37. package/src/runtime/cli-shell.ts +26 -3
  38. package/src/runtime/command-types.ts +1 -1
  39. package/src/storage/database.ts +43 -1
  40. package/src/storage/events-retention.ts +57 -8
  41. package/src/storage/migrations.ts +58 -3
  42. package/src/sync/service.ts +101 -24
  43. package/src/sync/types.ts +1 -0
@@ -10,6 +10,72 @@ Trekoon is a local-first issue tracker for epics, tasks, and subtasks.
10
10
  This skill is the agent operating guide, not the full CLI reference. Use it to
11
11
  pick the right command with the fewest reads and mutations.
12
12
 
13
+ ## Skill arguments
14
+
15
+ When invoked with arguments (e.g., `/trekoon <id> [user text]`), resolve the
16
+ argument as a Trekoon entity ID and choose the action based on user intent:
17
+
18
+ ### 1. Resolve the entity
19
+
20
+ ```bash
21
+ trekoon --toon epic show <id> 2>/dev/null || \
22
+ trekoon --toon task show <id> 2>/dev/null || \
23
+ trekoon --toon subtask show <id> 2>/dev/null
24
+ ```
25
+
26
+ If none match, tell the user the ID was not found.
27
+
28
+ ### 2. Choose the action
29
+
30
+ Interpret the user's accompanying text (or lack thereof) to decide what to do:
31
+
32
+ | User intent signal | Action |
33
+ |---|---|
34
+ | No text, just an ID | Orient: run `session --epic <epic-id>` (or show the task/subtask) and summarize status, readiness, and next steps |
35
+ | "analyze", "review", "check", "status", "progress" | **Analyze:** run `epic progress <id>` or `task show <id> --all`, then `suggest --epic <id>`, and report findings |
36
+ | "execute", "implement", "do", "complete", "start", "run" | **Execute:** read `reference/execution.md`, scope session to the entity's epic, and begin the execution loop |
37
+ | "plan", "break down", "design", "architect" | **Plan:** read `reference/planning.md` and create or expand the epic graph |
38
+
39
+ ### Examples
40
+
41
+ ```
42
+ /trekoon abc-123
43
+ → shows epic/task/subtask abc-123, summarizes status and next candidate
44
+
45
+ /trekoon abc-123 analyze this epic
46
+ → runs epic progress, suggest, reports readiness and blockers
47
+
48
+ /trekoon abc-123 execute
49
+ → reads execution reference, starts session --epic, begins work loop
50
+
51
+ /trekoon abc-123 plan the implementation
52
+ → reads planning reference, decomposes into tasks/subtasks/deps
53
+ ```
54
+
55
+ When the entity is a **task or subtask**, resolve its parent epic ID from the
56
+ entity record and scope session/suggest/progress calls to that epic.
57
+
58
+ ## Reference guides
59
+
60
+ This skill ships with bundled reference guides for planning and execution. Read
61
+ them when the task calls for it — they extend this command reference with
62
+ methodology and orchestration patterns.
63
+
64
+ | When | Read | What it covers |
65
+ |---|---|---|
66
+ | User asks to plan, design, or architect a feature | `reference/planning.md` | Decomposition into epic/task/subtask DAGs, writing standard, file scopes, owner assignment, dependency modeling, validation |
67
+ | User asks to execute, implement, or complete an epic | `reference/execution.md` | Execution graph building, lane grouping, sub-agent dispatch, task done orchestration, verification, cleanup |
68
+ | User asks to execute task with Agent Team (or just team) AND Agent Teams are available (`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=true`) | `reference/execution-with-team.md` | TeamCreate/SendMessage pattern, teammate spawning, team coordination, shutdown |
69
+
70
+ **Typical flow:**
71
+ 1. Read `reference/planning.md` and create the epic with tasks, subtasks, deps,
72
+ owners.
73
+ 2. Read `reference/execution.md` (or `reference/execution-with-team.md` for Agent
74
+ Teams), run `session --epic`, build lane groups, dispatch agents, use
75
+ `task done` responses to orchestrate waves.
76
+ 3. This file (SKILL.md) provides the command reference and status machine rules
77
+ that both planning and execution rely on.
78
+
13
79
  ## Non-negotiable defaults
14
80
 
15
81
  - Always include `--toon` on every Trekoon command.
@@ -23,9 +89,60 @@ pick the right command with the fewest reads and mutations.
23
89
  - Keep `.trekoon` gitignored; do not commit the SQLite DB as a recovery fix.
24
90
  - Never run `trekoon wipe --yes --toon` unless the user explicitly asks for it.
25
91
 
92
+ ## Status machine
93
+
94
+ Trekoon enforces a status transition graph. Only these transitions are valid:
95
+
96
+ | From | Allowed targets |
97
+ |---|---|
98
+ | `todo` | `in_progress`, `blocked` |
99
+ | `in_progress` | `done`, `blocked` |
100
+ | `blocked` | `in_progress`, `todo` |
101
+ | `done` | `in_progress` |
102
+
103
+ Invalid transitions (e.g. `todo → done`) return error code
104
+ `status_transition_invalid`. Always transition through `in_progress` to reach
105
+ `done`.
106
+
107
+ **Exception:** `task done` auto-transitions through `in_progress` when the task
108
+ is in `todo` or `blocked` status, so you can call `task done` from any
109
+ non-done status.
110
+
111
+ Recommended statuses for consistent workflows: `todo`, `in_progress`, `done`.
112
+ Use `blocked` with an appended reason when work is stuck.
113
+
114
+ ## Epic lifecycle
115
+
116
+ The orchestrator is responsible for managing the epic's status throughout
117
+ execution. Epics follow the same status machine as tasks — they must transition
118
+ through `in_progress` to reach `done`.
119
+
120
+ ### Start: mark epic `in_progress`
121
+
122
+ Immediately after session bootstrap and before dispatching any work, transition
123
+ the epic:
124
+
125
+ ```bash
126
+ trekoon --toon epic update <epic-id> --status in_progress
127
+ ```
128
+
129
+ This ensures the epic reflects actual state even if execution is interrupted.
130
+
131
+ ### Finish: mark epic `done`
132
+
133
+ After all tasks are verified done (see cleanup in execution references), mark
134
+ the epic complete:
135
+
136
+ ```bash
137
+ trekoon --toon epic update <epic-id> --status done
138
+ ```
139
+
140
+ Since the epic is already `in_progress` from the start step, this is a single
141
+ valid transition.
142
+
26
143
  ## Default agent loop
27
144
 
28
- The primary loop is: **session → work → task done → repeat**.
145
+ The primary loop is: **session → claim → work → task done → repeat**.
29
146
 
30
147
  ### 1. Orient with a single call
31
148
 
@@ -33,55 +150,141 @@ The primary loop is: **session → work → task done → repeat**.
33
150
  trekoon --toon session
34
151
  ```
35
152
 
36
- `session` replaces the old five-call bootstrap sequence
37
- (init + sync status + task next + dep list + task show) with a single DB open.
38
- It returns diagnostics, sync status, the full next-task tree with subtasks, blocker
39
- list, and readiness counts in one envelope.
153
+ If you already know which epic you are working on, scope the session:
40
154
 
41
- Fail fast if the envelope reports `recoveryRequired`, a storage mismatch, or any
42
- bootstrap error. In linked worktrees, `sharedStorageRoot` may differ from
43
- `worktreeRoot`; that is expected because the repo shares one DB across checkouts.
155
+ ```bash
156
+ trekoon --toon session --epic <epic-id>
157
+ ```
44
158
 
45
- If the session envelope shows `behind > 0`, pull before claiming any task:
159
+ `session` returns diagnostics, sync status, the next ready task with subtrees,
160
+ blocker list, and readiness counts in one envelope. Use `--compact` to reduce
161
+ output size when you do not need contract metadata:
46
162
 
47
163
  ```bash
48
- trekoon --toon sync pull --from main
164
+ trekoon --toon --compact session
49
165
  ```
50
166
 
51
- This syncs tracker events (not git commits) from the source branch so task
52
- states, dependencies, and subtrees are up to date before you start work.
167
+ **After session returns, follow this decision tree in order:**
168
+
169
+ 1. **`recoveryRequired` is true?** → Stop. Run `trekoon --toon init` and
170
+ re-check.
171
+ 2. **`behind > 0`?** → Sync first: `trekoon --toon sync pull --from main`.
172
+ This pulls tracker events (not git commits) so task states are current.
173
+ 3. **`pendingConflicts > 0`?** → Resolve before claiming work:
174
+ `trekoon --toon sync conflicts list`.
175
+ 4. **Session returned a next task?** → Proceed to step 2 (claim work).
176
+ 5. **No next task and unsure what to do?** → Run `trekoon --toon suggest` for
177
+ priority-ranked recommendations (see step 1b below).
178
+
179
+ ### 1b. Get suggestions when stuck
180
+
181
+ When the session has no clear next task, or you are unsure what action to take:
182
+
183
+ ```bash
184
+ trekoon --toon suggest
185
+ trekoon --toon suggest --epic <epic-id>
186
+ ```
187
+
188
+ `suggest` inspects recovery state, sync status, readiness, and epic progress,
189
+ then returns up to 3 suggestions ranked by priority. Each suggestion includes a
190
+ category (`recovery`, `sync`, `execution`, `planning`), a reason, and a
191
+ ready-to-run command you can execute directly.
192
+
193
+ Suggest respects the status machine — it will never recommend an invalid
194
+ transition. Use it:
195
+ - At session start when `readyCount` is 0 and you need guidance.
196
+ - Mid-loop when all tasks are blocked and you need to decide what to unblock.
197
+ - Before closing an epic to confirm the right next step.
198
+
199
+ ### 1c. Check epic progress
200
+
201
+ When you need a quick dashboard before or during work on an epic:
202
+
203
+ ```bash
204
+ trekoon --toon epic progress <epic-id>
205
+ ```
206
+
207
+ Returns done/in_progress/blocked/todo counts, ready task count, and the next
208
+ candidate. Use this:
209
+ - Before starting a work session to gauge how much remains.
210
+ - After completing several tasks to report progress to the user.
211
+ - To decide whether an epic is ready to be marked done.
53
212
 
54
213
  ### 2. Claim work explicitly
55
214
 
215
+ Once you know which task to work on, claim it:
216
+
56
217
  ```bash
57
218
  trekoon --toon task update <task-id> --status in_progress
58
219
  ```
59
220
 
60
- ### 3. Finish or report a block
221
+ Optionally assign ownership when multiple agents or people are working:
61
222
 
62
223
  ```bash
63
- trekoon --toon task done <task-id>
224
+ trekoon --toon task update <task-id> --status in_progress --owner <name>
225
+ ```
226
+
227
+ Owner is for tracking who is responsible. Set it on tasks or subtasks:
228
+
229
+ ```bash
230
+ trekoon --toon task update <task-id> --owner alice
231
+ trekoon --toon subtask update <subtask-id> --owner bob
232
+ ```
233
+
234
+ ### 3. Work on the task
235
+
236
+ While working, append progress notes:
237
+
238
+ ```bash
239
+ trekoon --toon task update <task-id> --append "Started implementation"
64
240
  trekoon --toon task update <task-id> --append "Blocked by <reason>" --status blocked
65
241
  ```
66
242
 
67
- `task done` replaces the old three-call transition sequence
68
- (mark done + get next + load deps + show task) with a single call that marks the
69
- task done and returns the next ready candidate with its full tree and blockers.
243
+ ### 4. Finish or report a block
70
244
 
71
- Append a completion note before calling `task done` when useful:
245
+ When done, append a completion note then mark done:
72
246
 
73
247
  ```bash
74
248
  trekoon --toon task update <task-id> --append "Completed implementation and checks"
75
249
  trekoon --toon task done <task-id>
76
250
  ```
77
251
 
78
- ### 4. Repeat
252
+ `task done` works from any non-done status (`todo`, `in_progress`, `blocked`).
253
+ It auto-transitions through `in_progress` when needed. The response includes:
79
254
 
80
- Run `session` again at the start of each new session. After `task done`, the
81
- returned next-task envelope is sufficient to continue; a fresh `session` call is
82
- not required mid-loop unless you need updated diagnostics or sync status.
255
+ - **Next candidate**: the next ready task with its full tree and blockers.
256
+ - **Unblocked tasks**: downstream tasks that became ready after this completion.
257
+ Use this to decide what to claim next or to launch parallel work.
258
+ - **Open subtask warning**: if subtasks remain incomplete (completion still
259
+ proceeds, but the warning is surfaced so you can decide whether to go back).
83
260
 
84
- Recommended statuses for consistent workflows: `todo`, `in_progress`, `done`.
261
+ If blocked instead of done:
262
+
263
+ ```bash
264
+ trekoon --toon task update <task-id> --append "Blocked by <reason>" --status blocked
265
+ ```
266
+
267
+ ### 5. Repeat
268
+
269
+ After `task done`, the returned next-task envelope is sufficient to continue
270
+ the loop from step 2. A fresh `session` call is not required mid-loop unless
271
+ you need updated diagnostics, sync status, or want to switch epics.
272
+
273
+ Run `session` again at the start of each new conversation session.
274
+
275
+ **When to use each command during the loop:**
276
+
277
+ | Situation | Command |
278
+ |---|---|
279
+ | Start of session | `session` or `session --epic <id>` |
280
+ | Unsure what to do next | `suggest` or `suggest --epic <id>` |
281
+ | Quick progress check | `epic progress <epic-id>` |
282
+ | Claim a task | `task update <id> --status in_progress` |
283
+ | Assign ownership | `task update <id> --owner <name>` |
284
+ | Log progress | `task update <id> --append "..."` |
285
+ | Mark done | `task done <id>` |
286
+ | Report blocker | `task update <id> --append "..." --status blocked` |
287
+ | Reduce output noise | Add `--compact` to any command |
85
288
 
86
289
  ## Read policy: use the smallest sufficient read
87
290
 
@@ -90,6 +293,9 @@ Use the narrowest command that answers the question.
90
293
  | Need | Preferred command |
91
294
  |---|---|
92
295
  | Session startup (diagnostics + sync + next task) | `trekoon --toon session` |
296
+ | Session scoped to one epic | `trekoon --toon session --epic <epic-id>` |
297
+ | Next-action suggestions | `trekoon --toon suggest` |
298
+ | Epic progress dashboard | `trekoon --toon epic progress <epic-id>` |
93
299
  | Next task only | `trekoon --toon task next` |
94
300
  | A few ready options | `trekoon --toon task ready --limit 5` |
95
301
  | Direct blockers for one task | `trekoon --toon dep list <task-id>` |
@@ -99,8 +305,8 @@ Use the narrowest command that answers the question.
99
305
  | Repeated text in one scope | `trekoon --toon epic|task|subtask search ...` |
100
306
 
101
307
  Avoid broad scans such as `task list --all` or `epic show --all` when
102
- `task next`, `task ready`, `dep list`, `dep reverse`, or `search` can answer the
103
- question more cheaply.
308
+ `task next`, `task ready`, `dep list`, `dep reverse`, `suggest`, or `search`
309
+ can answer the question more cheaply.
104
310
 
105
311
  ## Creation policy: prefer bulk planning workflows
106
312
 
@@ -203,12 +409,18 @@ trekoon --toon dep add-many \
203
409
  Use descriptions as the durable work log. For progress updates, append instead
204
410
  of rewriting full descriptions.
205
411
 
412
+ Status transitions must follow the status machine (see above). Use `in_progress`
413
+ as the intermediate step to reach `done`. Direct `todo → done` is invalid via
414
+ `task update`; use `task done` instead, which auto-transitions.
415
+
206
416
  ### Preferred patterns
207
417
 
208
418
  ```bash
209
419
  trekoon --toon task update <task-id> --append "Started implementation" --status in_progress
210
- trekoon --toon task update <task-id> --append "Completed implementation and checks" --status done
420
+ trekoon --toon task update <task-id> --append "Completed implementation and checks"
421
+ trekoon --toon task done <task-id>
211
422
  trekoon --toon task update <task-id> --append "Blocked by <reason>" --status blocked
423
+ trekoon --toon task update <task-id> --owner alice
212
424
  ```
213
425
 
214
426
  ### Bulk update rules
@@ -330,3 +542,39 @@ Cross-branch sync matters before merging a feature branch back:
330
542
  Trekoon stores local state in `.trekoon/trekoon.db`. In git repos and
331
543
  worktrees, storage resolves from the shared repository root rather than each
332
544
  worktree independently.
545
+
546
+ ## Tool selection
547
+
548
+ Check your available tool list to determine which harness you are running in.
549
+
550
+ ### Core tools (both harnesses)
551
+
552
+ | Purpose | Claude Code | OpenCode |
553
+ |---------|------------|----------|
554
+ | File search | `Glob` | `glob` |
555
+ | Content search | `Grep` | `grep` |
556
+ | Read files | `Read` | `read` |
557
+ | Edit files | `Edit` | `edit` |
558
+ | Write files | `Write` | `write` |
559
+ | Shell commands | `Bash` | `bash` |
560
+ | Ask user | `AskUserQuestion` | `question` |
561
+ | Web fetch | `WebFetch` | `webfetch` |
562
+ | Web search | `WebSearch` | `websearch` |
563
+ | Directory listing | `Bash(ls)` | `list` |
564
+
565
+ ### LSP tools (OpenCode only — use if available)
566
+
567
+ - `lsp goToDefinition`/`lsp findReferences`: navigate symbols safely.
568
+ - `lsp hover`: inspect type signatures.
569
+ - `lsp documentSymbol`/`lsp workspaceSymbol`: search symbols.
570
+ - `lsp goToImplementation`: find interface implementations.
571
+
572
+ **Fallbacks:** use `Grep`/`grep` for symbols, `Bash`/`bash` for compiler
573
+ diagnostics.
574
+
575
+ ### General guidance
576
+
577
+ - Do not overuse bash for searching/reading; prefer dedicated tools.
578
+ - Use LSP over grep for symbol navigation when available.
579
+ - Run Trekoon, git, build/lint/test, and verification commands via `Bash`/`bash`.
580
+ - Use `--compact` on Trekoon commands in sub-agent prompts to reduce token usage.
@@ -0,0 +1,213 @@
1
+ # Execution with Agent Teams Reference
2
+
3
+ **You are a team lead orchestrator.** Execute work from Trekoon using Agent
4
+ Teams — real parallel Claude Code instances coordinated via TeamCreate,
5
+ TaskCreate, SendMessage, and shared task lists. Each teammate runs in its own
6
+ tmux pane.
7
+
8
+ **Prerequisite:** Agent Teams requires the Claude Code environment variable
9
+ `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` set to `"true"`. This feature is Claude
10
+ Code only — it is not available in OpenCode or other harnesses.
11
+
12
+ - [Claude Agent Teams documentation](https://code.claude.com/docs/en/agent-teams.md)
13
+
14
+ **Clarify ambiguity upfront.** If the plan has unclear requirements or meaningful
15
+ tradeoffs, ask the user before starting.
16
+
17
+ ## Build the execution graph
18
+
19
+ Same as the standard execution reference — use `task ready`, `dep reverse`, and
20
+ lane grouping to construct a runnable graph. See `reference/execution.md` for
21
+ the full scheduler loop and lane grouping rules.
22
+
23
+ ## Mark epic in-progress
24
+
25
+ Before dispatching any work, transition the epic so it reflects actual state:
26
+
27
+ ```bash
28
+ trekoon --toon epic update <epic-id> --status in_progress
29
+ ```
30
+
31
+ This must happen once, immediately after building the execution graph. If
32
+ execution is interrupted, the epic is at least `in_progress` rather than `todo`.
33
+
34
+ ## Create the team
35
+
36
+ Use **TeamCreate** to set up the team, then **TaskCreate** to populate the
37
+ shared task list, then **Agent** with `team_name` to spawn teammates.
38
+
39
+ ### Step 1: Create the team
40
+
41
+ ```
42
+ TeamCreate:
43
+ team_name: "<epic-slug>"
44
+ description: "Executing epic <epic-id>: <title>"
45
+ ```
46
+
47
+ ### Step 2: Create tasks in the shared task list
48
+
49
+ For each task group from the execution graph, create a task:
50
+
51
+ ```
52
+ TaskCreate:
53
+ subject: "<lane description>: <task-ids/titles>"
54
+ description: |
55
+ Execute these Trekoon tasks IN ORDER unless task description says
56
+ parallel subtasks:
57
+ - Task <id>: <title>
58
+ - Task <id>: <title>
59
+
60
+ Before starting each task:
61
+ - claim and assign owner:
62
+ trekoon --toon task update <id> --status in_progress --owner <lane-name>
63
+ - append a short start note:
64
+ trekoon --toon task update <id> --append "Starting implementation"
65
+
66
+ While executing:
67
+ - complete required subtasks, update subtask statuses
68
+ - append meaningful progress notes (do not rewrite task description)
69
+ - respect the status machine: todo -> in_progress -> done (never skip)
70
+ - use --compact to reduce output noise:
71
+ trekoon --toon --compact task show <id>
72
+
73
+ On completion:
74
+ - append final verification evidence
75
+ - mark done: trekoon --toon task done <id>
76
+ (task done auto-transitions from todo/blocked through in_progress)
77
+ - read the response: it includes unblocked downstream tasks and open
78
+ subtask warnings — report these back via SendMessage
79
+
80
+ If blocked:
81
+ - append blocker reason, dependency id, and exact failing command/output
82
+ - set status: trekoon --toon task update <id> --status blocked
83
+ - notify team lead via SendMessage with blocker details
84
+
85
+ Commit after each edit tool usage.
86
+ Report: files changed, test results
87
+
88
+ **Commit format**:
89
+ <imperative verb> <what changed> <- Line 1: max 50 chars
90
+ <blank line> <- Line 2: blank
91
+ <why/context, one point per line> <- Body: max 72 chars per line
92
+ ```
93
+
94
+ Use `blockedBy` via TaskUpdate to set dependencies between tasks that require
95
+ sequential execution.
96
+
97
+ ### Step 3: Spawn teammates
98
+
99
+ For each parallel lane, spawn a teammate using the Agent tool:
100
+
101
+ ```
102
+ Agent:
103
+ name: "developer-1"
104
+ team_name: "<epic-slug>"
105
+ subagent_type: "general-purpose"
106
+ description: "<lane>: <task titles>"
107
+ prompt: |
108
+ You are a developer on team "<epic-slug>".
109
+ Check TaskList for your assigned tasks and work through them.
110
+ Use TaskUpdate to claim tasks (set owner to your name) and mark
111
+ them completed.
112
+
113
+ Status machine rules:
114
+ - todo -> in_progress -> done (valid)
115
+ - todo -> done (INVALID — use task done which auto-transitions)
116
+ - in_progress -> blocked (valid, with reason)
117
+ - blocked -> in_progress (valid, to resume)
118
+
119
+ When you complete a Trekoon task with `task done`, read the response:
120
+ - unblocked: tasks that became ready — report via SendMessage
121
+ - warning: open subtasks — report via SendMessage
122
+ - next: next ready candidate
123
+
124
+ Communicate with teammates via SendMessage if you need coordination.
125
+ After completing a task, check TaskList for the next available task.
126
+ ```
127
+
128
+ **Teammate count:** 3-5 teammates for most epics. Don't over-parallelize.
129
+
130
+ **Agent types:**
131
+ - Use `general-purpose` for implementation work (has edit/write/bash access)
132
+ - Use `Explore` or `Plan` only for read-only research or planning tasks
133
+
134
+ ## Coordinate as team lead
135
+
136
+ Your job as team lead:
137
+
138
+ 1. **Monitor progress** — teammates send messages when they complete tasks or
139
+ hit blockers.
140
+ 2. **Use task done responses** — when a teammate reports `unblocked` tasks from
141
+ a `task done` response, create new team tasks via TaskCreate for the
142
+ unblocked work and assign to idle teammates.
143
+ 3. **Unblock work** — when a teammate reports a blocker, help resolve it or
144
+ reassign.
145
+ 4. **Assign ownership** — use TaskUpdate with `owner` to assign tasks to idle
146
+ teammates. Also set Trekoon owner:
147
+ ```bash
148
+ trekoon --toon task update <task-id> --owner <teammate-name>
149
+ ```
150
+ 5. **Send messages** — use SendMessage to direct teammates, never plain text
151
+ output.
152
+ 6. **Check progress** — periodically run `epic progress` to gauge completion:
153
+ ```bash
154
+ trekoon --toon epic progress <epic-id>
155
+ ```
156
+ 7. **Get suggestions when stuck** — when all teammates are blocked:
157
+ ```bash
158
+ trekoon --toon suggest --epic <epic-id>
159
+ ```
160
+
161
+ ## Auto-recovery
162
+
163
+ 1. If status update fails with `status_transition_invalid`, check current status
164
+ and use the valid intermediate transition.
165
+ 2. If status update fails with `dependency_blocked`, refresh with
166
+ `task ready`/`task next` and continue with a ready candidate.
167
+ 3. Teammate attempts to fix failures (has context).
168
+ 4. If can't fix, teammate reports failure with error output via SendMessage.
169
+ 5. Dispatch fix instructions via SendMessage to the teammate.
170
+ 6. Same error twice -> stop and ask user.
171
+
172
+ ## Verify and close
173
+
174
+ Same verification steps as the standard execution reference: code review,
175
+ automated tests, manual verification, DX quality, record evidence, final
176
+ progress check. See `reference/execution.md` for details.
177
+
178
+ ## Shutdown and cleanup
179
+
180
+ After all work is verified:
181
+
182
+ 1. **Check everything is done:**
183
+ ```bash
184
+ trekoon --toon epic progress <epic-id>
185
+ ```
186
+
187
+ 2. **Confirm nothing remains:**
188
+ ```bash
189
+ trekoon --toon suggest --epic <epic-id>
190
+ ```
191
+ Should return no actionable suggestions.
192
+
193
+ 3. **Mark epic done** (already `in_progress` from the start step):
194
+ ```bash
195
+ trekoon --toon epic update <epic-id> --status done
196
+ ```
197
+
198
+ 4. **Shutdown teammates** — send `shutdown_request` via SendMessage to each.
199
+ 5. **Delete the team** — use TeamDelete to clean up team and task directories.
200
+ 6. Merge branch to main (if using branches).
201
+ 7. Remove worktree (if using worktrees).
202
+ 8. Return final execution summary: completed tasks, remaining blockers,
203
+ dependency state.
204
+
205
+ ## Team orchestration tools
206
+
207
+ | Purpose | Tool |
208
+ |---------|------|
209
+ | Create the team | `TeamCreate` |
210
+ | Manage shared task list | `TaskCreate` / `TaskList` / `TaskUpdate` / `TaskGet` |
211
+ | Spawn teammates | `Agent` (with `team_name`) |
212
+ | Communicate | `SendMessage` |
213
+ | Clean up | `TeamDelete` |