Skip to content

Commit f99fa0a

Browse files
authored
chore: add openspec workflow (#24)
* chore: add openspec * chore: openspec init * docs: add openspec capability specs * test: tag tests with openspec scenarios * chore: add openspec validation tasks * chore: validate openspec in ci * docs: document openspec workflow * chore: update stack tool version * fix: aube permissions * fix: install openspec from mise * fix: upgrade mise action * fix: run mise-action unlocked * fix: remove mise lock
1 parent 7b17a68 commit f99fa0a

54 files changed

Lines changed: 5921 additions & 71 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/opsx/apply.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
name: "OPSX: Apply"
3+
description: Implement tasks from an OpenSpec change (Experimental)
4+
category: Workflow
5+
tags: [workflow, artifacts, experimental]
6+
---
7+
8+
Implement tasks from an OpenSpec change.
9+
10+
**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.
11+
12+
**Steps**
13+
14+
1. **Select the change**
15+
16+
If a name is provided, use it. Otherwise:
17+
- Infer from conversation context if the user mentioned a change
18+
- Auto-select if only one active change exists
19+
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
20+
21+
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
22+
23+
2. **Check status to understand the schema**
24+
```bash
25+
openspec status --change "<name>" --json
26+
```
27+
Parse the JSON to understand:
28+
- `schemaName`: The workflow being used (e.g., "spec-driven")
29+
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
30+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
31+
32+
3. **Get apply instructions**
33+
34+
```bash
35+
openspec instructions apply --change "<name>" --json
36+
```
37+
38+
This returns:
39+
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
40+
- Progress (total, complete, remaining)
41+
- Task list with status
42+
- Dynamic instruction based on current state
43+
44+
**Handle states:**
45+
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
46+
- If `state: "all_done"`: congratulate, suggest archive
47+
- Otherwise: proceed to implementation
48+
49+
**Workspace guard:** If status JSON reports `actionContext.mode: "workspace-planning"` and `allowedEditRoots` is empty, explain that full workspace apply is not supported in this slice. Treat linked repos and folders as read-only context, ask the user to select an affected area through an explicit implementation workflow, and STOP before editing files.
50+
51+
4. **Read context files**
52+
53+
Read every file path listed under `contextFiles` from the apply instructions output.
54+
The files depend on the schema being used:
55+
- **spec-driven**: proposal, specs, design, tasks
56+
- Other schemas: follow the contextFiles from CLI output
57+
58+
5. **Show current progress**
59+
60+
Display:
61+
- Schema being used
62+
- Progress: "N/M tasks complete"
63+
- Remaining tasks overview
64+
- Dynamic instruction from CLI
65+
66+
6. **Implement tasks (loop until done or blocked)**
67+
68+
For each pending task:
69+
- Show which task is being worked on
70+
- Make the code changes required
71+
- Keep changes minimal and focused
72+
- Mark task complete in the tasks file: `- [ ]``- [x]`
73+
- Continue to next task
74+
75+
**Pause if:**
76+
- Task is unclear → ask for clarification
77+
- Implementation reveals a design issue → suggest updating artifacts
78+
- Error or blocker encountered → report and wait for guidance
79+
- User interrupts
80+
81+
7. **On completion or pause, show status**
82+
83+
Display:
84+
- Tasks completed this session
85+
- Overall progress: "N/M tasks complete"
86+
- If all done: suggest archive
87+
- If paused: explain why and wait for guidance
88+
89+
**Output During Implementation**
90+
91+
```
92+
## Implementing: <change-name> (schema: <schema-name>)
93+
94+
Working on task 3/7: <task description>
95+
[...implementation happening...]
96+
✓ Task complete
97+
98+
Working on task 4/7: <task description>
99+
[...implementation happening...]
100+
✓ Task complete
101+
```
102+
103+
**Output On Completion**
104+
105+
```
106+
## Implementation Complete
107+
108+
**Change:** <change-name>
109+
**Schema:** <schema-name>
110+
**Progress:** 7/7 tasks complete ✓
111+
112+
### Completed This Session
113+
- [x] Task 1
114+
- [x] Task 2
115+
...
116+
117+
All tasks complete! You can archive this change with `/opsx:archive`.
118+
```
119+
120+
**Output On Pause (Issue Encountered)**
121+
122+
```
123+
## Implementation Paused
124+
125+
**Change:** <change-name>
126+
**Schema:** <schema-name>
127+
**Progress:** 4/7 tasks complete
128+
129+
### Issue Encountered
130+
<description of the issue>
131+
132+
**Options:**
133+
1. <option 1>
134+
2. <option 2>
135+
3. Other approach
136+
137+
What would you like to do?
138+
```
139+
140+
**Guardrails**
141+
142+
- Keep going through tasks until done or blocked
143+
- Always read context files before starting (from the apply instructions output)
144+
- If task is ambiguous, pause and ask before implementing
145+
- If implementation reveals issues, pause and suggest artifact updates
146+
- Keep code changes minimal and scoped to each task
147+
- Update task checkbox immediately after completing each task
148+
- Pause on errors, blockers, or unclear requirements - don't guess
149+
- Use contextFiles from CLI output, don't assume specific file names
150+
151+
**Fluid Workflow Integration**
152+
153+
This skill supports the "actions on a change" model:
154+
155+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
156+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly

.claude/commands/opsx/archive.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
name: "OPSX: Archive"
3+
description: Archive a completed change in the experimental workflow
4+
category: Workflow
5+
tags: [workflow, archive, experimental]
6+
---
7+
8+
Archive a completed change in the experimental workflow.
9+
10+
**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.
11+
12+
**Steps**
13+
14+
1. **If no change name provided, prompt for selection**
15+
16+
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
17+
18+
Show only active changes (not already archived).
19+
Include the schema used for each change if available.
20+
21+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
22+
23+
2. **Check artifact completion status**
24+
25+
Run `openspec status --change "<name>" --json` to check artifact completion.
26+
27+
Parse the JSON to understand:
28+
- `schemaName`: The workflow being used
29+
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
30+
- `artifacts`: List of artifacts with their status (`done` or other)
31+
32+
If status reports `actionContext.mode: "workspace-planning"`, explain that workspace archive is not supported in this slice and STOP. Do not move workspace changes into repo-local archives or edit linked repos.
33+
34+
**If any artifacts are not `done`:**
35+
- Display warning listing incomplete artifacts
36+
- Prompt user for confirmation to continue
37+
- Proceed if user confirms
38+
39+
3. **Check task completion status**
40+
41+
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
42+
43+
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
44+
45+
**If incomplete tasks found:**
46+
- Display warning showing count of incomplete tasks
47+
- Prompt user for confirmation to continue
48+
- Proceed if user confirms
49+
50+
**If no tasks file exists:** Proceed without task-related warning.
51+
52+
4. **Assess delta spec sync state**
53+
54+
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
55+
56+
**If delta specs exist:**
57+
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
58+
- Determine what changes would be applied (adds, modifications, removals, renames)
59+
- Show a combined summary before prompting
60+
61+
**Prompt options:**
62+
- If changes needed: "Sync now (recommended)", "Archive without syncing"
63+
- If already synced: "Archive now", "Sync anyway", "Cancel"
64+
65+
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.
66+
67+
5. **Perform the archive**
68+
69+
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
70+
```bash
71+
mkdir -p "<planningHome.changesDir>/archive"
72+
```
73+
74+
Generate target name using current date: `YYYY-MM-DD-<change-name>`
75+
76+
**Check if target already exists:**
77+
- If yes: Fail with error, suggest renaming existing archive or using different date
78+
- If no: Move `changeRoot` to the archive directory
79+
80+
```bash
81+
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
82+
```
83+
84+
6. **Display summary**
85+
86+
Show archive completion summary including:
87+
- Change name
88+
- Schema that was used
89+
- Archive location
90+
- Spec sync status (synced / sync skipped / no delta specs)
91+
- Note about any warnings (incomplete artifacts/tasks)
92+
93+
**Output On Success**
94+
95+
```
96+
## Archive Complete
97+
98+
**Change:** <change-name>
99+
**Schema:** <schema-name>
100+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
101+
**Specs:** ✓ Synced to main specs
102+
103+
All artifacts complete. All tasks complete.
104+
```
105+
106+
**Output On Success (No Delta Specs)**
107+
108+
```
109+
## Archive Complete
110+
111+
**Change:** <change-name>
112+
**Schema:** <schema-name>
113+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
114+
**Specs:** No delta specs
115+
116+
All artifacts complete. All tasks complete.
117+
```
118+
119+
**Output On Success With Warnings**
120+
121+
```
122+
## Archive Complete (with warnings)
123+
124+
**Change:** <change-name>
125+
**Schema:** <schema-name>
126+
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
127+
**Specs:** Sync skipped (user chose to skip)
128+
129+
**Warnings:**
130+
- Archived with 2 incomplete artifacts
131+
- Archived with 3 incomplete tasks
132+
- Delta spec sync was skipped (user chose to skip)
133+
134+
Review the archive if this was not intentional.
135+
```
136+
137+
**Output On Error (Archive Exists)**
138+
139+
```
140+
## Archive Failed
141+
142+
**Change:** <change-name>
143+
**Target:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
144+
145+
Target archive directory already exists.
146+
147+
**Options:**
148+
1. Rename the existing archive
149+
2. Delete the existing archive if it's a duplicate
150+
3. Wait until a different date to archive
151+
```
152+
153+
**Guardrails**
154+
155+
- Always prompt for change selection if not provided
156+
- Use artifact graph (openspec status --json) for completion checking
157+
- Don't block archive on warnings - just inform and confirm
158+
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
159+
- Show clear summary of what happened
160+
- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
161+
- If delta specs exist, always run the sync assessment and show the combined summary before prompting

0 commit comments

Comments
 (0)