@rpamis/comet 0.2.2 → 0.2.4
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 +77 -13
- package/assets/manifest.json +1 -1
- package/assets/skills/comet/SKILL.md +50 -14
- package/assets/skills/comet/scripts/comet-archive.sh +2 -2
- package/assets/skills/comet/scripts/comet-guard.sh +50 -48
- package/assets/skills/comet/scripts/comet-state.sh +158 -39
- package/assets/skills/comet/scripts/comet-yaml-validate.sh +9 -3
- package/assets/skills/comet-archive/SKILL.md +7 -4
- package/assets/skills/comet-build/SKILL.md +22 -7
- package/assets/skills/comet-design/SKILL.md +12 -19
- package/assets/skills/comet-hotfix/SKILL.md +36 -26
- package/assets/skills/comet-open/SKILL.md +19 -7
- package/assets/skills/comet-tweak/SKILL.md +23 -12
- package/assets/skills/comet-verify/SKILL.md +32 -7
- package/assets/skills-zh/comet/SKILL.md +64 -21
- package/assets/skills-zh/comet-archive/SKILL.md +7 -4
- package/assets/skills-zh/comet-build/SKILL.md +22 -7
- package/assets/skills-zh/comet-design/SKILL.md +12 -19
- package/assets/skills-zh/comet-hotfix/SKILL.md +42 -26
- package/assets/skills-zh/comet-open/SKILL.md +30 -16
- package/assets/skills-zh/comet-tweak/SKILL.md +29 -12
- package/assets/skills-zh/comet-verify/SKILL.md +46 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/rpamis/comet">
|
|
3
|
+
<picture>
|
|
4
|
+
<source srcset="img/title-log.png">
|
|
5
|
+
<img src="img/title-log.png" alt="Comet logo">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
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>
|
|
12
|
+
<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
|
+
<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>
|
|
14
|
+
<a href="./LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
1
17
|
# @rpamis/comet
|
|
2
18
|
|
|
3
19
|
```
|
|
@@ -15,6 +31,16 @@
|
|
|
15
31
|
|
|
16
32
|
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.
|
|
17
33
|
|
|
34
|
+
## Why Comet
|
|
35
|
+
|
|
36
|
+
OpenSpec excels at managing requirements, creating proposals, managing Spec lifecycles, and archiving, but its proposals and tasks lack the detail of Superpowers brainstorming.
|
|
37
|
+
|
|
38
|
+
Superpowers generates Spec documents after brainstorming, but these documents typically lack stateful design — after completing requirements, Specs only have tasks checked off in the document, and Agents even forget to check them off. This causes the Agent to re-examine documents and project code to verify on resumption, wasting many tokens.
|
|
39
|
+
|
|
40
|
+
**Comet combines the strengths of both**, integrating the core workflow into 5 phases
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
18
44
|
## Install
|
|
19
45
|
|
|
20
46
|
```bash
|
|
@@ -38,6 +64,20 @@ comet init
|
|
|
38
64
|
6. Deploy Comet skills (in your chosen language) to selected platforms
|
|
39
65
|
7. Create `docs/superpowers/specs/` and `docs/superpowers/plans/` working directories
|
|
40
66
|
|
|
67
|
+
> [!TIP]
|
|
68
|
+
> update version
|
|
69
|
+
>
|
|
70
|
+
> comet update or `npm install -g @rpamis/comet@latest` to get the latest features and fixes.
|
|
71
|
+
|
|
72
|
+
## Screenshots
|
|
73
|
+
|
|
74
|
+
<p align="center">
|
|
75
|
+
<img src="img/runner.png" alt="runner">
|
|
76
|
+
</p>
|
|
77
|
+
|
|
78
|
+
<p align="center">Auto-install OpenSpec & Superpowers, one-click dev environment setup</p>
|
|
79
|
+
<p align="center">Multi-phase Skill entry, auto-detects current Spec stage, auto-triggers core flow, manual review at key nodes</p>
|
|
80
|
+
|
|
41
81
|
## Commands
|
|
42
82
|
|
|
43
83
|
| Command | Description |
|
|
@@ -164,15 +204,23 @@ Comet uses a decoupled state architecture with separate YAML files:
|
|
|
164
204
|
| `.comet.yaml` | Comet | Workflow phase, execution mode, verification status |
|
|
165
205
|
|
|
166
206
|
**Key Fields in `.comet.yaml`:**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
|
|
175
|
-
|
|
207
|
+
|
|
208
|
+
```yaml
|
|
209
|
+
workflow: full
|
|
210
|
+
phase: build
|
|
211
|
+
design_doc: docs/superpowers/specs/YYYY-MM-DD-topic-design.md
|
|
212
|
+
plan: docs/superpowers/plans/YYYY-MM-DD-feature.md
|
|
213
|
+
build_mode: subagent-driven-development
|
|
214
|
+
isolation: branch
|
|
215
|
+
verify_mode: light
|
|
216
|
+
verify_result: pending
|
|
217
|
+
verification_report: docs/superpowers/reports/YYYY-MM-DD-change-verify.md
|
|
218
|
+
branch_status: pending
|
|
219
|
+
verified_at: null
|
|
220
|
+
archived: false
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
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.
|
|
176
224
|
|
|
177
225
|
### Reliability Features
|
|
178
226
|
|
|
@@ -189,12 +237,18 @@ Comet ensures agent execution reliability through automated state transitions:
|
|
|
189
237
|
- Guard and archive scripts use `comet-state.sh` internally for state management
|
|
190
238
|
|
|
191
239
|
3. **Schema Validation** — `comet-yaml-validate.sh` ensures data integrity
|
|
192
|
-
- Validates required fields (
|
|
193
|
-
- Validates enum values (
|
|
240
|
+
- Validates required fields (12 fields)
|
|
241
|
+
- Validates enum values (8 enum types)
|
|
194
242
|
- Validates referenced file paths exist
|
|
195
243
|
- Detects unknown/typos fields
|
|
196
244
|
|
|
197
|
-
4. **
|
|
245
|
+
4. **Verification Evidence** — Guard enforces proof before phase advance
|
|
246
|
+
- `verify-pass` transition requires `verification_report` pointing to an existing report file
|
|
247
|
+
- `branch_status` must be `handled` before verify can pass
|
|
248
|
+
- Guard checks `verification_report exists` and `branch_status=handled` as hard prerequisites
|
|
249
|
+
- Prevents false phase advances when verification or branch handling was skipped
|
|
250
|
+
|
|
251
|
+
5. **Archive Automation** — `comet-archive.sh` handles the full archive flow in one command
|
|
198
252
|
- Validates entry state, syncs delta specs to main specs
|
|
199
253
|
- Annotates design doc and plan frontmatter
|
|
200
254
|
- Moves change to archive directory and updates `archived: true`
|
|
@@ -231,6 +285,16 @@ your-project/
|
|
|
231
285
|
└── plans/ # Implementation plans
|
|
232
286
|
```
|
|
233
287
|
|
|
288
|
+
## What You'll Learn
|
|
289
|
+
|
|
290
|
+
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.
|
|
291
|
+
|
|
292
|
+
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:
|
|
293
|
+
|
|
294
|
+
- **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?
|
|
295
|
+
|
|
296
|
+
- **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.
|
|
297
|
+
|
|
234
298
|
## Development
|
|
235
299
|
|
|
236
300
|
```bash
|
|
@@ -267,4 +331,4 @@ See [CHANGELOG.md](CHANGELOG.md) for version history and updates.
|
|
|
267
331
|
|
|
268
332
|
## License
|
|
269
333
|
|
|
270
|
-
MIT
|
|
334
|
+
[MIT](LICENSE.md)
|
package/assets/manifest.json
CHANGED
|
@@ -25,13 +25,20 @@ Agents need only read this section for decision-making. Refer to the Reference A
|
|
|
25
25
|
**Step 0: Active Change Discovery**
|
|
26
26
|
|
|
27
27
|
1. Run `openspec list --json` to get all active changes
|
|
28
|
-
2. For each change, check `docs/superpowers/specs/` and `docs/superpowers/plans/` for associated files to determine phase and progress
|
|
29
28
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
| Exactly 1
|
|
34
|
-
| Multiple
|
|
29
|
+
| Active changes | User input | Behavior |
|
|
30
|
+
|----------------|------------|----------|
|
|
31
|
+
| None | any | → Invoke `/comet-open` |
|
|
32
|
+
| Exactly 1 | `/comet <description>` | → **Ask**: continue this change or create a new change |
|
|
33
|
+
| Multiple | `/comet <description>` | → **Ask**: continue existing or create new; if continuing, list changes for selection |
|
|
34
|
+
| Exactly 1 | `/comet` with no description | → Auto-select, enter Step 1 |
|
|
35
|
+
| Multiple | `/comet` with no description | → List changes for user selection |
|
|
36
|
+
|
|
37
|
+
<IMPORTANT>
|
|
38
|
+
When the user chooses "create a new change", **must invoke `/comet-open`**. Do not call `/opsx:new` directly.
|
|
39
|
+
`/comet-open` performs dual initialization: OpenSpec artifacts plus `.comet.yaml` state.
|
|
40
|
+
Calling `/opsx:new` directly leaves `.comet.yaml` missing and breaks later phase detection.
|
|
41
|
+
</IMPORTANT>
|
|
35
42
|
|
|
36
43
|
**Preset detection**:
|
|
37
44
|
- User describes as bug fix / hotfix + meets hotfix conditions → directly invoke `/comet-hotfix`
|
|
@@ -41,14 +48,23 @@ Agents need only read this section for decision-making. Refer to the Reference A
|
|
|
41
48
|
|
|
42
49
|
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.
|
|
43
50
|
|
|
51
|
+
**Resume rules**:
|
|
52
|
+
- On every context resume, rerun Step 0 and Step 1; do not trust conversation history for phase detection
|
|
53
|
+
- If `phase: build`, read the next unchecked task from tasks.md and continue
|
|
54
|
+
- If `phase: verify` and `verify_result: fail`, first run `bash "$COMET_STATE" transition <name> verify-fail`, then invoke `/comet-build`
|
|
55
|
+
- If `phase: open` but proposal/design/tasks are complete, run `bash "$COMET_GUARD" <change-name> open --apply` to repair state, then continue detection
|
|
56
|
+
- If `phase: archive`, only invoke `/comet-archive`; after archive succeeds, the change moves to the archive directory, so do not run guard against the old active directory
|
|
57
|
+
|
|
44
58
|
**Step 2: Phase Determination** (check in order, first match wins)
|
|
45
59
|
|
|
46
60
|
1. `archived: true` or change moved to archive → Workflow complete
|
|
47
61
|
2. `verify_result: pass` and `archived` is not `true` → Invoke `/comet-archive`
|
|
48
|
-
3. `
|
|
49
|
-
4. `phase:
|
|
50
|
-
5. `phase:
|
|
51
|
-
6.
|
|
62
|
+
3. `verify_result: fail` → run `bash "$COMET_STATE" transition <name> verify-fail`, then invoke `/comet-build`
|
|
63
|
+
4. `phase: verify` or tasks.md all checked → Invoke `/comet-verify`
|
|
64
|
+
5. `phase: build` or has Design Doc but plan/execution incomplete → Invoke `/comet-build`
|
|
65
|
+
6. `phase: design` or has change but no Design Doc → Invoke `/comet-design`
|
|
66
|
+
7. `phase: open` or active change exists but `.comet.yaml` is missing → Invoke `/comet-open`
|
|
67
|
+
8. No active change → Invoke `/comet-open`
|
|
52
68
|
|
|
53
69
|
If metadata conflicts with file state, use verifiable file state as source of truth and correct `.comet.yaml` before continuing.
|
|
54
70
|
|
|
@@ -74,7 +90,7 @@ If metadata conflicts with file state, use verifiable file state as source of tr
|
|
|
74
90
|
| `openspec list --json` fails | Check if openspec is installed, prompt user to run `openspec init` |
|
|
75
91
|
| Sub-skill unavailable | Stop workflow, prompt to install or enable the corresponding skill |
|
|
76
92
|
| `.comet.yaml` malformed or missing | Use file state as source of truth, correct with `bash $COMET_STATE set` then continue |
|
|
77
|
-
|
|
|
93
|
+
| Build/test fails | Return to build phase for fixes, do not enter verify |
|
|
78
94
|
| Incomplete change directory structure | Fill missing files according to `comet-open` artifact requirements |
|
|
79
95
|
|
|
80
96
|
### Phase Transitions
|
|
@@ -84,6 +100,8 @@ A single `/comet` invocation starts from the detected phase and advances to the
|
|
|
84
100
|
|
|
85
101
|
Flow chain: open → design → build → verify → archive
|
|
86
102
|
|
|
103
|
+
**Continuous execution requirement**: starting from the detected phase, the agent must automatically continue through all later phases without waiting for another user command, except at explicit decision points. After a phase completes, immediately enter the next phase.
|
|
104
|
+
|
|
87
105
|
Nodes requiring user participation:
|
|
88
106
|
1. Confirm design approach during brainstorming
|
|
89
107
|
2. Select execution mode during build phase
|
|
@@ -160,9 +178,16 @@ archived: false
|
|
|
160
178
|
Comet scripts are distributed in `comet/scripts/`. **Do not hardcode paths** — locate once, cache in env vars:
|
|
161
179
|
|
|
162
180
|
```bash
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
181
|
+
COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
|
|
182
|
+
COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
|
|
183
|
+
COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
|
|
184
|
+
COMET_ARCHIVE="${COMET_ARCHIVE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-archive.sh' -type f -print -quit 2>/dev/null)}"
|
|
185
|
+
|
|
186
|
+
if [ -z "$COMET_GUARD" ] || [ -z "$COMET_STATE" ] || [ -z "$COMET_ARCHIVE" ]; then
|
|
187
|
+
echo "ERROR: Comet scripts not found. Ensure the comet skill is installed." >&2
|
|
188
|
+
echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
|
|
189
|
+
return 1
|
|
190
|
+
fi
|
|
166
191
|
```
|
|
167
192
|
|
|
168
193
|
**Auto state update**: Guard supports `--apply` flag, automatically updating `.comet.yaml` state fields after checks pass:
|
|
@@ -171,6 +196,17 @@ COMET_ARCHIVE="${COMET_ARCHIVE:-$(find . -path '*/comet/scripts/comet-archive.sh
|
|
|
171
196
|
bash "$COMET_GUARD" <change-name> <phase> --apply
|
|
172
197
|
```
|
|
173
198
|
|
|
199
|
+
`--apply` delegates to `comet-state transition`. Use these semantic events when state changes need to be expressed directly:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
bash "$COMET_STATE" transition <change-name> open-complete
|
|
203
|
+
bash "$COMET_STATE" transition <change-name> design-complete
|
|
204
|
+
bash "$COMET_STATE" transition <change-name> build-complete
|
|
205
|
+
bash "$COMET_STATE" transition <change-name> verify-pass
|
|
206
|
+
bash "$COMET_STATE" transition <change-name> verify-fail
|
|
207
|
+
bash "$COMET_STATE" transition <archive-name> archived
|
|
208
|
+
```
|
|
209
|
+
|
|
174
210
|
**Archive script**: Complete all archive steps in one command:
|
|
175
211
|
|
|
176
212
|
```bash
|
|
@@ -224,7 +224,7 @@ else
|
|
|
224
224
|
step_ok "Moved to: $ARCHIVE_DIR"
|
|
225
225
|
fi
|
|
226
226
|
|
|
227
|
-
# --- Step 8:
|
|
227
|
+
# --- Step 8: Mark archived via comet-state transition ---
|
|
228
228
|
|
|
229
229
|
STEPS_TOTAL=$((STEPS_TOTAL + 1))
|
|
230
230
|
|
|
@@ -235,7 +235,7 @@ if [ "$DRY_RUN" -eq 1 ]; then
|
|
|
235
235
|
STEPS_OK=$((STEPS_OK + 1))
|
|
236
236
|
else
|
|
237
237
|
if [ -f "$ARCHIVE_YAML" ]; then
|
|
238
|
-
|
|
238
|
+
bash "$STATE_SH" transition "$ARCHIVE_NAME" archived >/dev/null
|
|
239
239
|
step_ok "archived: true"
|
|
240
240
|
else
|
|
241
241
|
step_fail "archived: true (.comet.yaml not found after move)"
|
|
@@ -37,10 +37,14 @@ validate_change_name "$1"
|
|
|
37
37
|
CHANGE="$1"
|
|
38
38
|
PHASE="$2"
|
|
39
39
|
APPLY=0
|
|
40
|
+
SCRIPT_DIR="$(dirname "$(readlink -f "$0" 2>/dev/null || echo "$0")" 2>/dev/null || dirname "$0")"
|
|
40
41
|
if [[ "${3:-}" == "--apply" ]]; then
|
|
41
42
|
APPLY=1
|
|
42
43
|
fi
|
|
43
44
|
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
45
|
+
if [ "$PHASE" = "archive" ] && [ ! -d "$CHANGE_DIR" ] && [ -d "openspec/changes/archive/$CHANGE" ]; then
|
|
46
|
+
CHANGE_DIR="openspec/changes/archive/$CHANGE"
|
|
47
|
+
fi
|
|
44
48
|
|
|
45
49
|
BLOCK=0
|
|
46
50
|
check() {
|
|
@@ -81,7 +85,6 @@ file_nonempty() {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
preflight() {
|
|
84
|
-
local expected_phase="$1"
|
|
85
88
|
|
|
86
89
|
if [ ! -d "$CHANGE_DIR" ]; then
|
|
87
90
|
red "FATAL: change directory not found: $CHANGE_DIR"
|
|
@@ -92,17 +95,9 @@ preflight() {
|
|
|
92
95
|
exit 1
|
|
93
96
|
fi
|
|
94
97
|
|
|
95
|
-
local actual_phase
|
|
96
|
-
actual_phase=$(yaml_field_value "phase" 2>/dev/null || true)
|
|
97
|
-
if [ "$actual_phase" != "$expected_phase" ]; then
|
|
98
|
-
red "FATAL: .comet.yaml phase is '$actual_phase', expected '$expected_phase'"
|
|
99
|
-
exit 1
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
98
|
# Schema validation
|
|
103
|
-
local
|
|
104
|
-
|
|
105
|
-
validate_script="$script_dir/comet-yaml-validate.sh"
|
|
99
|
+
local validate_script
|
|
100
|
+
validate_script="$SCRIPT_DIR/comet-yaml-validate.sh"
|
|
106
101
|
if [ -f "$validate_script" ]; then
|
|
107
102
|
if ! bash "$validate_script" "$CHANGE" 2>/dev/null; then
|
|
108
103
|
bash "$validate_script" "$CHANGE"
|
|
@@ -116,8 +111,19 @@ build_passes() {
|
|
|
116
111
|
if [ "${COMET_SKIP_BUILD:-0}" = "1" ]; then
|
|
117
112
|
return 0
|
|
118
113
|
fi
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
if [ -f "package.json" ] && grep -q '"build"' "package.json"; then
|
|
115
|
+
npm run build >/dev/null
|
|
116
|
+
return $?
|
|
117
|
+
fi
|
|
118
|
+
if [ -f "pom.xml" ]; then
|
|
119
|
+
mvn compile -q >/dev/null
|
|
120
|
+
return $?
|
|
121
|
+
fi
|
|
122
|
+
if [ -f "Cargo.toml" ]; then
|
|
123
|
+
cargo build >/dev/null
|
|
124
|
+
return $?
|
|
125
|
+
fi
|
|
126
|
+
return 1
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
verify_result_is_pass() {
|
|
@@ -126,6 +132,18 @@ verify_result_is_pass() {
|
|
|
126
132
|
[ "$result" = "pass" ]
|
|
127
133
|
}
|
|
128
134
|
|
|
135
|
+
verification_report_exists() {
|
|
136
|
+
local report
|
|
137
|
+
report=$(yaml_field_value "verification_report" 2>/dev/null || true)
|
|
138
|
+
[ -n "$report" ] && [ "$report" != "null" ] && [ -f "$report" ]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
branch_status_handled() {
|
|
142
|
+
local status
|
|
143
|
+
status=$(yaml_field_value "branch_status" 2>/dev/null || true)
|
|
144
|
+
[ "$status" = "handled" ]
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
archived_is_true() {
|
|
130
148
|
local val
|
|
131
149
|
val=$(yaml_field_value "archived" 2>/dev/null || true)
|
|
@@ -135,7 +153,7 @@ archived_is_true() {
|
|
|
135
153
|
# --- Phase-specific checks ---
|
|
136
154
|
|
|
137
155
|
guard_open() {
|
|
138
|
-
echo "=== Guard: open →
|
|
156
|
+
echo "=== Guard: open → next ===" >&2
|
|
139
157
|
|
|
140
158
|
check "proposal.md exists and non-empty" file_nonempty "$CHANGE_DIR/proposal.md"
|
|
141
159
|
check "design.md exists and non-empty" file_nonempty "$CHANGE_DIR/design.md"
|
|
@@ -170,9 +188,10 @@ guard_build() {
|
|
|
170
188
|
guard_verify() {
|
|
171
189
|
echo "=== Guard: verify → archive ===" >&2
|
|
172
190
|
|
|
173
|
-
check "verify_result is pass" verify_result_is_pass
|
|
174
191
|
check "tasks.md all tasks checked" tasks_all_done
|
|
175
192
|
check "Build passes" build_passes
|
|
193
|
+
check "verification_report exists" verification_report_exists
|
|
194
|
+
check "branch_status=handled" branch_status_handled
|
|
176
195
|
}
|
|
177
196
|
|
|
178
197
|
guard_archive() {
|
|
@@ -184,50 +203,30 @@ guard_archive() {
|
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
apply_state_update() {
|
|
187
|
-
local state_sh="$
|
|
206
|
+
local state_sh="$SCRIPT_DIR/comet-state.sh"
|
|
188
207
|
local p="$1"
|
|
189
208
|
|
|
190
209
|
if [ -f "$state_sh" ]; then
|
|
191
210
|
case "$p" in
|
|
192
|
-
open) bash "$state_sh"
|
|
193
|
-
design) bash "$state_sh"
|
|
194
|
-
build)
|
|
195
|
-
|
|
196
|
-
bash "$state_sh" set "$CHANGE" verify_result pending
|
|
197
|
-
;;
|
|
198
|
-
verify)
|
|
199
|
-
bash "$state_sh" set "$CHANGE" phase archive
|
|
200
|
-
bash "$state_sh" set "$CHANGE" verify_result pass
|
|
201
|
-
bash "$state_sh" set "$CHANGE" verified_at "$(date +%Y-%m-%d)"
|
|
202
|
-
;;
|
|
211
|
+
open) bash "$state_sh" transition "$CHANGE" open-complete ;;
|
|
212
|
+
design) bash "$state_sh" transition "$CHANGE" design-complete ;;
|
|
213
|
+
build) bash "$state_sh" transition "$CHANGE" build-complete ;;
|
|
214
|
+
verify) bash "$state_sh" transition "$CHANGE" verify-pass ;;
|
|
203
215
|
esac
|
|
204
216
|
else
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
open) sed -i 's/^phase:.*/phase: design/' "$yaml" ;;
|
|
208
|
-
design) sed -i 's/^phase:.*/phase: build/' "$yaml" ;;
|
|
209
|
-
build) sed -i 's/^phase:.*/phase: verify/' "$yaml"; sed -i 's/^verify_result:.*/verify_result: pending/' "$yaml" ;;
|
|
210
|
-
verify)
|
|
211
|
-
sed -i 's/^phase:.*/phase: archive/' "$yaml"
|
|
212
|
-
sed -i 's/^verify_result:.*/verify_result: pass/' "$yaml"
|
|
213
|
-
if ! grep -q '^verified_at:' "$yaml" 2>/dev/null; then
|
|
214
|
-
echo "verified_at: $(date +%Y-%m-%d)" >> "$yaml"
|
|
215
|
-
else
|
|
216
|
-
sed -i "s/^verified_at:.*/verified_at: $(date +%Y-%m-%d)/" "$yaml"
|
|
217
|
-
fi
|
|
218
|
-
;;
|
|
219
|
-
esac
|
|
217
|
+
red "FATAL: comet-state.sh not found; cannot apply state transition"
|
|
218
|
+
exit 1
|
|
220
219
|
fi
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
# --- Main ---
|
|
224
223
|
|
|
225
224
|
case "$PHASE" in
|
|
226
|
-
open) preflight
|
|
227
|
-
design) preflight
|
|
228
|
-
build) preflight
|
|
229
|
-
verify) preflight
|
|
230
|
-
archive) preflight
|
|
225
|
+
open) preflight ; guard_open ;;
|
|
226
|
+
design) preflight ; guard_design ;;
|
|
227
|
+
build) preflight ; guard_build ;;
|
|
228
|
+
verify) preflight ; guard_verify ;;
|
|
229
|
+
archive) preflight ; guard_archive ;;
|
|
231
230
|
*)
|
|
232
231
|
red "Unknown phase: $PHASE"
|
|
233
232
|
echo "Valid phases: open, design, build, verify, archive" >&2
|
|
@@ -245,7 +244,10 @@ else
|
|
|
245
244
|
if [ "$APPLY" -eq 1 ]; then
|
|
246
245
|
apply_state_update "$PHASE"
|
|
247
246
|
case "$PHASE" in
|
|
248
|
-
open)
|
|
247
|
+
open)
|
|
248
|
+
new_phase=$(grep "^phase:" "$CHANGE_DIR/.comet.yaml" | sed 's/^phase: *//' | tr -d '"' | tr -d "'")
|
|
249
|
+
green " [APPLY] .comet.yaml updated: phase=$new_phase"
|
|
250
|
+
;;
|
|
249
251
|
design) green " [APPLY] .comet.yaml updated: phase=build" ;;
|
|
250
252
|
build) green " [APPLY] .comet.yaml updated: phase=verify, verify_result=pending" ;;
|
|
251
253
|
verify) green " [APPLY] .comet.yaml updated: phase=archive, verify_result=pass" ;;
|