codebyplan 1.13.25 → 1.13.27
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
scope: org-shared
|
|
3
3
|
paths:
|
|
4
4
|
- "apps/todo-worker/**"
|
|
5
|
-
- "
|
|
5
|
+
- "packages/mcp-tools/src/**"
|
|
6
6
|
- "supabase/migrations/*todos*"
|
|
7
7
|
- "supabase/migrations/*worktrees*"
|
|
8
8
|
---
|
|
@@ -31,7 +31,7 @@ The worker is a passive cross-checker (`apps/todo-worker/src/invariants/check.ts
|
|
|
31
31
|
`todos_jobs` is the work queue drained by the worker.
|
|
32
32
|
|
|
33
33
|
```
|
|
34
|
-
MCP write →
|
|
34
|
+
MCP write → enqueueTodosJob → todos_jobs (status='pending')
|
|
35
35
|
↓
|
|
36
36
|
worker claim_todos_job (SELECT … FOR UPDATE SKIP LOCKED)
|
|
37
37
|
↓
|
|
@@ -72,23 +72,36 @@ The queue head (`get_todos` `rows[0]`) maps to one of these slash commands. The
|
|
|
72
72
|
|
|
73
73
|
## 5. Heartbeat policy
|
|
74
74
|
|
|
75
|
-
The worker's `node-cron` heartbeat runs at `0 0 * * *` (UTC midnight). It enumerates every `(repo, worktree, user)` tuple with an active checkpoint OR in-progress standalone task and enqueues a `HEARTBEAT_SWEEP` todos_jobs row for each. This catches drift from missed `
|
|
75
|
+
The worker's `node-cron` heartbeat runs at `0 0 * * *` (UTC midnight). It enumerates every `(repo, worktree, user)` tuple with an active checkpoint OR in-progress standalone task and enqueues a `HEARTBEAT_SWEEP` todos_jobs row for each. This catches drift from missed `enqueueTodosJob` calls in MCP writers.
|
|
76
76
|
|
|
77
77
|
Backoff: a failed job retries at `now + 2^attempts minutes` (cap 60min). After 3 attempts, the job stays `failed` and the heartbeat picks it up again at the next sweep.
|
|
78
78
|
|
|
79
79
|
## 6. Writer obligations — every MCP write enqueues
|
|
80
80
|
|
|
81
|
-
`
|
|
81
|
+
The shared enqueue helper lives at `packages/mcp-tools/src/tools/enqueue-todos.ts`:
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
|
-
|
|
84
|
+
enqueueTodosJob(
|
|
85
|
+
client: SupabaseClient,
|
|
86
|
+
repoId: string,
|
|
87
|
+
callerWorktreeId: string | undefined,
|
|
88
|
+
userId: string | null,
|
|
89
|
+
reason: string
|
|
90
|
+
): Promise<void>
|
|
85
91
|
```
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
Two write modules import this helper:
|
|
94
|
+
|
|
95
|
+
- **`packages/mcp-tools/src/tools/write.ts`** — checkpoint-bound writers (11 tools)
|
|
96
|
+
- **`packages/mcp-tools/src/tools/standalone-write.ts`** — standalone task writers
|
|
97
|
+
|
|
98
|
+
Every workflow mutator MUST call `void enqueueTodosJob(...)` after the mutation succeeds. The 11 checkpoint-bound writers in `write.ts` (CHK-122 + CHK-189):
|
|
88
99
|
|
|
89
100
|
`create_checkpoint, update_checkpoint, complete_checkpoint, create_task, update_task, complete_task, add_round, update_round, complete_round, create_session_log, update_session_log`
|
|
90
101
|
|
|
91
|
-
|
|
102
|
+
**Dead code note**: `apps/web/src/lib/mcp/enqueueTodoJob.ts` and its companion test are orphaned dead code — `apps/web` no longer registers any MCP write tools (they live in `packages/mcp-tools`). Do not add new callers there.
|
|
103
|
+
|
|
104
|
+
**Removed tools**: `enqueue_todo_job` and `bind_worktree_user` no longer exist. Do not reference or recreate them.
|
|
92
105
|
|
|
93
106
|
**Contract**: best-effort. The helper logs and swallows failures — the heartbeat catches anything that slips through. Atomic in-txn enqueue is NOT supported (supabase-js limitation); the worker's bounded staleness (next heartbeat ≤ 24h) is the safety net.
|
|
94
107
|
|
|
@@ -188,6 +188,8 @@
|
|
|
188
188
|
"Bash(npx codebyplan tech-stack:*)",
|
|
189
189
|
"Bash(codebyplan eslint:*)",
|
|
190
190
|
"Bash(npx codebyplan eslint:*)",
|
|
191
|
+
"Bash(codebyplan lsp:*)",
|
|
192
|
+
"Bash(npx codebyplan lsp:*)",
|
|
191
193
|
"Bash(codebyplan round:*)",
|
|
192
194
|
"Bash(npx codebyplan round:*)",
|
|
193
195
|
"Bash(codebyplan help:*)",
|
|
@@ -12,7 +12,7 @@ Activate the session, open a fresh session log, and surface the previous log's p
|
|
|
12
12
|
|
|
13
13
|
## Instructions
|
|
14
14
|
|
|
15
|
-
Run Steps 0 through 5.8 silently (no intermediate output) — except Step 0 aborts the session on MCP failure, Step 1.4 may surface a one-line fast-forward note or warning, Step 1.5 may surface a one-line infra-drift nudge, Step 1.6 may run an install-and-halt path, Step 4.5 may auto-resume a handoff and exit session-start entirely (no Step 6 output), and Step 5.7 may surface an approval gate. (Step numbers are organizational labels; execution order is 0 → 1 → 1.4 → 1.5 → 1.6 → 3 → 4 → 4.5 → 5 → 5.7 → 5.8 → 6 → 7.) Produce ONE output block at Step 6, then auto-trigger or stop per Step 7.
|
|
15
|
+
Run Steps 0 through 5.8 silently (no intermediate output) — except Step 0 aborts the session on MCP failure, Step 1.4 may surface a one-line fast-forward note or warning, Step 1.5 may surface a one-line infra-drift nudge, Step 1.6 may run an install-and-halt path, Step 1.7 may surface a one-line LSP binary nudge, Step 4.5 may auto-resume a handoff and exit session-start entirely (no Step 6 output), and Step 5.7 may surface an approval gate. (Step numbers are organizational labels; execution order is 0 → 1 → 1.4 → 1.5 → 1.6 → 1.7 → 3 → 4 → 4.5 → 5 → 5.7 → 5.8 → 6 → 7.) Produce ONE output block at Step 6, then auto-trigger or stop per Step 7.
|
|
16
16
|
|
|
17
17
|
### Step 0: MCP Health Gate
|
|
18
18
|
|
|
@@ -130,6 +130,16 @@ Parse `$VERSION_JSON` as JSON and branch on the result:
|
|
|
130
130
|
|
|
131
131
|
**Home branches are intentionally not guarded.** A worktree's folder-named home branch (e.g. `codebyplan-web`) is neither protected/main nor the canonical source, so `version-status` returns `guarded:false` there and this gate fires exactly as on a feat branch. That is deliberate — the update lands on whatever branch the worktree is currently resting on (the "update the branch they're on, except main/canonical" decision), not an accidental halt.
|
|
132
132
|
|
|
133
|
+
### Step 1.7: LSP Binary Nudge
|
|
134
|
+
|
|
135
|
+
Surface — never block — any language-server binaries still missing for this repo's tech stack. Runs after the freshness gate (Step 1.6) and before session activation (Step 3); may add one line per missing binary to the Step 6 output. Fully non-blocking — every failure path falls through with no output.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
LSP_NUDGE=$(npx codebyplan lsp --check 2>/dev/null || true)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`codebyplan lsp --check` reads the committed `.codebyplan/lsp.json` (written by a prior project-scope `codebyplan claude install`/`update`), re-checks each LSP server binary on PATH, prunes any now-resolved `.codebyplan/todo/session-start/` nudge file, and prints ONE install-hint line per still-missing binary (e.g. `npm i -g typescript-language-server`). When `.codebyplan/lsp.json` is absent or every binary is already on PATH, it prints nothing. If `$LSP_NUDGE` is non-empty, hold each line for the Step 6 output prefixed with `LSP:`; otherwise skip silently.
|
|
142
|
+
|
|
133
143
|
### Step 3: Update Session State
|
|
134
144
|
|
|
135
145
|
Use MCP `update_session_state` with action `activate`. This deactivates all other repos automatically.
|
|
@@ -224,6 +234,8 @@ Ownership: [total_count] active CHK(s), [owned_count] owned by this worktree
|
|
|
224
234
|
[Owned: CHK-NNN (title), … — only when owned_count > 0]
|
|
225
235
|
[Cross-worktree: CHK-ZZZ (name), … — only when total_count > owned_count]
|
|
226
236
|
|
|
237
|
+
[LSP: <install hint> — one line per still-missing LSP binary held from Step 1.7, only when LSP_NUDGE is non-empty]
|
|
238
|
+
|
|
227
239
|
[⚠ Worktree unregistered — run `npx codebyplan setup` to register — only when WORKTREE_ID is null and no resolver distress was already shown]
|
|
228
240
|
```
|
|
229
241
|
|
|
@@ -241,7 +253,7 @@ Three-branch gate using `owned_count` and `total_count` from Step 5.8:
|
|
|
241
253
|
|
|
242
254
|
- **Triggered by**: user invocation, `/clear` recovery
|
|
243
255
|
- **Resolves**: `npx codebyplan resolve-worktree --json` (worktree id + distress signal; non-tuple-miss distress is non-blocking at session-start)
|
|
244
|
-
- **Reads**: `.codebyplan/repo.json`, `.codebyplan/git.json` (`branch_config.production` for the Step 1.4 home-branch fast-forward), MCP `get_session_logs` (worktree-filtered, limit 1 — single call shared by Step 4 and Step 4.5), MCP `health_check` (Step 0 hard gate), MCP `get_current_task`, MCP `get_rounds`, MCP `get_checkpoints` (two calls: `{ repo_id, status: 'active' }` for the Step 5.8 ownership partition; `{ repo_id }` unfiltered for the Step 4.5 freshness probe, which may resolve a non-active checkpoint), MCP `get_tasks` / `get_rounds` for the Step 4.5 freshness probe; `scripts/infra-drift.mjs` + a best-effort `git fetch` (Step 1.5 monorepo drift); `npx codebyplan version-status` (Step 1.6 package-freshness gate). Reads at Step 3 and later (session-state, session logs, checkpoints, tasks/rounds) do NOT fire on a Step 0 MCP hard-fail or the Step 1.6 update-and-halt path
|
|
256
|
+
- **Reads**: `.codebyplan/repo.json`, `.codebyplan/git.json` (`branch_config.production` for the Step 1.4 home-branch fast-forward), MCP `get_session_logs` (worktree-filtered, limit 1 — single call shared by Step 4 and Step 4.5), MCP `health_check` (Step 0 hard gate), MCP `get_current_task`, MCP `get_rounds`, MCP `get_checkpoints` (two calls: `{ repo_id, status: 'active' }` for the Step 5.8 ownership partition; `{ repo_id }` unfiltered for the Step 4.5 freshness probe, which may resolve a non-active checkpoint), MCP `get_tasks` / `get_rounds` for the Step 4.5 freshness probe; `scripts/infra-drift.mjs` + a best-effort `git fetch` (Step 1.5 monorepo drift); `npx codebyplan version-status` (Step 1.6 package-freshness gate); `npx codebyplan lsp --check` (Step 1.7 LSP binary nudge — reads `.codebyplan/lsp.json`, non-blocking). Reads at Step 3 and later (session-state, session logs, checkpoints, tasks/rounds) do NOT fire on a Step 0 MCP hard-fail or the Step 1.6 update-and-halt path
|
|
245
257
|
- **Writes**: MCP `create_session_log` (new, possibly empty), MCP `update_session_state` (activate) — both SKIPPED on a Step 0 MCP hard-fail and on the Step 1.6 update-and-halt path
|
|
246
258
|
- **Spawns**: none
|
|
247
259
|
- **Triggers**: `/cbp-git-commit` (conditional, on user approval at Step 5.7 or the Step 1.6 update path), `handoff.command` (on fresh handoff hit at Step 4.5), `/cbp-todo` (auto fall-through when owned_count >= 1 or total_count === 0; STOPS with no trigger when total_count >= 1 AND owned_count === 0; NOT triggered on a Step 0 hard-fail or the Step 1.6 update-and-halt path)
|