codebyplan 1.13.39 → 1.13.40
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.
- package/dist/cli.js +24631 -354
- package/package.json +4 -2
- package/templates/agents/cbp-cc-executor.md +4 -4
- package/templates/agents/cbp-round-executor.md +2 -10
- package/templates/agents/cbp-task-check.md +2 -0
- package/templates/agents/cbp-task-planner.md +2 -5
- package/templates/hooks/README.md +14 -2
- package/templates/hooks/cbp-session-start-hook.sh +32 -0
- package/templates/hooks/cbp-test-coverage-gate.sh +20 -6
- package/templates/hooks/cbp-test-hooks.sh +72 -0
- package/templates/hooks/hooks.json +11 -0
- package/templates/settings.project.base.json +10 -0
- package/templates/skills/cbp-checkpoint-check/SKILL.md +10 -10
- package/templates/skills/cbp-checkpoint-complete/SKILL.md +7 -7
- package/templates/skills/cbp-checkpoint-create/SKILL.md +11 -9
- package/templates/skills/cbp-checkpoint-end/SKILL.md +7 -10
- package/templates/skills/cbp-checkpoint-plan/SKILL.md +10 -10
- package/templates/skills/cbp-checkpoint-start/SKILL.md +6 -6
- package/templates/skills/cbp-checkpoint-update/SKILL.md +9 -9
- package/templates/skills/cbp-git-commit/SKILL.md +8 -4
- package/templates/skills/cbp-merge-main/SKILL.md +2 -5
- package/templates/skills/cbp-round-check/SKILL.md +12 -8
- package/templates/skills/cbp-round-complete/SKILL.md +16 -10
- package/templates/skills/cbp-round-end/SKILL.md +9 -10
- package/templates/skills/cbp-round-execute/SKILL.md +7 -6
- package/templates/skills/cbp-round-input/SKILL.md +24 -12
- package/templates/skills/cbp-round-start/SKILL.md +36 -16
- package/templates/skills/cbp-round-update/SKILL.md +14 -10
- package/templates/skills/cbp-session-end/SKILL.md +22 -12
- package/templates/skills/cbp-session-start/SKILL.md +20 -47
- package/templates/skills/cbp-ship/SKILL.md +4 -4
- package/templates/skills/cbp-ship-main/SKILL.md +4 -5
- package/templates/skills/cbp-supabase-migrate/SKILL.md +12 -9
- package/templates/skills/cbp-task-check/SKILL.md +10 -10
- package/templates/skills/cbp-task-complete/SKILL.md +11 -9
- package/templates/skills/cbp-task-create/SKILL.md +7 -5
- package/templates/skills/cbp-task-start/SKILL.md +15 -17
- package/templates/skills/cbp-task-testing/SKILL.md +18 -18
- package/templates/skills/cbp-todo/SKILL.md +21 -21
|
@@ -21,7 +21,7 @@ Parse the argument using the canonical chk-task-round notation (see `cbp-round-s
|
|
|
21
21
|
| Shape | Regex | Resolves to |
|
|
22
22
|
|-------|-------|-------------|
|
|
23
23
|
| `{chk}-{task}` (e.g. `108-1`) | `^[0-9]+-[0-9]+$` | Checkpoint-bound: CHK-{chk} TASK-{task} |
|
|
24
|
-
| _(empty)_ | — |
|
|
24
|
+
| _(empty)_ | — | Resolve from local state per Step 1.5/2 (MCP `get_current_task` break-glass) — the active in-progress task |
|
|
25
25
|
| `{task}` (bare number) | — | **Error**: "Use /cbp-standalone-task-complete {N} instead — bare numbers no longer route to standalone tasks." |
|
|
26
26
|
|
|
27
27
|
Anything else is malformed — surface this error and stop:
|
|
@@ -51,14 +51,14 @@ Given the parse from Step 1:
|
|
|
51
51
|
|
|
52
52
|
| Parse | Resolution path |
|
|
53
53
|
|-------|-----------------|
|
|
54
|
-
| `{chk}-{task}` |
|
|
55
|
-
| _(empty)_ |
|
|
54
|
+
| `{chk}-{task}` | Read `.codebyplan/state/checkpoints/*.json` → filter `number === {chk}`. Read `.codebyplan/state/checkpoints/<id>/tasks/*.json` → filter `number === {task}`. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_checkpoints`/`get_tasks` when state dir absent and sync fails. |
|
|
55
|
+
| _(empty)_ | Read `.codebyplan/state/todos.json` → find the active in-progress task. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_current_task(repo_id)` when state dir absent and sync fails. |
|
|
56
56
|
|
|
57
57
|
If no in-progress task, show error and stop.
|
|
58
58
|
|
|
59
59
|
### Step 2: Verify Rounds Complete and Validated
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Read `.codebyplan/state/checkpoints/<checkpointId>/tasks/<taskId>/rounds/*.json` (local-first). If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_rounds` when state dir absent and sync fails. Verify all rounds are `completed`.
|
|
62
62
|
|
|
63
63
|
If any round is `in_progress`:
|
|
64
64
|
|
|
@@ -132,11 +132,11 @@ Skip the push only when nothing was committed in Step 5 AND `/cbp-merge-main` re
|
|
|
132
132
|
|
|
133
133
|
### Step 6: Update Task Files
|
|
134
134
|
|
|
135
|
-
`update_task(task_id, files_changed: aggregated_files)
|
|
135
|
+
`codebyplan task update --id <taskId> --checkpoint-id <checkpointId> --files-changed '<json>'` (CLI write-through: local state file + REST). Break-glass fallback: MCP `update_task(task_id, files_changed: aggregated_files)` when CLI is unavailable.
|
|
136
136
|
|
|
137
137
|
### Step 7: Complete Task
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
MCP `complete_task(task_id)` — kept on MCP because the CLI `codebyplan task complete` sends an empty POST body and cannot forward `caller_worktree_id`, which the server uses to enforce the mutate-lock. `caller_worktree_id` is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent, then enforces the mutate-lock. The server auto-clears `assigned_user_id` + `assigned_worktree_id` on the task; if this was the last sibling task, it also clears the parent checkpoint's assignment. (Per CHK-104 hard-lock.)
|
|
140
140
|
|
|
141
141
|
### Step 8: Run Cleanup + Migration (inline)
|
|
142
142
|
|
|
@@ -164,7 +164,9 @@ Then route. Same-context transitions (next task in this checkpoint) auto-trigger
|
|
|
164
164
|
checkpoint_id := current_task.checkpoint_id
|
|
165
165
|
if checkpoint_id is null → error (should never happen — standalone tasks use /cbp-standalone-task-complete)
|
|
166
166
|
else
|
|
167
|
-
|
|
167
|
+
// Read sibling tasks from local state (already synced by Step 1.5)
|
|
168
|
+
siblings := .codebyplan/state/checkpoints/<checkpointId>/tasks/*.json minus current_task
|
|
169
|
+
// Break-glass: MCP get_tasks(checkpoint_id) when state dir absent and sync fails
|
|
168
170
|
all_done := every sibling has status === 'completed'
|
|
169
171
|
if all_done → CHECKPOINT-DONE; go to 9c
|
|
170
172
|
else → MORE-TASKS-IN-CHECKPOINT; go to 9b
|
|
@@ -193,8 +195,8 @@ Do NOT use AskUserQuestion here — this is a directive, not a menu. The user ru
|
|
|
193
195
|
|
|
194
196
|
- **Triggered by**: `/cbp-task-testing` (auto, when ALL PASS) — NOT directly from `/cbp-task-check`
|
|
195
197
|
- **Chain**: `/cbp-task-check` → `/cbp-task-testing` → `/cbp-task-complete`
|
|
196
|
-
- **Reads**:
|
|
197
|
-
- **Writes**: MCP `update_task
|
|
198
|
+
- **Reads**: `.codebyplan/state/checkpoints/*.json`, `checkpoints/<id>/tasks/*.json`, `checkpoints/<id>/tasks/<id>/rounds/*.json`, `todos.json` (local-first; `npx codebyplan sync` on miss; MCP `get_current_task`/`get_rounds`/`get_tasks` break-glass)
|
|
199
|
+
- **Writes**: `codebyplan task update` for `files_changed` (CLI write-through; MCP `update_task` break-glass); MCP `complete_task` for task completion (kept MCP — CLI cannot forward `caller_worktree_id`)
|
|
198
200
|
- **Uses skills (inline, no sub-agent)**: `cleanup` (if deletions), `migration` (if exports renamed)
|
|
199
201
|
- **Triggers**: Same-context transitions auto-trigger via the Skill tool (next task in checkpoint → `/cbp-task-start {N}`). Cross-context transitions emit a directive `Next: /clear, then /cbp-X` for the user to invoke.
|
|
200
202
|
- **Checkpoint-bound only** — for standalone tasks use `/cbp-standalone-task-complete`
|
|
@@ -32,7 +32,7 @@ Stop and redirect to `/cbp-standalone-task-create`.
|
|
|
32
32
|
|
|
33
33
|
### Step 1: Get Current Checkpoint
|
|
34
34
|
|
|
35
|
-
Use MCP `get_current_task`
|
|
35
|
+
Read local state `.codebyplan/state/checkpoints/<id>.json` to find the active checkpoint; on miss run `npx codebyplan sync` once and re-read. Use MCP `get_current_task` as documented break-glass when the state dir is absent and sync fails (daemon-dead + CLI-unavailable).
|
|
36
36
|
|
|
37
37
|
If no active checkpoint, show error and stop.
|
|
38
38
|
|
|
@@ -56,7 +56,7 @@ Please describe:
|
|
|
56
56
|
|
|
57
57
|
### Step 3: Load Existing Tasks
|
|
58
58
|
|
|
59
|
-
Use MCP `get_tasks`
|
|
59
|
+
Read local state `.codebyplan/state/checkpoints/<id>/tasks/*.json` to load existing tasks for the checkpoint; on miss run `npx codebyplan sync` once and re-read. Use MCP `get_tasks` as documented break-glass when the state dir is absent and sync fails. Review:
|
|
60
60
|
- Existing task titles and requirements
|
|
61
61
|
- Task statuses (completed, in_progress, pending)
|
|
62
62
|
- Dependencies between tasks
|
|
@@ -90,6 +90,8 @@ Before calling `create_task` for a finding, run a two-step dedup + bundle check:
|
|
|
90
90
|
mcp__codebyplan__get_tasks(repo_id, standalone=true, status="pending")
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
> **Note**: this `get_tasks(standalone=true)` call stays MCP — there is no local-state equivalent for cross-checkpoint standalone task listing.
|
|
94
|
+
|
|
93
95
|
Compare the proposed task to each pending standalone task on these match dimensions:
|
|
94
96
|
|
|
95
97
|
| Match dimension | Action if matched |
|
|
@@ -140,7 +142,7 @@ Find logical position in task order:
|
|
|
140
142
|
|
|
141
143
|
### Step 7: Create Task
|
|
142
144
|
|
|
143
|
-
Use MCP `create_task`
|
|
145
|
+
Use `codebyplan task create --checkpoint-id <id> ...` (CLI write-through) to create the task. Use MCP `create_task` as documented break-glass when the CLI is unavailable. Provide:
|
|
144
146
|
- **title**: Concise task title
|
|
145
147
|
- **requirements**: Numbered requirements list
|
|
146
148
|
- **context**: Include decisions from Q&A, dependencies, source findings
|
|
@@ -190,7 +192,7 @@ Waiting for user to decide next step.
|
|
|
190
192
|
|
|
191
193
|
## Integration
|
|
192
194
|
|
|
193
|
-
- **Reads**: MCP `get_current_task
|
|
194
|
-
- **Writes**: MCP `create_task`
|
|
195
|
+
- **Reads**: Local state `.codebyplan/state/checkpoints/<id>.json` + `.../tasks/<id>.json`; on miss `npx codebyplan sync` once; MCP `get_current_task` / `get_tasks` as documented break-glass when the state dir is absent and sync fails. Step 3.5 dedup `get_tasks(standalone=true)` stays MCP — no local-state equivalent for standalone listing.
|
|
196
|
+
- **Writes**: `codebyplan task create --checkpoint-id <id> ...` (CLI write-through); MCP `create_task` break-glass.
|
|
195
197
|
- **Triggered by**: `/cbp-task-check` (suggested), `/cbp-task-testing` (suggested), user manual
|
|
196
198
|
- **Does NOT auto-trigger** next command — user decides
|
|
@@ -20,7 +20,7 @@ Parse the argument using the canonical chk-task-round notation (see `cbp-round-s
|
|
|
20
20
|
| Shape | Regex | Resolves to |
|
|
21
21
|
|-------|-------|-------------|
|
|
22
22
|
| `{chk}-{task}` (e.g. `108-1`) | `^[0-9]+-[0-9]+$` | Checkpoint-bound: CHK-{chk} TASK-{task} |
|
|
23
|
-
| _(empty)_ | — |
|
|
23
|
+
| _(empty)_ | — | Resolve from local state per Step 1.5/2 (MCP `get_current_task` break-glass) — the next pending task |
|
|
24
24
|
| `{task}` (bare number) | — | **Error**: "Use /cbp-standalone-task-start {N} instead — bare numbers no longer route to standalone tasks." |
|
|
25
25
|
|
|
26
26
|
Anything else is malformed — surface this error and stop:
|
|
@@ -51,8 +51,8 @@ Given the parse from Step 1:
|
|
|
51
51
|
|
|
52
52
|
| Parse | Resolution path |
|
|
53
53
|
|-------|-----------------|
|
|
54
|
-
| `{chk}-{task}` |
|
|
55
|
-
| _(empty)_ | MCP `get_current_task(repo_id)`
|
|
54
|
+
| `{chk}-{task}` | Read `.codebyplan/state/checkpoints/*.json` (local-first) → filter `number === {chk}`. Read `.codebyplan/state/checkpoints/<id>/tasks/*.json` → filter `number === {task}`. If the state dir is missing or stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_checkpoints`/`get_tasks` when the state dir is absent and sync fails (daemon-dead + CLI-unavailable). |
|
|
55
|
+
| _(empty)_ | Read `.codebyplan/state/todos.json` (local-first) → find the next pending task. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_current_task(repo_id)` when the state dir is absent and sync fails. When multiple checkpoints are active and the result is ambiguous, surface the disambiguation prompt and stop. |
|
|
56
56
|
|
|
57
57
|
If any required row is missing, surface this and stop:
|
|
58
58
|
|
|
@@ -135,7 +135,7 @@ After successful switch:
|
|
|
135
135
|
|
|
136
136
|
1. Re-run `git branch --show-current` to confirm `current == TARGET`. If not, fail loudly — something raced.
|
|
137
137
|
2. **Persist for next time**:
|
|
138
|
-
- Checkpoint with `branch_name: null` → `
|
|
138
|
+
- Checkpoint with `branch_name: null` → `codebyplan checkpoint update --id <checkpoint-id> --branch-name TARGET` (CLI write-through; break-glass: MCP `update_checkpoint`)
|
|
139
139
|
- Checkpoint with existing `branch_name` → no write (already canonical)
|
|
140
140
|
3. One-line confirmation in output: `Branch: [TARGET] (switched from [previous])`. No prompt, no waiting.
|
|
141
141
|
|
|
@@ -157,8 +157,8 @@ Skip this step if the task title and requirements contain no CVE ID (`CVE-YYYY-N
|
|
|
157
157
|
|
|
158
158
|
1. Run `pnpm audit --json` from the monorepo root. If it fails (network, registry), surface the error and stop — do NOT start a CVE task without a clean snapshot.
|
|
159
159
|
2. Parse the advisory list from the JSON output.
|
|
160
|
-
3.
|
|
161
|
-
4. For every advisory with no matching open task,
|
|
160
|
+
3. Read `.codebyplan/state/checkpoints/<checkpointId>/tasks/*.json` (local-first; if missing/stale run `npx codebyplan sync` once; break-glass: MCP `get_tasks`); for each advisory, match by ID in task title/requirements.
|
|
161
|
+
4. For every advisory with no matching open task, run `codebyplan task create --checkpoint-id <id> ...` (CLI write-through; break-glass: MCP `create_task`) per `cbp-task-create` Step 3.5 "Immediate Issue Capture Contract".
|
|
162
162
|
5. Report the sweep result:
|
|
163
163
|
```
|
|
164
164
|
## CVE/GHSA Audit Sweep
|
|
@@ -175,7 +175,7 @@ Before activating the task, verify the caller's worktree matches the assigned wo
|
|
|
175
175
|
|
|
176
176
|
1. Read caller worktree: `CALLER_WT=$(npx codebyplan resolve-worktree 2>/dev/null)`.
|
|
177
177
|
2. Determine target worktree:
|
|
178
|
-
- **Checkpoint-bound tasks**: `TARGET_WT = checkpoint.worktree_id` (read from
|
|
178
|
+
- **Checkpoint-bound tasks**: `TARGET_WT = checkpoint.worktree_id` (read from the local checkpoint file already loaded in Step 2). Note: checkpoint-bound tasks may have a NULL `task.assigned_worktree_id` because the lock lives on the parent checkpoint — fall through to `checkpoint.worktree_id`.
|
|
179
179
|
3. If `TARGET_WT IS NOT NULL AND TARGET_WT != CALLER_WT`, surface this error and abort:
|
|
180
180
|
|
|
181
181
|
```
|
|
@@ -206,12 +206,12 @@ Before loading context, check if the feat branch has drifted from the production
|
|
|
206
206
|
|
|
207
207
|
### Step 4: Load Context
|
|
208
208
|
|
|
209
|
-
Load context from
|
|
209
|
+
Load context from local state files:
|
|
210
210
|
|
|
211
|
-
1. **Checkpoint context**: decisions, discoveries, dependencies, constraints
|
|
212
|
-
2. **Task context**: task-specific decisions and requirements
|
|
213
|
-
3. **Task research**: if any research was done
|
|
214
|
-
4. **Previous rounds**: check for completed rounds
|
|
211
|
+
1. **Checkpoint context**: decisions, discoveries, dependencies, constraints — from `.codebyplan/state/checkpoints/<checkpointId>.json`
|
|
212
|
+
2. **Task context**: task-specific decisions and requirements — from `.codebyplan/state/checkpoints/<checkpointId>/tasks/<taskId>.json`
|
|
213
|
+
3. **Task research**: if any research was done — from the task file's `context` field
|
|
214
|
+
4. **Previous rounds**: check for completed rounds — read `.codebyplan/state/checkpoints/<checkpointId>/tasks/<taskId>/rounds/*.json`. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_rounds` when state dir absent and sync fails.
|
|
215
215
|
|
|
216
216
|
Display context summary:
|
|
217
217
|
|
|
@@ -230,9 +230,7 @@ Display context summary:
|
|
|
230
230
|
|
|
231
231
|
### Step 5: Set Task Status
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
If worktree_id present, include `claim_worktree_id` to auto-claim the checkpoint. `caller_worktree_id` (CHK-140 TASK-7) identifies the calling worktree and is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook (CHK-198 TASK-2); the server falls back to the repo `main` worktree only when it is absent.
|
|
233
|
+
`codebyplan task update --id <taskId> --checkpoint-id <checkpointId> --status in_progress` (CLI write-through: local state file + REST). If a worktree_id is present, also pass `--claim-worktree-id <worktreeId>` to auto-claim the checkpoint (the CLI passes all flags as snake-case PATCH fields). Break-glass fallback: MCP `update_task(task_id, status: "in_progress", claim_worktree_id: ..., caller_worktree_id: ...)` when the CLI is unavailable — note `caller_worktree_id` is auto-injected by the `cbp-mcp-caller-worktree-inject.sh` PreToolUse hook only on the MCP path.
|
|
236
234
|
|
|
237
235
|
### Step 6: Auto-trigger Round Start
|
|
238
236
|
|
|
@@ -247,6 +245,6 @@ Trigger `/cbp-round-start` with **no argument**. Do NOT pass the task identifier
|
|
|
247
245
|
## Integration
|
|
248
246
|
|
|
249
247
|
- **Gates**: Step 2.5 permission gate — asks the user to confirm before any side effect; **Cancel** aborts cleanly with no writes. Fires on every invocation (manual, auto-trigger, auto-loop).
|
|
250
|
-
- **Reads**:
|
|
251
|
-
- **Writes**: MCP `update_task`
|
|
248
|
+
- **Reads**: `.codebyplan/state/checkpoints/*.json`, `checkpoints/<id>/tasks/*.json`, `checkpoints/<id>/tasks/<id>/rounds/*.json`, `todos.json` (local-first; `npx codebyplan sync` on miss; MCP `get_current_task`/`get_tasks`/`get_rounds` break-glass)
|
|
249
|
+
- **Writes**: `codebyplan task update` (CLI write-through; MCP `update_task` break-glass)
|
|
252
250
|
- **Triggers**: `/cbp-round-start` (auto, round 1, no argument)
|
|
@@ -30,7 +30,7 @@ Parse the argument using the canonical chk-task-round notation (see `cbp-round-s
|
|
|
30
30
|
| Shape | Regex | Resolves to |
|
|
31
31
|
|-------|-------|-------------|
|
|
32
32
|
| `{chk}-{task}` (e.g. `108-1`) | `^[0-9]+-[0-9]+$` | Checkpoint-bound: CHK-{chk} TASK-{task} |
|
|
33
|
-
| _(empty)_ | — |
|
|
33
|
+
| _(empty)_ | — | Resolve from local state per Step 1.5/2 (MCP `get_current_task` break-glass) — the active in-progress task |
|
|
34
34
|
| `{task}` (bare number) | — | **Error**: "Use /cbp-standalone-task-testing {N} instead — bare numbers no longer route to standalone tasks." |
|
|
35
35
|
|
|
36
36
|
Anything else is malformed — surface this error and stop:
|
|
@@ -60,14 +60,14 @@ Given the parse from Step 1:
|
|
|
60
60
|
|
|
61
61
|
| Parse | Resolution path |
|
|
62
62
|
|-------|-----------------|
|
|
63
|
-
| `{chk}-{task}` |
|
|
64
|
-
| _(empty)_ |
|
|
63
|
+
| `{chk}-{task}` | Read `.codebyplan/state/checkpoints/*.json` → filter `number === {chk}`. Read `.codebyplan/state/checkpoints/<id>/tasks/*.json` → filter `number === {task}`. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_checkpoints`/`get_tasks` when state dir absent and sync fails. |
|
|
64
|
+
| _(empty)_ | Read `.codebyplan/state/todos.json` → find the active in-progress task. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_current_task(repo_id)` when state dir absent and sync fails. |
|
|
65
65
|
|
|
66
66
|
If no in-progress task, show error and stop.
|
|
67
67
|
|
|
68
68
|
### Step 2: Verify All Rounds Complete
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Read `.codebyplan/state/checkpoints/<checkpointId>/tasks/<taskId>/rounds/*.json` (local-first). If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_rounds(task_id)` when state dir absent and sync fails. Verify all rounds are `completed`. If any still `in_progress`:
|
|
71
71
|
|
|
72
72
|
```
|
|
73
73
|
## Cannot Run Task Testing
|
|
@@ -202,20 +202,20 @@ Collect failures from automated tests (Step 6), cross-round code review (Step 6.
|
|
|
202
202
|
|
|
203
203
|
### Step 10: Save Results
|
|
204
204
|
|
|
205
|
+
`codebyplan task update --id <taskId> --checkpoint-id <checkpointId> --context '<json>'` (CLI write-through: local state file + REST), merging `task_testing_output` into the existing context object. Break-glass fallback: MCP `update_task` when CLI is unavailable.
|
|
206
|
+
|
|
205
207
|
```ts
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
summary: { total, passed, failed, pending }
|
|
216
|
-
}
|
|
208
|
+
// context payload to merge:
|
|
209
|
+
{
|
|
210
|
+
task_testing_output: {
|
|
211
|
+
claude_tests: [...],
|
|
212
|
+
cross_round_code_findings: [...], // from Step 6.5
|
|
213
|
+
user_tests: [...],
|
|
214
|
+
problems_found: [...],
|
|
215
|
+
all_passed: boolean,
|
|
216
|
+
summary: { total, passed, failed, pending }
|
|
217
217
|
}
|
|
218
|
-
}
|
|
218
|
+
}
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
### Step 11: Route Based on Results
|
|
@@ -269,7 +269,7 @@ Waiting for user to run `/cbp-task-create`.
|
|
|
269
269
|
|
|
270
270
|
## Integration
|
|
271
271
|
|
|
272
|
-
- **Reads**:
|
|
273
|
-
- **Writes**: MCP `update_task`
|
|
272
|
+
- **Reads**: `.codebyplan/state/checkpoints/*.json`, `checkpoints/<id>/tasks/*.json`, `checkpoints/<id>/tasks/<id>/rounds/*.json`, `todos.json` (local-first; `npx codebyplan sync` on miss; MCP `get_current_task`/`get_rounds` break-glass), plus all aggregated files
|
|
273
|
+
- **Writes**: `codebyplan task update` (CLI write-through; MCP `update_task` break-glass)
|
|
274
274
|
- **Triggers**: `/cbp-task-complete` (auto, when ALL PASS)
|
|
275
275
|
- **Triggered by**: user runs `/cbp-task-testing {chk-task}` per directive from `/cbp-task-check` on READY verdict (after `/cbp-round-execute`-driven validation completed all rounds)
|
|
@@ -40,7 +40,7 @@ npx codebyplan whoami --json # → {"user_id":"<uuid>","email":"…"} or null
|
|
|
40
40
|
|
|
41
41
|
### Step 1: Read the Todo Queue (pure-read)
|
|
42
42
|
|
|
43
|
-
With `USER_ID` resolved,
|
|
43
|
+
With `USER_ID` resolved, read `.codebyplan/state/todos.json` (local-first). If missing or stale (`_cursor.json` absent or `sync_status !== "synced"`), run `npx codebyplan sync` once and re-read. Break-glass fallback: MCP `get_todos({ repo_id, user_id, worktree_id })` when the state dir is absent and sync fails. Filter by `user_id` and `worktree_id` (omit `worktree_id` when `WORKTREE_ID` is `null` or unresolved). Take **`rows[0]`** as the queue head (ordered by `sort_order`).
|
|
44
44
|
|
|
45
45
|
- The head carries `command`, `instructions`, `state`, `metadata`, `worktree_id`, `checkpoint_id`, `task_id`.
|
|
46
46
|
- The routing context (checkpoint/task) lives in **`rows[0].metadata`**.
|
|
@@ -53,7 +53,7 @@ Queue `command` values may use the `/codebyplan:<name>` plugin-namespace form (e
|
|
|
53
53
|
|
|
54
54
|
Resolve the routing target's checkpoint and gate on ownership BEFORE any auto-trigger — including the Step 1.6 planning hand-offs. Refuse to route into, plan, or start work locked to a different worktree.
|
|
55
55
|
|
|
56
|
-
Resolve the checkpoint from `rows[0].metadata` (or MCP `get_current_task`), then load its `worktree_id` + `plan` + `status`
|
|
56
|
+
Resolve the checkpoint from `rows[0].metadata` (or read `.codebyplan/state/session/current.json` for the active task, falling back to MCP `get_current_task`), then load its `worktree_id` + `plan` + `status` from `.codebyplan/state/checkpoints/<id>.json` (falling back to MCP `get_checkpoints`) and its task count from `.codebyplan/state/checkpoints/<id>/tasks/` files (falling back to MCP `get_tasks(checkpoint_id)`). This single load is reused by the Step 1.6 planning gate. Skip this gate when the routing target has no checkpoint (idle — see Step 3) or the command is `/cbp-session-start`.
|
|
57
57
|
|
|
58
58
|
Two ownership signals:
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ Two ownership signals:
|
|
|
64
64
|
- target `worktree_id` non-null **AND** caller `WORKTREE_ID` is `null`/unresolved → **block** (deliberate safety: identity cannot be confirmed. This does not contradict Step 0 — reading the queue is fine, auto-triggering INTO assigned work is not. Run `npx codebyplan setup` to register this worktree).
|
|
65
65
|
- target `worktree_id` non-null and differs from a non-null caller → **block**.
|
|
66
66
|
|
|
67
|
-
On block, resolve the owning worktree's `name` + `path` via MCP `get_worktrees({ repo_id })` (
|
|
67
|
+
On block, resolve the owning worktree's `name` + `path` via MCP `get_worktrees({ repo_id })` (display-only ownership-block path — no CLI verb exists for worktrees; stays MCP), then emit and STOP:
|
|
68
68
|
|
|
69
69
|
```
|
|
70
70
|
⚠ Work mismatch: CHK-<NNN> TASK-<N> is assigned to worktree <name> (<short-uuid>), not this one (<this-name> / <this-short-uuid>).
|
|
@@ -83,7 +83,7 @@ Ownership passed (Step 1.5). Now guard against a lagging queue routing into alre
|
|
|
83
83
|
Reject the auto-trigger when EITHER holds:
|
|
84
84
|
|
|
85
85
|
- The target checkpoint's `status` is `completed` or `cancelled`.
|
|
86
|
-
- Every task
|
|
86
|
+
- Every task from `.codebyplan/state/checkpoints/<id>/tasks/` (loaded in Step 1.5; fallback MCP `get_tasks(checkpoint_id)`) has status `completed` or `cancelled` — no actionable task remains.
|
|
87
87
|
|
|
88
88
|
On reject, surface the mismatch — naming the head command and the stale entity — then **STOP** (do not auto-trigger the head command). Use the variant matching the trigger condition:
|
|
89
89
|
|
|
@@ -123,33 +123,33 @@ Skip this gate when the routing target has no checkpoint (idle — see Step 3) o
|
|
|
123
123
|
|
|
124
124
|
Once the gates pass, load the context the head command needs. This ensures `/clear` + `/cbp-todo` reliably restores full working context.
|
|
125
125
|
|
|
126
|
-
**Use the context loading matrix below.** Match the `command` (in its `/cbp-<name>` form) to determine what to load.
|
|
126
|
+
**Use the context loading matrix below.** Match the `command` (in its `/cbp-<name>` form) to determine what to load. For all reads: use `.codebyplan/state/` local files first; run `npx codebyplan sync` and re-read if stale; MCP break-glass when state dir absent and sync fails.
|
|
127
127
|
|
|
128
128
|
| Command Pattern | Context to Load |
|
|
129
129
|
|----------------|-----------------|
|
|
130
130
|
| `/cbp-session-start` | None — `/cbp-session-start` handles its own loading |
|
|
131
|
-
| `/cbp-checkpoint-create` | If checkpoint exists in `rows[0].metadata`: load checkpoint
|
|
132
|
-
| `/cbp-checkpoint-plan` | Load checkpoint
|
|
133
|
-
| `/cbp-checkpoint-start` | Load checkpoint
|
|
134
|
-
| `/cbp-task-start [N]` | Load
|
|
135
|
-
| `/cbp-round-start` | Load
|
|
136
|
-
| `/cbp-round-update` | Load
|
|
131
|
+
| `/cbp-checkpoint-create` | If checkpoint exists in `rows[0].metadata`: load checkpoint from `.codebyplan/state/checkpoints/<id>.json` (fallback MCP `get_checkpoints`). Display checkpoint title, goal, ideas summary |
|
|
132
|
+
| `/cbp-checkpoint-plan` | Load checkpoint from `.codebyplan/state/checkpoints/<id>.json` + task files under `checkpoints/<id>/tasks/` (fallback MCP `get_checkpoints` + `get_tasks`). Display checkpoint title, goal, ideas, existing task count |
|
|
133
|
+
| `/cbp-checkpoint-start` | Load checkpoint + task files from local state (fallback MCP `get_checkpoints` + `get_tasks`). Display checkpoint title, status, claim state, first pending task |
|
|
134
|
+
| `/cbp-task-start [N]` | Load from `.codebyplan/state/session/current.json` (fallback MCP `get_current_task`). Display checkpoint title + task title/requirements summary |
|
|
135
|
+
| `/cbp-round-start` | Load from local state session + round files (fallback MCP `get_current_task` + `get_rounds`). Display checkpoint + task + round count + last round summary |
|
|
136
|
+
| `/cbp-round-update` | Load from local state session + round files (fallback MCP `get_current_task` + `get_rounds`). Display checkpoint + task + files_changed triage summary (claude_approved, findings, hard_fail) |
|
|
137
137
|
| `/cbp-round-input` | **Full context load** (see Step 2b) |
|
|
138
|
-
| `/cbp-task-check` | Load
|
|
139
|
-
| `/cbp-task-testing` | Load
|
|
140
|
-
| `/cbp-task-create` | Load
|
|
141
|
-
| `/cbp-task-complete` | Load
|
|
142
|
-
| `/cbp-checkpoint-complete` | Load
|
|
138
|
+
| `/cbp-task-check` | Load from local state session (fallback MCP `get_current_task`). Display checkpoint + task + files summary |
|
|
139
|
+
| `/cbp-task-testing` | Load from local state session + round files (fallback MCP `get_current_task` + `get_rounds`). Display checkpoint + task + testing status summary |
|
|
140
|
+
| `/cbp-task-create` | Load from local state session (fallback MCP `get_current_task`). Display checkpoint + task list summary |
|
|
141
|
+
| `/cbp-task-complete` | Load from local state session (fallback MCP `get_current_task`). Display checkpoint + task summary |
|
|
142
|
+
| `/cbp-checkpoint-complete` | Load from local state session (fallback MCP `get_current_task`). Display checkpoint summary |
|
|
143
143
|
| *(no command / idle)* | See Step 3 — suggest `/cbp-session-end` |
|
|
144
144
|
|
|
145
|
-
**For any unrecognized command:** Load
|
|
145
|
+
**For any unrecognized command:** Load from local state session (fallback MCP `get_current_task`) as a safe default. Display whatever context is available.
|
|
146
146
|
|
|
147
147
|
### Step 2b: Full Context Load (for `/cbp-round-input`)
|
|
148
148
|
|
|
149
149
|
This is the most context-dependent command. Load everything:
|
|
150
150
|
|
|
151
|
-
1. **
|
|
152
|
-
2. **
|
|
151
|
+
1. **Local state** `.codebyplan/state/session/current.json` → checkpoint + task (title, goal, context with decisions/discoveries, requirements, files_changed, QA). Fallback: MCP `get_current_task`.
|
|
152
|
+
2. **Local round files** `.codebyplan/state/checkpoints/<id>/tasks/<id>/rounds/*.json` — all rounds for the task. Fallback: MCP `get_rounds(task_id)`.
|
|
153
153
|
|
|
154
154
|
Display a brief context summary:
|
|
155
155
|
|
|
@@ -172,7 +172,7 @@ Display a brief context summary:
|
|
|
172
172
|
|
|
173
173
|
Reached when `get_todos` returns `[]` or `USER_ID` was unavailable.
|
|
174
174
|
|
|
175
|
-
1. **Fallback discovery** (worktree-scoped):
|
|
175
|
+
1. **Fallback discovery** (worktree-scoped): read `.codebyplan/state/session/current.json` and scan `.codebyplan/state/checkpoints/` for active checkpoints (fallback: MCP `get_current_task` + `get_checkpoints`) to discover whether actionable work exists for this caller.
|
|
176
176
|
2. **Actionable work found** → treat the discovered checkpoint as the routing target and apply BOTH the Step 1.5 ownership gate and the Step 1.6 planning gate to it, using the `worktree_id` + `plan` + `status` returned by `get_checkpoints` (the fallback has no `rows[0]` — substitute the discovered checkpoint). If both gates pass, route via Step 2 → Step 4.
|
|
177
177
|
3. **Nothing actionable** → suggest ending the session:
|
|
178
178
|
|
|
@@ -193,5 +193,5 @@ Reached only when the Step 1.5 ownership gate allowed routing to continue, the S
|
|
|
193
193
|
|
|
194
194
|
- **Called by**: `/cbp-session-start`, `/cbp-task-complete`, `/cbp-checkpoint-complete`, manual, after `/clear`
|
|
195
195
|
- **Resolves**: `npx codebyplan resolve-worktree --json` (worktree id + distress signal), `npx codebyplan whoami --json` (user id)
|
|
196
|
-
- **Reads**: MCP `get_todos`, `get_current_task`, `get_rounds`, `get_checkpoints`, `get_tasks
|
|
196
|
+
- **Reads**: `.codebyplan/state/todos.json`, `session/current.json`, `checkpoints/<id>.json`, `checkpoints/<id>/tasks/<id>.json`, `checkpoints/<id>/tasks/<id>/rounds/<id>.json`, `worktrees.json`. If missing/stale, run `npx codebyplan sync` once and re-read. Break-glass: MCP `get_todos`, `get_current_task`, `get_rounds`, `get_checkpoints`, `get_tasks` when state dir absent and sync fails. `get_worktrees` stays MCP (display-only ownership-block path; no CLI verb).
|
|
197
197
|
- **Triggers**: `rows[0].command` (auto, after the Step 1.5 ownership gate and Step 1.55 stale-entity guard pass, and the Step 1.6 planning gate falls through); Step 1.55 overrides to STOP (stale completed/cancelled entity); Step 1.6 overrides to `/cbp-checkpoint-plan` (unplanned) or `/cbp-checkpoint-start` (planned-but-pending)
|