@rpamis/comet 0.3.7 → 0.3.9

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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +557 -539
  3. package/assets/manifest.json +41 -34
  4. package/assets/skills/comet/SKILL.md +282 -329
  5. package/assets/skills/comet/reference/auto-transition.md +27 -0
  6. package/assets/skills/comet/reference/comet-yaml-fields.md +68 -0
  7. package/assets/skills/comet/reference/context-recovery.md +35 -0
  8. package/assets/skills/comet/reference/debug-gate.md +17 -0
  9. package/assets/skills/comet/reference/decision-point.md +20 -0
  10. package/assets/skills/comet/reference/dirty-worktree.md +59 -59
  11. package/assets/skills/comet/reference/file-structure.md +28 -0
  12. package/assets/skills/comet/reference/subagent-dispatch.md +113 -0
  13. package/assets/skills/comet/rules/comet-phase-guard.en.md +123 -0
  14. package/assets/skills/comet/rules/comet-phase-guard.md +125 -90
  15. package/assets/skills/comet/scripts/comet-guard.sh +27 -1
  16. package/assets/skills/comet/scripts/comet-hook-guard.sh +121 -45
  17. package/assets/skills/comet/scripts/comet-state.sh +162 -7
  18. package/assets/skills/comet/scripts/comet-yaml-validate.sh +3 -1
  19. package/assets/skills/comet-archive/SKILL.md +100 -106
  20. package/assets/skills/comet-build/SKILL.md +304 -316
  21. package/assets/skills/comet-design/SKILL.md +263 -272
  22. package/assets/skills/comet-hotfix/SKILL.md +204 -211
  23. package/assets/skills/comet-open/SKILL.md +220 -186
  24. package/assets/skills/comet-tweak/SKILL.md +180 -179
  25. package/assets/skills/comet-verify/SKILL.md +234 -240
  26. package/assets/skills-zh/comet/SKILL.md +269 -332
  27. package/assets/skills-zh/comet/reference/auto-transition.md +27 -0
  28. package/assets/skills-zh/comet/reference/comet-yaml-fields.md +71 -0
  29. package/assets/skills-zh/comet/reference/context-recovery.md +35 -0
  30. package/assets/skills-zh/comet/reference/debug-gate.md +17 -0
  31. package/assets/skills-zh/comet/reference/decision-point.md +20 -0
  32. package/assets/skills-zh/comet/reference/dirty-worktree.md +59 -59
  33. package/assets/skills-zh/comet/reference/file-structure.md +28 -0
  34. package/assets/skills-zh/comet/reference/subagent-dispatch.md +120 -0
  35. package/assets/skills-zh/comet-archive/SKILL.md +100 -106
  36. package/assets/skills-zh/comet-build/SKILL.md +317 -316
  37. package/assets/skills-zh/comet-design/SKILL.md +264 -273
  38. package/assets/skills-zh/comet-hotfix/SKILL.md +200 -207
  39. package/assets/skills-zh/comet-open/SKILL.md +220 -186
  40. package/assets/skills-zh/comet-tweak/SKILL.md +176 -175
  41. package/assets/skills-zh/comet-verify/SKILL.md +232 -238
  42. package/bin/comet.js +3 -3
  43. package/dist/cli/index.js +21 -1
  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 +5 -1
  47. package/dist/commands/doctor.js.map +1 -1
  48. package/dist/commands/i18n.d.ts +4 -0
  49. package/dist/commands/i18n.d.ts.map +1 -0
  50. package/dist/commands/i18n.js +154 -0
  51. package/dist/commands/i18n.js.map +1 -0
  52. package/dist/commands/init.d.ts +3 -0
  53. package/dist/commands/init.d.ts.map +1 -1
  54. package/dist/commands/init.js +127 -75
  55. package/dist/commands/init.js.map +1 -1
  56. package/dist/commands/uninstall.d.ts +9 -0
  57. package/dist/commands/uninstall.d.ts.map +1 -0
  58. package/dist/commands/uninstall.js +132 -0
  59. package/dist/commands/uninstall.js.map +1 -0
  60. package/dist/commands/update.d.ts +3 -2
  61. package/dist/commands/update.d.ts.map +1 -1
  62. package/dist/commands/update.js +105 -68
  63. package/dist/commands/update.js.map +1 -1
  64. package/dist/core/codegraph.d.ts +4 -7
  65. package/dist/core/codegraph.d.ts.map +1 -1
  66. package/dist/core/codegraph.js +63 -41
  67. package/dist/core/codegraph.js.map +1 -1
  68. package/dist/core/detect.d.ts +13 -1
  69. package/dist/core/detect.d.ts.map +1 -1
  70. package/dist/core/detect.js +68 -12
  71. package/dist/core/detect.js.map +1 -1
  72. package/dist/core/openspec.d.ts +2 -2
  73. package/dist/core/openspec.d.ts.map +1 -1
  74. package/dist/core/openspec.js +51 -22
  75. package/dist/core/openspec.js.map +1 -1
  76. package/dist/core/platforms.d.ts.map +1 -1
  77. package/dist/core/platforms.js +14 -1
  78. package/dist/core/platforms.js.map +1 -1
  79. package/dist/core/skills.d.ts +3 -1
  80. package/dist/core/skills.d.ts.map +1 -1
  81. package/dist/core/skills.js +151 -66
  82. package/dist/core/skills.js.map +1 -1
  83. package/dist/core/superpowers.d.ts +1 -1
  84. package/dist/core/superpowers.d.ts.map +1 -1
  85. package/dist/core/superpowers.js +5 -1
  86. package/dist/core/superpowers.js.map +1 -1
  87. package/dist/core/uninstall.d.ts +28 -0
  88. package/dist/core/uninstall.d.ts.map +1 -0
  89. package/dist/core/uninstall.js +421 -0
  90. package/dist/core/uninstall.js.map +1 -0
  91. package/dist/core/version.d.ts +31 -0
  92. package/dist/core/version.d.ts.map +1 -0
  93. package/dist/core/version.js +111 -0
  94. package/dist/core/version.js.map +1 -0
  95. package/dist/utils/file-system.d.ts +23 -0
  96. package/dist/utils/file-system.d.ts.map +1 -1
  97. package/dist/utils/file-system.js +100 -5
  98. package/dist/utils/file-system.js.map +1 -1
  99. package/package.json +69 -64
  100. package/scripts/postinstall.js +44 -44
@@ -1,329 +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
- ### 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 match → follow 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, **using the current platform's available user input/confirmation mechanism to wait for the user's choice**. If the current platform has no structured question tool, ask clear options in the conversation and stop the workflow, waiting for the user's reply before continuing. 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
- ### .comet.yaml Field Reference
183
-
184
- ```yaml
185
- workflow: full
186
- phase: build
187
- design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
188
- plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
189
- base_ref: a1b2c3d4e5f6...
190
- build_mode: subagent-driven-development
191
- build_pause: null
192
- subagent_dispatch: confirmed
193
- tdd_mode: tdd
194
- isolation: branch
195
- verify_mode: light
196
- verify_result: pending
197
- verification_report: null
198
- branch_status: pending
199
- created_at: 2026-05-26
200
- verified_at: null
201
- archived: false
202
- ```
203
-
204
- | Field | Meaning |
205
- |-------|---------|
206
- | `workflow` | `full`, `hotfix`, or `tweak` |
207
- | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` (init sets to `open` uniformly, guard handles transitions) |
208
- | `design_doc` | Associated Superpowers Design Doc path, can be empty |
209
- | `plan` | Associated Superpowers Plan path, can be empty |
210
- | `base_ref` | Git commit SHA recorded at init, used for scale assessment. Serves as fallback when no plan exists |
211
- | `build_mode` | Selected execution method, can be empty |
212
- | `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 |
213
- | `subagent_dispatch` | `null` or `confirmed`. Only when the current platform has confirmed real background subagent / Task / multi-agent dispatch capability can `build_mode: subagent-driven-development` be written and used to leave the build phase |
214
- | `tdd_mode` | `tdd` or `direct`. Must be selected before full workflow leaves build phase. `tdd` enforces writing a failing test first for each task; `direct` does not enforce TDD. hotfix/tweak default to `direct` |
215
- | `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` |
216
- | `verify_mode` | `light` or `full`, can be empty |
217
- | `auto_transition` | `true` or `false`. `false` pauses only the next skill invocation; it does not block phase updates |
218
- | `verify_result` | `pending`, `pass`, or `fail` |
219
- | `verification_report` | Verification report file path; must point to an existing file before verify can pass |
220
- | `branch_status` | `pending` or `handled`; set to `handled` after branch handling completes |
221
- | `created_at` | Change creation date (auto-set at init), format `YYYY-MM-DD` |
222
- | `verified_at` | Verification pass time, can be empty |
223
- | `archived` | Whether change is archived |
224
-
225
- Optional fields:
226
-
227
- | Field | Meaning |
228
- |-------|---------|
229
- | `direct_override` | `true`/`false`. Full workflow may use `build_mode: direct` only when this is explicitly `true` |
230
- | `build_command` | Project build command. Guard runs this first and prints failure output |
231
- | `verify_command` | Project verification command. Verify guard runs this first; if absent, it falls back to the build command |
232
-
233
- State-machine hard constraints:
234
- - Before `build → verify`, `isolation` must be `branch` or `worktree`
235
- - Before `build → verify`, `build_mode` must be selected
236
- - `build_mode: subagent-driven-development` must also have `subagent_dispatch: confirmed`
237
- - Before full workflow leaves build phase, `tdd_mode` must be selected as `tdd` or `direct`
238
- - `build_mode: direct` is allowed by default only for `hotfix` / `tweak`; full workflow requires `direct_override: true`
239
- - `build_pause` is not an execution method and must not be written to `build_mode`
240
- - These constraints are enforced by both `comet-guard.sh build --apply` and `comet-state.sh transition <name> build-complete`
241
-
242
- ### Script Location
243
-
244
- 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):
245
-
246
- ```bash
247
- COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
248
- if [ -z "$COMET_ENV" ]; then
249
- echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
250
- return 1
251
- fi
252
- . "$COMET_ENV"
253
-
254
- # Stop workflow when script location fails
255
- if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_HANDOFF" ] || [ -z "$COMET_ARCHIVE" ]; then
256
- echo "ERROR: Comet scripts not found. Ensure the comet skill is installed." >&2
257
- echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
258
- return 1
259
- fi
260
- ```
261
-
262
- **Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
263
-
264
- ```bash
265
- "$COMET_BASH" "$COMET_GUARD" <change-name> <phase> --apply
266
- ```
267
-
268
- `--apply` delegates to `comet-state transition`. Use these semantic events when state changes need to be expressed directly:
269
-
270
- ```bash
271
- "$COMET_BASH" "$COMET_STATE" transition <change-name> open-complete
272
- "$COMET_BASH" "$COMET_STATE" transition <change-name> design-complete
273
- "$COMET_BASH" "$COMET_STATE" transition <change-name> build-complete
274
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-pass
275
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
276
- "$COMET_BASH" "$COMET_STATE" transition <archive-name> archived
277
- ```
278
-
279
- **Resolve next action**: after guard-based phase advancement, use the `next` subcommand to determine whether to auto-invoke the next skill:
280
-
281
- ```bash
282
- "$COMET_BASH" "$COMET_STATE" next <change-name>
283
- ```
284
-
285
- 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 affect the already-applied phase advancement.
286
-
287
- **Archive script**: Complete all archive steps in one command:
288
-
289
- ```bash
290
- "$COMET_BASH" "$COMET_ARCHIVE" <change-name>
291
- ```
292
-
293
- After loading comet, agents should run the variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_HANDOFF`, `$COMET_ARCHIVE` throughout the session.
294
-
295
- ### File Structure
296
-
297
- ```
298
- openspec/ # OpenSpec — WHAT
299
- ├── config.yaml
300
- ├── changes/
301
- │ ├── <name>/ # Active change
302
- │ │ ├── .openspec.yaml
303
- │ │ ├── .comet.yaml
304
- │ │ ├── proposal.md # Why + What
305
- │ │ ├── design.md # High-level architecture decisions
306
- │ │ ├── specs/<capability>/spec.md # Delta capability spec
307
- │ │ ├── .comet/handoff/ # Script-generated phase handoff packages
308
- │ │ └── tasks.md # Task checklist
309
- │ └── archive/YYYY-MM-DD-<name>/ # Archived
310
- └── specs/<capability>/spec.md # Main specs (merged from delta semantics at archive)
311
-
312
- docs/superpowers/ # Superpowers — HOW
313
- ├── specs/YYYY-MM-DD-<topic>-design.md # Design doc (technical RFC, mark status at archive)
314
- └── plans/YYYY-MM-DD-<feature>.md # Implementation plan (file header contains change association metadata)
315
- ```
316
-
317
- ### Best Practices
318
-
319
- 1. **brainstorming cannot be skipped** — Every change must undergo deep design (except hotfix and tweak)
320
- 2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
321
- 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
322
- 4. **Keep tasks.md in sync** — Check off each completed task
323
- 5. **Commit frequently** — One commit per task, message reflects design intent
324
- 6. **Verify before archive confirmation** — Enter `/comet-archive` only after `/comet-verify` passes, but wait for final user confirmation before running the archive script
325
- 7. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
326
- 8. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
327
- 9. **Archive closure** — design doc and plan must mark `archived-with` status
328
- 10. **Modifying existing features** — Just open a new change
329
- 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 match → follow 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