openspecui 0.0.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 (311) hide show
  1. package/.gitmodules +3 -0
  2. package/CHAT.md +3 -0
  3. package/package.json +12 -0
  4. package/references/openspec/.changeset/README.md +6 -0
  5. package/references/openspec/.changeset/config.json +12 -0
  6. package/references/openspec/.coderabbit.yaml +11 -0
  7. package/references/openspec/.devcontainer/README.md +92 -0
  8. package/references/openspec/.devcontainer/devcontainer.json +68 -0
  9. package/references/openspec/.github/CODEOWNERS +2 -0
  10. package/references/openspec/.github/workflows/ci.yml +222 -0
  11. package/references/openspec/.github/workflows/release-prepare.yml +50 -0
  12. package/references/openspec/AGENTS.md +18 -0
  13. package/references/openspec/CHANGELOG.md +205 -0
  14. package/references/openspec/LICENSE +22 -0
  15. package/references/openspec/README.md +374 -0
  16. package/references/openspec/assets/openspec_dashboard.png +0 -0
  17. package/references/openspec/assets/openspec_pixel_dark.svg +89 -0
  18. package/references/openspec/assets/openspec_pixel_light.svg +89 -0
  19. package/references/openspec/bin/openspec.js +3 -0
  20. package/references/openspec/build.js +31 -0
  21. package/references/openspec/openspec/AGENTS.md +454 -0
  22. package/references/openspec/openspec/changes/IMPLEMENTATION_ORDER.md +68 -0
  23. package/references/openspec/openspec/changes/add-antigravity-support/proposal.md +11 -0
  24. package/references/openspec/openspec/changes/add-antigravity-support/specs/cli-init/spec.md +9 -0
  25. package/references/openspec/openspec/changes/add-antigravity-support/specs/cli-update/spec.md +8 -0
  26. package/references/openspec/openspec/changes/add-antigravity-support/tasks.md +12 -0
  27. package/references/openspec/openspec/changes/add-scaffold-command/proposal.md +11 -0
  28. package/references/openspec/openspec/changes/add-scaffold-command/specs/cli-scaffold/spec.md +36 -0
  29. package/references/openspec/openspec/changes/add-scaffold-command/tasks.md +12 -0
  30. package/references/openspec/openspec/changes/archive/2025-01-11-add-update-command/design.md +86 -0
  31. package/references/openspec/openspec/changes/archive/2025-01-11-add-update-command/proposal.md +29 -0
  32. package/references/openspec/openspec/changes/archive/2025-01-11-add-update-command/specs/cli-update/spec.md +59 -0
  33. package/references/openspec/openspec/changes/archive/2025-01-11-add-update-command/tasks.md +20 -0
  34. package/references/openspec/openspec/changes/archive/2025-01-13-add-list-command/proposal.md +20 -0
  35. package/references/openspec/openspec/changes/archive/2025-01-13-add-list-command/specs/cli-list/spec.md +69 -0
  36. package/references/openspec/openspec/changes/archive/2025-01-13-add-list-command/tasks.md +26 -0
  37. package/references/openspec/openspec/changes/archive/2025-08-05-initialize-typescript-project/design.md +64 -0
  38. package/references/openspec/openspec/changes/archive/2025-08-05-initialize-typescript-project/proposal.md +18 -0
  39. package/references/openspec/openspec/changes/archive/2025-08-05-initialize-typescript-project/tasks.md +25 -0
  40. package/references/openspec/openspec/changes/archive/2025-08-06-add-init-command/design.md +104 -0
  41. package/references/openspec/openspec/changes/archive/2025-08-06-add-init-command/proposal.md +30 -0
  42. package/references/openspec/openspec/changes/archive/2025-08-06-add-init-command/specs/cli-init/spec.md +148 -0
  43. package/references/openspec/openspec/changes/archive/2025-08-06-add-init-command/tasks.md +38 -0
  44. package/references/openspec/openspec/changes/archive/2025-08-06-adopt-future-state-storage/proposal.md +24 -0
  45. package/references/openspec/openspec/changes/archive/2025-08-06-adopt-future-state-storage/specs/openspec-conventions/spec.md +120 -0
  46. package/references/openspec/openspec/changes/archive/2025-08-06-adopt-future-state-storage/tasks.md +38 -0
  47. package/references/openspec/openspec/changes/archive/2025-08-11-add-complexity-guidelines/proposal.md +13 -0
  48. package/references/openspec/openspec/changes/archive/2025-08-11-add-complexity-guidelines/specs/openspec-docs/README.md +472 -0
  49. package/references/openspec/openspec/changes/archive/2025-08-11-add-complexity-guidelines/tasks.md +9 -0
  50. package/references/openspec/openspec/changes/archive/2025-08-13-add-archive-command/proposal.md +15 -0
  51. package/references/openspec/openspec/changes/archive/2025-08-13-add-archive-command/specs/cli-archive/spec.md +111 -0
  52. package/references/openspec/openspec/changes/archive/2025-08-13-add-archive-command/tasks.md +44 -0
  53. package/references/openspec/openspec/changes/archive/2025-08-13-add-diff-command/proposal.md +19 -0
  54. package/references/openspec/openspec/changes/archive/2025-08-13-add-diff-command/specs/cli-diff/spec.md +77 -0
  55. package/references/openspec/openspec/changes/archive/2025-08-13-add-diff-command/tasks.md +23 -0
  56. package/references/openspec/openspec/changes/archive/2025-08-19-add-change-commands/design.md +56 -0
  57. package/references/openspec/openspec/changes/archive/2025-08-19-add-change-commands/proposal.md +17 -0
  58. package/references/openspec/openspec/changes/archive/2025-08-19-add-change-commands/specs/cli-change/spec.md +48 -0
  59. package/references/openspec/openspec/changes/archive/2025-08-19-add-change-commands/specs/cli-list/spec.md +12 -0
  60. package/references/openspec/openspec/changes/archive/2025-08-19-add-change-commands/tasks.md +34 -0
  61. package/references/openspec/openspec/changes/archive/2025-08-19-add-interactive-show-command/proposal.md +20 -0
  62. package/references/openspec/openspec/changes/archive/2025-08-19-add-interactive-show-command/specs/cli-change/spec.md +23 -0
  63. package/references/openspec/openspec/changes/archive/2025-08-19-add-interactive-show-command/specs/cli-show/spec.md +83 -0
  64. package/references/openspec/openspec/changes/archive/2025-08-19-add-interactive-show-command/specs/cli-spec/spec.md +23 -0
  65. package/references/openspec/openspec/changes/archive/2025-08-19-add-interactive-show-command/tasks.md +142 -0
  66. package/references/openspec/openspec/changes/archive/2025-08-19-add-skip-specs-archive-option/proposal.md +13 -0
  67. package/references/openspec/openspec/changes/archive/2025-08-19-add-skip-specs-archive-option/specs/cli-archive/spec.md +191 -0
  68. package/references/openspec/openspec/changes/archive/2025-08-19-add-skip-specs-archive-option/tasks.md +57 -0
  69. package/references/openspec/openspec/changes/archive/2025-08-19-add-spec-commands/design.md +45 -0
  70. package/references/openspec/openspec/changes/archive/2025-08-19-add-spec-commands/proposal.md +19 -0
  71. package/references/openspec/openspec/changes/archive/2025-08-19-add-spec-commands/specs/cli-spec/spec.md +43 -0
  72. package/references/openspec/openspec/changes/archive/2025-08-19-add-spec-commands/tasks.md +22 -0
  73. package/references/openspec/openspec/changes/archive/2025-08-19-add-zod-validation/design.md +104 -0
  74. package/references/openspec/openspec/changes/archive/2025-08-19-add-zod-validation/proposal.md +22 -0
  75. package/references/openspec/openspec/changes/archive/2025-08-19-add-zod-validation/specs/cli-archive/spec.md +18 -0
  76. package/references/openspec/openspec/changes/archive/2025-08-19-add-zod-validation/specs/cli-diff/spec.md +12 -0
  77. package/references/openspec/openspec/changes/archive/2025-08-19-add-zod-validation/tasks.md +59 -0
  78. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-delta-based-changes/proposal.md +93 -0
  79. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-delta-based-changes/specs/cli-archive/spec.md +48 -0
  80. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-delta-based-changes/specs/cli-diff/spec.md +45 -0
  81. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-delta-based-changes/specs/openspec-conventions/spec.md +101 -0
  82. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-delta-based-changes/tasks.md +55 -0
  83. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-verb-noun-cli-structure/design.md +19 -0
  84. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-verb-noun-cli-structure/proposal.md +67 -0
  85. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-verb-noun-cli-structure/specs/cli-list/spec.md +57 -0
  86. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-verb-noun-cli-structure/specs/openspec-conventions/spec.md +23 -0
  87. package/references/openspec/openspec/changes/archive/2025-08-19-adopt-verb-noun-cli-structure/tasks.md +27 -0
  88. package/references/openspec/openspec/changes/archive/2025-08-19-bulk-validation-interactive-selection/proposal.md +20 -0
  89. package/references/openspec/openspec/changes/archive/2025-08-19-bulk-validation-interactive-selection/specs/cli-change/spec.md +22 -0
  90. package/references/openspec/openspec/changes/archive/2025-08-19-bulk-validation-interactive-selection/specs/cli-spec/spec.md +23 -0
  91. package/references/openspec/openspec/changes/archive/2025-08-19-bulk-validation-interactive-selection/specs/cli-validate/spec.md +149 -0
  92. package/references/openspec/openspec/changes/archive/2025-08-19-bulk-validation-interactive-selection/tasks.md +81 -0
  93. package/references/openspec/openspec/changes/archive/2025-08-19-fix-update-tool-selection/proposal.md +40 -0
  94. package/references/openspec/openspec/changes/archive/2025-08-19-fix-update-tool-selection/specs/cli-update/spec.md +23 -0
  95. package/references/openspec/openspec/changes/archive/2025-08-19-fix-update-tool-selection/tasks.md +21 -0
  96. package/references/openspec/openspec/changes/archive/2025-08-19-improve-validate-error-messages/proposal.md +25 -0
  97. package/references/openspec/openspec/changes/archive/2025-08-19-improve-validate-error-messages/specs/cli-validate/spec.md +55 -0
  98. package/references/openspec/openspec/changes/archive/2025-08-19-improve-validate-error-messages/tasks.md +21 -0
  99. package/references/openspec/openspec/changes/archive/2025-08-19-structured-spec-format/proposal.md +36 -0
  100. package/references/openspec/openspec/changes/archive/2025-08-19-structured-spec-format/specs/openspec-conventions/spec.md +192 -0
  101. package/references/openspec/openspec/changes/archive/2025-08-19-structured-spec-format/tasks.md +19 -0
  102. package/references/openspec/openspec/changes/archive/2025-09-12-add-view-dashboard-command/proposal.md +38 -0
  103. package/references/openspec/openspec/changes/archive/2025-09-12-add-view-dashboard-command/specs/cli-view/spec.md +109 -0
  104. package/references/openspec/openspec/changes/archive/2025-09-12-add-view-dashboard-command/tasks.md +47 -0
  105. package/references/openspec/openspec/changes/archive/2025-09-29-add-agents-md-config/proposal.md +28 -0
  106. package/references/openspec/openspec/changes/archive/2025-09-29-add-agents-md-config/specs/cli-init/spec.md +71 -0
  107. package/references/openspec/openspec/changes/archive/2025-09-29-add-agents-md-config/specs/cli-update/spec.md +41 -0
  108. package/references/openspec/openspec/changes/archive/2025-09-29-add-agents-md-config/tasks.md +17 -0
  109. package/references/openspec/openspec/changes/archive/2025-09-29-add-multi-agent-init/proposal.md +35 -0
  110. package/references/openspec/openspec/changes/archive/2025-09-29-add-multi-agent-init/specs/cli-init/spec.md +45 -0
  111. package/references/openspec/openspec/changes/archive/2025-09-29-add-multi-agent-init/tasks.md +16 -0
  112. package/references/openspec/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md +119 -0
  113. package/references/openspec/openspec/changes/archive/2025-09-29-add-slash-command-support/specs/cli-init/spec.md +21 -0
  114. package/references/openspec/openspec/changes/archive/2025-09-29-add-slash-command-support/specs/cli-update/spec.md +22 -0
  115. package/references/openspec/openspec/changes/archive/2025-09-29-add-slash-command-support/tasks.md +20 -0
  116. package/references/openspec/openspec/changes/archive/2025-09-29-improve-cli-e2e-plan/proposal.md +19 -0
  117. package/references/openspec/openspec/changes/archive/2025-09-29-improve-cli-e2e-plan/tasks.md +9 -0
  118. package/references/openspec/openspec/changes/archive/2025-09-29-improve-deterministic-tests/proposal.md +78 -0
  119. package/references/openspec/openspec/changes/archive/2025-09-29-improve-deterministic-tests/tasks.md +25 -0
  120. package/references/openspec/openspec/changes/archive/2025-09-29-improve-init-onboarding/proposal.md +13 -0
  121. package/references/openspec/openspec/changes/archive/2025-09-29-improve-init-onboarding/specs/cli-init/spec.md +92 -0
  122. package/references/openspec/openspec/changes/archive/2025-09-29-improve-init-onboarding/tasks.md +12 -0
  123. package/references/openspec/openspec/changes/archive/2025-09-29-remove-diff-command/proposal.md +81 -0
  124. package/references/openspec/openspec/changes/archive/2025-09-29-remove-diff-command/tasks.md +37 -0
  125. package/references/openspec/openspec/changes/archive/2025-09-29-sort-active-changes-by-progress/proposal.md +25 -0
  126. package/references/openspec/openspec/changes/archive/2025-09-29-sort-active-changes-by-progress/specs/cli-view/spec.md +9 -0
  127. package/references/openspec/openspec/changes/archive/2025-09-29-sort-active-changes-by-progress/tasks.md +8 -0
  128. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-file-name/proposal.md +29 -0
  129. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-file-name/specs/cli-init/spec.md +40 -0
  130. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-file-name/specs/cli-update/spec.md +22 -0
  131. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-file-name/specs/openspec-conventions/spec.md +27 -0
  132. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-file-name/tasks.md +22 -0
  133. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-instructions/design.md +130 -0
  134. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-instructions/proposal.md +117 -0
  135. package/references/openspec/openspec/changes/archive/2025-09-29-update-agent-instructions/tasks.md +69 -0
  136. package/references/openspec/openspec/changes/archive/2025-09-29-update-markdown-parser-crlf/proposal.md +19 -0
  137. package/references/openspec/openspec/changes/archive/2025-09-29-update-markdown-parser-crlf/specs/cli-validate/spec.md +9 -0
  138. package/references/openspec/openspec/changes/archive/2025-09-29-update-markdown-parser-crlf/tasks.md +11 -0
  139. package/references/openspec/openspec/changes/archive/2025-10-14-add-codex-slash-command-support/proposal.md +25 -0
  140. package/references/openspec/openspec/changes/archive/2025-10-14-add-codex-slash-command-support/specs/cli-init/spec.md +56 -0
  141. package/references/openspec/openspec/changes/archive/2025-10-14-add-codex-slash-command-support/specs/cli-update/spec.md +41 -0
  142. package/references/openspec/openspec/changes/archive/2025-10-14-add-codex-slash-command-support/tasks.md +19 -0
  143. package/references/openspec/openspec/changes/archive/2025-10-14-add-github-copilot-prompts/proposal.md +25 -0
  144. package/references/openspec/openspec/changes/archive/2025-10-14-add-github-copilot-prompts/specs/cli-init/spec.md +48 -0
  145. package/references/openspec/openspec/changes/archive/2025-10-14-add-github-copilot-prompts/specs/cli-update/spec.md +48 -0
  146. package/references/openspec/openspec/changes/archive/2025-10-14-add-github-copilot-prompts/tasks.md +30 -0
  147. package/references/openspec/openspec/changes/archive/2025-10-14-add-kilocode-workflows/proposal.md +17 -0
  148. package/references/openspec/openspec/changes/archive/2025-10-14-add-kilocode-workflows/specs/cli-init/spec.md +43 -0
  149. package/references/openspec/openspec/changes/archive/2025-10-14-add-kilocode-workflows/specs/cli-update/spec.md +27 -0
  150. package/references/openspec/openspec/changes/archive/2025-10-14-add-kilocode-workflows/tasks.md +15 -0
  151. package/references/openspec/openspec/changes/archive/2025-10-14-add-non-interactive-init-options/proposal.md +12 -0
  152. package/references/openspec/openspec/changes/archive/2025-10-14-add-non-interactive-init-options/specs/cli-init/spec.md +39 -0
  153. package/references/openspec/openspec/changes/archive/2025-10-14-add-non-interactive-init-options/tasks.md +17 -0
  154. package/references/openspec/openspec/changes/archive/2025-10-14-add-windsurf-workflows/proposal.md +17 -0
  155. package/references/openspec/openspec/changes/archive/2025-10-14-add-windsurf-workflows/specs/cli-init/spec.md +42 -0
  156. package/references/openspec/openspec/changes/archive/2025-10-14-add-windsurf-workflows/specs/cli-update/spec.md +27 -0
  157. package/references/openspec/openspec/changes/archive/2025-10-14-add-windsurf-workflows/tasks.md +17 -0
  158. package/references/openspec/openspec/changes/archive/2025-10-14-enhance-validation-error-messages/proposal.md +12 -0
  159. package/references/openspec/openspec/changes/archive/2025-10-14-enhance-validation-error-messages/specs/cli-validate/spec.md +39 -0
  160. package/references/openspec/openspec/changes/archive/2025-10-14-enhance-validation-error-messages/tasks.md +12 -0
  161. package/references/openspec/openspec/changes/archive/2025-10-14-improve-agent-instruction-usability/proposal.md +12 -0
  162. package/references/openspec/openspec/changes/archive/2025-10-14-improve-agent-instruction-usability/specs/docs-agent-instructions/spec.md +33 -0
  163. package/references/openspec/openspec/changes/archive/2025-10-14-improve-agent-instruction-usability/tasks.md +11 -0
  164. package/references/openspec/openspec/changes/archive/2025-10-14-slim-root-agents-file/proposal.md +13 -0
  165. package/references/openspec/openspec/changes/archive/2025-10-14-slim-root-agents-file/tasks.md +15 -0
  166. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-enter-selection/proposal.md +14 -0
  167. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-enter-selection/specs/cli-init/spec.md +10 -0
  168. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-enter-selection/tasks.md +8 -0
  169. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-root-agents/proposal.md +15 -0
  170. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-root-agents/specs/cli-init/spec.md +32 -0
  171. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-root-agents/specs/cli-update/spec.md +10 -0
  172. package/references/openspec/openspec/changes/archive/2025-10-14-update-cli-init-root-agents/tasks.md +11 -0
  173. package/references/openspec/openspec/changes/archive/2025-10-14-update-release-automation/proposal.md +49 -0
  174. package/references/openspec/openspec/changes/archive/2025-10-14-update-release-automation/tasks.md +12 -0
  175. package/references/openspec/openspec/changes/archive/2025-10-22-add-archive-command-arguments/proposal.md +17 -0
  176. package/references/openspec/openspec/changes/archive/2025-10-22-add-archive-command-arguments/specs/cli-update/spec.md +32 -0
  177. package/references/openspec/openspec/changes/archive/2025-10-22-add-archive-command-arguments/tasks.md +15 -0
  178. package/references/openspec/openspec/changes/archive/2025-10-22-add-cline-support/proposal.md +15 -0
  179. package/references/openspec/openspec/changes/archive/2025-10-22-add-cline-support/specs/cli-init/spec.md +97 -0
  180. package/references/openspec/openspec/changes/archive/2025-10-22-add-cline-support/tasks.md +19 -0
  181. package/references/openspec/openspec/changes/archive/2025-10-22-add-crush-support/proposal.md +13 -0
  182. package/references/openspec/openspec/changes/archive/2025-10-22-add-crush-support/specs/cli-init/spec.md +67 -0
  183. package/references/openspec/openspec/changes/archive/2025-10-22-add-crush-support/tasks.md +7 -0
  184. package/references/openspec/openspec/changes/archive/2025-10-22-add-factory-slash-commands/proposal.md +12 -0
  185. package/references/openspec/openspec/changes/archive/2025-10-22-add-factory-slash-commands/specs/cli-init/spec.md +54 -0
  186. package/references/openspec/openspec/changes/archive/2025-10-22-add-factory-slash-commands/specs/cli-update/spec.md +54 -0
  187. package/references/openspec/openspec/changes/archive/2025-10-22-add-factory-slash-commands/tasks.md +11 -0
  188. package/references/openspec/openspec/changes/fix-cline-workflows-implementation/proposal.md +13 -0
  189. package/references/openspec/openspec/changes/fix-cline-workflows-implementation/specs/cli-init/spec.md +11 -0
  190. package/references/openspec/openspec/changes/fix-cline-workflows-implementation/tasks.md +13 -0
  191. package/references/openspec/openspec/changes/make-validation-scope-aware/proposal.md +12 -0
  192. package/references/openspec/openspec/changes/make-validation-scope-aware/specs/cli-validate/spec.md +25 -0
  193. package/references/openspec/openspec/changes/make-validation-scope-aware/tasks.md +16 -0
  194. package/references/openspec/openspec/project.md +53 -0
  195. package/references/openspec/openspec/specs/cli-archive/spec.md +210 -0
  196. package/references/openspec/openspec/specs/cli-change/spec.md +91 -0
  197. package/references/openspec/openspec/specs/cli-init/spec.md +311 -0
  198. package/references/openspec/openspec/specs/cli-list/spec.md +103 -0
  199. package/references/openspec/openspec/specs/cli-show/spec.md +85 -0
  200. package/references/openspec/openspec/specs/cli-spec/spec.md +87 -0
  201. package/references/openspec/openspec/specs/cli-update/spec.md +190 -0
  202. package/references/openspec/openspec/specs/cli-validate/spec.md +218 -0
  203. package/references/openspec/openspec/specs/cli-view/spec.md +105 -0
  204. package/references/openspec/openspec/specs/docs-agent-instructions/spec.md +38 -0
  205. package/references/openspec/openspec/specs/openspec-conventions/spec.md +474 -0
  206. package/references/openspec/openspec-parallel-merge-plan.md +98 -0
  207. package/references/openspec/package.json +73 -0
  208. package/references/openspec/pnpm-lock.yaml +2324 -0
  209. package/references/openspec/scripts/pack-version-check.mjs +111 -0
  210. package/references/openspec/src/cli/index.ts +253 -0
  211. package/references/openspec/src/commands/change.ts +291 -0
  212. package/references/openspec/src/commands/show.ts +139 -0
  213. package/references/openspec/src/commands/spec.ts +250 -0
  214. package/references/openspec/src/commands/validate.ts +305 -0
  215. package/references/openspec/src/core/archive.ts +606 -0
  216. package/references/openspec/src/core/config.ts +41 -0
  217. package/references/openspec/src/core/configurators/agents.ts +23 -0
  218. package/references/openspec/src/core/configurators/base.ts +6 -0
  219. package/references/openspec/src/core/configurators/claude.ts +23 -0
  220. package/references/openspec/src/core/configurators/cline.ts +23 -0
  221. package/references/openspec/src/core/configurators/codebuddy.ts +24 -0
  222. package/references/openspec/src/core/configurators/costrict.ts +23 -0
  223. package/references/openspec/src/core/configurators/iflow.ts +23 -0
  224. package/references/openspec/src/core/configurators/qoder.ts +53 -0
  225. package/references/openspec/src/core/configurators/qwen.ts +47 -0
  226. package/references/openspec/src/core/configurators/registry.ts +49 -0
  227. package/references/openspec/src/core/configurators/slash/amazon-q.ts +51 -0
  228. package/references/openspec/src/core/configurators/slash/antigravity.ts +28 -0
  229. package/references/openspec/src/core/configurators/slash/auggie.ts +37 -0
  230. package/references/openspec/src/core/configurators/slash/base.ts +95 -0
  231. package/references/openspec/src/core/configurators/slash/claude.ts +42 -0
  232. package/references/openspec/src/core/configurators/slash/cline.ts +27 -0
  233. package/references/openspec/src/core/configurators/slash/codebuddy.ts +43 -0
  234. package/references/openspec/src/core/configurators/slash/codex.ts +126 -0
  235. package/references/openspec/src/core/configurators/slash/costrict.ts +36 -0
  236. package/references/openspec/src/core/configurators/slash/crush.ts +42 -0
  237. package/references/openspec/src/core/configurators/slash/cursor.ts +42 -0
  238. package/references/openspec/src/core/configurators/slash/factory.ts +41 -0
  239. package/references/openspec/src/core/configurators/slash/gemini.ts +27 -0
  240. package/references/openspec/src/core/configurators/slash/github-copilot.ts +39 -0
  241. package/references/openspec/src/core/configurators/slash/iflow.ts +42 -0
  242. package/references/openspec/src/core/configurators/slash/kilocode.ts +21 -0
  243. package/references/openspec/src/core/configurators/slash/opencode.ts +83 -0
  244. package/references/openspec/src/core/configurators/slash/qoder.ts +84 -0
  245. package/references/openspec/src/core/configurators/slash/qwen.ts +55 -0
  246. package/references/openspec/src/core/configurators/slash/registry.ts +81 -0
  247. package/references/openspec/src/core/configurators/slash/roocode.ts +27 -0
  248. package/references/openspec/src/core/configurators/slash/toml-base.ts +66 -0
  249. package/references/openspec/src/core/configurators/slash/windsurf.ts +27 -0
  250. package/references/openspec/src/core/converters/json-converter.ts +61 -0
  251. package/references/openspec/src/core/index.ts +2 -0
  252. package/references/openspec/src/core/init.ts +986 -0
  253. package/references/openspec/src/core/list.ts +104 -0
  254. package/references/openspec/src/core/parsers/change-parser.ts +234 -0
  255. package/references/openspec/src/core/parsers/markdown-parser.ts +237 -0
  256. package/references/openspec/src/core/parsers/requirement-blocks.ts +234 -0
  257. package/references/openspec/src/core/schemas/base.schema.ts +20 -0
  258. package/references/openspec/src/core/schemas/change.schema.ts +42 -0
  259. package/references/openspec/src/core/schemas/index.ts +20 -0
  260. package/references/openspec/src/core/schemas/spec.schema.ts +17 -0
  261. package/references/openspec/src/core/styles/palette.ts +8 -0
  262. package/references/openspec/src/core/templates/agents-root-stub.ts +16 -0
  263. package/references/openspec/src/core/templates/agents-template.ts +457 -0
  264. package/references/openspec/src/core/templates/claude-template.ts +1 -0
  265. package/references/openspec/src/core/templates/cline-template.ts +1 -0
  266. package/references/openspec/src/core/templates/costrict-template.ts +1 -0
  267. package/references/openspec/src/core/templates/index.ts +50 -0
  268. package/references/openspec/src/core/templates/project-template.ts +38 -0
  269. package/references/openspec/src/core/templates/slash-command-templates.ts +60 -0
  270. package/references/openspec/src/core/update.ts +129 -0
  271. package/references/openspec/src/core/validation/constants.ts +48 -0
  272. package/references/openspec/src/core/validation/types.ts +19 -0
  273. package/references/openspec/src/core/validation/validator.ts +448 -0
  274. package/references/openspec/src/core/view.ts +189 -0
  275. package/references/openspec/src/index.ts +2 -0
  276. package/references/openspec/src/utils/file-system.ts +187 -0
  277. package/references/openspec/src/utils/index.ts +2 -0
  278. package/references/openspec/src/utils/interactive.ts +7 -0
  279. package/references/openspec/src/utils/item-discovery.ts +45 -0
  280. package/references/openspec/src/utils/match.ts +26 -0
  281. package/references/openspec/src/utils/task-progress.ts +43 -0
  282. package/references/openspec/test/cli-e2e/basic.test.ts +156 -0
  283. package/references/openspec/test/commands/change.interactive-show.test.ts +45 -0
  284. package/references/openspec/test/commands/change.interactive-validate.test.ts +48 -0
  285. package/references/openspec/test/commands/show.test.ts +123 -0
  286. package/references/openspec/test/commands/spec.interactive-show.test.ts +44 -0
  287. package/references/openspec/test/commands/spec.interactive-validate.test.ts +44 -0
  288. package/references/openspec/test/commands/spec.test.ts +324 -0
  289. package/references/openspec/test/commands/validate.enriched-output.test.ts +49 -0
  290. package/references/openspec/test/commands/validate.test.ts +133 -0
  291. package/references/openspec/test/core/archive.test.ts +680 -0
  292. package/references/openspec/test/core/commands/change-command.list.test.ts +76 -0
  293. package/references/openspec/test/core/commands/change-command.show-validate.test.ts +111 -0
  294. package/references/openspec/test/core/converters/json-converter.test.ts +184 -0
  295. package/references/openspec/test/core/init.test.ts +1710 -0
  296. package/references/openspec/test/core/list.test.ts +165 -0
  297. package/references/openspec/test/core/parsers/change-parser.test.ts +52 -0
  298. package/references/openspec/test/core/parsers/markdown-parser.test.ts +291 -0
  299. package/references/openspec/test/core/update.test.ts +1642 -0
  300. package/references/openspec/test/core/validation.enriched-messages.test.ts +74 -0
  301. package/references/openspec/test/core/validation.test.ts +489 -0
  302. package/references/openspec/test/core/view.test.ts +79 -0
  303. package/references/openspec/test/fixtures/tmp-init/openspec/changes/c1/proposal.md +7 -0
  304. package/references/openspec/test/fixtures/tmp-init/openspec/changes/c1/specs/alpha/spec.md +8 -0
  305. package/references/openspec/test/fixtures/tmp-init/openspec/specs/alpha/spec.md +12 -0
  306. package/references/openspec/test/helpers/run-cli.ts +139 -0
  307. package/references/openspec/test/utils/file-system.test.ts +211 -0
  308. package/references/openspec/test/utils/marker-updates.test.ts +287 -0
  309. package/references/openspec/tsconfig.json +21 -0
  310. package/references/openspec/vitest.config.ts +25 -0
  311. package/references/openspec/vitest.setup.ts +6 -0
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ // Guard: Ensure the packed tarball's CLI `--version` matches package.json.
3
+ //
4
+ // Notes:
5
+ // - We intentionally use `npm pack` (not pnpm) because `npm pack --json` is
6
+ // consistently supported and returns the tarball metadata we need. The
7
+ // project uses pnpm for install/publish, but this guard only needs to pack
8
+ // locally and verify the installed CLI output.
9
+ // - `npm pack` triggers the package's `prepare` script (build), and
10
+ // `changeset publish` triggers `prepublishOnly` (also builds here). This
11
+ // means an explicit build is not strictly necessary for the guard.
12
+
13
+ import { execFileSync } from 'child_process';
14
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
15
+ import { tmpdir } from 'os';
16
+ import path from 'path';
17
+
18
+ function log(msg) {
19
+ if (process.env.CI) return; // keep CI logs quiet by default
20
+ console.log(msg);
21
+ }
22
+
23
+ function run(cmd, args, opts = {}) {
24
+ return execFileSync(cmd, args, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], ...opts });
25
+ }
26
+
27
+ function npmPack() {
28
+ try {
29
+ const jsonOut = run('npm', ['pack', '--json', '--silent']);
30
+ const arr = JSON.parse(jsonOut);
31
+ if (Array.isArray(arr) && arr.length > 0) {
32
+ const last = arr[arr.length - 1];
33
+ const file = (last && typeof last === 'object' && last.filename) || (typeof last === 'string' ? last : null);
34
+ if (file) return String(file).trim();
35
+ }
36
+ // Unexpected JSON shape or empty array; fallback to plain output
37
+ const out = run('npm', ['pack', '--silent']).trim();
38
+ const lines = out.split(/\r?\n/);
39
+ return lines[lines.length - 1].trim();
40
+ } catch (e) {
41
+ // Fallback for environments not supporting --json
42
+ const out = run('npm', ['pack', '--silent']).trim();
43
+ const lines = out.split(/\r?\n/);
44
+ return lines[lines.length - 1].trim();
45
+ }
46
+ }
47
+
48
+ function main() {
49
+ const pkg = JSON.parse(readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'));
50
+ const expected = pkg.version;
51
+
52
+ let work;
53
+ let tgzPath;
54
+
55
+ try {
56
+ log(`Packing @fission-ai/openspec@${expected}...`);
57
+ const filename = npmPack();
58
+ tgzPath = path.resolve(filename);
59
+ log(`Created: ${tgzPath}`);
60
+
61
+ work = mkdtempSync(path.join(tmpdir(), 'openspec-pack-check-'));
62
+ log(`Temp dir: ${work}`);
63
+
64
+ // Make a tiny project
65
+ writeFileSync(
66
+ path.join(work, 'package.json'),
67
+ JSON.stringify({ name: 'pack-check', private: true }, null, 2)
68
+ );
69
+
70
+ // Try to avoid noisy output and speed up
71
+ const env = {
72
+ ...process.env,
73
+ npm_config_loglevel: 'silent',
74
+ npm_config_audit: 'false',
75
+ npm_config_fund: 'false',
76
+ npm_config_progress: 'false',
77
+ };
78
+
79
+ // Install the tarball
80
+ run('npm', ['install', tgzPath, '--silent', '--no-audit', '--no-fund'], { cwd: work, env });
81
+
82
+ // Run the installed CLI via Node to avoid bin resolution/platform issues
83
+ const binRel = path.join('node_modules', '@fission-ai', 'openspec', 'bin', 'openspec.js');
84
+ const actual = run(process.execPath, [binRel, '--version'], { cwd: work }).trim();
85
+
86
+ if (actual !== expected) {
87
+ throw new Error(
88
+ `Packed CLI version mismatch: expected ${expected}, got ${actual}. ` +
89
+ 'Ensure the dist is built and the CLI reads version from package.json.'
90
+ );
91
+ }
92
+
93
+ log('Version check passed.');
94
+ } finally {
95
+ // Always attempt cleanup
96
+ if (work) {
97
+ try { rmSync(work, { recursive: true, force: true }); } catch {}
98
+ }
99
+ if (tgzPath) {
100
+ try { rmSync(tgzPath, { force: true }); } catch {}
101
+ }
102
+ }
103
+ }
104
+
105
+ try {
106
+ main();
107
+ console.log('✅ pack-version-check: OK');
108
+ } catch (err) {
109
+ console.error(`❌ pack-version-check: ${err.message}`);
110
+ process.exit(1);
111
+ }
@@ -0,0 +1,253 @@
1
+ import { Command } from 'commander';
2
+ import { createRequire } from 'module';
3
+ import ora from 'ora';
4
+ import path from 'path';
5
+ import { promises as fs } from 'fs';
6
+ import { InitCommand } from '../core/init.js';
7
+ import { AI_TOOLS } from '../core/config.js';
8
+ import { UpdateCommand } from '../core/update.js';
9
+ import { ListCommand } from '../core/list.js';
10
+ import { ArchiveCommand } from '../core/archive.js';
11
+ import { ViewCommand } from '../core/view.js';
12
+ import { registerSpecCommand } from '../commands/spec.js';
13
+ import { ChangeCommand } from '../commands/change.js';
14
+ import { ValidateCommand } from '../commands/validate.js';
15
+ import { ShowCommand } from '../commands/show.js';
16
+
17
+ const program = new Command();
18
+ const require = createRequire(import.meta.url);
19
+ const { version } = require('../../package.json');
20
+
21
+ program
22
+ .name('openspec')
23
+ .description('AI-native system for spec-driven development')
24
+ .version(version);
25
+
26
+ // Global options
27
+ program.option('--no-color', 'Disable color output');
28
+
29
+ // Apply global flags before any command runs
30
+ program.hook('preAction', (thisCommand) => {
31
+ const opts = thisCommand.opts();
32
+ if (opts.noColor) {
33
+ process.env.NO_COLOR = '1';
34
+ }
35
+ });
36
+
37
+ const availableToolIds = AI_TOOLS.filter((tool) => tool.available).map((tool) => tool.value);
38
+ const toolsOptionDescription = `Configure AI tools non-interactively. Use "all", "none", or a comma-separated list of: ${availableToolIds.join(', ')}`;
39
+
40
+ program
41
+ .command('init [path]')
42
+ .description('Initialize OpenSpec in your project')
43
+ .option('--tools <tools>', toolsOptionDescription)
44
+ .action(async (targetPath = '.', options?: { tools?: string }) => {
45
+ try {
46
+ // Validate that the path is a valid directory
47
+ const resolvedPath = path.resolve(targetPath);
48
+
49
+ try {
50
+ const stats = await fs.stat(resolvedPath);
51
+ if (!stats.isDirectory()) {
52
+ throw new Error(`Path "${targetPath}" is not a directory`);
53
+ }
54
+ } catch (error: any) {
55
+ if (error.code === 'ENOENT') {
56
+ // Directory doesn't exist, but we can create it
57
+ console.log(`Directory "${targetPath}" doesn't exist, it will be created.`);
58
+ } else if (error.message && error.message.includes('not a directory')) {
59
+ throw error;
60
+ } else {
61
+ throw new Error(`Cannot access path "${targetPath}": ${error.message}`);
62
+ }
63
+ }
64
+
65
+ const initCommand = new InitCommand({
66
+ tools: options?.tools,
67
+ });
68
+ await initCommand.execute(targetPath);
69
+ } catch (error) {
70
+ console.log(); // Empty line for spacing
71
+ ora().fail(`Error: ${(error as Error).message}`);
72
+ process.exit(1);
73
+ }
74
+ });
75
+
76
+ program
77
+ .command('update [path]')
78
+ .description('Update OpenSpec instruction files')
79
+ .action(async (targetPath = '.') => {
80
+ try {
81
+ const resolvedPath = path.resolve(targetPath);
82
+ const updateCommand = new UpdateCommand();
83
+ await updateCommand.execute(resolvedPath);
84
+ } catch (error) {
85
+ console.log(); // Empty line for spacing
86
+ ora().fail(`Error: ${(error as Error).message}`);
87
+ process.exit(1);
88
+ }
89
+ });
90
+
91
+ program
92
+ .command('list')
93
+ .description('List items (changes by default). Use --specs to list specs.')
94
+ .option('--specs', 'List specs instead of changes')
95
+ .option('--changes', 'List changes explicitly (default)')
96
+ .action(async (options?: { specs?: boolean; changes?: boolean }) => {
97
+ try {
98
+ const listCommand = new ListCommand();
99
+ const mode: 'changes' | 'specs' = options?.specs ? 'specs' : 'changes';
100
+ await listCommand.execute('.', mode);
101
+ } catch (error) {
102
+ console.log(); // Empty line for spacing
103
+ ora().fail(`Error: ${(error as Error).message}`);
104
+ process.exit(1);
105
+ }
106
+ });
107
+
108
+ program
109
+ .command('view')
110
+ .description('Display an interactive dashboard of specs and changes')
111
+ .action(async () => {
112
+ try {
113
+ const viewCommand = new ViewCommand();
114
+ await viewCommand.execute('.');
115
+ } catch (error) {
116
+ console.log(); // Empty line for spacing
117
+ ora().fail(`Error: ${(error as Error).message}`);
118
+ process.exit(1);
119
+ }
120
+ });
121
+
122
+ // Change command with subcommands
123
+ const changeCmd = program
124
+ .command('change')
125
+ .description('Manage OpenSpec change proposals');
126
+
127
+ // Deprecation notice for noun-based commands
128
+ changeCmd.hook('preAction', () => {
129
+ console.error('Warning: The "openspec change ..." commands are deprecated. Prefer verb-first commands (e.g., "openspec list", "openspec validate --changes").');
130
+ });
131
+
132
+ changeCmd
133
+ .command('show [change-name]')
134
+ .description('Show a change proposal in JSON or markdown format')
135
+ .option('--json', 'Output as JSON')
136
+ .option('--deltas-only', 'Show only deltas (JSON only)')
137
+ .option('--requirements-only', 'Alias for --deltas-only (deprecated)')
138
+ .option('--no-interactive', 'Disable interactive prompts')
139
+ .action(async (changeName?: string, options?: { json?: boolean; requirementsOnly?: boolean; deltasOnly?: boolean; noInteractive?: boolean }) => {
140
+ try {
141
+ const changeCommand = new ChangeCommand();
142
+ await changeCommand.show(changeName, options);
143
+ } catch (error) {
144
+ console.error(`Error: ${(error as Error).message}`);
145
+ process.exitCode = 1;
146
+ }
147
+ });
148
+
149
+ changeCmd
150
+ .command('list')
151
+ .description('List all active changes (DEPRECATED: use "openspec list" instead)')
152
+ .option('--json', 'Output as JSON')
153
+ .option('--long', 'Show id and title with counts')
154
+ .action(async (options?: { json?: boolean; long?: boolean }) => {
155
+ try {
156
+ console.error('Warning: "openspec change list" is deprecated. Use "openspec list".');
157
+ const changeCommand = new ChangeCommand();
158
+ await changeCommand.list(options);
159
+ } catch (error) {
160
+ console.error(`Error: ${(error as Error).message}`);
161
+ process.exitCode = 1;
162
+ }
163
+ });
164
+
165
+ changeCmd
166
+ .command('validate [change-name]')
167
+ .description('Validate a change proposal')
168
+ .option('--strict', 'Enable strict validation mode')
169
+ .option('--json', 'Output validation report as JSON')
170
+ .option('--no-interactive', 'Disable interactive prompts')
171
+ .action(async (changeName?: string, options?: { strict?: boolean; json?: boolean; noInteractive?: boolean }) => {
172
+ try {
173
+ const changeCommand = new ChangeCommand();
174
+ await changeCommand.validate(changeName, options);
175
+ if (typeof process.exitCode === 'number' && process.exitCode !== 0) {
176
+ process.exit(process.exitCode);
177
+ }
178
+ } catch (error) {
179
+ console.error(`Error: ${(error as Error).message}`);
180
+ process.exitCode = 1;
181
+ }
182
+ });
183
+
184
+ program
185
+ .command('archive [change-name]')
186
+ .description('Archive a completed change and update main specs')
187
+ .option('-y, --yes', 'Skip confirmation prompts')
188
+ .option('--skip-specs', 'Skip spec update operations (useful for infrastructure, tooling, or doc-only changes)')
189
+ .option('--no-validate', 'Skip validation (not recommended, requires confirmation)')
190
+ .action(async (changeName?: string, options?: { yes?: boolean; skipSpecs?: boolean; noValidate?: boolean; validate?: boolean }) => {
191
+ try {
192
+ const archiveCommand = new ArchiveCommand();
193
+ await archiveCommand.execute(changeName, options);
194
+ } catch (error) {
195
+ console.log(); // Empty line for spacing
196
+ ora().fail(`Error: ${(error as Error).message}`);
197
+ process.exit(1);
198
+ }
199
+ });
200
+
201
+ registerSpecCommand(program);
202
+
203
+ // Top-level validate command
204
+ program
205
+ .command('validate [item-name]')
206
+ .description('Validate changes and specs')
207
+ .option('--all', 'Validate all changes and specs')
208
+ .option('--changes', 'Validate all changes')
209
+ .option('--specs', 'Validate all specs')
210
+ .option('--type <type>', 'Specify item type when ambiguous: change|spec')
211
+ .option('--strict', 'Enable strict validation mode')
212
+ .option('--json', 'Output validation results as JSON')
213
+ .option('--concurrency <n>', 'Max concurrent validations (defaults to env OPENSPEC_CONCURRENCY or 6)')
214
+ .option('--no-interactive', 'Disable interactive prompts')
215
+ .action(async (itemName?: string, options?: { all?: boolean; changes?: boolean; specs?: boolean; type?: string; strict?: boolean; json?: boolean; noInteractive?: boolean; concurrency?: string }) => {
216
+ try {
217
+ const validateCommand = new ValidateCommand();
218
+ await validateCommand.execute(itemName, options);
219
+ } catch (error) {
220
+ console.log();
221
+ ora().fail(`Error: ${(error as Error).message}`);
222
+ process.exit(1);
223
+ }
224
+ });
225
+
226
+ // Top-level show command
227
+ program
228
+ .command('show [item-name]')
229
+ .description('Show a change or spec')
230
+ .option('--json', 'Output as JSON')
231
+ .option('--type <type>', 'Specify item type when ambiguous: change|spec')
232
+ .option('--no-interactive', 'Disable interactive prompts')
233
+ // change-only flags
234
+ .option('--deltas-only', 'Show only deltas (JSON only, change)')
235
+ .option('--requirements-only', 'Alias for --deltas-only (deprecated, change)')
236
+ // spec-only flags
237
+ .option('--requirements', 'JSON only: Show only requirements (exclude scenarios)')
238
+ .option('--no-scenarios', 'JSON only: Exclude scenario content')
239
+ .option('-r, --requirement <id>', 'JSON only: Show specific requirement by ID (1-based)')
240
+ // allow unknown options to pass-through to underlying command implementation
241
+ .allowUnknownOption(true)
242
+ .action(async (itemName?: string, options?: { json?: boolean; type?: string; noInteractive?: boolean; [k: string]: any }) => {
243
+ try {
244
+ const showCommand = new ShowCommand();
245
+ await showCommand.execute(itemName, options ?? {});
246
+ } catch (error) {
247
+ console.log();
248
+ ora().fail(`Error: ${(error as Error).message}`);
249
+ process.exit(1);
250
+ }
251
+ });
252
+
253
+ program.parse();
@@ -0,0 +1,291 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { select } from '@inquirer/prompts';
4
+ import { JsonConverter } from '../core/converters/json-converter.js';
5
+ import { Validator } from '../core/validation/validator.js';
6
+ import { ChangeParser } from '../core/parsers/change-parser.js';
7
+ import { Change } from '../core/schemas/index.js';
8
+ import { isInteractive } from '../utils/interactive.js';
9
+ import { getActiveChangeIds } from '../utils/item-discovery.js';
10
+
11
+ // Constants for better maintainability
12
+ const ARCHIVE_DIR = 'archive';
13
+ const TASK_PATTERN = /^[-*]\s+\[[\sx]\]/i;
14
+ const COMPLETED_TASK_PATTERN = /^[-*]\s+\[x\]/i;
15
+
16
+ export class ChangeCommand {
17
+ private converter: JsonConverter;
18
+
19
+ constructor() {
20
+ this.converter = new JsonConverter();
21
+ }
22
+
23
+ /**
24
+ * Show a change proposal.
25
+ * - Text mode: raw markdown passthrough (no filters)
26
+ * - JSON mode: minimal object with deltas; --deltas-only returns same object with filtered deltas
27
+ * Note: --requirements-only is deprecated alias for --deltas-only
28
+ */
29
+ async show(changeName?: string, options?: { json?: boolean; requirementsOnly?: boolean; deltasOnly?: boolean; noInteractive?: boolean }): Promise<void> {
30
+ const changesPath = path.join(process.cwd(), 'openspec', 'changes');
31
+
32
+ if (!changeName) {
33
+ const canPrompt = isInteractive(options?.noInteractive);
34
+ const changes = await this.getActiveChanges(changesPath);
35
+ if (canPrompt && changes.length > 0) {
36
+ const selected = await select({
37
+ message: 'Select a change to show',
38
+ choices: changes.map(id => ({ name: id, value: id })),
39
+ });
40
+ changeName = selected;
41
+ } else {
42
+ if (changes.length === 0) {
43
+ console.error('No change specified. No active changes found.');
44
+ } else {
45
+ console.error(`No change specified. Available IDs: ${changes.join(', ')}`);
46
+ }
47
+ console.error('Hint: use "openspec change list" to view available changes.');
48
+ process.exitCode = 1;
49
+ return;
50
+ }
51
+ }
52
+
53
+ const proposalPath = path.join(changesPath, changeName, 'proposal.md');
54
+
55
+ try {
56
+ await fs.access(proposalPath);
57
+ } catch {
58
+ throw new Error(`Change "${changeName}" not found at ${proposalPath}`);
59
+ }
60
+
61
+ if (options?.json) {
62
+ const jsonOutput = await this.converter.convertChangeToJson(proposalPath);
63
+
64
+ if (options.requirementsOnly) {
65
+ console.error('Flag --requirements-only is deprecated; use --deltas-only instead.');
66
+ }
67
+
68
+ const parsed: Change = JSON.parse(jsonOutput);
69
+ const contentForTitle = await fs.readFile(proposalPath, 'utf-8');
70
+ const title = this.extractTitle(contentForTitle, changeName);
71
+ const id = parsed.name;
72
+ const deltas = parsed.deltas || [];
73
+
74
+ if (options.requirementsOnly || options.deltasOnly) {
75
+ const output = { id, title, deltaCount: deltas.length, deltas };
76
+ console.log(JSON.stringify(output, null, 2));
77
+ } else {
78
+ const output = {
79
+ id,
80
+ title,
81
+ deltaCount: deltas.length,
82
+ deltas,
83
+ };
84
+ console.log(JSON.stringify(output, null, 2));
85
+ }
86
+ } else {
87
+ const content = await fs.readFile(proposalPath, 'utf-8');
88
+ console.log(content);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * List active changes.
94
+ * - Text default: IDs only; --long prints minimal details (title, counts)
95
+ * - JSON: array of { id, title, deltaCount, taskStatus }, sorted by id
96
+ */
97
+ async list(options?: { json?: boolean; long?: boolean }): Promise<void> {
98
+ const changesPath = path.join(process.cwd(), 'openspec', 'changes');
99
+
100
+ const changes = await this.getActiveChanges(changesPath);
101
+
102
+ if (options?.json) {
103
+ const changeDetails = await Promise.all(
104
+ changes.map(async (changeName) => {
105
+ const proposalPath = path.join(changesPath, changeName, 'proposal.md');
106
+ const tasksPath = path.join(changesPath, changeName, 'tasks.md');
107
+
108
+ try {
109
+ const content = await fs.readFile(proposalPath, 'utf-8');
110
+ const changeDir = path.join(changesPath, changeName);
111
+ const parser = new ChangeParser(content, changeDir);
112
+ const change = await parser.parseChangeWithDeltas(changeName);
113
+
114
+ let taskStatus = { total: 0, completed: 0 };
115
+ try {
116
+ const tasksContent = await fs.readFile(tasksPath, 'utf-8');
117
+ taskStatus = this.countTasks(tasksContent);
118
+ } catch (error) {
119
+ // Tasks file may not exist, which is okay
120
+ if (process.env.DEBUG) {
121
+ console.error(`Failed to read tasks file at ${tasksPath}:`, error);
122
+ }
123
+ }
124
+
125
+ return {
126
+ id: changeName,
127
+ title: this.extractTitle(content, changeName),
128
+ deltaCount: change.deltas.length,
129
+ taskStatus,
130
+ };
131
+ } catch (error) {
132
+ return {
133
+ id: changeName,
134
+ title: 'Unknown',
135
+ deltaCount: 0,
136
+ taskStatus: { total: 0, completed: 0 },
137
+ };
138
+ }
139
+ })
140
+ );
141
+
142
+ const sorted = changeDetails.sort((a, b) => a.id.localeCompare(b.id));
143
+ console.log(JSON.stringify(sorted, null, 2));
144
+ } else {
145
+ if (changes.length === 0) {
146
+ console.log('No items found');
147
+ return;
148
+ }
149
+ const sorted = [...changes].sort();
150
+ if (!options?.long) {
151
+ // IDs only
152
+ sorted.forEach(id => console.log(id));
153
+ return;
154
+ }
155
+
156
+ // Long format: id: title and minimal counts
157
+ for (const changeName of sorted) {
158
+ const proposalPath = path.join(changesPath, changeName, 'proposal.md');
159
+ const tasksPath = path.join(changesPath, changeName, 'tasks.md');
160
+ try {
161
+ const content = await fs.readFile(proposalPath, 'utf-8');
162
+ const title = this.extractTitle(content, changeName);
163
+ let taskStatusText = '';
164
+ try {
165
+ const tasksContent = await fs.readFile(tasksPath, 'utf-8');
166
+ const { total, completed } = this.countTasks(tasksContent);
167
+ taskStatusText = ` [tasks ${completed}/${total}]`;
168
+ } catch (error) {
169
+ if (process.env.DEBUG) {
170
+ console.error(`Failed to read tasks file at ${tasksPath}:`, error);
171
+ }
172
+ }
173
+ const changeDir = path.join(changesPath, changeName);
174
+ const parser = new ChangeParser(await fs.readFile(proposalPath, 'utf-8'), changeDir);
175
+ const change = await parser.parseChangeWithDeltas(changeName);
176
+ const deltaCountText = ` [deltas ${change.deltas.length}]`;
177
+ console.log(`${changeName}: ${title}${deltaCountText}${taskStatusText}`);
178
+ } catch {
179
+ console.log(`${changeName}: (unable to read)`);
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ async validate(changeName?: string, options?: { strict?: boolean; json?: boolean; noInteractive?: boolean }): Promise<void> {
186
+ const changesPath = path.join(process.cwd(), 'openspec', 'changes');
187
+
188
+ if (!changeName) {
189
+ const canPrompt = isInteractive(options?.noInteractive);
190
+ const changes = await getActiveChangeIds();
191
+ if (canPrompt && changes.length > 0) {
192
+ const selected = await select({
193
+ message: 'Select a change to validate',
194
+ choices: changes.map(id => ({ name: id, value: id })),
195
+ });
196
+ changeName = selected;
197
+ } else {
198
+ if (changes.length === 0) {
199
+ console.error('No change specified. No active changes found.');
200
+ } else {
201
+ console.error(`No change specified. Available IDs: ${changes.join(', ')}`);
202
+ }
203
+ console.error('Hint: use "openspec change list" to view available changes.');
204
+ process.exitCode = 1;
205
+ return;
206
+ }
207
+ }
208
+
209
+ const changeDir = path.join(changesPath, changeName);
210
+
211
+ try {
212
+ await fs.access(changeDir);
213
+ } catch {
214
+ throw new Error(`Change "${changeName}" not found at ${changeDir}`);
215
+ }
216
+
217
+ const validator = new Validator(options?.strict || false);
218
+ const report = await validator.validateChangeDeltaSpecs(changeDir);
219
+
220
+ if (options?.json) {
221
+ console.log(JSON.stringify(report, null, 2));
222
+ } else {
223
+ if (report.valid) {
224
+ console.log(`Change "${changeName}" is valid`);
225
+ } else {
226
+ console.error(`Change "${changeName}" has issues`);
227
+ report.issues.forEach(issue => {
228
+ const label = issue.level === 'ERROR' ? 'ERROR' : 'WARNING';
229
+ const prefix = issue.level === 'ERROR' ? '✗' : '⚠';
230
+ console.error(`${prefix} [${label}] ${issue.path}: ${issue.message}`);
231
+ });
232
+ // Next steps footer to guide fixing issues
233
+ this.printNextSteps();
234
+ if (!options?.json) {
235
+ process.exitCode = 1;
236
+ }
237
+ }
238
+ }
239
+ }
240
+
241
+ private async getActiveChanges(changesPath: string): Promise<string[]> {
242
+ try {
243
+ const entries = await fs.readdir(changesPath, { withFileTypes: true });
244
+ const result: string[] = [];
245
+ for (const entry of entries) {
246
+ if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === ARCHIVE_DIR) continue;
247
+ const proposalPath = path.join(changesPath, entry.name, 'proposal.md');
248
+ try {
249
+ await fs.access(proposalPath);
250
+ result.push(entry.name);
251
+ } catch {
252
+ // skip directories without proposal.md
253
+ }
254
+ }
255
+ return result.sort();
256
+ } catch {
257
+ return [];
258
+ }
259
+ }
260
+
261
+ private extractTitle(content: string, changeName: string): string {
262
+ const match = content.match(/^#\s+(?:Change:\s+)?(.+)$/im);
263
+ return match ? match[1].trim() : changeName;
264
+ }
265
+
266
+ private countTasks(content: string): { total: number; completed: number } {
267
+ const lines = content.split('\n');
268
+ let total = 0;
269
+ let completed = 0;
270
+
271
+ for (const line of lines) {
272
+ if (line.match(TASK_PATTERN)) {
273
+ total++;
274
+ if (line.match(COMPLETED_TASK_PATTERN)) {
275
+ completed++;
276
+ }
277
+ }
278
+ }
279
+
280
+ return { total, completed };
281
+ }
282
+
283
+ private printNextSteps(): void {
284
+ const bullets: string[] = [];
285
+ bullets.push('- Ensure change has deltas in specs/: use headers ## ADDED/MODIFIED/REMOVED/RENAMED Requirements');
286
+ bullets.push('- Each requirement MUST include at least one #### Scenario: block');
287
+ bullets.push('- Debug parsed deltas: openspec change show <id> --json --deltas-only');
288
+ console.error('Next steps:');
289
+ bullets.forEach(b => console.error(` ${b}`));
290
+ }
291
+ }