@jspg-ai/coding-bb 0.0.3-beta.4 → 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 (85) hide show
  1. package/cbb/dev-standards/rules/cbb-ai-behavior.md +118 -116
  2. package/cbb/lib/install/codebuddy.js +32 -0
  3. package/cbb/lib/install/init.js +85 -35
  4. package/cbb/lib/install/rule-rewrite.js +27 -0
  5. package/cbb/lib/install/trae.js +35 -0
  6. package/cbb/lib/openspec/index.js +337 -554
  7. package/cbb/lib/superpowers/index.js +246 -265
  8. package/cbb/lib/utils/check-update.js +8 -1
  9. package/cbb/lib/utils/gitignore.js +2 -0
  10. package/cbb/lib/utils/settings.js +17 -4
  11. package/cbb/lib/utils/tar.js +92 -0
  12. package/cbb/lib/utils/upstream.js +90 -0
  13. package/cbb/worktrees/commands/worktree-close.md +1 -1
  14. package/config/upstream-mirrors.json +12 -0
  15. package/config/workspace-agents.sample.md +41 -39
  16. package/openspec/.version +2 -3
  17. package/openspec/commands/apply.md +189 -175
  18. package/openspec/commands/archive.md +237 -216
  19. package/openspec/commands/bulk-archive.md +355 -327
  20. package/openspec/commands/continue.md +116 -105
  21. package/openspec/commands/explore.md +230 -199
  22. package/openspec/commands/ff.md +115 -104
  23. package/openspec/commands/new.md +74 -63
  24. package/openspec/commands/onboard.md +557 -548
  25. package/openspec/commands/propose.md +161 -150
  26. package/openspec/commands/sync.md +277 -249
  27. package/openspec/commands/update.md +92 -80
  28. package/openspec/commands/verify.md +175 -162
  29. package/openspec/skills/openspec-apply-change/SKILL.md +20 -5
  30. package/openspec/skills/openspec-archive-change/SKILL.md +30 -8
  31. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +36 -6
  32. package/openspec/skills/openspec-continue-change/SKILL.md +14 -2
  33. package/openspec/skills/openspec-explore/SKILL.md +21 -9
  34. package/openspec/skills/openspec-ff-change/SKILL.md +14 -2
  35. package/openspec/skills/openspec-new-change/SKILL.md +13 -1
  36. package/openspec/skills/openspec-onboard/SKILL.md +49 -39
  37. package/openspec/skills/openspec-propose/SKILL.md +15 -3
  38. package/openspec/skills/openspec-sync-specs/SKILL.md +31 -2
  39. package/openspec/skills/openspec-update-change/SKILL.md +27 -14
  40. package/openspec/skills/openspec-verify-change/SKILL.md +17 -3
  41. package/package.json +2 -2
  42. package/superpowers/.version +4 -4
  43. package/superpowers/skills/brainstorming/SKILL.md +47 -12
  44. package/superpowers/skills/brainstorming/scripts/frame-template.html +213 -213
  45. package/superpowers/skills/brainstorming/scripts/server.cjs +723 -723
  46. package/superpowers/skills/brainstorming/visual-companion.md +6 -6
  47. package/superpowers/skills/diagnosing-superpowers/SKILL.md +120 -0
  48. package/superpowers/skills/diagnosing-superpowers/prompts/analyst-common.md +38 -0
  49. package/superpowers/skills/diagnosing-superpowers/prompts/cost-and-time.md +28 -0
  50. package/superpowers/skills/diagnosing-superpowers/prompts/plan-adherence.md +29 -0
  51. package/superpowers/skills/diagnosing-superpowers/prompts/quality-evidence.md +26 -0
  52. package/superpowers/skills/diagnosing-superpowers/prompts/repeated-work.md +30 -0
  53. package/superpowers/skills/diagnosing-superpowers/prompts/request-conflicts.md +20 -0
  54. package/superpowers/skills/diagnosing-superpowers/prompts/scrub-audit.md +33 -0
  55. package/superpowers/skills/diagnosing-superpowers/prompts/scrub.md +29 -0
  56. package/superpowers/skills/diagnosing-superpowers/prompts/similar-session.md +38 -0
  57. package/superpowers/skills/diagnosing-superpowers/prompts/skill-timeline.md +30 -0
  58. package/superpowers/skills/diagnosing-superpowers/prompts/stumbles.md +28 -0
  59. package/superpowers/skills/diagnosing-superpowers/references/context-safety.md +22 -0
  60. package/superpowers/skills/diagnosing-superpowers/references/github-issues.md +47 -0
  61. package/superpowers/skills/diagnosing-superpowers/references/redaction-policy.md +34 -0
  62. package/superpowers/skills/diagnosing-superpowers/references/session-discovery.md +31 -0
  63. package/superpowers/skills/diagnosing-superpowers/templates/bundle-README.md +77 -0
  64. package/superpowers/skills/diagnosing-superpowers/templates/case.md +64 -0
  65. package/superpowers/skills/diagnosing-superpowers/templates/issue.md +51 -0
  66. package/superpowers/skills/diagnosing-superpowers/templates/report.md +82 -0
  67. package/superpowers/skills/executing-plans/SKILL.md +350 -41
  68. package/superpowers/skills/executing-plans/scripts/task-done +52 -0
  69. package/superpowers/skills/executing-plans/scripts/task-start +28 -0
  70. package/superpowers/skills/requesting-code-review/SKILL.md +1 -1
  71. package/superpowers/skills/requesting-code-review/code-reviewer.md +17 -0
  72. package/superpowers/skills/subagent-driven-development/SKILL.md +18 -18
  73. package/superpowers/skills/subagent-driven-development/re-review-prompt.md +1 -1
  74. package/superpowers/skills/subagent-driven-development/scripts/review-package +53 -46
  75. package/superpowers/skills/subagent-driven-development/scripts/sdd-workspace +82 -40
  76. package/superpowers/skills/subagent-driven-development/scripts/task-brief +43 -41
  77. package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +2 -2
  78. package/superpowers/skills/systematic-debugging/root-cause-tracing.md +1 -1
  79. package/superpowers/skills/test-driven-development/SKILL.md +10 -0
  80. package/superpowers/skills/using-superpowers/SKILL.md +2 -0
  81. package/superpowers/skills/using-superpowers/references/claude-code-tools.md +29 -0
  82. package/superpowers/skills/using-superpowers/references/muse-tools.md +35 -0
  83. package/superpowers/skills/writing-plans/SKILL.md +30 -9
  84. package/superpowers/skills/writing-skills/SKILL.md +4 -2
  85. package/superpowers/skills/writing-skills/graphviz-conventions.dot +171 -171
@@ -4,331 +4,359 @@ description: Archive multiple completed changes at once
4
4
  category: Workflow
5
5
  tags: [workflow, archive, experimental, bulk]
6
6
  ---
7
- Archive multiple completed changes in a single operation.
8
-
9
- This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
10
-
11
- **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.
12
-
13
- `<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.
14
-
15
- **Input**: None required (prompts for selection)
16
-
17
- **Steps**
18
-
19
- 1. **Get active changes**
20
-
21
- Run `openspec list --json` to get all active changes.
22
-
23
- If no active changes exist, inform user and stop.
24
-
25
- 2. **Prompt for change selection**
26
-
27
- Ask the user to choose changes (multi-select):
28
- - Show each change with its schema
29
- - Include an option for "All changes"
30
- - Allow any number of selections (1+ works, 2+ is the typical use case)
31
-
32
- **IMPORTANT**: Do NOT auto-select. Always let the user choose.
33
-
34
- **Load current archive inputs once for the selected root before batch validation:**
35
-
36
- Choose one selected change from this root and run
37
- `openspec instructions archive --change "<selected-change>" --json` with the
38
- same selected-root flags. This lookup is advisory and optional: it only supplies
39
- extra prompt inputs, so it must never block the batch. If it fails or returns
40
- invalid JSON — for example on an older CLI that does not support this command
41
- yet continue the batch with no context and no operation guidance. Do not
42
- report an error and do not stop.
43
-
44
- A valid response may omit `context` and `operationGuidance`. Treat
45
- `context` as a required prompt-level input across the batch: read and consider
46
- it, and apply relevant project facts, conventions, and constraints. Treat
47
- `operationGuidance` as optional additive advice: read and consider every
48
- entry, and follow entries that are applicable and compatible with the built-in
49
- batch workflow.
50
-
51
- Keep both fields separate from conflict analysis, explicit user choices,
52
- resolved paths, CLI checks, and command contracts. If context conflicts with one
53
- of those controlling inputs, report the conflict and preserve the controlling
54
- value. If guidance is inapplicable or conflicts with a controlling input, do not
55
- follow it and explain why. Do not infer skipped prompts, replacement paths, or
56
- flags from either field, and do not copy their text verbatim into specs, changes,
57
- or summaries. These are prompt-level behavior contracts, not enforceable checks.
58
-
59
- 3. **Batch validation - gather status for all selected changes**
60
-
61
- For each selected change, collect:
62
-
63
- a. **Artifact status** - Run `openspec status --change "<name>" --json`
64
- - Parse `schemaName`, `artifacts`, `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`
65
- - Note which artifacts are `done` vs other states
66
-
67
- b. **Task completion** - Read `artifactPaths.tasks.existingOutputPaths` from status JSON
68
- - Count `- [ ]` (incomplete) vs `- [x]` (complete)
69
- - If no tasks file exists, note as "No tasks"
70
-
71
- c. **Delta specs** - Check `artifactPaths.specs.existingOutputPaths` from status JSON
72
- - List which capability specs exist
73
- - For each, extract requirement names (lines matching `### Requirement: <name>`)
74
- - Treat this list as the only delta-spec source. If the `specs` entry is
75
- missing or the list is empty, perform no spec sync or specs-instruction
76
- lookup for that change; do not infer deltas from unrelated artifacts.
77
- - Evaluate this independently for every change, including mixed-schema
78
- batches where some schemas have no `specs` artifact.
79
-
80
- 4. **Detect spec conflicts**
81
-
82
- Build a map keyed by `<capability-path>`, the exact path relative to `specs/`:
83
-
84
- ```text
85
- identity/user-auth -> [change-a, change-b] <- CONFLICT (2+ changes)
86
- billing/user-auth -> [change-c] <- OK (different full path)
87
- ```
88
-
89
- A conflict exists when 2+ selected changes have delta specs for the exact same `<capability-path>`.
90
-
91
- 5. **Resolve conflicts agentically**
92
-
93
- **For each conflict**, investigate the codebase:
94
-
95
- a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
96
-
97
- b. **Search the codebase** for implementation evidence:
98
- - Look for code implementing requirements from each delta spec
99
- - Check for related files, functions, or tests
100
-
101
- c. **Determine resolution**:
102
- - If only one change is actually implemented -> sync that one's specs
103
- - If both implemented -> apply in chronological order (older first, newer overwrites)
104
- - If neither implemented -> skip spec sync, warn user
105
-
106
- d. **Record resolution** for each conflict:
107
- - An inclusion or exclusion decision for every delta spec, keyed by change and `<capability-path>`
108
- - Which included delta specs to apply and in what order
109
- - Which delta specs to exclude from sync because their implementation is missing
110
- - Rationale (what was found in codebase)
111
-
112
- 6. **Show consolidated status table**
113
-
114
- Display a table summarizing all changes:
115
-
116
- ```markdown
117
- | Change | Artifacts | Tasks | Specs | Conflicts | Status |
118
- |---------------------|-----------|-------|---------|-----------|--------|
119
- | schema-management | Done | 5/5 | 2 delta | None | Ready |
120
- | project-config | Done | 3/3 | 1 delta | None | Ready |
121
- | add-oauth | Done | 4/4 | 1 delta | identity/user-auth (!) | Ready* |
122
- | add-verify-skill | 1 left | 2/5 | None | None | Warn |
123
- ```
124
-
125
- For conflicts, show the resolution:
126
- ```text
127
- * Conflict resolution:
128
- - identity/user-auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
129
- ```
130
-
131
- For incomplete changes, show warnings:
132
- ```text
133
- Warnings:
134
- - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
135
- ```
136
-
137
- 7. **Confirm batch operation**
138
-
139
- Ask the user a single confirmation question:
140
-
141
- - "Archive N changes?" with options based on status
142
- - Options might include:
143
- - "Archive all N changes"
144
- - "Archive only N ready changes (skip incomplete)"
145
- - "Cancel"
146
-
147
- If there are incomplete changes, make clear they'll be archived with warnings.
148
-
149
- Route on the answer by intent, not by exact label — you wrote these labels,
150
- so match what the user picked rather than the wording above:
151
- - "Cancel" — stop, do not archive. Report that nothing was archived and skip the remaining steps.
152
- - The archive-everything option — proceed with every selected change
153
- - The ready-only option — proceed with only the changes the step 6 table marks `Ready` or `Ready*`, and record the rest as Skipped in step 8d. If a `Ready*` change's conflict partner is skipped, re-derive that conflict's resolution using only the changes being archived.
154
- - Anything else ask again rather than archiving
155
-
156
- Before step 8 writes the first main spec or moves any change, fetch every
157
- required specs-rule snapshot for the confirmed batch. For each change that will
158
- sync concrete `artifactPaths.specs.existingOutputPaths`, run
159
- `openspec instructions specs --change "<name>" --json` exactly once with the
160
- same selected-root flags. Obtain all snapshots before the first write or move.
161
- If any lookup exits non-zero or returns invalid artifact-instruction JSON,
162
- identify the affected change, report the error, and stop the whole batch before
163
- any main-spec write or change move. Do not treat lookup failure as omitted
164
- rules. A valid response without `rules` is the no-rules case.
165
-
166
- 8. **Execute archive for each confirmed change**
167
-
168
- Before processing, carry the recorded decisions from step 5 (after any step 7 re-derivation) into two per-delta sets:
169
- - `includedDeltas`: all non-conflicting delta specs from confirmed changes plus conflict deltas selected for sync
170
- - `excludedDeltas`: conflict deltas from confirmed changes excluded because their implementation is missing
171
- - A single change can have both included and excluded delta specs. Keep the decision per delta; do not collapse it into a per-change sync flag.
172
-
173
- Process changes in the determined order (respecting conflict resolution):
174
-
175
- a. **Sync included delta specs**:
176
- - Run the `/opsx:sync` workflow inline (agent-driven intelligent merge) only for changes with entries in `includedDeltas`, passing only the included delta paths and explicitly instructing it to ignore that change's `excludedDeltas`. Wait for it to finish.
177
- - For conflicts, apply in resolved order.
178
- - Pass that change's fetched specs-rule snapshot into inline sync; inline
179
- sync must reuse it without fetching instructions again
180
- - Apply artifact rules only to main specs produced by that change. They do
181
- not change conflict resolution, archive behavior, or CLI contracts, and
182
- their text is not copied into an output file
183
- - Do not delegate to a background task — step 8c would move `changeRoot` out from under a sync that is still reading it.
184
- - If a change has no included delta specs, do not run the sync workflow for it.
185
-
186
- b. **Verify included delta specs before moving changeRoot**:
187
- - Re-run the comparison only for delta specs in `includedDeltas` against main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 3 status JSON, not a hardcoded repo path).
188
- - Verify that main specs are updated:
189
- - ADDED requirements present
190
- - MODIFIED requirements carrying scenario and description changes named in the delta, with their other scenarios intact
191
- - 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
192
- - RENAMED requirements present under the new name and absent under the old one
193
- - Do not verify delta specs in `excludedDeltas`; they are intentionally left unsynced.
194
- - If sync failed or any capability does not match verification, report what differs and fail/skip moving that change's `changeRoot` — do not archive that change. `changeRoot` remains intact.
195
-
196
- c. **Perform the archive**:
197
-
198
- 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-<name>` (same rule as `openspec archive`).
199
-
200
- ```bash
201
- mkdir -p "<planningHome.changesDir>/archive"
202
- mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
203
- ```
204
-
205
- d. **Track outcome** for each change:
206
- - Success: archived successfully
207
- - Failed: error during archive or spec verification (record error)
208
- - Skipped: user chose not to archive (if applicable)
209
- - Sync skipped: for every delta in `excludedDeltas`, report `sync skipped` with the change, `<capability-path>`, and recorded reason. This is distinct from skipping the archive.
210
-
211
- 9. **Display summary**
212
-
213
- Show final results:
214
-
215
- ```markdown
216
- ## Bulk Archive Complete
217
-
218
- Archived 3 changes:
219
- - schema-management-cli -> archive/2026-01-19-schema-management-cli/
220
- - project-config -> archive/2026-01-19-project-config/
221
- - add-oauth -> archive/2026-01-19-add-oauth/
222
-
223
- Skipped 1 change:
224
- - add-verify-skill (user chose not to archive incomplete)
225
-
226
- Spec sync summary:
227
- - 4 delta specs synced to main specs
228
- - 1 delta spec sync skipped (add-jwt, identity/user-auth: implementation not found)
229
- - 1 conflict resolved (identity/user-auth: synced add-oauth, skipped add-jwt)
230
- ```
231
-
232
- If any failures:
233
- ```text
234
- Failed 1 change:
235
- - some-change: Archive directory already exists
236
- ```
237
-
238
- **Conflict Resolution Examples**
239
-
240
- Example 1: Only one implemented
241
- ```text
242
- Conflict: <planningHome.root>/openspec/specs/auth/spec.md touched by [add-oauth, add-jwt]
243
-
244
- Checking add-oauth:
245
- - Delta adds "OAuth Provider Integration" requirement
246
- - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
247
-
248
- Checking add-jwt:
249
- - Delta adds "JWT Token Handling" requirement
250
- - Searching codebase... no JWT implementation found
251
-
252
- Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
253
- ```
254
-
255
- Example 2: Both implemented
256
- ```text
257
- Conflict: <planningHome.root>/openspec/specs/api/spec.md touched by [add-rest-api, add-graphql]
258
-
259
- Checking add-rest-api (created 2026-01-10):
260
- - Delta adds "REST Endpoints" requirement
261
- - Searching codebase... found src/api/rest.ts
262
-
263
- Checking add-graphql (created 2026-01-15):
264
- - Delta adds "GraphQL Schema" requirement
265
- - Searching codebase... found src/api/graphql.ts
266
-
267
- Resolution: Both implemented. Will apply add-rest-api specs first,
268
- then add-graphql specs (chronological order, newer takes precedence).
269
- ```
270
-
271
- **Output On Success**
272
-
273
- ```markdown
274
- ## Bulk Archive Complete
275
-
276
- Archived N changes:
277
- - <change-1> -> archive/<target-name-1>/
278
- - <change-2> -> archive/<target-name-2>/
279
-
280
- Spec sync summary:
281
- - N delta specs synced to main specs
282
- - No conflicts (or: M conflicts resolved)
283
- ```
284
-
285
- **Output On Partial Success**
286
-
287
- ```markdown
288
- ## Bulk Archive Complete (partial)
289
-
290
- Archived N changes:
291
- - <change-1> -> archive/<target-name-1>/
292
-
293
- Skipped M changes:
294
- - <change-2> (user chose not to archive incomplete)
295
-
296
- Failed K changes:
297
- - <change-3>: Archive directory already exists
298
- ```
299
-
300
- **Output When No Changes**
301
-
302
- ```markdown
303
- ## No Changes to Archive
304
-
305
- No active changes found. Create a new change to get started.
306
- ```
307
-
308
- **Guardrails**
309
- - Allow any number of changes (1+ is fine, 2+ is the typical use case)
310
- - Always prompt for selection, never auto-select
311
- - Detect spec conflicts early and resolve by checking codebase
312
- - When both changes are implemented, apply specs in chronological order
313
- - Skip spec sync only when implementation is missing (warn user)
314
- - Show clear per-change status before confirming
315
- - Use single confirmation for entire batch
316
- - Never archive after the user cancels the confirmation — a cancelled batch archives nothing
317
- - Track and report all outcomes (success/skip/fail)
318
- - Preserve .openspec.yaml when moving to archive
319
- - Archive directory target uses current date: YYYY-MM-DD-<name>; a name that already starts with a `YYYY-MM-DD-` prefix is used as-is (never stack a second date)
320
- - If archive target exists, fail that change but continue with others
321
- - If sync is requested, run the `/opsx:sync` workflow inline (agent-driven) for each change with included delta specs
322
- - Carry the per-delta `includedDeltas` and `excludedDeltas` decisions into execution; sync and verify only included deltas
323
- - Report every excluded delta as `sync skipped` without treating the archive itself as skipped
324
- - Never archive a change while a spec sync is still in flight — run the sync inline and verify main specs at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` before moving `changeRoot`
325
- - Fetch archive inputs once per selected root before spec inspection or moves
326
- - Fetch all required specs-rule snapshots before the batch's first main-spec write or move
327
- - A failed archive-inputs lookup never blocks the batch; it proceeds with no context or guidance
328
- - A failed specs instruction lookup stops the whole batch atomically
329
- - Changes without concrete `artifactPaths.specs.existingOutputPaths` continue without spec sync
330
- - Apply relevant runtime context across the batch and report conflicts
331
- - Operation guidance remains advisory; consider every entry and explain rejected advice
332
- - Keep runtime inputs, conflict analysis, CLI-derived values, and artifact rules separate
333
- - Artifact rules constrain only written specs
7
+ Archive multiple completed changes in a single operation.
8
+
9
+ This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
10
+
11
+ **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.
12
+
13
+ **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.
14
+
15
+ 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`.
16
+
17
+ Otherwise, with no root, what happens next depends on how this workflow was reached:
18
+
19
+ - **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.
20
+ - **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.
21
+
22
+ 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.
23
+
24
+ `<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.
25
+
26
+ **Input**: None required (prompts for selection)
27
+
28
+ **Steps**
29
+
30
+ 1. **Get active changes**
31
+
32
+ Run `openspec list --json` to get all active changes.
33
+
34
+ If no active changes exist, inform user and stop.
35
+
36
+ 2. **Prompt for change selection**
37
+
38
+ Ask the user to choose changes (multi-select):
39
+ - Show each change with its schema
40
+ - Include an option for "All changes"
41
+ - Allow any number of selections (1+ works, 2+ is the typical use case)
42
+
43
+ **IMPORTANT**: Do NOT auto-select. Always let the user choose.
44
+
45
+ **Load current archive inputs once for the selected root before batch validation:**
46
+
47
+ Choose one selected change from this root and run
48
+ `openspec instructions archive --change "<selected-change>" --json` with the
49
+ same selected-root flags. This lookup is advisory and optional: it only supplies
50
+ extra prompt inputs, so it must never block the batch. If it fails or returns
51
+ invalid JSON for example on an older CLI that does not support this command
52
+ yet continue the batch with no context and no operation guidance. Do not
53
+ report an error and do not stop.
54
+
55
+ A valid response may omit `context` and `operationGuidance`. Treat
56
+ `context` as a required prompt-level input across the batch: read and consider
57
+ it, and apply relevant project facts, conventions, and constraints. Treat
58
+ `operationGuidance` as optional additive advice: read and consider every
59
+ entry, and follow entries that are applicable and compatible with the built-in
60
+ batch workflow.
61
+
62
+ Keep both fields separate from conflict analysis, explicit user choices,
63
+ resolved paths, CLI checks, and command contracts. If context conflicts with one
64
+ of those controlling inputs, report the conflict and preserve the controlling
65
+ value. If guidance is inapplicable or conflicts with a controlling input, do not
66
+ follow it and explain why. Do not infer skipped prompts, replacement paths, or
67
+ flags from either field, and do not copy their text verbatim into specs, changes,
68
+ or summaries. These are prompt-level behavior contracts, not enforceable checks.
69
+
70
+ 3. **Batch validation - gather status for all selected changes**
71
+
72
+ For each selected change, collect:
73
+
74
+ a. **Artifact status** - Run `openspec status --change "<name>" --json`
75
+ - Parse `schemaName`, `artifacts`, `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`
76
+ - Note which artifacts are `done` vs other states
77
+
78
+ b. **Task completion** - Read `artifactPaths.tasks.existingOutputPaths` from status JSON
79
+ - Complete means the checkbox holds only `x`/`X`, ignoring spacing
80
+ (`- [ x]` is complete); every other marker is incomplete (`- [ ]`,
81
+ `- []`, and unfamiliar ones such as `- [~]` or `- [-]`)
82
+ - If no tasks file exists, note as "No tasks"
83
+
84
+ c. **Delta specs** - Check `artifactPaths.specs.existingOutputPaths` from status JSON
85
+ - List which capability specs exist
86
+ - For each, extract requirement names (lines matching `### Requirement: <name>`)
87
+ - Treat this list as the only delta-spec source. If the `specs` entry is
88
+ missing or the list is empty, perform no spec sync or specs-instruction
89
+ lookup for that change; do not infer deltas from unrelated artifacts.
90
+ - Evaluate this independently for every change, including mixed-schema
91
+ batches where some schemas have no `specs` artifact.
92
+
93
+ d. **Archive target** - Compute each change's target name once and record it as that change's `<target-name>`
94
+ - 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-<name>` (same rule as `openspec archive`)
95
+ - Check whether `<planningHome.changesDir>/archive/<target-name>` already exists
96
+ - If it exists, or another selected change resolves to the same target name, mark every such change `Blocked` with `Archive directory already exists`
97
+ - A blocked change is never synced or moved: show it as `Blocked` in the step 6 table, leave it out of conflict resolution (resolve its conflicts using only the other changes), and record it as Failed in step 8d
98
+ - Checking here, before any main spec is written, matches `openspec archive`: a collision found after sync would leave main specs rewritten for an archive that never happened
99
+
100
+ 4. **Detect spec conflicts**
101
+
102
+ Build a map keyed by `<capability-path>`, the exact path relative to `specs/`:
103
+
104
+ ```text
105
+ identity/user-auth -> [change-a, change-b] <- CONFLICT (2+ changes)
106
+ billing/user-auth -> [change-c] <- OK (different full path)
107
+ ```
108
+
109
+ A conflict exists when 2+ selected changes have delta specs for the exact same `<capability-path>`.
110
+
111
+ 5. **Resolve conflicts agentically**
112
+
113
+ **For each conflict**, investigate the codebase:
114
+
115
+ a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
116
+
117
+ b. **Search the codebase** for implementation evidence:
118
+ - Look for code implementing requirements from each delta spec
119
+ - Check for related files, functions, or tests
120
+
121
+ c. **Determine resolution**:
122
+ - If only one change is actually implemented -> sync that one's specs
123
+ - If both implemented -> apply in chronological order (older first, newer overwrites)
124
+ - If neither implemented -> skip spec sync, warn user
125
+
126
+ d. **Record resolution** for each conflict:
127
+ - An inclusion or exclusion decision for every delta spec, keyed by change and `<capability-path>`
128
+ - Which included delta specs to apply and in what order
129
+ - Which delta specs to exclude from sync because their implementation is missing
130
+ - Rationale (what was found in codebase)
131
+
132
+ 6. **Show consolidated status table**
133
+
134
+ Display a table summarizing all changes:
135
+
136
+ ```markdown
137
+ | Change | Artifacts | Tasks | Specs | Conflicts | Status |
138
+ |---------------------|-----------|-------|---------|-----------|--------|
139
+ | schema-management | Done | 5/5 | 2 delta | None | Ready |
140
+ | project-config | Done | 3/3 | 1 delta | None | Ready |
141
+ | add-oauth | Done | 4/4 | 1 delta | identity/user-auth (!) | Ready* |
142
+ | add-verify-skill | 1 left | 2/5 | None | None | Warn |
143
+ ```
144
+
145
+ For conflicts, show the resolution:
146
+ ```text
147
+ * Conflict resolution:
148
+ - identity/user-auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
149
+ ```
150
+
151
+ For incomplete changes, show warnings:
152
+ ```text
153
+ Warnings:
154
+ - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
155
+ ```
156
+
157
+ 7. **Confirm batch operation**
158
+
159
+ Ask the user a single confirmation question:
160
+
161
+ - "Archive N changes?" with options based on status
162
+ - Options might include:
163
+ - "Archive all N changes"
164
+ - "Archive only N ready changes (skip incomplete)"
165
+ - "Cancel"
166
+
167
+ If there are incomplete changes, make clear they'll be archived with warnings.
168
+
169
+ Route on the answer by intent, not by exact label you wrote these labels,
170
+ so match what the user picked rather than the wording above:
171
+ - "Cancel" stop, do not archive. Report that nothing was archived and skip the remaining steps.
172
+ - The archive-everything option — proceed with every selected change that is not `Blocked`
173
+ - The ready-only option — proceed with only the changes the step 6 table marks `Ready` or `Ready*`, and record the rest as Skipped in step 8d, except `Blocked` changes, which stay Failed with `Archive directory already exists`. If a `Ready*` change's conflict partner is skipped, re-derive that conflict's resolution using only the changes being archived.
174
+ - Anything else — ask again rather than archiving
175
+
176
+ Before step 8 writes the first main spec or moves any change, fetch every
177
+ required specs-rule snapshot for the confirmed batch. For each change that will
178
+ sync concrete `artifactPaths.specs.existingOutputPaths`, run
179
+ `openspec instructions specs --change "<name>" --json` exactly once with the
180
+ same selected-root flags. Obtain all snapshots before the first write or move.
181
+ If any lookup exits non-zero or returns invalid artifact-instruction JSON,
182
+ identify the affected change, report the error, and stop the whole batch before
183
+ any main-spec write or change move. Do not treat lookup failure as omitted
184
+ rules. A valid response without `rules` is the no-rules case.
185
+
186
+ 8. **Execute archive for each confirmed change**
187
+
188
+ Before processing, carry the recorded decisions from step 5 (after any step 7 re-derivation) into two per-delta sets:
189
+ - `includedDeltas`: all non-conflicting delta specs from confirmed changes plus conflict deltas selected for sync
190
+ - `excludedDeltas`: conflict deltas from confirmed changes excluded because their implementation is missing
191
+ - A single change can have both included and excluded delta specs. Keep the decision per delta; do not collapse it into a per-change sync flag.
192
+
193
+ Process changes in the determined order (respecting conflict resolution):
194
+
195
+ a. **Sync included delta specs**:
196
+ - Run the `/opsx:sync` workflow inline (agent-driven intelligent merge) only for changes with entries in `includedDeltas`, passing only the included delta paths and explicitly instructing it to ignore that change's `excludedDeltas`. Wait for it to finish.
197
+ - For conflicts, apply in resolved order.
198
+ - Pass that change's fetched specs-rule snapshot into inline sync; inline
199
+ sync must reuse it without fetching instructions again
200
+ - Apply artifact rules only to main specs produced by that change. They do
201
+ not change conflict resolution, archive behavior, or CLI contracts, and
202
+ their text is not copied into an output file
203
+ - Do not delegate to a background task — step 8c would move `changeRoot` out from under a sync that is still reading it.
204
+ - If a change has no included delta specs, do not run the sync workflow for it.
205
+
206
+ b. **Verify included delta specs before moving changeRoot**:
207
+ - Re-run the comparison only for delta specs in `includedDeltas` against main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 3 status JSON, not a hardcoded repo path).
208
+ - Verify that main specs are updated:
209
+ - ADDED requirements present
210
+ - MODIFIED requirements carrying scenario and description changes named in the delta, with their other scenarios intact
211
+ - 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
212
+ - RENAMED requirements present under the new name and absent under the old one
213
+ - Do not verify delta specs in `excludedDeltas`; they are intentionally left unsynced.
214
+ - If sync failed or any capability does not match verification, report what differs and fail/skip moving that change's `changeRoot` — do not archive that change. `changeRoot` remains intact.
215
+
216
+ c. **Perform the archive**:
217
+
218
+ Target name: use the `<target-name>` recorded for this change in step 3d, unchanged. Never recompute it here: a batch that runs past midnight would check one date in step 3 and move to another.
219
+
220
+ **Check if target already exists:**
221
+ - Check again immediately before the move, even though step 3 already checked: the target can appear mid-batch
222
+ - If yes: record this change as Failed with `Archive directory already exists`, leave `changeRoot` where it is, report any main specs step 8a already synced for it, and continue with the remaining changes
223
+ - If no: move `changeRoot` to the archive directory
224
+
225
+ ```bash
226
+ mkdir -p "<planningHome.changesDir>/archive"
227
+ mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
228
+ ```
229
+
230
+ **Confirm the move did not nest:** `mv` exits 0 even when the target appeared after the check, moving the change *inside* it. If `<planningHome.changesDir>/archive/<target-name>/<change-directory-name>` now exists (the last path segment of `changeRoot`), move that directory back to `changeRoot` and record this change as Failed with `Archive directory already exists`. Never report it as archived.
231
+
232
+ d. **Track outcome** for each change:
233
+ - Success: archived successfully
234
+ - Failed: error during archive or spec verification (record error)
235
+ - Skipped: user chose not to archive (if applicable)
236
+ - Sync skipped: for every delta in `excludedDeltas`, report `sync skipped` with the change, `<capability-path>`, and recorded reason. This is distinct from skipping the archive.
237
+
238
+ 9. **Display summary**
239
+
240
+ Show final results:
241
+
242
+ ```markdown
243
+ ## Bulk Archive Complete
244
+
245
+ Archived 3 changes:
246
+ - schema-management-cli -> archive/2026-01-19-schema-management-cli/
247
+ - project-config -> archive/2026-01-19-project-config/
248
+ - add-oauth -> archive/2026-01-19-add-oauth/
249
+
250
+ Skipped 1 change:
251
+ - add-verify-skill (user chose not to archive incomplete)
252
+
253
+ Spec sync summary:
254
+ - 4 delta specs synced to main specs
255
+ - 1 delta spec sync skipped (add-jwt, identity/user-auth: implementation not found)
256
+ - 1 conflict resolved (identity/user-auth: synced add-oauth, skipped add-jwt)
257
+ ```
258
+
259
+ If any failures:
260
+ ```text
261
+ Failed 1 change:
262
+ - some-change: Archive directory already exists
263
+ ```
264
+
265
+ **Conflict Resolution Examples**
266
+
267
+ Example 1: Only one implemented
268
+ ```text
269
+ Conflict: <planningHome.root>/openspec/specs/auth/spec.md touched by [add-oauth, add-jwt]
270
+
271
+ Checking add-oauth:
272
+ - Delta adds "OAuth Provider Integration" requirement
273
+ - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
274
+
275
+ Checking add-jwt:
276
+ - Delta adds "JWT Token Handling" requirement
277
+ - Searching codebase... no JWT implementation found
278
+
279
+ Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
280
+ ```
281
+
282
+ Example 2: Both implemented
283
+ ```text
284
+ Conflict: <planningHome.root>/openspec/specs/api/spec.md touched by [add-rest-api, add-graphql]
285
+
286
+ Checking add-rest-api (created 2026-01-10):
287
+ - Delta adds "REST Endpoints" requirement
288
+ - Searching codebase... found src/api/rest.ts
289
+
290
+ Checking add-graphql (created 2026-01-15):
291
+ - Delta adds "GraphQL Schema" requirement
292
+ - Searching codebase... found src/api/graphql.ts
293
+
294
+ Resolution: Both implemented. Will apply add-rest-api specs first,
295
+ then add-graphql specs (chronological order, newer takes precedence).
296
+ ```
297
+
298
+ **Output On Success**
299
+
300
+ ```markdown
301
+ ## Bulk Archive Complete
302
+
303
+ Archived N changes:
304
+ - <change-1> -> archive/<target-name-1>/
305
+ - <change-2> -> archive/<target-name-2>/
306
+
307
+ Spec sync summary:
308
+ - N delta specs synced to main specs
309
+ - No conflicts (or: M conflicts resolved)
310
+ ```
311
+
312
+ **Output On Partial Success**
313
+
314
+ ```markdown
315
+ ## Bulk Archive Complete (partial)
316
+
317
+ Archived N changes:
318
+ - <change-1> -> archive/<target-name-1>/
319
+
320
+ Skipped M changes:
321
+ - <change-2> (user chose not to archive incomplete)
322
+
323
+ Failed K changes:
324
+ - <change-3>: Archive directory already exists
325
+ ```
326
+
327
+ **Output When No Changes**
328
+
329
+ ```markdown
330
+ ## No Changes to Archive
331
+
332
+ No active changes found. Create a new change to get started.
333
+ ```
334
+
335
+ **Guardrails**
336
+ - Allow any number of changes (1+ is fine, 2+ is the typical use case)
337
+ - Always prompt for selection, never auto-select
338
+ - Detect spec conflicts early and resolve by checking codebase
339
+ - When both changes are implemented, apply specs in chronological order
340
+ - Skip spec sync only when implementation is missing (warn user)
341
+ - Show clear per-change status before confirming
342
+ - Use single confirmation for entire batch
343
+ - Never archive after the user cancels the confirmation — a cancelled batch archives nothing
344
+ - Track and report all outcomes (success/skip/fail)
345
+ - Preserve .openspec.yaml when moving to archive
346
+ - Archive directory target uses the current date, computed once in step 3d and reused at the move: YYYY-MM-DD-<name>; a name that already starts with a `YYYY-MM-DD-` prefix is used as-is (never stack a second date)
347
+ - If archive target exists, fail that change but continue with others
348
+ - Check every archive target in step 3, before the first main-spec write; a change whose target exists is never synced or moved
349
+ - If sync is requested, run the `/opsx:sync` workflow inline (agent-driven) for each change with included delta specs
350
+ - Carry the per-delta `includedDeltas` and `excludedDeltas` decisions into execution; sync and verify only included deltas
351
+ - Report every excluded delta as `sync skipped` without treating the archive itself as skipped
352
+ - Never archive a change while a spec sync is still in flight — run the sync inline and verify main specs at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` before moving `changeRoot`
353
+ - Fetch archive inputs once per selected root before spec inspection or moves
354
+ - Fetch all required specs-rule snapshots before the batch's first main-spec write or move
355
+ - A failed archive-inputs lookup never blocks the batch; it proceeds with no context or guidance
356
+ - A failed specs instruction lookup stops the whole batch atomically
357
+ - Changes without concrete `artifactPaths.specs.existingOutputPaths` continue without spec sync
358
+ - Apply relevant runtime context across the batch and report conflicts
359
+ - Operation guidance remains advisory; consider every entry and explain rejected advice
360
+ - Keep runtime inputs, conflict analysis, CLI-derived values, and artifact rules separate
361
+ - Artifact rules constrain only written specs
334
362
  - Never copy runtime input or artifact-rule text verbatim into output files