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,715 @@
1
+ const path = require('node:path');
2
+
3
+ const SPEC_FOUNDATION_SLICE_ID = 'slice-00-spec-foundation';
4
+
5
+ function currentDate() {
6
+ return new Date().toISOString().slice(0, 10);
7
+ }
8
+
9
+ function slugify(value) {
10
+ return String(value || '')
11
+ .normalize('NFKD')
12
+ .replace(/[\u0300-\u036f]/g, '')
13
+ .toLowerCase()
14
+ .replace(/[^a-z0-9]+/g, '-')
15
+ .replace(/^-+|-+$/g, '') || 'generated-spec';
16
+ }
17
+
18
+ function titleizeFromSlug(value) {
19
+ return String(value || '')
20
+ .split('-')
21
+ .filter(Boolean)
22
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
23
+ .join(' ');
24
+ }
25
+
26
+ function bullets(items, fallback = '- n/a') {
27
+ const list = Array.isArray(items) ? items.filter(Boolean) : [];
28
+ if (list.length === 0) {
29
+ return [fallback];
30
+ }
31
+ return list.map((item) => `- ${item}`);
32
+ }
33
+
34
+ function displayStatus(status, defaultStatus = 'draft') {
35
+ const normalized = String(status || defaultStatus).trim().toLowerCase();
36
+ if (normalized === 'completed') {
37
+ return 'Completed';
38
+ }
39
+ if (normalized === 'ready') {
40
+ return 'Ready';
41
+ }
42
+ if (normalized === 'blocked') {
43
+ return 'Blocked';
44
+ }
45
+ return 'Draft';
46
+ }
47
+
48
+ function section(lines, heading, bodyLines) {
49
+ lines.push(heading, '', ...bodyLines, '');
50
+ }
51
+
52
+ function renderScope(scope = {}) {
53
+ const lines = [];
54
+ section(lines, '### Included', bullets(scope.included, '- n/a'));
55
+ section(lines, '### Excluded', bullets(scope.excluded, '- n/a'));
56
+ return lines;
57
+ }
58
+
59
+ function renderSliceTableRows(manifest) {
60
+ return manifest.slices.map((slice, index) => {
61
+ const sliceLink = `./slices/${slice.slice_id}/slice.json`;
62
+ const status = displayStatus(slice.status, index === 0 ? 'ready' : 'draft');
63
+ return `| ${String(index).padStart(2, '0')} | ${slice.title} | ${status} | [${slice.slice_id}](${sliceLink}) |`;
64
+ });
65
+ }
66
+
67
+ function renderStatusRows(manifest) {
68
+ return manifest.slices.map((slice, index) => {
69
+ const status = displayStatus(slice.status, index === 0 ? 'ready' : 'draft');
70
+ return `| ${slice.slice_id} | ${slice.title} | ${status} | - | ${slice.estimated_hours || 0} | - |`;
71
+ });
72
+ }
73
+
74
+ function renderEvidenceRows(manifest) {
75
+ return manifest.slices.map((slice, index) => {
76
+ const status = displayStatus(slice.status, index === 0 ? 'ready' : 'draft');
77
+ const evidence = index === 0
78
+ ? 'Spec foundation generated and JSON validation completed.'
79
+ : 'Pending implementation.';
80
+ return `| ${slice.slice_id} | ${slice.acceptance.length || 0} | ${status} | ${evidence} |`;
81
+ });
82
+ }
83
+
84
+ function renderParallelGroups(manifest) {
85
+ const groups = manifest.executionGroups.filter((group) => group.length > 1);
86
+ if (groups.length === 0) {
87
+ return ['- No parallel groups in the first generated draft.'];
88
+ }
89
+
90
+ return groups.map((group, index) => {
91
+ const refs = group.map((slice) => slice.slice_id).join(', ');
92
+ return `- Group ${index + 1} after ${group[0].depends_on.join(', ') || 'slice-00-spec-foundation'}: ${refs}`;
93
+ });
94
+ }
95
+
96
+ function renderExecutionOrder(manifest) {
97
+ return manifest.executionOrder.map((slice, index) => {
98
+ const deps = slice.depends_on.length > 0 ? slice.depends_on.join(', ') : 'none';
99
+ return `${index + 1}. \`${slice.slice_id}\` - depends on ${deps}`;
100
+ });
101
+ }
102
+
103
+ function buildSpecMarkdown(manifest) {
104
+ const lines = [
105
+ `# ${manifest.title}`,
106
+ '',
107
+ `**Date:** ${manifest.date}`,
108
+ `**Status:** ${manifest.status}`,
109
+ '',
110
+ '## Objective',
111
+ '',
112
+ manifest.objective,
113
+ '',
114
+ '## Approved Input',
115
+ '',
116
+ `Approved source: \`${manifest.sourcePath}\``,
117
+ '',
118
+ '## Scope',
119
+ '',
120
+ ...renderScope(manifest.scope),
121
+ '## Acceptance Criteria',
122
+ '',
123
+ ...bullets(manifest.acceptance, '- All generated files parse and the spec is safe to review.'),
124
+ '',
125
+ '## Slices',
126
+ '',
127
+ '| Slice | Title | Status | Spec |',
128
+ '|-------|-------|--------|------|',
129
+ `| 00 | ${manifest.slices[0].title} | ${displayStatus(manifest.slices[0].status, 'ready')} | [${manifest.slices[0].slice_id}](./slices/${manifest.slices[0].slice_id}/slice.json) |`,
130
+ ...renderSliceTableRows(manifest).slice(1),
131
+ '',
132
+ '## Definition of Done',
133
+ '',
134
+ '- `slice-00` exists and every later slice depends on it directly or indirectly.',
135
+ '- Every slice has `slice.json`, `EXECUTION_BRIEF.md`, and `CLOSURE_BRIEF.md`.',
136
+ '- `pr.md` exists for the spec.',
137
+ '- All generated `slice.json` files parse successfully.',
138
+ '',
139
+ '## Risks',
140
+ '',
141
+ ...bullets(manifest.risks, '- The first version can only use the approved input source and a safe fallback layout.'),
142
+ '',
143
+ ];
144
+
145
+ return `${lines.join('\n')}\n`;
146
+ }
147
+
148
+ function buildStatusMarkdown(manifest) {
149
+ const lines = [
150
+ `# ${manifest.title} Spec Status`,
151
+ '',
152
+ `**Spec:** ${manifest.slug}`,
153
+ `**Last updated:** ${manifest.date}`,
154
+ '',
155
+ '## Spec Status',
156
+ '',
157
+ '| Slice | Title | Status | PR | Estimated hours | Actual hours |',
158
+ '|-------|--------|--------|----|-----------------|--------------|',
159
+ ...renderStatusRows(manifest),
160
+ '',
161
+ '## Progress',
162
+ '',
163
+ `- Completed slices: ${manifest.slices.filter((slice) => slice.status === 'completed').length} / ${manifest.slices.length}`,
164
+ `- Estimated hours: ${manifest.slices.reduce((sum, slice) => sum + Number(slice.estimated_hours || 0), 0)}`,
165
+ '- Actual hours: 0',
166
+ '',
167
+ '## Blockers',
168
+ '',
169
+ '| Slice | Blocker | Since | Action needed |',
170
+ '|-------|---------|-------|---------------|',
171
+ '| - | - | - | - |',
172
+ '',
173
+ ];
174
+
175
+ return `${lines.join('\n')}\n`;
176
+ }
177
+
178
+ function buildEvidenceMarkdown(manifest) {
179
+ const lines = [
180
+ `# ${manifest.title} Evidence Report`,
181
+ '',
182
+ `**Spec:** ${manifest.slug}`,
183
+ `**Last updated:** ${manifest.date}`,
184
+ `**Status:** In progress`,
185
+ '',
186
+ '## Summary',
187
+ '',
188
+ '| Slice | Acceptance criteria | Status | Evidence |',
189
+ '|-------|---------------------|--------|----------|',
190
+ ...renderEvidenceRows(manifest),
191
+ '',
192
+ '## Evidence by Slice',
193
+ '',
194
+ '- Record command, exit code, and the first relevant success or failure signal for each slice.',
195
+ '- Keep long logs in artifacts or separate files when needed.',
196
+ '',
197
+ ];
198
+
199
+ return `${lines.join('\n')}\n`;
200
+ }
201
+
202
+ function buildExecutionPlanMarkdown(manifest) {
203
+ const lines = [
204
+ `# Execution Plan - ${manifest.title}`,
205
+ '',
206
+ '## Rule',
207
+ '',
208
+ '`slice-00` is mandatory and must be committed first. It establishes the spec foundation in the repo.',
209
+ '',
210
+ '## Sequential Foundation',
211
+ '',
212
+ ...renderExecutionOrder(manifest),
213
+ '',
214
+ '## Parallelizable Work',
215
+ '',
216
+ ...renderParallelGroups(manifest),
217
+ '',
218
+ '## Final Integration',
219
+ '',
220
+ 'Keep later slices integrated in dependency order and only merge parallel work after its prerequisites are committed.',
221
+ '',
222
+ '## Suggested Commit Order',
223
+ '',
224
+ ...manifest.executionOrder.map((slice) => `- ${slice.slice_id}`),
225
+ '',
226
+ ];
227
+
228
+ return `${lines.join('\n')}\n`;
229
+ }
230
+
231
+ function buildPrMarkdown(manifest) {
232
+ const files = [
233
+ `specs/${manifest.slug}/SPEC.md`,
234
+ `specs/${manifest.slug}/STATUS.md`,
235
+ `specs/${manifest.slug}/EVIDENCE_REPORT.md`,
236
+ `specs/${manifest.slug}/EXECUTION_PLAN.md`,
237
+ `specs/${manifest.slug}/pr.md`,
238
+ `specs/${manifest.slug}/slices/**`,
239
+ ];
240
+
241
+ const lines = [
242
+ `# PR - ${manifest.ticket} - ${manifest.title}`,
243
+ '',
244
+ '## Title',
245
+ '',
246
+ `${manifest.title} spec generation`,
247
+ '',
248
+ '## Summary',
249
+ '',
250
+ 'Generate the spec foundation, slice-00, implementation slices, execution plan, and PR body from the approved planning input.',
251
+ '',
252
+ '## Scope',
253
+ '',
254
+ '- `SPEC.md`',
255
+ '- `STATUS.md`',
256
+ '- `EVIDENCE_REPORT.md`',
257
+ '- `EXECUTION_PLAN.md`',
258
+ '- `pr.md`',
259
+ '- `slice-00` and later slices with execution and closure briefs',
260
+ '',
261
+ '## Files',
262
+ '',
263
+ ...files.map((file) => `- \`${file}\``),
264
+ '',
265
+ '## How to Test (DETAILED - REQUIRED)',
266
+ '',
267
+ '### Required Environment',
268
+ '',
269
+ '- Node.js',
270
+ '- Git',
271
+ '',
272
+ '### Worktree Access',
273
+ '',
274
+ '```bash',
275
+ `cd <repo-root>`,
276
+ `npx create-quiver spec create --input <approved-input> --spec ${manifest.slug}`,
277
+ '```',
278
+ '',
279
+ '### Run the Project',
280
+ '',
281
+ '```bash',
282
+ 'git diff --check',
283
+ 'find specs/' + manifest.slug + " -name 'slice.json' -print -exec node -e \"JSON.parse(require('fs').readFileSync(process.argv[1], 'utf8'))\" {} \\;",
284
+ '```',
285
+ '',
286
+ '### Use Cases',
287
+ '',
288
+ '#### Case 1: Generate a new spec pack',
289
+ '',
290
+ '**Prerequisite:** approved input is available.',
291
+ '',
292
+ '1. Run `spec create`.',
293
+ '2. Inspect the generated spec directory.',
294
+ '',
295
+ '**Expected result:** all generated files exist and every JSON file parses.',
296
+ '',
297
+ '### Technical Verification',
298
+ '',
299
+ '```bash',
300
+ 'git diff --check',
301
+ '```',
302
+ '',
303
+ '## Evidence',
304
+ '',
305
+ '- Spec, status, evidence, execution plan, and slice briefs are present.',
306
+ '- Every generated `slice.json` parses successfully.',
307
+ '',
308
+ '## Rollback',
309
+ '',
310
+ '1. `git revert <commit-hash>`',
311
+ '2. Re-run the JSON validation command.',
312
+ '3. Confirm the spec directory is back to the previous state.',
313
+ '',
314
+ '## Risks / Notes',
315
+ '',
316
+ '- The first version uses the approved input as the source of truth and fails safely on existing spec directories.',
317
+ '',
318
+ ];
319
+
320
+ return `${lines.join('\n')}\n`;
321
+ }
322
+
323
+ function buildSliceJson(manifest, slice, index) {
324
+ const isFoundation = index === 0;
325
+ const dependsOn = isFoundation ? [] : Array.from(new Set(['slice-00-spec-foundation', ...(slice.depends_on || [])]));
326
+ const branchSlug = slice.git?.branch_slug || slugify(slice.slice_id);
327
+ const ticket = slice.ticket || manifest.ticket;
328
+
329
+ return {
330
+ slice_id: slice.slice_id,
331
+ ticket,
332
+ type: slice.type || (isFoundation ? 'docs' : 'feature'),
333
+ title: slice.title,
334
+ objective: slice.objective,
335
+ description: slice.description,
336
+ git: {
337
+ branch_type: slice.git?.branch_type || 'feature',
338
+ base_branch: slice.git?.base_branch || 'main',
339
+ branch_slug: branchSlug,
340
+ branch_name: slice.git?.branch_name || `feature/${ticket}-${branchSlug}`,
341
+ },
342
+ must: Array.isArray(slice.must) ? slice.must : [],
343
+ not_included: Array.isArray(slice.not_included) ? slice.not_included : [],
344
+ acceptance: Array.isArray(slice.acceptance) ? slice.acceptance : [],
345
+ files: Array.isArray(slice.files) ? slice.files : [],
346
+ depends_on: dependsOn,
347
+ parallel_safe: slice.parallel_safe || (isFoundation ? 'never' : 'after_dependencies'),
348
+ parallel_safe_reason: slice.parallel_safe_reason || (isFoundation
349
+ ? 'slice-00 is the mandatory documentation foundation and must land before every implementation slice.'
350
+ : 'Can run after slice-00 and the approved input has been staged.'),
351
+ tests: Array.isArray(slice.tests) ? slice.tests : [],
352
+ documentation: [
353
+ `specs/${manifest.slug}/slices/${slice.slice_id}/EXECUTION_BRIEF.md`,
354
+ `specs/${manifest.slug}/slices/${slice.slice_id}/CLOSURE_BRIEF.md`,
355
+ ],
356
+ assumptions: Array.isArray(slice.assumptions) ? slice.assumptions : [],
357
+ estimated_hours: Number.isFinite(Number(slice.estimated_hours)) ? Number(slice.estimated_hours) : 0,
358
+ actual_hours: 0,
359
+ status: slice.status || (isFoundation ? 'ready' : 'draft'),
360
+ blocked_reason: slice.blocked_reason ?? null,
361
+ ready_at: slice.ready_at ?? null,
362
+ started_at: slice.started_at ?? null,
363
+ completed_at: slice.completed_at ?? null,
364
+ };
365
+ }
366
+
367
+ function buildExecutionBrief(manifest, slice) {
368
+ const lines = [
369
+ `# EXECUTION BRIEF - ${slice.slice_id}`,
370
+ '',
371
+ `**Spec:** ${manifest.slug}`,
372
+ `**Slice:** ${slice.slice_id}`,
373
+ `**Tipo:** ${slice.type}`,
374
+ '',
375
+ '## Contexto',
376
+ '',
377
+ slice.description,
378
+ '',
379
+ '## Objetivo',
380
+ '',
381
+ slice.objective,
382
+ '',
383
+ '## Alcance',
384
+ '',
385
+ ...bullets(slice.must, '- No declared requirements.'),
386
+ '',
387
+ '## Criterios de aceptacion',
388
+ '',
389
+ ...bullets(slice.acceptance, '- No declared acceptance criteria.'),
390
+ '',
391
+ '## Plan tecnico resumido',
392
+ '',
393
+ `Follow the approved input staged in \`${manifest.sourcePath}\` and keep the slice inside its declared files.`,
394
+ '',
395
+ '## Pasos sugeridos de ejecucion',
396
+ '',
397
+ '1. Read the approved input.',
398
+ '2. Implement the declared files.',
399
+ '3. Run the declared validation commands.',
400
+ '',
401
+ '## Restricciones',
402
+ '',
403
+ ...bullets(slice.not_included, '- No explicit exclusions were declared.'),
404
+ '',
405
+ '## Riesgos',
406
+ '',
407
+ '- The slice can drift if the implementation expands beyond the approved files or acceptance criteria.',
408
+ '',
409
+ '## Checklist de finalizacion',
410
+ '',
411
+ '- [ ] Validations pass.',
412
+ '- [ ] JSON parses.',
413
+ '- [ ] The work stays inside scope.',
414
+ '',
415
+ ];
416
+
417
+ return `${lines.join('\n')}\n`;
418
+ }
419
+
420
+ function buildClosureBrief(manifest, slice) {
421
+ const lines = [
422
+ `# CLOSURE BRIEF - ${slice.slice_id}`,
423
+ '',
424
+ '## Resumen de lo realizado',
425
+ '',
426
+ 'Pendiente de completar al cerrar la slice.',
427
+ '',
428
+ '## Validacion contra criterios de aceptacion',
429
+ '',
430
+ ...bullets(slice.acceptance.map((item) => `[ ] ${item}`), '- [ ] Validations pending.'),
431
+ '',
432
+ '## Cambios relevantes',
433
+ '',
434
+ 'Pendiente.',
435
+ '',
436
+ '## Pendientes',
437
+ '',
438
+ 'Pendiente.',
439
+ '',
440
+ '## Riesgos remanentes',
441
+ '',
442
+ 'Pendiente.',
443
+ '',
444
+ '## Recomendaciones futuras',
445
+ '',
446
+ `Continue with the next dependent slice after reviewing \`${manifest.sourcePath}\`.`,
447
+ '',
448
+ ];
449
+
450
+ return `${lines.join('\n')}\n`;
451
+ }
452
+
453
+ function normalizeSliceName(sliceId) {
454
+ return String(sliceId || '').trim() || SPEC_FOUNDATION_SLICE_ID;
455
+ }
456
+
457
+ function buildDefaultImplementationSlice(manifest) {
458
+ const title = `${manifest.title} implementation`;
459
+ return {
460
+ slice_id: 'slice-01-implementation',
461
+ ticket: manifest.ticket,
462
+ type: 'feature',
463
+ title,
464
+ objective: manifest.objective,
465
+ description: `Implement the approved plan captured in ${manifest.sourcePath}.`,
466
+ git: {
467
+ branch_type: 'feature',
468
+ base_branch: 'main',
469
+ branch_slug: 'implementation',
470
+ branch_name: `feature/${manifest.ticket}-implementation`,
471
+ },
472
+ must: manifest.acceptance.length > 0 ? manifest.acceptance.slice(0, 3) : ['Implement the approved plan.'],
473
+ not_included: manifest.scope.excluded.length > 0 ? manifest.scope.excluded.slice() : ['No provider execution or PR opening.'],
474
+ acceptance: manifest.acceptance.length > 0 ? manifest.acceptance.slice() : ['The approved plan can be implemented safely.'],
475
+ files: [],
476
+ depends_on: [SPEC_FOUNDATION_SLICE_ID],
477
+ parallel_safe: 'after_dependencies',
478
+ parallel_safe_reason: 'Can run after slice-00 and the approved input has been staged.',
479
+ tests: [],
480
+ assumptions: manifest.assumptions.slice(),
481
+ estimated_hours: 4,
482
+ status: 'draft',
483
+ };
484
+ }
485
+
486
+ function buildManifest(source, options = {}) {
487
+ const sourcePath = options.sourcePath || source.sourcePath || 'approved-input.md';
488
+ const date = currentDate();
489
+ const specSource = source.spec && typeof source.spec === 'object' ? source.spec : source;
490
+ const rawSlug = options.specSlug || specSource.slug || specSource.spec_slug || specSource.specSlug || specSource.title || path.basename(sourcePath, path.extname(sourcePath));
491
+ const slug = slugify(rawSlug);
492
+ const title = String(specSource.title || source.title || titleizeFromSlug(slug) || 'Generated spec').trim();
493
+ const ticket = String(specSource.ticket || source.ticket || slug.toUpperCase().slice(0, 12) || 'SPEC-01').trim();
494
+ const objective = String(specSource.objective || source.objective || 'Generate the approved spec artifacts from the staged plan input.').trim();
495
+ const scope = {
496
+ included: Array.isArray(specSource.scope?.included) ? specSource.scope.included.slice() : Array.isArray(source.scope?.included) ? source.scope.included.slice() : [],
497
+ excluded: Array.isArray(specSource.scope?.excluded) ? specSource.scope.excluded.slice() : Array.isArray(source.scope?.excluded) ? source.scope.excluded.slice() : [],
498
+ };
499
+ const acceptance = Array.isArray(specSource.acceptance) ? specSource.acceptance.slice() : Array.isArray(source.acceptance) ? source.acceptance.slice() : [];
500
+ const risks = Array.isArray(specSource.risks) ? specSource.risks.slice() : Array.isArray(source.risks) ? source.risks.slice() : [];
501
+ const assumptions = Array.isArray(specSource.assumptions) ? specSource.assumptions.slice() : Array.isArray(source.assumptions) ? source.assumptions.slice() : [];
502
+
503
+ const rawSlices = Array.isArray(specSource.slices) ? specSource.slices : Array.isArray(source.slices) ? source.slices : [];
504
+ const normalizedSlices = rawSlices.length > 0
505
+ ? rawSlices.map((slice) => normalizeImplementationSlice(slice, ticket))
506
+ : [buildDefaultImplementationSlice({
507
+ acceptance,
508
+ assumptions,
509
+ objective,
510
+ scope,
511
+ sourcePath,
512
+ ticket,
513
+ title,
514
+ })];
515
+
516
+ const slices = [
517
+ {
518
+ slice_id: SPEC_FOUNDATION_SLICE_ID,
519
+ ticket: `${ticket}-00`,
520
+ type: 'docs',
521
+ title: 'Spec foundation',
522
+ objective: 'Create the spec foundation and generated PR materials.',
523
+ description: `Document the approved AI planning output from ${sourcePath}.`,
524
+ git: {
525
+ branch_type: 'feature',
526
+ base_branch: 'main',
527
+ branch_slug: 'spec-foundation',
528
+ branch_name: `feature/${ticket}-spec-foundation`,
529
+ },
530
+ must: [
531
+ 'Create SPEC.md with the approved requirements and plan.',
532
+ 'Create STATUS.md and EVIDENCE_REPORT.md.',
533
+ 'Create EXECUTION_PLAN.md and pr.md.',
534
+ 'Create slice.json, EXECUTION_BRIEF.md, and CLOSURE_BRIEF.md for every slice.',
535
+ ],
536
+ not_included: [
537
+ 'Provider execution.',
538
+ 'Automatic commits.',
539
+ ],
540
+ acceptance: [
541
+ 'The spec directory exists.',
542
+ 'Every generated JSON file parses successfully.',
543
+ 'pr.md always exists.',
544
+ ],
545
+ files: [
546
+ `specs/${slug}/SPEC.md`,
547
+ `specs/${slug}/STATUS.md`,
548
+ `specs/${slug}/EVIDENCE_REPORT.md`,
549
+ `specs/${slug}/EXECUTION_PLAN.md`,
550
+ `specs/${slug}/pr.md`,
551
+ `specs/${slug}/slices/**`,
552
+ ],
553
+ depends_on: [],
554
+ parallel_safe: 'never',
555
+ parallel_safe_reason: 'slice-00 is the mandatory documentation foundation and must land before every implementation slice.',
556
+ tests: ['git diff --check'],
557
+ assumptions,
558
+ estimated_hours: 1.5,
559
+ status: 'ready',
560
+ },
561
+ ...normalizedSlices,
562
+ ].map((slice, index) => normalizeSliceManifest(slice, index, ticket));
563
+
564
+ const executionOrder = orderSlices(slices);
565
+ const executionGroups = buildExecutionGroups(slices);
566
+
567
+ return {
568
+ slug,
569
+ title,
570
+ ticket,
571
+ date,
572
+ status: 'Active',
573
+ sourcePath,
574
+ sourceText: source.sourceText || '',
575
+ objective,
576
+ scope,
577
+ acceptance,
578
+ risks,
579
+ assumptions,
580
+ slices,
581
+ executionOrder,
582
+ executionGroups,
583
+ };
584
+ }
585
+
586
+ function normalizeImplementationSlice(slice, fallbackTicket) {
587
+ return normalizeSliceManifest({
588
+ ...slice,
589
+ type: slice.type || 'feature',
590
+ }, 1, fallbackTicket);
591
+ }
592
+
593
+ function normalizeSliceManifest(slice, index, fallbackTicket) {
594
+ const sliceId = normalizeSliceName(slice.slice_id || slice.sliceId || (index === 0 ? SPEC_FOUNDATION_SLICE_ID : `slice-${String(index).padStart(2, '0')}-implementation`));
595
+ const title = String(slice.title || (index === 0 ? 'Spec foundation' : titleizeFromSlug(sliceId))).trim();
596
+ const ticket = String(slice.ticket || fallbackTicket).trim();
597
+ const objective = String(slice.objective || '').trim() || (index === 0
598
+ ? 'Create the spec foundation and generated PR materials.'
599
+ : 'Implement the approved plan.');
600
+ const description = String(slice.description || '').trim() || (index === 0
601
+ ? 'Document the approved planning input.'
602
+ : `Implement the approved plan captured in the spec source.`);
603
+ const dependsOn = Array.isArray(slice.depends_on) ? slice.depends_on.map((dep) => String(dep).trim()).filter(Boolean) : [];
604
+ const files = Array.isArray(slice.files) ? slice.files.map((file) => String(file).trim()).filter(Boolean) : [];
605
+ const must = Array.isArray(slice.must) ? slice.must.map((item) => String(item).trim()).filter(Boolean) : [];
606
+ const notIncluded = Array.isArray(slice.not_included) ? slice.not_included.map((item) => String(item).trim()).filter(Boolean) : [];
607
+ const acceptance = Array.isArray(slice.acceptance) ? slice.acceptance.map((item) => String(item).trim()).filter(Boolean) : [];
608
+ const tests = Array.isArray(slice.tests) ? slice.tests.map((item) => String(item).trim()).filter(Boolean) : [];
609
+ const assumptions = Array.isArray(slice.assumptions) ? slice.assumptions.map((item) => String(item).trim()).filter(Boolean) : [];
610
+ const normalizedDependsOn = index === 0
611
+ ? dependsOn
612
+ : Array.from(new Set([SPEC_FOUNDATION_SLICE_ID, ...dependsOn]));
613
+
614
+ return {
615
+ slice_id: sliceId,
616
+ ticket,
617
+ type: slice.type || (index === 0 ? 'docs' : 'feature'),
618
+ title,
619
+ objective,
620
+ description,
621
+ git: {
622
+ branch_type: slice.git?.branch_type || 'feature',
623
+ base_branch: slice.git?.base_branch || 'main',
624
+ branch_slug: String(slice.git?.branch_slug || slugify(sliceId)).trim(),
625
+ branch_name: String(slice.git?.branch_name || `feature/${ticket}-${slugify(sliceId)}`).trim(),
626
+ },
627
+ must,
628
+ not_included: notIncluded,
629
+ acceptance,
630
+ files,
631
+ depends_on: normalizedDependsOn,
632
+ parallel_safe: slice.parallel_safe,
633
+ parallel_safe_reason: slice.parallel_safe_reason,
634
+ tests,
635
+ assumptions,
636
+ estimated_hours: Number.isFinite(Number(slice.estimated_hours)) ? Number(slice.estimated_hours) : 0,
637
+ status: slice.status || (index === 0 ? 'ready' : 'draft'),
638
+ blocked_reason: slice.blocked_reason ?? null,
639
+ ready_at: slice.ready_at ?? null,
640
+ started_at: slice.started_at ?? null,
641
+ completed_at: slice.completed_at ?? null,
642
+ };
643
+ }
644
+
645
+ function orderSlices(slices) {
646
+ const ordered = [];
647
+ const remaining = new Map(slices.map((slice) => [slice.slice_id, slice]));
648
+ const resolved = new Set();
649
+
650
+ while (remaining.size > 0) {
651
+ let progress = false;
652
+ for (const [sliceId, slice] of remaining) {
653
+ const deps = Array.isArray(slice.depends_on) ? slice.depends_on : [];
654
+ if (deps.every((dep) => resolved.has(dep) || dep === sliceId)) {
655
+ ordered.push(slice);
656
+ remaining.delete(sliceId);
657
+ resolved.add(sliceId);
658
+ progress = true;
659
+ }
660
+ }
661
+
662
+ if (!progress) {
663
+ ordered.push(...remaining.values());
664
+ break;
665
+ }
666
+ }
667
+
668
+ return ordered;
669
+ }
670
+
671
+ function buildExecutionGroups(slices) {
672
+ const remaining = new Map(slices.map((slice) => [slice.slice_id, slice]));
673
+ const completed = new Set();
674
+ const groups = [];
675
+
676
+ while (remaining.size > 0) {
677
+ const ready = Array.from(remaining.values()).filter((slice) => {
678
+ const deps = Array.isArray(slice.depends_on) ? slice.depends_on : [];
679
+ return deps.every((dep) => completed.has(dep) || dep === slice.slice_id);
680
+ });
681
+
682
+ if (ready.length === 0) {
683
+ groups.push(Array.from(remaining.values()));
684
+ break;
685
+ }
686
+
687
+ groups.push(ready);
688
+ for (const slice of ready) {
689
+ completed.add(slice.slice_id);
690
+ remaining.delete(slice.slice_id);
691
+ }
692
+ }
693
+
694
+ return groups;
695
+ }
696
+
697
+ function normalizeApprovedSource(text) {
698
+ return String(text || '').trim();
699
+ }
700
+
701
+ module.exports = {
702
+ SPEC_FOUNDATION_SLICE_ID,
703
+ buildClosureBrief,
704
+ buildEvidenceMarkdown,
705
+ buildExecutionBrief,
706
+ buildExecutionPlanMarkdown,
707
+ buildManifest,
708
+ buildPrMarkdown,
709
+ buildSliceJson,
710
+ buildSpecMarkdown,
711
+ buildStatusMarkdown,
712
+ normalizeApprovedSource,
713
+ slugify,
714
+ titleizeFromSlug,
715
+ };