@rpamis/comet 0.3.7 → 0.3.9

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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +557 -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/dirty-worktree.md +59 -59
  11. package/assets/skills/comet/reference/file-structure.md +28 -0
  12. package/assets/skills/comet/reference/subagent-dispatch.md +113 -0
  13. package/assets/skills/comet/rules/comet-phase-guard.en.md +123 -0
  14. package/assets/skills/comet/rules/comet-phase-guard.md +125 -90
  15. package/assets/skills/comet/scripts/comet-guard.sh +27 -1
  16. package/assets/skills/comet/scripts/comet-hook-guard.sh +121 -45
  17. package/assets/skills/comet/scripts/comet-state.sh +162 -7
  18. package/assets/skills/comet/scripts/comet-yaml-validate.sh +3 -1
  19. package/assets/skills/comet-archive/SKILL.md +100 -106
  20. package/assets/skills/comet-build/SKILL.md +304 -316
  21. package/assets/skills/comet-design/SKILL.md +263 -272
  22. package/assets/skills/comet-hotfix/SKILL.md +204 -211
  23. package/assets/skills/comet-open/SKILL.md +220 -186
  24. package/assets/skills/comet-tweak/SKILL.md +180 -179
  25. package/assets/skills/comet-verify/SKILL.md +234 -240
  26. package/assets/skills-zh/comet/SKILL.md +269 -332
  27. package/assets/skills-zh/comet/reference/auto-transition.md +27 -0
  28. package/assets/skills-zh/comet/reference/comet-yaml-fields.md +71 -0
  29. package/assets/skills-zh/comet/reference/context-recovery.md +35 -0
  30. package/assets/skills-zh/comet/reference/debug-gate.md +17 -0
  31. package/assets/skills-zh/comet/reference/decision-point.md +20 -0
  32. package/assets/skills-zh/comet/reference/dirty-worktree.md +59 -59
  33. package/assets/skills-zh/comet/reference/file-structure.md +28 -0
  34. package/assets/skills-zh/comet/reference/subagent-dispatch.md +120 -0
  35. package/assets/skills-zh/comet-archive/SKILL.md +100 -106
  36. package/assets/skills-zh/comet-build/SKILL.md +317 -316
  37. package/assets/skills-zh/comet-design/SKILL.md +264 -273
  38. package/assets/skills-zh/comet-hotfix/SKILL.md +200 -207
  39. package/assets/skills-zh/comet-open/SKILL.md +220 -186
  40. package/assets/skills-zh/comet-tweak/SKILL.md +176 -175
  41. package/assets/skills-zh/comet-verify/SKILL.md +232 -238
  42. package/bin/comet.js +3 -3
  43. package/dist/cli/index.js +21 -1
  44. package/dist/cli/index.js.map +1 -1
  45. package/dist/commands/doctor.d.ts.map +1 -1
  46. package/dist/commands/doctor.js +5 -1
  47. package/dist/commands/doctor.js.map +1 -1
  48. package/dist/commands/i18n.d.ts +4 -0
  49. package/dist/commands/i18n.d.ts.map +1 -0
  50. package/dist/commands/i18n.js +154 -0
  51. package/dist/commands/i18n.js.map +1 -0
  52. package/dist/commands/init.d.ts +3 -0
  53. package/dist/commands/init.d.ts.map +1 -1
  54. package/dist/commands/init.js +127 -75
  55. package/dist/commands/init.js.map +1 -1
  56. package/dist/commands/uninstall.d.ts +9 -0
  57. package/dist/commands/uninstall.d.ts.map +1 -0
  58. package/dist/commands/uninstall.js +132 -0
  59. package/dist/commands/uninstall.js.map +1 -0
  60. package/dist/commands/update.d.ts +3 -2
  61. package/dist/commands/update.d.ts.map +1 -1
  62. package/dist/commands/update.js +105 -68
  63. package/dist/commands/update.js.map +1 -1
  64. package/dist/core/codegraph.d.ts +4 -7
  65. package/dist/core/codegraph.d.ts.map +1 -1
  66. package/dist/core/codegraph.js +63 -41
  67. package/dist/core/codegraph.js.map +1 -1
  68. package/dist/core/detect.d.ts +13 -1
  69. package/dist/core/detect.d.ts.map +1 -1
  70. package/dist/core/detect.js +68 -12
  71. package/dist/core/detect.js.map +1 -1
  72. package/dist/core/openspec.d.ts +2 -2
  73. package/dist/core/openspec.d.ts.map +1 -1
  74. package/dist/core/openspec.js +51 -22
  75. package/dist/core/openspec.js.map +1 -1
  76. package/dist/core/platforms.d.ts.map +1 -1
  77. package/dist/core/platforms.js +14 -1
  78. package/dist/core/platforms.js.map +1 -1
  79. package/dist/core/skills.d.ts +3 -1
  80. package/dist/core/skills.d.ts.map +1 -1
  81. package/dist/core/skills.js +151 -66
  82. package/dist/core/skills.js.map +1 -1
  83. package/dist/core/superpowers.d.ts +1 -1
  84. package/dist/core/superpowers.d.ts.map +1 -1
  85. package/dist/core/superpowers.js +5 -1
  86. package/dist/core/superpowers.js.map +1 -1
  87. package/dist/core/uninstall.d.ts +28 -0
  88. package/dist/core/uninstall.d.ts.map +1 -0
  89. package/dist/core/uninstall.js +421 -0
  90. package/dist/core/uninstall.js.map +1 -0
  91. package/dist/core/version.d.ts +31 -0
  92. package/dist/core/version.d.ts.map +1 -0
  93. package/dist/core/version.js +111 -0
  94. package/dist/core/version.js.map +1 -0
  95. package/dist/utils/file-system.d.ts +23 -0
  96. package/dist/utils/file-system.d.ts.map +1 -1
  97. package/dist/utils/file-system.js +100 -5
  98. package/dist/utils/file-system.js.map +1 -1
  99. package/package.json +69 -64
  100. package/scripts/postinstall.js +44 -44
@@ -1,316 +1,304 @@
1
- ---
2
- name: comet-build
3
- description: "Comet Phase 3: Plan and Build. Invoke with /comet-build. Create plans and select execution method (subagent or direct) for implementation."
4
- ---
5
-
6
- # Comet Phase 3: Plan and Build (Build)
7
-
8
- ## Prerequisites
9
-
10
- - Design Doc has been created (Phase 2 complete)
11
- - Active change exists
12
-
13
- ## Steps
14
-
15
- ### 0. Entry State Verification (Entry Check)
16
-
17
- Execute entry verification:
18
-
19
- ```bash
20
- COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
21
- if [ -z "$COMET_ENV" ]; then
22
- echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
23
- return 1
24
- fi
25
- . "$COMET_ENV"
26
- "$COMET_BASH" "$COMET_STATE" check <name> build
27
- ```
28
-
29
- Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
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 use `grep -n '\- \[ \]' tasks.md | head -1` to find the first unchecked task. Already-committed tasks must not be re-committed.
32
-
33
- ### 1. Create Plan (Subagent Offload)
34
-
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
-
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:
47
- - Save to `docs/superpowers/plans/YYYY-MM-DD-<feature>.md`
48
- - Reference design document, break down into executable tasks
49
- - **Plan file header must contain associated metadata**:
50
-
51
- ```yaml
52
- ---
53
- change: <openspec-change-name>
54
- design-doc: docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md
55
- base-ref: <git rev-parse HEAD before implementation>
56
- ---
57
- ```
58
-
59
- `base-ref` is used during verification to measure committed changes across the full implementation range. Record the current commit when creating the plan:
60
-
61
- ```bash
62
- git rev-parse HEAD
63
- ```
64
-
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
74
-
75
- Record plan path:
76
-
77
- ```bash
78
- "$COMET_BASH" "$COMET_STATE" set <name> plan docs/superpowers/plans/YYYY-MM-DD-feature.md
79
- ```
80
-
81
- No manual phase update needed — guard auto-transitions when exit conditions are met.
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
-
106
- ### 3. Select Workflow Configuration
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
-
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**:
117
-
118
- **Workspace Isolation**:
119
-
120
- | Option | Method | Description |
121
- |--------|--------|-------------|
122
- | A | Create branch | Create a new branch in the current repo, simple and fast |
123
- | B | Create Worktree | Isolated workspace, fully independent, suitable for parallel development |
124
-
125
- **Recommendation rules**:
126
- - Change involves ≤ 3 files → Recommend A
127
- - Need parallel development, current branch has uncommitted work → Recommend B
128
-
129
- **Execution Method**:
130
-
131
- | Option | Skill | Applicable Scenario |
132
- |------|------|-------------------|
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 |
135
-
136
- **Execution method recommendation rules**:
137
- - Task count ≥ 3 → Recommend A
138
- - Task count ≤ 2 and no cross-module dependencies → Recommend B
139
- - From hotfix path → Recommend B
140
-
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.
142
-
143
- After user selection, update `isolation`, execution method, and TDD mode fields:
144
-
145
- ```bash
146
- "$COMET_BASH" "$COMET_STATE" set <name> isolation <branch|worktree>
147
- ```
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
-
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.
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
-
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:
169
-
170
- ```bash
171
- "$COMET_BASH" "$COMET_STATE" set <name> direct_override true
172
- "$COMET_BASH" "$COMET_STATE" set <name> build_mode direct
173
- ```
174
-
175
- Without `direct_override: true`, `build_mode=direct` in full workflow is blocked by both guard and state transition.
176
-
177
- **Execute isolation**:
178
-
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.
180
-
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
187
-
188
- Example: if change name is `fix-login-bug` and today is 2026-06-09, recommend `feature/20260609/fix-login-bug`
189
-
190
- After the user confirms or provides a custom branch name, run `git checkout -b <branch-name>`, subsequent work on the new branch.
191
-
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:
208
- - Execute tasks according to plan
209
- - Check off the corresponding Superpowers plan task; if the task maps to OpenSpec tasks.md, also check off the corresponding OpenSpec task (`- [ ]` → `- [x]`)
210
- - Commit code after each task completion
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
-
240
- ### 4. Spec Incremental Updates
241
-
242
- When the initial spec is found incomplete during implementation, handle by scale:
243
-
244
- | Scale | Trigger Conditions | Approach |
245
- |------|-------------------|----------|
246
- | Small | Missing acceptance scenarios, edge cases | Directly edit delta spec + design.md, append tasks.md tasks |
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` |
249
-
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.
251
-
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.
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
-
258
- **Principles**:
259
- - Delta spec is a living document, can be modified at any time during this phase
260
- - Each update should be committed with commit message explaining the change reason
261
- - Do not sync to main spec in advance, sync uniformly during archiving
262
- - For small-scale incremental direct delta spec edits, note in commit message to facilitate design doc drift assessment during archiving
263
-
264
- ### 5. Context Management
265
-
266
- Build is the longest phase and may span many tasks. To support resume after context compaction:
267
-
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.
270
- - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
271
- 1. After attribution, if the diff implies plan or spec changes, handle it through Step 4 "Spec Incremental Updates"
272
- - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
273
-
274
- ## Exit Conditions
275
-
276
- - All tasks.md checked
277
- - Code committed
278
- - Project-specific build/tests explicitly run and pass; do not rely only on guard auto-detection
279
- - `isolation` has been written as `branch` or `worktree`
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`
284
-
285
- Guard reads project command configuration first:
286
-
287
- ```yaml
288
- build_command: <build command>
289
- verify_command: <verify command>
290
- ```
291
-
292
- Configuration can live in the change `.comet.yaml`, or in repo-root `.comet.yaml` / `comet.yaml` / `.comet.yml` / `comet.yml`.
293
- Only when no command is configured does guard fall back to `npm run build`, Maven, or Cargo auto-detection. When a command fails, guard prints the command output as evidence for debugging.
294
-
295
- Before exit, run guard to auto-transition:
296
-
297
- ```bash
298
- "$COMET_BASH" "$COMET_GUARD" <change-name> build --apply
299
- ```
300
-
301
- State file is automatically updated to `phase: verify`, `verify_result: pending`.
302
-
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.
306
-
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
- ```
312
-
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
1
+ ---
2
+ name: comet-build
3
+ description: "Comet Phase 3: Plan and Build. Invoke with /comet-build. Create plans and select execution method (subagent or direct) for implementation."
4
+ ---
5
+
6
+ # Comet Phase 3: Plan and Build (Build)
7
+
8
+ ## Prerequisites
9
+
10
+ - Design Doc has been created (Phase 2 complete)
11
+ - Active change exists
12
+
13
+ ## Steps
14
+
15
+ ### 0. Entry State Verification (Entry Check)
16
+
17
+ Execute entry verification:
18
+
19
+ ```bash
20
+ COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
21
+ if [ -z "$COMET_ENV" ]; then
22
+ echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
23
+ return 1
24
+ fi
25
+ . "$COMET_ENV"
26
+ "$COMET_BASH" "$COMET_STATE" check <name> build
27
+ ```
28
+
29
+ Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
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 use `grep -n '\- \[ \]' tasks.md | head -1` to find the first unchecked task. Already-committed tasks must not be re-committed.
32
+
33
+ ### 1. Create Plan (Subagent Offload)
34
+
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
+
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:
47
+ - Save to `docs/superpowers/plans/YYYY-MM-DD-<feature>.md`
48
+ - Reference design document, break down into executable tasks
49
+ - **Plan file header must contain associated metadata**:
50
+
51
+ ```yaml
52
+ ---
53
+ change: <openspec-change-name>
54
+ design-doc: docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md
55
+ base-ref: <git rev-parse HEAD before implementation>
56
+ ---
57
+ ```
58
+
59
+ `base-ref` is used during verification to measure committed changes across the full implementation range. Record the current commit when creating the plan:
60
+
61
+ ```bash
62
+ git rev-parse HEAD
63
+ ```
64
+
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
74
+
75
+ Record plan path:
76
+
77
+ ```bash
78
+ "$COMET_BASH" "$COMET_STATE" set <name> plan docs/superpowers/plans/YYYY-MM-DD-feature.md
79
+ ```
80
+
81
+ No manual phase update needed — guard auto-transitions when exit conditions are met.
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 follow the `comet/reference/decision-point.md` protocol to pause and wait for the user to explicitly choose**. Must not auto-continue and must not write the pause into `build_mode`.
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
+
106
+ ### 3. Select Workflow Configuration
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
+
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**:
117
+
118
+ **Workspace Isolation**:
119
+
120
+ | Option | Method | Description |
121
+ |--------|--------|-------------|
122
+ | A | Create branch | Create a new branch in the current repo, simple and fast |
123
+ | B | Create Worktree | Isolated workspace, fully independent, suitable for parallel development |
124
+
125
+ **Recommendation rules**:
126
+ - Change involves ≤ 3 files → Recommend A
127
+ - Need parallel development, current branch has uncommitted work → Recommend B
128
+
129
+ **Execution Method**:
130
+
131
+ | Option | Skill | Applicable Scenario |
132
+ |------|------|-------------------|
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 |
135
+
136
+ **Execution method recommendation rules**:
137
+ - Task count ≥ 3 → Recommend A
138
+ - Task count ≤ 2 and no cross-module dependencies → Recommend B
139
+ - From hotfix path → Recommend B
140
+
141
+ This is a user decision point. **Must follow the `comet/reference/decision-point.md` protocol 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.
142
+
143
+ After user selection, update `isolation`, execution method, and TDD mode fields:
144
+
145
+ ```bash
146
+ "$COMET_BASH" "$COMET_STATE" set <name> isolation <branch|worktree>
147
+ ```
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
+
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.
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
+
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:
169
+
170
+ ```bash
171
+ "$COMET_BASH" "$COMET_STATE" set <name> direct_override true
172
+ "$COMET_BASH" "$COMET_STATE" set <name> build_mode direct
173
+ ```
174
+
175
+ Without `direct_override: true`, `build_mode=direct` in full workflow is blocked by both guard and state transition.
176
+
177
+ **Execute isolation**:
178
+
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.
180
+
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
187
+
188
+ Example: if change name is `fix-login-bug` and today is 2026-06-09, recommend `feature/20260609/fix-login-bug`
189
+
190
+ After the user confirms or provides a custom branch name, run `git checkout -b <branch-name>`, subsequent work on the new branch.
191
+
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 session only coordinates and must not write implementation code directly. **Immediately execute:** Use the Skill tool to load the Superpowers `subagent-driven-development` skill. After the skill loads, read `comet/reference/subagent-dispatch.md` for Comet-specific extensions (real background dispatch, task isolation, checkoff verification, TDD constraints, continuous execution, context recovery) and apply them alongside the skill's workflow. If they conflict, the more specific Comet extensions take precedence.
205
+ - If the current platform has no real background 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
+ **TDD Mode Execution Constraints**:
208
+
209
+ If `tdd_mode: tdd`:
210
+ - `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.
211
+ - `build_mode: subagent-driven-development`: The main session does not load the TDD skill. TDD constraints and evidence thresholds are defined in `comet/reference/subagent-dispatch.md`; every background implementer and fix agent must use the Skill tool to load the Superpowers `test-driven-development` skill and follow the Comet-injected TDD hard constraint.
212
+
213
+ If `tdd_mode: direct`: Follow normal flow, no enforced TDD.
214
+
215
+ **`executing-plans` review gate**:
216
+
217
+ 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.
218
+
219
+ Requirements:
220
+ - the `requesting-code-review` skill must be loaded before `"$COMET_BASH" "$COMET_GUARD" <change-name> build --apply`
221
+ - 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
222
+ - CRITICAL review findings (security vulnerabilities, data loss risk, build/test failures) must be fixed first and must not be carried into verify
223
+ - 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
224
+
225
+ ### 3b. In-Execution Debugging (Debug Gate)
226
+
227
+ 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.
228
+
229
+ For specific investigation, minimal failing test, fix verification, and keeping the current change verification loop, follow `comet/reference/debug-gate.md`.
230
+
231
+ ### 4. Spec Incremental Updates
232
+
233
+ When the initial spec is found incomplete during implementation, handle by scale:
234
+
235
+ | Scale | Trigger Conditions | Approach |
236
+ |------|-------------------|----------|
237
+ | Small | Missing acceptance scenarios, edge cases | Directly edit delta spec + design.md, append tasks.md tasks |
238
+ | 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 |
239
+ | 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` |
240
+
241
+ **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 follow the `comet/reference/decision-point.md` protocol to pause and wait for the user to decide whether to split into a new change**.
242
+
243
+ 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.
244
+
245
+ **User choices must include**:
246
+ - "Split into new change" create independent change via `/comet-open`
247
+ - "Continue in current change" record scope-expansion decision, update tasks.md and delta spec, then continue
248
+
249
+ **Principles**:
250
+ - Delta spec is a living document, can be modified at any time during this phase
251
+ - Each update should be committed with commit message explaining the change reason
252
+ - Do not sync to main spec in advance, sync uniformly during archiving
253
+ - For small-scale incremental direct delta spec edits, note in commit message to facilitate design doc drift assessment during archiving
254
+
255
+ ### 5. Context Management
256
+
257
+ Build is the longest phase and may span many tasks. To support resume after context compaction:
258
+
259
+ - **After each task**: complete acceptance per the current execution branch before checking off and committing. `subagent-driven-development` must wait for both reviews to pass and perform targeted verification by unique task text. Use `grep -c '\- \[ \]' tasks.md` to check remaining unchecked count; no need to re-read the entire file
260
+ - **Context compression recovery**: Follow `comet/reference/context-recovery.md` with phase set to `build`.
261
+ - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
262
+ 1. After attribution, if the diff implies plan or spec changes, handle it through Step 4 "Spec Incremental Updates"
263
+ - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
264
+
265
+ ## Exit Conditions
266
+
267
+ - All tasks.md checked
268
+ - Code committed
269
+ - Project-specific build/tests explicitly run and pass; do not rely only on guard auto-detection
270
+ - `isolation` has been written as `branch` or `worktree`
271
+ - `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`
272
+ - `tdd_mode` has been written as `tdd` or `direct`
273
+ - 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
274
+ - **Phase guard**: Run `"$COMET_BASH" "$COMET_GUARD" <change-name> build --apply`; after all PASS, state advances to `phase: verify`
275
+
276
+ Guard reads project command configuration first:
277
+
278
+ ```yaml
279
+ build_command: <build command>
280
+ verify_command: <verify command>
281
+ ```
282
+
283
+ Configuration can live in the change `.comet.yaml`, or in repo-root `.comet.yaml` / `comet.yaml` / `.comet.yml` / `comet.yml`.
284
+ Only when no command is configured does guard fall back to `npm run build`, Maven, or Cargo auto-detection. When a command fails, guard prints the command output as evidence for debugging.
285
+
286
+ Before exit, run guard to auto-transition:
287
+
288
+ ```bash
289
+ "$COMET_BASH" "$COMET_GUARD" <change-name> build --apply
290
+ ```
291
+
292
+ State file is automatically updated to `phase: verify`, `verify_result: pending`.
293
+
294
+ ## Automatic Handoff to Next Phase
295
+
296
+ Follow `comet/reference/auto-transition.md`. Key command:
297
+
298
+ ```bash
299
+ "$COMET_BASH" "$COMET_STATE" next <change-name>
300
+ ```
301
+
302
+ - `NEXT: auto` → invoke the skill pointed to by `SKILL` to enter the next phase
303
+ - `NEXT: manual` → do not invoke the next skill; prompt user to run `/<SKILL>` manually
304
+ - `NEXT: done` → workflow is complete, no further action needed