@rpamis/comet 0.1.5 → 0.1.7

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/README.md CHANGED
@@ -153,6 +153,7 @@ Comet uses a decoupled state architecture with separate YAML files:
153
153
  - `design_doc`: Path to Superpowers Design Doc
154
154
  - `plan`: Path to implementation plan
155
155
  - `build_mode`: `subagent-driven-development`, `executing-plans`, or `direct`
156
+ - `isolation`: `branch` or `worktree`, workspace isolation method
156
157
  - `verify_mode`: `light` or `full`
157
158
  - `verify_result`: `pending`, `pass`, or `fail`
158
159
  - `archived`: Boolean indicating if change is archived
@@ -170,8 +171,8 @@ Comet includes three-layer defense to ensure agent execution reliability:
170
171
  - Automatic retry mechanism (up to 2 attempts) on mismatch
171
172
 
172
173
  3. **Schema Validation** — `comet-yaml-validate.sh` ensures data integrity
173
- - Validates required fields (9 fields)
174
- - Validates enum values (6 enum types)
174
+ - Validates required fields (10 fields)
175
+ - Validates enum values (7 enum types)
175
176
  - Validates referenced file paths exist
176
177
  - Detects unknown/typos fields
177
178
 
@@ -208,7 +209,7 @@ your-project/
208
209
 
209
210
  ```bash
210
211
  # Clone
211
- git clone https://github.com/benym/comet.git
212
+ git clone https://github.com/rpamis/comet
212
213
  cd comet
213
214
 
214
215
  # Install dependencies
@@ -75,6 +75,7 @@ phase: build
75
75
  design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
76
76
  plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
77
77
  build_mode: subagent-driven-development
78
+ isolation: branch
78
79
  verify_mode: light
79
80
  verify_result: pending
80
81
  verified_at: null
@@ -90,6 +91,7 @@ Field meanings:
90
91
  | `design_doc` | Associated Superpowers Design Doc path, can be empty |
91
92
  | `plan` | Associated Superpowers Plan path, can be empty |
92
93
  | `build_mode` | Selected execution mode, can be empty |
94
+ | `isolation` | `branch` or `worktree`, workspace isolation method, defaults to `branch` |
93
95
  | `verify_mode` | `light` or `full`, can be empty |
94
96
  | `verify_result` | `pending`, `pass`, or `fail` |
95
97
  | `verified_at` | Verification pass time, can be empty |
@@ -159,7 +161,7 @@ If metadata conflicts with file state, use verifiable file state as source of tr
159
161
 
160
162
  ### Script Location
161
163
 
162
- Comet phase guard script `comet-guard.sh` is distributed with the skill package, located in `comet/scripts/` directory.
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.
163
165
  **Do not hardcode platform paths**, self-locate at runtime with:
164
166
 
165
167
  ```bash
@@ -167,6 +169,19 @@ COMET_GUARD=$(find . -path '*/comet/scripts/comet-guard.sh' -type f -print -quit
167
169
  bash "$COMET_GUARD" <change-name> <phase>
168
170
  ```
169
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
+
170
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`.
171
186
 
172
187
  ### File Structure
@@ -183,7 +198,7 @@ openspec/ # OpenSpec — WHAT
183
198
  │ │ ├── specs/<capability>/spec.md # Delta capability spec
184
199
  │ │ └── tasks.md # Task checklist
185
200
  │ └── archive/YYYY-MM-DD-<name>/ # Archived
186
- └── specs/<capability>/spec.md # Main specs (sync from delta at archive)
201
+ └── specs/<capability>/spec.md # Main specs (overwritten from delta at archive)
187
202
 
188
203
  docs/superpowers/ # Superpowers — HOW
189
204
  ├── specs/YYYY-MM-DD-<topic>-design.md # Design doc (technical RFC, mark status at archive)
@@ -200,5 +215,5 @@ docs/superpowers/ # Superpowers — HOW
200
215
  6. **Classify incremental updates** — Small edits, medium brainstorming, large new changes
201
216
  7. **Plan must associate with change** — File header contains `change:` and `design-doc:` metadata
202
217
  8. **Archive closure** — design doc and plan must mark `archived-with` status
203
- 9. **Incremental modification of existing features** — Create delta spec baseline based on main spec, not from scratch
218
+ 9. **Modifying existing features** — Just open a new change; brainstorming reads existing specs as context naturally
204
219
  10. **Preset has limits** — Switch to full workflow promptly when hotfix/tweak meet upgrade conditions
@@ -0,0 +1,252 @@
1
+ #!/bin/bash
2
+ # Comet Archive — automates the archive phase in one command
3
+ # Usage: comet-archive.sh <change-name> [--dry-run]
4
+ # Exit 0 = archive complete, exit 1 = fatal error
5
+
6
+ set -euo pipefail
7
+
8
+ red() { echo -e "\033[31m$1\033[0m" >&2; }
9
+ green() { echo -e "\033[32m$1\033[0m" >&2; }
10
+ yellow() { echo -e "\033[33m$1\033[0m" >&2; }
11
+
12
+ DRY_RUN=0
13
+ if [[ "${2:-}" == "--dry-run" ]]; then
14
+ DRY_RUN=1
15
+ fi
16
+
17
+ # Input validation
18
+ validate_change_name() {
19
+ local name="$1"
20
+ if [ -z "$name" ]; then
21
+ red "FATAL: Change name cannot be empty"
22
+ exit 1
23
+ fi
24
+ if [[ ! "$name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
25
+ red "FATAL: Invalid change name: '$name'"
26
+ red "Valid characters: a-z, A-Z, 0-9, -, _"
27
+ exit 1
28
+ fi
29
+ if [[ "$name" =~ \.\. ]]; then
30
+ red "FATAL: Change name cannot contain '..'"
31
+ exit 1
32
+ fi
33
+ }
34
+
35
+ CHANGE="$1"
36
+ validate_change_name "$CHANGE"
37
+
38
+ CHANGE_DIR="openspec/changes/$CHANGE"
39
+ YAML="$CHANGE_DIR/.comet.yaml"
40
+ TODAY=$(date +%Y-%m-%d)
41
+ ARCHIVE_NAME="${TODAY}-${CHANGE}"
42
+ ARCHIVE_DIR="openspec/changes/archive/${ARCHIVE_NAME}"
43
+
44
+ STEPS_OK=0
45
+ STEPS_TOTAL=0
46
+
47
+ step_ok() {
48
+ green " [OK] $1"
49
+ STEPS_OK=$((STEPS_OK + 1))
50
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
51
+ }
52
+
53
+ step_fail() {
54
+ red " [FAIL] $1"
55
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
56
+ }
57
+
58
+ echo "=== Comet Archive: $CHANGE ===" >&2
59
+
60
+ # --- Step 1: Read .comet.yaml, extract paths ---
61
+
62
+ yaml_field() {
63
+ local field="$1"
64
+ if [ -f "$YAML" ]; then
65
+ grep "^${field}:" "$YAML" | sed "s/^${field}: *//" | tr -d '"' | tr -d "'"
66
+ fi
67
+ }
68
+
69
+ if [ ! -f "$YAML" ]; then
70
+ red "FATAL: .comet.yaml not found in $CHANGE_DIR/"
71
+ exit 1
72
+ fi
73
+
74
+ DESIGN_DOC=$(yaml_field "design_doc")
75
+ PLAN_PATH=$(yaml_field "plan")
76
+
77
+ # --- Step 2: Validate entry state ---
78
+
79
+ PHASE_VAL=$(yaml_field "phase")
80
+ VERIFY_VAL=$(yaml_field "verify_result")
81
+ ARCHIVED_VAL=$(yaml_field "archived")
82
+
83
+ if [ "$PHASE_VAL" != "archive" ]; then
84
+ red "FATAL: phase is '$PHASE_VAL', expected 'archive'"
85
+ exit 1
86
+ fi
87
+
88
+ if [ "$VERIFY_VAL" != "pass" ]; then
89
+ red "FATAL: verify_result is '$VERIFY_VAL', expected 'pass'. Run comet-verify first."
90
+ exit 1
91
+ fi
92
+
93
+ if [ "$ARCHIVED_VAL" = "true" ]; then
94
+ red "FATAL: change already archived"
95
+ exit 1
96
+ fi
97
+
98
+ step_ok "Entry state verified"
99
+
100
+ # --- Step 3: Check archive target ---
101
+
102
+ if [ -d "$ARCHIVE_DIR" ]; then
103
+ red "FATAL: archive target already exists: $ARCHIVE_DIR"
104
+ exit 1
105
+ fi
106
+
107
+ step_ok "Archive target available"
108
+
109
+ # --- Step 4: Sync delta specs → main specs ---
110
+
111
+ sync_delta_specs() {
112
+ local delta_root="$CHANGE_DIR/specs"
113
+ if [ ! -d "$delta_root" ]; then
114
+ return 0
115
+ fi
116
+
117
+ for delta_spec_dir in "$delta_root"/*/; do
118
+ [ -d "$delta_spec_dir" ] || continue
119
+ local capability
120
+ capability=$(basename "$delta_spec_dir")
121
+ local delta_spec="$delta_spec_dir/spec.md"
122
+ local main_spec="openspec/specs/$capability/spec.md"
123
+
124
+ if [ ! -f "$delta_spec" ]; then
125
+ continue
126
+ fi
127
+
128
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
129
+
130
+ if [ "$DRY_RUN" -eq 1 ]; then
131
+ yellow " [DRY-RUN] Would sync: $capability → $main_spec"
132
+ STEPS_OK=$((STEPS_OK + 1))
133
+ continue
134
+ fi
135
+
136
+ if [ ! -f "$main_spec" ]; then
137
+ mkdir -p "openspec/specs/$capability"
138
+ fi
139
+ cp "$delta_spec" "$main_spec"
140
+
141
+ step_ok "Delta spec synced: $capability → openspec/specs/$capability/spec.md"
142
+ done
143
+ }
144
+
145
+ sync_delta_specs
146
+
147
+ # --- Step 5: Annotate design doc frontmatter ---
148
+
149
+ annotate_frontmatter() {
150
+ local file="$1"
151
+ local extra_fields="$2"
152
+
153
+ if [ ! -f "$file" ]; then
154
+ return 0
155
+ fi
156
+
157
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
158
+
159
+ if [ "$DRY_RUN" -eq 1 ]; then
160
+ yellow " [DRY-RUN] Would annotate: $file"
161
+ STEPS_OK=$((STEPS_OK + 1))
162
+ return 0
163
+ fi
164
+
165
+ if head -1 "$file" | grep -q '^---'; then
166
+ local tmp_file
167
+ tmp_file=$(mktemp)
168
+ awk -v archive="$ARCHIVE_NAME" -v extra="$extra_fields" '
169
+ /^archived-with:/ { next }
170
+ NR==1 && /^---/ { print; next }
171
+ /^---/ && NR>1 {
172
+ print "archived-with: " archive
173
+ if (extra != "") print extra
174
+ print; next
175
+ }
176
+ { print }
177
+ ' "$file" > "$tmp_file"
178
+ mv "$tmp_file" "$file"
179
+ else
180
+ local tmp_file
181
+ tmp_file=$(mktemp)
182
+ {
183
+ echo "---"
184
+ echo "archived-with: $ARCHIVE_NAME"
185
+ if [ -n "$extra_fields" ]; then
186
+ echo "$extra_fields"
187
+ fi
188
+ echo "status: final"
189
+ echo "---"
190
+ cat "$file"
191
+ } > "$tmp_file"
192
+ mv "$tmp_file" "$file"
193
+ fi
194
+
195
+ step_ok "Annotated: $file"
196
+ }
197
+
198
+ if [ -n "$DESIGN_DOC" ] && [ "$DESIGN_DOC" != "null" ]; then
199
+ annotate_frontmatter "$DESIGN_DOC" "status: final"
200
+ fi
201
+
202
+ # --- Step 6: Annotate plan frontmatter ---
203
+
204
+ if [ -n "$PLAN_PATH" ] && [ "$PLAN_PATH" != "null" ]; then
205
+ annotate_frontmatter "$PLAN_PATH" ""
206
+ fi
207
+
208
+ # --- Step 7: Move change to archive ---
209
+
210
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
211
+
212
+ if [ "$DRY_RUN" -eq 1 ]; then
213
+ yellow " [DRY-RUN] Would move: $CHANGE_DIR → $ARCHIVE_DIR"
214
+ STEPS_OK=$((STEPS_OK + 1))
215
+ else
216
+ mkdir -p "openspec/changes/archive"
217
+ mv "$CHANGE_DIR" "$ARCHIVE_DIR"
218
+ step_ok "Moved to: $ARCHIVE_DIR"
219
+ fi
220
+
221
+ # --- Step 8: Update archived: true in .comet.yaml ---
222
+
223
+ STEPS_TOTAL=$((STEPS_TOTAL + 1))
224
+
225
+ ARCHIVE_YAML="$ARCHIVE_DIR/.comet.yaml"
226
+
227
+ if [ "$DRY_RUN" -eq 1 ]; then
228
+ yellow " [DRY-RUN] Would set archived: true in $ARCHIVE_YAML"
229
+ STEPS_OK=$((STEPS_OK + 1))
230
+ else
231
+ if [ -f "$ARCHIVE_YAML" ]; then
232
+ sed -i 's/^archived:.*/archived: true/' "$ARCHIVE_YAML"
233
+ step_ok "archived: true"
234
+ else
235
+ step_fail "archived: true (.comet.yaml not found after move)"
236
+ fi
237
+ fi
238
+
239
+ # --- Step 9: Print summary ---
240
+
241
+ echo "" >&2
242
+ if [ "$DRY_RUN" -eq 1 ]; then
243
+ yellow "Dry run complete. $STEPS_OK/$STEPS_TOTAL steps would succeed."
244
+ else
245
+ green "Archive complete. $STEPS_OK/$STEPS_TOTAL steps succeeded."
246
+ fi
247
+
248
+ if [ "$STEPS_OK" -lt "$STEPS_TOTAL" ]; then
249
+ exit 1
250
+ fi
251
+
252
+ exit 0
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
  # Comet Phase Guard — validates exit conditions before phase transitions
3
- # Usage: comet-guard.sh <change-name> <from-phase>
3
+ # Usage: comet-guard.sh <change-name> <current-phase> [--apply]
4
4
  # Phases: open, design, build, verify, archive
5
5
  # Exit 0 = all checks pass, exit 1 = blocked (reasons printed to stderr)
6
6
 
@@ -35,6 +35,10 @@ validate_change_name "$1"
35
35
 
36
36
  CHANGE="$1"
37
37
  PHASE="$2"
38
+ APPLY=0
39
+ if [[ "${3:-}" == "--apply" ]]; then
40
+ APPLY=1
41
+ fi
38
42
  CHANGE_DIR="openspec/changes/$CHANGE"
39
43
 
40
44
  BLOCK=0
@@ -177,6 +181,33 @@ guard_archive() {
177
181
  check "tasks.md all tasks checked" tasks_all_done
178
182
  }
179
183
 
184
+ apply_state_update() {
185
+ local yaml="$CHANGE_DIR/.comet.yaml"
186
+ local p="$1"
187
+
188
+ case "$p" in
189
+ open)
190
+ sed -i 's/^phase:.*/phase: design/' "$yaml"
191
+ ;;
192
+ design)
193
+ sed -i 's/^phase:.*/phase: build/' "$yaml"
194
+ ;;
195
+ build)
196
+ sed -i 's/^phase:.*/phase: verify/' "$yaml"
197
+ sed -i 's/^verify_result:.*/verify_result: pending/' "$yaml"
198
+ ;;
199
+ verify)
200
+ sed -i 's/^phase:.*/phase: archive/' "$yaml"
201
+ sed -i 's/^verify_result:.*/verify_result: pass/' "$yaml"
202
+ if ! grep -q '^verified_at:' "$yaml" 2>/dev/null; then
203
+ echo "verified_at: $(date +%Y-%m-%d)" >> "$yaml"
204
+ else
205
+ sed -i "s/^verified_at:.*/verified_at: $(date +%Y-%m-%d)/" "$yaml"
206
+ fi
207
+ ;;
208
+ esac
209
+ }
210
+
180
211
  # --- Main ---
181
212
 
182
213
  case "$PHASE" in
@@ -199,5 +230,14 @@ if [ "$BLOCK" -eq 1 ]; then
199
230
  else
200
231
  echo "" >&2
201
232
  green "ALL CHECKS PASSED — ready for next phase"
233
+ if [ "$APPLY" -eq 1 ]; then
234
+ apply_state_update "$PHASE"
235
+ case "$PHASE" in
236
+ open) green " [APPLY] .comet.yaml updated: phase=design" ;;
237
+ design) green " [APPLY] .comet.yaml updated: phase=build" ;;
238
+ build) green " [APPLY] .comet.yaml updated: phase=verify, verify_result=pending" ;;
239
+ verify) green " [APPLY] .comet.yaml updated: phase=archive, verify_result=pass" ;;
240
+ esac
241
+ fi
202
242
  exit 0
203
243
  fi
@@ -49,7 +49,7 @@ warn_msg() { warn " WARN: $1"; WARNINGS=$((WARNINGS + 1)); }
49
49
  echo "[VALIDATE] $YAML" >&2
50
50
 
51
51
  # --- Required fields ---
52
- REQUIRED_FIELDS="workflow phase design_doc plan build_mode verify_mode verify_result verified_at archived"
52
+ REQUIRED_FIELDS="workflow phase design_doc plan build_mode isolation verify_mode verify_result verified_at archived"
53
53
  for field in $REQUIRED_FIELDS; do
54
54
  if ! grep -q "^${field}:" "$YAML" 2>/dev/null; then
55
55
  fail "missing required field '$field'"
@@ -78,6 +78,7 @@ validate_enum() {
78
78
  workflow=$(field_value "workflow")
79
79
  phase=$(field_value "phase")
80
80
  build_mode=$(field_value "build_mode")
81
+ isolation=$(field_value "isolation")
81
82
  verify_mode=$(field_value "verify_mode")
82
83
  verify_result=$(field_value "verify_result")
83
84
  archived=$(field_value "archived")
@@ -87,6 +88,7 @@ plan=$(field_value "plan")
87
88
  validate_enum "workflow" "$workflow" "full hotfix tweak"
88
89
  validate_enum "phase" "$phase" "design build verify archive"
89
90
  validate_enum "build_mode" "$build_mode" "subagent-driven-development executing-plans direct"
91
+ validate_enum "isolation" "$isolation" "branch worktree"
90
92
  validate_enum "verify_mode" "$verify_mode" "light full"
91
93
  validate_enum "verify_result" "$verify_result" "pending pass fail"
92
94
  validate_enum "archived" "$archived" "true false"
@@ -106,7 +108,7 @@ if [ -n "$plan" ] && [ "$plan" != "null" ]; then
106
108
  fi
107
109
 
108
110
  # --- Unknown keys check ---
109
- KNOWN_KEYS="workflow phase design_doc plan build_mode verify_mode verify_result verified_at archived"
111
+ KNOWN_KEYS="workflow phase design_doc plan build_mode isolation verify_mode verify_result verified_at archived"
110
112
  while IFS=: read -r key _; do
111
113
  key="${key// /}"
112
114
  [ -z "$key" ] && continue
@@ -39,113 +39,38 @@ Proceed to Step 1 only after verification passes.
39
39
 
40
40
  ### 1. Execute Archive
41
41
 
42
- Before archiving, if `verify_result` is not `pass`, stop archiving and return to `/comet-verify`.
43
-
44
- **Immediately execute:** Use the Skill tool to load the `openspec-archive-change` skill. Skipping this step is prohibited.
45
-
46
- After the skill loads, follow its guidance to archive. Automatic checks:
47
- 1. Artifact completion status (proposal, design, specs, tasks)
48
- 2. All tasks marked `[x]`
49
- 3. Delta specs sync status
50
-
51
- ### 1b. Move Comet State File
52
-
53
- `openspec-archive-change` is not aware of `.comet.yaml`, so Comet needs to move this file itself after OpenSpec archiving completes:
42
+ Run the archive script to automatically complete all steps:
54
43
 
55
44
  ```bash
56
- mv openspec/changes/<name>/.comet.yaml openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
57
- ```
58
-
59
- 【Write verification】After move completion, must verify:
60
- test -f openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
61
- Confirm .comet.yaml exists in archive directory
62
- If file is not at expected location, check if mv command executed successfully.
63
-
64
- ### 2. Delta Spec Sync
65
-
66
- Sync delta specs to main specs during archiving:
67
-
68
- ```
69
- openspec/changes/<name>/specs/<capability>/spec.md
70
- ↓ sync
71
- openspec/specs/<capability>/spec.md ← main spec (persistent)
45
+ COMET_ARCHIVE=$(find . -path '*/comet/scripts/comet-archive.sh' -type f -print -quit)
46
+ bash "$COMET_ARCHIVE" "<change-name>"
72
47
  ```
73
48
 
74
- ### 3. Design Doc & Plan Handling
75
-
76
- Handle associated files under `docs/superpowers/` during archiving. If target file already has YAML frontmatter, merge archive fields into existing frontmatter; if no frontmatter, create new frontmatter.
77
-
78
- **3a. Design Doc Consistency Annotation**
49
+ The script automatically executes:
50
+ 1. Entry state validation (phase=archive, verify_result=pass, archived=false)
51
+ 2. Delta spec sync to main spec (overwrite)
52
+ 3. Design doc frontmatter annotation (archived-with, status)
53
+ 4. Plan frontmatter annotation (archived-with)
54
+ 5. Move change to archive directory
55
+ 6. Update archived: true
79
56
 
80
- Find design documents associated with current change in `docs/superpowers/specs/`:
81
- - Compare delta spec final version with design doc content
82
- - If there are discrepancies (incremental spec modifications during implementation), set the following metadata in design doc's YAML frontmatter:
57
+ If script returns non-zero exit code, report error and stop.
58
+ If script returns zero exit code, archive is complete.
83
59
 
84
- ```yaml
85
- ---
86
- archived-with: YYYY-MM-DD-<name>
87
- status: superseded-by-main-spec
88
- implementation-notes: |
89
- <briefly describe key changes deviating from original design during implementation>
90
- ---
91
- ```
60
+ Use `--dry-run` flag to preview without executing.
92
61
 
93
- - If completely consistent, only set:
94
-
95
- ```yaml
96
- ---
97
- archived-with: YYYY-MM-DD-<name>
98
- status: final
99
- ---
100
- ```
101
-
102
- **3b. Plan Association Annotation**
103
-
104
- Find implementation plans associated with current change in `docs/superpowers/plans/`, set the same `archived-with` metadata in YAML frontmatter.
105
-
106
- ### 4. Archive Directory
107
-
108
- Change moves to archive directory:
109
-
110
- ```
111
- openspec/changes/archive/YYYY-MM-DD-<name>/
112
- ├── .openspec.yaml
113
- ├── .comet.yaml
114
- ├── proposal.md
115
- ├── design.md
116
- ├── specs/<capability>/spec.md
117
- └── tasks.md
118
- ```
119
-
120
- ### 5. Lifecycle Closed Loop
62
+ ### 2. Lifecycle Closed Loop
121
63
 
122
64
  Spec lifecycle completes here:
123
65
  ```
124
- brainstorming → delta spec → implementation (incremental modifications) → verification → main spec sync → design doc annotation → archive
66
+ brainstorming → delta spec → implementation → verification → main spec overwrite → design doc annotation → archive
125
67
  ```
126
68
 
127
69
  ## Exit Conditions
128
70
 
129
- - Change archived (removed from active list)
130
- - Main specs updated (delta → main sync complete)
131
- - Associated design doc annotated with archive status
132
- - Associated plan annotated with archive status
133
- - `.comet.yaml` `archived` recorded as `true`
71
+ - Archive script executed successfully (exit code 0)
134
72
  - **Phase guard**: Run `bash $COMET_GUARD <change-name> archive`, confirm archive complete after all PASS
135
73
 
136
- After archiving completes, update `.comet.yaml` in archive directory:
137
-
138
- ```yaml
139
- phase: archive
140
- archived: true
141
- ```
142
-
143
- 【Write verification】After update completion, must verify:
144
- cat openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
145
- Confirm phase line value is "archive"
146
- Confirm archived line value is "true"
147
- If any field does not match, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
148
-
149
74
  ## Complete
150
75
 
151
76
  Comet workflow complete. To start new work, invoke `/comet` or `/comet-open`.
@@ -56,19 +56,40 @@ design-doc: docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md
56
56
 
57
57
  ### 2. Update Plan Status
58
58
 
59
- Merge and update the following fields in `openspec/changes/<name>/.comet.yaml` (keep other fields unchanged):
59
+ Record plan path:
60
60
 
61
- ```yaml
62
- phase: build
63
- plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
61
+ ```bash
62
+ sed -i 's|^plan:.*|plan: docs/superpowers/plans/YYYY-MM-DD-feature.md|' openspec/changes/<name>/.comet.yaml
64
63
  ```
65
64
 
66
- 【Write verification】After update completion, must verify:
67
- cat openspec/changes/<name>/.comet.yaml
68
- Confirm plan line value is "docs/superpowers/plans/YYYY-MM-DD-feature.md"
69
- If not matching, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
65
+ No manual phase update needed guard auto-transitions when exit conditions are met.
66
+
67
+ ### 3. Workspace Isolation
68
+
69
+ Plan has been written to the current branch. Before starting execution, choose workspace isolation method:
70
+
71
+ | Option | Method | Description |
72
+ |--------|--------|-------------|
73
+ | A | Create branch | Create a new branch in the current repo, simple and fast |
74
+ | B | Create Worktree | Isolated workspace, fully independent, suitable for parallel development |
75
+
76
+ **Recommendation rules**:
77
+ - Change involves ≤ 3 files → Recommend A
78
+ - Need parallel development, current branch has uncommitted work → Recommend B
79
+
80
+ After user selection, update `isolation` in `openspec/changes/<name>/.comet.yaml`. `isolation` only allows one of the following values:
81
+
82
+ - `branch`
83
+ - `worktree`
84
+
85
+ **Execute isolation**:
86
+
87
+ - **branch**: Run `git checkout -b <change-name>`, subsequent work on the new branch
88
+ - **worktree**: Invoke `superpowers:using-git-worktrees` skill or use native `EnterWorktree` tool to create isolated workspace
70
89
 
71
- ### 3. Select Execution Method
90
+ After creating isolation, confirm plan file is accessible (naturally accessible with branch method; for worktree method, confirm plan has been committed).
91
+
92
+ ### 4. Select Execution Method
72
93
 
73
94
  Present plan summary to user (task count, involved modules), then ask for execution method:
74
95
 
@@ -82,29 +103,12 @@ Present plan summary to user (task count, involved modules), then ask for execut
82
103
  - Task count ≤ 2 and no cross-module dependencies → Recommend B
83
104
  - From hotfix path → Recommend B
84
105
 
85
- After user selection, merge and update `build_mode` in `openspec/changes/<name>/.comet.yaml` (keep other fields unchanged). `build_mode` only allows one of the following values:
106
+ After user selection, update `build_mode` in `openspec/changes/<name>/.comet.yaml`. `build_mode` only allows one of the following values:
86
107
 
87
108
  - `subagent-driven-development`
88
109
  - `executing-plans`
89
110
  - `direct` (only for hotfix preset use)
90
111
 
91
- Few-shot examples:
92
-
93
- ```yaml
94
- # User selects robust mode / A
95
- build_mode: subagent-driven-development
96
- ```
97
-
98
- ```yaml
99
- # User selects fast mode / B
100
- build_mode: executing-plans
101
- ```
102
-
103
- 【Write verification】After update completion, must verify:
104
- cat openspec/changes/<name>/.comet.yaml
105
- Confirm build_mode line value is "<subagent-driven-development or executing-plans or direct>"
106
- If not matching, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
107
-
108
112
  Then, **immediately execute:** Use the Skill tool to load the corresponding skill. Skipping this step is prohibited.
109
113
 
110
114
  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.
@@ -114,7 +118,7 @@ After the skill loads, follow its guidance to execute:
114
118
  - Complete tasks.md check (`- [ ]` → `- [x]`)
115
119
  - Commit code after each task completion
116
120
 
117
- ### 4. Spec Incremental Updates
121
+ ### 5. Spec Incremental Updates
118
122
 
119
123
  When the initial spec is found incomplete during implementation, handle by scale:
120
124
 
@@ -141,18 +145,13 @@ When the initial spec is found incomplete during implementation, handle by scale
141
145
  - `.comet.yaml` `phase` updated to `verify`
142
146
  - **Phase guard**: Run `bash $COMET_GUARD <change-name> build`, allow transition only after all PASS
143
147
 
144
- Before exit, merge and update the following fields in `.comet.yaml` (keep other fields unchanged):
148
+ Before exit, run guard to auto-transition:
145
149
 
146
- ```yaml
147
- phase: verify
148
- verify_result: pending
150
+ ```bash
151
+ bash $COMET_GUARD <change-name> build --apply
149
152
  ```
150
153
 
151
- 【Write verification】After update completion, must verify:
152
- cat openspec/changes/<name>/.comet.yaml
153
- Confirm phase line value is "verify"
154
- Confirm verify_result line value is "pending"
155
- If any field does not match, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
154
+ State file is automatically updated to `phase: verify`, `verify_result: pending`.
156
155
 
157
156
  ## Automatic Transition
158
157
 
@@ -66,18 +66,17 @@ After the skill loads, follow its guidance to produce:
66
66
 
67
67
  ### 2. Update Comet State
68
68
 
69
- Merge and update the following fields in `openspec/changes/<name>/.comet.yaml` (keep other fields unchanged):
69
+ Record design_doc path, then run guard to auto-transition:
70
70
 
71
- ```yaml
72
- phase: build
73
- design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
71
+ ```bash
72
+ # Record design_doc path
73
+ sed -i 's|^design_doc:.*|design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md|' openspec/changes/<name>/.comet.yaml
74
+
75
+ # Auto-transition to next phase
76
+ bash $COMET_GUARD <change-name> design --apply
74
77
  ```
75
78
 
76
- 【Write verification】After update completion, must verify:
77
- cat openspec/changes/<name>/.comet.yaml
78
- Confirm phase line value is "build"
79
- Confirm design_doc line value is "docs/superpowers/specs/YYYY-MM-DD-topic-design.md"
80
- If any field does not match, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
79
+ State file is updated automatically. No manual editing of other fields required.
81
80
 
82
81
  ### 3. Dual Spec Division of Labor
83
82
 
@@ -64,6 +64,7 @@ phase: build
64
64
  design_doc: null
65
65
  plan: null
66
66
  build_mode: direct
67
+ isolation: branch
67
68
  verify_mode: light
68
69
  verify_result: pending
69
70
  verified_at: null
@@ -77,6 +78,7 @@ archived: false
77
78
  Confirm design_doc line value is "null"
78
79
  Confirm plan line value is "null"
79
80
  Confirm build_mode line value is "direct"
81
+ Confirm isolation line value is "branch"
80
82
  Confirm verify_mode line value is "light"
81
83
  Confirm verify_result line value is "pending"
82
84
  Confirm verified_at line value is "null"
@@ -57,24 +57,6 @@ openspec/changes/<name>/
57
57
  └── tasks.md # Task checklist (checkboxes)
58
58
  ```
59
59
 
60
- ### 2b. Incrementally Modify Existing Capability (Optional)
61
-
62
- **Trigger condition:** proposal.md mentions modifying an existing capability, or user explicitly requests incremental modification.
63
-
64
- **Applicable scenario:** Incremental modification to archived functionality (not a brand-new capability).
65
-
66
- When proposal.md goals involve modifying an existing capability:
67
- 1. Check if `openspec/specs/<capability>/spec.md` main spec already exists
68
- 2. If it exists, copy the main spec as a delta spec baseline:
69
-
70
- ```bash
71
- mkdir -p openspec/changes/<name>/specs/<capability>/
72
- cp openspec/specs/<capability>/spec.md openspec/changes/<name>/specs/<capability>/spec.md
73
- ```
74
-
75
- 3. In the copied delta spec, organize changes in delta format (`## ADDED`, `## MODIFIED`, `## REMOVED`)
76
- 4. Note in proposal.md: `based on existing capability: <capability-name>`
77
-
78
60
  ### 3. Initialize Comet State
79
61
 
80
62
  Create an independent `.comet.yaml` file under `openspec/changes/<name>/`:
@@ -91,19 +73,6 @@ verified_at: null
91
73
  archived: false
92
74
  ```
93
75
 
94
- 【Write verification】After creation, must verify:
95
- cat openspec/changes/<name>/.comet.yaml
96
- Confirm workflow line value is "full"
97
- Confirm phase line value is "design"
98
- Confirm design_doc line value is "null"
99
- Confirm plan line value is "null"
100
- Confirm build_mode line value is "null"
101
- Confirm verify_mode line value is "null"
102
- Confirm verify_result line value is "pending"
103
- Confirm verified_at line value is "null"
104
- Confirm archived line value is "false"
105
- If any field does not match, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
106
-
107
76
  ### 4. Content Completeness Check
108
77
 
109
78
  Confirm the three documents have complete content:
@@ -65,6 +65,7 @@ phase: build
65
65
  design_doc: null
66
66
  plan: null
67
67
  build_mode: direct
68
+ isolation: branch
68
69
  verify_mode: light
69
70
  verify_result: pending
70
71
  verified_at: null
@@ -78,6 +79,7 @@ archived: false
78
79
  Confirm design_doc line value is "null"
79
80
  Confirm plan line value is "null"
80
81
  Confirm build_mode line value is "direct"
82
+ Confirm isolation line value is "branch"
81
83
  Confirm verify_mode line value is "light"
82
84
  Confirm verify_result line value is "pending"
83
85
  Confirm verified_at line value is "null"
@@ -53,27 +53,6 @@ After determination, record actual verification mode in `openspec/changes/<name>
53
53
  - `light`
54
54
  - `full`
55
55
 
56
- Few-shot examples:
57
-
58
- ```yaml
59
- # All metrics hit "small"
60
- phase: verify
61
- verify_mode: light
62
- verify_result: pending
63
- ```
64
-
65
- ```yaml
66
- # Any metric hits "large"
67
- phase: verify
68
- verify_mode: full
69
- verify_result: pending
70
- ```
71
-
72
- 【Write verification】After update completion, must verify:
73
- cat openspec/changes/<name>/.comet.yaml
74
- Confirm verify_mode line value is "<light or full>"
75
- If not matching, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
76
-
77
56
  ### 2a. Lightweight Verification (Small Changes)
78
57
 
79
58
  When scale assessment result is "small", skip `openspec-verify-change`, directly execute the following checks:
@@ -142,20 +121,13 @@ After the skill loads, follow its guidance to complete. Branch handling options:
142
121
  - `.comet.yaml` `verify_result` recorded as `pass`
143
122
  - **Phase guard**: Run `bash $COMET_GUARD <change-name> verify`, allow transition only after all PASS
144
123
 
145
- Before exit, merge and update the following fields in `.comet.yaml` (keep other fields unchanged):
124
+ Before exit, run guard to auto-transition:
146
125
 
147
- ```yaml
148
- phase: archive
149
- verify_result: pass
150
- verified_at: YYYY-MM-DD
126
+ ```bash
127
+ bash $COMET_GUARD <change-name> verify --apply
151
128
  ```
152
129
 
153
- 【Write verification】After update completion, must verify:
154
- cat openspec/changes/<name>/.comet.yaml
155
- Confirm phase line value is "archive"
156
- Confirm verify_result line value is "pass"
157
- Confirm verified_at line value is non-empty (format YYYY-MM-DD)
158
- If any field does not match, retry write then verify again. Maximum 2 retries, report error and terminate if still fails.
130
+ State file is automatically updated to `phase: archive`, `verify_result: pass`, `verified_at: YYYY-MM-DD`.
159
131
 
160
132
  ## Automatic Transition
161
133
 
@@ -75,6 +75,7 @@ phase: build
75
75
  design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
76
76
  plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
77
77
  build_mode: subagent-driven-development
78
+ isolation: branch
78
79
  verify_mode: light
79
80
  verify_result: pending
80
81
  verified_at: null
@@ -90,6 +91,7 @@ archived: false
90
91
  | `design_doc` | 关联的 Superpowers Design Doc 路径,可为空 |
91
92
  | `plan` | 关联的 Superpowers Plan 路径,可为空 |
92
93
  | `build_mode` | 已选择的执行方式,可为空 |
94
+ | `isolation` | `branch` 或 `worktree`,工作区隔离方式,默认 `branch` |
93
95
  | `verify_mode` | `light` 或 `full`,可为空 |
94
96
  | `verify_result` | `pending`、`pass` 或 `fail` |
95
97
  | `verified_at` | 验证通过时间,可为空 |
@@ -159,7 +161,7 @@ archived: false
159
161
 
160
162
  ### 脚本定位
161
163
 
162
- Comet 阶段守卫脚本 `comet-guard.sh` 随 skill 包分发,位于 `comet/scripts/` 目录。
164
+ Comet 阶段守卫脚本 `comet-guard.sh` 和归档脚本 `comet-archive.sh` 随 skill 包分发,位于 `comet/scripts/` 目录。
163
165
  **不硬编码平台路径**,运行时通过以下命令自定位:
164
166
 
165
167
  ```bash
@@ -167,6 +169,19 @@ COMET_GUARD=$(find . -path '*/comet/scripts/comet-guard.sh' -type f -print -quit
167
169
  bash "$COMET_GUARD" <change-name> <phase>
168
170
  ```
169
171
 
172
+ **自动状态更新**:guard 支持 `--apply` 参数,验证通过后自动更新 `.comet.yaml` 状态字段:
173
+
174
+ ```bash
175
+ bash "$COMET_GUARD" <change-name> <phase> --apply
176
+ ```
177
+
178
+ **归档脚本**:一键完成归档全部步骤:
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
+
170
185
  后续文档中 `bash $COMET_GUARD <change> <phase>` 均指此命令。加载 comet 后,agent 应在 shell 环境中缓存 `COMET_GUARD` 路径,避免重复 `find`。
171
186
 
172
187
  ### 文件结构
@@ -183,7 +198,7 @@ openspec/ # OpenSpec — WHAT
183
198
  │ │ ├── specs/<capability>/spec.md # Delta 能力规格
184
199
  │ │ └── tasks.md # 任务清单
185
200
  │ └── archive/YYYY-MM-DD-<name>/ # 已归档
186
- └── specs/<capability>/spec.md # 主 specs(归档时从 delta 同步)
201
+ └── specs/<capability>/spec.md # 主 specs(归档时从 delta 覆盖)
187
202
 
188
203
  docs/superpowers/ # Superpowers — HOW
189
204
  ├── specs/YYYY-MM-DD-<topic>-design.md # 设计文档(技术 RFC,归档时标注状态)
@@ -200,5 +215,5 @@ docs/superpowers/ # Superpowers — HOW
200
215
  6. **增量更新分级** — 小编辑、中重 brainstorming、大新 change
201
216
  7. **Plan 必须关联 change** — 文件头包含 `change:` 和 `design-doc:` 元数据
202
217
  8. **归档闭环** — design doc 和 plan 必须标注 `archived-with` 状态
203
- 9. **增量修改已有功能** — 基于 main spec 创建 delta spec 基线,不从零编写
218
+ 9. **增量修改已有功能** — 直接 open change,brainstorming 会读取已有 main spec 作为上下文
204
219
  10. **Preset 有上限** — hotfix/tweak 满足升级条件时及时切换到完整流程
@@ -39,113 +39,38 @@ description: "Comet 阶段 5:归档。用 /comet-archive 调用。同步 delta
39
39
 
40
40
  ### 1. 执行归档
41
41
 
42
- 归档前如 `verify_result` 不是 `pass`,停止归档并返回 `/comet-verify`。
43
-
44
- **立即执行:** 使用 Skill 工具加载 `openspec-archive-change` 技能。禁止跳过此步骤。
45
-
46
- 技能加载后,按其指引归档。自动检查:
47
- 1. artifact 完成状态(proposal、design、specs、tasks)
48
- 2. 所有任务已标记 `[x]`
49
- 3. delta specs 同步状态
50
-
51
- ### 1b. 移动 Comet 状态文件
52
-
53
- `openspec-archive-change` 不感知 `.comet.yaml`,因此 Comet 需要在 OpenSpec 归档完成后自行移动该文件:
42
+ 运行归档脚本,自动完成以下全部步骤:
54
43
 
55
44
  ```bash
56
- mv openspec/changes/<name>/.comet.yaml openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
57
- ```
58
-
59
- 【写入验证】移动完成后必须验证:
60
- test -f openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
61
- 确认归档目录中 .comet.yaml 存在
62
- 如文件不在预期位置,检查 mv 命令是否成功执行。
63
-
64
- ### 2. Delta Spec 同步
65
-
66
- 归档时将 delta specs 同步到主 specs:
67
-
68
- ```
69
- openspec/changes/<name>/specs/<capability>/spec.md
70
- ↓ 同步
71
- openspec/specs/<capability>/spec.md ← 主 spec(持久化)
45
+ COMET_ARCHIVE=$(find . -path '*/comet/scripts/comet-archive.sh' -type f -print -quit)
46
+ bash "$COMET_ARCHIVE" "<change-name>"
72
47
  ```
73
48
 
74
- ### 3. Design Doc & Plan 处理
75
-
76
- 归档时同步处理 `docs/superpowers/` 下的关联文件。若目标文件已有 YAML frontmatter,将归档字段合并到现有 frontmatter;若没有 frontmatter,才新建一组 frontmatter。
77
-
78
- **3a. Design Doc 一致性标注**
49
+ 脚本自动执行:
50
+ 1. 入口状态验证(phase=archive, verify_result=pass, archived=false)
51
+ 2. Delta spec 同步到主 spec
52
+ 3. Design doc 前置元数据标注(archived-with, status)
53
+ 4. Plan 前置元数据标注(archived-with)
54
+ 5. 移动 change 到归档目录
55
+ 6. 更新 archived: true
79
56
 
80
- 查找 `docs/superpowers/specs/` 中与当前 change 关联的设计文档:
81
- - 对比 delta spec 最终版与 design doc 内容
82
- - 如有偏差(实施过程中 spec 发生了增量修改),在 design doc 的 YAML frontmatter 中设置以下元数据:
57
+ 如脚本返回非零退出码,报告错误并停止。
58
+ 如脚本返回零退出码,归档完成。
83
59
 
84
- ```yaml
85
- ---
86
- archived-with: YYYY-MM-DD-<name>
87
- status: superseded-by-main-spec
88
- implementation-notes: |
89
- <简述实施过程中偏离原设计的关键变化>
90
- ---
91
- ```
60
+ 如需预览而不实际执行,使用 `--dry-run` 参数。
92
61
 
93
- - 如完全一致,仅设置:
94
-
95
- ```yaml
96
- ---
97
- archived-with: YYYY-MM-DD-<name>
98
- status: final
99
- ---
100
- ```
101
-
102
- **3b. Plan 关联标注**
103
-
104
- 查找 `docs/superpowers/plans/` 中与当前 change 关联的实施计划,在 YAML frontmatter 中设置相同的 `archived-with` 元数据。
105
-
106
- ### 4. 归档目录
107
-
108
- change 移入归档目录:
109
-
110
- ```
111
- openspec/changes/archive/YYYY-MM-DD-<name>/
112
- ├── .openspec.yaml
113
- ├── .comet.yaml
114
- ├── proposal.md
115
- ├── design.md
116
- ├── specs/<capability>/spec.md
117
- └── tasks.md
118
- ```
119
-
120
- ### 5. 生命周期闭环
62
+ ### 2. 生命周期闭环
121
63
 
122
64
  Spec 生命周期在此完成:
123
65
  ```
124
- brainstorming → delta spec → 实施(增量修改)→ 验证 → 主 spec 同步 → design doc 标注 → 归档
66
+ brainstorming → delta spec → 实施 验证 → 主 spec 覆盖 → design doc 标注 → 归档
125
67
  ```
126
68
 
127
69
  ## 退出条件
128
70
 
129
- - change 已归档(从活跃列表移除)
130
- - 主 specs 已更新(delta → main 同步完成)
131
- - 关联 design doc 已标注归档状态
132
- - 关联 plan 已标注归档状态
133
- - `.comet.yaml` 中 `archived` 已记录为 `true`
71
+ - 归档脚本执行成功(退出码 0)
134
72
  - **阶段守卫**:运行 `bash $COMET_GUARD <change-name> archive`,全部 PASS 后确认归档完整
135
73
 
136
- 归档完成后,在归档目录的 `.comet.yaml` 中更新:
137
-
138
- ```yaml
139
- phase: archive
140
- archived: true
141
- ```
142
-
143
- 【写入验证】更新完成后必须验证:
144
- cat openspec/changes/archive/YYYY-MM-DD-<name>/.comet.yaml
145
- 确认 phase 行的值为 "archive"
146
- 确认 archived 行的值为 "true"
147
- 如任一字段不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
148
-
149
74
  ## 完成
150
75
 
151
76
  Comet 流程全部完成。如需开始新工作,调用 `/comet` 或 `/comet-open`。
@@ -56,19 +56,40 @@ design-doc: docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md
56
56
 
57
57
  ### 2. 更新计划状态
58
58
 
59
- `openspec/changes/<name>/.comet.yaml` 中合并更新以下字段(保留其他字段不变):
59
+ 先记录 plan 路径:
60
60
 
61
- ```yaml
62
- phase: build
63
- plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
61
+ ```bash
62
+ sed -i 's|^plan:.*|plan: docs/superpowers/plans/YYYY-MM-DD-feature.md|' openspec/changes/<name>/.comet.yaml
64
63
  ```
65
64
 
66
- 【写入验证】更新完成后必须验证:
67
- cat openspec/changes/<name>/.comet.yaml
68
- 确认 plan 行的值为 "docs/superpowers/plans/YYYY-MM-DD-feature.md"
69
- 如不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
65
+ 无需手动更新 phase,guard 会在退出条件满足后自动流转。
66
+
67
+ ### 3. 工作区隔离
68
+
69
+ 计划已写入当前分支。在开始执行前,选择工作区隔离方式:
70
+
71
+ | 选项 | 方式 | 说明 |
72
+ |------|------|------|
73
+ | A | 创建分支 | 在当前仓库创建新分支,简单快速 |
74
+ | B | 创建 Worktree | 隔离工作区,完全独立,适合并行开发 |
75
+
76
+ **推荐规则**:
77
+ - 变更涉及 ≤ 3 个文件 → 推荐 A
78
+ - 需要并行开发、当前分支有未提交工作 → 推荐 B
79
+
80
+ 用户选择后,在 `openspec/changes/<name>/.comet.yaml` 中更新 `isolation`。`isolation` 只允许以下值之一:
81
+
82
+ - `branch`
83
+ - `worktree`
84
+
85
+ **执行隔离**:
86
+
87
+ - **branch**:执行 `git checkout -b <change-name>`,后续工作在新分支上进行
88
+ - **worktree**:调用 `superpowers:using-git-worktrees` 技能或使用原生 `EnterWorktree` 工具创建隔离工作区
70
89
 
71
- ### 3. 选择执行方式
90
+ 创建隔离后,确认计划文件可访问(分支方式天然可访问;worktree 方式需确认计划已提交)。
91
+
92
+ ### 4. 选择执行方式
72
93
 
73
94
  向用户展示计划摘要(任务数、涉及模块),然后询问执行方式:
74
95
 
@@ -82,29 +103,12 @@ plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
82
103
  - 任务数 ≤ 2 且无跨模块依赖 → 推荐 B
83
104
  - 来自 hotfix 路径 → 推荐 B
84
105
 
85
- 用户选择后,在 `openspec/changes/<name>/.comet.yaml` 中合并更新 `build_mode`(保留其他字段不变)。`build_mode` 只允许以下值之一:
106
+ 用户选择后,在 `openspec/changes/<name>/.comet.yaml` 中更新 `build_mode`。`build_mode` 只允许以下值之一:
86
107
 
87
108
  - `subagent-driven-development`
88
109
  - `executing-plans`
89
110
  - `direct`(仅 hotfix preset 使用)
90
111
 
91
- Few-shot 示例:
92
-
93
- ```yaml
94
- # 用户选择稳健模式 / A
95
- build_mode: subagent-driven-development
96
- ```
97
-
98
- ```yaml
99
- # 用户选择快速模式 / B
100
- build_mode: executing-plans
101
- ```
102
-
103
- 【写入验证】更新完成后必须验证:
104
- cat openspec/changes/<name>/.comet.yaml
105
- 确认 build_mode 行的值为 "<subagent-driven-development 或 executing-plans 或 direct>"
106
- 如不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
107
-
108
112
  然后,**立即执行:** 使用 Skill 工具加载对应技能。禁止跳过此步骤。
109
113
 
110
114
  如所选 Superpowers 技能不可用,停止流程并提示安装或启用对应技能,不要用普通对话替代该步骤。
@@ -114,7 +118,7 @@ build_mode: executing-plans
114
118
  - 完成 tasks.md 勾选(`- [ ]` → `- [x]`)
115
119
  - 每个任务完成后提交代码
116
120
 
117
- ### 4. Spec 增量更新
121
+ ### 5. Spec 增量更新
118
122
 
119
123
  实施过程中发现初版 spec 不完整时,按变更规模分级处理:
120
124
 
@@ -141,18 +145,13 @@ build_mode: executing-plans
141
145
  - `.comet.yaml` 中 `phase` 已更新为 `verify`
142
146
  - **阶段守卫**:运行 `bash $COMET_GUARD <change-name> build`,全部 PASS 后才允许流转
143
147
 
144
- 退出前在 `.comet.yaml` 中合并更新以下字段(保留其他字段不变):
148
+ 退出前运行 guard 自动流转:
145
149
 
146
- ```yaml
147
- phase: verify
148
- verify_result: pending
150
+ ```bash
151
+ bash $COMET_GUARD <change-name> build --apply
149
152
  ```
150
153
 
151
- 【写入验证】更新完成后必须验证:
152
- cat openspec/changes/<name>/.comet.yaml
153
- 确认 phase 行的值为 "verify"
154
- 确认 verify_result 行的值为 "pending"
155
- 如任一字段不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
154
+ 状态文件自动更新为 `phase: verify`、`verify_result: pending`。
156
155
 
157
156
  ## 自动流转
158
157
 
@@ -66,18 +66,17 @@ Design 摘要: <design.md 架构决策>
66
66
 
67
67
  ### 2. 更新 Comet 状态
68
68
 
69
- `openspec/changes/<name>/.comet.yaml` 中合并更新以下字段(保留其他字段不变):
69
+ 先记录 design_doc 路径,再运行 guard 自动流转:
70
70
 
71
- ```yaml
72
- phase: build
73
- design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
71
+ ```bash
72
+ # 记录 design_doc 路径
73
+ sed -i 's|^design_doc:.*|design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md|' openspec/changes/<name>/.comet.yaml
74
+
75
+ # 自动流转到下一阶段
76
+ bash $COMET_GUARD <change-name> design --apply
74
77
  ```
75
78
 
76
- 【写入验证】更新完成后必须验证:
77
- cat openspec/changes/<name>/.comet.yaml
78
- 确认 phase 行的值为 "build"
79
- 确认 design_doc 行的值为 "docs/superpowers/specs/YYYY-MM-DD-topic-design.md"
80
- 如任一字段不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
79
+ 状态文件自动更新,无需手动编辑其他字段。
81
80
 
82
81
  ### 3. 双 Spec 分工
83
82
 
@@ -64,6 +64,7 @@ phase: build
64
64
  design_doc: null
65
65
  plan: null
66
66
  build_mode: direct
67
+ isolation: branch
67
68
  verify_mode: light
68
69
  verify_result: pending
69
70
  verified_at: null
@@ -77,6 +78,7 @@ archived: false
77
78
  确认 design_doc 行的值为 "null"
78
79
  确认 plan 行的值为 "null"
79
80
  确认 build_mode 行的值为 "direct"
81
+ 确认 isolation 行的值为 "branch"
80
82
  确认 verify_mode 行的值为 "light"
81
83
  确认 verify_result 行的值为 "pending"
82
84
  确认 verified_at 行的值为 "null"
@@ -57,24 +57,6 @@ openspec/changes/<name>/
57
57
  └── tasks.md # 任务清单(勾选框)
58
58
  ```
59
59
 
60
- ### 2b. 增量修改已有 Capability(可选)
61
-
62
- **触发条件**:proposal.md 中提到修改已有 capability,或用户明确要求增量修改。
63
-
64
- **适用场景**:对已归档功能做增量修改(而非全新 capability)。
65
-
66
- 当 proposal.md 目标涉及修改已有 capability 时:
67
- 1. 查找 `openspec/specs/<capability>/spec.md` 是否已存在主 spec
68
- 2. 如已存在,将主 spec 复制为 delta spec 基线:
69
-
70
- ```bash
71
- mkdir -p openspec/changes/<name>/specs/<capability>/
72
- cp openspec/specs/<capability>/spec.md openspec/changes/<name>/specs/<capability>/spec.md
73
- ```
74
-
75
- 3. 在复制的 delta spec 中,按 delta 格式组织变更(`## ADDED`、`## MODIFIED`、`## REMOVED`)
76
- 4. 在 proposal.md 中注明 `基于已有 capability: <capability-name>`
77
-
78
60
  ### 3. 初始化 Comet 状态
79
61
 
80
62
  在 `openspec/changes/<name>/` 下创建独立的 `.comet.yaml` 文件:
@@ -91,19 +73,6 @@ verified_at: null
91
73
  archived: false
92
74
  ```
93
75
 
94
- 【写入验证】创建完成后必须验证:
95
- cat openspec/changes/<name>/.comet.yaml
96
- 确认 workflow 行的值为 "full"
97
- 确认 phase 行的值为 "design"
98
- 确认 design_doc 行的值为 "null"
99
- 确认 plan 行的值为 "null"
100
- 确认 build_mode 行的值为 "null"
101
- 确认 verify_mode 行的值为 "null"
102
- 确认 verify_result 行的值为 "pending"
103
- 确认 verified_at 行的值为 "null"
104
- 确认 archived 行的值为 "false"
105
- 如任一字段不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
106
-
107
76
  ### 4. 内容完整性检查
108
77
 
109
78
  确认三个文档内容完整:
@@ -65,6 +65,7 @@ phase: build
65
65
  design_doc: null
66
66
  plan: null
67
67
  build_mode: direct
68
+ isolation: branch
68
69
  verify_mode: light
69
70
  verify_result: pending
70
71
  verified_at: null
@@ -78,6 +79,7 @@ archived: false
78
79
  确认 design_doc 行的值为 "null"
79
80
  确认 plan 行的值为 "null"
80
81
  确认 build_mode 行的值为 "direct"
82
+ 确认 isolation 行的值为 "branch"
81
83
  确认 verify_mode 行的值为 "light"
82
84
  确认 verify_result 行的值为 "pending"
83
85
  确认 verified_at 行的值为 "null"
@@ -53,27 +53,6 @@ description: "Comet 阶段 4:验证与收尾。用 /comet-verify 调用。验
53
53
  - `light`
54
54
  - `full`
55
55
 
56
- Few-shot 示例:
57
-
58
- ```yaml
59
- # 全部指标命中“小”
60
- phase: verify
61
- verify_mode: light
62
- verify_result: pending
63
- ```
64
-
65
- ```yaml
66
- # 任一指标命中”大”
67
- phase: verify
68
- verify_mode: full
69
- verify_result: pending
70
- ```
71
-
72
- 【写入验证】更新完成后必须验证:
73
- cat openspec/changes/<name>/.comet.yaml
74
- 确认 verify_mode 行的值为 “<light 或 full>”
75
- 如不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
76
-
77
56
  ### 2a. 轻量验证(小改动)
78
57
 
79
58
  当规模评估结果为"小"时,跳过 `openspec-verify-change`,直接执行以下检查:
@@ -142,20 +121,13 @@ verify_result: pending
142
121
  - `.comet.yaml` 中 `verify_result` 已记录为 `pass`
143
122
  - **阶段守卫**:运行 `bash $COMET_GUARD <change-name> verify`,全部 PASS 后才允许流转
144
123
 
145
- 退出前在 `.comet.yaml` 中合并更新以下字段(保留其他字段不变):
124
+ 退出前运行 guard 自动流转:
146
125
 
147
- ```yaml
148
- phase: archive
149
- verify_result: pass
150
- verified_at: YYYY-MM-DD
126
+ ```bash
127
+ bash $COMET_GUARD <change-name> verify --apply
151
128
  ```
152
129
 
153
- 【写入验证】更新完成后必须验证:
154
- cat openspec/changes/<name>/.comet.yaml
155
- 确认 phase 行的值为 "archive"
156
- 确认 verify_result 行的值为 "pass"
157
- 确认 verified_at 行的值非空(格式为 YYYY-MM-DD)
158
- 如任一字段不匹配,重试写入后再次验证。最多重试 2 次,仍失败则报告错误并终止。
130
+ 状态文件自动更新为 `phase: archive`、`verify_result: pass`、`verified_at: YYYY-MM-DD`。
159
131
 
160
132
  ## 自动流转
161
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpamis/comet",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "OpenSpec + Superpowers dual-star development workflow",
5
5
  "keywords": [
6
6
  "comet",