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
@@ -0,0 +1,210 @@
1
+ # Execution Reference
2
+
3
+ **You are an orchestrator.** Execute work from Trekoon, not markdown plan files.
4
+ Spawn and coordinate sub-agents based on the task dependency graph and subsystem
5
+ grouping so independent lanes run in parallel and dependent lanes run
6
+ sequentially.
7
+
8
+ **Clarify ambiguity upfront.** If the plan has unclear requirements or meaningful
9
+ tradeoffs, ask the user before starting.
10
+
11
+ ## Build the execution graph
12
+
13
+ Construct a runnable graph from Trekoon entities using the deterministic
14
+ scheduler loop:
15
+
16
+ 1. **Get the ready set for batching decisions:**
17
+ ```bash
18
+ trekoon --toon task ready --epic <epic-id> --limit 50
19
+ ```
20
+ 2. **Use reverse lookup when deciding what completed work unblocks:**
21
+ ```bash
22
+ trekoon --toon dep reverse <task-or-subtask-id>
23
+ ```
24
+ 3. **Load full context only when execution details are needed:**
25
+ ```bash
26
+ trekoon --toon epic show <epic-id> --all
27
+ ```
28
+
29
+ Prefer scheduler primitives (`task next`, `task ready`, `dep reverse`) over
30
+ broad scans (`task list --all`, `epic show --all`).
31
+
32
+ ## Group tasks into lanes
33
+
34
+ Batch ready tasks by subsystem/domain to minimize repeated context loading:
35
+
36
+ ```
37
+ Without: Task 1 (auth/login) -> Agent 1 [explores auth/]
38
+ Task 2 (auth/logout) -> Agent 2 [explores auth/ again]
39
+
40
+ With: Tasks 1-2 (auth/*) -> Agent 1 [explores once, executes both]
41
+ ```
42
+
43
+ | Signal | Group together |
44
+ |--------|----------------|
45
+ | Same directory prefix | `src/auth/*` tasks |
46
+ | Same domain/feature | Auth tasks, billing tasks |
47
+ | Same `--owner` value | Tasks assigned to same lane |
48
+ | Same Trekoon intent | Similar task title/description scope |
49
+
50
+ **Limits:** 3-4 tasks max per group. Split if larger.
51
+
52
+ **Parallel:** Groups touch different subsystems.
53
+ **Sequential:** Groups have dependency edges between them.
54
+
55
+ ## Mark epic in-progress
56
+
57
+ Before dispatching any work, transition the epic so it reflects actual state:
58
+
59
+ ```bash
60
+ trekoon --toon epic update <epic-id> --status in_progress
61
+ ```
62
+
63
+ This must happen once, immediately after building the execution graph. If
64
+ execution is interrupted, the epic is at least `in_progress` rather than `todo`.
65
+
66
+ ## Dispatch sub-agents
67
+
68
+ For each parallel lane group, spawn a sub-agent with a prompt like:
69
+
70
+ ```
71
+ Execute these Trekoon tasks IN ORDER unless task description says parallel
72
+ subtasks:
73
+ - Task <id>: <title>
74
+ - Task <id>: <title>
75
+
76
+ Before starting each task:
77
+ - set status to in_progress and assign owner:
78
+ trekoon --toon task update <id> --status in_progress --owner <lane-name>
79
+ - append a short start note:
80
+ trekoon --toon task update <id> --append "Starting implementation"
81
+
82
+ While executing:
83
+ - complete required subtasks, update subtask statuses
84
+ - append meaningful progress notes (do not rewrite the task description)
85
+ - respect the status machine: todo -> in_progress -> done (never skip)
86
+
87
+ On completion:
88
+ - append final verification evidence
89
+ - mark done: trekoon --toon task done <id>
90
+ (task done auto-transitions from todo/blocked through in_progress)
91
+ - read the response: it includes unblocked downstream tasks and open
92
+ subtask warnings — report these back
93
+
94
+ If blocked:
95
+ - append blocker reason, dependency id, and exact failing command/output
96
+ - set status: trekoon --toon task update <id> --status blocked
97
+
98
+ Use --compact to reduce output noise:
99
+ trekoon --toon --compact task show <id>
100
+
101
+ Commit after each edit. Report: files changed, test results.
102
+ ```
103
+
104
+ ## Use task done response for orchestration
105
+
106
+ When a sub-agent calls `task done`, the response includes:
107
+
108
+ - **`unblocked`**: array of downstream tasks that became ready. Use this to
109
+ decide what to launch next without re-querying the full readiness graph.
110
+ - **`openSubtaskIds`/`warning`**: if subtasks remain open, decide whether to
111
+ go back or proceed.
112
+ - **`next`**: the next ready candidate with full tree and blockers.
113
+
114
+ **Orchestration flow after each task done:**
115
+
116
+ 1. Read `unblocked` from the response.
117
+ 2. If unblocked tasks exist, group them by subsystem and dispatch new agents.
118
+ 3. If no unblocked tasks, check `next` for the top candidate.
119
+ 4. If neither exists, run `suggest --epic <id>` for guidance.
120
+
121
+ ## Auto-recovery
122
+
123
+ 1. Agent attempts to fix failures (has context).
124
+ 2. If can't fix, report failure with error output.
125
+ 3. Dispatch fix agent with context.
126
+ 4. Same error twice -> stop and ask user.
127
+
128
+ If a status update fails with `status_transition_invalid`, check current status
129
+ and transition through the valid intermediate step.
130
+
131
+ If a status update fails with `dependency_blocked`, refresh with
132
+ `task ready`/`task next` and continue with a ready candidate.
133
+
134
+ ## Verify before closing
135
+
136
+ All checks must pass before marking the epic complete:
137
+
138
+ ### Code review
139
+
140
+ Run your code-review command/flow. Fix issues before proceeding. Poor DX/UX is
141
+ a bug.
142
+
143
+ ### Automated tests
144
+
145
+ Run the full test suite. All tests must pass.
146
+
147
+ ### Manual verification
148
+
149
+ Automated tests aren't sufficient. Actually exercise the changes:
150
+
151
+ - **API changes:** Curl endpoints with realistic payloads.
152
+ - **External integrations:** Test against real services.
153
+ - **CLI changes:** Run actual commands, verify output.
154
+ - **Parser changes:** Feed real data, not just fixtures.
155
+
156
+ ### DX quality
157
+
158
+ During manual testing, watch for friction: confusing errors, noisy output,
159
+ inconsistent behavior, rough edges. Fix inline or document for follow-up.
160
+
161
+ ### Record evidence
162
+
163
+ Append verification results to Trekoon as progress notes:
164
+
165
+ ```bash
166
+ trekoon --toon task update <task-id> --append "All 358 tests pass, lint clean"
167
+ ```
168
+
169
+ ### Final progress check
170
+
171
+ Before closing the epic, confirm completion state:
172
+
173
+ ```bash
174
+ trekoon --toon epic progress <epic-id>
175
+ ```
176
+
177
+ Verify: `doneCount` equals `total`, `todoCount`/`blockedCount`/`inProgressCount`
178
+ are all 0.
179
+
180
+ ## Cleanup
181
+
182
+ After committing and verifying:
183
+
184
+ 1. **Verify all tasks are done:**
185
+ ```bash
186
+ trekoon --toon epic progress <epic-id>
187
+ ```
188
+ All tasks must be `done` or clearly `blocked` with reason.
189
+
190
+ 2. **Mark epic done** (already `in_progress` from the start step):
191
+ ```bash
192
+ trekoon --toon epic update <epic-id> --status done
193
+ ```
194
+
195
+ 3. **Run suggest to confirm nothing remains:**
196
+ ```bash
197
+ trekoon --toon suggest --epic <epic-id>
198
+ ```
199
+ Should return no actionable suggestions if the epic is cleanly closed.
200
+
201
+ 4. **Create a branch** for the work unless trivial. Merge branch to main when
202
+ done.
203
+
204
+ 5. **Return final execution summary:** completed tasks, remaining blockers,
205
+ dependency state.
206
+
207
+ ## Architectural fit
208
+
209
+ Changes should integrate cleanly with existing patterns. If a change fights the
210
+ architecture, refactor first rather than bolt on. The goal is zero tech debt.
@@ -0,0 +1,244 @@
1
+ # Planning Reference
2
+
3
+ Write implementation plans directly into Trekoon as epics with task/subtask
4
+ DAGs. Plans must be directly executable without re-interpretation.
5
+
6
+ **Clarify ambiguity upfront.** If the plan has unclear requirements or meaningful
7
+ tradeoffs, ask the user before writing. Present options with clear tradeoffs.
8
+ Use multi-select for independent features that can be combined; use single-select
9
+ for mutually exclusive choices.
10
+
11
+ ## Planning data model
12
+
13
+ - **Epic** = full feature outcome and constraints.
14
+ - **Task** = one complete subsystem/domain work unit that can be owned by one
15
+ agent.
16
+ - **Subtask** = concrete implementation/test/verification step under a task.
17
+ - **Dependency edge** = strict prerequisite only (do not add "nice to have"
18
+ dependencies).
19
+
20
+ All entities start in `todo`. See the status machine in the main SKILL.md.
21
+
22
+ Plan implications:
23
+ - Never set initial status to anything other than `todo` in create commands.
24
+ - Task descriptions should reference valid transitions when documenting
25
+ completion flow (e.g., "todo -> in_progress -> done", not "todo -> done").
26
+ - `task done` auto-transitions through `in_progress`, but `task update` does
27
+ not — plan descriptions should note this for agents.
28
+
29
+ ## Information-dense writing standard
30
+
31
+ ### Epic title
32
+
33
+ Use a functional, outcome-oriented format:
34
+
35
+ `<Product/Area>: <deliverable> to <user/system outcome> (<key constraint>)`
36
+
37
+ Example: `Checkout: add idempotent payment capture to prevent duplicate charges
38
+ (Stripe + retries)`
39
+
40
+ ### Epic description
41
+
42
+ Include:
43
+
44
+ 1. **Goal & why now**
45
+ 2. **In scope** (specific capabilities)
46
+ 3. **Out of scope** (explicit exclusions)
47
+ 4. **Success criteria** (testable outcomes)
48
+ 5. **Risks/constraints** (data migration, latency budgets, auth boundaries)
49
+ 6. **Verification gates** (tests, manual checks, perf/security checks)
50
+
51
+ ### Task title
52
+
53
+ Use a structure that encodes subsystem + action + outcome:
54
+
55
+ `[<Subsystem>] <verb> <artifact/interface> to <observable outcome>`
56
+
57
+ Example: `[API/Auth] issue refresh-token rotation endpoint to invalidate
58
+ replayed sessions`
59
+
60
+ ### Task description
61
+
62
+ Must include:
63
+
64
+ - concrete scope and affected paths/symbols
65
+ - acceptance criteria (observable behavior)
66
+ - required tests/verification commands
67
+ - integration constraints (contracts, backward compatibility)
68
+ - explicit "can run in parallel with ..." or "blocked by ..." note
69
+
70
+ **File scope** — declare explicitly so the agent doesn't waste tokens exploring:
71
+
72
+ - **Target files**: files to create or modify
73
+ - **Read-first files**: files the agent should read for context
74
+ - **Do-not-touch**: paths that parallel agents own — prevents merge conflicts
75
+
76
+ **Context loading hints** — point the agent to existing patterns:
77
+
78
+ - Reference a concrete file as the pattern to mirror
79
+ - Name the specific function/class/export to extend or integrate with
80
+ - State project conventions rather than assuming the agent will discover them
81
+
82
+ **Owner assignment** — when the plan has clear subsystem lanes, assign owners in
83
+ task descriptions so the executor knows which agent/person owns each task:
84
+
85
+ ```
86
+ Owner: auth-lane
87
+ Can run in parallel with: billing-lane tasks
88
+ ```
89
+
90
+ Example task description:
91
+
92
+ ```
93
+ Implement refresh-token rotation endpoint.
94
+
95
+ Target files: src/auth/refresh.ts (new), src/auth/refresh.test.ts (new)
96
+ Read first: src/auth/login.ts (follow same handler pattern)
97
+ Do not touch: src/billing/* (owned by billing-lane)
98
+
99
+ Follow the handler pattern in login.ts: schema validation -> service call ->
100
+ response mapping.
101
+
102
+ Acceptance: POST /auth/refresh returns new token pair, invalidates old token.
103
+ Verify: bun test src/auth/refresh.test.ts
104
+ Owner: auth-lane
105
+ Can run in parallel with: billing-lane. Blocked by: task-types (needs AuthToken).
106
+ ```
107
+
108
+ ### Subtask title/description
109
+
110
+ - Titles are imperative and specific, not generic.
111
+ - Description states exact artifact and completion signal.
112
+ - Use subtasks for real units, not filler checklist noise.
113
+ - Inherit file scope from parent task — only override if different files.
114
+
115
+ ## Parallelism & dependencies
116
+
117
+ Model execution lanes intentionally:
118
+
119
+ - Tasks with no dependency edge between them are parallel candidates.
120
+ - Tasks in different subsystems should usually run in parallel.
121
+ - Tasks in the same subsystem should be combined or sequenced.
122
+ - Keep task groups to ~3-4 tasks per active subsystem lane.
123
+
124
+ Dependency policy:
125
+
126
+ 1. Add an edge only for hard prerequisites.
127
+ 2. Prefer task-to-task dependencies; use subtask dependencies only when required.
128
+ 3. Validate acyclic graph assumptions before finalizing.
129
+
130
+ ## Assign owners after creation
131
+
132
+ After creating tasks, assign ownership for multi-agent execution:
133
+
134
+ ```bash
135
+ trekoon --toon task update <task-id> --owner auth-lane
136
+ trekoon --toon task update <task-id> --owner billing-lane
137
+ ```
138
+
139
+ ## Validate the plan
140
+
141
+ After creating the epic, validate before handing off to execution.
142
+
143
+ ### Check progress structure
144
+
145
+ ```bash
146
+ trekoon --toon epic progress <epic-id>
147
+ ```
148
+
149
+ Verify: total count matches expectations, all tasks are in `todo`, ready count
150
+ equals the number of tasks with no dependencies.
151
+
152
+ ### Run suggest to confirm sanity
153
+
154
+ ```bash
155
+ trekoon --toon suggest --epic <epic-id>
156
+ ```
157
+
158
+ `suggest` will surface issues: sync gaps, recovery needs, or unexpected blocker
159
+ states. If it suggests claiming a task, the plan's dependency graph is valid and
160
+ execution-ready.
161
+
162
+ ### Verify dependency graph
163
+
164
+ ```bash
165
+ trekoon --toon task ready --epic <epic-id> --limit 50
166
+ ```
167
+
168
+ Confirm that the expected first-wave tasks appear as ready candidates and
169
+ second-wave tasks appear as blocked with the right dependencies.
170
+
171
+ ## Plan output and handoff
172
+
173
+ After creating the epic and validating, present a summary to the user. This
174
+ summary is the primary handoff artifact — it must be self-contained and
175
+ actionable.
176
+
177
+ ### ID rules
178
+
179
+ - **Always use full UUIDs** for epic and task IDs. Never use temp-keys
180
+ (`task-truthy`, `@task-api`, etc.) in the summary — those are ephemeral
181
+ creation-time references that do not exist in the database.
182
+ - IDs must be copy-friendly: render them in monospace/code formatting so the
183
+ user can select and copy a UUID directly.
184
+
185
+ ### Summary structure
186
+
187
+ 1. **Epic ID + title** — displayed prominently at the top, e.g.:
188
+ ```
189
+ Epic: <full-uuid>
190
+ Title: <epic title>
191
+ ```
192
+ 2. Tasks grouped by wave/batch with columns: full UUID, title, owner/lane
193
+ 3. Dependencies shown per task (using full UUIDs or task titles, not temp-keys)
194
+ 4. Verification gate (commands to run after all tasks complete)
195
+
196
+ ### Example format
197
+
198
+ ```
199
+ Epic: 904b3129-be2d-4b20-8030-537dc327491a
200
+ Title: Checkout: add idempotent payment capture
201
+
202
+ Wave 1 (parallel)
203
+ | ID | Task | Owner |
204
+ |--------------------------------------|-------------------------------|--------------|
205
+ | c12c9746-dbae-4660-bcbb-ebe660cb7054 | [API] Payment capture endpoint| api-lane |
206
+ | 4f0848f3-538a-44d3-8415-5bb16cf3f39e | [UI] Checkout button states | ui-lane |
207
+
208
+ Wave 2 (depends on wave 1)
209
+ | ID | Task | Depends on |
210
+ |--------------------------------------|-------------------------------|--------------------------------------|
211
+ | 8a76afac-155d-45b3-b205-df2e4ef8988b | [API] Retry logic | c12c9746-dbae-4660-bcbb-ebe660cb7054 |
212
+
213
+ Verification: bun run build && bun run test
214
+ ```
215
+
216
+ ### Execution handoff contract
217
+
218
+ Every plan must be directly executable without re-interpretation. Include these
219
+ in task descriptions:
220
+
221
+ 1. **Lane/subsystem ownership** (`[Subsystem] ...` in title, `--owner` set).
222
+ 2. **Dependency intent** (explicit `blocked by ...` / `can run in parallel
223
+ with ...`).
224
+ 3. **Verification evidence** (exact commands and expected outcome).
225
+ 4. **Completion semantics** (`done` means verified and handoff-ready; use
226
+ `blocked` with reason when not).
227
+ 5. **Stable contract** (execution appends progress notes rather than rewriting
228
+ original plan text unless the plan itself is wrong).
229
+
230
+ ## Quality rules
231
+
232
+ 1. **No markdown plan files** as source of truth.
233
+ 2. **No vague titles** ("Refactor stuff", "Fix bugs").
234
+ 3. **Descriptions must be implementation-usable** by another agent without
235
+ guessing.
236
+ 4. **Every task must define completion evidence** (tests/manual checks).
237
+ 5. **Parallelism must be explicit** (not implied).
238
+ 6. **Status transitions must be valid** — never describe a `todo -> done` flow.
239
+ 7. **Owners should be assigned** when multiple execution lanes exist.
240
+
241
+ ## Large initiatives
242
+
243
+ For large scope, create multiple epics with explicit cross-epic boundaries. Use
244
+ dependencies within each epic DAG and keep each epic executable in bounded time.
package/README.md CHANGED
@@ -51,7 +51,9 @@ These are the commands most people need to recognize quickly:
51
51
  | Install/open/update the local board | `trekoon board open`, `trekoon board update` |
52
52
  | Learn the CLI | `trekoon help [command]`, `trekoon quickstart` |
53
53
  | Plan work | `trekoon epic ...`, `trekoon task ...`, `trekoon subtask ...`, `trekoon dep ...` |
54
- | Start an execution session | `trekoon session` |
54
+ | Track epic progress | `trekoon epic progress <id>` |
55
+ | Start an execution session | `trekoon session`, `trekoon session --epic <id>` |
56
+ | Get next-action suggestions | `trekoon suggest`, `trekoon suggest --epic <id>` |
55
57
  | Keep worktrees in sync | `trekoon sync ...` |
56
58
  | Install or refresh the AI skill | `trekoon skills install`, `trekoon skills update` |
57
59
  | Maintenance | `trekoon events prune ...`, `trekoon migrate ...`, `trekoon wipe --yes` |
@@ -60,6 +62,7 @@ Machine output modes:
60
62
 
61
63
  - `--toon` for true TOON-encoded payloads
62
64
  - `--json` for JSON output
65
+ - `--compact` to strip metadata from TOON envelopes
63
66
  - `--compat <mode>` for explicit compatibility behavior
64
67
  - `--help` and `--version` at the root or command level
65
68
 
@@ -126,18 +129,29 @@ For the full lifecycle and examples, read [Quickstart](docs/quickstart.md) and
126
129
 
127
130
  ## AI skill
128
131
 
129
- Trekoon ships with a bundled `trekoon` skill for AI agents. It teaches the
130
- agent to:
132
+ Trekoon ships with a self-contained `trekoon` skill for AI agents. One skill
133
+ covers the full plan-to-completion workflow:
131
134
 
132
- - use `--toon` by default
133
- - prefer the smallest sufficient read
134
- - use transactional bulk planning commands when possible
135
- - append progress and blocker notes instead of rewriting full descriptions
136
- - preview scoped replace before `--apply`
137
- - treat `.trekoon` as shared repo-scoped operational state
135
+ - **Command reference** — `--toon` defaults, status machine, bulk planning,
136
+ append-based progress logging
137
+ - **Planning** decomposition into epic/task/subtask DAGs, writing standard,
138
+ file scopes, owner assignment, dependency modeling
139
+ - **Execution** graph building, lane grouping, sub-agent dispatch, task done
140
+ orchestration, verification
141
+ - **Agent Teams** — TeamCreate/SendMessage pattern for parallel Claude Code
142
+ instances (requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=true`)
143
+
144
+ The skill accepts arguments for quick entity-scoped actions:
145
+
146
+ ```
147
+ /trekoon → load the skill
148
+ /trekoon <id> → show status and next steps for an entity
149
+ /trekoon <id> execute → start executing the entity's epic
150
+ /trekoon <id> plan → decompose into tasks/subtasks/deps
151
+ ```
138
152
 
139
153
  Read [AI agents and the Trekoon skill](docs/ai-agents.md) for installation,
140
- editor linking, recommended skill combinations, and example prompts.
154
+ editor linking, and example prompts.
141
155
 
142
156
  ## Read next
143
157