create-quiver 0.9.1 → 0.12.0

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 (245) hide show
  1. package/BACKLOG.md +16 -17
  2. package/CHANGELOG.md +34 -0
  3. package/README.md +419 -330
  4. package/README_FOR_AI.md +93 -56
  5. package/ROADMAP.md +22 -11
  6. package/docs/AI_CONTEXT.md.template +2 -0
  7. package/docs/AI_ONBOARDING_PROMPT.md.template +36 -19
  8. package/docs/COMMANDS.md.template +73 -1
  9. package/docs/CONTEXTO.md.template +2 -0
  10. package/docs/DECISIONS.md.template +1 -0
  11. package/docs/GITFLOW_PR_GUIDE.md.template +11 -0
  12. package/docs/INDEX.md.template +20 -18
  13. package/docs/STANDARD.md.template +1 -1
  14. package/docs/STATUS.md.template +1 -0
  15. package/docs/SUPPORT_MATRIX.md.template +6 -2
  16. package/docs/TROUBLESHOOTING.md.template +79 -1
  17. package/docs/WORKFLOW.md.template +26 -18
  18. package/package.json +24 -2
  19. package/package.template.json +24 -7
  20. package/scripts/check-pr-readiness.sh +1 -1
  21. package/scripts/check-scope.sh +0 -1
  22. package/scripts/check-slice-readiness.sh +3 -4
  23. package/scripts/init-docs.sh +53 -6
  24. package/scripts/package-quiver.sh +18 -2
  25. package/specs/quiver-v20-ai-cli-orchestration/EVIDENCE_REPORT.md +23 -0
  26. package/specs/quiver-v20-ai-cli-orchestration/EXECUTION_PLAN.md +57 -0
  27. package/specs/quiver-v20-ai-cli-orchestration/SPEC.md +202 -0
  28. package/specs/quiver-v20-ai-cli-orchestration/STATUS.md +35 -0
  29. package/specs/quiver-v20-ai-cli-orchestration/pr.md +100 -0
  30. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-00-spec-foundation/CLOSURE_BRIEF.md +30 -0
  31. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-00-spec-foundation/EXECUTION_BRIEF.md +61 -0
  32. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-00-spec-foundation/slice.json +54 -0
  33. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-01-ai-provider-runner/CLOSURE_BRIEF.md +39 -0
  34. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-01-ai-provider-runner/EXECUTION_BRIEF.md +63 -0
  35. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-01-ai-provider-runner/slice.json +55 -0
  36. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-02-context-packs-token-budget/CLOSURE_BRIEF.md +40 -0
  37. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-02-context-packs-token-budget/EXECUTION_BRIEF.md +60 -0
  38. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-02-context-packs-token-budget/slice.json +54 -0
  39. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-03-ai-phase-gated-planner/CLOSURE_BRIEF.md +43 -0
  40. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-03-ai-phase-gated-planner/EXECUTION_BRIEF.md +62 -0
  41. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-03-ai-phase-gated-planner/slice.json +62 -0
  42. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-04-spec-slice-handoff-pr-generation/CLOSURE_BRIEF.md +36 -0
  43. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-04-spec-slice-handoff-pr-generation/EXECUTION_BRIEF.md +63 -0
  44. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-04-spec-slice-handoff-pr-generation/slice.json +59 -0
  45. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-05-execution-plan-parallel-worktrees/CLOSURE_BRIEF.md +32 -0
  46. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-05-execution-plan-parallel-worktrees/EXECUTION_BRIEF.md +61 -0
  47. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-05-execution-plan-parallel-worktrees/slice.json +59 -0
  48. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-06-ai-execute-slice-scope-enforcement/CLOSURE_BRIEF.md +36 -0
  49. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-06-ai-execute-slice-scope-enforcement/EXECUTION_BRIEF.md +64 -0
  50. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-06-ai-execute-slice-scope-enforcement/slice.json +65 -0
  51. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-07-github-pr-preflight/CLOSURE_BRIEF.md +36 -0
  52. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-07-github-pr-preflight/EXECUTION_BRIEF.md +66 -0
  53. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-07-github-pr-preflight/slice.json +63 -0
  54. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-08-docs-smokes-release-readiness/CLOSURE_BRIEF.md +35 -0
  55. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-08-docs-smokes-release-readiness/EXECUTION_BRIEF.md +64 -0
  56. package/specs/quiver-v20-ai-cli-orchestration/slices/slice-08-docs-smokes-release-readiness/slice.json +77 -0
  57. package/specs/quiver-v21-ai-first-layout/EVIDENCE_REPORT.md +31 -0
  58. package/specs/quiver-v21-ai-first-layout/EXECUTION_PLAN.md +185 -0
  59. package/specs/quiver-v21-ai-first-layout/SPEC.md +212 -0
  60. package/specs/quiver-v21-ai-first-layout/STATUS.md +37 -0
  61. package/specs/quiver-v21-ai-first-layout/pr.md +110 -0
  62. package/specs/quiver-v21-ai-first-layout/slices/slice-00-spec-foundation/CLOSURE_BRIEF.md +30 -0
  63. package/specs/quiver-v21-ai-first-layout/slices/slice-00-spec-foundation/EXECUTION_BRIEF.md +63 -0
  64. package/specs/quiver-v21-ai-first-layout/slices/slice-00-spec-foundation/slice.json +45 -0
  65. package/specs/quiver-v21-ai-first-layout/slices/slice-01-init-profiles-dry-run/CLOSURE_BRIEF.md +31 -0
  66. package/specs/quiver-v21-ai-first-layout/slices/slice-01-init-profiles-dry-run/EXECUTION_BRIEF.md +59 -0
  67. package/specs/quiver-v21-ai-first-layout/slices/slice-01-init-profiles-dry-run/slice.json +57 -0
  68. package/specs/quiver-v21-ai-first-layout/slices/slice-02-internal-layout-template-resolver/CLOSURE_BRIEF.md +32 -0
  69. package/specs/quiver-v21-ai-first-layout/slices/slice-02-internal-layout-template-resolver/EXECUTION_BRIEF.md +60 -0
  70. package/specs/quiver-v21-ai-first-layout/slices/slice-02-internal-layout-template-resolver/slice.json +58 -0
  71. package/specs/quiver-v21-ai-first-layout/slices/slice-03-generation-profiles-visible-contract/CLOSURE_BRIEF.md +34 -0
  72. package/specs/quiver-v21-ai-first-layout/slices/slice-03-generation-profiles-visible-contract/EXECUTION_BRIEF.md +61 -0
  73. package/specs/quiver-v21-ai-first-layout/slices/slice-03-generation-profiles-visible-contract/slice.json +64 -0
  74. package/specs/quiver-v21-ai-first-layout/slices/slice-04-analyze-scan-relocation/CLOSURE_BRIEF.md +32 -0
  75. package/specs/quiver-v21-ai-first-layout/slices/slice-04-analyze-scan-relocation/EXECUTION_BRIEF.md +58 -0
  76. package/specs/quiver-v21-ai-first-layout/slices/slice-04-analyze-scan-relocation/slice.json +64 -0
  77. package/specs/quiver-v21-ai-first-layout/slices/slice-05-empty-specs-layout-doctor/CLOSURE_BRIEF.md +32 -0
  78. package/specs/quiver-v21-ai-first-layout/slices/slice-05-empty-specs-layout-doctor/EXECUTION_BRIEF.md +60 -0
  79. package/specs/quiver-v21-ai-first-layout/slices/slice-05-empty-specs-layout-doctor/slice.json +65 -0
  80. package/specs/quiver-v21-ai-first-layout/slices/slice-06-legacy-migration-optional-assets/CLOSURE_BRIEF.md +31 -0
  81. package/specs/quiver-v21-ai-first-layout/slices/slice-06-legacy-migration-optional-assets/EXECUTION_BRIEF.md +62 -0
  82. package/specs/quiver-v21-ai-first-layout/slices/slice-06-legacy-migration-optional-assets/slice.json +66 -0
  83. package/specs/quiver-v21-ai-first-layout/slices/slice-07-docs-guidance-alignment/CLOSURE_BRIEF.md +33 -0
  84. package/specs/quiver-v21-ai-first-layout/slices/slice-07-docs-guidance-alignment/EXECUTION_BRIEF.md +61 -0
  85. package/specs/quiver-v21-ai-first-layout/slices/slice-07-docs-guidance-alignment/slice.json +67 -0
  86. package/specs/quiver-v21-ai-first-layout/slices/slice-08-smokes-release-readiness/CLOSURE_BRIEF.md +35 -0
  87. package/specs/quiver-v21-ai-first-layout/slices/slice-08-smokes-release-readiness/EXECUTION_BRIEF.md +66 -0
  88. package/specs/quiver-v21-ai-first-layout/slices/slice-08-smokes-release-readiness/slice.json +62 -0
  89. package/specs/quiver-v22-guided-ai-workflow/EVIDENCE_REPORT.md +58 -0
  90. package/specs/quiver-v22-guided-ai-workflow/EXECUTION_PLAN.md +88 -0
  91. package/specs/quiver-v22-guided-ai-workflow/SPEC.md +228 -0
  92. package/specs/quiver-v22-guided-ai-workflow/STATUS.md +42 -0
  93. package/specs/quiver-v22-guided-ai-workflow/pr.md +104 -0
  94. package/specs/quiver-v22-guided-ai-workflow/slices/slice-00-spec-foundation/CLOSURE_BRIEF.md +35 -0
  95. package/specs/quiver-v22-guided-ai-workflow/slices/slice-00-spec-foundation/EXECUTION_BRIEF.md +61 -0
  96. package/specs/quiver-v22-guided-ai-workflow/slices/slice-00-spec-foundation/slice.json +51 -0
  97. package/specs/quiver-v22-guided-ai-workflow/slices/slice-01-docs-source-of-truth-sync/CLOSURE_BRIEF.md +31 -0
  98. package/specs/quiver-v22-guided-ai-workflow/slices/slice-01-docs-source-of-truth-sync/EXECUTION_BRIEF.md +58 -0
  99. package/specs/quiver-v22-guided-ai-workflow/slices/slice-01-docs-source-of-truth-sync/slice.json +55 -0
  100. package/specs/quiver-v22-guided-ai-workflow/slices/slice-02-prepare-command-diagnostics/CLOSURE_BRIEF.md +30 -0
  101. package/specs/quiver-v22-guided-ai-workflow/slices/slice-02-prepare-command-diagnostics/EXECUTION_BRIEF.md +57 -0
  102. package/specs/quiver-v22-guided-ai-workflow/slices/slice-02-prepare-command-diagnostics/slice.json +57 -0
  103. package/specs/quiver-v22-guided-ai-workflow/slices/slice-03-context-doc-refresh/CLOSURE_BRIEF.md +32 -0
  104. package/specs/quiver-v22-guided-ai-workflow/slices/slice-03-context-doc-refresh/EXECUTION_BRIEF.md +56 -0
  105. package/specs/quiver-v22-guided-ai-workflow/slices/slice-03-context-doc-refresh/slice.json +56 -0
  106. package/specs/quiver-v22-guided-ai-workflow/slices/slice-04-planner-approval-state/CLOSURE_BRIEF.md +33 -0
  107. package/specs/quiver-v22-guided-ai-workflow/slices/slice-04-planner-approval-state/EXECUTION_BRIEF.md +56 -0
  108. package/specs/quiver-v22-guided-ai-workflow/slices/slice-04-planner-approval-state/slice.json +58 -0
  109. package/specs/quiver-v22-guided-ai-workflow/slices/slice-05-spec-worktree-lifecycle/CLOSURE_BRIEF.md +32 -0
  110. package/specs/quiver-v22-guided-ai-workflow/slices/slice-05-spec-worktree-lifecycle/EXECUTION_BRIEF.md +56 -0
  111. package/specs/quiver-v22-guided-ai-workflow/slices/slice-05-spec-worktree-lifecycle/slice.json +54 -0
  112. package/specs/quiver-v22-guided-ai-workflow/slices/slice-06-executor-commit-recovery/CLOSURE_BRIEF.md +32 -0
  113. package/specs/quiver-v22-guided-ai-workflow/slices/slice-06-executor-commit-recovery/EXECUTION_BRIEF.md +58 -0
  114. package/specs/quiver-v22-guided-ai-workflow/slices/slice-06-executor-commit-recovery/slice.json +57 -0
  115. package/specs/quiver-v22-guided-ai-workflow/slices/slice-07-execution-waves-delegation/CLOSURE_BRIEF.md +32 -0
  116. package/specs/quiver-v22-guided-ai-workflow/slices/slice-07-execution-waves-delegation/EXECUTION_BRIEF.md +58 -0
  117. package/specs/quiver-v22-guided-ai-workflow/slices/slice-07-execution-waves-delegation/slice.json +55 -0
  118. package/specs/quiver-v22-guided-ai-workflow/slices/slice-08-pr-create-gh-ssh/CLOSURE_BRIEF.md +32 -0
  119. package/specs/quiver-v22-guided-ai-workflow/slices/slice-08-pr-create-gh-ssh/EXECUTION_BRIEF.md +58 -0
  120. package/specs/quiver-v22-guided-ai-workflow/slices/slice-08-pr-create-gh-ssh/slice.json +53 -0
  121. package/specs/quiver-v22-guided-ai-workflow/slices/slice-09-post-merge-cleanup-release-safety/CLOSURE_BRIEF.md +33 -0
  122. package/specs/quiver-v22-guided-ai-workflow/slices/slice-09-post-merge-cleanup-release-safety/EXECUTION_BRIEF.md +59 -0
  123. package/specs/quiver-v22-guided-ai-workflow/slices/slice-09-post-merge-cleanup-release-safety/slice.json +59 -0
  124. package/specs/quiver-v22-guided-ai-workflow/slices/slice-10-docs-smokes-release-readiness/CLOSURE_BRIEF.md +34 -0
  125. package/specs/quiver-v22-guided-ai-workflow/slices/slice-10-docs-smokes-release-readiness/EXECUTION_BRIEF.md +58 -0
  126. package/specs/quiver-v22-guided-ai-workflow/slices/slice-10-docs-smokes-release-readiness/slice.json +60 -0
  127. package/specs/quiver-v23-guided-flow-productization/EVIDENCE_REPORT.md +80 -0
  128. package/specs/quiver-v23-guided-flow-productization/EXECUTION_PLAN.md +80 -0
  129. package/specs/quiver-v23-guided-flow-productization/SPEC.md +203 -0
  130. package/specs/quiver-v23-guided-flow-productization/STATUS.md +39 -0
  131. package/specs/quiver-v23-guided-flow-productization/pr.md +119 -0
  132. package/specs/quiver-v23-guided-flow-productization/slices/slice-00-spec-foundation/CLOSURE_BRIEF.md +30 -0
  133. package/specs/quiver-v23-guided-flow-productization/slices/slice-00-spec-foundation/EXECUTION_BRIEF.md +61 -0
  134. package/specs/quiver-v23-guided-flow-productization/slices/slice-00-spec-foundation/slice.json +51 -0
  135. package/specs/quiver-v23-guided-flow-productization/slices/slice-01-short-command-and-flow-entrypoint/CLOSURE_BRIEF.md +33 -0
  136. package/specs/quiver-v23-guided-flow-productization/slices/slice-01-short-command-and-flow-entrypoint/EXECUTION_BRIEF.md +35 -0
  137. package/specs/quiver-v23-guided-flow-productization/slices/slice-01-short-command-and-flow-entrypoint/slice.json +56 -0
  138. package/specs/quiver-v23-guided-flow-productization/slices/slice-02-flow-status-wizard/CLOSURE_BRIEF.md +31 -0
  139. package/specs/quiver-v23-guided-flow-productization/slices/slice-02-flow-status-wizard/EXECUTION_BRIEF.md +29 -0
  140. package/specs/quiver-v23-guided-flow-productization/slices/slice-02-flow-status-wizard/slice.json +55 -0
  141. package/specs/quiver-v23-guided-flow-productization/slices/slice-03-agent-profiles/CLOSURE_BRIEF.md +33 -0
  142. package/specs/quiver-v23-guided-flow-productization/slices/slice-03-agent-profiles/EXECUTION_BRIEF.md +29 -0
  143. package/specs/quiver-v23-guided-flow-productization/slices/slice-03-agent-profiles/slice.json +54 -0
  144. package/specs/quiver-v23-guided-flow-productization/slices/slice-04-context-preparation-onboarding/CLOSURE_BRIEF.md +32 -0
  145. package/specs/quiver-v23-guided-flow-productization/slices/slice-04-context-preparation-onboarding/EXECUTION_BRIEF.md +30 -0
  146. package/specs/quiver-v23-guided-flow-productization/slices/slice-04-context-preparation-onboarding/slice.json +59 -0
  147. package/specs/quiver-v23-guided-flow-productization/slices/slice-05-planner-iteration-history/CLOSURE_BRIEF.md +31 -0
  148. package/specs/quiver-v23-guided-flow-productization/slices/slice-05-planner-iteration-history/EXECUTION_BRIEF.md +29 -0
  149. package/specs/quiver-v23-guided-flow-productization/slices/slice-05-planner-iteration-history/slice.json +53 -0
  150. package/specs/quiver-v23-guided-flow-productization/slices/slice-06-production-plan-review/CLOSURE_BRIEF.md +33 -0
  151. package/specs/quiver-v23-guided-flow-productization/slices/slice-06-production-plan-review/EXECUTION_BRIEF.md +30 -0
  152. package/specs/quiver-v23-guided-flow-productization/slices/slice-06-production-plan-review/slice.json +54 -0
  153. package/specs/quiver-v23-guided-flow-productization/slices/slice-07-spec-create-experience/CLOSURE_BRIEF.md +33 -0
  154. package/specs/quiver-v23-guided-flow-productization/slices/slice-07-spec-create-experience/EXECUTION_BRIEF.md +30 -0
  155. package/specs/quiver-v23-guided-flow-productization/slices/slice-07-spec-create-experience/slice.json +55 -0
  156. package/specs/quiver-v23-guided-flow-productization/slices/slice-08-executor-prompt-generation/CLOSURE_BRIEF.md +32 -0
  157. package/specs/quiver-v23-guided-flow-productization/slices/slice-08-executor-prompt-generation/EXECUTION_BRIEF.md +30 -0
  158. package/specs/quiver-v23-guided-flow-productization/slices/slice-08-executor-prompt-generation/slice.json +55 -0
  159. package/specs/quiver-v23-guided-flow-productization/slices/slice-09-delegated-slice-execution/CLOSURE_BRIEF.md +33 -0
  160. package/specs/quiver-v23-guided-flow-productization/slices/slice-09-delegated-slice-execution/EXECUTION_BRIEF.md +34 -0
  161. package/specs/quiver-v23-guided-flow-productization/slices/slice-09-delegated-slice-execution/slice.json +57 -0
  162. package/specs/quiver-v23-guided-flow-productization/slices/slice-10-docs-smokes-release-readiness/CLOSURE_BRIEF.md +33 -0
  163. package/specs/quiver-v23-guided-flow-productization/slices/slice-10-docs-smokes-release-readiness/EXECUTION_BRIEF.md +32 -0
  164. package/specs/quiver-v23-guided-flow-productization/slices/slice-10-docs-smokes-release-readiness/slice.json +63 -0
  165. package/specs/quiver-v24-dx-onboarding-hardening/EVIDENCE_REPORT.md +55 -0
  166. package/specs/quiver-v24-dx-onboarding-hardening/EXECUTION_PLAN.md +43 -0
  167. package/specs/quiver-v24-dx-onboarding-hardening/SPEC.md +149 -0
  168. package/specs/quiver-v24-dx-onboarding-hardening/STATUS.md +31 -0
  169. package/specs/quiver-v24-dx-onboarding-hardening/pr.md +76 -0
  170. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-00-spec-foundation/CLOSURE_BRIEF.md +31 -0
  171. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-00-spec-foundation/EXECUTION_BRIEF.md +52 -0
  172. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-00-spec-foundation/slice.json +51 -0
  173. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-01-init-template-hygiene/CLOSURE_BRIEF.md +38 -0
  174. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-01-init-template-hygiene/EXECUTION_BRIEF.md +53 -0
  175. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-01-init-template-hygiene/slice.json +55 -0
  176. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-02-cli-command-routing-version-errors/CLOSURE_BRIEF.md +33 -0
  177. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-02-cli-command-routing-version-errors/EXECUTION_BRIEF.md +50 -0
  178. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-02-cli-command-routing-version-errors/slice.json +52 -0
  179. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-03-doctor-fix-doc-link-checks/CLOSURE_BRIEF.md +33 -0
  180. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-03-doctor-fix-doc-link-checks/EXECUTION_BRIEF.md +50 -0
  181. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-03-doctor-fix-doc-link-checks/slice.json +53 -0
  182. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-04-prepare-output-ai-context-drafts/CLOSURE_BRIEF.md +33 -0
  183. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-04-prepare-output-ai-context-drafts/EXECUTION_BRIEF.md +50 -0
  184. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-04-prepare-output-ai-context-drafts/slice.json +70 -0
  185. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-05-local-slice-validation-base-guidance/CLOSURE_BRIEF.md +36 -0
  186. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-05-local-slice-validation-base-guidance/EXECUTION_BRIEF.md +49 -0
  187. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-05-local-slice-validation-base-guidance/slice.json +52 -0
  188. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-06-plan-graph-next-history-views/CLOSURE_BRIEF.md +43 -0
  189. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-06-plan-graph-next-history-views/EXECUTION_BRIEF.md +53 -0
  190. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-06-plan-graph-next-history-views/slice.json +60 -0
  191. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-07-analyzer-command-map-hardening/CLOSURE_BRIEF.md +32 -0
  192. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-07-analyzer-command-map-hardening/EXECUTION_BRIEF.md +50 -0
  193. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-07-analyzer-command-map-hardening/slice.json +51 -0
  194. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-08-evidence-run-command/CLOSURE_BRIEF.md +34 -0
  195. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-08-evidence-run-command/EXECUTION_BRIEF.md +52 -0
  196. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-08-evidence-run-command/slice.json +54 -0
  197. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-09-spec-viewer-demo-scaffolding/CLOSURE_BRIEF.md +34 -0
  198. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-09-spec-viewer-demo-scaffolding/EXECUTION_BRIEF.md +51 -0
  199. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-09-spec-viewer-demo-scaffolding/slice.json +59 -0
  200. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-10-docs-smokes-release-readiness/CLOSURE_BRIEF.md +33 -0
  201. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-10-docs-smokes-release-readiness/EXECUTION_BRIEF.md +54 -0
  202. package/specs/quiver-v24-dx-onboarding-hardening/slices/slice-10-docs-smokes-release-readiness/slice.json +76 -0
  203. package/src/create-quiver/commands/ai.js +915 -0
  204. package/src/create-quiver/commands/demo.js +22 -0
  205. package/src/create-quiver/commands/evidence.js +37 -0
  206. package/src/create-quiver/commands/flow.js +561 -0
  207. package/src/create-quiver/commands/graph.js +14 -1
  208. package/src/create-quiver/commands/next.js +28 -0
  209. package/src/create-quiver/commands/plan.js +6 -3
  210. package/src/create-quiver/commands/prepare.js +236 -0
  211. package/src/create-quiver/commands/spec.js +133 -0
  212. package/src/create-quiver/index.js +1096 -96
  213. package/src/create-quiver/lib/agent-profiles.js +148 -0
  214. package/src/create-quiver/lib/ai/context-packs.js +170 -0
  215. package/src/create-quiver/lib/ai/execution-plan.js +614 -0
  216. package/src/create-quiver/lib/ai/executor.js +682 -0
  217. package/src/create-quiver/lib/ai/github.js +525 -0
  218. package/src/create-quiver/lib/ai/onboarding-template.js +365 -0
  219. package/src/create-quiver/lib/ai/phase-gates.js +72 -0
  220. package/src/create-quiver/lib/ai/plan-review.js +283 -0
  221. package/src/create-quiver/lib/ai/preflight.js +58 -0
  222. package/src/create-quiver/lib/ai/prompt-transport.js +81 -0
  223. package/src/create-quiver/lib/ai/prompts.js +39 -0
  224. package/src/create-quiver/lib/ai/providers.js +315 -0
  225. package/src/create-quiver/lib/ai/safety.js +156 -0
  226. package/src/create-quiver/lib/ai/spec-generator.js +314 -0
  227. package/src/create-quiver/lib/ai/spec-templates.js +715 -0
  228. package/src/create-quiver/lib/approvals.js +350 -0
  229. package/src/create-quiver/lib/demo.js +657 -0
  230. package/src/create-quiver/lib/doctor.js +348 -0
  231. package/src/create-quiver/lib/evidence.js +115 -0
  232. package/src/create-quiver/lib/git.js +21 -0
  233. package/src/create-quiver/lib/init-docs.js +545 -23
  234. package/src/create-quiver/lib/init-layout.js +451 -0
  235. package/src/create-quiver/lib/lifecycle.js +8 -2
  236. package/src/create-quiver/lib/package-safety.js +117 -0
  237. package/src/create-quiver/lib/paths.js +63 -2
  238. package/src/create-quiver/lib/project-scan.js +66 -0
  239. package/src/create-quiver/lib/readiness.js +87 -18
  240. package/src/create-quiver/lib/scope.js +125 -0
  241. package/src/create-quiver/lib/slice-graph.js +7 -0
  242. package/src/create-quiver/lib/slice.js +59 -16
  243. package/src/create-quiver/lib/spec-worktrees.js +349 -0
  244. package/src/create-quiver/lib/state.js +18 -1
  245. package/src/create-quiver/lib/template-resolver.js +74 -0
@@ -0,0 +1,614 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+
4
+ const { resolveProfileProvider } = require('../agent-profiles');
5
+ const { branchDelete, runGit, statusPorcelain, worktreeAdd, worktreePrune, worktreeRemove } = require('../git');
6
+ const { safeBranchName, worktreesRootForRepo } = require('../slice');
7
+ const { buildGraph, computeLevels, detectFileConflicts, isFoundationSliceId, readAllSlices, topoSort, SliceGraphError } = require('../slice-graph');
8
+ const { runExecuteSlice } = require('./executor');
9
+
10
+ const EXCLUDED_STATUSES = new Set(['completed', 'skipped', 'cancelled']);
11
+ const EXECUTION_MODES = new Set(['auto', 'manual', 'delegated']);
12
+
13
+ function formatError(message) {
14
+ return `create-quiver: ${message}`;
15
+ }
16
+
17
+ function toRelativePath(repoRoot, filePath) {
18
+ return path.relative(repoRoot, filePath).split(path.sep).join('/');
19
+ }
20
+
21
+ function normalizeExecutionMode(mode) {
22
+ const value = String(mode || 'auto').trim().toLowerCase() || 'auto';
23
+ if (!EXECUTION_MODES.has(value)) {
24
+ throw new Error(formatError(`unsupported execution mode: ${mode}. Use auto, manual, or delegated.`));
25
+ }
26
+ return value;
27
+ }
28
+
29
+ function summarizeSlice(node, repoRoot) {
30
+ return {
31
+ ref: node.ref,
32
+ spec_slug: node.specSlug,
33
+ slice_id: node.sliceId,
34
+ slice_path: node.slicePath ? toRelativePath(repoRoot, node.slicePath) : '',
35
+ title: node.title || node.sliceId,
36
+ status: node.status || 'draft',
37
+ files: Array.isArray(node.files) ? node.files : [],
38
+ depends_on: Array.isArray(node.depends_on) ? node.depends_on : [],
39
+ parallel_safe: node.parallel_safe || null,
40
+ parallel_safe_reason: node.parallel_safe_reason || null,
41
+ branch_name: node.json?.git?.branch_name || '',
42
+ };
43
+ }
44
+
45
+ function buildPendingGraph(graph, options = {}) {
46
+ const specSlug = options.specSlug ? String(options.specSlug).trim() : '';
47
+ const pendingNodes = graph.nodes.filter((node) => {
48
+ if (specSlug && node.specSlug !== specSlug) {
49
+ return false;
50
+ }
51
+ return !EXCLUDED_STATUSES.has(String(node.status || '').toLowerCase());
52
+ });
53
+ const pendingRefs = new Set(pendingNodes.map((node) => node.ref));
54
+ const nodesBySpec = new Map();
55
+ const foundationRefsBySpec = new Map();
56
+
57
+ for (const node of pendingNodes) {
58
+ if (!nodesBySpec.has(node.specSlug)) {
59
+ nodesBySpec.set(node.specSlug, []);
60
+ }
61
+ nodesBySpec.get(node.specSlug).push(node);
62
+
63
+ if (isFoundationSliceId(node.sliceId)) {
64
+ if (!foundationRefsBySpec.has(node.specSlug)) {
65
+ foundationRefsBySpec.set(node.specSlug, []);
66
+ }
67
+ foundationRefsBySpec.get(node.specSlug).push(node.ref);
68
+ }
69
+ }
70
+
71
+ const edgeKey = (from, to) => `${from}::${to}`;
72
+ const edges = [];
73
+ const seenEdges = new Set();
74
+
75
+ for (const edge of graph.edges) {
76
+ if (!pendingRefs.has(edge.from) || !pendingRefs.has(edge.to)) {
77
+ continue;
78
+ }
79
+ const key = edgeKey(edge.from, edge.to);
80
+ if (seenEdges.has(key)) {
81
+ continue;
82
+ }
83
+ seenEdges.add(key);
84
+ edges.push({ from: edge.from, to: edge.to });
85
+ }
86
+
87
+ for (const [specSlug, specNodes] of nodesBySpec.entries()) {
88
+ const foundationRefs = foundationRefsBySpec.get(specSlug) || [];
89
+ if (foundationRefs.length === 0) {
90
+ continue;
91
+ }
92
+
93
+ for (const node of specNodes) {
94
+ if (isFoundationSliceId(node.sliceId)) {
95
+ continue;
96
+ }
97
+
98
+ for (const foundationRef of foundationRefs) {
99
+ const key = edgeKey(foundationRef, node.ref);
100
+ if (seenEdges.has(key)) {
101
+ continue;
102
+ }
103
+ seenEdges.add(key);
104
+ edges.push({ from: foundationRef, to: node.ref, implicit: true, reason: 'slice-00 foundation barrier' });
105
+ }
106
+ }
107
+ }
108
+
109
+ return {
110
+ nodes: pendingNodes,
111
+ edges,
112
+ foundationRefs: Array.from(foundationRefsBySpec.values()).flat().sort((left, right) => String(left).localeCompare(String(right))),
113
+ };
114
+ }
115
+
116
+ function buildFallbackReason({ conflicts, unknownScopeSlices }) {
117
+ if (unknownScopeSlices.length > 0) {
118
+ return `Unknown file scope: ${unknownScopeSlices.join(', ')}`;
119
+ }
120
+ if (conflicts.length > 0) {
121
+ return `File conflicts: ${conflicts.map((conflict) => conflict.slices.join(', ')).join('; ')}`;
122
+ }
123
+ return '';
124
+ }
125
+
126
+ function buildLevelStrategy(levelNodes, { parallelReady, conflicts, unknownScopeSlices }) {
127
+ if (parallelReady) {
128
+ return {
129
+ mode: 'temporary-per-slice',
130
+ temporary_worktrees: true,
131
+ reason: 'Run each ready slice in its own temporary worktree, then integrate the commits in stable level order.',
132
+ };
133
+ }
134
+
135
+ if (levelNodes.length > 1) {
136
+ return {
137
+ mode: 'sequential-fallback',
138
+ temporary_worktrees: false,
139
+ reason: buildFallbackReason({ conflicts, unknownScopeSlices }) || 'Run sequentially because this level is not parallel-ready.',
140
+ };
141
+ }
142
+
143
+ return {
144
+ mode: 'shared-worktree',
145
+ temporary_worktrees: false,
146
+ reason: 'A single ready slice can reuse the active worktree.',
147
+ };
148
+ }
149
+
150
+ function buildExecutionGroups(slices, parallelReady, fallbackReason) {
151
+ if (parallelReady) {
152
+ return [{
153
+ mode: 'parallel',
154
+ reason: 'No file-scope conflicts detected.',
155
+ slice_refs: slices.map((slice) => slice.ref),
156
+ }];
157
+ }
158
+
159
+ return slices.map((slice) => ({
160
+ mode: 'sequential',
161
+ reason: fallbackReason || 'Sequential execution is the safe default.',
162
+ slice_refs: [slice.ref],
163
+ }));
164
+ }
165
+
166
+ function summarizeLevel(levelNodes, index, repoRoot) {
167
+ const slices = levelNodes.map((node) => summarizeSlice(node, repoRoot));
168
+ const sliceRefs = slices.map((slice) => slice.ref);
169
+ const conflicts = detectFileConflicts(levelNodes).map((group) => ({
170
+ files: group.files,
171
+ slices: group.slices,
172
+ }));
173
+ const unknownScopeSlices = slices
174
+ .filter((slice) => !Array.isArray(slice.files) || slice.files.length === 0)
175
+ .map((slice) => slice.ref);
176
+ const fallbackReason = buildFallbackReason({ conflicts, unknownScopeSlices });
177
+ const parallelReady = levelNodes.length > 1 && conflicts.length === 0 && unknownScopeSlices.length === 0;
178
+
179
+ return {
180
+ index,
181
+ slice_refs: sliceRefs,
182
+ parallel_ready: parallelReady,
183
+ requires_temporary_worktrees: parallelReady,
184
+ worktree_strategy: buildLevelStrategy(levelNodes, { parallelReady, conflicts, unknownScopeSlices }),
185
+ conflicts,
186
+ unknown_scope_slices: unknownScopeSlices,
187
+ fallback_reason: fallbackReason || null,
188
+ execution_groups: buildExecutionGroups(slices, parallelReady, fallbackReason),
189
+ slices,
190
+ };
191
+ }
192
+
193
+ function collectExecutionPlan(repoRoot, options = {}) {
194
+ try {
195
+ const allSlices = readAllSlices(repoRoot);
196
+ const graph = buildGraph(allSlices);
197
+ topoSort(graph);
198
+
199
+ const specSlug = options.specSlug ? String(options.specSlug).trim() : '';
200
+ const pendingGraph = buildPendingGraph(graph, { specSlug });
201
+ if (pendingGraph.nodes.length === 0) {
202
+ return {
203
+ root: repoRoot,
204
+ summary: {
205
+ total_slices: 0,
206
+ ready_levels: 0,
207
+ parallel_levels: 0,
208
+ foundation_refs: [],
209
+ },
210
+ ready_levels: [],
211
+ levels: [],
212
+ execution_order: [],
213
+ integration_order: [],
214
+ sequential_order: [],
215
+ };
216
+ }
217
+
218
+ const readyLevels = computeLevels(pendingGraph);
219
+ const readyLevelReports = readyLevels.map((levelNodes, index) => summarizeLevel(levelNodes, index, repoRoot));
220
+ const executionOrder = topoSort(pendingGraph).map((node) => node.ref);
221
+ const integrationOrder = readyLevelReports.flatMap((level) => level.slice_refs);
222
+ const foundationRefs = pendingGraph.foundationRefs;
223
+
224
+ return {
225
+ root: repoRoot,
226
+ summary: {
227
+ total_slices: pendingGraph.nodes.length,
228
+ ready_levels: readyLevelReports.length,
229
+ parallel_levels: readyLevelReports.filter((level) => level.parallel_ready).length,
230
+ foundation_refs: foundationRefs,
231
+ },
232
+ ready_levels: readyLevelReports,
233
+ levels: readyLevelReports,
234
+ execution_order: executionOrder,
235
+ integration_order: integrationOrder,
236
+ sequential_order: executionOrder,
237
+ options: {
238
+ specSlug,
239
+ },
240
+ };
241
+ } catch (error) {
242
+ if (error instanceof SliceGraphError) {
243
+ throw error;
244
+ }
245
+ throw new Error(formatError(`unable to build execution plan: ${error.message || error}`));
246
+ }
247
+ }
248
+
249
+ function formatHumanExecutionPlan(report) {
250
+ const lines = [
251
+ 'Execution plan',
252
+ `Total slices: ${report.summary.total_slices}`,
253
+ `Ready levels: ${report.summary.ready_levels}`,
254
+ `Parallel levels: ${report.summary.parallel_levels}`,
255
+ `Foundation refs: ${report.summary.foundation_refs.length > 0 ? report.summary.foundation_refs.join(', ') : '-'}`,
256
+ '',
257
+ 'Sequential order',
258
+ ];
259
+
260
+ if (report.sequential_order.length === 0) {
261
+ lines.push('- none');
262
+ } else {
263
+ for (const [index, ref] of report.sequential_order.entries()) {
264
+ lines.push(`${index + 1}. ${ref}`);
265
+ }
266
+ }
267
+
268
+ lines.push('', 'Ready levels');
269
+
270
+ if (report.ready_levels.length === 0) {
271
+ lines.push('- none');
272
+ return `${lines.join('\n')}\n`;
273
+ }
274
+
275
+ for (const level of report.ready_levels) {
276
+ const modeLabel = level.parallel_ready ? 'parallel-ready' : 'sequential';
277
+ lines.push(`Level ${level.index} (${modeLabel})`);
278
+ lines.push(`Worktree strategy: ${level.worktree_strategy.mode}`);
279
+ if (level.fallback_reason) {
280
+ lines.push(`Fallback: ${level.fallback_reason}`);
281
+ }
282
+
283
+ for (const slice of level.slices) {
284
+ lines.push(`- ${slice.ref} [${slice.status}]`);
285
+ }
286
+
287
+ if (level.conflicts.length > 0) {
288
+ lines.push('Conflicts:');
289
+ for (const conflict of level.conflicts) {
290
+ lines.push(`- ${conflict.slices.join(', ')} :: ${conflict.files.join(', ')}`);
291
+ }
292
+ }
293
+
294
+ if (level.unknown_scope_slices.length > 0) {
295
+ lines.push('Unknown scope:');
296
+ for (const ref of level.unknown_scope_slices) {
297
+ lines.push(`- ${ref}`);
298
+ }
299
+ }
300
+
301
+ lines.push('');
302
+ }
303
+
304
+ lines.push('Integration order');
305
+ for (const [index, ref] of report.integration_order.entries()) {
306
+ lines.push(`${index + 1}. ${ref}`);
307
+ }
308
+
309
+ return `${lines.join('\n')}\n`;
310
+ }
311
+
312
+ function formatExecutePlanDryRun(report, options = {}) {
313
+ const provider = options.resolvedProvider || options.provider || 'codex';
314
+ const commitEnabled = options.commit === true;
315
+ const executionMode = normalizeExecutionMode(options.mode || options.executionMode);
316
+ const lines = [
317
+ 'AI execute-plan dry-run',
318
+ `Execution mode: ${executionMode}`,
319
+ `Provider: ${provider}`,
320
+ `Commit after each slice: ${commitEnabled ? 'enabled' : 'disabled'}`,
321
+ `Total slices: ${report.summary.total_slices}`,
322
+ '',
323
+ 'Waves',
324
+ ];
325
+
326
+ const commandForSlice = (slice) => {
327
+ const parts = [
328
+ 'npx create-quiver ai execute-slice',
329
+ `--slice ${JSON.stringify(slice.slice_path)}`,
330
+ `--provider ${provider}`,
331
+ ];
332
+ if (commitEnabled) {
333
+ parts.push('--commit');
334
+ }
335
+ return parts.join(' ');
336
+ };
337
+ const promptCommandForSlice = (slice) => [
338
+ 'npx create-quiver ai prompt-slice',
339
+ `--slice ${JSON.stringify(slice.slice_path)}`,
340
+ '--dry-run',
341
+ ].join(' ');
342
+
343
+ for (const level of report.ready_levels) {
344
+ lines.push(`Wave ${level.index}: ${level.parallel_ready ? 'parallel-ready' : 'sequential'}`);
345
+ lines.push(`Workspace strategy: ${level.worktree_strategy.mode}`);
346
+ if (level.fallback_reason) {
347
+ lines.push(`Fallback: ${level.fallback_reason}`);
348
+ }
349
+ for (const group of level.execution_groups) {
350
+ lines.push(`Group: ${group.mode}`);
351
+ for (const ref of group.slice_refs) {
352
+ const slice = level.slices.find((item) => item.ref === ref);
353
+ lines.push(`- Prompt: ${promptCommandForSlice(slice)}`);
354
+ if (executionMode !== 'manual') {
355
+ lines.push(` Execute: ${commandForSlice(slice)}`);
356
+ }
357
+ }
358
+ }
359
+ }
360
+
361
+ return `${lines.join('\n')}\n`;
362
+ }
363
+
364
+ function buildRecoveryGuidance(ref, workspaces = []) {
365
+ const lines = [
366
+ 'Recovery:',
367
+ `- Retry slice: npx create-quiver ai prompt-slice --slice <slice.json> --dry-run, then rerun only ${ref}.`,
368
+ '- Abort: inspect the active checkout and temporary worktrees before reverting, stashing, or removing anything.',
369
+ ];
370
+
371
+ if (workspaces.length > 0) {
372
+ lines.push('- Temporary worktrees left for inspection:');
373
+ for (const workspace of workspaces) {
374
+ lines.push(` - ${workspace.worktreePath}`);
375
+ }
376
+ }
377
+
378
+ return lines.join('\n');
379
+ }
380
+
381
+ function appendRecovery(error, ref, workspaces = []) {
382
+ const message = error && error.message ? error.message : String(error);
383
+ if (message.includes('Recovery:')) {
384
+ return error;
385
+ }
386
+
387
+ const wrapped = new Error(`${message}\n\n${buildRecoveryGuidance(ref, workspaces)}`);
388
+ wrapped.cause = error;
389
+ wrapped.code = error && error.code ? error.code : undefined;
390
+ wrapped.details = error && error.details ? error.details : undefined;
391
+ return wrapped;
392
+ }
393
+
394
+ function ensureCleanIntegrationWorktree(repoRoot) {
395
+ const status = statusPorcelain(repoRoot);
396
+ if (status !== '') {
397
+ throw new Error(formatError(`delegated parallel execution requires a clean active worktree before integration. Dirty files: ${status.split('\n').join(', ')}`));
398
+ }
399
+ }
400
+
401
+ function buildDelegatedRunId() {
402
+ return new Date().toISOString().replace(/[^0-9A-Za-z]/g, '');
403
+ }
404
+
405
+ function buildDelegatedWorkspace(repoRoot, slice, runId, index, options = {}) {
406
+ const safeRef = safeBranchName(slice.ref).slice(0, 80);
407
+ const branchName = `quiver-exec-${runId}-${index + 1}-${safeRef}`;
408
+ const worktreesRoot = options.worktreesRoot || path.join(worktreesRootForRepo(repoRoot, branchName), 'execute-plan');
409
+ const worktreePath = path.join(worktreesRoot, runId, safeRef);
410
+
411
+ return {
412
+ branchName,
413
+ ref: slice.ref,
414
+ slice,
415
+ worktreePath,
416
+ };
417
+ }
418
+
419
+ function createDelegatedWorkspace(repoRoot, workspace, baseRef) {
420
+ if (fs.existsSync(workspace.worktreePath)) {
421
+ throw new Error(formatError(`temporary worktree path already exists: ${workspace.worktreePath}`));
422
+ }
423
+
424
+ fs.mkdirSync(path.dirname(workspace.worktreePath), { recursive: true });
425
+ worktreeAdd(repoRoot, workspace.worktreePath, baseRef, { branch: workspace.branchName });
426
+ }
427
+
428
+ function cleanupDelegatedWorkspace(repoRoot, workspace) {
429
+ try {
430
+ worktreeRemove(repoRoot, workspace.worktreePath);
431
+ } catch {
432
+ // Keep cleanup best-effort after successful integration.
433
+ }
434
+ try {
435
+ branchDelete(repoRoot, workspace.branchName, true);
436
+ } catch {
437
+ // The committed changes were already integrated; a leftover temp branch is non-blocking.
438
+ }
439
+ }
440
+
441
+ async function runSequentialGroup(repoRoot, level, group, options = {}) {
442
+ const runSlice = options.runExecuteSliceFn || runExecuteSlice;
443
+ const results = [];
444
+
445
+ for (const ref of group.slice_refs) {
446
+ const slice = level.slices.find((item) => item.ref === ref);
447
+ try {
448
+ const result = await runSlice(repoRoot, {
449
+ allowDirty: options.allowDirty === true,
450
+ commit: true,
451
+ context: options.context,
452
+ dryRun: false,
453
+ provider: options.provider,
454
+ providerExplicit: options.providerExplicit,
455
+ role: options.role,
456
+ slice: slice.slice_path,
457
+ timeout: options.timeout,
458
+ });
459
+ results.push({
460
+ level: level.index,
461
+ mode: 'sequential',
462
+ ref,
463
+ ok: true,
464
+ result,
465
+ workspace: repoRoot,
466
+ });
467
+ } catch (error) {
468
+ throw appendRecovery(error, ref);
469
+ }
470
+ }
471
+
472
+ return results;
473
+ }
474
+
475
+ async function runParallelGroupInWorktrees(repoRoot, level, group, options = {}) {
476
+ ensureCleanIntegrationWorktree(repoRoot);
477
+
478
+ const runSlice = options.runExecuteSliceFn || runExecuteSlice;
479
+ const baseRef = runGit(['rev-parse', 'HEAD'], repoRoot);
480
+ const runId = options.runId || buildDelegatedRunId();
481
+ const slices = group.slice_refs.map((ref) => level.slices.find((item) => item.ref === ref));
482
+ const workspaces = slices.map((slice, index) => buildDelegatedWorkspace(repoRoot, slice, runId, index, options));
483
+
484
+ let runResults;
485
+ try {
486
+ worktreePrune(repoRoot);
487
+ for (const workspace of workspaces) {
488
+ createDelegatedWorkspace(repoRoot, workspace, baseRef);
489
+ }
490
+
491
+ runResults = await Promise.all(workspaces.map(async (workspace) => {
492
+ const result = await runSlice(workspace.worktreePath, {
493
+ allowDirty: false,
494
+ commit: true,
495
+ context: options.context,
496
+ dryRun: false,
497
+ provider: options.provider,
498
+ providerExplicit: options.providerExplicit,
499
+ role: options.role,
500
+ slice: workspace.slice.slice_path,
501
+ timeout: options.timeout,
502
+ });
503
+ const commit = runGit(['rev-parse', 'HEAD'], workspace.worktreePath);
504
+ if (commit === baseRef) {
505
+ throw new Error(formatError(`delegated slice ${workspace.ref} finished without creating a slice commit.`));
506
+ }
507
+ return {
508
+ commit,
509
+ level: level.index,
510
+ mode: 'parallel-worktree',
511
+ ok: true,
512
+ ref: workspace.ref,
513
+ result,
514
+ workspace,
515
+ };
516
+ }));
517
+
518
+ ensureCleanIntegrationWorktree(repoRoot);
519
+ for (const item of runResults) {
520
+ runGit(['cherry-pick', item.commit], repoRoot);
521
+ }
522
+
523
+ for (const workspace of workspaces) {
524
+ cleanupDelegatedWorkspace(repoRoot, workspace);
525
+ }
526
+ } catch (error) {
527
+ throw appendRecovery(error, group.slice_refs.join(', '), workspaces);
528
+ }
529
+
530
+ return runResults.map((item) => ({
531
+ level: item.level,
532
+ mode: item.mode,
533
+ ref: item.ref,
534
+ ok: item.ok,
535
+ result: item.result,
536
+ workspace: item.workspace.worktreePath,
537
+ integratedCommit: item.commit,
538
+ }));
539
+ }
540
+
541
+ async function runExecutePlan(repoRoot, options = {}) {
542
+ const report = collectExecutionPlan(repoRoot, options);
543
+ const execute = options.execute === true;
544
+ const executionMode = normalizeExecutionMode(options.mode || options.executionMode);
545
+ const provider = options.providerExplicit === true || (options.provider && options.providerExplicit !== false)
546
+ ? options.provider
547
+ : resolveProfileProvider(repoRoot, options.role || 'executor', 'codex');
548
+ const resolvedOptions = {
549
+ ...options,
550
+ mode: executionMode,
551
+ provider,
552
+ resolvedProvider: provider,
553
+ };
554
+
555
+ if (options.json && !execute) {
556
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
557
+ return { task: 'execute-plan', dryRun: true, report };
558
+ }
559
+
560
+ if (!execute || options.dryRun === true) {
561
+ process.stdout.write(formatExecutePlanDryRun(report, resolvedOptions));
562
+ return { task: 'execute-plan', dryRun: true, report };
563
+ }
564
+
565
+ if (executionMode === 'manual') {
566
+ throw new Error(formatError('ai execute-plan --execute does not support --mode manual. Use the printed prompt-slice commands, or choose --mode delegated.'));
567
+ }
568
+
569
+ if (options.commit !== true) {
570
+ throw new Error(formatError('ai execute-plan --execute requires --commit so each successful slice creates one commit.'));
571
+ }
572
+
573
+ const results = [];
574
+
575
+ for (const level of report.ready_levels) {
576
+ for (const group of level.execution_groups) {
577
+ try {
578
+ const groupResults = executionMode === 'delegated' && group.mode === 'parallel' && group.slice_refs.length > 1
579
+ ? await runParallelGroupInWorktrees(repoRoot, level, group, resolvedOptions)
580
+ : await runSequentialGroup(repoRoot, level, group, resolvedOptions);
581
+ results.push(...groupResults);
582
+ } catch (error) {
583
+ const wrapped = new Error(formatError(`ai execute-plan stopped at wave ${level.index} group ${group.slice_refs.join(', ')}: ${error.message || error}`));
584
+ wrapped.cause = error;
585
+ wrapped.code = error.code || 'AI_EXECUTE_PLAN_FAILED';
586
+ wrapped.details = { level: level.index, group, results };
587
+ throw wrapped;
588
+ }
589
+ }
590
+ }
591
+
592
+ process.stdout.write(`AI execute-plan completed\nSlices executed: ${results.length}\n`);
593
+ return { task: 'execute-plan', dryRun: false, report, results };
594
+ }
595
+
596
+ function runExecutionPlan(repoRoot, options = {}) {
597
+ const report = collectExecutionPlan(repoRoot, options);
598
+ if (options.json) {
599
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
600
+ return report;
601
+ }
602
+
603
+ process.stdout.write(formatHumanExecutionPlan(report, options));
604
+ return report;
605
+ }
606
+
607
+ module.exports = {
608
+ collectExecutionPlan,
609
+ formatExecutePlanDryRun,
610
+ formatHumanExecutionPlan,
611
+ normalizeExecutionMode,
612
+ runExecutePlan,
613
+ runExecutionPlan,
614
+ };