trekoon 0.4.1 → 0.4.3

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 (58) hide show
  1. package/.agents/skills/trekoon/SKILL.md +97 -765
  2. package/.agents/skills/trekoon/reference/execution-with-team.md +91 -141
  3. package/.agents/skills/trekoon/reference/execution.md +188 -159
  4. package/.agents/skills/trekoon/reference/harness-primitives.md +77 -0
  5. package/.agents/skills/trekoon/reference/planning.md +213 -213
  6. package/.agents/skills/trekoon/reference/status-machine.md +21 -0
  7. package/.agents/skills/trekoon/reference/sync.md +82 -0
  8. package/README.md +29 -8
  9. package/docs/ai-agents.md +65 -6
  10. package/docs/commands.md +149 -5
  11. package/docs/machine-contracts.md +123 -0
  12. package/docs/quickstart.md +55 -3
  13. package/package.json +1 -1
  14. package/src/board/assets/app.js +47 -13
  15. package/src/board/assets/components/Component.js +20 -8
  16. package/src/board/assets/components/Workspace.js +9 -3
  17. package/src/board/assets/components/helpers.js +4 -0
  18. package/src/board/assets/runtime/delegation.js +8 -0
  19. package/src/board/assets/runtime/focus-trap.js +48 -0
  20. package/src/board/assets/state/actions.js +45 -4
  21. package/src/board/assets/state/api.js +304 -17
  22. package/src/board/assets/state/store.js +82 -11
  23. package/src/board/assets/state/url.js +10 -0
  24. package/src/board/assets/state/utils.js +2 -1
  25. package/src/board/event-bus.ts +81 -0
  26. package/src/board/routes.ts +430 -40
  27. package/src/board/server.ts +86 -10
  28. package/src/board/snapshot.ts +6 -0
  29. package/src/board/wal-watcher.ts +313 -0
  30. package/src/commands/board.ts +52 -17
  31. package/src/commands/epic.ts +7 -9
  32. package/src/commands/error-utils.ts +54 -1
  33. package/src/commands/help.ts +75 -10
  34. package/src/commands/migrate.ts +153 -24
  35. package/src/commands/quickstart.ts +7 -0
  36. package/src/commands/skills.ts +17 -5
  37. package/src/commands/subtask.ts +71 -10
  38. package/src/commands/suggest.ts +6 -13
  39. package/src/commands/task.ts +137 -88
  40. package/src/domain/batch-validation.ts +329 -0
  41. package/src/domain/cascade-planner.ts +412 -0
  42. package/src/domain/dependency-rules.ts +15 -0
  43. package/src/domain/mutation-service.ts +842 -187
  44. package/src/domain/search.ts +113 -0
  45. package/src/domain/tracker-domain.ts +167 -693
  46. package/src/domain/types.ts +56 -2
  47. package/src/export/render-markdown.ts +1 -2
  48. package/src/index.ts +37 -0
  49. package/src/runtime/cli-shell.ts +44 -0
  50. package/src/runtime/daemon.ts +700 -0
  51. package/src/storage/backup.ts +166 -0
  52. package/src/storage/database.ts +268 -4
  53. package/src/storage/migrations.ts +441 -22
  54. package/src/storage/path.ts +8 -0
  55. package/src/storage/schema.ts +5 -1
  56. package/src/sync/event-writes.ts +38 -11
  57. package/src/sync/git-context.ts +226 -8
  58. package/src/sync/service.ts +679 -156
@@ -1,292 +1,292 @@
1
1
  # Planning Reference
2
2
 
3
- Write implementation plans directly into Trekoon as epics with task/subtask
4
- DAGs. Plans must be directly executable without re-interpretation.
3
+ Write plans directly into Trekoon as epics with task/subtask DAGs. A plan is
4
+ done only when the epic exists, the graph is validated, and the user can run
5
+ `trekoon <epic-id> execute` without reinterpretation.
5
6
 
6
- **Plan mode contract:** planning is complete only when the epic exists in
7
- Trekoon, the dependency graph is validated, and the user can immediately run
8
- `trekoon <epic-id> execute`.
7
+ Ask planning-critical questions before writing. Use the harness question tool
8
+ when available (`question`, `AskUserQuestion`, or native equivalent); otherwise
9
+ ask one concise plain-text question. Use multi-select only for independent
10
+ features that can combine. Use single-select for mutually exclusive choices.
9
11
 
10
- **Clarify ambiguity upfront.** If the plan has unclear requirements or meaningful
11
- tradeoffs, ask the user before writing. Present options with clear tradeoffs.
12
- Use multi-select for independent features that can be combined; use single-select
13
- for mutually exclusive choices.
12
+ ## Before You Create Records
14
13
 
15
- Use the harness's interactive user-question tool when you need clarification:
14
+ Synthesize existing context instead of rediscovering it:
16
15
 
17
- - OpenCode: `question`
18
- - Claude Code: `AskUserQuestion`
16
+ 1. Goal and user outcome.
17
+ 2. Decisions already made and rejected options.
18
+ 3. Constraints: architecture, compatibility, safety, timelines, libraries.
19
+ 4. Affected areas: subsystems, paths, interfaces, workflows.
20
+ 5. Verification evidence needed for completion.
21
+ 6. Unknowns that block graph creation.
19
22
 
20
- Do not hide planning-critical questions inside a long narrative response.
23
+ If the brief is sufficient, plan. If not, do targeted research or ask one narrow
24
+ question. Preserve prior user decisions unless they explicitly reopen them.
25
+ Expand existing Trekoon items when they already represent the work.
21
26
 
22
- ## Pre-plan synthesis
27
+ ## Data Model
23
28
 
24
- Before creating or expanding an epic, synthesize the context you already have.
25
- Planning should consume previous brainstorming, research, and codebase discovery
26
- rather than redoing it from scratch.
29
+ - Epic: full outcome, scope, constraints, and verification gates.
30
+ - Task: one complete subsystem/domain work unit that one agent can own.
31
+ - Subtask: concrete implementation/test/verification step under a task.
32
+ - Dependency: hard prerequisite only, not "nice to have" ordering.
27
33
 
28
- Build a short internal planning brief with:
34
+ All new entities start as `todo`. Do not create records as `in_progress`,
35
+ `blocked`, or `done`.
29
36
 
30
- 1. **Goal** what outcome the user wants
31
- 2. **Decisions already made** — chosen direction, rejected options, known tradeoffs
32
- 3. **Known constraints** — architecture, library constraints, timelines, safety, compatibility
33
- 4. **Affected areas** — subsystems, files, interfaces, or workflows likely involved
34
- 5. **Verification expectations** — what evidence will prove the work is complete
35
- 6. **Remaining unknowns** — only the ones that actually block graph creation
37
+ ## Write Detailed, Executable Records
36
38
 
37
- If the brief is already sufficient, go straight into planning. If important
38
- unknowns remain, do targeted research or ask a narrow user question before
39
- creating the graph.
39
+ ### Epic
40
40
 
41
- ## Research-aware planning rules
42
-
43
- - Reuse research conclusions in the epic and task descriptions.
44
- - Carry forward concrete patterns, file paths, APIs, and constraints that were
45
- discovered earlier.
46
- - Do not replace prior decisions with generic planning boilerplate.
47
- - If the user already chose an approach during brainstorming, plan that approach
48
- unless they explicitly reopen the decision.
49
- - If existing Trekoon items already represent part of the work, expand or refine
50
- them instead of recreating parallel tracking state.
51
-
52
- ## Planning data model
53
-
54
- - **Epic** = full feature outcome and constraints.
55
- - **Task** = one complete subsystem/domain work unit that can be owned by one
56
- agent.
57
- - **Subtask** = concrete implementation/test/verification step under a task.
58
- - **Dependency edge** = strict prerequisite only (do not add "nice to have"
59
- dependencies).
60
-
61
- All entities start in `todo`. See the status machine in the main SKILL.md.
62
-
63
- Plan implications:
64
- - Never set initial status to anything other than `todo` in create commands.
65
- - Task descriptions should reference valid transitions when documenting
66
- completion flow (e.g., "todo -> in_progress -> done", not "todo -> done").
67
- - `task done` auto-transitions through `in_progress`, but `task update` does
68
- not — plan descriptions should note this for agents.
69
-
70
- ## Information-dense writing standard
71
-
72
- ### Epic title
73
-
74
- Use a functional, outcome-oriented format:
41
+ Title format:
75
42
 
76
43
  `<Product/Area>: <deliverable> to <user/system outcome> (<key constraint>)`
77
44
 
78
- Example: `Checkout: add idempotent payment capture to prevent duplicate charges
79
- (Stripe + retries)`
80
-
81
- ### Epic description
45
+ Description must include:
82
46
 
83
- Include:
47
+ - Goal and why now.
48
+ - In scope and out of scope.
49
+ - Success criteria.
50
+ - Risks and constraints.
51
+ - Verification gates.
52
+ - Key prior decisions or research findings that affect implementation.
84
53
 
85
- 1. **Goal & why now**
86
- 2. **In scope** (specific capabilities)
87
- 3. **Out of scope** (explicit exclusions)
88
- 4. **Success criteria** (testable outcomes)
89
- 5. **Risks/constraints** (data migration, latency budgets, auth boundaries)
90
- 6. **Verification gates** (tests, manual checks, perf/security checks)
91
- 7. **Key prior decisions or research findings** when they materially affect the
92
- implementation path
54
+ ### Task
93
55
 
94
- ### Task title
95
-
96
- Use a structure that encodes subsystem + action + outcome:
56
+ Title format:
97
57
 
98
58
  `[<Subsystem>] <verb> <artifact/interface> to <observable outcome>`
99
59
 
100
- Example: `[API/Auth] issue refresh-token rotation endpoint to invalidate
101
- replayed sessions`
102
-
103
- ### Task description
60
+ Description must include:
104
61
 
105
- Must include:
106
-
107
- - concrete scope and affected paths/symbols
108
- - acceptance criteria (observable behavior)
109
- - required tests/verification commands
110
- - integration constraints (contracts, backward compatibility)
111
- - explicit "can run in parallel with ..." or "blocked by ..." note
112
- - relevant findings from prior research or brainstorming that execution agents
113
- should not have to rediscover
114
-
115
- **File scope** — declare explicitly so the agent doesn't waste tokens exploring:
116
-
117
- - **Target files**: files to create or modify
118
- - **Read-first files**: files the agent should read for context
119
- - **Do-not-touch**: paths that parallel agents own — prevents merge conflicts
120
-
121
- **Context loading hints** — point the agent to existing patterns:
122
-
123
- - Reference a concrete file as the pattern to mirror
124
- - Name the specific function/class/export to extend or integrate with
125
- - State project conventions rather than assuming the agent will discover them
126
-
127
- **Owner assignment** — when the plan has clear subsystem lanes, assign owners in
128
- task descriptions so the executor knows which agent/person owns each task:
129
-
130
- ```
131
- Owner: auth-lane
132
- Can run in parallel with: billing-lane tasks
133
- ```
62
+ - Target files: files to create or modify.
63
+ - Read first: files, functions, or patterns to inspect before editing.
64
+ - Do not touch: paths owned by other lanes.
65
+ - Acceptance criteria with observable behavior.
66
+ - Required tests or manual verification commands.
67
+ - Integration constraints and compatibility requirements.
68
+ - Owner/lane when clear.
69
+ - Parallelism note: "can run in parallel with ..." or "blocked by ...".
70
+ - Relevant prior findings so execution agents do not rediscover context.
134
71
 
135
- Example task description:
72
+ Example:
136
73
 
137
- ```
74
+ ```text
138
75
  Implement refresh-token rotation endpoint.
139
76
 
140
77
  Target files: src/auth/refresh.ts (new), src/auth/refresh.test.ts (new)
141
- Read first: src/auth/login.ts (follow same handler pattern)
78
+ Read first: src/auth/login.ts (follow handler pattern)
142
79
  Do not touch: src/billing/* (owned by billing-lane)
143
80
 
144
- Follow the handler pattern in login.ts: schema validation -> service call ->
145
- response mapping.
146
-
147
- Acceptance: POST /auth/refresh returns new token pair, invalidates old token.
81
+ Follow login.ts: schema validation -> service call -> response mapping.
82
+ Acceptance: POST /auth/refresh returns a new token pair and invalidates old token.
148
83
  Verify: bun test src/auth/refresh.test.ts
149
84
  Owner: auth-lane
150
- Can run in parallel with: billing-lane. Blocked by: task-types (needs AuthToken).
85
+ Can run in parallel with: billing-lane. Blocked by: task-types.
151
86
  ```
152
87
 
153
- ### Subtask title/description
154
-
155
- - Titles are imperative and specific, not generic.
156
- - Description states exact artifact and completion signal.
157
- - Use subtasks for real units, not filler checklist noise.
158
- - Inherit file scope from parent task only override if different files.
159
-
160
- ## Parallelism & dependencies
161
-
162
- Model execution lanes intentionally:
88
+ ### Subtask
89
+
90
+ - Use imperative, specific titles.
91
+ - State exact artifact and completion signal.
92
+ - Use subtasks for real execution units, not filler checklist noise.
93
+ - Inherit parent task file scope unless a subtask differs.
94
+
95
+ ## Design For Delegated Execution
96
+
97
+ Plan so meaningful independent work can run in subagents:
98
+
99
+ - Tasks with no dependency edge are parallel candidates.
100
+ - Different subsystems usually become different lanes.
101
+ - Same subsystem work should usually be grouped or sequenced.
102
+ - Keep each active subsystem lane to about 3-4 tasks.
103
+ - Add owners after creation when lanes are clear:
104
+ ```bash
105
+ trekoon --toon task update <task-id> --owner auth-lane
106
+ trekoon --toon task update <task-id> --owner billing-lane
107
+ ```
108
+
109
+ Use dependencies only for hard prerequisites. Prefer task-to-task dependencies.
110
+ Use subtask dependencies only when task-level ordering is too coarse.
111
+
112
+ ## Create Records Efficiently
113
+
114
+ Use `--toon` on every planning command. It saves tokens and gives agents a
115
+ stable structured response.
116
+
117
+ Prefer one transactional planning command over repeated single-item creates. If
118
+ you know the epic, tasks, subtasks, and dependencies, one-shot the whole epic
119
+ with `epic create --task ... --subtask ... --dep ...`. This saves tool calls and
120
+ keeps the graph internally consistent.
121
+
122
+ | Situation | Command |
123
+ |---|---|
124
+ | New epic with known graph | Prefer `trekoon --toon epic create ... --task ... --subtask ... --dep ...` |
125
+ | Existing epic needs linked additions | `trekoon --toon epic expand <epic-id> ...` |
126
+ | Many sibling tasks | `trekoon --toon task create-many --epic <epic-id> --task ...` |
127
+ | Many sibling subtasks | `trekoon --toon subtask create-many <task-id> --subtask ...` |
128
+ | Many dependency edges across existing IDs | `trekoon --toon dep add-many --dep ...` |
129
+ | One record only | `epic create`, `task create`, or `subtask create` |
130
+
131
+ Compact specs use pipe-delimited values. `\` is the escape character:
132
+
133
+ | Sequence | Produces |
134
+ |---|---|
135
+ | `\|` | literal `|` |
136
+ | `\\` | literal `\` |
137
+ | `\n` | newline |
138
+ | `\r` | carriage return |
139
+ | `\t` | tab |
140
+
141
+ Any other `\X` is invalid. Do not paste regex-escaped or shell-escaped
142
+ patterns directly into compact specs: sequences like `\?`, `\.`, `\{`, `\}`,
143
+ `\(`, `\)`, `\[`, and `\]` will fail before records are created. When a task
144
+ description needs a search pattern, prefer prose over exact regex syntax. Avoid
145
+ operators like `!=` in descriptions because shell or compact-spec escaping can
146
+ be confusing; rephrase as words.
147
+
148
+ Good:
149
+
150
+ ```text
151
+ Verify: search docs for currentUpdatedAt, updatedAt-ms, SSE auth token rides, and token query contract text.
152
+ ```
163
153
 
164
- - Tasks with no dependency edge between them are parallel candidates.
165
- - Tasks in different subsystems should usually run in parallel.
166
- - Tasks in the same subsystem should be combined or sequenced.
167
- - Keep task groups to ~3-4 tasks per active subsystem lane.
154
+ Bad:
168
155
 
169
- Dependency policy:
156
+ ```text
157
+ Verify: search with regex "currentUpdatedAt|<updatedAt-ms>|/api/snapshot/stream\?token|\?token=\{token\}" in docs and README.md
158
+ ```
170
159
 
171
- 1. Add an edge only for hard prerequisites.
172
- 2. Prefer task-to-task dependencies; use subtask dependencies only when required.
173
- 3. Validate acyclic graph assumptions before finalizing.
160
+ One-shot rules:
174
161
 
175
- ## Assign owners after creation
162
+ - Declare tasks/subtasks with plain temp keys, e.g. `task-api`, `sub-tests`.
163
+ - Refer to records created in the same command as `@task-api` or `@sub-tests`.
164
+ - Use `@task-key` as the subtask parent ref and in `--dep` specs.
165
+ - `--dep <source>|<depends-on>` points from blocked item to prerequisite.
166
+ - `epic create` returns `result.mappings` and counts. Use those real UUIDs in
167
+ handoff summaries and follow-up updates. Never show temp keys as real IDs.
168
+ - `dep add-many` does not resolve temp keys from earlier commands. Use real IDs.
176
169
 
177
- After creating tasks, assign ownership for multi-agent execution:
170
+ One-shot example:
178
171
 
179
172
  ```bash
180
- trekoon --toon task update <task-id> --owner auth-lane
181
- trekoon --toon task update <task-id> --owner billing-lane
173
+ trekoon --toon epic create \
174
+ --title "Checkout: add idempotent payment capture" \
175
+ --description "Goal: prevent duplicate charges.\nVerification: bun test tests/payments" \
176
+ --task "task-api|[API] add capture endpoint|Target files: src/payments/capture.ts\nRead first: src/payments/service.ts\nDo not touch: src/ui/*\nAcceptance: duplicate request returns prior result.\nVerify: bun test tests/payments/capture.test.ts\nOwner: api-lane\nCan run in parallel with: task-ui.|todo" \
177
+ --task "task-ui|[UI] show capture states|Target files: src/ui/checkout.tsx\nRead first: src/ui/form.tsx\nDo not touch: src/payments/*\nAcceptance: loading and retry states render.\nVerify: bun test tests/ui/checkout.test.ts\nOwner: ui-lane\nBlocked by: task-api.|todo" \
178
+ --subtask "@task-api|sub-api-tests|Write capture tests|Cover idempotent retry and conflict responses.|todo" \
179
+ --subtask "@task-ui|sub-ui-states|Write UI state tests|Cover loading, success, retry, and error states.|todo" \
180
+ --dep "@task-ui|@task-api"
182
181
  ```
183
182
 
184
- ## Validate the plan
183
+ ## Append Efficiently
185
184
 
186
- After creating the epic, validate before handing off to execution.
185
+ Use `--append` for progress notes, shared findings, verification requirements,
186
+ or planning refinements. Appending is cheaper and safer than rewriting full
187
+ descriptions.
187
188
 
188
- ### Check progress structure
189
+ Entity-specific append:
189
190
 
190
191
  ```bash
191
- trekoon --toon epic progress <epic-id>
192
+ trekoon --toon epic update <epic-id> --append "Planning note: <text>"
193
+ trekoon --toon task update <task-id> --append "Planning note: <text>"
194
+ trekoon --toon subtask update <subtask-id> --append "Planning note: <text>"
192
195
  ```
193
196
 
194
- Verify: total count matches expectations, all tasks are in `todo`, ready count
195
- equals the number of tasks with no dependencies.
196
-
197
- ### Run suggest to confirm sanity
197
+ Append to selected tasks or subtasks with IDs from `result.mappings`:
198
198
 
199
199
  ```bash
200
- trekoon --toon suggest --epic <epic-id>
200
+ trekoon --toon task update --ids id1,id2,id3 --append "Shared verification: bun test tests/payments"
201
+ trekoon --toon subtask update --ids id1,id2 --append "Shared note: follow capture endpoint contract"
201
202
  ```
202
203
 
203
- `suggest` will surface issues: sync gaps, recovery needs, or unexpected blocker
204
- states. If it suggests claiming a task, the plan's dependency graph is valid and
205
- execution-ready.
204
+ Important:
206
205
 
207
- ### Verify dependency graph
206
+ - `epic update <epic-id> --append ...` appends only to the epic description.
207
+ - There is no scoped "append to all tasks in this epic" command. Use task IDs
208
+ from one-shot mappings, `epic show --all`, or `task ready`, then
209
+ `task update --ids ... --append ...`.
210
+ - Do not use `task update --all --append ...` unless you truly mean every task
211
+ in the database.
212
+ - `epic update <epic-id> --all` is cascade status mode only and rejects
213
+ `--append`.
214
+ - Bulk append is per-row, not one atomic transaction.
215
+
216
+ ## Validate Before Handoff
217
+
218
+ After creating or expanding the epic:
208
219
 
209
220
  ```bash
221
+ trekoon --toon epic progress <epic-id>
222
+ trekoon --toon suggest --epic <epic-id>
210
223
  trekoon --toon task ready --epic <epic-id> --limit 50
211
224
  ```
212
225
 
213
- Confirm that the expected first-wave tasks appear as ready candidates and
214
- second-wave tasks appear as blocked with the right dependencies.
215
-
216
- ## Plan output and handoff
226
+ Verify:
217
227
 
218
- After creating the epic and validating, present a summary to the user. This
219
- summary is the primary handoff artifact — it must be self-contained and
220
- actionable.
228
+ - Counts match expectations.
229
+ - All new tasks are `todo`.
230
+ - Ready count equals first-wave tasks with no dependencies.
231
+ - Blocked tasks show the expected dependencies.
232
+ - `suggest` returns a sensible first execution candidate and no recovery/sync
233
+ issue that blocks execution.
221
234
 
222
- Do not stop at a prose-only design. The final handoff must reference the actual
223
- Trekoon epic and the first execution wave.
235
+ ## Handoff Summary
224
236
 
225
- ### ID rules
237
+ Do not stop at a prose-only design. Return the actual Trekoon epic and first
238
+ execution wave.
226
239
 
227
- - **Always use full UUIDs** for epic and task IDs. Never use temp-keys
228
- (`task-truthy`, `@task-api`, etc.) in the summary — those are ephemeral
229
- creation-time references that do not exist in the database.
230
- - IDs must be copy-friendly: render them in monospace/code formatting so the
231
- user can select and copy a UUID directly.
240
+ Rules:
232
241
 
233
- ### Summary structure
242
+ - Always use full UUIDs for epic/task IDs in summaries.
243
+ - Never use temp keys (`task-api`, `@sub-tests`) outside create commands.
244
+ - Render IDs in code formatting.
245
+ - Group tasks by wave with title, owner/lane, and dependencies.
246
+ - Include final verification gate.
234
247
 
235
- 1. **Epic ID + title** — displayed prominently at the top, e.g.:
236
- ```
237
- Epic: <full-uuid>
238
- Title: <epic title>
239
- ```
240
- 2. Tasks grouped by wave/batch with columns: full UUID, title, owner/lane
241
- 3. Dependencies shown per task (using full UUIDs or task titles, not temp-keys)
242
- 4. Verification gate (commands to run after all tasks complete)
248
+ Format:
243
249
 
244
- ### Example format
245
-
246
- ```
247
- Epic: 904b3129-be2d-4b20-8030-537dc327491a
248
- Title: Checkout: add idempotent payment capture
250
+ ```text
251
+ Epic: <full-uuid>
252
+ Title: <epic title>
249
253
 
250
254
  Wave 1 (parallel)
251
- | ID | Task | Owner |
252
- |--------------------------------------|-------------------------------|--------------|
253
- | c12c9746-dbae-4660-bcbb-ebe660cb7054 | [API] Payment capture endpoint| api-lane |
254
- | 4f0848f3-538a-44d3-8415-5bb16cf3f39e | [UI] Checkout button states | ui-lane |
255
+ | ID | Task | Owner |
256
+ |---|---|---|
257
+ | <uuid> | [API] Payment capture endpoint | api-lane |
255
258
 
256
- Wave 2 (depends on wave 1)
257
- | ID | Task | Depends on |
258
- |--------------------------------------|-------------------------------|--------------------------------------|
259
- | 8a76afac-155d-45b3-b205-df2e4ef8988b | [API] Retry logic | c12c9746-dbae-4660-bcbb-ebe660cb7054 |
259
+ Wave 2
260
+ | ID | Task | Depends on |
261
+ |---|---|---|
262
+ | <uuid> | [API] Retry logic | <wave-1-uuid> |
260
263
 
261
264
  Verification: bun run build && bun run test
262
265
  ```
263
266
 
264
- ### Execution handoff contract
267
+ ## Search And Replace
268
+
269
+ Use scoped search before manual tree reads when locating repeated paths, labels,
270
+ owners, or migration targets.
265
271
 
266
- Every plan must be directly executable without re-interpretation. Include these
267
- in task descriptions:
272
+ Narrowest valid scope first:
268
273
 
269
- 1. **Lane/subsystem ownership** (`[Subsystem] ...` in title, `--owner` set).
270
- 2. **Dependency intent** (explicit `blocked by ...` / `can run in parallel
271
- with ...`).
272
- 3. **Verification evidence** (exact commands and expected outcome).
273
- 4. **Completion semantics** (`done` means verified and handoff-ready; use
274
- `blocked` with reason when not).
275
- 5. **Stable contract** (execution appends progress notes rather than rewriting
276
- original plan text unless the plan itself is wrong).
274
+ 1. `subtask search` / `subtask replace`
275
+ 2. `task search` / `task replace`
276
+ 3. `epic search` / `epic replace`
277
277
 
278
- ## Quality rules
278
+ Workflow:
279
279
 
280
- 1. **No markdown plan files** as source of truth.
281
- 2. **No vague titles** ("Refactor stuff", "Fix bugs").
282
- 3. **Descriptions must be implementation-usable** by another agent without
283
- guessing.
284
- 4. **Every task must define completion evidence** (tests/manual checks).
285
- 5. **Parallelism must be explicit** (not implied).
286
- 6. **Status transitions must be valid** — never describe a `todo -> done` flow.
287
- 7. **Owners should be assigned** when multiple execution lanes exist.
280
+ ```bash
281
+ trekoon --toon epic search <epic-id> "path/to/somewhere"
282
+ trekoon --toon epic replace <epic-id> --search "path/to/somewhere" --replace "path/to/new-path"
283
+ trekoon --toon epic replace <epic-id> --search "path/to/somewhere" --replace "path/to/new-path" --apply
284
+ ```
288
285
 
289
- ## Large initiatives
286
+ Guardrails:
290
287
 
291
- For large scope, create multiple epics with explicit cross-epic boundaries. Use
292
- dependencies within each epic DAG and keep each epic executable in bounded time.
288
+ - Use literal, explicit search text.
289
+ - Narrow fields when useful: `--fields title`, `--fields description`, or
290
+ `--fields title,description`.
291
+ - Preview before `--apply`.
292
+ - Prefer scoped replace over manually editing many records one by one.
@@ -0,0 +1,21 @@
1
+ # Status Machine Reference
2
+
3
+ Trekoon enforces a status transition graph. Only these transitions are valid:
4
+
5
+ | From | Allowed targets |
6
+ |---|---|
7
+ | `todo` | `in_progress`, `blocked` |
8
+ | `in_progress` | `done`, `blocked` |
9
+ | `blocked` | `in_progress`, `todo` |
10
+ | `done` | `in_progress` |
11
+
12
+ Invalid transitions (e.g. `todo → done`) return error code
13
+ `status_transition_invalid`. Always transition through `in_progress` to reach
14
+ `done`.
15
+
16
+ **Exception:** `task done` auto-transitions through `in_progress` when the task
17
+ is in `todo` or `blocked` status, so you can call `task done` from any
18
+ non-done status.
19
+
20
+ Recommended statuses for consistent workflows: `todo`, `in_progress`, `done`.
21
+ Use `blocked` with an appended reason when work is stuck.
@@ -0,0 +1,82 @@
1
+ # Sync Reference
2
+
3
+ Trekoon uses one live SQLite database per repository at
4
+ `<sharedStorageRoot>/.trekoon/trekoon.db`. Linked worktrees share it. `git
5
+ checkout` and `git switch` do not roll back tracker state. Sync imports tracker
6
+ events between branches; never copy or commit the `.db` file.
7
+
8
+ Same-branch sync is a no-op. Cross-branch sync matters before merging a feature
9
+ branch back.
10
+
11
+ ## Before Merge
12
+
13
+ Pull tracker events from the base branch:
14
+
15
+ ```bash
16
+ trekoon --toon sync pull --from main
17
+ ```
18
+
19
+ If conflicts exist:
20
+
21
+ ```bash
22
+ trekoon --toon sync conflicts list
23
+ trekoon --toon sync conflicts show <conflict-id>
24
+ trekoon --toon sync resolve <conflict-id> --use theirs --dry-run
25
+ trekoon --toon sync resolve <conflict-id> --use ours
26
+ ```
27
+
28
+ ## Conflict Rules
29
+
30
+ Conflicts are field-level, not whole-record. Each conflict targets one field on
31
+ one entity.
32
+
33
+ - `--use ours`: keep the current shared DB field value; mark conflict resolved.
34
+ - `--use theirs`: write the source-branch field value into the shared DB; mark
35
+ conflict resolved.
36
+ - `--dry-run`: preview without mutation. Returns `oursValue`, `theirsValue`,
37
+ `wouldWrite`, and `dryRun: true`.
38
+
39
+ Always inspect with `sync conflicts show` before resolving. Choosing `theirs`
40
+ without inspection can overwrite in-progress shared DB work.
41
+
42
+ Typical choices:
43
+
44
+ | Scenario | Usually use | Why |
45
+ |---|---|---|
46
+ | Completed work vs stale main | ours | Your branch has latest progress |
47
+ | Enriched descriptions vs original | ours | Your descriptions are more detailed |
48
+ | Upstream updates from another agent | theirs | Accept newer upstream state |
49
+ | User-intentional reset | theirs | Respect explicit user action |
50
+
51
+ When unsure, ask the user.
52
+
53
+ ## Batch Resolve
54
+
55
+ ```bash
56
+ trekoon --toon sync resolve --all --use ours --dry-run
57
+ trekoon --toon sync resolve --all --use ours
58
+ trekoon --toon sync resolve --all --use ours --field status
59
+ trekoon --toon sync resolve --all --use theirs --entity <id>
60
+ trekoon --toon sync resolve --all --use ours --entity <id> --field description
61
+ ```
62
+
63
+ Use batch resolve only when the conflict pattern is uniform. Otherwise inspect
64
+ and resolve individually or narrow by `--entity` / `--field`.
65
+
66
+ ## Worktree Scope
67
+
68
+ Inspect machine-readable storage fields when debugging worktrees:
69
+ `storageMode`, `repoCommonDir`, `worktreeRoot`, `sharedStorageRoot`, and
70
+ `databaseFile`.
71
+
72
+ Conflicts are scoped per worktree and branch. `sync conflicts list` and
73
+ `sync resolve` only act on rows for the current worktree/branch, so resolving a
74
+ conflict does not erase a peer worktree's conflict on the same entity.
75
+
76
+ ## Destructive Recovery
77
+
78
+ `sharedStorageRoot` is the repo-scoped source of truth for `.trekoon` in git
79
+ worktrees. If the user explicitly requests `trekoon wipe --yes --toon`, warn
80
+ that it deletes shared storage for the whole repository and every linked
81
+ worktree. Wipe is destructive recovery only; it is never the fix for a tracked
82
+ DB or gitignore mistake.