@jspg-ai/coding-bb 0.0.3-beta.6 → 0.0.3-beta.7

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 (76) hide show
  1. package/cbb/lib/install/init.js +60 -23
  2. package/cbb/lib/openspec/index.js +337 -554
  3. package/cbb/lib/superpowers/index.js +246 -265
  4. package/cbb/lib/utils/tar.js +92 -0
  5. package/cbb/lib/utils/upstream.js +90 -0
  6. package/config/upstream-mirrors.json +12 -0
  7. package/openspec/.version +2 -3
  8. package/openspec/commands/apply.md +189 -175
  9. package/openspec/commands/archive.md +237 -216
  10. package/openspec/commands/bulk-archive.md +355 -327
  11. package/openspec/commands/continue.md +116 -105
  12. package/openspec/commands/explore.md +230 -199
  13. package/openspec/commands/ff.md +115 -104
  14. package/openspec/commands/new.md +74 -63
  15. package/openspec/commands/onboard.md +557 -548
  16. package/openspec/commands/propose.md +161 -150
  17. package/openspec/commands/sync.md +277 -249
  18. package/openspec/commands/update.md +92 -80
  19. package/openspec/commands/verify.md +175 -162
  20. package/openspec/skills/openspec-apply-change/SKILL.md +20 -5
  21. package/openspec/skills/openspec-archive-change/SKILL.md +30 -8
  22. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +36 -6
  23. package/openspec/skills/openspec-continue-change/SKILL.md +14 -2
  24. package/openspec/skills/openspec-explore/SKILL.md +21 -9
  25. package/openspec/skills/openspec-ff-change/SKILL.md +14 -2
  26. package/openspec/skills/openspec-new-change/SKILL.md +13 -1
  27. package/openspec/skills/openspec-onboard/SKILL.md +49 -39
  28. package/openspec/skills/openspec-propose/SKILL.md +15 -3
  29. package/openspec/skills/openspec-sync-specs/SKILL.md +31 -2
  30. package/openspec/skills/openspec-update-change/SKILL.md +27 -14
  31. package/openspec/skills/openspec-verify-change/SKILL.md +17 -3
  32. package/package.json +1 -1
  33. package/superpowers/.version +4 -4
  34. package/superpowers/skills/brainstorming/SKILL.md +47 -12
  35. package/superpowers/skills/brainstorming/scripts/frame-template.html +213 -213
  36. package/superpowers/skills/brainstorming/scripts/server.cjs +723 -723
  37. package/superpowers/skills/brainstorming/visual-companion.md +6 -6
  38. package/superpowers/skills/diagnosing-superpowers/SKILL.md +120 -0
  39. package/superpowers/skills/diagnosing-superpowers/prompts/analyst-common.md +38 -0
  40. package/superpowers/skills/diagnosing-superpowers/prompts/cost-and-time.md +28 -0
  41. package/superpowers/skills/diagnosing-superpowers/prompts/plan-adherence.md +29 -0
  42. package/superpowers/skills/diagnosing-superpowers/prompts/quality-evidence.md +26 -0
  43. package/superpowers/skills/diagnosing-superpowers/prompts/repeated-work.md +30 -0
  44. package/superpowers/skills/diagnosing-superpowers/prompts/request-conflicts.md +20 -0
  45. package/superpowers/skills/diagnosing-superpowers/prompts/scrub-audit.md +33 -0
  46. package/superpowers/skills/diagnosing-superpowers/prompts/scrub.md +29 -0
  47. package/superpowers/skills/diagnosing-superpowers/prompts/similar-session.md +38 -0
  48. package/superpowers/skills/diagnosing-superpowers/prompts/skill-timeline.md +30 -0
  49. package/superpowers/skills/diagnosing-superpowers/prompts/stumbles.md +28 -0
  50. package/superpowers/skills/diagnosing-superpowers/references/context-safety.md +22 -0
  51. package/superpowers/skills/diagnosing-superpowers/references/github-issues.md +47 -0
  52. package/superpowers/skills/diagnosing-superpowers/references/redaction-policy.md +34 -0
  53. package/superpowers/skills/diagnosing-superpowers/references/session-discovery.md +31 -0
  54. package/superpowers/skills/diagnosing-superpowers/templates/bundle-README.md +77 -0
  55. package/superpowers/skills/diagnosing-superpowers/templates/case.md +64 -0
  56. package/superpowers/skills/diagnosing-superpowers/templates/issue.md +51 -0
  57. package/superpowers/skills/diagnosing-superpowers/templates/report.md +82 -0
  58. package/superpowers/skills/executing-plans/SKILL.md +350 -41
  59. package/superpowers/skills/executing-plans/scripts/task-done +52 -0
  60. package/superpowers/skills/executing-plans/scripts/task-start +28 -0
  61. package/superpowers/skills/requesting-code-review/SKILL.md +1 -1
  62. package/superpowers/skills/requesting-code-review/code-reviewer.md +17 -0
  63. package/superpowers/skills/subagent-driven-development/SKILL.md +18 -18
  64. package/superpowers/skills/subagent-driven-development/re-review-prompt.md +1 -1
  65. package/superpowers/skills/subagent-driven-development/scripts/review-package +53 -46
  66. package/superpowers/skills/subagent-driven-development/scripts/sdd-workspace +82 -40
  67. package/superpowers/skills/subagent-driven-development/scripts/task-brief +43 -41
  68. package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +2 -2
  69. package/superpowers/skills/systematic-debugging/root-cause-tracing.md +1 -1
  70. package/superpowers/skills/test-driven-development/SKILL.md +10 -0
  71. package/superpowers/skills/using-superpowers/SKILL.md +2 -0
  72. package/superpowers/skills/using-superpowers/references/claude-code-tools.md +29 -0
  73. package/superpowers/skills/using-superpowers/references/muse-tools.md +35 -0
  74. package/superpowers/skills/writing-plans/SKILL.md +30 -9
  75. package/superpowers/skills/writing-skills/SKILL.md +4 -2
  76. package/superpowers/skills/writing-skills/graphviz-conventions.dot +171 -171
@@ -4,220 +4,241 @@ description: Archive a completed change in the experimental workflow
4
4
  category: Workflow
5
5
  tags: [workflow, archive, experimental]
6
6
  ---
7
- Archive a completed change in the experimental workflow.
8
-
9
- **Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
10
-
11
- `<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.
12
-
13
- **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.
14
-
15
- **Steps**
16
-
17
- 1. **Select the change**
18
-
19
- If a name is provided, use it. Otherwise:
20
- - Infer from conversation context if the user mentioned a change
21
- - Auto-select if only one active change exists
22
- - If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
23
-
24
- When prompting, show only active changes (not already archived).
25
- Include the schema used for each change if available.
26
-
27
- Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
28
-
29
- **Load current archive inputs before the existing archive checks:**
30
-
31
- After resolving the selected change and planning root, run:
32
- ```bash
33
- openspec instructions archive --change "<name>" --json
34
- ```
35
- Keep the same selected-root flags on this command. This lookup is advisory and
36
- optional: it only supplies extra prompt inputs, so it must never block archiving.
37
- If it exits non-zero or returns invalid JSON — for example on an older CLI that
38
- does not support this command yet continue the archive workflow with no
39
- context and no operation guidance. Do not report an error and do not stop.
40
-
41
- A successful response may omit both optional fields. Treat `context` as a
42
- required prompt-level input: read and consider it, and apply relevant project
43
- facts, conventions, and constraints. Treat `operationGuidance` as optional
44
- additive advice: read and consider every entry, and follow entries that are
45
- applicable and compatible with the built-in archive workflow.
46
-
47
- Keep both fields separate from built-in steps, explicit user choices, resolved
48
- paths, CLI checks, and command contracts. If context conflicts with one of those
49
- controlling inputs, report the conflict and preserve the controlling value. If
50
- guidance is inapplicable or conflicts with a controlling input, do not follow it
51
- and explain why. Do not infer replacement paths, skipped prompts, or flags from
52
- either field, and do not copy their text verbatim into specs, change artifacts,
53
- or archive summaries unless the user separately asks for it. These are
54
- prompt-level behavior contracts, not enforceable checks.
55
-
56
- 2. **Check artifact completion status**
57
-
58
- Run `openspec status --change "<name>" --json` to check artifact completion.
59
-
60
- Parse the JSON to understand:
61
- - `schemaName`: The workflow being used
62
- - `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
63
- - `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
64
-
65
- **If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
66
- - Display warning listing incomplete artifacts
67
- - Prompt user for confirmation to continue
68
- - Proceed if user confirms
69
-
70
- 3. **Check task completion status**
71
-
72
- Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
73
-
74
- Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
75
-
76
- **If incomplete tasks found:**
77
- - Display warning showing count of incomplete tasks
78
- - Prompt user for confirmation to continue
79
- - Proceed if user confirms
80
-
81
- **If no tasks file exists:** Proceed without task-related warning.
82
-
83
- 4. **Assess delta spec sync state**
84
-
85
- Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
86
- delta-spec source. If the `specs` entry is missing or
87
- `existingOutputPaths` is empty, proceed without a sync prompt and do not infer
88
- delta specs from other artifacts.
89
-
90
- **If delta specs exist:**
91
- - 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)
92
- - Determine what changes would be applied (adds, modifications, removals, renames)
93
- - Show a combined summary before prompting
94
-
95
- **Prompt options:**
96
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
97
- - If already synced: "Archive now", "Sync anyway", "Cancel"
98
-
99
- Route on the answer:
100
- - "Cancel" stop, do not archive
101
- - "Archive without syncing" or "Archive now" proceed to archive
102
- - "Sync now" or "Sync anyway" sync, then verify (below)
103
- - Anything else ask again rather than archiving
104
-
105
- Before a selected sync writes any main spec, run
106
- `openspec instructions specs --change "<name>" --json` once with the same
107
- selected-root flags. Require a zero exit status and valid artifact-instruction
108
- JSON. If the lookup fails or returns invalid JSON, report the error and stop
109
- before writing any main spec or moving the change. A valid response with omitted
110
- `rules` is the no-rules case. Apply returned `rules` only to the content and
111
- form of main specs produced by this merge; do not use them as archive guidance,
112
- change CLI behavior, or copy the rule text into any output file.
113
-
114
- 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.
115
-
116
- 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:
117
- - ADDED requirements present
118
- - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
119
- - 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
120
- - RENAMED requirements present under the new name and absent under the old one
121
-
122
- 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.
123
-
124
- 5. **Perform the archive**
125
-
126
- Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
127
- ```bash
128
- mkdir -p "<planningHome.changesDir>/archive"
129
- ```
130
-
131
- 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`).
132
-
133
- **Check if target already exists:**
134
- - If yes: Fail with error, suggest renaming existing archive or using different date
135
- - If no: Move `changeRoot` to the archive directory
136
-
137
- ```bash
138
- mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
139
- ```
140
-
141
- 6. **Display summary**
142
-
143
- Show archive completion summary including:
144
- - Change name
145
- - Schema that was used
146
- - Archive location
147
- - Spec sync status (synced / sync skipped / no delta specs)
148
- - Note about any warnings (incomplete artifacts/tasks)
149
-
150
- **Output On Success**
151
-
152
- ```markdown
153
- ## Archive Complete
154
-
155
- **Change:** <change-name>
156
- **Schema:** <schema-name>
157
- **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
158
- **Specs:** ✓ Synced to main specs
159
-
160
- All artifacts complete. All tasks complete.
161
- ```
162
-
163
- **Output On Success (No Delta Specs)**
164
-
165
- ```markdown
166
- ## Archive Complete
167
-
168
- **Change:** <change-name>
169
- **Schema:** <schema-name>
170
- **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
171
- **Specs:** No delta specs
172
-
173
- All artifacts complete. All tasks complete.
174
- ```
175
-
176
- **Output On Success With Warnings**
177
-
178
- ```markdown
179
- ## Archive Complete (with warnings)
180
-
181
- **Change:** <change-name>
182
- **Schema:** <schema-name>
183
- **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
184
- **Specs:** Sync skipped (user chose to skip)
185
-
186
- **Warnings:**
187
- - Archived with 2 incomplete artifacts
188
- - Archived with 3 incomplete tasks
189
- - Delta spec sync was skipped (user chose to skip)
190
-
191
- Review the archive if this was not intentional.
192
- ```
193
-
194
- **Output On Error (Archive Exists)**
195
-
196
- ```markdown
197
- ## Archive Failed
198
-
199
- **Change:** <change-name>
200
- **Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
201
-
202
- Target archive directory already exists.
203
-
204
- **Options:**
205
- 1. Rename the existing archive
206
- 2. Delete the existing archive if it's a duplicate
207
- 3. Wait until a different date to archive
208
- ```
209
-
210
- **Guardrails**
211
- - Announce the selected change; prompt for selection when it is ambiguous
212
- - Use artifact graph (openspec status --json) for completion checking
213
- - Don't block archive on warnings - just inform and confirm
214
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
215
- - Show clear summary of what happened
216
- - If sync is requested, run the `/opsx:sync` workflow inline (agent-driven)
217
- - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
218
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting
219
- - Apply relevant runtime context and report conflicts; operation guidance remains advisory
220
- - Consider every guidance entry and explain any inapplicable or conflicting advice
221
- - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
222
- - Artifact rules constrain only the specs being written and are never operation guidance
7
+ Archive a completed change in the experimental workflow.
8
+
9
+ **Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `schemas`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
10
+
11
+ **Project check:** These steps expect a project that already uses OpenSpec. Before the first step that writes anything (`new change`, `archive`, `sync specs`, or authoring an artifact file), confirm the project has a root: run `openspec list --json` (with `--store <id>` when a store is selected, since the store is then the root) and read `root`. A root object means the project is set up. `"root": null` means it is not - there is no `openspec/` directory here, and a write such as `openspec new change` would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
12
+
13
+ One `"root": null` is not about setup: when a `status` error message starts with `Declared in` or `Invalid store declaration in` and names this project's `openspec/config.yaml` (or `config.yml`), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the `store:` line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's `message` and `fix`.
14
+
15
+ Otherwise, with no root, what happens next depends on how this workflow was reached:
16
+
17
+ - **Auto-selected**: you chose this workflow yourself, without the user naming OpenSpec, naming this skill, or running its slash command. Stop using OpenSpec and answer the request normally, as you would with no OpenSpec installed. Do not ask them to set anything up and do not mention OpenSpec setup.
18
+ - **Explicit OpenSpec request**: the user named OpenSpec, named this skill, or ran its slash command. Stop before writing and ask how to proceed: set this project up (`openspec init`), target a store they already have (`--store <id>`), or continue without OpenSpec for this request. Wait for their answer.
19
+
20
+ In both branches, never create the root as a side effect: do not run `openspec init` until the user asks for it, do not hand-create `openspec/` files, and do not let a command create it.
21
+
22
+ `<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.
23
+
24
+ **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.
25
+
26
+ **Steps**
27
+
28
+ 1. **Select the change**
29
+
30
+ If a name is provided, use it. Otherwise:
31
+ - Infer from conversation context if the user mentioned a change
32
+ - Auto-select if only one active change exists
33
+ - If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
34
+
35
+ When prompting, show only active changes (not already archived).
36
+ Include the schema used for each change if available.
37
+
38
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
39
+
40
+ **Load current archive inputs before the existing archive checks:**
41
+
42
+ After resolving the selected change and planning root, run:
43
+ ```bash
44
+ openspec instructions archive --change "<name>" --json
45
+ ```
46
+ Keep the same selected-root flags on this command. This lookup is advisory and
47
+ optional: it only supplies extra prompt inputs, so it must never block archiving.
48
+ If it exits non-zero or returns invalid JSON for example on an older CLI that
49
+ does not support this command yet continue the archive workflow with no
50
+ context and no operation guidance. Do not report an error and do not stop.
51
+
52
+ A successful response may omit both optional fields. Treat `context` as a
53
+ required prompt-level input: read and consider it, and apply relevant project
54
+ facts, conventions, and constraints. Treat `operationGuidance` as optional
55
+ additive advice: read and consider every entry, and follow entries that are
56
+ applicable and compatible with the built-in archive workflow.
57
+
58
+ Keep both fields separate from built-in steps, explicit user choices, resolved
59
+ paths, CLI checks, and command contracts. If context conflicts with one of those
60
+ controlling inputs, report the conflict and preserve the controlling value. If
61
+ guidance is inapplicable or conflicts with a controlling input, do not follow it
62
+ and explain why. Do not infer replacement paths, skipped prompts, or flags from
63
+ either field, and do not copy their text verbatim into specs, change artifacts,
64
+ or archive summaries unless the user separately asks for it. These are
65
+ prompt-level behavior contracts, not enforceable checks.
66
+
67
+ 2. **Check artifact completion status**
68
+
69
+ Run `openspec status --change "<name>" --json` to check artifact completion.
70
+
71
+ Parse the JSON to understand:
72
+ - `schemaName`: The workflow being used
73
+ - `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
74
+ - `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
75
+
76
+ **If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
77
+ - Display warning listing incomplete artifacts
78
+ - Prompt user for confirmation to continue
79
+ - Proceed if user confirms
80
+
81
+ 3. **Check task completion status**
82
+
83
+ Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
84
+
85
+ A checkbox is complete when its only content is `x` or `X`; spacing inside
86
+ the brackets does not matter, so `- [ x]` counts as complete too. Every
87
+ other marker is incomplete - `- [ ]`, an empty `- []`, and markers OpenSpec
88
+ assigns no meaning to such as `- [~]` or `- [-]`. Never read an unfamiliar
89
+ marker as complete.
90
+
91
+ **If incomplete tasks found:**
92
+ - Display warning showing count of incomplete tasks
93
+ - Prompt user for confirmation to continue
94
+ - Proceed if user confirms
95
+
96
+ **If no tasks file exists:** Proceed without task-related warning.
97
+
98
+ 4. **Assess delta spec sync state**
99
+
100
+ Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
101
+ delta-spec source. If the `specs` entry is missing or
102
+ `existingOutputPaths` is empty, proceed without a sync prompt and do not infer
103
+ delta specs from other artifacts.
104
+
105
+ **If delta specs exist:**
106
+ - 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)
107
+ - A missing main spec is **not automatically** "already synced". For a new capability, the main spec is an *output* of the sync, not an input:
108
+ - If the delta has MODIFIED or RENAMED requirements, report that only ADDED requirements can create a new main spec and mark that capability as sync-blocked. Never invent a requirement that has no current version.
109
+ - Otherwise, if the delta has only REMOVED requirements and the change's `.openspec.yaml` declares `retire_capabilities: true`, the capability is already retired: count it as already synced, warn that there is nothing left to remove, and do not recreate the main spec. Apply this rule both now and when verifying a completed sync.
110
+ - Otherwise, if the delta has no ADDED requirements, report that no sync is possible and mark that capability as sync-blocked. For a REMOVED-only delta, warn that there is no main spec to remove from and leave the main-spec tree unchanged. `openspec archive` refuses the unmarked REMOVED-only case with `Spec must have at least one requirement`.
111
+ - Otherwise, count the capability as needing sync and name it in the summary (`<capability-path>: new main spec will be created`). If the delta also has REMOVED requirements, warn that they will be ignored because there is no main spec to remove from. The sync creates the main spec from only the delta's ADDED requirements, exactly as `openspec archive` does.
112
+ - Determine what changes would be applied (adds, modifications, removals, renames)
113
+ - Continue assessing the remaining capabilities even when one is sync-blocked. Show a combined summary before prompting.
114
+
115
+ **Prompt options:**
116
+ - If any capability is sync-blocked: explain why and offer only "Archive without syncing", "Cancel"
117
+ - Otherwise, if changes needed: "Sync now (recommended)", "Archive without syncing"
118
+ - Otherwise, if already synced: "Archive now", "Sync anyway", "Cancel"
119
+
120
+ Route on the answer:
121
+ - "Cancel" — stop, do not archive
122
+ - "Archive without syncing" or "Archive now"proceed to archive
123
+ - "Sync now" or "Sync anyway" — sync, then verify (below). Do not start any sync while a capability is sync-blocked; explain the blocker and repeat the available choices.
124
+ - Anything else — ask again rather than archiving
125
+
126
+ Before a selected sync writes any main spec, run
127
+ `openspec instructions specs --change "<name>" --json` once with the same
128
+ selected-root flags. Require a zero exit status and valid artifact-instruction
129
+ JSON. If the lookup fails or returns invalid JSON, report the error and stop
130
+ before writing any main spec or moving the change. A valid response with omitted
131
+ `rules` is the no-rules case. Apply returned `rules` only to the content and
132
+ form of main specs produced by this merge; do not use them as archive guidance,
133
+ change CLI behavior, or copy the rule text into any output file.
134
+
135
+ 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.
136
+
137
+ Then re-run the comparison from the top of this step, including the explicitly retired, missing-spec case, 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:
138
+ - ADDED requirements present
139
+ - MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
140
+ - 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
141
+ - RENAMED requirements present under the new name and absent under the old one
142
+
143
+ 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.
144
+
145
+ 5. **Perform the archive**
146
+
147
+ Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
148
+ ```bash
149
+ mkdir -p "<planningHome.changesDir>/archive"
150
+ ```
151
+
152
+ 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`).
153
+
154
+ **Check if target already exists:**
155
+ - If yes: Fail with error, suggest renaming existing archive or using different date
156
+ - If no: Move `changeRoot` to the archive directory
157
+
158
+ ```bash
159
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
160
+ ```
161
+
162
+ 6. **Display summary**
163
+
164
+ Show archive completion summary including:
165
+ - Change name
166
+ - Schema that was used
167
+ - Archive location
168
+ - Spec sync status (synced / sync skipped / no delta specs)
169
+ - Note about any warnings (incomplete artifacts/tasks)
170
+
171
+ **Output On Success**
172
+
173
+ ```markdown
174
+ ## Archive Complete
175
+
176
+ **Change:** <change-name>
177
+ **Schema:** <schema-name>
178
+ **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
179
+ **Specs:** Synced to main specs
180
+
181
+ All artifacts complete. All tasks complete.
182
+ ```
183
+
184
+ **Output On Success (No Delta Specs)**
185
+
186
+ ```markdown
187
+ ## Archive Complete
188
+
189
+ **Change:** <change-name>
190
+ **Schema:** <schema-name>
191
+ **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
192
+ **Specs:** No delta specs
193
+
194
+ All artifacts complete. All tasks complete.
195
+ ```
196
+
197
+ **Output On Success With Warnings**
198
+
199
+ ```markdown
200
+ ## Archive Complete (with warnings)
201
+
202
+ **Change:** <change-name>
203
+ **Schema:** <schema-name>
204
+ **Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
205
+ **Specs:** Sync skipped (user chose to skip)
206
+
207
+ **Warnings:**
208
+ - Archived with 2 incomplete artifacts
209
+ - Archived with 3 incomplete tasks
210
+ - Delta spec sync was skipped (user chose to skip)
211
+
212
+ Review the archive if this was not intentional.
213
+ ```
214
+
215
+ **Output On Error (Archive Exists)**
216
+
217
+ ```markdown
218
+ ## Archive Failed
219
+
220
+ **Change:** <change-name>
221
+ **Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
222
+
223
+ Target archive directory already exists.
224
+
225
+ **Options:**
226
+ 1. Rename the existing archive
227
+ 2. Delete the existing archive if it's a duplicate
228
+ 3. Wait until a different date to archive
229
+ ```
230
+
231
+ **Guardrails**
232
+ - Announce the selected change; prompt for selection when it is ambiguous
233
+ - Use artifact graph (openspec status --json) for completion checking
234
+ - Don't block archive on warnings - just inform and confirm
235
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
236
+ - Show clear summary of what happened
237
+ - If sync is requested, run the `/opsx:sync` workflow inline (agent-driven)
238
+ - Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
239
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
240
+ - Apply relevant runtime context and report conflicts; operation guidance remains advisory
241
+ - Consider every guidance entry and explain any inapplicable or conflicting advice
242
+ - Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
243
+ - Artifact rules constrain only the specs being written and are never operation guidance
223
244
  - Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files