@rpamis/comet 0.3.6 → 0.3.8

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 (95) hide show
  1. package/README.md +575 -443
  2. package/assets/manifest.json +41 -24
  3. package/assets/skills/comet/SKILL.md +282 -301
  4. package/assets/skills/comet/reference/auto-transition.md +27 -0
  5. package/assets/skills/comet/reference/comet-yaml-fields.md +68 -0
  6. package/assets/skills/comet/reference/context-recovery.md +35 -0
  7. package/assets/skills/comet/reference/debug-gate.md +17 -0
  8. package/assets/skills/comet/reference/decision-point.md +20 -0
  9. package/assets/skills/comet/reference/dirty-worktree.md +1 -0
  10. package/assets/skills/comet/reference/file-structure.md +28 -0
  11. package/assets/skills/comet/reference/subagent-dispatch.md +113 -0
  12. package/assets/skills/comet/rules/comet-phase-guard.en.md +99 -0
  13. package/assets/skills/comet/rules/comet-phase-guard.md +99 -0
  14. package/assets/skills/comet/scripts/comet-archive.sh +71 -55
  15. package/assets/skills/comet/scripts/comet-guard.sh +174 -18
  16. package/assets/skills/comet/scripts/comet-handoff.sh +133 -6
  17. package/assets/skills/comet/scripts/comet-hook-guard.sh +260 -0
  18. package/assets/skills/comet/scripts/comet-state.sh +362 -25
  19. package/assets/skills/comet/scripts/comet-yaml-validate.sh +24 -1
  20. package/assets/skills/comet-archive/SKILL.md +100 -73
  21. package/assets/skills/comet-build/SKILL.md +304 -221
  22. package/assets/skills/comet-design/SKILL.md +263 -166
  23. package/assets/skills/comet-hotfix/SKILL.md +204 -169
  24. package/assets/skills/comet-open/SKILL.md +203 -113
  25. package/assets/skills/comet-tweak/SKILL.md +180 -154
  26. package/assets/skills/comet-verify/SKILL.md +234 -201
  27. package/assets/skills-zh/comet/SKILL.md +269 -301
  28. package/assets/skills-zh/comet/reference/auto-transition.md +27 -0
  29. package/assets/skills-zh/comet/reference/comet-yaml-fields.md +68 -0
  30. package/assets/skills-zh/comet/reference/context-recovery.md +35 -0
  31. package/assets/skills-zh/comet/reference/debug-gate.md +17 -0
  32. package/assets/skills-zh/comet/reference/decision-point.md +20 -0
  33. package/assets/skills-zh/comet/reference/dirty-worktree.md +2 -1
  34. package/assets/skills-zh/comet/reference/file-structure.md +28 -0
  35. package/assets/skills-zh/comet/reference/subagent-dispatch.md +113 -0
  36. package/assets/skills-zh/comet-archive/SKILL.md +100 -73
  37. package/assets/skills-zh/comet-build/SKILL.md +304 -221
  38. package/assets/skills-zh/comet-design/SKILL.md +264 -166
  39. package/assets/skills-zh/comet-hotfix/SKILL.md +200 -169
  40. package/assets/skills-zh/comet-open/SKILL.md +203 -113
  41. package/assets/skills-zh/comet-tweak/SKILL.md +176 -154
  42. package/assets/skills-zh/comet-verify/SKILL.md +232 -201
  43. package/dist/cli/index.js +19 -0
  44. package/dist/cli/index.js.map +1 -1
  45. package/dist/commands/doctor.d.ts.map +1 -1
  46. package/dist/commands/doctor.js +22 -0
  47. package/dist/commands/doctor.js.map +1 -1
  48. package/dist/commands/init.d.ts +5 -1
  49. package/dist/commands/init.d.ts.map +1 -1
  50. package/dist/commands/init.js +64 -9
  51. package/dist/commands/init.js.map +1 -1
  52. package/dist/commands/uninstall.d.ts +9 -0
  53. package/dist/commands/uninstall.d.ts.map +1 -0
  54. package/dist/commands/uninstall.js +113 -0
  55. package/dist/commands/uninstall.js.map +1 -0
  56. package/dist/commands/update.d.ts +1 -1
  57. package/dist/commands/update.d.ts.map +1 -1
  58. package/dist/commands/update.js +120 -32
  59. package/dist/commands/update.js.map +1 -1
  60. package/dist/core/codegraph.d.ts +4 -0
  61. package/dist/core/codegraph.d.ts.map +1 -0
  62. package/dist/core/codegraph.js +63 -0
  63. package/dist/core/codegraph.js.map +1 -0
  64. package/dist/core/detect.d.ts +8 -1
  65. package/dist/core/detect.d.ts.map +1 -1
  66. package/dist/core/detect.js +41 -2
  67. package/dist/core/detect.js.map +1 -1
  68. package/dist/core/openspec.d.ts +1 -1
  69. package/dist/core/openspec.d.ts.map +1 -1
  70. package/dist/core/openspec.js +40 -17
  71. package/dist/core/openspec.js.map +1 -1
  72. package/dist/core/platforms.d.ts +10 -0
  73. package/dist/core/platforms.d.ts.map +1 -1
  74. package/dist/core/platforms.js +177 -16
  75. package/dist/core/platforms.js.map +1 -1
  76. package/dist/core/skills.d.ts +36 -1
  77. package/dist/core/skills.d.ts.map +1 -1
  78. package/dist/core/skills.js +451 -15
  79. package/dist/core/skills.js.map +1 -1
  80. package/dist/core/superpowers.d.ts.map +1 -1
  81. package/dist/core/superpowers.js +1 -0
  82. package/dist/core/superpowers.js.map +1 -1
  83. package/dist/core/uninstall.d.ts +28 -0
  84. package/dist/core/uninstall.d.ts.map +1 -0
  85. package/dist/core/uninstall.js +421 -0
  86. package/dist/core/uninstall.js.map +1 -0
  87. package/dist/core/version.d.ts +31 -0
  88. package/dist/core/version.d.ts.map +1 -0
  89. package/dist/core/version.js +111 -0
  90. package/dist/core/version.js.map +1 -0
  91. package/dist/utils/file-system.d.ts +23 -0
  92. package/dist/utils/file-system.d.ts.map +1 -1
  93. package/dist/utils/file-system.js +100 -5
  94. package/dist/utils/file-system.js.map +1 -1
  95. package/package.json +69 -62
@@ -1,301 +1,282 @@
1
- ---
2
- name: comet
3
- description: "Comet — OpenSpec + Superpowers dual-star development workflow. Start with /comet for automatic phase detection and dispatch to subcommands. Five phases: open → design → build → verify → archive."
4
- ---
5
-
6
- # Comet — OpenSpec + Superpowers Dual-Star Development Workflow
7
-
8
- OpenSpec and Superpowers orbit the same goal like a binary star system.
9
-
10
- ```
11
- OpenSpec handles WHAT — outline, proposal, spec lifecycle, archive
12
- Superpowers handles HOW — technical design, planning, execution, closing
13
- ```
14
-
15
- **Core principle: brainstorming cannot be skipped. Every change must undergo deep design (except hotfix and tweak presets).**
16
-
17
- ---
18
-
19
- ## Decision Core
20
-
21
- Agents need only read this section for decision-making. Refer to the Reference Appendix as needed.
22
-
23
- ### Automatic Phase Detection
24
-
25
- **Step 0: Active Change Discovery and Intent Detection**
26
-
27
- 1. Detect presets first; if hotfix/tweak matches, invoke the corresponding preset skill directly and do not enter the normal open branch
28
- 2. When no preset matches, run `openspec list --json` to get all active changes
29
-
30
- **Preset detection has highest priority**:
31
- - User explicitly describes a bug fix / hotfix + meets hotfix conditions directly invoke `/comet-hotfix`
32
- - User explicitly describes copy/config/docs/prompt small adjustment + meets tweak conditions directly invoke `/comet-tweak`
33
- - No preset match → follow the table below
34
-
35
- | Active changes | User input | Behavior |
36
- |----------------|------------|----------|
37
- | None | non-preset input | Invoke `/comet-open` |
38
- | Exactly 1 | `/comet <description>` | → **Ask**: continue this change or create a new change |
39
- | Multiple | `/comet <description>` | **Ask**: continue existing or create new; if continuing, list changes for selection |
40
- | Exactly 1 | `/comet` with no description | → Auto-select, enter Step 1 |
41
- | Multiple | `/comet` with no description | → List changes for user selection |
42
-
43
- <IMPORTANT>
44
- When the user chooses "create a new change", **must invoke `/comet-open`**. Do not call `/opsx:new` directly.
45
- `/comet-open` performs dual initialization: OpenSpec artifacts (created by internal `/opsx:new`) plus `.comet.yaml` state file.
46
- Calling `/opsx:new` directly leaves `.comet.yaml` missing and breaks later phase detection.
47
- </IMPORTANT>
48
-
49
- **Step 1: Read `.comet.yaml` state metadata**
50
-
51
- Prefer reading `openspec/changes/<name>/.comet.yaml`. If not available, fall back to `openspec status --change "<name>" --json`, `tasks.md`, and `docs/superpowers/` file checks.
52
-
53
- **Resume rules**:
54
- - On every context resume, rerun Step 0 and Step 1; do not trust conversation history for phase detection
55
- - If there is an active change and the worktree has uncommitted changes, handle them through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions; this file does not repeat them
56
- - If `phase: build`, first check `build_pause`, `plan`, `build_mode`, and `isolation`:
57
- - If `build_pause: plan-ready` and the plan file exists, return to the `/comet-build` plan-ready resume point, prompt the user to continue choosing isolation and execution method, and do not regenerate the plan
58
- - If `build_pause: plan-ready` but the plan file is missing, return to `/comet-build` to handle corrupted state or regenerate the plan
59
- - If `build_mode` or `isolation` is unset, return to the corresponding `/comet-build` step to supplement before executing
60
- - If both are set, read the next unchecked task from tasks.md and continue
61
- - If `phase: verify` and `verify_result: fail`, enter the verification failure decision blocking point: pause and ask the user to fix or accept deviation; only after the user chooses fix, run `"$COMET_BASH" "$COMET_STATE" transition <name> verify-fail` and invoke `/comet-build`
62
- - If `phase: open` but proposal/design/tasks are complete, first run `"$COMET_BASH" "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
63
- - If `phase: archive`, only invoke `/comet-archive`; after archive succeeds, the change moves to the archive directory, so do not run guard against the old active directory
64
-
65
- **Step 2: Phase Determination** (check in order, first match wins)
66
-
67
- 1. `archived: true` or change moved to archive → Workflow complete
68
- 2. `verify_result: pass` and `archived` is not `true` Invoke `/comet-archive`
69
- 3. `verify_result: fail` Enter verification failure decision blocking point (pause and ask fix or accept deviation; only after user chooses fix, run `verify-fail` then `/comet-build`)
70
- 4. `phase: verify` or tasks.md all checked Invoke `/comet-verify`
71
- 5. `phase: build` or has Design Doc but plan/execution incomplete → Route by workflow: `hotfix` → `/comet-hotfix`, `tweak` → `/comet-tweak`, `full` → `/comet-build`
72
- 6. `phase: design` or has change but no Design Doc → Invoke `/comet-design`
73
- 7. `phase: open` or active change exists but `.comet.yaml` is missing → Invoke `/comet-open`
74
- 8. No active change → Invoke `/comet-open`
75
-
76
- If metadata conflicts with file state, use verifiable file state as source of truth and correct `.comet.yaml` before continuing.
77
-
78
- ### Preset Upgrade Criteria
79
-
80
- **hotfix full** (upgrade if any condition met):
81
- - Change involves **3+ files**
82
- - Architecture changes (new modules, new interfaces, new dependencies)
83
- - Database schema changes
84
- - Fix introduces new public API
85
- - Fix scope exceeds a single function/module
86
-
87
- **tweak → full** (upgrade if any condition met):
88
- - Change involves **5+ files**
89
- - Cross-module coordination required
90
- - **5+** new test cases needed
91
- - Config item additions or deletions (not value changes)
92
-
93
- ### Error Handling Quick Reference
94
-
95
- | Scenario | Handling |
96
- |----------|----------|
97
- | `openspec list --json` fails | Check if openspec is installed, prompt user to run `openspec init` |
98
- | Sub-skill unavailable | Stop workflow, prompt to install or enable the corresponding skill |
99
- | `.comet.yaml` malformed or missing | Use file state as source of truth, correct with `"$COMET_BASH" "$COMET_STATE" set` then continue |
100
- | Build/test fails | Return to build phase for fixes, do not enter verify |
101
- | Incomplete change directory structure | Fill missing files according to `comet-open` artifact requirements |
102
-
103
- ### Phase Transitions
104
-
105
- <IMPORTANT>
106
- A single `/comet` invocation starts from the detected phase and advances to the next phase when exit conditions are met.
107
-
108
- Flow chain: open design build verify archive
109
-
110
- **Continuous execution requirement**: starting from the detected phase, the agent automatically continues through all later phases. But **auto-advancing only applies at transition points without user decisions**. When encountering user decision points, **must use the AskUserQuestion tool to pause and wait for the user's explicit response**. Must not use recommendation rules, defaults, or historical preferences to substitute for user confirmation, and must not just output a text prompt and then continue executing.
111
-
112
- **Decision points are blocking points**: whenever reaching any of the following nodes, the current `/comet` invocation must stop, **using the AskUserQuestion tool to wait for the user's choice**. Only after the user explicitly chooses can the corresponding state fields be written and operations executed, then auto-advance resumes.
113
-
114
- Nodes requiring user participation (pause only at these nodes):
115
- 1. Open phase proposal/design/tasks review and confirmation
116
- 2. Confirm design approach during brainstorming
117
- 3. Plan-ready pause choice during build phase, followed by workflow configuration selection (isolation + execution method)
118
- 4. Decide to fix or accept deviation when verify fails (including Spec drift handling)
119
- 5. Choose branch handling method for finishing-branch
120
- 6. Encounter upgrade conditions (hotfix/tweak → full workflow)
121
- 7. Build phase scope expansion requiring redesign or new change split
122
-
123
- Agents should not skip these decision points; other unambiguous phase transitions must proceed automatically, must not exit midway. At decision points, **text output must NOT substitute for tool-based waiting must explicitly obtain the user's choice via AskUserQuestion before continuing**.
124
-
125
- **Red Flags** when these thoughts appear, STOP and check:
126
-
127
- | Agent Thought | Actual Risk |
128
- |--------------|-------------|
129
- | "The user would probably agree with this approach" | Cannot decide for the user — use AskUserQuestion |
130
- | "This is a small change, confirmation isn't needed" | Decision points have no size exception — blocking points must wait |
131
- | "The user chose A last time, so A again" | Historical preference cannot substitute for current confirmation |
132
- | "I explained the plan and the user didn't object" | No objection ≠ consent — must use tool to get explicit choice |
133
- | "The flow has reached this point, should be fine" | Verification not passed ≠ passed — check verify_result |
134
- </IMPORTANT>
135
-
136
- ---
137
-
138
- ## Subcommand Quick Reference
139
-
140
- | Command | Phase | Owner | Artifacts |
141
- |---------|-------|-------|-----------|
142
- | `/comet-open` | 1. Open | OpenSpec | proposal.md, design.md, tasks.md |
143
- | `/comet-design` | 2. Deep Design | Superpowers | Design Doc, delta spec |
144
- | `/comet-build` | 3. Plan and Build | Superpowers | Implementation plan, code commits |
145
- | `/comet-verify` | 4. Verify and Close | Both | Verification report, branch handling |
146
- | `/comet-archive` | 5. Archive | OpenSpec | delta→main spec sync, design doc markup, archive |
147
- | `/comet-hotfix` | Preset path | Both | Quick fix (skip brainstorming) |
148
- | `/comet-tweak` | Preset path | Both | Small change (skip brainstorming and full plan) |
149
-
150
- ```
151
- /comet
152
- ↓ Auto-detect
153
- /comet-open ──→ /comet-design ──→ /comet-build ──→ /comet-verify ──→ /comet-archive
154
- (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
155
-
156
- /comet-hotfix (preset, skip brainstorming)
157
- open ──→ build ──→ verify ──→ archive
158
- If upgrade triggered block for confirmation supplement Design Doc return to full workflow
159
-
160
- /comet-tweak (preset, skip brainstorming and full plan)
161
- open ──→ lightweight build ──→ light verify ──→ archive
162
- ↑ If upgrade triggered → block for confirmation → supplement Design Doc → return to full workflow
163
- ```
164
-
165
- ---
166
-
167
- ## Reference Appendix
168
-
169
- ### .comet.yaml Field Reference
170
-
171
- ```yaml
172
- workflow: full
173
- phase: build
174
- design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
175
- plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
176
- base_ref: a1b2c3d4e5f6...
177
- build_mode: subagent-driven-development
178
- build_pause: null
179
- isolation: branch
180
- verify_mode: light
181
- verify_result: pending
182
- verification_report: null
183
- branch_status: pending
184
- created_at: 2026-05-26
185
- verified_at: null
186
- archived: false
187
- ```
188
-
189
- | Field | Meaning |
190
- |-------|---------|
191
- | `workflow` | `full`, `hotfix`, or `tweak` |
192
- | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` (init sets to `open` uniformly, guard handles transitions) |
193
- | `design_doc` | Associated Superpowers Design Doc path, can be empty |
194
- | `plan` | Associated Superpowers Plan path, can be empty |
195
- | `base_ref` | Git commit SHA recorded at init, used for scale assessment. Serves as fallback when no plan exists |
196
- | `build_mode` | Selected execution method, can be empty |
197
- | `build_pause` | Internal build-phase pause point. `null` means no pause; `plan-ready` means the plan has been generated and the user chose to pause for switching models |
198
- | `isolation` | `branch` or `worktree`, workspace isolation method. Full workflow init may leave this as `null`, but only until `/comet-build` Step 3; hotfix/tweak default to `branch` |
199
- | `verify_mode` | `light` or `full`, can be empty |
200
- | `verify_result` | `pending`, `pass`, or `fail` |
201
- | `verification_report` | Verification report file path; must point to an existing file before verify can pass |
202
- | `branch_status` | `pending` or `handled`; set to `handled` after branch handling completes |
203
- | `created_at` | Change creation date (auto-set at init), format `YYYY-MM-DD` |
204
- | `verified_at` | Verification pass time, can be empty |
205
- | `archived` | Whether change is archived |
206
-
207
- Optional fields:
208
-
209
- | Field | Meaning |
210
- |-------|---------|
211
- | `direct_override` | `true`/`false`. Full workflow may use `build_mode: direct` only when this is explicitly `true` |
212
- | `build_command` | Project build command. Guard runs this first and prints failure output |
213
- | `verify_command` | Project verification command. Verify guard runs this first; if absent, it falls back to the build command |
214
-
215
- State-machine hard constraints:
216
- - Before `build → verify`, `isolation` must be `branch` or `worktree`
217
- - Before `build → verify`, `build_mode` must be selected
218
- - `build_mode: direct` is allowed by default only for `hotfix` / `tweak`; full workflow requires `direct_override: true`
219
- - `build_pause` is not an execution method and must not be written to `build_mode`
220
- - These constraints are enforced by both `comet-guard.sh build --apply` and `comet-state.sh transition <name> build-complete`
221
-
222
- ### Script Location
223
-
224
- Comet scripts are distributed in `comet/scripts/`. **Do not hardcode paths** — locate once, cache in env vars:
225
-
226
- ```bash
227
- COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
228
- if [ -z "$COMET_ENV" ]; then
229
- echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
230
- return 1
231
- fi
232
- . "$COMET_ENV"
233
-
234
- # Stop workflow when script location fails
235
- if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_HANDOFF" ] || [ -z "$COMET_ARCHIVE" ]; then
236
- echo "ERROR: Comet scripts not found. Ensure the comet skill is installed." >&2
237
- echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
238
- return 1
239
- fi
240
- ```
241
-
242
- **Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
243
-
244
- ```bash
245
- "$COMET_BASH" "$COMET_GUARD" <change-name> <phase> --apply
246
- ```
247
-
248
- `--apply` delegates to `comet-state transition`. Use these semantic events when state changes need to be expressed directly:
249
-
250
- ```bash
251
- "$COMET_BASH" "$COMET_STATE" transition <change-name> open-complete
252
- "$COMET_BASH" "$COMET_STATE" transition <change-name> design-complete
253
- "$COMET_BASH" "$COMET_STATE" transition <change-name> build-complete
254
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-pass
255
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
256
- "$COMET_BASH" "$COMET_STATE" transition <archive-name> archived
257
- ```
258
-
259
- **Archive script**: Complete all archive steps in one command:
260
-
261
- ```bash
262
- "$COMET_BASH" "$COMET_ARCHIVE" <change-name>
263
- ```
264
-
265
- After loading comet, agents should run the variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_HANDOFF`, `$COMET_ARCHIVE` throughout the session.
266
-
267
- ### File Structure
268
-
269
- ```
270
- openspec/ # OpenSpec — WHAT
271
- ├── config.yaml
272
- ├── changes/
273
- │ ├── <name>/ # Active change
274
- │ │ ├── .openspec.yaml
275
- │ │ ├── .comet.yaml
276
- │ │ ├── proposal.md # Why + What
277
- │ │ ├── design.md # High-level architecture decisions
278
- │ │ ├── specs/<capability>/spec.md # Delta capability spec
279
- │ │ ├── .comet/handoff/ # Script-generated phase handoff packages
280
- │ │ └── tasks.md # Task checklist
281
- │ └── archive/YYYY-MM-DD-<name>/ # Archived
282
- └── specs/<capability>/spec.md # Main specs (overwritten from delta at archive)
283
-
284
- docs/superpowers/ # Superpowers — HOW
285
- ├── specs/YYYY-MM-DD-<topic>-design.md # Design doc (technical RFC, mark status at archive)
286
- └── plans/YYYY-MM-DD-<feature>.md # Implementation plan (file header contains change association metadata)
287
- ```
288
-
289
- ### Best Practices
290
-
291
- 1. **brainstorming cannot be skipped** — Every change must undergo deep design (except hotfix and tweak)
292
- 2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
293
- 3. **Handoff packages are generated by scripts** — OpenSpec → Superpowers context must be generated through `comet-handoff.sh` as compact traceable excerpts (use `--full` when needed), and validated by guard for source/hash/mode
294
- 4. **Keep tasks.md in sync** — Check off each completed task
295
- 5. **Commit frequently** — One commit per task, message reflects design intent
296
- 6. **Verify before archive** — Execute `/comet-archive` only after `/comet-verify` passes
297
- 7. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
298
- 8. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
299
- 9. **Archive closure** — design doc and plan must mark `archived-with` status
300
- 10. **Modifying existing features** — Just open a new change
301
- 11. **Preset has limits** — Switch to full workflow promptly when hotfix/tweak meet upgrade conditions
1
+ ---
2
+ name: comet
3
+ description: "Comet — OpenSpec + Superpowers dual-star development workflow. Start with /comet for automatic phase detection and dispatch to subcommands. Five phases: open → design → build → verify → archive."
4
+ ---
5
+
6
+ # Comet — OpenSpec + Superpowers Dual-Star Development Workflow
7
+
8
+ OpenSpec and Superpowers orbit the same goal like a binary star system.
9
+
10
+ ```
11
+ OpenSpec handles WHAT — outline, proposal, spec lifecycle, archive
12
+ Superpowers handles HOW — technical design, planning, execution, closing
13
+ ```
14
+
15
+ **Core principle: brainstorming cannot be skipped. Every change must undergo deep design (except hotfix and tweak presets).**
16
+
17
+ ---
18
+
19
+ ## Decision Core
20
+
21
+ Agents need only read this section for decision-making. Refer to the Reference Appendix as needed.
22
+
23
+ ### Output Language Rule
24
+
25
+ Use the language of the user request that triggered this workflow as the default output language. When resuming an existing change with a clear dominant artifact language, preserve that language unless the user explicitly asks to switch.
26
+
27
+ ### Automatic Phase Detection
28
+
29
+ **Step 0: Active Change Discovery and Intent Detection**
30
+
31
+ 1. Detect presets first; if hotfix/tweak matches, invoke the corresponding preset skill directly and do not enter the normal open branch
32
+ 2. When no preset matches, run `openspec list --json` to get all active changes
33
+
34
+ **Preset detection has highest priority**:
35
+ - User explicitly describes a bug fix / hotfix + meets hotfix conditions → directly invoke `/comet-hotfix`
36
+ - User explicitly describes copy/config/docs/prompt small adjustment + meets tweak conditions → directly invoke `/comet-tweak`
37
+ - No preset matchfollow the table below
38
+
39
+ | Active changes | User input | Behavior |
40
+ |----------------|------------|----------|
41
+ | None | non-preset input | → Invoke `/comet-open` |
42
+ | Exactly 1 | `/comet <description>` | → **Ask**: continue this change or create a new change |
43
+ | Multiple | `/comet <description>` | → **Ask**: continue existing or create new; if continuing, list changes for selection |
44
+ | Exactly 1 | `/comet` with no description | Auto-select, enter Step 1 |
45
+ | Multiple | `/comet` with no description | List changes for user selection |
46
+
47
+ <IMPORTANT>
48
+ When the user chooses "create a new change", **must invoke `/comet-open`**. Do not call `/opsx:new` directly.
49
+ `/comet-open` performs dual initialization: OpenSpec artifacts (created by internal `/opsx:new`) plus `.comet.yaml` state file.
50
+ Calling `/opsx:new` directly leaves `.comet.yaml` missing and breaks later phase detection.
51
+ </IMPORTANT>
52
+
53
+ **Step 1: Read `.comet.yaml` state metadata**
54
+
55
+ Prefer reading `openspec/changes/<name>/.comet.yaml`. If not available, fall back to `openspec status --change "<name>" --json`, `tasks.md`, and `docs/superpowers/` file checks.
56
+
57
+ **Resume rules**:
58
+ - On every context resume, rerun Step 0 and Step 1; do not trust conversation history for phase detection
59
+ - If there is an active change and the worktree has uncommitted changes, handle them through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions; this file does not repeat them
60
+ - If `phase: build`, first check `build_pause`, `plan`, `build_mode`, and `isolation` (see details below):
61
+ - If `build_pause: plan-ready` but `isolation` and `build_mode` are already set, treat as stale pause: first output `[COMET] Detected stale pause (build_pause=plan-ready but isolation/build_mode already set), auto-clearing and continuing`, then run `"$COMET_BASH" "$COMET_STATE" set <name> build_pause null`, then read the next unchecked task from tasks.md and resume execution per `build_mode`
62
+ - If `build_pause: plan-ready` and the plan file exists, but `isolation` or `build_mode` is not yet set, return to the `/comet-build` plan-ready resume point, prompt the user to choose isolation and execution method, and do not regenerate the plan
63
+ - If `build_pause: plan-ready` but the plan file is missing, return to `/comet-build` to handle corrupted state or regenerate the plan
64
+ - If `build_mode`, `isolation`, or `tdd_mode` is unset, return to the corresponding `/comet-build` step to supplement before executing
65
+ - If all are set, read the next unchecked task from tasks.md and continue:
66
+ - If `build_mode: subagent-driven-development`, do not execute tasks directly in the main window; return to `/comet-build`'s background subagent dispatch rules, main window only coordinates
67
+ - Other execution modes follow `/comet-build`'s corresponding rules
68
+ - If `phase: verify` and `verify_result: fail`, enter the verification failure decision blocking point: pause and ask the user to fix or accept deviation; only after the user chooses fix, run `"$COMET_BASH" "$COMET_STATE" transition <name> verify-fail` and invoke `/comet-build`
69
+ - If `phase: open` but proposal/design/tasks are complete, first run `"$COMET_BASH" "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
70
+ - If `phase: archive`, only invoke `/comet-archive`; `/comet-archive` must first wait for final archive confirmation. After archive succeeds, the change moves to the archive directory, so do not run guard against the old active directory
71
+
72
+ **Step 2: Phase Determination** (check in order, first match wins)
73
+
74
+ 1. `archived: true` or change moved to archive Workflow complete
75
+ 2. `verify_result: pass` and `archived` is not `true` → Invoke `/comet-archive` (first perform final archive confirmation)
76
+ 3. `verify_result: fail` Enter verification failure decision blocking point (pause and ask fix or accept deviation; only after user chooses fix, run `verify-fail` then `/comet-build`)
77
+ 4. `phase: verify` or tasks.md all checked → Invoke `/comet-verify`
78
+ 5. `phase: build` or has Design Doc but plan/execution incomplete → Route by workflow: `hotfix` → `/comet-hotfix`, `tweak` → `/comet-tweak`, `full` → `/comet-build`
79
+ 6. `phase: design` or has change but no Design Doc → Invoke `/comet-design`
80
+ 7. `phase: open` or active change exists but `.comet.yaml` is missing → Invoke `/comet-open`
81
+ 8. No active change → Invoke `/comet-open`
82
+
83
+ If metadata conflicts with file state, use verifiable file state as source of truth and correct `.comet.yaml` before continuing.
84
+
85
+ ### Preset Upgrade Criteria
86
+
87
+ **hotfix → full** (upgrade if any condition met):
88
+ - Change involves **3+ files**
89
+ - Architecture changes (new modules, new interfaces, new dependencies)
90
+ - Database schema changes
91
+ - Fix introduces new public API
92
+ - Fix scope exceeds a single function/module
93
+
94
+ **tweak → full** (upgrade if any condition met):
95
+ - Change involves **5+ files**
96
+ - Cross-module coordination required
97
+ - **5+** new test cases needed
98
+ - Config item additions or deletions (not value changes)
99
+ - New capability needed
100
+ - Delta spec needed (existing spec affected)
101
+
102
+ ### Error Handling Quick Reference
103
+
104
+ | Scenario | Handling |
105
+ |----------|----------|
106
+ | `openspec list --json` fails | Check if openspec is installed, prompt user to run `openspec init` |
107
+ | Sub-skill unavailable | Stop workflow, prompt to install or enable the corresponding skill |
108
+ | `.comet.yaml` malformed or missing | Use file state as source of truth, correct with `"$COMET_BASH" "$COMET_STATE" set` then continue |
109
+ | Build/test fails | Return to build phase for fixes, do not enter verify |
110
+ | Incomplete change directory structure | Fill missing files according to `comet-open` artifact requirements |
111
+
112
+ ### Phase Transitions
113
+
114
+ <IMPORTANT>
115
+ A single `/comet` invocation starts from the detected phase and advances to the next phase when exit conditions are met.
116
+
117
+ Flow chain: open design build verify archive
118
+
119
+ **Continuous execution requirement**: starting from the detected phase, the agent automatically continues through all later phases. But **auto-advancing only applies at transition points without user decisions**. When encountering user decision points, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user's explicit response**. Must not use recommendation rules, defaults, or historical preferences to substitute for user confirmation, and must not just output a text prompt and then continue executing.
120
+
121
+ **Distinguish phase advancement vs automatic handoff**: each sub-skill runs phase guard `--apply` before exit to advance the `.comet.yaml` `phase` field. This step **always happens** and is not controlled by `auto_transition`. After that, the sub-skill runs `"$COMET_BASH" "$COMET_STATE" next <name>` to resolve the next action: when `auto_transition` is not `false`, output is `NEXT: auto` (auto-invoke next skill); when `auto_transition` is `false`, output is `NEXT: manual` (do not invoke next skill, show a manual run hint). Therefore `auto_transition` **only controls next skill invocation, not phase advancement**. Regardless of `auto_transition`, user decision points below remain blocking.
122
+
123
+ **Decision points are blocking points**: whenever reaching any of the following nodes, the current `/comet` invocation must stop, and follow the `comet/reference/decision-point.md` protocol to obtain the user's explicit choice. Only after the user explicitly chooses can the corresponding state fields be written and operations executed, then auto-advance resumes.
124
+
125
+ Nodes requiring user participation (pause only at these nodes):
126
+ 1. Open phase proposal/design/tasks review and confirmation
127
+ 2. Confirm design approach during brainstorming
128
+ 3. Plan-ready pause choice during build phase, followed by workflow configuration selection (isolation + execution method + TDD mode)
129
+ 4. Decide to fix or accept deviation when verify fails (including Spec drift handling)
130
+ 5. Choose branch handling method for finishing-branch
131
+ 6. Archive phase final confirmation before running the archive script
132
+ 7. Encounter upgrade conditions (hotfix/tweak full workflow)
133
+ 8. Build phase scope expansion requiring redesign or new change split
134
+ 9. Open phase large PRD requiring confirmation to split into multiple changes
135
+
136
+ Agents should not skip these decision points; other unambiguous phase transitions must proceed automatically, must not exit midway. At decision points, **must not skip user confirmation or choose automatically — must explicitly obtain the user's choice through the current platform's available user input/confirmation mechanism before continuing**.
137
+
138
+ **Red Flags** when these thoughts appear, STOP and check:
139
+
140
+ | Agent Thought | Actual Risk |
141
+ |--------------|-------------|
142
+ | "The user would probably agree with this approach" | Cannot decide for the user — use the current platform's user input/confirmation mechanism |
143
+ | "This is a small change, confirmation isn't needed" | Decision points have no size exception — blocking points must wait |
144
+ | "The user chose A last time, so A again" | Historical preference cannot substitute for current confirmation |
145
+ | "I explained the plan and the user didn't object" | No objection consent — must use tool to get explicit choice |
146
+ | "The flow has reached this point, should be fine" | Verification not passed passed check verify_result |
147
+ </IMPORTANT>
148
+
149
+ ---
150
+
151
+ ## Subcommand Quick Reference
152
+
153
+ | Command | Phase | Owner | Artifacts |
154
+ |---------|-------|-------|-----------|
155
+ | `/comet-open` | 1. Open | OpenSpec | proposal.md, design.md, tasks.md |
156
+ | `/comet-design` | 2. Deep Design | Superpowers | Design Doc, delta spec |
157
+ | `/comet-build` | 3. Plan and Build | Superpowers | Implementation plan, code commits |
158
+ | `/comet-verify` | 4. Verify and Close | Both | Verification report, branch handling |
159
+ | `/comet-archive` | 5. Archive | OpenSpec | delta→main spec sync, design doc markup, archive |
160
+ | `/comet-hotfix` | Preset path | Both | Quick fix (skip brainstorming) |
161
+ | `/comet-tweak` | Preset path | Both | Small change (skip brainstorming and full plan) |
162
+
163
+ ```
164
+ /comet
165
+ ↓ Auto-detect
166
+ /comet-open ──→ /comet-design ──→ /comet-build ──→ /comet-verify ──→ /comet-archive
167
+ (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
168
+
169
+ /comet-hotfix (preset, skip brainstorming)
170
+ open ──→ build ──→ verify ──→ archive
171
+ ↑ If upgrade triggered → block for confirmation → supplement Design Doc → return to full workflow
172
+
173
+ /comet-tweak (preset, skip brainstorming and full plan)
174
+ open ──→ lightweight build ──→ light verify ──→ archive
175
+ If upgrade triggered → block for confirmation → supplement Design Doc → return to full workflow
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Reference Appendix
181
+
182
+ ### State Machine Hard Constraints
183
+
184
+ - Before `build → verify`, `isolation` must be `branch` or `worktree`
185
+ - Before `build → verify`, `build_mode` must be selected
186
+ - `build_mode: subagent-driven-development` must also have `subagent_dispatch: confirmed`
187
+ - Before full workflow leaves build phase, `tdd_mode` must be selected as `tdd` or `direct`
188
+ - `build_mode: direct` is allowed by default only for `hotfix` / `tweak`; full workflow requires `direct_override: true`
189
+ - `build_pause` is not an execution method and must not be written to `build_mode`
190
+ - These constraints are enforced by both `comet-guard.sh build --apply` and `comet-state.sh transition <name> build-complete`
191
+
192
+ ### .comet.yaml Field Reference
193
+
194
+ See `comet/reference/comet-yaml-fields.md` for complete field reference with examples and descriptions.
195
+
196
+ ### File Structure
197
+
198
+ See `comet/reference/file-structure.md` for the complete directory layout and artifact organization.
199
+
200
+ ### Auto-Transition Protocol
201
+
202
+ See `comet/reference/auto-transition.md` for the complete automatic handoff workflow.
203
+
204
+ ### Context Recovery
205
+
206
+ See `comet/reference/context-recovery.md` for structured recovery after context compression.
207
+
208
+ ### Decision Point Protocol
209
+
210
+ See `comet/reference/decision-point.md` for the complete user decision point protocol.
211
+
212
+ ### Debug Gate Protocol
213
+
214
+ See `comet/reference/debug-gate.md` for the complete debug gate protocol.
215
+
216
+ ### Script Location
217
+
218
+ Comet scripts are distributed in `comet/scripts/`. **Do not hardcode paths** — locate once, cache in env vars. This block is a standard boilerplate repeated in every sub-skill for independent loadability; changes must be kept in sync across all files (boilerplate version: `v2`, update this version when changing to help locate files needing sync):
219
+
220
+ ```bash
221
+ COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
222
+ if [ -z "$COMET_ENV" ]; then
223
+ echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
224
+ return 1
225
+ fi
226
+ . "$COMET_ENV"
227
+
228
+ # Stop workflow when script location fails
229
+ if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_HANDOFF" ] || [ -z "$COMET_ARCHIVE" ]; then
230
+ echo "ERROR: Comet scripts not found. Ensure the comet skill is installed." >&2
231
+ echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
232
+ return 1
233
+ fi
234
+ ```
235
+
236
+ **Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
237
+
238
+ ```bash
239
+ "$COMET_BASH" "$COMET_GUARD" <change-name> <phase> --apply
240
+ ```
241
+
242
+ `--apply` delegates to `comet-state transition`. Use these semantic events when state changes need to be expressed directly:
243
+
244
+ ```bash
245
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> open-complete
246
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> design-complete
247
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> build-complete
248
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-pass
249
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
250
+ "$COMET_BASH" "$COMET_STATE" transition <archive-name> archived
251
+ ```
252
+
253
+ **Resolve next action**: after guard-based phase advancement, use the `next` subcommand to determine whether to auto-invoke the next skill:
254
+
255
+ ```bash
256
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
257
+ ```
258
+
259
+ Output format: `NEXT: auto|manual|done` + `SKILL: <skill-name>` (omitted for `done`) + `HINT` (for `manual` only). With `auto_transition: false`, output is `manual`, which pauses only the next skill invocation and does not block phase updates.
260
+
261
+ **Archive script**: Complete all archive steps in one command:
262
+
263
+ ```bash
264
+ "$COMET_BASH" "$COMET_ARCHIVE" <change-name>
265
+ ```
266
+
267
+ After loading comet, agents should run the variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_HANDOFF`, `$COMET_ARCHIVE` throughout the session.
268
+
269
+
270
+ ### Best Practices
271
+
272
+ 1. **brainstorming cannot be skipped** — Every change must undergo deep design (except hotfix and tweak)
273
+ 2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
274
+ 3. **Handoff packages are generated by scripts** — OpenSpec → Superpowers context must be generated through `comet-handoff.sh` as compact traceable excerpts (use `--full` when needed), and validated by guard for source/hash/mode
275
+ 4. **Keep tasks.md in sync** — Check off each completed task
276
+ 5. **Commit frequently** — One commit per task, message reflects design intent
277
+ 6. **Verify before archive confirmation** — Enter `/comet-archive` only after `/comet-verify` passes, but wait for final user confirmation before running the archive script
278
+ 7. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
279
+ 8. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
280
+ 9. **Archive closure** — design doc and plan must mark `archived-with` status
281
+ 10. **Modifying existing features** — Just open a new change
282
+ 11. **Preset has limits** Switch to full workflow promptly when hotfix/tweak meet upgrade conditions