@bhargavvc/sdd-cc 1.30.1 → 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 (1392) hide show
  1. package/README.ja-JP.md +165 -129
  2. package/README.ko-KR.md +161 -123
  3. package/README.md +103 -679
  4. package/README.pt-BR.md +92 -52
  5. package/README.zh-CN.md +145 -103
  6. package/agents/sdd-advisor-researcher.md +23 -0
  7. package/agents/sdd-ai-researcher.md +133 -0
  8. package/agents/sdd-code-fixer.md +668 -0
  9. package/agents/sdd-code-reviewer.md +387 -0
  10. package/agents/sdd-codebase-mapper.md +86 -3
  11. package/agents/sdd-debug-session-manager.md +314 -0
  12. package/agents/sdd-debugger.md +157 -78
  13. package/agents/sdd-doc-classifier.md +168 -0
  14. package/agents/sdd-doc-synthesizer.md +204 -0
  15. package/agents/sdd-doc-verifier.md +217 -0
  16. package/agents/sdd-doc-writer.md +615 -0
  17. package/agents/sdd-domain-researcher.md +153 -0
  18. package/agents/sdd-eval-auditor.md +191 -0
  19. package/agents/sdd-eval-planner.md +154 -0
  20. package/agents/sdd-executor.md +283 -40
  21. package/agents/sdd-framework-selector.md +160 -0
  22. package/agents/sdd-integration-checker.md +30 -3
  23. package/agents/sdd-intel-updater.md +342 -0
  24. package/agents/sdd-nyquist-auditor.md +31 -4
  25. package/agents/sdd-pattern-mapper.md +335 -0
  26. package/agents/sdd-phase-researcher.md +254 -24
  27. package/agents/sdd-plan-checker.md +223 -18
  28. package/agents/sdd-planner.md +286 -362
  29. package/agents/sdd-project-researcher.md +28 -5
  30. package/agents/sdd-research-synthesizer.md +4 -4
  31. package/agents/sdd-roadmapper.md +14 -5
  32. package/agents/sdd-security-auditor.md +155 -0
  33. package/agents/sdd-ui-auditor.md +60 -4
  34. package/agents/sdd-ui-checker.md +11 -2
  35. package/agents/sdd-ui-researcher.md +27 -4
  36. package/agents/sdd-user-profiler.md +2 -2
  37. package/agents/sdd-verifier.md +258 -41
  38. package/bin/install.js +6862 -618
  39. package/bin/sdd-sdk.js +37 -0
  40. package/commands/sdd/add-tests.md +3 -2
  41. package/commands/sdd/ai-integration-phase.md +37 -0
  42. package/commands/sdd/audit-fix.md +34 -0
  43. package/commands/sdd/audit-milestone.md +3 -2
  44. package/commands/sdd/autonomous.md +10 -5
  45. package/commands/sdd/capture.md +62 -0
  46. package/commands/sdd/cleanup.md +7 -1
  47. package/commands/sdd/code-review.md +59 -0
  48. package/commands/sdd/complete-milestone.md +11 -4
  49. package/commands/sdd/config.md +58 -0
  50. package/commands/sdd/debug.md +23 -144
  51. package/commands/sdd/discuss-phase.md +22 -10
  52. package/commands/sdd/docs-update.md +49 -0
  53. package/commands/sdd/eval-review.md +33 -0
  54. package/commands/sdd/execute-phase.md +9 -4
  55. package/commands/sdd/explore.md +27 -0
  56. package/commands/sdd/extract-learnings.md +23 -0
  57. package/commands/sdd/fast.md +2 -1
  58. package/commands/sdd/forensics.md +3 -2
  59. package/commands/sdd/graphify.md +199 -0
  60. package/commands/sdd/health.md +12 -3
  61. package/commands/sdd/help.md +3 -1
  62. package/commands/sdd/import.md +41 -0
  63. package/commands/sdd/inbox.md +39 -0
  64. package/commands/sdd/ingest-docs.md +42 -0
  65. package/commands/sdd/manager.md +9 -3
  66. package/commands/sdd/map-codebase.md +15 -3
  67. package/commands/sdd/milestone-summary.md +1 -1
  68. package/commands/sdd/mvp-phase.md +45 -0
  69. package/commands/sdd/new-milestone.md +3 -2
  70. package/commands/sdd/new-project.md +7 -2
  71. package/commands/sdd/ns-context.md +23 -0
  72. package/commands/sdd/ns-ideate.md +24 -0
  73. package/commands/sdd/ns-manage.md +29 -0
  74. package/commands/sdd/ns-project.md +22 -0
  75. package/commands/sdd/ns-review.md +26 -0
  76. package/commands/sdd/ns-workflow.md +28 -0
  77. package/commands/sdd/pause-work.md +6 -1
  78. package/commands/sdd/phase.md +56 -0
  79. package/commands/sdd/plan-phase.md +19 -4
  80. package/commands/sdd/plan-review-convergence.md +59 -0
  81. package/commands/sdd/pr-branch.md +2 -1
  82. package/commands/sdd/profile-user.md +2 -2
  83. package/commands/sdd/progress.md +27 -5
  84. package/commands/sdd/quick.md +132 -5
  85. package/commands/sdd/resume-work.md +2 -12
  86. package/commands/sdd/review-backlog.md +4 -2
  87. package/commands/sdd/review.md +7 -3
  88. package/commands/sdd/secure-phase.md +36 -0
  89. package/commands/sdd/settings.md +2 -9
  90. package/commands/sdd/ship.md +1 -0
  91. package/commands/sdd/sketch.md +60 -0
  92. package/commands/sdd/spec-phase.md +63 -0
  93. package/commands/sdd/spike.md +57 -0
  94. package/commands/sdd/stats.md +2 -1
  95. package/commands/sdd/surface.md +129 -0
  96. package/commands/sdd/thread.md +8 -111
  97. package/commands/sdd/ui-phase.md +3 -2
  98. package/commands/sdd/ui-review.md +3 -2
  99. package/commands/sdd/ultraplan-phase.md +34 -0
  100. package/commands/sdd/undo.md +35 -0
  101. package/commands/sdd/update.md +21 -10
  102. package/commands/sdd/validate-phase.md +3 -2
  103. package/commands/sdd/verify-work.md +4 -3
  104. package/commands/sdd/workspace.md +52 -0
  105. package/commands/sdd/workstreams.md +15 -8
  106. package/hooks/dist/sdd-check-update-worker.js +116 -0
  107. package/hooks/dist/sdd-check-update.js +19 -69
  108. package/hooks/dist/sdd-context-monitor.js +43 -7
  109. package/hooks/dist/sdd-phase-boundary.sh +47 -0
  110. package/hooks/dist/sdd-prompt-guard.js +1 -0
  111. package/hooks/dist/sdd-read-guard.js +101 -0
  112. package/hooks/dist/sdd-read-injection-scanner.js +152 -0
  113. package/hooks/dist/sdd-session-state.sh +59 -0
  114. package/hooks/dist/sdd-statusline.js +439 -21
  115. package/hooks/dist/sdd-update-banner.js +134 -0
  116. package/hooks/dist/sdd-validate-commit.sh +57 -0
  117. package/hooks/dist/sdd-workflow-guard.js +2 -2
  118. package/hooks/lib/git-cmd.js +150 -0
  119. package/hooks/sdd-check-update-worker.js +116 -0
  120. package/hooks/sdd-check-update.js +64 -0
  121. package/hooks/sdd-context-monitor.js +192 -0
  122. package/hooks/sdd-phase-boundary.sh +47 -0
  123. package/hooks/sdd-prompt-guard.js +97 -0
  124. package/hooks/sdd-read-guard.js +101 -0
  125. package/hooks/sdd-read-injection-scanner.js +152 -0
  126. package/hooks/sdd-session-state.sh +59 -0
  127. package/hooks/sdd-statusline.js +537 -0
  128. package/hooks/sdd-update-banner.js +134 -0
  129. package/hooks/sdd-validate-commit.sh +57 -0
  130. package/hooks/sdd-workflow-guard.js +94 -0
  131. package/package.json +34 -9
  132. package/scripts/audit-workflow-script-paths.cjs +73 -0
  133. package/scripts/build-hooks.js +114 -9
  134. package/scripts/changeset/cli.cjs +269 -0
  135. package/scripts/changeset/github-release-notes.cjs +198 -0
  136. package/scripts/changeset/lint.cjs +110 -0
  137. package/scripts/changeset/new.cjs +137 -0
  138. package/scripts/changeset/parse.cjs +60 -0
  139. package/scripts/changeset/render.cjs +34 -0
  140. package/scripts/changeset/serialize.cjs +74 -0
  141. package/scripts/command-contract-helpers.cjs +61 -0
  142. package/scripts/diff-touches-shipped-paths.cjs +147 -0
  143. package/scripts/fix-slash-commands.cjs +106 -0
  144. package/scripts/gen-inventory-manifest.cjs +109 -0
  145. package/scripts/lint-command-contract.cjs +108 -0
  146. package/scripts/lint-descriptions.cjs +83 -0
  147. package/scripts/lint-no-source-grep-extras.cjs +81 -0
  148. package/scripts/lint-no-source-grep.cjs +174 -0
  149. package/scripts/lint-shell-command-projection-drift.cjs +57 -0
  150. package/scripts/lint-skill-deps.cjs +180 -0
  151. package/scripts/pr-template-policy.cjs +169 -0
  152. package/scripts/prompt-injection-scan.sh +3 -0
  153. package/scripts/rebrand-gsd-to-sdd.sh +222 -220
  154. package/scripts/run-tests.cjs +5 -1
  155. package/scripts/strip-prose-atrefs.cjs +106 -0
  156. package/scripts/verify-tarball-sdk-dist.sh +69 -0
  157. package/sdd/bin/check-latest-version.cjs +104 -0
  158. package/sdd/bin/lib/active-workstream-store.cjs +85 -0
  159. package/sdd/bin/lib/adr-parser.cjs +394 -0
  160. package/sdd/bin/lib/artifacts.cjs +53 -0
  161. package/sdd/bin/lib/audit.cjs +755 -0
  162. package/sdd/bin/lib/cjs-command-router-adapter.cjs +39 -0
  163. package/sdd/bin/lib/clusters.cjs +135 -0
  164. package/sdd/bin/lib/command-aliases.generated.cjs +838 -0
  165. package/sdd/bin/lib/commands.cjs +179 -107
  166. package/sdd/bin/lib/config-schema.cjs +135 -0
  167. package/sdd/bin/lib/config.cjs +313 -86
  168. package/sdd/bin/lib/context-utilization.cjs +47 -0
  169. package/sdd/bin/lib/core.cjs +1146 -391
  170. package/sdd/bin/lib/decisions.cjs +48 -0
  171. package/sdd/bin/lib/docs.cjs +270 -0
  172. package/sdd/bin/lib/drift.cjs +379 -0
  173. package/sdd/bin/lib/fallow-runner.cjs +109 -0
  174. package/sdd/bin/lib/frontmatter.cjs +389 -336
  175. package/sdd/bin/lib/gap-checker.cjs +197 -0
  176. package/sdd/bin/lib/graphify.cjs +577 -0
  177. package/sdd/bin/lib/init-command-router.cjs +70 -0
  178. package/sdd/bin/lib/init.cjs +692 -97
  179. package/sdd/bin/lib/install-profiles.cjs +572 -0
  180. package/sdd/bin/lib/installer-migration-authoring.cjs +117 -0
  181. package/sdd/bin/lib/installer-migration-report.cjs +328 -0
  182. package/sdd/bin/lib/installer-migrations/000-first-time-baseline.cjs +220 -0
  183. package/sdd/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +41 -0
  184. package/sdd/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +80 -0
  185. package/sdd/bin/lib/installer-migrations.cjs +703 -0
  186. package/sdd/bin/lib/intel.cjs +643 -0
  187. package/sdd/bin/lib/learnings.cjs +379 -0
  188. package/sdd/bin/lib/milestone.cjs +313 -252
  189. package/sdd/bin/lib/model-catalog.cjs +136 -0
  190. package/sdd/bin/lib/model-profiles.cjs +25 -68
  191. package/sdd/bin/lib/phase-command-router.cjs +96 -0
  192. package/sdd/bin/lib/phase.cjs +868 -335
  193. package/sdd/bin/lib/phases-command-router.cjs +39 -0
  194. package/sdd/bin/lib/plan-scan.cjs +138 -0
  195. package/sdd/bin/lib/planning-workspace.cjs +361 -0
  196. package/sdd/bin/lib/profile-output.cjs +197 -35
  197. package/sdd/bin/lib/profile-pipeline.cjs +1 -1
  198. package/sdd/bin/lib/review-reviewer-selection.cjs +125 -0
  199. package/sdd/bin/lib/roadmap-command-router.cjs +23 -0
  200. package/sdd/bin/lib/roadmap.cjs +416 -124
  201. package/sdd/bin/lib/runtime-homes.cjs +178 -0
  202. package/sdd/bin/lib/schema-detect.cjs +238 -0
  203. package/sdd/bin/lib/sdd2-import.cjs +511 -0
  204. package/sdd/bin/lib/secrets.cjs +33 -0
  205. package/sdd/bin/lib/security.cjs +131 -9
  206. package/sdd/bin/lib/shell-command-projection.cjs +548 -0
  207. package/sdd/bin/lib/state-command-router.cjs +100 -0
  208. package/sdd/bin/lib/state-document.cjs +12 -0
  209. package/sdd/bin/lib/state-document.generated.cjs +127 -0
  210. package/sdd/bin/lib/state.cjs +1253 -367
  211. package/sdd/bin/lib/surface.cjs +398 -0
  212. package/sdd/bin/lib/template.cjs +11 -5
  213. package/sdd/bin/lib/uat.cjs +9 -2
  214. package/sdd/bin/lib/validate-command-router.cjs +55 -0
  215. package/sdd/bin/lib/verify-command-router.cjs +34 -0
  216. package/sdd/bin/lib/verify.cjs +648 -140
  217. package/sdd/bin/lib/workstream-inventory.cjs +159 -0
  218. package/sdd/bin/lib/workstream-name-policy.cjs +33 -0
  219. package/sdd/bin/lib/workstream.cjs +78 -196
  220. package/sdd/bin/lib/worktree-safety.cjs +563 -0
  221. package/sdd/bin/sdd-tools.cjs +528 -222
  222. package/sdd/bin/verify-reapply-patches.cjs +247 -0
  223. package/sdd/contexts/dev.md +21 -0
  224. package/sdd/contexts/research.md +22 -0
  225. package/sdd/contexts/review.md +23 -0
  226. package/sdd/references/agent-contracts.md +79 -0
  227. package/sdd/references/ai-evals.md +156 -0
  228. package/sdd/references/ai-frameworks.md +186 -0
  229. package/sdd/references/artifact-types.md +131 -0
  230. package/sdd/references/autonomous-smart-discuss.md +277 -0
  231. package/sdd/references/checkpoints.md +36 -0
  232. package/sdd/references/common-bug-patterns.md +114 -0
  233. package/sdd/references/context-budget.md +85 -0
  234. package/sdd/references/continuation-format.md +30 -26
  235. package/sdd/references/debugger-philosophy.md +76 -0
  236. package/sdd/references/decimal-phase-calculation.md +5 -5
  237. package/sdd/references/doc-conflict-engine.md +91 -0
  238. package/sdd/references/domain-probes.md +125 -0
  239. package/sdd/references/execute-mvp-tdd.md +81 -0
  240. package/sdd/references/executor-examples.md +110 -0
  241. package/sdd/references/few-shot-examples/plan-checker.md +73 -0
  242. package/sdd/references/few-shot-examples/verifier.md +109 -0
  243. package/sdd/references/gate-prompts.md +100 -0
  244. package/sdd/references/gates.md +70 -0
  245. package/sdd/references/git-integration.md +9 -6
  246. package/sdd/references/git-planning-commit.md +6 -4
  247. package/sdd/references/ios-scaffold.md +123 -0
  248. package/sdd/references/mandatory-initial-read.md +2 -0
  249. package/sdd/references/model-profile-resolution.md +2 -0
  250. package/sdd/references/model-profiles.md +128 -22
  251. package/sdd/references/mvp-concepts.md +49 -0
  252. package/sdd/references/phase-argument-parsing.md +3 -3
  253. package/sdd/references/planner-antipatterns.md +89 -0
  254. package/sdd/references/planner-chunked.md +49 -0
  255. package/sdd/references/planner-gap-closure.md +62 -0
  256. package/sdd/references/planner-human-verify-mode.md +57 -0
  257. package/sdd/references/planner-mvp-mode.md +53 -0
  258. package/sdd/references/planner-reviews.md +39 -0
  259. package/sdd/references/planner-revision.md +87 -0
  260. package/sdd/references/planner-source-audit.md +73 -0
  261. package/sdd/references/planning-config.md +276 -7
  262. package/sdd/references/project-skills-discovery.md +19 -0
  263. package/sdd/references/revision-loop.md +97 -0
  264. package/sdd/references/scout-codebase.md +51 -0
  265. package/sdd/references/skeleton-template.md +48 -0
  266. package/sdd/references/sketch-interactivity.md +41 -0
  267. package/sdd/references/sketch-theme-system.md +94 -0
  268. package/sdd/references/sketch-tooling.md +45 -0
  269. package/sdd/references/sketch-variant-patterns.md +81 -0
  270. package/sdd/references/spidr-splitting.md +69 -0
  271. package/sdd/references/tdd.md +67 -0
  272. package/sdd/references/thinking-models-debug.md +44 -0
  273. package/sdd/references/thinking-models-execution.md +50 -0
  274. package/sdd/references/thinking-models-planning.md +62 -0
  275. package/sdd/references/thinking-models-research.md +50 -0
  276. package/sdd/references/thinking-models-verification.md +55 -0
  277. package/sdd/references/thinking-partner.md +96 -0
  278. package/sdd/references/ui-brand.md +4 -4
  279. package/sdd/references/universal-anti-patterns.md +63 -0
  280. package/sdd/references/user-story-template.md +58 -0
  281. package/sdd/references/verification-overrides.md +227 -0
  282. package/sdd/references/verify-mvp-mode.md +85 -0
  283. package/sdd/references/workstream-flag.md +63 -10
  284. package/sdd/references/worktree-path-safety.md +89 -0
  285. package/sdd/templates/AI-SPEC.md +246 -0
  286. package/sdd/templates/DEBUG.md +7 -2
  287. package/sdd/templates/README.md +77 -0
  288. package/sdd/templates/SECURITY.md +61 -0
  289. package/sdd/templates/VALIDATION.md +3 -3
  290. package/sdd/templates/claude-md.md +27 -4
  291. package/sdd/templates/config.json +20 -2
  292. package/sdd/templates/discovery.md +2 -2
  293. package/sdd/templates/research.md +40 -0
  294. package/sdd/templates/spec.md +307 -0
  295. package/sdd/templates/state.md +10 -2
  296. package/sdd/workflows/add-backlog.md +90 -0
  297. package/sdd/workflows/add-phase.md +12 -12
  298. package/sdd/workflows/add-tests.md +6 -3
  299. package/sdd/workflows/add-todo.md +8 -6
  300. package/sdd/workflows/ai-integration-phase.md +294 -0
  301. package/sdd/workflows/analyze-dependencies.md +96 -0
  302. package/sdd/workflows/audit-fix.md +177 -0
  303. package/sdd/workflows/audit-milestone.md +35 -18
  304. package/sdd/workflows/audit-uat.md +1 -1
  305. package/sdd/workflows/autonomous.md +202 -304
  306. package/sdd/workflows/check-todos.md +12 -10
  307. package/sdd/workflows/cleanup.md +3 -1
  308. package/sdd/workflows/code-review-fix.md +501 -0
  309. package/sdd/workflows/code-review.md +613 -0
  310. package/sdd/workflows/complete-milestone.md +115 -28
  311. package/sdd/workflows/debug.md +231 -0
  312. package/sdd/workflows/diagnose-issues.md +14 -5
  313. package/sdd/workflows/discovery-phase.md +3 -1
  314. package/sdd/workflows/discuss-phase/modes/advisor.md +175 -0
  315. package/sdd/workflows/discuss-phase/modes/all.md +28 -0
  316. package/sdd/workflows/discuss-phase/modes/analyze.md +44 -0
  317. package/sdd/workflows/discuss-phase/modes/auto.md +56 -0
  318. package/sdd/workflows/discuss-phase/modes/batch.md +52 -0
  319. package/sdd/workflows/discuss-phase/modes/chain.md +97 -0
  320. package/sdd/workflows/discuss-phase/modes/default.md +141 -0
  321. package/sdd/workflows/discuss-phase/modes/power.md +44 -0
  322. package/sdd/workflows/discuss-phase/modes/text.md +55 -0
  323. package/sdd/workflows/discuss-phase/templates/checkpoint.json +18 -0
  324. package/sdd/workflows/discuss-phase/templates/context.md +136 -0
  325. package/sdd/workflows/discuss-phase/templates/discussion-log.md +50 -0
  326. package/sdd/workflows/discuss-phase-assumptions.md +41 -20
  327. package/sdd/workflows/discuss-phase-power.md +291 -0
  328. package/sdd/workflows/discuss-phase.md +242 -792
  329. package/sdd/workflows/do.md +13 -7
  330. package/sdd/workflows/docs-update.md +1161 -0
  331. package/sdd/workflows/edit-phase.md +294 -0
  332. package/sdd/workflows/eval-review.md +155 -0
  333. package/sdd/workflows/execute-phase/steps/codebase-drift-gate.md +81 -0
  334. package/sdd/workflows/execute-phase/steps/per-plan-worktree-gate.md +94 -0
  335. package/sdd/workflows/execute-phase/steps/post-merge-gate.md +116 -0
  336. package/sdd/workflows/execute-phase.md +1062 -108
  337. package/sdd/workflows/execute-plan.md +118 -107
  338. package/sdd/workflows/explore.md +143 -0
  339. package/sdd/workflows/extract-learnings.md +242 -0
  340. package/sdd/workflows/forensics.md +17 -4
  341. package/sdd/workflows/graduation.md +195 -0
  342. package/sdd/workflows/health.md +45 -3
  343. package/sdd/workflows/help.md +265 -88
  344. package/sdd/workflows/import.md +253 -0
  345. package/sdd/workflows/inbox.md +387 -0
  346. package/sdd/workflows/ingest-docs.md +339 -0
  347. package/sdd/workflows/insert-phase.md +37 -16
  348. package/sdd/workflows/list-phase-assumptions.md +2 -2
  349. package/sdd/workflows/list-workspaces.md +3 -3
  350. package/sdd/workflows/manager.md +62 -32
  351. package/sdd/workflows/map-codebase.md +90 -24
  352. package/sdd/workflows/milestone-summary.md +6 -6
  353. package/sdd/workflows/mvp-phase.md +221 -0
  354. package/sdd/workflows/new-milestone.md +168 -20
  355. package/sdd/workflows/new-project.md +273 -47
  356. package/sdd/workflows/new-workspace.md +8 -6
  357. package/sdd/workflows/next.md +127 -4
  358. package/sdd/workflows/note.md +7 -5
  359. package/sdd/workflows/pause-work.md +79 -12
  360. package/sdd/workflows/plan-milestone-gaps.md +14 -7
  361. package/sdd/workflows/plan-phase.md +987 -62
  362. package/sdd/workflows/plan-review-convergence.md +329 -0
  363. package/sdd/workflows/plant-seed.md +145 -85
  364. package/sdd/workflows/pr-branch.md +41 -13
  365. package/sdd/workflows/profile-user.md +20 -18
  366. package/sdd/workflows/progress.md +186 -44
  367. package/sdd/workflows/quick.md +470 -58
  368. package/sdd/workflows/reapply-patches.md +390 -0
  369. package/sdd/workflows/remove-phase.md +12 -12
  370. package/sdd/workflows/remove-workspace.md +24 -7
  371. package/sdd/workflows/resume-project.md +18 -15
  372. package/sdd/workflows/review.md +242 -11
  373. package/sdd/workflows/scan.md +104 -0
  374. package/sdd/workflows/secure-phase.md +179 -0
  375. package/sdd/workflows/session-report.md +2 -2
  376. package/sdd/workflows/settings-advanced.md +579 -0
  377. package/sdd/workflows/settings-integrations.md +281 -0
  378. package/sdd/workflows/settings.md +221 -16
  379. package/sdd/workflows/ship.md +140 -13
  380. package/sdd/workflows/sketch-wrap-up.md +285 -0
  381. package/sdd/workflows/sketch.md +360 -0
  382. package/sdd/workflows/spec-phase.md +262 -0
  383. package/sdd/workflows/spike-wrap-up.md +306 -0
  384. package/sdd/workflows/spike.md +452 -0
  385. package/sdd/workflows/stats.md +20 -1
  386. package/sdd/workflows/sync-skills.md +182 -0
  387. package/sdd/workflows/thread.md +221 -0
  388. package/sdd/workflows/transition.md +44 -22
  389. package/sdd/workflows/ui-phase.md +39 -14
  390. package/sdd/workflows/ui-review.md +33 -6
  391. package/sdd/workflows/ultraplan-phase.md +198 -0
  392. package/sdd/workflows/undo.md +314 -0
  393. package/sdd/workflows/update.md +350 -29
  394. package/sdd/workflows/validate-phase.md +10 -6
  395. package/sdd/workflows/verify-phase.md +307 -18
  396. package/sdd/workflows/verify-work.md +153 -10
  397. package/sdk/dist/cli-transport.d.ts +19 -0
  398. package/sdk/dist/cli-transport.d.ts.map +1 -0
  399. package/sdk/dist/cli-transport.js +104 -0
  400. package/sdk/dist/cli-transport.js.map +1 -0
  401. package/sdk/dist/cli.d.ts +46 -0
  402. package/sdk/dist/cli.d.ts.map +1 -0
  403. package/sdk/dist/cli.js +511 -0
  404. package/sdk/dist/cli.js.map +1 -0
  405. package/sdk/dist/config.d.ts +84 -0
  406. package/sdk/dist/config.d.ts.map +1 -0
  407. package/sdk/dist/config.js +135 -0
  408. package/sdk/dist/config.js.map +1 -0
  409. package/sdk/dist/context-engine.d.ts +49 -0
  410. package/sdk/dist/context-engine.d.ts.map +1 -0
  411. package/sdk/dist/context-engine.js +142 -0
  412. package/sdk/dist/context-engine.js.map +1 -0
  413. package/sdk/dist/context-truncation.d.ts +33 -0
  414. package/sdk/dist/context-truncation.d.ts.map +1 -0
  415. package/sdk/dist/context-truncation.js +197 -0
  416. package/sdk/dist/context-truncation.js.map +1 -0
  417. package/sdk/dist/errors.d.ts +46 -0
  418. package/sdk/dist/errors.d.ts.map +1 -0
  419. package/sdk/dist/errors.js +64 -0
  420. package/sdk/dist/errors.js.map +1 -0
  421. package/sdk/dist/event-stream.d.ts +53 -0
  422. package/sdk/dist/event-stream.d.ts.map +1 -0
  423. package/sdk/dist/event-stream.js +321 -0
  424. package/sdk/dist/event-stream.js.map +1 -0
  425. package/sdk/dist/golden/capture.d.ts +15 -0
  426. package/sdk/dist/golden/capture.d.ts.map +1 -0
  427. package/sdk/dist/golden/capture.js +67 -0
  428. package/sdk/dist/golden/capture.js.map +1 -0
  429. package/sdk/dist/golden/golden-integration-covered.d.ts +6 -0
  430. package/sdk/dist/golden/golden-integration-covered.d.ts.map +1 -0
  431. package/sdk/dist/golden/golden-integration-covered.js +30 -0
  432. package/sdk/dist/golden/golden-integration-covered.js.map +1 -0
  433. package/sdk/dist/golden/golden-mutation-covered.d.ts +7 -0
  434. package/sdk/dist/golden/golden-mutation-covered.d.ts.map +1 -0
  435. package/sdk/dist/golden/golden-mutation-covered.js +17 -0
  436. package/sdk/dist/golden/golden-mutation-covered.js.map +1 -0
  437. package/sdk/dist/golden/golden-policy.d.ts +10 -0
  438. package/sdk/dist/golden/golden-policy.d.ts.map +1 -0
  439. package/sdk/dist/golden/golden-policy.js +98 -0
  440. package/sdk/dist/golden/golden-policy.js.map +1 -0
  441. package/sdk/dist/golden/init-golden-normalize.d.ts +8 -0
  442. package/sdk/dist/golden/init-golden-normalize.d.ts.map +1 -0
  443. package/sdk/dist/golden/init-golden-normalize.js +14 -0
  444. package/sdk/dist/golden/init-golden-normalize.js.map +1 -0
  445. package/sdk/dist/golden/read-only-golden-rows.d.ts +20 -0
  446. package/sdk/dist/golden/read-only-golden-rows.d.ts.map +1 -0
  447. package/sdk/dist/golden/read-only-golden-rows.js +67 -0
  448. package/sdk/dist/golden/read-only-golden-rows.js.map +1 -0
  449. package/sdk/dist/golden/registry-canonical-commands.d.ts +6 -0
  450. package/sdk/dist/golden/registry-canonical-commands.d.ts.map +1 -0
  451. package/sdk/dist/golden/registry-canonical-commands.js +30 -0
  452. package/sdk/dist/golden/registry-canonical-commands.js.map +1 -0
  453. package/sdk/dist/index.d.ts +125 -0
  454. package/sdk/dist/index.d.ts.map +1 -0
  455. package/sdk/dist/index.js +298 -0
  456. package/sdk/dist/index.js.map +1 -0
  457. package/sdk/dist/init-runner.d.ts +90 -0
  458. package/sdk/dist/init-runner.d.ts.map +1 -0
  459. package/sdk/dist/init-runner.js +613 -0
  460. package/sdk/dist/init-runner.js.map +1 -0
  461. package/sdk/dist/logger.d.ts +50 -0
  462. package/sdk/dist/logger.d.ts.map +1 -0
  463. package/sdk/dist/logger.js +70 -0
  464. package/sdk/dist/logger.js.map +1 -0
  465. package/sdk/dist/model-catalog.d.ts +31 -0
  466. package/sdk/dist/model-catalog.d.ts.map +1 -0
  467. package/sdk/dist/model-catalog.js +31 -0
  468. package/sdk/dist/model-catalog.js.map +1 -0
  469. package/sdk/dist/phase-prompt.d.ts +72 -0
  470. package/sdk/dist/phase-prompt.d.ts.map +1 -0
  471. package/sdk/dist/phase-prompt.js +213 -0
  472. package/sdk/dist/phase-prompt.js.map +1 -0
  473. package/sdk/dist/phase-runner.d.ts +145 -0
  474. package/sdk/dist/phase-runner.d.ts.map +1 -0
  475. package/sdk/dist/phase-runner.js +1206 -0
  476. package/sdk/dist/phase-runner.js.map +1 -0
  477. package/sdk/dist/plan-parser.d.ts +55 -0
  478. package/sdk/dist/plan-parser.d.ts.map +1 -0
  479. package/sdk/dist/plan-parser.js +389 -0
  480. package/sdk/dist/plan-parser.js.map +1 -0
  481. package/sdk/dist/planning-journal.d.ts +64 -0
  482. package/sdk/dist/planning-journal.d.ts.map +1 -0
  483. package/sdk/dist/planning-journal.js +88 -0
  484. package/sdk/dist/planning-journal.js.map +1 -0
  485. package/sdk/dist/planning-runtime.d.ts +67 -0
  486. package/sdk/dist/planning-runtime.d.ts.map +1 -0
  487. package/sdk/dist/planning-runtime.js +58 -0
  488. package/sdk/dist/planning-runtime.js.map +1 -0
  489. package/sdk/dist/prompt-builder.d.ts +44 -0
  490. package/sdk/dist/prompt-builder.d.ts.map +1 -0
  491. package/sdk/dist/prompt-builder.js +180 -0
  492. package/sdk/dist/prompt-builder.js.map +1 -0
  493. package/sdk/dist/prompt-sanitizer.d.ts +35 -0
  494. package/sdk/dist/prompt-sanitizer.d.ts.map +1 -0
  495. package/sdk/dist/prompt-sanitizer.js +101 -0
  496. package/sdk/dist/prompt-sanitizer.js.map +1 -0
  497. package/sdk/dist/query/active-workstream-store.d.ts +7 -0
  498. package/sdk/dist/query/active-workstream-store.d.ts.map +1 -0
  499. package/sdk/dist/query/active-workstream-store.js +56 -0
  500. package/sdk/dist/query/active-workstream-store.js.map +1 -0
  501. package/sdk/dist/query/agent-failure-classifier.d.ts +38 -0
  502. package/sdk/dist/query/agent-failure-classifier.d.ts.map +1 -0
  503. package/sdk/dist/query/agent-failure-classifier.js +83 -0
  504. package/sdk/dist/query/agent-failure-classifier.js.map +1 -0
  505. package/sdk/dist/query/audit-open.d.ts +46 -0
  506. package/sdk/dist/query/audit-open.d.ts.map +1 -0
  507. package/sdk/dist/query/audit-open.js +662 -0
  508. package/sdk/dist/query/audit-open.js.map +1 -0
  509. package/sdk/dist/query/check-auto-mode.d.ts +13 -0
  510. package/sdk/dist/query/check-auto-mode.d.ts.map +1 -0
  511. package/sdk/dist/query/check-auto-mode.js +40 -0
  512. package/sdk/dist/query/check-auto-mode.js.map +1 -0
  513. package/sdk/dist/query/check-completion.d.ts +10 -0
  514. package/sdk/dist/query/check-completion.d.ts.map +1 -0
  515. package/sdk/dist/query/check-completion.js +157 -0
  516. package/sdk/dist/query/check-completion.js.map +1 -0
  517. package/sdk/dist/query/check-decision-coverage.d.ts +33 -0
  518. package/sdk/dist/query/check-decision-coverage.d.ts.map +1 -0
  519. package/sdk/dist/query/check-decision-coverage.js +472 -0
  520. package/sdk/dist/query/check-decision-coverage.js.map +1 -0
  521. package/sdk/dist/query/check-gates.d.ts +10 -0
  522. package/sdk/dist/query/check-gates.d.ts.map +1 -0
  523. package/sdk/dist/query/check-gates.js +89 -0
  524. package/sdk/dist/query/check-gates.js.map +1 -0
  525. package/sdk/dist/query/check-ship-ready.d.ts +10 -0
  526. package/sdk/dist/query/check-ship-ready.d.ts.map +1 -0
  527. package/sdk/dist/query/check-ship-ready.js +93 -0
  528. package/sdk/dist/query/check-ship-ready.js.map +1 -0
  529. package/sdk/dist/query/check-verification-status.d.ts +10 -0
  530. package/sdk/dist/query/check-verification-status.d.ts.map +1 -0
  531. package/sdk/dist/query/check-verification-status.js +142 -0
  532. package/sdk/dist/query/check-verification-status.js.map +1 -0
  533. package/sdk/dist/query/command-aliases.generated.d.ts +31 -0
  534. package/sdk/dist/query/command-aliases.generated.d.ts.map +1 -0
  535. package/sdk/dist/query/command-aliases.generated.js +135 -0
  536. package/sdk/dist/query/command-aliases.generated.js.map +1 -0
  537. package/sdk/dist/query/command-catalog.d.ts +9 -0
  538. package/sdk/dist/query/command-catalog.d.ts.map +1 -0
  539. package/sdk/dist/query/command-catalog.js +17 -0
  540. package/sdk/dist/query/command-catalog.js.map +1 -0
  541. package/sdk/dist/query/command-definition.d.ts +19 -0
  542. package/sdk/dist/query/command-definition.d.ts.map +1 -0
  543. package/sdk/dist/query/command-definition.js +44 -0
  544. package/sdk/dist/query/command-definition.js.map +1 -0
  545. package/sdk/dist/query/command-family-handlers.d.ts +3 -0
  546. package/sdk/dist/query/command-family-handlers.d.ts.map +1 -0
  547. package/sdk/dist/query/command-family-handlers.js +94 -0
  548. package/sdk/dist/query/command-family-handlers.js.map +1 -0
  549. package/sdk/dist/query/command-manifest.d.ts +2 -0
  550. package/sdk/dist/query/command-manifest.d.ts.map +1 -0
  551. package/sdk/dist/query/command-manifest.init.d.ts +6 -0
  552. package/sdk/dist/query/command-manifest.init.d.ts.map +1 -0
  553. package/sdk/dist/query/command-manifest.init.js +23 -0
  554. package/sdk/dist/query/command-manifest.init.js.map +1 -0
  555. package/sdk/dist/query/command-manifest.js +17 -0
  556. package/sdk/dist/query/command-manifest.js.map +1 -0
  557. package/sdk/dist/query/command-manifest.non-family.d.ts +9 -0
  558. package/sdk/dist/query/command-manifest.non-family.d.ts.map +1 -0
  559. package/sdk/dist/query/command-manifest.non-family.js +59 -0
  560. package/sdk/dist/query/command-manifest.non-family.js.map +1 -0
  561. package/sdk/dist/query/command-manifest.phase.d.ts +6 -0
  562. package/sdk/dist/query/command-manifest.phase.d.ts.map +1 -0
  563. package/sdk/dist/query/command-manifest.phase.js +15 -0
  564. package/sdk/dist/query/command-manifest.phase.js.map +1 -0
  565. package/sdk/dist/query/command-manifest.phases.d.ts +7 -0
  566. package/sdk/dist/query/command-manifest.phases.d.ts.map +1 -0
  567. package/sdk/dist/query/command-manifest.phases.js +10 -0
  568. package/sdk/dist/query/command-manifest.phases.js.map +1 -0
  569. package/sdk/dist/query/command-manifest.roadmap.d.ts +6 -0
  570. package/sdk/dist/query/command-manifest.roadmap.d.ts.map +1 -0
  571. package/sdk/dist/query/command-manifest.roadmap.js +10 -0
  572. package/sdk/dist/query/command-manifest.roadmap.js.map +1 -0
  573. package/sdk/dist/query/command-manifest.state.d.ts +9 -0
  574. package/sdk/dist/query/command-manifest.state.d.ts.map +1 -0
  575. package/sdk/dist/query/command-manifest.state.js +30 -0
  576. package/sdk/dist/query/command-manifest.state.js.map +1 -0
  577. package/sdk/dist/query/command-manifest.types.d.ts +12 -0
  578. package/sdk/dist/query/command-manifest.types.d.ts.map +1 -0
  579. package/sdk/dist/query/command-manifest.types.js +2 -0
  580. package/sdk/dist/query/command-manifest.types.js.map +1 -0
  581. package/sdk/dist/query/command-manifest.validate.d.ts +6 -0
  582. package/sdk/dist/query/command-manifest.validate.d.ts.map +1 -0
  583. package/sdk/dist/query/command-manifest.validate.js +10 -0
  584. package/sdk/dist/query/command-manifest.validate.js.map +1 -0
  585. package/sdk/dist/query/command-manifest.verify.d.ts +6 -0
  586. package/sdk/dist/query/command-manifest.verify.d.ts.map +1 -0
  587. package/sdk/dist/query/command-manifest.verify.js +14 -0
  588. package/sdk/dist/query/command-manifest.verify.js.map +1 -0
  589. package/sdk/dist/query/command-static-catalog-domain.d.ts +3 -0
  590. package/sdk/dist/query/command-static-catalog-domain.d.ts.map +1 -0
  591. package/sdk/dist/query/command-static-catalog-domain.js +116 -0
  592. package/sdk/dist/query/command-static-catalog-domain.js.map +1 -0
  593. package/sdk/dist/query/command-static-catalog-foundation.d.ts +7 -0
  594. package/sdk/dist/query/command-static-catalog-foundation.d.ts.map +1 -0
  595. package/sdk/dist/query/command-static-catalog-foundation.js +98 -0
  596. package/sdk/dist/query/command-static-catalog-foundation.js.map +1 -0
  597. package/sdk/dist/query/command-topology.d.ts +32 -0
  598. package/sdk/dist/query/command-topology.d.ts.map +1 -0
  599. package/sdk/dist/query/command-topology.js +66 -0
  600. package/sdk/dist/query/command-topology.js.map +1 -0
  601. package/sdk/dist/query/commands-list.d.ts +14 -0
  602. package/sdk/dist/query/commands-list.d.ts.map +1 -0
  603. package/sdk/dist/query/commands-list.js +18 -0
  604. package/sdk/dist/query/commands-list.js.map +1 -0
  605. package/sdk/dist/query/commit.d.ts +79 -0
  606. package/sdk/dist/query/commit.d.ts.map +1 -0
  607. package/sdk/dist/query/commit.js +340 -0
  608. package/sdk/dist/query/commit.js.map +1 -0
  609. package/sdk/dist/query/config-gates.d.ts +12 -0
  610. package/sdk/dist/query/config-gates.d.ts.map +1 -0
  611. package/sdk/dist/query/config-gates.js +66 -0
  612. package/sdk/dist/query/config-gates.js.map +1 -0
  613. package/sdk/dist/query/config-mutation.d.ts +86 -0
  614. package/sdk/dist/query/config-mutation.d.ts.map +1 -0
  615. package/sdk/dist/query/config-mutation.js +518 -0
  616. package/sdk/dist/query/config-mutation.js.map +1 -0
  617. package/sdk/dist/query/config-query.d.ts +57 -0
  618. package/sdk/dist/query/config-query.d.ts.map +1 -0
  619. package/sdk/dist/query/config-query.js +208 -0
  620. package/sdk/dist/query/config-query.js.map +1 -0
  621. package/sdk/dist/query/config-schema.d.ts +36 -0
  622. package/sdk/dist/query/config-schema.d.ts.map +1 -0
  623. package/sdk/dist/query/config-schema.js +147 -0
  624. package/sdk/dist/query/config-schema.js.map +1 -0
  625. package/sdk/dist/query/decisions.d.ts +58 -0
  626. package/sdk/dist/query/decisions.d.ts.map +1 -0
  627. package/sdk/dist/query/decisions.js +161 -0
  628. package/sdk/dist/query/decisions.js.map +1 -0
  629. package/sdk/dist/query/detect-custom-files.d.ts +11 -0
  630. package/sdk/dist/query/detect-custom-files.d.ts.map +1 -0
  631. package/sdk/dist/query/detect-custom-files.js +89 -0
  632. package/sdk/dist/query/detect-custom-files.js.map +1 -0
  633. package/sdk/dist/query/detect-phase-type.d.ts +9 -0
  634. package/sdk/dist/query/detect-phase-type.d.ts.map +1 -0
  635. package/sdk/dist/query/detect-phase-type.js +124 -0
  636. package/sdk/dist/query/detect-phase-type.js.map +1 -0
  637. package/sdk/dist/query/docs-init.d.ts +26 -0
  638. package/sdk/dist/query/docs-init.d.ts.map +1 -0
  639. package/sdk/dist/query/docs-init.js +231 -0
  640. package/sdk/dist/query/docs-init.js.map +1 -0
  641. package/sdk/dist/query/fallow-audit.d.ts +44 -0
  642. package/sdk/dist/query/fallow-audit.d.ts.map +1 -0
  643. package/sdk/dist/query/fallow-audit.js +44 -0
  644. package/sdk/dist/query/fallow-audit.js.map +1 -0
  645. package/sdk/dist/query/frontmatter-mutation.d.ts +77 -0
  646. package/sdk/dist/query/frontmatter-mutation.d.ts.map +1 -0
  647. package/sdk/dist/query/frontmatter-mutation.js +317 -0
  648. package/sdk/dist/query/frontmatter-mutation.js.map +1 -0
  649. package/sdk/dist/query/frontmatter.d.ts +93 -0
  650. package/sdk/dist/query/frontmatter.d.ts.map +1 -0
  651. package/sdk/dist/query/frontmatter.js +365 -0
  652. package/sdk/dist/query/frontmatter.js.map +1 -0
  653. package/sdk/dist/query/helpers.d.ts +191 -0
  654. package/sdk/dist/query/helpers.d.ts.map +1 -0
  655. package/sdk/dist/query/helpers.js +613 -0
  656. package/sdk/dist/query/helpers.js.map +1 -0
  657. package/sdk/dist/query/index.d.ts +8 -0
  658. package/sdk/dist/query/index.d.ts.map +1 -0
  659. package/sdk/dist/query/index.js +6 -0
  660. package/sdk/dist/query/index.js.map +1 -0
  661. package/sdk/dist/query/init-complex.d.ts +47 -0
  662. package/sdk/dist/query/init-complex.d.ts.map +1 -0
  663. package/sdk/dist/query/init-complex.js +718 -0
  664. package/sdk/dist/query/init-complex.js.map +1 -0
  665. package/sdk/dist/query/init.d.ts +106 -0
  666. package/sdk/dist/query/init.d.ts.map +1 -0
  667. package/sdk/dist/query/init.js +1159 -0
  668. package/sdk/dist/query/init.js.map +1 -0
  669. package/sdk/dist/query/intel.d.ts +43 -0
  670. package/sdk/dist/query/intel.d.ts.map +1 -0
  671. package/sdk/dist/query/intel.js +416 -0
  672. package/sdk/dist/query/intel.js.map +1 -0
  673. package/sdk/dist/query/mutation-event-decorator.d.ts +5 -0
  674. package/sdk/dist/query/mutation-event-decorator.d.ts.map +1 -0
  675. package/sdk/dist/query/mutation-event-decorator.js +28 -0
  676. package/sdk/dist/query/mutation-event-decorator.js.map +1 -0
  677. package/sdk/dist/query/mutation-event-mapper.d.ts +4 -0
  678. package/sdk/dist/query/mutation-event-mapper.d.ts.map +1 -0
  679. package/sdk/dist/query/mutation-event-mapper.js +70 -0
  680. package/sdk/dist/query/mutation-event-mapper.js.map +1 -0
  681. package/sdk/dist/query/mvp.d.ts +113 -0
  682. package/sdk/dist/query/mvp.d.ts.map +1 -0
  683. package/sdk/dist/query/mvp.js +225 -0
  684. package/sdk/dist/query/mvp.js.map +1 -0
  685. package/sdk/dist/query/phase-filesystem-adapter.d.ts +4 -0
  686. package/sdk/dist/query/phase-filesystem-adapter.d.ts.map +1 -0
  687. package/sdk/dist/query/phase-filesystem-adapter.js +33 -0
  688. package/sdk/dist/query/phase-filesystem-adapter.js.map +1 -0
  689. package/sdk/dist/query/phase-lifecycle-policy.d.ts +34 -0
  690. package/sdk/dist/query/phase-lifecycle-policy.d.ts.map +1 -0
  691. package/sdk/dist/query/phase-lifecycle-policy.js +138 -0
  692. package/sdk/dist/query/phase-lifecycle-policy.js.map +1 -0
  693. package/sdk/dist/query/phase-lifecycle.d.ts +116 -0
  694. package/sdk/dist/query/phase-lifecycle.d.ts.map +1 -0
  695. package/sdk/dist/query/phase-lifecycle.js +1486 -0
  696. package/sdk/dist/query/phase-lifecycle.js.map +1 -0
  697. package/sdk/dist/query/phase-list-queries.d.ts +18 -0
  698. package/sdk/dist/query/phase-list-queries.d.ts.map +1 -0
  699. package/sdk/dist/query/phase-list-queries.js +129 -0
  700. package/sdk/dist/query/phase-list-queries.js.map +1 -0
  701. package/sdk/dist/query/phase-ready.d.ts +9 -0
  702. package/sdk/dist/query/phase-ready.d.ts.map +1 -0
  703. package/sdk/dist/query/phase-ready.js +132 -0
  704. package/sdk/dist/query/phase-ready.js.map +1 -0
  705. package/sdk/dist/query/phase-roadmap-mutation.d.ts +13 -0
  706. package/sdk/dist/query/phase-roadmap-mutation.d.ts.map +1 -0
  707. package/sdk/dist/query/phase-roadmap-mutation.js +65 -0
  708. package/sdk/dist/query/phase-roadmap-mutation.js.map +1 -0
  709. package/sdk/dist/query/phase.d.ts +48 -0
  710. package/sdk/dist/query/phase.d.ts.map +1 -0
  711. package/sdk/dist/query/phase.js +451 -0
  712. package/sdk/dist/query/phase.js.map +1 -0
  713. package/sdk/dist/query/pipeline.d.ts +53 -0
  714. package/sdk/dist/query/pipeline.d.ts.map +1 -0
  715. package/sdk/dist/query/pipeline.js +198 -0
  716. package/sdk/dist/query/pipeline.js.map +1 -0
  717. package/sdk/dist/query/plan-scan.d.ts +14 -0
  718. package/sdk/dist/query/plan-scan.d.ts.map +1 -0
  719. package/sdk/dist/query/plan-scan.js +70 -0
  720. package/sdk/dist/query/plan-scan.js.map +1 -0
  721. package/sdk/dist/query/plan-task-structure.d.ts +9 -0
  722. package/sdk/dist/query/plan-task-structure.d.ts.map +1 -0
  723. package/sdk/dist/query/plan-task-structure.js +59 -0
  724. package/sdk/dist/query/plan-task-structure.js.map +1 -0
  725. package/sdk/dist/query/profile-extract-messages.d.ts +40 -0
  726. package/sdk/dist/query/profile-extract-messages.d.ts.map +1 -0
  727. package/sdk/dist/query/profile-extract-messages.js +195 -0
  728. package/sdk/dist/query/profile-extract-messages.js.map +1 -0
  729. package/sdk/dist/query/profile-output.d.ts +11 -0
  730. package/sdk/dist/query/profile-output.d.ts.map +1 -0
  731. package/sdk/dist/query/profile-output.js +873 -0
  732. package/sdk/dist/query/profile-output.js.map +1 -0
  733. package/sdk/dist/query/profile-questionnaire-data.d.ts +21 -0
  734. package/sdk/dist/query/profile-questionnaire-data.d.ts.map +1 -0
  735. package/sdk/dist/query/profile-questionnaire-data.js +171 -0
  736. package/sdk/dist/query/profile-questionnaire-data.js.map +1 -0
  737. package/sdk/dist/query/profile-sample.d.ts +22 -0
  738. package/sdk/dist/query/profile-sample.d.ts.map +1 -0
  739. package/sdk/dist/query/profile-sample.js +136 -0
  740. package/sdk/dist/query/profile-sample.js.map +1 -0
  741. package/sdk/dist/query/profile-scan-sessions.d.ts +49 -0
  742. package/sdk/dist/query/profile-scan-sessions.d.ts.map +1 -0
  743. package/sdk/dist/query/profile-scan-sessions.js +137 -0
  744. package/sdk/dist/query/profile-scan-sessions.js.map +1 -0
  745. package/sdk/dist/query/profile.d.ts +61 -0
  746. package/sdk/dist/query/profile.d.ts.map +1 -0
  747. package/sdk/dist/query/profile.js +307 -0
  748. package/sdk/dist/query/profile.js.map +1 -0
  749. package/sdk/dist/query/progress.d.ts +77 -0
  750. package/sdk/dist/query/progress.d.ts.map +1 -0
  751. package/sdk/dist/query/progress.js +481 -0
  752. package/sdk/dist/query/progress.js.map +1 -0
  753. package/sdk/dist/query/query-cli-adapter.d.ts +8 -0
  754. package/sdk/dist/query/query-cli-adapter.d.ts.map +1 -0
  755. package/sdk/dist/query/query-cli-adapter.js +32 -0
  756. package/sdk/dist/query/query-cli-adapter.js.map +1 -0
  757. package/sdk/dist/query/query-cli-output.d.ts +9 -0
  758. package/sdk/dist/query/query-cli-output.d.ts.map +1 -0
  759. package/sdk/dist/query/query-cli-output.js +28 -0
  760. package/sdk/dist/query/query-cli-output.js.map +1 -0
  761. package/sdk/dist/query/query-command-diagnosis.d.ts +6 -0
  762. package/sdk/dist/query/query-command-diagnosis.d.ts.map +1 -0
  763. package/sdk/dist/query/query-command-diagnosis.js +6 -0
  764. package/sdk/dist/query/query-command-diagnosis.js.map +1 -0
  765. package/sdk/dist/query/query-command-resolution-strategy.d.ts +29 -0
  766. package/sdk/dist/query/query-command-resolution-strategy.d.ts.map +1 -0
  767. package/sdk/dist/query/query-command-resolution-strategy.js +103 -0
  768. package/sdk/dist/query/query-command-resolution-strategy.js.map +1 -0
  769. package/sdk/dist/query/query-command-semantics.d.ts +7 -0
  770. package/sdk/dist/query/query-command-semantics.d.ts.map +1 -0
  771. package/sdk/dist/query/query-command-semantics.js +7 -0
  772. package/sdk/dist/query/query-command-semantics.js.map +1 -0
  773. package/sdk/dist/query/query-dispatch-contract.d.ts +21 -0
  774. package/sdk/dist/query/query-dispatch-contract.d.ts.map +1 -0
  775. package/sdk/dist/query/query-dispatch-contract.js +2 -0
  776. package/sdk/dist/query/query-dispatch-contract.js.map +1 -0
  777. package/sdk/dist/query/query-dispatch-error-mapper.d.ts +6 -0
  778. package/sdk/dist/query/query-dispatch-error-mapper.d.ts.map +1 -0
  779. package/sdk/dist/query/query-dispatch-error-mapper.js +6 -0
  780. package/sdk/dist/query/query-dispatch-error-mapper.js.map +1 -0
  781. package/sdk/dist/query/query-dispatch-formatting.d.ts +6 -0
  782. package/sdk/dist/query/query-dispatch-formatting.d.ts.map +1 -0
  783. package/sdk/dist/query/query-dispatch-formatting.js +6 -0
  784. package/sdk/dist/query/query-dispatch-formatting.js.map +1 -0
  785. package/sdk/dist/query/query-dispatch-input-validation.d.ts +6 -0
  786. package/sdk/dist/query/query-dispatch-input-validation.d.ts.map +1 -0
  787. package/sdk/dist/query/query-dispatch-input-validation.js +6 -0
  788. package/sdk/dist/query/query-dispatch-input-validation.js.map +1 -0
  789. package/sdk/dist/query/query-dispatch-observability.d.ts +2 -0
  790. package/sdk/dist/query/query-dispatch-observability.d.ts.map +1 -0
  791. package/sdk/dist/query/query-dispatch-observability.js +7 -0
  792. package/sdk/dist/query/query-dispatch-observability.js.map +1 -0
  793. package/sdk/dist/query/query-dispatch-plan.d.ts +6 -0
  794. package/sdk/dist/query/query-dispatch-plan.d.ts.map +1 -0
  795. package/sdk/dist/query/query-dispatch-plan.js +6 -0
  796. package/sdk/dist/query/query-dispatch-plan.js.map +1 -0
  797. package/sdk/dist/query/query-dispatch-result-builder.d.ts +6 -0
  798. package/sdk/dist/query/query-dispatch-result-builder.d.ts.map +1 -0
  799. package/sdk/dist/query/query-dispatch-result-builder.js +6 -0
  800. package/sdk/dist/query/query-dispatch-result-builder.js.map +1 -0
  801. package/sdk/dist/query/query-dispatch.d.ts +48 -0
  802. package/sdk/dist/query/query-dispatch.d.ts.map +1 -0
  803. package/sdk/dist/query/query-dispatch.js +175 -0
  804. package/sdk/dist/query/query-dispatch.js.map +1 -0
  805. package/sdk/dist/query/query-error-details-schema.d.ts +19 -0
  806. package/sdk/dist/query/query-error-details-schema.d.ts.map +1 -0
  807. package/sdk/dist/query/query-error-details-schema.js +10 -0
  808. package/sdk/dist/query/query-error-details-schema.js.map +1 -0
  809. package/sdk/dist/query/query-error-taxonomy.d.ts +38 -0
  810. package/sdk/dist/query/query-error-taxonomy.d.ts.map +1 -0
  811. package/sdk/dist/query/query-error-taxonomy.js +74 -0
  812. package/sdk/dist/query/query-error-taxonomy.js.map +1 -0
  813. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts +14 -0
  814. package/sdk/dist/query/query-fallback-bridge-adapter.d.ts.map +1 -0
  815. package/sdk/dist/query/query-fallback-bridge-adapter.js +33 -0
  816. package/sdk/dist/query/query-fallback-bridge-adapter.js.map +1 -0
  817. package/sdk/dist/query/query-fallback-executor.d.ts +11 -0
  818. package/sdk/dist/query/query-fallback-executor.d.ts.map +1 -0
  819. package/sdk/dist/query/query-fallback-executor.js +31 -0
  820. package/sdk/dist/query/query-fallback-executor.js.map +1 -0
  821. package/sdk/dist/query/query-fallback-output-classifier.d.ts +6 -0
  822. package/sdk/dist/query/query-fallback-output-classifier.d.ts.map +1 -0
  823. package/sdk/dist/query/query-fallback-output-classifier.js +27 -0
  824. package/sdk/dist/query/query-fallback-output-classifier.js.map +1 -0
  825. package/sdk/dist/query/query-fallback-policy.d.ts +6 -0
  826. package/sdk/dist/query/query-fallback-policy.d.ts.map +1 -0
  827. package/sdk/dist/query/query-fallback-policy.js +7 -0
  828. package/sdk/dist/query/query-fallback-policy.js.map +1 -0
  829. package/sdk/dist/query/query-native-dispatch-adapter.d.ts +7 -0
  830. package/sdk/dist/query/query-native-dispatch-adapter.d.ts.map +1 -0
  831. package/sdk/dist/query/query-native-dispatch-adapter.js +6 -0
  832. package/sdk/dist/query/query-native-dispatch-adapter.js.map +1 -0
  833. package/sdk/dist/query/query-policy-capability.d.ts +10 -0
  834. package/sdk/dist/query/query-policy-capability.d.ts.map +1 -0
  835. package/sdk/dist/query/query-policy-capability.js +17 -0
  836. package/sdk/dist/query/query-policy-capability.js.map +1 -0
  837. package/sdk/dist/query/query-runtime-context.d.ts +19 -0
  838. package/sdk/dist/query/query-runtime-context.d.ts.map +1 -0
  839. package/sdk/dist/query/query-runtime-context.js +31 -0
  840. package/sdk/dist/query/query-runtime-context.js.map +1 -0
  841. package/sdk/dist/query/query-unknown-command-hints.d.ts +2 -0
  842. package/sdk/dist/query/query-unknown-command-hints.d.ts.map +1 -0
  843. package/sdk/dist/query/query-unknown-command-hints.js +6 -0
  844. package/sdk/dist/query/query-unknown-command-hints.js.map +1 -0
  845. package/sdk/dist/query/registry-assembly-descriptor.d.ts +12 -0
  846. package/sdk/dist/query/registry-assembly-descriptor.d.ts.map +1 -0
  847. package/sdk/dist/query/registry-assembly-descriptor.js +61 -0
  848. package/sdk/dist/query/registry-assembly-descriptor.js.map +1 -0
  849. package/sdk/dist/query/registry-assembly-invariants.d.ts +30 -0
  850. package/sdk/dist/query/registry-assembly-invariants.d.ts.map +1 -0
  851. package/sdk/dist/query/registry-assembly-invariants.js +77 -0
  852. package/sdk/dist/query/registry-assembly-invariants.js.map +1 -0
  853. package/sdk/dist/query/registry-assembly.d.ts +10 -0
  854. package/sdk/dist/query/registry-assembly.d.ts.map +1 -0
  855. package/sdk/dist/query/registry-assembly.js +53 -0
  856. package/sdk/dist/query/registry-assembly.js.map +1 -0
  857. package/sdk/dist/query/registry.d.ts +90 -0
  858. package/sdk/dist/query/registry.d.ts.map +1 -0
  859. package/sdk/dist/query/registry.js +129 -0
  860. package/sdk/dist/query/registry.js.map +1 -0
  861. package/sdk/dist/query/requirements-extract-from-plans.d.ts +9 -0
  862. package/sdk/dist/query/requirements-extract-from-plans.d.ts.map +1 -0
  863. package/sdk/dist/query/requirements-extract-from-plans.js +76 -0
  864. package/sdk/dist/query/requirements-extract-from-plans.js.map +1 -0
  865. package/sdk/dist/query/roadmap-update-plan-progress.d.ts +11 -0
  866. package/sdk/dist/query/roadmap-update-plan-progress.d.ts.map +1 -0
  867. package/sdk/dist/query/roadmap-update-plan-progress.js +124 -0
  868. package/sdk/dist/query/roadmap-update-plan-progress.js.map +1 -0
  869. package/sdk/dist/query/roadmap.d.ts +137 -0
  870. package/sdk/dist/query/roadmap.d.ts.map +1 -0
  871. package/sdk/dist/query/roadmap.js +753 -0
  872. package/sdk/dist/query/roadmap.js.map +1 -0
  873. package/sdk/dist/query/route-next-action.d.ts +9 -0
  874. package/sdk/dist/query/route-next-action.d.ts.map +1 -0
  875. package/sdk/dist/query/route-next-action.js +318 -0
  876. package/sdk/dist/query/route-next-action.js.map +1 -0
  877. package/sdk/dist/query/schema-detect.d.ts +21 -0
  878. package/sdk/dist/query/schema-detect.d.ts.map +1 -0
  879. package/sdk/dist/query/schema-detect.js +146 -0
  880. package/sdk/dist/query/schema-detect.js.map +1 -0
  881. package/sdk/dist/query/secrets.d.ts +27 -0
  882. package/sdk/dist/query/secrets.d.ts.map +1 -0
  883. package/sdk/dist/query/secrets.js +42 -0
  884. package/sdk/dist/query/secrets.js.map +1 -0
  885. package/sdk/dist/query/skill-manifest.d.ts +50 -0
  886. package/sdk/dist/query/skill-manifest.d.ts.map +1 -0
  887. package/sdk/dist/query/skill-manifest.js +171 -0
  888. package/sdk/dist/query/skill-manifest.js.map +1 -0
  889. package/sdk/dist/query/skills.d.ts +27 -0
  890. package/sdk/dist/query/skills.d.ts.map +1 -0
  891. package/sdk/dist/query/skills.js +137 -0
  892. package/sdk/dist/query/skills.js.map +1 -0
  893. package/sdk/dist/query/state-document.d.ts +14 -0
  894. package/sdk/dist/query/state-document.d.ts.map +1 -0
  895. package/sdk/dist/query/state-document.js +110 -0
  896. package/sdk/dist/query/state-document.js.map +1 -0
  897. package/sdk/dist/query/state-mutation.d.ts +224 -0
  898. package/sdk/dist/query/state-mutation.d.ts.map +1 -0
  899. package/sdk/dist/query/state-mutation.js +1539 -0
  900. package/sdk/dist/query/state-mutation.js.map +1 -0
  901. package/sdk/dist/query/state-project-load.d.ts +23 -0
  902. package/sdk/dist/query/state-project-load.d.ts.map +1 -0
  903. package/sdk/dist/query/state-project-load.js +75 -0
  904. package/sdk/dist/query/state-project-load.js.map +1 -0
  905. package/sdk/dist/query/state.d.ts +78 -0
  906. package/sdk/dist/query/state.d.ts.map +1 -0
  907. package/sdk/dist/query/state.js +430 -0
  908. package/sdk/dist/query/state.js.map +1 -0
  909. package/sdk/dist/query/summary.d.ts +18 -0
  910. package/sdk/dist/query/summary.d.ts.map +1 -0
  911. package/sdk/dist/query/summary.js +249 -0
  912. package/sdk/dist/query/summary.js.map +1 -0
  913. package/sdk/dist/query/template.d.ts +46 -0
  914. package/sdk/dist/query/template.d.ts.map +1 -0
  915. package/sdk/dist/query/template.js +210 -0
  916. package/sdk/dist/query/template.js.map +1 -0
  917. package/sdk/dist/query/uat.d.ts +34 -0
  918. package/sdk/dist/query/uat.d.ts.map +1 -0
  919. package/sdk/dist/query/uat.js +339 -0
  920. package/sdk/dist/query/uat.js.map +1 -0
  921. package/sdk/dist/query/utils.d.ts +59 -0
  922. package/sdk/dist/query/utils.d.ts.map +1 -0
  923. package/sdk/dist/query/utils.js +74 -0
  924. package/sdk/dist/query/utils.js.map +1 -0
  925. package/sdk/dist/query/validate.d.ts +67 -0
  926. package/sdk/dist/query/validate.d.ts.map +1 -0
  927. package/sdk/dist/query/validate.js +908 -0
  928. package/sdk/dist/query/validate.js.map +1 -0
  929. package/sdk/dist/query/verify.d.ts +110 -0
  930. package/sdk/dist/query/verify.d.ts.map +1 -0
  931. package/sdk/dist/query/verify.js +631 -0
  932. package/sdk/dist/query/verify.js.map +1 -0
  933. package/sdk/dist/query/websearch.d.ts +24 -0
  934. package/sdk/dist/query/websearch.d.ts.map +1 -0
  935. package/sdk/dist/query/websearch.js +68 -0
  936. package/sdk/dist/query/websearch.js.map +1 -0
  937. package/sdk/dist/query/workspace.d.ts +62 -0
  938. package/sdk/dist/query/workspace.d.ts.map +1 -0
  939. package/sdk/dist/query/workspace.js +104 -0
  940. package/sdk/dist/query/workspace.js.map +1 -0
  941. package/sdk/dist/query/workstream-inventory.d.ts +52 -0
  942. package/sdk/dist/query/workstream-inventory.d.ts.map +1 -0
  943. package/sdk/dist/query/workstream-inventory.js +141 -0
  944. package/sdk/dist/query/workstream-inventory.js.map +1 -0
  945. package/sdk/dist/query/workstream.d.ts +35 -0
  946. package/sdk/dist/query/workstream.d.ts.map +1 -0
  947. package/sdk/dist/query/workstream.js +298 -0
  948. package/sdk/dist/query/workstream.js.map +1 -0
  949. package/sdk/dist/query/worktree.d.ts +3 -0
  950. package/sdk/dist/query/worktree.d.ts.map +1 -0
  951. package/sdk/dist/query/worktree.js +36 -0
  952. package/sdk/dist/query/worktree.js.map +1 -0
  953. package/sdk/dist/query-command-executor.d.ts +22 -0
  954. package/sdk/dist/query-command-executor.d.ts.map +1 -0
  955. package/sdk/dist/query-command-executor.js +22 -0
  956. package/sdk/dist/query-command-executor.js.map +1 -0
  957. package/sdk/dist/query-execution-policy.d.ts +24 -0
  958. package/sdk/dist/query-execution-policy.d.ts.map +1 -0
  959. package/sdk/dist/query-execution-policy.js +27 -0
  960. package/sdk/dist/query-execution-policy.js.map +1 -0
  961. package/sdk/dist/query-failure-classification.d.ts +9 -0
  962. package/sdk/dist/query-failure-classification.d.ts.map +1 -0
  963. package/sdk/dist/query-failure-classification.js +32 -0
  964. package/sdk/dist/query-failure-classification.js.map +1 -0
  965. package/sdk/dist/query-hotpath-methods.d.ts +19 -0
  966. package/sdk/dist/query-hotpath-methods.d.ts.map +1 -0
  967. package/sdk/dist/query-hotpath-methods.js +34 -0
  968. package/sdk/dist/query-hotpath-methods.js.map +1 -0
  969. package/sdk/dist/query-native-direct-adapter.d.ts +20 -0
  970. package/sdk/dist/query-native-direct-adapter.d.ts.map +1 -0
  971. package/sdk/dist/query-native-direct-adapter.js +52 -0
  972. package/sdk/dist/query-native-direct-adapter.js.map +1 -0
  973. package/sdk/dist/query-native-hotpath-adapter.d.ts +15 -0
  974. package/sdk/dist/query-native-hotpath-adapter.d.ts.map +1 -0
  975. package/sdk/dist/query-native-hotpath-adapter.js +32 -0
  976. package/sdk/dist/query-native-hotpath-adapter.js.map +1 -0
  977. package/sdk/dist/query-raw-output-projection.d.ts +6 -0
  978. package/sdk/dist/query-raw-output-projection.d.ts.map +1 -0
  979. package/sdk/dist/query-raw-output-projection.js +67 -0
  980. package/sdk/dist/query-raw-output-projection.js.map +1 -0
  981. package/sdk/dist/query-runtime-bridge.d.ts +61 -0
  982. package/sdk/dist/query-runtime-bridge.d.ts.map +1 -0
  983. package/sdk/dist/query-runtime-bridge.js +144 -0
  984. package/sdk/dist/query-runtime-bridge.js.map +1 -0
  985. package/sdk/dist/query-sdd-tools-path.d.ts +2 -0
  986. package/sdk/dist/query-sdd-tools-path.d.ts.map +1 -0
  987. package/sdk/dist/query-sdd-tools-path.js +2 -0
  988. package/sdk/dist/query-sdd-tools-path.js.map +1 -0
  989. package/sdk/dist/query-sdd-tools-runtime.d.ts +20 -0
  990. package/sdk/dist/query-sdd-tools-runtime.d.ts.map +1 -0
  991. package/sdk/dist/query-sdd-tools-runtime.js +47 -0
  992. package/sdk/dist/query-sdd-tools-runtime.js.map +1 -0
  993. package/sdk/dist/query-subprocess-adapter.d.ts +18 -0
  994. package/sdk/dist/query-subprocess-adapter.d.ts.map +1 -0
  995. package/sdk/dist/query-subprocess-adapter.js +92 -0
  996. package/sdk/dist/query-subprocess-adapter.js.map +1 -0
  997. package/sdk/dist/query-tools-error-factory.d.ts +16 -0
  998. package/sdk/dist/query-tools-error-factory.d.ts.map +1 -0
  999. package/sdk/dist/query-tools-error-factory.js +33 -0
  1000. package/sdk/dist/query-tools-error-factory.js.map +1 -0
  1001. package/sdk/dist/research-gate.d.ts +24 -0
  1002. package/sdk/dist/research-gate.d.ts.map +1 -0
  1003. package/sdk/dist/research-gate.js +70 -0
  1004. package/sdk/dist/research-gate.js.map +1 -0
  1005. package/sdk/dist/runtime-gate.d.ts +14 -0
  1006. package/sdk/dist/runtime-gate.d.ts.map +1 -0
  1007. package/sdk/dist/runtime-gate.js +48 -0
  1008. package/sdk/dist/runtime-gate.js.map +1 -0
  1009. package/sdk/dist/sdd-tools-error.d.ts +23 -0
  1010. package/sdk/dist/sdd-tools-error.d.ts.map +1 -0
  1011. package/sdk/dist/sdd-tools-error.js +29 -0
  1012. package/sdk/dist/sdd-tools-error.js.map +1 -0
  1013. package/sdk/dist/sdd-tools.d.ts +97 -0
  1014. package/sdk/dist/sdd-tools.d.ts.map +1 -0
  1015. package/sdk/dist/sdd-tools.js +168 -0
  1016. package/sdk/dist/sdd-tools.js.map +1 -0
  1017. package/sdk/dist/sdd-transport-policy.d.ts +10 -0
  1018. package/sdk/dist/sdd-transport-policy.d.ts.map +1 -0
  1019. package/sdk/dist/sdd-transport-policy.js +32 -0
  1020. package/sdk/dist/sdd-transport-policy.js.map +1 -0
  1021. package/sdk/dist/sdd-transport.d.ts +39 -0
  1022. package/sdk/dist/sdd-transport.d.ts.map +1 -0
  1023. package/sdk/dist/sdd-transport.js +78 -0
  1024. package/sdk/dist/sdd-transport.js.map +1 -0
  1025. package/sdk/dist/sdk-package-compatibility.d.ts +38 -0
  1026. package/sdk/dist/sdk-package-compatibility.d.ts.map +1 -0
  1027. package/sdk/dist/sdk-package-compatibility.js +90 -0
  1028. package/sdk/dist/sdk-package-compatibility.js.map +1 -0
  1029. package/sdk/dist/session-runner.d.ts +40 -0
  1030. package/sdk/dist/session-runner.d.ts.map +1 -0
  1031. package/sdk/dist/session-runner.js +274 -0
  1032. package/sdk/dist/session-runner.js.map +1 -0
  1033. package/sdk/dist/tool-scoping.d.ts +31 -0
  1034. package/sdk/dist/tool-scoping.d.ts.map +1 -0
  1035. package/sdk/dist/tool-scoping.js +54 -0
  1036. package/sdk/dist/tool-scoping.js.map +1 -0
  1037. package/sdk/dist/types.d.ts +794 -0
  1038. package/sdk/dist/types.d.ts.map +1 -0
  1039. package/sdk/dist/types.js +77 -0
  1040. package/sdk/dist/types.js.map +1 -0
  1041. package/sdk/dist/workstream-name-policy.d.ts +13 -0
  1042. package/sdk/dist/workstream-name-policy.d.ts.map +1 -0
  1043. package/sdk/dist/workstream-name-policy.js +24 -0
  1044. package/sdk/dist/workstream-name-policy.js.map +1 -0
  1045. package/sdk/dist/workstream-utils.d.ts +15 -0
  1046. package/sdk/dist/workstream-utils.d.ts.map +1 -0
  1047. package/sdk/dist/workstream-utils.js +21 -0
  1048. package/sdk/dist/workstream-utils.js.map +1 -0
  1049. package/sdk/dist/ws-transport.d.ts +32 -0
  1050. package/sdk/dist/ws-transport.d.ts.map +1 -0
  1051. package/sdk/dist/ws-transport.js +84 -0
  1052. package/sdk/dist/ws-transport.js.map +1 -0
  1053. package/sdk/package-lock.json +2502 -0
  1054. package/sdk/package.json +57 -0
  1055. package/sdk/prompts/templates/project.md +186 -0
  1056. package/sdk/prompts/templates/requirements.md +231 -0
  1057. package/sdk/prompts/templates/research-project/ARCHITECTURE.md +204 -0
  1058. package/sdk/prompts/templates/research-project/FEATURES.md +147 -0
  1059. package/sdk/prompts/templates/research-project/PITFALLS.md +200 -0
  1060. package/sdk/prompts/templates/research-project/STACK.md +120 -0
  1061. package/sdk/prompts/templates/research-project/SUMMARY.md +170 -0
  1062. package/sdk/prompts/templates/roadmap.md +202 -0
  1063. package/sdk/prompts/templates/state.md +175 -0
  1064. package/sdk/shared/model-catalog.json +122 -0
  1065. package/sdk/src/assembled-prompts.test.ts +349 -0
  1066. package/sdk/src/bug-3591-sddtools-runtime-workstream.test.ts +179 -0
  1067. package/sdk/src/cli-transport.test.ts +388 -0
  1068. package/sdk/src/cli-transport.ts +130 -0
  1069. package/sdk/src/cli.test.ts +426 -0
  1070. package/sdk/src/cli.ts +589 -0
  1071. package/sdk/src/config.test.ts +271 -0
  1072. package/sdk/src/config.ts +218 -0
  1073. package/sdk/src/context-engine.test.ts +295 -0
  1074. package/sdk/src/context-engine.ts +170 -0
  1075. package/sdk/src/context-truncation.test.ts +163 -0
  1076. package/sdk/src/context-truncation.ts +233 -0
  1077. package/sdk/src/e2e.integration.test.ts +181 -0
  1078. package/sdk/src/errors.ts +72 -0
  1079. package/sdk/src/event-stream.test.ts +661 -0
  1080. package/sdk/src/event-stream.ts +441 -0
  1081. package/sdk/src/golden/capture.ts +95 -0
  1082. package/sdk/src/golden/fixtures/generate-slug.golden.json +1 -0
  1083. package/sdk/src/golden/fixtures/profile-sample-sessions/demo-project/sample.jsonl +3 -0
  1084. package/sdk/src/golden/fixtures/summary-extract-sample.md +26 -0
  1085. package/sdk/src/golden/fixtures/uat-render-checkpoint-sample.md +15 -0
  1086. package/sdk/src/golden/golden-integration-covered.ts +30 -0
  1087. package/sdk/src/golden/golden-mutation-covered.ts +17 -0
  1088. package/sdk/src/golden/golden-policy.test.ts +8 -0
  1089. package/sdk/src/golden/golden-policy.ts +120 -0
  1090. package/sdk/src/golden/golden.integration.test.ts +677 -0
  1091. package/sdk/src/golden/init-golden-normalize.ts +15 -0
  1092. package/sdk/src/golden/read-only-golden-rows.ts +77 -0
  1093. package/sdk/src/golden/read-only-parity.integration.test.ts +133 -0
  1094. package/sdk/src/golden/registry-canonical-commands.ts +31 -0
  1095. package/sdk/src/index.ts +352 -0
  1096. package/sdk/src/init-e2e.integration.test.ts +138 -0
  1097. package/sdk/src/init-runner.test.ts +740 -0
  1098. package/sdk/src/init-runner.ts +734 -0
  1099. package/sdk/src/lifecycle-e2e.integration.test.ts +258 -0
  1100. package/sdk/src/logger.test.ts +149 -0
  1101. package/sdk/src/logger.ts +113 -0
  1102. package/sdk/src/milestone-runner.test.ts +421 -0
  1103. package/sdk/src/model-catalog.ts +70 -0
  1104. package/sdk/src/phase-prompt.test.ts +535 -0
  1105. package/sdk/src/phase-prompt.ts +259 -0
  1106. package/sdk/src/phase-runner-types.test.ts +421 -0
  1107. package/sdk/src/phase-runner.integration.test.ts +377 -0
  1108. package/sdk/src/phase-runner.test.ts +2720 -0
  1109. package/sdk/src/phase-runner.ts +1442 -0
  1110. package/sdk/src/plan-parser.test.ts +579 -0
  1111. package/sdk/src/plan-parser.ts +431 -0
  1112. package/sdk/src/planning-journal.test.ts +70 -0
  1113. package/sdk/src/planning-journal.ts +153 -0
  1114. package/sdk/src/planning-runtime.test.ts +29 -0
  1115. package/sdk/src/planning-runtime.ts +100 -0
  1116. package/sdk/src/prompt-builder.test.ts +318 -0
  1117. package/sdk/src/prompt-builder.ts +218 -0
  1118. package/sdk/src/prompt-sanitizer.test.ts +260 -0
  1119. package/sdk/src/prompt-sanitizer.ts +116 -0
  1120. package/sdk/src/query/QUERY-HANDLERS.md +349 -0
  1121. package/sdk/src/query/active-workstream-store.ts +50 -0
  1122. package/sdk/src/query/agent-failure-classifier.test.ts +157 -0
  1123. package/sdk/src/query/agent-failure-classifier.ts +105 -0
  1124. package/sdk/src/query/audit-open.ts +722 -0
  1125. package/sdk/src/query/check-auto-mode.test.ts +77 -0
  1126. package/sdk/src/query/check-auto-mode.ts +49 -0
  1127. package/sdk/src/query/check-completion.test.ts +113 -0
  1128. package/sdk/src/query/check-completion.ts +182 -0
  1129. package/sdk/src/query/check-decision-coverage.test.ts +519 -0
  1130. package/sdk/src/query/check-decision-coverage.ts +554 -0
  1131. package/sdk/src/query/check-gates.test.ts +103 -0
  1132. package/sdk/src/query/check-gates.ts +112 -0
  1133. package/sdk/src/query/check-ship-ready.test.ts +111 -0
  1134. package/sdk/src/query/check-ship-ready.ts +104 -0
  1135. package/sdk/src/query/check-verification-status.test.ts +143 -0
  1136. package/sdk/src/query/check-verification-status.ts +160 -0
  1137. package/sdk/src/query/command-aliases.generated.ts +156 -0
  1138. package/sdk/src/query/command-catalog.ts +31 -0
  1139. package/sdk/src/query/command-definition.test.ts +47 -0
  1140. package/sdk/src/query/command-definition.ts +70 -0
  1141. package/sdk/src/query/command-family-handlers.ts +117 -0
  1142. package/sdk/src/query/command-manifest.init.ts +24 -0
  1143. package/sdk/src/query/command-manifest.non-family.ts +85 -0
  1144. package/sdk/src/query/command-manifest.phase.ts +16 -0
  1145. package/sdk/src/query/command-manifest.phases.ts +11 -0
  1146. package/sdk/src/query/command-manifest.roadmap.ts +11 -0
  1147. package/sdk/src/query/command-manifest.state.ts +31 -0
  1148. package/sdk/src/query/command-manifest.ts +17 -0
  1149. package/sdk/src/query/command-manifest.types.ts +13 -0
  1150. package/sdk/src/query/command-manifest.validate.ts +11 -0
  1151. package/sdk/src/query/command-manifest.verify.ts +15 -0
  1152. package/sdk/src/query/command-resolution.test.ts +70 -0
  1153. package/sdk/src/query/command-seam-coverage.test.ts +118 -0
  1154. package/sdk/src/query/command-static-catalog-domain.ts +117 -0
  1155. package/sdk/src/query/command-static-catalog-foundation.ts +103 -0
  1156. package/sdk/src/query/command-topology.test.ts +28 -0
  1157. package/sdk/src/query/command-topology.ts +114 -0
  1158. package/sdk/src/query/commands-list.test.ts +36 -0
  1159. package/sdk/src/query/commands-list.ts +19 -0
  1160. package/sdk/src/query/commit.test.ts +485 -0
  1161. package/sdk/src/query/commit.ts +383 -0
  1162. package/sdk/src/query/config-gates.test.ts +89 -0
  1163. package/sdk/src/query/config-gates.ts +69 -0
  1164. package/sdk/src/query/config-mutation.test.ts +598 -0
  1165. package/sdk/src/query/config-mutation.ts +575 -0
  1166. package/sdk/src/query/config-query.test.ts +367 -0
  1167. package/sdk/src/query/config-query.ts +244 -0
  1168. package/sdk/src/query/config-schema.ts +159 -0
  1169. package/sdk/src/query/decisions.test.ts +215 -0
  1170. package/sdk/src/query/decisions.ts +192 -0
  1171. package/sdk/src/query/decomposed-handlers.test.ts +431 -0
  1172. package/sdk/src/query/detect-custom-files.test.ts +115 -0
  1173. package/sdk/src/query/detect-custom-files.ts +96 -0
  1174. package/sdk/src/query/detect-phase-type.test.ts +105 -0
  1175. package/sdk/src/query/detect-phase-type.ts +141 -0
  1176. package/sdk/src/query/docs-init.ts +258 -0
  1177. package/sdk/src/query/fallow-audit.ts +88 -0
  1178. package/sdk/src/query/frontmatter-array.test.ts +14 -0
  1179. package/sdk/src/query/frontmatter-mutation.test.ts +259 -0
  1180. package/sdk/src/query/frontmatter-mutation.ts +343 -0
  1181. package/sdk/src/query/frontmatter.test.ts +326 -0
  1182. package/sdk/src/query/frontmatter.ts +395 -0
  1183. package/sdk/src/query/helpers.test.ts +615 -0
  1184. package/sdk/src/query/helpers.ts +646 -0
  1185. package/sdk/src/query/index-thin-seam.test.ts +16 -0
  1186. package/sdk/src/query/index.ts +9 -0
  1187. package/sdk/src/query/init-complex.test.ts +616 -0
  1188. package/sdk/src/query/init-complex.ts +799 -0
  1189. package/sdk/src/query/init-progress-precedence.test.ts +177 -0
  1190. package/sdk/src/query/init-workstream-milestone-op.test.ts +321 -0
  1191. package/sdk/src/query/init.test.ts +792 -0
  1192. package/sdk/src/query/init.ts +1262 -0
  1193. package/sdk/src/query/intel.test.ts +90 -0
  1194. package/sdk/src/query/intel.ts +404 -0
  1195. package/sdk/src/query/mutation-event-decorator.test.ts +45 -0
  1196. package/sdk/src/query/mutation-event-decorator.ts +37 -0
  1197. package/sdk/src/query/mutation-event-mapper.test.ts +33 -0
  1198. package/sdk/src/query/mutation-event-mapper.ts +102 -0
  1199. package/sdk/src/query/mvp.test.ts +335 -0
  1200. package/sdk/src/query/mvp.ts +292 -0
  1201. package/sdk/src/query/normalize-query-command.test.ts +102 -0
  1202. package/sdk/src/query/phase-filesystem-adapter.ts +35 -0
  1203. package/sdk/src/query/phase-lifecycle-policy.ts +171 -0
  1204. package/sdk/src/query/phase-lifecycle.test.ts +1750 -0
  1205. package/sdk/src/query/phase-lifecycle.ts +1833 -0
  1206. package/sdk/src/query/phase-list-queries.test.ts +88 -0
  1207. package/sdk/src/query/phase-list-queries.ts +152 -0
  1208. package/sdk/src/query/phase-ready.test.ts +65 -0
  1209. package/sdk/src/query/phase-ready.ts +159 -0
  1210. package/sdk/src/query/phase-roadmap-mutation.ts +77 -0
  1211. package/sdk/src/query/phase.test.ts +651 -0
  1212. package/sdk/src/query/phase.ts +550 -0
  1213. package/sdk/src/query/pipeline.test.ts +169 -0
  1214. package/sdk/src/query/pipeline.ts +243 -0
  1215. package/sdk/src/query/plan-scan.test.ts +35 -0
  1216. package/sdk/src/query/plan-scan.ts +82 -0
  1217. package/sdk/src/query/plan-task-structure.test.ts +65 -0
  1218. package/sdk/src/query/plan-task-structure.ts +63 -0
  1219. package/sdk/src/query/policy-convergence.test.ts +28 -0
  1220. package/sdk/src/query/profile-extract-messages.ts +247 -0
  1221. package/sdk/src/query/profile-output.ts +929 -0
  1222. package/sdk/src/query/profile-questionnaire-data.ts +181 -0
  1223. package/sdk/src/query/profile-sample.ts +184 -0
  1224. package/sdk/src/query/profile-scan-sessions.ts +174 -0
  1225. package/sdk/src/query/profile.test.ts +136 -0
  1226. package/sdk/src/query/profile.ts +337 -0
  1227. package/sdk/src/query/progress.test.ts +156 -0
  1228. package/sdk/src/query/progress.ts +566 -0
  1229. package/sdk/src/query/query-cli-adapter.test.ts +79 -0
  1230. package/sdk/src/query/query-cli-adapter.ts +39 -0
  1231. package/sdk/src/query/query-cli-output.test.ts +33 -0
  1232. package/sdk/src/query/query-cli-output.ts +35 -0
  1233. package/sdk/src/query/query-command-diagnosis.test.ts +22 -0
  1234. package/sdk/src/query/query-command-diagnosis.ts +5 -0
  1235. package/sdk/src/query/query-command-resolution-strategy.test.ts +34 -0
  1236. package/sdk/src/query/query-command-resolution-strategy.ts +121 -0
  1237. package/sdk/src/query/query-command-semantics.test.ts +22 -0
  1238. package/sdk/src/query/query-command-semantics.ts +22 -0
  1239. package/sdk/src/query/query-dispatch-contract.ts +30 -0
  1240. package/sdk/src/query/query-dispatch-error-mapper.test.ts +62 -0
  1241. package/sdk/src/query/query-dispatch-error-mapper.ts +5 -0
  1242. package/sdk/src/query/query-dispatch-formatting.test.ts +28 -0
  1243. package/sdk/src/query/query-dispatch-formatting.ts +5 -0
  1244. package/sdk/src/query/query-dispatch-input-validation.test.ts +23 -0
  1245. package/sdk/src/query/query-dispatch-input-validation.ts +5 -0
  1246. package/sdk/src/query/query-dispatch-observability.test.ts +10 -0
  1247. package/sdk/src/query/query-dispatch-observability.ts +6 -0
  1248. package/sdk/src/query/query-dispatch-plan.test.ts +25 -0
  1249. package/sdk/src/query/query-dispatch-plan.ts +5 -0
  1250. package/sdk/src/query/query-dispatch-result-builder.test.ts +16 -0
  1251. package/sdk/src/query/query-dispatch-result-builder.ts +5 -0
  1252. package/sdk/src/query/query-dispatch.test.ts +399 -0
  1253. package/sdk/src/query/query-dispatch.ts +243 -0
  1254. package/sdk/src/query/query-error-details-schema.ts +29 -0
  1255. package/sdk/src/query/query-error-taxonomy.test.ts +39 -0
  1256. package/sdk/src/query/query-error-taxonomy.ts +117 -0
  1257. package/sdk/src/query/query-fallback-bridge-adapter.test.ts +32 -0
  1258. package/sdk/src/query/query-fallback-bridge-adapter.ts +54 -0
  1259. package/sdk/src/query/query-fallback-executor.test.ts +82 -0
  1260. package/sdk/src/query/query-fallback-executor.ts +44 -0
  1261. package/sdk/src/query/query-fallback-output-classifier.test.ts +36 -0
  1262. package/sdk/src/query/query-fallback-output-classifier.ts +31 -0
  1263. package/sdk/src/query/query-fallback-policy.test.ts +13 -0
  1264. package/sdk/src/query/query-fallback-policy.ts +11 -0
  1265. package/sdk/src/query/query-native-dispatch-adapter.ts +16 -0
  1266. package/sdk/src/query/query-policy-capability.test.ts +10 -0
  1267. package/sdk/src/query/query-policy-capability.ts +26 -0
  1268. package/sdk/src/query/query-policy-snapshot.test.ts +9 -0
  1269. package/sdk/src/query/query-registry-capability.test.ts +14 -0
  1270. package/sdk/src/query/query-runtime-context.ts +44 -0
  1271. package/sdk/src/query/query-unknown-command-hints.test.ts +9 -0
  1272. package/sdk/src/query/query-unknown-command-hints.ts +5 -0
  1273. package/sdk/src/query/registry-assembly-descriptor.ts +87 -0
  1274. package/sdk/src/query/registry-assembly-invariants.ts +127 -0
  1275. package/sdk/src/query/registry-assembly.test.ts +138 -0
  1276. package/sdk/src/query/registry-assembly.ts +78 -0
  1277. package/sdk/src/query/registry.test.ts +208 -0
  1278. package/sdk/src/query/registry.ts +142 -0
  1279. package/sdk/src/query/requirements-extract-from-plans.test.ts +58 -0
  1280. package/sdk/src/query/requirements-extract-from-plans.ts +86 -0
  1281. package/sdk/src/query/roadmap-update-plan-progress.test.ts +233 -0
  1282. package/sdk/src/query/roadmap-update-plan-progress.ts +159 -0
  1283. package/sdk/src/query/roadmap.test.ts +1181 -0
  1284. package/sdk/src/query/roadmap.ts +894 -0
  1285. package/sdk/src/query/route-next-action.test.ts +61 -0
  1286. package/sdk/src/query/route-next-action.ts +345 -0
  1287. package/sdk/src/query/schema-detect.ts +189 -0
  1288. package/sdk/src/query/secrets.test.ts +66 -0
  1289. package/sdk/src/query/secrets.ts +43 -0
  1290. package/sdk/src/query/skill-manifest.test.ts +62 -0
  1291. package/sdk/src/query/skill-manifest.ts +216 -0
  1292. package/sdk/src/query/skills.test.ts +234 -0
  1293. package/sdk/src/query/skills.ts +143 -0
  1294. package/sdk/src/query/state-document.test.ts +197 -0
  1295. package/sdk/src/query/state-document.ts +129 -0
  1296. package/sdk/src/query/state-mutation.test.ts +1198 -0
  1297. package/sdk/src/query/state-mutation.ts +1718 -0
  1298. package/sdk/src/query/state-project-load.ts +80 -0
  1299. package/sdk/src/query/state.test.ts +616 -0
  1300. package/sdk/src/query/state.ts +463 -0
  1301. package/sdk/src/query/sub-repos-root.integration.test.ts +79 -0
  1302. package/sdk/src/query/summary.test.ts +95 -0
  1303. package/sdk/src/query/summary.ts +296 -0
  1304. package/sdk/src/query/template.test.ts +180 -0
  1305. package/sdk/src/query/template.ts +242 -0
  1306. package/sdk/src/query/uat.test.ts +77 -0
  1307. package/sdk/src/query/uat.ts +365 -0
  1308. package/sdk/src/query/utils.test.ts +82 -0
  1309. package/sdk/src/query/utils.ts +106 -0
  1310. package/sdk/src/query/validate.test.ts +831 -0
  1311. package/sdk/src/query/validate.ts +952 -0
  1312. package/sdk/src/query/verify.test.ts +414 -0
  1313. package/sdk/src/query/verify.ts +692 -0
  1314. package/sdk/src/query/websearch.test.ts +31 -0
  1315. package/sdk/src/query/websearch.ts +82 -0
  1316. package/sdk/src/query/workspace.test.ts +120 -0
  1317. package/sdk/src/query/workspace.ts +145 -0
  1318. package/sdk/src/query/workstream-inventory.ts +195 -0
  1319. package/sdk/src/query/workstream.test.ts +153 -0
  1320. package/sdk/src/query/workstream.ts +324 -0
  1321. package/sdk/src/query/worktree.ts +39 -0
  1322. package/sdk/src/query-command-executor.ts +31 -0
  1323. package/sdk/src/query-execution-policy.test.ts +52 -0
  1324. package/sdk/src/query-execution-policy.ts +46 -0
  1325. package/sdk/src/query-failure-classification.test.ts +23 -0
  1326. package/sdk/src/query-failure-classification.ts +42 -0
  1327. package/sdk/src/query-hotpath-methods.ts +48 -0
  1328. package/sdk/src/query-native-direct-adapter.test.ts +35 -0
  1329. package/sdk/src/query-native-direct-adapter.ts +70 -0
  1330. package/sdk/src/query-native-hotpath-adapter.test.ts +43 -0
  1331. package/sdk/src/query-native-hotpath-adapter.ts +45 -0
  1332. package/sdk/src/query-raw-output-projection.test.ts +39 -0
  1333. package/sdk/src/query-raw-output-projection.ts +74 -0
  1334. package/sdk/src/query-runtime-bridge.test.ts +150 -0
  1335. package/sdk/src/query-runtime-bridge.ts +215 -0
  1336. package/sdk/src/query-runtime-seam-coverage.test.ts +20 -0
  1337. package/sdk/src/query-sdd-tools-path.ts +1 -0
  1338. package/sdk/src/query-sdd-tools-runtime.ts +89 -0
  1339. package/sdk/src/query-subprocess-adapter.test.ts +84 -0
  1340. package/sdk/src/query-subprocess-adapter.ts +146 -0
  1341. package/sdk/src/query-tools-error-factory.test.ts +35 -0
  1342. package/sdk/src/query-tools-error-factory.ts +76 -0
  1343. package/sdk/src/research-gate.test.ts +190 -0
  1344. package/sdk/src/research-gate.ts +94 -0
  1345. package/sdk/src/runtime-bridge-options.test.ts +33 -0
  1346. package/sdk/src/runtime-gate.test.ts +84 -0
  1347. package/sdk/src/runtime-gate.ts +52 -0
  1348. package/sdk/src/sdd-tools-error.test.ts +21 -0
  1349. package/sdk/src/sdd-tools-error.ts +65 -0
  1350. package/sdk/src/sdd-tools.test.ts +472 -0
  1351. package/sdk/src/sdd-tools.ts +237 -0
  1352. package/sdk/src/sdd-transport-policy.test.ts +34 -0
  1353. package/sdk/src/sdd-transport-policy.ts +48 -0
  1354. package/sdk/src/sdd-transport.test.ts +292 -0
  1355. package/sdk/src/sdd-transport.ts +117 -0
  1356. package/sdk/src/sdk-package-compatibility.test.ts +97 -0
  1357. package/sdk/src/sdk-package-compatibility.ts +141 -0
  1358. package/sdk/src/session-runner.test.ts +164 -0
  1359. package/sdk/src/session-runner.ts +327 -0
  1360. package/sdk/src/tool-scoping.test.ts +160 -0
  1361. package/sdk/src/tool-scoping.ts +61 -0
  1362. package/sdk/src/types.ts +927 -0
  1363. package/sdk/src/workflow-agent-skills-consistency.test.ts +98 -0
  1364. package/sdk/src/workstream-name-policy.ts +24 -0
  1365. package/sdk/src/workstream-utils.ts +21 -0
  1366. package/sdk/src/ws-flag.test.ts +285 -0
  1367. package/sdk/src/ws-transport.test.ts +161 -0
  1368. package/sdk/src/ws-transport.ts +93 -0
  1369. package/sdk/tsconfig.json +20 -0
  1370. package/commands/sdd/add-backlog.md +0 -76
  1371. package/commands/sdd/add-phase.md +0 -43
  1372. package/commands/sdd/add-todo.md +0 -47
  1373. package/commands/sdd/check-todos.md +0 -45
  1374. package/commands/sdd/do.md +0 -30
  1375. package/commands/sdd/insert-phase.md +0 -32
  1376. package/commands/sdd/join-discord.md +0 -18
  1377. package/commands/sdd/list-phase-assumptions.md +0 -46
  1378. package/commands/sdd/list-workspaces.md +0 -19
  1379. package/commands/sdd/new-workspace.md +0 -44
  1380. package/commands/sdd/next.md +0 -24
  1381. package/commands/sdd/note.md +0 -34
  1382. package/commands/sdd/plan-milestone-gaps.md +0 -34
  1383. package/commands/sdd/plant-seed.md +0 -28
  1384. package/commands/sdd/reapply-patches.md +0 -123
  1385. package/commands/sdd/remove-phase.md +0 -31
  1386. package/commands/sdd/remove-workspace.md +0 -26
  1387. package/commands/sdd/research-phase.md +0 -195
  1388. package/commands/sdd/session-report.md +0 -19
  1389. package/commands/sdd/set-profile.md +0 -12
  1390. package/scripts/sync-upstream.sh +0 -56
  1391. package/sdd/commands/sdd/workstreams.md +0 -63
  1392. package/sdd/workflows/research-phase.md +0 -82
@@ -6,52 +6,172 @@ Create executable phase prompts (PLAN.md files) for a roadmap phase with integra
6
6
  Read all files referenced by the invoking prompt's execution_context before starting.
7
7
 
8
8
  @~/.claude/sdd/references/ui-brand.md
9
+ @~/.claude/sdd/references/revision-loop.md
10
+ @~/.claude/sdd/references/gate-prompts.md
11
+ @~/.claude/sdd/references/agent-contracts.md
12
+ @~/.claude/sdd/references/gates.md
9
13
  </required_reading>
10
14
 
11
15
  <available_agent_types>
12
16
  Valid SDD subagent types (use exact names — do not fall back to 'general-purpose'):
13
17
  - sdd-phase-researcher — Researches technical approaches for a phase
18
+ - sdd-pattern-mapper — Analyzes codebase for existing patterns, produces PATTERNS.md
14
19
  - sdd-planner — Creates detailed plans from phase scope
15
20
  - sdd-plan-checker — Reviews plan quality before execution
16
21
  </available_agent_types>
17
22
 
18
23
  <process>
19
24
 
25
+ ## 0. Git Branch Invariant
26
+
27
+ **Do not create, rename, or switch git branches during plan-phase.** Branch identity is established at discuss-phase and is owned by the user's git workflow. A phase rename in ROADMAP.md is a plan-level change only — it does not mutate git branch names. If `phase_slug` in the init JSON differs from the current branch name, that is expected and correct; leave the branch unchanged.
28
+
20
29
  ## 1. Initialize
21
30
 
22
31
  Load all context in one call (paths only to minimize orchestrator context):
23
32
 
24
33
  ```bash
25
- INIT=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" init plan-phase "$PHASE")
34
+ INIT=$(sdd-sdk query init.plan-phase "$PHASE")
26
35
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
27
- AGENT_SKILLS_RESEARCHER=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-researcher 2>/dev/null)
28
- AGENT_SKILLS_PLANNER=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-planner 2>/dev/null)
29
- AGENT_SKILLS_CHECKER=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" agent-skills sdd-checker 2>/dev/null)
36
+ AGENT_SKILLS_RESEARCHER=$(sdd-sdk query agent-skills sdd-phase-researcher)
37
+ AGENT_SKILLS_PLANNER=$(sdd-sdk query agent-skills sdd-planner)
38
+ AGENT_SKILLS_CHECKER=$(sdd-sdk query agent-skills sdd-plan-checker)
39
+ CONTEXT_WINDOW=$(sdd-sdk query config-get context_window 2>/dev/null || echo "200000")
40
+ TDD_MODE=$(sdd-sdk query config-get workflow.tdd_mode 2>/dev/null || echo "false")
41
+ MVP_MODE_CFG=$(sdd-sdk query config-get workflow.mvp_mode 2>/dev/null || echo "false")
30
42
  ```
31
43
 
32
- Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_enabled`, `plan_checker_enabled`, `nyquist_validation_enabled`, `commit_docs`, `text_mode`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_reviews`, `has_plans`, `plan_count`, `planning_exists`, `roadmap_exists`, `phase_req_ids`.
44
+ When `TDD_MODE` is `true`, the planner agent is instructed to apply `type: tdd` to eligible tasks using heuristics from `references/tdd.md`. The planner's `<required_reading>` is extended to include `@~/.claude/sdd/references/tdd.md` so gate enforcement rules are available during planning.
45
+
46
+ When `CONTEXT_WINDOW >= 500000`, the planner prompt includes the 3 most recent prior phase CONTEXT.md and SUMMARY.md files PLUS any phases explicitly listed in the current phase's `Depends on:` field in ROADMAP.md. Explicit dependencies always load regardless of recency (e.g., Phase 7 declaring `Depends on: Phase 2` always sees Phase 2's context). Bounded recency keeps the planner's context budget focused on recent work.
47
+
48
+ Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_enabled`, `plan_checker_enabled`, `nyquist_validation_enabled`, `commit_docs`, `text_mode`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_reviews`, `has_plans`, `plan_count`, `phase_status` (#3569), `planning_exists`, `roadmap_exists`, `phase_req_ids`, `response_language`.
49
+
50
+ **If `response_language` is set:** Include `response_language: {value}` in all spawned subagent prompts so any user-facing output stays in the configured language.
33
51
 
34
52
  **File paths (for <files_to_read> blocks):** `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`, `verification_path`, `uat_path`, `reviews_path`. These are null if files don't exist.
35
53
 
36
54
  **If `planning_exists` is false:** Error — run `/sdd:new-project` first.
37
55
 
56
+ ## 1.5. Closed-Phase Gate (#3569)
57
+
58
+ The init JSON includes `phase_status` — one of `Pending | Planned | In Progress | Executed | Complete | Needs Review`. `Complete` means the phase has all summaries AND a `VERIFICATION.md` with `status: passed`. Replanning a closed phase silently rewrites plan docs that no longer match the shipped code, so the workflow must hard-stop here unless the operator explicitly overrides.
59
+
60
+ Parse `phase_status` from the init JSON, then:
61
+
62
+ ```bash
63
+ FORCE_REPLAN=false
64
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--force([[:space:]]|$) ]]; then
65
+ FORCE_REPLAN=true
66
+ fi
67
+
68
+ if [ "${phase_status}" = "Complete" ]; then
69
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--reviews([[:space:]]|$) ]]; then
70
+ # --reviews on a closed phase is never legitimate — concerns belong in a
71
+ # new phase or issue against the closed phase's commits.
72
+ cat <<EOF >&2
73
+ Phase ${phase_number} (${phase_name}) is already CLOSED (VERIFICATION status: passed).
74
+ /sdd:plan-phase --reviews cannot replan a closed phase. If the review surfaced
75
+ real concerns, open a follow-up phase or file an issue against the closed
76
+ phase's commits. There is no --force override for --reviews on a closed phase.
77
+ EOF
78
+ exit 1
79
+ fi
80
+ if [ "$FORCE_REPLAN" != "true" ]; then
81
+ cat <<EOF >&2
82
+ Phase ${phase_number} (${phase_name}) is already CLOSED (VERIFICATION status: passed).
83
+ Replanning a closed phase will overwrite plan docs that no longer match the
84
+ shipped code. If you intentionally want to replan over closed work, re-run
85
+ with: /sdd:plan-phase ${phase_number} --force
86
+
87
+ Otherwise, to view what shipped, see: ${verification_path}
88
+ EOF
89
+ exit 1
90
+ fi
91
+ # FORCE_REPLAN=true: continue, but emit a banner so the operator sees the
92
+ # decision in the transcript and in any committed plan docs.
93
+ echo "WARNING: Replanning CLOSED phase ${phase_number} under --force. Verify the closeout was wrong before committing new plan docs." >&2
94
+ fi
95
+ ```
96
+
97
+ The gate fires only on `Complete`. `Executed` and `Needs Review` are not gated — those states mean planning was finished but verification did not pass, and replanning is a legitimate next step.
98
+
38
99
  ## 2. Parse and Normalize Arguments
39
100
 
40
- Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--gaps`, `--skip-verify`, `--prd <filepath>`, `--reviews`, `--text`).
101
+ Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--research`, `--skip-research`, `--research-phase <N>`, `--gaps`, `--skip-verify`, `--skip-ui`, `--prd <filepath>`, `--ingest <path-or-glob>`, `--ingest-format <auto|nygard|madr|narrative>`, `--reviews`, `--text`, `--bounce`, `--skip-bounce`, `--chunked`, `--mvp`, `--force` (override closed-phase gate, see §1.5)).
102
+
103
+ **`--research-phase <N>` — research-only mode (#3042 + #3044).** When this flag is present, parse `<N>` as the phase number (overrides any positional phase argument), set `RESEARCH_ONLY=true`, and treat the rest of this workflow as a research-dispatch only — the planner spawn (step 8), plan-checker, verification, gaps, bounce, and post-planning-gaps blocks all skip on `RESEARCH_ONLY`. Use this for cross-phase research, doc review before committing to a planning approach, and correction-without-replanning loops. Replaces the deleted `/sdd-research-phase` command.
104
+
105
+ In research-only mode, two modifiers control behavior when `RESEARCH.md` already exists:
106
+
107
+ - **`--research`** — force-refresh re-research without prompting. Re-spawns the researcher unconditionally and overwrites the existing RESEARCH.md. (This is the existing `--research` flag's standard "force re-research" semantics, reused here.)
108
+ - **`--view`** — view-only: print existing `RESEARCH.md` to stdout, do **not** spawn the researcher. Sets `VIEW_ONLY=true`. Cheapest mode for the correction-without-replanning loop. If `RESEARCH.md` does not exist, error with a hint to drop `--view`.
109
+
110
+ ```bash
111
+ RESEARCH_ONLY=false
112
+ VIEW_ONLY=false
113
+ if [[ "$ARGUMENTS" =~ --research-phase[[:space:]]+([0-9]+(\.[0-9]+)?) ]]; then
114
+ RESEARCH_ONLY=true
115
+ PHASE="${BASH_REMATCH[1]}"
116
+ fi
117
+ if $RESEARCH_ONLY && [[ "$ARGUMENTS" =~ (^|[[:space:]])--view([[:space:]]|$) ]]; then
118
+ VIEW_ONLY=true
119
+ fi
120
+ ```
41
121
 
42
122
  Set `TEXT_MODE=true` if `--text` is present in $ARGUMENTS OR `text_mode` from init JSON is `true`. When `TEXT_MODE` is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number. This is required for Claude Code remote sessions (`/rc` mode) where TUI menus don't work through the Claude App.
43
123
 
44
- Extract `--prd <filepath>` from $ARGUMENTS. If present, set PRD_FILE to the filepath.
124
+ **MVP_MODE resolution.** Resolve `MVP_MODE` once via the centralized `phase.mvp-mode` query verb. Precedence (first hit wins): CLI flag → ROADMAP.md `**Mode:** mvp` → `workflow.mvp_mode` config → false. The verb is the single source of truth — do not re-implement the chain.
125
+
126
+ ```bash
127
+ MVP_FLAG_ARG=""
128
+ if [[ "$ARGUMENTS" =~ (^|[[:space:]])--mvp([[:space:]]|$) ]]; then MVP_FLAG_ARG="--cli-flag"; fi
129
+ ```
130
+
131
+ Defer the `phase.mvp-mode` query until `PHASE` is finalized (after explicit argument parsing/fallback phase detection + validation).
132
+ The verb returns `true|false`. Full result also exposes `source` (`cli_flag` | `roadmap` | `config` | `none`) for diagnostics. The mode is **all-or-nothing per phase** (PRD decision Q1) — never selective per task.
133
+
134
+ **Walking Skeleton gate.** When `MVP_MODE=true` AND `phase_number == "01"` AND there are zero prior phase summaries (new project), the planner runs in **Walking Skeleton mode** (per PRD decision Q2 — new projects only). Detect with:
135
+
136
+ ```bash
137
+ WALKING_SKELETON=false
138
+ if [ "$MVP_MODE" = "true" ] && [ "$padded_phase" = "01" ]; then
139
+ PRIOR_SUMMARIES=$(sdd-sdk query phases.list --pick summaries_total 2>/dev/null || echo "0")
140
+ if [ "$PRIOR_SUMMARIES" = "0" ]; then WALKING_SKELETON=true; fi
141
+ fi
142
+ ```
143
+
144
+ When `WALKING_SKELETON=true`:
145
+ - Planner is instructed to produce `SKELETON.md` in the phase directory alongside `PLAN.md`. The template lives at `@~/.claude/sdd/references/skeleton-template.md`.
146
+ - The plan must scaffold project + routing + one real DB read/write + one real UI interaction + dev deployment — the thinnest possible end-to-end working slice.
147
+
148
+ **Interaction with `--prd <filepath>`.** `--mvp` and `--prd` compose. The PRD express path (Step 3.5) creates `CONTEXT.md` from the PRD file and continues to research; the Walking Skeleton gate fires independently from the conditions above. When both are active on Phase 1 of a new project, the planner receives `WALKING_SKELETON=true` and PRD-derived context simultaneously — the PRD informs *what the skeleton should prove*. No precedence is needed; the two signals are orthogonal. See [`references/mvp-concepts.md`](../references/mvp-concepts.md) for the broader interaction map.
149
+
150
+ Extract express-path args from $ARGUMENTS: `PRD_FILE` (`--prd <filepath>`), `INGEST_PATH` (`--ingest <path-or-glob>`), and optional `INGEST_FORMAT` (`--ingest-format <auto|nygard|madr|narrative>`, default `auto`).
151
+
152
+ `--prd` and `--ingest` are mutually exclusive. If both are present, error and exit:
153
+ `Invalid arguments: cannot combine \`--prd\` with \`--ingest\`.`
45
154
 
46
155
  **If no phase number:** Detect next unplanned phase from roadmap.
47
156
 
48
- **If `phase_found` is false:** Validate phase exists in ROADMAP.md. If valid, create the directory using `phase_slug` and `padded_phase` from init:
157
+ **If `phase_found` is false:** Validate phase exists in ROADMAP.md. If valid, create the directory using `expected_phase_dir` from init (includes `project_code` prefix when set):
49
158
  ```bash
50
- mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
159
+ mkdir -p "${expected_phase_dir}"
51
160
  ```
52
161
 
162
+ Set `phase_dir="${expected_phase_dir}"` after creation.
163
+
53
164
  **Existing artifacts from init:** `has_research`, `has_plans`, `plan_count`.
54
165
 
166
+ Set `CHUNKED_MODE` from flag or config:
167
+ ```bash
168
+ CHUNKED_CFG=$(sdd-sdk query config-get workflow.plan_chunked 2>/dev/null || echo "false")
169
+ CHUNKED_MODE=false
170
+ if [[ "$ARGUMENTS" =~ --chunked ]] || [[ "$CHUNKED_CFG" == "true" ]]; then
171
+ CHUNKED_MODE=true
172
+ fi
173
+ ```
174
+
55
175
  ## 2.5. Validate `--reviews` Prerequisite
56
176
 
57
177
  **Skip if:** No `--reviews` flag.
@@ -73,11 +193,16 @@ Exit workflow.
73
193
  ## 3. Validate Phase
74
194
 
75
195
  ```bash
76
- PHASE_INFO=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" roadmap get-phase "${PHASE}")
196
+ PHASE_INFO=$(sdd-sdk query roadmap.get-phase "${PHASE}")
77
197
  ```
78
198
 
79
199
  **If `found` is false:** Error with available phases. **If `found` is true:** Extract `phase_number`, `phase_name`, `goal` from JSON.
80
200
 
201
+ Now that `PHASE` is finalized, resolve MVP mode:
202
+ ```bash
203
+ MVP_MODE=$(sdd-sdk query phase.mvp-mode "${PHASE}" $MVP_FLAG_ARG --pick active)
204
+ ```
205
+
81
206
  ## 3.5. Handle PRD Express Path
82
207
 
83
208
  **Skip if:** No `--prd` flag in arguments.
@@ -175,16 +300,31 @@ Use full relative paths. Group by topic area.]
175
300
 
176
301
  5. Commit:
177
302
  ```bash
178
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" commit "docs(${padded_phase}): generate context from PRD" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
303
+ sdd-sdk query commit "docs(${padded_phase}): generate context from PRD" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
179
304
  ```
180
305
 
181
306
  6. Set `context_content` to the generated CONTEXT.md content and continue to step 5 (Handle Research).
182
307
 
183
308
  **Effect:** This completely bypasses step 4 (Load CONTEXT.md) since we just created it. The rest of the workflow (research, planning, verification) proceeds normally with the PRD-derived context.
184
309
 
310
+ ## 3.6. Handle ADR Ingest Express Path
311
+
312
+ **Skip if:** No `--ingest` flag in arguments.
313
+
314
+ **If `--ingest <path-or-glob>` provided:**
315
+
316
+ 1. Display banner: `SDD ► ADR Ingest Express Path` with `{INGEST_PATH}` and `{INGEST_FORMAT}`.
317
+ 2. Parse each resolved ADR through `sdd/bin/lib/adr-parser.cjs` (`--input`, `--format`) and collect normalized records.
318
+ 3. Status gate: reject `superseded`/`rejected`/`deprecated`; warn on `proposed`; missing status defaults to `accepted`.
319
+ 4. Empty-decisions fallback: if all parsed ADRs have zero `decisions[]`, emit `ADR ingest produced no locked decisions; fall back to discuss-phase for this phase.` and exit with `/sdd:discuss-phase {N}` guidance.
320
+ 5. Generate CONTEXT.md using `<domain>`, `<decisions>`, `<canonical_refs>`, `<specifics>`, `<deferred>`, `<scope_fence>`, map `consequences_positive[]` to Success Criteria and `consequences_negative[]` to Risk Summary, and include `**Source:** ADR Ingest Express Path ({INGEST_PATH})`.
321
+ 6. Commit with `sdd-sdk query commit "docs(${padded_phase}): generate context from ADR ingest" --files "${phase_dir}/${padded_phase}-CONTEXT.md"` and set `context_content`; continue to step 5.
322
+
323
+ **Effect:** This bypasses step 4 (Load CONTEXT.md) since CONTEXT.md was synthesized from ADR input.
324
+
185
325
  ## 4. Load CONTEXT.md
186
326
 
187
- **Skip if:** PRD express path was used (CONTEXT.md already created in step 3.5).
327
+ **Skip if:** PRD express path or ADR ingest express path was used (CONTEXT.md already created in step 3.5/3.6).
188
328
 
189
329
  Check `context_path` from init JSON.
190
330
 
@@ -194,7 +334,7 @@ If `context_path` is not null, display: `Using phase context from: ${context_pat
194
334
 
195
335
  Read discuss mode for context gate label:
196
336
  ```bash
197
- DISCUSS_MODE=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.discuss_mode 2>/dev/null || echo "discuss")
337
+ DISCUSS_MODE=$(sdd-sdk query config-get workflow.discuss_mode 2>/dev/null || echo "discuss")
198
338
  ```
199
339
 
200
340
  If `TEXT_MODE` is true, present as a plain-text numbered list:
@@ -232,10 +372,71 @@ If "Run discuss-phase first":
232
372
  ```
233
373
  **Exit the plan-phase workflow. Do not continue.**
234
374
 
375
+ ## 4.5. Check AI-SPEC
376
+
377
+ **Skip if:** `ai_integration_phase_enabled` from config is false, or `--skip-ai-spec` flag provided.
378
+
379
+ ```bash
380
+ AI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-AI-SPEC.md 2>/dev/null | head -1)
381
+ AI_PHASE_CFG=$(sdd-sdk query config-get workflow.ai_integration_phase 2>/dev/null || echo "true")
382
+ ```
383
+
384
+ **Skip if `AI_PHASE_CFG` is `false`.**
385
+
386
+ **If `AI_SPEC_FILE` is empty:** Check phase goal for AI keywords:
387
+ ```bash
388
+ echo "${phase_goal}" | grep -qi "agent\|llm\|rag\|chatbot\|embedding\|langchain\|llamaindex\|crewai\|langgraph\|openai\|anthropic\|vector\|eval\|ai system"
389
+ ```
390
+
391
+ **If AI keywords detected AND no AI-SPEC.md:**
392
+ ```
393
+ ◆ Note: This phase appears to involve AI system development.
394
+ Consider running /sdd:ai-integration-phase {N} before planning to:
395
+ - Select the right framework for your use case
396
+ - Research its docs and best practices
397
+ - Design an evaluation strategy
398
+
399
+ Continue planning without AI-SPEC? (non-blocking — /sdd:ai-integration-phase can be run after)
400
+ ```
401
+
402
+ Use AskUserQuestion with options:
403
+ - "Continue — plan without AI-SPEC"
404
+ - "Stop — I'll run /sdd:ai-integration-phase {N} first"
405
+
406
+ If "Stop": Exit with `/sdd:ai-integration-phase {N}` reminder.
407
+ If "Continue": Proceed. (Non-blocking — planner will note AI-SPEC is absent.)
408
+
409
+ **If `AI_SPEC_FILE` is non-empty:** Extract framework for planner context:
410
+ ```bash
411
+ FRAMEWORK_LINE=$(grep "Selected Framework:" "${AI_SPEC_FILE}" | head -1)
412
+ ```
413
+ Pass `ai_spec_path` and `framework_line` to planner in step 7 so it can reference the AI design contract.
414
+
235
415
  ## 5. Handle Research
236
416
 
237
417
  **Skip if:** `--gaps` flag or `--skip-research` flag or `--reviews` flag.
238
418
 
419
+ ### 5.0. Research-Only Modifiers (`--view`, `--research`, prompt)
420
+
421
+ **Skip if:** `RESEARCH_ONLY` is `false`.
422
+
423
+ Three branches in research-only mode (`--research-phase <N>`):
424
+
425
+ 1. **`--view`** (or user picks "View" in the prompt below): print `RESEARCH.md` to stdout, no spawn, exit. If `RESEARCH.md` is missing, error with: `--view requires an existing RESEARCH.md; drop --view to spawn the researcher.`
426
+ 2. **`--research`** (force-refresh): re-spawn researcher unconditionally — fall through to "Spawn sdd-phase-researcher" below.
427
+ 3. **Neither flag AND `has_research=true`:** emit `RESEARCH.md already exists for Phase ${PHASE}.` and prompt the user with three choices: `1. Update — re-spawn researcher and refresh RESEARCH.md`, `2. View — print existing RESEARCH.md and exit (no spawn)`, `3. Skip — exit without spawning or printing`. Map "Update" → fall through to spawn, "View" → set `VIEW_ONLY=true` and emit RESEARCH.md as in (1), "Skip" → exit cleanly. Mirrors the deleted `/sdd-research-phase` standalone's existing-artifact menu (#3042 parity).
428
+
429
+ ```bash
430
+ if [[ "$VIEW_ONLY" == "true" ]]; then
431
+ [[ -f "$research_path" ]] || { echo "Error: --view requires an existing RESEARCH.md (Phase ${PHASE}). Drop --view to spawn the researcher."; exit 1; }
432
+ cat "$research_path"; exit 0
433
+ fi
434
+ ```
435
+
436
+ ### 5.1. Standard Research Decision
437
+
438
+ **Skip if** `RESEARCH_ONLY=true` (the research-only mode in 5.0 already determined the path: spawn or exit). Without this guard, an LLM following the workflow could fall through into "use existing, skip to step 6" → planner spawn, violating the research-only contract. **CR #3045 finding: this gate makes the early-exit unreachable from any non-research-only branch.**
439
+
239
440
  **If `has_research` is true (from init) AND no `--research` flag:** Use existing, skip to step 6.
240
441
 
241
442
  **If RESEARCH.md missing OR `--research` flag:**
@@ -284,7 +485,7 @@ Display banner:
284
485
  ### Spawn sdd-phase-researcher
285
486
 
286
487
  ```bash
287
- PHASE_DESC=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" roadmap get-phase "${PHASE}" --pick section)
488
+ PHASE_DESC=$(sdd-sdk query roadmap.get-phase "${PHASE}" --pick section)
288
489
  ```
289
490
 
290
491
  Research prompt:
@@ -317,7 +518,7 @@ Write to: {phase_dir}/{phase_num}-RESEARCH.md
317
518
  ```
318
519
 
319
520
  ```
320
- Task(
521
+ Agent(
321
522
  prompt=research_prompt,
322
523
  subagent_type="sdd-phase-researcher",
323
524
  model="{researcher_model}",
@@ -325,11 +526,31 @@ Task(
325
526
  )
326
527
  ```
327
528
 
529
+ > **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.
530
+
328
531
  ### Handle Researcher Return
329
532
 
330
533
  - **`## RESEARCH COMPLETE`:** Display confirmation, continue to step 6
331
534
  - **`## RESEARCH BLOCKED`:** Display blocker, offer: 1) Provide context, 2) Skip research, 3) Abort
332
535
 
536
+ ### Research-Only Early Exit (`--research-phase`)
537
+
538
+ **Skip if:** `RESEARCH_ONLY` is `false` (the default).
539
+
540
+ **If `RESEARCH_ONLY=true`:** the user invoked `/sdd:plan-phase --research-phase <N>` for research-only mode. Do **not** continue to Section 5.5+ (validation strategy, planner, plan-checker, verification, gaps, bounce, post-planning-gaps). Print the research-complete summary and exit cleanly:
541
+
542
+ ```text
543
+ ✓ Research-only mode complete (#3042)
544
+
545
+ Phase: ${PHASE}
546
+ RESEARCH.md: ${research_path}
547
+
548
+ Re-run /sdd:plan-phase ${PHASE} to plan the phase using this research,
549
+ or /sdd:plan-phase ${PHASE} --research to refresh research and plan.
550
+ ```
551
+
552
+ This exits the workflow. The planner / plan-checker / verifier blocks below are skipped.
553
+
333
554
  ## 5.5. Create Validation Strategy
334
555
 
335
556
  Skip if `nyquist_validation_enabled` is false OR `research_enabled` is false.
@@ -360,13 +581,39 @@ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED
360
581
 
361
582
  **If not found:** Warn and continue — plans may fail Dimension 8.
362
583
 
584
+ ## 5.55. Security Threat Model Gate
585
+
586
+ > Skip if `workflow.security_enforcement` is explicitly `false`. Absent = enabled.
587
+
588
+ ```bash
589
+ SECURITY_CFG=$(sdd-sdk query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
590
+ SECURITY_ASVS=$(sdd-sdk query config-get workflow.security_asvs_level --raw 2>/dev/null || echo "1")
591
+ SECURITY_BLOCK=$(sdd-sdk query config-get workflow.security_block_on --raw 2>/dev/null || echo "high")
592
+ ```
593
+
594
+ **If `SECURITY_CFG` is `false`:** Skip to step 5.6.
595
+
596
+ **If `SECURITY_CFG` is `true`:** Display banner:
597
+
598
+ ```
599
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
600
+ SDD ► SECURITY THREAT MODEL REQUIRED (ASVS L{SECURITY_ASVS})
601
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
602
+
603
+ Each PLAN.md must include a <threat_model> block.
604
+ Block on: {SECURITY_BLOCK} severity threats.
605
+ Opt out: set security_enforcement: false in .planning/config.json
606
+ ```
607
+
608
+ Continue to step 5.6. Security config is passed to the planner in step 8.
609
+
363
610
  ## 5.6. UI Design Contract Gate
364
611
 
365
612
  > Skip if `workflow.ui_phase` is explicitly `false` AND `workflow.ui_safety_gate` is explicitly `false` in `.planning/config.json`. If keys are absent, treat as enabled.
366
613
 
367
614
  ```bash
368
- UI_PHASE_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.ui_phase 2>/dev/null || echo "true")
369
- UI_GATE_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.ui_safety_gate 2>/dev/null || echo "true")
615
+ UI_PHASE_CFG=$(sdd-sdk query config-get workflow.ui_phase 2>/dev/null || echo "true")
616
+ UI_GATE_CFG=$(sdd-sdk query config-get workflow.ui_safety_gate 2>/dev/null || echo "true")
370
617
  ```
371
618
 
372
619
  **If both are `false`:** Skip to step 6.
@@ -374,7 +621,7 @@ UI_GATE_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.ui_
374
621
  Check if phase has frontend indicators:
375
622
 
376
623
  ```bash
377
- PHASE_SECTION=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" roadmap get-phase "${PHASE}" 2>/dev/null)
624
+ PHASE_SECTION=$(sdd-sdk query roadmap.get-phase "${PHASE}" 2>/dev/null)
378
625
  echo "$PHASE_SECTION" | grep -iE "UI|interface|frontend|component|layout|page|screen|view|form|dashboard|widget" > /dev/null 2>&1
379
626
  HAS_UI=$?
380
627
  ```
@@ -388,28 +635,106 @@ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
388
635
 
389
636
  **If UI-SPEC.md found:** Set `UI_SPEC_PATH=$UI_SPEC_FILE`. Display: `Using UI design contract: ${UI_SPEC_PATH}`
390
637
 
638
+ **If UI-SPEC.md missing AND `--skip-ui` flag is present in $ARGUMENTS:** Skip silently to step 6.
639
+
391
640
  **If UI-SPEC.md missing AND `UI_GATE_CFG` is `true`:**
392
641
 
393
- If `TEXT_MODE` is true, present as a plain-text numbered list:
642
+ Read ephemeral chain flag (same field as `check.auto-mode` `auto_chain_active`):
643
+ ```bash
644
+ AUTO_CHAIN=$(sdd-sdk query check auto-mode --pick auto_chain_active 2>/dev/null || echo "false")
394
645
  ```
395
- Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?
396
646
 
397
- 1. Generate UI-SPEC first Run /sdd:ui-phase {N} then re-run /sdd:plan-phase {N}
398
- 2. Continue without UI-SPEC
399
- 3. Not a frontend phase
647
+ **If `AUTO_CHAIN` is `true` (running inside a `--chain` or `--auto` pipeline):**
400
648
 
401
- Enter number:
649
+ Auto-generate UI-SPEC without prompting:
650
+ ```
651
+ Skill(skill="sdd-ui-phase", args="${PHASE} --auto ${SDD_WS}")
652
+ ```
653
+ After `sdd-ui-phase` returns, re-read:
654
+ ```bash
655
+ UI_SPEC_FILE=$(ls "${PHASE_DIR}"/*-UI-SPEC.md 2>/dev/null | head -1)
656
+ UI_SPEC_PATH="${UI_SPEC_FILE}"
402
657
  ```
658
+ Continue to step 6.
403
659
 
404
- Otherwise use AskUserQuestion:
405
- - header: "UI Design Contract"
406
- - question: "Phase {N} has frontend indicators but no UI-SPEC.md. Generate a design contract before planning?"
407
- - options:
408
- - "Generate UI-SPEC first" → Display: "Run `/sdd:ui-phase {N} ${SDD_WS}` then re-run `/sdd:plan-phase {N} ${SDD_WS}`". Exit workflow.
409
- - "Continue without UI-SPEC" Continue to step 6.
410
- - "Not a frontend phase" → Continue to step 6.
660
+ **If `AUTO_CHAIN` is `false` (manual invocation):**
661
+
662
+ Output this markdown directly (not as a code block):
663
+
664
+ ```
665
+ ## UI-SPEC.md missing for Phase {N}
666
+ Recommended next step:
667
+ `/sdd:ui-phase {N} ${SDD_WS}` — generate UI design contract before planning
668
+ ───────────────────────────────────────────────
669
+ Also available:
670
+ - `/sdd:plan-phase {N} --skip-ui ${SDD_WS}` — plan without UI-SPEC (not recommended for frontend phases)
671
+ ```
672
+
673
+ **Exit the plan-phase workflow. Do not continue.**
674
+
675
+ **If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 5.7.
676
+
677
+ ## 5.7. Schema Push Detection Gate
411
678
 
412
- **If `HAS_UI` is 1 (no frontend indicators):** Skip silently to step 6.
679
+ > Detects schema-relevant files in the phase scope and injects a mandatory `[BLOCKING]` schema push task into the plan. Prevents false-positive verification where build/types pass because TypeScript types come from config, not the live database.
680
+
681
+ Check if any files in the phase scope match schema patterns:
682
+
683
+ ```bash
684
+ PHASE_SECTION=$(sdd-sdk query roadmap.get-phase "${PHASE}" --pick section 2>/dev/null)
685
+ ```
686
+
687
+ Scan `PHASE_SECTION`, `CONTEXT.md` (if loaded), and `RESEARCH.md` (if exists) for file paths matching these ORM patterns:
688
+
689
+ | ORM | File Patterns |
690
+ |-----|--------------|
691
+ | Payload CMS | `src/collections/**/*.ts`, `src/globals/**/*.ts` |
692
+ | Prisma | `prisma/schema.prisma`, `prisma/schema/*.prisma` |
693
+ | Drizzle | `drizzle/schema.ts`, `src/db/schema.ts`, `drizzle/*.ts` |
694
+ | Supabase | `supabase/migrations/*.sql` |
695
+ | TypeORM | `src/entities/**/*.ts`, `src/migrations/**/*.ts` |
696
+
697
+ Also check if any existing PLAN.md files for this phase already reference these file patterns in `files_modified`.
698
+
699
+ **If schema-relevant files detected:**
700
+
701
+ Set `SCHEMA_PUSH_REQUIRED=true` and `SCHEMA_ORM={detected_orm}`.
702
+
703
+ Determine the push command for the detected ORM:
704
+
705
+ | ORM | Push Command | Non-TTY Workaround |
706
+ |-----|-------------|-------------------|
707
+ | Payload CMS | `npx payload migrate` | `CI=true PAYLOAD_MIGRATING=true npx payload migrate` |
708
+ | Prisma | `npx prisma db push` | `npx prisma db push --accept-data-loss` (if destructive) |
709
+ | Drizzle | `npx drizzle-kit push` | `npx drizzle-kit push` |
710
+ | Supabase | `supabase db push` | Set `SUPABASE_ACCESS_TOKEN` env var |
711
+ | TypeORM | `npx typeorm migration:run` | `npx typeorm migration:run -d src/data-source.ts` |
712
+
713
+ Inject the following into the planner prompt (step 8) as an additional constraint:
714
+
715
+ ```markdown
716
+ <schema_push_requirement>
717
+ **[BLOCKING] Schema Push Required**
718
+
719
+ This phase modifies schema-relevant files ({detected_files}). The planner MUST include
720
+ a `[BLOCKING]` task that runs the database schema push command AFTER all schema file
721
+ modifications are complete but BEFORE verification.
722
+
723
+ - ORM detected: {SCHEMA_ORM}
724
+ - Push command: {push_command}
725
+ - Non-TTY workaround: {env_hint}
726
+ - If push requires interactive prompts that cannot be suppressed, flag the task for
727
+ manual intervention with `autonomous: false`
728
+
729
+ This task is mandatory — the phase CANNOT pass verification without it. Build and
730
+ type checks will pass without the push (types come from config, not the live database),
731
+ creating a false-positive verification state.
732
+ </schema_push_requirement>
733
+ ```
734
+
735
+ Display: `Schema files detected ({SCHEMA_ORM}) — [BLOCKING] push task will be injected into plans`
736
+
737
+ **If no schema-relevant files detected:** Skip silently to step 6.
413
738
 
414
739
  ## 6. Check Existing Plans
415
740
 
@@ -435,6 +760,11 @@ VERIFICATION_PATH=$(_sdd_field "$INIT" verification_path)
435
760
  UAT_PATH=$(_sdd_field "$INIT" uat_path)
436
761
  CONTEXT_PATH=$(_sdd_field "$INIT" context_path)
437
762
  REVIEWS_PATH=$(_sdd_field "$INIT" reviews_path)
763
+ PATTERNS_PATH=$(_sdd_field "$INIT" patterns_path)
764
+
765
+ # Detect spike/sketch findings skills (project-local)
766
+ SPIKE_FINDINGS_PATH=$(ls ./.claude/skills/spike-findings-*/SKILL.md 2>/dev/null | head -1 || true)
767
+ SKETCH_FINDINGS_PATH=$(ls ./.claude/skills/sketch-findings-*/SKILL.md 2>/dev/null | head -1 || true)
438
768
  ```
439
769
 
440
770
  ## 7.5. Verify Nyquist Artifacts
@@ -455,10 +785,71 @@ VALIDATION_EXISTS=$(ls "${PHASE_DIR}"/*-VALIDATION.md 2>/dev/null | head -1)
455
785
  If missing and Nyquist is still enabled/applicable — ask user:
456
786
  1. Re-run: `/sdd:plan-phase {PHASE} --research ${SDD_WS}`
457
787
  2. Disable Nyquist with the exact command:
458
- `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-set workflow.nyquist_validation false`
788
+ `sdd-sdk query config-set workflow.nyquist_validation false`
459
789
  3. Continue anyway (plans fail Dimension 8)
460
790
 
461
- Proceed to Step 8 only if user selects 2 or 3.
791
+ Proceed to Step 7.8 (or Step 8 if pattern mapper is disabled) only if user selects 2 or 3.
792
+
793
+ ## 7.8. Spawn sdd-pattern-mapper Agent (Optional)
794
+
795
+ **Skip if** `workflow.pattern_mapper` is explicitly set to `false` in config.json (absent key = enabled). Also skip if no CONTEXT.md and no RESEARCH.md exist for this phase (nothing to extract file lists from).
796
+
797
+ Check config:
798
+ ```bash
799
+ PATTERN_MAPPER_CFG=$(sdd-sdk query config-get workflow.pattern_mapper 2>/dev/null || echo "true")
800
+ ```
801
+
802
+ **If `PATTERN_MAPPER_CFG` is `false`:** Skip to step 8.
803
+
804
+ **If PATTERNS.md already exists** (`PATTERNS_PATH` is non-empty from step 7): Skip to step 8 (use existing).
805
+
806
+ Display banner:
807
+ ```
808
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
809
+ SDD ► PATTERN MAPPING PHASE {X}
810
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
811
+
812
+ ◆ Spawning pattern mapper...
813
+ ```
814
+
815
+ Pattern mapper prompt:
816
+
817
+ ```markdown
818
+ <pattern_mapping_context>
819
+ **Phase:** {phase_number} - {phase_name}
820
+ **Phase directory:** {phase_dir}
821
+ **Padded phase:** {padded_phase}
822
+
823
+ <files_to_read>
824
+ - {context_path} (USER DECISIONS from /sdd:discuss-phase)
825
+ - {research_path} (Technical Research)
826
+ </files_to_read>
827
+
828
+ **Output file:** {phase_dir}/{padded_phase}-PATTERNS.md
829
+
830
+ Extract the list of files to be created/modified from CONTEXT.md and RESEARCH.md. For each file, classify by role and data flow, find the closest existing analog in the codebase, extract concrete code excerpts, and produce PATTERNS.md.
831
+ </pattern_mapping_context>
832
+ ```
833
+
834
+ Spawn with:
835
+ ```
836
+ Agent(
837
+ prompt="{above}",
838
+ subagent_type="sdd-pattern-mapper",
839
+ model="{researcher_model}",
840
+ )
841
+ ```
842
+
843
+ > **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.
844
+
845
+ **Handle return:**
846
+ - **`## PATTERN MAPPING COMPLETE`:** Update `PATTERNS_PATH` to the created file path, continue to step 8.
847
+ - **Any error or empty return:** Log warning, continue to step 8 without patterns (non-blocking).
848
+
849
+ After pattern mapper completes, update the path variable:
850
+ ```bash
851
+ PATTERNS_PATH="${PHASE_DIR}/${PADDED_PHASE}-PATTERNS.md"
852
+ ```
462
853
 
463
854
  ## 8. Spawn sdd-planner Agent
464
855
 
@@ -484,10 +875,21 @@ Planner prompt:
484
875
  - {requirements_path} (Requirements)
485
876
  - {context_path} (USER DECISIONS from /sdd:discuss-phase)
486
877
  - {research_path} (Technical Research)
878
+ - {PATTERNS_PATH} (Pattern Map — analog files and code excerpts, if exists)
487
879
  - {verification_path} (Verification Gaps - if --gaps)
488
880
  - {uat_path} (UAT Gaps - if --gaps)
489
881
  - {reviews_path} (Cross-AI Review Feedback - if --reviews)
490
882
  - {UI_SPEC_PATH} (UI Design Contract — visual/interaction specs, if exists)
883
+ - {SPIKE_FINDINGS_PATH} (Spike Findings — validated patterns, constraints, landmines from experiments, if exists)
884
+ - {SKETCH_FINDINGS_PATH} (Sketch Findings — validated design decisions, CSS patterns, visual direction, if exists)
885
+ ${CONTEXT_WINDOW >= 500000 ? `
886
+ **Cross-phase context (1M model enrichment):**
887
+ - CONTEXT.md files from the 3 most recent completed phases (locked decisions — maintain consistency)
888
+ - SUMMARY.md files from the 3 most recent completed phases (what was built — reuse patterns, avoid duplication)
889
+ - LEARNINGS.md files from the 3 most recent completed phases (structured decisions, patterns, lessons, surprises — skip silently if a phase has no LEARNINGS.md; prefix each block with \`[from Phase N LEARNINGS]\` for source attribution; if total size exceeds 15% of context budget, drop oldest first)
890
+ - CONTEXT.md, SUMMARY.md, and LEARNINGS.md from any phases listed in the current phase's "Depends on:" field in ROADMAP.md (regardless of recency — explicit dependencies always load, deduplicated against the 3 most recent)
891
+ - Skip all other prior phases to stay within context budget
892
+ ` : ''}
491
893
  </files_to_read>
492
894
 
493
895
  ${AGENT_SKILLS_PLANNER}
@@ -496,6 +898,26 @@ ${AGENT_SKILLS_PLANNER}
496
898
 
497
899
  **Project instructions:** Read ./CLAUDE.md if exists — follow project-specific guidelines
498
900
  **Project skills:** Check .claude/skills/ or .agents/skills/ directory (if either exists) — read SKILL.md files, plans should account for project skill rules
901
+
902
+ ${TDD_MODE === 'true' ? `
903
+ <tdd_mode_active>
904
+ **TDD Mode is ENABLED.** Apply TDD heuristics from @~/.claude/sdd/references/tdd.md to all eligible tasks:
905
+ - Business logic with defined I/O → type: tdd
906
+ - API endpoints with request/response contracts → type: tdd
907
+ - Data transformations, validation, algorithms → type: tdd
908
+ - UI, config, glue code, CRUD → standard plan (type: execute)
909
+ Each TDD plan gets one feature with RED/GREEN/REFACTOR gate sequence.
910
+ </tdd_mode_active>
911
+ ` : ''}
912
+
913
+ **MVP_MODE:** ${MVP_MODE} (when true, follow vertical-slice rules from `@~/.claude/sdd/references/planner-mvp-mode.md`; when false, ignore MVP guidance entirely.)
914
+ **WALKING_SKELETON:** ${WALKING_SKELETON} (when true, the first deliverable must be a Walking Skeleton — produce SKELETON.md alongside PLAN.md.)
915
+
916
+ ${MVP_MODE === 'true' ? `
917
+ <mvp_mode_active>
918
+ **MVP Mode is ENABLED.** Follow vertical-slice planning rules from @~/.claude/sdd/references/planner-mvp-mode.md. Each plan must deliver a complete vertical slice — thin end-to-end functionality rather than horizontal layers.
919
+ </mvp_mode_active>
920
+ ` : ''}
499
921
  </planning_context>
500
922
 
501
923
  <downstream_consumer>
@@ -517,22 +939,24 @@ Every task MUST include these fields — they are NOT optional:
517
939
  - Any file whose patterns, signatures, types, or conventions must be replicated or respected
518
940
 
519
941
  2. **`<acceptance_criteria>`** — Verifiable conditions that prove the task was done correctly. Rules:
520
- - Every criterion must be checkable with grep, file read, test command, or CLI output
942
+ - Every criterion must be checkable as a source assertion, behavior assertion, test command, or CLI output
521
943
  - NEVER use subjective language ("looks correct", "properly configured", "consistent with")
522
- - ALWAYS include exact strings, patterns, values, or command outputs that must be present
944
+ - Include exact strings, patterns, values, command outputs, or observable behavior where that is the right proof
523
945
  - Examples:
524
946
  - Code: `auth.py contains def verify_token(` / `test_auth.py exits 0`
947
+ - Behavior: `POST /api/auth/login returns 200 + httpOnly JWT cookie for valid credentials`
525
948
  - Config: `.env.example contains DATABASE_URL=` / `Dockerfile contains HEALTHCHECK`
526
949
  - Docs: `README.md contains '## Installation'` / `API.md lists all endpoints`
527
950
  - Infra: `deploy.yml has rollback step` / `docker-compose.yml has healthcheck for db`
528
951
 
529
952
  3. **`<action>`** — Must include CONCRETE values, not references. Rules:
530
953
  - NEVER say "align X with Y", "match X to Y", "update to be consistent" without specifying the exact target state
531
- - ALWAYS include the actual values: config keys, function signatures, SQL statements, class names, import paths, env vars, etc.
532
- - If CONTEXT.md has a comparison table or expected values, copy them into the action verbatim
533
- - The executor should be able to complete the task from the action text alone, without needing to read CONTEXT.md or reference files (read_first is for verification, not discovery)
954
+ - Include concrete identifiers and reference values: config keys, function signatures, SQL table names, class names, import paths, env vars, endpoint paths, etc.
955
+ - If CONTEXT.md has a comparison table or expected values, copy only the target identifiers/values needed to remove ambiguity
956
+ - Do not include full file contents, fenced code blocks, or complete implementations in `<action>`
957
+ - The executor should understand the intended target state from `<action>` and use `<read_first>` files for current implementation details, patterns, and source-of-truth context
534
958
 
535
- **Why this matters:** Executor agents work from the plan text. Vague instructions like "update the config to match production" produce shallow one-line changes. Concrete instructions like "add DATABASE_URL=postgresql://... , set POOL_SIZE=20, add REDIS_URL=redis://..." produce complete work. The cost of verbose plans is far less than the cost of re-doing shallow execution.
959
+ **Why this matters:** Executor agents work from the plan text. Vague instructions like "update the config to match production" produce shallow one-line changes. Concrete instructions like "add DATABASE_URL, set POOL_SIZE=20, add REDIS_URL, and read config/runtime.ts before editing" produce complete work without turning the planner into the executor.
536
960
  </deep_work_rules>
537
961
 
538
962
  <quality_gate>
@@ -540,16 +964,18 @@ Every task MUST include these fields — they are NOT optional:
540
964
  - [ ] Each plan has valid frontmatter
541
965
  - [ ] Tasks are specific and actionable
542
966
  - [ ] Every task has `<read_first>` with at least the file being modified
543
- - [ ] Every task has `<acceptance_criteria>` with grep-verifiable conditions
544
- - [ ] Every `<action>` contains concrete values (no "align X with Y" without specifying what)
967
+ - [ ] Every task has `<acceptance_criteria>` with behavior, test-command, CLI, or source assertions
968
+ - [ ] Every `<action>` contains concrete identifiers without fenced code blocks or full implementations
545
969
  - [ ] Dependencies correctly identified
546
970
  - [ ] Waves assigned for parallel execution
547
971
  - [ ] must_haves derived from phase goal
548
972
  </quality_gate>
549
973
  ```
550
974
 
551
- ```
552
- Task(
975
+ **If `CHUNKED_MODE` is `false` (default):** Spawn the planner as a single long-lived Agent:
976
+
977
+ ```text
978
+ Agent(
553
979
  prompt=filled_prompt,
554
980
  subagent_type="sdd-planner",
555
981
  model="{planner_model}",
@@ -557,11 +983,214 @@ Task(
557
983
  )
558
984
  ```
559
985
 
986
+ > **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.
987
+
988
+ **If `CHUNKED_MODE` is `true`:** Skip the Agent() call above — proceed to step 8.5 instead.
989
+
990
+ ## 8.5. Chunked Planning Mode
991
+
992
+ **Skip if `CHUNKED_MODE` is `false`.**
993
+
994
+ Chunked mode splits the single long-lived planner Agent run into a short outline Agent run followed by
995
+ N short per-plan Agent runs. Each run is bounded to ~3–5 min; each plan is committed individually
996
+ for crash resilience. If any run hangs and the terminal is force-killed, rerunning
997
+ `/sdd:plan-phase {N} --chunked` resumes from the last successfully committed plan.
998
+
999
+ **Intended for new or in-progress chunked runs.** To recover plans already written by a prior
1000
+ *non-chunked* run, use step 6's "Add more plans" or proceed directly to `/sdd:execute-phase`
1001
+ — don't start a fresh chunked run over existing non-chunked plans.
1002
+
1003
+ ### 8.5.1 Outline Phase (outline-only mode, ~2 min)
1004
+
1005
+ **Resume detection:** If `${PHASE_DIR}/${PADDED_PHASE}-PLAN-OUTLINE.md` already exists **and
1006
+ is valid** (contains the `## OUTLINE COMPLETE` marker), skip this sub-step — the outline
1007
+ already exists from a previous run. Proceed directly to 8.5.2.
1008
+
1009
+ ```bash
1010
+ OUTLINE_FILE="${PHASE_DIR}/${PADDED_PHASE}-PLAN-OUTLINE.md"
1011
+ if [[ -f "$OUTLINE_FILE" ]] && grep -q "^## OUTLINE COMPLETE" "$OUTLINE_FILE"; then
1012
+ # reuse existing outline — skip to 8.5.2
1013
+ fi
1014
+ ```
1015
+
1016
+ Display:
1017
+ ```text
1018
+ ◆ Chunked mode: spawning outline planner...
1019
+ ```
1020
+
1021
+ Spawn the planner in **outline-only** mode — it must write only the outline manifest, not any
1022
+ PLAN.md files:
1023
+
1024
+ ```javascript
1025
+ Agent(
1026
+ prompt="{same planning_context as step 8, plus:}
1027
+
1028
+ **Chunked mode: outline-only.**
1029
+ Do NOT write any PLAN.md files in this Task.
1030
+ Write only: {PHASE_DIR}/{PADDED_PHASE}-PLAN-OUTLINE.md
1031
+
1032
+ The outline must be a markdown table with columns:
1033
+ Plan ID | Objective | Wave | Depends On | Requirements
1034
+
1035
+ Return: ## OUTLINE COMPLETE with plan count.",
1036
+ subagent_type="sdd-planner",
1037
+ model="{planner_model}",
1038
+ description="Outline Phase {phase} (chunked)"
1039
+ )
1040
+ ```
1041
+
1042
+ > **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.
1043
+
1044
+ Handle return:
1045
+ - **`## OUTLINE COMPLETE`:** Read `PLAN-OUTLINE.md`, extract plan list. Continue to 8.5.2.
1046
+ - **Any other return or empty:** Display error. Offer: 1) Retry outline, 2) Stop.
1047
+
1048
+ ### 8.5.2 Per-Plan Tasks (single-plan mode, ~3-5 min each)
1049
+
1050
+ For each plan entry extracted from `PLAN-OUTLINE.md`:
1051
+
1052
+ 1. **Resume check:** If `${PHASE_DIR}/{plan_id}-PLAN.md` already exists on disk **and has
1053
+ valid YAML frontmatter** (opening `---` delimiter present), skip this plan (do not
1054
+ overwrite completed work — resume safety).
1055
+
1056
+ ```bash
1057
+ PLAN_FILE="${PHASE_DIR}/${plan_id}-PLAN.md"
1058
+ if [[ -f "$PLAN_FILE" ]] && head -1 "$PLAN_FILE" | grep -q '^---'; then
1059
+ continue # plan already written, skip
1060
+ fi
1061
+ ```
1062
+
1063
+ 2. Display:
1064
+ ```text
1065
+ ◆ Chunked mode: planning {plan_id} ({k}/{N})...
1066
+ ```
1067
+
1068
+ 3. Spawn the planner in **single-plan** mode — it must write exactly one PLAN.md file:
1069
+ ```javascript
1070
+ Agent(
1071
+ prompt="{same planning_context as step 8, plus:}
1072
+
1073
+ **Chunked mode: single-plan.**
1074
+ Write exactly ONE plan file: {PHASE_DIR}/{plan_id}-PLAN.md
1075
+ Plan to write: {plan_id} — {objective}
1076
+ Wave: {wave} | Depends on: {depends_on}
1077
+ Phase requirement IDs to cover in this plan: {plan_requirements}
1078
+
1079
+ Return: ## PLAN COMPLETE with the plan ID.",
1080
+ subagent_type="sdd-planner",
1081
+ model="{planner_model}",
1082
+ description="Plan {plan_id} (chunked {k}/{N})"
1083
+ )
1084
+ ```
1085
+
1086
+ > **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.
1087
+
1088
+ 4. **Verify disk:** Check `${PHASE_DIR}/{plan_id}-PLAN.md` exists. If missing: offer 1) Retry, 2) Stop.
1089
+
1090
+ 5. **Commit per-plan:**
1091
+ ```bash
1092
+ sdd-sdk query commit "docs(${PADDED_PHASE}): plan ${plan_id} (chunked)" --files "${PHASE_DIR}/${plan_id}-PLAN.md"
1093
+ ```
1094
+
1095
+ After all N plans are written and committed, treat this as `## PLANNING COMPLETE` and continue
1096
+ to step 9.
1097
+
560
1098
  ## 9. Handle Planner Return
561
1099
 
562
1100
  - **`## PLANNING COMPLETE`:** Display plan count. If `--skip-verify` or `plan_checker_enabled` is false (from init): skip to step 13. Otherwise: step 10.
1101
+ - **`## PHASE SPLIT RECOMMENDED`:** The planner determined the phase exceeds the context budget for full-fidelity implementation of all source items. Handle in step 9b.
1102
+ - **`## ⚠ Source Audit: Unplanned Items Found`:** The planner's multi-source coverage audit found items from REQUIREMENTS.md, RESEARCH.md, ROADMAP goal, or CONTEXT.md decisions that are not covered by any plan. Handle in step 9c.
563
1103
  - **`## CHECKPOINT REACHED`:** Present to user, get response, spawn continuation (step 12)
564
1104
  - **`## PLANNING INCONCLUSIVE`:** Show attempts, offer: Add context / Retry / Manual
1105
+ - **Empty / truncated / no recognized marker:** → Filesystem fallback (step 9a).
1106
+
1107
+ ## 9a. Filesystem Fallback (Planner)
1108
+
1109
+ **Triggered when:** Agent() returns but the return contains no recognized marker (`## PLANNING COMPLETE`, `## PHASE SPLIT RECOMMENDED`, `## ⚠ Source Audit`, `## CHECKPOINT REACHED`, `## PLANNING INCONCLUSIVE`).
1110
+
1111
+ ```bash
1112
+ DISK_PLANS=$(ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1113
+ ```
1114
+
1115
+ **If `DISK_PLANS` > 0:** The planner wrote plans to disk but the Agent() return was empty or
1116
+ truncated (the Windows stdio hang pattern — the subagent finished but the return never
1117
+ arrived). Display:
1118
+
1119
+ ```text
1120
+ ◆ Planner wrote {DISK_PLANS} plan(s) to disk but did not emit a PLANNING COMPLETE marker.
1121
+ This is a known Windows stdio hang pattern — work is likely recoverable.
1122
+
1123
+ Plans found on disk:
1124
+ {ls output of *-PLAN.md}
1125
+ ```
1126
+
1127
+ Offer 3 options:
1128
+ 1. **Accept plans** — treat as `## PLANNING COMPLETE` and continue through step 9 `## PLANNING COMPLETE` handling (so `--skip-verify` / `plan_checker_enabled=false` are honored — may skip to step 13 rather than step 10)
1129
+ 2. **Retry planner** — re-spawn the planner with the same prompt (return to step 8)
1130
+ 3. **Stop** — exit; user can re-run `/sdd:plan-phase {N}` to resume
1131
+
1132
+ **If `DISK_PLANS` is 0 and no marker:** The planner produced no output. Treat as
1133
+ `## PLANNING INCONCLUSIVE` and handle accordingly.
1134
+
1135
+ ## 9b. Handle Phase Split Recommendation
1136
+
1137
+ When the planner returns `## PHASE SPLIT RECOMMENDED`, it means the phase's source items exceed the context budget for full-fidelity implementation. The planner proposes groupings.
1138
+
1139
+ **Extract from planner return:**
1140
+ - Proposed sub-phases (e.g., "17a: processing core (D-01 to D-19)", "17b: billing + config UX (D-20 to D-27)")
1141
+ - Which source items (REQ-IDs, D-XX decisions, RESEARCH items) go in each sub-phase
1142
+ - Why the split is necessary (context cost estimate, file count)
1143
+
1144
+ **Present to user:**
1145
+ ```
1146
+ ## Phase {X} exceeds context budget for full-fidelity implementation
1147
+
1148
+ The planner found {N} source items that exceed the context budget when
1149
+ planned at full fidelity. Instead of reducing scope, we recommend splitting:
1150
+
1151
+ **Option 1: Split into sub-phases**
1152
+ - Phase {X}a: {name} — {items} ({N} source items, ~{P}% context)
1153
+ - Phase {X}b: {name} — {items} ({M} source items, ~{Q}% context)
1154
+
1155
+ **Option 2: Proceed anyway** (planner will attempt all, quality may degrade past 50% context)
1156
+
1157
+ **Option 3: Prioritize** — you choose which items to implement now,
1158
+ rest become a follow-up phase
1159
+ ```
1160
+
1161
+ Use AskUserQuestion with these 3 options.
1162
+
1163
+ **If "Split":** Use `/sdd:phase --insert` to create the sub-phases, then replan each.
1164
+ **If "Proceed":** Return to planner with instruction to attempt all items at full fidelity, accepting more plans/tasks.
1165
+ **If "Prioritize":** Use AskUserQuestion (multiSelect) to let user pick which items are "now" vs "later". Create CONTEXT.md for each sub-phase with the selected items.
1166
+
1167
+ ## 9c. Handle Source Audit Gaps
1168
+
1169
+ When the planner returns `## ⚠ Source Audit: Unplanned Items Found`, it means items from REQUIREMENTS.md, RESEARCH.md, ROADMAP goal, or CONTEXT.md decisions have no corresponding plan.
1170
+
1171
+ **Extract from planner return:**
1172
+ - Each unplanned item with its source artifact and section
1173
+ - The planner's suggested options (A: add plan, B: split phase, C: defer with confirmation)
1174
+
1175
+ **Present each gap to user.** For each unplanned item:
1176
+
1177
+ ```
1178
+ ## ⚠ Unplanned: {item description}
1179
+
1180
+ Source: {RESEARCH.md / REQUIREMENTS.md / ROADMAP goal / CONTEXT.md}
1181
+ Details: {why the planner flagged this}
1182
+
1183
+ Options:
1184
+ 1. Add a plan to cover this item (recommended)
1185
+ 2. Split phase — move to a sub-phase with related items
1186
+ 3. Defer — add to backlog (developer confirms this is intentional)
1187
+ ```
1188
+
1189
+ Use AskUserQuestion for each gap (or batch if multiple gaps).
1190
+
1191
+ **If "Add plan":** Return to planner (step 8) with instruction to add plans covering the missing items, preserving existing plans.
1192
+ **If "Split":** Use `/sdd:phase --insert` for overflow items, then replan.
1193
+ **If "Defer":** Record in CONTEXT.md `## Deferred Ideas` with developer's confirmation. Proceed to step 10.
565
1194
 
566
1195
  ## 10. Spawn sdd-plan-checker Agent
567
1196
 
@@ -604,7 +1233,7 @@ ${AGENT_SKILLS_CHECKER}
604
1233
  ```
605
1234
 
606
1235
  ```
607
- Task(
1236
+ Agent(
608
1237
  prompt=checker_prompt,
609
1238
  subagent_type="sdd-plan-checker",
610
1239
  model="{checker_model}",
@@ -612,18 +1241,87 @@ Task(
612
1241
  )
613
1242
  ```
614
1243
 
1244
+ > **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.
1245
+
615
1246
  ## 11. Handle Checker Return
616
1247
 
617
1248
  - **`## VERIFICATION PASSED`:** Display confirmation, proceed to step 13.
618
1249
  - **`## ISSUES FOUND`:** Display issues, check iteration count, proceed to step 12.
1250
+ - **Empty / truncated / no recognized marker:** → Filesystem fallback (step 11a).
1251
+
1252
+ **Thinking partner for architectural tradeoffs (conditional):**
1253
+ If `features.thinking_partner` is enabled, scan the checker's issues for architectural tradeoff keywords
1254
+ ("architecture", "approach", "strategy", "pattern", "vs", "alternative"). If found:
1255
+
1256
+ ```
1257
+ The plan-checker flagged an architectural decision point:
1258
+ {issue description}
1259
+
1260
+ Brief analysis:
1261
+ - Option A: {approach_from_plan} — {pros/cons}
1262
+ - Option B: {alternative_approach} — {pros/cons}
1263
+ - Recommendation: {choice} aligned with {phase_goal}
1264
+
1265
+ Apply this to the revision? [Yes] / [No, I'll decide]
1266
+ ```
1267
+
1268
+ If yes: include the recommendation in the revision prompt. If no: proceed to revision loop as normal.
1269
+ If thinking_partner disabled: skip this block entirely.
1270
+
1271
+ ## 11a. Filesystem Fallback (Checker)
1272
+
1273
+ **Triggered when:** Checker Agent() returns but the return contains neither `## VERIFICATION PASSED` nor `## ISSUES FOUND`.
1274
+
1275
+ ```bash
1276
+ DISK_PLANS=$(ls "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1277
+ ```
1278
+
1279
+ **If `DISK_PLANS` > 0:** Plans exist on disk; the checker return was empty or truncated (the
1280
+ Windows stdio hang pattern — the subagent finished but the return never arrived). Display:
1281
+
1282
+ ```text
1283
+ ◆ Checker return was empty or truncated. {DISK_PLANS} plan(s) exist on disk.
1284
+ This is a known Windows stdio hang pattern — checker may have completed without returning.
1285
+ ```
1286
+
1287
+ Offer 3 options:
1288
+ 1. **Accept verification** — treat as `## VERIFICATION PASSED` and continue to step 13
1289
+ 2. **Retry checker** — re-spawn the checker with the same prompt (return to step 10)
1290
+ 3. **Stop** — exit; user can re-run `/sdd:plan-phase {N}` to resume
1291
+
1292
+ **If `DISK_PLANS` is 0:** No plans on disk — something is seriously wrong. Display error and stop.
619
1293
 
620
1294
  ## 12. Revision Loop (Max 3 Iterations)
621
1295
 
622
1296
  Track `iteration_count` (starts at 1 after initial plan + check).
1297
+ Track `prev_issue_count` (initialized to `Infinity` before the loop begins).
1298
+ Track `stall_reentry_count` (starts at 0; incremented each time "Adjust approach" re-enters step 8).
623
1299
 
624
1300
  **If iteration_count < 3:**
625
1301
 
626
- Display: `Sending back to planner for revision... (iteration {N}/3)`
1302
+ Parse issue count from checker return: count BLOCKER + WARNING entries in the YAML issues block (structured output from sdd-plan-checker). If the checker's return contains no YAML issues block (i.e., the plan was approved with no issues), treat `issue_count` as 0 and skip the stall check — the plan passed. Proceed to step 13.
1303
+
1304
+ Display: `Revision iteration {N}/3 -- {blocker_count} blockers, {warning_count} warnings`
1305
+
1306
+ **Stall detection:** If `issue_count >= prev_issue_count`:
1307
+ Display: `Revision loop stalled — issue count not decreasing ({issue_count} issues remain after {N} iterations)`
1308
+
1309
+ **If `stall_reentry_count < 2`:**
1310
+ Ask user:
1311
+ Question: "Issues remain after {N} revision attempts with no progress. Proceed with current output?"
1312
+ Options: "Proceed anyway" | "Adjust approach"
1313
+ If "Proceed anyway": accept current plans and continue to step 13.
1314
+ If "Adjust approach": increment `stall_reentry_count`, open freeform discussion, then re-enter step 8 (full replanning). Note: re-entry resets `iteration_count` and `prev_issue_count` but `stall_reentry_count` persists across re-entries and is capped at 2.
1315
+
1316
+ **If `stall_reentry_count >= 2`:**
1317
+ Display: `Stall persists after 2 re-planning attempts. The following issues could not be resolved automatically:`
1318
+ List the remaining issues from the checker.
1319
+ Suggest: "Consider resolving these issues manually or running `/sdd:debug` to investigate root causes."
1320
+ Options: "Proceed anyway" | "Abandon"
1321
+ If "Proceed anyway": accept current plans and continue to step 13.
1322
+ If "Abandon": stop workflow.
1323
+
1324
+ Set `prev_issue_count = issue_count`.
627
1325
 
628
1326
  Revision prompt:
629
1327
 
@@ -650,7 +1348,7 @@ Return what changed.
650
1348
  ```
651
1349
 
652
1350
  ```
653
- Task(
1351
+ Agent(
654
1352
  prompt=revision_prompt,
655
1353
  subagent_type="sdd-planner",
656
1354
  model="{planner_model}",
@@ -658,6 +1356,8 @@ Task(
658
1356
  )
659
1357
  ```
660
1358
 
1359
+ > **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.
1360
+
661
1361
  After planner returns -> spawn checker again (step 10), increment iteration_count.
662
1362
 
663
1363
  **If iteration_count >= 3:**
@@ -666,6 +1366,77 @@ Display: `Max iterations reached. {N} issues remain:` + issue list
666
1366
 
667
1367
  Offer: 1) Force proceed, 2) Provide guidance and retry, 3) Abandon
668
1368
 
1369
+ ## 12.5. Plan Bounce (Optional External Refinement)
1370
+
1371
+ **Skip if:** `--skip-bounce` flag, `--gaps` flag, or bounce is not activated.
1372
+
1373
+ **Activation:** Bounce runs when `--bounce` flag is present OR `workflow.plan_bounce` config is `true`. The `--skip-bounce` flag always wins (disables bounce even if config enables it). The `--gaps` flag also disables bounce (gap-closure mode should not modify plans externally).
1374
+
1375
+ **Prerequisites:** `workflow.plan_bounce_script` must be set to a valid script path. If bounce is activated but no script is configured, display warning and skip:
1376
+ ```
1377
+ ⚠ Plan bounce activated but no script configured.
1378
+ Set workflow.plan_bounce_script to the path of your refinement script.
1379
+ Skipping bounce step.
1380
+ ```
1381
+
1382
+ **Read pass count:**
1383
+ ```bash
1384
+ BOUNCE_PASSES=$(sdd-sdk query config-get workflow.plan_bounce_passes 2>/dev/null || echo "2")
1385
+ BOUNCE_SCRIPT=$(sdd-sdk query config-get workflow.plan_bounce_script 2>/dev/null | jq -r '.' 2>/dev/null || true)
1386
+ ```
1387
+
1388
+ Display banner:
1389
+ ```
1390
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1391
+ SDD ► BOUNCING PLANS (External Refinement)
1392
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1393
+
1394
+ Script: ${BOUNCE_SCRIPT}
1395
+ Max passes: ${BOUNCE_PASSES}
1396
+ ```
1397
+
1398
+ **For each PLAN.md file in the phase directory:**
1399
+
1400
+ 1. **Backup:** Copy `*-PLAN.md` to `*-PLAN.pre-bounce.md`
1401
+ ```bash
1402
+ cp "${PLAN_FILE}" "${PLAN_FILE%.md}.pre-bounce.md"
1403
+ ```
1404
+
1405
+ 2. **Invoke bounce script:**
1406
+ ```bash
1407
+ "${BOUNCE_SCRIPT}" "${PLAN_FILE}" "${BOUNCE_PASSES}"
1408
+ ```
1409
+
1410
+ 3. **Validate bounced plan — YAML frontmatter integrity:**
1411
+ After the script returns, check that the bounced file still has valid YAML frontmatter (opening and closing `---` delimiters with parseable content between them). If the bounced plan breaks YAML frontmatter validation, restore the original from the pre-bounce.md backup and continue to the next plan:
1412
+ ```
1413
+ ⚠ Bounced plan ${PLAN_FILE} has broken YAML frontmatter — restoring original from pre-bounce backup.
1414
+ ```
1415
+
1416
+ 4. **Handle script failure:** If the bounce script exits non-zero, restore the original plan from the pre-bounce.md backup and continue to the next plan:
1417
+ ```
1418
+ ⚠ Bounce script failed for ${PLAN_FILE} (exit code ${EXIT_CODE}) — restoring original from pre-bounce backup.
1419
+ ```
1420
+
1421
+ **After all plans are bounced:**
1422
+
1423
+ 5. **Re-run plan checker on bounced plans:** Spawn sdd-plan-checker (same as step 10) on all modified plans. If a bounced plan fails the checker, restore original from its pre-bounce.md backup:
1424
+ ```
1425
+ ⚠ Bounced plan ${PLAN_FILE} failed checker validation — restoring original from pre-bounce backup.
1426
+ ```
1427
+
1428
+ 6. **Commit surviving bounced plans:** If at least one plan survived both the frontmatter validation and the checker re-run, commit the changes:
1429
+ ```bash
1430
+ sdd-sdk query commit "refactor(${padded_phase}): bounce plans through external refinement" --files "${PHASE_DIR}/*-PLAN.md"
1431
+ ```
1432
+
1433
+ Display summary:
1434
+ ```
1435
+ Plan bounce complete: {survived}/{total} plans refined
1436
+ ```
1437
+
1438
+ **Clean up:** Remove all `*-PLAN.pre-bounce.md` backup files after the bounce step completes (whether plans survived or were restored).
1439
+
669
1440
  ## 13. Requirements Coverage Gate
670
1441
 
671
1442
  After plans pass the checker (or checker is skipped), verify that all phase requirements are covered by at least one plan.
@@ -717,28 +1488,182 @@ Options:
717
1488
 
718
1489
  If `TEXT_MODE` is true, present as a plain-text numbered list (options already shown in the block above). Otherwise use AskUserQuestion to present the options.
719
1490
 
1491
+ ## 13a. Decision Coverage Gate
1492
+
1493
+ After the requirements coverage gate passes, verify that every trackable
1494
+ decision captured by discuss-phase in CONTEXT.md `<decisions>` is referenced
1495
+ by at least one plan. This is the **translation gate** from issue #2492 —
1496
+ its job is to refuse to mark a phase planned when a discuss-phase decision
1497
+ silently dropped on the way into the plans.
1498
+
1499
+ **Skip if** `workflow.context_coverage_gate` is explicitly set to `false`
1500
+ (absent key = enabled). Also skip if no CONTEXT.md exists for this phase
1501
+ (nothing to translate) or if its `<decisions>` block is empty.
1502
+
1503
+ ```bash
1504
+ GATE_CFG=$(sdd-sdk query config-get workflow.context_coverage_gate 2>/dev/null || echo "true")
1505
+ if [ "$GATE_CFG" != "false" ]; then
1506
+ GATE_RESULT=$(sdd-sdk query check.decision-coverage-plan "${PHASE_DIR}" "${CONTEXT_PATH}")
1507
+ # BLOCKING: refuse to mark phase planned when a trackable decision is uncovered.
1508
+ # `passed: true` covers both real-pass and skipped cases (gate disabled / no CONTEXT.md /
1509
+ # no trackable decisions). Verify-phase counterpart deliberately omits this exit-1 — that
1510
+ # gate is non-blocking by design (review finding F15).
1511
+ echo "$GATE_RESULT" | jq -e '.data.passed == true' >/dev/null || {
1512
+ echo "$GATE_RESULT" | jq -r '.data.message'
1513
+ exit 1
1514
+ }
1515
+ fi
1516
+ ```
1517
+
1518
+ The handler returns JSON:
1519
+ ```json
1520
+ {
1521
+ "passed": true,
1522
+ "skipped": false,
1523
+ "total": 2,
1524
+ "covered": 2,
1525
+ "uncovered": [ { "id": "D-01", "text": "...", "category": "..." } ],
1526
+ "message": "..."
1527
+ }
1528
+ ```
1529
+
1530
+ **If `passed` is true (or `skipped` is true):** Display
1531
+ `✓ Decision coverage: {M}/{N} CONTEXT.md decisions covered by plans` (or
1532
+ `(skipped — gate disabled)` / `(skipped — no decisions)`) and proceed to
1533
+ step 13b.
1534
+
1535
+ **If `passed` is false:** Display the handler's `message` block. It already
1536
+ names each uncovered decision (`D-NN | category | text`) and tells the user
1537
+ what to do — cite the id in a relevant plan's `must_haves` / `truths`, or
1538
+ move the decision under `### Claude's Discretion` / tag it `[informational]`
1539
+ if it should not be tracked. Then offer:
1540
+
1541
+ ```text
1542
+ Options:
1543
+ 1. Re-plan to cover missing decisions (recommended)
1544
+ 2. Edit CONTEXT.md to mark dropped decisions as [informational] / Discretion
1545
+ 3. Proceed anyway — accept the coverage gap
1546
+ ```
1547
+
1548
+ If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use
1549
+ AskUserQuestion. Selecting "Proceed anyway" continues to step 13b but
1550
+ records the override in STATE.md so verify-phase can re-surface it.
1551
+
1552
+ **Why this gate blocks:** failing here is cheap. The plans are the contract
1553
+ between discuss-phase and execute-phase; if a decision isn't visible in any
1554
+ plan, no executor will implement it. Catching that now beats discovering it
1555
+ after thousands of dollars of execution.
1556
+
1557
+ ## 13b. Record Planning Completion in STATE.md
1558
+
1559
+ After plans pass all gates, record that planning is complete so STATE.md reflects the new phase status:
1560
+
1561
+ ```bash
1562
+ sdd-sdk query state.planned-phase --phase "${PHASE_NUMBER}" --name "${PHASE_NAME}" --plans "${PLAN_COUNT}"
1563
+ ```
1564
+
1565
+ This updates STATUS to "Ready to execute", sets the correct plan count, and timestamps Last Activity.
1566
+
1567
+ ## 13c. Annotate ROADMAP with Wave Dependencies and Cross-cutting Constraints
1568
+
1569
+ After plans are finalized, annotate the ROADMAP.md plan list for this phase with:
1570
+ - **Wave dependency notes** — a bold header before each wave group ("Wave 2 *(blocked on Wave 1 completion)*")
1571
+ - **Cross-cutting constraints** — a "Cross-cutting constraints:" subsection listing `must_haves.truths` entries that appear in 2 or more plans
1572
+
1573
+ This step is derived entirely from existing PLAN frontmatter — no extra LLM pass is required.
1574
+
1575
+ ```bash
1576
+ sdd-sdk query roadmap.annotate-dependencies "${PHASE_NUMBER}"
1577
+ ```
1578
+
1579
+ This operation is idempotent: if wave headers or cross-cutting constraints already exist in the ROADMAP phase section, the command returns without modifying the file. Skip this step if `plan_count` is 0.
1580
+
1581
+ ## 13d. Commit Plans if commit_docs is true
1582
+
1583
+ If `commit_docs` is true (from the init JSON parsed in step 1), commit the generated plan artifacts (including any ROADMAP.md annotations from step 13c):
1584
+
1585
+ ```bash
1586
+ sdd-sdk query commit "docs(${PADDED_PHASE}): create phase plan" --files "${PHASE_DIR}"/*-PLAN.md .planning/STATE.md .planning/ROADMAP.md
1587
+ ```
1588
+
1589
+ This commits all PLAN.md files for the phase plus the updated STATE.md and ROADMAP.md to version-control the planning artifacts. Skip this step if `commit_docs` is false.
1590
+
1591
+ ## 13e. Post-Planning Gap Analysis
1592
+
1593
+ After all plans are generated, committed, and the Requirements Coverage Gate (§13)
1594
+ has run, emit a single unified gap report covering both REQUIREMENTS.md and the
1595
+ CONTEXT.md `<decisions>` section. This is a **proactive, post-hoc report** — it
1596
+ does not block phase advancement and does not re-plan. It exists so that any
1597
+ requirement or decision that slipped through the per-plan checks is surfaced in
1598
+ one place before execution begins.
1599
+
1600
+ **Skip if:** `workflow.post_planning_gaps` is `false`. Default is `true`.
1601
+
1602
+ ```bash
1603
+ POST_PLANNING_GAPS=$(sdd-sdk query config-get workflow.post_planning_gaps --default true 2>/dev/null || echo true)
1604
+ if [ "$POST_PLANNING_GAPS" = "true" ]; then
1605
+ node "$HOME/.claude/sdd/bin/sdd-tools.cjs" gap-analysis --phase-dir "${PHASE_DIR}"
1606
+ fi
1607
+ ```
1608
+
1609
+ (`sdd-tools.cjs gap-analysis` reads `.planning/REQUIREMENTS.md`, `${PHASE_DIR}/CONTEXT.md`,
1610
+ and `${PHASE_DIR}/*-PLAN.md`, then prints a markdown table with one row per
1611
+ REQ-ID and D-ID. Word-boundary matching prevents `REQ-1` from being mistaken for
1612
+ `REQ-10`.)
1613
+
1614
+ **Output format (deterministic; sorted REQUIREMENTS.md → CONTEXT.md, then natural
1615
+ sort within source):**
1616
+
1617
+ ```
1618
+ ## Post-Planning Gap Analysis
1619
+
1620
+ | Source | Item | Status |
1621
+ |--------|------|--------|
1622
+ | REQUIREMENTS.md | REQ-01 | ✓ Covered |
1623
+ | REQUIREMENTS.md | REQ-02 | ✗ Not covered |
1624
+ | CONTEXT.md | D-01 | ✓ Covered |
1625
+ | CONTEXT.md | D-02 | ✗ Not covered |
1626
+
1627
+ ⚠ N items not covered by any plan
1628
+ ```
1629
+
1630
+ **Skip-gracefully behavior:**
1631
+ - REQUIREMENTS.md missing → CONTEXT-only report.
1632
+ - CONTEXT.md missing → REQUIREMENTS-only report.
1633
+ - Both missing or `<decisions>` block missing → "No requirements or decisions to check" line, no error.
1634
+
1635
+ This step is non-blocking. If items are reported as not covered, the user may
1636
+ re-run `/sdd:plan-phase --gaps` to add plans, or proceed to execute-phase as-is.
1637
+
720
1638
  ## 14. Present Final Status
721
1639
 
722
1640
  Route to `<offer_next>` OR `auto_advance` depending on flags/config.
723
1641
 
724
1642
  ## 15. Auto-Advance Check
725
1643
 
726
- Check for auto-advance trigger:
1644
+ Check for auto-advance trigger using values already loaded in step 1:
727
1645
 
728
- 1. Parse `--auto` flag from $ARGUMENTS
729
- 2. **Sync chain flag with intent**if user invoked manually (no `--auto`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
1646
+ 1. Parse `--auto` and `--chain` flags from $ARGUMENTS
1647
+ 2. Use `auto_chain_active` and `auto_advance` from the INIT JSON parsed in step 1 **do not issue additional `config-get` calls for these values** (they are already present in the init output). Issuing redundant `config-get` calls for values already in INIT can cause infinite read loops on some runtimes.
1648
+ 3. **Sync chain flag with intent** — if user invoked manually (no `--auto` and no `--chain`), clear the ephemeral chain flag from any previous interrupted `--auto` chain. This does NOT touch `workflow.auto_advance` (the user's persistent settings preference):
730
1649
  ```bash
731
- if [[ ! "$ARGUMENTS" =~ --auto ]]; then
732
- node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-set workflow._auto_chain_active false 2>/dev/null
1650
+ if [[ ! "$ARGUMENTS" =~ --auto ]] && [[ ! "$ARGUMENTS" =~ --chain ]]; then
1651
+ sdd-sdk query config-set workflow._auto_chain_active false || true
733
1652
  fi
734
1653
  ```
735
- 3. Read both the chain flag and user preference:
736
- ```bash
737
- AUTO_CHAIN=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow._auto_chain_active 2>/dev/null || echo "false")
738
- AUTO_CFG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" config-get workflow.auto_advance 2>/dev/null || echo "false")
739
- ```
740
1654
 
741
- **If `--auto` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
1655
+ Set local variables from INIT (parsed once in step 1):
1656
+ - `AUTO_CHAIN` = `auto_chain_active` from INIT JSON (boolean, default false)
1657
+ - `AUTO_CFG` = `auto_advance` from INIT JSON (boolean, default false)
1658
+
1659
+ **If `--auto` or `--chain` flag present AND `AUTO_CHAIN` is not true:** Persist chain flag to config (handles direct invocation without prior discuss-phase):
1660
+ ```bash
1661
+ if ([[ "$ARGUMENTS" =~ --auto ]] || [[ "$ARGUMENTS" =~ --chain ]]) && [[ "$AUTO_CHAIN" != "true" ]]; then
1662
+ sdd-sdk query config-set workflow._auto_chain_active true
1663
+ fi
1664
+ ```
1665
+
1666
+ **If `--auto` or `--chain` flag present OR `AUTO_CHAIN` is true OR `AUTO_CFG` is true:**
742
1667
 
743
1668
  Display banner:
744
1669
  ```
@@ -751,7 +1676,7 @@ Plans ready. Launching execute-phase...
751
1676
 
752
1677
  Launch execute-phase using the Skill tool to avoid nested Task sessions (which cause runtime freezes due to deep agent nesting):
753
1678
  ```
754
- Skill(skill="sdd:execute-phase", args="${PHASE} --auto --no-transition ${SDD_WS}")
1679
+ Skill(skill="sdd-execute-phase", args="${PHASE} --auto --no-transition ${SDD_WS}")
755
1680
  ```
756
1681
 
757
1682
  The `--no-transition` flag tells execute-phase to return status after verification instead of chaining further. This keeps the auto-advance chain flat — each phase runs at the same nesting level rather than spawning deeper Task agents.
@@ -799,13 +1724,13 @@ Verification: {Passed | Passed with override | Skipped}
799
1724
 
800
1725
  ───────────────────────────────────────────────────────────────
801
1726
 
802
- ## ▶ Next Up
1727
+ ## ▶ Next Up — [${PROJECT_CODE}] ${PROJECT_TITLE}
803
1728
 
804
1729
  **Execute Phase {X}** — run all {N} plans
805
1730
 
806
- /sdd:execute-phase {X} ${SDD_WS}
1731
+ /clear then:
807
1732
 
808
- <sub>/clear first → fresh context window</sub>
1733
+ /sdd:execute-phase {X} ${SDD_WS}
809
1734
 
810
1735
  ───────────────────────────────────────────────────────────────
811
1736