@rpamis/comet 0.3.5 → 0.3.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.
Files changed (54) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +180 -56
  3. package/assets/manifest.json +11 -1
  4. package/assets/skills/comet/SKILL.md +59 -24
  5. package/assets/skills/comet/reference/dirty-worktree.md +1 -0
  6. package/assets/skills/comet/rules/comet-phase-guard.md +90 -0
  7. package/assets/skills/comet/scripts/comet-archive.sh +75 -57
  8. package/assets/skills/comet/scripts/comet-env.sh +57 -2
  9. package/assets/skills/comet/scripts/comet-guard.sh +187 -29
  10. package/assets/skills/comet/scripts/comet-handoff.sh +137 -8
  11. package/assets/skills/comet/scripts/comet-hook-guard.sh +260 -0
  12. package/assets/skills/comet/scripts/comet-state.sh +312 -25
  13. package/assets/skills/comet/scripts/comet-yaml-validate.sh +26 -1
  14. package/assets/skills/comet-archive/SKILL.md +45 -12
  15. package/assets/skills/comet-build/SKILL.md +159 -33
  16. package/assets/skills/comet-design/SKILL.md +129 -23
  17. package/assets/skills/comet-hotfix/SKILL.md +57 -15
  18. package/assets/skills/comet-open/SKILL.md +90 -17
  19. package/assets/skills/comet-tweak/SKILL.md +40 -15
  20. package/assets/skills/comet-verify/SKILL.md +64 -25
  21. package/assets/skills-zh/comet/SKILL.md +63 -25
  22. package/assets/skills-zh/comet/reference/dirty-worktree.md +2 -1
  23. package/assets/skills-zh/comet-archive/SKILL.md +46 -13
  24. package/assets/skills-zh/comet-build/SKILL.md +161 -35
  25. package/assets/skills-zh/comet-design/SKILL.md +132 -25
  26. package/assets/skills-zh/comet-hotfix/SKILL.md +53 -15
  27. package/assets/skills-zh/comet-open/SKILL.md +90 -17
  28. package/assets/skills-zh/comet-tweak/SKILL.md +36 -15
  29. package/assets/skills-zh/comet-verify/SKILL.md +64 -27
  30. package/bin/comet.js +3 -3
  31. package/dist/commands/doctor.d.ts.map +1 -1
  32. package/dist/commands/doctor.js +22 -0
  33. package/dist/commands/doctor.js.map +1 -1
  34. package/dist/commands/init.d.ts +5 -1
  35. package/dist/commands/init.d.ts.map +1 -1
  36. package/dist/commands/init.js +64 -9
  37. package/dist/commands/init.js.map +1 -1
  38. package/dist/commands/update.d.ts.map +1 -1
  39. package/dist/commands/update.js +60 -1
  40. package/dist/commands/update.js.map +1 -1
  41. package/dist/core/codegraph.d.ts +9 -0
  42. package/dist/core/codegraph.d.ts.map +1 -0
  43. package/dist/core/codegraph.js +96 -0
  44. package/dist/core/codegraph.js.map +1 -0
  45. package/dist/core/platforms.d.ts +10 -0
  46. package/dist/core/platforms.d.ts.map +1 -1
  47. package/dist/core/platforms.js +163 -15
  48. package/dist/core/platforms.js.map +1 -1
  49. package/dist/core/skills.d.ts +34 -1
  50. package/dist/core/skills.d.ts.map +1 -1
  51. package/dist/core/skills.js +360 -1
  52. package/dist/core/skills.js.map +1 -1
  53. package/package.json +3 -1
  54. package/scripts/postinstall.js +44 -44
@@ -13,7 +13,7 @@ Applicable for non-bug small scope changes, such as copy adjustment, configurati
13
13
  1. No new capability
14
14
  2. No architecture changes
15
15
  3. No interface changes
16
- 4. Typically no more than 3 tasks, 4 files
16
+ 4. Typically no more than 3 tasks (file count constraint see upgrade conditions below)
17
17
 
18
18
  **Not applicable**: If change process discovers need for capability, architecture or interface adjustments, should upgrade to full `/comet` workflow.
19
19
 
@@ -21,7 +21,11 @@ Applicable for non-bug small scope changes, such as copy adjustment, configurati
21
21
 
22
22
  ## Process (preset workflow, 4 phases)
23
23
 
24
- Execution chain: open → lightweight build → light verify → archive. Tweak provides default decisions for each phase: streamlined open, lightweight build, lightweight verification, archive after verification passes.
24
+ ### 0. Output Language Constraint
25
+
26
+ Streamlined OpenSpec artifacts must use the language of the user request that triggered this workflow.
27
+
28
+ Execution chain: open → lightweight build → light verify → archive. Tweak provides default decisions for each phase: streamlined open, lightweight build, lightweight verification, and final archive confirmation after verification passes.
25
29
 
26
30
  Locate Comet scripts before starting:
27
31
 
@@ -49,24 +53,24 @@ After the skill loads, follow its guidance to create streamlined artifacts:
49
53
  Initialize Comet state file:
50
54
 
51
55
  ```bash
52
- bash "$COMET_STATE" init <name> tweak
56
+ "$COMET_BASH" "$COMET_STATE" init <name> tweak
53
57
  ```
54
58
 
55
59
  Verify initialized state:
56
60
 
57
61
  ```bash
58
- bash "$COMET_STATE" check <name> open
62
+ "$COMET_BASH" "$COMET_STATE" check <name> open
59
63
  ```
60
64
 
61
65
  Run phase guard to transition open → build:
62
66
 
63
67
  ```bash
64
- bash "$COMET_GUARD" <change-name> open --apply
68
+ "$COMET_BASH" "$COMET_GUARD" <change-name> open --apply
65
69
  ```
66
70
 
67
71
  ### 2. Lightweight Build (preset build)
68
72
 
69
- Use tweak defaults: `build_mode: direct`. Skip `superpowers:brainstorming` and `superpowers:writing-plans`.
73
+ Use tweak defaults: `build_mode: direct`. Skip Superpowers `brainstorming` and `writing-plans`.
70
74
 
71
75
  Before continuing or starting changes, handle uncommitted changes through `comet/reference/dirty-worktree.md`. If attribution shows scope exceeds tweak, handle it through this file's "Upgrade Conditions".
72
76
 
@@ -83,7 +87,7 @@ Before continuing or starting changes, handle uncommitted changes through `comet
83
87
  4. Run phase guard to transition build → verify:
84
88
 
85
89
  ```bash
86
- bash "$COMET_GUARD" <change-name> build --apply
90
+ "$COMET_BASH" "$COMET_GUARD" <change-name> build --apply
87
91
  ```
88
92
 
89
93
  State automatically updates to `phase: verify`, `verify_result: pending`, then enter verification.
@@ -96,11 +100,11 @@ Reuse `/comet-verify`. Tweak must maintain lightweight verification conditions:
96
100
 
97
101
  If scale assessment enters full verification path, stop tweak, handle per upgrade conditions blocking confirmation.
98
102
 
99
- After verification passes, record `.comet.yaml` `verify_result` as `pass` according to `/comet-verify` rules, must not skip this status before archiving.
103
+ After verification passes, record `.comet.yaml` `verify_result` as `pass` according to `/comet-verify` rules, must not skip this status before archiving. After verification passes, still enter `/comet-archive`'s final archive confirmation; do not automatically run the archive script.
100
104
 
101
105
  ### 4. Archive (preset archive)
102
106
 
103
- Reuse `/comet-archive`. Must satisfy `verify_result: pass` in `.comet.yaml` before archiving.
107
+ Reuse `/comet-archive`. Must satisfy `verify_result: pass` in `.comet.yaml` before archiving, and wait for `/comet-archive`'s final archive confirmation.
104
108
 
105
109
  **Immediately execute:** Use the Skill tool to load the `comet-archive` skill to archive. Skipping this step is prohibited.
106
110
 
@@ -109,10 +113,15 @@ Reuse `/comet-archive`. Must satisfy `verify_result: pass` in `.comet.yaml` befo
109
113
  ## Continuous Execution Mode
110
114
 
111
115
  <IMPORTANT>
112
- Tweak workflow is **one-time continuous execution**. After invoking `/comet-tweak`, agent must automatically advance through tweak steps, without pausing to wait for user input mid-way. But the following situations must pause and wait for user confirmation:
116
+ Tweak workflow is **one-time continuous execution**. After invoking `/comet-tweak`, agent must automatically advance through tweak steps, without pausing to wait for user input mid-way.
117
+
118
+ Exception: when `.comet.yaml` has `auto_transition: false`, after each phase guard advances `phase`, do not auto-invoke the next skill. In this case, use `"$COMET_BASH" "$COMET_STATE" next <name>` output and pause for manual continuation as instructed.
113
119
 
114
- 1. Encountering upgrade conditions (see "Upgrade Conditions" section). **Must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm** upgrading to full workflow
120
+ The following situations must pause and wait for user confirmation:
121
+
122
+ 1. Encountering upgrade conditions (see "Upgrade Conditions" section). **Must use the current platform's available user input/confirmation mechanism to pause and wait for the user to explicitly confirm** upgrading to full workflow
115
123
  2. verify phase (comet-verify) verification-failure and branch-handling decisions
124
+ 3. Final archive confirmation (before comet-archive runs the archive script)
116
125
 
117
126
  Execution order: quick open → lightweight build → lightweight verification → archive → complete
118
127
 
@@ -134,12 +143,13 @@ Upgrade to full `/comet` when **any** of the following conditions are met:
134
143
  | New capability needed | Exceeds local optimization |
135
144
  | Delta spec needed | Affects existing specs |
136
145
 
137
- When upgrade conditions are met, **must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm** upgrading to the full `/comet` workflow. Do not directly enter `/comet-design`, and do not automatically supplement Design Doc. Must not just output a text prompt and then continue executing.
146
+ When upgrade conditions are met, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user to explicitly confirm** upgrading to the full `/comet` workflow. Do not directly enter `/comet-design`, and do not automatically supplement Design Doc. If the current platform has no structured question tool, ask an upgrade confirmation question in the conversation, stop the workflow, and wait for the user's reply before continuing.
138
147
 
139
- After user confirms upgrade, **must first update the workflow field** before entering full flow:
148
+ After user confirms upgrade, **must first update the workflow and phase fields** before entering full flow:
140
149
 
141
150
  ```bash
142
- bash "$COMET_STATE" set <name> workflow full
151
+ "$COMET_BASH" "$COMET_STATE" set <name> workflow full
152
+ "$COMET_BASH" "$COMET_STATE" set <name> phase design
143
153
  ```
144
154
 
145
155
  Then on current change basis, supplement Design Doc: **Immediately use the Skill tool to load the `comet-design` skill**, proceed normally with full workflow. If user does not confirm upgrade, stop tweak and report that current change has exceeded tweak scope.
@@ -151,4 +161,19 @@ Then on current change basis, supplement Design Doc: **Immediately use the Skill
151
161
  - Small change completed, tests pass
152
162
  - Change archived
153
163
  - No new capability, architecture adjustments or interface changes
154
- - **Phase guard**: Before build → verify run `bash "$COMET_GUARD" <change-name> build --apply`; before verify → archive follow `/comet-verify` and run `bash "$COMET_GUARD" <change-name> verify --apply`
164
+ - **Phase guard**: Before build → verify run `"$COMET_BASH" "$COMET_GUARD" <change-name> build --apply`; before verify → archive follow `/comet-verify` and run `"$COMET_BASH" "$COMET_GUARD" <change-name> verify --apply`
165
+
166
+ ## Automatic Handoff to Next Phase
167
+
168
+ > **Terminology distinction**: phase guard `--apply` advances the `.comet.yaml` `phase` field. This step **always happens** and is not controlled by `auto_transition`. This section's "automatic handoff" only controls whether to automatically invoke the next skill.
169
+
170
+ After each phase guard or state transition advances phase, run:
171
+
172
+ ```bash
173
+ "$COMET_BASH" "$COMET_STATE" next <name>
174
+ ```
175
+
176
+ The script determines the next action from `phase`, `workflow`, and `auto_transition`:
177
+ - `NEXT: auto` -> invoke the `SKILL` target to continue the tweak flow (`phase: build` returns `comet-tweak`, `verify` returns `comet-verify`, `archive` returns `comet-archive`)
178
+ - `NEXT: manual` -> do not invoke the next skill; follow `HINT` and ask the user to run `/<SKILL>` manually
179
+ - `NEXT: done` -> workflow is complete; no further action needed
@@ -12,7 +12,11 @@ description: "Comet Phase 4: Verify and Close. Invoke with /comet-verify. Verify
12
12
 
13
13
  ## Steps
14
14
 
15
- ### 0. Entry State Verification (Entry Check)
15
+ ### 0a. Output Language Constraint
16
+
17
+ Verification reports and branch-handling notes must use the language of the user request that triggered this workflow.
18
+
19
+ ### 0b. Entry State Verification (Entry Check)
16
20
 
17
21
  Execute entry verification:
18
22
 
@@ -23,7 +27,7 @@ if [ -z "$COMET_ENV" ]; then
23
27
  return 1
24
28
  fi
25
29
  . "$COMET_ENV"
26
- bash "$COMET_STATE" check <change-name> verify
30
+ "$COMET_BASH" "$COMET_STATE" check <change-name> verify
27
31
  ```
28
32
 
29
33
  Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
@@ -35,10 +39,10 @@ Proceed to Step 1 after verification passes. The script outputs specific failure
35
39
  Execute scale assessment:
36
40
 
37
41
  ```bash
38
- bash "$COMET_STATE" scale <change-name>
42
+ "$COMET_BASH" "$COMET_STATE" scale <change-name>
39
43
  ```
40
44
 
41
- The script automatically counts tasks, delta spec count, changed file count, determines light or full verification mode, and sets the verify_mode field.
45
+ The script automatically counts tasks, delta spec count, changed file count, determines light or full verification mode, and sets the verify_mode field. Decision rule (any condition triggers full): tasks > 3, delta spec capabilities > 1, changed files > 4.
42
46
 
43
47
  Before verification begins, handle uncommitted changes through `comet/reference/dirty-worktree.md` protocol. Verify phase special handling:
44
48
 
@@ -50,13 +54,15 @@ Only after user chooses fix, allow rollback to build phase:
50
54
 
51
55
  ```bash
52
56
  # Execute only after user confirms fix
53
- bash "$COMET_STATE" transition <change-name> verify-fail
57
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
54
58
  ```
55
59
 
60
+ Note: When verify-fail rolls back to build, `branch_status` is not reset. If branch handling was already completed during the first verify attempt, skip the branch handling step on re-verify and keep the existing `branch_status: handled`.
61
+
56
62
  Note: If every task in build phase was committed, the script's file count based on working tree diff may underestimate change scale. In this case, must read plan file header `base-ref` and verify with commit range:
57
63
 
58
64
  ```bash
59
- PLAN=$(bash "$COMET_STATE" get <change-name> plan)
65
+ PLAN=$("$COMET_BASH" "$COMET_STATE" get <change-name> plan)
60
66
  BASE_REF=$(grep '^base-ref:' "$PLAN" 2>/dev/null | head -1 | sed 's/^base-ref: *//')
61
67
  git diff --stat "$BASE_REF"...HEAD
62
68
  ```
@@ -64,12 +70,14 @@ git diff --stat "$BASE_REF"...HEAD
64
70
  If commit range shows changes exceed lightweight threshold (> 4 files, cross-module coordination, or delta spec spans more than 1 capability), manually set to full verification:
65
71
 
66
72
  ```bash
67
- bash "$COMET_STATE" set <change-name> verify_mode full
73
+ "$COMET_BASH" "$COMET_STATE" set <change-name> verify_mode full
68
74
  ```
69
75
 
76
+ **Override mechanism**: If the agent or user believes the automated assessment is inappropriate, override at any time with `"$COMET_BASH" "$COMET_STATE" set <change-name> verify_mode <light|full>`.
77
+
70
78
  ### 1b. Verification Failure Decision (Blocking Point)
71
79
 
72
- When verification does not pass, **must use the AskUserQuestion tool to pause and wait for the user to decide fix or accept deviation**. Must not automatically run `bash "$COMET_STATE" transition <change-name> verify-fail`, nor automatically invoke `/comet-build`. Must not just output a text prompt and then continue executing.
80
+ When verification does not pass, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user to decide whether to fix or accept the deviation**. Must not automatically run `"$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail`, nor automatically invoke `/comet-build`. If the current platform has no structured question tool, ask fix/accept-deviation options in the conversation, stop the workflow, and wait for the user's reply before continuing.
73
81
 
74
82
  When pausing, must list:
75
83
  - Failed items
@@ -79,12 +87,32 @@ When pausing, must list:
79
87
  **Uncertainty principle**: When severity is unclear, downgrade (SUGGESTION > WARNING > CRITICAL). Only use CRITICAL for build failures, test failures, and security issues; ambiguous or uncertain issues should be WARNING or SUGGESTION.
80
88
 
81
89
  After user selection, continue as follows:
82
- - **Fix all**: Run `bash "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build` to fix
90
+ - **Fix all**: Run `"$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build` to fix
83
91
  - **Handle item by item**: CRITICAL failures must be fixed; non-CRITICAL failures may choose to accept deviation, but must record acceptance reason and impact scope in verification report. If any CRITICAL failure exists, skipping fix to accept all is not allowed
84
92
 
93
+ **Retry limit**: After 3 consecutive verify-fail cycles, on the 4th failure the agent must not automatically choose to continue fixing; **must use the current platform's available user input/confirmation mechanism to pause** with only two options: "Accept all deviations and record" or "Continue fixing", for the user to explicitly decide.
94
+
95
+ ### 2. Artifact Context Loading (Hash On-Demand Read)
96
+
97
+ When verification needs to read OpenSpec artifacts, first check whether they have changed since the design phase:
98
+
99
+ ```bash
100
+ RECORDED_HASH=$("$COMET_BASH" "$COMET_STATE" get <change-name> handoff_hash)
101
+ CURRENT_HASH=$("$COMET_BASH" "$COMET_HANDOFF" <change-name> --hash-only 2>/dev/null || echo "")
102
+ ```
103
+
104
+ - If `RECORDED_HASH` = `CURRENT_HASH` and both are non-empty and neither is `null`: OpenSpec artifacts are unchanged. **tasks.md does not need to be re-read in full** (use `grep -c '\- \[ \]' tasks.md` to confirm completion count). proposal.md, design.md, and delta specs must still be read for comparison checks.
105
+ - If `RECORDED_HASH` is empty, is `null`, or differs from `CURRENT_HASH`: artifacts have changed or hash was never recorded. Read all required files in full normally.
106
+
107
+ This optimization only skips re-reading tasks.md in full. proposal.md and design.md contain the full context needed for verification checks and must not be skipped due to hash match.
108
+
109
+ **Immediately execute:** Use the Skill tool to load the Superpowers `verification-before-completion` skill. Skipping this step is prohibited.
110
+
111
+ After the skill loads, follow the `verify_mode` branch:
112
+
85
113
  ### 2a. Lightweight Verification (Small Changes)
86
114
 
87
- When scale assessment result is "small", skip `openspec-verify-change` and directly execute these checks:
115
+ Run these 5 checks:
88
116
 
89
117
  1. All tasks.md tasks completed `[x]`
90
118
  2. Changed files match tasks.md descriptions (`git diff --stat` / `git diff --cached --stat` / `git diff --stat <base-ref>...HEAD` compared against tasks content)
@@ -98,7 +126,7 @@ When scale assessment result is "small", skip `openspec-verify-change` and direc
98
126
 
99
127
  ```bash
100
128
  # Execute only after user confirms fix
101
- bash "$COMET_STATE" transition <change-name> verify-fail
129
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
102
130
  ```
103
131
 
104
132
  **Report format**: Brief table listing 5 check results + PASS/FAIL.
@@ -128,20 +156,20 @@ When verification does not pass: report missing items, enter Step 1b verificatio
128
156
 
129
157
  ```bash
130
158
  # Execute only after user confirms fix
131
- bash "$COMET_STATE" transition <change-name> verify-fail
159
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
132
160
  ```
133
161
 
134
162
  **Spec Drift Handling** (user decision point):
135
- - If check item 6 finds contradictions (delta spec has content but design doc does not reflect it), **must use the AskUserQuestion tool as a single-select question to pause and wait for user to choose handling method**; must not select automatically. Options:
163
+ - If check item 6 finds contradictions (delta spec has content but design doc does not reflect it), **must use the current platform's available user input/confirmation mechanism as a single-select question to pause and wait for the user to choose the handling method**; must not select automatically. Options:
136
164
  - Option A: Append "Implementation Divergence" section to design doc recording deviation reason. Option A is a verify phase allowed artifact; after writing, must not re-trigger Step 1b dirty-worktree decision due to that design doc change
137
- - Option B: After user selects B, run `bash "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build`; `/comet-build`'s Spec Incremental Update rules will load `superpowers:brainstorming` to update Design Doc + delta spec
165
+ - Option B: After user selects B, run `"$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build`; `/comet-build`'s Spec Incremental Update rules will load the Superpowers `brainstorming` skill to update Design Doc + delta spec
138
166
  - Option C: Confirm deviation is acceptable, continue verification (design doc will be marked as `superseded-by-main-spec` during archiving)
139
167
 
140
168
  ### 3. Finishing (Superpowers)
141
169
 
142
- **Immediately execute:** Use the Skill tool to load the `superpowers:finishing-a-development-branch` skill. Skipping this step is prohibited.
170
+ **Immediately execute:** Use the Skill tool to load the Superpowers `finishing-a-development-branch` skill. Skipping this step is prohibited.
143
171
 
144
- If `superpowers:finishing-a-development-branch` is unavailable, stop the process and prompt to install or enable Superpowers skills. Do not substitute this step with normal conversation.
172
+ If the Superpowers `finishing-a-development-branch` skill is unavailable, stop the process and prompt to install or enable Superpowers skills. Do not substitute this step with normal conversation.
145
173
 
146
174
  After the skill loads, follow its guidance to finish. Branch handling options:
147
175
  1. Merge to main branch locally
@@ -149,7 +177,7 @@ After the skill loads, follow its guidance to finish. Branch handling options:
149
177
  3. Keep branch (handle later)
150
178
  4. Discard work
151
179
 
152
- This is a user decision point. **Must use the AskUserQuestion tool to pause and wait for user to choose branch handling method**. Must not select based on recommendations, defaults, or current branch status. Must not just output a text prompt and then continue executing. Only after the user completes selection and the corresponding operation finishes, may `branch_status: handled` be written.
180
+ This is a user decision point. **Must use the current platform's available user input/confirmation mechanism to pause and wait for the user to choose branch handling method**. Must not select based on recommendations, defaults, or current branch status. If the current platform has no structured question tool, ask branch-handling options in the conversation, stop the workflow, and wait for the user's reply before continuing. Only after the user completes selection and the corresponding operation finishes, may `branch_status: handled` be written.
153
181
 
154
182
  **Confirmation items**:
155
183
  - All tests pass
@@ -164,8 +192,8 @@ mkdir -p docs/superpowers/reports
164
192
  # Write verification conclusions to report file, e.g.:
165
193
  # docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
166
194
 
167
- bash "$COMET_STATE" set <change-name> verification_report docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
168
- bash "$COMET_STATE" set <change-name> branch_status handled
195
+ "$COMET_BASH" "$COMET_STATE" set <change-name> verification_report docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
196
+ "$COMET_BASH" "$COMET_STATE" set <change-name> branch_status handled
169
197
  ```
170
198
 
171
199
  ## Exit Conditions
@@ -174,28 +202,39 @@ bash "$COMET_STATE" set <change-name> branch_status handled
174
202
  - Branch handled
175
203
  - `verification_report` in `.comet.yaml` points to an existing verification report file
176
204
  - `branch_status: handled` in `.comet.yaml`
177
- - **Phase guard**: Run `bash "$COMET_GUARD" <change-name> verify --apply`; after all PASS, auto-transitions to `phase: archive` through `comet-state transition verify-pass`
205
+ - **Phase guard**: Run `"$COMET_BASH" "$COMET_GUARD" <change-name> verify --apply`; after all PASS, auto-transitions to `phase: archive` through `comet-state transition verify-pass`
178
206
 
179
207
  After both verification and branch handling are complete, run guard for auto-transition:
180
208
 
181
209
  ```bash
182
- bash "$COMET_GUARD" <change-name> verify --apply
210
+ "$COMET_BASH" "$COMET_GUARD" <change-name> verify --apply
183
211
  ```
184
212
 
185
213
  State file auto-updates to `phase: archive`, `verify_result: pass`, `verified_at: YYYY-MM-DD`.
186
214
 
187
- ## Automatic Transition
215
+ ## Automatic Handoff to Next Phase
216
+
217
+ > **Terminology distinction**: the "phase advancement" above is performed by guard `--apply`, which updates the `.comet.yaml` `phase` field. This step **always happens** and is not controlled by `auto_transition`. This section's "automatic handoff" only controls whether to automatically invoke the next skill.
218
+
219
+ After verification and branch handling are complete, and guard-based phase advancement has completed, run:
220
+
221
+ ```bash
222
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
223
+ ```
188
224
 
189
- After exit conditions are met (including user selecting branch handling method), auto-transition to next phase:
225
+ The script determines the next action from `phase`, `workflow`, and `auto_transition`:
226
+ - `NEXT: auto` -> invoke the `SKILL` target to continue to the next phase
227
+ - `NEXT: manual` -> do not invoke the next skill; follow `HINT` and ask the user to run `/<SKILL>` manually
228
+ - `NEXT: done` -> workflow is complete; no further action needed
190
229
 
191
- > **REQUIRED NEXT SKILL:** Invoke `comet-archive` skill to enter the archive phase.
230
+ Note: after `comet-archive` starts, it must first execute the final archive confirmation blocking point and wait for the user to explicitly choose "Confirm archive" before running the archive script. Must not automatically archive just because verification passed.
192
231
 
193
232
  ## Context Compaction Recovery
194
233
 
195
234
  The verify phase may trigger context compaction. To recover, first run:
196
235
 
197
236
  ```bash
198
- bash "$COMET_STATE" check <change-name> verify --recover
237
+ "$COMET_BASH" "$COMET_STATE" check <change-name> verify --recover
199
238
  ```
200
239
 
201
240
  The script outputs structured recovery context (phase, verification status, branch status, recovery action). Follow the Recovery action to determine next step.
@@ -20,6 +20,10 @@ Superpowers 负责 HOW — 技术设计、计划、执行、收尾
20
20
 
21
21
  agent 做决策只需读本节,参考附录按需查阅。
22
22
 
23
+ ### 输出语言规则
24
+
25
+ 以触发本次工作流的用户请求语言作为默认输出语言。恢复已有 change 时,如果现有产物有明确主语言,除非用户明确要求切换,否则保持该语言。
26
+
23
27
  ### 阶段自动检测
24
28
 
25
29
  **Step 0: 活跃 Change 发现与意图判定**
@@ -53,15 +57,22 @@ agent 做决策只需读本节,参考附录按需查阅。
53
57
  **断点恢复规则**:
54
58
  - 每次恢复上下文时,先重新执行 Step 0 和 Step 1,不依赖对话历史判断阶段
55
59
  - 只要存在 active change 且工作区有未提交改动,必须按 `comet/reference/dirty-worktree.md` 协议处理。该协议定义了检查步骤、归因分类和禁令,本文件不重复
56
- - 若 `phase: build`,先检查 `build_mode` 和 `isolation` 是否已设置;若有未设置的字段,回到 `/comet-build` 对应步骤补充后再执行;若均已设置,读取 tasks.md 的下一个未勾选任务继续
57
- - 若 `phase: verify` `verify_result: fail`,进入验证失败决策阻塞点:暂停并询问用户修复或接受偏差;用户选择修复后才运行 `bash "$COMET_STATE" transition <name> verify-fail` 并调用 `/comet-build`
58
- - 若 `phase: open` proposal/design/tasks 已完整,先运行 `bash "$COMET_GUARD" <change-name> open --apply` 修正状态,再继续判定
59
- - 若 `phase: archive`,只允许调用 `/comet-archive`;归档成功后 change 会移动到 archive 目录,不再对原活跃目录运行 guard
60
+ - 若 `phase: build`,先检查 `build_pause`、`plan`、`build_mode` 和 `isolation`(详见下方):
61
+ - 若 `build_pause: plan-ready` `isolation` `build_mode` 已经设置,则视为 stale pause:先输出 `[COMET] 检测到 stale pause(build_pause=plan-ready 但 isolation/build_mode 已设置),自动清除并继续`,再运行 `"$COMET_BASH" "$COMET_STATE" set <name> build_pause null`,然后读取 tasks.md 的下一个未勾选任务并按 `build_mode` 恢复执行
62
+ - 若 `build_pause: plan-ready` plan 文件存在,但 `isolation` `build_mode` 尚未设置,回到 `/comet-build` 的 plan-ready 恢复点,提示用户继续选择隔离方式和执行方式,不重新生成 plan
63
+ - 若 `build_pause: plan-ready` 但 plan 文件缺失,回到 `/comet-build` 处理状态损坏或重新生成 plan
64
+ - 若 `build_mode`、`isolation` 或 `tdd_mode` 未设置,回到 `/comet-build` 对应步骤补充后再执行
65
+ - 若均已设置,读取 tasks.md 的下一个未勾选任务,并按 `build_mode` 恢复执行:
66
+ - 若 `build_mode: subagent-driven-development`,不得在主窗口直接执行任务;必须回到 `/comet-build` 的后台 subagent 调度规则,由主窗口只做协调
67
+ - 其他执行方式按 `/comet-build` 的对应规则继续
68
+ - 若 `phase: verify` 且 `verify_result: fail`,进入验证失败决策阻塞点:暂停并询问用户修复或接受偏差;用户选择修复后才运行 `"$COMET_BASH" "$COMET_STATE" transition <name> verify-fail` 并调用 `/comet-build`
69
+ - 若 `phase: open` 但 proposal/design/tasks 已完整,先运行 `"$COMET_BASH" "$COMET_GUARD" <change-name> open --apply` 修正状态,再继续判定
70
+ - 若 `phase: archive`,只允许调用 `/comet-archive`;`/comet-archive` 必须先等待归档前最终确认,归档成功后 change 会移动到 archive 目录,不再对原活跃目录运行 guard
60
71
 
61
72
  **Step 2: 阶段判定**(按顺序,命中即停)
62
73
 
63
74
  1. `archived: true` 或 change 已移入 archive → 流程已完成
64
- 2. `verify_result: pass` 且 `archived` 不是 `true` → `/comet-archive`
75
+ 2. `verify_result: pass` 且 `archived` 不是 `true` → `/comet-archive`(先进行归档前最终确认)
65
76
  3. `verify_result: fail` → 进入验证失败决策阻塞点(暂停询问修复或接受偏差;用户选择修复后才 `verify-fail` 并 `/comet-build`)
66
77
  4. `phase: verify` 或 tasks.md 全部勾选 → `/comet-verify`
67
78
  5. `phase: build` 或已有 Design Doc 但计划/执行未完成 → 优先按 workflow 路由:`hotfix` → `/comet-hotfix`,`tweak` → `/comet-tweak`,`full` → `/comet-build`
@@ -85,6 +96,8 @@ agent 做决策只需读本节,参考附录按需查阅。
85
96
  - 涉及多个模块的协调修改
86
97
  - 需要新增测试用例 **5+**
87
98
  - 涉及配置项的新增或删除(非值修改)
99
+ - 需要新增 capability
100
+ - 需要 delta spec(影响了已有规格)
88
101
 
89
102
  ### 错误处理速查
90
103
 
@@ -92,7 +105,7 @@ agent 做决策只需读本节,参考附录按需查阅。
92
105
  |------|---------|
93
106
  | `openspec list --json` 失败 | 检查 openspec 是否已安装,提示 `openspec init` |
94
107
  | 子 skill 不可用 | 停止流程,提示安装或启用对应 skill |
95
- | `.comet.yaml` 格式异常或缺失 | 以文件状态为准,用 `bash $COMET_STATE set` 修正后继续 |
108
+ | `.comet.yaml` 格式异常或缺失 | 以文件状态为准,用 `"$COMET_BASH" "$COMET_STATE" set` 修正后继续 |
96
109
  | 构建/测试失败 | 返回 build 阶段修复,不进入 verify |
97
110
  | change 目录结构不完整 | 按 `comet-open` 产物要求补齐 |
98
111
 
@@ -103,26 +116,30 @@ agent 做决策只需读本节,参考附录按需查阅。
103
116
 
104
117
  流转链:open → design → build → verify → archive
105
118
 
106
- **连续执行要求**:从检测到的阶段开始,agent 自动推进后续阶段。但**自动推进仅适用于没有用户决策的衔接点**。遇到用户决策点时,**必须使用 AskUserQuestion 工具暂停并等待用户明确回复**,不得用推荐规则、默认值或历史偏好代替用户确认,也不得仅输出文字提示后继续执行。
119
+ **连续执行要求**:从检测到的阶段开始,agent 自动推进后续阶段。但**自动推进仅适用于没有用户决策的衔接点**。遇到用户决策点时,**必须使用当前平台可用的用户输入/确认机制暂停并等待用户明确回复**,不得用推荐规则、默认值或历史偏好代替用户确认,也不得仅输出文字提示后继续执行。
120
+
121
+ **阶段推进与自动衔接的区分**:每个子 skill 退出前都会运行阶段守卫 `--apply` 推进 `.comet.yaml` 的 `phase` 字段——这一步**始终发生**,与 `auto_transition` 无关。之后子 skill 运行 `"$COMET_BASH" "$COMET_STATE" next <name>` 解析下一步:`auto_transition` 不为 `false` 时输出 `NEXT: auto`(自动调用下一 skill),为 `false` 时输出 `NEXT: manual`(不调用下一 skill,提示用户手动运行)。因此 `auto_transition` **只控制是否自动调用下一个 skill,不影响 phase 推进**。无论 `auto_transition` 取何值,下方的用户决策点都必须阻塞等待。
107
122
 
108
- **决策点是阻塞点**:只要到达下列任一节点,当前 `/comet` 调用必须停住,**使用 AskUserQuestion 工具等待用户选择**。用户明确选择后才能写入对应状态字段、执行对应操作,随后再继续自动流转。
123
+ **决策点是阻塞点**:只要到达下列任一节点,当前 `/comet` 调用必须停住,**使用当前平台可用的用户输入/确认机制等待用户选择**。若当前平台没有结构化提问工具,则必须在对话中提出明确选项并停止流程,等待用户回复后才能继续。用户明确选择后才能写入对应状态字段、执行对应操作,随后再继续自动流转。
109
124
 
110
125
  需要用户参与的节点(仅在这些节点暂停):
111
126
  1. open 阶段 proposal/design/tasks 审视确认
112
127
  2. brainstorming 确认设计方案
113
- 3. build 阶段选择工作方式(隔离方式 + 执行方式,一次交互完成)
128
+ 3. build 阶段 plan-ready 暂停选择,以及随后选择工作方式(隔离方式 + 执行方式)
114
129
  4. verify 不通过时决定修复或接受偏差(含 Spec 漂移处理方式选择)
115
130
  5. finishing-branch 选择分支处理方式
116
- 6. 遇到升级条件(hotfix/tweak → 完整流程)
117
- 7. build 阶段范围扩张需重新设计或拆分新 change
131
+ 6. archive 阶段执行归档脚本前的最终确认
132
+ 7. 遇到升级条件(hotfix/tweak 完整流程)
133
+ 8. build 阶段范围扩张需重新设计或拆分新 change
134
+ 9. open 阶段大型 PRD 需确认拆分为多个 change
118
135
 
119
- agent 不应跳过这些决策点;其他明确无歧义的阶段衔接必须自动继续推进,不得中途退出。到达决策点时,**禁止以文字输出代替工具等待——必须通过 AskUserQuestion 明确获取用户选择后才能继续**。
136
+ agent 不应跳过这些决策点;其他明确无歧义的阶段衔接必须自动继续推进,不得中途退出。到达决策点时,**禁止跳过用户确认或自动选择——必须通过当前平台可用的用户输入/确认机制明确获取用户选择后才能继续**。
120
137
 
121
138
  **红旗清单** — 以下想法出现时立即停止并检查:
122
139
 
123
140
  | Agent 心理 | 实际风险 |
124
141
  |-----------|---------|
125
- | "用户应该会同意这个方案" | 不能替用户决策,用 AskUserQuestion |
142
+ | "用户应该会同意这个方案" | 不能替用户决策,必须等待用户明确选择 |
126
143
  | "这只是个小改动,不需要确认" | 决策点无大小之分,阻塞点必须等待 |
127
144
  | "用户之前选过 A,这次也选 A" | 历史偏好不能替代当前确认 |
128
145
  | "我已经解释了方案,用户没反对" | 没反对 ≠ 同意,必须用工具获取明确选择 |
@@ -171,6 +188,9 @@ design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
171
188
  plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
172
189
  base_ref: a1b2c3d4e5f6...
173
190
  build_mode: subagent-driven-development
191
+ build_pause: null
192
+ subagent_dispatch: confirmed
193
+ tdd_mode: tdd
174
194
  isolation: branch
175
195
  verify_mode: light
176
196
  verify_result: pending
@@ -189,8 +209,12 @@ archived: false
189
209
  | `plan` | 关联的 Superpowers Plan 路径,可为空 |
190
210
  | `base_ref` | init 时记录的 git commit SHA,用于 scale 评估。无 plan 时作为改动文件数统计基准 |
191
211
  | `build_mode` | 已选择的执行方式,可为空 |
212
+ | `build_pause` | build 阶段内部暂停点。`null` 表示无暂停,`plan-ready` 表示 plan 已生成,用户选择切换模型后暂停 |
213
+ | `subagent_dispatch` | `null` 或 `confirmed`。仅当已确认当前平台存在真实后台 subagent / Task / multi-agent 调度能力时,`build_mode: subagent-driven-development` 才能写入并用于离开 build 阶段 |
214
+ | `tdd_mode` | `tdd` 或 `direct`。full workflow 离开 build 阶段前必须已选择。`tdd` 强制每个任务先写失败测试再实现;`direct` 不强制 TDD。hotfix/tweak 默认 `direct` |
192
215
  | `isolation` | `branch` 或 `worktree`,工作区隔离方式。full 初始化可为 `null`,但只允许持续到 `/comet-build` Step 3 前;hotfix/tweak 默认 `branch` |
193
216
  | `verify_mode` | `light` 或 `full`,可为空 |
217
+ | `auto_transition` | `true` 或 `false`。只控制阶段守卫推进 phase 后是否自动调用下一个 skill;`false` 时由 `comet-state next` 输出 `manual`,暂停下一 skill 调用,但不阻止 phase 字段更新 |
194
218
  | `verify_result` | `pending`、`pass` 或 `fail` |
195
219
  | `verification_report` | 验证报告文件路径,verify 通过前必须指向已存在文件 |
196
220
  | `branch_status` | `pending` 或 `handled`,分支处理完成后设为 `handled` |
@@ -209,12 +233,15 @@ archived: false
209
233
  状态机硬约束:
210
234
  - `build → verify` 前,`isolation` 必须是 `branch` 或 `worktree`
211
235
  - `build → verify` 前,`build_mode` 必须已选择
236
+ - `build_mode: subagent-driven-development` 必须同时有 `subagent_dispatch: confirmed`
237
+ - full workflow 离开 build 阶段前 `tdd_mode` 必须已选择为 `tdd` 或 `direct`
212
238
  - `build_mode: direct` 默认只允许 `hotfix` / `tweak`;full workflow 需要 `direct_override: true`
239
+ - `build_pause` 不是执行方式,不得写入 `build_mode`
213
240
  - 这些约束同时存在于 `comet-guard.sh build --apply` 和 `comet-state.sh transition <name> build-complete`
214
241
 
215
242
  ### 脚本定位
216
243
 
217
- Comet 脚本随 skill 包分发在 `comet/scripts/` 下。**不硬编码路径** — 定位一次,缓存到环境变量:
244
+ Comet 脚本随 skill 包分发在 `comet/scripts/` 下。**不硬编码路径** — 定位一次,缓存到环境变量。此块为标准样板,在每个子 skill 中独立重复以确保可独立加载;修改时必须保持所有文件同步(样板版本: `v2`,变更时更新此版本号便于定位需要同步的文件):
218
245
 
219
246
  ```bash
220
247
  COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
@@ -235,24 +262,32 @@ fi
235
262
  **自动状态更新**:guard 支持 `--apply` 参数,验证通过后自动更新 `.comet.yaml` 状态字段:
236
263
 
237
264
  ```bash
238
- bash "$COMET_GUARD" <change-name> <phase> --apply
265
+ "$COMET_BASH" "$COMET_GUARD" <change-name> <phase> --apply
239
266
  ```
240
267
 
241
268
  `--apply` 内部委托给 `comet-state transition`。需要直接表达状态事件时使用:
242
269
 
243
270
  ```bash
244
- bash "$COMET_STATE" transition <change-name> open-complete
245
- bash "$COMET_STATE" transition <change-name> design-complete
246
- bash "$COMET_STATE" transition <change-name> build-complete
247
- bash "$COMET_STATE" transition <change-name> verify-pass
248
- bash "$COMET_STATE" transition <change-name> verify-fail
249
- bash "$COMET_STATE" transition <archive-name> archived
271
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> open-complete
272
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> design-complete
273
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> build-complete
274
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-pass
275
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
276
+ "$COMET_BASH" "$COMET_STATE" transition <archive-name> archived
250
277
  ```
251
278
 
279
+ **解析下一步**:阶段守卫推进 phase 后,用 `next` 子命令解析是否自动调用下一个 skill:
280
+
281
+ ```bash
282
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
283
+ ```
284
+
285
+ 输出 `NEXT: auto|manual|done` + `SKILL: <skill-name>`(`done` 时省略)+ `HINT`(仅 `manual` 时)。`auto_transition: false` 时输出 `manual`,只暂停下一 skill 调用,不影响已发生的 phase 推进。
286
+
252
287
  **归档脚本**:一键完成归档全部步骤:
253
288
 
254
289
  ```bash
255
- bash "$COMET_ARCHIVE" <change-name>
290
+ "$COMET_BASH" "$COMET_ARCHIVE" <change-name>
256
291
  ```
257
292
 
258
293
  加载 comet 后,agent 应执行以上变量赋值一次,后续全程复用 `$COMET_GUARD`、`$COMET_STATE`、`$COMET_HANDOFF`、`$COMET_ARCHIVE`。
@@ -272,21 +307,24 @@ openspec/ # OpenSpec — WHAT
272
307
  │ │ ├── .comet/handoff/ # 脚本生成的阶段交接包
273
308
  │ │ └── tasks.md # 任务清单
274
309
  │ └── archive/YYYY-MM-DD-<name>/ # 已归档
275
- └── specs/<capability>/spec.md # 主 specs(归档时从 delta 覆盖)
310
+ └── specs/<capability>/spec.md # 主 specs(归档时按 OpenSpec delta 语义合并)
276
311
 
277
312
  docs/superpowers/ # Superpowers — HOW
278
313
  ├── specs/YYYY-MM-DD-<topic>-design.md # 设计文档(技术 RFC,归档时标注状态)
279
314
  └── plans/YYYY-MM-DD-<feature>.md # 实施计划(文件头含 change 关联元数据)
315
+
316
+ .comet/
317
+ └── config.yaml # Comet 项目配置(context_compression 默认 off,可设 beta)
280
318
  ```
281
319
 
282
320
  ### 最佳实践
283
321
 
284
322
  1. **brainstorming 不可跳过** — 每次变更必须经过深度设计(hotfix 和 tweak 除外)
285
323
  2. **delta spec 是活文档** — 阶段 3 期间可自由修改,归档时同步
286
- 3. **交接包由脚本生成** — OpenSpec → Superpowers 的上下文必须通过 `comet-handoff.sh` 生成 compact 可追溯摘录(必要时 `--full`),并由 guard 校验 source/hash/mode
324
+ 3. **交接包由脚本生成** — OpenSpec → Superpowers 的上下文必须通过 `comet-handoff.sh` 生成 compact 可追溯摘录(需要全文时用 `--full`),并由 guard 校验 source/hash/mode
287
325
  4. **保持 tasks.md 同步** — 完成一个勾一个
288
326
  5. **频繁提交** — 每个任务一次提交,message 体现设计意图
289
- 6. **先验证再归档** — `/comet-verify` 通过后才执行 `/comet-archive`
327
+ 6. **先验证再确认归档** — `/comet-verify` 通过后进入 `/comet-archive`,但运行归档脚本前必须等待用户最终确认
290
328
  7. **增量更新分级** — 小编辑、中重 brainstorming、大新 change
291
329
  8. **Plan 必须关联 change** — 文件头包含 `change:` 和 `design-doc:` 元数据
292
330
  9. **归档闭环** — design doc 和 plan 必须标注 `archived-with` 状态
@@ -2,7 +2,7 @@
2
2
 
3
3
  规范路径:`comet/reference/dirty-worktree.md`
4
4
 
5
- 本协议由所有涉及代码修改的 comet 子 skill 共享。当 agent 恢复上下文或继续执行时,必须按本协议处理未提交的工作区改动。
5
+ 本协议由所有涉及代码修改的 comet 子 skill 共享。当 agent 恢复上下文或继续执行时,必须按本协议处理未提交的工作区改动。各子 skill 可在本协议基础上定义阶段特例(如 verify 阶段对实现改动的特殊处理),详见对应子 skill 文件。本文件不重复阶段特例。
6
6
 
7
7
  ## 1. 检查步骤
8
8
 
@@ -20,6 +20,7 @@ git ls-files --others --exclude-standard
20
20
  ## 2. 核心规则
21
21
 
22
22
  - 用户可能不会说明自己改了哪里。只要存在 dirty worktree(包括 Git 状态里显示为 `??` 的新建文件),就先假设改动可能来自用户或混合来源
23
+ - **构建产物排除**:`??` 文件若匹配 `.gitignore` 中的模式(如 `node_modules/`、`dist/`、`__pycache__/`、`*.o`、`target/`、`build/` 等),自动跳过归因,不视为用户改动
23
24
  - dirty worktree 只代表代码事实,不会自动推进 `.comet.yaml` 的 `phase` 或勾选 `tasks.md`;只有完成归因、验证、同步必要文档,并通过对应阶段 guard 后,才允许推进 Comet 状态
24
25
 
25
26
  ## 3. 归因分类