@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
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: comet-archive
3
- description: "Comet Phase 5: Archive. Invoke with /comet-archive. Sync delta spec to main spec, archive change."
3
+ description: "Comet Phase 5: Archive. Invoke with /comet-archive. Merge delta specs into main specs with OpenSpec semantics, archive change."
4
4
  ---
5
5
 
6
6
  # Comet Phase 5: Archive (Archive)
@@ -13,6 +13,10 @@ description: "Comet Phase 5: Archive. Invoke with /comet-archive. Sync delta spe
13
13
 
14
14
  ## Steps
15
15
 
16
+ ### 0. Output Language Constraint
17
+
18
+ Archive summaries and lifecycle closure notes must use the language of the user request that triggered this workflow.
19
+
16
20
  ### 0. Entry State Verification (Entry Check)
17
21
 
18
22
  Execute entry verification:
@@ -24,40 +28,57 @@ if [ -z "$COMET_ENV" ]; then
24
28
  return 1
25
29
  fi
26
30
  . "$COMET_ENV"
27
- bash "$COMET_STATE" check <name> archive
31
+ "$COMET_BASH" "$COMET_STATE" check <name> archive
28
32
  ```
29
33
 
30
34
  Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
31
35
 
32
- ### 1. Execute Archive
36
+ ### 1. Final Archive Confirmation (Blocking Point)
37
+
38
+ After entry verification passes, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user to confirm whether to archive immediately**. Must not run `"$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"` before user confirmation. If the current platform has no structured question tool, ask an equivalent single-select question in the conversation, stop the workflow, and wait for the user's reply before continuing.
39
+
40
+ Before confirmation, show the user a brief summary:
41
+ - Change name
42
+ - Verification report path and result
43
+ - Branch handling status
44
+ - Irreversible actions this archive will perform: merge main specs with OpenSpec delta semantics, annotate design doc / plan, and move the change to the archive directory
45
+
46
+ The user confirmation question must be presented as a single-select question with these options:
47
+ - "Confirm archive" — immediately run the archive script to complete spec merge and change movement
48
+ - "Needs adjustment or re-verification" — do not archive; run `"$COMET_BASH" "$COMET_STATE" transition <change-name> archive-reopen` to return to `phase: verify`, then invoke `/comet-verify`. If verification confirms fixes are needed, follow `/comet-verify`'s verification-failure decision flow back to `/comet-build`
49
+ - "Do not archive yet" — do not archive; keep the current `phase: archive` state and wait for the user to invoke `/comet-archive` again later
50
+
51
+ Only after the user selects "Confirm archive" may Step 2 continue. After the user selects "Needs adjustment or re-verification", must first run the `archive-reopen` state transition; do not edit `.comet.yaml` manually.
52
+
53
+ ### 2. Execute Archive
33
54
 
34
55
  Run the archive script to automatically complete all steps:
35
56
 
36
57
  ```bash
37
- bash "$COMET_ARCHIVE" "<change-name>"
58
+ "$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"
38
59
  ```
39
60
 
40
61
  The script automatically executes:
41
62
  1. Entry state validation (phase=archive, verify_result=pass, archived=false)
42
- 2. Delta spec sync to main spec (overwrite)
43
- 3. Design doc frontmatter annotation (archived-with, status)
44
- 4. Plan frontmatter annotation (archived-with)
45
- 5. Move change to archive directory
63
+ 2. Design doc frontmatter annotation (archived-with, status)
64
+ 3. Plan frontmatter annotation (archived-with)
65
+ 4. OpenSpec archive for delta-merge semantics and moving the change to the archive directory
66
+ 5. Main spec guard against leaked delta-only section headings
46
67
  6. Update `archived: true` through `comet-state transition <archive-name> archived`
47
68
 
48
69
  If script returns non-zero exit code, report error and stop.
49
70
  If script returns zero exit code, archive is complete.
50
71
  The summary `X/Y steps succeeded` counts real executed steps and does not double-count delta spec sync or document annotation.
51
72
 
52
- When a delta spec differs from an existing main spec, the script prints a unified diff preview before overwrite to help confirm archive sync content.
73
+ The script calls OpenSpec archive to merge `ADDED/MODIFIED/REMOVED/RENAMED` delta semantics into main specs, then verifies main specs do not contain delta-only section headings.
53
74
 
54
75
  Use `--dry-run` flag to preview without executing.
55
76
 
56
- ### 2. Lifecycle Closed Loop
77
+ ### 3. Lifecycle Closed Loop
57
78
 
58
79
  Spec lifecycle completes here:
59
80
  ```
60
- brainstorming → delta spec → implementation → verification → main spec overwrite → design doc annotation → archive
81
+ brainstorming → delta spec → implementation → verification → main spec merge → design doc annotation → archive
61
82
  ```
62
83
 
63
84
  ## Exit Conditions
@@ -66,8 +87,20 @@ brainstorming → delta spec → implementation → verification → main spec o
66
87
  - Archive directory `openspec/changes/archive/YYYY-MM-DD-<change-name>/` exists
67
88
  - Archived `.comet.yaml` contains `archived: true`
68
89
 
69
- The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`. After successful archive, **do not run** `bash "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Archive completeness is determined by script exit code and archived directory state.
90
+ The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`.
91
+
92
+ > **WARNING**: After successful archive, **do not run** `"$COMET_BASH" "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Doing so will cause the guard to error with "change directory not found". Archive completeness is determined by script exit code and archived directory state.
70
93
 
71
94
  ## Complete
72
95
 
73
96
  Comet workflow complete. To start new work, invoke `/comet` or `/comet-open`.
97
+
98
+ ## Context Compaction Recovery
99
+
100
+ The archive phase may trigger context compaction during execution. On resume, first run:
101
+
102
+ ```bash
103
+ "$COMET_BASH" "$COMET_STATE" check <change-name> archive --recover
104
+ ```
105
+
106
+ The script outputs structured recovery context (archive status, completed steps). Follow the Recovery action to determine next steps. If `archived: true` and the archive directory exists, archiving is already complete — no need to run the archive operation again.
@@ -23,18 +23,27 @@ if [ -z "$COMET_ENV" ]; then
23
23
  return 1
24
24
  fi
25
25
  . "$COMET_ENV"
26
- bash "$COMET_STATE" check <name> build
26
+ "$COMET_BASH" "$COMET_STATE" check <name> build
27
27
  ```
28
28
 
29
29
  Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
30
30
 
31
- **Idempotency**: All build phase operations can be safely re-executed. Read `.comet.yaml` `phase` field to confirm still in build, read plan header `base-ref`, then read tasks.md to find the first unchecked task. Already-committed tasks must not be re-committed.
31
+ **Idempotency**: All build phase operations can be safely re-executed. Read `.comet.yaml` `phase` field to confirm still in build, read plan header `base-ref`, then use `grep -n '\- \[ \]' tasks.md | head -1` to find the first unchecked task. Already-committed tasks must not be re-committed.
32
32
 
33
- ### 1. Create Plan
33
+ ### 1. Create Plan (Subagent Offload)
34
34
 
35
- **Immediately execute:** Use the Skill tool to load the `superpowers:writing-plans` skill. Skipping this step is prohibited.
35
+ Create the implementation plan through a subagent, avoiding planning skill occupying main session context. Plan files and execution feedback must use the language of the user request that triggered this workflow.
36
36
 
37
- After the skill loads, follow its guidance to create a plan. Plan requirements:
37
+ **Subagent instructions**:
38
+
39
+ You are an implementation planning expert. Create an implementation plan based on the following inputs:
40
+
41
+ 1. **Immediately execute:** Use the Skill tool to load the Superpowers `writing-plans` skill. Skipping this step is prohibited. After the skill loads, ARGUMENTS must include: `Language: Use the language of the user request that triggered this workflow`
42
+ 2. Read the Design Doc (technical design document under `docs/superpowers/specs/`)
43
+ 3. Read `openspec/changes/<name>/tasks.md` (task boundaries)
44
+ 4. Follow the skill's guidance to create the plan
45
+
46
+ Plan requirements:
38
47
  - Save to `docs/superpowers/plans/YYYY-MM-DD-<feature>.md`
39
48
  - Reference design document, break down into executable tasks
40
49
  - **Plan file header must contain associated metadata**:
@@ -53,18 +62,57 @@ base-ref: <git rev-parse HEAD before implementation>
53
62
  git rev-parse HEAD
54
63
  ```
55
64
 
56
- ### 2. Update Plan Status
65
+ Write the plan to file, then return the file path.
66
+
67
+ **Execute subagent**: Use the current platform's subagent dispatch mechanism to send the above task.
68
+
69
+ After the subagent completes:
70
+ - If a valid file path is returned and the file exists, record it as the plan
71
+ - If the subagent fails or returns an invalid path, fall back to loading the Superpowers `writing-plans` skill inline in the main session (degraded fallback)
72
+
73
+ ### 2. Update Plan Status and Provide Plan-Ready Pause Point
57
74
 
58
75
  Record plan path:
59
76
 
60
77
  ```bash
61
- bash "$COMET_STATE" set <name> plan docs/superpowers/plans/YYYY-MM-DD-feature.md
78
+ "$COMET_BASH" "$COMET_STATE" set <name> plan docs/superpowers/plans/YYYY-MM-DD-feature.md
62
79
  ```
63
80
 
64
81
  No manual phase update needed — guard auto-transitions when exit conditions are met.
65
82
 
83
+ After the plan is recorded, immediately provide a new user decision point:
84
+
85
+ | Option | Behavior | Description |
86
+ |--------|----------|-------------|
87
+ | A | Continue execution | Stay in the current model and proceed to Step 3 to choose workspace isolation and execution method |
88
+ | B | Pause to switch model | Record `build_pause: plan-ready`, stop this `/comet-build` invocation, and allow the user to resume later from `/comet` or `/comet-build` |
89
+
90
+ 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 explicitly choose**. Must not auto-continue and must not write the pause into `build_mode`. If the current platform has no structured question tool, ask equivalent options in the conversation, stop the workflow, and wait for the user's reply before continuing.
91
+
92
+ When the user chooses to continue:
93
+
94
+ ```bash
95
+ "$COMET_BASH" "$COMET_STATE" set <name> build_pause null
96
+ ```
97
+
98
+ When the user chooses to pause:
99
+
100
+ ```bash
101
+ "$COMET_BASH" "$COMET_STATE" set <name> build_pause plan-ready
102
+ ```
103
+
104
+ After setting `build_pause: plan-ready`, stop the current invocation. Do not choose `isolation` or `build_mode`, and do not load an execution skill.
105
+
66
106
  ### 3. Select Workflow Configuration
67
107
 
108
+ If resuming with `build_pause: plan-ready` and the `plan` file exists, do not rerun `writing-plans`. First tell the user the workflow is stopped at the plan-ready pause point; after the user confirms continuing, set:
109
+
110
+ ```bash
111
+ "$COMET_BASH" "$COMET_STATE" set <name> build_pause null
112
+ ```
113
+
114
+ Then continue this step to choose workspace isolation and execution method.
115
+
68
116
  Plan has been written to the current branch. Before starting execution, **ask the user to choose both workspace isolation and execution method in a single interaction**:
69
117
 
70
118
  **Workspace Isolation**:
@@ -82,50 +130,113 @@ Plan has been written to the current branch. Before starting execution, **ask th
82
130
 
83
131
  | Option | Skill | Applicable Scenario |
84
132
  |------|------|-------------------|
85
- | A | `superpowers:subagent-driven-development` | Independent tasks, high complexity, requires two-phase review |
86
- | B | `superpowers:executing-plans` | Simple tasks, no subagent environment, lightweight and fast |
133
+ | A | Superpowers `subagent-driven-development` | Independent tasks, high complexity, requires two-phase review |
134
+ | B | Superpowers `executing-plans` | Simple tasks, no subagent environment, lightweight and fast |
87
135
 
88
136
  **Execution method recommendation rules**:
89
137
  - Task count ≥ 3 → Recommend A
90
138
  - Task count ≤ 2 and no cross-module dependencies → Recommend B
91
139
  - From hotfix path → Recommend B
92
140
 
93
- This is a user decision point. **Must use the AskUserQuestion tool to pause and wait for the user to explicitly choose both isolation method and execution method**. Must not choose `branch` or `worktree` based on recommendation rules, and must not choose the execution method based on recommendation rules. Recommendation rules are for suggestion only, not a substitute for user confirmation. Must not just output a text prompt and then continue executing.
141
+ 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 explicitly choose isolation method, execution method, and TDD mode**. Must not choose `branch` or `worktree` based on recommendation rules, and must not choose the execution method or TDD mode based on recommendation rules. Recommendation rules are for suggestion only, not a substitute for user confirmation. If the current platform has no structured question tool, ask equivalent options in the conversation, stop the workflow, and wait for the user's reply before continuing.
94
142
 
95
- After user selection, update `isolation` and `build_mode` fields:
143
+ After user selection, update `isolation`, execution method, and TDD mode fields:
96
144
 
97
145
  ```bash
98
- bash "$COMET_STATE" set <name> isolation <branch|worktree>
99
- bash "$COMET_STATE" set <name> build_mode <subagent-driven-development|executing-plans|direct>
146
+ "$COMET_BASH" "$COMET_STATE" set <name> isolation <branch|worktree>
100
147
  ```
101
148
 
149
+ - If the user chooses `executing-plans`: run `"$COMET_BASH" "$COMET_STATE" set <name> subagent_dispatch null`, then run `"$COMET_BASH" "$COMET_STATE" set <name> build_mode executing-plans`
150
+ - If the user chooses `subagent-driven-development`: first confirm the current platform has real background subagent / Task / multi-agent dispatch capability; after confirming, run `"$COMET_BASH" "$COMET_STATE" set <name> subagent_dispatch confirmed`, then run `"$COMET_BASH" "$COMET_STATE" set <name> build_mode subagent-driven-development`
151
+ - If real background dispatch capability cannot be confirmed, must not write `build_mode: subagent-driven-development`; must pause and wait for the user to choose `executing-plans` instead
152
+
153
+ **TDD Mode**:
154
+
155
+ | Option | Meaning | Applicable Scenario |
156
+ |--------|---------|---------------------|
157
+ | `tdd` | Write a failing test first for each task, then implement | Recommended. Changes involving business logic, new features, APIs |
158
+ | `direct` | Implement directly, no enforced TDD flow | Changes that don't need test coverage, or user chooses to skip tests and write code directly. hotfix/tweak presets default to `direct` |
159
+
160
+ Run `"$COMET_BASH" "$COMET_STATE" set <name> tdd_mode <tdd|direct>`
161
+
102
162
  `isolation` is a script-enforced hard constraint. Full workflow init may temporarily leave it as `null`, but only before this step. If it remains `null`, both the `build → verify` guard and `comet-state transition build-complete` will fail.
103
163
 
164
+ `subagent_dispatch` is a script-enforced hard constraint. `build_mode: subagent-driven-development` requires `subagent_dispatch: confirmed` before leaving the build phase, otherwise both `comet-guard.sh build --apply` and `comet-state transition build-complete` will fail.
165
+
166
+ `tdd_mode` is a script-enforced hard constraint. Full workflow must have `tdd_mode` selected as `tdd` or `direct` before leaving the build phase, otherwise both `comet-guard.sh build --apply` and `comet-state transition build-complete` will fail.
167
+
104
168
  `build_mode` defaults to `direct` only for hotfix/tweak presets. Full workflow must not default to `direct`. Use it only when the user explicitly asks to bypass the plan execution skills and you record an explicit override:
105
169
 
106
170
  ```bash
107
- bash "$COMET_STATE" set <name> direct_override true
108
- bash "$COMET_STATE" set <name> build_mode direct
171
+ "$COMET_BASH" "$COMET_STATE" set <name> direct_override true
172
+ "$COMET_BASH" "$COMET_STATE" set <name> build_mode direct
109
173
  ```
110
174
 
111
175
  Without `direct_override: true`, `build_mode=direct` in full workflow is blocked by both guard and state transition.
112
176
 
113
177
  **Execute isolation**:
114
178
 
115
- - **branch**: Run `git checkout -b <change-name>`, subsequent work on the new branch
116
- - **worktree**: Must use the Skill tool to load `superpowers:using-git-worktrees` skill to create isolated workspace. Do not bypass this skill with plain shell commands or native tools; if the skill is unavailable, stop the process and prompt to install or enable Superpowers skills.
179
+ - **branch**: Recommend a branch name based on the workflow type and current date, then let the user confirm or input a custom name. 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 explicitly confirm or override the branch name**. Must not skip this step and create the branch directly.
117
180
 
118
- After creating isolation, confirm plan file is accessible (naturally accessible with branch method; for worktree method, confirm plan has been committed).
181
+ Branch naming convention:
182
+ - Read the `workflow` field from `.comet.yaml` to determine the prefix
183
+ - `workflow: full` → recommend `feature/YYYYMMDD/<change-name>`
184
+ - `workflow: hotfix` → recommend `hotfix/YYYYMMDD/<change-name>`
185
+ - `workflow: tweak` → recommend `tweak/YYYYMMDD/<change-name>`
186
+ - Date is derived from `date +%Y%m%d` at runtime
119
187
 
120
- **Load execution skill**: Use the Skill tool to load the corresponding skill. Skipping this step is prohibited.
188
+ Example: if change name is `fix-login-bug` and today is 2026-06-09, recommend `feature/20260609/fix-login-bug`
121
189
 
122
- 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.
190
+ After the user confirms or provides a custom branch name, run `git checkout -b <branch-name>`, subsequent work on the new branch.
123
191
 
124
- After the skill loads, follow its guidance to execute:
192
+ - **worktree**: Must use the Skill tool to load the Superpowers `using-git-worktrees` skill to create isolated workspace. Do not bypass this skill with plain shell commands or native tools; if the skill is unavailable, stop the process and prompt to install or enable Superpowers skills.
193
+
194
+ After creating isolation, confirm plan file is accessible (naturally accessible with branch method; for worktree method, confirm plan has been committed). If the plan file has not been committed under worktree mode, commit it first before creating the worktree:
195
+
196
+ ```bash
197
+ git add docs/superpowers/plans/YYYY-MM-DD-feature.md
198
+ git commit -m "chore: add implementation plan"
199
+ ```
200
+
201
+ **Execute plan**: Must handle execution according to the actual runtime of `build_mode`.
202
+
203
+ - `build_mode: executing-plans`: **Immediately execute:** Use the Skill tool to load the Superpowers `executing-plans` skill. Skipping this step is prohibited. If the skill is unavailable, stop the process and prompt to install or enable the corresponding skill; do not substitute with normal conversation. After the skill loads, ARGUMENTS must include the same Language constraint as Step 1: `Language: Use the language of the user request that triggered this workflow`. Execute according to plan.
204
+ - `build_mode: subagent-driven-development`: The main window only coordinates; must not run `subagent-driven-development` as the main window execution skill directly. Must use the confirmed real background subagent / Task / multi-agent dispatch capability to dispatch the next unchecked task to a background subagent. When dispatching each subagent, the prompt must explicitly require: after the skill loads, ARGUMENTS must include the same Language constraint as Step 1: `Language: Use the language of the user request that triggered this workflow`; after the task is complete and validated, immediately check off the corresponding plan task in `docs/superpowers/plans/<plan-file>.md`; if that plan task maps to an item in `openspec/changes/<name>/tasks.md`, also change that OpenSpec task from `- [ ]` to `- [x]`; if the plan added a step that does not exist in OpenSpec, only the corresponding plan task needs to be checked off. Do not only update the built-in Todo or an in-chat checklist. The background subagent loads the Superpowers `subagent-driven-development` execution flow on its own and follows its guidance for implementation, review, and commit.
205
+ - If the current platform has no real background subagent / Task / multi-agent dispatch capability, must pause and wait for the user to choose main window execution instead. After the user chooses, must run `"$COMET_BASH" "$COMET_STATE" set <name> build_mode executing-plans`, then follow the `build_mode: executing-plans` branch to load the Superpowers `executing-plans` skill. Must not continue executing tasks before the user explicitly chooses.
206
+
207
+ After execution begins, follow the chosen branch to completion:
125
208
  - Execute tasks according to plan
126
- - Complete tasks.md check (`- [ ]` → `- [x]`)
209
+ - Check off the corresponding Superpowers plan task; if the task maps to OpenSpec tasks.md, also check off the corresponding OpenSpec task (`- [ ]` → `- [x]`)
127
210
  - Commit code after each task completion
128
211
 
212
+ **TDD Mode Execution Constraints**:
213
+
214
+ If `tdd_mode: tdd`:
215
+ - `build_mode: executing-plans`: After loading the execution skill and before executing the first task, **Immediately execute:** Use the Skill tool to load the Superpowers `test-driven-development` skill once. Skipping this step is prohibited. After the skill loads, start from the first unchecked task and follow the loaded TDD Red-Green-Refactor cycle for each task. Must not skip the failing test verification phase. Do not reload this skill for subsequent tasks; follow the already-loaded flow. If resuming after context compaction, re-run this step to load the TDD skill once, then continue from the first unchecked task.
216
+ - `build_mode: subagent-driven-development`: When dispatching each subagent, must inject the TDD hard constraint into the prompt: **"You MUST follow TDD: for each task, write a failing test first, watch it fail, then write minimal code to pass. No production code without a failing test first."**. The same prompt must also include the OpenSpec tasks.md and Superpowers plan persistent check-off requirement above. Must not rely on implementer-prompt.md's conditional trigger; must explicitly write it in the dispatch prompt.
217
+
218
+ If `tdd_mode: direct`: Follow normal flow, no enforced TDD.
219
+
220
+ **`executing-plans` review gate**:
221
+
222
+ When `build_mode` is `executing-plans`, after all planned tasks are complete and before running the build → verify phase guard, must use the Skill tool to load the Superpowers `requesting-code-review` skill and request code review at least once.
223
+
224
+ Requirements:
225
+ - the `requesting-code-review` skill must be loaded before `"$COMET_BASH" "$COMET_GUARD" <change-name> build --apply`
226
+ - if `requesting-code-review` skill is unavailable, skip the review gate but must record `<!-- review skipped: skill unavailable -->` in tasks.md, then continue guard transition
227
+ - CRITICAL review findings (security vulnerabilities, data loss risk, build/test failures) must be fixed first and must not be carried into verify
228
+ - if non-CRITICAL review findings are accepted, record the acceptance reason and impact scope in tasks.md, the commit body, a verification report draft, or another durable artifact
229
+
230
+ ### 3b. In-Execution Debugging (Debug Gate)
231
+
232
+ During task execution, whenever a crash, unexpected behavior, test failure, or build failure appears while running the program, tests, build, or manual verification, must use the Skill tool to load the Superpowers `systematic-debugging` skill. Before root-cause investigation is complete, must not propose or implement source-code fixes.
233
+
234
+ Handle it using the four-phase `systematic-debugging` flow:
235
+ - First reproduce and locate the root cause, read full errors, check recent changes, and trace data flow
236
+ - If root cause points to a source bug, first add a minimal failing test that reproduces the crash or unexpected behavior, then modify source code
237
+ - After the fix, run that failing test, related tests, and project build/verification commands to confirm all pass
238
+ - Keep the test, source fix, and tasks.md checkoff inside the current change; Must not replace the current change verification loop by starting a separate "write test cases" change
239
+
129
240
  ### 4. Spec Incremental Updates
130
241
 
131
242
  When the initial spec is found incomplete during implementation, handle by scale:
@@ -133,13 +244,17 @@ When the initial spec is found incomplete during implementation, handle by scale
133
244
  | Scale | Trigger Conditions | Approach |
134
245
  |------|-------------------|----------|
135
246
  | Small | Missing acceptance scenarios, edge cases | Directly edit delta spec + design.md, append tasks.md tasks |
136
- | Medium | Interface changes, new components, data flow changes | **Must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm**, then must use Skill tool to load `superpowers:brainstorming` to update Design Doc + delta spec |
137
- | Large | Brand-new capability requirements | **Must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm the split**; after user confirms, create independent change through `/comet-open` |
247
+ | Medium | Interface changes, new components, data flow changes | **Must use the current platform's available user input/confirmation mechanism to pause and wait for the user to explicitly confirm**, then must use Skill tool to load the Superpowers `brainstorming` skill to update Design Doc + delta spec |
248
+ | Large | Brand-new capability requirements | **Must use the current platform's available user input/confirmation mechanism to pause and wait for the user to explicitly confirm the split**; after user confirms, create independent change through `/comet-open` |
138
249
 
139
- **50% Threshold Determination**: Using initial task count in tasks.md as baseline, if new tasks exceed half of that total, it's considered outside original plan scope, **must use the AskUserQuestion tool to pause and wait for the user to decide whether to split into a new change**. Must not just output a text prompt and then continue executing.
250
+ **50% Threshold Determination**: Using initial task count in tasks.md as baseline, if new tasks exceed half of that total, it's considered outside original plan scope, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user to decide whether to split into a new change**. If the current platform has no structured question tool, ask split options in the conversation, stop the workflow, and wait for the user's reply before continuing.
140
251
 
141
252
  When creating an independent change, must invoke `/comet-open`, not `/opsx:new` directly. `/comet-open` creates both OpenSpec artifacts and `.comet.yaml`, preventing the new change from leaving the Comet state machine.
142
253
 
254
+ **User choices must include**:
255
+ - "Split into new change" — create independent change via `/comet-open`
256
+ - "Continue in current change" — record scope-expansion decision, update tasks.md and delta spec, then continue
257
+
143
258
  **Principles**:
144
259
  - Delta spec is a living document, can be modified at any time during this phase
145
260
  - Each update should be committed with commit message explaining the change reason
@@ -150,8 +265,8 @@ When creating an independent change, must invoke `/comet-open`, not `/opsx:new`
150
265
 
151
266
  Build is the longest phase and may span many tasks. To support resume after context compaction:
152
267
 
153
- - **After each task**: immediately check off tasks.md and commit code so `.comet.yaml` and file state are durable
154
- - **After context compaction**: first run `bash "$COMET_STATE" check <change-name> build --recover` — the script outputs structured recovery context (isolation/build_mode status, plan path, task progress, recovery action). Follow the Recovery action to determine next step.
268
+ - **After each task**: immediately check off the corresponding task in the Superpowers plan; if the task maps to OpenSpec tasks.md, also check off the corresponding OpenSpec task; then commit code so `.comet.yaml` and file state are durable. Use `grep -c '\- \[ \]' tasks.md` to check remaining unchecked count; no need to re-read the entire file
269
+ - **After context compaction**: first run `"$COMET_BASH" "$COMET_STATE" check <change-name> build --recover` — the script outputs structured recovery context (isolation/build_mode status, plan path, task progress, recovery action). Follow the Recovery action to determine next step.
155
270
  - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
156
271
  1. After attribution, if the diff implies plan or spec changes, handle it through Step 4 "Spec Incremental Updates"
157
272
  - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
@@ -162,8 +277,10 @@ Build is the longest phase and may span many tasks. To support resume after cont
162
277
  - Code committed
163
278
  - Project-specific build/tests explicitly run and pass; do not rely only on guard auto-detection
164
279
  - `isolation` has been written as `branch` or `worktree`
165
- - `build_mode` has been written as `subagent-driven-development`, `executing-plans`, or `direct` with explicit override
166
- - **Phase guard**: Run `bash "$COMET_GUARD" <change-name> build --apply`; after all PASS, state advances to `phase: verify`
280
+ - `build_mode` has been written as `subagent-driven-development`, `executing-plans`, or `direct` with explicit override; if `subagent-driven-development`, `subagent_dispatch` must be `confirmed`
281
+ - `tdd_mode` has been written as `tdd` or `direct`
282
+ - If `build_mode` is `executing-plans`, the Skill tool has been used to load the Superpowers `requesting-code-review` skill and request code review at least once, and CRITICAL review findings have been fixed or acceptance rationale for non-CRITICAL review findings has been recorded
283
+ - **Phase guard**: Run `"$COMET_BASH" "$COMET_GUARD" <change-name> build --apply`; after all PASS, state advances to `phase: verify`
167
284
 
168
285
  Guard reads project command configuration first:
169
286
 
@@ -178,13 +295,22 @@ Only when no command is configured does guard fall back to `npm run build`, Mave
178
295
  Before exit, run guard to auto-transition:
179
296
 
180
297
  ```bash
181
- bash "$COMET_GUARD" <change-name> build --apply
298
+ "$COMET_BASH" "$COMET_GUARD" <change-name> build --apply
182
299
  ```
183
300
 
184
301
  State file is automatically updated to `phase: verify`, `verify_result: pending`.
185
302
 
186
- ## Automatic Transition
303
+ ## Automatic Handoff to Next Phase
304
+
305
+ > **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.
187
306
 
188
- After exit conditions are met (including user selecting workflow configuration), auto-transition to next phase:
307
+ After exit conditions are met and guard-based phase advancement has completed, run:
308
+
309
+ ```bash
310
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
311
+ ```
189
312
 
190
- > **REQUIRED NEXT SKILL:** Invoke `comet-verify` skill to enter the verification and completion phase.
313
+ The script determines the next action from `phase`, `workflow`, and `auto_transition`:
314
+ - `NEXT: auto` -> invoke the `SKILL` target to continue to the next phase
315
+ - `NEXT: manual` -> do not invoke the next skill; follow `HINT` and ask the user to run `/<SKILL>` manually
316
+ - `NEXT: done` -> workflow is complete; no further action needed