@rpamis/comet 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 rpamis
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rpamis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.6",
2
+ "version": "0.3.1",
3
3
  "skills": [
4
4
  "comet/SKILL.md",
5
5
  "comet/reference/dirty-worktree.md",
@@ -5,7 +5,7 @@ description: "Comet — OpenSpec + Superpowers dual-star development workflow. S
5
5
 
6
6
  # Comet — OpenSpec + Superpowers Dual-Star Development Workflow
7
7
 
8
- OpenSpec and Superpowers orbit the same goal like a binary star system. OpenSpec handles WHAT, Superpowers handles HOW.
8
+ OpenSpec and Superpowers orbit the same goal like a binary star system.
9
9
 
10
10
  ```
11
11
  OpenSpec handles WHAT — outline, proposal, spec lifecycle, archive
@@ -42,7 +42,7 @@ Agents need only read this section for decision-making. Refer to the Reference A
42
42
 
43
43
  <IMPORTANT>
44
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 plus `.comet.yaml` state.
45
+ `/comet-open` performs dual initialization: OpenSpec artifacts (created by internal `/opsx:new`) plus `.comet.yaml` state file.
46
46
  Calling `/opsx:new` directly leaves `.comet.yaml` missing and breaks later phase detection.
47
47
  </IMPORTANT>
48
48
 
@@ -53,18 +53,18 @@ Prefer reading `openspec/changes/<name>/.comet.yaml`. If not available, fall bac
53
53
  **Resume rules**:
54
54
  - On every context resume, rerun Step 0 and Step 1; do not trust conversation history for phase detection
55
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`, read the next unchecked task from tasks.md and continue
57
- - If `phase: verify` and `verify_result: fail`, first run `bash "$COMET_STATE" transition <name> verify-fail`, then invoke `/comet-build`
58
- - If `phase: open` but proposal/design/tasks are complete, run `bash "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
56
+ - If `phase: build`, first check whether `build_mode` and `isolation` are set; if any fields are unset, return to `/comet-build` corresponding step to supplement before executing; if both are set, read the next unchecked task from tasks.md and continue
57
+ - 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 `bash "$COMET_STATE" transition <name> verify-fail` and invoke `/comet-build`
58
+ - If `phase: open` but proposal/design/tasks are complete, first run `bash "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
59
59
  - 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
60
60
 
61
61
  **Step 2: Phase Determination** (check in order, first match wins)
62
62
 
63
63
  1. `archived: true` or change moved to archive → Workflow complete
64
64
  2. `verify_result: pass` and `archived` is not `true` → Invoke `/comet-archive`
65
- 3. `verify_result: fail` → run `bash "$COMET_STATE" transition <name> verify-fail`, then invoke `/comet-build`
65
+ 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`)
66
66
  4. `phase: verify` or tasks.md all checked → Invoke `/comet-verify`
67
- 5. `phase: build` or has Design Doc but plan/execution incomplete → Invoke `/comet-build`
67
+ 5. `phase: build` or has Design Doc but plan/execution incomplete → Route by workflow: `hotfix` → `/comet-hotfix`, `tweak` → `/comet-tweak`, `full` → `/comet-build`
68
68
  6. `phase: design` or has change but no Design Doc → Invoke `/comet-design`
69
69
  7. `phase: open` or active change exists but `.comet.yaml` is missing → Invoke `/comet-open`
70
70
  8. No active change → Invoke `/comet-open`
@@ -103,16 +103,19 @@ A single `/comet` invocation starts from the detected phase and advances to the
103
103
 
104
104
  Flow chain: open → design → build → verify → archive
105
105
 
106
- **Continuous execution requirement**: starting from the detected phase, the agent must automatically continue through all later phases without waiting for another user command, except at explicit decision points. After a phase completes, immediately enter the next phase.
106
+ **Continuous execution requirement**: starting from the detected phase, the agent must automatically continue through all later phases. Auto-advancing only applies at transition points without user decisions. When encountering user decision points, must pause and wait for the user's explicit response. Must not use recommendation rules, defaults, or historical preferences to substitute for user confirmation.
107
107
 
108
- Nodes requiring user participation:
108
+ **Decision points are blocking points**: whenever reaching any of the following nodes, the current `/comet` invocation must stop. Only after the user explicitly chooses can the corresponding state fields be written and operations executed, then auto-advance resumes.
109
+
110
+ Nodes requiring user participation (pause only at these nodes):
109
111
  1. Confirm design approach during brainstorming
110
- 2. Select execution mode during build phase
111
- 3. Decide to fix or accept deviation when verify fails
112
+ 2. Select workflow configuration during build phase (isolation + execution method, single interaction)
113
+ 3. Decide to fix or accept deviation when verify fails (including Spec drift handling)
112
114
  4. Choose branch handling method for finishing-branch
113
115
  5. Encounter upgrade conditions (hotfix/tweak → full workflow)
116
+ 6. Build phase scope expansion requiring redesign or new change split
114
117
 
115
- Agents should not skip these decision points; other unambiguous phase transitions can proceed automatically.
118
+ Agents should not skip these decision points; other unambiguous phase transitions must proceed automatically, must not exit midway.
116
119
  </IMPORTANT>
117
120
 
118
121
  ---
@@ -137,11 +140,11 @@ Agents should not skip these decision points; other unambiguous phase transition
137
140
 
138
141
  /comet-hotfix (preset, skip brainstorming)
139
142
  open ──→ build ──→ verify ──→ archive
140
- ↑ If upgrade triggered → supplement Design Doc → return to full workflow
143
+ ↑ If upgrade triggered → block for confirmation → supplement Design Doc → return to full workflow
141
144
 
142
145
  /comet-tweak (preset, skip brainstorming and full plan)
143
146
  open ──→ lightweight build ──→ light verify ──→ archive
144
- ↑ If upgrade triggered → supplement Design Doc → return to full workflow
147
+ ↑ If upgrade triggered → block for confirmation → supplement Design Doc → return to full workflow
145
148
  ```
146
149
 
147
150
  ---
@@ -155,12 +158,14 @@ workflow: full
155
158
  phase: build
156
159
  design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
157
160
  plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
161
+ base_ref: a1b2c3d4e5f6...
158
162
  build_mode: subagent-driven-development
159
163
  isolation: branch
160
164
  verify_mode: light
161
165
  verify_result: pending
162
166
  verification_report: null
163
167
  branch_status: pending
168
+ created_at: 2026-05-26
164
169
  verified_at: null
165
170
  archived: false
166
171
  ```
@@ -168,15 +173,17 @@ archived: false
168
173
  | Field | Meaning |
169
174
  |-------|---------|
170
175
  | `workflow` | `full`, `hotfix`, or `tweak` |
171
- | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` |
176
+ | `phase` | Current phase: `open`, `design`, `build`, `verify`, `archive` (init sets to `open` uniformly, guard handles transitions) |
172
177
  | `design_doc` | Associated Superpowers Design Doc path, can be empty |
173
178
  | `plan` | Associated Superpowers Plan path, can be empty |
174
- | `build_mode` | Selected execution mode, can be empty |
179
+ | `base_ref` | Git commit SHA recorded at init, used for scale assessment. Serves as fallback when no plan exists |
180
+ | `build_mode` | Selected execution method, can be empty |
175
181
  | `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` |
176
182
  | `verify_mode` | `light` or `full`, can be empty |
177
183
  | `verify_result` | `pending`, `pass`, or `fail` |
178
184
  | `verification_report` | Verification report file path; must point to an existing file before verify can pass |
179
185
  | `branch_status` | `pending` or `handled`; set to `handled` after branch handling completes |
186
+ | `created_at` | Change creation date (auto-set at init), format `YYYY-MM-DD` |
180
187
  | `verified_at` | Verification pass time, can be empty |
181
188
  | `archived` | Whether change is archived |
182
189
 
@@ -202,9 +209,11 @@ Comet scripts are distributed in `comet/scripts/`. **Do not hardcode paths** —
202
209
  COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
203
210
  COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
204
211
  COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
212
+ COMET_HANDOFF="${COMET_HANDOFF:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-handoff.sh' -type f -print -quit 2>/dev/null)}"
205
213
  COMET_ARCHIVE="${COMET_ARCHIVE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-archive.sh' -type f -print -quit 2>/dev/null)}"
206
214
 
207
- if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_ARCHIVE" ]; then
215
+ # Stop workflow when script location fails
216
+ if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_HANDOFF" ] || [ -z "$COMET_ARCHIVE" ]; then
208
217
  echo "ERROR: Comet scripts not found. Ensure the comet skill is installed." >&2
209
218
  echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
210
219
  return 1
@@ -234,7 +243,7 @@ bash "$COMET_STATE" transition <archive-name> archived
234
243
  bash "$COMET_ARCHIVE" <change-name>
235
244
  ```
236
245
 
237
- After loading comet, agents should run the three variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_ARCHIVE` throughout the session.
246
+ After loading comet, agents should run the variable assignments above once, then reuse `$COMET_GUARD`, `$COMET_STATE`, `$COMET_HANDOFF`, `$COMET_ARCHIVE` throughout the session.
238
247
 
239
248
  ### File Structure
240
249
 
@@ -248,6 +257,7 @@ openspec/ # OpenSpec — WHAT
248
257
  │ │ ├── proposal.md # Why + What
249
258
  │ │ ├── design.md # High-level architecture decisions
250
259
  │ │ ├── specs/<capability>/spec.md # Delta capability spec
260
+ │ │ ├── .comet/handoff/ # Script-generated phase handoff packages
251
261
  │ │ └── tasks.md # Task checklist
252
262
  │ └── archive/YYYY-MM-DD-<name>/ # Archived
253
263
  └── specs/<capability>/spec.md # Main specs (overwritten from delta at archive)
@@ -261,11 +271,12 @@ docs/superpowers/ # Superpowers — HOW
261
271
 
262
272
  1. **brainstorming cannot be skipped** — Every change must undergo deep design (except hotfix and tweak)
263
273
  2. **delta spec is a living document** — Freely modify during phase 3, sync at archive
264
- 3. **Keep tasks.md in sync** — Check off each completed task
265
- 4. **Commit frequently** — One commit per task, message reflects design intent
266
- 5. **Verify before archive** — Execute `/comet-archive` only after `/comet-verify` passes
267
- 6. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
268
- 7. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
269
- 8. **Archive closure** — design doc and plan must mark `archived-with` status
270
- 9. **Modifying existing features** — Just open a new change
271
- 10. **Preset has limits** — Switch to full workflow promptly when hotfix/tweak meet upgrade conditions
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** — Execute `/comet-archive` only after `/comet-verify` passes
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
@@ -194,17 +194,25 @@ cmd_init() {
194
194
  esac
195
195
 
196
196
  # Write .comet.yaml
197
+ # Record current HEAD as base_ref for scale assessment fallback
198
+ local base_ref="null"
199
+ if git rev-parse --verify HEAD >/dev/null 2>&1; then
200
+ base_ref=$(git rev-parse HEAD 2>/dev/null || echo "null")
201
+ fi
202
+
197
203
  cat > "$yaml_file" <<EOF
198
204
  workflow: $workflow
199
205
  phase: $phase
200
206
  build_mode: $build_mode
201
207
  isolation: $isolation
202
208
  verify_mode: $verify_mode
209
+ base_ref: $base_ref
203
210
  design_doc: null
204
211
  plan: null
205
212
  verify_result: pending
206
213
  verification_report: null
207
214
  branch_status: pending
215
+ created_at: $(date +%Y-%m-%d)
208
216
  verified_at: null
209
217
  archived: false
210
218
  EOF
@@ -251,7 +259,11 @@ cmd_set() {
251
259
 
252
260
  # Validate field name
253
261
  case "$field" in
254
- workflow|phase|build_mode|isolation|verify_mode|verify_result|verification_report|branch_status|archived|design_doc|plan|verified_at|direct_override|build_command|verify_command|handoff_context|handoff_hash)
262
+ phase)
263
+ yellow "WARNING: Setting 'phase' directly bypasses state machine constraints." >&2
264
+ yellow " Consider using: comet-state.sh transition <change-name> <event>" >&2
265
+ ;;
266
+ workflow|build_mode|isolation|verify_mode|verify_result|verification_report|branch_status|archived|design_doc|plan|verified_at|created_at|direct_override|build_command|verify_command|handoff_context|handoff_hash|base_ref)
255
267
  # Valid field
256
268
  ;;
257
269
  *)
@@ -294,7 +306,7 @@ cmd_set() {
294
306
  direct_override)
295
307
  validate_enum "$value" "true" "false"
296
308
  ;;
297
- design_doc|plan|verification_report|verified_at|build_command|verify_command|handoff_context|handoff_hash)
309
+ design_doc|plan|verification_report|verified_at|created_at|build_command|verify_command|handoff_context|handoff_hash)
298
310
  # No validation for path fields, date fields, or project command strings
299
311
  ;;
300
312
  esac
@@ -605,16 +617,20 @@ cmd_scale() {
605
617
  delta_spec_count=$(find "$change_dir/specs" -name "spec.md" -type f 2>/dev/null | wc -l | tr -d ' ')
606
618
  fi
607
619
 
608
- # 3. Changed files: prefer plan base-ref, fall back to worktree diff
620
+ # 3. Changed files: prefer plan base-ref, then .comet.yaml base_ref, fall back to worktree diff
609
621
  local changed_files=0
610
622
  if git rev-parse --git-dir > /dev/null 2>&1; then
611
- local plan_file base_ref
623
+ local plan_file base_ref=""
612
624
  plan_file=$(cmd_get "$change_name" "plan" 2>/dev/null || true)
613
625
  if [ -n "$plan_file" ] && [ "$plan_file" != "null" ] && [ -f "$plan_file" ]; then
614
626
  base_ref=$(grep '^base-ref:' "$plan_file" 2>/dev/null | head -1 | sed 's/^base-ref: *//')
615
627
  fi
628
+ # Fallback to base_ref stored in .comet.yaml (set during init)
629
+ if [ -z "$base_ref" ] || [ "$base_ref" = "null" ]; then
630
+ base_ref=$(cmd_get "$change_name" "base_ref" 2>/dev/null || true)
631
+ fi
616
632
 
617
- if [ -n "${base_ref:-}" ] && git rev-parse --verify "$base_ref" >/dev/null 2>&1; then
633
+ if [ -n "${base_ref:-}" ] && [ "$base_ref" != "null" ] && git rev-parse --verify "$base_ref" >/dev/null 2>&1; then
618
634
  changed_files=$(git diff --name-only "$base_ref"...HEAD 2>/dev/null | wc -l | tr -d ' ')
619
635
  else
620
636
  changed_files=$(git diff --name-only HEAD 2>/dev/null | wc -l | tr -d ' ')
@@ -623,7 +639,7 @@ cmd_scale() {
623
639
 
624
640
  # Decision rules
625
641
  local result="light"
626
- if [ "$task_count" -gt 3 ] || [ "$delta_spec_count" -gt 1 ] || [ "$changed_files" -gt 5 ]; then
642
+ if [ "$task_count" -gt 3 ] || [ "$delta_spec_count" -gt 1 ] || [ "$changed_files" -gt 4 ]; then
627
643
  result="full"
628
644
  fi
629
645
 
@@ -631,7 +647,7 @@ cmd_scale() {
631
647
  echo "=== Scale Assessment: $change_name ===" >&2
632
648
  echo " Tasks: $task_count (threshold: 3)" >&2
633
649
  echo " Delta specs: $delta_spec_count capabilities (threshold: 1)" >&2
634
- echo " Changed files: $changed_files (threshold: 5)" >&2
650
+ echo " Changed files: $changed_files (threshold: 4)" >&2
635
651
  echo " → Result: $result" >&2
636
652
 
637
653
  # Update verify_mode in .comet.yaml
@@ -174,7 +174,7 @@ if [ -n "$handoff_hash" ] && [ "$handoff_hash" != "null" ]; then
174
174
  fi
175
175
 
176
176
  # --- Unknown keys check ---
177
- KNOWN_KEYS="workflow phase design_doc plan build_mode isolation verify_mode verify_result verification_report branch_status verified_at archived direct_override build_command verify_command handoff_context handoff_hash"
177
+ KNOWN_KEYS="workflow phase design_doc plan build_mode isolation verify_mode verify_result verification_report branch_status verified_at created_at archived direct_override build_command verify_command handoff_context handoff_hash base_ref"
178
178
  while IFS=: read -r key _; do
179
179
  key="${key// /}"
180
180
  [ -z "$key" ] && continue
@@ -45,7 +45,7 @@ If script returns non-zero exit code, report error and stop.
45
45
  If script returns zero exit code, archive is complete.
46
46
  The summary `X/Y steps succeeded` counts real executed steps and does not double-count delta spec sync or document annotation.
47
47
 
48
- When a delta spec differs from an existing main spec, the script prints a unified diff before overwrite so the archive sync content is visible.
48
+ When a delta spec differs from an existing main spec, the script prints a unified diff preview before overwrite to help confirm archive sync content.
49
49
 
50
50
  Use `--dry-run` flag to preview without executing.
51
51
 
@@ -62,7 +62,7 @@ brainstorming → delta spec → implementation → verification → main spec o
62
62
  - Archive directory `openspec/changes/archive/YYYY-MM-DD-<change-name>/` exists
63
63
  - Archived `.comet.yaml` contains `archived: true`
64
64
 
65
- The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`. After successful archive, do not run `bash "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Archive completeness is determined by the script exit code and archived directory state.
65
+ The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`. After successful archive, **do not run** `bash "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Archive completeness is determined by script exit code and archived directory state.
66
66
 
67
67
  ## Complete
68
68
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: comet-build
3
- description: "Comet Phase 3: Plan and Build. Invoke with /comet-build. Create plans and choose execution method (subagent or direct) for implementation."
3
+ description: "Comet Phase 3: Plan and Build. Invoke with /comet-build. Create plans and select execution method (subagent or direct) for implementation."
4
4
  ---
5
5
 
6
6
  # Comet Phase 3: Plan and Build (Build)
@@ -58,9 +58,11 @@ bash "$COMET_STATE" set <name> plan docs/superpowers/plans/YYYY-MM-DD-feature.md
58
58
 
59
59
  No manual phase update needed — guard auto-transitions when exit conditions are met.
60
60
 
61
- ### 3. Workspace Isolation
61
+ ### 3. Select Workflow Configuration
62
62
 
63
- Plan has been written to the current branch. Before starting execution, choose workspace isolation method:
63
+ Plan has been written to the current branch. Before starting execution, **ask the user to choose both workspace isolation and execution method in a single interaction**:
64
+
65
+ **Workspace Isolation**:
64
66
 
65
67
  | Option | Method | Description |
66
68
  |--------|--------|-------------|
@@ -71,52 +73,30 @@ Plan has been written to the current branch. Before starting execution, choose w
71
73
  - Change involves ≤ 3 files → Recommend A
72
74
  - Need parallel development, current branch has uncommitted work → Recommend B
73
75
 
74
- After user selection, update `isolation` field. `isolation` only allows one of the following values:
75
-
76
- ```bash
77
- bash "$COMET_STATE" set <name> isolation <value>
78
- ```
79
-
80
- - `branch`
81
- - `worktree`
82
-
83
- <IMPORTANT>
84
- This is a script-enforced hard constraint, not a suggestion. Full workflow init may temporarily leave `isolation` as `null`, but only before this step.
85
- Before implementation starts, stop and ask the user, then write either `branch` or `worktree`. If it remains `null`, both the `build → verify` guard and `comet-state transition build-complete` will fail.
86
- </IMPORTANT>
87
-
88
- **Execute isolation**:
89
-
90
- - **branch**: Run `git checkout -b <change-name>`, subsequent work on the new branch
91
- - **worktree**: Invoke `superpowers:using-git-worktrees` skill or use native `EnterWorktree` tool to create isolated workspace
92
-
93
- After creating isolation, confirm plan file is accessible (naturally accessible with branch method; for worktree method, confirm plan has been committed).
94
-
95
- ### 4. Select Execution Method
96
-
97
- Present plan summary to user (task count, involved modules), then ask for execution method:
76
+ **Execution Method**:
98
77
 
99
78
  | Option | Skill | Applicable Scenario |
100
79
  |------|------|-------------------|
101
80
  | A | `superpowers:subagent-driven-development` | Independent tasks, high complexity, requires two-phase review |
102
81
  | B | `superpowers:executing-plans` | Simple tasks, no subagent environment, lightweight and fast |
103
82
 
104
- **Recommendation rules**:
83
+ **Execution method recommendation rules**:
105
84
  - Task count ≥ 3 → Recommend A
106
85
  - Task count ≤ 2 and no cross-module dependencies → Recommend B
107
86
  - From hotfix path → Recommend B
108
87
 
109
- After user selection, update `build_mode` field. `build_mode` only allows one of the following values:
88
+ This is a user decision point. Must pause and wait for the user to explicitly choose both isolation method and execution method. **Must not select based on recommendation rules**. Recommendation rules are for suggestion only, not a substitute for user confirmation.
89
+
90
+ After user selection, update `isolation` and `build_mode` fields:
110
91
 
111
92
  ```bash
112
- bash "$COMET_STATE" set <name> build_mode <value>
93
+ bash "$COMET_STATE" set <name> isolation <branch|worktree>
94
+ bash "$COMET_STATE" set <name> build_mode <subagent-driven-development|executing-plans|direct>
113
95
  ```
114
96
 
115
- - `subagent-driven-development`
116
- - `executing-plans`
117
- - `direct` (default only for hotfix/tweak preset use)
97
+ `isolation` is a script-enforced hard constraint. Full workflow init may temporarily leave it as `null`, but only before this step. If it remains `null`, both the `build → verify` guard and `comet-state transition build-complete` will fail.
118
98
 
119
- Full workflow must not default to `direct`. Use it only when the user explicitly asks to bypass the plan execution skills and you record an explicit override:
99
+ `build_mode` defaults to `direct` only for hotfix/tweak presets. Full workflow must not default to `direct`. Use it only when the user explicitly asks to bypass the plan execution skills and you record an explicit override:
120
100
 
121
101
  ```bash
122
102
  bash "$COMET_STATE" set <name> direct_override true
@@ -125,7 +105,14 @@ bash "$COMET_STATE" set <name> build_mode direct
125
105
 
126
106
  Without `direct_override: true`, `build_mode=direct` in full workflow is blocked by both guard and state transition.
127
107
 
128
- Then, **immediately execute:** Use the Skill tool to load the corresponding skill. Skipping this step is prohibited.
108
+ **Execute isolation**:
109
+
110
+ - **branch**: Run `git checkout -b <change-name>`, subsequent work on the new branch
111
+ - **worktree**: Must use the Skill tool to load `superpowers:using-git-worktrees` skill to create isolated workspace. Do not bypass this skill with plain shell commands or native tools; if the skill is unavailable, stop the process and prompt to install or enable Superpowers skills.
112
+
113
+ After creating isolation, confirm plan file is accessible (naturally accessible with branch method; for worktree method, confirm plan has been committed).
114
+
115
+ **Load execution skill**: Use the Skill tool to load the corresponding skill. Skipping this step is prohibited.
129
116
 
130
117
  If the selected Superpowers skill is unavailable, stop the process and prompt to install or enable the corresponding skill. Do not substitute this step with normal conversation.
131
118
 
@@ -134,17 +121,19 @@ After the skill loads, follow its guidance to execute:
134
121
  - Complete tasks.md check (`- [ ]` → `- [x]`)
135
122
  - Commit code after each task completion
136
123
 
137
- ### 5. Spec Incremental Updates
124
+ ### 4. Spec Incremental Updates
138
125
 
139
126
  When the initial spec is found incomplete during implementation, handle by scale:
140
127
 
141
128
  | Scale | Trigger Conditions | Approach |
142
129
  |------|-------------------|----------|
143
130
  | Small | Missing acceptance scenarios, edge cases | Directly edit delta spec + design.md, append tasks.md tasks |
144
- | Medium | Interface changes, new components, data flow changes | Re-run `superpowers:brainstorming` to update Design Doc + delta spec |
145
- | Large | Brand-new capability requirements | `/opsx:new` to create independent change |
131
+ | Medium | Interface changes, new components, data flow changes | Pause and wait for user confirmation, then must use Skill tool to load `superpowers:brainstorming` to update Design Doc + delta spec |
132
+ | Large | Brand-new capability requirements | Must pause and wait for user confirmation to split; after user confirms, create independent change through `/comet-open` |
133
+
134
+ **50% Threshold Determination**: Using initial task count in tasks.md as baseline, if new tasks exceed half of that total, it's considered outside original plan scope, must pause and wait for the user to decide whether to split into new change.
146
135
 
147
- **50% Threshold Determination**: Using initial task count in tasks.md as baseline, if new tasks exceed half of that total, it's considered outside original plan scope, should consider splitting into new change.
136
+ When creating an independent change, must invoke `/comet-open`, not `/opsx:new` directly. `/comet-open` creates both OpenSpec artifacts and `.comet.yaml`, preventing the new change from leaving the Comet state machine.
148
137
 
149
138
  **Principles**:
150
139
  - Delta spec is a living document, can be modified at any time during this phase
@@ -152,14 +141,14 @@ When the initial spec is found incomplete during implementation, handle by scale
152
141
  - Do not sync to main spec in advance, sync uniformly during archiving
153
142
  - For small-scale incremental direct delta spec edits, note in commit message to facilitate design doc drift assessment during archiving
154
143
 
155
- ### 6. Context Management
144
+ ### 5. Context Management
156
145
 
157
146
  Build is the longest phase and may span many tasks. To support resume after context compaction:
158
147
 
159
148
  - **After each task**: immediately check off tasks.md and commit code so `.comet.yaml` and file state are durable
160
149
  - **After context compaction**: read `.comet.yaml` to confirm the phase is still build, read the plan header `base-ref`, then read tasks.md to find the next unchecked task
161
150
  - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
162
- 1. After attribution, if the diff implies plan or spec changes, handle it through Step 5 "Spec Incremental Updates"
151
+ 1. After attribution, if the diff implies plan or spec changes, handle it through Step 4 "Spec Incremental Updates"
163
152
  - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
164
153
 
165
154
  ## Exit Conditions
@@ -20,58 +20,126 @@ Execute entry verification:
20
20
  COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
21
21
  COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
22
22
  COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
23
+ COMET_HANDOFF="${COMET_HANDOFF:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-handoff.sh' -type f -print -quit 2>/dev/null)}"
23
24
  bash "$COMET_STATE" check <name> design
24
25
  ```
25
26
 
26
27
  Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
27
28
 
28
- ### 1a. Read Existing Context
29
+ ### 1a. Generate OpenSpec → Superpowers Handoff Package
29
30
 
30
- Read `proposal.md` and `design.md` under the active change, organize core content into summaries:
31
- - **Proposal summary**: goals, motivation, scope
32
- - **Design summary**: architectural decisions, high-level design
31
+ **Must be generated by script. Agent writing summaries on the fly is not allowed.**
33
32
 
34
- ### 1b. Execute Brainstorming (With Context)
33
+ ```bash
34
+ bash "$COMET_HANDOFF" <change-name> design --write
35
+ ```
36
+
37
+ The script generates and records:
38
+
39
+ ```
40
+ openspec/changes/<name>/.comet/handoff/design-context.json
41
+ openspec/changes/<name>/.comet/handoff/design-context.md
42
+ ```
43
+
44
+ And writes to `.comet.yaml`:
35
45
 
36
- **Immediately execute:** Use the Skill tool to load the `superpowers:brainstorming` skill, ARGUMENTS contains:
46
+ ```yaml
47
+ handoff_context: openspec/changes/<name>/.comet/handoff/design-context.json
48
+ handoff_hash: <sha256>
49
+ ```
50
+
51
+ The default handoff package is a **compact traceable excerpt**, not an agent summary:
52
+ - `design-context.json`: machine index containing change, phase, canonical spec, source paths, hash
53
+ - `design-context.md`: context for Superpowers to read, containing script markers, source path, line range, sha256, deterministic excerpts
54
+ - When exceeding excerpt budget, marks `[TRUNCATED]` and retains Full source path
55
+
56
+ If full context is genuinely needed, explicitly run:
57
+
58
+ ```bash
59
+ bash "$COMET_HANDOFF" <change-name> design --write --full
60
+ ```
61
+
62
+ Handoff package sources come from OpenSpec open phase artifacts:
63
+ - `proposal.md`: goals, motivation, scope, non-goals
64
+ - `design.md`: high-level architecture decisions, approach constraints
65
+ - `tasks.md`: initial task boundaries
66
+ - `specs/*/spec.md`: delta capability specs
67
+
68
+ ### 1b. Execute Brainstorming (with Context)
69
+
70
+ **Immediately execute:** Use the Skill tool to load the `superpowers:brainstorming` skill, ARGUMENTS containing:
37
71
 
38
72
  ```
39
73
  Change: <change-name>
40
- Proposal summary: <proposal core content>
41
- Design summary: <design.md architectural decisions>
42
- Skip context exploration, proceed directly to design questioning.
74
+ OpenSpec Context Pack: openspec/changes/<name>/.comet/handoff/design-context.md
75
+ Machine handoff: openspec/changes/<name>/.comet/handoff/design-context.json
76
+
77
+ OpenSpec artifacts are the upstream source of truth. Do not redefine requirements, do not rewrite proposal/spec.
78
+ Your task is to perform deep technical design based on the handoff package: implementation approach, technical risks, testing strategy, boundary conditions.
79
+ If you find OpenSpec delta spec missing acceptance scenarios, you may only propose Spec Patches and write them back to OpenSpec delta spec; do not create a second requirements spec in the Design Doc.
80
+
81
+ Design Doc frontmatter must be minimal, containing only:
82
+ ---
83
+ comet_change: <change-name>
84
+ role: technical-design
85
+ canonical_spec: openspec
86
+ ---
87
+
88
+ Skip redundant context exploration, proceed directly to design questions.
43
89
  ```
44
90
 
45
- Skipping this step is prohibited, and continuing without loading this skill is prohibited.
91
+ Skipping this step is prohibited. Proceeding without loading this skill is prohibited.
46
92
 
47
93
  If `superpowers:brainstorming` is unavailable, stop the process and prompt to install or enable Superpowers skills. Do not substitute this step with normal conversation.
48
94
 
49
- After the skill loads, follow its guidance to produce:
50
- - `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md` design document (technical RFC)
51
- - `openspec/changes/<name>/specs/<capability>/spec.md` — capability specification (delta)
95
+ After the skill loads, follow its guidance to produce design proposals (presented as conversation):
96
+ - Technical approach: architecture, data flow, key technology choices and risks
97
+ - Testing strategy
98
+ - If acceptance scenarios need supplementing, indicate delta spec changes to be written back
99
+
100
+ The brainstorming phase does not write to the Design Doc file; it only produces design proposals for Step 1c user confirmation. Only after confirmation should `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md` be created and delta spec written back.
101
+
102
+ ### 1c. User Confirms Design Proposal (Blocking Point)
103
+
104
+ After brainstorming produces a design proposal, **must pause and wait for the user to explicitly confirm the design proposal**. Must not create the final Design Doc, write `design_doc`, run design guard, or enter `/comet-build` before user confirmation.
105
+
106
+ When pausing, only present essential summary:
107
+ - Technical approach adopted
108
+ - Key trade-offs and risks
109
+ - Testing strategy
110
+ - If there are Spec Patches, list the delta spec changes to be written back
111
+
112
+ Only after the user explicitly confirms, proceed to Step 2. If the user requests adjustments, continue brainstorming iteration until the user confirms.
52
113
 
53
114
  ### 2. Update Comet State
54
115
 
55
- Record design_doc path, then run guard to auto-transition:
116
+ First record the design_doc path. If Step 1c wrote back delta spec (added or modified `specs/*/spec.md`), must regenerate handoff to update hash:
56
117
 
57
118
  ```bash
58
119
  # Record design_doc path
59
120
  bash "$COMET_STATE" set <name> design_doc docs/superpowers/specs/YYYY-MM-DD-topic-design.md
60
121
 
122
+ # If delta spec changes exist, regenerate handoff (update hash)
123
+ bash "$COMET_HANDOFF" <change-name> design --write
124
+
61
125
  # Auto-transition to next phase
62
126
  bash "$COMET_GUARD" <change-name> design --apply
63
127
  ```
64
128
 
65
- State file is updated automatically. No manual editing of other fields required.
129
+ If there are no delta spec changes, skip the handoff regeneration step. The state file updates automatically; no manual editing of other fields needed.
66
130
 
67
131
  ## Exit Conditions
68
132
 
69
- - Design Doc has been created and saved
70
- - Delta spec has been created if there are new capabilities
133
+ - Design Doc created and saved
134
+ - Design Doc frontmatter contains `comet_change`, `role: technical-design`, `canonical_spec: openspec`
135
+ - `handoff_context` and `handoff_hash` written to `.comet.yaml` (enforced by guard)
136
+ - `handoff_hash` matches current OpenSpec open phase artifacts (enforced by guard)
137
+ - `design-context.md` must be script-generated and contain source path, mode, sha256 traceability markers (enforced by guard)
138
+ - If new capabilities or supplementary acceptance scenarios exist, OpenSpec delta spec has been created/updated
71
139
  - `design_doc` written to `.comet.yaml`
72
- - **Phase guard**: Run `bash "$COMET_GUARD" <change-name> design --apply`; after all PASS, state advances to `phase: build`
140
+ - **Phase guard**: Run `bash "$COMET_GUARD" <change-name> design --apply`; after all PASS, auto-transitions to `phase: build`
73
141
 
74
- You must use `--apply` before exiting:
142
+ Must use `--apply` before exit:
75
143
 
76
144
  ```bash
77
145
  bash "$COMET_GUARD" <change-name> design --apply
@@ -81,4 +149,4 @@ bash "$COMET_GUARD" <change-name> design --apply
81
149
 
82
150
  After exit conditions are met, **proceed immediately to the next phase without waiting for user input**:
83
151
 
84
- > **REQUIRED NEXT SKILL:** Invoke `comet-build` skill to enter the planning and build phase.
152
+ > **REQUIRED NEXT SKILL:** Invoke `comet-build` skill to enter the plan and build phase.