@rpamis/comet 0.3.7 → 0.3.8

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 (86) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +559 -539
  3. package/assets/manifest.json +41 -34
  4. package/assets/skills/comet/SKILL.md +282 -329
  5. package/assets/skills/comet/reference/auto-transition.md +27 -0
  6. package/assets/skills/comet/reference/comet-yaml-fields.md +68 -0
  7. package/assets/skills/comet/reference/context-recovery.md +35 -0
  8. package/assets/skills/comet/reference/debug-gate.md +17 -0
  9. package/assets/skills/comet/reference/decision-point.md +20 -0
  10. package/assets/skills/comet/reference/file-structure.md +28 -0
  11. package/assets/skills/comet/reference/subagent-dispatch.md +113 -0
  12. package/assets/skills/comet/rules/comet-phase-guard.en.md +99 -0
  13. package/assets/skills/comet/rules/comet-phase-guard.md +99 -90
  14. package/assets/skills/comet/scripts/comet-state.sh +62 -0
  15. package/assets/skills/comet-archive/SKILL.md +100 -106
  16. package/assets/skills/comet-build/SKILL.md +304 -316
  17. package/assets/skills/comet-design/SKILL.md +263 -272
  18. package/assets/skills/comet-hotfix/SKILL.md +204 -211
  19. package/assets/skills/comet-open/SKILL.md +203 -186
  20. package/assets/skills/comet-tweak/SKILL.md +180 -179
  21. package/assets/skills/comet-verify/SKILL.md +234 -240
  22. package/assets/skills-zh/comet/SKILL.md +269 -332
  23. package/assets/skills-zh/comet/reference/auto-transition.md +27 -0
  24. package/assets/skills-zh/comet/reference/comet-yaml-fields.md +68 -0
  25. package/assets/skills-zh/comet/reference/context-recovery.md +35 -0
  26. package/assets/skills-zh/comet/reference/debug-gate.md +17 -0
  27. package/assets/skills-zh/comet/reference/decision-point.md +20 -0
  28. package/assets/skills-zh/comet/reference/file-structure.md +28 -0
  29. package/assets/skills-zh/comet/reference/subagent-dispatch.md +113 -0
  30. package/assets/skills-zh/comet-archive/SKILL.md +100 -106
  31. package/assets/skills-zh/comet-build/SKILL.md +304 -316
  32. package/assets/skills-zh/comet-design/SKILL.md +264 -273
  33. package/assets/skills-zh/comet-hotfix/SKILL.md +200 -207
  34. package/assets/skills-zh/comet-open/SKILL.md +203 -186
  35. package/assets/skills-zh/comet-tweak/SKILL.md +176 -175
  36. package/assets/skills-zh/comet-verify/SKILL.md +232 -238
  37. package/bin/comet.js +3 -3
  38. package/dist/cli/index.js +19 -0
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/commands/init.d.ts.map +1 -1
  41. package/dist/commands/init.js +8 -8
  42. package/dist/commands/init.js.map +1 -1
  43. package/dist/commands/uninstall.d.ts +9 -0
  44. package/dist/commands/uninstall.d.ts.map +1 -0
  45. package/dist/commands/uninstall.js +113 -0
  46. package/dist/commands/uninstall.js.map +1 -0
  47. package/dist/commands/update.d.ts +1 -1
  48. package/dist/commands/update.d.ts.map +1 -1
  49. package/dist/commands/update.js +65 -36
  50. package/dist/commands/update.js.map +1 -1
  51. package/dist/core/codegraph.d.ts +2 -7
  52. package/dist/core/codegraph.d.ts.map +1 -1
  53. package/dist/core/codegraph.js +4 -37
  54. package/dist/core/codegraph.js.map +1 -1
  55. package/dist/core/detect.d.ts +8 -1
  56. package/dist/core/detect.d.ts.map +1 -1
  57. package/dist/core/detect.js +41 -2
  58. package/dist/core/detect.js.map +1 -1
  59. package/dist/core/openspec.d.ts +1 -1
  60. package/dist/core/openspec.d.ts.map +1 -1
  61. package/dist/core/openspec.js +40 -17
  62. package/dist/core/openspec.js.map +1 -1
  63. package/dist/core/platforms.d.ts.map +1 -1
  64. package/dist/core/platforms.js +14 -1
  65. package/dist/core/platforms.js.map +1 -1
  66. package/dist/core/skills.d.ts +3 -1
  67. package/dist/core/skills.d.ts.map +1 -1
  68. package/dist/core/skills.js +142 -65
  69. package/dist/core/skills.js.map +1 -1
  70. package/dist/core/superpowers.d.ts.map +1 -1
  71. package/dist/core/superpowers.js +1 -0
  72. package/dist/core/superpowers.js.map +1 -1
  73. package/dist/core/uninstall.d.ts +28 -0
  74. package/dist/core/uninstall.d.ts.map +1 -0
  75. package/dist/core/uninstall.js +421 -0
  76. package/dist/core/uninstall.js.map +1 -0
  77. package/dist/core/version.d.ts +31 -0
  78. package/dist/core/version.d.ts.map +1 -0
  79. package/dist/core/version.js +111 -0
  80. package/dist/core/version.js.map +1 -0
  81. package/dist/utils/file-system.d.ts +23 -0
  82. package/dist/utils/file-system.d.ts.map +1 -1
  83. package/dist/utils/file-system.js +100 -5
  84. package/dist/utils/file-system.js.map +1 -1
  85. package/package.json +69 -64
  86. package/scripts/postinstall.js +44 -44
@@ -1,240 +1,234 @@
1
- ---
2
- name: comet-verify
3
- description: "Comet Phase 4: Verify and Close. Invoke with /comet-verify. Verify implementation matches design, handle development branch."
4
- ---
5
-
6
- # Comet Phase 4: Verify and Close (Verify)
7
-
8
- ## Prerequisites
9
-
10
- - Code committed (Phase 3 complete)
11
- - All tasks.md tasks completed
12
-
13
- ## Steps
14
-
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)
20
-
21
- Execute entry verification:
22
-
23
- ```bash
24
- COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
25
- if [ -z "$COMET_ENV" ]; then
26
- echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
27
- return 1
28
- fi
29
- . "$COMET_ENV"
30
- "$COMET_BASH" "$COMET_STATE" check <change-name> verify
31
- ```
32
-
33
- Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
34
-
35
- **Idempotency**: All verify phase checks can be safely re-executed. If `verify_result` is already `pass` and `branch_status` is `handled`, verification is complete — execute guard to transition. If `verify_result` is `pending`, start verification from the beginning.
36
-
37
- ### 1. Scale Assessment
38
-
39
- Execute scale assessment:
40
-
41
- ```bash
42
- "$COMET_BASH" "$COMET_STATE" scale <change-name>
43
- ```
44
-
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.
46
-
47
- Before verification begins, handle uncommitted changes through `comet/reference/dirty-worktree.md` protocol. Verify phase special handling:
48
-
49
- 1. If dirty diff belongs to current change and involves implementation, tests, tasks, delta spec, or design doc changes, do not fix or commit directly in verify phase; report failures and enter Step 1b verification failure decision blocking point
50
- 2. If dirty diff is only verify phase artifacts (e.g., verification report draft, branch handling records), may continue and record state in verify phase
51
- 3. If dirty diff shows implementation but tasks.md not checked, treat as build state lag; report failures and enter Step 1b, let user decide to roll back for fix or accept deviation
52
-
53
- Only after user chooses fix, allow rollback to build phase:
54
-
55
- ```bash
56
- # Execute only after user confirms fix
57
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
58
- ```
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
-
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:
63
-
64
- ```bash
65
- PLAN=$("$COMET_BASH" "$COMET_STATE" get <change-name> plan)
66
- BASE_REF=$(grep '^base-ref:' "$PLAN" 2>/dev/null | head -1 | sed 's/^base-ref: *//')
67
- git diff --stat "$BASE_REF"...HEAD
68
- ```
69
-
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:
71
-
72
- ```bash
73
- "$COMET_BASH" "$COMET_STATE" set <change-name> verify_mode full
74
- ```
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
-
78
- ### 1b. Verification Failure Decision (Blocking Point)
79
-
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.
81
-
82
- When pausing, must list:
83
- - Failed items
84
- - Whether CRITICAL (build failure, test failure, security issues, core acceptance scenario failure)
85
- - Recommended handling approach
86
-
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.
88
-
89
- After user selection, continue as follows:
90
- - **Fix all**: Run `"$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build` to fix
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
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
-
113
- ### 2a. Lightweight Verification (Small Changes)
114
-
115
- Run these 5 checks:
116
-
117
- 1. All tasks.md tasks completed `[x]`
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)
119
- 3. Build passes (run project-specific build command, e.g., `npm run build`, `mvn compile`, `cargo build`, etc.)
120
- 4. Related tests pass
121
- 5. No obvious security issues (no hardcoded keys, no new unsafe operations)
122
-
123
- **Pass criteria**: All 5 items OK, no CRITICAL issues.
124
-
125
- **When not passing**: Report failures, enter Step 1b verification failure decision blocking point. Only after user confirms fix, execute the following command to record failure and roll back to build phase, then invoke `/comet-build` to fix:
126
-
127
- ```bash
128
- # Execute only after user confirms fix
129
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
130
- ```
131
-
132
- **Report format**: Brief table listing 5 check results + PASS/FAIL.
133
-
134
- **Skipped items** (not checked in lightweight verification):
135
- - spec scenario coverage
136
- - design doc consistency deep comparison
137
- - code pattern consistency suggestions
138
- - delta spec and design doc drift detection
139
-
140
- ### 2b. Full Verification (Large Changes)
141
-
142
- When scale assessment result is "large":
143
-
144
- **Immediately execute:** Use the Skill tool to load the `openspec-verify-change` skill. Skipping this step is prohibited.
145
-
146
- After the skill loads, follow its guidance to verify. Check items:
147
- 1. All tasks.md tasks completed (`[x]`)
148
- 2. Implementation matches `openspec/changes/<name>/design.md` high-level design decisions
149
- 3. Implementation matches Design Doc (technical design documents under `docs/superpowers/specs/`)
150
- 4. All capability spec scenarios pass
151
- 5. proposal.md goals are satisfied
152
- 6. No contradictions between delta spec and design doc (if Build phase had incremental spec modifications, check if design doc has corresponding records)
153
- 7. Associated design documents under `docs/superpowers/specs/` are locatable (file exists and is related to current change)
154
-
155
- When verification does not pass: report missing items, enter Step 1b verification failure decision blocking point. Only after user confirms fix, execute the following command to record failure and roll back to build phase, then invoke `/comet-build` to supplement:
156
-
157
- ```bash
158
- # Execute only after user confirms fix
159
- "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
160
- ```
161
-
162
- **Spec Drift Handling** (user decision point):
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:
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
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
166
- - Option C: Confirm deviation is acceptable, continue verification (design doc will be marked as `superseded-by-main-spec` during archiving)
167
-
168
- ### 3. Finishing (Superpowers)
169
-
170
- **Immediately execute:** Use the Skill tool to load the Superpowers `finishing-a-development-branch` skill. Skipping this step is prohibited.
171
-
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.
173
-
174
- After the skill loads, follow its guidance to finish. Branch handling options:
175
- 1. Merge to main branch locally
176
- 2. Push and create PR
177
- 3. Keep branch (handle later)
178
- 4. Discard work
179
-
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.
181
-
182
- **Confirmation items**:
183
- - All tests pass
184
- - No hardcoded keys or security issues
185
-
186
- ### 4. Record Verification Evidence
187
-
188
- Verification report must be saved to disk and recorded in `.comet.yaml`; after branch handling completes, state fields must also be written. Do not manually set `verify_result: pass`; use guard for auto-transition.
189
-
190
- ```bash
191
- mkdir -p docs/superpowers/reports
192
- # Write verification conclusions to report file, e.g.:
193
- # docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
194
-
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
197
- ```
198
-
199
- ## Exit Conditions
200
-
201
- - Verification report passed
202
- - Branch handled
203
- - `verification_report` in `.comet.yaml` points to an existing verification report file
204
- - `branch_status: handled` in `.comet.yaml`
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`
206
-
207
- After both verification and branch handling are complete, run guard for auto-transition:
208
-
209
- ```bash
210
- "$COMET_BASH" "$COMET_GUARD" <change-name> verify --apply
211
- ```
212
-
213
- State file auto-updates to `phase: archive`, `verify_result: pass`, `verified_at: YYYY-MM-DD`.
214
-
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
- ```
224
-
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
229
-
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.
231
-
232
- ## Context Compaction Recovery
233
-
234
- The verify phase may trigger context compaction. To recover, first run:
235
-
236
- ```bash
237
- "$COMET_BASH" "$COMET_STATE" check <change-name> verify --recover
238
- ```
239
-
240
- The script outputs structured recovery context (phase, verification status, branch status, recovery action). Follow the Recovery action to determine next step.
1
+ ---
2
+ name: comet-verify
3
+ description: "Comet Phase 4: Verify and Close. Invoke with /comet-verify. Verify implementation matches design, handle development branch."
4
+ ---
5
+
6
+ # Comet Phase 4: Verify and Close (Verify)
7
+
8
+ ## Prerequisites
9
+
10
+ - Code committed (Phase 3 complete)
11
+ - All tasks.md tasks completed
12
+
13
+ ## Steps
14
+
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)
20
+
21
+ Execute entry verification:
22
+
23
+ ```bash
24
+ COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
25
+ if [ -z "$COMET_ENV" ]; then
26
+ echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
27
+ return 1
28
+ fi
29
+ . "$COMET_ENV"
30
+ "$COMET_BASH" "$COMET_STATE" check <change-name> verify
31
+ ```
32
+
33
+ Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
34
+
35
+ **Idempotency**: All verify phase checks can be safely re-executed. If `verify_result` is already `pass` and `branch_status` is `handled`, verification is complete — execute guard to transition. If `verify_result` is `pending`, start verification from the beginning.
36
+
37
+ ### 1. Scale Assessment
38
+
39
+ Execute scale assessment:
40
+
41
+ ```bash
42
+ "$COMET_BASH" "$COMET_STATE" scale <change-name>
43
+ ```
44
+
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.
46
+
47
+ Before verification begins, handle uncommitted changes through `comet/reference/dirty-worktree.md` protocol. Verify phase special handling:
48
+
49
+ 1. If dirty diff belongs to current change and involves implementation, tests, tasks, delta spec, or design doc changes, do not fix or commit directly in verify phase; report failures and enter Step 1b verification failure decision blocking point
50
+ 2. If dirty diff is only verify phase artifacts (e.g., verification report draft, branch handling records), may continue and record state in verify phase
51
+ 3. If dirty diff shows implementation but tasks.md not checked, treat as build state lag; report failures and enter Step 1b, let user decide to roll back for fix or accept deviation
52
+
53
+ Only after user chooses fix, allow rollback to build phase:
54
+
55
+ ```bash
56
+ # Execute only after user confirms fix
57
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
58
+ ```
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
+
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:
63
+
64
+ ```bash
65
+ PLAN=$("$COMET_BASH" "$COMET_STATE" get <change-name> plan)
66
+ BASE_REF=$(grep '^base-ref:' "$PLAN" 2>/dev/null | head -1 | sed 's/^base-ref: *//')
67
+ git diff --stat "$BASE_REF"...HEAD
68
+ ```
69
+
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:
71
+
72
+ ```bash
73
+ "$COMET_BASH" "$COMET_STATE" set <change-name> verify_mode full
74
+ ```
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
+
78
+ ### 1b. Verification Failure Decision (Blocking Point)
79
+
80
+ When verification does not pass, **must follow the `comet/reference/decision-point.md` protocol 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`.
81
+
82
+ When pausing, must list:
83
+ - Failed items
84
+ - Whether CRITICAL or IMPORTANT (build failure, test failure, security issues, core acceptance scenario failure, lightweight code review correctness/security/edge-case issue)
85
+ - Recommended handling approach
86
+
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.
88
+
89
+ After user selection, continue as follows:
90
+ - **Fix all**: Run `"$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail`, then invoke `/comet-build` to fix
91
+ - **Handle item by item**: CRITICAL or IMPORTANT failures must be fixed; WARNING/SUGGESTION failures may choose to accept deviation, but must record acceptance reason and impact scope in verification report. If any CRITICAL or IMPORTANT failure exists, skipping fix to accept all is not allowed
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
+
113
+ ### 2a. Lightweight Verification (Small Changes)
114
+
115
+ Run these 6 checks:
116
+
117
+ 1. All tasks.md tasks completed `[x]`
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)
119
+ 3. Build passes (run project-specific build command, e.g., `npm run build`, `mvn compile`, `cargo build`, etc.)
120
+ 4. Related tests pass
121
+ 5. No obvious security issues (no hardcoded keys, no new unsafe operations)
122
+ 6. Lightweight code review passes: use the Skill tool to load the Superpowers `requesting-code-review` skill and request a lightweight review that checks only correctness, security, and edge cases
123
+
124
+ The lightweight code review input should be limited to this change's diff, tasks.md, and necessary test results; the review scope covers implementation correctness, security risk, and edge cases only, and does not perform spec coverage, Design Doc consistency, or drift checks. If the review finds CRITICAL or IMPORTANT issues, treat verification as failed and enter Step 1b.
125
+
126
+ **Pass criteria**: All 6 items OK, no CRITICAL or IMPORTANT issues.
127
+
128
+ **When not passing**: Report failures, enter Step 1b verification failure decision blocking point. Only after user confirms fix, execute the following command to record failure and roll back to build phase, then invoke `/comet-build` to fix:
129
+
130
+ ```bash
131
+ # Execute only after user confirms fix
132
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
133
+ ```
134
+
135
+ **Report format**: Brief table listing 6 check results + PASS/FAIL.
136
+
137
+ **Skipped items** (not checked in lightweight verification):
138
+ - spec scenario coverage
139
+ - design doc consistency deep comparison
140
+ - code pattern consistency suggestions that do not affect correctness, security, or edge cases
141
+ - delta spec and design doc drift detection
142
+
143
+ ### 2b. Full Verification (Large Changes)
144
+
145
+ When scale assessment result is "large":
146
+
147
+ **Immediately execute:** Use the Skill tool to load the `openspec-verify-change` skill. Skipping this step is prohibited.
148
+
149
+ After the skill loads, follow its guidance to verify. Check items:
150
+ 1. All tasks.md tasks completed (`[x]`)
151
+ 2. Implementation matches `openspec/changes/<name>/design.md` high-level design decisions
152
+ 3. Implementation matches Design Doc (technical design documents under `docs/superpowers/specs/`)
153
+ 4. All capability spec scenarios pass
154
+ 5. proposal.md goals are satisfied
155
+ 6. No contradictions between delta spec and design doc (if Build phase had incremental spec modifications, check if design doc has corresponding records)
156
+ 7. Associated design documents under `docs/superpowers/specs/` are locatable (file exists and is related to current change)
157
+
158
+ When verification does not pass: report missing items, enter Step 1b verification failure decision blocking point. Only after user confirms fix, execute the following command to record failure and roll back to build phase, then invoke `/comet-build` to supplement:
159
+
160
+ ```bash
161
+ # Execute only after user confirms fix
162
+ "$COMET_BASH" "$COMET_STATE" transition <change-name> verify-fail
163
+ ```
164
+
165
+ **Spec Drift Handling** (user decision point):
166
+ - 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:
167
+ - 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
168
+ - 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
169
+ - Option C: Confirm deviation is acceptable, continue verification (design doc will be marked as `superseded-by-main-spec` during archiving)
170
+
171
+ ### 3. Finishing (Superpowers)
172
+
173
+ **Immediately execute:** Use the Skill tool to load the Superpowers `finishing-a-development-branch` skill. Skipping this step is prohibited.
174
+
175
+ 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.
176
+
177
+ After the skill loads, follow its guidance to finish. Branch handling options:
178
+ 1. Merge to main branch locally
179
+ 2. Push and create PR
180
+ 3. Keep branch (handle later)
181
+ 4. Discard work
182
+
183
+ This is a user decision point. **Must follow the `comet/reference/decision-point.md` protocol to pause and wait for the user to choose branch handling method**. Must not select based on recommendations, defaults, or current branch status. Only after the user completes selection and the corresponding operation finishes, may `branch_status: handled` be written.
184
+
185
+ **Confirmation items**:
186
+ - All tests pass
187
+ - No hardcoded keys or security issues
188
+
189
+ ### 4. Record Verification Evidence
190
+
191
+ Verification report must be saved to disk and recorded in `.comet.yaml`; after branch handling completes, state fields must also be written. Do not manually set `verify_result: pass`; use guard for auto-transition.
192
+
193
+ ```bash
194
+ mkdir -p docs/superpowers/reports
195
+ # Write verification conclusions to report file, e.g.:
196
+ # docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
197
+
198
+ "$COMET_BASH" "$COMET_STATE" set <change-name> verification_report docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
199
+ "$COMET_BASH" "$COMET_STATE" set <change-name> branch_status handled
200
+ ```
201
+
202
+ ## Exit Conditions
203
+
204
+ - Verification report passed
205
+ - Branch handled
206
+ - `verification_report` in `.comet.yaml` points to an existing verification report file
207
+ - `branch_status: handled` in `.comet.yaml`
208
+ - **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`
209
+
210
+ After both verification and branch handling are complete, run guard for auto-transition:
211
+
212
+ ```bash
213
+ "$COMET_BASH" "$COMET_GUARD" <change-name> verify --apply
214
+ ```
215
+
216
+ State file auto-updates to `phase: archive`, `verify_result: pass`, `verified_at: YYYY-MM-DD`.
217
+
218
+ ## Automatic Handoff to Next Phase
219
+
220
+ Follow `comet/reference/auto-transition.md`. Key command:
221
+
222
+ ```bash
223
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
224
+ ```
225
+
226
+ - `NEXT: auto` invoke the skill pointed to by `SKILL` to enter the next phase
227
+ - `NEXT: manual` do not invoke the next skill; prompt user to run `/<SKILL>` manually
228
+ - `NEXT: done` workflow is complete, no further action needed
229
+
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.
231
+
232
+ ## Context Compression Recovery
233
+
234
+ Follow `comet/reference/context-recovery.md` with phase set to `verify`.