@superkou/openspec 1.4.1

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 (373) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +213 -0
  3. package/bin/openspec.js +5 -0
  4. package/dist/cli/index.d.ts +5 -0
  5. package/dist/cli/index.js +544 -0
  6. package/dist/commands/change.d.ts +35 -0
  7. package/dist/commands/change.js +277 -0
  8. package/dist/commands/completion.d.ts +72 -0
  9. package/dist/commands/completion.js +264 -0
  10. package/dist/commands/config.d.ts +36 -0
  11. package/dist/commands/config.js +611 -0
  12. package/dist/commands/context-store.d.ts +3 -0
  13. package/dist/commands/context-store.js +475 -0
  14. package/dist/commands/feedback.d.ts +9 -0
  15. package/dist/commands/feedback.js +183 -0
  16. package/dist/commands/initiative.d.ts +13 -0
  17. package/dist/commands/initiative.js +318 -0
  18. package/dist/commands/schema.d.ts +6 -0
  19. package/dist/commands/schema.js +869 -0
  20. package/dist/commands/show.d.ts +14 -0
  21. package/dist/commands/show.js +132 -0
  22. package/dist/commands/spec.d.ts +15 -0
  23. package/dist/commands/spec.js +225 -0
  24. package/dist/commands/validate.d.ts +24 -0
  25. package/dist/commands/validate.js +294 -0
  26. package/dist/commands/workflow/index.d.ts +19 -0
  27. package/dist/commands/workflow/index.js +13 -0
  28. package/dist/commands/workflow/initiative-link.d.ts +24 -0
  29. package/dist/commands/workflow/initiative-link.js +47 -0
  30. package/dist/commands/workflow/instructions.d.ts +29 -0
  31. package/dist/commands/workflow/instructions.js +344 -0
  32. package/dist/commands/workflow/new-change.d.ts +17 -0
  33. package/dist/commands/workflow/new-change.js +141 -0
  34. package/dist/commands/workflow/schemas.d.ts +10 -0
  35. package/dist/commands/workflow/schemas.js +34 -0
  36. package/dist/commands/workflow/set-change.d.ts +13 -0
  37. package/dist/commands/workflow/set-change.js +87 -0
  38. package/dist/commands/workflow/shared.d.ts +59 -0
  39. package/dist/commands/workflow/shared.js +116 -0
  40. package/dist/commands/workflow/status.d.ts +14 -0
  41. package/dist/commands/workflow/status.js +90 -0
  42. package/dist/commands/workflow/templates.d.ts +16 -0
  43. package/dist/commands/workflow/templates.js +69 -0
  44. package/dist/commands/workspace/context-status.d.ts +4 -0
  45. package/dist/commands/workspace/context-status.js +59 -0
  46. package/dist/commands/workspace/open-target-selection.d.ts +13 -0
  47. package/dist/commands/workspace/open-target-selection.js +146 -0
  48. package/dist/commands/workspace/open-view.d.ts +62 -0
  49. package/dist/commands/workspace/open-view.js +249 -0
  50. package/dist/commands/workspace/open.d.ts +37 -0
  51. package/dist/commands/workspace/open.js +110 -0
  52. package/dist/commands/workspace/opener-selection.d.ts +11 -0
  53. package/dist/commands/workspace/opener-selection.js +98 -0
  54. package/dist/commands/workspace/operations.d.ts +29 -0
  55. package/dist/commands/workspace/operations.js +543 -0
  56. package/dist/commands/workspace/prompt-theme.d.ts +29 -0
  57. package/dist/commands/workspace/prompt-theme.js +24 -0
  58. package/dist/commands/workspace/registration.d.ts +13 -0
  59. package/dist/commands/workspace/registration.js +84 -0
  60. package/dist/commands/workspace/selection.d.ts +8 -0
  61. package/dist/commands/workspace/selection.js +104 -0
  62. package/dist/commands/workspace/setup-prompts.d.ts +13 -0
  63. package/dist/commands/workspace/setup-prompts.js +121 -0
  64. package/dist/commands/workspace/types.d.ts +103 -0
  65. package/dist/commands/workspace/types.js +36 -0
  66. package/dist/commands/workspace.d.ts +5 -0
  67. package/dist/commands/workspace.js +577 -0
  68. package/dist/core/archive.d.ts +11 -0
  69. package/dist/core/archive.js +318 -0
  70. package/dist/core/artifact-graph/graph.d.ts +56 -0
  71. package/dist/core/artifact-graph/graph.js +141 -0
  72. package/dist/core/artifact-graph/index.d.ts +9 -0
  73. package/dist/core/artifact-graph/index.js +14 -0
  74. package/dist/core/artifact-graph/instruction-loader.d.ts +183 -0
  75. package/dist/core/artifact-graph/instruction-loader.js +256 -0
  76. package/dist/core/artifact-graph/outputs.d.ts +14 -0
  77. package/dist/core/artifact-graph/outputs.js +39 -0
  78. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  79. package/dist/core/artifact-graph/resolver.js +257 -0
  80. package/dist/core/artifact-graph/schema.d.ts +13 -0
  81. package/dist/core/artifact-graph/schema.js +108 -0
  82. package/dist/core/artifact-graph/state.d.ts +12 -0
  83. package/dist/core/artifact-graph/state.js +31 -0
  84. package/dist/core/artifact-graph/types.d.ts +40 -0
  85. package/dist/core/artifact-graph/types.js +29 -0
  86. package/dist/core/available-tools.d.ts +17 -0
  87. package/dist/core/available-tools.js +43 -0
  88. package/dist/core/change-metadata/index.d.ts +2 -0
  89. package/dist/core/change-metadata/index.js +2 -0
  90. package/dist/core/change-metadata/schema.d.ts +18 -0
  91. package/dist/core/change-metadata/schema.js +28 -0
  92. package/dist/core/change-status-policy.d.ts +50 -0
  93. package/dist/core/change-status-policy.js +70 -0
  94. package/dist/core/collections/index.d.ts +3 -0
  95. package/dist/core/collections/index.js +3 -0
  96. package/dist/core/collections/initiatives/collection.d.ts +4 -0
  97. package/dist/core/collections/initiatives/collection.js +17 -0
  98. package/dist/core/collections/initiatives/index.d.ts +6 -0
  99. package/dist/core/collections/initiatives/index.js +6 -0
  100. package/dist/core/collections/initiatives/operations.d.ts +49 -0
  101. package/dist/core/collections/initiatives/operations.js +175 -0
  102. package/dist/core/collections/initiatives/resolution.d.ts +87 -0
  103. package/dist/core/collections/initiatives/resolution.js +374 -0
  104. package/dist/core/collections/initiatives/schema.d.ts +41 -0
  105. package/dist/core/collections/initiatives/schema.js +134 -0
  106. package/dist/core/collections/initiatives/templates.d.ts +12 -0
  107. package/dist/core/collections/initiatives/templates.js +90 -0
  108. package/dist/core/collections/runtime.d.ts +46 -0
  109. package/dist/core/collections/runtime.js +194 -0
  110. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  111. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  112. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  113. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  114. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  115. package/dist/core/command-generation/adapters/auggie.js +27 -0
  116. package/dist/core/command-generation/adapters/bob.d.ts +14 -0
  117. package/dist/core/command-generation/adapters/bob.js +45 -0
  118. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  119. package/dist/core/command-generation/adapters/claude.js +50 -0
  120. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  121. package/dist/core/command-generation/adapters/cline.js +27 -0
  122. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  123. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  124. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  125. package/dist/core/command-generation/adapters/codex.js +39 -0
  126. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  127. package/dist/core/command-generation/adapters/continue.js +28 -0
  128. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  129. package/dist/core/command-generation/adapters/costrict.js +27 -0
  130. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  131. package/dist/core/command-generation/adapters/crush.js +30 -0
  132. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  133. package/dist/core/command-generation/adapters/cursor.js +44 -0
  134. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  135. package/dist/core/command-generation/adapters/factory.js +27 -0
  136. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  137. package/dist/core/command-generation/adapters/gemini.js +26 -0
  138. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  139. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  140. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  141. package/dist/core/command-generation/adapters/iflow.js +29 -0
  142. package/dist/core/command-generation/adapters/index.d.ts +32 -0
  143. package/dist/core/command-generation/adapters/index.js +32 -0
  144. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  145. package/dist/core/command-generation/adapters/junie.js +26 -0
  146. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  147. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  148. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  149. package/dist/core/command-generation/adapters/kiro.js +26 -0
  150. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  151. package/dist/core/command-generation/adapters/lingma.js +30 -0
  152. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  153. package/dist/core/command-generation/adapters/opencode.js +29 -0
  154. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  155. package/dist/core/command-generation/adapters/pi.js +55 -0
  156. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  157. package/dist/core/command-generation/adapters/qoder.js +30 -0
  158. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  159. package/dist/core/command-generation/adapters/qwen.js +26 -0
  160. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  161. package/dist/core/command-generation/adapters/roocode.js +27 -0
  162. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  163. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  164. package/dist/core/command-generation/generator.d.ts +21 -0
  165. package/dist/core/command-generation/generator.js +27 -0
  166. package/dist/core/command-generation/index.d.ts +22 -0
  167. package/dist/core/command-generation/index.js +24 -0
  168. package/dist/core/command-generation/registry.d.ts +36 -0
  169. package/dist/core/command-generation/registry.js +98 -0
  170. package/dist/core/command-generation/types.d.ts +56 -0
  171. package/dist/core/command-generation/types.js +8 -0
  172. package/dist/core/completions/command-registry.d.ts +3 -0
  173. package/dist/core/completions/command-registry.js +961 -0
  174. package/dist/core/completions/completion-provider.d.ts +71 -0
  175. package/dist/core/completions/completion-provider.js +129 -0
  176. package/dist/core/completions/factory.d.ts +64 -0
  177. package/dist/core/completions/factory.js +75 -0
  178. package/dist/core/completions/generators/bash-generator.d.ts +35 -0
  179. package/dist/core/completions/generators/bash-generator.js +230 -0
  180. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  181. package/dist/core/completions/generators/fish-generator.js +160 -0
  182. package/dist/core/completions/generators/powershell-generator.d.ts +36 -0
  183. package/dist/core/completions/generators/powershell-generator.js +266 -0
  184. package/dist/core/completions/generators/zsh-generator.d.ts +47 -0
  185. package/dist/core/completions/generators/zsh-generator.js +274 -0
  186. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  187. package/dist/core/completions/installers/bash-installer.js +318 -0
  188. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  189. package/dist/core/completions/installers/fish-installer.js +143 -0
  190. package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
  191. package/dist/core/completions/installers/powershell-installer.js +387 -0
  192. package/dist/core/completions/installers/zsh-installer.d.ts +117 -0
  193. package/dist/core/completions/installers/zsh-installer.js +421 -0
  194. package/dist/core/completions/shared-flags.d.ts +12 -0
  195. package/dist/core/completions/shared-flags.js +28 -0
  196. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  197. package/dist/core/completions/templates/bash-templates.js +30 -0
  198. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  199. package/dist/core/completions/templates/fish-templates.js +45 -0
  200. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  201. package/dist/core/completions/templates/powershell-templates.js +34 -0
  202. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  203. package/dist/core/completions/templates/zsh-templates.js +45 -0
  204. package/dist/core/completions/types.d.ts +101 -0
  205. package/dist/core/completions/types.js +2 -0
  206. package/dist/core/config-prompts.d.ts +9 -0
  207. package/dist/core/config-prompts.js +34 -0
  208. package/dist/core/config-schema.d.ts +86 -0
  209. package/dist/core/config-schema.js +213 -0
  210. package/dist/core/config.d.ts +18 -0
  211. package/dist/core/config.js +39 -0
  212. package/dist/core/context-store/binding.d.ts +53 -0
  213. package/dist/core/context-store/binding.js +197 -0
  214. package/dist/core/context-store/errors.d.ts +20 -0
  215. package/dist/core/context-store/errors.js +22 -0
  216. package/dist/core/context-store/foundation.d.ts +55 -0
  217. package/dist/core/context-store/foundation.js +321 -0
  218. package/dist/core/context-store/index.d.ts +6 -0
  219. package/dist/core/context-store/index.js +6 -0
  220. package/dist/core/context-store/operations.d.ts +85 -0
  221. package/dist/core/context-store/operations.js +528 -0
  222. package/dist/core/context-store/registry.d.ts +45 -0
  223. package/dist/core/context-store/registry.js +229 -0
  224. package/dist/core/converters/json-converter.d.ts +6 -0
  225. package/dist/core/converters/json-converter.js +51 -0
  226. package/dist/core/global-config.d.ts +49 -0
  227. package/dist/core/global-config.js +124 -0
  228. package/dist/core/index.d.ts +6 -0
  229. package/dist/core/index.js +7 -0
  230. package/dist/core/init.d.ts +37 -0
  231. package/dist/core/init.js +593 -0
  232. package/dist/core/legacy-cleanup.d.ts +162 -0
  233. package/dist/core/legacy-cleanup.js +514 -0
  234. package/dist/core/list.d.ts +9 -0
  235. package/dist/core/list.js +171 -0
  236. package/dist/core/migration.d.ts +23 -0
  237. package/dist/core/migration.js +108 -0
  238. package/dist/core/parsers/change-parser.d.ts +13 -0
  239. package/dist/core/parsers/change-parser.js +197 -0
  240. package/dist/core/parsers/markdown-parser.d.ts +26 -0
  241. package/dist/core/parsers/markdown-parser.js +227 -0
  242. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  243. package/dist/core/parsers/requirement-blocks.js +201 -0
  244. package/dist/core/parsers/spec-structure.d.ts +9 -0
  245. package/dist/core/parsers/spec-structure.js +88 -0
  246. package/dist/core/planning-home.d.ts +21 -0
  247. package/dist/core/planning-home.js +108 -0
  248. package/dist/core/profile-sync-drift.d.ts +38 -0
  249. package/dist/core/profile-sync-drift.js +200 -0
  250. package/dist/core/profiles.d.ts +26 -0
  251. package/dist/core/profiles.js +40 -0
  252. package/dist/core/project-config.d.ts +64 -0
  253. package/dist/core/project-config.js +223 -0
  254. package/dist/core/schemas/base.schema.d.ts +13 -0
  255. package/dist/core/schemas/base.schema.js +13 -0
  256. package/dist/core/schemas/change.schema.d.ts +73 -0
  257. package/dist/core/schemas/change.schema.js +31 -0
  258. package/dist/core/schemas/index.d.ts +4 -0
  259. package/dist/core/schemas/index.js +4 -0
  260. package/dist/core/schemas/spec.schema.d.ts +18 -0
  261. package/dist/core/schemas/spec.schema.js +15 -0
  262. package/dist/core/shared/index.d.ts +8 -0
  263. package/dist/core/shared/index.js +8 -0
  264. package/dist/core/shared/skill-generation.d.ts +49 -0
  265. package/dist/core/shared/skill-generation.js +96 -0
  266. package/dist/core/shared/tool-detection.d.ts +71 -0
  267. package/dist/core/shared/tool-detection.js +158 -0
  268. package/dist/core/specs-apply.d.ts +73 -0
  269. package/dist/core/specs-apply.js +392 -0
  270. package/dist/core/styles/palette.d.ts +7 -0
  271. package/dist/core/styles/palette.js +8 -0
  272. package/dist/core/templates/index.d.ts +8 -0
  273. package/dist/core/templates/index.js +9 -0
  274. package/dist/core/templates/skill-templates.d.ts +19 -0
  275. package/dist/core/templates/skill-templates.js +18 -0
  276. package/dist/core/templates/types.d.ts +19 -0
  277. package/dist/core/templates/types.js +5 -0
  278. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  279. package/dist/core/templates/workflows/apply-change.js +314 -0
  280. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  281. package/dist/core/templates/workflows/archive-change.js +277 -0
  282. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  283. package/dist/core/templates/workflows/bulk-archive-change.js +492 -0
  284. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  285. package/dist/core/templates/workflows/continue-change.js +234 -0
  286. package/dist/core/templates/workflows/explore.d.ts +10 -0
  287. package/dist/core/templates/workflows/explore.js +459 -0
  288. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  289. package/dist/core/templates/workflows/feedback.js +108 -0
  290. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  291. package/dist/core/templates/workflows/ff-change.js +200 -0
  292. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  293. package/dist/core/templates/workflows/new-change.js +143 -0
  294. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  295. package/dist/core/templates/workflows/onboard.js +563 -0
  296. package/dist/core/templates/workflows/propose.d.ts +10 -0
  297. package/dist/core/templates/workflows/propose.js +218 -0
  298. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  299. package/dist/core/templates/workflows/sync-specs.js +290 -0
  300. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  301. package/dist/core/templates/workflows/verify-change.js +338 -0
  302. package/dist/core/update.d.ts +82 -0
  303. package/dist/core/update.js +557 -0
  304. package/dist/core/validation/constants.d.ts +34 -0
  305. package/dist/core/validation/constants.js +40 -0
  306. package/dist/core/validation/types.d.ts +18 -0
  307. package/dist/core/validation/types.js +2 -0
  308. package/dist/core/validation/validator.d.ts +43 -0
  309. package/dist/core/validation/validator.js +435 -0
  310. package/dist/core/view.d.ts +8 -0
  311. package/dist/core/view.js +168 -0
  312. package/dist/core/workspace/foundation.d.ts +67 -0
  313. package/dist/core/workspace/foundation.js +295 -0
  314. package/dist/core/workspace/index.d.ts +8 -0
  315. package/dist/core/workspace/index.js +8 -0
  316. package/dist/core/workspace/legacy-state.d.ts +28 -0
  317. package/dist/core/workspace/legacy-state.js +200 -0
  318. package/dist/core/workspace/link-input.d.ts +9 -0
  319. package/dist/core/workspace/link-input.js +32 -0
  320. package/dist/core/workspace/open-surface.d.ts +45 -0
  321. package/dist/core/workspace/open-surface.js +215 -0
  322. package/dist/core/workspace/openers.d.ts +21 -0
  323. package/dist/core/workspace/openers.js +124 -0
  324. package/dist/core/workspace/registry.d.ts +24 -0
  325. package/dist/core/workspace/registry.js +146 -0
  326. package/dist/core/workspace/skills.d.ts +57 -0
  327. package/dist/core/workspace/skills.js +334 -0
  328. package/dist/core/workspace/state-io.d.ts +10 -0
  329. package/dist/core/workspace/state-io.js +121 -0
  330. package/dist/index.d.ts +3 -0
  331. package/dist/index.js +3 -0
  332. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  333. package/dist/prompts/searchable-multi-select.js +159 -0
  334. package/dist/telemetry/config.d.ts +38 -0
  335. package/dist/telemetry/config.js +136 -0
  336. package/dist/telemetry/index.d.ts +31 -0
  337. package/dist/telemetry/index.js +164 -0
  338. package/dist/ui/ascii-patterns.d.ts +16 -0
  339. package/dist/ui/ascii-patterns.js +133 -0
  340. package/dist/ui/welcome-screen.d.ts +10 -0
  341. package/dist/ui/welcome-screen.js +146 -0
  342. package/dist/utils/change-metadata.d.ts +54 -0
  343. package/dist/utils/change-metadata.js +141 -0
  344. package/dist/utils/change-utils.d.ts +71 -0
  345. package/dist/utils/change-utils.js +123 -0
  346. package/dist/utils/command-references.d.ts +18 -0
  347. package/dist/utils/command-references.js +20 -0
  348. package/dist/utils/file-system.d.ts +41 -0
  349. package/dist/utils/file-system.js +301 -0
  350. package/dist/utils/index.d.ts +6 -0
  351. package/dist/utils/index.js +9 -0
  352. package/dist/utils/interactive.d.ts +18 -0
  353. package/dist/utils/interactive.js +21 -0
  354. package/dist/utils/item-discovery.d.ts +4 -0
  355. package/dist/utils/item-discovery.js +72 -0
  356. package/dist/utils/match.d.ts +3 -0
  357. package/dist/utils/match.js +22 -0
  358. package/dist/utils/shell-detection.d.ts +20 -0
  359. package/dist/utils/shell-detection.js +41 -0
  360. package/dist/utils/task-progress.d.ts +8 -0
  361. package/dist/utils/task-progress.js +36 -0
  362. package/package.json +85 -0
  363. package/schemas/spec-driven/schema.yaml +151 -0
  364. package/schemas/spec-driven/templates/design.md +19 -0
  365. package/schemas/spec-driven/templates/proposal.md +23 -0
  366. package/schemas/spec-driven/templates/spec.md +8 -0
  367. package/schemas/spec-driven/templates/tasks.md +9 -0
  368. package/schemas/workspace-planning/schema.yaml +72 -0
  369. package/schemas/workspace-planning/templates/design.md +33 -0
  370. package/schemas/workspace-planning/templates/proposal.md +28 -0
  371. package/schemas/workspace-planning/templates/spec.md +9 -0
  372. package/schemas/workspace-planning/templates/tasks.md +15 -0
  373. package/scripts/postinstall.js +83 -0
@@ -0,0 +1,294 @@
1
+ import ora from 'ora';
2
+ import path from 'path';
3
+ import { Validator } from '../core/validation/validator.js';
4
+ import { isInteractive, resolveNoInteractive } from '../utils/interactive.js';
5
+ import { getActiveChangeIds, getSpecIds } from '../utils/item-discovery.js';
6
+ import { nearestMatches } from '../utils/match.js';
7
+ export class ValidateCommand {
8
+ async execute(itemName, options = {}) {
9
+ const interactive = isInteractive(options);
10
+ // Handle bulk flags first
11
+ if (options.all || options.changes || options.specs) {
12
+ await this.runBulkValidation({
13
+ changes: !!options.all || !!options.changes,
14
+ specs: !!options.all || !!options.specs,
15
+ }, { strict: !!options.strict, json: !!options.json, concurrency: options.concurrency, noInteractive: resolveNoInteractive(options) });
16
+ return;
17
+ }
18
+ // No item and no flags
19
+ if (!itemName) {
20
+ if (interactive) {
21
+ await this.runInteractiveSelector({ strict: !!options.strict, json: !!options.json, concurrency: options.concurrency });
22
+ return;
23
+ }
24
+ this.printNonInteractiveHint();
25
+ process.exitCode = 1;
26
+ return;
27
+ }
28
+ // Direct item validation with type detection or override
29
+ const typeOverride = this.normalizeType(options.type);
30
+ await this.validateDirectItem(itemName, { typeOverride, strict: !!options.strict, json: !!options.json });
31
+ }
32
+ normalizeType(value) {
33
+ if (!value)
34
+ return undefined;
35
+ const v = value.toLowerCase();
36
+ if (v === 'change' || v === 'spec')
37
+ return v;
38
+ return undefined;
39
+ }
40
+ async runInteractiveSelector(opts) {
41
+ const { select } = await import('@inquirer/prompts');
42
+ const choice = await select({
43
+ message: '你想验证什么?',
44
+ choices: [
45
+ { name: '全部(变更 + 规格)', value: 'all' },
46
+ { name: '所有变更', value: 'changes' },
47
+ { name: '所有规格', value: 'specs' },
48
+ { name: '选择特定的变更或规格', value: 'one' },
49
+ ],
50
+ });
51
+ if (choice === 'all')
52
+ return this.runBulkValidation({ changes: true, specs: true }, opts);
53
+ if (choice === 'changes')
54
+ return this.runBulkValidation({ changes: true, specs: false }, opts);
55
+ if (choice === 'specs')
56
+ return this.runBulkValidation({ changes: false, specs: true }, opts);
57
+ // one
58
+ const [changes, specs] = await Promise.all([getActiveChangeIds(), getSpecIds()]);
59
+ const items = [];
60
+ items.push(...changes.map(id => ({ name: `change/${id}`, value: { type: 'change', id } })));
61
+ items.push(...specs.map(id => ({ name: `spec/${id}`, value: { type: 'spec', id } })));
62
+ if (items.length === 0) {
63
+ console.error('未找到要验证的项目。');
64
+ process.exitCode = 1;
65
+ return;
66
+ }
67
+ const picked = await select({ message: '选择一个项目', choices: items });
68
+ await this.validateByType(picked.type, picked.id, opts);
69
+ }
70
+ printNonInteractiveHint() {
71
+ console.error('没有可验证的内容。试试以下命令之一:');
72
+ console.error(' openspec validate --all');
73
+ console.error(' openspec validate --changes');
74
+ console.error(' openspec validate --specs');
75
+ console.error(' openspec validate <项目名称>');
76
+ console.error('或者在交互式终端中运行。');
77
+ }
78
+ async validateDirectItem(itemName, opts) {
79
+ const [changes, specs] = await Promise.all([getActiveChangeIds(), getSpecIds()]);
80
+ const isChange = changes.includes(itemName);
81
+ const isSpec = specs.includes(itemName);
82
+ const type = opts.typeOverride ?? (isChange ? 'change' : isSpec ? 'spec' : undefined);
83
+ if (!type) {
84
+ console.error(`未知项目 '${itemName}'`);
85
+ const suggestions = nearestMatches(itemName, [...changes, ...specs]);
86
+ if (suggestions.length)
87
+ console.error(`你是否想找: ${suggestions.join(', ')}?`);
88
+ process.exitCode = 1;
89
+ return;
90
+ }
91
+ if (!opts.typeOverride && isChange && isSpec) {
92
+ console.error(`项目 '${itemName}' 同时匹配了变更和规格,存在歧义。`);
93
+ console.error('请传递 --type change|spec,或使用: openspec change validate / openspec spec validate');
94
+ process.exitCode = 1;
95
+ return;
96
+ }
97
+ await this.validateByType(type, itemName, opts);
98
+ }
99
+ async validateByType(type, id, opts) {
100
+ const validator = new Validator(opts.strict);
101
+ if (type === 'change') {
102
+ const changeDir = path.join(process.cwd(), 'openspec', 'changes', id);
103
+ const start = Date.now();
104
+ const report = await validator.validateChangeDeltaSpecs(changeDir);
105
+ const durationMs = Date.now() - start;
106
+ this.printReport('change', id, report, durationMs, opts.json);
107
+ // Non-zero exit if invalid (keeps enriched output test semantics)
108
+ process.exitCode = report.valid ? 0 : 1;
109
+ return;
110
+ }
111
+ const file = path.join(process.cwd(), 'openspec', 'specs', id, 'spec.md');
112
+ const start = Date.now();
113
+ const report = await validator.validateSpec(file);
114
+ const durationMs = Date.now() - start;
115
+ this.printReport('spec', id, report, durationMs, opts.json);
116
+ process.exitCode = report.valid ? 0 : 1;
117
+ }
118
+ printReport(type, id, report, durationMs, json) {
119
+ if (json) {
120
+ const out = { items: [{ id, type, valid: report.valid, issues: report.issues, durationMs }], summary: { totals: { items: 1, passed: report.valid ? 1 : 0, failed: report.valid ? 0 : 1 }, byType: { [type]: { items: 1, passed: report.valid ? 1 : 0, failed: report.valid ? 0 : 1 } } }, version: '1.0' };
121
+ console.log(JSON.stringify(out, null, 2));
122
+ return;
123
+ }
124
+ if (report.valid) {
125
+ console.log(`${type === 'change' ? '变更' : '规格'} '${id}' 验证通过`);
126
+ }
127
+ else {
128
+ console.error(`${type === 'change' ? '变更' : '规格'} '${id}' 存在问题`);
129
+ for (const issue of report.issues) {
130
+ const label = issue.level === 'ERROR' ? 'ERROR' : issue.level;
131
+ const prefix = issue.level === 'ERROR' ? '✗' : issue.level === 'WARNING' ? '⚠' : 'ℹ';
132
+ console.error(`${prefix} [${label}] ${issue.path}: ${issue.message}`);
133
+ }
134
+ this.printNextSteps(type);
135
+ }
136
+ }
137
+ printNextSteps(type) {
138
+ const bullets = [];
139
+ if (type === 'change') {
140
+ bullets.push('- 确保变更在 specs/ 中有 delta: 使用 ## ADDED/MODIFIED/REMOVED/RENAMED Requirements 标题');
141
+ bullets.push('- 每个需求必须至少包含一个 #### Scenario: 块');
142
+ bullets.push('- 调试已解析的 delta: openspec change show <id> --json --deltas-only');
143
+ }
144
+ else {
145
+ bullets.push('- 确保规格包含 ## Purpose 和 ## Requirements 段落');
146
+ bullets.push('- 每个需求必须至少包含一个 #### Scenario: 块');
147
+ bullets.push('- 使用 --json 重新运行以查看结构化报告');
148
+ }
149
+ console.error('后续步骤:');
150
+ bullets.forEach(b => console.error(` ${b}`));
151
+ }
152
+ async runBulkValidation(scope, opts) {
153
+ const spinner = !opts.json && !opts.noInteractive ? ora('正在验证...').start() : undefined;
154
+ const [changeIds, specIds] = await Promise.all([
155
+ scope.changes ? getActiveChangeIds() : Promise.resolve([]),
156
+ scope.specs ? getSpecIds() : Promise.resolve([]),
157
+ ]);
158
+ const DEFAULT_CONCURRENCY = 6;
159
+ const maxSuggestions = 5; // used by nearestMatches
160
+ const concurrency = normalizeConcurrency(opts.concurrency) ?? normalizeConcurrency(process.env.OPENSPEC_CONCURRENCY) ?? DEFAULT_CONCURRENCY;
161
+ const validator = new Validator(opts.strict);
162
+ const queue = [];
163
+ for (const id of changeIds) {
164
+ queue.push(async () => {
165
+ const start = Date.now();
166
+ const changeDir = path.join(process.cwd(), 'openspec', 'changes', id);
167
+ const report = await validator.validateChangeDeltaSpecs(changeDir);
168
+ const durationMs = Date.now() - start;
169
+ return { id, type: 'change', valid: report.valid, issues: report.issues, durationMs };
170
+ });
171
+ }
172
+ for (const id of specIds) {
173
+ queue.push(async () => {
174
+ const start = Date.now();
175
+ const file = path.join(process.cwd(), 'openspec', 'specs', id, 'spec.md');
176
+ const report = await validator.validateSpec(file);
177
+ const durationMs = Date.now() - start;
178
+ return { id, type: 'spec', valid: report.valid, issues: report.issues, durationMs };
179
+ });
180
+ }
181
+ if (queue.length === 0) {
182
+ spinner?.stop();
183
+ const summary = {
184
+ totals: { items: 0, passed: 0, failed: 0 },
185
+ byType: {
186
+ ...(scope.changes ? { change: { items: 0, passed: 0, failed: 0 } } : {}),
187
+ ...(scope.specs ? { spec: { items: 0, passed: 0, failed: 0 } } : {}),
188
+ },
189
+ };
190
+ if (opts.json) {
191
+ const out = { items: [], summary, version: '1.0' };
192
+ console.log(JSON.stringify(out, null, 2));
193
+ }
194
+ else {
195
+ console.log('未找到要验证的项目。');
196
+ }
197
+ process.exitCode = 0;
198
+ return;
199
+ }
200
+ const results = [];
201
+ let index = 0;
202
+ let running = 0;
203
+ let passed = 0;
204
+ let failed = 0;
205
+ await new Promise((resolve) => {
206
+ const next = () => {
207
+ while (running < concurrency && index < queue.length) {
208
+ const currentIndex = index++;
209
+ const task = queue[currentIndex];
210
+ running++;
211
+ if (spinner)
212
+ spinner.text = `正在验证 (${currentIndex + 1}/${queue.length})...`;
213
+ task()
214
+ .then(res => {
215
+ results.push(res);
216
+ if (res.valid)
217
+ passed++;
218
+ else
219
+ failed++;
220
+ })
221
+ .catch((error) => {
222
+ const message = error?.message || 'Unknown error';
223
+ const res = { id: getPlannedId(currentIndex, changeIds, specIds) ?? 'unknown', type: getPlannedType(currentIndex, changeIds, specIds) ?? 'change', valid: false, issues: [{ level: 'ERROR', path: 'file', message }], durationMs: 0 };
224
+ results.push(res);
225
+ failed++;
226
+ })
227
+ .finally(() => {
228
+ running--;
229
+ if (index >= queue.length && running === 0)
230
+ resolve();
231
+ else
232
+ next();
233
+ });
234
+ }
235
+ };
236
+ next();
237
+ });
238
+ spinner?.stop();
239
+ results.sort((a, b) => a.id.localeCompare(b.id));
240
+ const summary = {
241
+ totals: { items: results.length, passed, failed },
242
+ byType: {
243
+ ...(scope.changes ? { change: summarizeType(results, 'change') } : {}),
244
+ ...(scope.specs ? { spec: summarizeType(results, 'spec') } : {}),
245
+ },
246
+ };
247
+ if (opts.json) {
248
+ const out = { items: results, summary, version: '1.0' };
249
+ console.log(JSON.stringify(out, null, 2));
250
+ }
251
+ else {
252
+ for (const res of results) {
253
+ if (res.valid)
254
+ console.log(`✓ ${res.type}/${res.id}`);
255
+ else
256
+ console.error(`✗ ${res.type}/${res.id}`);
257
+ }
258
+ console.log(`总计: ${summary.totals.passed} 通过, ${summary.totals.failed} 失败 (共 ${summary.totals.items} 项)`);
259
+ }
260
+ process.exitCode = failed > 0 ? 1 : 0;
261
+ }
262
+ }
263
+ function summarizeType(results, type) {
264
+ const filtered = results.filter(r => r.type === type);
265
+ const items = filtered.length;
266
+ const passed = filtered.filter(r => r.valid).length;
267
+ const failed = items - passed;
268
+ return { items, passed, failed };
269
+ }
270
+ function normalizeConcurrency(value) {
271
+ if (!value)
272
+ return undefined;
273
+ const n = parseInt(value, 10);
274
+ if (Number.isNaN(n) || n <= 0)
275
+ return undefined;
276
+ return n;
277
+ }
278
+ function getPlannedId(index, changeIds, specIds) {
279
+ const totalChanges = changeIds.length;
280
+ if (index < totalChanges)
281
+ return changeIds[index];
282
+ const specIndex = index - totalChanges;
283
+ return specIds[specIndex];
284
+ }
285
+ function getPlannedType(index, changeIds, specIds) {
286
+ const totalChanges = changeIds.length;
287
+ if (index < totalChanges)
288
+ return 'change';
289
+ const specIndex = index - totalChanges;
290
+ if (specIndex >= 0 && specIndex < specIds.length)
291
+ return 'spec';
292
+ return undefined;
293
+ }
294
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Workflow CLI Commands
3
+ *
4
+ * Commands for the artifact-driven workflow: status, instructions, templates, schemas, new change.
5
+ */
6
+ export { statusCommand } from './status.js';
7
+ export type { StatusOptions } from './status.js';
8
+ export { instructionsCommand, applyInstructionsCommand } from './instructions.js';
9
+ export type { InstructionsOptions } from './instructions.js';
10
+ export { templatesCommand } from './templates.js';
11
+ export type { TemplatesOptions } from './templates.js';
12
+ export { schemasCommand } from './schemas.js';
13
+ export type { SchemasOptions } from './schemas.js';
14
+ export { newChangeCommand } from './new-change.js';
15
+ export type { NewChangeOptions } from './new-change.js';
16
+ export { setChangeCommand } from './set-change.js';
17
+ export type { SetChangeOptions } from './set-change.js';
18
+ export { DEFAULT_SCHEMA } from './shared.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Workflow CLI Commands
3
+ *
4
+ * Commands for the artifact-driven workflow: status, instructions, templates, schemas, new change.
5
+ */
6
+ export { statusCommand } from './status.js';
7
+ export { instructionsCommand, applyInstructionsCommand } from './instructions.js';
8
+ export { templatesCommand } from './templates.js';
9
+ export { schemasCommand } from './schemas.js';
10
+ export { newChangeCommand } from './new-change.js';
11
+ export { setChangeCommand } from './set-change.js';
12
+ export { DEFAULT_SCHEMA } from './shared.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,24 @@
1
+ import type { PlanningHome } from '../../core/planning-home.js';
2
+ import { type InitiativeLinkReference } from '../../core/collections/initiatives/index.js';
3
+ export interface ChangeCommandStatus {
4
+ severity: 'error' | 'warning';
5
+ code: string;
6
+ message: string;
7
+ target?: string;
8
+ fix?: string;
9
+ details?: unknown;
10
+ }
11
+ export interface InitiativeSelectorOptions {
12
+ initiative?: string;
13
+ store?: string;
14
+ storePath?: string;
15
+ }
16
+ export declare const REPO_LOCAL_INITIATIVE_LINK_ERROR = "Initiative links are supported only for repo-local changes. Run this command from the repo that owns the implementation plan.";
17
+ export declare function printJson(payload: unknown): void;
18
+ export declare function statusFromError(error: unknown): ChangeCommandStatus;
19
+ export declare function assertInitiativeSelectorsHaveReference(options: InitiativeSelectorOptions): void;
20
+ export declare function assertInitiativeReference(value: string | undefined): asserts value is string;
21
+ export declare function assertRepoLocalInitiativeLinkPlanningHome(planningHome: PlanningHome): void;
22
+ export declare function formatInitiativeLink(initiative: InitiativeLinkReference): string;
23
+ export declare function sameInitiativeLink(left: InitiativeLinkReference | undefined, right: InitiativeLinkReference): boolean;
24
+ //# sourceMappingURL=initiative-link.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { InitiativeResolutionError, } from '../../core/collections/initiatives/index.js';
2
+ export const REPO_LOCAL_INITIATIVE_LINK_ERROR = 'Initiative links are supported only for repo-local changes. Run this command from the repo that owns the implementation plan.';
3
+ export function printJson(payload) {
4
+ console.log(JSON.stringify(payload, null, 2));
5
+ }
6
+ export function statusFromError(error) {
7
+ if (error instanceof InitiativeResolutionError) {
8
+ return {
9
+ severity: 'error',
10
+ code: error.code,
11
+ message: error.message,
12
+ ...(error.target ? { target: error.target } : {}),
13
+ ...(error.fix ? { fix: error.fix } : {}),
14
+ ...(error.details ? { details: error.details } : {}),
15
+ };
16
+ }
17
+ return {
18
+ severity: 'error',
19
+ code: 'change_error',
20
+ message: error instanceof Error ? error.message : String(error),
21
+ };
22
+ }
23
+ export function assertInitiativeSelectorsHaveReference(options) {
24
+ if (!options.initiative && (options.store !== undefined || options.storePath !== undefined)) {
25
+ throw new Error('Pass --initiative when using --store or --store-path.');
26
+ }
27
+ if (options.initiative !== undefined && options.initiative.trim().length === 0) {
28
+ throw new Error('Pass --initiative <id> to link a change to an initiative.');
29
+ }
30
+ }
31
+ export function assertInitiativeReference(value) {
32
+ if (value === undefined || value.trim().length === 0) {
33
+ throw new Error('Pass --initiative <id> to set a change initiative link.');
34
+ }
35
+ }
36
+ export function assertRepoLocalInitiativeLinkPlanningHome(planningHome) {
37
+ if (planningHome.kind === 'workspace') {
38
+ throw new Error(REPO_LOCAL_INITIATIVE_LINK_ERROR);
39
+ }
40
+ }
41
+ export function formatInitiativeLink(initiative) {
42
+ return `${initiative.store}/${initiative.id}`;
43
+ }
44
+ export function sameInitiativeLink(left, right) {
45
+ return left?.store === right.store && left.id === right.id;
46
+ }
47
+ //# sourceMappingURL=initiative-link.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Instructions Command
3
+ *
4
+ * Generates enriched instructions for creating artifacts or applying tasks.
5
+ * Includes both artifact instructions and apply instructions.
6
+ */
7
+ import { type ArtifactInstructions } from '../../core/artifact-graph/index.js';
8
+ import { type ApplyInstructions } from './shared.js';
9
+ export interface InstructionsOptions {
10
+ change?: string;
11
+ schema?: string;
12
+ json?: boolean;
13
+ }
14
+ export interface ApplyInstructionsOptions {
15
+ change?: string;
16
+ schema?: string;
17
+ json?: boolean;
18
+ }
19
+ export declare function instructionsCommand(artifactId: string | undefined, options: InstructionsOptions): Promise<void>;
20
+ export declare function printInstructionsText(instructions: ArtifactInstructions, isBlocked: boolean): void;
21
+ /**
22
+ * Generates apply instructions for implementing tasks from a change.
23
+ * Schema-aware: reads apply phase configuration from schema to determine
24
+ * required artifacts, tracking file, and instruction.
25
+ */
26
+ export declare function generateApplyInstructions(projectRoot: string, changeName: string, schemaName?: string, planningHome?: import("../../core/planning-home.js").PlanningHome): Promise<ApplyInstructions>;
27
+ export declare function applyInstructionsCommand(options: ApplyInstructionsOptions): Promise<void>;
28
+ export declare function printApplyInstructionsText(instructions: ApplyInstructions): void;
29
+ //# sourceMappingURL=instructions.d.ts.map