codebyplan 1.13.65 → 1.13.67

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 (300) hide show
  1. package/README.md +118 -75
  2. package/dist/__tests__/helpers.d.ts +22 -0
  3. package/dist/__tests__/helpers.d.ts.map +1 -0
  4. package/dist/ci-public.d.ts +20 -0
  5. package/dist/ci-public.d.ts.map +1 -0
  6. package/dist/ci.js +11 -2
  7. package/dist/cli/arch-map.d.ts +33 -0
  8. package/dist/cli/arch-map.d.ts.map +1 -0
  9. package/dist/cli/branch.d.ts +10 -0
  10. package/dist/cli/branch.d.ts.map +1 -0
  11. package/dist/cli/bump.d.ts +12 -0
  12. package/dist/cli/bump.d.ts.map +1 -0
  13. package/dist/cli/cd.d.ts +20 -0
  14. package/dist/cli/cd.d.ts.map +1 -0
  15. package/dist/cli/check.d.ts +30 -0
  16. package/dist/cli/check.d.ts.map +1 -0
  17. package/dist/cli/checkpoint.d.ts +17 -0
  18. package/dist/cli/checkpoint.d.ts.map +1 -0
  19. package/dist/cli/ci.d.ts +31 -0
  20. package/dist/cli/ci.d.ts.map +1 -0
  21. package/dist/cli/claude/__test-helpers__/expect-manifest.d.ts +7 -0
  22. package/dist/cli/claude/__test-helpers__/expect-manifest.d.ts.map +1 -0
  23. package/dist/cli/claude/__test-helpers__/tmp-fixture.d.ts +64 -0
  24. package/dist/cli/claude/__test-helpers__/tmp-fixture.d.ts.map +1 -0
  25. package/dist/cli/claude/audit-mode.d.ts +16 -0
  26. package/dist/cli/claude/audit-mode.d.ts.map +1 -0
  27. package/dist/cli/claude/generate.d.ts +23 -0
  28. package/dist/cli/claude/generate.d.ts.map +1 -0
  29. package/dist/cli/claude/install.d.ts +55 -0
  30. package/dist/cli/claude/install.d.ts.map +1 -0
  31. package/dist/cli/claude/migrate-memory.d.ts +117 -0
  32. package/dist/cli/claude/migrate-memory.d.ts.map +1 -0
  33. package/dist/cli/claude/readme.d.ts +28 -0
  34. package/dist/cli/claude/readme.d.ts.map +1 -0
  35. package/dist/cli/claude/status.d.ts +41 -0
  36. package/dist/cli/claude/status.d.ts.map +1 -0
  37. package/dist/cli/claude/uninstall.d.ts +21 -0
  38. package/dist/cli/claude/uninstall.d.ts.map +1 -0
  39. package/dist/cli/claude/update.d.ts +25 -0
  40. package/dist/cli/claude/update.d.ts.map +1 -0
  41. package/dist/cli/claude/verify-parity.d.ts +25 -0
  42. package/dist/cli/claude/verify-parity.d.ts.map +1 -0
  43. package/dist/cli/cleanup-plan-folders.d.ts +21 -0
  44. package/dist/cli/cleanup-plan-folders.d.ts.map +1 -0
  45. package/dist/cli/commit.d.ts +25 -0
  46. package/dist/cli/commit.d.ts.map +1 -0
  47. package/dist/cli/config.d.ts +50 -0
  48. package/dist/cli/config.d.ts.map +1 -0
  49. package/dist/cli/confirm.d.ts +9 -0
  50. package/dist/cli/confirm.d.ts.map +1 -0
  51. package/dist/cli/create-org.d.ts +9 -0
  52. package/dist/cli/create-org.d.ts.map +1 -0
  53. package/dist/cli/create-project.d.ts +10 -0
  54. package/dist/cli/create-project.d.ts.map +1 -0
  55. package/dist/cli/create-repo.d.ts +14 -0
  56. package/dist/cli/create-repo.d.ts.map +1 -0
  57. package/dist/cli/docs.d.ts +41 -0
  58. package/dist/cli/docs.d.ts.map +1 -0
  59. package/dist/cli/doctor.d.ts +17 -0
  60. package/dist/cli/doctor.d.ts.map +1 -0
  61. package/dist/cli/e2e/verify-round.d.ts +46 -0
  62. package/dist/cli/e2e/verify-round.d.ts.map +1 -0
  63. package/dist/cli/e2e.d.ts +11 -0
  64. package/dist/cli/e2e.d.ts.map +1 -0
  65. package/dist/cli/eslint.d.ts +20 -0
  66. package/dist/cli/eslint.d.ts.map +1 -0
  67. package/dist/cli/export-writer.d.ts +99 -0
  68. package/dist/cli/export-writer.d.ts.map +1 -0
  69. package/dist/cli/handoff.d.ts +13 -0
  70. package/dist/cli/handoff.d.ts.map +1 -0
  71. package/dist/cli/login.d.ts +10 -0
  72. package/dist/cli/login.d.ts.map +1 -0
  73. package/dist/cli/logout.d.ts +2 -0
  74. package/dist/cli/logout.d.ts.map +1 -0
  75. package/dist/cli/lsp.d.ts +16 -0
  76. package/dist/cli/lsp.d.ts.map +1 -0
  77. package/dist/cli/migration-collisions.d.ts +10 -0
  78. package/dist/cli/migration-collisions.d.ts.map +1 -0
  79. package/dist/cli/ports.d.ts +29 -0
  80. package/dist/cli/ports.d.ts.map +1 -0
  81. package/dist/cli/process-exit-signal.d.ts +24 -0
  82. package/dist/cli/process-exit-signal.d.ts.map +1 -0
  83. package/dist/cli/round.d.ts +79 -0
  84. package/dist/cli/round.d.ts.map +1 -0
  85. package/dist/cli/scaffold-publish-workflow.d.ts +16 -0
  86. package/dist/cli/scaffold-publish-workflow.d.ts.map +1 -0
  87. package/dist/cli/session/freshness-gate.d.ts +21 -0
  88. package/dist/cli/session/freshness-gate.d.ts.map +1 -0
  89. package/dist/cli/session/home-ff.d.ts +16 -0
  90. package/dist/cli/session/home-ff.d.ts.map +1 -0
  91. package/dist/cli/session/infra-files.d.ts +21 -0
  92. package/dist/cli/session/infra-files.d.ts.map +1 -0
  93. package/dist/cli/session/start.d.ts +70 -0
  94. package/dist/cli/session/start.d.ts.map +1 -0
  95. package/dist/cli/session.d.ts +17 -0
  96. package/dist/cli/session.d.ts.map +1 -0
  97. package/dist/cli/setup.d.ts +2 -0
  98. package/dist/cli/setup.d.ts.map +1 -0
  99. package/dist/cli/ship.d.ts +16 -0
  100. package/dist/cli/ship.d.ts.map +1 -0
  101. package/dist/cli/slug.d.ts +10 -0
  102. package/dist/cli/slug.d.ts.map +1 -0
  103. package/dist/cli/standalone-task.d.ts +31 -0
  104. package/dist/cli/standalone-task.d.ts.map +1 -0
  105. package/dist/cli/statusline.d.ts +10 -0
  106. package/dist/cli/statusline.d.ts.map +1 -0
  107. package/dist/cli/supabase/new-migration.d.ts +24 -0
  108. package/dist/cli/supabase/new-migration.d.ts.map +1 -0
  109. package/dist/cli/supabase/preview-check.d.ts +30 -0
  110. package/dist/cli/supabase/preview-check.d.ts.map +1 -0
  111. package/dist/cli/supabase/resolve-preview.d.ts +19 -0
  112. package/dist/cli/supabase/resolve-preview.d.ts.map +1 -0
  113. package/dist/cli/supabase/teardown-preview.d.ts +22 -0
  114. package/dist/cli/supabase/teardown-preview.d.ts.map +1 -0
  115. package/dist/cli/sync.d.ts +13 -0
  116. package/dist/cli/sync.d.ts.map +1 -0
  117. package/dist/cli/task.d.ts +17 -0
  118. package/dist/cli/task.d.ts.map +1 -0
  119. package/dist/cli/tech-stack.d.ts +11 -0
  120. package/dist/cli/tech-stack.d.ts.map +1 -0
  121. package/dist/cli/upgrade-auth.d.ts +2 -0
  122. package/dist/cli/upgrade-auth.d.ts.map +1 -0
  123. package/dist/cli/upload-e2e-images.d.ts +18 -0
  124. package/dist/cli/upload-e2e-images.d.ts.map +1 -0
  125. package/dist/cli/validate-waves.d.ts +22 -0
  126. package/dist/cli/validate-waves.d.ts.map +1 -0
  127. package/dist/cli/version-status.d.ts +42 -0
  128. package/dist/cli/version-status.d.ts.map +1 -0
  129. package/dist/cli/watch.d.ts +18 -0
  130. package/dist/cli/watch.d.ts.map +1 -0
  131. package/dist/cli/whoami.d.ts +5 -0
  132. package/dist/cli/whoami.d.ts.map +1 -0
  133. package/dist/cli/worktree/add.d.ts +81 -0
  134. package/dist/cli/worktree/add.d.ts.map +1 -0
  135. package/dist/cli/worktree/create.d.ts +46 -0
  136. package/dist/cli/worktree/create.d.ts.map +1 -0
  137. package/dist/cli/worktree/path.d.ts +19 -0
  138. package/dist/cli/worktree/path.d.ts.map +1 -0
  139. package/dist/cli/worktree/remove.d.ts +92 -0
  140. package/dist/cli/worktree/remove.d.ts.map +1 -0
  141. package/dist/cli/worktree.d.ts +15 -0
  142. package/dist/cli/worktree.d.ts.map +1 -0
  143. package/dist/cli.js +5697 -5322
  144. package/dist/dispatch.d.ts +64 -0
  145. package/dist/dispatch.d.ts.map +1 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/lib/agents-generator.d.ts +42 -0
  149. package/dist/lib/agents-generator.d.ts.map +1 -0
  150. package/dist/lib/api.d.ts +54 -0
  151. package/dist/lib/api.d.ts.map +1 -0
  152. package/dist/lib/atomic-write.d.ts +27 -0
  153. package/dist/lib/atomic-write.d.ts.map +1 -0
  154. package/dist/lib/branch-checkout.d.ts +47 -0
  155. package/dist/lib/branch-checkout.d.ts.map +1 -0
  156. package/dist/lib/branch-port-resolver.d.ts +58 -0
  157. package/dist/lib/branch-port-resolver.d.ts.map +1 -0
  158. package/dist/lib/bump.d.ts +97 -0
  159. package/dist/lib/bump.d.ts.map +1 -0
  160. package/dist/lib/cd-init.d.ts +86 -0
  161. package/dist/lib/cd-init.d.ts.map +1 -0
  162. package/dist/lib/check-baseline.d.ts +91 -0
  163. package/dist/lib/check-baseline.d.ts.map +1 -0
  164. package/dist/lib/check.d.ts +178 -0
  165. package/dist/lib/check.d.ts.map +1 -0
  166. package/dist/lib/ci-init.d.ts +106 -0
  167. package/dist/lib/ci-init.d.ts.map +1 -0
  168. package/dist/lib/ci-resolve.d.ts +60 -0
  169. package/dist/lib/ci-resolve.d.ts.map +1 -0
  170. package/dist/lib/claude-mode-audit.d.ts +41 -0
  171. package/dist/lib/claude-mode-audit.d.ts.map +1 -0
  172. package/dist/lib/claude-plan.d.ts +34 -0
  173. package/dist/lib/claude-plan.d.ts.map +1 -0
  174. package/dist/lib/commit-scope.d.ts +21 -0
  175. package/dist/lib/commit-scope.d.ts.map +1 -0
  176. package/dist/lib/e2e.d.ts +157 -0
  177. package/dist/lib/e2e.d.ts.map +1 -0
  178. package/dist/lib/eslint-generator.d.ts +86 -0
  179. package/dist/lib/eslint-generator.d.ts.map +1 -0
  180. package/dist/lib/file-lock.d.ts +44 -0
  181. package/dist/lib/file-lock.d.ts.map +1 -0
  182. package/dist/lib/flags.d.ts +115 -0
  183. package/dist/lib/flags.d.ts.map +1 -0
  184. package/dist/lib/gh-required-checks.d.ts +76 -0
  185. package/dist/lib/gh-required-checks.d.ts.map +1 -0
  186. package/dist/lib/git-utils.d.ts +46 -0
  187. package/dist/lib/git-utils.d.ts.map +1 -0
  188. package/dist/lib/gitignore-block.d.ts +32 -0
  189. package/dist/lib/gitignore-block.d.ts.map +1 -0
  190. package/dist/lib/gitignore-detect.d.ts +117 -0
  191. package/dist/lib/gitignore-detect.d.ts.map +1 -0
  192. package/dist/lib/handoff-file.d.ts +63 -0
  193. package/dist/lib/handoff-file.d.ts.map +1 -0
  194. package/dist/lib/hash.d.ts +9 -0
  195. package/dist/lib/hash.d.ts.map +1 -0
  196. package/dist/lib/lsp-detect.d.ts +42 -0
  197. package/dist/lib/lsp-detect.d.ts.map +1 -0
  198. package/dist/lib/manifest.d.ts +88 -0
  199. package/dist/lib/manifest.d.ts.map +1 -0
  200. package/dist/lib/mcp-client.d.ts +39 -0
  201. package/dist/lib/mcp-client.d.ts.map +1 -0
  202. package/dist/lib/migrate-branch-model.d.ts +34 -0
  203. package/dist/lib/migrate-branch-model.d.ts.map +1 -0
  204. package/dist/lib/migrate-local-config.d.ts +39 -0
  205. package/dist/lib/migrate-local-config.d.ts.map +1 -0
  206. package/dist/lib/migration-collisions.d.ts +61 -0
  207. package/dist/lib/migration-collisions.d.ts.map +1 -0
  208. package/dist/lib/port-verify.d.ts +73 -0
  209. package/dist/lib/port-verify.d.ts.map +1 -0
  210. package/dist/lib/prompt.d.ts +41 -0
  211. package/dist/lib/prompt.d.ts.map +1 -0
  212. package/dist/lib/readme-generator.d.ts +108 -0
  213. package/dist/lib/readme-generator.d.ts.map +1 -0
  214. package/dist/lib/repo-reader.d.ts +59 -0
  215. package/dist/lib/repo-reader.d.ts.map +1 -0
  216. package/dist/lib/scaffold-cd-workflow.d.ts +48 -0
  217. package/dist/lib/scaffold-cd-workflow.d.ts.map +1 -0
  218. package/dist/lib/scaffold-ci-workflow.d.ts +83 -0
  219. package/dist/lib/scaffold-ci-workflow.d.ts.map +1 -0
  220. package/dist/lib/scaffold-publish-workflow.d.ts +48 -0
  221. package/dist/lib/scaffold-publish-workflow.d.ts.map +1 -0
  222. package/dist/lib/server-detect.d.ts +20 -0
  223. package/dist/lib/server-detect.d.ts.map +1 -0
  224. package/dist/lib/session.d.ts +371 -0
  225. package/dist/lib/session.d.ts.map +1 -0
  226. package/dist/lib/settings-merge.d.ts +268 -0
  227. package/dist/lib/settings-merge.d.ts.map +1 -0
  228. package/dist/lib/ship.d.ts +84 -0
  229. package/dist/lib/ship.d.ts.map +1 -0
  230. package/dist/lib/slug.d.ts +26 -0
  231. package/dist/lib/slug.d.ts.map +1 -0
  232. package/dist/lib/spawn.d.ts +12 -0
  233. package/dist/lib/spawn.d.ts.map +1 -0
  234. package/dist/lib/state-client.d.ts +54 -0
  235. package/dist/lib/state-client.d.ts.map +1 -0
  236. package/dist/lib/state-store.d.ts +153 -0
  237. package/dist/lib/state-store.d.ts.map +1 -0
  238. package/dist/lib/state-sync.d.ts +101 -0
  239. package/dist/lib/state-sync.d.ts.map +1 -0
  240. package/dist/lib/statusline-config.d.ts +55 -0
  241. package/dist/lib/statusline-config.d.ts.map +1 -0
  242. package/dist/lib/structure-generator.d.ts +63 -0
  243. package/dist/lib/structure-generator.d.ts.map +1 -0
  244. package/dist/lib/supabase.d.ts +87 -0
  245. package/dist/lib/supabase.d.ts.map +1 -0
  246. package/dist/lib/sync-approvals.d.ts +108 -0
  247. package/dist/lib/sync-approvals.d.ts.map +1 -0
  248. package/dist/lib/tech-detect.d.ts +77 -0
  249. package/dist/lib/tech-detect.d.ts.map +1 -0
  250. package/dist/lib/template-walker.d.ts +26 -0
  251. package/dist/lib/template-walker.d.ts.map +1 -0
  252. package/dist/lib/templates-dir.d.ts +25 -0
  253. package/dist/lib/templates-dir.d.ts.map +1 -0
  254. package/dist/lib/types.d.ts +843 -0
  255. package/dist/lib/types.d.ts.map +1 -0
  256. package/dist/lib/validate-waves.d.ts +38 -0
  257. package/dist/lib/validate-waves.d.ts.map +1 -0
  258. package/dist/lib/verify-parity.d.ts +154 -0
  259. package/dist/lib/verify-parity.d.ts.map +1 -0
  260. package/dist/lib/version.d.ts +3 -0
  261. package/dist/lib/version.d.ts.map +1 -0
  262. package/dist/lib/watch-daemon.d.ts +114 -0
  263. package/dist/lib/watch-daemon.d.ts.map +1 -0
  264. package/dist/lib/worktree.d.ts +56 -0
  265. package/dist/lib/worktree.d.ts.map +1 -0
  266. package/dist/oauth/browser.d.ts +8 -0
  267. package/dist/oauth/browser.d.ts.map +1 -0
  268. package/dist/oauth/client-registration.d.ts +16 -0
  269. package/dist/oauth/client-registration.d.ts.map +1 -0
  270. package/dist/oauth/device-flow.d.ts +40 -0
  271. package/dist/oauth/device-flow.d.ts.map +1 -0
  272. package/dist/oauth/jwt-decode.d.ts +10 -0
  273. package/dist/oauth/jwt-decode.d.ts.map +1 -0
  274. package/dist/oauth/keychain.d.ts +17 -0
  275. package/dist/oauth/keychain.d.ts.map +1 -0
  276. package/dist/oauth/token-refresh.d.ts +7 -0
  277. package/dist/oauth/token-refresh.d.ts.map +1 -0
  278. package/dist/oauth/types.d.ts +28 -0
  279. package/dist/oauth/types.d.ts.map +1 -0
  280. package/dist/oauth/urls.d.ts +16 -0
  281. package/dist/oauth/urls.d.ts.map +1 -0
  282. package/package.json +5 -6
  283. package/templates/agents/cbp-security-agent.md +0 -1
  284. package/templates/agents/cbp-stripe-agent.md +0 -1
  285. package/templates/agents/cbp-testing-qa-agent.md +0 -1
  286. package/templates/hooks/cbp-skill-context-guard.sh +0 -1
  287. package/templates/hooks/cbp-test-hooks.sh +0 -81
  288. package/templates/hooks/validate-structure-lib.sh +36 -9
  289. package/templates/rules/cbp-operating-gotchas.md +8 -10
  290. package/templates/rules/todo-backend.md +4 -2
  291. package/templates/skills/cbp-build-cc-settings/reference/cbp-permission-policy.md +3 -3
  292. package/templates/skills/cbp-checkpoint-check/SKILL.md +0 -1
  293. package/templates/skills/cbp-checkpoint-end/SKILL.md +11 -5
  294. package/templates/skills/cbp-clear-continue/SKILL.md +0 -1
  295. package/templates/skills/cbp-clear-prep/SKILL.md +0 -1
  296. package/templates/skills/cbp-finalize/SKILL.md +2 -2
  297. package/templates/skills/cbp-setup-cd/SKILL.md +0 -1
  298. package/templates/skills/cbp-setup-ci/SKILL.md +0 -1
  299. package/templates/skills/cbp-standalone-task-complete/SKILL.md +40 -0
  300. package/templates/skills/cbp-stripe/SKILL.md +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.13.65",
3
+ "version": "1.13.67",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,18 +52,17 @@
52
52
  "registry": "https://registry.npmjs.org/"
53
53
  },
54
54
  "engines": {
55
- "node": ">=18"
55
+ "node": ">=22"
56
56
  },
57
57
  "dependencies": {
58
58
  "@napi-rs/keyring": "^1.1.6",
59
- "@supabase/supabase-js": "^2.106.0",
60
- "ws": ">=8.20.1"
59
+ "@supabase/supabase-js": "^2.106.0"
61
60
  },
62
61
  "devDependencies": {
63
62
  "@eslint/js": "^9.18.0",
64
- "@types/node": "^20",
63
+ "@types/node": "^22",
65
64
  "@vitest/eslint-plugin": "^1.1.44",
66
- "esbuild": ">=0.28.1",
65
+ "esbuild": "^0.28.1",
67
66
  "eslint": "^9.18.0",
68
67
  "eslint-config-prettier": "^10.0.1",
69
68
  "eslint-plugin-no-secrets": "^2.2.1",
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-security-agent
4
3
  description: Security review specialist. Checks for OWASP top 10 vulnerabilities, hardcoded secrets, SQL injection, XSS, CSRF, and dependency vulnerabilities.
5
4
  tools: Read, Glob, Grep, Bash
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-stripe-agent
4
3
  description: Stripe integration specialist. Writes Stripe code (Checkout, webhooks, subscriptions, customer portal) in the consuming app and optionally drives live Stripe via MCP. Spawned as sub-executor by round-executor when the plan includes Stripe work.
5
4
  tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-testing-qa-agent
4
3
  description: Combined testing, QA generation, and default checklists. Runs build/lint/types/unit-tests/audit, generates auto QA items, applies default production checklists. Does NOT consume e2e screenshots or frontend-ui findings.
5
4
  tools: Read, Glob, Grep, Bash, AskUserQuestion
@@ -1,5 +1,4 @@
1
1
  #!/bin/bash
2
- # @scope: org-shared
3
2
  # Hook: PreToolUse (Skill)
4
3
  # Purpose: Deny heavy close-out skills when context window exceeds the model-aware threshold:
5
4
  # 200K tokens for standard models (CBP_CONTEXT_WARN_TOKENS, default 200000);
@@ -374,87 +374,6 @@ fi
374
374
 
375
375
  echo ""
376
376
 
377
- # ===== HOOK SMOKE TESTS — cbp-mcp-caller-worktree-inject =====
378
- echo "## Hook Smoke Tests — cbp-mcp-caller-worktree-inject (CHK-198)"
379
-
380
- INJECT_HOOK="$HOOKS_DIR/cbp-mcp-caller-worktree-inject.sh"
381
- # Absolute path — the fail-open test runs the hook from a temp cwd (to isolate it
382
- # from this repo's git context), where the relative "$HOOKS_DIR" no longer resolves.
383
- INJECT_HOOK_ABS="$(cd "$HOOKS_DIR" 2>/dev/null && pwd)/cbp-mcp-caller-worktree-inject.sh"
384
-
385
- if [ ! -f "$INJECT_HOOK" ]; then
386
- test_result "cbp-mcp-caller-worktree-inject.sh present" "passed" "missing"
387
- else
388
- test_result "cbp-mcp-caller-worktree-inject.sh present" "passed" "passed"
389
-
390
- FIRST_LINE=$(head -1 "$INJECT_HOOK")
391
- if echo "$FIRST_LINE" | grep -q '^#!/'; then
392
- test_result "cbp-mcp-caller-worktree-inject.sh has shebang" "passed" "passed"
393
- else
394
- test_result "cbp-mcp-caller-worktree-inject.sh has shebang" "passed" "missing"
395
- fi
396
-
397
- if grep -q '@scope: org-shared' "$INJECT_HOOK"; then
398
- test_result "cbp-mcp-caller-worktree-inject.sh has @scope: org-shared" "passed" "passed"
399
- else
400
- test_result "cbp-mcp-caller-worktree-inject.sh has @scope: org-shared" "passed" "missing"
401
- fi
402
-
403
- # Fail-open: run from a non-repo temp dir with no worktree cache and no
404
- # CLAUDE_PROJECT_DIR — neither the cache nor the CLI fallback can resolve a
405
- # worktree, so the hook must exit 0 with empty stdout (no updatedInput).
406
- ISO=$(mktemp -d)
407
- OUTPUT=$( (cd "$ISO" && env -u CLAUDE_PROJECT_DIR bash "$INJECT_HOOK_ABS" <<< '{"tool_input":{"task_id":"x"}}') 2>/dev/null )
408
- EXIT_CODE=$?
409
- if [ "$EXIT_CODE" = "0" ] && [ -z "$OUTPUT" ]; then
410
- test_result "cbp-mcp-caller-worktree-inject.sh fail-open (unresolvable) exits 0 + empty stdout" "passed" "passed"
411
- else
412
- test_result "cbp-mcp-caller-worktree-inject.sh fail-open (unresolvable) exits 0 + empty stdout" "passed" "failed (exit=$EXIT_CODE)"
413
- fi
414
- rm -rf "$ISO"
415
-
416
- # C6 — input already carries a non-empty caller_worktree_id → never overwrite;
417
- # early-return with exit 0 and empty stdout (no resolution attempted).
418
- OUTPUT=$(echo '{"tool_input":{"caller_worktree_id":"11111111-1111-1111-1111-111111111111"}}' | bash "$INJECT_HOOK" 2>/dev/null)
419
- EXIT_CODE=$?
420
- if [ "$EXIT_CODE" = "0" ] && [ -z "$OUTPUT" ]; then
421
- test_result "cbp-mcp-caller-worktree-inject.sh C6 keeps existing caller_worktree_id (exit 0 + empty stdout)" "passed" "passed"
422
- else
423
- test_result "cbp-mcp-caller-worktree-inject.sh C6 keeps existing caller_worktree_id (exit 0 + empty stdout)" "passed" "failed (exit=$EXIT_CODE)"
424
- fi
425
-
426
- # Injection — a worktree.local.json whose .branch matches the current git branch
427
- # makes the cache fast-path resolve. Use a synthetic UUID so the assertion proves
428
- # the cache value (not the live CLI) was injected. Skipped when no concrete git
429
- # branch resolves (detached HEAD / non-git checkout) or jq is unavailable.
430
- CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
431
- if [ -n "$CUR_BRANCH" ] && [ "$CUR_BRANCH" != "HEAD" ] && command -v jq >/dev/null 2>&1; then
432
- ISO=$(mktemp -d)
433
- mkdir -p "$ISO/.codebyplan"
434
- FAKE_WT="abcdef01-2345-6789-abcd-ef0123456789"
435
- jq -n --arg b "$CUR_BRANCH" --arg w "$FAKE_WT" \
436
- '{worktree_id:$w, branch:$b}' > "$ISO/.codebyplan/worktree.local.json"
437
- OUTPUT=$(CLAUDE_PROJECT_DIR="$ISO" bash "$INJECT_HOOK" <<< '{"tool_input":{"task_id":"x"}}' 2>/dev/null)
438
- EXIT_CODE=$?
439
- INJECTED=$(echo "$OUTPUT" | jq -r '.hookSpecificOutput.updatedInput.caller_worktree_id // empty' 2>/dev/null)
440
- # Sibling-key survival — CC's updatedInput REPLACES tool_input wholesale (it is
441
- # not a partial merge), so the hook must echo back every original field merged
442
- # with caller_worktree_id. Assert the non-target sibling key (task_id) survives;
443
- # this is the assertion gap that let the replace-vs-merge bug ship in round 2.
444
- PRESERVED=$(echo "$OUTPUT" | jq -r '.hookSpecificOutput.updatedInput.task_id // empty' 2>/dev/null)
445
- if [ "$EXIT_CODE" = "0" ] && [ "$INJECTED" = "$FAKE_WT" ] && [ "$PRESERVED" = "x" ]; then
446
- test_result "cbp-mcp-caller-worktree-inject.sh injects caller_worktree_id AND preserves sibling keys" "passed" "passed"
447
- else
448
- test_result "cbp-mcp-caller-worktree-inject.sh injects caller_worktree_id AND preserves sibling keys" "passed" "failed (exit=$EXIT_CODE injected=$INJECTED preserved=$PRESERVED)"
449
- fi
450
- rm -rf "$ISO"
451
- else
452
- test_result "cbp-mcp-caller-worktree-inject.sh injection test (no branch resolvable — skipped)" "passed" "passed"
453
- fi
454
- fi
455
-
456
- echo ""
457
-
458
377
  # ===== HOOK SMOKE TESTS — cbp-session-start-hook =====
459
378
  echo "## Hook Smoke Tests — cbp-session-start-hook (CHK-178)"
460
379
 
@@ -103,17 +103,44 @@ has_scope_comment() {
103
103
  }
104
104
 
105
105
  # has_template_twin <rel_path_under_claude>
106
- # Returns 0 when the codebyplan package ships a template twin for this .claude file
107
- # (i.e. the file is package-MANAGED org-shared is its implicit default and a
108
- # scope marker is NOT required). <rel_path_under_claude> is the path beneath
109
- # .claude/ (e.g. "rules/foo.md", "skills/x/SKILL.md").
110
- # Monorepo: $REPO_ROOT/packages/codebyplan-package/templates/<rel>
111
- # Consumer: $REPO_ROOT/node_modules/codebyplan/templates/<rel>
112
- # Returns non-zero when no twin is found including when no templates dir is
113
- # resolvable at all. Callers treat a non-zero result as "user-created", which is
114
- # the conservative fallback: a scope marker is then required (legacy behavior).
106
+ # Returns 0 when the file is package-MANAGED (a template twin exists) org-shared
107
+ # is its implicit default and a scope marker is NOT required. <rel_path_under_claude>
108
+ # is the path beneath .claude/ (e.g. "rules/foo.md", "skills/x/SKILL.md").
109
+ #
110
+ # Resolution order:
111
+ # 1. The install manifest (.claude/.cbp.manifest.json, with mid/legacy filename
112
+ # fallback). Its files[].dest entries are the authoritative record of what
113
+ # codebyplan installed INTO THIS repo independent of where the package
114
+ # lives on disk (pnpm symlinks, hoisting, monorepo sub-packages). Requires jq.
115
+ # 2. Filesystem probe of the package's templates dir — fallback when there is no
116
+ # manifest/jq, and a backstop so a stale manifest never hides a genuine twin:
117
+ # Monorepo: $REPO_ROOT/packages/codebyplan-package/templates/<rel>
118
+ # Consumer: $REPO_ROOT/node_modules/codebyplan/templates/<rel>
119
+ # Returns non-zero when no twin is found by either path. Callers treat non-zero as
120
+ # "user-created": a scope marker is then required (the conservative fallback).
115
121
  has_template_twin() {
116
122
  local rel="$1"
123
+
124
+ # 1. Authoritative: the install manifest lists every managed file by dest path.
125
+ if command -v jq >/dev/null 2>&1; then
126
+ local manifest
127
+ for manifest in \
128
+ "$REPO_ROOT/.claude/.cbp.manifest.json" \
129
+ "$REPO_ROOT/.claude/.cbp-claude.manifest.json" \
130
+ "$REPO_ROOT/.claude/.codebyplan-claude.manifest.json"; do
131
+ if [ -f "$manifest" ]; then
132
+ if jq -e --arg rel "$rel" 'any(.files[]?; .dest == $rel)' "$manifest" >/dev/null 2>&1; then
133
+ return 0
134
+ fi
135
+ # Manifest found but does not list this file — stop scanning older
136
+ # manifest names and fall through to the filesystem probe (a stale
137
+ # manifest must not hide a genuine template twin).
138
+ break
139
+ fi
140
+ done
141
+ fi
142
+
143
+ # 2. Fallback / backstop: probe the package's templates dir directly.
117
144
  [ -f "$REPO_ROOT/packages/codebyplan-package/templates/$rel" ] && return 0
118
145
  [ -f "$REPO_ROOT/node_modules/codebyplan/templates/$rel" ] && return 0
119
146
  return 1
@@ -25,11 +25,13 @@ SHARED tooling behavior only — repo-specific gotchas belong in that repo's own
25
25
  clobbers existing `decisions` / `discoveries` / `check_results`. Always read the current row,
26
26
  merge your change into the full object/array, then write the whole thing back.
27
27
 
28
- - **`resolve-worktree` empty output = a NULL `(device, path, branch)` tuple, not a broken
29
- resolver.** When identity is unresolved the server can collapse the caller to the repo's main
30
- worktree, so feat-locked writes get rejected. Pass `caller_worktree_id` on every MCP mutation,
31
- and confirm ownership by matching the row's repo path + branch to the current directory before
32
- mutating.
28
+ - **User-level locks are invisible until a mutation they block.** `get_checkpoints` /
29
+ `get_tasks` succeed even when another user holds the assignment; the 403 fires only on
30
+ `update_*` / `complete_*`. The lock keys on the JWT user (`ctx.userId`) vs the row's
31
+ `assigned_user_id` (null = open). `caller_worktree_id` / `worktree_id` params are
32
+ accepted-and-ignored — do not thread them. Verify `assigned_user_id` matches
33
+ `npx codebyplan whoami` before mutating; recover a stale assignment with
34
+ `release_assignment` (maintainer).
33
35
 
34
36
  - **Full-repo lint/type baselines are often pre-existing red.** A round must gate on the files
35
37
  it changed, not the whole-repo baseline — scope lint/tsc checks to the round's changed set so a
@@ -42,14 +44,10 @@ SHARED tooling behavior only — repo-specific gotchas belong in that repo's own
42
44
  files or carried directory-slash round artifacts, `complete_task` can hard-fail "N files not
43
45
  approved"; fix by re-writing each affected round's `files_changed` via `update_round`.
44
46
 
45
- - **CLI transport uses REST (reads) and OAuth+MCP (writes) — a 502 from `codebyplan round sync-approvals` is transient MCP churn, not an outage.** The CLI exits 0 with a warning and MCP tools still work. A missing `CODEBYPLAN_API_KEY` surfaces as an `ApiError`, not a 502. `sync-approvals` can also drag untracked per-device dirs into `files_changed` — run it from the repo root or pass `--caller-worktree-id`.
47
+ - **CLI transport uses REST (reads) and OAuth+MCP (writes) — a 502 from `codebyplan round sync-approvals` is transient MCP churn, not an outage.** The CLI exits 0 with a warning and MCP tools still work. A missing `CODEBYPLAN_API_KEY` surfaces as an `ApiError`, not a 502. `sync-approvals` can also drag untracked per-device dirs into `files_changed` — run it from the repo root.
46
48
 
47
49
  - **`codebyplan claude update` requires a TTY.** On non-TTY stdin (CI, piped) it half-applies then errors. Re-run with `--yes` to accept defaults non-interactively.
48
50
 
49
- - **Checkpoint locks are invisible until a mutation they block.** `get_checkpoints` / `get_tasks` succeed even when another worktree holds the lock; the 403 fires only on `update_*` / `complete_*`. Verify the row's `worktree_id` matches the caller before mutating. A null-`worktree_id` checkpoint can still be actively shipped by whichever worktree physically holds its feat branch — check `git worktree list` first.
50
-
51
- - **`update_task` accepts `caller_worktree_id` for lock-verify only — it does NOT assign ownership.** Ownership assignment goes through the web UI or the dedicated assignment path. Don't conflate `caller_worktree_id` with `assigned_worktree_id`.
52
-
53
51
  - **Re-run config-driven gates after merging main into a feat branch.** A merge can add or change `.codebyplan/shipment.json`, ports, branch config, `e2e.json`, and `eslint.json` — treat the post-merge state as a fresh baseline before continuing.
54
52
 
55
53
  - **MCP write calls can return 403 via Cloudflare WAF when the JSONB payload contains DDL
@@ -20,8 +20,8 @@ Defined in `supabase/migrations/20260511211900_chk111_workflow_invariants.sql` (
20
20
  | 2 | `trg_enforce_standalone_task_workflow_invariants` | A standalone task cannot be moved to `in_progress` without `assigned_user_id` (CHK-225: was `assigned_worktree_id`) |
21
21
  | 3 | `trg_enforce_task_workflow_invariants` | ≤ 1 `in_progress` task per checkpoint |
22
22
  | 4 | `trg_enforce_single_in_progress_round_per_task` | ≤ 1 `in_progress` round per task |
23
- | 5 | `trg_enforce_single_active_scope_per_worktree` | ≤ 1 active (checkpoint OR standalone task) per `assigned_user_id` (CHK-225: was per `worktree_id`) |
24
- | 6 | `trg_enforce_standalone_task_scope_per_worktree` | ≤ 1 `in_progress` standalone task per `assigned_user_id` (CHK-225: was per `assigned_worktree_id`) |
23
+ | 5 | `trg_enforce_single_active_scope_per_worktree` | ≤ 1 active (checkpoint OR standalone task) per `branch_name` (CHK-235: was per `assigned_user_id`) |
24
+ | 6 | `trg_enforce_standalone_task_scope_per_worktree` | ≤ 1 `in_progress` standalone task per `branch_name` (CHK-235: was per `assigned_user_id`) |
25
25
 
26
26
  The worker is a passive cross-checker (`apps/todo-worker/src/invariants/check.ts`) — if its check disagrees with the DB, the DB wins.
27
27
 
@@ -109,6 +109,8 @@ CHK-111 shipped the original todos queue as Postgres triggers + a 583-LOC `regen
109
109
 
110
110
  CHK-225 updated the invariant triggers from worktree-scoped to user-scoped (`assigned_user_id`). The trigger names were preserved for continuity; only the function bodies changed. Migration: `20260612000000_chk225_task1_user_locks.sql`.
111
111
 
112
+ CHK-235 re-scoped the same two trigger functions from per-`assigned_user_id` to per-`branch_name`, restoring multi-worktree concurrency (one active scope per feat branch). Migration: `20260622000000_chk235_task1_active_scope_per_branch.sql`.
113
+
112
114
  ## 8. Deployment — Railway
113
115
 
114
116
  `apps/todo-worker` runs as a Railway service alongside `apps/backend`. Setup:
@@ -24,15 +24,15 @@ Precedence is `deny > ask > allow`; arrays union across scopes (managed/user/pro
24
24
 
25
25
  - **Non-lifecycle, non-shipment `/cbp-*` skills** — authoring (`cbp-build-cc-*`), frontend (`cbp-frontend-*`), git (`cbp-git-*`, `cbp-merge-main`, `cbp-refresh-infra`), round work (`cbp-round-plan`, `cbp-verify` — `cbp-verify` is the autonomous verify stage that runs deterministic gates, proves execution, spawns the fresh-context reviewer, and routes to `cbp-round-complete` or `cbp-round-plan`, so it runs without a prompt), setup/configure (`cbp-setup-*`, `cbp-ship-configure`, `cbp-supabase-*`), task prep (`cbp-task-create`/`-start`, `cbp-standalone-task-check`/`-testing`), planning (`cbp-checkpoint-plan`/`-update`), plus `cbp-session-start` and `cbp-todo`. Invoking a skill is the intended mode of operation; the gated side effects happen inside via the Bash/MCP tools the skill calls, which carry their own tiering. The lifecycle/state-transition and plan-approval skills are the exception — they live in `ask` (next section).
26
26
  - **All `mcp__codebyplan__*` reads** (`get_*`, `list_*`, `search_*`, `health_check`, `lookup_symbol`, `resolve_library_id`, `get_chunk`).
27
- - **Routine workflow-write MCP tools** the pipeline calls many times per task: create/update/complete checkpoint, task, and round; session log + session-state writes; `create_worktree`, `add_library`, `flag_stale_chunk`, `update_server_config`, `update_eslint_repo_config`. Gating these with `ask` would make the autonomous workflow unusable.
28
- - **Read/safe CLI commands** (both `codebyplan X` and `npx codebyplan X`): `whoami`, `resolve-worktree`, `statusline`, `ports`, `tech-stack`, `eslint`, `round`, `help`, `--version`.
27
+ - **Routine workflow-write MCP tools** the pipeline calls many times per task: create/update/complete checkpoint, task, and round; session log + session-state writes; `add_library`, `flag_stale_chunk`, `update_server_config`, `update_eslint_repo_config`. Gating these with `ask` would make the autonomous workflow unusable.
28
+ - **Read/safe CLI commands** (both `codebyplan X` and `npx codebyplan X`): `whoami`, `docs`, `statusline`, `ports`, `tech-stack`, `eslint`, `round`, `help`, `--version`.
29
29
 
30
30
  ### `ask` — the deliberate confirm-gate
31
31
 
32
32
  - **Production-shipment skills**: `cbp-ship`, `cbp-ship-main`, `cbp-checkpoint-end` — these promote/deploy to production, so they prompt even in an otherwise auto-allowed setup.
33
33
  - **Lifecycle / state-transition skills**: `cbp-checkpoint-start`, `cbp-checkpoint-create`, `cbp-checkpoint-check`, `cbp-checkpoint-complete`, `cbp-round-complete`, `cbp-session-end`, `cbp-finalize`, `cbp-standalone-task-create`, `cbp-standalone-task-start`, `cbp-standalone-task-complete` — these open or close checkpoints, tasks, rounds, and sessions (advancing workflow state in the database), so they stop for explicit confirmation rather than running autonomously. `cbp-round-complete` is the permission-gated round finalizer (reconciles the user's `git add`s, completes the round, routes onward); its `ask` prompt is the human gate downstream of `cbp-verify` — the autonomous, `allow`-tier verify stage whose triage routes here.
34
34
  - **Plan-approval gate**: `cbp-round-build` — the round plan is approved by confirming this `ask` prompt rather than via an in-skill AskUserQuestion. `cbp-round-plan` runs its planning Q&A, then hands off to `cbp-round-build`; the permission prompt is the user's go/no-go on the plan.
35
- - **Destructive / admin MCP tools**: `delete_session_log`, `delete_worktree`, `create_repo`, `release_assignment`. (The launch and member-admin tools were dropped from the MCP surface in CHK-180 — those concerns are web-app only now.)
35
+ - **Destructive / admin MCP tools**: `delete_session_log`, `create_repo`, `release_assignment`. (The launch and member-admin tools were dropped from the MCP surface in CHK-180 — those concerns are web-app only now.)
36
36
  - **Mutating / external / clobber-risk CLI commands** (both prefixes): `setup`, `login`, `logout`, `upgrade-auth`, `config` (can overwrite committed `.codebyplan/` files), `branch` (rewrites branch config), `ship`, `claude` (`install`/`update`/`uninstall` overwrite `.claude/`).
37
37
 
38
38
  ### `deny` — unchanged
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-checkpoint-check
4
3
  description: Full re-evaluation of a checkpoint with before/after comparison
5
4
  argument-hint: [CHK-NNN]
@@ -280,15 +280,21 @@ Scan the output for any `worktree` entry whose `branch` field matches `refs/head
280
280
  **Case A — the current session is NOT inside that worktree path:**
281
281
 
282
282
  ```bash
283
- codebyplan worktree remove <path>
283
+ codebyplan worktree remove <abs-path> # pass the absolute path from worktree list
284
284
  git worktree prune
285
285
  ```
286
286
 
287
- Record the removed path in `WORKTREES_REMOVED[]`. If `codebyplan worktree remove` exits
288
- non-zero, emit a non-blocking warning and continue a failed removal does not halt shipment.
287
+ `codebyplan worktree remove <abs-path>` handles both the git worktree removal and the
288
+ remote feat-branch deletion (non-fatal). No separate `git push origin --delete` is needed
289
+ here. Parse the JSON output; record `{ path, removed: true, remote_branch_deleted }` in
290
+ `WORKTREES_REMOVED[]`. On any non-zero exit (except exit code 2 — see Case B), emit a
291
+ non-blocking warning and continue — a failed removal does not halt shipment.
289
292
 
290
- **Case B — the current session IS inside that worktree path (i.e. `$PWD` starts with
291
- `<path>`):**
293
+ **Case B — the current session IS inside that worktree path:**
294
+
295
+ The CLI self-cwd guard fires and exits with **code 2** when `codebyplan worktree remove`
296
+ is called from inside the target worktree. Detect this via exit code 2, OR pre-check that
297
+ `$PWD` starts with `<path>` before calling the CLI.
292
298
 
293
299
  Do NOT self-remove. Surface a single directive (no A/B/C menu):
294
300
 
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-clear-continue
4
3
  description: Resume work after /clear by reading .codebyplan/clear/handoff.md and re-invoking the previously-blocked heavy skill. Reports a friendly error if no handoff file exists.
5
4
  model: inherit
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-clear-prep
4
3
  description: Capture a clear-context handoff when the context window is too large to run a heavy skill. Reads active task/round state, writes .codebyplan/clear/handoff.md, then instructs the user to run /clear and /cbp-clear-continue to resume.
5
4
  argument-hint: "[blocked-skill]"
@@ -169,7 +169,7 @@ Skip the push only when nothing was committed in Step 5 AND `/cbp-merge-main` re
169
169
 
170
170
  ### Step 7: Complete Task
171
171
 
172
- 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.)
172
+ MCP `complete_task(task_id)`. The server keys on the JWT user (`ctx.userId`) no worktree param is needed. The server auto-clears `assigned_user_id` on the task; if this was the last sibling task, it also clears the parent checkpoint's assignment.
173
173
 
174
174
  ### Step 8: Run Cleanup + Migration (inline)
175
175
 
@@ -226,7 +226,7 @@ direct you to run `/cbp-clear-prep` first; otherwise checkpoint-check starts on
226
226
  - **Triggered by**: `/cbp-verify` (auto, scope=task, when it writes `verify_verdict.verdict === 'READY'`)
227
227
  - **Chain**: `/cbp-verify` (scope=task READY) → `/cbp-finalize`
228
228
  - **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) — including each round's `verify_manifest` and `task.context.verify_verdict`
229
- - **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`)
229
+ - **Writes**: `codebyplan task update` for `files_changed` (CLI write-through; MCP `update_task` break-glass); MCP `complete_task` for task completion
230
230
  - **Uses skills (inline, no sub-agent)**: `cleanup` (if deletions), `migration` (if exports renamed)
231
231
  - **Triggers**: Same-context transitions auto-trigger via the Skill tool (next task in checkpoint → `cbp-task-start {N}`, `allow`-tier, fires silently). Checkpoint-done → auto-triggers `cbp-checkpoint-check` via Skill tool (`ask`-tier, permission prompt IS the human gate). No-task-anywhere fallback → directive `Next: Run /clear, then /cbp-session-end.`
232
232
  - **Checkpoint-bound only** — for standalone tasks use `/cbp-standalone-task-complete`
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-setup-cd
4
3
  description: Detect configured CD surfaces, write/update .codebyplan/cd.json via `codebyplan cd init`, scaffold publish.yml and release-desktop.yml GitHub Actions workflows, and walk through environment/approval/OIDC setup. Interactive, idempotent.
5
4
  argument-hint: "[--force]"
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-setup-ci
4
3
  description: Detect CI platforms, write/update .codebyplan/ci.json, scaffold the GitHub Actions CI workflow, and enforce the required CI status check on the main branch. Interactive, idempotent.
5
4
  argument-hint: "[--force]"
@@ -249,6 +249,45 @@ When `branch_deleted === true` in the ship JSON:
249
249
  - If the `list_branches` call itself fails (network, auth, or non-success response): emit a non-blocking warning that the Supabase preview branch for `FEAT_BRANCH` may still exist and should be verified in the dashboard. Never treat an API failure as a not-found success.
250
250
  - Never delete the branch where `is_default` is true in the `list_branches` response (the production/parent project branch) or any other persistent/long-lived branch.
251
251
 
252
+ #### Step 7.4 — Git-worktree cleanup (defensive)
253
+
254
+ Read `FEAT_BRANCH` from the `feat_branch` field in the ship JSON (same source as Step 7.3).
255
+
256
+ ```bash
257
+ git worktree list --porcelain
258
+ ```
259
+
260
+ Scan for any `worktree` entry whose `branch` field matches `refs/heads/$FEAT_BRANCH`. If NO
261
+ entry matches, skip this step silently — most standalone tasks have no dedicated worktree,
262
+ so a no-match is the normal case.
263
+
264
+ If a match exists, obtain its absolute path and apply the same Case A / Case B logic:
265
+
266
+ **Case A — session cwd is NOT inside that worktree path:**
267
+
268
+ ```bash
269
+ codebyplan worktree remove <abs-path> # absolute path from worktree list
270
+ git worktree prune
271
+ ```
272
+
273
+ The CLI handles both the git removal and remote feat-branch deletion (non-fatal). Parse
274
+ the JSON output; record `{ path, removed: true, remote_branch_deleted }` in
275
+ `WORKTREES_REMOVED[]`. On any non-zero exit other than exit code 2, emit a non-blocking
276
+ warning and continue.
277
+
278
+ **Case B — session cwd IS inside that worktree path (CLI exits with code 2, or pre-check
279
+ detects `$PWD` starts with `<path>`):**
280
+
281
+ Do NOT self-remove. Surface a single directive:
282
+
283
+ > "This session is inside the worktree at `<path>`. After switching to your main checkout,
284
+ > run `codebyplan worktree remove <path>` to clean it up."
285
+
286
+ Record `{ path, status: 'pending_manual_cleanup' }` in `WORKTREES_REMOVED[]`.
287
+
288
+ In either case (and when no worktree matched — `WORKTREES_REMOVED` stays empty), include
289
+ `worktrees_removed: WORKTREES_REMOVED` in the Step 9 summary.
290
+
252
291
  ### Step 7.5: Complete Standalone Task
253
292
 
254
293
  Note: completion is called only after `codebyplan ship` succeeds (no `checks_failed`) — the DB completion record reflects work that has landed in production.
@@ -280,6 +319,7 @@ Apply the `cleanup` skill inline to remove orphan references to deleted/modified
280
319
  **Version bumps**: [<name>: <current> → <next> per package, or "none"]
281
320
  **Export**: [EXPORT_RESULT.path from Step 5.6, or "skipped: <reason>"]
282
321
  **Warnings**: [any QA / file-approval warnings from Step 3, or "none"]
322
+ **Git worktrees cleaned**: [paths from WORKTREES_REMOVED (Step 7.4), or "none"]
283
323
  ```
284
324
 
285
325
  #### Route (single directive — never a menu)
@@ -1,5 +1,4 @@
1
1
  ---
2
- scope: org-shared
3
2
  name: cbp-stripe
4
3
  description: "Stripe integration guidance — load when implementing or reviewing payments, Checkout, subscriptions/billing, webhooks, Connect, Tax, or Treasury. Encodes the API-selection routing table, the no-payment_method_types rule, restricted-key security, and Stripe SDK conventions."
5
4
  model: inherit