@kafka0102/onespec 0.1.2 → 0.2.2
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.
- package/README.md +45 -48
- package/assets/skills/onespec/SKILL.md +22 -14
- package/assets/skills/onespec/references/archive.md +214 -0
- package/assets/skills/{onespec-design/SKILL.md → onespec/references/design.md} +55 -51
- package/assets/skills/onespec/references/execute.md +291 -0
- package/assets/skills/onespec/references/fast.md +110 -0
- package/assets/skills/onespec/scripts/onespec-closeout.sh +238 -77
- package/assets/skills/onespec/scripts/onespec-commit.sh +191 -11
- package/assets/skills/onespec/scripts/onespec-handoff.sh +19 -6
- package/assets/skills/onespec/scripts/onespec-state.sh +157 -18
- package/assets/skills/onespec-fast/SKILL.md +22 -0
- package/assets/skills/onespec-fast/agents/openai.yaml +4 -0
- package/assets/skills-en/onespec/SKILL.md +22 -13
- package/assets/skills-en/onespec/references/archive.md +213 -0
- package/assets/skills-en/{onespec-design/SKILL.md → onespec/references/design.md} +58 -43
- package/assets/skills-en/onespec/references/execute.md +291 -0
- package/assets/skills-en/onespec/references/fast.md +110 -0
- package/assets/skills-en/onespec-fast/SKILL.md +22 -0
- package/package.json +10 -3
- package/scripts/postinstall.js +3 -3
- package/src/cli.js +120 -110
- package/src/doctor.js +46 -20
- package/src/init.js +24 -10
- package/src/platforms.js +88 -8
- package/src/setup.js +211 -0
- package/assets/skills/onespec-archive/SKILL.md +0 -202
- package/assets/skills/onespec-execute/SKILL.md +0 -219
- package/assets/skills-en/onespec-archive/SKILL.md +0 -199
- package/assets/skills-en/onespec-execute/SKILL.md +0 -219
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: onespec
|
|
3
|
-
description: Use when the user wants to manage the full AI coding change lifecycle with OpenSpec and Superpowers, or is unsure whether they should be in design, execution, or
|
|
3
|
+
description: Use when the user wants to manage the full AI coding change lifecycle with OpenSpec and Superpowers, or is unsure whether they should be in design, execution, archive, or the fast path.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# OneSpec Workflow
|
|
7
7
|
|
|
8
|
-
OneSpec is a
|
|
8
|
+
OneSpec is a single-entry workflow skill. Restore state, determine the current phase, then read the matching module under `references/`; do not call deprecated phase child skills.
|
|
9
9
|
|
|
10
10
|
Announce at the start:
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ Announce at the start:
|
|
|
16
16
|
Always check state before relying on chat history:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
ONESPEC_ENV="${ONESPEC_ENV:-$(find . "$HOME"/.codex "$HOME"/.agents "$HOME"/.config -path '*/onespec/scripts/onespec-env.sh' -type f -print -quit 2>/dev/null)}"
|
|
19
|
+
ONESPEC_ENV="${ONESPEC_ENV:-$(find . "$HOME"/.codex "$HOME"/.claude "$HOME"/.cursor "$HOME"/.gemini "$HOME"/.copilot "$HOME"/.agents "$HOME"/.config -path '*/onespec/scripts/onespec-env.sh' -type f -print -quit 2>/dev/null)}"
|
|
20
20
|
. "$ONESPEC_ENV"
|
|
21
21
|
"$ONESPEC_BASH" "$ONESPEC_STATE" list
|
|
22
22
|
```
|
|
@@ -28,30 +28,39 @@ If a relevant change exists, run:
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Runtime state lives in `openspec/changes/<change-id>/.onespec.yaml`. Handoff summary, hashes, and touched-file tracking all live there; keep it until archive, then delete it during archive cleanup.
|
|
31
|
-
Treat `recover` output as the execution contract, not as a hint. Read at least `phase`, `next_skill`, `next_gate`, and `allowed_actions` before deciding what to do next.
|
|
31
|
+
Treat `recover` output as the execution contract, not as a hint. Read at least `phase`, `next_skill`, `next_reference`, `next_gate`, and `allowed_actions` before deciding what to do next.
|
|
32
32
|
|
|
33
33
|
## Phase Routing
|
|
34
34
|
|
|
35
35
|
Classify the current request first:
|
|
36
36
|
|
|
37
|
-
- `propose`: define a new change, clarify scope, generate `proposal.md`, `design.md`, `tasks.md`, and spec deltas.
|
|
38
|
-
- `apply`: implement an approved change, continue an existing change, generate or resume a Superpowers plan, and sync OpenSpec state.
|
|
39
|
-
- `review-closeout`: user review, feedback handling, worktree deletion, or archive.
|
|
37
|
+
- `propose`: define a new change, clarify scope, generate `proposal.md`, `design.md`, `tasks.md`, and spec deltas. Read `references/design.md`.
|
|
38
|
+
- `apply`: implement an approved change, continue an existing change, generate or resume a Superpowers plan, and sync OpenSpec state. Read `references/execute.md`.
|
|
39
|
+
- `review-closeout`: user review, feedback handling, worktree deletion, or archive. Read `references/archive.md`.
|
|
40
|
+
- `fast`: the user explicitly asks for `onespec-fast`, the fast path, fast apply, automatic OpenSpec end-to-end execution, or automatic proposal/implementation/archive. Read `references/fast.md`; the standalone `onespec-fast` entrypoint also routes to this same reference.
|
|
40
41
|
|
|
41
42
|
If intent is unclear, ask one short question only.
|
|
42
43
|
|
|
43
44
|
Default intent mapping:
|
|
44
45
|
|
|
45
|
-
- Requests like "new requirement", "design this", "write a proposal/spec", or "define a change"
|
|
46
|
-
- Requests like "start implementation", "execute this change", "apply this proposal/change", "continue this change", "start coding/development", or "make plan"
|
|
47
|
-
- Requests like "review", "close out", "archive", or "delete the worktree"
|
|
46
|
+
- Requests like "new requirement", "design this", "write a proposal/spec", or "define a change" read `references/design.md`.
|
|
47
|
+
- Requests like "start implementation", "execute this change", "apply this proposal/change", "continue this change", "start coding/development", or "make plan" read `references/execute.md`. If the proposal is not approved yet, stop and send the flow back to the approval gate in `references/design.md`.
|
|
48
|
+
- Requests like "review", "close out", "archive", or "delete the worktree" read `references/archive.md`.
|
|
49
|
+
- Requests like "onespec-fast", "fast path", "fast apply", "automatic OpenSpec end-to-end execution", or "automatic proposal/implementation/archive" read `references/fast.md`.
|
|
50
|
+
|
|
51
|
+
## Reference Loading
|
|
52
|
+
|
|
53
|
+
- Read only the one reference needed for the current phase; do not preload other phases.
|
|
54
|
+
- If `recover` returns `next_reference`, read it by default. Override it only when the user explicitly changes phase and the previous phase gate is already complete.
|
|
55
|
+
- `references/fast.md` may reuse procedure sections from `design.md`, `execute.md`, and `archive.md`, but the fast path overrides the normal proposal approval, review pause, and closeout-menu gates.
|
|
56
|
+
- For cross-phase checks, read only the smallest section directly required by the gate.
|
|
48
57
|
|
|
49
58
|
## Shared Constraints
|
|
50
59
|
|
|
51
60
|
- OpenSpec owns scope, formal artifacts, approval gates, spec deltas, and archive semantics.
|
|
52
61
|
- Superpowers owns high-ambiguity clarification, implementation planning, TDD, per-task review, and execution quality.
|
|
53
62
|
- Do not ask the user to name the change. Generate a short kebab-case `change-id` from the task and append a suffix if needed.
|
|
54
|
-
- Read the minimum necessary context: `openspec/config.yaml`,
|
|
63
|
+
- Read the minimum necessary context: `openspec/config.yaml`, relevant `openspec/specs/**`, project entry docs, and current branch/worktree state.
|
|
55
64
|
- Only ask questions that can change the proposal, execution path, branch handling, or archive result.
|
|
56
|
-
- If shared and phase-specific rules conflict, the
|
|
57
|
-
-
|
|
65
|
+
- If shared and phase-specific rules conflict, the current phase reference wins.
|
|
66
|
+
- Each phase reference defines mandatory pause gates, such as the approval gate in `references/design.md` and the implementation-complete gate in `references/execute.md`. Before routing to the next phase, confirm the previous gate is complete; if it is not, refuse to continue and name the missing gate.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Archive Phase
|
|
2
|
+
|
|
3
|
+
Read on demand from `onespec` during the `review-closeout` phase. The goal is to resolve the code fate of temporary worktrees and complete merge, discard, or archive actions according to the user's explicit closeout selection.
|
|
4
|
+
|
|
5
|
+
## 1. Review Entry
|
|
6
|
+
|
|
7
|
+
Recover state first:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ONESPEC_ENV="${ONESPEC_ENV:-$(find . "$HOME"/.codex "$HOME"/.claude "$HOME"/.cursor "$HOME"/.gemini "$HOME"/.copilot "$HOME"/.agents "$HOME"/.config -path '*/onespec/scripts/onespec-env.sh' -type f -print -quit 2>/dev/null)}"
|
|
11
|
+
. "$ONESPEC_ENV"
|
|
12
|
+
"$ONESPEC_BASH" "$ONESPEC_STATE" list
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If a relevant change exists, you must continue with:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
"$ONESPEC_BASH" "$ONESPEC_STATE" recover <change-id>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Treat `recover` output as the current phase contract, not as reference information. Read at least `phase`, `next_skill`, `next_reference`, `next_gate`, and `allowed_actions` before deciding whether to continue closeout-phase work.
|
|
22
|
+
|
|
23
|
+
Read the minimum necessary context:
|
|
24
|
+
|
|
25
|
+
- `openspec/changes/<change-id>/proposal.md`
|
|
26
|
+
- `openspec/changes/<change-id>/tasks.md`
|
|
27
|
+
- `openspec/changes/<change-id>/design.md`, if present
|
|
28
|
+
- relevant `openspec/specs/**`
|
|
29
|
+
- latest test results and `openspec validate <change-id> --strict` result
|
|
30
|
+
- current branch, worktree, and workspace status
|
|
31
|
+
- `origin_branch`, `origin_workspace_path`, and `origin_workspace_mode`
|
|
32
|
+
|
|
33
|
+
If state has not reached `review`, explain what is still missing: implementation, verification, `tasks.md` sync, or proposal approval.
|
|
34
|
+
|
|
35
|
+
Entry validation: if phase is already `review` but `.onespec.yaml` does not show `handoff_purpose: review` or does not have a `handoff_hash`, treat that as an incomplete execute gate. Tell the user the review handoff state was not written back and send them to re-run the execute report instead of silently continuing.
|
|
36
|
+
|
|
37
|
+
### 1.1 User Confirmation Request Rules
|
|
38
|
+
|
|
39
|
+
When archive phase requires the user to confirm archive, merge, discard-worktree, continued implementation, or staying in review, render "user choice required" as a standalone block titled `User Confirmation Request`. Do not mix current state, recommended closeout action, and pending confirmation into one paragraph.
|
|
40
|
+
|
|
41
|
+
The confirmation block must include:
|
|
42
|
+
|
|
43
|
+
- one explicit instruction: `Reply with a number.`
|
|
44
|
+
- 1-3 numbered options, with item 1 usually marked as `Recommended`
|
|
45
|
+
- `Other:` explaining how non-numbered content will be handled, usually as continued implementation work
|
|
46
|
+
- if the user adds constraints but still has not made a clear choice, continue presenting updated numbered options until the user chooses, stops, or explicitly tells you to continue
|
|
47
|
+
|
|
48
|
+
If the platform provides structured question UI such as `ask user questions`, `request_user_input`, or an equivalent mechanism, prefer that for these numbered options. If no such mechanism is available, render the `User Confirmation Request` block in the normal message. In either form, do not end with only a sentence like "archive is recommended" or "the next step is closeout."
|
|
49
|
+
|
|
50
|
+
## 2. User Review
|
|
51
|
+
|
|
52
|
+
Let the user review the implementation. If they raise issues, continue editing and re-verify.
|
|
53
|
+
|
|
54
|
+
After implementation is done, do not require another explicit review-confirmation step and do not show a generic "continue review / preserve branch" menu. First decide what happens to the temporary worktree code. If the user replies with any non-numbered content, treat that as a request to keep modifying the implementation and return directly to code work.
|
|
55
|
+
|
|
56
|
+
Do not make the user guess what to type next. If the user enters archive phase without having made a closeout choice yet, provide a numbered menu.
|
|
57
|
+
|
|
58
|
+
If the user arrived from the execute phase completion report and already replied with a closeout number there, treat that earlier reply as the only required authorization. Do not show the same menu again and do not add an intermediate "should I handle merge/archive?" confirmation. At that point, only report the required state checks and execute the selected actions directly without splitting closeout into a second confirmation round.
|
|
59
|
+
|
|
60
|
+
Before offering closeout choices, explicitly tell the user:
|
|
61
|
+
|
|
62
|
+
- the current branch name
|
|
63
|
+
- the current workspace path
|
|
64
|
+
- the recorded `origin_branch` and `origin_workspace_path`
|
|
65
|
+
- whether the current review location still matches the original branch/workspace
|
|
66
|
+
|
|
67
|
+
If the current branch or workspace differs from the recorded `origin_*` fields, explicitly say that the implementation is now living in a temporary branch or temporary worktree. If the user switches to free-form text, treat it as a request for more code changes.
|
|
68
|
+
|
|
69
|
+
Supported closeout paths must first be selected from the actual temporary-worktree state. Do not show a fixed menu by intuition. First run:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
"$ONESPEC_BASH" "$ONESPEC_CLOSEOUT" recommend-actions <change-id>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If `temporary_worktree: true`, supported closeout paths are limited to these three outcomes:
|
|
76
|
+
|
|
77
|
+
- Archive the current change, then merge the branch into the base branch
|
|
78
|
+
- Archive only, without merging
|
|
79
|
+
- Delete the current temporary worktree and discard the code
|
|
80
|
+
|
|
81
|
+
If `temporary_worktree: false`, the only supported closeout path is:
|
|
82
|
+
|
|
83
|
+
- Archive only, without merging or deleting a worktree
|
|
84
|
+
|
|
85
|
+
Merge, discard, deletion, and archive are consequential actions, but once the user has explicitly selected them in the numbered menu, execute them directly without another confirmation round.
|
|
86
|
+
|
|
87
|
+
## 2.1 Superpowers Worktree Priority
|
|
88
|
+
|
|
89
|
+
If `origin_workspace_mode=worktree`, or the current path is a temporary implementation worktree created during execution, make the "return to the original branch/workspace" consequence explicit before any destructive action.
|
|
90
|
+
|
|
91
|
+
The agent must tell the user:
|
|
92
|
+
|
|
93
|
+
- implementation currently lives in a temporary worktree
|
|
94
|
+
- the original branch is `origin_branch`
|
|
95
|
+
- the original workspace is `origin_workspace_path`
|
|
96
|
+
- whether local temporary branch/worktree cleanup will happen after closeout
|
|
97
|
+
|
|
98
|
+
Default recommended order:
|
|
99
|
+
|
|
100
|
+
1. finish review inside the temporary worktree
|
|
101
|
+
2. if no more implementation work is needed, archive first, then merge the temporary worktree into the base branch and delete the temporary worktree
|
|
102
|
+
3. if the user only wants to preserve the archive record without merging code, allow archive-only
|
|
103
|
+
4. if the user wants to discard the code, delete the worktree and drop the local temporary branch
|
|
104
|
+
|
|
105
|
+
## 2.2 State-Specific Closeout Rules
|
|
106
|
+
|
|
107
|
+
If the script reports `temporary_worktree: true`, show this menu:
|
|
108
|
+
|
|
109
|
+
```text
|
|
110
|
+
1. Archive the current change, then merge the branch into the base branch
|
|
111
|
+
2. Archive only, without merging
|
|
112
|
+
3. Delete the current temporary worktree and discard the code
|
|
113
|
+
Other: any non-numbered content means continue modifying the current implementation; if the user gives no input, remain paused in the current review stage
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Menu interpretation:
|
|
117
|
+
|
|
118
|
+
- reply `1`: run `archive-then-merge-worktree`; archive first, then merge into the base branch, then delete the temporary worktree and the merged local temporary branch.
|
|
119
|
+
- reply `2`: run `archive-only`; archive immediately, do not merge into the base branch, and do not auto-delete the current worktree.
|
|
120
|
+
- reply `3`: run `discard-worktree`; delete the temporary worktree and delete the matching local branch. Do not archive discarded code.
|
|
121
|
+
- any non-numbered content means continue modifying the current implementation; ask only one short clarification if the intent is unclear.
|
|
122
|
+
|
|
123
|
+
If the current workspace is not a temporary worktree and the code is already truly on the target branch, `archive-only` is allowed.
|
|
124
|
+
|
|
125
|
+
If the script reports `temporary_worktree: false`, the code is already truly on the target branch/workspace. Regardless of whether the target branch is `main`, `master`, `develop`, `feature/*`, or any other name, do not show the "archive then merge" or "delete the current temporary worktree" options. In that case the closeout menu must contain only:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
1. Archive only (current checkout is not a temporary worktree; no branch merge or worktree deletion is needed)
|
|
129
|
+
Other: any non-numbered content means continue modifying the current implementation; if the user gives no input, remain paused in the current review stage
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
In other words, when `temporary_worktree: false`, do not prompt for branch merge or worktree deletion on any target branch.
|
|
133
|
+
|
|
134
|
+
If the user already selected a closeout number in the execute phase completion menu, do not repeat the same menu here; combine that reply with the actual workspace state and execute the matching action directly.
|
|
135
|
+
|
|
136
|
+
## 3. Archive Rules
|
|
137
|
+
|
|
138
|
+
Before merge, discard, delete, or archive is finalized, always check whether there is still uncommitted code related to the current change:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
"$ONESPEC_BASH" "$ONESPEC_COMMIT" related-dirty <change-id>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- if the result is empty, continue with closeout
|
|
145
|
+
- if the result is empty, unrelated untracked directories must not block closeout; for example, `.superpowers/` that is not recorded in the tracked-file list inside `.onespec.yaml` can be called out as "not included in this change" and then ignored for closeout purposes
|
|
146
|
+
- if the result is not empty, do not stop at "please commit first". The closeout scripts must auto-commit those files, and they must only commit files related to this change:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
"$ONESPEC_BASH" "$ONESPEC_COMMIT" commit-related <change-id> <closeout|archive|preserve-state>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
- prefer the repository's own Git commit policy for commit-message format, scope, and language; detect project docs and config first:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
"$ONESPEC_BASH" "$ONESPEC_COMMIT" detect-policy <change-id>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- if the project defines an explicit policy, follow it
|
|
159
|
+
- if the project does not define a policy, fall back to general Conventional Commits: `<type>(<scope>): <short summary>`
|
|
160
|
+
- only commit the intersection of the tracked-file list stored in `.onespec.yaml` and current dirty files; if `.onespec.yaml` itself is dirty, include it too; never include unrelated changes
|
|
161
|
+
- exception: temporary zip files, export bundles, or other change-local artifacts under `openspec/changes/<change-id>/` are also part of the current change; auto-commit should include them so archive preserves them in change history
|
|
162
|
+
- auto-commit only covers the local commits needed for closeout. Local merge/archive actions included in the numbered closeout selection are already authorized. Merge, rebase, or push actions outside that selection still require explicit user approval.
|
|
163
|
+
- recommended order:
|
|
164
|
+
1. auto-commit current-workspace dirty files related to the change before closeout continues
|
|
165
|
+
2. if archive creates new archive artifacts or removes `.onespec.yaml`, auto-commit the archive result after archive finishes
|
|
166
|
+
3. if the user chooses archive-then-merge, merge the implementation branch back into the base branch only after the archive commit is complete
|
|
167
|
+
- If the user selects `archive-then-merge-worktree`, run it only when `temporary_worktree: true`; archive first, then merge into the target branch, then delete the temporary worktree, and set state to `archived`.
|
|
168
|
+
- If the user selects `archive-only`, run OpenSpec archive and set state to `archived`; do not auto-merge. When `temporary_worktree: false`, also do not delete any workspace or worktree.
|
|
169
|
+
- If the user discards the worktree, do not archive and do not merge discarded branch code into the base branch.
|
|
170
|
+
- Only after archive actually runs should the runtime state file be removed:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
"$ONESPEC_BASH" "$ONESPEC_CLOSEOUT" cleanup-runtime <change-id>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
For actual closeout execution, prefer:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
"$ONESPEC_BASH" "$ONESPEC_CLOSEOUT" run-actions <change-id> [archive-then-merge-worktree|archive-only|discard-worktree]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
"$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase done
|
|
184
|
+
"$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> archive <skipped|archived>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Before archiving, confirm:
|
|
188
|
+
|
|
189
|
+
- `tasks.md` is checked off to match reality
|
|
190
|
+
- project tests passed, or any failures are explicitly called out
|
|
191
|
+
- `openspec validate <change-id> --strict` passed
|
|
192
|
+
- the user explicitly chose archive-then-merge, archive-only, or discard-worktree
|
|
193
|
+
- no user-review feedback remains unresolved
|
|
194
|
+
|
|
195
|
+
## 4. Report
|
|
196
|
+
|
|
197
|
+
The closeout report must cover:
|
|
198
|
+
|
|
199
|
+
- user review result
|
|
200
|
+
- selected closeout path: archive then merge, archive only, or discard worktree
|
|
201
|
+
- final branch/worktree state
|
|
202
|
+
- how the current branch relates to `origin_branch`, and whether a temporary worktree is still kept locally
|
|
203
|
+
- status of `tasks.md`, tests, and OpenSpec validate
|
|
204
|
+
- archive field: `skipped` or `archived`
|
|
205
|
+
|
|
206
|
+
## 5. Stop Conditions
|
|
207
|
+
|
|
208
|
+
Pause and explain if:
|
|
209
|
+
|
|
210
|
+
- the user has not finished final review
|
|
211
|
+
- the user has not explicitly chosen a closeout path
|
|
212
|
+
- the user has not explicitly approved archive-then-merge, archive-only, or discard-worktree
|
|
213
|
+
- tests or `openspec validate <change-id> --strict` are failing and the user has not explicitly accepted the risk
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
name: onespec-design
|
|
3
|
-
description: Use when the user needs requirement clarification, proposal/design/tasks/spec deltas, complexity analysis, or approval-path selection for an OpenSpec change.
|
|
4
|
-
---
|
|
1
|
+
# Design Phase
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Handles the design and proposal phase for OneSpec. The goal is to turn a request into pre-approval OpenSpec artifacts and recommend the correct implementation path.
|
|
9
|
-
|
|
10
|
-
Announce at the start:
|
|
11
|
-
|
|
12
|
-
> I am using `onespec-design` for the proposal/design phase.
|
|
3
|
+
Read on demand from `onespec` during the `propose` phase. The goal is to turn a request into pre-approval OpenSpec artifacts and recommend the correct implementation path.
|
|
13
4
|
|
|
14
5
|
## 1. Intake
|
|
15
6
|
|
|
16
7
|
Recover state first:
|
|
17
8
|
|
|
18
9
|
```bash
|
|
19
|
-
ONESPEC_ENV="${ONESPEC_ENV:-$(find . "$HOME"/.codex "$HOME"/.agents "$HOME"/.config -path '*/onespec/scripts/onespec-env.sh' -type f -print -quit 2>/dev/null)}"
|
|
10
|
+
ONESPEC_ENV="${ONESPEC_ENV:-$(find . "$HOME"/.codex "$HOME"/.claude "$HOME"/.cursor "$HOME"/.gemini "$HOME"/.copilot "$HOME"/.agents "$HOME"/.config -path '*/onespec/scripts/onespec-env.sh' -type f -print -quit 2>/dev/null)}"
|
|
20
11
|
. "$ONESPEC_ENV"
|
|
21
12
|
"$ONESPEC_BASH" "$ONESPEC_STATE" list
|
|
22
13
|
```
|
|
@@ -27,11 +18,11 @@ If a relevant change exists, you must continue with:
|
|
|
27
18
|
"$ONESPEC_BASH" "$ONESPEC_STATE" recover <change-id>
|
|
28
19
|
```
|
|
29
20
|
|
|
30
|
-
Treat `recover` output as the current phase contract, not as reference information. Read at least `phase`, `next_skill`, `next_gate`, and `allowed_actions` before deciding whether to continue design-phase work.
|
|
21
|
+
Treat `recover` output as the current phase contract, not as reference information. Read at least `phase`, `next_skill`, `next_reference`, `next_gate`, and `allowed_actions` before deciding whether to continue design-phase work.
|
|
31
22
|
|
|
32
23
|
Read the minimum necessary context:
|
|
33
24
|
|
|
34
|
-
- Relevant parts of `openspec/config.yaml
|
|
25
|
+
- Relevant parts of `openspec/config.yaml` and `openspec/specs/**`
|
|
35
26
|
- Relevant project entry docs such as `AGENTS.md`, `README.md`, or `docs/**`
|
|
36
27
|
- Current branch and workspace state
|
|
37
28
|
|
|
@@ -141,18 +132,42 @@ Always state:
|
|
|
141
132
|
- change id and artifact locations
|
|
142
133
|
- a short summary of the task artifact
|
|
143
134
|
- complexity level and concrete reasons
|
|
144
|
-
- recommended
|
|
135
|
+
- the recommended combination, not only an abstract route:
|
|
136
|
+
- `OpenSpec apply + native + current branch`
|
|
137
|
+
- `Superpowers + subagent + new worktree`
|
|
138
|
+
- `Superpowers + subagent + current worktree/current branch`
|
|
145
139
|
- that the user may override the recommendation
|
|
146
140
|
|
|
141
|
+
### 3.1 User Confirmation Request Rules
|
|
142
|
+
|
|
143
|
+
When the result requires the user to decide whether to approve, start implementation, change the path, or stay in design, render "user choice required" as a standalone block titled `User Confirmation Request`. Do not mix the conclusion, recommendation, and pending confirmation into one paragraph.
|
|
144
|
+
|
|
145
|
+
The confirmation block must include:
|
|
146
|
+
|
|
147
|
+
- one explicit instruction: `Reply with a number.`
|
|
148
|
+
- 2-4 numbered options, with item 1 usually marked as `Recommended`
|
|
149
|
+
- `Other:` explaining that the user may add constraints or request an operation not listed
|
|
150
|
+
- if the user adds constraints but still has not made a clear choice, continue presenting updated numbered options until the user chooses, stops, or explicitly tells you to continue
|
|
151
|
+
|
|
152
|
+
If the platform provides structured question UI such as `ask user questions`, `request_user_input`, or an equivalent mechanism, prefer that for these numbered options. If no such mechanism is available, render the `User Confirmation Request` block in the normal message. In either form, do not end with only a sentence like "I recommend this path."
|
|
153
|
+
|
|
147
154
|
## 4. Proposal Approval Gate and Path Selection
|
|
148
155
|
|
|
149
156
|
Default intent mapping, issue-workflow routing, or implementation recommendations do not count as proposal approval.
|
|
150
157
|
|
|
151
158
|
Implementation planning is only allowed after the user explicitly approves the proposal / design / spec. At the end of the design phase, do not fall back to a single free-form sentence, and do not require the user to type words like `approve`, `yes`, or `continue`. Present an "explicit options + recommendation + direct reply phrase" menu. The user may reply with digits or with the matching phrase. Silence, "looks okay", the original "start implementation", "execute this change", or "make plan" do not count as artifact approval.
|
|
152
159
|
|
|
153
|
-
|
|
160
|
+
Before rendering the approval menu, determine the recommended combination:
|
|
161
|
+
|
|
162
|
+
- If recommending `OpenSpec apply`, the combination is fixed as `OpenSpec apply + native + current branch`; record `implementation_path=openspec-apply`, `execution_method=native`, and `workspace=current-branch` (if the current branch is `main`/`master` and project docs forbid direct main-branch changes, pause and warn first).
|
|
163
|
+
- If recommending `Superpowers`, default the execution method to `subagent`; recommend `local` only when tasks are tightly coupled, unsuitable for per-task dispatch, or the user/platform clearly cannot use subagents.
|
|
164
|
+
- Detect whether the current checkout is already an attached git worktree: compare `git rev-parse --path-format=absolute --git-dir` with `git rev-parse --path-format=absolute --git-common-dir`; if they differ, the current checkout is an attached worktree. If that command is unavailable, fall back to `git worktree list --porcelain` and match the current `pwd -P` against `worktree` entries.
|
|
165
|
+
- If already inside an attached worktree, do not recommend creating another worktree; recommend `Superpowers + <subagent|local> + current worktree/current branch`, and record `workspace=current-branch` because execution happens in the current checkout.
|
|
166
|
+
- If not inside an attached worktree and recommending `Superpowers`, default to `Superpowers + subagent + new worktree` for implementation-branch isolation; record `workspace=worktree`.
|
|
167
|
+
|
|
168
|
+
Use this default approval menu, with the recommended combination baked into item 1. The menu must explain that the combination has three parts: implementation path + execution method + workspace policy.
|
|
154
169
|
|
|
155
|
-
1. approve the current proposal / design / spec and continue with the recommended
|
|
170
|
+
1. approve the current proposal / design / spec and continue with the recommended combination: `<recommended-combination>` (Recommended)
|
|
156
171
|
Direct reply phrase: `approve and use the recommended path`
|
|
157
172
|
2. approve the current proposal / design / spec, but change the implementation path, execution method, or workspace
|
|
158
173
|
Direct reply phrase: `approve but change the implementation path`
|
|
@@ -164,41 +179,41 @@ Other: if the user's intent is not covered by the menu, allow free-form instruct
|
|
|
164
179
|
|
|
165
180
|
Menu handling rules:
|
|
166
181
|
|
|
167
|
-
- reply `1` or `approve and use the recommended path`: treat this as approval of the current artifacts and acceptance of the recommended
|
|
168
|
-
- reply `2` or `approve but change the implementation path`: treat this as approval of the current artifacts, but continue with
|
|
169
|
-
- reply `3` or `revise the proposal first`: stay in
|
|
182
|
+
- reply `1` or `approve and use the recommended path`: treat this as approval of the current artifacts and acceptance of the recommended combination; do not ask a second round for `subagent/local` or `worktree/current-branch`; directly record the combination's `implementation_path`, `execution_method`, and `workspace`
|
|
183
|
+
- reply `2` or `approve but change the implementation path`: treat this as approval of the current artifacts, but continue with a combination menu; do not split `subagent/local` and `worktree/current-branch` into two rounds
|
|
184
|
+
- reply `3` or `revise the proposal first`: stay in design phase, revise artifacts based on feedback, and do not enter implementation
|
|
170
185
|
- reply `4` or `stay in design for now`: pause at the design phase and wait for later instructions
|
|
171
186
|
- free-form text instead of digits: if intent is clear, follow it; otherwise ask one minimal clarification question
|
|
172
187
|
|
|
173
|
-
If the user
|
|
188
|
+
If the user picked item 2, keep using the same "explicit combination options + recommendation + direct reply phrase" format instead of only digits or only free-form words. Generate the menu based on whether the current checkout is already an attached worktree:
|
|
174
189
|
|
|
175
|
-
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
- If not currently inside an attached worktree, use this default menu:
|
|
191
|
+
1. `Superpowers + subagent + new worktree` (Recommended)
|
|
192
|
+
Direct reply phrase: `use Superpowers subagent worktree`
|
|
193
|
+
2. `Superpowers + local + new worktree`
|
|
194
|
+
Direct reply phrase: `use Superpowers local worktree`
|
|
195
|
+
3. `Superpowers + local + current branch`
|
|
196
|
+
Direct reply phrase: `use Superpowers local current-branch`
|
|
197
|
+
4. `OpenSpec apply + native + current branch`
|
|
198
|
+
Direct reply phrase: `use OpenSpec apply`
|
|
199
|
+
Other: allow a special combination, for example an explicit `Superpowers + subagent + current branch`
|
|
200
|
+
- If already inside an attached worktree, use this default menu:
|
|
201
|
+
1. `Superpowers + subagent + current worktree/current branch` (Recommended)
|
|
202
|
+
Direct reply phrase: `use Superpowers subagent current worktree`
|
|
203
|
+
2. `Superpowers + local + current worktree/current branch`
|
|
204
|
+
Direct reply phrase: `use Superpowers local current worktree`
|
|
205
|
+
3. `OpenSpec apply + native + current worktree/current branch`
|
|
184
206
|
Direct reply phrase: `use OpenSpec apply`
|
|
185
|
-
|
|
186
|
-
1. `subagent` (Recommended)
|
|
187
|
-
Direct reply phrase: `use subagent`
|
|
188
|
-
2. `local`
|
|
189
|
-
Direct reply phrase: `use local`
|
|
190
|
-
- workspace:
|
|
191
|
-
1. `worktree` (Recommended)
|
|
192
|
-
Direct reply phrase: `use worktree`
|
|
193
|
-
2. `current-branch`
|
|
194
|
-
Direct reply phrase: `use current-branch`
|
|
195
|
-
Other: allow the user to describe a special workspace arrangement
|
|
207
|
+
Other: allow a special combination; do not recommend creating another worktree
|
|
196
208
|
|
|
197
209
|
`main`/`master` rules:
|
|
198
210
|
|
|
199
211
|
- Do not implement directly on `main`/`master` unless the user explicitly accepts the risk after being warned.
|
|
200
|
-
- If the current branch is `main`/`master` and the user chooses `Superpowers
|
|
212
|
+
- If the current branch is `main`/`master` and the user chooses `Superpowers + current branch`, warn first and record `main-override`; if the user chooses `new worktree`, follow the worktree creation rules.
|
|
201
213
|
- If already on a feature branch and the workspace is clean, `current-branch` is acceptable.
|
|
214
|
+
- If the plan is to switch into a `worktree` but the current workspace is dirty, handle those changes first before creating the worktree. In particular, do not create a temporary worktree while carrying uncommitted `main`/`master` changes.
|
|
215
|
+
- For uncommitted changes on `main`/`master`, require a local commit that follows the project's commit policy before creating the temporary branch/worktree. Do not implicitly carry dirty base-branch code into a new implementation branch.
|
|
216
|
+
- If the user refuses to commit the current dirty changes first, do not continue creating the worktree. Stop, switch to `current-branch`, or ask the user to clean up the branch state first.
|
|
202
217
|
|
|
203
218
|
After confirmation record:
|
|
204
219
|
|
|
@@ -213,7 +228,7 @@ After confirmation record:
|
|
|
213
228
|
"$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase approved
|
|
214
229
|
```
|
|
215
230
|
|
|
216
|
-
These `origin_*` fields represent the branch and workspace where the user originally started the change. If implementation later happens in a different branch or temporary worktree,
|
|
231
|
+
These `origin_*` fields represent the branch and workspace where the user originally started the change. If implementation later happens in a different branch or temporary worktree, execute phase and archive phase must use them when prompting for review and closeout.
|
|
217
232
|
|
|
218
233
|
## 5. Stop Conditions
|
|
219
234
|
|