@jspg-ai/coding-bb 0.0.1 → 0.0.2-beta.23

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 (145) hide show
  1. package/cbb/bin/cbb.js +6 -0
  2. package/cbb/bin/cbbm.js +6 -0
  3. package/cbb/dev-standards/rules/cbb-ai-behavior.md +103 -103
  4. package/cbb/dev-standards/rules/cbb-priority.md +55 -55
  5. package/cbb/lib/install/claude-code.js +2 -0
  6. package/cbb/lib/install/init.js +496 -290
  7. package/cbb/lib/install/opencode.js +31 -0
  8. package/cbb/lib/install/qoder.js +2 -0
  9. package/cbb/lib/install/workspaces.js +53 -13
  10. package/cbb/lib/openspec/index.js +3 -3
  11. package/cbb/lib/superpowers/index.js +1 -1
  12. package/cbb/lib/utils/check-update.js +16 -14
  13. package/cbb/lib/utils/gitignore.js +2 -1
  14. package/cbb/lib/utils/output.js +92 -4
  15. package/cbb/lib/utils/version.js +2 -31
  16. package/cbb/lib/wiki/cli.js +25 -25
  17. package/cbb/lib/wiki/index.js +16 -16
  18. package/cbb/tools/cbb-design-to-wiki/SKILL.md +14 -14
  19. package/cbb/tools/cbb-wiki-ops/SKILL.md +22 -22
  20. package/cbb/worktrees/_shared/scripts/find-target-worktree.js +2 -2
  21. package/cbb/worktrees/_shared/scripts/find-workspace-root.js +7 -7
  22. package/cbb/worktrees/_shared/scripts/push-core.js +18 -0
  23. package/cbb/worktrees/commands/{close.md → worktree-close.md} +8 -8
  24. package/cbb/worktrees/commands/{init.md → worktree-init.md} +9 -9
  25. package/cbb/worktrees/commands/{push.md → worktree-push.md} +3 -3
  26. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/SKILL.md +20 -20
  27. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-env.js +4 -4
  28. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-unarchived.js +1 -1
  29. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/delete-branches.js +3 -3
  30. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/discover-apps.js +6 -6
  31. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-close}/scripts/find-target-worktree.js +2 -2
  32. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-close}/scripts/find-workspace-root.js +7 -7
  33. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/remove-worktrees.js +4 -4
  34. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/safety-check.js +4 -4
  35. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/SKILL.md +81 -107
  36. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/auto-open.js +1 -1
  37. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env-deep.js +4 -4
  38. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env.js +6 -6
  39. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-repos.js +4 -4
  40. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-branches.js +4 -4
  41. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-worktrees.js +8 -7
  42. package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-init}/scripts/find-workspace-root.js +7 -7
  43. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/install-ai.js +33 -33
  44. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/parse-config.js +7 -7
  45. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/push-branches.js +9 -7
  46. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/push-core.js +18 -0
  47. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/sync-repos.js +10 -12
  48. package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/update-gitignore.js +19 -6
  49. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/SKILL.md +16 -16
  50. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/commit-worktrees.js +2 -2
  51. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/find-target-worktree.js +2 -2
  52. package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-push}/scripts/find-workspace-root.js +7 -7
  53. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-core.js +18 -0
  54. package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-worktrees.js +7 -5
  55. package/config/workspace-config.sample.json +18 -0
  56. package/config/workspaces.json +11 -6
  57. package/openspec/.version +6 -6
  58. package/openspec/commands/apply.md +7 -7
  59. package/openspec/commands/archive.md +7 -7
  60. package/openspec/commands/bulk-archive.md +7 -7
  61. package/openspec/commands/continue.md +7 -7
  62. package/openspec/commands/explore.md +7 -7
  63. package/openspec/commands/ff.md +7 -7
  64. package/openspec/commands/new.md +7 -7
  65. package/openspec/commands/onboard.md +7 -7
  66. package/openspec/commands/propose.md +7 -7
  67. package/openspec/commands/sync.md +7 -7
  68. package/openspec/commands/update.md +7 -7
  69. package/openspec/commands/verify.md +7 -7
  70. package/openspec/skills/openspec-apply-change/SKILL.md +187 -187
  71. package/openspec/skills/openspec-archive-change/SKILL.md +181 -181
  72. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +338 -338
  73. package/openspec/skills/openspec-continue-change/SKILL.md +117 -117
  74. package/openspec/skills/openspec-explore/SKILL.md +342 -342
  75. package/openspec/skills/openspec-ff-change/SKILL.md +116 -116
  76. package/openspec/skills/openspec-new-change/SKILL.md +76 -76
  77. package/openspec/skills/openspec-onboard/SKILL.md +560 -560
  78. package/openspec/skills/openspec-propose/SKILL.md +162 -162
  79. package/openspec/skills/openspec-sync-specs/SKILL.md +261 -261
  80. package/openspec/skills/openspec-update-change/SKILL.md +90 -90
  81. package/openspec/skills/openspec-verify-change/SKILL.md +174 -174
  82. package/package.json +4 -3
  83. package/superpowers/.version +6 -6
  84. package/superpowers/skills/brainstorming/SKILL.md +250 -250
  85. package/superpowers/skills/brainstorming/scripts/helper.js +167 -167
  86. package/superpowers/skills/brainstorming/scripts/start-server.sh +209 -209
  87. package/superpowers/skills/brainstorming/scripts/stop-server.sh +120 -120
  88. package/superpowers/skills/brainstorming/spec-document-reviewer-prompt.md +49 -49
  89. package/superpowers/skills/brainstorming/visual-companion.md +299 -299
  90. package/superpowers/skills/dispatching-parallel-agents/SKILL.md +167 -167
  91. package/superpowers/skills/executing-plans/SKILL.md +64 -64
  92. package/superpowers/skills/finishing-a-development-branch/SKILL.md +225 -225
  93. package/superpowers/skills/receiving-code-review/SKILL.md +205 -205
  94. package/superpowers/skills/requesting-code-review/SKILL.md +95 -95
  95. package/superpowers/skills/requesting-code-review/code-reviewer.md +181 -181
  96. package/superpowers/skills/subagent-driven-development/SKILL.md +568 -568
  97. package/superpowers/skills/subagent-driven-development/implementer-prompt.md +154 -154
  98. package/superpowers/skills/subagent-driven-development/re-review-prompt.md +115 -115
  99. package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +207 -207
  100. package/superpowers/skills/systematic-debugging/CREATION-LOG.md +119 -119
  101. package/superpowers/skills/systematic-debugging/SKILL.md +283 -283
  102. package/superpowers/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
  103. package/superpowers/skills/systematic-debugging/condition-based-waiting.md +115 -115
  104. package/superpowers/skills/systematic-debugging/defense-in-depth.md +122 -122
  105. package/superpowers/skills/systematic-debugging/find-polluter.sh +72 -72
  106. package/superpowers/skills/systematic-debugging/root-cause-tracing.md +169 -169
  107. package/superpowers/skills/systematic-debugging/test-academic.md +14 -14
  108. package/superpowers/skills/systematic-debugging/test-pressure-1.md +58 -58
  109. package/superpowers/skills/systematic-debugging/test-pressure-2.md +68 -68
  110. package/superpowers/skills/systematic-debugging/test-pressure-3.md +69 -69
  111. package/superpowers/skills/test-driven-development/SKILL.md +320 -320
  112. package/superpowers/skills/test-driven-development/writing-good-tests.md +198 -198
  113. package/superpowers/skills/using-git-worktrees/SKILL.md +167 -167
  114. package/superpowers/skills/using-superpowers/SKILL.md +63 -63
  115. package/superpowers/skills/using-superpowers/references/antigravity-tools.md +23 -23
  116. package/superpowers/skills/using-superpowers/references/codex-tools.md +108 -108
  117. package/superpowers/skills/using-superpowers/references/gemini-tools.md +63 -63
  118. package/superpowers/skills/using-superpowers/references/hermes-tools.md +56 -56
  119. package/superpowers/skills/using-superpowers/references/pi-tools.md +16 -16
  120. package/superpowers/skills/verification-before-completion/SKILL.md +120 -120
  121. package/superpowers/skills/writing-plans/SKILL.md +171 -171
  122. package/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +49 -49
  123. package/superpowers/skills/writing-skills/SKILL.md +679 -679
  124. package/superpowers/skills/writing-skills/anthropic-best-practices.md +1150 -1150
  125. package/superpowers/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -189
  126. package/superpowers/skills/writing-skills/persuasion-principles.md +187 -187
  127. package/superpowers/skills/writing-skills/render-graphs.js +169 -169
  128. package/superpowers/skills/writing-skills/testing-skills-with-subagents.md +384 -384
  129. package/cbb/worktrees/commands/extend.md +0 -65
  130. package/cbb/worktrees/skills/openspec-close-worktree/scripts/find-target-worktree.js +0 -96
  131. package/cbb/worktrees/skills/openspec-extend-worktree/SKILL.md +0 -390
  132. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-env.js +0 -95
  133. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-repos.js +0 -98
  134. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/create-branches-and-worktrees.js +0 -135
  135. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/install-ai.js +0 -150
  136. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/list-available-apps.js +0 -88
  137. package/cbb/worktrees/skills/openspec-extend-worktree/scripts/sync-repos.js +0 -93
  138. package/cbb/worktrees/skills/openspec-init-worktree/scripts/find-workspace-root.js +0 -67
  139. package/cbb/worktrees/skills/openspec-init-worktree/scripts/generate-app-options.js +0 -93
  140. package/cbb/worktrees/skills/openspec-init-worktree/scripts/push-core.js +0 -136
  141. package/cbb/worktrees/skills/openspec-push-worktrees/scripts/silence-popup.js +0 -23
  142. package/config/config.sample.json +0 -16
  143. /package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/silence-popup.js +0 -0
  144. /package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/silence-popup.js +0 -0
  145. /package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-push}/scripts/silence-popup.js +0 -0
@@ -1,261 +1,261 @@
1
- ---
2
- name: openspec-sync-specs
3
- description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
4
- allowed-tools: Bash(openspec:*)
5
- license: MIT
6
- compatibility: Requires openspec CLI.
7
- metadata:
8
- author: openspec
9
- version: "1.0"
10
- ---
11
-
12
- Sync delta specs from a change to main specs.
13
-
14
- This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
15
-
16
- **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.
17
-
18
- `<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.
19
-
20
- **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
21
-
22
- **Steps**
23
-
24
- 1. **Select the change**
25
-
26
- If a name is provided, use it. Otherwise:
27
- - Infer from conversation context if the user mentioned a change
28
- - Auto-select if only one active change exists
29
- - If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
30
-
31
- When prompting, show changes that have delta specs (under `specs/` directory).
32
-
33
- Always announce: "Using change: <name>" and how to override (e.g., `/openspec-sync-specs <other>`).
34
-
35
- 2. **Resolve change context**
36
-
37
- Run:
38
- ```bash
39
- openspec status --change "<name>" --json
40
- ```
41
-
42
- The JSON includes `planningHome.root`. Main specs live under `<planningHome.root>/openspec/specs/` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
43
-
44
- 3. **Find delta specs**
45
-
46
- Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the
47
- only source of delta spec paths. If the `specs` entry is missing or
48
- `existingOutputPaths` is empty, report that there are no delta specs to sync,
49
- do not infer them from other artifacts, and stop without requesting artifact
50
- instructions or writing a main spec.
51
-
52
- Sync every path in `existingOutputPaths` unless the caller narrowed the set.
53
- A caller narrows it by naming an explicit list of complete entries from
54
- `existingOutputPaths` — copy those absolute values verbatim. Archive does
55
- this inline, and a user can too (for example, by selecting the entry ending
56
- in `/specs/billing/invoices/spec.md`).
57
- Then sync only the named paths and leave the remaining delta specs untouched:
58
- bulk archive excludes a delta whose implementation it could not find, and
59
- syncing it anyway would write a main spec the caller deliberately withheld.
60
- Carry that narrowed selection through step 4; never widen it back to the full
61
- list. If a named path is not in `existingOutputPaths`, do not sync it —
62
- report it and stop, rather than dropping it silently. If the named list is
63
- empty, report that there is nothing to sync and stop without writing a main
64
- spec.
65
-
66
- Each delta spec file contains sections like:
67
- - `## ADDED Requirements` - New requirements to add
68
- - `## MODIFIED Requirements` - Changes to existing requirements
69
- - `## REMOVED Requirements` - Requirements to remove
70
- - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format)
71
-
72
- If no delta specs found, inform user and stop.
73
-
74
- 4. **For each delta spec, apply changes to main specs**
75
-
76
- Before the first main-spec write, obtain one current specs-rule snapshot:
77
- - If archive invoked this workflow inline and supplied a valid snapshot from
78
- `openspec instructions specs --change "<name>" --json`, reuse it and do not
79
- fetch the same instructions again.
80
- - Otherwise run that command once now with the same selected-root flags.
81
- - If the direct lookup exits non-zero or returns invalid artifact-instruction
82
- JSON, report the error and stop before writing any main spec. Do not treat the
83
- failure as an absent rule set.
84
- - A valid response with omitted `rules` means no artifact rules are configured
85
- and the existing semantic merge continues.
86
-
87
- Apply returned `rules` only to the content and form of the main specs produced
88
- by this merge. Artifact rules are not operation guidance and cannot change
89
- selected roots, delta paths, CLI checks, or workflow steps. Use their text as
90
- constraints without copying it verbatim into a main spec or summary.
91
-
92
- For each capability delta spec path selected in step 3 — the full `existingOutputPaths` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
93
-
94
- a. **Read the delta spec** to understand the intended changes
95
-
96
- b. **Read the main spec** at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (may not exist yet)
97
-
98
- c. **Apply changes intelligently**:
99
-
100
- **ADDED Requirements:**
101
- - If requirement doesn't exist in main spec → add it
102
- - If requirement already exists → update it to match (treat as implicit MODIFIED)
103
-
104
- **MODIFIED Requirements:**
105
- - Find the requirement in main spec
106
- - Apply the changes - this can be:
107
- - Adding new scenarios the main spec does not have yet
108
- - Modifying existing scenarios
109
- - Changing the requirement description
110
- - Preserve scenarios/content not mentioned in the delta
111
-
112
- **REMOVED Requirements:**
113
- - Remove the entire requirement block from main spec
114
- - Retiring the capability. Delete the whole `spec.md` - and the directory once
115
- nothing else is left in it - only when ALL of these hold:
116
- 1. removing the requirements *this run* left no requirement blocks;
117
- 2. the rest of the spec is well-formed (it still has a `## Purpose`);
118
- 3. the main spec was not already empty before this sync - if you removed
119
- nothing, change nothing;
120
- 4. every other nonblank line in the whole file is accounted for as the
121
- title, Purpose, Requirements header, or a canonical requirement's
122
- statement, scenarios, or fenced examples;
123
- 5. the change's `.openspec.yaml` declares `retire_capabilities: true`;
124
- 6. the `spec.md` resolves inside the real specs root (do not follow a
125
- capability-directory symlink to delete an external file).
126
- If removing the selected requirements would leave no requirement blocks and
127
- any retirement condition is not satisfied, do not modify the main spec. Stop
128
- the sync for that capability, report the blocking condition, and tell the user
129
- how to resolve it. Never write or leave an empty `## Requirements` section.
130
- When only the marker is missing, say that too - it is the one thing the user
131
- can add to make the retirement go through.
132
- - Deleting the file also deletes its `## Purpose`; any other section blocks
133
- retirement. Name Purpose when you report the retirement. Include a pasteable
134
- `git checkout` only when the spec lived in the caller's checkout;
135
- otherwise give checkout-scoped recovery guidance.
136
-
137
- **RENAMED Requirements:**
138
- - Find the FROM requirement, rename to TO
139
-
140
- **`## Purpose` in the delta:**
141
- - The main spec already has one and it is authoritative - leave it alone
142
- (this is what `openspec archive` does; it warns and moves on)
143
-
144
- d. **Create new main spec** if capability doesn't exist yet:
145
- - Create `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
146
- - Add Purpose section: copy the delta's `## Purpose` body verbatim when it has one
147
- (this is what `openspec archive` does); only write a brief TBD placeholder when it does not
148
- - Add Requirements section with the ADDED requirements
149
- - Follow the **Main Spec Format Reference** below
150
-
151
- 5. **Validate updated main specs**
152
-
153
- Run `openspec validate --specs` with the same selected-root flags used earlier.
154
- If validation fails, report the problems and do not claim the sync succeeded.
155
-
156
- 6. **Show summary**
157
-
158
- After applying all changes, summarize:
159
- - Which capabilities were updated
160
- - What changes were made (requirements added/modified/removed/renamed)
161
- - Any new main spec left with a TBD Purpose placeholder, so it gets written
162
- now rather than lingering
163
- - Any capability retired, naming the deleted `spec.md`, its Purpose, and
164
- either a pasteable `git checkout` or checkout-scoped recovery guidance
165
-
166
- **Delta Spec Format Reference**
167
-
168
- ```markdown
169
- ## Purpose
170
-
171
- Only on a delta that introduces a brand-new capability. Seeds the new main spec.
172
-
173
- ## ADDED Requirements
174
-
175
- ### Requirement: New Feature
176
- The system SHALL do something new.
177
-
178
- #### Scenario: Basic case
179
- - **WHEN** user does X
180
- - **THEN** system does Y
181
-
182
- ## MODIFIED Requirements
183
-
184
- ### Requirement: Existing Feature
185
- The system SHALL keep doing the existing thing, now also handling A.
186
-
187
- #### Scenario: Scenario the main spec already has
188
- - **WHEN** user does X
189
- - **THEN** system does Y
190
-
191
- #### Scenario: New scenario to add
192
- - **WHEN** user does A
193
- - **THEN** system does B
194
-
195
- ## REMOVED Requirements
196
-
197
- ### Requirement: Deprecated Feature
198
-
199
- ## RENAMED Requirements
200
-
201
- - FROM: `### Requirement: Old Name`
202
- - TO: `### Requirement: New Name`
203
- ```
204
-
205
- **Main Spec Format Reference**
206
-
207
- Main specs are what the delta merges INTO. They must never contain delta operation headers (`## ADDED/MODIFIED/REMOVED/RENAMED Requirements`) - after syncing, every requirement lives under a single `## Requirements` section:
208
-
209
- ```markdown
210
- # <capability> Specification
211
-
212
- ## Purpose
213
- Short description of what this capability does and why it exists.
214
-
215
- ## Requirements
216
-
217
- ### Requirement: New Feature
218
- The system SHALL do something new.
219
-
220
- #### Scenario: Basic case
221
- - **WHEN** user does X
222
- - **THEN** system does Y
223
- ```
224
-
225
- **Key Principle: Intelligent Merging**
226
-
227
- Unlike programmatic merging, you merge rather than overwrite:
228
- - A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. `openspec validate` and `openspec archive` both reject one that drops a scenario the main spec still has.
229
- - Keep anything the delta does not mention, in the main spec's existing order
230
- - Use your judgment to merge changes sensibly
231
-
232
- **Output On Success**
233
-
234
- ```markdown
235
- ## Specs Synced: <change-name>
236
-
237
- Updated main specs:
238
-
239
- **<capability-1>**:
240
- - Added requirement: "New Feature"
241
- - Modified requirement: "Existing Feature" (added 1 scenario)
242
-
243
- **<capability-2>**:
244
- - Created new spec file
245
- - Added requirement: "Another Feature"
246
-
247
- Main specs are now updated. The change remains active - archive when implementation is complete.
248
- ```
249
-
250
- **Guardrails**
251
- - Read both delta and main specs before making changes
252
- - Preserve existing content not mentioned in delta
253
- - Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
254
- - If something is unclear, ask for clarification
255
- - Show what you're changing as you go
256
- - The operation should be idempotent - running twice should give same result
257
- - Use only `artifactPaths.specs.existingOutputPaths`; never infer delta specs from unrelated artifacts
258
- - Honor a caller-supplied subset of `existingOutputPaths`; never widen it back to the full list
259
- - Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
260
- - Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
261
- - Artifact rules constrain only the specs being written and are never copied into output files
1
+ ---
2
+ name: openspec-sync-specs
3
+ description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
4
+ allowed-tools: Bash(openspec:*)
5
+ license: MIT
6
+ compatibility: Requires openspec CLI.
7
+ metadata:
8
+ author: openspec
9
+ version: "1.0"
10
+ ---
11
+
12
+ Sync delta specs from a change to main specs.
13
+
14
+ This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
15
+
16
+ **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.
17
+
18
+ `<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.
19
+
20
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
21
+
22
+ **Steps**
23
+
24
+ 1. **Select the change**
25
+
26
+ If a name is provided, use it. Otherwise:
27
+ - Infer from conversation context if the user mentioned a change
28
+ - Auto-select if only one active change exists
29
+ - If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
30
+
31
+ When prompting, show changes that have delta specs (under `specs/` directory).
32
+
33
+ Always announce: "Using change: <name>" and how to override (e.g., `/openspec-sync-specs <other>`).
34
+
35
+ 2. **Resolve change context**
36
+
37
+ Run:
38
+ ```bash
39
+ openspec status --change "<name>" --json
40
+ ```
41
+
42
+ The JSON includes `planningHome.root`. Main specs live under `<planningHome.root>/openspec/specs/` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
43
+
44
+ 3. **Find delta specs**
45
+
46
+ Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the
47
+ only source of delta spec paths. If the `specs` entry is missing or
48
+ `existingOutputPaths` is empty, report that there are no delta specs to sync,
49
+ do not infer them from other artifacts, and stop without requesting artifact
50
+ instructions or writing a main spec.
51
+
52
+ Sync every path in `existingOutputPaths` unless the caller narrowed the set.
53
+ A caller narrows it by naming an explicit list of complete entries from
54
+ `existingOutputPaths` — copy those absolute values verbatim. Archive does
55
+ this inline, and a user can too (for example, by selecting the entry ending
56
+ in `/specs/billing/invoices/spec.md`).
57
+ Then sync only the named paths and leave the remaining delta specs untouched:
58
+ bulk archive excludes a delta whose implementation it could not find, and
59
+ syncing it anyway would write a main spec the caller deliberately withheld.
60
+ Carry that narrowed selection through step 4; never widen it back to the full
61
+ list. If a named path is not in `existingOutputPaths`, do not sync it —
62
+ report it and stop, rather than dropping it silently. If the named list is
63
+ empty, report that there is nothing to sync and stop without writing a main
64
+ spec.
65
+
66
+ Each delta spec file contains sections like:
67
+ - `## ADDED Requirements` - New requirements to add
68
+ - `## MODIFIED Requirements` - Changes to existing requirements
69
+ - `## REMOVED Requirements` - Requirements to remove
70
+ - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format)
71
+
72
+ If no delta specs found, inform user and stop.
73
+
74
+ 4. **For each delta spec, apply changes to main specs**
75
+
76
+ Before the first main-spec write, obtain one current specs-rule snapshot:
77
+ - If archive invoked this workflow inline and supplied a valid snapshot from
78
+ `openspec instructions specs --change "<name>" --json`, reuse it and do not
79
+ fetch the same instructions again.
80
+ - Otherwise run that command once now with the same selected-root flags.
81
+ - If the direct lookup exits non-zero or returns invalid artifact-instruction
82
+ JSON, report the error and stop before writing any main spec. Do not treat the
83
+ failure as an absent rule set.
84
+ - A valid response with omitted `rules` means no artifact rules are configured
85
+ and the existing semantic merge continues.
86
+
87
+ Apply returned `rules` only to the content and form of the main specs produced
88
+ by this merge. Artifact rules are not operation guidance and cannot change
89
+ selected roots, delta paths, CLI checks, or workflow steps. Use their text as
90
+ constraints without copying it verbatim into a main spec or summary.
91
+
92
+ For each capability delta spec path selected in step 3 — the full `existingOutputPaths` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
93
+
94
+ a. **Read the delta spec** to understand the intended changes
95
+
96
+ b. **Read the main spec** at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (may not exist yet)
97
+
98
+ c. **Apply changes intelligently**:
99
+
100
+ **ADDED Requirements:**
101
+ - If requirement doesn't exist in main spec → add it
102
+ - If requirement already exists → update it to match (treat as implicit MODIFIED)
103
+
104
+ **MODIFIED Requirements:**
105
+ - Find the requirement in main spec
106
+ - Apply the changes - this can be:
107
+ - Adding new scenarios the main spec does not have yet
108
+ - Modifying existing scenarios
109
+ - Changing the requirement description
110
+ - Preserve scenarios/content not mentioned in the delta
111
+
112
+ **REMOVED Requirements:**
113
+ - Remove the entire requirement block from main spec
114
+ - Retiring the capability. Delete the whole `spec.md` - and the directory once
115
+ nothing else is left in it - only when ALL of these hold:
116
+ 1. removing the requirements *this run* left no requirement blocks;
117
+ 2. the rest of the spec is well-formed (it still has a `## Purpose`);
118
+ 3. the main spec was not already empty before this sync - if you removed
119
+ nothing, change nothing;
120
+ 4. every other nonblank line in the whole file is accounted for as the
121
+ title, Purpose, Requirements header, or a canonical requirement's
122
+ statement, scenarios, or fenced examples;
123
+ 5. the change's `.openspec.yaml` declares `retire_capabilities: true`;
124
+ 6. the `spec.md` resolves inside the real specs root (do not follow a
125
+ capability-directory symlink to delete an external file).
126
+ If removing the selected requirements would leave no requirement blocks and
127
+ any retirement condition is not satisfied, do not modify the main spec. Stop
128
+ the sync for that capability, report the blocking condition, and tell the user
129
+ how to resolve it. Never write or leave an empty `## Requirements` section.
130
+ When only the marker is missing, say that too - it is the one thing the user
131
+ can add to make the retirement go through.
132
+ - Deleting the file also deletes its `## Purpose`; any other section blocks
133
+ retirement. Name Purpose when you report the retirement. Include a pasteable
134
+ `git checkout` only when the spec lived in the caller's checkout;
135
+ otherwise give checkout-scoped recovery guidance.
136
+
137
+ **RENAMED Requirements:**
138
+ - Find the FROM requirement, rename to TO
139
+
140
+ **`## Purpose` in the delta:**
141
+ - The main spec already has one and it is authoritative - leave it alone
142
+ (this is what `openspec archive` does; it warns and moves on)
143
+
144
+ d. **Create new main spec** if capability doesn't exist yet:
145
+ - Create `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
146
+ - Add Purpose section: copy the delta's `## Purpose` body verbatim when it has one
147
+ (this is what `openspec archive` does); only write a brief TBD placeholder when it does not
148
+ - Add Requirements section with the ADDED requirements
149
+ - Follow the **Main Spec Format Reference** below
150
+
151
+ 5. **Validate updated main specs**
152
+
153
+ Run `openspec validate --specs` with the same selected-root flags used earlier.
154
+ If validation fails, report the problems and do not claim the sync succeeded.
155
+
156
+ 6. **Show summary**
157
+
158
+ After applying all changes, summarize:
159
+ - Which capabilities were updated
160
+ - What changes were made (requirements added/modified/removed/renamed)
161
+ - Any new main spec left with a TBD Purpose placeholder, so it gets written
162
+ now rather than lingering
163
+ - Any capability retired, naming the deleted `spec.md`, its Purpose, and
164
+ either a pasteable `git checkout` or checkout-scoped recovery guidance
165
+
166
+ **Delta Spec Format Reference**
167
+
168
+ ```markdown
169
+ ## Purpose
170
+
171
+ Only on a delta that introduces a brand-new capability. Seeds the new main spec.
172
+
173
+ ## ADDED Requirements
174
+
175
+ ### Requirement: New Feature
176
+ The system SHALL do something new.
177
+
178
+ #### Scenario: Basic case
179
+ - **WHEN** user does X
180
+ - **THEN** system does Y
181
+
182
+ ## MODIFIED Requirements
183
+
184
+ ### Requirement: Existing Feature
185
+ The system SHALL keep doing the existing thing, now also handling A.
186
+
187
+ #### Scenario: Scenario the main spec already has
188
+ - **WHEN** user does X
189
+ - **THEN** system does Y
190
+
191
+ #### Scenario: New scenario to add
192
+ - **WHEN** user does A
193
+ - **THEN** system does B
194
+
195
+ ## REMOVED Requirements
196
+
197
+ ### Requirement: Deprecated Feature
198
+
199
+ ## RENAMED Requirements
200
+
201
+ - FROM: `### Requirement: Old Name`
202
+ - TO: `### Requirement: New Name`
203
+ ```
204
+
205
+ **Main Spec Format Reference**
206
+
207
+ Main specs are what the delta merges INTO. They must never contain delta operation headers (`## ADDED/MODIFIED/REMOVED/RENAMED Requirements`) - after syncing, every requirement lives under a single `## Requirements` section:
208
+
209
+ ```markdown
210
+ # <capability> Specification
211
+
212
+ ## Purpose
213
+ Short description of what this capability does and why it exists.
214
+
215
+ ## Requirements
216
+
217
+ ### Requirement: New Feature
218
+ The system SHALL do something new.
219
+
220
+ #### Scenario: Basic case
221
+ - **WHEN** user does X
222
+ - **THEN** system does Y
223
+ ```
224
+
225
+ **Key Principle: Intelligent Merging**
226
+
227
+ Unlike programmatic merging, you merge rather than overwrite:
228
+ - A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. `openspec validate` and `openspec archive` both reject one that drops a scenario the main spec still has.
229
+ - Keep anything the delta does not mention, in the main spec's existing order
230
+ - Use your judgment to merge changes sensibly
231
+
232
+ **Output On Success**
233
+
234
+ ```markdown
235
+ ## Specs Synced: <change-name>
236
+
237
+ Updated main specs:
238
+
239
+ **<capability-1>**:
240
+ - Added requirement: "New Feature"
241
+ - Modified requirement: "Existing Feature" (added 1 scenario)
242
+
243
+ **<capability-2>**:
244
+ - Created new spec file
245
+ - Added requirement: "Another Feature"
246
+
247
+ Main specs are now updated. The change remains active - archive when implementation is complete.
248
+ ```
249
+
250
+ **Guardrails**
251
+ - Read both delta and main specs before making changes
252
+ - Preserve existing content not mentioned in delta
253
+ - Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
254
+ - If something is unclear, ask for clarification
255
+ - Show what you're changing as you go
256
+ - The operation should be idempotent - running twice should give same result
257
+ - Use only `artifactPaths.specs.existingOutputPaths`; never infer delta specs from unrelated artifacts
258
+ - Honor a caller-supplied subset of `existingOutputPaths`; never widen it back to the full list
259
+ - Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
260
+ - Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
261
+ - Artifact rules constrain only the specs being written and are never copied into output files