@codewalla_india/openspec 1.3.1 → 1.3.2

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 (333) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +272 -191
  3. package/bin/openspec.js +5 -5
  4. package/dist/cli/index.js +99 -62
  5. package/dist/commands/change.d.ts +0 -2
  6. package/dist/commands/change.js +107 -86
  7. package/dist/commands/config.js +14 -16
  8. package/dist/commands/doctor.js +9 -4
  9. package/dist/commands/feedback.js +79 -30
  10. package/dist/commands/modify.d.ts +26 -0
  11. package/dist/commands/modify.js +147 -0
  12. package/dist/commands/schema.js +170 -91
  13. package/dist/commands/show.js +5 -2
  14. package/dist/commands/spec.js +49 -29
  15. package/dist/commands/store.js +15 -21
  16. package/dist/commands/validate.d.ts +8 -0
  17. package/dist/commands/validate.js +43 -20
  18. package/dist/commands/workflow/index.d.ts +2 -2
  19. package/dist/commands/workflow/index.js +1 -1
  20. package/dist/commands/workflow/instructions.d.ts +6 -26
  21. package/dist/commands/workflow/instructions.js +183 -376
  22. package/dist/commands/workflow/new-change.d.ts +0 -4
  23. package/dist/commands/workflow/new-change.js +10 -28
  24. package/dist/commands/workflow/shared.d.ts +34 -19
  25. package/dist/commands/workflow/shared.js +34 -4
  26. package/dist/commands/workflow/status.js +10 -32
  27. package/dist/commands/workflow/templates.js +15 -5
  28. package/dist/commands/workset.d.ts +2 -2
  29. package/dist/commands/workset.js +19 -22
  30. package/dist/comprehension-quiz/fingerprint.d.ts +39 -0
  31. package/dist/comprehension-quiz/fingerprint.js +84 -0
  32. package/dist/comprehension-quiz/index.d.ts +42 -0
  33. package/dist/comprehension-quiz/index.js +47 -0
  34. package/dist/comprehension-quiz/pass-record.d.ts +44 -0
  35. package/dist/comprehension-quiz/pass-record.js +98 -0
  36. package/dist/comprehension-quiz/providers/anthropic.d.ts +34 -0
  37. package/dist/comprehension-quiz/providers/anthropic.js +53 -0
  38. package/dist/comprehension-quiz/providers/factory.d.ts +44 -0
  39. package/dist/comprehension-quiz/providers/factory.js +174 -0
  40. package/dist/comprehension-quiz/providers/interface.d.ts +59 -0
  41. package/dist/comprehension-quiz/providers/interface.js +63 -0
  42. package/dist/comprehension-quiz/providers/local.d.ts +34 -0
  43. package/dist/comprehension-quiz/providers/local.js +53 -0
  44. package/dist/comprehension-quiz/providers/ollama.d.ts +34 -0
  45. package/dist/comprehension-quiz/providers/ollama.js +53 -0
  46. package/dist/comprehension-quiz/providers/openai.d.ts +34 -0
  47. package/dist/comprehension-quiz/providers/openai.js +53 -0
  48. package/dist/comprehension-quiz/question-generator.d.ts +69 -0
  49. package/dist/comprehension-quiz/question-generator.js +141 -0
  50. package/dist/comprehension-quiz/quiz-executor.d.ts +70 -0
  51. package/dist/comprehension-quiz/quiz-executor.js +165 -0
  52. package/dist/comprehension-quiz/types.d.ts +115 -0
  53. package/dist/comprehension-quiz/types.js +11 -0
  54. package/dist/core/archive.d.ts +14 -1
  55. package/dist/core/archive.js +1350 -190
  56. package/dist/core/artifact-graph/graph.d.ts +28 -9
  57. package/dist/core/artifact-graph/graph.js +94 -43
  58. package/dist/core/artifact-graph/index.d.ts +1 -1
  59. package/dist/core/artifact-graph/index.js +1 -1
  60. package/dist/core/artifact-graph/instruction-loader.d.ts +30 -3
  61. package/dist/core/artifact-graph/instruction-loader.js +70 -12
  62. package/dist/core/artifact-graph/outputs.d.ts +1 -0
  63. package/dist/core/artifact-graph/outputs.js +67 -5
  64. package/dist/core/artifact-graph/resolver.d.ts +14 -0
  65. package/dist/core/artifact-graph/resolver.js +69 -15
  66. package/dist/core/artifact-graph/types.js +21 -3
  67. package/dist/core/available-tools.d.ts +2 -2
  68. package/dist/core/available-tools.js +14 -3
  69. package/dist/core/change-metadata/schema.d.ts +2 -0
  70. package/dist/core/change-metadata/schema.js +13 -0
  71. package/dist/core/change-status-policy.d.ts +10 -1
  72. package/dist/core/change-status-policy.js +30 -2
  73. package/dist/core/command-generation/adapters/amazon-q.d.ts +4 -0
  74. package/dist/core/command-generation/adapters/amazon-q.js +11 -5
  75. package/dist/core/command-generation/adapters/antigravity.js +6 -5
  76. package/dist/core/command-generation/adapters/auggie.js +7 -6
  77. package/dist/core/command-generation/adapters/bob.d.ts +5 -1
  78. package/dist/core/command-generation/adapters/bob.js +11 -10
  79. package/dist/core/command-generation/adapters/claude.d.ts +1 -1
  80. package/dist/core/command-generation/adapters/claude.js +12 -17
  81. package/dist/core/command-generation/adapters/cline.js +5 -5
  82. package/dist/core/command-generation/adapters/codebuddy.js +8 -7
  83. package/dist/core/command-generation/adapters/continue.js +8 -7
  84. package/dist/core/command-generation/adapters/costrict.js +7 -6
  85. package/dist/core/command-generation/adapters/crush.js +9 -9
  86. package/dist/core/command-generation/adapters/cursor.js +8 -8
  87. package/dist/core/command-generation/adapters/devin.d.ts +19 -0
  88. package/dist/core/command-generation/adapters/devin.js +36 -0
  89. package/dist/core/command-generation/adapters/factory.js +7 -6
  90. package/dist/core/command-generation/adapters/gemini.js +40 -5
  91. package/dist/core/command-generation/adapters/github-copilot.js +6 -5
  92. package/dist/core/command-generation/adapters/iflow.js +9 -8
  93. package/dist/core/command-generation/adapters/index.d.ts +4 -2
  94. package/dist/core/command-generation/adapters/index.js +4 -2
  95. package/dist/core/command-generation/adapters/junie.js +6 -5
  96. package/dist/core/command-generation/adapters/kilocode.js +1 -1
  97. package/dist/core/command-generation/adapters/kiro.js +6 -5
  98. package/dist/core/command-generation/adapters/lingma.js +9 -9
  99. package/dist/core/command-generation/adapters/oh-my-pi.d.ts +21 -0
  100. package/dist/core/command-generation/adapters/oh-my-pi.js +42 -0
  101. package/dist/core/command-generation/adapters/opencode.js +6 -8
  102. package/dist/core/command-generation/adapters/pi.d.ts +2 -2
  103. package/dist/core/command-generation/adapters/pi.js +7 -10
  104. package/dist/core/command-generation/adapters/qoder.js +9 -9
  105. package/dist/core/command-generation/adapters/qwen.d.ts +7 -3
  106. package/dist/core/command-generation/adapters/qwen.js +14 -9
  107. package/dist/core/command-generation/adapters/roocode.d.ts +4 -4
  108. package/dist/core/command-generation/adapters/roocode.js +9 -9
  109. package/dist/core/command-generation/adapters/trae.d.ts +13 -0
  110. package/dist/core/command-generation/adapters/trae.js +28 -0
  111. package/dist/core/command-generation/adapters/zcode.d.ts +16 -0
  112. package/dist/core/command-generation/adapters/zcode.js +33 -0
  113. package/dist/core/command-generation/generator.d.ts +8 -0
  114. package/dist/core/command-generation/generator.js +15 -1
  115. package/dist/core/command-generation/index.d.ts +1 -1
  116. package/dist/core/command-generation/index.js +1 -1
  117. package/dist/core/command-generation/invocation.d.ts +73 -0
  118. package/dist/core/command-generation/invocation.js +77 -0
  119. package/dist/core/command-generation/registry.js +8 -4
  120. package/dist/core/command-generation/types.d.ts +9 -2
  121. package/dist/core/command-generation/yaml.d.ts +20 -6
  122. package/dist/core/command-generation/yaml.js +31 -21
  123. package/dist/core/command-surface.d.ts +15 -0
  124. package/dist/core/command-surface.js +33 -0
  125. package/dist/core/completions/command-registry.js +16 -61
  126. package/dist/core/completions/generators/bash-generator.js +41 -41
  127. package/dist/core/completions/generators/fish-generator.js +7 -7
  128. package/dist/core/completions/generators/powershell-generator.js +44 -37
  129. package/dist/core/completions/generators/zsh-generator.js +33 -33
  130. package/dist/core/completions/installers/zsh-installer.d.ts +9 -0
  131. package/dist/core/completions/installers/zsh-installer.js +20 -4
  132. package/dist/core/completions/templates/bash-templates.js +24 -24
  133. package/dist/core/completions/templates/fish-templates.js +38 -38
  134. package/dist/core/completions/templates/powershell-templates.js +28 -28
  135. package/dist/core/completions/templates/zsh-templates.js +39 -39
  136. package/dist/core/config-prompts.d.ts +1 -1
  137. package/dist/core/config-prompts.js +14 -1
  138. package/dist/core/config-schema.d.ts +10 -1
  139. package/dist/core/config-schema.js +67 -1
  140. package/dist/core/config.d.ts +15 -0
  141. package/dist/core/config.js +46 -5
  142. package/dist/core/file-state.js +56 -24
  143. package/dist/core/github-copilot/cloud-agent.d.ts +95 -0
  144. package/dist/core/github-copilot/cloud-agent.js +497 -0
  145. package/dist/core/global-config.d.ts +16 -0
  146. package/dist/core/init.d.ts +58 -0
  147. package/dist/core/init.js +474 -73
  148. package/dist/core/legacy-cleanup.d.ts +59 -0
  149. package/dist/core/legacy-cleanup.js +253 -24
  150. package/dist/core/list.js +23 -16
  151. package/dist/core/migration.d.ts +73 -1
  152. package/dist/core/migration.js +360 -11
  153. package/dist/core/modify/conflict-detector.d.ts +26 -0
  154. package/dist/core/modify/conflict-detector.js +62 -0
  155. package/dist/core/modify/dependency-propagator.d.ts +38 -0
  156. package/dist/core/modify/dependency-propagator.js +103 -0
  157. package/dist/core/modify/history-tracker.d.ts +34 -0
  158. package/dist/core/modify/history-tracker.js +114 -0
  159. package/dist/core/modify/index.d.ts +7 -0
  160. package/dist/core/modify/index.js +7 -0
  161. package/dist/core/onboarding-commands.d.ts +30 -0
  162. package/dist/core/onboarding-commands.js +38 -0
  163. package/dist/core/openspec-root.js +18 -15
  164. package/dist/core/parsers/change-parser.d.ts +17 -2
  165. package/dist/core/parsers/change-parser.js +35 -21
  166. package/dist/core/parsers/code-fence.d.ts +15 -0
  167. package/dist/core/parsers/code-fence.js +49 -0
  168. package/dist/core/parsers/markdown-parser.d.ts +0 -3
  169. package/dist/core/parsers/markdown-parser.js +7 -60
  170. package/dist/core/parsers/requirement-blocks.d.ts +29 -0
  171. package/dist/core/parsers/requirement-blocks.js +150 -31
  172. package/dist/core/parsers/requirement-text.d.ts +48 -0
  173. package/dist/core/parsers/requirement-text.js +98 -0
  174. package/dist/core/parsers/spec-structure.d.ts +1 -1
  175. package/dist/core/parsers/spec-structure.js +20 -30
  176. package/dist/core/profile-sync-drift.d.ts +0 -8
  177. package/dist/core/profile-sync-drift.js +49 -50
  178. package/dist/core/profiles.d.ts +2 -2
  179. package/dist/core/profiles.js +2 -2
  180. package/dist/core/project-config.d.ts +27 -18
  181. package/dist/core/project-config.js +101 -34
  182. package/dist/core/references.js +42 -4
  183. package/dist/core/relationship-health.d.ts +8 -0
  184. package/dist/core/relationship-health.js +13 -0
  185. package/dist/core/root-selection.d.ts +9 -6
  186. package/dist/core/root-selection.js +42 -5
  187. package/dist/core/schemas/base.schema.js +7 -2
  188. package/dist/core/shared/allowed-tools.d.ts +12 -0
  189. package/dist/core/shared/allowed-tools.js +12 -0
  190. package/dist/core/shared/index.d.ts +1 -0
  191. package/dist/core/shared/index.js +1 -0
  192. package/dist/core/shared/skill-content-equivalence.d.ts +7 -0
  193. package/dist/core/shared/skill-content-equivalence.js +41 -0
  194. package/dist/core/shared/skill-generation.js +17 -13
  195. package/dist/core/shared/skill-paths.d.ts +13 -0
  196. package/dist/core/shared/skill-paths.js +23 -0
  197. package/dist/core/shared/tool-detection.d.ts +27 -7
  198. package/dist/core/shared/tool-detection.js +167 -37
  199. package/dist/core/shared-skill-target.d.ts +16 -0
  200. package/dist/core/shared-skill-target.js +156 -0
  201. package/dist/core/specs-apply.d.ts +80 -33
  202. package/dist/core/specs-apply.js +667 -145
  203. package/dist/core/store/git.d.ts +13 -0
  204. package/dist/core/store/git.js +24 -0
  205. package/dist/core/store/operations.js +20 -0
  206. package/dist/core/templates/skill-templates.d.ts +3 -2
  207. package/dist/core/templates/skill-templates.js +3 -2
  208. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  209. package/dist/core/templates/workflows/apply-change.js +186 -224
  210. package/dist/core/templates/workflows/archive-change.js +387 -260
  211. package/dist/core/templates/workflows/bulk-archive-change.js +655 -475
  212. package/dist/core/templates/workflows/continue-change.js +210 -219
  213. package/dist/core/templates/workflows/explore.js +479 -443
  214. package/dist/core/templates/workflows/feedback.js +97 -97
  215. package/dist/core/templates/workflows/ff-change.js +200 -191
  216. package/dist/core/templates/workflows/modify-change.d.ts +4 -1
  217. package/dist/core/templates/workflows/modify-change.js +237 -115
  218. package/dist/core/templates/workflows/new-change.js +127 -134
  219. package/dist/core/templates/workflows/onboard.js +548 -542
  220. package/dist/core/templates/workflows/propose.js +273 -217
  221. package/dist/core/templates/workflows/store-selection.d.ts +1 -1
  222. package/dist/core/templates/workflows/store-selection.js +1 -1
  223. package/dist/core/templates/workflows/sync-specs.js +500 -273
  224. package/dist/core/templates/workflows/update-change.d.ts +10 -0
  225. package/dist/core/templates/workflows/update-change.js +177 -0
  226. package/dist/core/templates/workflows/verify-change.js +324 -326
  227. package/dist/core/update.d.ts +40 -5
  228. package/dist/core/update.js +411 -96
  229. package/dist/core/validation/constants.d.ts +4 -1
  230. package/dist/core/validation/constants.js +4 -1
  231. package/dist/core/validation/plan-validator.d.ts +8 -0
  232. package/dist/core/validation/plan-validator.js +45 -0
  233. package/dist/core/validation/task-numbering.d.ts +16 -0
  234. package/dist/core/validation/task-numbering.js +57 -0
  235. package/dist/core/validation/validator.d.ts +27 -3
  236. package/dist/core/validation/validator.js +337 -48
  237. package/dist/core/version-check.d.ts +152 -0
  238. package/dist/core/version-check.js +731 -0
  239. package/dist/core/view.js +13 -18
  240. package/dist/prompts/searchable-multi-select.js +1 -1
  241. package/dist/telemetry/caller-detection.d.ts +27 -0
  242. package/dist/telemetry/caller-detection.js +85 -0
  243. package/dist/telemetry/caller-detection.test.d.ts +5 -0
  244. package/dist/telemetry/config.d.ts +48 -2
  245. package/dist/telemetry/config.js +113 -11
  246. package/dist/telemetry/config.test.d.ts +5 -0
  247. package/dist/telemetry/deduplication.d.ts +35 -0
  248. package/dist/telemetry/deduplication.js +82 -0
  249. package/dist/telemetry/deduplication.test.d.ts +5 -0
  250. package/dist/telemetry/identity.d.ts +62 -22
  251. package/dist/telemetry/identity.js +147 -102
  252. package/dist/telemetry/index.d.ts +126 -15
  253. package/dist/telemetry/index.js +569 -37
  254. package/dist/telemetry/sanitization.d.ts +40 -0
  255. package/dist/telemetry/sanitization.js +114 -0
  256. package/dist/telemetry/sanitization.test.d.ts +5 -0
  257. package/dist/telemetry/throttling.d.ts +20 -0
  258. package/dist/telemetry/throttling.js +70 -0
  259. package/dist/ui/welcome-screen.d.ts +9 -1
  260. package/dist/ui/welcome-screen.js +91 -38
  261. package/dist/utils/change-metadata.d.ts +43 -0
  262. package/dist/utils/change-metadata.js +123 -7
  263. package/dist/utils/change-utils.d.ts +10 -4
  264. package/dist/utils/change-utils.js +20 -13
  265. package/dist/utils/ci.d.ts +12 -0
  266. package/dist/utils/ci.js +16 -0
  267. package/dist/utils/command-references.d.ts +92 -6
  268. package/dist/utils/command-references.js +180 -7
  269. package/dist/utils/date.d.ts +8 -0
  270. package/dist/utils/date.js +13 -0
  271. package/dist/utils/file-system.d.ts +10 -0
  272. package/dist/utils/file-system.js +70 -0
  273. package/dist/utils/index.d.ts +1 -1
  274. package/dist/utils/index.js +1 -1
  275. package/dist/utils/interactive.d.ts +23 -0
  276. package/dist/utils/interactive.js +32 -0
  277. package/dist/utils/item-discovery.d.ts +19 -0
  278. package/dist/utils/item-discovery.js +30 -48
  279. package/dist/utils/shell-detection.d.ts +1 -1
  280. package/dist/utils/shell-detection.js +64 -11
  281. package/dist/utils/spec-discovery.d.ts +40 -0
  282. package/dist/utils/spec-discovery.js +115 -0
  283. package/dist/utils/task-progress.d.ts +29 -1
  284. package/dist/utils/task-progress.js +109 -15
  285. package/package.json +96 -84
  286. package/schemas/spec-driven/schema.yaml +252 -184
  287. package/schemas/spec-driven/templates/design.md +19 -19
  288. package/schemas/spec-driven/templates/plan-template.md +91 -0
  289. package/schemas/spec-driven/templates/proposal.md +29 -24
  290. package/schemas/spec-driven/templates/spec.md +11 -8
  291. package/schemas/spec-driven/templates/tasks.md +9 -9
  292. package/scripts/postinstall.js +83 -83
  293. package/dist/core/command-generation/adapters/codex.d.ts +0 -16
  294. package/dist/core/command-generation/adapters/codex.js +0 -39
  295. package/dist/core/command-generation/adapters/windsurf.d.ts +0 -14
  296. package/dist/core/command-generation/adapters/windsurf.js +0 -38
  297. package/dist/core/comprehension/config.d.ts +0 -20
  298. package/dist/core/comprehension/config.js +0 -23
  299. package/dist/core/comprehension/fingerprint.d.ts +0 -14
  300. package/dist/core/comprehension/fingerprint.js +0 -33
  301. package/dist/core/comprehension/index.d.ts +0 -57
  302. package/dist/core/comprehension/index.js +0 -87
  303. package/dist/core/comprehension/pass-record.d.ts +0 -29
  304. package/dist/core/comprehension/pass-record.js +0 -64
  305. package/dist/core/comprehension/stats.d.ts +0 -35
  306. package/dist/core/comprehension/stats.js +0 -133
  307. package/dist/core/templates/workflows/comprehension-guidance.d.ts +0 -9
  308. package/dist/core/templates/workflows/comprehension-guidance.js +0 -73
  309. package/dist/core/templates/workflows/mcp-guidance.d.ts +0 -13
  310. package/dist/core/templates/workflows/mcp-guidance.js +0 -131
  311. package/dist/core/templates/workflows/user-prompt-guidance.d.ts +0 -16
  312. package/dist/core/templates/workflows/user-prompt-guidance.js +0 -48
  313. package/dist/telemetry/caller.d.ts +0 -5
  314. package/dist/telemetry/caller.js +0 -29
  315. package/dist/telemetry/client.d.ts +0 -27
  316. package/dist/telemetry/client.js +0 -127
  317. package/dist/telemetry/command-context.d.ts +0 -13
  318. package/dist/telemetry/command-context.js +0 -59
  319. package/dist/telemetry/comprehension.d.ts +0 -44
  320. package/dist/telemetry/comprehension.js +0 -105
  321. package/dist/telemetry/content.d.ts +0 -10
  322. package/dist/telemetry/content.js +0 -56
  323. package/dist/telemetry/git-stats.d.ts +0 -12
  324. package/dist/telemetry/git-stats.js +0 -69
  325. package/dist/telemetry/identify-cache.d.ts +0 -7
  326. package/dist/telemetry/identify-cache.js +0 -47
  327. package/dist/telemetry/input.d.ts +0 -17
  328. package/dist/telemetry/input.js +0 -68
  329. package/dist/telemetry/marker.d.ts +0 -37
  330. package/dist/telemetry/marker.js +0 -67
  331. package/dist/telemetry/workflow.d.ts +0 -85
  332. package/dist/telemetry/workflow.js +0 -318
  333. package/schemas/spec-driven/templates/plan.md +0 -19
@@ -1,115 +1,178 @@
1
1
  import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
2
- import { PROMPT_CONFIRM, PROMPT_SELECT_CHANGE } from './user-prompt-guidance.js';
3
2
  export function getArchiveChangeSkillTemplate() {
4
3
  return {
5
4
  name: 'openspec-archive-change',
6
5
  description: 'Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.',
7
- instructions: `Archive a completed change in the experimental workflow.
8
-
9
- ${STORE_SELECTION_GUIDANCE}
10
-
11
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
12
-
13
- **Steps**
14
-
15
- 1. **If no change name provided, prompt for selection**
16
-
17
- ${PROMPT_SELECT_CHANGE}
18
-
19
- Show only active changes (not already archived).
20
- Include the schema used for each change if available.
21
-
22
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
23
-
24
- 2. **Check artifact completion status**
25
-
26
- Run \`openspec status --change "<name>" --json\` to check artifact completion.
27
-
28
- Parse the JSON to understand:
29
- - \`schemaName\`: The workflow being used
30
- - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
31
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
32
-
33
- **If any artifacts are not \`done\`:**
34
- - Display warning listing incomplete artifacts
35
- - ${PROMPT_CONFIRM}
36
- - Proceed if user confirms
37
-
38
- 3. **Check task completion status**
39
-
40
- Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
41
-
42
- Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
43
-
44
- **If incomplete tasks found:**
45
- - Display warning showing count of incomplete tasks
46
- - ${PROMPT_CONFIRM}
47
- - Proceed if user confirms
48
-
49
- **If no tasks file exists:** Proceed without task-related warning.
50
-
51
- 4. **Assess delta spec sync state**
52
-
53
- Use \`artifactPaths.specs.existingOutputPaths\` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
54
-
55
- **If delta specs exist:**
56
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
57
- - Determine what changes would be applied (adds, modifications, removals, renames)
58
- - Show a combined summary before prompting
59
-
60
- **Prompt options:**
61
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
62
- - If already synced: "Archive now", "Sync anyway", "Cancel"
63
-
64
- If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
65
-
66
- 5. **Perform the archive**
67
-
68
- Create an \`archive\` directory under \`planningHome.changesDir\` if it doesn't exist:
69
- \`\`\`bash
70
- mkdir -p "<planningHome.changesDir>/archive"
71
- \`\`\`
72
-
73
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
74
-
75
- **Check if target already exists:**
76
- - If yes: Fail with error, suggest renaming existing archive or using different date
77
- - If no: Move \`changeRoot\` to the archive directory
78
-
79
- \`\`\`bash
80
- mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
81
- \`\`\`
82
-
83
- 6. **Display summary**
84
-
85
- Show archive completion summary including:
86
- - Change name
87
- - Schema that was used
88
- - Archive location
89
- - Whether specs were synced (if applicable)
90
- - Note about any warnings (incomplete artifacts/tasks)
91
-
92
- **Output On Success**
93
-
94
- \`\`\`
95
- ## Archive Complete
96
-
97
- **Change:** <change-name>
98
- **Schema:** <schema-name>
99
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
100
- **Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
101
-
102
- All artifacts complete. All tasks complete.
103
- \`\`\`
104
-
105
- **Guardrails**
106
- - Always prompt for change selection if not provided
107
- - Use artifact graph (openspec status --json) for completion checking
108
- - Don't block archive on warnings - just inform and confirm
109
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
110
- - Show clear summary of what happened
111
- - If sync is requested, use openspec-sync-specs approach (agent-driven)
112
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`,
6
+ instructions: `Archive a completed change in the experimental workflow.
7
+
8
+ ${STORE_SELECTION_GUIDANCE}
9
+
10
+ \`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
11
+
12
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
13
+
14
+ **Steps**
15
+
16
+ 1. **Select the change**
17
+
18
+ If a name is provided, use it. Otherwise:
19
+ - Infer from conversation context if the user mentioned a change
20
+ - Auto-select if only one active change exists
21
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
22
+
23
+ When prompting, show only active changes (not already archived).
24
+ Include the schema used for each change if available.
25
+
26
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:archive <other>\`).
27
+
28
+ **Load current archive inputs before the existing archive checks:**
29
+
30
+ After resolving the selected change and planning root, run:
31
+ \`\`\`bash
32
+ openspec instructions archive --change "<name>" --json
33
+ \`\`\`
34
+ Keep the same selected-root flags on this command. This lookup is advisory and
35
+ optional: it only supplies extra prompt inputs, so it must never block archiving.
36
+ If it exits non-zero or returns invalid JSON — for example on an older CLI that
37
+ does not support this command yet — continue the archive workflow with no
38
+ context and no operation guidance. Do not report an error and do not stop.
39
+
40
+ A successful response may omit both optional fields. Treat \`context\` as a
41
+ required prompt-level input: read and consider it, and apply relevant project
42
+ facts, conventions, and constraints. Treat \`operationGuidance\` as optional
43
+ additive advice: read and consider every entry, and follow entries that are
44
+ applicable and compatible with the built-in archive workflow.
45
+
46
+ Keep both fields separate from built-in steps, explicit user choices, resolved
47
+ paths, CLI checks, and command contracts. If context conflicts with one of those
48
+ controlling inputs, report the conflict and preserve the controlling value. If
49
+ guidance is inapplicable or conflicts with a controlling input, do not follow it
50
+ and explain why. Do not infer replacement paths, skipped prompts, or flags from
51
+ either field, and do not copy their text verbatim into specs, change artifacts,
52
+ or archive summaries unless the user separately asks for it. These are
53
+ prompt-level behavior contracts, not enforceable checks.
54
+
55
+ 2. **Check artifact completion status**
56
+
57
+ Run \`openspec status --change "<name>" --json\` to check artifact completion.
58
+
59
+ Parse the JSON to understand:
60
+ - \`schemaName\`: The workflow being used
61
+ - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
62
+ - \`artifacts\`: List of artifacts with their status (\`done\`, \`skipped\`, or other)
63
+
64
+ **If any artifacts are neither \`done\` nor \`skipped\`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
65
+ - Display warning listing incomplete artifacts
66
+ - Ask the user to confirm they want to proceed
67
+ - Proceed if user confirms
68
+
69
+ 3. **Check task completion status**
70
+
71
+ Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
72
+
73
+ Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
74
+
75
+ **If incomplete tasks found:**
76
+ - Display warning showing count of incomplete tasks
77
+ - Ask the user to confirm they want to proceed
78
+ - Proceed if user confirms
79
+
80
+ **If no tasks file exists:** Proceed without task-related warning.
81
+
82
+ 4. **Assess delta spec sync state**
83
+
84
+ Use \`artifactPaths.specs.existingOutputPaths\` from status JSON as the only
85
+ delta-spec source. If the \`specs\` entry is missing or
86
+ \`existingOutputPaths\` is empty, proceed without a sync prompt and do not infer
87
+ delta specs from other artifacts.
88
+
89
+ **If delta specs exist:**
90
+ - Compare each delta spec with its corresponding main spec at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (use the store-aware \`planningHome.root\` from step 2, not a hardcoded repo path)
91
+ - Determine what changes would be applied (adds, modifications, removals, renames)
92
+ - Show a combined summary before prompting
93
+
94
+ **Prompt options:**
95
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
96
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
97
+
98
+ Route on the answer:
99
+ - "Cancel" stop, do not archive
100
+ - "Archive without syncing" or "Archive now" — proceed to archive
101
+ - "Sync now" or "Sync anyway" — sync, then verify (below)
102
+ - Anything else — ask again rather than archiving
103
+
104
+ Before a selected sync writes any main spec, run
105
+ \`openspec instructions specs --change "<name>" --json\` once with the same
106
+ selected-root flags. Require a zero exit status and valid artifact-instruction
107
+ JSON. If the lookup fails or returns invalid JSON, report the error and stop
108
+ before writing any main spec or moving the change. A valid response with omitted
109
+ \`rules\` is the no-rules case. Apply returned \`rules\` only to the content and
110
+ form of main specs produced by this merge; do not use them as archive guidance,
111
+ change CLI behavior, or copy the rule text into any output file.
112
+
113
+ Then run the \`openspec-sync-specs\` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching \`specs\` instructions again. Do not delegate it to a background task — step 5 would move \`changeRoot\` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.
114
+
115
+ Then re-run the comparison from the top of this step against every capability that has a delta spec in \`artifactPaths.specs.existingOutputPaths\` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
116
+ - ADDED requirements present
117
+ - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
118
+ - REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving \`## Requirements\` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
119
+ - RENAMED requirements present under the new name and absent under the old one
120
+
121
+ If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and \`changeRoot\` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.
122
+
123
+ 5. **Perform the archive**
124
+
125
+ Create an \`archive\` directory under \`planningHome.changesDir\` if it doesn't exist:
126
+ \`\`\`bash
127
+ mkdir -p "<planningHome.changesDir>/archive"
128
+ \`\`\`
129
+
130
+ Generate the target name: use the change name as-is when it already starts with a \`YYYY-MM-DD-\` prefix; otherwise prepend the current date as \`YYYY-MM-DD-<change-name>\`. Never stack a second date (same rule as \`openspec archive\`).
131
+
132
+ **Check if target already exists:**
133
+ - If yes: Fail with error, suggest renaming existing archive or using different date
134
+ - If no: Move \`changeRoot\` to the archive directory
135
+
136
+ \`\`\`bash
137
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
138
+ \`\`\`
139
+
140
+ 6. **Display summary**
141
+
142
+ Show archive completion summary including:
143
+ - Change name
144
+ - Schema that was used
145
+ - Archive location
146
+ - Whether specs were synced (if applicable)
147
+ - Note about any warnings (incomplete artifacts/tasks)
148
+
149
+ **Output On Success**
150
+
151
+ \`\`\`markdown
152
+ ## Archive Complete
153
+
154
+ **Change:** <change-name>
155
+ **Schema:** <schema-name>
156
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
157
+ **Specs:** <"✓ Synced to main specs" only if the step 4 verification passed; otherwise "No delta specs" or "Sync skipped">
158
+
159
+ <"All artifacts complete. All tasks complete." — or, if archived with warnings, list them instead (e.g. "Archived with 2 incomplete tasks")>
160
+ \`\`\`
161
+
162
+ **Guardrails**
163
+ - Announce the selected change; prompt for selection when it is ambiguous
164
+ - Use artifact graph (openspec status --json) for completion checking
165
+ - Don't block archive on warnings - just inform and confirm
166
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
167
+ - Show clear summary of what happened
168
+ - If sync is requested, run the \`openspec-sync-specs\` workflow inline (agent-driven)
169
+ - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving \`changeRoot\`
170
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
171
+ - Apply relevant runtime context and report conflicts; operation guidance remains advisory
172
+ - Consider every guidance entry and explain any inapplicable or conflicting advice
173
+ - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
174
+ - Artifact rules constrain only the specs being written and are never operation guidance
175
+ - Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files`,
113
176
  license: 'MIT',
114
177
  compatibility: 'Requires openspec CLI.',
115
178
  metadata: { author: 'openspec', version: '1.0' },
@@ -121,159 +184,223 @@ export function getOpsxArchiveCommandTemplate() {
121
184
  description: 'Archive a completed change in the experimental workflow',
122
185
  category: 'Workflow',
123
186
  tags: ['workflow', 'archive', 'experimental'],
124
- content: `Archive a completed change in the experimental workflow.
125
-
126
- ${STORE_SELECTION_GUIDANCE}
127
-
128
- **Input**: Optionally specify a change name after \`/opsx:archive\` (e.g., \`/opsx:archive add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
129
-
130
- **Steps**
131
-
132
- 1. **If no change name provided, prompt for selection**
133
-
134
- ${PROMPT_SELECT_CHANGE}
135
-
136
- Show only active changes (not already archived).
137
- Include the schema used for each change if available.
138
-
139
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
140
-
141
- 2. **Check artifact completion status**
142
-
143
- Run \`openspec status --change "<name>" --json\` to check artifact completion.
144
-
145
- Parse the JSON to understand:
146
- - \`schemaName\`: The workflow being used
147
- - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
148
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
149
-
150
- **If any artifacts are not \`done\`:**
151
- - Display warning listing incomplete artifacts
152
- - Prompt user for confirmation to continue
153
- - Proceed if user confirms
154
-
155
- 3. **Check task completion status**
156
-
157
- Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
158
-
159
- Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
160
-
161
- **If incomplete tasks found:**
162
- - Display warning showing count of incomplete tasks
163
- - Prompt user for confirmation to continue
164
- - Proceed if user confirms
165
-
166
- **If no tasks file exists:** Proceed without task-related warning.
167
-
168
- 4. **Assess delta spec sync state**
169
-
170
- Use \`artifactPaths.specs.existingOutputPaths\` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
171
-
172
- **If delta specs exist:**
173
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
174
- - Determine what changes would be applied (adds, modifications, removals, renames)
175
- - Show a combined summary before prompting
176
-
177
- **Prompt options:**
178
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
179
- - If already synced: "Archive now", "Sync anyway", "Cancel"
180
-
181
- If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
182
-
183
- 5. **Perform the archive**
184
-
185
- Create an \`archive\` directory under \`planningHome.changesDir\` if it doesn't exist:
186
- \`\`\`bash
187
- mkdir -p "<planningHome.changesDir>/archive"
188
- \`\`\`
189
-
190
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
191
-
192
- **Check if target already exists:**
193
- - If yes: Fail with error, suggest renaming existing archive or using different date
194
- - If no: Move \`changeRoot\` to the archive directory
195
-
196
- \`\`\`bash
197
- mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
198
- \`\`\`
199
-
200
- 6. **Display summary**
201
-
202
- Show archive completion summary including:
203
- - Change name
204
- - Schema that was used
205
- - Archive location
206
- - Spec sync status (synced / sync skipped / no delta specs)
207
- - Note about any warnings (incomplete artifacts/tasks)
208
-
209
- **Output On Success**
210
-
211
- \`\`\`
212
- ## Archive Complete
213
-
214
- **Change:** <change-name>
215
- **Schema:** <schema-name>
216
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
217
- **Specs:** Synced to main specs
218
-
219
- All artifacts complete. All tasks complete.
220
- \`\`\`
221
-
222
- **Output On Success (No Delta Specs)**
223
-
224
- \`\`\`
225
- ## Archive Complete
226
-
227
- **Change:** <change-name>
228
- **Schema:** <schema-name>
229
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
230
- **Specs:** No delta specs
231
-
232
- All artifacts complete. All tasks complete.
233
- \`\`\`
234
-
235
- **Output On Success With Warnings**
236
-
237
- \`\`\`
238
- ## Archive Complete (with warnings)
239
-
240
- **Change:** <change-name>
241
- **Schema:** <schema-name>
242
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
243
- **Specs:** Sync skipped (user chose to skip)
244
-
245
- **Warnings:**
246
- - Archived with 2 incomplete artifacts
247
- - Archived with 3 incomplete tasks
248
- - Delta spec sync was skipped (user chose to skip)
249
-
250
- Review the archive if this was not intentional.
251
- \`\`\`
252
-
253
- **Output On Error (Archive Exists)**
254
-
255
- \`\`\`
256
- ## Archive Failed
257
-
258
- **Change:** <change-name>
259
- **Target:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
260
-
261
- Target archive directory already exists.
262
-
263
- **Options:**
264
- 1. Rename the existing archive
265
- 2. Delete the existing archive if it's a duplicate
266
- 3. Wait until a different date to archive
267
- \`\`\`
268
-
269
- **Guardrails**
270
- - Always prompt for change selection if not provided
271
- - Use artifact graph (openspec status --json) for completion checking
272
- - Don't block archive on warnings - just inform and confirm
273
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
274
- - Show clear summary of what happened
275
- - If sync is requested, use the Skill tool to invoke \`openspec-sync-specs\` (agent-driven)
276
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`
187
+ content: `Archive a completed change in the experimental workflow.
188
+
189
+ ${STORE_SELECTION_GUIDANCE}
190
+
191
+ \`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
192
+
193
+ **Input**: Optionally specify a change name after \`/opsx:archive\` (e.g., \`/opsx:archive add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
194
+
195
+ **Steps**
196
+
197
+ 1. **Select the change**
198
+
199
+ If a name is provided, use it. Otherwise:
200
+ - Infer from conversation context if the user mentioned a change
201
+ - Auto-select if only one active change exists
202
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
203
+
204
+ When prompting, show only active changes (not already archived).
205
+ Include the schema used for each change if available.
206
+
207
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:archive <other>\`).
208
+
209
+ **Load current archive inputs before the existing archive checks:**
210
+
211
+ After resolving the selected change and planning root, run:
212
+ \`\`\`bash
213
+ openspec instructions archive --change "<name>" --json
214
+ \`\`\`
215
+ Keep the same selected-root flags on this command. This lookup is advisory and
216
+ optional: it only supplies extra prompt inputs, so it must never block archiving.
217
+ If it exits non-zero or returns invalid JSON — for example on an older CLI that
218
+ does not support this command yet — continue the archive workflow with no
219
+ context and no operation guidance. Do not report an error and do not stop.
220
+
221
+ A successful response may omit both optional fields. Treat \`context\` as a
222
+ required prompt-level input: read and consider it, and apply relevant project
223
+ facts, conventions, and constraints. Treat \`operationGuidance\` as optional
224
+ additive advice: read and consider every entry, and follow entries that are
225
+ applicable and compatible with the built-in archive workflow.
226
+
227
+ Keep both fields separate from built-in steps, explicit user choices, resolved
228
+ paths, CLI checks, and command contracts. If context conflicts with one of those
229
+ controlling inputs, report the conflict and preserve the controlling value. If
230
+ guidance is inapplicable or conflicts with a controlling input, do not follow it
231
+ and explain why. Do not infer replacement paths, skipped prompts, or flags from
232
+ either field, and do not copy their text verbatim into specs, change artifacts,
233
+ or archive summaries unless the user separately asks for it. These are
234
+ prompt-level behavior contracts, not enforceable checks.
235
+
236
+ 2. **Check artifact completion status**
237
+
238
+ Run \`openspec status --change "<name>" --json\` to check artifact completion.
239
+
240
+ Parse the JSON to understand:
241
+ - \`schemaName\`: The workflow being used
242
+ - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
243
+ - \`artifacts\`: List of artifacts with their status (\`done\`, \`skipped\`, or other)
244
+
245
+ **If any artifacts are neither \`done\` nor \`skipped\`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
246
+ - Display warning listing incomplete artifacts
247
+ - Prompt user for confirmation to continue
248
+ - Proceed if user confirms
249
+
250
+ 3. **Check task completion status**
251
+
252
+ Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
253
+
254
+ Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
255
+
256
+ **If incomplete tasks found:**
257
+ - Display warning showing count of incomplete tasks
258
+ - Prompt user for confirmation to continue
259
+ - Proceed if user confirms
260
+
261
+ **If no tasks file exists:** Proceed without task-related warning.
262
+
263
+ 4. **Assess delta spec sync state**
264
+
265
+ Use \`artifactPaths.specs.existingOutputPaths\` from status JSON as the only
266
+ delta-spec source. If the \`specs\` entry is missing or
267
+ \`existingOutputPaths\` is empty, proceed without a sync prompt and do not infer
268
+ delta specs from other artifacts.
269
+
270
+ **If delta specs exist:**
271
+ - Compare each delta spec with its corresponding main spec at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (use the store-aware \`planningHome.root\` from step 2, not a hardcoded repo path)
272
+ - Determine what changes would be applied (adds, modifications, removals, renames)
273
+ - Show a combined summary before prompting
274
+
275
+ **Prompt options:**
276
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
277
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
278
+
279
+ Route on the answer:
280
+ - "Cancel" stop, do not archive
281
+ - "Archive without syncing" or "Archive now" — proceed to archive
282
+ - "Sync now" or "Sync anyway" — sync, then verify (below)
283
+ - Anything else — ask again rather than archiving
284
+
285
+ Before a selected sync writes any main spec, run
286
+ \`openspec instructions specs --change "<name>" --json\` once with the same
287
+ selected-root flags. Require a zero exit status and valid artifact-instruction
288
+ JSON. If the lookup fails or returns invalid JSON, report the error and stop
289
+ before writing any main spec or moving the change. A valid response with omitted
290
+ \`rules\` is the no-rules case. Apply returned \`rules\` only to the content and
291
+ form of main specs produced by this merge; do not use them as archive guidance,
292
+ change CLI behavior, or copy the rule text into any output file.
293
+
294
+ Then run the \`/opsx:sync\` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching \`specs\` instructions again. Do not delegate it to a background task — step 5 would move \`changeRoot\` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.
295
+
296
+ Then re-run the comparison from the top of this step against every capability that has a delta spec in \`artifactPaths.specs.existingOutputPaths\` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
297
+ - ADDED requirements present
298
+ - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
299
+ - REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving \`## Requirements\` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
300
+ - RENAMED requirements present under the new name and absent under the old one
301
+
302
+ If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and \`changeRoot\` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.
303
+
304
+ 5. **Perform the archive**
305
+
306
+ Create an \`archive\` directory under \`planningHome.changesDir\` if it doesn't exist:
307
+ \`\`\`bash
308
+ mkdir -p "<planningHome.changesDir>/archive"
309
+ \`\`\`
310
+
311
+ Generate the target name: use the change name as-is when it already starts with a \`YYYY-MM-DD-\` prefix; otherwise prepend the current date as \`YYYY-MM-DD-<change-name>\`. Never stack a second date (same rule as \`openspec archive\`).
312
+
313
+ **Check if target already exists:**
314
+ - If yes: Fail with error, suggest renaming existing archive or using different date
315
+ - If no: Move \`changeRoot\` to the archive directory
316
+
317
+ \`\`\`bash
318
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
319
+ \`\`\`
320
+
321
+ 6. **Display summary**
322
+
323
+ Show archive completion summary including:
324
+ - Change name
325
+ - Schema that was used
326
+ - Archive location
327
+ - Spec sync status (synced / sync skipped / no delta specs)
328
+ - Note about any warnings (incomplete artifacts/tasks)
329
+
330
+ **Output On Success**
331
+
332
+ \`\`\`markdown
333
+ ## Archive Complete
334
+
335
+ **Change:** <change-name>
336
+ **Schema:** <schema-name>
337
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
338
+ **Specs:** Synced to main specs
339
+
340
+ All artifacts complete. All tasks complete.
341
+ \`\`\`
342
+
343
+ **Output On Success (No Delta Specs)**
344
+
345
+ \`\`\`markdown
346
+ ## Archive Complete
347
+
348
+ **Change:** <change-name>
349
+ **Schema:** <schema-name>
350
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
351
+ **Specs:** No delta specs
352
+
353
+ All artifacts complete. All tasks complete.
354
+ \`\`\`
355
+
356
+ **Output On Success With Warnings**
357
+
358
+ \`\`\`markdown
359
+ ## Archive Complete (with warnings)
360
+
361
+ **Change:** <change-name>
362
+ **Schema:** <schema-name>
363
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
364
+ **Specs:** Sync skipped (user chose to skip)
365
+
366
+ **Warnings:**
367
+ - Archived with 2 incomplete artifacts
368
+ - Archived with 3 incomplete tasks
369
+ - Delta spec sync was skipped (user chose to skip)
370
+
371
+ Review the archive if this was not intentional.
372
+ \`\`\`
373
+
374
+ **Output On Error (Archive Exists)**
375
+
376
+ \`\`\`markdown
377
+ ## Archive Failed
378
+
379
+ **Change:** <change-name>
380
+ **Target:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
381
+
382
+ Target archive directory already exists.
383
+
384
+ **Options:**
385
+ 1. Rename the existing archive
386
+ 2. Delete the existing archive if it's a duplicate
387
+ 3. Wait until a different date to archive
388
+ \`\`\`
389
+
390
+ **Guardrails**
391
+ - Announce the selected change; prompt for selection when it is ambiguous
392
+ - Use artifact graph (openspec status --json) for completion checking
393
+ - Don't block archive on warnings - just inform and confirm
394
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
395
+ - Show clear summary of what happened
396
+ - If sync is requested, run the \`/opsx:sync\` workflow inline (agent-driven)
397
+ - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving \`changeRoot\`
398
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
399
+ - Apply relevant runtime context and report conflicts; operation guidance remains advisory
400
+ - Consider every guidance entry and explain any inapplicable or conflicting advice
401
+ - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
402
+ - Artifact rules constrain only the specs being written and are never operation guidance
403
+ - Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files`
277
404
  };
278
405
  }
279
406
  //# sourceMappingURL=archive-change.js.map