Skip to content

Commit 98984f3

Browse files
committed
Merge branch 'master' of https://github.com/CaseyRo/ha_bosch
2 parents d40d4ca + 5d3dada commit 98984f3

65 files changed

Lines changed: 4265 additions & 884 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: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
22
name: "OPSX: Apply"
3-
description: Implement tasks from an OpenSpec change (Experimental)
4-
category: Workflow
5-
tags: [workflow, artifacts, experimental]
3+
description: "Implement tasks from an OpenSpec change (Experimental)"
4+
allowed-tools: Bash(openspec:*)
5+
category: "Workflow"
6+
tags: ["workflow", "artifacts", "experimental"]
67
---
78

89
Implement tasks from an OpenSpec change.
910

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`, `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+
1013
**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.
1114

1215
**Steps**
@@ -16,7 +19,7 @@ Implement tasks from an OpenSpec change.
1619
If a name is provided, use it. Otherwise:
1720
- Infer from conversation context if the user mentioned a change
1821
- 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
22+
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
2023

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

@@ -36,17 +39,32 @@ Implement tasks from an OpenSpec change.
3639
```
3740

3841
This returns:
39-
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
42+
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
4043
- Progress (total, complete, remaining)
4144
- Task list with status
4245
- Dynamic instruction based on current state
46+
- Optional `context`: current required project instruction input from the selected root
47+
- Optional `operationGuidance`: current advisory guidance for apply
4348

4449
**Handle states:**
45-
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
50+
- 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)
4651
- If `state: "all_done"`: congratulate, suggest archive
4752
- Otherwise: proceed to implementation
4853

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

5169
4. **Read context files**
5270

@@ -55,6 +73,9 @@ Implement tasks from an OpenSpec change.
5573
- **spec-driven**: proposal, specs, design, tasks
5674
- Other schemas: follow the contextFiles from CLI output
5775

76+
Do not copy `context` or `operationGuidance` verbatim into implementation
77+
files or planning artifacts unless the user separately asks for that content.
78+
5879
5. **Show current progress**
5980

6081
Display:
@@ -146,6 +167,11 @@ What would you like to do?
146167
- Update task checkbox immediately after completing each task
147168
- Pause on errors, blockers, or unclear requirements - don't guess
148169
- Use contextFiles from CLI output, don't assume specific file names
170+
- Do not use context or operation guidance as proof that a task is complete
171+
- Apply relevant project context; report conflicts with controlling workflow inputs
172+
- Consider every guidance entry; explain any inapplicable or conflicting advice
173+
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
174+
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
149175

150176
**Fluid Workflow Integration**
151177

.claude/commands/opsx/archive.md

Lines changed: 91 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,59 @@
11
---
22
name: "OPSX: Archive"
3-
description: Archive a completed change in the experimental workflow
4-
category: Workflow
5-
tags: [workflow, archive, experimental]
3+
description: "Archive a completed change in the experimental workflow"
4+
allowed-tools: Bash(openspec:*)
5+
category: "Workflow"
6+
tags: ["workflow", "archive", "experimental"]
67
---
78

89
Archive a completed change in the experimental workflow.
910

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`, `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+
`<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+
1015
**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.
1116

1217
**Steps**
1318

14-
1. **If no change name provided, prompt for selection**
19+
1. **Select the change**
1520

16-
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
21+
If a name is provided, use it. Otherwise:
22+
- Infer from conversation context if the user mentioned a change
23+
- Auto-select if only one active change exists
24+
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
1725

18-
Show only active changes (not already archived).
26+
When prompting, show only active changes (not already archived).
1927
Include the schema used for each change if available.
2028

21-
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
29+
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
30+
31+
**Load current archive inputs before the existing archive checks:**
32+
33+
After resolving the selected change and planning root, run:
34+
```bash
35+
openspec instructions archive --change "<name>" --json
36+
```
37+
Keep the same selected-root flags on this command. This lookup is advisory and
38+
optional: it only supplies extra prompt inputs, so it must never block archiving.
39+
If it exits non-zero or returns invalid JSON — for example on an older CLI that
40+
does not support this command yet — continue the archive workflow with no
41+
context and no operation guidance. Do not report an error and do not stop.
42+
43+
A successful response may omit both optional fields. Treat `context` as a
44+
required prompt-level input: read and consider it, and apply relevant project
45+
facts, conventions, and constraints. Treat `operationGuidance` as optional
46+
additive advice: read and consider every entry, and follow entries that are
47+
applicable and compatible with the built-in archive workflow.
48+
49+
Keep both fields separate from built-in steps, explicit user choices, resolved
50+
paths, CLI checks, and command contracts. If context conflicts with one of those
51+
controlling inputs, report the conflict and preserve the controlling value. If
52+
guidance is inapplicable or conflicts with a controlling input, do not follow it
53+
and explain why. Do not infer replacement paths, skipped prompts, or flags from
54+
either field, and do not copy their text verbatim into specs, change artifacts,
55+
or archive summaries unless the user separately asks for it. These are
56+
prompt-level behavior contracts, not enforceable checks.
2257

2358
2. **Check artifact completion status**
2459

@@ -27,11 +62,9 @@ Archive a completed change in the experimental workflow.
2762
Parse the JSON to understand:
2863
- `schemaName`: The workflow being used
2964
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
30-
- `artifacts`: List of artifacts with their status (`done` or other)
65+
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
3166

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`:**
67+
**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
3568
- Display warning listing incomplete artifacts
3669
- Prompt user for confirmation to continue
3770
- Proceed if user confirms
@@ -51,18 +84,44 @@ Archive a completed change in the experimental workflow.
5184

5285
4. **Assess delta spec sync state**
5386

54-
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
87+
Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
88+
delta-spec source. If the `specs` entry is missing or
89+
`existingOutputPaths` is empty, proceed without a sync prompt and do not infer
90+
delta specs from other artifacts.
5591

5692
**If delta specs exist:**
57-
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
93+
- 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)
5894
- Determine what changes would be applied (adds, modifications, removals, renames)
5995
- Show a combined summary before prompting
6096

6197
**Prompt options:**
6298
- If changes needed: "Sync now (recommended)", "Archive without syncing"
6399
- If already synced: "Archive now", "Sync anyway", "Cancel"
64100

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.
101+
Route on the answer:
102+
- "Cancel" — stop, do not archive
103+
- "Archive without syncing" or "Archive now" — proceed to archive
104+
- "Sync now" or "Sync anyway" — sync, then verify (below)
105+
- Anything else — ask again rather than archiving
106+
107+
Before a selected sync writes any main spec, run
108+
`openspec instructions specs --change "<name>" --json` once with the same
109+
selected-root flags. Require a zero exit status and valid artifact-instruction
110+
JSON. If the lookup fails or returns invalid JSON, report the error and stop
111+
before writing any main spec or moving the change. A valid response with omitted
112+
`rules` is the no-rules case. Apply returned `rules` only to the content and
113+
form of main specs produced by this merge; do not use them as archive guidance,
114+
change CLI behavior, or copy the rule text into any output file.
115+
116+
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.
117+
118+
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:
119+
- ADDED requirements present
120+
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
121+
- 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
122+
- RENAMED requirements present under the new name and absent under the old one
123+
124+
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.
66125

67126
5. **Perform the archive**
68127

@@ -71,14 +130,14 @@ Archive a completed change in the experimental workflow.
71130
mkdir -p "<planningHome.changesDir>/archive"
72131
```
73132

74-
Generate target name using current date: `YYYY-MM-DD-<change-name>`
133+
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`).
75134

76135
**Check if target already exists:**
77136
- If yes: Fail with error, suggest renaming existing archive or using different date
78137
- If no: Move `changeRoot` to the archive directory
79138

80139
```bash
81-
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
140+
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
82141
```
83142

84143
6. **Display summary**
@@ -92,38 +151,38 @@ Archive a completed change in the experimental workflow.
92151

93152
**Output On Success**
94153

95-
```
154+
```markdown
96155
## Archive Complete
97156

98157
**Change:** <change-name>
99158
**Schema:** <schema-name>
100-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
159+
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
101160
**Specs:** ✓ Synced to main specs
102161

103162
All artifacts complete. All tasks complete.
104163
```
105164

106165
**Output On Success (No Delta Specs)**
107166

108-
```
167+
```markdown
109168
## Archive Complete
110169

111170
**Change:** <change-name>
112171
**Schema:** <schema-name>
113-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
172+
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
114173
**Specs:** No delta specs
115174

116175
All artifacts complete. All tasks complete.
117176
```
118177

119178
**Output On Success With Warnings**
120179

121-
```
180+
```markdown
122181
## Archive Complete (with warnings)
123182

124183
**Change:** <change-name>
125184
**Schema:** <schema-name>
126-
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
185+
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
127186
**Specs:** Sync skipped (user chose to skip)
128187

129188
**Warnings:**
@@ -136,11 +195,11 @@ Review the archive if this was not intentional.
136195

137196
**Output On Error (Archive Exists)**
138197

139-
```
198+
```markdown
140199
## Archive Failed
141200

142201
**Change:** <change-name>
143-
**Target:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
202+
**Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
144203

145204
Target archive directory already exists.
146205

@@ -151,10 +210,16 @@ Target archive directory already exists.
151210
```
152211

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

0 commit comments

Comments
 (0)