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
package/docs/ai-agents.md CHANGED
@@ -15,9 +15,21 @@ agent to:
15
15
  - preview scoped replace before `--apply`
16
16
  - treat `.trekoon` as shared repo-scoped operational state
17
17
 
18
- The canonical installed file lives at:
18
+ The skill ships with bundled reference guides for planning and execution so the
19
+ agent can handle the full plan-to-completion workflow from a single skill:
19
20
 
20
- - `.agents/skills/trekoon/SKILL.md`
21
+ ```
22
+ .agents/skills/trekoon/
23
+ SKILL.md ← command reference, status machine, agent loop
24
+ reference/
25
+ planning.md ← decomposition, writing standard, validation
26
+ execution.md ← graph building, lane dispatch, verification
27
+ execution-with-team.md ← Agent Teams pattern (Claude Code only)
28
+ ```
29
+
30
+ The agent reads the relevant reference file on demand — `planning.md` when asked
31
+ to plan, `execution.md` when asked to execute, `execution-with-team.md` when Agent
32
+ Teams are available.
21
33
 
22
34
  ## Install the skill
23
35
 
@@ -46,34 +58,58 @@ Path behavior:
46
58
  - `--to <path>` changes only the editor link root
47
59
  - `--allow-outside-repo` is for intentional external links
48
60
 
49
- ## Recommended skill stack
61
+ ## Using the skill with arguments
62
+
63
+ The skill accepts an optional entity ID and action text:
64
+
65
+ ```
66
+ /trekoon → loads the skill normally
67
+ /trekoon <id> → resolves the entity, shows status and next steps
68
+ /trekoon <id> analyze → runs epic progress + suggest, reports findings
69
+ /trekoon <id> execute → starts the execution loop for the entity's epic
70
+ /trekoon <id> plan the implementation → decomposes into tasks/subtasks/deps
71
+ ```
72
+
73
+ The skill resolves the ID as an epic, task, or subtask. For tasks and subtasks,
74
+ it scopes session/suggest/progress calls to the parent epic automatically.
50
75
 
51
- If your agent environment supports skills, this is the cleanest split of
52
- responsibilities:
76
+ ## Skill stack
53
77
 
54
- | Job | Skill | Why |
78
+ The `trekoon` skill is self-contained for the full plan-to-completion workflow.
79
+ It bundles planning methodology, execution orchestration, and the command
80
+ reference in one install.
81
+
82
+ For specialized needs, these optional companion skills add value:
83
+
84
+ | Job | Skill | When to use |
55
85
  | --- | --- | --- |
56
- | Turn a request into a concrete backlog | `writing-plans` | Breaks work into epics, tasks, subtasks, and dependencies |
57
- | Create and update tracker state | `trekoon` | Uses Trekoon safely and efficiently |
58
- | Execute the plan in dependency order | `executing-plans` | Helps the agent work through the backlog without losing the sequence |
59
- | Clarify architecture before planning | `architecting-systems` | Useful when boundaries or ownership are still fuzzy |
86
+ | Clarify architecture before planning | `architecting-systems` | Boundaries or ownership are still fuzzy |
87
+ | Specialized code review | `code-review-expert` | Want structured review before closing an epic |
60
88
 
61
- In practice, the flow is usually:
89
+ In practice, the flow is:
62
90
 
63
- 1. plan the work
64
- 2. load `trekoon`
65
- 3. create or update the Trekoon graph
66
- 4. execute the next ready task
67
- 5. update progress, blockers, and completion state as work moves forward
91
+ 1. `/trekoon` — load the skill
92
+ 2. Plan the work (skill reads `reference/planning.md` internally)
93
+ 3. Create or update the Trekoon graph
94
+ 4. Execute the plan (skill reads `reference/execution.md` internally)
95
+ 5. Update progress, blockers, and completion state as work moves forward
68
96
 
69
97
  ## Default execution loop for agents
70
98
 
71
99
  The main loop is: **session → work → task done → repeat**.
72
100
 
73
- Start with a single orientation call:
101
+ Start with a single orientation call, optionally scoped to an epic:
74
102
 
75
103
  ```bash
76
104
  trekoon --toon session
105
+ trekoon --toon session --epic <epic-id>
106
+ ```
107
+
108
+ Or use `suggest` for priority-ranked next-action recommendations:
109
+
110
+ ```bash
111
+ trekoon --toon suggest
112
+ trekoon --toon suggest --epic <epic-id>
77
113
  ```
78
114
 
79
115
  If the session output shows you are behind, pull tracker events before claiming
@@ -83,16 +119,50 @@ work:
83
119
  trekoon --toon sync pull --from main
84
120
  ```
85
121
 
86
- Claim work, then finish or report a block:
122
+ Claim work, assign ownership, then finish or report a block:
87
123
 
88
124
  ```bash
89
- trekoon --toon task update <task-id> --status in_progress
125
+ trekoon --toon task update <task-id> --status in_progress --owner "agent-1"
90
126
  trekoon --toon task done <task-id>
91
127
  trekoon --toon task update <task-id> --append "Blocked by <reason>" --status blocked
92
128
  ```
93
129
 
94
130
  Use `task done` when the task is actually finished. It marks the task complete
95
- and returns the next ready candidate with blockers inline.
131
+ and returns the next ready candidate with blockers inline. `task done`
132
+ auto-transitions through `in_progress` when the current status is `todo` or
133
+ `blocked`. The response also reports newly unblocked downstream tasks and warns
134
+ about incomplete subtasks.
135
+
136
+ Use `--compact` to strip contract metadata from envelopes when you do not need
137
+ it:
138
+
139
+ ```bash
140
+ trekoon --toon --compact task done <task-id>
141
+ ```
142
+
143
+ ## Status machine rules
144
+
145
+ Trekoon enforces valid status transitions. Do not attempt direct jumps like
146
+ `todo → done` — they will fail with `status_transition_invalid`. Use `task done`
147
+ for completing tasks (it handles the intermediate step automatically).
148
+
149
+ Valid transitions:
150
+
151
+ | From | Allowed targets |
152
+ | --- | --- |
153
+ | `todo` | `in_progress`, `blocked` |
154
+ | `in_progress` | `done`, `blocked` |
155
+ | `blocked` | `in_progress`, `todo` |
156
+ | `done` | `in_progress` |
157
+
158
+ ## Track epic progress
159
+
160
+ Use `epic progress` to get a summary of task status counts and the next ready
161
+ candidate for an epic:
162
+
163
+ ```bash
164
+ trekoon --toon epic progress <epic-id>
165
+ ```
96
166
 
97
167
  ## Use descendant cascade mode when closing a whole tree
98
168
 
@@ -119,29 +189,34 @@ Notes:
119
189
 
120
190
  ## Tell the agent exactly what to do
121
191
 
122
- These prompts work well because they are explicit about the skill order and the
123
- expected loop.
192
+ These prompts work well because they are explicit about the expected workflow.
124
193
 
125
194
  ### Plan first, then create the backlog
126
195
 
127
196
  ```text
128
- Load writing-plans, break this feature into one epic with tasks and subtasks,
129
- then load trekoon and create that graph in Trekoon.
197
+ /trekoon plan this feature as one epic with tasks, subtasks, and dependencies,
198
+ then create the graph in Trekoon.
130
199
  ```
131
200
 
132
201
  ### Execute an existing backlog
133
202
 
134
203
  ```text
135
- Load trekoon, run `trekoon --toon session`, take the next ready task, do the
136
- work, append progress notes, mark it done, and repeat until there are no ready
137
- tasks or you hit a blocker.
204
+ /trekoon <epic-id> execute
205
+ ```
206
+
207
+ Or more explicitly:
208
+
209
+ ```text
210
+ /trekoon — run session, take the next ready task, do the work, append progress
211
+ notes, mark it done, and repeat until there are no ready tasks or you hit a
212
+ blocker.
138
213
  ```
139
214
 
140
- ### Use planning, tracking, and execution together
215
+ ### Plan and execute end to end
141
216
 
142
217
  ```text
143
- Load writing-plans to shape the backlog, load trekoon to create and update the
144
- tasks, then load executing-plans and complete the work in dependency order.
218
+ /trekoon plan this feature, create the backlog, then execute the tasks in
219
+ dependency order until the epic is complete.
145
220
  ```
146
221
 
147
222
  ## Keep reads small and mutations safe
@@ -151,6 +226,9 @@ Use the narrowest command that answers the question:
151
226
  | Need | Preferred command |
152
227
  | --- | --- |
153
228
  | Session startup | `trekoon --toon session` |
229
+ | Session scoped to epic | `trekoon --toon session --epic <epic-id>` |
230
+ | Next-action suggestions | `trekoon --toon suggest` |
231
+ | Epic progress summary | `trekoon --toon epic progress <epic-id>` |
154
232
  | Next task only | `trekoon --toon task next` |
155
233
  | A few ready options | `trekoon --toon task ready --limit 5` |
156
234
  | One task with subtasks | `trekoon --toon task show <task-id> --all` |
package/docs/commands.md CHANGED
@@ -9,8 +9,9 @@ surface, defaults, and flag rules.
9
9
  - `trekoon board <open|update>`
10
10
  - `trekoon help [command]`
11
11
  - `trekoon quickstart`
12
- - `trekoon epic <create|expand|list|show|search|replace|update|delete>`
13
- - `trekoon session`
12
+ - `trekoon epic <create|expand|list|show|search|replace|update|delete|progress>`
13
+ - `trekoon session [--epic <epic-id>]`
14
+ - `trekoon suggest [--epic <epic-id>]`
14
15
  - `trekoon task <create|create-many|list|show|ready|next|done|search|replace|update|delete>`
15
16
  - `trekoon subtask <create|create-many|list|search|replace|update|delete>`
16
17
  - `trekoon dep <add|add-many|remove|list|reverse>`
@@ -25,6 +26,7 @@ surface, defaults, and flag rules.
25
26
 
26
27
  - `--json` for structured JSON output
27
28
  - `--toon` for true TOON-encoded output
29
+ - `--compact` strips contract metadata from TOON/JSON envelopes
28
30
  - `--compat <mode>` for explicit machine compatibility behavior
29
31
  - `--help` for root and command help
30
32
  - `--version` for CLI version
@@ -119,8 +121,8 @@ Board API endpoints (all require token authentication):
119
121
  - `GET /api/snapshot` — full board state (epics, tasks, subtasks, dependencies,
120
122
  counts)
121
123
  - `PATCH /api/epics/{id}` — update epic title, description, or status
122
- - `PATCH /api/tasks/{id}` — update task title, description, or status
123
- - `PATCH /api/subtasks/{id}` — update subtask title, description, or status
124
+ - `PATCH /api/tasks/{id}` — update task title, description, status, or owner
125
+ - `PATCH /api/subtasks/{id}` — update subtask title, description, status, or owner
124
126
  - `POST /api/subtasks` — create subtask (requires taskId, title)
125
127
  - `DELETE /api/subtasks/{id}` — delete subtask
126
128
  - `POST /api/dependencies` — add dependency edge (sourceId, dependsOnId)
@@ -149,7 +151,7 @@ trekoon board update
149
151
 
150
152
  These defaults apply to `epic list`, `task list`, and `subtask list`:
151
153
 
152
- - Default scope: open work only (`in_progress`, `in-progress`, `todo`)
154
+ - Default scope: open work only (`in_progress`, `todo`)
153
155
  - Default limit: `10`
154
156
  - Status filter: `--status in_progress,todo`
155
157
  - Custom limit: `--limit <n>`
@@ -217,6 +219,80 @@ trekoon task update <task-id> --all --status todo
217
219
  trekoon subtask update <subtask-id> --all --status done
218
220
  ```
219
221
 
222
+ ## Status machine
223
+
224
+ Trekoon enforces a status machine for all entities. The canonical statuses are
225
+ `todo`, `in_progress`, `done`, and `blocked`. The hyphenated `in-progress`
226
+ variant is no longer accepted.
227
+
228
+ **Upgrading from 0.3.0:** Existing entities with `in-progress` or other custom
229
+ statuses are handled gracefully — transitions from non-canonical statuses to any
230
+ valid status are allowed, so you can update them to `in_progress` without error.
231
+
232
+ Valid transitions:
233
+
234
+ | From | Allowed targets |
235
+ | --- | --- |
236
+ | `todo` | `in_progress`, `blocked` |
237
+ | `in_progress` | `done`, `blocked` |
238
+ | `blocked` | `in_progress`, `todo` |
239
+ | `done` | `in_progress` |
240
+
241
+ Invalid transitions return a `status_transition_invalid` error with the current
242
+ status, target status, and allowed transitions.
243
+
244
+ ## Owner field
245
+
246
+ Tasks and subtasks have an optional `owner` field. Set or clear it with the
247
+ `--owner` flag on update commands:
248
+
249
+ ```bash
250
+ trekoon task update <task-id> --owner "agent-1"
251
+ trekoon subtask update <subtask-id> --owner "agent-2"
252
+ ```
253
+
254
+ The board API also accepts `owner` on `PATCH /api/tasks/{id}` and
255
+ `PATCH /api/subtasks/{id}`.
256
+
257
+ ## Task done behavior
258
+
259
+ `trekoon task done <task-id>` marks a task complete and returns the next ready
260
+ candidate. Additional behavior:
261
+
262
+ - Auto-transitions through `in_progress` when the current status is `todo` or
263
+ `blocked`, emitting two sync events for the intermediate step.
264
+ - Reports newly unblocked downstream tasks in the response (`data.unblocked`).
265
+ - Warns when subtasks remain incomplete (`data.warning`,
266
+ `data.openSubtaskCount`, `data.openSubtaskIds`).
267
+
268
+ ## Epic progress
269
+
270
+ ```bash
271
+ trekoon epic progress <epic-id>
272
+ ```
273
+
274
+ Returns status counts (`total`, `doneCount`, `inProgressCount`, `blockedCount`,
275
+ `todoCount`), `readyCount`, and `nextCandidate` for the given epic.
276
+
277
+ ## Session scoping
278
+
279
+ ```bash
280
+ trekoon session --epic <epic-id>
281
+ ```
282
+
283
+ Scopes session readiness to a specific epic instead of the full tracker.
284
+
285
+ ## Suggest command
286
+
287
+ ```bash
288
+ trekoon suggest [--epic <epic-id>]
289
+ ```
290
+
291
+ Returns up to 3 priority-ranked next-action suggestions based on recovery state,
292
+ sync status, task readiness, and epic progress. Categories: `recovery`, `sync`,
293
+ `execution`, `planning`. Each suggestion includes an `action`, `command`, and
294
+ `reason`.
295
+
220
296
  ## Related docs
221
297
 
222
298
  - [Quickstart](quickstart.md)
@@ -246,6 +246,126 @@ Behavior:
246
246
  - machine output includes `metadata.compatibility` with migration guidance and
247
247
  removal timing
248
248
 
249
+ ## Compact envelope mode
250
+
251
+ ```bash
252
+ trekoon --toon --compact task list
253
+ ```
254
+
255
+ When `--compact` is passed, the `metadata` key is omitted from the TOON/JSON
256
+ envelope. The `ok`, `command`, `data`, `error`, and `meta` keys are unaffected.
257
+
258
+ ## Status transition error contract
259
+
260
+ Invalid status transitions return:
261
+
262
+ ```text
263
+ ok: false
264
+ error:
265
+ code: status_transition_invalid
266
+ message: "cannot transition <kind> <id> from '<from>' to '<to>'"
267
+ details:
268
+ entity: epic|task|subtask
269
+ id: <entity-id>
270
+ fromStatus: <current-status>
271
+ toStatus: <attempted-status>
272
+ allowedTransitions[]: <valid targets from current status>
273
+ ```
274
+
275
+ ## Epic progress contract
276
+
277
+ ```bash
278
+ trekoon --toon epic progress <epic-id>
279
+ ```
280
+
281
+ Payload fields:
282
+
283
+ ```text
284
+ ok: true
285
+ command: epic.progress
286
+ data:
287
+ epicId: <epic-id>
288
+ title: <epic-title>
289
+ total
290
+ doneCount
291
+ inProgressCount
292
+ blockedCount
293
+ todoCount
294
+ readyCount
295
+ nextCandidate: { id, title } | null
296
+ ```
297
+
298
+ ## Task done enhanced contract
299
+
300
+ ```bash
301
+ trekoon --toon task done <task-id>
302
+ ```
303
+
304
+ Payload fields:
305
+
306
+ ```text
307
+ ok: true
308
+ command: task.done
309
+ data:
310
+ completed: { ...task record... }
311
+ openSubtaskCount
312
+ openSubtaskIds[]
313
+ warning: "Warning: N subtask(s) still open." | null
314
+ unblocked[]:
315
+ id
316
+ kind: task
317
+ title
318
+ status
319
+ wasBlockedBy[]
320
+ next: { ...task tree... } | null
321
+ nextDeps[]
322
+ readiness:
323
+ readyCount
324
+ blockedCount
325
+ ```
326
+
327
+ ## Suggest command contract
328
+
329
+ ```bash
330
+ trekoon --toon suggest [--epic <epic-id>]
331
+ ```
332
+
333
+ Payload fields:
334
+
335
+ ```text
336
+ ok: true
337
+ command: suggest
338
+ data:
339
+ suggestions[]:
340
+ priority
341
+ action
342
+ command
343
+ reason
344
+ category: recovery|sync|execution|planning
345
+ context:
346
+ totalEpics
347
+ activeEpic: <epic-id> | null
348
+ readyTasks
349
+ blockedTasks
350
+ inProgressTasks
351
+ syncBehind
352
+ pendingConflicts
353
+ ```
354
+
355
+ ## Owner field in update payloads
356
+
357
+ Task and subtask update payloads now include `owner` in their event data:
358
+
359
+ ```text
360
+ data:
361
+ task | subtask:
362
+ ...existing fields...
363
+ owner: <string> | null
364
+ ```
365
+
366
+ The board API accepts `owner` on `PATCH /api/tasks/{id}` and
367
+ `PATCH /api/subtasks/{id}`.
368
+
249
369
  ## Related docs
250
370
 
251
371
  - [Quickstart](quickstart.md)