@fission-ai/openspec 1.6.0-beta.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +28 -1
  2. package/dist/cli/index.js +73 -7
  3. package/dist/commands/change.d.ts +0 -1
  4. package/dist/commands/change.js +90 -50
  5. package/dist/commands/config.js +14 -8
  6. package/dist/commands/doctor.js +9 -4
  7. package/dist/commands/feedback.js +74 -23
  8. package/dist/commands/schema.js +21 -11
  9. package/dist/commands/show.js +5 -2
  10. package/dist/commands/spec.js +20 -24
  11. package/dist/commands/validate.js +18 -3
  12. package/dist/commands/workflow/index.d.ts +1 -1
  13. package/dist/commands/workflow/index.js +1 -1
  14. package/dist/commands/workflow/instructions.d.ts +7 -1
  15. package/dist/commands/workflow/instructions.js +89 -6
  16. package/dist/commands/workflow/shared.d.ts +13 -2
  17. package/dist/commands/workflow/shared.js +34 -4
  18. package/dist/commands/workflow/status.js +7 -2
  19. package/dist/core/archive.d.ts +0 -1
  20. package/dist/core/archive.js +96 -33
  21. package/dist/core/artifact-graph/graph.d.ts +16 -0
  22. package/dist/core/artifact-graph/graph.js +30 -6
  23. package/dist/core/artifact-graph/instruction-loader.d.ts +27 -2
  24. package/dist/core/artifact-graph/instruction-loader.js +55 -7
  25. package/dist/core/artifact-graph/resolver.d.ts +14 -0
  26. package/dist/core/artifact-graph/resolver.js +34 -6
  27. package/dist/core/change-metadata/schema.d.ts +1 -0
  28. package/dist/core/change-metadata/schema.js +6 -0
  29. package/dist/core/change-status-policy.d.ts +1 -1
  30. package/dist/core/command-generation/adapters/amazon-q.d.ts +4 -0
  31. package/dist/core/command-generation/adapters/amazon-q.js +7 -1
  32. package/dist/core/command-generation/adapters/antigravity.js +2 -1
  33. package/dist/core/command-generation/adapters/auggie.js +2 -1
  34. package/dist/core/command-generation/adapters/bob.d.ts +5 -1
  35. package/dist/core/command-generation/adapters/bob.js +6 -5
  36. package/dist/core/command-generation/adapters/claude.js +1 -8
  37. package/dist/core/command-generation/adapters/codebuddy.js +3 -2
  38. package/dist/core/command-generation/adapters/continue.js +3 -2
  39. package/dist/core/command-generation/adapters/costrict.js +2 -1
  40. package/dist/core/command-generation/adapters/crush.js +5 -5
  41. package/dist/core/command-generation/adapters/cursor.js +2 -2
  42. package/dist/core/command-generation/adapters/devin.d.ts +19 -0
  43. package/dist/core/command-generation/adapters/devin.js +36 -0
  44. package/dist/core/command-generation/adapters/factory.js +2 -1
  45. package/dist/core/command-generation/adapters/gemini.js +37 -2
  46. package/dist/core/command-generation/adapters/github-copilot.js +2 -1
  47. package/dist/core/command-generation/adapters/iflow.js +5 -4
  48. package/dist/core/command-generation/adapters/index.d.ts +2 -2
  49. package/dist/core/command-generation/adapters/index.js +2 -2
  50. package/dist/core/command-generation/adapters/junie.js +2 -1
  51. package/dist/core/command-generation/adapters/kiro.js +2 -1
  52. package/dist/core/command-generation/adapters/lingma.js +5 -5
  53. package/dist/core/command-generation/adapters/oh-my-pi.d.ts +2 -2
  54. package/dist/core/command-generation/adapters/oh-my-pi.js +3 -5
  55. package/dist/core/command-generation/adapters/opencode.js +3 -5
  56. package/dist/core/command-generation/adapters/pi.d.ts +2 -2
  57. package/dist/core/command-generation/adapters/pi.js +3 -6
  58. package/dist/core/command-generation/adapters/qoder.js +5 -5
  59. package/dist/core/command-generation/adapters/qwen.d.ts +7 -3
  60. package/dist/core/command-generation/adapters/qwen.js +12 -7
  61. package/dist/core/command-generation/adapters/roocode.d.ts +4 -4
  62. package/dist/core/command-generation/adapters/roocode.js +4 -4
  63. package/dist/core/command-generation/adapters/trae.js +1 -21
  64. package/dist/core/command-generation/adapters/zcode.d.ts +16 -0
  65. package/dist/core/command-generation/adapters/zcode.js +33 -0
  66. package/dist/core/command-generation/generator.d.ts +8 -0
  67. package/dist/core/command-generation/generator.js +15 -1
  68. package/dist/core/command-generation/index.d.ts +1 -1
  69. package/dist/core/command-generation/index.js +1 -1
  70. package/dist/core/command-generation/invocation.d.ts +73 -0
  71. package/dist/core/command-generation/invocation.js +77 -0
  72. package/dist/core/command-generation/registry.js +4 -4
  73. package/dist/core/command-generation/types.d.ts +9 -2
  74. package/dist/core/command-generation/yaml.d.ts +20 -6
  75. package/dist/core/command-generation/yaml.js +31 -21
  76. package/dist/core/command-surface.d.ts +15 -0
  77. package/dist/core/command-surface.js +33 -0
  78. package/dist/core/completions/command-registry.js +8 -2
  79. package/dist/core/completions/generators/powershell-generator.js +15 -8
  80. package/dist/core/completions/installers/zsh-installer.d.ts +9 -0
  81. package/dist/core/completions/installers/zsh-installer.js +20 -4
  82. package/dist/core/config-prompts.d.ts +1 -1
  83. package/dist/core/config-prompts.js +14 -1
  84. package/dist/core/config-schema.d.ts +7 -1
  85. package/dist/core/config-schema.js +40 -1
  86. package/dist/core/config.d.ts +12 -0
  87. package/dist/core/config.js +21 -3
  88. package/dist/core/global-config.d.ts +5 -0
  89. package/dist/core/init.d.ts +35 -0
  90. package/dist/core/init.js +225 -39
  91. package/dist/core/legacy-cleanup.d.ts +59 -0
  92. package/dist/core/legacy-cleanup.js +249 -22
  93. package/dist/core/list.js +5 -7
  94. package/dist/core/migration.d.ts +71 -1
  95. package/dist/core/migration.js +294 -1
  96. package/dist/core/onboarding-commands.d.ts +30 -0
  97. package/dist/core/onboarding-commands.js +38 -0
  98. package/dist/core/parsers/change-parser.d.ts +17 -2
  99. package/dist/core/parsers/change-parser.js +33 -20
  100. package/dist/core/parsers/code-fence.d.ts +15 -0
  101. package/dist/core/parsers/code-fence.js +49 -0
  102. package/dist/core/parsers/markdown-parser.js +2 -1
  103. package/dist/core/parsers/requirement-blocks.d.ts +8 -0
  104. package/dist/core/parsers/requirement-blocks.js +60 -35
  105. package/dist/core/parsers/requirement-text.d.ts +1 -8
  106. package/dist/core/parsers/requirement-text.js +4 -42
  107. package/dist/core/parsers/spec-structure.js +3 -29
  108. package/dist/core/profile-sync-drift.d.ts +0 -8
  109. package/dist/core/profile-sync-drift.js +9 -45
  110. package/dist/core/project-config.d.ts +25 -6
  111. package/dist/core/project-config.js +77 -7
  112. package/dist/core/references.js +42 -4
  113. package/dist/core/relationship-health.d.ts +8 -0
  114. package/dist/core/relationship-health.js +13 -0
  115. package/dist/core/root-selection.d.ts +9 -6
  116. package/dist/core/root-selection.js +42 -5
  117. package/dist/core/shared/tool-detection.d.ts +25 -5
  118. package/dist/core/shared/tool-detection.js +105 -6
  119. package/dist/core/specs-apply.d.ts +8 -33
  120. package/dist/core/specs-apply.js +252 -157
  121. package/dist/core/store/git.d.ts +13 -0
  122. package/dist/core/store/git.js +24 -0
  123. package/dist/core/templates/workflows/apply-change.js +54 -4
  124. package/dist/core/templates/workflows/archive-change.js +166 -42
  125. package/dist/core/templates/workflows/bulk-archive-change.js +240 -63
  126. package/dist/core/templates/workflows/continue-change.js +32 -40
  127. package/dist/core/templates/workflows/explore.js +12 -0
  128. package/dist/core/templates/workflows/ff-change.js +46 -30
  129. package/dist/core/templates/workflows/new-change.js +2 -2
  130. package/dist/core/templates/workflows/onboard.js +4 -4
  131. package/dist/core/templates/workflows/propose.js +50 -32
  132. package/dist/core/templates/workflows/store-selection.d.ts +1 -1
  133. package/dist/core/templates/workflows/store-selection.js +1 -1
  134. package/dist/core/templates/workflows/sync-specs.js +172 -22
  135. package/dist/core/templates/workflows/update-change.js +20 -12
  136. package/dist/core/templates/workflows/verify-change.js +16 -10
  137. package/dist/core/update.d.ts +39 -5
  138. package/dist/core/update.js +288 -71
  139. package/dist/core/validation/constants.d.ts +4 -1
  140. package/dist/core/validation/constants.js +4 -1
  141. package/dist/core/validation/validator.d.ts +1 -7
  142. package/dist/core/validation/validator.js +92 -36
  143. package/dist/core/version-check.d.ts +152 -0
  144. package/dist/core/version-check.js +736 -0
  145. package/dist/core/view.js +12 -17
  146. package/dist/prompts/searchable-multi-select.js +1 -1
  147. package/dist/telemetry/index.d.ts +1 -1
  148. package/dist/telemetry/index.js +55 -33
  149. package/dist/ui/welcome-screen.d.ts +9 -1
  150. package/dist/ui/welcome-screen.js +91 -38
  151. package/dist/utils/change-metadata.d.ts +30 -0
  152. package/dist/utils/change-metadata.js +101 -7
  153. package/dist/utils/change-utils.d.ts +10 -4
  154. package/dist/utils/change-utils.js +20 -13
  155. package/dist/utils/command-references.d.ts +80 -6
  156. package/dist/utils/command-references.js +138 -7
  157. package/dist/utils/date.d.ts +8 -0
  158. package/dist/utils/date.js +13 -0
  159. package/dist/utils/index.d.ts +1 -1
  160. package/dist/utils/index.js +1 -1
  161. package/dist/utils/item-discovery.d.ts +19 -0
  162. package/dist/utils/item-discovery.js +30 -48
  163. package/dist/utils/shell-detection.d.ts +1 -1
  164. package/dist/utils/shell-detection.js +64 -11
  165. package/dist/utils/spec-discovery.d.ts +40 -0
  166. package/dist/utils/spec-discovery.js +102 -0
  167. package/package.json +29 -30
  168. package/schemas/spec-driven/schema.yaml +60 -5
  169. package/schemas/spec-driven/templates/design.md +2 -2
  170. package/schemas/spec-driven/templates/proposal.md +5 -1
  171. package/schemas/spec-driven/templates/spec.md +3 -0
  172. package/dist/core/command-generation/adapters/codex.d.ts +0 -16
  173. package/dist/core/command-generation/adapters/codex.js +0 -39
  174. package/dist/core/command-generation/adapters/windsurf.d.ts +0 -14
  175. package/dist/core/command-generation/adapters/windsurf.js +0 -38
@@ -16,7 +16,7 @@ ${STORE_SELECTION_GUIDANCE}
16
16
  If a name is provided, use it. Otherwise:
17
17
  - Infer from conversation context if the user mentioned a change
18
18
  - Auto-select if only one active change exists
19
- - If ambiguous, run \`openspec list --json\` to get available changes and use the **AskUserQuestion tool** to let the user select
19
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
20
20
 
21
21
  Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:apply <other>\`).
22
22
 
@@ -40,12 +40,29 @@ ${STORE_SELECTION_GUIDANCE}
40
40
  - Progress (total, complete, remaining)
41
41
  - Task list with status
42
42
  - Dynamic instruction based on current state
43
+ - Optional \`context\`: current required project instruction input from the selected root
44
+ - Optional \`operationGuidance\`: current advisory guidance for apply
43
45
 
44
46
  **Handle states:**
45
- - If \`state: "blocked"\` (missing artifacts): show message, suggest using openspec-continue-change
47
+ - If \`state: "blocked"\` (missing artifacts): show message, suggest using openspec-continue-change (if it is not installed, run \`openspec status --change "<name>" --json\` to see the next artifact and \`openspec instructions <artifact-id> --change "<name>" --json\` for how to create it)
46
48
  - If \`state: "all_done"\`: congratulate, suggest archive
47
49
  - Otherwise: proceed to implementation
48
50
 
51
+ Treat \`context\` as a required prompt-level input. Read and consider it, and
52
+ apply relevant project facts, conventions, and constraints while implementing.
53
+ Treat \`operationGuidance\` as optional additive advice. Read and consider every
54
+ entry, and follow entries that are applicable and compatible with the built-in
55
+ workflow.
56
+
57
+ Keep both fields separate from CLI-returned state, missing artifacts, tasks,
58
+ progress, \`contextFiles\`, and the built-in \`instruction\`. They are not
59
+ evidence of task completion, do not replace the built-in instruction, and do
60
+ not permit bypassing a blocked state. If context conflicts with the built-in
61
+ instruction, an explicit user choice, or a CLI-controlled value, report the
62
+ conflict and preserve the controlling value. If guidance is inapplicable or
63
+ conflicts with those controlling inputs, do not follow it and explain why.
64
+ These are prompt-level behavior contracts, not enforceable checks.
65
+
49
66
  4. **Read context files**
50
67
 
51
68
  Read every file path listed under \`contextFiles\` from the apply instructions output.
@@ -53,6 +70,9 @@ ${STORE_SELECTION_GUIDANCE}
53
70
  - **spec-driven**: proposal, specs, design, tasks
54
71
  - Other schemas: follow the contextFiles from CLI output
55
72
 
73
+ Do not copy \`context\` or \`operationGuidance\` verbatim into implementation
74
+ files or planning artifacts unless the user separately asks for that content.
75
+
56
76
  5. **Show current progress**
57
77
 
58
78
  Display:
@@ -144,6 +164,11 @@ What would you like to do?
144
164
  - Update task checkbox immediately after completing each task
145
165
  - Pause on errors, blockers, or unclear requirements - don't guess
146
166
  - Use contextFiles from CLI output, don't assume specific file names
167
+ - Do not use context or operation guidance as proof that a task is complete
168
+ - Apply relevant project context; report conflicts with controlling workflow inputs
169
+ - Consider every guidance entry; explain any inapplicable or conflicting advice
170
+ - Do not copy runtime context or operation guidance into implementation files or planning artifacts
171
+ - Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
147
172
 
148
173
  **Fluid Workflow Integration**
149
174
 
@@ -175,7 +200,7 @@ ${STORE_SELECTION_GUIDANCE}
175
200
  If a name is provided, use it. Otherwise:
176
201
  - Infer from conversation context if the user mentioned a change
177
202
  - Auto-select if only one active change exists
178
- - If ambiguous, run \`openspec list --json\` to get available changes and use the **AskUserQuestion tool** to let the user select
203
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
179
204
 
180
205
  Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:apply <other>\`).
181
206
 
@@ -199,12 +224,29 @@ ${STORE_SELECTION_GUIDANCE}
199
224
  - Progress (total, complete, remaining)
200
225
  - Task list with status
201
226
  - Dynamic instruction based on current state
227
+ - Optional \`context\`: current required project instruction input from the selected root
228
+ - Optional \`operationGuidance\`: current advisory guidance for apply
202
229
 
203
230
  **Handle states:**
204
- - If \`state: "blocked"\` (missing artifacts): show message, suggest using \`/opsx:continue\`
231
+ - If \`state: "blocked"\` (missing artifacts): show message, suggest using \`/opsx:continue\` (if it is not installed, run \`openspec status --change "<name>" --json\` to see the next artifact and \`openspec instructions <artifact-id> --change "<name>" --json\` for how to create it)
205
232
  - If \`state: "all_done"\`: congratulate, suggest archive
206
233
  - Otherwise: proceed to implementation
207
234
 
235
+ Treat \`context\` as a required prompt-level input. Read and consider it, and
236
+ apply relevant project facts, conventions, and constraints while implementing.
237
+ Treat \`operationGuidance\` as optional additive advice. Read and consider every
238
+ entry, and follow entries that are applicable and compatible with the built-in
239
+ workflow.
240
+
241
+ Keep both fields separate from CLI-returned state, missing artifacts, tasks,
242
+ progress, \`contextFiles\`, and the built-in \`instruction\`. They are not
243
+ evidence of task completion, do not replace the built-in instruction, and do
244
+ not permit bypassing a blocked state. If context conflicts with the built-in
245
+ instruction, an explicit user choice, or a CLI-controlled value, report the
246
+ conflict and preserve the controlling value. If guidance is inapplicable or
247
+ conflicts with those controlling inputs, do not follow it and explain why.
248
+ These are prompt-level behavior contracts, not enforceable checks.
249
+
208
250
  4. **Read context files**
209
251
 
210
252
  Read every file path listed under \`contextFiles\` from the apply instructions output.
@@ -212,6 +254,9 @@ ${STORE_SELECTION_GUIDANCE}
212
254
  - **spec-driven**: proposal, specs, design, tasks
213
255
  - Other schemas: follow the contextFiles from CLI output
214
256
 
257
+ Do not copy \`context\` or \`operationGuidance\` verbatim into implementation
258
+ files or planning artifacts unless the user separately asks for that content.
259
+
215
260
  5. **Show current progress**
216
261
 
217
262
  Display:
@@ -303,6 +348,11 @@ What would you like to do?
303
348
  - Update task checkbox immediately after completing each task
304
349
  - Pause on errors, blockers, or unclear requirements - don't guess
305
350
  - Use contextFiles from CLI output, don't assume specific file names
351
+ - Do not use context or operation guidance as proof that a task is complete
352
+ - Apply relevant project context; report conflicts with controlling workflow inputs
353
+ - Consider every guidance entry; explain any inapplicable or conflicting advice
354
+ - Do not copy runtime context or operation guidance into implementation files or planning artifacts
355
+ - Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
306
356
 
307
357
  **Fluid Workflow Integration**
308
358
 
@@ -11,14 +11,44 @@ ${STORE_SELECTION_GUIDANCE}
11
11
 
12
12
  **Steps**
13
13
 
14
- 1. **If no change name provided, prompt for selection**
14
+ 1. **Select the change**
15
15
 
16
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
16
+ If a name is provided, use it. Otherwise:
17
+ - Infer from conversation context if the user mentioned a change
18
+ - Auto-select if only one active change exists
19
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
17
20
 
18
- Show only active changes (not already archived).
21
+ When prompting, show only active changes (not already archived).
19
22
  Include the schema used for each change if available.
20
23
 
21
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
24
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:archive <other>\`).
25
+
26
+ **Load current archive inputs before the existing archive checks:**
27
+
28
+ After resolving the selected change and planning root, run:
29
+ \`\`\`bash
30
+ openspec instructions archive --change "<name>" --json
31
+ \`\`\`
32
+ Keep the same selected-root flags on this command. This lookup is advisory and
33
+ optional: it only supplies extra prompt inputs, so it must never block archiving.
34
+ If it exits non-zero or returns invalid JSON — for example on an older CLI that
35
+ does not support this command yet — continue the archive workflow with no
36
+ context and no operation guidance. Do not report an error and do not stop.
37
+
38
+ A successful response may omit both optional fields. Treat \`context\` as a
39
+ required prompt-level input: read and consider it, and apply relevant project
40
+ facts, conventions, and constraints. Treat \`operationGuidance\` as optional
41
+ additive advice: read and consider every entry, and follow entries that are
42
+ applicable and compatible with the built-in archive workflow.
43
+
44
+ Keep both fields separate from built-in steps, explicit user choices, resolved
45
+ paths, CLI checks, and command contracts. If context conflicts with one of those
46
+ controlling inputs, report the conflict and preserve the controlling value. If
47
+ guidance is inapplicable or conflicts with a controlling input, do not follow it
48
+ and explain why. Do not infer replacement paths, skipped prompts, or flags from
49
+ either field, and do not copy their text verbatim into specs, change artifacts,
50
+ or archive summaries unless the user separately asks for it. These are
51
+ prompt-level behavior contracts, not enforceable checks.
22
52
 
23
53
  2. **Check artifact completion status**
24
54
 
@@ -27,11 +57,11 @@ ${STORE_SELECTION_GUIDANCE}
27
57
  Parse the JSON to understand:
28
58
  - \`schemaName\`: The workflow being used
29
59
  - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
30
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
60
+ - \`artifacts\`: List of artifacts with their status (\`done\`, \`skipped\`, or other)
31
61
 
32
- **If any artifacts are not \`done\`:**
62
+ **If any artifacts are neither \`done\` nor \`skipped\`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
33
63
  - Display warning listing incomplete artifacts
34
- - Use **AskUserQuestion tool** to confirm user wants to proceed
64
+ - Ask the user to confirm they want to proceed
35
65
  - Proceed if user confirms
36
66
 
37
67
  3. **Check task completion status**
@@ -42,17 +72,20 @@ ${STORE_SELECTION_GUIDANCE}
42
72
 
43
73
  **If incomplete tasks found:**
44
74
  - Display warning showing count of incomplete tasks
45
- - Use **AskUserQuestion tool** to confirm user wants to proceed
75
+ - Ask the user to confirm they want to proceed
46
76
  - Proceed if user confirms
47
77
 
48
78
  **If no tasks file exists:** Proceed without task-related warning.
49
79
 
50
80
  4. **Assess delta spec sync state**
51
81
 
52
- Use \`artifactPaths.specs.existingOutputPaths\` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
82
+ Use \`artifactPaths.specs.existingOutputPaths\` from status JSON as the only
83
+ delta-spec source. If the \`specs\` entry is missing or
84
+ \`existingOutputPaths\` is empty, proceed without a sync prompt and do not infer
85
+ delta specs from other artifacts.
53
86
 
54
87
  **If delta specs exist:**
55
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
88
+ - Compare each delta spec with its corresponding main spec at \`<planningHome.root>/openspec/specs/<capability>/spec.md\` (use the store-aware \`planningHome.root\` from step 2, not a hardcoded repo path)
56
89
  - Determine what changes would be applied (adds, modifications, removals, renames)
57
90
  - Show a combined summary before prompting
58
91
 
@@ -60,7 +93,30 @@ ${STORE_SELECTION_GUIDANCE}
60
93
  - If changes needed: "Sync now (recommended)", "Archive without syncing"
61
94
  - If already synced: "Archive now", "Sync anyway", "Cancel"
62
95
 
63
- 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.
96
+ Route on the answer:
97
+ - "Cancel" — stop, do not archive
98
+ - "Archive without syncing" or "Archive now" — proceed to archive
99
+ - "Sync now" or "Sync anyway" — sync, then verify (below)
100
+ - Anything else — ask again rather than archiving
101
+
102
+ Before a selected sync writes any main spec, run
103
+ \`openspec instructions specs --change "<name>" --json\` once with the same
104
+ selected-root flags. Require a zero exit status and valid artifact-instruction
105
+ JSON. If the lookup fails or returns invalid JSON, report the error and stop
106
+ before writing any main spec or moving the change. A valid response with omitted
107
+ \`rules\` is the no-rules case. Apply returned \`rules\` only to the content and
108
+ form of main specs produced by this merge; do not use them as archive guidance,
109
+ change CLI behavior, or copy the rule text into any output file.
110
+
111
+ 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.
112
+
113
+ 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:
114
+ - ADDED requirements present
115
+ - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
116
+ - REMOVED requirements gone
117
+ - RENAMED requirements present under the new name and absent under the old one
118
+
119
+ 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.
64
120
 
65
121
  5. **Perform the archive**
66
122
 
@@ -69,14 +125,14 @@ ${STORE_SELECTION_GUIDANCE}
69
125
  mkdir -p "<planningHome.changesDir>/archive"
70
126
  \`\`\`
71
127
 
72
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
128
+ 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\`).
73
129
 
74
130
  **Check if target already exists:**
75
131
  - If yes: Fail with error, suggest renaming existing archive or using different date
76
132
  - If no: Move \`changeRoot\` to the archive directory
77
133
 
78
134
  \`\`\`bash
79
- mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
135
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
80
136
  \`\`\`
81
137
 
82
138
  6. **Display summary**
@@ -90,25 +146,31 @@ ${STORE_SELECTION_GUIDANCE}
90
146
 
91
147
  **Output On Success**
92
148
 
93
- \`\`\`
149
+ \`\`\`markdown
94
150
  ## Archive Complete
95
151
 
96
152
  **Change:** <change-name>
97
153
  **Schema:** <schema-name>
98
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
99
- **Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
154
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
155
+ **Specs:** <"✓ Synced to main specs" only if the step 4 verification passed; otherwise "No delta specs" or "Sync skipped">
100
156
 
101
- All artifacts complete. All tasks complete.
157
+ <"All artifacts complete. All tasks complete." — or, if archived with warnings, list them instead (e.g. "Archived with 2 incomplete tasks")>
102
158
  \`\`\`
103
159
 
104
160
  **Guardrails**
105
- - Always prompt for change selection if not provided
161
+ - Announce the selected change; prompt for selection when it is ambiguous
106
162
  - Use artifact graph (openspec status --json) for completion checking
107
163
  - Don't block archive on warnings - just inform and confirm
108
164
  - Preserve .openspec.yaml when moving to archive (it moves with the directory)
109
165
  - Show clear summary of what happened
110
- - If sync is requested, use openspec-sync-specs approach (agent-driven)
111
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`,
166
+ - If sync is requested, run the \`openspec-sync-specs\` workflow inline (agent-driven)
167
+ - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving \`changeRoot\`
168
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
169
+ - Apply relevant runtime context and report conflicts; operation guidance remains advisory
170
+ - Consider every guidance entry and explain any inapplicable or conflicting advice
171
+ - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
172
+ - Artifact rules constrain only the specs being written and are never operation guidance
173
+ - Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files`,
112
174
  license: 'MIT',
113
175
  compatibility: 'Requires openspec CLI.',
114
176
  metadata: { author: 'openspec', version: '1.0' },
@@ -128,14 +190,44 @@ ${STORE_SELECTION_GUIDANCE}
128
190
 
129
191
  **Steps**
130
192
 
131
- 1. **If no change name provided, prompt for selection**
193
+ 1. **Select the change**
132
194
 
133
- Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
195
+ If a name is provided, use it. Otherwise:
196
+ - Infer from conversation context if the user mentioned a change
197
+ - Auto-select if only one active change exists
198
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
134
199
 
135
- Show only active changes (not already archived).
200
+ When prompting, show only active changes (not already archived).
136
201
  Include the schema used for each change if available.
137
202
 
138
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
203
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:archive <other>\`).
204
+
205
+ **Load current archive inputs before the existing archive checks:**
206
+
207
+ After resolving the selected change and planning root, run:
208
+ \`\`\`bash
209
+ openspec instructions archive --change "<name>" --json
210
+ \`\`\`
211
+ Keep the same selected-root flags on this command. This lookup is advisory and
212
+ optional: it only supplies extra prompt inputs, so it must never block archiving.
213
+ If it exits non-zero or returns invalid JSON — for example on an older CLI that
214
+ does not support this command yet — continue the archive workflow with no
215
+ context and no operation guidance. Do not report an error and do not stop.
216
+
217
+ A successful response may omit both optional fields. Treat \`context\` as a
218
+ required prompt-level input: read and consider it, and apply relevant project
219
+ facts, conventions, and constraints. Treat \`operationGuidance\` as optional
220
+ additive advice: read and consider every entry, and follow entries that are
221
+ applicable and compatible with the built-in archive workflow.
222
+
223
+ Keep both fields separate from built-in steps, explicit user choices, resolved
224
+ paths, CLI checks, and command contracts. If context conflicts with one of those
225
+ controlling inputs, report the conflict and preserve the controlling value. If
226
+ guidance is inapplicable or conflicts with a controlling input, do not follow it
227
+ and explain why. Do not infer replacement paths, skipped prompts, or flags from
228
+ either field, and do not copy their text verbatim into specs, change artifacts,
229
+ or archive summaries unless the user separately asks for it. These are
230
+ prompt-level behavior contracts, not enforceable checks.
139
231
 
140
232
  2. **Check artifact completion status**
141
233
 
@@ -144,9 +236,9 @@ ${STORE_SELECTION_GUIDANCE}
144
236
  Parse the JSON to understand:
145
237
  - \`schemaName\`: The workflow being used
146
238
  - \`planningHome\`, \`changeRoot\`, \`artifactPaths\`, and \`actionContext\`: path and scope context
147
- - \`artifacts\`: List of artifacts with their status (\`done\` or other)
239
+ - \`artifacts\`: List of artifacts with their status (\`done\`, \`skipped\`, or other)
148
240
 
149
- **If any artifacts are not \`done\`:**
241
+ **If any artifacts are neither \`done\` nor \`skipped\`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
150
242
  - Display warning listing incomplete artifacts
151
243
  - Prompt user for confirmation to continue
152
244
  - Proceed if user confirms
@@ -166,10 +258,13 @@ ${STORE_SELECTION_GUIDANCE}
166
258
 
167
259
  4. **Assess delta spec sync state**
168
260
 
169
- Use \`artifactPaths.specs.existingOutputPaths\` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
261
+ Use \`artifactPaths.specs.existingOutputPaths\` from status JSON as the only
262
+ delta-spec source. If the \`specs\` entry is missing or
263
+ \`existingOutputPaths\` is empty, proceed without a sync prompt and do not infer
264
+ delta specs from other artifacts.
170
265
 
171
266
  **If delta specs exist:**
172
- - Compare each delta spec with its corresponding main spec at \`openspec/specs/<capability>/spec.md\`
267
+ - Compare each delta spec with its corresponding main spec at \`<planningHome.root>/openspec/specs/<capability>/spec.md\` (use the store-aware \`planningHome.root\` from step 2, not a hardcoded repo path)
173
268
  - Determine what changes would be applied (adds, modifications, removals, renames)
174
269
  - Show a combined summary before prompting
175
270
 
@@ -177,7 +272,30 @@ ${STORE_SELECTION_GUIDANCE}
177
272
  - If changes needed: "Sync now (recommended)", "Archive without syncing"
178
273
  - If already synced: "Archive now", "Sync anyway", "Cancel"
179
274
 
180
- 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.
275
+ Route on the answer:
276
+ - "Cancel" — stop, do not archive
277
+ - "Archive without syncing" or "Archive now" — proceed to archive
278
+ - "Sync now" or "Sync anyway" — sync, then verify (below)
279
+ - Anything else — ask again rather than archiving
280
+
281
+ Before a selected sync writes any main spec, run
282
+ \`openspec instructions specs --change "<name>" --json\` once with the same
283
+ selected-root flags. Require a zero exit status and valid artifact-instruction
284
+ JSON. If the lookup fails or returns invalid JSON, report the error and stop
285
+ before writing any main spec or moving the change. A valid response with omitted
286
+ \`rules\` is the no-rules case. Apply returned \`rules\` only to the content and
287
+ form of main specs produced by this merge; do not use them as archive guidance,
288
+ change CLI behavior, or copy the rule text into any output file.
289
+
290
+ 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.
291
+
292
+ 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:
293
+ - ADDED requirements present
294
+ - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
295
+ - REMOVED requirements gone
296
+ - RENAMED requirements present under the new name and absent under the old one
297
+
298
+ 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.
181
299
 
182
300
  5. **Perform the archive**
183
301
 
@@ -186,14 +304,14 @@ ${STORE_SELECTION_GUIDANCE}
186
304
  mkdir -p "<planningHome.changesDir>/archive"
187
305
  \`\`\`
188
306
 
189
- Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
307
+ 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\`).
190
308
 
191
309
  **Check if target already exists:**
192
310
  - If yes: Fail with error, suggest renaming existing archive or using different date
193
311
  - If no: Move \`changeRoot\` to the archive directory
194
312
 
195
313
  \`\`\`bash
196
- mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
314
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
197
315
  \`\`\`
198
316
 
199
317
  6. **Display summary**
@@ -207,12 +325,12 @@ ${STORE_SELECTION_GUIDANCE}
207
325
 
208
326
  **Output On Success**
209
327
 
210
- \`\`\`
328
+ \`\`\`markdown
211
329
  ## Archive Complete
212
330
 
213
331
  **Change:** <change-name>
214
332
  **Schema:** <schema-name>
215
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
333
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
216
334
  **Specs:** ✓ Synced to main specs
217
335
 
218
336
  All artifacts complete. All tasks complete.
@@ -220,12 +338,12 @@ All artifacts complete. All tasks complete.
220
338
 
221
339
  **Output On Success (No Delta Specs)**
222
340
 
223
- \`\`\`
341
+ \`\`\`markdown
224
342
  ## Archive Complete
225
343
 
226
344
  **Change:** <change-name>
227
345
  **Schema:** <schema-name>
228
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
346
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
229
347
  **Specs:** No delta specs
230
348
 
231
349
  All artifacts complete. All tasks complete.
@@ -233,12 +351,12 @@ All artifacts complete. All tasks complete.
233
351
 
234
352
  **Output On Success With Warnings**
235
353
 
236
- \`\`\`
354
+ \`\`\`markdown
237
355
  ## Archive Complete (with warnings)
238
356
 
239
357
  **Change:** <change-name>
240
358
  **Schema:** <schema-name>
241
- **Archived to:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
359
+ **Archived to:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
242
360
  **Specs:** Sync skipped (user chose to skip)
243
361
 
244
362
  **Warnings:**
@@ -251,11 +369,11 @@ Review the archive if this was not intentional.
251
369
 
252
370
  **Output On Error (Archive Exists)**
253
371
 
254
- \`\`\`
372
+ \`\`\`markdown
255
373
  ## Archive Failed
256
374
 
257
375
  **Change:** <change-name>
258
- **Target:** the archive path derived from \`planningHome.changesDir\`/YYYY-MM-DD-<name>/
376
+ **Target:** the archive path derived from \`planningHome.changesDir\`/<target-name>/
259
377
 
260
378
  Target archive directory already exists.
261
379
 
@@ -266,13 +384,19 @@ Target archive directory already exists.
266
384
  \`\`\`
267
385
 
268
386
  **Guardrails**
269
- - Always prompt for change selection if not provided
387
+ - Announce the selected change; prompt for selection when it is ambiguous
270
388
  - Use artifact graph (openspec status --json) for completion checking
271
389
  - Don't block archive on warnings - just inform and confirm
272
390
  - Preserve .openspec.yaml when moving to archive (it moves with the directory)
273
391
  - Show clear summary of what happened
274
- - If sync is requested, use the Skill tool to invoke \`openspec-sync-specs\` (agent-driven)
275
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting`
392
+ - If sync is requested, run the \`/opsx:sync\` workflow inline (agent-driven)
393
+ - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving \`changeRoot\`
394
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
395
+ - Apply relevant runtime context and report conflicts; operation guidance remains advisory
396
+ - Consider every guidance entry and explain any inapplicable or conflicting advice
397
+ - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
398
+ - Artifact rules constrain only the specs being written and are never operation guidance
399
+ - Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files`
276
400
  };
277
401
  }
278
402
  //# sourceMappingURL=archive-change.js.map