@rpamis/comet 0.2.8 → 0.3.0

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 (43) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +92 -55
  3. package/assets/manifest.json +1 -0
  4. package/assets/skills/comet/SKILL.md +10 -7
  5. package/assets/skills/comet/reference/dirty-worktree.md +58 -0
  6. package/assets/skills/comet-build/SKILL.md +2 -0
  7. package/assets/skills/comet-hotfix/SKILL.md +8 -0
  8. package/assets/skills/comet-tweak/SKILL.md +8 -0
  9. package/assets/skills/comet-verify/SKILL.md +34 -7
  10. package/assets/skills-zh/comet/SKILL.md +1 -0
  11. package/assets/skills-zh/comet/reference/dirty-worktree.md +58 -0
  12. package/assets/skills-zh/comet-build/SKILL.md +2 -0
  13. package/assets/skills-zh/comet-hotfix/SKILL.md +2 -0
  14. package/assets/skills-zh/comet-tweak/SKILL.md +2 -0
  15. package/assets/skills-zh/comet-verify/SKILL.md +21 -9
  16. package/bin/comet.js +3 -3
  17. package/dist/commands/doctor.d.ts.map +1 -1
  18. package/dist/commands/doctor.js +9 -3
  19. package/dist/commands/doctor.js.map +1 -1
  20. package/dist/commands/init.d.ts.map +1 -1
  21. package/dist/commands/init.js +8 -7
  22. package/dist/commands/init.js.map +1 -1
  23. package/dist/commands/update.d.ts +1 -1
  24. package/dist/commands/update.d.ts.map +1 -1
  25. package/dist/commands/update.js +13 -9
  26. package/dist/commands/update.js.map +1 -1
  27. package/dist/core/detect.d.ts +1 -1
  28. package/dist/core/detect.d.ts.map +1 -1
  29. package/dist/core/detect.js +19 -10
  30. package/dist/core/detect.js.map +1 -1
  31. package/dist/core/platforms.d.ts +4 -0
  32. package/dist/core/platforms.d.ts.map +1 -1
  33. package/dist/core/platforms.js +16 -1
  34. package/dist/core/platforms.js.map +1 -1
  35. package/dist/core/skills.d.ts +3 -2
  36. package/dist/core/skills.d.ts.map +1 -1
  37. package/dist/core/skills.js +3 -2
  38. package/dist/core/skills.js.map +1 -1
  39. package/dist/core/superpowers.d.ts.map +1 -1
  40. package/dist/core/superpowers.js +2 -1
  41. package/dist/core/superpowers.js.map +1 -1
  42. package/package.json +1 -1
  43. package/scripts/postinstall.js +44 -44
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 rpamis
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rpamis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -8,9 +8,11 @@
8
8
  </p>
9
9
 
10
10
  <p align="center">
11
- <a href="https://github.com/rpamis/comet/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/rpamis/comet/actions/workflows/ci.yml/badge.svg" /></a>
11
+ <a href="https://github.com/rpamis/comet/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/rpamis/comet/ci.yml?branch=master&style=flat-square&label=CI" /></a>
12
+ <a href="https://deepwiki.com/rpamis/comet"><img alt="DeepWiki" src="https://img.shields.io/badge/DeepWiki-rpamis%2Fcomet-blue?style=flat-square" /></a>
12
13
  <a href="https://www.npmjs.com/package/@rpamis/comet"><img alt="npm version" src="https://img.shields.io/npm/v/@rpamis/comet?style=flat-square" /></a>
13
14
  <a href="https://www.npmjs.com/package/@rpamis/comet"><img alt="npm download count" src="https://img.shields.io/npm/dm/@rpamis/comet?style=flat-square&label=Downloads/mo" /></a>
15
+ <a href="https://www.npmjs.com/package/@rpamis/comet"><img alt="npm weekly download count" src="https://img.shields.io/npm/dw/@rpamis/comet?style=flat-square&label=Downloads/wk" /></a>
14
16
  <a href="./LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" /></a>
15
17
  </p>
16
18
 
@@ -30,7 +32,11 @@
30
32
 
31
33
  **OpenSpec + Superpowers dual-star development workflow** — one command from idea to archive.
32
34
 
33
- OpenSpec handles **WHAT** (outlines, proposals, spec lifecycle, archiving). Superpowers handles **HOW** (technical design, planning, execution, wrap-up). Comet chains both into a five-phase automated pipeline.
35
+ OpenSpec handles **WHAT** (outlines, proposals, spec lifecycle, archiving).
36
+
37
+ Superpowers handles **HOW** (technical design, planning, execution, wrap-up).
38
+
39
+ Comet chains both into a five-phase automated pipeline.
34
40
 
35
41
  ## Why Comet
36
42
 
@@ -42,6 +48,28 @@ Superpowers generates Spec documents after brainstorming, but these documents ty
42
48
 
43
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.
44
50
 
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
+
53
+ ## What You'll Learn
54
+
55
+ Many excellent Skill projects exist in the current Skill market, but they generally have preference issues — users may only like some features. For example, when using both OpenSpec and Superpowers, one might only use OpenSpec's Spec management capabilities, but prefer Superpowers' TDD-driven approach for coding.
56
+
57
+ Long-term Skill users know these capabilities can be freely combined, but exactly how to do so still requires real practice. The Comet project can serve as a reference:
58
+
59
+ - **How to reliably trigger nested Skills** — Not letting the Agent rely on document descriptions to perform "look-alike Skill trigger" operations (like writing files based on Skill descriptions), but truly triggering Skills (key feature: Skill trigger prints on CC). Comet triggers many capabilities from OpenSpec and Superpowers. How is this Prompt written?
60
+
61
+ - **How to make combined Skills flow automatically across phases** — Not relying on manual intervention. Comet's 5-phase flow can automatically trigger Skills for the core process except for necessary user choices, while the state machine also protects state transition reliability.
62
+
63
+ - **How to turn the Spec lifecycle into a resumable workflow** — Comet links OpenSpec change/spec artifacts with Superpowers design and planning documents, then records phase, execution mode, verification results, and archive status in `.comet.yaml`, so the Agent can resume after interruption instead of rereading documents and guessing progress.
64
+
65
+ - **How to turn document synchronization from "user reminders" into automation** — Comet puts handoff, state updates, validation, and archive sync into scripted flows, reducing repeated prompts like "remember to update the design doc", "remember to sync the spec", and "remember to archive the change".
66
+
67
+ - **How to design guard conditions that Agents can execute** — Comet does not simply trust the Agent saying "done" at phase exits. Scripts such as `comet-guard.sh`, `comet-yaml-validate.sh`, and `comet-state.sh` check tasks, state fields, verification evidence, and archive conditions before allowing the workflow to advance.
68
+
69
+ - **How to distribute and install Skills across platforms** — Comet supports multiple AI coding platforms, project/global installation, Chinese/English Skill choices, and platform-specific directory differences such as Antigravity using different project-level and global paths. It can be a reference for CLI installers and Skill package structure.
70
+
71
+ - **How to turn shell scripts into Agent workflow infrastructure** — Comet's scripts need to work across macOS, Linux, and Windows Git Bash while handling hashes, YAML fields, state machines, and archive flows. It shows how to move fragile workflow control out of scattered Prompt text and into testable, reusable tools.
72
+
45
73
  ## Install
46
74
 
47
75
  ```bash
@@ -70,6 +98,12 @@ comet init
70
98
  >
71
99
  > `comet update` or `npm install -g @rpamis/comet@latest` to get the latest features and fixes.
72
100
 
101
+ ## Support for OpenClaw and Hermes, and other AI platforms
102
+
103
+ ```bash
104
+ npx skills add rpamis/comet
105
+ ```
106
+
73
107
  ## Screenshots
74
108
 
75
109
  <p align="center">
@@ -81,16 +115,10 @@ comet init
81
115
 
82
116
  ## Commands
83
117
 
84
- | Command | Description |
85
- |---------|-------------|
86
- | `comet init [path]` | Initialize Comet workflow |
87
- | `comet status [path]` | Show active changes, task progress, and next workflow command |
88
- | `comet doctor [path]` | Diagnose project/global Comet installation health |
89
- | `comet update [path]` | Update the npm package and installed Comet skills |
90
- | `comet --help` | Show help |
91
- | `comet --version` | Show version |
118
+ <details>
119
+ <summary><code>comet init [path]</code> — Initialize Comet workflow</summary>
92
120
 
93
- ### init Options
121
+ Initializes OpenSpec, Superpowers, and Comet skills for selected AI coding platforms.
94
122
 
95
123
  | Option | Description |
96
124
  |--------|-------------|
@@ -102,20 +130,35 @@ comet init
102
130
 
103
131
  When multiple existing components are found on the same platform, interactive init offers one bulk choice: overwrite all, skip all, or choose per component.
104
132
 
105
- ### status Options
133
+ </details>
134
+
135
+ <details>
136
+ <summary><code>comet status [path]</code> — Show active changes and next workflow command</summary>
137
+
138
+ Displays active changes, task progress, and the recommended next Comet workflow command.
106
139
 
107
140
  | Option | Description |
108
141
  |--------|-------------|
109
142
  | `--json` | Output active changes with `nextCommand` |
110
143
 
111
- ### doctor Options
144
+ </details>
145
+
146
+ <details>
147
+ <summary><code>comet doctor [path]</code> — Diagnose Comet installation health</summary>
148
+
149
+ Checks project/global installation health, working directories, installed skills, scripts, and Comet state files.
112
150
 
113
151
  | Option | Description |
114
152
  |--------|-------------|
115
153
  | `--json` | Output structured diagnostic results |
116
154
  | `--scope <scope>` | Diagnose `auto`, `project`, or `global` scope (default: `auto`) |
117
155
 
118
- ### update Options
156
+ </details>
157
+
158
+ <details>
159
+ <summary><code>comet update [path]</code> — Update Comet package and skills</summary>
160
+
161
+ Updates the npm package and refreshes installed Comet skills in detected project/global targets.
119
162
 
120
163
  | Option | Description |
121
164
  |--------|-------------|
@@ -123,10 +166,20 @@ When multiple existing components are found on the same platform, interactive in
123
166
  | `--language <lang>` | Override detected skill language (`en`, `zh`) |
124
167
  | `--scope <scope>` | Update only `global` or `project` scope |
125
168
 
169
+ </details>
170
+
171
+ | Command | Description |
172
+ |---------|-------------|
173
+ | `comet --help` | Show help |
174
+ | `comet --version` | Show version |
175
+
126
176
  ## Supported Platforms
127
177
 
128
178
  `comet init` supports 28 AI coding platforms:
129
179
 
180
+ <details>
181
+ <summary>View full platform list</summary>
182
+
130
183
  | Platform | Skills Dir | Platform | Skills Dir |
131
184
  |----------|-----------|----------|-----------|
132
185
  | Claude Code | `.claude/` | Cursor | `.cursor/` |
@@ -141,15 +194,20 @@ When multiple existing components are found on the same platform, interactive in
141
194
  | CoStrict | `.cospec/` | Crush | `.crush/` |
142
195
  | Factory Droid | `.factory/` | iFlow | `.iflow/` |
143
196
  | Pi | `.pi/` | Qoder | `.qoder/` |
144
- | Antigravity | `.agent/` | Bob Shell | `.bob/` |
197
+ | Antigravity | `.agents/` | Bob Shell | `.bob/` |
145
198
  | ForgeCode | `.forge/` | Trae | `.trae/` |
146
199
 
200
+ </details>
201
+
147
202
  ## Skills
148
203
 
149
204
  After `comet init`, three groups of skills are installed to the selected platform's `skills/` directory:
150
205
 
151
206
  ### Comet Skills
152
207
 
208
+ <details>
209
+ <summary>View Comet skills</summary>
210
+
153
211
  | Skill | Description |
154
212
  |-------|-------------|
155
213
  | `/comet` | Main entry — auto-detects phase and dispatches to sub-commands |
@@ -161,8 +219,13 @@ After `comet init`, three groups of skills are installed to the selected platfor
161
219
  | `/comet-hotfix` | Preset: Quick bug fix (skips brainstorming) |
162
220
  | `/comet-tweak` | Preset: Small change (skips brainstorming and full plan) |
163
221
 
222
+ </details>
223
+
164
224
  ### Guard & Automation Scripts
165
225
 
226
+ <details>
227
+ <summary>View script list</summary>
228
+
166
229
  | Script | Purpose |
167
230
  |--------|---------|
168
231
  | `comet-guard.sh` | Phase transition guard — validates exit conditions, `--apply` auto-updates `.comet.yaml` |
@@ -171,6 +234,8 @@ After `comet init`, three groups of skills are installed to the selected platfor
171
234
  | `comet-yaml-validate.sh` | Schema validator — validates `.comet.yaml` structure and field values |
172
235
  | `comet-state.sh` | Unified state management — init/set/get/check/scale, agents' exclusive YAML interface |
173
236
 
237
+ </details>
238
+
174
239
  ### OpenSpec Skills
175
240
 
176
241
  Spec lifecycle management: propose, explore, sync, verify, archive, and more.
@@ -221,6 +286,11 @@ Comet uses a decoupled state architecture with separate YAML files:
221
286
  | `.openspec.yaml` | OpenSpec | Spec lifecycle, change metadata |
222
287
  | `.comet.yaml` | Comet | Workflow phase, execution mode, verification status |
223
288
 
289
+ 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
+
291
+ <details>
292
+ <summary>View key .comet.yaml fields</summary>
293
+
224
294
  **Key Fields in `.comet.yaml`:**
225
295
 
226
296
  ```yaml
@@ -245,12 +315,15 @@ handoff_hash: <sha256>
245
315
 
246
316
  In full workflow, `build_mode`, `isolation`, and `verify_mode` may temporarily be `null`; `build_mode` and `isolation` must be resolved before `build → verify`. `verification_report` stays `null` until verification writes a report, and `verify-pass` requires that report to exist plus `branch_status: handled`. Fields after `archived` in the example are optional or script-derived: `direct_override` is only needed for full-workflow direct builds, project commands may be absent unless configured, and `handoff_context` / `handoff_hash` are recorded by `comet-handoff.sh` before leaving design. Projects can configure `build_command` / `verify_command` in the change or repo root, and guard will run those commands first and print failure output.
247
317
 
248
- All states and execution phases are updated via scripts, and **each phase verifies that tasks are truly completed before exiting — conditions are met before the phase exits and state is updated**. Compared to recording complex state management mechanisms in Skills, the script approach strongly guarantees the reliability of core state transitions, correctness of YAML files, and convenience of breakpoint recovery — Agents only need to use Comet's built-in commands to read state and know the current Spec's situation.
318
+ </details>
249
319
 
250
320
  ### Reliability Features
251
321
 
252
322
  Comet ensures agent execution reliability through automated state transitions:
253
323
 
324
+ <details>
325
+ <summary>View reliability features</summary>
326
+
254
327
  1. **Entry Verification** — Each phase validates preconditions before execution
255
328
  - Checks file existence, state consistency, and phase transitions
256
329
  - Outputs `[HARD STOP]` with actionable suggestions if validation fails
@@ -284,7 +357,7 @@ Comet ensures agent execution reliability through automated state transitions:
284
357
  - Moves change to archive directory and updates `archived: true`
285
358
  - Supports `--dry-run` for preview
286
359
 
287
- **Security**: Path traversal protection on all change name inputs
360
+ </details>
288
361
 
289
362
  ## Project Structure
290
363
 
@@ -316,55 +389,19 @@ your-project/
316
389
  └── plans/ # Implementation plans
317
390
  ```
318
391
 
319
- ## What You'll Learn
320
-
321
- Many excellent Skill projects exist in the current Skill market, but they generally have preference issues — users may only like some features. For example, when using both OpenSpec and Superpowers, one might only use OpenSpec's Spec management capabilities, but prefer Superpowers' TDD-driven approach for coding.
322
-
323
- Long-term Skill users know these capabilities can be freely combined, but exactly how to do so still requires real practice. The Comet project can serve as a reference:
324
-
325
- - **How to reliably trigger nested Skills** — Not letting the Agent rely on document descriptions to perform "look-alike Skill trigger" operations (like writing files based on Skill descriptions), but truly triggering Skills (key feature: Skill trigger prints on CC). Comet will trigger many capabilities from OpenSpec and Superpowers — how is this Prompt written?
326
-
327
- - **How to make combined Skills multi-phase auto-flow** — Not relying on manual intervention. Comet's 5-phase flow automatically triggers Skills for core processes except necessary user selections, while the **state machine mechanism** also ensures state transition reliability.
328
-
329
392
  ## Development
330
393
 
331
394
  See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, commit conventions, PR process, and guidance for adding platforms or skills.
332
395
 
333
- ```bash
334
- # Clone
335
- git clone https://github.com/rpamis/comet
336
- cd comet
337
-
338
- # Install dependencies
339
- pnpm install
340
-
341
- # Dev mode (watch)
342
- pnpm dev
343
-
344
- # Build
345
- pnpm build
346
-
347
- # Test (unit + coverage)
348
- pnpm test
349
- pnpm test:coverage
350
- pnpm test:shell # bats shell tests
351
-
352
- # Lint & format
353
- pnpm lint
354
- pnpm format
355
- ```
356
-
357
396
  See [CHANGELOG.md](CHANGELOG.md) for version history and updates.
358
397
 
359
398
  ## Roadmap
360
399
 
361
400
  Track our development progress and upcoming features on the [Comet Roadmap](https://github.com/orgs/rpamis/projects/1).
362
401
 
363
- ## Security
402
+ ## Star History
364
403
 
365
- - Pre-publish scan for API keys, secrets, tokens, and private keys
366
- - `.npmignore` prevents source code and config files from entering the npm package
367
- - `.gitignore` covers secrets, credentials, IDE configs, and more
404
+ [![Star History Chart](https://api.star-history.com/svg?repos=rpamis/comet&type=Date)](https://star-history.com/#rpamis/comet&Date)
368
405
 
369
406
  ## License
370
407
 
@@ -2,6 +2,7 @@
2
2
  "version": "0.2.6",
3
3
  "skills": [
4
4
  "comet/SKILL.md",
5
+ "comet/reference/dirty-worktree.md",
5
6
  "comet/scripts/comet-guard.sh",
6
7
  "comet/scripts/comet-state.sh",
7
8
  "comet/scripts/comet-handoff.sh",
@@ -22,13 +22,19 @@ Agents need only read this section for decision-making. Refer to the Reference A
22
22
 
23
23
  ### Automatic Phase Detection
24
24
 
25
- **Step 0: Active Change Discovery**
25
+ **Step 0: Active Change Discovery and Intent Detection**
26
26
 
27
- 1. Run `openspec list --json` to get all active changes
27
+ 1. Detect presets first; if hotfix/tweak matches, invoke the corresponding preset skill directly and do not enter the normal open branch
28
+ 2. When no preset matches, run `openspec list --json` to get all active changes
29
+
30
+ **Preset detection has highest priority**:
31
+ - User explicitly describes a bug fix / hotfix + meets hotfix conditions → directly invoke `/comet-hotfix`
32
+ - User explicitly describes copy/config/docs/prompt small adjustment + meets tweak conditions → directly invoke `/comet-tweak`
33
+ - No preset match → follow the table below
28
34
 
29
35
  | Active changes | User input | Behavior |
30
36
  |----------------|------------|----------|
31
- | None | any | → Invoke `/comet-open` |
37
+ | None | non-preset input | → Invoke `/comet-open` |
32
38
  | Exactly 1 | `/comet <description>` | → **Ask**: continue this change or create a new change |
33
39
  | Multiple | `/comet <description>` | → **Ask**: continue existing or create new; if continuing, list changes for selection |
34
40
  | Exactly 1 | `/comet` with no description | → Auto-select, enter Step 1 |
@@ -40,16 +46,13 @@ When the user chooses "create a new change", **must invoke `/comet-open`**. Do n
40
46
  Calling `/opsx:new` directly leaves `.comet.yaml` missing and breaks later phase detection.
41
47
  </IMPORTANT>
42
48
 
43
- **Preset detection**:
44
- - User describes as bug fix / hotfix + meets hotfix conditions → directly invoke `/comet-hotfix`
45
- - User describes as copy, config, docs, prompt or small non-bug adjustment + meets tweak conditions → directly invoke `/comet-tweak`
46
-
47
49
  **Step 1: Read `.comet.yaml` state metadata**
48
50
 
49
51
  Prefer reading `openspec/changes/<name>/.comet.yaml`. If not available, fall back to `openspec status --change "<name>" --json`, `tasks.md`, and `docs/superpowers/` file checks.
50
52
 
51
53
  **Resume rules**:
52
54
  - On every context resume, rerun Step 0 and Step 1; do not trust conversation history for phase detection
55
+ - If there is an active change and the worktree has uncommitted changes, handle them through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions; this file does not repeat them
53
56
  - If `phase: build`, read the next unchecked task from tasks.md and continue
54
57
  - If `phase: verify` and `verify_result: fail`, first run `bash "$COMET_STATE" transition <name> verify-fail`, then invoke `/comet-build`
55
58
  - If `phase: open` but proposal/design/tasks are complete, run `bash "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
@@ -0,0 +1,58 @@
1
+ # Dirty Worktree Protocol
2
+
3
+ Canonical path: `comet/reference/dirty-worktree.md`
4
+
5
+ This protocol is shared by all Comet sub-skills that may modify code. When an agent resumes context or continues execution, it must handle uncommitted working tree changes through this protocol.
6
+
7
+ ## 1. Checks
8
+
9
+ Before continuing or starting code changes, run:
10
+
11
+ ```bash
12
+ git status --short
13
+ git diff --stat
14
+ git diff --cached --stat
15
+ git ls-files --others --exclude-standard
16
+ ```
17
+
18
+ When needed, inspect `git diff`, `git diff --cached`, and newly created file contents.
19
+
20
+ ## 2. Core Rules
21
+
22
+ - The user may not say which files they changed. If the worktree is dirty, including new files shown as `??` in Git status, assume changes may come from the user or mixed sources.
23
+ - A dirty worktree is code evidence only. It does not automatically advance `.comet.yaml` `phase` or check off `tasks.md`; Comet state may advance only after attribution, verification, required document synchronization, and the relevant phase guard.
24
+
25
+ ## 3. Attribution
26
+
27
+ Classify dirty diffs into three groups:
28
+
29
+ 1. **Belongs to the current change**: Files and content match the current change goal, tasks.md, plan, or delta spec. Incorporate the diff into the current task and avoid redoing the same work.
30
+ 2. **Does not belong to the current change**: Files or content are unrelated. Pause and ask whether to include it in the current change, split it into a new change, leave it alone, or discard it with explicit authorization.
31
+ 3. **Unclear source**: The diff and documents are not enough to determine ownership. Pause, report the file list and reasoning, and do not advance the phase.
32
+
33
+ ## 4. Common Patterns
34
+
35
+ ### Implemented But tasks.md Is Not Checked
36
+
37
+ Verify the implementation with build and tests. If it passes, check off the task. Do not redo work just because the task is unchecked, and do not ignore code evidence because state files lag behind. If the current sub-skill defines a phase-specific rule, follow that sub-skill.
38
+
39
+ ### Plan Or Scope Changed
40
+
41
+ Follow the current sub-skill's escalation, incremental-update, or rollback rules. This protocol does not repeat phase-specific details.
42
+
43
+ ### Ambiguous Resume Intent
44
+
45
+ When the user says things like "continue", "keep going", "I changed a bit", "I wasn't happy with it", "redo it", "code changed", or "use what is there", follow this protocol. Do not require the user to remember exactly what they changed.
46
+
47
+ ### Code Changes During open/design
48
+
49
+ If the current phase is still `open` or `design` but the dirty worktree already contains code changes, first attribute the changes through this protocol and do not advance the phase directly:
50
+
51
+ - If the changes belong to the current change, treat them as requirements or design input and record them in proposal/design/spec/design doc/tasks as appropriate. The current phase guard must still pass before entering build.
52
+ - If the changes do not belong to the current change or ownership is unclear, pause and ask whether to include them, split them into a new change, leave them alone, or discard them with explicit authorization.
53
+ - Do not treat code changes made during open/design as completed implementation ready for verify.
54
+
55
+ ## 5. Prohibitions
56
+
57
+ - Do not overwrite, revert, reformat over, or ignore user changes before understanding the dirty diff source.
58
+ - Do not mark verification as passed while dirty diff remains unexplained.
@@ -158,6 +158,8 @@ Build is the longest phase and may span many tasks. To support resume after cont
158
158
 
159
159
  - **After each task**: immediately check off tasks.md and commit code so `.comet.yaml` and file state are durable
160
160
  - **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
161
+ - **User manual-change resume**: handle uncommitted changes through `comet/reference/dirty-worktree.md`. That protocol defines checks, attribution, and prohibitions. Build-specific handling:
162
+ 1. After attribution, if the diff implies plan or spec changes, handle it through Step 5 "Spec Incremental Updates"
161
163
  - **Long task split**: if a single task exceeds 200 lines of code changes, consider splitting it into multiple subtasks and commits
162
164
 
163
165
  ## Exit Conditions
@@ -47,6 +47,12 @@ Initialize Comet state file:
47
47
  bash "$COMET_STATE" init <name> hotfix
48
48
  ```
49
49
 
50
+ Verify initialized state:
51
+
52
+ ```bash
53
+ bash "$COMET_STATE" check <name> open
54
+ ```
55
+
50
56
  Run phase guard to transition open → build:
51
57
 
52
58
  ```bash
@@ -57,6 +63,8 @@ bash "$COMET_GUARD" <change-name> open --apply
57
63
 
58
64
  Use hotfix defaults: `build_mode: direct`. Skip `superpowers:brainstorming` and `superpowers:writing-plans` (unless tasks > 3; if exceeds 3 tasks, transfer to `/comet-build`'s plan and execution method selection).
59
65
 
66
+ Before continuing or starting changes, handle uncommitted changes through `comet/reference/dirty-worktree.md`. If attribution shows the fix scope exceeds hotfix, handle it through this file's "Upgrade Conditions".
67
+
60
68
  **Immediately execute:** Execute tasks one by one according to tasks.md:
61
69
 
62
70
  1. Read `openspec/changes/<name>/tasks.md`, get incomplete task list
@@ -50,6 +50,12 @@ Initialize Comet state file:
50
50
  bash "$COMET_STATE" init <name> tweak
51
51
  ```
52
52
 
53
+ Verify initialized state:
54
+
55
+ ```bash
56
+ bash "$COMET_STATE" check <name> open
57
+ ```
58
+
53
59
  Run phase guard to transition open → build:
54
60
 
55
61
  ```bash
@@ -60,6 +66,8 @@ bash "$COMET_GUARD" <change-name> open --apply
60
66
 
61
67
  Use tweak defaults: `build_mode: direct`. Skip `superpowers:brainstorming` and `superpowers:writing-plans`.
62
68
 
69
+ Before continuing or starting changes, handle uncommitted changes through `comet/reference/dirty-worktree.md`. If attribution shows the scope exceeds tweak, handle it through this file's "Upgrade Conditions".
70
+
63
71
  **Immediately execute:** Execute tasks one by one according to tasks.md:
64
72
 
65
73
  1. Read `openspec/changes/<name>/tasks.md`, get incomplete task list
@@ -20,7 +20,7 @@ Execute entry verification:
20
20
  COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
21
21
  COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
22
22
  COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
23
- bash "$COMET_STATE" check <name> verify
23
+ bash "$COMET_STATE" check <change-name> verify
24
24
  ```
25
25
 
26
26
  Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
@@ -30,15 +30,27 @@ Proceed to Step 1 after verification passes. The script outputs specific failure
30
30
  Execute scale assessment:
31
31
 
32
32
  ```bash
33
- bash "$COMET_STATE" scale <name>
33
+ bash "$COMET_STATE" scale <change-name>
34
34
  ```
35
35
 
36
36
  Script automatically counts tasks, delta specs, and changed files to determine whether to use light or full verification mode, and sets the verify_mode field.
37
37
 
38
+ Before verification starts, inspect and handle uncommitted changes through `comet/reference/dirty-worktree.md`. Verify-specific handling:
39
+
40
+ 1. If dirty diff belongs to the current change and involves implementation, tests, tasks, delta spec, or design doc changes, do not fix or commit directly in verify; record failure and return to build
41
+ 2. If dirty diff is only a verify-phase artifact, such as a verification report draft or branch-handling record, continue in verify and record state
42
+ 3. If dirty diff has implemented work but tasks.md is unchecked, treat it as stale build state; record failure and return to build so `/comet-build` verifies the implementation, checks off tasks, and commits
43
+
44
+ Return to build:
45
+
46
+ ```bash
47
+ bash "$COMET_STATE" transition <change-name> verify-fail
48
+ ```
49
+
38
50
  Note: if the build phase committed after each task, worktree diff can underestimate change size. In that case, read the plan header `base-ref` and re-check the full commit range:
39
51
 
40
52
  ```bash
41
- PLAN=$(bash "$COMET_STATE" get <name> plan)
53
+ PLAN=$(bash "$COMET_STATE" get <change-name> plan)
42
54
  BASE_REF=$(grep '^base-ref:' "$PLAN" 2>/dev/null | head -1 | sed 's/^base-ref: *//')
43
55
  git diff --stat "$BASE_REF"...HEAD
44
56
  ```
@@ -46,7 +58,7 @@ git diff --stat "$BASE_REF"...HEAD
46
58
  If the commit range exceeds lightweight thresholds (> 5 files, cross-module coordination, or more than 1 delta spec capability), manually switch to full verification:
47
59
 
48
60
  ```bash
49
- bash "$COMET_STATE" set <name> verify_mode full
61
+ bash "$COMET_STATE" set <change-name> verify_mode full
50
62
  ```
51
63
 
52
64
  ### 2a. Lightweight Verification (Small Changes)
@@ -54,7 +66,7 @@ bash "$COMET_STATE" set <name> verify_mode full
54
66
  When scale assessment result is "small", skip `openspec-verify-change`, directly execute the following checks:
55
67
 
56
68
  1. All tasks in tasks.md completed `[x]`
57
- 2. Changed files consistent with tasks.md description (compare `git diff --stat` against task content)
69
+ 2. Changed files consistent with tasks.md description (compare `git diff --stat` / `git diff --cached --stat` / `git diff --stat <base-ref>...HEAD` against task content)
58
70
  3. Build passes (run project-appropriate build command, e.g., `npm run build`, `mvn compile`, `cargo build`)
59
71
  4. Related tests pass
60
72
  5. No obvious security issues (no hardcoded secrets, no new unsafe operations)
@@ -64,7 +76,7 @@ When scale assessment result is "small", skip `openspec-verify-change`, directly
64
76
  **When failing**: report failed items, record failure, move back to build, then invoke `/comet-build`.
65
77
 
66
78
  ```bash
67
- bash "$COMET_STATE" transition <name> verify-fail
79
+ bash "$COMET_STATE" transition <change-name> verify-fail
68
80
  ```
69
81
 
70
82
  **Report format**: Brief table listing 5 check results + PASS/FAIL.
@@ -93,7 +105,7 @@ After the skill loads, follow its guidance to verify. Check items:
93
105
  When verification fails: report missing items, record failure, move back to build, then invoke `/comet-build`.
94
106
 
95
107
  ```bash
96
- bash "$COMET_STATE" transition <name> verify-fail
108
+ bash "$COMET_STATE" transition <change-name> verify-fail
97
109
  ```
98
110
 
99
111
  **Spec drift handling**:
@@ -118,10 +130,25 @@ After the skill loads, follow its guidance to complete. Branch handling options:
118
130
  - All tests pass
119
131
  - No hardcoded secrets or security issues
120
132
 
133
+ ### 4. Record Verification Evidence
134
+
135
+ The verification report must be written to disk and recorded in `.comet.yaml`; branch handling must also be written to state after it completes. Do not manually set `verify_result: pass`; guard performs the transition.
136
+
137
+ ```bash
138
+ mkdir -p docs/superpowers/reports
139
+ # Write this verification result to a report file, for example:
140
+ # docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
141
+
142
+ bash "$COMET_STATE" set <change-name> verification_report docs/superpowers/reports/YYYY-MM-DD-<change-name>-verify.md
143
+ bash "$COMET_STATE" set <change-name> branch_status handled
144
+ ```
145
+
121
146
  ## Exit Conditions
122
147
 
123
148
  - Verification report passed
124
149
  - Branch handled
150
+ - `.comet.yaml` `verification_report` points to an existing verification report file
151
+ - `.comet.yaml` has `branch_status: handled`
125
152
  - **Phase guard**: Run `bash "$COMET_GUARD" <change-name> verify --apply`; after all PASS, it uses `comet-state transition verify-pass` to advance to `phase: archive`
126
153
 
127
154
  After verification and branch handling are complete, run guard to auto-transition:
@@ -52,6 +52,7 @@ agent 做决策只需读本节,参考附录按需查阅。
52
52
 
53
53
  **断点恢复规则**:
54
54
  - 每次恢复上下文时,先重新执行 Step 0 和 Step 1,不依赖对话历史判断阶段
55
+ - 只要存在 active change 且工作区有未提交改动,必须按 `comet/reference/dirty-worktree.md` 协议处理。该协议定义了检查步骤、归因分类和禁令,本文件不重复
55
56
  - 若 `phase: build`,读取 tasks.md 的下一个未勾选任务继续
56
57
  - 若 `phase: verify` 且 `verify_result: fail`,先运行 `bash "$COMET_STATE" transition <name> verify-fail`,再调用 `/comet-build`
57
58
  - 若 `phase: open` 但 proposal/design/tasks 已完整,先运行 `bash "$COMET_GUARD" <change-name> open --apply` 修正状态,再继续判定