Skip to content

Commit 3d57487

Browse files
authored
feat: core issues in comet state machine and enhance workflows
2 parents 7f45708 + 7d4f1d0 commit 3d57487

31 files changed

Lines changed: 1352 additions & 337 deletions

File tree

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22

33
All notable changes to @rpamis/comet will be documented in this file.
44

5+
## What's Changed [0.2.4] - 2026-05-21
6+
7+
### Added
8+
9+
- **Verification evidence enforcement**: `verify-pass` transition now requires `verification_report` (file must exist) and `branch_status: handled` before allowing phase advance. Guard checks these as hard prerequisites
10+
- **`verification_report` and `branch_status` fields** in `.comet.yaml`: New state fields track verification report path and branch handling status
11+
- **Verification evidence step** in comet-verify (zh): New Step 4 requiring report file creation and branch status recording before guard apply
12+
- **`branch_status` enum validation**: `comet-state.sh set` validates `branch_status` as `pending` or `handled`
13+
- **Guard verify checks**: `comet-guard.sh` now checks `verification_report exists` and `branch_status=handled` during verify phase
14+
- **Bats test CRLF fix**: Shell tests strip `\r` from scripts before execution, fixing Windows compatibility
15+
- **`test:shell` runner**: Replaced direct `bats` call with `node scripts/run-bats.js` for cross-platform support
16+
17+
### Changed
18+
19+
- **Hotfix root cause check reordered**: Moved root cause elimination check **before** comet-verify loading (Step 3a → 3b split), preventing it from being skipped during verify flow
20+
- **Hotfix header description simplified**: Replaced ambiguous "not a separate parallel process" with direct "Quick bug fix workflow" for standalone invocation clarity
21+
- **Removed non-action steps from comet-design**: Deleted Step 3 (Dual Spec Division table) and Step 4 (Document Hierarchy) — pure reference material with no agent actions
22+
- **Removed duplicate script location blocks**: comet-open (Step 3) and comet-archive (Step 1) no longer repeat the full `COMET_SEARCH_ROOTS` find block when variables already cached
23+
- **Removed duplicate 50% threshold in comet-build**: Single mention in threshold determination table instead of table + bullet repetition
24+
- **Generic error handling**: Error table in comet main skill changed "Maven compile/test" → "Build/test" for language-agnostic wording
25+
- **comet-state.sh usage help**: Fixed `check` parameter order in help text (`check <change-name> <phase>`)
26+
27+
### Fixed
28+
29+
- **comet-state.sh `init` change directory resolution**: `cmd_init` now resolves `change_dir` before checking if `.comet.yaml` already exists, fixing path resolution for nested directories
30+
- **Guard deadlock on verify**: `verify-pass` transition now resets `verification_report` and `branch_status` when rolling back via `verify-fail`, preventing stale evidence from allowing false transitions
31+
32+
### Tests
33+
34+
- **+66 lines** in `comet-scripts.test.ts`: New tests for verification evidence blocking, branch status validation, and guard verify with evidence
35+
- **+12 lines** in `comet-state.bats`: New tests for `branch_status` enum validation, CRLF stripping, and new field presence in init output
36+
537
## What's Changed [0.2.3] - 2026-05-19
638

739
### Added

README-zh.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
117
# @rpamis/comet
218

319
```
@@ -48,12 +64,12 @@ comet init
4864
6. 将 Comet 技能(你选择的语言)部署到所选平台
4965
7. 创建 `docs/superpowers/specs/``docs/superpowers/plans/` 工作目录
5066

51-
## 运行截图
67+
> [!TIP]
68+
> 更新版本号
69+
>
70+
> 执行 comet update 或者 `npm install -g @rpamis/comet@latest` 即可更新到最新版本。
5271
53-
<p align="center">
54-
<img src="img/select-platform.png" alt="平台选择" width="600">
55-
</p>
56-
<p align="center">支持分发中文、英文 Skill 版本,支持 28 个 AI Coding 平台</p>
72+
## 运行截图
5773

5874
<p align="center">
5975
<img src="img/init.png" alt="初始化" width="600">
@@ -201,6 +217,8 @@ build_mode: subagent-driven-development
201217
isolation: branch
202218
verify_mode: light
203219
verify_result: pending
220+
verification_report: docs/superpowers/reports/YYYY-MM-DD-change-verify.md
221+
branch_status: pending
204222
verified_at: null
205223
archived: false
206224
```
@@ -222,12 +240,18 @@ Comet 通过自动化状态转换确保 agent 执行可靠性:
222240
- Guard 和 archive 脚本内部使用 `comet-state.sh` 进行状态管理
223241

224242
3. **模式校验** — `comet-yaml-validate.sh` 确保数据完整性
225-
- 校验必填字段(10 个字段)
226-
- 校验枚举值(7 种枚举类型)
243+
- 校验必填字段(12 个字段)
244+
- 校验枚举值(8 种枚举类型)
227245
- 校验引用文件路径存在
228246
- 检测未知/拼写错误字段
229247

230-
4. **归档自动化** — `comet-archive.sh` 一键处理完整归档流程
248+
4. **验证证据强制** — Guard 在阶段流转前强制要求验证凭证
249+
- `verify-pass` 转换要求 `verification_report` 指向已存在的验证报告文件
250+
- `branch_status` 必须为 `handled` 才能通过验证
251+
- Guard 检查 `verification_report exists` 和 `branch_status=handled` 作为硬性前提
252+
- 防止验证或分支处理被跳过时产生虚假的阶段推进
253+
254+
5. **归档自动化** — `comet-archive.sh` 一键处理完整归档流程
231255
- 验证入口状态、同步 delta specs 到 main specs
232256
- 标注设计文档和计划文档的 frontmatter
233257
- 将变更移至归档目录并更新 `archived: true`
@@ -310,4 +334,4 @@ pnpm format
310334

311335
## License
312336

313-
MIT
337+
[MIT](LICENSE.md)

README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
117
# @rpamis/comet
218

319
```
@@ -48,12 +64,12 @@ comet init
4864
6. Deploy Comet skills (in your chosen language) to selected platforms
4965
7. Create `docs/superpowers/specs/` and `docs/superpowers/plans/` working directories
5066

51-
## Screenshots
67+
> [!TIP]
68+
> update version
69+
>
70+
> comet update or `npm install -g @rpamis/comet@latest` to get the latest features and fixes.
5271
53-
<p align="center">
54-
<img src="img/select-platform.png" alt="Platform Selection" width="600">
55-
</p>
56-
<p align="center">Supports Chinese & English Skill distribution, 28 AI Coding platforms</p>
72+
## Screenshots
5773

5874
<p align="center">
5975
<img src="img/init.png" alt="Initialization" width="600">
@@ -201,6 +217,8 @@ build_mode: subagent-driven-development
201217
isolation: branch
202218
verify_mode: light
203219
verify_result: pending
220+
verification_report: docs/superpowers/reports/YYYY-MM-DD-change-verify.md
221+
branch_status: pending
204222
verified_at: null
205223
archived: false
206224
```
@@ -222,12 +240,18 @@ Comet ensures agent execution reliability through automated state transitions:
222240
- Guard and archive scripts use `comet-state.sh` internally for state management
223241

224242
3. **Schema Validation** — `comet-yaml-validate.sh` ensures data integrity
225-
- Validates required fields (10 fields)
226-
- Validates enum values (7 enum types)
243+
- Validates required fields (12 fields)
244+
- Validates enum values (8 enum types)
227245
- Validates referenced file paths exist
228246
- Detects unknown/typos fields
229247

230-
4. **Archive Automation** — `comet-archive.sh` handles the full archive flow in one command
248+
4. **Verification Evidence** — Guard enforces proof before phase advance
249+
- `verify-pass` transition requires `verification_report` pointing to an existing report file
250+
- `branch_status` must be `handled` before verify can pass
251+
- Guard checks `verification_report exists` and `branch_status=handled` as hard prerequisites
252+
- Prevents false phase advances when verification or branch handling was skipped
253+
254+
5. **Archive Automation** — `comet-archive.sh` handles the full archive flow in one command
231255
- Validates entry state, syncs delta specs to main specs
232256
- Annotates design doc and plan frontmatter
233257
- Moves change to archive directory and updates `archived: true`
@@ -310,4 +334,4 @@ See [CHANGELOG.md](CHANGELOG.md) for version history and updates.
310334

311335
## License
312336

313-
MIT
337+
[MIT](LICENSE.md)

assets/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.3",
2+
"version": "0.2.4",
33
"skills": [
44
"comet/SKILL.md",
55
"comet/scripts/comet-guard.sh",

assets/skills-zh/comet-archive/SKILL.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ description: "Comet 阶段 5:归档。用 /comet-archive 调用。同步 delta
1818
执行入口验证:
1919

2020
```bash
21-
COMET_STATE="${COMET_STATE:-$(find . -path '*/comet/scripts/comet-state.sh' -type f -print -quit)}"
21+
COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
22+
COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
2223
bash "$COMET_STATE" check <name> archive
2324
```
2425

@@ -29,7 +30,6 @@ bash "$COMET_STATE" check <name> archive
2930
运行归档脚本,自动完成以下全部步骤:
3031

3132
```bash
32-
COMET_ARCHIVE="${COMET_ARCHIVE:-$(find . -path '*/comet/scripts/comet-archive.sh' -type f -print -quit)}"
3333
bash "$COMET_ARCHIVE" "<change-name>"
3434
```
3535

@@ -39,7 +39,7 @@ bash "$COMET_ARCHIVE" "<change-name>"
3939
3. Design doc 前置元数据标注(archived-with, status)
4040
4. Plan 前置元数据标注(archived-with)
4141
5. 移动 change 到归档目录
42-
6. 更新 archived: true
42+
6. 通过 `comet-state transition <archive-name> archived` 更新 `archived: true`
4343

4444
如脚本返回非零退出码,报告错误并停止。
4545
如脚本返回零退出码,归档完成。
@@ -56,7 +56,10 @@ brainstorming → delta spec → 实施 → 验证 → 主 spec 覆盖 → desig
5656
## 退出条件
5757

5858
- 归档脚本执行成功(退出码 0)
59-
- **阶段守卫**:运行 `bash $COMET_GUARD <change-name> archive`,全部 PASS 后确认归档完整
59+
- 归档目录 `openspec/changes/archive/YYYY-MM-DD-<change-name>/` 存在
60+
- 归档后的 `.comet.yaml``archived: true`
61+
62+
归档脚本会把 `openspec/changes/<name>/` 移动到 `openspec/changes/archive/YYYY-MM-DD-<name>/`。归档成功后**不要再对原 change 名运行** `bash "$COMET_GUARD" <change-name> archive`,因为原活跃目录已经不存在。归档完整性以脚本退出码和归档目录状态为准。
6063

6164
## 完成
6265

assets/skills-zh/comet-build/SKILL.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ description: "Comet 阶段 3:计划与构建。用 /comet-build 调用。制
1717
执行入口验证:
1818

1919
```bash
20-
COMET_STATE="${COMET_STATE:-$(find . -path '*/comet/scripts/comet-state.sh' -type f -print -quit)}"
20+
COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
21+
COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
22+
COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
2123
bash "$COMET_STATE" check <name> build
2224
```
2325

@@ -36,9 +38,16 @@ bash "$COMET_STATE" check <name> build
3638
---
3739
change: <openspec-change-name>
3840
design-doc: docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md
41+
base-ref: <git rev-parse HEAD before implementation>
3942
---
4043
```
4144

45+
`base-ref` 用于验证阶段跨提交统计改动规模。创建计划时先记录当前提交:
46+
47+
```bash
48+
git rev-parse HEAD
49+
```
50+
4251
### 2. 更新计划状态
4352

4453
先记录 plan 路径:
@@ -127,21 +136,27 @@ bash "$COMET_STATE" set <name> build_mode <value>
127136
- delta spec 是活文档,本阶段期间随时可修改
128137
- 每次更新应提交,commit message 说明变更原因
129138
- 不提前同步到 main spec,归档时统一同步
130-
- 如增量任务超过原 tasks.md 初始任务总数 50%,考虑拆分为新 change
131139
- 小规模增量直接改 delta spec 时,应在 commit message 中注明,便于归档时判断 design doc 漂移
132140

141+
### 6. 上下文管理
142+
143+
Build 是最长阶段,可能跨越大量任务。为支持上下文压缩后断点恢复:
144+
145+
- **每完成一个 task**:立即勾选 tasks.md 并提交代码,确保 `.comet.yaml` 和文件状态持久化
146+
- **上下文压缩后恢复**:读取 `.comet.yaml``phase` 字段确认仍在 build 阶段,读取 plan 文件头的 `base-ref`,再读取 tasks.md 找到下一个未勾选任务继续执行
147+
- **长任务拆分**:单任务超过 200 行代码变更时,考虑拆分为多个子任务分别提交
148+
133149
## 退出条件
134150

135151
- tasks.md 全部勾选
136152
- 代码已提交
137-
- 测试通过
138-
- `.comet.yaml``phase` 已更新为 `verify`
139-
- **阶段守卫**:运行 `bash $COMET_GUARD <change-name> build`,全部 PASS 后才允许流转
153+
- 已显式运行项目对应的构建/测试命令并通过(不要只依赖 guard 自动猜测)
154+
- **阶段守卫**:运行 `bash "$COMET_GUARD" <change-name> build --apply`,全部 PASS 后自动流转到 `phase: verify`
140155

141156
退出前运行 guard 自动流转:
142157

143158
```bash
144-
bash $COMET_GUARD <change-name> build --apply
159+
bash "$COMET_GUARD" <change-name> build --apply
145160
```
146161

147162
状态文件自动更新为 `phase: verify``verify_result: pending`

assets/skills-zh/comet-design/SKILL.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ description: "Comet 阶段 2:深度设计。用 /comet-design 调用。通过
1717
执行入口验证:
1818

1919
```bash
20-
COMET_STATE="${COMET_STATE:-$(find . -path '*/comet/scripts/comet-state.sh' -type f -print -quit)}"
20+
COMET_SEARCH_ROOTS=("." "$HOME/.claude/skills" "$HOME/.codex/skills" "$HOME/.cursor/skills")
21+
COMET_STATE="${COMET_STATE:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-state.sh' -type f -print -quit 2>/dev/null)}"
22+
COMET_GUARD="${COMET_GUARD:-$(find "${COMET_SEARCH_ROOTS[@]}" -path '*/comet/scripts/comet-guard.sh' -type f -print -quit 2>/dev/null)}"
2123
bash "$COMET_STATE" check <name> design
2224
```
2325

@@ -57,32 +59,23 @@ Design 摘要: <design.md 架构决策>
5759
bash "$COMET_STATE" set <name> design_doc docs/superpowers/specs/YYYY-MM-DD-topic-design.md
5860

5961
# 自动流转到下一阶段
60-
bash $COMET_GUARD <change-name> design --apply
62+
bash "$COMET_GUARD" <change-name> design --apply
6163
```
6264

6365
状态文件自动更新,无需手动编辑其他字段。
6466

65-
### 3. 双 Spec 分工
66-
67-
| Spec 类型 | 归属 | 存放位置 | 定义 |
68-
|-----------|------|---------|------|
69-
| 能力规格 | OpenSpec | `openspec/changes/<name>/specs/` | 系统应该做什么(需求 + 验收场景) |
70-
| 设计文档 | Superpowers | `docs/superpowers/specs/` | 怎么构建(技术架构 + 实现细节) |
71-
72-
### 4. 文档层级确认
73-
74-
```
75-
proposal.md(阶段 1) → Why + What
76-
design.md(阶段 1,OpenSpec) → 高层架构决策
77-
设计文档(阶段 2,Superpowers) → 深度技术设计
78-
能力规格(阶段 2,delta) → 需求 + 验收场景
79-
```
80-
8167
## 退出条件
8268

8369
- Design Doc 已创建并保存
8470
- 如有新能力则 delta spec 已创建
85-
- **阶段守卫**:运行 `bash $COMET_GUARD <change-name> design`,全部 PASS 后才允许流转
71+
- `design_doc` 已写入 `.comet.yaml`
72+
- **阶段守卫**:运行 `bash "$COMET_GUARD" <change-name> design --apply`,全部 PASS 后自动流转到 `phase: build`
73+
74+
退出前必须使用 `--apply`
75+
76+
```bash
77+
bash "$COMET_GUARD" <change-name> design --apply
78+
```
8679

8780
## 自动流转
8881

0 commit comments

Comments
 (0)