@rpamis/comet 0.1.7 → 0.2.0

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 (67) hide show
  1. package/README.md +45 -13
  2. package/assets/manifest.json +2 -0
  3. package/assets/skills/comet/SKILL.md +214 -219
  4. package/assets/skills/comet/scripts/comet-archive.sh +8 -2
  5. package/assets/skills/comet/scripts/comet-guard.sh +32 -22
  6. package/assets/skills/comet/scripts/comet-state.sh +496 -0
  7. package/assets/skills/comet-archive/SKILL.md +6 -19
  8. package/assets/skills/comet-build/SKILL.md +16 -23
  9. package/assets/skills/comet-design/SKILL.md +7 -23
  10. package/assets/skills/comet-hotfix/SKILL.md +136 -167
  11. package/assets/skills/comet-open/SKILL.md +9 -31
  12. package/assets/skills/comet-tweak/SKILL.md +122 -154
  13. package/assets/skills/comet-verify/SKILL.md +11 -33
  14. package/assets/skills-zh/comet/SKILL.md +87 -92
  15. package/assets/skills-zh/comet-archive/SKILL.md +63 -76
  16. package/assets/skills-zh/comet-build/SKILL.md +153 -160
  17. package/assets/skills-zh/comet-design/SKILL.md +91 -107
  18. package/assets/skills-zh/comet-hotfix/SKILL.md +18 -49
  19. package/assets/skills-zh/comet-open/SKILL.md +70 -92
  20. package/assets/skills-zh/comet-tweak/SKILL.md +19 -51
  21. package/assets/skills-zh/comet-verify/SKILL.md +114 -136
  22. package/dist/cli/index.js +28 -1
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/commands/doctor.d.ts +6 -0
  25. package/dist/commands/doctor.d.ts.map +1 -0
  26. package/dist/commands/doctor.js +168 -0
  27. package/dist/commands/doctor.js.map +1 -0
  28. package/dist/commands/init.d.ts +9 -0
  29. package/dist/commands/init.d.ts.map +1 -0
  30. package/dist/commands/init.js +183 -0
  31. package/dist/commands/init.js.map +1 -0
  32. package/dist/commands/status.d.ts +6 -0
  33. package/dist/commands/status.d.ts.map +1 -0
  34. package/dist/commands/status.js +89 -0
  35. package/dist/commands/status.js.map +1 -0
  36. package/dist/commands/update.d.ts +8 -0
  37. package/dist/commands/update.d.ts.map +1 -0
  38. package/dist/commands/update.js +47 -0
  39. package/dist/commands/update.js.map +1 -0
  40. package/dist/core/detect.d.ts +8 -0
  41. package/dist/core/detect.d.ts.map +1 -0
  42. package/dist/core/detect.js +73 -0
  43. package/dist/core/detect.js.map +1 -0
  44. package/dist/core/openspec.d.ts +5 -0
  45. package/dist/core/openspec.d.ts.map +1 -0
  46. package/dist/core/openspec.js +58 -0
  47. package/dist/core/openspec.js.map +1 -0
  48. package/dist/core/platforms.d.ts.map +1 -1
  49. package/dist/core/platforms.js +6 -1
  50. package/dist/core/platforms.js.map +1 -1
  51. package/dist/core/skills.d.ts +22 -0
  52. package/dist/core/skills.d.ts.map +1 -0
  53. package/dist/core/skills.js +59 -0
  54. package/dist/core/skills.js.map +1 -0
  55. package/dist/core/superpowers.d.ts +5 -0
  56. package/dist/core/superpowers.d.ts.map +1 -0
  57. package/dist/core/superpowers.js +60 -0
  58. package/dist/core/superpowers.js.map +1 -0
  59. package/dist/core/types.d.ts +2 -0
  60. package/dist/core/types.d.ts.map +1 -0
  61. package/dist/core/types.js +2 -0
  62. package/dist/core/types.js.map +1 -0
  63. package/package.json +61 -50
  64. package/dist/core/init.d.ts +0 -14
  65. package/dist/core/init.d.ts.map +0 -1
  66. package/dist/core/init.js +0 -492
  67. package/dist/core/init.js.map +0 -1
package/README.md CHANGED
@@ -9,6 +9,8 @@
9
9
  ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝
10
10
  ```
11
11
 
12
+ > 中文版:[README-zh.md](README-zh.md)
13
+
12
14
  **OpenSpec + Superpowers dual-star development workflow** — one command from idea to archive.
13
15
 
14
16
  OpenSpec handles **WHAT** (outlines, proposals, spec lifecycle, archiving). Superpowers handles **HOW** (technical design, planning, execution, wrap-up). Comet chains both into a five-phase automated pipeline.
@@ -41,6 +43,9 @@ comet init
41
43
  | Command | Description |
42
44
  |---------|-------------|
43
45
  | `comet init [path]` | Initialize Comet workflow |
46
+ | `comet status [path]` | Show active changes and workflow status |
47
+ | `comet doctor [path]` | Diagnose Comet installation health |
48
+ | `comet update [path]` | Update comet skills to latest version |
44
49
  | `comet --help` | Show help |
45
50
  | `comet --version` | Show version |
46
51
 
@@ -51,6 +56,15 @@ comet init
51
56
  | `--yes` | Non-interactive mode, auto-select detected platforms |
52
57
  | `--skip-existing` | Skip already installed components |
53
58
  | `--overwrite` | Overwrite already installed components |
59
+ | `--json` | Output structured JSON |
60
+
61
+ ### status / doctor / update Options
62
+
63
+ | Option | Applies to | Description |
64
+ |--------|-----------|-------------|
65
+ | `--json` | `status`, `doctor` | Output structured JSON |
66
+ | `--language <lang>` | `update` | Language for skills (`en`, `zh`) |
67
+ | `--scope <scope>` | `update` | Install scope (`global`, `project`)|
54
68
 
55
69
  ## Supported Platforms
56
70
 
@@ -90,12 +104,14 @@ After `comet init`, three groups of skills are installed to the selected platfor
90
104
  | `/comet-hotfix` | Preset: Quick bug fix (skips brainstorming) |
91
105
  | `/comet-tweak` | Preset: Small change (skips brainstorming and full plan) |
92
106
 
93
- ### Guard Scripts
107
+ ### Guard & Automation Scripts
94
108
 
95
109
  | Script | Purpose |
96
110
  |--------|---------|
97
- | `comet-guard.sh` | Phase transition guard — validates exit conditions before phase transitions |
111
+ | `comet-guard.sh` | Phase transition guard — validates exit conditions, `--apply` auto-updates `.comet.yaml` |
112
+ | `comet-archive.sh` | One-command archive — validates state, syncs specs, moves to archive, updates status |
98
113
  | `comet-yaml-validate.sh` | Schema validator — validates `.comet.yaml` structure and field values |
114
+ | `comet-state.sh` | Unified state management — init/set/get/check/scale, agents' exclusive YAML interface |
99
115
 
100
116
  ### OpenSpec Skills
101
117
 
@@ -110,14 +126,14 @@ Development methodology: brainstorming, TDD, subagent-driven development, code r
110
126
  ```
111
127
  /comet
112
128
  ↓ auto-detect
113
- /comet-open ——→ /comet-design ——→ /comet-build ——→ /comet-verify ——→ /comet-archive
114
- (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
129
+ /comet-open --> /comet-design --> /comet-build --> /comet-verify --> /comet-archive
130
+ (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
115
131
 
116
132
  /comet-hotfix (preset path, skips brainstorming)
117
- open ——→ build ——→ verify ——→ archive
133
+ open --> build --> verify --> archive
118
134
 
119
135
  /comet-tweak (preset path, skips brainstorming and full plan)
120
- open ——→ lightweight build ——→ light verify ——→ archive
136
+ open --> lightweight build --> light verify --> archive
121
137
  ```
122
138
 
123
139
  ### Five Phases
@@ -160,15 +176,17 @@ Comet uses a decoupled state architecture with separate YAML files:
160
176
 
161
177
  ### Reliability Features
162
178
 
163
- Comet includes three-layer defense to ensure agent execution reliability:
179
+ Comet ensures agent execution reliability through automated state transitions:
164
180
 
165
181
  1. **Entry Verification** — Each phase validates preconditions before execution
166
182
  - Checks file existence, state consistency, and phase transitions
167
183
  - Outputs `[HARD STOP]` with actionable suggestions if validation fails
168
184
 
169
- 2. **Write-Then-Verify** — Every state write is immediately verified
170
- - After updating `.comet.yaml`, agents must verify field values
171
- - Automatic retry mechanism (up to 2 attempts) on mismatch
185
+ 2. **Automated State Transitions** — `comet-guard.sh --apply` updates `.comet.yaml` automatically
186
+ - All phase transitions (design build → verify archive) use `guard --apply`
187
+ - No manual state editing required eliminates write-verification errors
188
+ - `comet-state.sh` is the agents' exclusive interface for state operations
189
+ - Guard and archive scripts use `comet-state.sh` internally for state management
172
190
 
173
191
  3. **Schema Validation** — `comet-yaml-validate.sh` ensures data integrity
174
192
  - Validates required fields (10 fields)
@@ -176,6 +194,12 @@ Comet includes three-layer defense to ensure agent execution reliability:
176
194
  - Validates referenced file paths exist
177
195
  - Detects unknown/typos fields
178
196
 
197
+ 4. **Archive Automation** — `comet-archive.sh` handles the full archive flow in one command
198
+ - Validates entry state, syncs delta specs to main specs
199
+ - Annotates design doc and plan frontmatter
200
+ - Moves change to archive directory and updates `archived: true`
201
+ - Supports `--dry-run` for preview
202
+
179
203
  **Security**: Path traversal protection on all change name inputs
180
204
 
181
205
  ## Project Structure
@@ -185,8 +209,10 @@ your-project/
185
209
  ├── .claude/skills/ # Platform skills dir (Comet + OpenSpec + Superpowers)
186
210
  │ ├── comet/SKILL.md
187
211
  │ │ └── scripts/
188
- │ │ ├── comet-guard.sh # Phase transition guard
189
- │ │ └── comet-yaml-validate.sh # Schema validator
212
+ │ │ ├── comet-guard.sh # Phase transition guard (--apply auto-updates state)
213
+ │ │ ├── comet-archive.sh # One-command archive automation
214
+ │ │ ├── comet-yaml-validate.sh # Schema validator
215
+ │ │ └── comet-state.sh # Unified state management (init/set/get/check/scale)
190
216
  │ ├── comet-*/SKILL.md
191
217
  │ ├── openspec-*/SKILL.md
192
218
  │ └── brainstorming/SKILL.md
@@ -221,8 +247,14 @@ pnpm dev
221
247
  # Build
222
248
  pnpm build
223
249
 
224
- # Test
250
+ # Test (unit + coverage)
225
251
  pnpm test
252
+ pnpm test:coverage
253
+ pnpm test:shell # bats shell tests
254
+
255
+ # Lint & format
256
+ pnpm lint
257
+ pnpm format
226
258
  ```
227
259
 
228
260
  See [CHANGELOG.md](CHANGELOG.md) for version history and updates.
@@ -3,6 +3,8 @@
3
3
  "skills": [
4
4
  "comet/SKILL.md",
5
5
  "comet/scripts/comet-guard.sh",
6
+ "comet/scripts/comet-state.sh",
7
+ "comet/scripts/comet-archive.sh",
6
8
  "comet/scripts/comet-yaml-validate.sh",
7
9
  "comet-open/SKILL.md",
8
10
  "comet-design/SKILL.md",
@@ -1,219 +1,214 @@
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. OpenSpec handles WHAT, Superpowers handles HOW.
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
- <IMPORTANT>
18
- ## Phase Transitions
19
-
20
- A single `/comet` invocation starts from the detected phase and prompts or advances to the next phase when exit conditions are met.
21
-
22
- Flow chain: open → design → build → verify → archive
23
-
24
- Nodes requiring user participation:
25
- 1. Confirm design approach during brainstorming
26
- 2. Select execution mode during build phase
27
- 3. Decide to fix or accept deviation when verify fails
28
- 4. Choose branch handling method for finishing-branch
29
- 5. Encounter upgrade conditions (hotfix/tweak → full workflow)
30
-
31
- Agents should not skip these decision points; other unambiguous phase transitions can proceed automatically.
32
- </IMPORTANT>
33
-
34
- ## Automatic Phase Detection
35
-
36
- ### Step 0: Active Change Discovery
37
-
38
- **Execute immediately:**
39
-
40
- 1. Run `openspec list --json` to get all active changes
41
- 2. For each change, check `docs/superpowers/specs/` and `docs/superpowers/plans/` for associated files to determine phase and progress
42
-
43
- **Branch logic:**
44
-
45
- | Situation | Action |
46
- |-----------|--------|
47
- | No active change | → Invoke `/comet-open` |
48
- | Exactly 1 active change |Auto-select, enter phase determination (Step 1) |
49
- | Multiple active changes | List for user selection |
50
-
51
- **Multi-change selection**: Display using AskUserQuestion, example format:
52
-
53
- ```
54
- | # | Change Name | Current Phase | Task Progress |
55
- |---|-------------|---------------|---------------|
56
- | 1 | xxx-feature | Build | 3/5 tasks |
57
- | 2 | yyy-fix | Design | No design doc |
58
- ```
59
-
60
- After user selection, enter phase determination for the selected change.
61
-
62
- **Preset detection**:
63
- - If user explicitly describes as bug fix / hotfix and hotfix conditions are met, directly invoke `/comet-hotfix` (skip selection).
64
- - If user explicitly describes as copy, config, docs, prompt, or small non-bug adjustment and tweak conditions are met, directly invoke `/comet-tweak` (skip selection).
65
-
66
- ### Step 1: Comet State Metadata Reading
67
-
68
- 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.
69
-
70
- Recommended metadata structure:
71
-
72
- ```yaml
73
- workflow: full
74
- phase: build
75
- design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
76
- plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
77
- build_mode: subagent-driven-development
78
- isolation: branch
79
- verify_mode: light
80
- verify_result: pending
81
- verified_at: null
82
- archived: false
83
- ```
84
-
85
- Field meanings:
86
-
87
- | Field | Meaning |
88
- |-------|---------|
89
- | `workflow` | `full`, `hotfix`, or `tweak` |
90
- | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` |
91
- | `design_doc` | Associated Superpowers Design Doc path, can be empty |
92
- | `plan` | Associated Superpowers Plan path, can be empty |
93
- | `build_mode` | Selected execution mode, can be empty |
94
- | `isolation` | `branch` or `worktree`, workspace isolation method, defaults to `branch` |
95
- | `verify_mode` | `light` or `full`, can be empty |
96
- | `verify_result` | `pending`, `pass`, or `fail` |
97
- | `verified_at` | Verification pass time, can be empty |
98
- | `archived` | Whether change is archived |
99
-
100
- ### Step 2: Phase Determination
101
-
102
- For the selected change, determine current state in the following order:
103
-
104
- 1. **`archived: true` or change moved to archive** Workflow complete
105
- 2. **`verify_result: pass` and `archived` is not `true`** Invoke `/comet-archive`
106
- 3. **`phase: verify` or tasks.md all checked** Invoke `/comet-verify`
107
- 4. **`phase: build` or has Design Doc but plan/execution incomplete** Invoke `/comet-build`
108
- 5. **`phase: design` or has change but no Design Doc** Invoke `/comet-design`
109
- 6. **No active change or state undeterminable** Invoke `/comet-open`
110
-
111
- If metadata conflicts with file state, use verifiable file state as source of truth and correct `.comet.yaml` before continuing phase.
112
-
113
- ---
114
-
115
- ## Subcommands
116
-
117
- | Command | Phase | Owner | Artifacts |
118
- |---------|-------|-------|-----------|
119
- | `/comet-open` | 1. Open | OpenSpec | proposal.md、design.md、tasks.md |
120
- | `/comet-design` | 2. Deep Design | Superpowers | Design Doc、delta spec |
121
- | `/comet-build` | 3. Plan & Build | Superpowers | Implementation plan、code commits |
122
- | `/comet-verify` | 4. Verify & Close | Both | Verification report、branch handling |
123
- | `/comet-archive` | 5. Archive | OpenSpec | deltamain spec sync、design doc markup、archive |
124
- | `/comet-hotfix` | Preset path | Both | Quick fix (skip brainstorming) |
125
- | `/comet-tweak` | Preset path | Both | Small change (skip brainstorming and full plan) |
126
-
127
- ---
128
-
129
- ## Flow Diagram
130
-
131
- ```
132
- /comet
133
- Auto-detect
134
- /comet-open ──→ /comet-design ──→ /comet-build ──→ /comet-verify ──→ /comet-archive
135
- (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
136
-
137
- /comet-hotfix(preset path, skip brainstorming)
138
- open ──→ build ──→ verify ──→ archive
139
- If upgrade triggered → supplement Design Doc → return to full workflow
140
-
141
- /comet-tweak(preset path, skip brainstorming and full plan)
142
- open ──→ lightweight build ──→ light verify ──→ archive
143
- ↑ If upgrade triggered → supplement Design Doc → return to full workflow
144
- ```
145
-
146
- ---
147
-
148
- ## Error Handling
149
-
150
- | Scenario | Handling |
151
- |----------|----------|
152
- | `openspec list --json` fails | Check if openspec is installed, prompt user to run `openspec init` |
153
- | Sub-skill unavailable (e.g., `superpowers:brainstorming`) | Stop workflow, prompt to install or enable corresponding skill |
154
- | `.comet.yaml` malformed or missing | Use file state as source of truth (tasks.md、docs/superpowers/), correct metadata then continue |
155
- | Maven compile/test fails | Return to build phase for fixes, do not enter verify |
156
- | Incomplete change directory structure | Fill missing files according to `comet-open` artifact requirements |
157
-
158
- ---
159
-
160
- ## Quick Reference
161
-
162
- ### Script Location
163
-
164
- Comet phase guard script `comet-guard.sh` and archive script `comet-archive.sh` are distributed with the skill package, located in `comet/scripts/` directory.
165
- **Do not hardcode platform paths**, self-locate at runtime with:
166
-
167
- ```bash
168
- COMET_GUARD=$(find . -path '*/comet/scripts/comet-guard.sh' -type f -print -quit)
169
- bash "$COMET_GUARD" <change-name> <phase>
170
- ```
171
-
172
- **Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
173
-
174
- ```bash
175
- bash "$COMET_GUARD" <change-name> <phase> --apply
176
- ```
177
-
178
- **Archive script**: Complete all archive steps in one command:
179
-
180
- ```bash
181
- COMET_ARCHIVE=$(find . -path '*/comet/scripts/comet-archive.sh' -type f -print -quit)
182
- bash "$COMET_ARCHIVE" <change-name>
183
- ```
184
-
185
- In subsequent documentation, `bash $COMET_GUARD <change> <phase>` refers to this command. After loading comet, agents should cache `COMET_GUARD` path in shell environment to avoid repeated `find`.
186
-
187
- ### File Structure
188
-
189
- ```
190
- openspec/ # OpenSpec — WHAT
191
- ├── config.yaml
192
- ├── changes/
193
- │ ├── <name>/ # Active change
194
- │ │ ├── .openspec.yaml
195
- │ ├── .comet.yaml
196
- │ │ ├── proposal.md # Why + What
197
- │ │ ├── design.md # High-level architecture decisions
198
- │ │ ├── specs/<capability>/spec.md # Delta capability spec
199
- │ │ └── tasks.md # Task checklist
200
- └── archive/YYYY-MM-DD-<name>/ # Archived
201
- └── specs/<capability>/spec.md # Main specs (overwritten from delta at archive)
202
-
203
- docs/superpowers/ # Superpowers — HOW
204
- ├── specs/YYYY-MM-DD-<topic>-design.md # Design doc (technical RFC, mark status at archive)
205
- └── plans/YYYY-MM-DD-<feature>.md # Implementation plan (file header contains change association metadata)
206
- ```
207
-
208
- ### Best Practices
209
-
210
- 1. **brainstorming cannot be skipped** — Every change must undergo deep design (except hotfix and tweak)
211
- 2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
212
- 3. **Keep tasks.md in sync** — Check off each completed task
213
- 4. **Commit frequently** — One commit per task, message reflects design intent
214
- 5. **Verify before archive** — Execute `/comet-archive` only after `/comet-verify` passes
215
- 6. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
216
- 7. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
217
- 8. **Archive closure** — design doc and plan must mark `archived-with` status
218
- 9. **Modifying existing features** — Just open a new change; brainstorming reads existing specs as context naturally
219
- 10. **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. OpenSpec handles WHAT, Superpowers handles HOW.
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**
26
+
27
+ 1. Run `openspec list --json` to get all active changes
28
+ 2. For each change, check `docs/superpowers/specs/` and `docs/superpowers/plans/` for associated files to determine phase and progress
29
+
30
+ | Situation | Action |
31
+ |-----------|--------|
32
+ | No active change | → Invoke `/comet-open` |
33
+ | Exactly 1 active change | → Auto-select, enter Step 1 |
34
+ | Multiple active changes | → List for user selection |
35
+
36
+ **Preset detection**:
37
+ - User describes as bug fix / hotfix + meets hotfix conditions → directly invoke `/comet-hotfix`
38
+ - User describes as copy, config, docs, prompt or small non-bug adjustment + meets tweak conditions → directly invoke `/comet-tweak`
39
+
40
+ **Step 1: Read `.comet.yaml` state metadata**
41
+
42
+ 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.
43
+
44
+ **Step 2: Phase Determination** (check in order, first match wins)
45
+
46
+ 1. `archived: true` or change moved to archive → Workflow complete
47
+ 2. `verify_result: pass` and `archived` is not `true` → Invoke `/comet-archive`
48
+ 3. `phase: verify` or tasks.md all checked Invoke `/comet-verify`
49
+ 4. `phase: build` or has Design Doc but plan/execution incomplete → Invoke `/comet-build`
50
+ 5. `phase: design` or has change but no Design Doc → Invoke `/comet-design`
51
+ 6. No active change or state undeterminable Invoke `/comet-open`
52
+
53
+ If metadata conflicts with file state, use verifiable file state as source of truth and correct `.comet.yaml` before continuing.
54
+
55
+ ### Preset Upgrade Criteria
56
+
57
+ **hotfix full** (upgrade if any condition met):
58
+ - Change involves **3+ files**
59
+ - Architecture changes (new modules, new interfaces, new dependencies)
60
+ - Database schema changes
61
+ - Fix introduces new public API
62
+ - Fix scope exceeds a single function/module
63
+
64
+ **tweak full** (upgrade if any condition met):
65
+ - Change involves **5+ files**
66
+ - Cross-module coordination required
67
+ - **5+** new test cases needed
68
+ - Config item additions or deletions (not value changes)
69
+
70
+ ### Error Handling Quick Reference
71
+
72
+ | Scenario | Handling |
73
+ |----------|----------|
74
+ | `openspec list --json` fails | Check if openspec is installed, prompt user to run `openspec init` |
75
+ | Sub-skill unavailable | Stop workflow, prompt to install or enable the corresponding skill |
76
+ | `.comet.yaml` malformed or missing | Use file state as source of truth, correct with `bash $COMET_STATE set` then continue |
77
+ | Maven compile/test fails | Return to build phase for fixes, do not enter verify |
78
+ | Incomplete change directory structure | Fill missing files according to `comet-open` artifact requirements |
79
+
80
+ ### Phase Transitions
81
+
82
+ <IMPORTANT>
83
+ A single `/comet` invocation starts from the detected phase and advances to the next phase when exit conditions are met.
84
+
85
+ Flow chain: open → design → build → verify → archive
86
+
87
+ Nodes requiring user participation:
88
+ 1. Confirm design approach during brainstorming
89
+ 2. Select execution mode during build phase
90
+ 3. Decide to fix or accept deviation when verify fails
91
+ 4. Choose branch handling method for finishing-branch
92
+ 5. Encounter upgrade conditions (hotfix/tweak full workflow)
93
+
94
+ Agents should not skip these decision points; other unambiguous phase transitions can proceed automatically.
95
+ </IMPORTANT>
96
+
97
+ ---
98
+
99
+ ## Subcommand Quick Reference
100
+
101
+ | Command | Phase | Owner | Artifacts |
102
+ |---------|-------|-------|-----------|
103
+ | `/comet-open` | 1. Open | OpenSpec | proposal.md, design.md, tasks.md |
104
+ | `/comet-design` | 2. Deep Design | Superpowers | Design Doc, delta spec |
105
+ | `/comet-build` | 3. Plan and Build | Superpowers | Implementation plan, code commits |
106
+ | `/comet-verify` | 4. Verify and Close | Both | Verification report, branch handling |
107
+ | `/comet-archive` | 5. Archive | OpenSpec | delta→main spec sync, design doc markup, archive |
108
+ | `/comet-hotfix` | Preset path | Both | Quick fix (skip brainstorming) |
109
+ | `/comet-tweak` | Preset path | Both | Small change (skip brainstorming and full plan) |
110
+
111
+ ```
112
+ /comet
113
+ ↓ Auto-detect
114
+ /comet-open ──→ /comet-design ──→ /comet-build ──→ /comet-verify ──→ /comet-archive
115
+ (OpenSpec) (Superpowers) (Superpowers) (Both) (OpenSpec)
116
+
117
+ /comet-hotfix (preset, skip brainstorming)
118
+ open ──→ build ──→ verify ──→ archive
119
+ If upgrade triggered supplement Design Doc return to full workflow
120
+
121
+ /comet-tweak (preset, skip brainstorming and full plan)
122
+ open ──→ lightweight build ──→ light verify ──→ archive
123
+ If upgrade triggered supplement Design Docreturn to full workflow
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Reference Appendix
129
+
130
+ ### .comet.yaml Field Reference
131
+
132
+ ```yaml
133
+ workflow: full
134
+ phase: build
135
+ design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
136
+ plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
137
+ build_mode: subagent-driven-development
138
+ isolation: branch
139
+ verify_mode: light
140
+ verify_result: pending
141
+ verified_at: null
142
+ archived: false
143
+ ```
144
+
145
+ | Field | Meaning |
146
+ |-------|---------|
147
+ | `workflow` | `full`, `hotfix`, or `tweak` |
148
+ | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` |
149
+ | `design_doc` | Associated Superpowers Design Doc path, can be empty |
150
+ | `plan` | Associated Superpowers Plan path, can be empty |
151
+ | `build_mode` | Selected execution mode, can be empty |
152
+ | `isolation` | `branch` or `worktree`, workspace isolation method, defaults to `branch` |
153
+ | `verify_mode` | `light` or `full`, can be empty |
154
+ | `verify_result` | `pending`, `pass`, or `fail` |
155
+ | `verified_at` | Verification pass time, can be empty |
156
+ | `archived` | Whether change is archived |
157
+
158
+ ### Script Location
159
+
160
+ Comet scripts are distributed in `comet/scripts/`. **Do not hardcode paths** — locate once, cache in env vars:
161
+
162
+ ```bash
163
+ COMET_GUARD="${COMET_GUARD:-$(find . -path '*/comet/scripts/comet-guard.sh' -type f -print -quit)}"
164
+ COMET_STATE="${COMET_STATE:-$(find . -path '*/comet/scripts/comet-state.sh' -type f -print -quit)}"
165
+ COMET_ARCHIVE="${COMET_ARCHIVE:-$(find . -path '*/comet/scripts/comet-archive.sh' -type f -print -quit)}"
166
+ ```
167
+
168
+ **Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
169
+
170
+ ```bash
171
+ bash "$COMET_GUARD" <change-name> <phase> --apply
172
+ ```
173
+
174
+ **Archive script**: Complete all archive steps in one command:
175
+
176
+ ```bash
177
+ bash "$COMET_ARCHIVE" <change-name>
178
+ ```
179
+
180
+ After loading comet, agents should run the three variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_ARCHIVE` throughout the session.
181
+
182
+ ### File Structure
183
+
184
+ ```
185
+ openspec/ # OpenSpec WHAT
186
+ ├── config.yaml
187
+ ├── changes/
188
+ │ ├── <name>/ # Active change
189
+ │ │ ├── .openspec.yaml
190
+ │ │ ├── .comet.yaml
191
+ │ │ ├── proposal.md # Why + What
192
+ │ │ ├── design.md # High-level architecture decisions
193
+ ├── specs/<capability>/spec.md # Delta capability spec
194
+ │ │ └── tasks.md # Task checklist
195
+ └── archive/YYYY-MM-DD-<name>/ # Archived
196
+ └── specs/<capability>/spec.md # Main specs (overwritten from delta at archive)
197
+
198
+ docs/superpowers/ # Superpowers HOW
199
+ ├── specs/YYYY-MM-DD-<topic>-design.md # Design doc (technical RFC, mark status at archive)
200
+ └── plans/YYYY-MM-DD-<feature>.md # Implementation plan (file header contains change association metadata)
201
+ ```
202
+
203
+ ### Best Practices
204
+
205
+ 1. **brainstorming cannot be skipped** Every change must undergo deep design (except hotfix and tweak)
206
+ 2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
207
+ 3. **Keep tasks.md in sync** — Check off each completed task
208
+ 4. **Commit frequently** — One commit per task, message reflects design intent
209
+ 5. **Verify before archive** — Execute `/comet-archive` only after `/comet-verify` passes
210
+ 6. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
211
+ 7. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
212
+ 8. **Archive closure** — design doc and plan must mark `archived-with` status
213
+ 9. **Modifying existing features** — Just open a new change
214
+ 10. **Preset has limits** — Switch to full workflow promptly when hotfix/tweak meet upgrade conditions
@@ -37,6 +37,8 @@ validate_change_name "$CHANGE"
37
37
 
38
38
  CHANGE_DIR="openspec/changes/$CHANGE"
39
39
  YAML="$CHANGE_DIR/.comet.yaml"
40
+ SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "$0" 2>/dev/null || echo "$0")" 2>/dev/null || dirname "$0")" && pwd)"
41
+ STATE_SH="$SCRIPT_DIR/comet-state.sh"
40
42
  TODAY=$(date +%Y-%m-%d)
41
43
  ARCHIVE_NAME="${TODAY}-${CHANGE}"
42
44
  ARCHIVE_DIR="openspec/changes/archive/${ARCHIVE_NAME}"
@@ -61,8 +63,12 @@ echo "=== Comet Archive: $CHANGE ===" >&2
61
63
 
62
64
  yaml_field() {
63
65
  local field="$1"
64
- if [ -f "$YAML" ]; then
65
- grep "^${field}:" "$YAML" | sed "s/^${field}: *//" | tr -d '"' | tr -d "'"
66
+ if [ -f "$STATE_SH" ]; then
67
+ bash "$STATE_SH" get "$CHANGE" "$field" 2>/dev/null
68
+ else
69
+ if [ -f "$YAML" ]; then
70
+ grep "^${field}:" "$YAML" | sed "s/^${field}: *//" | tr -d '"' | tr -d "'"
71
+ fi
66
72
  fi
67
73
  }
68
74