@rpamis/comet 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,13 +28,13 @@
28
28
  ```
29
29
 
30
30
  > 中文版:[README-zh.md](README-zh.md)
31
- > [B站视频介绍](https://www.bilibili.com/video/BV1y4Gi6CEo1/?spm_id_from=333.1387.homepage.video_card.click&vd_source=d22726fe6b108647dbebf1c5d8817377)
31
+ > [Bilibili video](https://www.bilibili.com/video/BV1y4Gi6CEo1/?spm_id_from=333.1387.homepage.video_card.click&vd_source=d22726fe6b108647dbebf1c5d8817377)
32
32
 
33
33
  **OpenSpec + Superpowers dual-star development workflow** — one command from idea to archive.
34
34
 
35
- OpenSpec handles **WHAT** (outlines, proposals, spec lifecycle, archiving).
35
+ OpenSpec handles **WHAT** (outlines, proposals, spec lifecycle, archiving).
36
36
 
37
- Superpowers handles **HOW** (technical design, planning, execution, wrap-up).
37
+ Superpowers handles **HOW** (technical design, planning, execution, wrap-up).
38
38
 
39
39
  Comet chains both into a five-phase automated pipeline.
40
40
 
@@ -46,7 +46,7 @@ Superpowers generates Spec documents after brainstorming, but these documents ty
46
46
 
47
47
  **Comet combines the strengths of both**, integrating the core workflow into 5 phases
48
48
 
49
- The main entry `/comet` supports current Spec state detection, suitable for long tasks — after completing and closing CC midway, just `/comet continue` and Comet will automatically read the active Spec (lists multiple for selection), dynamically identify which phase is currently executing, and continue.
49
+ The main entry `/comet` supports current Spec state detection, suitable for long tasks — after closing your AI coding session midway, just `/comet` and Comet will automatically read the active Spec (lists multiple for selection), dynamically identify which phase is currently executing, and continue.
50
50
 
51
51
  At the same time, Comet provides full Spec lifecycle management. During execution, it links OpenSpec change/spec artifacts with Superpowers design and planning documents, then automates handoff, state updates, validation, and archive sync so users do not have to repeatedly remind the Agent to keep documents synchronized and connected.
52
52
 
@@ -72,6 +72,13 @@ Long-term Skill users know these capabilities can be freely combined, but exactl
72
72
 
73
73
  ## Install
74
74
 
75
+ Requirements:
76
+
77
+ - Node.js 20+
78
+ - npm/npx
79
+ - Git
80
+ - Bash-compatible shell for workflow scripts (Windows users should use Git Bash or an equivalent bash environment)
81
+
75
82
  ```bash
76
83
  npm install -g @rpamis/comet
77
84
  ```
@@ -100,6 +107,8 @@ comet init
100
107
 
101
108
  ## Support for OpenClaw and Hermes, and other AI platforms
102
109
 
110
+ For platforms that use the generic `skills` CLI directly, you can install the Comet skill package with:
111
+
103
112
  ```bash
104
113
  npx skills add rpamis/comet
105
114
  ```
@@ -120,13 +129,13 @@ npx skills add rpamis/comet
120
129
 
121
130
  Initializes OpenSpec, Superpowers, and Comet skills for selected AI coding platforms.
122
131
 
123
- | Option | Description |
124
- |--------|-------------|
125
- | `--yes` | Non-interactive mode, auto-select detected platforms (or all if none detected) |
126
- | `--scope <scope>` | Install scope: `project` or `global` |
127
- | `--skip-existing` | Skip already installed components |
128
- | `--overwrite` | Overwrite already installed components |
129
- | `--json` | Output structured JSON |
132
+ | Option | Description |
133
+ | ----------------- | ------------------------------------------------------------------------------ |
134
+ | `--yes` | Non-interactive mode, auto-select detected platforms (or all if none detected) |
135
+ | `--scope <scope>` | Install scope: `project` or `global` |
136
+ | `--skip-existing` | Skip already installed components |
137
+ | `--overwrite` | Overwrite already installed components |
138
+ | `--json` | Output structured JSON |
130
139
 
131
140
  When multiple existing components are found on the same platform, interactive init offers one bulk choice: overwrite all, skip all, or choose per component.
132
141
 
@@ -137,8 +146,8 @@ When multiple existing components are found on the same platform, interactive in
137
146
 
138
147
  Displays active changes, task progress, and the recommended next Comet workflow command.
139
148
 
140
- | Option | Description |
141
- |--------|-------------|
149
+ | Option | Description |
150
+ | -------- | ---------------------------------------- |
142
151
  | `--json` | Output active changes with `nextCommand` |
143
152
 
144
153
  </details>
@@ -148,9 +157,9 @@ Displays active changes, task progress, and the recommended next Comet workflow
148
157
 
149
158
  Checks project/global installation health, working directories, installed skills, scripts, and Comet state files.
150
159
 
151
- | Option | Description |
152
- |--------|-------------|
153
- | `--json` | Output structured diagnostic results |
160
+ | Option | Description |
161
+ | ----------------- | --------------------------------------------------------------- |
162
+ | `--json` | Output structured diagnostic results |
154
163
  | `--scope <scope>` | Diagnose `auto`, `project`, or `global` scope (default: `auto`) |
155
164
 
156
165
  </details>
@@ -160,17 +169,17 @@ Checks project/global installation health, working directories, installed skills
160
169
 
161
170
  Updates the npm package and refreshes installed Comet skills in detected project/global targets.
162
171
 
163
- | Option | Description |
164
- |--------|-------------|
165
- | `--json` | Output npm and skill update results as JSON |
172
+ | Option | Description |
173
+ | ------------------- | --------------------------------------------- |
174
+ | `--json` | Output npm and skill update results as JSON |
166
175
  | `--language <lang>` | Override detected skill language (`en`, `zh`) |
167
- | `--scope <scope>` | Update only `global` or `project` scope |
176
+ | `--scope <scope>` | Update only `global` or `project` scope |
168
177
 
169
178
  </details>
170
179
 
171
- | Command | Description |
172
- |---------|-------------|
173
- | `comet --help` | Show help |
180
+ | Command | Description |
181
+ | ----------------- | ------------ |
182
+ | `comet --help` | Show help |
174
183
  | `comet --version` | Show version |
175
184
 
176
185
  ## Supported Platforms
@@ -180,25 +189,27 @@ Updates the npm package and refreshes installed Comet skills in detected project
180
189
  <details>
181
190
  <summary>View full platform list</summary>
182
191
 
183
- | Platform | Skills Dir | Platform | Skills Dir |
184
- |----------|-----------|----------|-----------|
185
- | Claude Code | `.claude/` | Cursor | `.cursor/` |
186
- | Codex | `.codex/` | OpenCode | `.opencode/` |
187
- | Windsurf | `.windsurf/` | Cline | `.cline/` |
188
- | RooCode | `.roo/` | Continue | `.continue/` |
189
- | GitHub Copilot | `.github/` | Gemini CLI | `.gemini/` |
190
- | Amazon Q Developer | `.amazonq/` | Qwen Code | `.qwen/` |
191
- | Kilo Code | `.kilocode/` | Auggie | `.augment/` |
192
- | Kiro | `.kiro/` | Lingma | `.lingma/` |
193
- | Junie | `.junie/` | CodeBuddy | `.codebuddy/` |
194
- | CoStrict | `.cospec/` | Crush | `.crush/` |
195
- | Factory Droid | `.factory/` | iFlow | `.iflow/` |
196
- | Pi | `.pi/` | Qoder | `.qoder/` |
197
- | Antigravity | `.agents/` | Bob Shell | `.bob/` |
198
- | ForgeCode | `.forge/` | Trae | `.trae/` |
192
+ | Platform | Skills Dir | Platform | Skills Dir |
193
+ | ------------------ | ------------ | ---------- | ------------- |
194
+ | Claude Code | `.claude/` | Cursor | `.cursor/` |
195
+ | Codex | `.codex/` | OpenCode | `.opencode/` |
196
+ | Windsurf | `.windsurf/` | Cline | `.cline/` |
197
+ | RooCode | `.roo/` | Continue | `.continue/` |
198
+ | GitHub Copilot | `.github/` | Gemini CLI | `.gemini/` |
199
+ | Amazon Q Developer | `.amazonq/` | Qwen Code | `.qwen/` |
200
+ | Kilo Code | `.kilocode/` | Auggie | `.augment/` |
201
+ | Kiro | `.kiro/` | Lingma | `.lingma/` |
202
+ | Junie | `.junie/` | CodeBuddy | `.codebuddy/` |
203
+ | CoStrict | `.cospec/` | Crush | `.crush/` |
204
+ | Factory Droid | `.factory/` | iFlow | `.iflow/` |
205
+ | Pi | `.pi/` | Qoder | `.qoder/` |
206
+ | Antigravity | `.agents/` | Bob Shell | `.bob/` |
207
+ | ForgeCode | `.forge/` | Trae | `.trae/` |
199
208
 
200
209
  </details>
201
210
 
211
+ Some platforms use different project and global directories. For example, OpenCode global installs use `.config/opencode`, Lingma global installs use `.lingma`, and Antigravity global installs use `.gemini/antigravity`.
212
+
202
213
  ## Skills
203
214
 
204
215
  After `comet init`, three groups of skills are installed to the selected platform's `skills/` directory:
@@ -208,16 +219,16 @@ After `comet init`, three groups of skills are installed to the selected platfor
208
219
  <details>
209
220
  <summary>View Comet skills</summary>
210
221
 
211
- | Skill | Description |
212
- |-------|-------------|
213
- | `/comet` | Main entry — auto-detects phase and dispatches to sub-commands |
214
- | `/comet-open` | Phase 1: Open a change (proposal, design, task breakdown) |
215
- | `/comet-design` | Phase 2: Deep design (brainstorming, Design Doc) |
216
- | `/comet-build` | Phase 3: Plan and build (implementation plan, code commits) |
217
- | `/comet-verify` | Phase 4: Verify and finish (testing, verification report) |
218
- | `/comet-archive` | Phase 5: Archive (delta spec sync, status annotation) |
219
- | `/comet-hotfix` | Preset: Quick bug fix (skips brainstorming) |
220
- | `/comet-tweak` | Preset: Small change (skips brainstorming and full plan) |
222
+ | Skill | Description |
223
+ | ---------------- | -------------------------------------------------------------- |
224
+ | `/comet` | Main entry — auto-detects phase and dispatches to sub-commands |
225
+ | `/comet-open` | Phase 1: Open a change (proposal, design, task breakdown) |
226
+ | `/comet-design` | Phase 2: Deep design (brainstorming, Design Doc) |
227
+ | `/comet-build` | Phase 3: Plan and build (implementation plan, code commits) |
228
+ | `/comet-verify` | Phase 4: Verify and finish (testing, verification report) |
229
+ | `/comet-archive` | Phase 5: Archive (delta spec sync, status annotation) |
230
+ | `/comet-hotfix` | Preset: Quick bug fix (skips brainstorming) |
231
+ | `/comet-tweak` | Preset: Small change (skips brainstorming and full plan) |
221
232
 
222
233
  </details>
223
234
 
@@ -226,13 +237,14 @@ After `comet init`, three groups of skills are installed to the selected platfor
226
237
  <details>
227
238
  <summary>View script list</summary>
228
239
 
229
- | Script | Purpose |
230
- |--------|---------|
231
- | `comet-guard.sh` | Phase transition guardvalidates exit conditions, `--apply` auto-updates `.comet.yaml` |
232
- | `comet-handoff.sh` | Design handoffgenerates deterministic context packages from OpenSpec artifacts with SHA256 tracing |
233
- | `comet-archive.sh` | One-command archivevalidates state, syncs specs, moves to archive, updates status |
234
- | `comet-yaml-validate.sh` | Schema validator — validates `.comet.yaml` structure and field values |
235
- | `comet-state.sh` | Unified state management init/set/get/check/scale, agents' exclusive YAML interface |
240
+ | Script | Purpose |
241
+ | ------------------------ | ----------------------------------------------------------------------------------------------------- |
242
+ | `comet-env.sh` | Script discovery helperexports bundled script paths such as `COMET_GUARD`, `COMET_STATE`, `COMET_HANDOFF`, and `COMET_ARCHIVE` |
243
+ | `comet-guard.sh` | Phase transition guard validates exit conditions, `--apply` auto-updates `.comet.yaml` |
244
+ | `comet-handoff.sh` | Design handoffgenerates deterministic context packages from OpenSpec artifacts with SHA256 tracing |
245
+ | `comet-archive.sh` | One-command archive — validates state, syncs specs, moves to archive, updates status |
246
+ | `comet-yaml-validate.sh` | Schema validatorvalidates `.comet.yaml` structure and field values |
247
+ | `comet-state.sh` | Unified state management — init/set/get/check/scale, agents' exclusive YAML interface |
236
248
 
237
249
  </details>
238
250
 
@@ -261,13 +273,13 @@ Development methodology: brainstorming, TDD, subagent-driven development, code r
261
273
 
262
274
  ### Five Phases
263
275
 
264
- | Phase | Command | Owner | Artifacts |
265
- |-------|---------|-------|-----------|
266
- | 1. Open | `/comet-open` | OpenSpec | proposal.md, design.md, tasks.md |
267
- | 2. Deep Design | `/comet-design` | Superpowers | Design Doc, delta spec |
268
- | 3. Plan & Build | `/comet-build` | Superpowers | Implementation plan, code commits |
269
- | 4. Verify & Finish | `/comet-verify` | Both | Verification report, branch handling |
270
- | 5. Archive | `/comet-archive` | OpenSpec | delta→main spec sync, archive |
276
+ | Phase | Command | Owner | Artifacts |
277
+ | ------------------ | ---------------- | ----------- | ------------------------------------ |
278
+ | 1. Open | `/comet-open` | OpenSpec | proposal.md, design.md, tasks.md |
279
+ | 2. Deep Design | `/comet-design` | Superpowers | Design Doc, delta spec |
280
+ | 3. Plan & Build | `/comet-build` | Superpowers | Implementation plan, code commits |
281
+ | 4. Verify & Finish | `/comet-verify` | Both | Verification report, branch handling |
282
+ | 5. Archive | `/comet-archive` | OpenSpec | delta→main spec sync, archive |
271
283
 
272
284
  ### Core Principles
273
285
 
@@ -281,10 +293,10 @@ Development methodology: brainstorming, TDD, subagent-driven development, code r
281
293
 
282
294
  Comet uses a decoupled state architecture with separate YAML files:
283
295
 
284
- | File | Owner | Purpose |
285
- |------|-------|---------|
286
- | `.openspec.yaml` | OpenSpec | Spec lifecycle, change metadata |
287
- | `.comet.yaml` | Comet | Workflow phase, execution mode, verification status |
296
+ | File | Owner | Purpose |
297
+ | ---------------- | -------- | --------------------------------------------------- |
298
+ | `.openspec.yaml` | OpenSpec | Spec lifecycle, change metadata |
299
+ | `.comet.yaml` | Comet | Workflow phase, execution mode, verification status |
288
300
 
289
301
  All states and execution phases are updated via scripts, and each phase verifies that tasks are truly complete before advancing. Compared to storing complex state rules only in Skill text, this script-backed state machine gives Comet more reliable phase transitions, correct YAML, and easier breakpoint recovery; agents can read the current Spec situation through Comet's built-in commands.
290
302
 
@@ -367,6 +379,7 @@ your-project/
367
379
  │ ├── comet/SKILL.md
368
380
  │ │ └── scripts/
369
381
  │ │ ├── comet-guard.sh # Phase transition guard (--apply auto-updates state)
382
+ │ │ ├── comet-env.sh # Script discovery helper
370
383
  │ │ ├── comet-handoff.sh # Design handoff (OpenSpec → Superpowers context tracing)
371
384
  │ │ ├── comet-archive.sh # One-command archive automation
372
385
  │ │ ├── comet-yaml-validate.sh # Schema validator
@@ -403,9 +416,16 @@ Track our development progress and upcoming features on the [Comet Roadmap](http
403
416
 
404
417
  [![Star History Chart](https://api.star-history.com/svg?repos=rpamis/comet&type=Date)](https://star-history.com/#rpamis/comet&Date)
405
418
 
419
+ ## Contributors
420
+
421
+ <a href="https://github.com/rpamis/comet/graphs/contributors">
422
+ <img src="https://contrib.rocks/image?repo=rpamis/comet&max=999&columns=12&anon=1" />
423
+ </a>
424
+
406
425
  ## License
407
426
 
408
- [MIT](LICENSE.md)
427
+ [MIT](LICENSE)
409
428
 
410
429
  ## Reference
430
+
411
431
  [LINUX DO - 新的理想型社区](https://linux.do/)
@@ -103,19 +103,30 @@ A single `/comet` invocation starts from the detected phase and advances to the
103
103
 
104
104
  Flow chain: open → design → build → verify → archive
105
105
 
106
- **Continuous execution requirement**: starting from the detected phase, the agent must automatically continue through all later phases. Auto-advancing only applies at transition points without user decisions. When encountering user decision points, must pause and wait for the user's explicit response. Must not use recommendation rules, defaults, or historical preferences to substitute for user confirmation.
106
+ **Continuous execution requirement**: starting from the detected phase, the agent automatically continues through all later phases. But **auto-advancing only applies at transition points without user decisions**. When encountering user decision points, **must use the AskUserQuestion tool to pause and wait for the user's explicit response**. Must not use recommendation rules, defaults, or historical preferences to substitute for user confirmation, and must not just output a text prompt and then continue executing.
107
107
 
108
- **Decision points are blocking points**: whenever reaching any of the following nodes, the current `/comet` invocation must stop. Only after the user explicitly chooses can the corresponding state fields be written and operations executed, then auto-advance resumes.
108
+ **Decision points are blocking points**: whenever reaching any of the following nodes, the current `/comet` invocation must stop, **using the AskUserQuestion tool to wait for the user's choice**. Only after the user explicitly chooses can the corresponding state fields be written and operations executed, then auto-advance resumes.
109
109
 
110
110
  Nodes requiring user participation (pause only at these nodes):
111
- 1. Confirm design approach during brainstorming
112
- 2. Select workflow configuration during build phase (isolation + execution method, single interaction)
113
- 3. Decide to fix or accept deviation when verify fails (including Spec drift handling)
114
- 4. Choose branch handling method for finishing-branch
115
- 5. Encounter upgrade conditions (hotfix/tweak full workflow)
116
- 6. Build phase scope expansion requiring redesign or new change split
117
-
118
- Agents should not skip these decision points; other unambiguous phase transitions must proceed automatically, must not exit midway.
111
+ 1. Open phase proposal/design/tasks review and confirmation
112
+ 2. Confirm design approach during brainstorming
113
+ 3. Select workflow configuration during build phase (isolation + execution method, single interaction)
114
+ 4. Decide to fix or accept deviation when verify fails (including Spec drift handling)
115
+ 5. Choose branch handling method for finishing-branch
116
+ 6. Encounter upgrade conditions (hotfix/tweak full workflow)
117
+ 7. Build phase scope expansion requiring redesign or new change split
118
+
119
+ Agents should not skip these decision points; other unambiguous phase transitions must proceed automatically, must not exit midway. At decision points, **text output must NOT substitute for tool-based waiting — must explicitly obtain the user's choice via AskUserQuestion before continuing**.
120
+
121
+ **Red Flags** — when these thoughts appear, STOP and check:
122
+
123
+ | Agent Thought | Actual Risk |
124
+ |--------------|-------------|
125
+ | "The user would probably agree with this approach" | Cannot decide for the user — use AskUserQuestion |
126
+ | "This is a small change, confirmation isn't needed" | Decision points have no size exception — blocking points must wait |
127
+ | "The user chose A last time, so A again" | Historical preference cannot substitute for current confirmation |
128
+ | "I explained the plan and the user didn't object" | No objection ≠ consent — must use tool to get explicit choice |
129
+ | "The flow has reached this point, should be fine" | Verification not passed ≠ passed — check verify_result |
119
130
  </IMPORTANT>
120
131
 
121
132
  ---
@@ -8,6 +8,7 @@
8
8
  # set <change-name> <field> <val> — Update a field value
9
9
  # transition <change-name> <event> — Apply a validated state transition
10
10
  # check <change-name> <phase> — Verify entry requirements for a phase
11
+ # check <change-name> <phase> --recover — Output structured recovery context for compaction resume
11
12
  # scale <change-name> — Assess and set verification mode based on metrics
12
13
  #
13
14
  # Workflows: full, hotfix, tweak
@@ -589,6 +590,169 @@ cmd_check() {
589
590
  fi
590
591
  }
591
592
 
593
+ # --- Recovery context for compaction resume ---
594
+
595
+ field_status() {
596
+ # Args: field_name value [file_path]
597
+ # Prints: "field_name: DONE (value)" or "field_name: PENDING"
598
+ local field="$1"
599
+ local value="$2"
600
+ local file_path="${3:-}"
601
+
602
+ if [ -z "$value" ] || [ "$value" = "null" ]; then
603
+ echo " - ${field}: PENDING"
604
+ elif [ -n "$file_path" ] && [ ! -f "$file_path" ]; then
605
+ echo " - ${field}: BROKEN (path ${value} does not exist)"
606
+ else
607
+ echo " - ${field}: DONE (${value})"
608
+ fi
609
+ }
610
+
611
+ cmd_recover() {
612
+ local change_name="$1"
613
+
614
+ validate_change_name "$change_name"
615
+
616
+ local change_dir="openspec/changes/$change_name"
617
+ local yaml_file="$change_dir/.comet.yaml"
618
+
619
+ if [ ! -f "$yaml_file" ]; then
620
+ red "ERROR: .comet.yaml not found at $yaml_file"
621
+ exit 1
622
+ fi
623
+
624
+ local phase workflow
625
+ phase=$(cmd_get "$change_name" "phase")
626
+ workflow=$(cmd_get "$change_name" "workflow")
627
+
628
+ echo "=== Recovery Context: ${change_name} ==="
629
+ echo "Phase: ${phase}"
630
+ echo "Workflow: ${workflow}"
631
+ echo ""
632
+
633
+ # Read all relevant fields
634
+ local design_doc plan verify_result verify_mode verification_report
635
+ local branch_status handoff_context handoff_hash isolation build_mode direct_override
636
+ design_doc=$(cmd_get "$change_name" "design_doc")
637
+ plan=$(cmd_get "$change_name" "plan")
638
+ verify_result=$(cmd_get "$change_name" "verify_result")
639
+ verify_mode=$(cmd_get "$change_name" "verify_mode")
640
+ verification_report=$(cmd_get "$change_name" "verification_report")
641
+ branch_status=$(cmd_get "$change_name" "branch_status")
642
+ handoff_context=$(cmd_get "$change_name" "handoff_context")
643
+ handoff_hash=$(cmd_get "$change_name" "handoff_hash")
644
+ isolation=$(cmd_get "$change_name" "isolation")
645
+ build_mode=$(cmd_get "$change_name" "build_mode")
646
+ direct_override=$(cmd_get "$change_name" "direct_override" 2>/dev/null || true)
647
+
648
+ echo "State fields:"
649
+
650
+ # Phase-specific field reporting
651
+ case "$phase" in
652
+ open)
653
+ echo " Artifacts:"
654
+ for f in proposal.md design.md tasks.md; do
655
+ if file_nonempty "$change_dir/$f"; then
656
+ echo " - ${f}: DONE"
657
+ else
658
+ echo " - ${f}: PENDING"
659
+ fi
660
+ done
661
+ echo ""
662
+ echo "Recovery action: Create or complete missing artifacts, then use AskUserQuestion for user confirmation."
663
+ ;;
664
+ design)
665
+ echo " Artifacts:"
666
+ for f in proposal.md design.md tasks.md; do
667
+ if file_nonempty "$change_dir/$f"; then
668
+ echo " - ${f}: DONE"
669
+ else
670
+ echo " - ${f}: MISSING (unexpected in design phase)"
671
+ fi
672
+ done
673
+ echo ""
674
+ echo " Design progress:"
675
+ field_status "handoff_context" "$handoff_context" "$handoff_context"
676
+ field_status "handoff_hash" "$handoff_hash"
677
+ field_status "design_doc" "$design_doc" "$design_doc"
678
+ echo ""
679
+ if [ -n "$design_doc" ] && [ "$design_doc" != "null" ] && [ -f "$design_doc" ]; then
680
+ echo "Recovery action: Design Doc already created and linked. Run guard to transition to build."
681
+ elif [ -n "$handoff_context" ] && [ "$handoff_context" != "null" ] && [ -f "$handoff_context" ]; then
682
+ echo "Recovery action: Handoff generated but Design Doc not yet created. Resume from brainstorming confirmation (Step 1c)."
683
+ else
684
+ echo "Recovery action: No handoff generated yet. Start from Step 1a (generate handoff package)."
685
+ fi
686
+ ;;
687
+ build)
688
+ echo " Build decisions:"
689
+ field_status "isolation" "$isolation"
690
+ field_status "build_mode" "$build_mode"
691
+ if [ "$build_mode" = "direct" ] && [ "$workflow" != "hotfix" ] && [ "$workflow" != "tweak" ]; then
692
+ field_status "direct_override" "$direct_override"
693
+ fi
694
+ echo ""
695
+ echo " Plan:"
696
+ field_status "plan" "$plan" "$plan"
697
+ echo ""
698
+ # Count completed vs pending tasks
699
+ local tasks_file="$change_dir/tasks.md"
700
+ local total=0 done=0 pending=0
701
+ if [ -f "$tasks_file" ]; then
702
+ total=$(grep -c '^\- \[' "$tasks_file" 2>/dev/null || echo "0")
703
+ done=$(grep -c '^\- \[x\]' "$tasks_file" 2>/dev/null || echo "0")
704
+ pending=$((total - done))
705
+ echo " Tasks: ${done}/${total} done, ${pending} pending"
706
+ else
707
+ echo " Tasks: tasks.md MISSING"
708
+ fi
709
+ echo ""
710
+ if [ "$isolation" = "null" ] || [ -z "$isolation" ]; then
711
+ echo "Recovery action: Isolation not selected. Use AskUserQuestion to ask user for branch/worktree choice."
712
+ elif [ "$build_mode" = "null" ] || [ -z "$build_mode" ]; then
713
+ echo "Recovery action: Build mode not selected. Use AskUserQuestion to ask user for execution method."
714
+ elif [ ! -f "$tasks_file" ]; then
715
+ echo "Recovery action: tasks.md missing. Verify change directory integrity."
716
+ elif [ "$pending" -gt 0 ]; then
717
+ echo "Recovery action: Read tasks.md and continue from first unchecked task."
718
+ else
719
+ echo "Recovery action: All tasks done. Run guard to transition to verify."
720
+ fi
721
+ ;;
722
+ verify)
723
+ echo " Verification:"
724
+ field_status "verify_result" "$verify_result"
725
+ field_status "verify_mode" "$verify_mode"
726
+ field_status "verification_report" "$verification_report" "$verification_report"
727
+ field_status "branch_status" "$branch_status"
728
+ echo ""
729
+ if [ "$verify_result" = "pass" ] && [ "$branch_status" = "handled" ]; then
730
+ echo "Recovery action: Verification complete. Run guard to transition to archive."
731
+ elif [ "$verify_result" = "pass" ]; then
732
+ echo "Recovery action: Verification passed but branch not yet handled. Complete branch handling and set branch_status to handled."
733
+ elif [ "$verify_result" = "fail" ]; then
734
+ echo "Recovery action: Verification failed and rolled back to build. Resume from /comet-build."
735
+ else
736
+ echo "Recovery action: Verification not yet started or in progress. Run scale assessment then verify."
737
+ fi
738
+ ;;
739
+ archive)
740
+ echo " Archive:"
741
+ field_status "verify_result" "$verify_result"
742
+ field_status "archived" "$(cmd_get "$change_name" "archived")"
743
+ echo ""
744
+ echo "Recovery action: Run /comet-archive to complete archiving."
745
+ ;;
746
+ *)
747
+ red "ERROR: Unknown phase: $phase"
748
+ exit 1
749
+ ;;
750
+ esac
751
+
752
+ echo ""
753
+ echo "=== End Recovery Context ==="
754
+ }
755
+
592
756
  cmd_scale() {
593
757
  local change_name="$1"
594
758
 
@@ -694,11 +858,16 @@ case "$SUBCOMMAND" in
694
858
  ;;
695
859
  check)
696
860
  if [ $# -lt 2 ]; then
697
- red "Usage: comet-state.sh check <change-name> <phase>" >&2
861
+ red "Usage: comet-state.sh check <change-name> <phase> [--recover]" >&2
698
862
  red "Phases: open, design, build, verify, archive" >&2
699
863
  exit 1
700
864
  fi
701
- cmd_check "$@"
865
+ # Detect --recover flag (3rd argument)
866
+ if [ "${3:-}" = "--recover" ]; then
867
+ cmd_recover "$1"
868
+ else
869
+ cmd_check "$@"
870
+ fi
702
871
  ;;
703
872
  scale)
704
873
  if [ $# -lt 1 ]; then
@@ -28,6 +28,8 @@ bash "$COMET_STATE" check <name> build
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.
32
+
31
33
  ### 1. Create Plan
32
34
 
33
35
  **Immediately execute:** Use the Skill tool to load the `superpowers:writing-plans` skill. Skipping this step is prohibited.
@@ -88,7 +90,7 @@ Plan has been written to the current branch. Before starting execution, **ask th
88
90
  - Task count ≤ 2 and no cross-module dependencies → Recommend B
89
91
  - From hotfix path → Recommend B
90
92
 
91
- This is a user decision point. Must pause and wait for the user to explicitly choose both isolation method and execution method. You **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.
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.
92
94
 
93
95
  After user selection, update `isolation` and `build_mode` fields:
94
96
 
@@ -131,10 +133,10 @@ When the initial spec is found incomplete during implementation, handle by scale
131
133
  | Scale | Trigger Conditions | Approach |
132
134
  |------|-------------------|----------|
133
135
  | Small | Missing acceptance scenarios, edge cases | Directly edit delta spec + design.md, append tasks.md tasks |
134
- | Medium | Interface changes, new components, data flow changes | Pause and wait for user confirmation, then must use Skill tool to load `superpowers:brainstorming` to update Design Doc + delta spec |
135
- | Large | Brand-new capability requirements | Must pause and wait for user confirmation to split; after user confirms, create independent change through `/comet-open` |
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` |
136
138
 
137
- **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 pause and wait for the user to decide whether to split into new change.
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.
138
140
 
139
141
  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.
140
142
 
@@ -149,7 +151,7 @@ When creating an independent change, must invoke `/comet-open`, not `/opsx:new`
149
151
  Build is the longest phase and may span many tasks. To support resume after context compaction:
150
152
 
151
153
  - **After each task**: immediately check off tasks.md and commit code so `.comet.yaml` and file state are durable
152
- - **After context compaction**: read `.comet.yaml` to confirm the phase is still build, read the plan header `base-ref`, then read tasks.md to find the next unchecked task
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.
153
155
  - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
154
156
  1. After attribution, if the diff implies plan or spec changes, handle it through Step 4 "Spec Incremental Updates"
155
157
  - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
@@ -183,6 +185,6 @@ State file is automatically updated to `phase: verify`, `verify_result: pending`
183
185
 
184
186
  ## Automatic Transition
185
187
 
186
- After exit conditions are met, **proceed immediately to the next phase without waiting for user input**:
188
+ After exit conditions are met (including user selecting workflow configuration), auto-transition to next phase:
187
189
 
188
190
  > **REQUIRED NEXT SKILL:** Invoke `comet-verify` skill to enter the verification and completion phase.
@@ -28,6 +28,8 @@ bash "$COMET_STATE" check <name> design
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 design phase operations can be safely re-executed. If `handoff_context` and `handoff_hash` already exist, confirm they match current artifacts before deciding whether to regenerate.
32
+
31
33
  ### 1a. Generate OpenSpec → Superpowers Handoff Package
32
34
 
33
35
  **Must be generated by script. Agent writing summaries on the fly is not allowed.**
@@ -103,7 +105,7 @@ The brainstorming phase does not write to the Design Doc file; it only produces
103
105
 
104
106
  ### 1c. User Confirms Design Proposal (Blocking Point)
105
107
 
106
- After brainstorming produces a design proposal, **must pause and wait for the user to explicitly confirm the design proposal**. Must not create the final Design Doc, write `design_doc`, run design guard, or enter `/comet-build` before user confirmation.
108
+ After brainstorming produces a design proposal, **must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm the design proposal**. Must not create the final Design Doc, write `design_doc`, run design guard, or enter `/comet-build` before user confirmation. Must not just output a text prompt and then continue executing.
107
109
 
108
110
  When pausing, only present essential summary:
109
111
  - Technical approach adopted
@@ -147,8 +149,18 @@ Must use `--apply` before exit:
147
149
  bash "$COMET_GUARD" <change-name> design --apply
148
150
  ```
149
151
 
152
+ ## Context Compaction Recovery
153
+
154
+ The design phase may trigger context compaction during brainstorming. To recover, first run:
155
+
156
+ ```bash
157
+ bash "$COMET_STATE" check <change-name> design --recover
158
+ ```
159
+
160
+ The script outputs structured recovery context (phase, completed fields, pending fields, recovery action). Follow the Recovery action to determine next step.
161
+
150
162
  ## Automatic Transition
151
163
 
152
- After exit conditions are met, **proceed immediately to the next phase without waiting for user input**:
164
+ After exit conditions are met (including user confirming the design proposal), auto-transition to next phase:
153
165
 
154
166
  > **REQUIRED NEXT SKILL:** Invoke `comet-build` skill to enter the plan and build phase.
@@ -126,7 +126,7 @@ If there is delta spec, sync to main spec according to comet-archive rules, and
126
126
  <IMPORTANT>
127
127
  Hotfix workflow is **one-time continuous execution**. After invoking `/comet-hotfix`, agent must automatically advance through hotfix steps, without pausing to wait for user input mid-way. But the following situations must pause and wait for user confirmation:
128
128
 
129
- 1. Encountering upgrade conditions (see "Upgrade Conditions" section). Handle through the upgrade-condition blocking confirmation
129
+ 1. Encountering upgrade conditions (see "Upgrade Conditions" section). **Must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm** upgrading to full workflow
130
130
  2. workspace isolation and execution-method selection when tasks exceed 3 and transfer to `/comet-build`
131
131
  3. verify phase (comet-verify) verification-failure and branch-handling decisions
132
132
 
@@ -149,7 +149,7 @@ Upgrade to full `/comet` when **any** of the following conditions are met:
149
149
  | Introduces new public API | Fix creates new external interface |
150
150
  | Fix scope exceeds single function/module | Requires coordinated changes |
151
151
 
152
- When upgrade conditions are met, must pause and wait for the user to explicitly confirm upgrading to the full `/comet` workflow. Do not directly enter `/comet-design`, and do not automatically supplement Design Doc.
152
+ When upgrade conditions are met, **must use the AskUserQuestion tool to pause and wait for the user to explicitly confirm** upgrading to the full `/comet` workflow. Do not directly enter `/comet-design`, and do not automatically supplement Design Doc. Must not just output a text prompt and then continue executing.
153
153
 
154
154
  After user confirms upgrade, **must first update the workflow field** before entering full flow:
155
155