@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.
Files changed (29) hide show
  1. package/README.md +45 -48
  2. package/assets/skills/onespec/SKILL.md +22 -14
  3. package/assets/skills/onespec/references/archive.md +214 -0
  4. package/assets/skills/{onespec-design/SKILL.md → onespec/references/design.md} +55 -51
  5. package/assets/skills/onespec/references/execute.md +291 -0
  6. package/assets/skills/onespec/references/fast.md +110 -0
  7. package/assets/skills/onespec/scripts/onespec-closeout.sh +238 -77
  8. package/assets/skills/onespec/scripts/onespec-commit.sh +191 -11
  9. package/assets/skills/onespec/scripts/onespec-handoff.sh +19 -6
  10. package/assets/skills/onespec/scripts/onespec-state.sh +157 -18
  11. package/assets/skills/onespec-fast/SKILL.md +22 -0
  12. package/assets/skills/onespec-fast/agents/openai.yaml +4 -0
  13. package/assets/skills-en/onespec/SKILL.md +22 -13
  14. package/assets/skills-en/onespec/references/archive.md +213 -0
  15. package/assets/skills-en/{onespec-design/SKILL.md → onespec/references/design.md} +58 -43
  16. package/assets/skills-en/onespec/references/execute.md +291 -0
  17. package/assets/skills-en/onespec/references/fast.md +110 -0
  18. package/assets/skills-en/onespec-fast/SKILL.md +22 -0
  19. package/package.json +10 -3
  20. package/scripts/postinstall.js +3 -3
  21. package/src/cli.js +120 -110
  22. package/src/doctor.js +46 -20
  23. package/src/init.js +24 -10
  24. package/src/platforms.js +88 -8
  25. package/src/setup.js +211 -0
  26. package/assets/skills/onespec-archive/SKILL.md +0 -202
  27. package/assets/skills/onespec-execute/SKILL.md +0 -219
  28. package/assets/skills-en/onespec-archive/SKILL.md +0 -199
  29. package/assets/skills-en/onespec-execute/SKILL.md +0 -219
@@ -1,199 +0,0 @@
1
- ---
2
- name: onespec-archive
3
- description: Use when the user needs final review, feedback handling, worktree deletion, or OpenSpec archive for a OneSpec change.
4
- ---
5
-
6
- # OneSpec Archive
7
-
8
- Handles the review, closeout, and archive phase for OneSpec. The goal is to execute worktree deletion and OpenSpec archive only after explicit user confirmation.
9
-
10
- Announce at the start:
11
-
12
- > I am using `onespec-archive` for the review / closeout phase.
13
-
14
- ## 1. Review Entry
15
-
16
- Recover state first:
17
-
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)}"
20
- . "$ONESPEC_ENV"
21
- "$ONESPEC_BASH" "$ONESPEC_STATE" list
22
- ```
23
-
24
- If a relevant change exists, you must continue with:
25
-
26
- ```bash
27
- "$ONESPEC_BASH" "$ONESPEC_STATE" recover <change-id>
28
- ```
29
-
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 closeout-phase work.
31
-
32
- Read the minimum necessary context:
33
-
34
- - `openspec/changes/<change-id>/proposal.md`
35
- - `openspec/changes/<change-id>/tasks.md`
36
- - `openspec/changes/<change-id>/design.md`, if present
37
- - relevant `openspec/specs/**`
38
- - latest test results and `openspec validate <change-id> --strict` result
39
- - current branch, worktree, and workspace status
40
- - `origin_branch`, `origin_workspace_path`, and `origin_workspace_mode`
41
-
42
- If state has not reached `review`, explain what is still missing: implementation, verification, `tasks.md` sync, or proposal approval.
43
-
44
- 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.
45
-
46
- ## 2. User Review
47
-
48
- Let the user review the implementation. If they raise issues, continue editing and re-verify.
49
-
50
- After implementation is done, do not require another explicit review-confirmation step and do not show a generic "continue review / preserve branch" menu. Only ask whether archive-related cleanup should happen. 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.
51
-
52
- Do not make the user guess what to type next. When entering `onespec-archive`, provide a numbered menu. If multiple actions can be combined, allow comma-separated digits such as `1,3`.
53
-
54
- Before offering closeout choices, explicitly tell the user:
55
-
56
- - the current branch name
57
- - the current workspace path
58
- - the recorded `origin_branch` and `origin_workspace_path`
59
- - whether the current review location still matches the original branch/workspace
60
-
61
- 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. In that case, show delete-worktree / archive combinations by default; if the user switches to free-form text, treat it as a request for more code changes.
62
-
63
- Supported closeout paths are only about these two actions:
64
-
65
- - delete worktree
66
- - run archive
67
-
68
- Do not auto-delete the worktree. Deletion and archive are consequential actions and require an explicit user choice.
69
-
70
- ## 2.1 Superpowers Worktree Priority
71
-
72
- 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.
73
-
74
- The agent must tell the user:
75
-
76
- - implementation currently lives in a temporary worktree
77
- - the original branch is `origin_branch`
78
- - the original workspace is `origin_workspace_path`
79
- - whether local temporary branch/worktree cleanup will happen after closeout
80
-
81
- Default recommended order:
82
-
83
- 1. finish review inside the temporary worktree
84
- 2. if no more code changes are needed, prefer `delete worktree and archive`
85
- 3. if the user only wants local cleanup, allow `delete worktree` only
86
- 4. if the code is already truly on the target branch, allow `run archive` only
87
-
88
- ## 2.2 Multi-Select Closeout Combinations
89
-
90
- Do not model closeout as a pure single-choice menu anymore. The menu should revolve around combinable archive-related actions. Use numbered combinations such as `1,3`:
91
-
92
- - `delete worktree`
93
- - `run archive`
94
-
95
- Recommended validation rules:
96
-
97
- - `{delete worktree, run archive}`: valid. Use when the temporary worktree should be cleaned up and the change should be archived now.
98
- - `{delete worktree}`: valid. Use when the user only wants to clean up the local temporary worktree for now.
99
- - `{run archive}`: valid only when code is already on the target branch; if the code is still in a temporary branch/worktree, this is invalid by default.
100
-
101
- If the user selects an invalid combination, explain the conflict explicitly. Do not guess the execution order on the user's behalf.
102
-
103
- Default recommended combinations:
104
-
105
- - if currently in a Superpowers temporary worktree: recommend `{delete worktree, run archive}`
106
- - if currently in a temporary worktree but the user only wants local cleanup: recommend `{delete worktree}`
107
- - if not in a temporary worktree and code is already truly on the target branch: recommend `{run archive}`
108
-
109
- The user-facing closeout menu should include at least:
110
-
111
- 1. delete worktree and archive
112
- 2. delete worktree only
113
- 3. run archive only
114
- Other: if the user's intent is not covered, allow free-form instructions; any non-numbered content means continue modifying the current implementation
115
-
116
- Menu handling rules:
117
-
118
- - reply `1`: execute `delete worktree and archive`
119
- - reply `2`: execute `delete worktree` only
120
- - reply `3`: run archive only when archive prerequisites are satisfied; otherwise explain the blocker
121
- - reply with multiple digits, such as `1,3`: validate the combination and execute it in a safe order if valid; otherwise explain the conflict explicitly
122
- - free-form text instead of digits: treat it as a request to continue modifying the implementation; only ask a minimal clarification question if the intent is genuinely unclear
123
-
124
- ## 3. Archive Rules
125
-
126
- Before archive or worktree deletion is finalized, always check whether there is still uncommitted code related to the current change:
127
-
128
- ```bash
129
- "$ONESPEC_BASH" "$ONESPEC_COMMIT" related-dirty <change-id>
130
- ```
131
-
132
- - if the result is empty, continue with closeout
133
- - 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
134
- - if the result is not empty, explicitly tell the user which change-related files are still uncommitted and pause archive
135
- - if the user wants to commit now, stage only the files related to this change:
136
-
137
- ```bash
138
- "$ONESPEC_BASH" "$ONESPEC_COMMIT" stage-related <change-id>
139
- ```
140
-
141
- - prefer the repository's own Git commit policy for commit-message format, scope, and language; detect project docs and config first:
142
-
143
- ```bash
144
- "$ONESPEC_BASH" "$ONESPEC_COMMIT" detect-policy <change-id>
145
- ```
146
-
147
- - if the project defines an explicit policy, follow it
148
- - if the project does not define a policy, fall back to general Conventional Commits: `<type>(<scope>): <short summary>`
149
- - 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
150
- - 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
151
- - If code is merged into the target branch and the user chooses archive, run OpenSpec archive immediately and set state to `archived`.
152
- - If the user deletes the worktree but does not archive yet, set state to `done` and explain that archive can be run later. Do not delete `.onespec.yaml` in that case.
153
- - Only after archive actually runs should the runtime state file be removed:
154
-
155
- ```bash
156
- "$ONESPEC_BASH" "$ONESPEC_CLOSEOUT" cleanup-runtime <change-id>
157
- ```
158
-
159
- Once the user chooses archive or a combined archive action from the closeout menu, treat that menu choice as the only required confirmation. Do not ask for a second archive confirmation.
160
-
161
- For actual closeout execution, prefer:
162
-
163
- ```bash
164
- "$ONESPEC_BASH" "$ONESPEC_CLOSEOUT" run-actions <change-id> [delete-worktree] [archive]
165
- ```
166
-
167
- ```bash
168
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase done
169
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> archive <skipped|archived>
170
- ```
171
-
172
- Before archiving, confirm:
173
-
174
- - `tasks.md` is checked off to match reality
175
- - project tests passed, or any failures are explicitly called out
176
- - `openspec validate <change-id> --strict` passed
177
- - the user explicitly chose a delete-worktree, archive, or combined strategy
178
- - no user-review feedback remains unresolved
179
-
180
- ## 4. Report
181
-
182
- The closeout report must cover:
183
-
184
- - user review result
185
- - selected closeout path: delete worktree, archive, or a combination
186
- - final branch/worktree state
187
- - how the current branch relates to `origin_branch`, and whether a temporary worktree is still preserved
188
- - status of `tasks.md`, tests, and OpenSpec validate
189
- - archive field: `skipped` or `archived`
190
-
191
- ## 5. Stop Conditions
192
-
193
- Pause and explain if:
194
-
195
- - the user has not finished final review
196
- - the user has not explicitly chosen a closeout path
197
- - the user has not explicitly approved worktree deletion or OpenSpec archive
198
- - code is not merged into the target branch and the user asks to archive without a valid delete-worktree combination
199
- - tests or `openspec validate <change-id> --strict` are failing and the user has not explicitly accepted the risk
@@ -1,219 +0,0 @@
1
- ---
2
- name: onespec-execute
3
- description: Use when the user needs to execute an approved OpenSpec change, continue implementation, generate a Superpowers plan, run OpenSpec apply, sync tasks, or verify the result.
4
- ---
5
-
6
- # OneSpec Execute
7
-
8
- Handles the execution phase for OneSpec. The goal is to implement only within approved scope and sync the outcome back into OpenSpec state.
9
-
10
- Announce at the start:
11
-
12
- > I am using `onespec-execute` for the apply / implementation phase.
13
-
14
- ## 1. Apply Routing
15
-
16
- Recover state first:
17
-
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)}"
20
- . "$ONESPEC_ENV"
21
- "$ONESPEC_BASH" "$ONESPEC_STATE" list
22
- ```
23
-
24
- If a relevant change exists, you must continue with:
25
-
26
- ```bash
27
- "$ONESPEC_BASH" "$ONESPEC_STATE" recover <change-id>
28
- ```
29
-
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 execution-phase work.
31
-
32
- Before apply, read at least:
33
-
34
- - `openspec/changes/<change-id>/proposal.md`
35
- - `openspec/changes/<change-id>/tasks.md`
36
- - `openspec/changes/<change-id>/design.md`, if present
37
- - relevant `openspec/specs/**`
38
- - relevant `docs/**`
39
-
40
- Default intent mapping:
41
-
42
- - Requests like "start implementation", "execute this change", "apply this proposal/change", "continue this change", "start coding/development", or "make plan" default to the Superpowers implementation-prep route for an approved change, not direct native `openspec apply`.
43
- - Only allow native `OpenSpec apply` if the user explicitly says "do not use Superpowers plan", "do not use subagents", or "just use OpenSpec apply".
44
- - If the proposal phase already confirmed the implementation route, honor that prior decision instead of overriding it with default mapping.
45
-
46
- If the proposal is not approved yet, stop immediately.
47
-
48
- If the proposal phase already confirmed the implementation path:
49
-
50
- - user chose `Superpowers`: continue into Superpowers Make Plan.
51
- - user chose native `OpenSpec apply`: switch to native apply.
52
- - user still has not confirmed: restate the recommendation and require a numbered choice before implementation starts.
53
-
54
- If execution-time route confirmation is still needed, use this menu and let the user reply with digits:
55
-
56
- 1. continue with the recommended route
57
- 2. switch to `Superpowers`
58
- 3. switch to native `OpenSpec apply`
59
- 4. do not start implementation yet; go back and revise proposal / design / tasks
60
- Other: if intent is not covered by the menu, allow free-form instructions
61
-
62
- Menu handling rules:
63
-
64
- - reply `1`: use the current recommendation
65
- - reply `2`: switch to `Superpowers`, then keep using numbered menus for `subagent/local` and `worktree/current-branch`
66
- - reply `3`: switch to native `OpenSpec apply`
67
- - reply `4`: stop execution and return to design revision
68
- - free-form text instead of digits: if intent is clear, follow it; otherwise ask one minimal clarification question
69
-
70
- ## 2. Superpowers Make Plan and Execution
71
-
72
- On the Superpowers path, apply does not mean "start coding immediately". First translate the approved OpenSpec change into an executable Superpowers plan.
73
-
74
- Must do:
75
-
76
- - read and summarize `proposal.md`, `design.md`, `tasks.md`, relevant spec deltas, and relevant project docs
77
- - extract incomplete tasks from `tasks.md` as the planning scope
78
- - use `writing-plans` or `superpowers:writing-plans` to generate a plan at `docs/superpowers/plans/YYYY-MM-DD-<change-id>.md`
79
- - ensure the plan covers every incomplete OpenSpec task; it may split tasks further but may not omit or expand scope
80
- - if a matching plan already exists, verify that it still covers the current incomplete tasks; update or rewrite it otherwise
81
- - if the plan conflicts with approved OpenSpec artifacts, fix the OpenSpec artifacts first, then rewrite the plan
82
- - from the start of implementation until review, maintain `openspec/changes/<change-id>/.onespec.yaml` as the only runtime state file; store only the repo-relative paths directly changed for this change in its `touched_files_b64` field; prefer:
83
-
84
- ```bash
85
- "$ONESPEC_BASH" "$ONESPEC_COMMIT" track <change-id> <path>...
86
- ```
87
-
88
- - do not add pre-existing dirty files that are unrelated to the current change into that tracked-file list
89
- - if you generate a temporary zip, export bundle, or other change-local artifact under `openspec/changes/<change-id>/`, keep it as part of the current change until archive; it does not need a separate `touched_files_b64` entry, but auto-commit must include it together with `.onespec.yaml`
90
- - if auto-commit happens later, `.onespec.yaml` itself must be committed with the change while it is dirty; it is not a disposable file before archive
91
-
92
- Record the plan and create handoff:
93
-
94
- ```bash
95
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> plan <plan-path>
96
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase plan-ready
97
- "$ONESPEC_BASH" "$ONESPEC_HANDOFF" <change-id> plan --write
98
- ```
99
-
100
- Before writing code, running native apply, or dispatching sub-work, move state into `phase implementing`:
101
-
102
- ```bash
103
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase implementing
104
- ```
105
-
106
- If the change is still in `approved` or `plan-ready`, implementation has not formally started yet. Do not treat incidental edits as "continued implementation".
107
-
108
- If `origin_branch` or `origin_workspace_path` is still `unknown`, fill them in immediately before creating a worktree, switching branches, or starting implementation:
109
-
110
- ```bash
111
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> origin_branch "$(git branch --show-current || echo detached)"
112
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> origin_workspace_path "$(pwd -P)"
113
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> origin_workspace_mode "$( "$ONESPEC_BASH" "$ONESPEC_STATE" get <change-id> workspace )"
114
- ```
115
-
116
- Default execution path:
117
-
118
- - prefer `subagent-driven-development`
119
- - when dispatching subagents per task, enforce `test-driven-development`
120
- - after every task, the controller reviews spec compliance and code quality before moving on
121
- - if the user explicitly rejects subagents, or the work is too tightly coupled for task-wise dispatch, explain why and switch to `executing-plans`
122
- - use `using-git-worktrees` when isolation is needed; do not bypass its safety checks manually
123
-
124
- After implementation, always sync OpenSpec artifacts:
125
-
126
- - check off completed tasks in `tasks.md`
127
- - if the Superpowers plan split one OpenSpec task into smaller steps, only mark the OpenSpec task done after implementation, testing, and any necessary review for that task are complete
128
- - if implementation changed approved facts, update `design.md`, `proposal.md`, or spec deltas before proceeding
129
- - do not let implementation silently drift away from approved OpenSpec scope
130
- - run project tests and `openspec validate <change-id> --strict`
131
-
132
- ## 3. Native OpenSpec Apply
133
-
134
- Only use native `OpenSpec apply` when the user chooses it, accepts the low-complexity recommendation, or explicitly rejects Superpowers.
135
-
136
- After native apply, still do all of the following:
137
-
138
- - check off `tasks.md`
139
- - if new ambiguity or design conflict appears during implementation, stop and fix OpenSpec artifacts first; return to brainstorming if needed
140
- - run project tests
141
- - run `openspec validate <change-id> --strict`
142
- - enter user review and pause with the same numbered next-step menu described above
143
- - move state to `review`
144
-
145
- ## 4. Stop Conditions
146
-
147
- Pause and explain if:
148
-
149
- - proposal is not approved but the user asks to implement directly
150
- - the Superpowers plan conflicts with approved OpenSpec artifacts
151
- - `tasks.md` has not been translated into an executable Superpowers plan but the model is about to code anyway
152
- - implementation reveals a new requirement that would change scope, design, or specs
153
- - tests or `openspec validate <change-id> --strict` are failing and not yet fixed
154
-
155
- ## 5. Implementation-Complete Gate (Mandatory Pause)
156
-
157
- > This gate is mandatory. If it is not satisfied, do not output a completion summary, do not give closeout suggestions, and do not enter the next phase.
158
-
159
- After implementation and verification, the flow must pause explicitly. Do not continue directly into merge, worktree deletion, archive, or any implicit closeout. The goal here is to enter user-review / `review-closeout` waiting state. After development finishes, ask only whether archive-related cleanup should happen; do not require a separate review-confirmation step first.
160
-
161
- ### 5.1 Mandatory Script Calls
162
-
163
- After artifacts are synced and tests pass, you must run:
164
-
165
- ```bash
166
- "$ONESPEC_BASH" "$ONESPEC_STATE" set <change-id> phase review
167
- "$ONESPEC_BASH" "$ONESPEC_HANDOFF" <change-id> review --write
168
- ```
169
-
170
- If these two commands were not executed, the gate has not passed. Do not skip this and jump straight to the completion report.
171
-
172
- ### 5.2 Mandatory Report Checklist
173
-
174
- After running those commands, the user-facing report must include all of the following:
175
-
176
- 1. current branch name
177
- 2. current workspace path
178
- 3. `origin_branch` and `origin_workspace_path`, including whether they match the current location
179
- 4. which Superpowers plan file was used
180
- 5. which OpenSpec tasks were completed
181
- 6. how `tasks.md` was synced back
182
- 7. whether `proposal.md`, `design.md`, or spec deltas changed
183
- 8. test results
184
- 9. `openspec validate <change-id> --strict` result
185
- 10. the numbered next-step menu, including that any non-numbered reply means continue modifying the current implementation
186
-
187
- ### 5.3 Numbered Next-Step Menu Template
188
-
189
- The report must end with a menu equivalent to:
190
-
191
- ```text
192
- ---
193
- Implementation and verification are complete.
194
-
195
- Current branch: <branch>
196
- Current workspace: <path>
197
- Origin: <origin_branch> @ <origin_workspace_path>
198
-
199
- 1. Enter `onespec-archive` and choose delete-worktree / archive actions
200
- 2. Keep the current branch / worktree as-is and stop here for now
201
- Other: any non-numbered content means continue modifying the current implementation; if the intent is outside the menu, the user may also describe it directly
202
- ---
203
- ```
204
-
205
- If the current branch or workspace differs from `origin_*`, add an explicit note that implementation currently lives in a temporary branch or temporary worktree and that any non-numbered reply will be treated as a request for more implementation work.
206
-
207
- Do not stop at an abstract note such as "the next step is `onespec-archive`" or just "do review-closeout". You must also give the user a concrete numbered menu.
208
-
209
- ### 5.4 Anti-Patterns (NEVER)
210
-
211
- The following are gate violations:
212
-
213
- - reporting "done" without first running the scripts in 5.1
214
- - omitting current branch / workspace information from the report
215
- - omitting a concrete numbered next-step menu
216
- - mixing archive, merge, or worktree-deletion actions into the implementation-complete report
217
- - entering `onespec-archive` before the user replies
218
- - replacing the concrete numbered menu with an abstract "next step is onespec-archive" statement
219
- - deleting a temporary worktree before review is complete and the user explicitly asks for closeout