@bhargavvc/sdd-cc 1.35.0 → 1.42.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 (1374) hide show
  1. package/README.ja-JP.md +54 -52
  2. package/README.ko-KR.md +47 -45
  3. package/README.md +86 -733
  4. package/README.pt-BR.md +14 -12
  5. package/README.zh-CN.md +31 -29
  6. package/agents/sdd-ai-researcher.md +2 -2
  7. package/agents/sdd-code-fixer.md +169 -17
  8. package/agents/sdd-code-reviewer.md +40 -8
  9. package/agents/sdd-codebase-mapper.md +89 -6
  10. package/agents/sdd-debug-session-manager.md +314 -0
  11. package/agents/sdd-debugger.md +147 -80
  12. package/agents/sdd-doc-classifier.md +168 -0
  13. package/agents/sdd-doc-synthesizer.md +204 -0
  14. package/agents/sdd-doc-verifier.md +20 -4
  15. package/agents/sdd-doc-writer.md +22 -9
  16. package/agents/sdd-domain-researcher.md +2 -2
  17. package/agents/sdd-eval-auditor.md +30 -3
  18. package/agents/sdd-eval-planner.md +2 -2
  19. package/agents/sdd-executor.md +203 -43
  20. package/agents/sdd-framework-selector.md +1 -1
  21. package/agents/sdd-integration-checker.md +30 -3
  22. package/agents/sdd-intel-updater.md +51 -23
  23. package/agents/sdd-nyquist-auditor.md +31 -4
  24. package/agents/sdd-pattern-mapper.md +335 -0
  25. package/agents/sdd-phase-researcher.md +195 -32
  26. package/agents/sdd-plan-checker.md +135 -24
  27. package/agents/sdd-planner.md +190 -205
  28. package/agents/sdd-project-researcher.md +7 -7
  29. package/agents/sdd-research-synthesizer.md +6 -6
  30. package/agents/sdd-roadmapper.md +19 -10
  31. package/agents/sdd-security-auditor.md +33 -6
  32. package/agents/sdd-ui-auditor.md +23 -7
  33. package/agents/sdd-ui-checker.md +16 -7
  34. package/agents/sdd-ui-researcher.md +8 -8
  35. package/agents/sdd-verifier.md +124 -27
  36. package/bin/install.js +5016 -372
  37. package/bin/sdd-sdk.js +37 -0
  38. package/commands/sdd/add-tests.md +5 -4
  39. package/commands/sdd/ai-integration-phase.md +4 -3
  40. package/commands/sdd/audit-fix.md +2 -1
  41. package/commands/sdd/audit-milestone.md +3 -2
  42. package/commands/sdd/autonomous.md +3 -3
  43. package/commands/sdd/capture.md +62 -0
  44. package/commands/sdd/cleanup.md +2 -1
  45. package/commands/sdd/code-review.md +8 -4
  46. package/commands/sdd/complete-milestone.md +15 -8
  47. package/commands/sdd/config.md +58 -0
  48. package/commands/sdd/debug.md +21 -155
  49. package/commands/sdd/discuss-phase.md +18 -11
  50. package/commands/sdd/docs-update.md +3 -2
  51. package/commands/sdd/eval-review.md +4 -3
  52. package/commands/sdd/execute-phase.md +5 -4
  53. package/commands/sdd/explore.md +3 -3
  54. package/commands/sdd/extract-learnings.md +23 -0
  55. package/commands/sdd/fast.md +4 -3
  56. package/commands/sdd/forensics.md +3 -2
  57. package/commands/sdd/graphify.md +199 -0
  58. package/commands/sdd/health.md +12 -3
  59. package/commands/sdd/help.md +1 -1
  60. package/commands/sdd/import.md +10 -5
  61. package/commands/sdd/inbox.md +39 -0
  62. package/commands/sdd/ingest-docs.md +42 -0
  63. package/commands/sdd/manager.md +8 -3
  64. package/commands/sdd/map-codebase.md +18 -6
  65. package/commands/sdd/milestone-summary.md +1 -1
  66. package/commands/sdd/mvp-phase.md +45 -0
  67. package/commands/sdd/new-milestone.md +4 -3
  68. package/commands/sdd/new-project.md +4 -3
  69. package/commands/sdd/ns-context.md +23 -0
  70. package/commands/sdd/ns-ideate.md +24 -0
  71. package/commands/sdd/ns-manage.md +29 -0
  72. package/commands/sdd/ns-project.md +22 -0
  73. package/commands/sdd/ns-review.md +26 -0
  74. package/commands/sdd/ns-workflow.md +28 -0
  75. package/commands/sdd/pause-work.md +6 -1
  76. package/commands/sdd/phase.md +56 -0
  77. package/commands/sdd/plan-phase.md +15 -5
  78. package/commands/sdd/plan-review-convergence.md +59 -0
  79. package/commands/sdd/pr-branch.md +2 -1
  80. package/commands/sdd/profile-user.md +1 -1
  81. package/commands/sdd/progress.md +27 -5
  82. package/commands/sdd/quick.md +128 -3
  83. package/commands/sdd/resume-work.md +2 -12
  84. package/commands/sdd/review-backlog.md +3 -2
  85. package/commands/sdd/review.md +3 -2
  86. package/commands/sdd/secure-phase.md +3 -2
  87. package/commands/sdd/settings.md +2 -9
  88. package/commands/sdd/ship.md +2 -1
  89. package/commands/sdd/sketch.md +60 -0
  90. package/commands/sdd/spec-phase.md +63 -0
  91. package/commands/sdd/spike.md +57 -0
  92. package/commands/sdd/stats.md +2 -1
  93. package/commands/sdd/surface.md +129 -0
  94. package/commands/sdd/thread.md +8 -111
  95. package/commands/sdd/ui-phase.md +3 -2
  96. package/commands/sdd/ui-review.md +3 -2
  97. package/commands/sdd/ultraplan-phase.md +34 -0
  98. package/commands/sdd/undo.md +2 -1
  99. package/commands/sdd/update.md +21 -10
  100. package/commands/sdd/validate-phase.md +3 -2
  101. package/commands/sdd/verify-work.md +5 -4
  102. package/commands/sdd/workspace.md +52 -0
  103. package/commands/sdd/workstreams.md +12 -11
  104. package/hooks/dist/sdd-check-update-worker.js +116 -0
  105. package/hooks/dist/sdd-check-update.js +13 -88
  106. package/hooks/dist/sdd-context-monitor.js +28 -1
  107. package/hooks/dist/sdd-phase-boundary.sh +23 -3
  108. package/hooks/dist/sdd-read-guard.js +21 -2
  109. package/hooks/dist/sdd-read-injection-scanner.js +152 -0
  110. package/hooks/dist/sdd-session-state.sh +38 -12
  111. package/hooks/dist/sdd-statusline.js +324 -28
  112. package/hooks/dist/sdd-update-banner.js +134 -0
  113. package/hooks/dist/sdd-validate-commit.sh +15 -5
  114. package/hooks/dist/sdd-workflow-guard.js +2 -2
  115. package/hooks/lib/git-cmd.js +150 -0
  116. package/hooks/sdd-check-update-worker.js +116 -0
  117. package/hooks/sdd-check-update.js +13 -88
  118. package/hooks/sdd-context-monitor.js +28 -1
  119. package/hooks/sdd-phase-boundary.sh +23 -3
  120. package/hooks/sdd-read-guard.js +21 -2
  121. package/hooks/sdd-read-injection-scanner.js +152 -0
  122. package/hooks/sdd-session-state.sh +38 -12
  123. package/hooks/sdd-statusline.js +324 -28
  124. package/hooks/sdd-update-banner.js +134 -0
  125. package/hooks/sdd-validate-commit.sh +15 -5
  126. package/hooks/sdd-workflow-guard.js +2 -2
  127. package/package.json +32 -7
  128. package/scripts/audit-workflow-script-paths.cjs +73 -0
  129. package/scripts/build-hooks.js +98 -4
  130. package/scripts/changeset/cli.cjs +269 -0
  131. package/scripts/changeset/github-release-notes.cjs +198 -0
  132. package/scripts/changeset/lint.cjs +110 -0
  133. package/scripts/changeset/new.cjs +137 -0
  134. package/scripts/changeset/parse.cjs +60 -0
  135. package/scripts/changeset/render.cjs +34 -0
  136. package/scripts/changeset/serialize.cjs +74 -0
  137. package/scripts/command-contract-helpers.cjs +61 -0
  138. package/scripts/diff-touches-shipped-paths.cjs +147 -0
  139. package/scripts/fix-slash-commands.cjs +106 -0
  140. package/scripts/gen-inventory-manifest.cjs +109 -0
  141. package/scripts/lint-command-contract.cjs +108 -0
  142. package/scripts/lint-descriptions.cjs +83 -0
  143. package/scripts/lint-no-source-grep-extras.cjs +81 -0
  144. package/scripts/lint-no-source-grep.cjs +174 -0
  145. package/scripts/lint-shell-command-projection-drift.cjs +57 -0
  146. package/scripts/lint-skill-deps.cjs +180 -0
  147. package/scripts/pr-template-policy.cjs +169 -0
  148. package/scripts/prompt-injection-scan.sh +2 -0
  149. package/scripts/rebrand-gsd-to-sdd.sh +4 -3
  150. package/scripts/strip-prose-atrefs.cjs +106 -0
  151. package/scripts/verify-tarball-sdk-dist.sh +69 -0
  152. package/sdd/bin/check-latest-version.cjs +104 -0
  153. package/sdd/bin/lib/active-workstream-store.cjs +85 -0
  154. package/sdd/bin/lib/adr-parser.cjs +394 -0
  155. package/sdd/bin/lib/artifacts.cjs +53 -0
  156. package/sdd/bin/lib/audit.cjs +755 -0
  157. package/sdd/bin/lib/cjs-command-router-adapter.cjs +39 -0
  158. package/sdd/bin/lib/clusters.cjs +135 -0
  159. package/sdd/bin/lib/command-aliases.generated.cjs +838 -0
  160. package/sdd/bin/lib/commands.cjs +108 -98
  161. package/sdd/bin/lib/config-schema.cjs +135 -0
  162. package/sdd/bin/lib/config.cjs +253 -68
  163. package/sdd/bin/lib/context-utilization.cjs +47 -0
  164. package/sdd/bin/lib/core.cjs +997 -607
  165. package/sdd/bin/lib/decisions.cjs +48 -0
  166. package/sdd/bin/lib/docs.cjs +36 -33
  167. package/sdd/bin/lib/drift.cjs +379 -0
  168. package/sdd/bin/lib/fallow-runner.cjs +109 -0
  169. package/sdd/bin/lib/frontmatter.cjs +19 -11
  170. package/sdd/bin/lib/gap-checker.cjs +197 -0
  171. package/sdd/bin/lib/graphify.cjs +577 -0
  172. package/sdd/bin/lib/init-command-router.cjs +70 -0
  173. package/sdd/bin/lib/init.cjs +603 -102
  174. package/sdd/bin/lib/install-profiles.cjs +572 -0
  175. package/sdd/bin/lib/installer-migration-authoring.cjs +117 -0
  176. package/sdd/bin/lib/installer-migration-report.cjs +328 -0
  177. package/sdd/bin/lib/installer-migrations/000-first-time-baseline.cjs +220 -0
  178. package/sdd/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +41 -0
  179. package/sdd/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +80 -0
  180. package/sdd/bin/lib/installer-migrations.cjs +703 -0
  181. package/sdd/bin/lib/intel.cjs +35 -52
  182. package/sdd/bin/lib/learnings.cjs +2 -1
  183. package/sdd/bin/lib/milestone.cjs +313 -283
  184. package/sdd/bin/lib/model-catalog.cjs +136 -0
  185. package/sdd/bin/lib/model-profiles.cjs +25 -70
  186. package/sdd/bin/lib/phase-command-router.cjs +96 -0
  187. package/sdd/bin/lib/phase.cjs +556 -102
  188. package/sdd/bin/lib/phases-command-router.cjs +39 -0
  189. package/sdd/bin/lib/plan-scan.cjs +138 -0
  190. package/sdd/bin/lib/planning-workspace.cjs +361 -0
  191. package/sdd/bin/lib/profile-output.cjs +109 -43
  192. package/sdd/bin/lib/profile-pipeline.cjs +1 -1
  193. package/sdd/bin/lib/review-reviewer-selection.cjs +125 -0
  194. package/sdd/bin/lib/roadmap-command-router.cjs +23 -0
  195. package/sdd/bin/lib/roadmap.cjs +278 -17
  196. package/sdd/bin/lib/runtime-homes.cjs +178 -0
  197. package/sdd/bin/lib/sdd2-import.cjs +3 -3
  198. package/sdd/bin/lib/secrets.cjs +33 -0
  199. package/sdd/bin/lib/security.cjs +8 -7
  200. package/sdd/bin/lib/shell-command-projection.cjs +548 -0
  201. package/sdd/bin/lib/state-command-router.cjs +100 -0
  202. package/sdd/bin/lib/state-document.cjs +12 -0
  203. package/sdd/bin/lib/state-document.generated.cjs +127 -0
  204. package/sdd/bin/lib/state.cjs +720 -218
  205. package/sdd/bin/lib/surface.cjs +398 -0
  206. package/sdd/bin/lib/template.cjs +4 -2
  207. package/sdd/bin/lib/uat.cjs +9 -2
  208. package/sdd/bin/lib/validate-command-router.cjs +55 -0
  209. package/sdd/bin/lib/verify-command-router.cjs +34 -0
  210. package/sdd/bin/lib/verify.cjs +464 -137
  211. package/sdd/bin/lib/workstream-inventory.cjs +159 -0
  212. package/sdd/bin/lib/workstream-name-policy.cjs +33 -0
  213. package/sdd/bin/lib/workstream.cjs +73 -195
  214. package/sdd/bin/lib/worktree-safety.cjs +563 -0
  215. package/sdd/bin/sdd-tools.cjs +386 -252
  216. package/sdd/bin/verify-reapply-patches.cjs +247 -0
  217. package/sdd/contexts/review.md +1 -0
  218. package/sdd/references/artifact-types.md +18 -0
  219. package/sdd/references/autonomous-smart-discuss.md +277 -0
  220. package/sdd/references/checkpoints.md +36 -0
  221. package/sdd/references/context-budget.md +85 -49
  222. package/sdd/references/continuation-format.md +26 -22
  223. package/sdd/references/debugger-philosophy.md +76 -0
  224. package/sdd/references/decimal-phase-calculation.md +5 -5
  225. package/sdd/references/doc-conflict-engine.md +91 -0
  226. package/sdd/references/domain-probes.md +1 -1
  227. package/sdd/references/execute-mvp-tdd.md +81 -0
  228. package/sdd/references/executor-examples.md +110 -0
  229. package/sdd/references/gate-prompts.md +2 -2
  230. package/sdd/references/git-integration.md +10 -7
  231. package/sdd/references/git-planning-commit.md +6 -4
  232. package/sdd/references/mandatory-initial-read.md +2 -0
  233. package/sdd/references/model-profiles.md +106 -6
  234. package/sdd/references/mvp-concepts.md +49 -0
  235. package/sdd/references/phase-argument-parsing.md +3 -3
  236. package/sdd/references/planner-antipatterns.md +89 -0
  237. package/sdd/references/planner-chunked.md +49 -0
  238. package/sdd/references/planner-human-verify-mode.md +57 -0
  239. package/sdd/references/planner-mvp-mode.md +53 -0
  240. package/sdd/references/planner-revision.md +1 -1
  241. package/sdd/references/planner-source-audit.md +73 -0
  242. package/sdd/references/planning-config.md +30 -13
  243. package/sdd/references/project-skills-discovery.md +19 -0
  244. package/sdd/references/scout-codebase.md +51 -0
  245. package/sdd/references/skeleton-template.md +48 -0
  246. package/sdd/references/sketch-interactivity.md +41 -0
  247. package/sdd/references/sketch-theme-system.md +94 -0
  248. package/sdd/references/sketch-tooling.md +45 -0
  249. package/sdd/references/sketch-variant-patterns.md +81 -0
  250. package/sdd/references/spidr-splitting.md +69 -0
  251. package/sdd/references/tdd.md +67 -0
  252. package/sdd/references/thinking-partner.md +1 -1
  253. package/sdd/references/universal-anti-patterns.md +4 -4
  254. package/sdd/references/user-story-template.md +58 -0
  255. package/sdd/references/verification-overrides.md +3 -3
  256. package/sdd/references/verify-mvp-mode.md +85 -0
  257. package/sdd/references/workstream-flag.md +11 -11
  258. package/sdd/references/worktree-path-safety.md +89 -0
  259. package/sdd/templates/AI-SPEC.md +1 -1
  260. package/sdd/templates/DEBUG.md +8 -3
  261. package/sdd/templates/README.md +77 -0
  262. package/sdd/templates/UAT.md +4 -4
  263. package/sdd/templates/VALIDATION.md +1 -1
  264. package/sdd/templates/claude-md.md +5 -5
  265. package/sdd/templates/config.json +16 -2
  266. package/sdd/templates/debug-subagent-prompt.md +1 -1
  267. package/sdd/templates/dev-preferences.md +1 -1
  268. package/sdd/templates/discovery.md +2 -2
  269. package/sdd/templates/phase-prompt.md +1 -1
  270. package/sdd/templates/planner-subagent-prompt.md +3 -3
  271. package/sdd/templates/project.md +1 -1
  272. package/sdd/templates/research.md +41 -1
  273. package/sdd/templates/spec.md +307 -0
  274. package/sdd/templates/state.md +9 -1
  275. package/sdd/workflows/add-backlog.md +90 -0
  276. package/sdd/workflows/add-phase.md +7 -7
  277. package/sdd/workflows/add-tests.md +12 -12
  278. package/sdd/workflows/add-todo.md +4 -4
  279. package/sdd/workflows/ai-integration-phase.md +26 -16
  280. package/sdd/workflows/analyze-dependencies.md +3 -3
  281. package/sdd/workflows/audit-fix.md +23 -3
  282. package/sdd/workflows/audit-milestone.md +37 -20
  283. package/sdd/workflows/audit-uat.md +3 -3
  284. package/sdd/workflows/autonomous.md +31 -301
  285. package/sdd/workflows/check-todos.md +6 -6
  286. package/sdd/workflows/cleanup.md +1 -1
  287. package/sdd/workflows/code-review-fix.md +20 -16
  288. package/sdd/workflows/code-review.md +114 -16
  289. package/sdd/workflows/complete-milestone.md +68 -15
  290. package/sdd/workflows/debug.md +231 -0
  291. package/sdd/workflows/diagnose-issues.md +8 -6
  292. package/sdd/workflows/discovery-phase.md +3 -3
  293. package/sdd/workflows/discuss-phase/modes/advisor.md +175 -0
  294. package/sdd/workflows/discuss-phase/modes/all.md +28 -0
  295. package/sdd/workflows/discuss-phase/modes/analyze.md +44 -0
  296. package/sdd/workflows/discuss-phase/modes/auto.md +56 -0
  297. package/sdd/workflows/discuss-phase/modes/batch.md +52 -0
  298. package/sdd/workflows/discuss-phase/modes/chain.md +97 -0
  299. package/sdd/workflows/discuss-phase/modes/default.md +141 -0
  300. package/sdd/workflows/discuss-phase/modes/power.md +44 -0
  301. package/sdd/workflows/discuss-phase/modes/text.md +55 -0
  302. package/sdd/workflows/discuss-phase/templates/checkpoint.json +18 -0
  303. package/sdd/workflows/discuss-phase/templates/context.md +136 -0
  304. package/sdd/workflows/discuss-phase/templates/discussion-log.md +50 -0
  305. package/sdd/workflows/discuss-phase-assumptions.md +24 -21
  306. package/sdd/workflows/discuss-phase-power.md +3 -3
  307. package/sdd/workflows/discuss-phase.md +203 -905
  308. package/sdd/workflows/do.md +25 -21
  309. package/sdd/workflows/docs-update.md +23 -17
  310. package/sdd/workflows/edit-phase.md +294 -0
  311. package/sdd/workflows/eval-review.md +7 -7
  312. package/sdd/workflows/execute-phase/steps/codebase-drift-gate.md +81 -0
  313. package/sdd/workflows/execute-phase/steps/per-plan-worktree-gate.md +94 -0
  314. package/sdd/workflows/execute-phase/steps/post-merge-gate.md +116 -0
  315. package/sdd/workflows/execute-phase.md +650 -252
  316. package/sdd/workflows/execute-plan.md +75 -35
  317. package/sdd/workflows/explore.md +7 -3
  318. package/sdd/workflows/extract-learnings.md +242 -0
  319. package/sdd/workflows/fast.md +5 -5
  320. package/sdd/workflows/forensics.md +19 -6
  321. package/sdd/workflows/graduation.md +195 -0
  322. package/sdd/workflows/health.md +49 -7
  323. package/sdd/workflows/help.md +323 -149
  324. package/sdd/workflows/import.md +20 -43
  325. package/sdd/workflows/inbox.md +5 -5
  326. package/sdd/workflows/ingest-docs.md +339 -0
  327. package/sdd/workflows/insert-phase.md +33 -12
  328. package/sdd/workflows/list-phase-assumptions.md +2 -2
  329. package/sdd/workflows/list-workspaces.md +2 -2
  330. package/sdd/workflows/manager.md +38 -11
  331. package/sdd/workflows/map-codebase.md +87 -23
  332. package/sdd/workflows/milestone-summary.md +8 -8
  333. package/sdd/workflows/mvp-phase.md +221 -0
  334. package/sdd/workflows/new-milestone.md +163 -23
  335. package/sdd/workflows/new-project.md +254 -53
  336. package/sdd/workflows/new-workspace.md +8 -8
  337. package/sdd/workflows/next.md +85 -18
  338. package/sdd/workflows/note.md +2 -2
  339. package/sdd/workflows/pause-work.md +13 -9
  340. package/sdd/workflows/plan-milestone-gaps.md +18 -11
  341. package/sdd/workflows/plan-phase.md +767 -94
  342. package/sdd/workflows/plan-review-convergence.md +329 -0
  343. package/sdd/workflows/plant-seed.md +146 -89
  344. package/sdd/workflows/pr-branch.md +1 -1
  345. package/sdd/workflows/profile-user.md +15 -15
  346. package/sdd/workflows/progress.md +198 -56
  347. package/sdd/workflows/quick.md +318 -54
  348. package/{commands/sdd → sdd/workflows}/reapply-patches.md +102 -23
  349. package/sdd/workflows/remove-phase.md +10 -10
  350. package/sdd/workflows/remove-workspace.md +21 -6
  351. package/sdd/workflows/resume-project.md +26 -23
  352. package/sdd/workflows/review.md +151 -20
  353. package/sdd/workflows/scan.md +5 -3
  354. package/sdd/workflows/secure-phase.md +26 -13
  355. package/sdd/workflows/settings-advanced.md +579 -0
  356. package/sdd/workflows/settings-integrations.md +281 -0
  357. package/sdd/workflows/settings.md +202 -23
  358. package/sdd/workflows/ship.md +131 -16
  359. package/sdd/workflows/sketch-wrap-up.md +285 -0
  360. package/sdd/workflows/sketch.md +360 -0
  361. package/sdd/workflows/spec-phase.md +262 -0
  362. package/sdd/workflows/spike-wrap-up.md +306 -0
  363. package/sdd/workflows/spike.md +452 -0
  364. package/sdd/workflows/stats.md +21 -2
  365. package/sdd/workflows/sync-skills.md +182 -0
  366. package/sdd/workflows/thread.md +221 -0
  367. package/sdd/workflows/transition.md +52 -30
  368. package/sdd/workflows/ui-phase.md +37 -20
  369. package/sdd/workflows/ui-review.md +12 -10
  370. package/sdd/workflows/ultraplan-phase.md +198 -0
  371. package/sdd/workflows/undo.md +9 -9
  372. package/sdd/workflows/update.md +187 -17
  373. package/sdd/workflows/validate-phase.md +12 -10
  374. package/sdd/workflows/verify-phase.md +112 -27
  375. package/sdd/workflows/verify-work.md +97 -28
  376. package/sdk/dist/cli-transport.d.ts +19 -0
  377. package/sdk/dist/cli-transport.d.ts.map +1 -0
  378. package/sdk/dist/cli-transport.js +104 -0
  379. package/sdk/dist/cli-transport.js.map +1 -0
  380. package/sdk/dist/cli.d.ts +46 -0
  381. package/sdk/dist/cli.d.ts.map +1 -0
  382. package/sdk/dist/cli.js +511 -0
  383. package/sdk/dist/cli.js.map +1 -0
  384. package/sdk/dist/config.d.ts +84 -0
  385. package/sdk/dist/config.d.ts.map +1 -0
  386. package/sdk/dist/config.js +135 -0
  387. package/sdk/dist/config.js.map +1 -0
  388. package/sdk/dist/context-engine.d.ts +49 -0
  389. package/sdk/dist/context-engine.d.ts.map +1 -0
  390. package/sdk/dist/context-engine.js +142 -0
  391. package/sdk/dist/context-engine.js.map +1 -0
  392. package/sdk/dist/context-truncation.d.ts +33 -0
  393. package/sdk/dist/context-truncation.d.ts.map +1 -0
  394. package/sdk/dist/context-truncation.js +197 -0
  395. package/sdk/dist/context-truncation.js.map +1 -0
  396. package/sdk/dist/errors.d.ts +46 -0
  397. package/sdk/dist/errors.d.ts.map +1 -0
  398. package/sdk/dist/errors.js +64 -0
  399. package/sdk/dist/errors.js.map +1 -0
  400. package/sdk/dist/event-stream.d.ts +53 -0
  401. package/sdk/dist/event-stream.d.ts.map +1 -0
  402. package/sdk/dist/event-stream.js +321 -0
  403. package/sdk/dist/event-stream.js.map +1 -0
  404. package/sdk/dist/golden/capture.d.ts +15 -0
  405. package/sdk/dist/golden/capture.d.ts.map +1 -0
  406. package/sdk/dist/golden/capture.js +67 -0
  407. package/sdk/dist/golden/capture.js.map +1 -0
  408. package/sdk/dist/golden/golden-integration-covered.d.ts +6 -0
  409. package/sdk/dist/golden/golden-integration-covered.d.ts.map +1 -0
  410. package/sdk/dist/golden/golden-integration-covered.js +30 -0
  411. package/sdk/dist/golden/golden-integration-covered.js.map +1 -0
  412. package/sdk/dist/golden/golden-mutation-covered.d.ts +7 -0
  413. package/sdk/dist/golden/golden-mutation-covered.d.ts.map +1 -0
  414. package/sdk/dist/golden/golden-mutation-covered.js +17 -0
  415. package/sdk/dist/golden/golden-mutation-covered.js.map +1 -0
  416. package/sdk/dist/golden/golden-policy.d.ts +10 -0
  417. package/sdk/dist/golden/golden-policy.d.ts.map +1 -0
  418. package/sdk/dist/golden/golden-policy.js +98 -0
  419. package/sdk/dist/golden/golden-policy.js.map +1 -0
  420. package/sdk/dist/golden/init-golden-normalize.d.ts +8 -0
  421. package/sdk/dist/golden/init-golden-normalize.d.ts.map +1 -0
  422. package/sdk/dist/golden/init-golden-normalize.js +14 -0
  423. package/sdk/dist/golden/init-golden-normalize.js.map +1 -0
  424. package/sdk/dist/golden/read-only-golden-rows.d.ts +20 -0
  425. package/sdk/dist/golden/read-only-golden-rows.d.ts.map +1 -0
  426. package/sdk/dist/golden/read-only-golden-rows.js +67 -0
  427. package/sdk/dist/golden/read-only-golden-rows.js.map +1 -0
  428. package/sdk/dist/golden/registry-canonical-commands.d.ts +6 -0
  429. package/sdk/dist/golden/registry-canonical-commands.d.ts.map +1 -0
  430. package/sdk/dist/golden/registry-canonical-commands.js +30 -0
  431. package/sdk/dist/golden/registry-canonical-commands.js.map +1 -0
  432. package/sdk/dist/index.d.ts +125 -0
  433. package/sdk/dist/index.d.ts.map +1 -0
  434. package/sdk/dist/index.js +298 -0
  435. package/sdk/dist/index.js.map +1 -0
  436. package/sdk/dist/init-runner.d.ts +90 -0
  437. package/sdk/dist/init-runner.d.ts.map +1 -0
  438. package/sdk/dist/init-runner.js +613 -0
  439. package/sdk/dist/init-runner.js.map +1 -0
  440. package/sdk/dist/logger.d.ts +50 -0
  441. package/sdk/dist/logger.d.ts.map +1 -0
  442. package/sdk/dist/logger.js +70 -0
  443. package/sdk/dist/logger.js.map +1 -0
  444. package/sdk/dist/model-catalog.d.ts +31 -0
  445. package/sdk/dist/model-catalog.d.ts.map +1 -0
  446. package/sdk/dist/model-catalog.js +31 -0
  447. package/sdk/dist/model-catalog.js.map +1 -0
  448. package/sdk/dist/phase-prompt.d.ts +72 -0
  449. package/sdk/dist/phase-prompt.d.ts.map +1 -0
  450. package/sdk/dist/phase-prompt.js +213 -0
  451. package/sdk/dist/phase-prompt.js.map +1 -0
  452. package/sdk/dist/phase-runner.d.ts +145 -0
  453. package/sdk/dist/phase-runner.d.ts.map +1 -0
  454. package/sdk/dist/phase-runner.js +1206 -0
  455. package/sdk/dist/phase-runner.js.map +1 -0
  456. package/sdk/dist/plan-parser.d.ts +55 -0
  457. package/sdk/dist/plan-parser.d.ts.map +1 -0
  458. package/sdk/dist/plan-parser.js +389 -0
  459. package/sdk/dist/plan-parser.js.map +1 -0
  460. package/sdk/dist/planning-journal.d.ts +64 -0
  461. package/sdk/dist/planning-journal.d.ts.map +1 -0
  462. package/sdk/dist/planning-journal.js +88 -0
  463. package/sdk/dist/planning-journal.js.map +1 -0
  464. package/sdk/dist/planning-runtime.d.ts +67 -0
  465. package/sdk/dist/planning-runtime.d.ts.map +1 -0
  466. package/sdk/dist/planning-runtime.js +58 -0
  467. package/sdk/dist/planning-runtime.js.map +1 -0
  468. package/sdk/dist/prompt-builder.d.ts +44 -0
  469. package/sdk/dist/prompt-builder.d.ts.map +1 -0
  470. package/sdk/dist/prompt-builder.js +180 -0
  471. package/sdk/dist/prompt-builder.js.map +1 -0
  472. package/sdk/dist/prompt-sanitizer.d.ts +35 -0
  473. package/sdk/dist/prompt-sanitizer.d.ts.map +1 -0
  474. package/sdk/dist/prompt-sanitizer.js +101 -0
  475. package/sdk/dist/prompt-sanitizer.js.map +1 -0
  476. package/sdk/dist/query/active-workstream-store.d.ts +7 -0
  477. package/sdk/dist/query/active-workstream-store.d.ts.map +1 -0
  478. package/sdk/dist/query/active-workstream-store.js +56 -0
  479. package/sdk/dist/query/active-workstream-store.js.map +1 -0
  480. package/sdk/dist/query/agent-failure-classifier.d.ts +38 -0
  481. package/sdk/dist/query/agent-failure-classifier.d.ts.map +1 -0
  482. package/sdk/dist/query/agent-failure-classifier.js +83 -0
  483. package/sdk/dist/query/agent-failure-classifier.js.map +1 -0
  484. package/sdk/dist/query/audit-open.d.ts +46 -0
  485. package/sdk/dist/query/audit-open.d.ts.map +1 -0
  486. package/sdk/dist/query/audit-open.js +662 -0
  487. package/sdk/dist/query/audit-open.js.map +1 -0
  488. package/sdk/dist/query/check-auto-mode.d.ts +13 -0
  489. package/sdk/dist/query/check-auto-mode.d.ts.map +1 -0
  490. package/sdk/dist/query/check-auto-mode.js +40 -0
  491. package/sdk/dist/query/check-auto-mode.js.map +1 -0
  492. package/sdk/dist/query/check-completion.d.ts +10 -0
  493. package/sdk/dist/query/check-completion.d.ts.map +1 -0
  494. package/sdk/dist/query/check-completion.js +157 -0
  495. package/sdk/dist/query/check-completion.js.map +1 -0
  496. package/sdk/dist/query/check-decision-coverage.d.ts +33 -0
  497. package/sdk/dist/query/check-decision-coverage.d.ts.map +1 -0
  498. package/sdk/dist/query/check-decision-coverage.js +472 -0
  499. package/sdk/dist/query/check-decision-coverage.js.map +1 -0
  500. package/sdk/dist/query/check-gates.d.ts +10 -0
  501. package/sdk/dist/query/check-gates.d.ts.map +1 -0
  502. package/sdk/dist/query/check-gates.js +89 -0
  503. package/sdk/dist/query/check-gates.js.map +1 -0
  504. package/sdk/dist/query/check-ship-ready.d.ts +10 -0
  505. package/sdk/dist/query/check-ship-ready.d.ts.map +1 -0
  506. package/sdk/dist/query/check-ship-ready.js +93 -0
  507. package/sdk/dist/query/check-ship-ready.js.map +1 -0
  508. package/sdk/dist/query/check-verification-status.d.ts +10 -0
  509. package/sdk/dist/query/check-verification-status.d.ts.map +1 -0
  510. package/sdk/dist/query/check-verification-status.js +142 -0
  511. package/sdk/dist/query/check-verification-status.js.map +1 -0
  512. package/sdk/dist/query/command-aliases.generated.d.ts +31 -0
  513. package/sdk/dist/query/command-aliases.generated.d.ts.map +1 -0
  514. package/sdk/dist/query/command-aliases.generated.js +135 -0
  515. package/sdk/dist/query/command-aliases.generated.js.map +1 -0
  516. package/sdk/dist/query/command-catalog.d.ts +9 -0
  517. package/sdk/dist/query/command-catalog.d.ts.map +1 -0
  518. package/sdk/dist/query/command-catalog.js +17 -0
  519. package/sdk/dist/query/command-catalog.js.map +1 -0
  520. package/sdk/dist/query/command-definition.d.ts +19 -0
  521. package/sdk/dist/query/command-definition.d.ts.map +1 -0
  522. package/sdk/dist/query/command-definition.js +44 -0
  523. package/sdk/dist/query/command-definition.js.map +1 -0
  524. package/sdk/dist/query/command-family-handlers.d.ts +3 -0
  525. package/sdk/dist/query/command-family-handlers.d.ts.map +1 -0
  526. package/sdk/dist/query/command-family-handlers.js +94 -0
  527. package/sdk/dist/query/command-family-handlers.js.map +1 -0
  528. package/sdk/dist/query/command-manifest.d.ts +2 -0
  529. package/sdk/dist/query/command-manifest.d.ts.map +1 -0
  530. package/sdk/dist/query/command-manifest.init.d.ts +6 -0
  531. package/sdk/dist/query/command-manifest.init.d.ts.map +1 -0
  532. package/sdk/dist/query/command-manifest.init.js +23 -0
  533. package/sdk/dist/query/command-manifest.init.js.map +1 -0
  534. package/sdk/dist/query/command-manifest.js +17 -0
  535. package/sdk/dist/query/command-manifest.js.map +1 -0
  536. package/sdk/dist/query/command-manifest.non-family.d.ts +9 -0
  537. package/sdk/dist/query/command-manifest.non-family.d.ts.map +1 -0
  538. package/sdk/dist/query/command-manifest.non-family.js +59 -0
  539. package/sdk/dist/query/command-manifest.non-family.js.map +1 -0
  540. package/sdk/dist/query/command-manifest.phase.d.ts +6 -0
  541. package/sdk/dist/query/command-manifest.phase.d.ts.map +1 -0
  542. package/sdk/dist/query/command-manifest.phase.js +15 -0
  543. package/sdk/dist/query/command-manifest.phase.js.map +1 -0
  544. package/sdk/dist/query/command-manifest.phases.d.ts +7 -0
  545. package/sdk/dist/query/command-manifest.phases.d.ts.map +1 -0
  546. package/sdk/dist/query/command-manifest.phases.js +10 -0
  547. package/sdk/dist/query/command-manifest.phases.js.map +1 -0
  548. package/sdk/dist/query/command-manifest.roadmap.d.ts +6 -0
  549. package/sdk/dist/query/command-manifest.roadmap.d.ts.map +1 -0
  550. package/sdk/dist/query/command-manifest.roadmap.js +10 -0
  551. package/sdk/dist/query/command-manifest.roadmap.js.map +1 -0
  552. package/sdk/dist/query/command-manifest.state.d.ts +9 -0
  553. package/sdk/dist/query/command-manifest.state.d.ts.map +1 -0
  554. package/sdk/dist/query/command-manifest.state.js +30 -0
  555. package/sdk/dist/query/command-manifest.state.js.map +1 -0
  556. package/sdk/dist/query/command-manifest.types.d.ts +12 -0
  557. package/sdk/dist/query/command-manifest.types.d.ts.map +1 -0
  558. package/sdk/dist/query/command-manifest.types.js +2 -0
  559. package/sdk/dist/query/command-manifest.types.js.map +1 -0
  560. package/sdk/dist/query/command-manifest.validate.d.ts +6 -0
  561. package/sdk/dist/query/command-manifest.validate.d.ts.map +1 -0
  562. package/sdk/dist/query/command-manifest.validate.js +10 -0
  563. package/sdk/dist/query/command-manifest.validate.js.map +1 -0
  564. package/sdk/dist/query/command-manifest.verify.d.ts +6 -0
  565. package/sdk/dist/query/command-manifest.verify.d.ts.map +1 -0
  566. package/sdk/dist/query/command-manifest.verify.js +14 -0
  567. package/sdk/dist/query/command-manifest.verify.js.map +1 -0
  568. package/sdk/dist/query/command-static-catalog-domain.d.ts +3 -0
  569. package/sdk/dist/query/command-static-catalog-domain.d.ts.map +1 -0
  570. package/sdk/dist/query/command-static-catalog-domain.js +116 -0
  571. package/sdk/dist/query/command-static-catalog-domain.js.map +1 -0
  572. package/sdk/dist/query/command-static-catalog-foundation.d.ts +7 -0
  573. package/sdk/dist/query/command-static-catalog-foundation.d.ts.map +1 -0
  574. package/sdk/dist/query/command-static-catalog-foundation.js +98 -0
  575. package/sdk/dist/query/command-static-catalog-foundation.js.map +1 -0
  576. package/sdk/dist/query/command-topology.d.ts +32 -0
  577. package/sdk/dist/query/command-topology.d.ts.map +1 -0
  578. package/sdk/dist/query/command-topology.js +66 -0
  579. package/sdk/dist/query/command-topology.js.map +1 -0
  580. package/sdk/dist/query/commands-list.d.ts +14 -0
  581. package/sdk/dist/query/commands-list.d.ts.map +1 -0
  582. package/sdk/dist/query/commands-list.js +18 -0
  583. package/sdk/dist/query/commands-list.js.map +1 -0
  584. package/sdk/dist/query/commit.d.ts +79 -0
  585. package/sdk/dist/query/commit.d.ts.map +1 -0
  586. package/sdk/dist/query/commit.js +340 -0
  587. package/sdk/dist/query/commit.js.map +1 -0
  588. package/sdk/dist/query/config-gates.d.ts +12 -0
  589. package/sdk/dist/query/config-gates.d.ts.map +1 -0
  590. package/sdk/dist/query/config-gates.js +66 -0
  591. package/sdk/dist/query/config-gates.js.map +1 -0
  592. package/sdk/dist/query/config-mutation.d.ts +86 -0
  593. package/sdk/dist/query/config-mutation.d.ts.map +1 -0
  594. package/sdk/dist/query/config-mutation.js +518 -0
  595. package/sdk/dist/query/config-mutation.js.map +1 -0
  596. package/sdk/dist/query/config-query.d.ts +57 -0
  597. package/sdk/dist/query/config-query.d.ts.map +1 -0
  598. package/sdk/dist/query/config-query.js +208 -0
  599. package/sdk/dist/query/config-query.js.map +1 -0
  600. package/sdk/dist/query/config-schema.d.ts +36 -0
  601. package/sdk/dist/query/config-schema.d.ts.map +1 -0
  602. package/sdk/dist/query/config-schema.js +147 -0
  603. package/sdk/dist/query/config-schema.js.map +1 -0
  604. package/sdk/dist/query/decisions.d.ts +58 -0
  605. package/sdk/dist/query/decisions.d.ts.map +1 -0
  606. package/sdk/dist/query/decisions.js +161 -0
  607. package/sdk/dist/query/decisions.js.map +1 -0
  608. package/sdk/dist/query/detect-custom-files.d.ts +11 -0
  609. package/sdk/dist/query/detect-custom-files.d.ts.map +1 -0
  610. package/sdk/dist/query/detect-custom-files.js +89 -0
  611. package/sdk/dist/query/detect-custom-files.js.map +1 -0
  612. package/sdk/dist/query/detect-phase-type.d.ts +9 -0
  613. package/sdk/dist/query/detect-phase-type.d.ts.map +1 -0
  614. package/sdk/dist/query/detect-phase-type.js +124 -0
  615. package/sdk/dist/query/detect-phase-type.js.map +1 -0
  616. package/sdk/dist/query/docs-init.d.ts +26 -0
  617. package/sdk/dist/query/docs-init.d.ts.map +1 -0
  618. package/sdk/dist/query/docs-init.js +231 -0
  619. package/sdk/dist/query/docs-init.js.map +1 -0
  620. package/sdk/dist/query/fallow-audit.d.ts +44 -0
  621. package/sdk/dist/query/fallow-audit.d.ts.map +1 -0
  622. package/sdk/dist/query/fallow-audit.js +44 -0
  623. package/sdk/dist/query/fallow-audit.js.map +1 -0
  624. package/sdk/dist/query/frontmatter-mutation.d.ts +77 -0
  625. package/sdk/dist/query/frontmatter-mutation.d.ts.map +1 -0
  626. package/sdk/dist/query/frontmatter-mutation.js +317 -0
  627. package/sdk/dist/query/frontmatter-mutation.js.map +1 -0
  628. package/sdk/dist/query/frontmatter.d.ts +93 -0
  629. package/sdk/dist/query/frontmatter.d.ts.map +1 -0
  630. package/sdk/dist/query/frontmatter.js +365 -0
  631. package/sdk/dist/query/frontmatter.js.map +1 -0
  632. package/sdk/dist/query/helpers.d.ts +191 -0
  633. package/sdk/dist/query/helpers.d.ts.map +1 -0
  634. package/sdk/dist/query/helpers.js +613 -0
  635. package/sdk/dist/query/helpers.js.map +1 -0
  636. package/sdk/dist/query/index.d.ts +8 -0
  637. package/sdk/dist/query/index.d.ts.map +1 -0
  638. package/sdk/dist/query/index.js +6 -0
  639. package/sdk/dist/query/index.js.map +1 -0
  640. package/sdk/dist/query/init-complex.d.ts +47 -0
  641. package/sdk/dist/query/init-complex.d.ts.map +1 -0
  642. package/sdk/dist/query/init-complex.js +718 -0
  643. package/sdk/dist/query/init-complex.js.map +1 -0
  644. package/sdk/dist/query/init.d.ts +106 -0
  645. package/sdk/dist/query/init.d.ts.map +1 -0
  646. package/sdk/dist/query/init.js +1159 -0
  647. package/sdk/dist/query/init.js.map +1 -0
  648. package/sdk/dist/query/intel.d.ts +43 -0
  649. package/sdk/dist/query/intel.d.ts.map +1 -0
  650. package/sdk/dist/query/intel.js +416 -0
  651. package/sdk/dist/query/intel.js.map +1 -0
  652. package/sdk/dist/query/mutation-event-decorator.d.ts +5 -0
  653. package/sdk/dist/query/mutation-event-decorator.d.ts.map +1 -0
  654. package/sdk/dist/query/mutation-event-decorator.js +28 -0
  655. package/sdk/dist/query/mutation-event-decorator.js.map +1 -0
  656. package/sdk/dist/query/mutation-event-mapper.d.ts +4 -0
  657. package/sdk/dist/query/mutation-event-mapper.d.ts.map +1 -0
  658. package/sdk/dist/query/mutation-event-mapper.js +70 -0
  659. package/sdk/dist/query/mutation-event-mapper.js.map +1 -0
  660. package/sdk/dist/query/mvp.d.ts +113 -0
  661. package/sdk/dist/query/mvp.d.ts.map +1 -0
  662. package/sdk/dist/query/mvp.js +225 -0
  663. package/sdk/dist/query/mvp.js.map +1 -0
  664. package/sdk/dist/query/phase-filesystem-adapter.d.ts +4 -0
  665. package/sdk/dist/query/phase-filesystem-adapter.d.ts.map +1 -0
  666. package/sdk/dist/query/phase-filesystem-adapter.js +33 -0
  667. package/sdk/dist/query/phase-filesystem-adapter.js.map +1 -0
  668. package/sdk/dist/query/phase-lifecycle-policy.d.ts +34 -0
  669. package/sdk/dist/query/phase-lifecycle-policy.d.ts.map +1 -0
  670. package/sdk/dist/query/phase-lifecycle-policy.js +138 -0
  671. package/sdk/dist/query/phase-lifecycle-policy.js.map +1 -0
  672. package/sdk/dist/query/phase-lifecycle.d.ts +116 -0
  673. package/sdk/dist/query/phase-lifecycle.d.ts.map +1 -0
  674. package/sdk/dist/query/phase-lifecycle.js +1486 -0
  675. package/sdk/dist/query/phase-lifecycle.js.map +1 -0
  676. package/sdk/dist/query/phase-list-queries.d.ts +18 -0
  677. package/sdk/dist/query/phase-list-queries.d.ts.map +1 -0
  678. package/sdk/dist/query/phase-list-queries.js +129 -0
  679. package/sdk/dist/query/phase-list-queries.js.map +1 -0
  680. package/sdk/dist/query/phase-ready.d.ts +9 -0
  681. package/sdk/dist/query/phase-ready.d.ts.map +1 -0
  682. package/sdk/dist/query/phase-ready.js +132 -0
  683. package/sdk/dist/query/phase-ready.js.map +1 -0
  684. package/sdk/dist/query/phase-roadmap-mutation.d.ts +13 -0
  685. package/sdk/dist/query/phase-roadmap-mutation.d.ts.map +1 -0
  686. package/sdk/dist/query/phase-roadmap-mutation.js +65 -0
  687. package/sdk/dist/query/phase-roadmap-mutation.js.map +1 -0
  688. package/sdk/dist/query/phase.d.ts +48 -0
  689. package/sdk/dist/query/phase.d.ts.map +1 -0
  690. package/sdk/dist/query/phase.js +451 -0
  691. package/sdk/dist/query/phase.js.map +1 -0
  692. package/sdk/dist/query/pipeline.d.ts +53 -0
  693. package/sdk/dist/query/pipeline.d.ts.map +1 -0
  694. package/sdk/dist/query/pipeline.js +198 -0
  695. package/sdk/dist/query/pipeline.js.map +1 -0
  696. package/sdk/dist/query/plan-scan.d.ts +14 -0
  697. package/sdk/dist/query/plan-scan.d.ts.map +1 -0
  698. package/sdk/dist/query/plan-scan.js +70 -0
  699. package/sdk/dist/query/plan-scan.js.map +1 -0
  700. package/sdk/dist/query/plan-task-structure.d.ts +9 -0
  701. package/sdk/dist/query/plan-task-structure.d.ts.map +1 -0
  702. package/sdk/dist/query/plan-task-structure.js +59 -0
  703. package/sdk/dist/query/plan-task-structure.js.map +1 -0
  704. package/sdk/dist/query/profile-extract-messages.d.ts +40 -0
  705. package/sdk/dist/query/profile-extract-messages.d.ts.map +1 -0
  706. package/sdk/dist/query/profile-extract-messages.js +195 -0
  707. package/sdk/dist/query/profile-extract-messages.js.map +1 -0
  708. package/sdk/dist/query/profile-output.d.ts +11 -0
  709. package/sdk/dist/query/profile-output.d.ts.map +1 -0
  710. package/sdk/dist/query/profile-output.js +873 -0
  711. package/sdk/dist/query/profile-output.js.map +1 -0
  712. package/sdk/dist/query/profile-questionnaire-data.d.ts +21 -0
  713. package/sdk/dist/query/profile-questionnaire-data.d.ts.map +1 -0
  714. package/sdk/dist/query/profile-questionnaire-data.js +171 -0
  715. package/sdk/dist/query/profile-questionnaire-data.js.map +1 -0
  716. package/sdk/dist/query/profile-sample.d.ts +22 -0
  717. package/sdk/dist/query/profile-sample.d.ts.map +1 -0
  718. package/sdk/dist/query/profile-sample.js +136 -0
  719. package/sdk/dist/query/profile-sample.js.map +1 -0
  720. package/sdk/dist/query/profile-scan-sessions.d.ts +49 -0
  721. package/sdk/dist/query/profile-scan-sessions.d.ts.map +1 -0
  722. package/sdk/dist/query/profile-scan-sessions.js +137 -0
  723. package/sdk/dist/query/profile-scan-sessions.js.map +1 -0
  724. package/sdk/dist/query/profile.d.ts +61 -0
  725. package/sdk/dist/query/profile.d.ts.map +1 -0
  726. package/sdk/dist/query/profile.js +307 -0
  727. package/sdk/dist/query/profile.js.map +1 -0
  728. package/sdk/dist/query/progress.d.ts +77 -0
  729. package/sdk/dist/query/progress.d.ts.map +1 -0
  730. package/sdk/dist/query/progress.js +481 -0
  731. package/sdk/dist/query/progress.js.map +1 -0
  732. package/sdk/dist/query/query-cli-adapter.d.ts +8 -0
  733. package/sdk/dist/query/query-cli-adapter.d.ts.map +1 -0
  734. package/sdk/dist/query/query-cli-adapter.js +32 -0
  735. package/sdk/dist/query/query-cli-adapter.js.map +1 -0
  736. package/sdk/dist/query/query-cli-output.d.ts +9 -0
  737. package/sdk/dist/query/query-cli-output.d.ts.map +1 -0
  738. package/sdk/dist/query/query-cli-output.js +28 -0
  739. package/sdk/dist/query/query-cli-output.js.map +1 -0
  740. package/sdk/dist/query/query-command-diagnosis.d.ts +6 -0
  741. package/sdk/dist/query/query-command-diagnosis.d.ts.map +1 -0
  742. package/sdk/dist/query/query-command-diagnosis.js +6 -0
  743. package/sdk/dist/query/query-command-diagnosis.js.map +1 -0
  744. package/sdk/dist/query/query-command-resolution-strategy.d.ts +29 -0
  745. package/sdk/dist/query/query-command-resolution-strategy.d.ts.map +1 -0
  746. package/sdk/dist/query/query-command-resolution-strategy.js +103 -0
  747. package/sdk/dist/query/query-command-resolution-strategy.js.map +1 -0
  748. package/sdk/dist/query/query-command-semantics.d.ts +7 -0
  749. package/sdk/dist/query/query-command-semantics.d.ts.map +1 -0
  750. package/sdk/dist/query/query-command-semantics.js +7 -0
  751. package/sdk/dist/query/query-command-semantics.js.map +1 -0
  752. package/sdk/dist/query/query-dispatch-contract.d.ts +21 -0
  753. package/sdk/dist/query/query-dispatch-contract.d.ts.map +1 -0
  754. package/sdk/dist/query/query-dispatch-contract.js +2 -0
  755. package/sdk/dist/query/query-dispatch-contract.js.map +1 -0
  756. package/sdk/dist/query/query-dispatch-error-mapper.d.ts +6 -0
  757. package/sdk/dist/query/query-dispatch-error-mapper.d.ts.map +1 -0
  758. package/sdk/dist/query/query-dispatch-error-mapper.js +6 -0
  759. package/sdk/dist/query/query-dispatch-error-mapper.js.map +1 -0
  760. package/sdk/dist/query/query-dispatch-formatting.d.ts +6 -0
  761. package/sdk/dist/query/query-dispatch-formatting.d.ts.map +1 -0
  762. package/sdk/dist/query/query-dispatch-formatting.js +6 -0
  763. package/sdk/dist/query/query-dispatch-formatting.js.map +1 -0
  764. package/sdk/dist/query/query-dispatch-input-validation.d.ts +6 -0
  765. package/sdk/dist/query/query-dispatch-input-validation.d.ts.map +1 -0
  766. package/sdk/dist/query/query-dispatch-input-validation.js +6 -0
  767. package/sdk/dist/query/query-dispatch-input-validation.js.map +1 -0
  768. package/sdk/dist/query/query-dispatch-observability.d.ts +2 -0
  769. package/sdk/dist/query/query-dispatch-observability.d.ts.map +1 -0
  770. package/sdk/dist/query/query-dispatch-observability.js +7 -0
  771. package/sdk/dist/query/query-dispatch-observability.js.map +1 -0
  772. package/sdk/dist/query/query-dispatch-plan.d.ts +6 -0
  773. package/sdk/dist/query/query-dispatch-plan.d.ts.map +1 -0
  774. package/sdk/dist/query/query-dispatch-plan.js +6 -0
  775. package/sdk/dist/query/query-dispatch-plan.js.map +1 -0
  776. package/sdk/dist/query/query-dispatch-result-builder.d.ts +6 -0
  777. package/sdk/dist/query/query-dispatch-result-builder.d.ts.map +1 -0
  778. package/sdk/dist/query/query-dispatch-result-builder.js +6 -0
  779. package/sdk/dist/query/query-dispatch-result-builder.js.map +1 -0
  780. package/sdk/dist/query/query-dispatch.d.ts +48 -0
  781. package/sdk/dist/query/query-dispatch.d.ts.map +1 -0
  782. package/sdk/dist/query/query-dispatch.js +175 -0
  783. package/sdk/dist/query/query-dispatch.js.map +1 -0
  784. package/sdk/dist/query/query-error-details-schema.d.ts +19 -0
  785. package/sdk/dist/query/query-error-details-schema.d.ts.map +1 -0
  786. package/sdk/dist/query/query-error-details-schema.js +10 -0
  787. package/sdk/dist/query/query-error-details-schema.js.map +1 -0
  788. package/sdk/dist/query/query-error-taxonomy.d.ts +38 -0
  789. package/sdk/dist/query/query-error-taxonomy.d.ts.map +1 -0
  790. package/sdk/dist/query/query-error-taxonomy.js +74 -0
  791. package/sdk/dist/query/query-error-taxonomy.js.map +1 -0
  792. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts +14 -0
  793. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts.map +1 -0
  794. package/sdk/dist/query/query-fallback-bridge-adapter.js +33 -0
  795. package/sdk/dist/query/query-fallback-bridge-adapter.js.map +1 -0
  796. package/sdk/dist/query/query-fallback-executor.d.ts +11 -0
  797. package/sdk/dist/query/query-fallback-executor.d.ts.map +1 -0
  798. package/sdk/dist/query/query-fallback-executor.js +31 -0
  799. package/sdk/dist/query/query-fallback-executor.js.map +1 -0
  800. package/sdk/dist/query/query-fallback-output-classifier.d.ts +6 -0
  801. package/sdk/dist/query/query-fallback-output-classifier.d.ts.map +1 -0
  802. package/sdk/dist/query/query-fallback-output-classifier.js +27 -0
  803. package/sdk/dist/query/query-fallback-output-classifier.js.map +1 -0
  804. package/sdk/dist/query/query-fallback-policy.d.ts +6 -0
  805. package/sdk/dist/query/query-fallback-policy.d.ts.map +1 -0
  806. package/sdk/dist/query/query-fallback-policy.js +7 -0
  807. package/sdk/dist/query/query-fallback-policy.js.map +1 -0
  808. package/sdk/dist/query/query-native-dispatch-adapter.d.ts +7 -0
  809. package/sdk/dist/query/query-native-dispatch-adapter.d.ts.map +1 -0
  810. package/sdk/dist/query/query-native-dispatch-adapter.js +6 -0
  811. package/sdk/dist/query/query-native-dispatch-adapter.js.map +1 -0
  812. package/sdk/dist/query/query-policy-capability.d.ts +10 -0
  813. package/sdk/dist/query/query-policy-capability.d.ts.map +1 -0
  814. package/sdk/dist/query/query-policy-capability.js +17 -0
  815. package/sdk/dist/query/query-policy-capability.js.map +1 -0
  816. package/sdk/dist/query/query-runtime-context.d.ts +19 -0
  817. package/sdk/dist/query/query-runtime-context.d.ts.map +1 -0
  818. package/sdk/dist/query/query-runtime-context.js +31 -0
  819. package/sdk/dist/query/query-runtime-context.js.map +1 -0
  820. package/sdk/dist/query/query-unknown-command-hints.d.ts +2 -0
  821. package/sdk/dist/query/query-unknown-command-hints.d.ts.map +1 -0
  822. package/sdk/dist/query/query-unknown-command-hints.js +6 -0
  823. package/sdk/dist/query/query-unknown-command-hints.js.map +1 -0
  824. package/sdk/dist/query/registry-assembly-descriptor.d.ts +12 -0
  825. package/sdk/dist/query/registry-assembly-descriptor.d.ts.map +1 -0
  826. package/sdk/dist/query/registry-assembly-descriptor.js +61 -0
  827. package/sdk/dist/query/registry-assembly-descriptor.js.map +1 -0
  828. package/sdk/dist/query/registry-assembly-invariants.d.ts +30 -0
  829. package/sdk/dist/query/registry-assembly-invariants.d.ts.map +1 -0
  830. package/sdk/dist/query/registry-assembly-invariants.js +77 -0
  831. package/sdk/dist/query/registry-assembly-invariants.js.map +1 -0
  832. package/sdk/dist/query/registry-assembly.d.ts +10 -0
  833. package/sdk/dist/query/registry-assembly.d.ts.map +1 -0
  834. package/sdk/dist/query/registry-assembly.js +53 -0
  835. package/sdk/dist/query/registry-assembly.js.map +1 -0
  836. package/sdk/dist/query/registry.d.ts +90 -0
  837. package/sdk/dist/query/registry.d.ts.map +1 -0
  838. package/sdk/dist/query/registry.js +129 -0
  839. package/sdk/dist/query/registry.js.map +1 -0
  840. package/sdk/dist/query/requirements-extract-from-plans.d.ts +9 -0
  841. package/sdk/dist/query/requirements-extract-from-plans.d.ts.map +1 -0
  842. package/sdk/dist/query/requirements-extract-from-plans.js +76 -0
  843. package/sdk/dist/query/requirements-extract-from-plans.js.map +1 -0
  844. package/sdk/dist/query/roadmap-update-plan-progress.d.ts +11 -0
  845. package/sdk/dist/query/roadmap-update-plan-progress.d.ts.map +1 -0
  846. package/sdk/dist/query/roadmap-update-plan-progress.js +124 -0
  847. package/sdk/dist/query/roadmap-update-plan-progress.js.map +1 -0
  848. package/sdk/dist/query/roadmap.d.ts +137 -0
  849. package/sdk/dist/query/roadmap.d.ts.map +1 -0
  850. package/sdk/dist/query/roadmap.js +753 -0
  851. package/sdk/dist/query/roadmap.js.map +1 -0
  852. package/sdk/dist/query/route-next-action.d.ts +9 -0
  853. package/sdk/dist/query/route-next-action.d.ts.map +1 -0
  854. package/sdk/dist/query/route-next-action.js +318 -0
  855. package/sdk/dist/query/route-next-action.js.map +1 -0
  856. package/sdk/dist/query/schema-detect.d.ts +21 -0
  857. package/sdk/dist/query/schema-detect.d.ts.map +1 -0
  858. package/sdk/dist/query/schema-detect.js +146 -0
  859. package/sdk/dist/query/schema-detect.js.map +1 -0
  860. package/sdk/dist/query/secrets.d.ts +27 -0
  861. package/sdk/dist/query/secrets.d.ts.map +1 -0
  862. package/sdk/dist/query/secrets.js +42 -0
  863. package/sdk/dist/query/secrets.js.map +1 -0
  864. package/sdk/dist/query/skill-manifest.d.ts +50 -0
  865. package/sdk/dist/query/skill-manifest.d.ts.map +1 -0
  866. package/sdk/dist/query/skill-manifest.js +171 -0
  867. package/sdk/dist/query/skill-manifest.js.map +1 -0
  868. package/sdk/dist/query/skills.d.ts +27 -0
  869. package/sdk/dist/query/skills.d.ts.map +1 -0
  870. package/sdk/dist/query/skills.js +137 -0
  871. package/sdk/dist/query/skills.js.map +1 -0
  872. package/sdk/dist/query/state-document.d.ts +14 -0
  873. package/sdk/dist/query/state-document.d.ts.map +1 -0
  874. package/sdk/dist/query/state-document.js +110 -0
  875. package/sdk/dist/query/state-document.js.map +1 -0
  876. package/sdk/dist/query/state-mutation.d.ts +224 -0
  877. package/sdk/dist/query/state-mutation.d.ts.map +1 -0
  878. package/sdk/dist/query/state-mutation.js +1539 -0
  879. package/sdk/dist/query/state-mutation.js.map +1 -0
  880. package/sdk/dist/query/state-project-load.d.ts +23 -0
  881. package/sdk/dist/query/state-project-load.d.ts.map +1 -0
  882. package/sdk/dist/query/state-project-load.js +75 -0
  883. package/sdk/dist/query/state-project-load.js.map +1 -0
  884. package/sdk/dist/query/state.d.ts +78 -0
  885. package/sdk/dist/query/state.d.ts.map +1 -0
  886. package/sdk/dist/query/state.js +430 -0
  887. package/sdk/dist/query/state.js.map +1 -0
  888. package/sdk/dist/query/summary.d.ts +18 -0
  889. package/sdk/dist/query/summary.d.ts.map +1 -0
  890. package/sdk/dist/query/summary.js +249 -0
  891. package/sdk/dist/query/summary.js.map +1 -0
  892. package/sdk/dist/query/template.d.ts +46 -0
  893. package/sdk/dist/query/template.d.ts.map +1 -0
  894. package/sdk/dist/query/template.js +210 -0
  895. package/sdk/dist/query/template.js.map +1 -0
  896. package/sdk/dist/query/uat.d.ts +34 -0
  897. package/sdk/dist/query/uat.d.ts.map +1 -0
  898. package/sdk/dist/query/uat.js +339 -0
  899. package/sdk/dist/query/uat.js.map +1 -0
  900. package/sdk/dist/query/utils.d.ts +59 -0
  901. package/sdk/dist/query/utils.d.ts.map +1 -0
  902. package/sdk/dist/query/utils.js +74 -0
  903. package/sdk/dist/query/utils.js.map +1 -0
  904. package/sdk/dist/query/validate.d.ts +67 -0
  905. package/sdk/dist/query/validate.d.ts.map +1 -0
  906. package/sdk/dist/query/validate.js +908 -0
  907. package/sdk/dist/query/validate.js.map +1 -0
  908. package/sdk/dist/query/verify.d.ts +110 -0
  909. package/sdk/dist/query/verify.d.ts.map +1 -0
  910. package/sdk/dist/query/verify.js +631 -0
  911. package/sdk/dist/query/verify.js.map +1 -0
  912. package/sdk/dist/query/websearch.d.ts +24 -0
  913. package/sdk/dist/query/websearch.d.ts.map +1 -0
  914. package/sdk/dist/query/websearch.js +68 -0
  915. package/sdk/dist/query/websearch.js.map +1 -0
  916. package/sdk/dist/query/workspace.d.ts +62 -0
  917. package/sdk/dist/query/workspace.d.ts.map +1 -0
  918. package/sdk/dist/query/workspace.js +104 -0
  919. package/sdk/dist/query/workspace.js.map +1 -0
  920. package/sdk/dist/query/workstream-inventory.d.ts +52 -0
  921. package/sdk/dist/query/workstream-inventory.d.ts.map +1 -0
  922. package/sdk/dist/query/workstream-inventory.js +141 -0
  923. package/sdk/dist/query/workstream-inventory.js.map +1 -0
  924. package/sdk/dist/query/workstream.d.ts +35 -0
  925. package/sdk/dist/query/workstream.d.ts.map +1 -0
  926. package/sdk/dist/query/workstream.js +298 -0
  927. package/sdk/dist/query/workstream.js.map +1 -0
  928. package/sdk/dist/query/worktree.d.ts +3 -0
  929. package/sdk/dist/query/worktree.d.ts.map +1 -0
  930. package/sdk/dist/query/worktree.js +36 -0
  931. package/sdk/dist/query/worktree.js.map +1 -0
  932. package/sdk/dist/query-command-executor.d.ts +22 -0
  933. package/sdk/dist/query-command-executor.d.ts.map +1 -0
  934. package/sdk/dist/query-command-executor.js +22 -0
  935. package/sdk/dist/query-command-executor.js.map +1 -0
  936. package/sdk/dist/query-execution-policy.d.ts +24 -0
  937. package/sdk/dist/query-execution-policy.d.ts.map +1 -0
  938. package/sdk/dist/query-execution-policy.js +27 -0
  939. package/sdk/dist/query-execution-policy.js.map +1 -0
  940. package/sdk/dist/query-failure-classification.d.ts +9 -0
  941. package/sdk/dist/query-failure-classification.d.ts.map +1 -0
  942. package/sdk/dist/query-failure-classification.js +32 -0
  943. package/sdk/dist/query-failure-classification.js.map +1 -0
  944. package/sdk/dist/query-hotpath-methods.d.ts +19 -0
  945. package/sdk/dist/query-hotpath-methods.d.ts.map +1 -0
  946. package/sdk/dist/query-hotpath-methods.js +34 -0
  947. package/sdk/dist/query-hotpath-methods.js.map +1 -0
  948. package/sdk/dist/query-native-direct-adapter.d.ts +20 -0
  949. package/sdk/dist/query-native-direct-adapter.d.ts.map +1 -0
  950. package/sdk/dist/query-native-direct-adapter.js +52 -0
  951. package/sdk/dist/query-native-direct-adapter.js.map +1 -0
  952. package/sdk/dist/query-native-hotpath-adapter.d.ts +15 -0
  953. package/sdk/dist/query-native-hotpath-adapter.d.ts.map +1 -0
  954. package/sdk/dist/query-native-hotpath-adapter.js +32 -0
  955. package/sdk/dist/query-native-hotpath-adapter.js.map +1 -0
  956. package/sdk/dist/query-raw-output-projection.d.ts +6 -0
  957. package/sdk/dist/query-raw-output-projection.d.ts.map +1 -0
  958. package/sdk/dist/query-raw-output-projection.js +67 -0
  959. package/sdk/dist/query-raw-output-projection.js.map +1 -0
  960. package/sdk/dist/query-runtime-bridge.d.ts +61 -0
  961. package/sdk/dist/query-runtime-bridge.d.ts.map +1 -0
  962. package/sdk/dist/query-runtime-bridge.js +144 -0
  963. package/sdk/dist/query-runtime-bridge.js.map +1 -0
  964. package/sdk/dist/query-sdd-tools-path.d.ts +2 -0
  965. package/sdk/dist/query-sdd-tools-path.d.ts.map +1 -0
  966. package/sdk/dist/query-sdd-tools-path.js +2 -0
  967. package/sdk/dist/query-sdd-tools-path.js.map +1 -0
  968. package/sdk/dist/query-sdd-tools-runtime.d.ts +20 -0
  969. package/sdk/dist/query-sdd-tools-runtime.d.ts.map +1 -0
  970. package/sdk/dist/query-sdd-tools-runtime.js +47 -0
  971. package/sdk/dist/query-sdd-tools-runtime.js.map +1 -0
  972. package/sdk/dist/query-subprocess-adapter.d.ts +18 -0
  973. package/sdk/dist/query-subprocess-adapter.d.ts.map +1 -0
  974. package/sdk/dist/query-subprocess-adapter.js +92 -0
  975. package/sdk/dist/query-subprocess-adapter.js.map +1 -0
  976. package/sdk/dist/query-tools-error-factory.d.ts +16 -0
  977. package/sdk/dist/query-tools-error-factory.d.ts.map +1 -0
  978. package/sdk/dist/query-tools-error-factory.js +33 -0
  979. package/sdk/dist/query-tools-error-factory.js.map +1 -0
  980. package/sdk/dist/research-gate.d.ts +24 -0
  981. package/sdk/dist/research-gate.d.ts.map +1 -0
  982. package/sdk/dist/research-gate.js +70 -0
  983. package/sdk/dist/research-gate.js.map +1 -0
  984. package/sdk/dist/runtime-gate.d.ts +14 -0
  985. package/sdk/dist/runtime-gate.d.ts.map +1 -0
  986. package/sdk/dist/runtime-gate.js +48 -0
  987. package/sdk/dist/runtime-gate.js.map +1 -0
  988. package/sdk/dist/sdd-tools-error.d.ts +23 -0
  989. package/sdk/dist/sdd-tools-error.d.ts.map +1 -0
  990. package/sdk/dist/sdd-tools-error.js +29 -0
  991. package/sdk/dist/sdd-tools-error.js.map +1 -0
  992. package/sdk/dist/sdd-tools.d.ts +97 -0
  993. package/sdk/dist/sdd-tools.d.ts.map +1 -0
  994. package/sdk/dist/sdd-tools.js +168 -0
  995. package/sdk/dist/sdd-tools.js.map +1 -0
  996. package/sdk/dist/sdd-transport-policy.d.ts +10 -0
  997. package/sdk/dist/sdd-transport-policy.d.ts.map +1 -0
  998. package/sdk/dist/sdd-transport-policy.js +32 -0
  999. package/sdk/dist/sdd-transport-policy.js.map +1 -0
  1000. package/sdk/dist/sdd-transport.d.ts +39 -0
  1001. package/sdk/dist/sdd-transport.d.ts.map +1 -0
  1002. package/sdk/dist/sdd-transport.js +78 -0
  1003. package/sdk/dist/sdd-transport.js.map +1 -0
  1004. package/sdk/dist/sdk-package-compatibility.d.ts +38 -0
  1005. package/sdk/dist/sdk-package-compatibility.d.ts.map +1 -0
  1006. package/sdk/dist/sdk-package-compatibility.js +90 -0
  1007. package/sdk/dist/sdk-package-compatibility.js.map +1 -0
  1008. package/sdk/dist/session-runner.d.ts +40 -0
  1009. package/sdk/dist/session-runner.d.ts.map +1 -0
  1010. package/sdk/dist/session-runner.js +274 -0
  1011. package/sdk/dist/session-runner.js.map +1 -0
  1012. package/sdk/dist/tool-scoping.d.ts +31 -0
  1013. package/sdk/dist/tool-scoping.d.ts.map +1 -0
  1014. package/sdk/dist/tool-scoping.js +54 -0
  1015. package/sdk/dist/tool-scoping.js.map +1 -0
  1016. package/sdk/dist/types.d.ts +794 -0
  1017. package/sdk/dist/types.d.ts.map +1 -0
  1018. package/sdk/dist/types.js +77 -0
  1019. package/sdk/dist/types.js.map +1 -0
  1020. package/sdk/dist/workstream-name-policy.d.ts +13 -0
  1021. package/sdk/dist/workstream-name-policy.d.ts.map +1 -0
  1022. package/sdk/dist/workstream-name-policy.js +24 -0
  1023. package/sdk/dist/workstream-name-policy.js.map +1 -0
  1024. package/sdk/dist/workstream-utils.d.ts +15 -0
  1025. package/sdk/dist/workstream-utils.d.ts.map +1 -0
  1026. package/sdk/dist/workstream-utils.js +21 -0
  1027. package/sdk/dist/workstream-utils.js.map +1 -0
  1028. package/sdk/dist/ws-transport.d.ts +32 -0
  1029. package/sdk/dist/ws-transport.d.ts.map +1 -0
  1030. package/sdk/dist/ws-transport.js +84 -0
  1031. package/sdk/dist/ws-transport.js.map +1 -0
  1032. package/sdk/package-lock.json +2502 -0
  1033. package/sdk/package.json +57 -0
  1034. package/sdk/prompts/templates/project.md +186 -0
  1035. package/sdk/prompts/templates/requirements.md +231 -0
  1036. package/sdk/prompts/templates/research-project/ARCHITECTURE.md +204 -0
  1037. package/sdk/prompts/templates/research-project/FEATURES.md +147 -0
  1038. package/sdk/prompts/templates/research-project/PITFALLS.md +200 -0
  1039. package/sdk/prompts/templates/research-project/STACK.md +120 -0
  1040. package/sdk/prompts/templates/research-project/SUMMARY.md +170 -0
  1041. package/sdk/prompts/templates/roadmap.md +202 -0
  1042. package/sdk/prompts/templates/state.md +175 -0
  1043. package/sdk/shared/model-catalog.json +122 -0
  1044. package/sdk/src/assembled-prompts.test.ts +349 -0
  1045. package/sdk/src/bug-3591-sddtools-runtime-workstream.test.ts +179 -0
  1046. package/sdk/src/cli-transport.test.ts +388 -0
  1047. package/sdk/src/cli-transport.ts +130 -0
  1048. package/sdk/src/cli.test.ts +426 -0
  1049. package/sdk/src/cli.ts +589 -0
  1050. package/sdk/src/config.test.ts +271 -0
  1051. package/sdk/src/config.ts +218 -0
  1052. package/sdk/src/context-engine.test.ts +295 -0
  1053. package/sdk/src/context-engine.ts +170 -0
  1054. package/sdk/src/context-truncation.test.ts +163 -0
  1055. package/sdk/src/context-truncation.ts +233 -0
  1056. package/sdk/src/e2e.integration.test.ts +181 -0
  1057. package/sdk/src/errors.ts +72 -0
  1058. package/sdk/src/event-stream.test.ts +661 -0
  1059. package/sdk/src/event-stream.ts +441 -0
  1060. package/sdk/src/golden/capture.ts +95 -0
  1061. package/sdk/src/golden/fixtures/generate-slug.golden.json +1 -0
  1062. package/sdk/src/golden/fixtures/profile-sample-sessions/demo-project/sample.jsonl +3 -0
  1063. package/sdk/src/golden/fixtures/summary-extract-sample.md +26 -0
  1064. package/sdk/src/golden/fixtures/uat-render-checkpoint-sample.md +15 -0
  1065. package/sdk/src/golden/golden-integration-covered.ts +30 -0
  1066. package/sdk/src/golden/golden-mutation-covered.ts +17 -0
  1067. package/sdk/src/golden/golden-policy.test.ts +8 -0
  1068. package/sdk/src/golden/golden-policy.ts +120 -0
  1069. package/sdk/src/golden/golden.integration.test.ts +677 -0
  1070. package/sdk/src/golden/init-golden-normalize.ts +15 -0
  1071. package/sdk/src/golden/read-only-golden-rows.ts +77 -0
  1072. package/sdk/src/golden/read-only-parity.integration.test.ts +133 -0
  1073. package/sdk/src/golden/registry-canonical-commands.ts +31 -0
  1074. package/sdk/src/index.ts +352 -0
  1075. package/sdk/src/init-e2e.integration.test.ts +138 -0
  1076. package/sdk/src/init-runner.test.ts +740 -0
  1077. package/sdk/src/init-runner.ts +734 -0
  1078. package/sdk/src/lifecycle-e2e.integration.test.ts +258 -0
  1079. package/sdk/src/logger.test.ts +149 -0
  1080. package/sdk/src/logger.ts +113 -0
  1081. package/sdk/src/milestone-runner.test.ts +421 -0
  1082. package/sdk/src/model-catalog.ts +70 -0
  1083. package/sdk/src/phase-prompt.test.ts +535 -0
  1084. package/sdk/src/phase-prompt.ts +259 -0
  1085. package/sdk/src/phase-runner-types.test.ts +421 -0
  1086. package/sdk/src/phase-runner.integration.test.ts +377 -0
  1087. package/sdk/src/phase-runner.test.ts +2720 -0
  1088. package/sdk/src/phase-runner.ts +1442 -0
  1089. package/sdk/src/plan-parser.test.ts +579 -0
  1090. package/sdk/src/plan-parser.ts +431 -0
  1091. package/sdk/src/planning-journal.test.ts +70 -0
  1092. package/sdk/src/planning-journal.ts +153 -0
  1093. package/sdk/src/planning-runtime.test.ts +29 -0
  1094. package/sdk/src/planning-runtime.ts +100 -0
  1095. package/sdk/src/prompt-builder.test.ts +318 -0
  1096. package/sdk/src/prompt-builder.ts +218 -0
  1097. package/sdk/src/prompt-sanitizer.test.ts +260 -0
  1098. package/sdk/src/prompt-sanitizer.ts +116 -0
  1099. package/sdk/src/query/QUERY-HANDLERS.md +349 -0
  1100. package/sdk/src/query/active-workstream-store.ts +50 -0
  1101. package/sdk/src/query/agent-failure-classifier.test.ts +157 -0
  1102. package/sdk/src/query/agent-failure-classifier.ts +105 -0
  1103. package/sdk/src/query/audit-open.ts +722 -0
  1104. package/sdk/src/query/check-auto-mode.test.ts +77 -0
  1105. package/sdk/src/query/check-auto-mode.ts +49 -0
  1106. package/sdk/src/query/check-completion.test.ts +113 -0
  1107. package/sdk/src/query/check-completion.ts +182 -0
  1108. package/sdk/src/query/check-decision-coverage.test.ts +519 -0
  1109. package/sdk/src/query/check-decision-coverage.ts +554 -0
  1110. package/sdk/src/query/check-gates.test.ts +103 -0
  1111. package/sdk/src/query/check-gates.ts +112 -0
  1112. package/sdk/src/query/check-ship-ready.test.ts +111 -0
  1113. package/sdk/src/query/check-ship-ready.ts +104 -0
  1114. package/sdk/src/query/check-verification-status.test.ts +143 -0
  1115. package/sdk/src/query/check-verification-status.ts +160 -0
  1116. package/sdk/src/query/command-aliases.generated.ts +156 -0
  1117. package/sdk/src/query/command-catalog.ts +31 -0
  1118. package/sdk/src/query/command-definition.test.ts +47 -0
  1119. package/sdk/src/query/command-definition.ts +70 -0
  1120. package/sdk/src/query/command-family-handlers.ts +117 -0
  1121. package/sdk/src/query/command-manifest.init.ts +24 -0
  1122. package/sdk/src/query/command-manifest.non-family.ts +85 -0
  1123. package/sdk/src/query/command-manifest.phase.ts +16 -0
  1124. package/sdk/src/query/command-manifest.phases.ts +11 -0
  1125. package/sdk/src/query/command-manifest.roadmap.ts +11 -0
  1126. package/sdk/src/query/command-manifest.state.ts +31 -0
  1127. package/sdk/src/query/command-manifest.ts +17 -0
  1128. package/sdk/src/query/command-manifest.types.ts +13 -0
  1129. package/sdk/src/query/command-manifest.validate.ts +11 -0
  1130. package/sdk/src/query/command-manifest.verify.ts +15 -0
  1131. package/sdk/src/query/command-resolution.test.ts +70 -0
  1132. package/sdk/src/query/command-seam-coverage.test.ts +118 -0
  1133. package/sdk/src/query/command-static-catalog-domain.ts +117 -0
  1134. package/sdk/src/query/command-static-catalog-foundation.ts +103 -0
  1135. package/sdk/src/query/command-topology.test.ts +28 -0
  1136. package/sdk/src/query/command-topology.ts +114 -0
  1137. package/sdk/src/query/commands-list.test.ts +36 -0
  1138. package/sdk/src/query/commands-list.ts +19 -0
  1139. package/sdk/src/query/commit.test.ts +485 -0
  1140. package/sdk/src/query/commit.ts +383 -0
  1141. package/sdk/src/query/config-gates.test.ts +89 -0
  1142. package/sdk/src/query/config-gates.ts +69 -0
  1143. package/sdk/src/query/config-mutation.test.ts +598 -0
  1144. package/sdk/src/query/config-mutation.ts +575 -0
  1145. package/sdk/src/query/config-query.test.ts +367 -0
  1146. package/sdk/src/query/config-query.ts +244 -0
  1147. package/sdk/src/query/config-schema.ts +159 -0
  1148. package/sdk/src/query/decisions.test.ts +215 -0
  1149. package/sdk/src/query/decisions.ts +192 -0
  1150. package/sdk/src/query/decomposed-handlers.test.ts +431 -0
  1151. package/sdk/src/query/detect-custom-files.test.ts +115 -0
  1152. package/sdk/src/query/detect-custom-files.ts +96 -0
  1153. package/sdk/src/query/detect-phase-type.test.ts +105 -0
  1154. package/sdk/src/query/detect-phase-type.ts +141 -0
  1155. package/sdk/src/query/docs-init.ts +258 -0
  1156. package/sdk/src/query/fallow-audit.ts +88 -0
  1157. package/sdk/src/query/frontmatter-array.test.ts +14 -0
  1158. package/sdk/src/query/frontmatter-mutation.test.ts +259 -0
  1159. package/sdk/src/query/frontmatter-mutation.ts +343 -0
  1160. package/sdk/src/query/frontmatter.test.ts +326 -0
  1161. package/sdk/src/query/frontmatter.ts +395 -0
  1162. package/sdk/src/query/helpers.test.ts +615 -0
  1163. package/sdk/src/query/helpers.ts +646 -0
  1164. package/sdk/src/query/index-thin-seam.test.ts +16 -0
  1165. package/sdk/src/query/index.ts +9 -0
  1166. package/sdk/src/query/init-complex.test.ts +616 -0
  1167. package/sdk/src/query/init-complex.ts +799 -0
  1168. package/sdk/src/query/init-progress-precedence.test.ts +177 -0
  1169. package/sdk/src/query/init-workstream-milestone-op.test.ts +321 -0
  1170. package/sdk/src/query/init.test.ts +792 -0
  1171. package/sdk/src/query/init.ts +1262 -0
  1172. package/sdk/src/query/intel.test.ts +90 -0
  1173. package/sdk/src/query/intel.ts +404 -0
  1174. package/sdk/src/query/mutation-event-decorator.test.ts +45 -0
  1175. package/sdk/src/query/mutation-event-decorator.ts +37 -0
  1176. package/sdk/src/query/mutation-event-mapper.test.ts +33 -0
  1177. package/sdk/src/query/mutation-event-mapper.ts +102 -0
  1178. package/sdk/src/query/mvp.test.ts +335 -0
  1179. package/sdk/src/query/mvp.ts +292 -0
  1180. package/sdk/src/query/normalize-query-command.test.ts +102 -0
  1181. package/sdk/src/query/phase-filesystem-adapter.ts +35 -0
  1182. package/sdk/src/query/phase-lifecycle-policy.ts +171 -0
  1183. package/sdk/src/query/phase-lifecycle.test.ts +1750 -0
  1184. package/sdk/src/query/phase-lifecycle.ts +1833 -0
  1185. package/sdk/src/query/phase-list-queries.test.ts +88 -0
  1186. package/sdk/src/query/phase-list-queries.ts +152 -0
  1187. package/sdk/src/query/phase-ready.test.ts +65 -0
  1188. package/sdk/src/query/phase-ready.ts +159 -0
  1189. package/sdk/src/query/phase-roadmap-mutation.ts +77 -0
  1190. package/sdk/src/query/phase.test.ts +651 -0
  1191. package/sdk/src/query/phase.ts +550 -0
  1192. package/sdk/src/query/pipeline.test.ts +169 -0
  1193. package/sdk/src/query/pipeline.ts +243 -0
  1194. package/sdk/src/query/plan-scan.test.ts +35 -0
  1195. package/sdk/src/query/plan-scan.ts +82 -0
  1196. package/sdk/src/query/plan-task-structure.test.ts +65 -0
  1197. package/sdk/src/query/plan-task-structure.ts +63 -0
  1198. package/sdk/src/query/policy-convergence.test.ts +28 -0
  1199. package/sdk/src/query/profile-extract-messages.ts +247 -0
  1200. package/sdk/src/query/profile-output.ts +929 -0
  1201. package/sdk/src/query/profile-questionnaire-data.ts +181 -0
  1202. package/sdk/src/query/profile-sample.ts +184 -0
  1203. package/sdk/src/query/profile-scan-sessions.ts +174 -0
  1204. package/sdk/src/query/profile.test.ts +136 -0
  1205. package/sdk/src/query/profile.ts +337 -0
  1206. package/sdk/src/query/progress.test.ts +156 -0
  1207. package/sdk/src/query/progress.ts +566 -0
  1208. package/sdk/src/query/query-cli-adapter.test.ts +79 -0
  1209. package/sdk/src/query/query-cli-adapter.ts +39 -0
  1210. package/sdk/src/query/query-cli-output.test.ts +33 -0
  1211. package/sdk/src/query/query-cli-output.ts +35 -0
  1212. package/sdk/src/query/query-command-diagnosis.test.ts +22 -0
  1213. package/sdk/src/query/query-command-diagnosis.ts +5 -0
  1214. package/sdk/src/query/query-command-resolution-strategy.test.ts +34 -0
  1215. package/sdk/src/query/query-command-resolution-strategy.ts +121 -0
  1216. package/sdk/src/query/query-command-semantics.test.ts +22 -0
  1217. package/sdk/src/query/query-command-semantics.ts +22 -0
  1218. package/sdk/src/query/query-dispatch-contract.ts +30 -0
  1219. package/sdk/src/query/query-dispatch-error-mapper.test.ts +62 -0
  1220. package/sdk/src/query/query-dispatch-error-mapper.ts +5 -0
  1221. package/sdk/src/query/query-dispatch-formatting.test.ts +28 -0
  1222. package/sdk/src/query/query-dispatch-formatting.ts +5 -0
  1223. package/sdk/src/query/query-dispatch-input-validation.test.ts +23 -0
  1224. package/sdk/src/query/query-dispatch-input-validation.ts +5 -0
  1225. package/sdk/src/query/query-dispatch-observability.test.ts +10 -0
  1226. package/sdk/src/query/query-dispatch-observability.ts +6 -0
  1227. package/sdk/src/query/query-dispatch-plan.test.ts +25 -0
  1228. package/sdk/src/query/query-dispatch-plan.ts +5 -0
  1229. package/sdk/src/query/query-dispatch-result-builder.test.ts +16 -0
  1230. package/sdk/src/query/query-dispatch-result-builder.ts +5 -0
  1231. package/sdk/src/query/query-dispatch.test.ts +399 -0
  1232. package/sdk/src/query/query-dispatch.ts +243 -0
  1233. package/sdk/src/query/query-error-details-schema.ts +29 -0
  1234. package/sdk/src/query/query-error-taxonomy.test.ts +39 -0
  1235. package/sdk/src/query/query-error-taxonomy.ts +117 -0
  1236. package/sdk/src/query/query-fallback-bridge-adapter.test.ts +32 -0
  1237. package/sdk/src/query/query-fallback-bridge-adapter.ts +54 -0
  1238. package/sdk/src/query/query-fallback-executor.test.ts +82 -0
  1239. package/sdk/src/query/query-fallback-executor.ts +44 -0
  1240. package/sdk/src/query/query-fallback-output-classifier.test.ts +36 -0
  1241. package/sdk/src/query/query-fallback-output-classifier.ts +31 -0
  1242. package/sdk/src/query/query-fallback-policy.test.ts +13 -0
  1243. package/sdk/src/query/query-fallback-policy.ts +11 -0
  1244. package/sdk/src/query/query-native-dispatch-adapter.ts +16 -0
  1245. package/sdk/src/query/query-policy-capability.test.ts +10 -0
  1246. package/sdk/src/query/query-policy-capability.ts +26 -0
  1247. package/sdk/src/query/query-policy-snapshot.test.ts +9 -0
  1248. package/sdk/src/query/query-registry-capability.test.ts +14 -0
  1249. package/sdk/src/query/query-runtime-context.ts +44 -0
  1250. package/sdk/src/query/query-unknown-command-hints.test.ts +9 -0
  1251. package/sdk/src/query/query-unknown-command-hints.ts +5 -0
  1252. package/sdk/src/query/registry-assembly-descriptor.ts +87 -0
  1253. package/sdk/src/query/registry-assembly-invariants.ts +127 -0
  1254. package/sdk/src/query/registry-assembly.test.ts +138 -0
  1255. package/sdk/src/query/registry-assembly.ts +78 -0
  1256. package/sdk/src/query/registry.test.ts +208 -0
  1257. package/sdk/src/query/registry.ts +142 -0
  1258. package/sdk/src/query/requirements-extract-from-plans.test.ts +58 -0
  1259. package/sdk/src/query/requirements-extract-from-plans.ts +86 -0
  1260. package/sdk/src/query/roadmap-update-plan-progress.test.ts +233 -0
  1261. package/sdk/src/query/roadmap-update-plan-progress.ts +159 -0
  1262. package/sdk/src/query/roadmap.test.ts +1181 -0
  1263. package/sdk/src/query/roadmap.ts +894 -0
  1264. package/sdk/src/query/route-next-action.test.ts +61 -0
  1265. package/sdk/src/query/route-next-action.ts +345 -0
  1266. package/sdk/src/query/schema-detect.ts +189 -0
  1267. package/sdk/src/query/secrets.test.ts +66 -0
  1268. package/sdk/src/query/secrets.ts +43 -0
  1269. package/sdk/src/query/skill-manifest.test.ts +62 -0
  1270. package/sdk/src/query/skill-manifest.ts +216 -0
  1271. package/sdk/src/query/skills.test.ts +234 -0
  1272. package/sdk/src/query/skills.ts +143 -0
  1273. package/sdk/src/query/state-document.test.ts +197 -0
  1274. package/sdk/src/query/state-document.ts +129 -0
  1275. package/sdk/src/query/state-mutation.test.ts +1198 -0
  1276. package/sdk/src/query/state-mutation.ts +1718 -0
  1277. package/sdk/src/query/state-project-load.ts +80 -0
  1278. package/sdk/src/query/state.test.ts +616 -0
  1279. package/sdk/src/query/state.ts +463 -0
  1280. package/sdk/src/query/sub-repos-root.integration.test.ts +79 -0
  1281. package/sdk/src/query/summary.test.ts +95 -0
  1282. package/sdk/src/query/summary.ts +296 -0
  1283. package/sdk/src/query/template.test.ts +180 -0
  1284. package/sdk/src/query/template.ts +242 -0
  1285. package/sdk/src/query/uat.test.ts +77 -0
  1286. package/sdk/src/query/uat.ts +365 -0
  1287. package/sdk/src/query/utils.test.ts +82 -0
  1288. package/sdk/src/query/utils.ts +106 -0
  1289. package/sdk/src/query/validate.test.ts +831 -0
  1290. package/sdk/src/query/validate.ts +952 -0
  1291. package/sdk/src/query/verify.test.ts +414 -0
  1292. package/sdk/src/query/verify.ts +692 -0
  1293. package/sdk/src/query/websearch.test.ts +31 -0
  1294. package/sdk/src/query/websearch.ts +82 -0
  1295. package/sdk/src/query/workspace.test.ts +120 -0
  1296. package/sdk/src/query/workspace.ts +145 -0
  1297. package/sdk/src/query/workstream-inventory.ts +195 -0
  1298. package/sdk/src/query/workstream.test.ts +153 -0
  1299. package/sdk/src/query/workstream.ts +324 -0
  1300. package/sdk/src/query/worktree.ts +39 -0
  1301. package/sdk/src/query-command-executor.ts +31 -0
  1302. package/sdk/src/query-execution-policy.test.ts +52 -0
  1303. package/sdk/src/query-execution-policy.ts +46 -0
  1304. package/sdk/src/query-failure-classification.test.ts +23 -0
  1305. package/sdk/src/query-failure-classification.ts +42 -0
  1306. package/sdk/src/query-hotpath-methods.ts +48 -0
  1307. package/sdk/src/query-native-direct-adapter.test.ts +35 -0
  1308. package/sdk/src/query-native-direct-adapter.ts +70 -0
  1309. package/sdk/src/query-native-hotpath-adapter.test.ts +43 -0
  1310. package/sdk/src/query-native-hotpath-adapter.ts +45 -0
  1311. package/sdk/src/query-raw-output-projection.test.ts +39 -0
  1312. package/sdk/src/query-raw-output-projection.ts +74 -0
  1313. package/sdk/src/query-runtime-bridge.test.ts +150 -0
  1314. package/sdk/src/query-runtime-bridge.ts +215 -0
  1315. package/sdk/src/query-runtime-seam-coverage.test.ts +20 -0
  1316. package/sdk/src/query-sdd-tools-path.ts +1 -0
  1317. package/sdk/src/query-sdd-tools-runtime.ts +89 -0
  1318. package/sdk/src/query-subprocess-adapter.test.ts +84 -0
  1319. package/sdk/src/query-subprocess-adapter.ts +146 -0
  1320. package/sdk/src/query-tools-error-factory.test.ts +35 -0
  1321. package/sdk/src/query-tools-error-factory.ts +76 -0
  1322. package/sdk/src/research-gate.test.ts +190 -0
  1323. package/sdk/src/research-gate.ts +94 -0
  1324. package/sdk/src/runtime-bridge-options.test.ts +33 -0
  1325. package/sdk/src/runtime-gate.test.ts +84 -0
  1326. package/sdk/src/runtime-gate.ts +52 -0
  1327. package/sdk/src/sdd-tools-error.test.ts +21 -0
  1328. package/sdk/src/sdd-tools-error.ts +65 -0
  1329. package/sdk/src/sdd-tools.test.ts +472 -0
  1330. package/sdk/src/sdd-tools.ts +237 -0
  1331. package/sdk/src/sdd-transport-policy.test.ts +34 -0
  1332. package/sdk/src/sdd-transport-policy.ts +48 -0
  1333. package/sdk/src/sdd-transport.test.ts +292 -0
  1334. package/sdk/src/sdd-transport.ts +117 -0
  1335. package/sdk/src/sdk-package-compatibility.test.ts +97 -0
  1336. package/sdk/src/sdk-package-compatibility.ts +141 -0
  1337. package/sdk/src/session-runner.test.ts +164 -0
  1338. package/sdk/src/session-runner.ts +327 -0
  1339. package/sdk/src/tool-scoping.test.ts +160 -0
  1340. package/sdk/src/tool-scoping.ts +61 -0
  1341. package/sdk/src/types.ts +927 -0
  1342. package/sdk/src/workflow-agent-skills-consistency.test.ts +98 -0
  1343. package/sdk/src/workstream-name-policy.ts +24 -0
  1344. package/sdk/src/workstream-utils.ts +21 -0
  1345. package/sdk/src/ws-flag.test.ts +285 -0
  1346. package/sdk/src/ws-transport.test.ts +161 -0
  1347. package/sdk/src/ws-transport.ts +93 -0
  1348. package/sdk/tsconfig.json +20 -0
  1349. package/commands/sdd/add-backlog.md +0 -76
  1350. package/commands/sdd/add-phase.md +0 -43
  1351. package/commands/sdd/add-todo.md +0 -47
  1352. package/commands/sdd/analyze-dependencies.md +0 -34
  1353. package/commands/sdd/check-todos.md +0 -45
  1354. package/commands/sdd/code-review-fix.md +0 -52
  1355. package/commands/sdd/do.md +0 -30
  1356. package/commands/sdd/from-sdd2.md +0 -45
  1357. package/commands/sdd/insert-phase.md +0 -32
  1358. package/commands/sdd/intel.md +0 -179
  1359. package/commands/sdd/join-discord.md +0 -19
  1360. package/commands/sdd/list-phase-assumptions.md +0 -46
  1361. package/commands/sdd/list-workspaces.md +0 -19
  1362. package/commands/sdd/new-workspace.md +0 -44
  1363. package/commands/sdd/next.md +0 -26
  1364. package/commands/sdd/note.md +0 -34
  1365. package/commands/sdd/plan-milestone-gaps.md +0 -34
  1366. package/commands/sdd/plant-seed.md +0 -28
  1367. package/commands/sdd/remove-phase.md +0 -31
  1368. package/commands/sdd/remove-workspace.md +0 -26
  1369. package/commands/sdd/research-phase.md +0 -195
  1370. package/commands/sdd/scan.md +0 -26
  1371. package/commands/sdd/session-report.md +0 -19
  1372. package/commands/sdd/set-profile.md +0 -12
  1373. package/scripts/sync-upstream.sh +0 -56
  1374. package/sdd/workflows/research-phase.md +0 -82
@@ -8,13 +8,13 @@ Orchestrator coordinates, not executes. Each subagent loads the full execute-pla
8
8
 
9
9
  <runtime_compatibility>
10
10
  **Subagent spawning is runtime-specific:**
11
- - **Claude Code:** Uses `Task(subagent_type="sdd-executor", ...)` — blocks until complete, returns result
11
+ - **Claude Code:** Uses `Agent(subagent_type="sdd-executor", ...)` — blocks until complete, returns result
12
12
  - **Copilot:** Subagent spawning does not reliably return completion signals. **Default to
13
13
  sequential inline execution**: read and follow execute-plan.md directly for each plan
14
14
  instead of spawning parallel agents. Only attempt parallel spawning if the user
15
15
  explicitly requests it — and in that case, rely on the spot-check fallback in step 3
16
16
  to detect completion.
17
- - **Other runtimes:** If `Task`/`task` tool is unavailable, use sequential inline execution as the
17
+ - **Other runtimes:** If `Agent`/`agent` tool is unavailable, use sequential inline execution as the
18
18
  fallback. Check for tool availability at runtime rather than assuming based on runtime name.
19
19
 
20
20
  **Fallback rule:** If a spawned agent completes its work (commits visible, SUMMARY.md exists) but
@@ -25,7 +25,6 @@ via filesystem and git state.
25
25
 
26
26
  <required_reading>
27
27
  Read STATE.md before any operation to load project context.
28
-
29
28
  @~/.claude/sdd/references/agent-contracts.md
30
29
  @~/.claude/sdd/references/context-budget.md
31
30
  @~/.claude/sdd/references/gates.md
@@ -57,6 +56,8 @@ Parse `$ARGUMENTS` before loading any context:
57
56
  - First positional token → `PHASE_ARG`
58
57
  - Optional `--wave N` → `WAVE_FILTER`
59
58
  - Optional `--gaps-only` keeps its current meaning
59
+ - Optional `--cross-ai` → `CROSS_AI_FORCE=true` (force all plans through cross-AI execution)
60
+ - Optional `--no-cross-ai` → `CROSS_AI_DISABLED=true` (disable cross-AI for this run, overrides config and frontmatter)
60
61
 
61
62
  If `--wave` is absent, preserve the current behavior of executing all incomplete waves in the phase.
62
63
  </step>
@@ -65,27 +66,52 @@ If `--wave` is absent, preserve the current behavior of executing all incomplete
65
66
  Load all context in one call:
66
67
 
67
68
  ```bash
68
- INIT=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" init execute-phase "${PHASE_ARG}")
69
+ INIT=$(sdd-sdk query init.execute-phase "${PHASE_ARG}")
69
70
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
70
- AGENT_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-executor 2>/dev/null)
71
+ AGENT_SKILLS=$(sdd-sdk query agent-skills sdd-executor)
71
72
  ```
72
73
 
73
74
  Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
74
75
 
76
+ **Model resolution:** If `executor_model` is `"inherit"`, omit the `model=` parameter from all `Agent()` calls — do NOT pass `model="inherit"` to Agent. Omitting the `model=` parameter causes Claude Code to inherit the current orchestrator model automatically. Only set `model=` when `executor_model` is an explicit model name (e.g., `"claude-sonnet-4-6"`, `"claude-opus-4-7"`).
77
+
75
78
  **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
76
79
 
77
- Read worktree config:
80
+ Read runtime/worktree config and fail closed before any executor dispatch:
81
+
82
+ ```bash
83
+ RUNTIME=$(sdd-sdk query config-get runtime --default claude 2>/dev/null || echo "claude")
84
+ USE_WORKTREES=$(sdd-sdk query config-get workflow.use_worktrees 2>/dev/null || echo "true")
85
+ EXECUTOR_STALL_INTERVAL_MINUTES=$(sdd-sdk query config-get executor.stall_detect_interval_minutes 2>/dev/null || echo "5")
86
+ EXECUTOR_STALL_THRESHOLD_MINUTES=$(sdd-sdk query config-get executor.stall_threshold_minutes 2>/dev/null || echo "10")
87
+
88
+ if [ "$RUNTIME" = "codex" ] && [ "$USE_WORKTREES" != "false" ]; then
89
+ echo "FATAL: Codex execute-phase worktree isolation is unsupported. Set workflow.use_worktrees=false or use a runtime with Agent isolation=\"worktree\" support." >&2
90
+ exit 1
91
+ fi
92
+ ```
93
+ Codex maps subagents to `spawn_agent`, which has no direct Codex mapping for Claude Code's `isolation="worktree"` parameter. Failing closed prevents main-checkout edits while the workflow believes agents are isolated.
94
+
95
+ If the project uses git submodules, worktree isolation is unsafe **only when a plan touches a submodule path** — the executor commit protocol cannot correctly handle submodule commits inside isolated worktrees. The previous behavior unconditionally disabled worktree isolation whenever `.gitmodules` existed, which penalised every plan in a submodule project even when the plan was nowhere near a submodule. Compute submodule paths once and intersect them per-plan with the plan's declared `files_modified` frontmatter.
78
96
 
79
97
  ```bash
80
- USE_WORKTREES=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.use_worktrees 2>/dev/null || echo "true")
98
+ # Parse submodule paths from .gitmodules once (empty if no .gitmodules).
99
+ # SUBMODULE_PATHS is a newline-separated list of repo-relative paths.
100
+ if [ -f .gitmodules ]; then
101
+ SUBMODULE_PATHS=$(git config --file .gitmodules --get-regexp '^submodule\..*\.path$' 2>/dev/null | awk '{print $2}')
102
+ else
103
+ SUBMODULE_PATHS=""
104
+ fi
81
105
  ```
82
106
 
83
- When `USE_WORKTREES` is `false`, all executor agents run without `isolation="worktree"` they execute sequentially on the main working tree instead of in parallel worktrees.
107
+ `SUBMODULE_PATHS` is exported to the `execute_waves` step, where the per-plan decision actually happens (see "Per-plan worktree decision" sub-step inside `execute_waves`). The decision is per-plan because different plans in the same wave can touch different files — only plans whose paths intersect a submodule must drop worktree isolation; plans nowhere near a submodule keep parallel isolation.
108
+
109
+ When `USE_WORKTREES` (project-level) is `false`, all executor agents run without `isolation="worktree"` — they execute sequentially on the main working tree instead of in parallel worktrees. The per-plan decision below has no effect when worktrees are project-disabled.
84
110
 
85
111
  Read context window size for adaptive prompt enrichment:
86
112
 
87
113
  ```bash
88
- CONTEXT_WINDOW=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get context_window 2>/dev/null || echo "200000")
114
+ CONTEXT_WINDOW=$(sdd-sdk query config-get context_window 2>/dev/null || echo "200000")
89
115
  ```
90
116
 
91
117
  When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include richer context:
@@ -93,6 +119,12 @@ When `CONTEXT_WINDOW >= 500000` (1M-class models), subagent prompts include rich
93
119
  - Verifier agents receive all PLAN.md, SUMMARY.md, CONTEXT.md files plus REQUIREMENTS.md
94
120
  - This enables cross-phase awareness and history-aware verification
95
121
 
122
+ When `CONTEXT_WINDOW < 200000` (sub-200K models), subagent prompts are thinned to reduce static overhead:
123
+ - Executor agents omit extended deviation rule examples and checkpoint examples from inline prompt — load on-demand via @~/.claude/sdd/references/executor-examples.md
124
+ - Planner agents omit extended anti-pattern lists and specificity examples from inline prompt — load on-demand via @~/.claude/sdd/references/planner-antipatterns.md
125
+ - Core rules and decision logic remain inline; only verbose examples and edge-case lists are extracted
126
+ - This reduces executor static overhead by ~40% while preserving behavioral correctness
127
+
96
128
  **If `phase_found` is false:** Error — phase directory not found.
97
129
  **If `plan_count` is 0:** Error — no plans found in phase.
98
130
  **If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
@@ -101,7 +133,7 @@ When `parallelization` is false, plans within a wave execute sequentially.
101
133
 
102
134
  **Runtime detection for Copilot:**
103
135
  Check if the current runtime is Copilot by testing for the `@sdd-executor` agent pattern
104
- or absence of the `Task()` subagent API. If running under Copilot, force sequential inline
136
+ or absence of the `Agent()` subagent API. If running under Copilot, force sequential inline
105
137
  execution regardless of the `parallelization` setting — Copilot's subagent completion
106
138
  signals are unreliable (see `<runtime_compatibility>`). Set `COPILOT_SEQUENTIAL=true`
107
139
  internally and skip the `execute_waves` step in favor of `check_interactive_mode`'s
@@ -111,9 +143,49 @@ inline path for each plan.
111
143
  ```bash
112
144
  # REQUIRED: prevents stale auto-chain from previous --auto runs
113
145
  if [[ ! "$ARGUMENTS" =~ --auto ]]; then
114
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
146
+ sdd-sdk query config-set workflow._auto_chain_active false || true
115
147
  fi
116
148
  ```
149
+
150
+ Resolve `MVP_MODE` once via the centralized `phase.mvp-mode` query verb (precedence chain: CLI flag → ROADMAP `**Mode:** mvp` → `workflow.mvp_mode` config → false):
151
+ ```bash
152
+ MVP_FLAG_ARG=""
153
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--mvp([[:space:]]|$) ]]; then MVP_FLAG_ARG="--cli-flag"; fi
154
+ MVP_MODE=$(sdd-sdk query phase.mvp-mode "${PHASE_NUMBER}" $MVP_FLAG_ARG --pick active)
155
+ TDD_MODE=$(sdd-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
156
+ ```
157
+
158
+ <step name="safe_resume_gate">
159
+ Before trusting `STATE.md` or dispatching any executor, derive `CURRENT_PLAN_ID`
160
+ from the active incomplete plan in `INIT`, then search recent history:
161
+ ```bash
162
+ CURRENT_PLAN_ID="{phase_number}-{plan_padded}"
163
+ SUMMARY_PATH="{phase_dir}/{plan_padded}-SUMMARY.md"
164
+ PLAN_COMMITS=$(git log --oneline --grep="${CURRENT_PLAN_ID}" -30)
165
+ ```
166
+ If production commits exist and `SUMMARY.md is missing`, stop before spawning a
167
+ new executor; continuing risks duplicate work and stale `STATE.md`/ROADMAP progress.
168
+ Offer these recovery options:
169
+ - `close out manually` — inspect commits, write SUMMARY.md, then update STATE/ROADMAP.
170
+ - `re-execute from scratch` — revert or supersede partial commits before dispatch.
171
+ - `mark-and-skip` — record the anomaly and move on only with explicit confirmation.
172
+ </step>
173
+
174
+ **MVP+TDD gate.** Task-scoped enforcement runs inside plan execution (immediately before each implementation step), where `TASK_FILE`, `PLAN_ID`, and `TASK_ID` are defined. Keep the same predicate and RED-commit contract:
175
+ ```bash
176
+ if [ "$MVP_MODE" = "true" ] && [ "$TDD_MODE" = "true" ]; then
177
+ IS_BEHAVIOR_ADDING=$(sdd-sdk query task.is-behavior-adding "$TASK_FILE" --pick is_behavior_adding)
178
+ if [ "$IS_BEHAVIOR_ADDING" = "true" ]; then
179
+ RED_COMMIT=$(git log --oneline --grep="^test(${PHASE_NUMBER}-${PLAN_ID}):" -- "**/*.test.*" "**/*.spec.*" "tests/" | head -1)
180
+ if [ -z "$RED_COMMIT" ]; then
181
+ sdd-sdk query state.update last_gate_trip "${PLAN_ID}/${TASK_ID}" || true
182
+ echo "MVP+TDD GATE TRIPPED: missing RED commit for ${PLAN_ID}/${TASK_ID}"
183
+ exit 1
184
+ fi
185
+ fi
186
+ fi
187
+ ```
188
+ Pure doc-only / config-only / test-only tasks return `is_behavior_adding=false` and are exempt. See `execute-mvp-tdd.md` for the halt report format.
117
189
  </step>
118
190
 
119
191
  <step name="check_blocking_antipatterns" priority="first">
@@ -193,9 +265,33 @@ Check `branching_strategy` from init:
193
265
 
194
266
  **"none":** Skip, continue on current branch.
195
267
 
196
- **"phase" or "milestone":** Use pre-computed `branch_name` from init:
268
+ **"phase" or "milestone":** Use pre-computed `branch_name` from init.
269
+
270
+ Fork the new phase branch off `origin/HEAD` (the project's default branch), not the current HEAD — otherwise consecutive phases compound and stay unpushed (#2916). If `$BRANCH_NAME` already exists locally, reuse it as-is.
271
+
197
272
  ```bash
198
- git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
273
+ DEFAULT_BRANCH=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')
274
+ DEFAULT_BRANCH=${DEFAULT_BRANCH:-main}
275
+
276
+ if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
277
+ git switch "$BRANCH_NAME" || { echo "ERROR: Could not switch to existing branch '$BRANCH_NAME'." >&2; exit 1; }
278
+ else
279
+ if ! git fetch --quiet origin "$DEFAULT_BRANCH"; then # #2916
280
+ git show-ref --verify --quiet "refs/remotes/origin/$DEFAULT_BRANCH" \
281
+ || { echo "ERROR: fetch origin/$DEFAULT_BRANCH failed and no local copy exists. Refusing to create '$BRANCH_NAME' off current HEAD (#2916)." >&2; exit 1; }
282
+ echo "WARNING: fetch origin/$DEFAULT_BRANCH failed; using local copy as base." >&2
283
+ fi
284
+ if [ -n "$(git status --porcelain)" ]; then
285
+ echo "WARNING: Uncommitted changes will be carried onto '$BRANCH_NAME' (branched off origin/$DEFAULT_BRANCH, not previous HEAD)."
286
+ else
287
+ git switch --quiet "$DEFAULT_BRANCH" 2>/dev/null && git merge --ff-only --quiet "origin/$DEFAULT_BRANCH" 2>/dev/null || true
288
+ fi
289
+ # Pinned base + fail-fast: on success HEAD is exactly at origin/$DEFAULT_BRANCH,
290
+ # so a post-creation merge-base or "ahead-of" guard would be unreachable. The
291
+ # explicit base argument here is the single source of correctness for #2916.
292
+ git checkout -b "$BRANCH_NAME" "origin/$DEFAULT_BRANCH" \
293
+ || { echo "ERROR: Could not create '$BRANCH_NAME' from origin/$DEFAULT_BRANCH (#2916)." >&2; exit 1; }
294
+ fi
199
295
  ```
200
296
 
201
297
  All subsequent commits go to this branch. User handles merging.
@@ -208,7 +304,7 @@ Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)
208
304
 
209
305
  **Update STATE.md for phase start:**
210
306
  ```bash
211
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" state begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
307
+ sdd-sdk query state.begin-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
212
308
  ```
213
309
  This updates Status, Last Activity, Current focus, Current Position, and plan counts in STATE.md so frontmatter and body text reflect the active phase immediately.
214
310
  </step>
@@ -217,7 +313,7 @@ This updates Status, Last Activity, Current focus, Current Position, and plan co
217
313
  Load plan inventory with wave grouping in one call:
218
314
 
219
315
  ```bash
220
- PLAN_INDEX=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
316
+ PLAN_INDEX=$(sdd-sdk query phase-plan-index "${PHASE_NUMBER}")
221
317
  ```
222
318
 
223
319
  Parse JSON for: `phase`, `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `files_modified`, `task_count`, `has_summary`), `waves` (map of wave number → plan IDs), `incomplete`, `has_checkpoints`.
@@ -243,9 +339,100 @@ Report:
243
339
  ```
244
340
  </step>
245
341
 
342
+ <step name="cross_ai_delegation">
343
+ **Optional step 2.5 — Delegate plans to an external AI runtime.**
344
+
345
+ This step runs after plan discovery and before normal wave execution. It identifies plans
346
+ that should be delegated to an external AI command and executes them via stdin-based prompt
347
+ delivery. Plans handled here are removed from the execute_waves plan list so the normal
348
+ executor skips them.
349
+
350
+ **Activation logic:**
351
+
352
+ 1. If `CROSS_AI_DISABLED` is true (`--no-cross-ai` flag): skip this step entirely.
353
+ 2. If `CROSS_AI_FORCE` is true (`--cross-ai` flag): mark ALL incomplete plans for cross-AI execution.
354
+ 3. Otherwise: check each plan's frontmatter for `cross_ai: true` AND verify config
355
+ `workflow.cross_ai_execution` is `true`. Plans matching both conditions are marked for cross-AI.
356
+
357
+ ```bash
358
+ CROSS_AI_ENABLED=$(sdd-sdk query config-get workflow.cross_ai_execution 2>/dev/null || echo "false")
359
+ CROSS_AI_CMD=$(sdd-sdk query config-get workflow.cross_ai_command 2>/dev/null || echo "")
360
+ CROSS_AI_TIMEOUT=$(sdd-sdk query config-get workflow.cross_ai_timeout 2>/dev/null || echo "300")
361
+ ```
362
+
363
+ **If no plans are marked for cross-AI:** Skip to execute_waves.
364
+
365
+ **If plans are marked but `cross_ai_command` is empty:** Error — tell user to set
366
+ `workflow.cross_ai_command` via `sdd-sdk query config-set workflow.cross_ai_command "<command>"`.
367
+
368
+ **For each cross-AI plan (sequentially):**
369
+
370
+ 1. **Construct the task prompt** from the plan file:
371
+ - Extract `<objective>` and `<tasks>` sections from the PLAN.md
372
+ - Append PROJECT.md context (project name, description, tech stack)
373
+ - Format as a self-contained execution prompt
374
+
375
+ 2. **Check for dirty working tree before execution:**
376
+ ```bash
377
+ if ! git diff --quiet HEAD 2>/dev/null; then
378
+ echo "WARNING: dirty working tree detected — the external AI command may produce uncommitted changes that conflict with existing modifications"
379
+ fi
380
+ ```
381
+
382
+ 3. **Run the external command** from the project root, writing the prompt to stdin.
383
+ Never shell-interpolate the prompt — always pipe via stdin to prevent injection:
384
+ ```bash
385
+ echo "$TASK_PROMPT" | timeout "${CROSS_AI_TIMEOUT}s" ${CROSS_AI_CMD} > "$CANDIDATE_SUMMARY" 2>"$ERROR_LOG"
386
+ EXIT_CODE=$?
387
+ ```
388
+
389
+ 4. **Evaluate the result:**
390
+
391
+ **Success (exit 0 + valid summary):**
392
+ - Read `$CANDIDATE_SUMMARY` and validate it contains meaningful content
393
+ (not empty, has at least a heading and description — a valid SUMMARY.md structure)
394
+ - Write it as the plan's SUMMARY.md file
395
+ - Update STATE.md plan status to complete
396
+ - Update ROADMAP.md progress
397
+ - Mark plan as handled — skip it in execute_waves
398
+
399
+ **Failure (non-zero exit or invalid summary):**
400
+ - Display the error output and exit code
401
+ - Warn: "The external command may have left uncommitted changes or partial edits
402
+ in the working tree. Review `git status` and `git diff` before proceeding."
403
+ - Offer three choices:
404
+ - **retry** — run the same plan through cross-AI again
405
+ - **skip** — fall back to normal executor for this plan (re-add to execute_waves list)
406
+ - **abort** — stop execution entirely, preserve state for resume
407
+
408
+ 5. **After all cross-AI plans processed:** Remove successfully handled plans from the
409
+ incomplete plan list so execute_waves skips them. Any skipped-to-fallback plans remain
410
+ in the list for normal executor processing.
411
+ </step>
412
+
246
413
  <step name="execute_waves">
247
414
  Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZATION=true`, sequential if `false`.
248
415
 
416
+ **Stream-idle-timeout prevention — checkpoint heartbeats (#2410):**
417
+
418
+ Multi-plan phases can accumulate enough subagent context that the Claude API
419
+ SSE layer terminates with `Stream idle timeout - partial response received`
420
+ between a large tool_result and the next assistant turn (seen on Claude Code
421
+ + Opus 4.7 at ~200K+ cache_read). To keep the stream warm, emit short
422
+ assistant-text heartbeats — **no tool call, just a literal line** — at every
423
+ wave and plan boundary. Each heartbeat MUST start with `[checkpoint]` so
424
+ tooling and `/sdd:manager`'s background-completion handler can grep partial
425
+ transcripts. `{P}/{Q}` is the phase-wide completed/total plans counter and
426
+ increases monotonically across waves. `{status}` is `complete` (success),
427
+ `failed` (executor error), or `checkpoint` (human-gate returned).
428
+
429
+ ```
430
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} starting, {wave_plan_count} plan(s), {P}/{Q} plans done
431
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} starting ({P}/{Q} plans done)
432
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} {status} ({P}/{Q} plans done)
433
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} complete, {P}/{Q} plans done ({wave_success}/{wave_plan_count} ok)
434
+ ```
435
+
249
436
  **For each wave:**
250
437
 
251
438
  1. **Intra-wave files_modified overlap check (BEFORE spawning):**
@@ -284,7 +471,15 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
284
471
 
285
472
  2. **Describe what's being built (BEFORE spawning):**
286
473
 
287
- Read each plan's `<objective>`. Extract what's being built and why.
474
+ **First, emit the wave-start checkpoint heartbeat as a literal assistant-text
475
+ line — no tool call (#2410). Do NOT skip this even for single-plan waves; it
476
+ is required before any further reasoning or spawning:**
477
+
478
+ ```
479
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} starting, {wave_plan_count} plan(s), {P}/{Q} plans done
480
+ ```
481
+
482
+ Then read each plan's `<objective>`. Extract what's being built and why.
288
483
 
289
484
  ```
290
485
  ---
@@ -300,40 +495,55 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
300
495
  - Bad: "Executing terrain generation plan"
301
496
  - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
302
497
 
498
+ 2.5. **Per-plan worktree decision (run for each plan in this wave BEFORE its dispatch):**
499
+
500
+ Read and execute `sdd/workflows/execute-phase/steps/per-plan-worktree-gate.md` for each plan. It extracts `PLAN_FILES` from the plan's JSON, intersects against `SUBMODULE_PATHS` (with normalization, bidirectional matching, and glob-prefix handling), and sets `USE_WORKTREES_FOR_PLAN` to `false` when the plan touches a submodule path. Append `plan_id` to a `WAVE_WORKTREE_PLANS` accumulator when `USE_WORKTREES_FOR_PLAN != false`.
501
+
502
+ The dispatch branches in step 3 below MUST gate on `USE_WORKTREES_FOR_PLAN` for the current plan, not on the project-level `USE_WORKTREES`.
503
+
303
504
  3. **Spawn executor agents:**
304
505
 
506
+ **Emit a plan-start heartbeat (literal line, no tool call) immediately before
507
+ each `Agent()` dispatch (#2410):**
508
+
509
+ `[checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} starting ({P}/{Q} plans done)`
510
+
305
511
  Pass paths only — executors read files themselves with their fresh context window.
306
512
  For 200k models, this keeps orchestrator context lean (~10-15%).
307
513
  For 1M+ models (Opus 4.6, Sonnet 4.6), richer context can be passed directly.
308
514
 
309
- **Worktree mode** (`USE_WORKTREES` is not `false`):
515
+ **Worktree mode** (`USE_WORKTREES_FOR_PLAN` is not `false` — evaluated per-plan in step 2.5):
310
516
 
311
517
  Before spawning, capture the current HEAD:
312
518
  ```bash
313
519
  EXPECTED_BASE=$(git rev-parse HEAD)
520
+ DISPATCH_TS=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
521
+ EXPECTED_BRANCH=$(git rev-parse --abbrev-ref HEAD)
522
+ if [ "${USE_WORKTREES_FOR_PLAN:-true}" != "false" ] && [ -z "${WAVE_WORKTREE_MANIFEST:-}" ]; then
523
+ WAVE_WORKTREE_MANIFEST=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-wave-XXXXXX.json")
524
+ printf '{"worktrees":[]}\n' > "$WAVE_WORKTREE_MANIFEST"
525
+ export WAVE_WORKTREE_MANIFEST
526
+ fi
314
527
  ```
315
528
 
316
529
  **Sequential dispatch for parallel execution (waves with 2+ agents):**
317
- When spawning multiple agents in a wave, dispatch each `Task()` call **one at a time
318
- with `run_in_background: true`** — do NOT send all Task calls in a single message.
319
- `git worktree add` acquires an exclusive lock on `.git/config.lock`, so simultaneous
320
- calls race for this lock and fail. Sequential dispatch ensures each worktree finishes
321
- creation before the next begins (the round-trip latency of each tool call provides
322
- natural spacing), while all agents still **run in parallel** once created.
530
+ Dispatch each `Agent()` call **one at a time with `run_in_background: true`**. Do NOT
531
+ send all Agent calls in a single message: simultaneous `git worktree add` calls race
532
+ on `.git/config.lock`. Agents still run in parallel once their worktrees are created.
323
533
 
324
- ```
325
- # CORRECT: dispatch one Task() per message, each with run_in_background: true
326
- # worktrees created sequentially, agents execute in parallel
327
- #
328
- # WRONG: multiple Task() calls in a single message
329
- # → simultaneous git worktree add → .git/config.lock contention → failures
534
+ ```text
535
+ # CORRECT: one Agent() per message with run_in_background: true
536
+ # WRONG: multiple Agent() calls in one message -> .git/config.lock contention
330
537
  ```
331
538
 
332
- ```
333
- Task(
539
+ ```text
540
+ Agent(
334
541
  subagent_type="sdd-executor",
335
542
  description="Execute plan {plan_number} of phase {phase_number}",
336
- model="{executor_model}",
543
+ # Only include model= when executor_model is an explicit model name.
544
+ # When executor_model is "inherit", omit this parameter entirely so
545
+ # Claude Code inherits the orchestrator model automatically.
546
+ model="{executor_model}", # omit this line when executor_model == "inherit"
337
547
  isolation="worktree",
338
548
  prompt="
339
549
  <objective>
@@ -343,40 +553,37 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
343
553
  </objective>
344
554
 
345
555
  <worktree_branch_check>
346
- FIRST ACTION before any other work: verify this worktree's branch is based on the correct commit.
347
-
348
- Run:
556
+ FIRST ACTION: HEAD assertion MUST run before any reset/checkout. Worktrees
557
+ spawned by Claude Code's `isolation="worktree"` use the `worktree-agent-<id>`
558
+ namespace. If HEAD is on a protected ref (main/master/develop/trunk/release/*)
559
+ or detached, HALT — do NOT self-recover by force-rewinding via `git update-ref`,
560
+ that destroys concurrent commits in multi-active scenarios (#2924). Only after
561
+ Step 1 passes is `git reset --hard` safe (#2015 — affects all platforms).
349
562
  ```bash
350
- ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
351
- ```
352
-
353
- If `ACTUAL_BASE` != `{EXPECTED_BASE}` (i.e. the worktree branch was created from an older
354
- base such as `main` instead of the feature branch HEAD), hard-reset to the correct base:
355
- ```bash
356
- # Safe: this runs before any agent work, so no uncommitted changes to lose
357
- git reset --hard {EXPECTED_BASE}
358
- # Verify correction succeeded
359
- if [ "$(git rev-parse HEAD)" != "{EXPECTED_BASE}" ]; then
360
- echo "ERROR: Could not correct worktree base — aborting to prevent data loss"
563
+ HEAD_REF=$(git symbolic-ref --quiet HEAD || echo "DETACHED")
564
+ ACTUAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
565
+ if [ "$HEAD_REF" = "DETACHED" ] || echo "$ACTUAL_BRANCH" | grep -Eq '^(main|master|develop|trunk|release/.*)$'; then
566
+ echo "FATAL: worktree HEAD on '$ACTUAL_BRANCH' (expected worktree-agent-*); refusing to self-recover via 'git update-ref' (#2924)." >&2
361
567
  exit 1
362
568
  fi
569
+ if ! echo "$ACTUAL_BRANCH" | grep -Eq '^worktree-agent-[A-Za-z0-9._/-]+$'; then
570
+ echo "FATAL: worktree HEAD '$ACTUAL_BRANCH' is not in the worktree-agent-* namespace; refusing to commit (#2924)." >&2
571
+ exit 1
572
+ fi
573
+ ACTUAL_BASE=$(git merge-base HEAD {EXPECTED_BASE})
574
+ if [ "$ACTUAL_BASE" != "{EXPECTED_BASE}" ]; then
575
+ git reset --hard {EXPECTED_BASE}
576
+ [ "$(git rev-parse HEAD)" != "{EXPECTED_BASE}" ] && { echo "ERROR: could not correct worktree base"; exit 1; }
577
+ fi
363
578
  ```
364
-
365
- `reset --hard` is safe here because this is a fresh worktree with no user changes. It
366
- resets both the HEAD pointer AND the working tree to the correct base commit (#2015).
367
-
368
- If `ACTUAL_BASE` == `{EXPECTED_BASE}`: the branch base is correct, proceed immediately.
369
-
370
- This check fixes a known issue where `EnterWorktree` creates branches from
371
- `main` instead of the current feature branch HEAD (affects all platforms).
579
+ Per-commit HEAD/cwd-drift/path-guard: `agents/sdd-executor.md` steps 0/0a/0b + `references/worktree-path-safety.md` (in <execution_context>).
372
580
  </worktree_branch_check>
373
581
 
374
582
  <parallel_execution>
375
- You are running as a PARALLEL executor agent in a git worktree.
376
- Use --no-verify on all git commits to avoid pre-commit hook contention
377
- with other agents. The orchestrator validates hooks once after all agents complete.
378
- For sdd-tools commits: add --no-verify flag.
379
- For direct git commits: use git commit --no-verify -m "..."
583
+ You are running as a PARALLEL executor agent in a git worktree. Worktree path safety (cwd-drift, absolute-path guards) is in `worktree-path-safety.md` (loaded below).
584
+ Run `git commit` normally hooks run by default. Do NOT pass `--no-verify`
585
+ unless the orchestrator surfaces `workflow.worktree_skip_hooks=true` in this
586
+ prompt; silent bypass violates project CLAUDE.md guidance (#2924).
380
587
 
381
588
  IMPORTANT: Do NOT modify STATE.md or ROADMAP.md. execute-plan.md
382
589
  auto-detects worktree mode (`.git` is a file, not a directory) and skips
@@ -388,6 +595,7 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
388
595
  only (STATE.md and ROADMAP.md are excluded automatically). Do NOT skip or defer
389
596
  this commit — the orchestrator force-removes the worktree after you return, and
390
597
  any uncommitted SUMMARY.md will be permanently lost (#2070).
598
+ REQUIRED ORDER: Write SUMMARY.md → commit → only then any narration. No text between Write and commit (truncation risk; #2070 rescue is not primary defense).
391
599
  </parallel_execution>
392
600
 
393
601
  <execution_context>
@@ -395,6 +603,8 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
395
603
  @~/.claude/sdd/templates/summary.md
396
604
  @~/.claude/sdd/references/checkpoints.md
397
605
  @~/.claude/sdd/references/tdd.md
606
+ @~/.claude/sdd/references/worktree-path-safety.md
607
+ ${CONTEXT_WINDOW < 200000 ? '' : '@~/.claude/sdd/references/executor-examples.md'}
398
608
  </execution_context>
399
609
 
400
610
  <files_to_read>
@@ -431,18 +641,23 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
431
641
  )
432
642
  ```
433
643
 
434
- **Sequential mode** (`USE_WORKTREES` is `false`):
644
+ Immediately after each worktree `Agent()` spawn returns metadata, atomically append `{agent_id, worktree_path, branch, expected_base}` to `WAVE_WORKTREE_MANIFEST`. If any field is missing, stop and ask for recovery instead of scanning all agent worktrees.
645
+
646
+ > **ORCHESTRATOR RULE — CODEX RUNTIME**: After calling Agent() above to spawn executor agent(s), stop working on this task immediately. Do not read more files, edit code, or run tests related to this task while the subagent is active. Wait for the subagent to return its result. This prevents duplicate work, conflicting edits, and wasted context. Only resume when the subagent result is available.
647
+
648
+ **Sequential mode** (`USE_WORKTREES_FOR_PLAN` is `false` — either project-level `USE_WORKTREES=false`, or per-plan submodule intersection forced it false in step 2.5):
435
649
 
436
- Omit `isolation="worktree"` from the Task call. Replace the `<parallel_execution>` block with:
650
+ Omit `isolation="worktree"` from the Agent call. Replace the `<parallel_execution>` block with:
437
651
 
438
652
  ```
439
653
  <sequential_execution>
440
654
  You are running as a SEQUENTIAL executor agent on the main working tree.
441
655
  Use normal git commits (with hooks). Do NOT use --no-verify.
656
+ REQUIRED ORDER: Write SUMMARY.md → commit → only then any narration. No text between Write and commit (truncation risk; #2070 rescue is not primary defense).
442
657
  </sequential_execution>
443
658
  ```
444
659
 
445
- The sequential mode Task prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
660
+ The sequential mode Agent prompt uses the same structure as worktree mode but with these differences in success_criteria — since there is only one agent writing at a time, there are no shared-file conflicts:
446
661
 
447
662
  ```
448
663
  <success_criteria>
@@ -454,11 +669,21 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
454
669
  </success_criteria>
455
670
  ```
456
671
 
457
- When worktrees are disabled, execute plans **one at a time within each wave** (sequential) regardless of the `PARALLELIZATION` setting multiple agents writing to the same working tree concurrently would cause conflicts.
672
+ When worktrees are disabled for a plan (per-plan or project-level), that plan's executor runs on the main working tree. If **any** plan in the current wave dropped to sequential mode, execute the affected plan(s) **one at a time** to avoid concurrent writes to the main working tree — plans in the same wave that retained worktree isolation can still run in parallel alongside the sequential ones, but two non-worktree plans in the same wave must serialize. When the project-level `USE_WORKTREES=false`, all plans in the wave serialize regardless of the `PARALLELIZATION` setting.
458
673
 
459
674
  4. **Wait for all agents in wave to complete.**
460
675
 
461
- **Completion signal fallback (Copilot and runtimes where Task() may not return):**
676
+ **Plan-complete heartbeat (#2410):** as each executor returns (or is verified
677
+ via spot-check below), emit one line — `complete` advances `{P}`, `failed`
678
+ and `checkpoint` do not but still warm the stream:
679
+
680
+ ```
681
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} complete ({P}/{Q} plans done)
682
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} failed ({P}/{Q} plans done)
683
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} plan {plan_id} checkpoint ({P}/{Q} plans done)
684
+ ```
685
+
686
+ **Completion signal fallback (Copilot and runtimes where Agent() may not return):**
462
687
 
463
688
  If a spawned agent does not return a completion signal but appears to have finished
464
689
  its work, do NOT block indefinitely. Instead, verify completion via spot-checks:
@@ -467,6 +692,7 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
467
692
  # For each plan in this wave, check if the executor finished:
468
693
  SUMMARY_EXISTS=$(test -f "{phase_dir}/{plan_number}-{plan_padded}-SUMMARY.md" && echo "true" || echo "false")
469
694
  COMMITS_FOUND=$(git log --oneline --all --grep="{phase_number}-{plan_padded}" --since="1 hour ago" | head -1)
695
+ COMMITS_SINCE_DISPATCH=$(git log "${EXPECTED_BRANCH}" --since="${DISPATCH_TS}" --oneline | head -1)
470
696
  ```
471
697
 
472
698
  **If SUMMARY.md exists AND commits are found:** The agent completed successfully —
@@ -477,46 +703,75 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
477
703
  activity. If commits are still appearing, wait longer. If no activity, report
478
704
  the plan as failed and route to the failure handler in step 6.
479
705
 
480
- **This fallback applies automatically to all runtimes.** Claude Code's Task() normally
481
- returns synchronously, but the fallback ensures resilience if it doesn't.
706
+ **Configurable stall surveillance (#3212):** Every `${EXECUTOR_STALL_INTERVAL_MINUTES}`
707
+ minutes while waiting, inspect `git log "${EXPECTED_BRANCH}" --since="${DISPATCH_TS}"`
708
+ for activity. If no completion signal, no SUMMARY.md, and no expected-branch
709
+ commits appear for `${EXECUTOR_STALL_THRESHOLD_MINUTES}` minutes, pause and
710
+ ask for one recovery path: `continue waiting`, `kill and retry`, or
711
+ `kill and switch to inline execution`.
482
712
 
483
- 5. **Post-wave hook validation (parallel mode only):**
713
+ **This fallback applies automatically to all runtimes.** Claude Code's Agent() normally
714
+ returns synchronously, but the fallback ensures resilience if it doesn't.
484
715
 
485
- When agents committed with `--no-verify`, run pre-commit hooks once after the wave:
716
+ 5. **Post-wave hook validation (parallel mode only):** Hooks run on every executor commit by default (#2924); this post-wave run only fires when `workflow.worktree_skip_hooks=true` opted out of per-commit hooks:
486
717
  ```bash
487
- # Run project's pre-commit hooks on the current state
488
- git diff --cached --quiet || git stash # stash any unstaged changes
489
- git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed review before continuing"
718
+ SKIP_HOOKS=$(sdd-sdk query config-get workflow.worktree_skip_hooks 2>/dev/null || echo "false")
719
+ if [ "$SKIP_HOOKS" = "true" ]; then
720
+ # Stash uncommitted changes under a named ref so we always pop (bare `git stash` strands them on hook/script failure). #3542: `refs/stash` is shared across worktrees, so this helper runs ONLY in the orchestrator's main checkout after all wave worktrees have been merged + removed; executors are forbidden from running any `git stash` subcommand (see `<destructive_git_prohibition>` in `agents/sdd-executor.md`).
721
+ STASHED=false
722
+ if (! git diff --quiet || ! git diff --cached --quiet) && git stash push -u -m "sdd-post-wave-hook-$$" >/dev/null 2>&1; then STASHED=true; fi
723
+ git hook run pre-commit 2>&1 || echo "⚠ Pre-commit hooks failed — review before continuing"
724
+ [ "$STASHED" = "true" ] && (git stash pop >/dev/null 2>&1 || echo "⚠ Could not pop sdd-post-wave-hook stash — recover manually")
725
+ fi
490
726
  ```
491
727
  If hooks fail: report the failure and ask "Fix hook issues now?" or "Continue to next wave?"
492
728
 
493
729
  5.5. **Worktree cleanup (when `isolation="worktree"` was used):**
494
730
 
731
+ **Standard wave contract:** Each wave's worktrees merge to main via the templated path below before the next wave's worktrees fork. The cleanup loop runs once per wave at the end of the wave lifecycle. Worktrees created in wave N must be fully removed before wave N+1 forks new ones.
732
+
733
+ **Cross-wave dependency deviation (supported execution mode):** When the orchestrator legitimately deviates from the standard wave model — for example, a phase with cross-wave plan dependencies that requires custom inter-worktree base-update merges (e.g., `merge: bring 09-01 + 09-02 into 09-03 base`) — the cleanup loop below is NOT automatically re-entered for those custom merges. The deviation path produces correct final history but bypasses this loop, leaving `worktree-agent-*` directories in place. Use the **cleanup-tail snippet** below to remove any residual worktrees after such a deviation.
734
+
495
735
  When executor agents ran in worktree isolation, their commits land on temporary branches in separate working trees. After the wave completes, merge these changes back and clean up:
496
736
 
737
+ **Manifest source of truth (#3384):** Cleanup consumes the `WAVE_WORKTREE_MANIFEST` created and populated during executor dispatch in step 3. Do not recreate or truncate it here.
738
+
739
+ Prefer the bounded helper, which validates branch identity, expected base, deletion
740
+ diffs, merge result, and worktree removal before deleting the temporary branch.
741
+ If the helper reports a blocked cleanup, resolve the reported manifest entry and
742
+ rerun the same command. Do not fall back to broad worktree discovery.
743
+
497
744
  ```bash
498
- # List worktrees created by this wave's agents
499
- WORKTREES=$(git worktree list --porcelain | grep "^worktree " | grep -v "$(pwd)$" | sed 's/^worktree //')
745
+ [ -n "${WAVE_WORKTREE_MANIFEST:-}" ] && [ -f "$WAVE_WORKTREE_MANIFEST" ] || {
746
+ echo "BLOCKED: missing WAVE_WORKTREE_MANIFEST; refusing broad worktree cleanup (#3384)." >&2
747
+ exit 1
748
+ }
749
+
750
+ # Guard: pin cleanup back to the primary worktree and fail on branch drift (#3174).
751
+ PRIMARY_WT=$(git worktree list --porcelain | awk '/^worktree /{print substr($0,10); exit}')
752
+ if [ -z "$PRIMARY_WT" ]; then
753
+ echo "FATAL: could not resolve primary worktree before cleanup" >&2
754
+ exit 1
755
+ fi
756
+ if [ -n "$PRIMARY_WT" ] && [ "$(pwd -P 2>/dev/null)" != "$(cd "$PRIMARY_WT" 2>/dev/null && pwd -P)" ]; then echo "⚠ Orchestrator CWD drifted to $(pwd) — pinning to $PRIMARY_WT before worktree cleanup (#3174)"; cd "$PRIMARY_WT" || { echo "FATAL: cannot cd to primary worktree $PRIMARY_WT" >&2; exit 1; }; fi
757
+ ORCH_BRANCH=$(git rev-parse --abbrev-ref HEAD)
758
+ [ -z "${EXPECTED_BRANCH:-}" ] || [ "$ORCH_BRANCH" = "$EXPECTED_BRANCH" ] || { echo "FATAL: orchestrator on '$ORCH_BRANCH' but expected '$EXPECTED_BRANCH' before worktree cleanup — refusing to merge (#3174-class drift)" >&2; exit 1; }
500
759
 
501
- for WT in $WORKTREES; do
502
- # Get the branch name for this worktree
760
+ if command -v sdd-sdk >/dev/null 2>&1; then
761
+ sdd-sdk query worktree.cleanup-wave --manifest "$WAVE_WORKTREE_MANIFEST" || exit 1
762
+ else
763
+ echo "WARN: sdd-sdk unavailable; using manifest-scoped shell fallback (#3384)." >&2
764
+ WT_PATHS_FILE=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-paths-XXXXXX")
765
+ node -e 'const fs=require("fs");const p=process.env.WAVE_WORKTREE_MANIFEST;try{if(!p)throw new Error("WAVE_WORKTREE_MANIFEST is unset");if(!fs.existsSync(p))throw new Error("manifest does not exist");const s=fs.readFileSync(p,"utf8");if(!s.trim())throw new Error("manifest is empty");const j=JSON.parse(s);for(const w of j.worktrees||[])if(w.worktree_path)console.log(w.worktree_path)}catch(e){console.error(`ERROR: cannot read worktree manifest ${p||"(unset)"}: ${e.message}`);process.exit(1)}' > "$WT_PATHS_FILE" || { echo "BLOCKED: cannot read WAVE_WORKTREE_MANIFEST; refusing cleanup (#3384)." >&2; exit 1; }
766
+ while IFS= read -r WT; do
767
+ [ -z "$WT" ] && continue
503
768
  WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
504
769
  if [ -n "$WT_BRANCH" ] && [ "$WT_BRANCH" != "HEAD" ]; then
505
770
  CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
506
-
507
- # --- Orchestrator file protection (#1756) ---
508
- # Snapshot orchestrator-owned files BEFORE merge. If the worktree
509
- # branch outlived a milestone transition, its versions of STATE.md
510
- # and ROADMAP.md are stale. Main always wins for these files.
511
771
  STATE_BACKUP=$(mktemp)
512
772
  ROADMAP_BACKUP=$(mktemp)
513
- git show HEAD:.planning/STATE.md > "$STATE_BACKUP" 2>/dev/null || true
514
- git show HEAD:.planning/ROADMAP.md > "$ROADMAP_BACKUP" 2>/dev/null || true
515
-
516
- # Snapshot list of files on main BEFORE merge to detect resurrections
517
- PRE_MERGE_FILES=$(git ls-files .planning/)
518
-
519
- # Pre-merge deletion check: warn if the worktree branch deletes tracked files
773
+ [ -f .planning/STATE.md ] && cp .planning/STATE.md "$STATE_BACKUP" || true
774
+ [ -f .planning/ROADMAP.md ] && cp .planning/ROADMAP.md "$ROADMAP_BACKUP" || true
520
775
  DELETIONS=$(git diff --diff-filter=D --name-only HEAD..."$WT_BRANCH" 2>/dev/null || true)
521
776
  if [ -n "$DELETIONS" ]; then
522
777
  echo "BLOCKED: Worktree branch $WT_BRANCH contains file deletions: $DELETIONS"
@@ -524,15 +779,23 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
524
779
  rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
525
780
  continue
526
781
  fi
527
-
528
- # Merge the worktree branch into the current branch
529
- git merge "$WT_BRANCH" --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
782
+ git merge "$WT_BRANCH" --no-ff --no-edit -m "chore: merge executor worktree ($WT_BRANCH)" 2>&1 || {
530
783
  echo "⚠ Merge conflict from worktree $WT_BRANCH — resolve manually"
784
+ echo " STATE.md backup: $STATE_BACKUP"
785
+ echo " ROADMAP.md backup: $ROADMAP_BACKUP"
786
+ echo " Restore with: cp \$STATE_BACKUP .planning/STATE.md && cp \$ROADMAP_BACKUP .planning/ROADMAP.md"
787
+ break
788
+ }
789
+ MERGE_DEL_COUNT=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -vc '^\.planning/' || true)
790
+ if [ "$MERGE_DEL_COUNT" -gt 5 ] && [ "${ALLOW_BULK_DELETE:-0}" != "1" ]; then
791
+ MERGE_DELETIONS=$(git diff --diff-filter=D --name-only HEAD~1 HEAD 2>/dev/null | grep -v '^\.planning/' || true)
792
+ echo "⚠ BLOCKED: Merge of $WT_BRANCH deleted $MERGE_DEL_COUNT files outside .planning/ — reverting to protect repository integrity (#2384)"
793
+ echo "$MERGE_DELETIONS"
794
+ echo " If these deletions are intentional, re-run with ALLOW_BULK_DELETE=1"
795
+ git reset --hard HEAD~1 2>/dev/null || true
531
796
  rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
532
797
  continue
533
- }
534
-
535
- # Restore orchestrator-owned files (main always wins)
798
+ fi
536
799
  if [ -s "$STATE_BACKUP" ]; then
537
800
  cp "$STATE_BACKUP" .planning/STATE.md
538
801
  fi
@@ -540,101 +803,119 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
540
803
  cp "$ROADMAP_BACKUP" .planning/ROADMAP.md
541
804
  fi
542
805
  rm -f "$STATE_BACKUP" "$ROADMAP_BACKUP"
543
-
544
- # Detect files deleted on main but re-added by worktree merge
545
- # (e.g., archived phase directories that were intentionally removed)
806
+ # Detect files deleted on main but re-added by worktree merge (#2501).
546
807
  DELETED_FILES=$(git diff --diff-filter=A --name-only HEAD~1 -- .planning/ 2>/dev/null || true)
547
808
  for RESURRECTED in $DELETED_FILES; do
548
- # Check if this file was NOT in main's pre-merge tree
549
- if ! echo "$PRE_MERGE_FILES" | grep -qxF "$RESURRECTED"; then
809
+ WAS_DELETED=$(git log --follow --diff-filter=D --name-only --format="" HEAD~1 -- "$RESURRECTED" 2>/dev/null | grep -c . || true)
810
+ if [ "${WAS_DELETED:-0}" -gt 0 ]; then
550
811
  git rm -f "$RESURRECTED" 2>/dev/null || true
551
812
  fi
552
813
  done
553
-
554
- # Amend merge commit with restored files if any changed
555
814
  if ! git diff --quiet .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || \
556
815
  [ -n "$DELETED_FILES" ]; then
557
- # Only amend the commit with .planning/ files if commit_docs is enabled (#1783)
558
- COMMIT_DOCS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get commit_docs 2>/dev/null || echo "true")
816
+ COMMIT_DOCS=$(sdd-sdk query config-get commit_docs 2>/dev/null || echo "true")
559
817
  if [ "$COMMIT_DOCS" != "false" ]; then
560
818
  git add .planning/STATE.md .planning/ROADMAP.md 2>/dev/null || true
561
819
  git commit --amend --no-edit 2>/dev/null || true
562
820
  fi
563
821
  fi
564
-
565
- # Safety net: commit any uncommitted SUMMARY.md before force-removing the worktree.
566
- # This guards against executors that skipped the git_commit_metadata step (#2070).
567
- UNCOMMITTED_SUMMARY=$(git -C "$WT" ls-files --modified --others --exclude-standard -- "*SUMMARY.md" 2>/dev/null || true)
568
- if [ -n "$UNCOMMITTED_SUMMARY" ]; then
569
- echo " SUMMARY.md was not committed by executor — committing now to prevent data loss"
570
- git -C "$WT" add -- "*SUMMARY.md" 2>/dev/null || true
571
- git -C "$WT" commit --no-verify -m "docs(recovery): rescue uncommitted SUMMARY.md before worktree removal (#2070)" 2>/dev/null || true
572
- # Re-merge the recovery commit
573
- git merge "$WT_BRANCH" --no-edit -m "chore: merge rescued SUMMARY.md from executor worktree ($WT_BRANCH)" 2>/dev/null || true
822
+ # Safety net: rescue uncommitted SUMMARY.md before worktree removal (#2070, #2838).
823
+ while IFS= read -r SUMMARY; do
824
+ [ -z "$SUMMARY" ] && continue
825
+ REL_PATH="${SUMMARY#$WT/}"
826
+ if [ ! -f "$REL_PATH" ] || ! cmp -s "$SUMMARY" "$REL_PATH"; then
827
+ mkdir -p "$(dirname "$REL_PATH")"
828
+ cp "$SUMMARY" "$REL_PATH"
829
+ echo " Rescued $REL_PATH from worktree before removal"
830
+ fi
831
+ done < <(find "$WT/.planning" -name "*SUMMARY.md" 2>/dev/null)
832
+ REMOVE_OK=false
833
+ if git worktree remove "$WT" --force; then
834
+ REMOVE_OK=true
835
+ else
836
+ WT_NAME=$(basename "$WT")
837
+ if [ -f ".git/worktrees/${WT_NAME}/locked" ]; then
838
+ echo "⚠ Worktree $WT is locked — attempting to unlock and retry"
839
+ git worktree unlock "$WT" 2>/dev/null || true
840
+ if git worktree remove "$WT" --force; then
841
+ REMOVE_OK=true
842
+ else
843
+ echo "⚠ Residual worktree at $WT — manual cleanup required after session exits:"
844
+ echo " git worktree unlock \"$WT\" && git worktree remove \"$WT\" --force && git branch -D \"$WT_BRANCH\""
845
+ fi
846
+ else
847
+ echo "⚠ Residual worktree at $WT (remove failed) — investigate manually"
848
+ fi
849
+ fi
850
+ if [ "$REMOVE_OK" = "true" ]; then
851
+ git branch -D "$WT_BRANCH" 2>/dev/null || true
852
+ else
853
+ echo "⚠ Keeping branch $WT_BRANCH because worktree removal failed (#3384)"
574
854
  fi
855
+ fi
856
+ done < "$WT_PATHS_FILE"
857
+ fi
858
+ ```
859
+
860
+ **Cleanup-tail snippet (use after any wave whose merges did not flow through the templated path above):**
575
861
 
576
- # Remove the worktree
577
- git worktree remove "$WT" --force 2>/dev/null || true
862
+ If the orchestrator deviated from the standard wave merge path (e.g., custom inter-worktree base-update merges with `merge: bring …` style messages), run this snippet after the custom merges are complete. It reads only `WAVE_WORKTREE_MANIFEST`; do not discover unrelated `worktree-agent-*` worktrees.
578
863
 
579
- # Delete the temporary branch
864
+ ```bash
865
+ # Cleanup-tail: pin orchestrator CWD to primary worktree before cleanup-tail (#3174).
866
+ PRIMARY_WT=$(git worktree list --porcelain | awk '/^worktree /{print substr($0,10); exit}')
867
+ if [ -n "$PRIMARY_WT" ] && [ "$(pwd -P 2>/dev/null)" != "$(cd "$PRIMARY_WT" 2>/dev/null && pwd -P)" ]; then echo "⚠ Orchestrator CWD drifted to $(pwd) — pinning to $PRIMARY_WT before cleanup-tail (#3174)"; cd "$PRIMARY_WT" || { echo "FATAL: cannot cd to primary worktree $PRIMARY_WT" >&2; exit 1; }; fi
868
+ # Cleanup-tail: remove residual agent worktrees after a cross-wave-dependency deviation.
869
+ # Uses only the current wave manifest to avoid touching unrelated active agents (#3384).
870
+ WT_PATHS_FILE=$(mktemp "${TMPDIR:-/tmp}/sdd-worktree-paths-XXXXXX")
871
+ node -e 'const fs=require("fs");const p=process.env.WAVE_WORKTREE_MANIFEST;try{if(!p)throw new Error("WAVE_WORKTREE_MANIFEST is unset");if(!fs.existsSync(p))throw new Error("manifest does not exist");const s=fs.readFileSync(p,"utf8");if(!s.trim())throw new Error("manifest is empty");const j=JSON.parse(s);for(const w of j.worktrees||[])if(w.worktree_path)console.log(w.worktree_path)}catch(e){console.error(`ERROR: cannot read worktree manifest ${p||"(unset)"}: ${e.message}`);process.exit(1)}' > "$WT_PATHS_FILE" || { echo "BLOCKED: cannot read WAVE_WORKTREE_MANIFEST; refusing cleanup (#3384)." >&2; exit 1; }
872
+ while IFS= read -r WT; do
873
+ [ -z "$WT" ] && continue
874
+ WT_BRANCH=$(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null)
875
+ [ -z "$WT_BRANCH" ] || [ "$WT_BRANCH" = "HEAD" ] && continue
876
+ echo "Cleaning up residual worktree: $WT (branch: $WT_BRANCH)"
877
+ git worktree unlock "$WT" 2>/dev/null || true
878
+ if ! git worktree remove "$WT" --force; then
879
+ WT_NAME=$(basename "$WT")
880
+ if [ -f ".git/worktrees/${WT_NAME}/locked" ]; then
881
+ echo "⚠ Worktree $WT is locked — unlock failed; manual cleanup required:"
882
+ echo " git worktree unlock \"$WT\" && git worktree remove \"$WT\" --force && git branch -D \"$WT_BRANCH\""
883
+ else
884
+ echo "⚠ Residual worktree at $WT — remove failed; manual cleanup required"
885
+ fi
886
+ else
580
887
  git branch -D "$WT_BRANCH" 2>/dev/null || true
581
888
  fi
582
- done
889
+ done < "$WT_PATHS_FILE"
890
+ git worktree prune
583
891
  ```
584
892
 
585
- **If `workflow.use_worktrees` is `false`:** Agents ran on the main working tree — skip this step entirely.
893
+ **When to skip step 5.5:**
586
894
 
587
- **If no worktrees found:** Skip silently — agents may have been spawned without worktree isolation.
895
+ **If no plan in this wave used worktree isolation** (project-level `USE_WORKTREES=false` OR every plan in the wave had `USE_WORKTREES_FOR_PLAN=false` i.e. `WAVE_WORKTREE_PLANS` from step 2.5 is empty): all agents ran on the main working tree — skip this step entirely.
588
896
 
589
- 5.6. **Post-merge test gate (parallel mode only):**
897
+ **If the orchestrator merged via custom messages (cross-wave-dependency deviation):** the templated cleanup loop above was not triggered for those merges. Run the cleanup-tail snippet above instead. After the snippet completes, proceed to step 5.6.
590
898
 
591
- After merging all worktrees in a wave, run the project's test suite to catch
592
- cross-plan integration issues that individual worktree self-checks cannot detect
593
- (e.g., conflicting type definitions, removed exports, import changes).
899
+ **If at least one plan used worktrees but others did not:** still run this cleanup — it iterates over actual `git worktree list` output and only merges back the worktrees that were created, leaving sequential plans' commits on the main tree untouched.
594
900
 
595
- This addresses the Generator self-evaluation blind spot identified in Anthropic's
596
- harness engineering research: agents reliably report Self-Check: PASSED even when
597
- merging their work creates failures.
901
+ **If no worktrees found at runtime:** Skip silently agents may have been spawned without worktree isolation, or the orchestrator already cleaned them up.
598
902
 
599
- ```bash
600
- # Detect test runner and run quick smoke test (timeout: 5 minutes)
601
- TEST_EXIT=0
602
- timeout 300 bash -c '
603
- if [ -f "package.json" ]; then
604
- npm test 2>&1
605
- elif [ -f "Cargo.toml" ]; then
606
- cargo test 2>&1
607
- elif [ -f "go.mod" ]; then
608
- go test ./... 2>&1
609
- elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
610
- python -m pytest -x -q --tb=short 2>&1 || uv run python -m pytest -x -q --tb=short 2>&1
611
- else
612
- echo "⚠ No test runner detected — skipping post-merge test gate"
613
- exit 0
614
- fi
615
- '
616
- TEST_EXIT=$?
617
- if [ "${TEST_EXIT}" -eq 0 ]; then
618
- echo "✓ Post-merge test gate passed — no cross-plan conflicts"
619
- elif [ "${TEST_EXIT}" -eq 124 ]; then
620
- echo "⚠ Post-merge test gate timed out after 5 minutes"
621
- else
622
- echo "✗ Post-merge test gate failed (exit code ${TEST_EXIT})"
623
- WAVE_FAILURE_COUNT=$((WAVE_FAILURE_COUNT + 1))
624
- fi
625
- ```
903
+ 5.6. **Post-merge build & test gate:**
626
904
 
627
- **If `TEST_EXIT` is 0 (pass):** `✓ Post-merge test gate: {N} tests passed no cross-plan conflicts` → continue to orchestrator tracking update.
905
+ After merging all worktrees in a wave (parallel mode), or after the last plan completes
906
+ (serial mode), run a build and then the project's test suite to catch cross-plan
907
+ integration issues that individual worktree self-checks cannot detect (e.g., conflicting
908
+ type definitions, removed exports, import changes, link errors).
628
909
 
629
- **If `TEST_EXIT` is 124 (timeout):** Log warning, treat as non-blocking, continue. Tests may need a longer budget or manual run.
910
+ This addresses the Generator self-evaluation blind spot identified in Anthropic's
911
+ harness engineering research: agents reliably report Self-Check: PASSED even when
912
+ merging their work creates failures.
630
913
 
631
- **If `TEST_EXIT` is non-zero (test failure):** Increment `WAVE_FAILURE_COUNT` to track
632
- cumulative failures across waves. Subsequent waves should report:
633
- `⚠ Note: ${WAVE_FAILURE_COUNT} prior wave(s) had test failures`
914
+ Read and execute `sdd/workflows/execute-phase/steps/post-merge-gate.md`.
634
915
 
635
- 5.7. **Post-wave shared artifact update (worktree mode only, skip if tests failed):**
916
+ 5.7. **Post-wave shared artifact update (when at least one plan used worktrees, skip if tests failed):**
636
917
 
637
- When executor agents ran with `isolation="worktree"`, they skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once.
918
+ When **any** executor agent in this wave ran with `isolation="worktree"`, that agent skipped STATE.md and ROADMAP.md updates to avoid last-merge-wins overwrites. The orchestrator is the single writer for these files. After worktrees are merged back, update shared artifacts once for every completed plan in the wave (worktree-mode plans **and** sequential plans that ran on the main tree but deferred to the orchestrator for tracking writes).
638
919
 
639
920
  **Only update tracking when tests passed (TEST_EXIT=0).**
640
921
  If tests failed or timed out, skip the tracking update — plans should
@@ -646,12 +927,12 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
646
927
  if [ "${TEST_EXIT}" -eq 0 ]; then
647
928
  # Update ROADMAP plan progress for each completed plan in this wave
648
929
  for plan_id in {completed_plan_ids}; do
649
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" roadmap update-plan-progress "${PHASE_NUMBER}" "${plan_id}" "complete"
930
+ sdd-sdk query roadmap.update-plan-progress "${PHASE_NUMBER}" "${plan_id}" "complete"
650
931
  done
651
932
 
652
933
  # Only commit tracking files if they actually changed
653
934
  if ! git diff --quiet .planning/ROADMAP.md .planning/STATE.md 2>/dev/null; then
654
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-${PHASE_NUMBER}): update tracking after wave ${N}" --files .planning/ROADMAP.md .planning/STATE.md
935
+ sdd-sdk query commit "docs(phase-${PHASE_NUMBER}): update tracking after wave ${N}" --files .planning/ROADMAP.md .planning/STATE.md
655
936
  fi
656
937
  elif [ "${TEST_EXIT}" -eq 124 ]; then
657
938
  echo "⚠ Skipping tracking update — test suite timed out. Plans remain in-progress. Run tests manually to confirm."
@@ -662,7 +943,7 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
662
943
 
663
944
  Where `WAVE_PLAN_IDS` is the space-separated list of plan IDs that completed in this wave.
664
945
 
665
- **If `workflow.use_worktrees` is `false`:** Sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
946
+ **If no plan in this wave used worktrees** (project-level `USE_WORKTREES=false` OR `WAVE_WORKTREE_PLANS` is empty): sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
666
947
 
667
948
  5.8. **Handle test gate failures (when `WAVE_FAILURE_COUNT > 0`):**
668
949
 
@@ -695,6 +976,15 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
695
976
 
696
977
  6. **Report completion — spot-check claims first:**
697
978
 
979
+ **Wave-close heartbeat (#2410):** after spot-checks finish (pass or fail),
980
+ before the `## Wave {N} Complete` summary, emit as a literal line:
981
+
982
+ ```
983
+ [checkpoint] phase {PHASE_NUMBER} wave {N}/{M} complete, {P}/{Q} plans done ({wave_success}/{wave_plan_count} ok)
984
+ ```
985
+
986
+
987
+
698
988
  For each SUMMARY.md:
699
989
  - Verify first 2 files from `key-files.created` exist on disk
700
990
  - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
@@ -715,53 +1005,52 @@ Execute each selected wave in sequence. Within a wave: parallel if `PARALLELIZAT
715
1005
  ---
716
1006
  ```
717
1007
 
718
- - Bad: "Wave 2 complete. Proceeding to Wave 3."
719
- - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
720
-
721
1008
  7. **Handle failures:**
722
-
723
- **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a SDD or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 5 (SUMMARY.md exists, git commits present, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
724
-
725
- For real failures: report which plan failed → ask "Continue?" or "Stop?" if continue, dependent plans may also fail. If stop, partial completion report.
1009
+ **Step 7.0 — classify before branching (#3095):**
1010
+ ```bash
1011
+ CLASS_JSON=$(sdd-sdk query agent.classify-failure -- "$AGENT_RETURN_BODY")
1012
+ CLASS=$(echo "$CLASS_JSON" | jq -r '.class')
1013
+ SENTINEL=$(echo "$CLASS_JSON" | jq -r '.sentinel // empty')
1014
+ RETRY_AFTER=$(echo "$CLASS_JSON" | jq -r '.retryAfterSeconds // empty')
1015
+ if [ -n "$RETRY_AFTER" ]; then RETRY_HINT=" Provider hinted retry-after: ${RETRY_AFTER}s"; else RETRY_HINT=""; fi
1016
+ ```
1017
+ One classifier branch handles sentinels across Claude/Copilot/Codex/Gemini. Reference: `docs/research/provider-rate-limit-signals.md`.
1018
+ **Step 7.1 — `class == "quota-exceeded"`:**
1019
+ Do not offer "retry now". Run step-5 spot-check first; if SUMMARY.md is missing but commits exist, route to safe-resume (`state.verify-against-disk`) instead of immediate redispatch.
1020
+ ```text
1021
+ ⚠ Plan {plan_id} terminated by provider quota / rate limit
1022
+ Runtime sentinel: {SENTINEL}
1023
+ {RETRY_HINT}
1024
+ Partial commits on worktree branch: {N}
1025
+ SUMMARY.md present: {yes|no}
1026
+ 1. Wait for quota reset, then resume (recommended)
1027
+ 2. Switch to a different runtime / model and resume
1028
+ 3. Abort phase and report partial state
1029
+ ```
1030
+ Re-run `/sdd:execute-phase` after quota reset for Option 1.
1031
+ **Step 7.2 — `class == "classify-handoff-bug"`:**
1032
+ If error contains `classifyHandoffIfNeeded is not defined`, treat as Claude runtime bug. Run the same step-5 spot-checks; PASS => treat as success, FAIL => fall through.
1033
+ **Step 7.3 — `class == "unknown-failure"`:**
1034
+ Report failed plan and ask Continue/Stop; continuing may cascade into dependent plan failures.
726
1035
 
727
1036
  7b. **Pre-wave dependency check (waves 2+ only):**
728
-
729
- Before spawning wave N+1, for each plan in the upcoming wave:
730
- ```bash
731
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" verify key-links {phase_dir}/{plan}-PLAN.md
732
- ```
733
-
734
- If any key-link from a PRIOR wave's artifact fails verification:
735
-
736
- ## Cross-Plan Wiring Gap
737
-
738
- | Plan | Link | From | Expected Pattern | Status |
739
- |------|------|------|-----------------|--------|
740
- | {plan} | {via} | {from} | {pattern} | NOT FOUND |
741
-
742
- Wave {N} artifacts may not be properly wired. Options:
743
- 1. Investigate and fix before continuing
744
- 2. Continue (may cause cascading failures in wave {N+1})
745
-
746
- Key-links referencing files in the CURRENT (upcoming) wave are skipped.
747
-
1037
+ Before wave N+1, run `sdd-sdk query verify.key-links {phase_dir}/{plan}-PLAN.md` for each upcoming plan.
1038
+ If any PRIOR-wave artifact link fails, present:
1039
+ - `## Cross-Plan Wiring Gap` with plan/link/from/pattern rows
1040
+ - Options: investigate+fix before continue, or continue with cascade risk
1041
+ Skip key-links that reference files in the CURRENT (upcoming) wave.
748
1042
  8. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
749
-
750
1043
  9. **Proceed to next wave.**
751
1044
  </step>
752
-
753
1045
  <step name="checkpoint_handling">
754
1046
  Plans with `autonomous: false` require user interaction.
755
-
756
1047
  **Auto-mode checkpoint handling:**
757
-
758
- Read auto-advance config (chain flag + user preference):
1048
+ Read auto-advance config (chain flag OR user preference — same boolean as `check.auto-mode`):
759
1049
  ```bash
760
- AUTO_CHAIN=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
761
- AUTO_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
1050
+ AUTO_MODE=$(sdd-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
762
1051
  ```
763
1052
 
764
- When executor returns a checkpoint AND (`AUTO_CHAIN` is `"true"` OR `AUTO_CFG` is `"true"`):
1053
+ When executor returns a checkpoint AND `AUTO_MODE` is `true`:
765
1054
  - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
766
1055
  - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
767
1056
  - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
@@ -819,7 +1108,7 @@ After all waves:
819
1108
 
820
1109
  **Security gate check:**
821
1110
  ```bash
822
- SECURITY_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
1111
+ SECURITY_CFG=$(sdd-sdk query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
823
1112
  SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
824
1113
  ```
825
1114
 
@@ -829,21 +1118,74 @@ If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
829
1118
  Include in the next-steps routing output:
830
1119
  ```
831
1120
  ⚠ Security enforcement enabled — run before advancing:
832
- /sdd-secure-phase {PHASE} ${SDD_WS}
1121
+ /sdd:secure-phase {PHASE} ${SDD_WS}
833
1122
  ```
834
1123
 
835
1124
  If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
836
1125
  ```
837
1126
  ⚠ Security gate: {threats_open} threats open
838
- /sdd-secure-phase {PHASE} — resolve before advancing
1127
+ /sdd:secure-phase {PHASE} — resolve before advancing
1128
+ ```
1129
+ </step>
1130
+
1131
+ <step name="tdd_review_checkpoint">
1132
+ **Optional step — TDD collaborative review.**
1133
+
1134
+ ```bash
1135
+ TDD_MODE=$(sdd-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
1136
+ ```
1137
+
1138
+ **Skip if `TDD_MODE` is `false`.**
1139
+
1140
+ When `TDD_MODE` is `true`, check whether any completed plans in this phase have `type: tdd` in their frontmatter:
1141
+
1142
+ ```bash
1143
+ TDD_PLANS=$(grep -rl "^type: tdd" "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1144
+ ```
1145
+
1146
+ **If `TDD_PLANS` > 0:** Insert end-of-phase collaborative review checkpoint.
1147
+
1148
+ 1. Collect all SUMMARY.md files for TDD plans
1149
+ 2. For each TDD plan summary, verify the RED/GREEN/REFACTOR gate sequence:
1150
+ - RED gate: A failing test commit exists (`test(...)` commit with MUST-fail evidence)
1151
+ - GREEN gate: An implementation commit exists (`feat(...)` commit making tests pass)
1152
+ - REFACTOR gate: Optional cleanup commit (`refactor(...)` commit, tests still pass)
1153
+ 3. If any TDD plan is missing the RED or GREEN gate commits, flag it:
1154
+ ```
1155
+ ⚠ TDD gate violation: Plan {plan_id} missing {RED|GREEN} phase commit.
1156
+ Expected commit pattern: test({phase}-{plan}): ... → feat({phase}-{plan}): ...
1157
+ ```
1158
+ 4. Present collaborative review summary:
1159
+ ```
1160
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1161
+ TDD REVIEW — Phase {X}
1162
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1163
+
1164
+ TDD Plans: {TDD_PLANS} | Gate violations: {count}
1165
+
1166
+ | Plan | RED | GREEN | REFACTOR | Status |
1167
+ |------|-----|-------|----------|--------|
1168
+ | {id} | ✓ | ✓ | ✓ | Pass |
1169
+ | {id} | ✓ | ✗ | — | FAIL |
1170
+ ```
1171
+
1172
+ **Escalation under MVP+TDD.** When `MVP_MODE=true` AND `TDD_MODE=true`, the review verdict escalates from advisory to **blocking**: missing RED or GREEN gate commits prevent marking the phase complete.
1173
+ ```text
1174
+ Phase blocked: {N} TDD plan(s) violate the RED→GREEN gate sequence under MVP+TDD.
1175
+ Resolve and re-run /sdd execute-phase, or override with
1176
+ /sdd execute-phase {phase} --force-mvp-gate to ship anyway.
839
1177
  ```
1178
+ `--force-mvp-gate` is the escape hatch (documented, not yet implemented). Policy is:
1179
+ - `MVP_MODE=true` AND `TDD_MODE=true`: violations are **blocking** unless explicitly overridden.
1180
+ - otherwise: violations are advisory/non-blocking and are surfaced for review.
1181
+ The verifier agent (step `verify_phase_goal`) still checks TDD discipline in both cases.
840
1182
  </step>
841
1183
 
842
1184
  <step name="handle_partial_wave_execution">
843
1185
  If `WAVE_FILTER` was used, re-run plan discovery after execution:
844
1186
 
845
1187
  ```bash
846
- POST_PLAN_INDEX=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase-plan-index "${PHASE_NUMBER}")
1188
+ POST_PLAN_INDEX=$(sdd-sdk query phase-plan-index "${PHASE_NUMBER}")
847
1189
  ```
848
1190
 
849
1191
  Apply the same "incomplete" filtering rules as earlier:
@@ -861,8 +1203,8 @@ Apply the same "incomplete" filtering rules as earlier:
861
1203
 
862
1204
  Selected wave finished successfully. This phase still has incomplete plans, so phase-level verification and completion were intentionally skipped.
863
1205
 
864
- /sdd-execute-phase {phase} ${SDD_WS} # Continue remaining waves
865
- /sdd-execute-phase {phase} --wave {next} ${SDD_WS} # Run the next wave explicitly
1206
+ /sdd:execute-phase {phase} ${SDD_WS} # Continue remaining waves
1207
+ /sdd:execute-phase {phase} --wave {next} ${SDD_WS} # Run the next wave explicitly
866
1208
  ```
867
1209
 
868
1210
  **If no incomplete plans remain after the selected wave finishes:**
@@ -875,14 +1217,14 @@ Selected wave finished successfully. This phase still has incomplete plans, so p
875
1217
 
876
1218
  **Config gate:**
877
1219
  ```bash
878
- CODE_REVIEW_ENABLED=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.code_review 2>/dev/null || echo "true")
1220
+ CODE_REVIEW_ENABLED=$(sdd-sdk query config-get workflow.code_review 2>/dev/null || echo "true")
879
1221
  ```
880
1222
 
881
1223
  If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
882
1224
 
883
1225
  **Invoke review:**
884
1226
  ```
885
- Skill(skill="sdd:code-review", args="${PHASE_NUMBER}")
1227
+ Skill(skill="sdd-code-review", args="${PHASE_NUMBER}")
886
1228
  ```
887
1229
 
888
1230
  **Check results using deterministic path (not glob):**
@@ -895,7 +1237,7 @@ REVIEW_STATUS=$(sed -n '/^---$/,/^---$/p' "$REVIEW_FILE" | grep "^status:" | hea
895
1237
  If REVIEW_STATUS is not "clean" and not "skipped" and not empty, display:
896
1238
  ```
897
1239
  Code review found issues. Consider running:
898
- /sdd-code-review-fix ${PHASE_NUMBER}
1240
+ /sdd:code-review ${PHASE_NUMBER} --fix
899
1241
  ```
900
1242
 
901
1243
  **Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to next step. Review failures must never block execution.
@@ -918,7 +1260,7 @@ fi
918
1260
 
919
1261
  **2. Find parent UAT file:**
920
1262
  ```bash
921
- PARENT_INFO=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" find-phase "${PARENT_PHASE}" --raw)
1263
+ PARENT_INFO=$(sdd-sdk query find-phase "${PARENT_PHASE}" --raw)
922
1264
  # Extract directory from PARENT_INFO JSON, then find UAT file in that directory
923
1265
  ```
924
1266
 
@@ -949,7 +1291,7 @@ mv .planning/debug/{slug}.md .planning/debug/resolved/
949
1291
 
950
1292
  **6. Commit updated artifacts:**
951
1293
  ```bash
952
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
1294
+ sdd-sdk query commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
953
1295
  ```
954
1296
  </step>
955
1297
 
@@ -976,16 +1318,27 @@ Collect all unique test file paths into `REGRESSION_FILES`.
976
1318
  **Step 3: Run regression tests (if any found)**
977
1319
 
978
1320
  ```bash
979
- # Detect test runner and run prior phase tests
980
- if [ -f "package.json" ]; then
981
- npm test 2>&1
982
- elif [ -f "Cargo.toml" ]; then
983
- cargo test 2>&1
984
- elif [ -f "go.mod" ]; then
985
- go test ./... 2>&1
986
- elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
987
- python -m pytest ${REGRESSION_FILES} -q --tb=short 2>&1
1321
+ # Resolve test command: project config > Makefile > language sniff
1322
+ REG_TEST_CMD=$(sdd-sdk query config-get workflow.test_command --default "" 2>/dev/null || true)
1323
+ if [ -z "$REG_TEST_CMD" ]; then
1324
+ if [ -f "Makefile" ] && grep -q "^test:" Makefile; then
1325
+ REG_TEST_CMD="make test"
1326
+ elif [ -f "Justfile" ] || [ -f "justfile" ]; then
1327
+ REG_TEST_CMD="just test"
1328
+ elif [ -f "package.json" ]; then
1329
+ REG_TEST_CMD="npm test"
1330
+ elif [ -f "Cargo.toml" ]; then
1331
+ REG_TEST_CMD="cargo test"
1332
+ elif [ -f "go.mod" ]; then
1333
+ REG_TEST_CMD="go test ./..."
1334
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
1335
+ REG_TEST_CMD="python -m pytest ${REGRESSION_FILES} -q --tb=short"
1336
+ else
1337
+ REG_TEST_CMD="true"
1338
+ fi
988
1339
  fi
1340
+ # Detect test runner and run prior phase tests
1341
+ eval "$REG_TEST_CMD" 2>&1
989
1342
  ```
990
1343
 
991
1344
  **Step 4: Report results**
@@ -1022,7 +1375,7 @@ build/types pass because TypeScript types come from config, not the live databas
1022
1375
  **Run after execution completes but BEFORE verification marks success.**
1023
1376
 
1024
1377
  ```bash
1025
- SCHEMA_DRIFT=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" verify schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1378
+ SCHEMA_DRIFT=$(sdd-sdk query verify.schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1026
1379
  ```
1027
1380
 
1028
1381
  Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
@@ -1081,15 +1434,26 @@ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use Ask
1081
1434
  **If user selects option 3:** Stop execution. Report partial completion.
1082
1435
  </step>
1083
1436
 
1437
+ <step name="codebase_drift_gate">
1438
+ Post-execution structural drift detection (#2003). Non-blocking by contract:
1439
+ any internal error here MUST fall through to `verify_phase_goal`. The phase
1440
+ is never failed by this gate.
1441
+
1442
+ Load and follow the full step spec from
1443
+ `sdd/workflows/execute-phase/steps/codebase-drift-gate.md` —
1444
+ covers the SDK call, JSON contract, `warn` vs `auto-remap` branches, mapper
1445
+ spawn template, and the two `workflow.drift_*` config keys.
1446
+ </step>
1447
+
1084
1448
  <step name="verify_phase_goal">
1085
1449
  Verify phase achieved its GOAL, not just completed tasks.
1086
1450
 
1087
1451
  ```bash
1088
- VERIFIER_SKILLS=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-verifier 2>/dev/null)
1452
+ VERIFIER_SKILLS=$(sdd-sdk query agent-skills sdd-verifier)
1089
1453
  ```
1090
1454
 
1091
1455
  ```
1092
- Task(
1456
+ Agent(
1093
1457
  description="Verify phase {phase_number} goal achievement",
1094
1458
  prompt="Verify phase {phase_number} goal achievement.
1095
1459
  Phase directory: {phase_dir}
@@ -1116,6 +1480,8 @@ ${VERIFIER_SKILLS}",
1116
1480
  )
1117
1481
  ```
1118
1482
 
1483
+ > **ORCHESTRATOR RULE — CODEX RUNTIME**: After calling Agent() above, stop working on this task immediately. Do not read more files, edit code, or run tests related to this task while the subagent is active. Wait for the subagent to return its result. This prevents duplicate work, conflicting edits, and wasted context. Only resume when the subagent result is available.
1484
+
1119
1485
  Read status:
1120
1486
  ```bash
1121
1487
  grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
@@ -1124,8 +1490,8 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
1124
1490
  | Status | Action |
1125
1491
  |--------|--------|
1126
1492
  | `passed` | → update_roadmap |
1127
- | `human_needed` | Present items for human testing, get approval or feedback |
1128
- | `gaps_found` | Present gap summary, offer `/sdd-plan-phase {phase} --gaps ${SDD_WS}` |
1493
+ | `human_needed` | Persist and present human testing items; keep phase pending until verification reruns as `passed` |
1494
+ | `gaps_found` | Present gap summary, offer `/sdd:plan-phase {phase} --gaps ${SDD_WS}` |
1129
1495
 
1130
1496
  **If human_needed:**
1131
1497
 
@@ -1168,7 +1534,7 @@ blocked: 0
1168
1534
 
1169
1535
  Commit the file:
1170
1536
  ```bash
1171
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
1537
+ sdd-sdk query commit "test({phase_num}): persist human verification items as UAT" --files "{phase_dir}/{phase_num}-HUMAN-UAT.md"
1172
1538
  ```
1173
1539
 
1174
1540
  **Step B: Present to user:**
@@ -1180,12 +1546,12 @@ All automated checks passed. {N} items need human testing:
1180
1546
 
1181
1547
  {From VERIFICATION.md human_verification section}
1182
1548
 
1183
- Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd-progress` and `/sdd-audit-uat`.
1549
+ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd:progress` and `/sdd:audit-uat`.
1184
1550
 
1185
1551
  "approved" → continue | Report issues → gap closure
1186
1552
  ```
1187
1553
 
1188
- **If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/sdd-verify-work` on it.
1554
+ **If user says "approved":** Proceed to `update_roadmap`. The HUMAN-UAT.md file persists with `status: partial` and will surface in future progress checks until the user runs `/sdd:verify-work` on it.
1189
1555
 
1190
1556
  **If user reports issues:** Proceed to gap closure as currently implemented.
1191
1557
 
@@ -1200,24 +1566,24 @@ Items saved to `{phase_num}-HUMAN-UAT.md` — they will appear in `/sdd-progress
1200
1566
  {Gap summaries from VERIFICATION.md}
1201
1567
 
1202
1568
  ---
1203
- ## ▶ Next Up
1569
+ ## ▶ Next Up — [${PROJECT_CODE}] ${PROJECT_TITLE}
1204
1570
 
1205
1571
  `/clear` then:
1206
1572
 
1207
- `/sdd-plan-phase {X} --gaps ${SDD_WS}`
1573
+ `/sdd:plan-phase {X} --gaps ${SDD_WS}`
1208
1574
 
1209
1575
  Also: `cat {phase_dir}/{phase_num}-VERIFICATION.md` — full report
1210
- Also: `/sdd-verify-work {X} ${SDD_WS}` — manual testing first
1576
+ Also: `/sdd:verify-work {X} ${SDD_WS}` — manual testing first
1211
1577
  ```
1212
1578
 
1213
- Gap closure cycle: `/sdd-plan-phase {X} --gaps ${SDD_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/sdd-execute-phase {X} --gaps-only ${SDD_WS}` → verifier re-runs.
1579
+ Gap closure cycle: `/sdd:plan-phase {X} --gaps ${SDD_WS}` reads VERIFICATION.md → creates gap plans with `gap_closure: true` → user runs `/sdd:execute-phase {X} --gaps-only ${SDD_WS}` → verifier re-runs.
1214
1580
  </step>
1215
1581
 
1216
1582
  <step name="update_roadmap">
1217
1583
  **Mark phase complete and update all tracking files:**
1218
1584
 
1219
1585
  ```bash
1220
- COMPLETION=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" phase complete "${PHASE_NUMBER}")
1586
+ COMPLETION=$(sdd-sdk query phase.complete "${PHASE_NUMBER}")
1221
1587
  ```
1222
1588
 
1223
1589
  The CLI handles:
@@ -1236,11 +1602,11 @@ Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`, `warnings
1236
1602
 
1237
1603
  {list each warning}
1238
1604
 
1239
- These items are tracked and will appear in `/sdd-progress` and `/sdd-audit-uat`.
1605
+ These items are tracked and will appear in `/sdd:progress` and `/sdd:audit-uat`.
1240
1606
  ```
1241
1607
 
1242
1608
  ```bash
1243
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1609
+ sdd-sdk query commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
1244
1610
  ```
1245
1611
  </step>
1246
1612
 
@@ -1252,7 +1618,7 @@ entries from the completed phase to the global learnings store at `~/.sdd/knowle
1252
1618
 
1253
1619
  **Check config gate:**
1254
1620
  ```bash
1255
- GL_ENABLED=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get features.global_learnings --raw 2>/dev/null || echo "false")
1621
+ GL_ENABLED=$(sdd-sdk query config-get features.global_learnings --raw 2>/dev/null || echo "false")
1256
1622
  ```
1257
1623
 
1258
1624
  **If `GL_ENABLED` is not `true`:** Skip this step entirely (feature disabled by default).
@@ -1262,11 +1628,43 @@ GL_ENABLED=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get features.glob
1262
1628
  1. Check if LEARNINGS.md exists in the phase directory (use the `phase_dir` value from init context)
1263
1629
  2. If found, copy to global store:
1264
1630
  ```bash
1265
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" learnings copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
1631
+ sdd-sdk query learnings.copy 2>/dev/null || echo "⚠ Learnings copy failed — continuing"
1266
1632
  ```
1267
1633
  Copy failure must NOT block phase completion.
1268
1634
  </step>
1269
1635
 
1636
+ <step name="close_phase_todos">
1637
+ **Auto-close pending todos tagged for this phase (#2433).**
1638
+
1639
+ This step runs AFTER `update_roadmap` marks the phase complete. It moves any pending todos that carry `resolves_phase: <current-phase-number>` to the completed directory.
1640
+
1641
+ ```bash
1642
+ PHASE_NUM="${PHASE_NUMBER}"
1643
+ PENDING_DIR=".planning/todos/pending"
1644
+ COMPLETED_DIR=".planning/todos/completed"
1645
+ mkdir -p "$COMPLETED_DIR"
1646
+
1647
+ CLOSED=()
1648
+ for TODO_FILE in "$PENDING_DIR"/*.md; do
1649
+ [ -f "$TODO_FILE" ] || continue
1650
+ # Extract resolves_phase from YAML frontmatter (first --- block only)
1651
+ RP=$(awk '/^---/{c++;next} c==1 && /^resolves_phase:/{print $2;exit} c==2{exit}' "$TODO_FILE" 2>/dev/null || true)
1652
+ if [ "$RP" = "$PHASE_NUM" ] || [ "$RP" = "\"$PHASE_NUM\"" ]; then
1653
+ mv "$TODO_FILE" "$COMPLETED_DIR/"
1654
+ CLOSED+=("$(basename "$TODO_FILE")")
1655
+ fi
1656
+ done
1657
+
1658
+ if [ ${#CLOSED[@]} -gt 0 ]; then
1659
+ sdd-sdk query commit "docs(phase-${PHASE_NUMBER}): auto-close ${#CLOSED[@]} todo(s) resolved by this phase" --files .planning/todos/completed/ .planning/STATE.md|| true
1660
+ echo "◆ Closed ${#CLOSED[@]} todo(s) resolved by Phase ${PHASE_NUMBER}:"
1661
+ for f in "${CLOSED[@]}"; do echo " ✓ $f"; done
1662
+ fi
1663
+ ```
1664
+
1665
+ **If no todos have `resolves_phase: <this-phase>`:** Skip silently — this step is always additive and never blocks phase completion.
1666
+ </step>
1667
+
1270
1668
  <step name="update_project_md">
1271
1669
  **Evolve PROJECT.md to reflect phase completion (prevents planning document drift — #956):**
1272
1670
 
@@ -1283,7 +1681,7 @@ PROJECT.md falls behind silently over multiple phases.
1283
1681
  5. Commit the change:
1284
1682
 
1285
1683
  ```bash
1286
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
1684
+ sdd-sdk query commit "docs(phase-{X}): evolve PROJECT.md after phase completion" --files .planning/PROJECT.md
1287
1685
  ```
1288
1686
 
1289
1687
  **Skip this step if** `.planning/PROJECT.md` does not exist.
@@ -1291,7 +1689,7 @@ node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(phase-{X}): evolve PROJE
1291
1689
 
1292
1690
  <step name="offer_next">
1293
1691
 
1294
- **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/sdd-plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
1692
+ **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/sdd:plan-phase {X} --gaps`). No additional routing needed — skip auto-advance.
1295
1693
 
1296
1694
  **No-transition check (spawned by auto-advance chain):**
1297
1695
 
@@ -1319,13 +1717,12 @@ STOP. Do not proceed to auto-advance or transition.
1319
1717
  **Auto-advance detection:**
1320
1718
 
1321
1719
  1. Parse `--auto` flag from $ARGUMENTS
1322
- 2. Read both the chain flag and user preference (chain flag already synced in init step):
1720
+ 2. Read consolidated auto-mode (`active` = chain flag OR user preference; chain flag already synced in init step):
1323
1721
  ```bash
1324
- AUTO_CHAIN=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
1325
- AUTO_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
1722
+ AUTO_MODE=$(sdd-sdk query check auto-mode --pick active 2>/dev/null || echo "false")
1326
1723
  ```
1327
1724
 
1328
- **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true (AND verification passed with no gaps):**
1725
+ **If `--auto` flag present OR `AUTO_MODE` is true (AND verification passed with no gaps):**
1329
1726
 
1330
1727
  ```
1331
1728
  ╔══════════════════════════════════════════╗
@@ -1334,11 +1731,11 @@ STOP. Do not proceed to auto-advance or transition.
1334
1731
  ╚══════════════════════════════════════════╝
1335
1732
  ```
1336
1733
 
1337
- Execute the transition workflow inline (do NOT use Task — orchestrator context is ~10-15%, transition needs phase completion data already in context):
1734
+ Execute the transition workflow inline (do NOT use Agent — orchestrator context is ~10-15%, transition needs phase completion data already in context):
1338
1735
 
1339
1736
  Read and follow `~/.claude/sdd/workflows/transition.md`, passing through the `--auto` flag so it propagates to the next phase invocation.
1340
1737
 
1341
- **If none of `--auto`, `AUTO_CHAIN`, or `AUTO_CFG` is true:**
1738
+ **If neither `--auto` nor `AUTO_MODE` is true:**
1342
1739
 
1343
1740
  **STOP. Do not auto-advance. Do not execute transition. Do not plan next phase. Present options to the user and wait.**
1344
1741
 
@@ -1355,10 +1752,10 @@ If CONTEXT.md does **not** exist for the next phase, present:
1355
1752
  ```
1356
1753
  ## ✓ Phase {X}: {Name} Complete
1357
1754
 
1358
- /sdd-progress ${SDD_WS} — see updated roadmap
1359
- /sdd-discuss-phase {next} ${SDD_WS} — start here: discuss next phase before planning ← recommended
1360
- /sdd-plan-phase {next} ${SDD_WS} — plan next phase (skip discuss)
1361
- /sdd-execute-phase {next} ${SDD_WS} — execute next phase (skip discuss and plan)
1755
+ /sdd:progress ${SDD_WS} — see updated roadmap
1756
+ /sdd:discuss-phase {next} ${SDD_WS} — start here: discuss next phase before planning ← recommended
1757
+ /sdd:plan-phase {next} ${SDD_WS} — plan next phase (skip discuss)
1758
+ /sdd:execute-phase {next} ${SDD_WS} — execute next phase (skip discuss and plan)
1362
1759
  ```
1363
1760
 
1364
1761
  If CONTEXT.md **exists** for the next phase, present:
@@ -1366,10 +1763,10 @@ If CONTEXT.md **exists** for the next phase, present:
1366
1763
  ```
1367
1764
  ## ✓ Phase {X}: {Name} Complete
1368
1765
 
1369
- /sdd-progress ${SDD_WS} — see updated roadmap
1370
- /sdd-plan-phase {next} ${SDD_WS} — start here: plan next phase (CONTEXT.md already present) ← recommended
1371
- /sdd-discuss-phase {next} ${SDD_WS} — re-discuss next phase
1372
- /sdd-execute-phase {next} ${SDD_WS} — execute next phase (skip planning)
1766
+ /sdd:progress ${SDD_WS} — see updated roadmap
1767
+ /sdd:plan-phase {next} ${SDD_WS} — start here: plan next phase (CONTEXT.md already present) ← recommended
1768
+ /sdd:discuss-phase {next} ${SDD_WS} — re-discuss next phase
1769
+ /sdd:execute-phase {next} ${SDD_WS} — execute next phase (skip planning)
1373
1770
  ```
1374
1771
 
1375
1772
  Only suggest the commands listed above. Do not invent or hallucinate command names.
@@ -1379,7 +1776,7 @@ Only suggest the commands listed above. Do not invent or hallucinate command nam
1379
1776
 
1380
1777
  <context_efficiency>
1381
1778
  Orchestrator: ~10-15% context for 200k windows, can use more for 1M+ windows.
1382
- Subagents: fresh context each (200k-1M depending on model). No polling (Task blocks). No context bleed.
1779
+ Subagents: fresh context each (200k-1M depending on model). No polling (Agent blocks). No context bleed.
1383
1780
 
1384
1781
  For 1M+ context models, consider:
1385
1782
  - Passing richer context (code snippets, dependency outputs) directly to executors instead of just file paths
@@ -1388,6 +1785,7 @@ For 1M+ context models, consider:
1388
1785
  </context_efficiency>
1389
1786
 
1390
1787
  <failure_handling>
1788
+ - **Quota / rate-limit (any runtime — #3095):** Agent return body contains a sentinel like `usage limit`, `rate limit`, `429`, `too many requests`, `RESOURCE_EXHAUSTED`, `usage_limit_reached`. Route via `sdd-sdk query agent.classify-failure` → `class: "quota-exceeded"`. Do not offer retry-now; the right action is wait-for-reset and resume.
1391
1789
  - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not SDD. Spot-check (SUMMARY exists, commits present) → if pass, treat as success
1392
1790
  - **Agent fails mid-plan:** Missing SUMMARY.md → report, ask user how to proceed
1393
1791
  - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip
@@ -1396,7 +1794,7 @@ For 1M+ context models, consider:
1396
1794
  </failure_handling>
1397
1795
 
1398
1796
  <resumption>
1399
- Re-run `/sdd-execute-phase {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
1797
+ Re-run `/sdd:execute-phase {phase}` → discover_plans finds completed SUMMARYs → skips them → resumes from first incomplete plan → continues wave execution.
1400
1798
 
1401
1799
  STATE.md tracks: last completed plan, current wave, pending checkpoints.
1402
1800
  </resumption>