Skip to content

Commit e4e1b3a

Browse files
committed
chore: openspec update
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent efb2c27 commit e4e1b3a

27 files changed

Lines changed: 2779 additions & 883 deletions

File tree

‎.opencode/commands/opsx-apply.md‎

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
description: 'Implement tasks from an OpenSpec change (Experimental)'
2+
description: Implement tasks from an OpenSpec change (Experimental)
33
---
44

55
Implement tasks from an OpenSpec change.
66

7-
**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.
7+
**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.
88

99
**Input**: Optionally specify a change name (e.g., `/opsx-apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
1010

@@ -15,7 +15,7 @@ Implement tasks from an OpenSpec change.
1515
If a name is provided, use it. Otherwise:
1616
- Infer from conversation context if the user mentioned a change
1717
- Auto-select if only one active change exists
18-
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
18+
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
1919

2020
Always announce: "Using change: <name>" and how to override (e.g., `/opsx-apply <other>`).
2121

@@ -37,43 +37,23 @@ Implement tasks from an OpenSpec change.
3737
```
3838

3939
This returns:
40-
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
40+
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
4141
- Progress (total, complete, remaining)
4242
- Task list with status
4343
- Dynamic instruction based on current state
44-
- Optional `context`: current required project instruction input from the selected root
45-
- Optional `operationGuidance`: current advisory guidance for apply
4644

4745
**Handle states:**
48-
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx-continue` (if it is not installed, run `openspec status --change "<name>" --json` to see the next artifact and `openspec instructions <artifact-id> --change "<name>" --json` for how to create it)
46+
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx-continue`
4947
- If `state: "all_done"`: congratulate, suggest archive
5048
- Otherwise: proceed to implementation
5149

52-
Treat `context` as a required prompt-level input. Read and consider it, and
53-
apply relevant project facts, conventions, and constraints while implementing.
54-
Treat `operationGuidance` as optional additive advice. Read and consider every
55-
entry, and follow entries that are applicable and compatible with the built-in
56-
workflow.
57-
58-
Keep both fields separate from CLI-returned state, missing artifacts, tasks,
59-
progress, `contextFiles`, and the built-in `instruction`. They are not
60-
evidence of task completion, do not replace the built-in instruction, and do
61-
not permit bypassing a blocked state. If context conflicts with the built-in
62-
instruction, an explicit user choice, or a CLI-controlled value, report the
63-
conflict and preserve the controlling value. If guidance is inapplicable or
64-
conflicts with those controlling inputs, do not follow it and explain why.
65-
These are prompt-level behavior contracts, not enforceable checks.
66-
6750
4. **Read context files**
6851

6952
Read every file path listed under `contextFiles` from the apply instructions output.
7053
The files depend on the schema being used:
7154
- **spec-driven**: proposal, specs, design, tasks
7255
- Other schemas: follow the contextFiles from CLI output
7356

74-
Do not copy `context` or `operationGuidance` verbatim into implementation
75-
files or planning artifacts unless the user separately asks for that content.
76-
7757
5. **Show current progress**
7858

7959
Display:
@@ -94,7 +74,6 @@ Implement tasks from an OpenSpec change.
9474
**Pause if:**
9575
- Task is unclear → ask for clarification
9676
- Implementation reveals a design issue → suggest updating artifacts
97-
- A task needs work beyond what the spec and tasks describe, or you are tempted to drop, narrow, defer, or accept exceptions to specified behavior to make it fit → surface the added scope and ask; do not absorb it silently
9877
- Error or blocker encountered → report and wait for guidance
9978
- User interrupts
10079

@@ -166,14 +145,7 @@ What would you like to do?
166145
- Keep code changes minimal and scoped to each task
167146
- Update task checkbox immediately after completing each task
168147
- Pause on errors, blockers, or unclear requirements - don't guess
169-
- When a task needs work beyond what the spec describes, surface the added scope and pause - never silently narrow, defer, or simplify away specified behavior
170-
- Only mark a task `- [x]` when its specified behavior is fully implemented, not when it is partially done or deferred
171148
- Use contextFiles from CLI output, don't assume specific file names
172-
- Do not use context or operation guidance as proof that a task is complete
173-
- Apply relevant project context; report conflicts with controlling workflow inputs
174-
- Consider every guidance entry; explain any inapplicable or conflicting advice
175-
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
176-
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
177149

178150
**Fluid Workflow Integration**
179151

‎.opencode/commands/opsx-archive.md‎

Lines changed: 23 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,23 @@
11
---
2-
description: 'Archive a completed change in the experimental workflow'
2+
description: Archive a completed change in the experimental workflow
33
---
44

55
Archive a completed change in the experimental workflow.
66

7-
**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.
8-
9-
`<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.
7+
**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.
108

119
**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.
1210

1311
**Steps**
1412

15-
1. **Select the change**
13+
1. **If no change name provided, prompt for selection**
1614

17-
If a name is provided, use it. Otherwise:
18-
- Infer from conversation context if the user mentioned a change
19-
- Auto-select if only one active change exists
20-
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
15+
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
2116

22-
When prompting, show only active changes (not already archived).
17+
Show only active changes (not already archived).
2318
Include the schema used for each change if available.
2419

25-
Always announce: "Using change: <name>" and how to override (e.g., `/opsx-archive <other>`).
26-
27-
**Load current archive inputs before the existing archive checks:**
28-
29-
After resolving the selected change and planning root, run:
30-
31-
```bash
32-
openspec instructions archive --change "<name>" --json
33-
```
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.
20+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
5521

5622
2. **Check artifact completion status**
5723

@@ -60,9 +26,9 @@ Archive a completed change in the experimental workflow.
6026
Parse the JSON to understand:
6127
- `schemaName`: The workflow being used
6228
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
63-
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
29+
- `artifacts`: List of artifacts with their status (`done` or other)
6430

65-
**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
31+
**If any artifacts are not `done`:**
6632
- Display warning listing incomplete artifacts
6733
- Prompt user for confirmation to continue
6834
- Proceed if user confirms
@@ -82,44 +48,18 @@ Archive a completed change in the experimental workflow.
8248

8349
4. **Assess delta spec sync state**
8450

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.
51+
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
8952

9053
**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)
54+
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
9255
- Determine what changes would be applied (adds, modifications, removals, renames)
9356
- Show a combined summary before prompting
9457

9558
**Prompt options:**
9659
- If changes needed: "Sync now (recommended)", "Archive without syncing"
9760
- If already synced: "Archive now", "Sync anyway", "Cancel"
9861

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.
62+
If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
12363

12464
5. **Perform the archive**
12565

@@ -129,14 +69,14 @@ Archive a completed change in the experimental workflow.
12969
mkdir -p "<planningHome.changesDir>/archive"
13070
```
13171

132-
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`).
72+
Generate target name using current date: `YYYY-MM-DD-<change-name>`
13373

13474
**Check if target already exists:**
13575
- If yes: Fail with error, suggest renaming existing archive or using different date
13676
- If no: Move `changeRoot` to the archive directory
13777

13878
```bash
139-
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
79+
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
14080
```
14181

14282
6. **Display summary**
@@ -150,42 +90,41 @@ Archive a completed change in the experimental workflow.
15090

15191
**Output On Success**
15292

153-
```markdown
93+
```
15494
## Archive Complete
15595
15696
**Change:** <change-name>
15797
**Schema:** <schema-name>
158-
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
98+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
15999
**Specs:** ✓ Synced to main specs
160100
161101
All artifacts complete. All tasks complete.
162102
```
163103

164104
**Output On Success (No Delta Specs)**
165105

166-
```markdown
106+
```
167107
## Archive Complete
168108
169109
**Change:** <change-name>
170110
**Schema:** <schema-name>
171-
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
111+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
172112
**Specs:** No delta specs
173113
174114
All artifacts complete. All tasks complete.
175115
```
176116

177117
**Output On Success With Warnings**
178118

179-
```markdown
119+
```
180120
## Archive Complete (with warnings)
181121
182122
**Change:** <change-name>
183123
**Schema:** <schema-name>
184-
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
124+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
185125
**Specs:** Sync skipped (user chose to skip)
186126
187127
**Warnings:**
188-
189128
- Archived with 2 incomplete artifacts
190129
- Archived with 3 incomplete tasks
191130
- Delta spec sync was skipped (user chose to skip)
@@ -195,33 +134,26 @@ Review the archive if this was not intentional.
195134

196135
**Output On Error (Archive Exists)**
197136

198-
```markdown
137+
```
199138
## Archive Failed
200139
201140
**Change:** <change-name>
202-
**Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
141+
**Target:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
203142
204143
Target archive directory already exists.
205144
206145
**Options:**
207-
208146
1. Rename the existing archive
209147
2. Delete the existing archive if it's a duplicate
210148
3. Wait until a different date to archive
211149
```
212150

213151
**Guardrails**
214152

215-
- Announce the selected change; prompt for selection when it is ambiguous
153+
- Always prompt for change selection if not provided
216154
- Use artifact graph (openspec status --json) for completion checking
217155
- Don't block archive on warnings - just inform and confirm
218156
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
219157
- Show clear summary of what happened
220-
- If sync is requested, run the `/opsx-sync` workflow inline (agent-driven)
221-
- Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
158+
- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
222159
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
223-
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
224-
- Consider every guidance entry and explain any inapplicable or conflicting advice
225-
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
226-
- Artifact rules constrain only the specs being written and are never operation guidance
227-
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files

0 commit comments

Comments
 (0)