解耦的 State Files
| File | Owner | 用途 |
|---|---|---|
.openspec.yaml | OpenSpec | 由 OpenSpec Skills 管理的 spec lifecycle metadata、change identity 和 status annotations |
.comet.yaml | Comet | 由 Comet scripts 管理的 workflow phase、execution mode(build_mode、isolation)、verification status、artifact paths 和 archive state |
openspec/changes/<name>/ 下的 change directory 中。保持分离意味着 OpenSpec operations 永远不会破坏 Comet workflow state,Comet state updates 也不会干扰 OpenSpec 的 spec-lifecycle logic。从直接编辑的角度看,Agents 应将 .comet.yaml 视为只读,所有写入都应通过 comet-state.sh 完成。
The .comet.yaml File
一个完整填充的 .comet.yaml 如下所示:
核心字段
| 字段 | 允许值 | 含义 |
|---|---|---|
workflow | full, hotfix, tweak | 此 change 使用的 workflow preset。它在 init 时设置,并驱动整个 pipeline 中的 routing decisions。 |
phase | open, design, build, verify, archive | 当前 workflow phase。由 comet-state.sh init 初始化为 open;只能通过 guard transitions 推进。 |
build_mode | subagent-driven-development, tdd, direct, or null | 用户在 build 阶段选择的 Superpowers execution method。必须在 build → verify transition 前设置。 |
build_pause | plan-ready, null | 内部 build-phase pause marker。参见下方 The build_pause Field。 |
isolation | branch, worktree, null | Workspace isolation method。hotfix 和 tweak 默认使用 branch;full workflow 会保持 null,直到用户在 Phase 3 选择。必须在 build → verify 前解析完成。 |
verify_mode | light, full, null | Verification thoroughness。tweak 使用 light;full workflow 和 hotfix 使用 full。 |
verify_result | pending, pass, fail | 最近一次 verification run 的结果。pass 作为 archive phase 的门禁;fail 会触发阻塞性的用户决策。 |
verification_report | File path or null | 已写入 verification report file 的路径。必须指向一个现有文件,才允许 verify-pass transition。 |
branch_status | pending, handled | Branch operations(merge、close 或 carry-forward)是否已完成。Verify 通过前必须是 handled。 |
archived | true, false | Change 是否已完成 archive phase。一旦为 true,workflow 即完成,目录已移动到 archive tree。 |
verified_at | ISO timestamp or null | 应用 verify-pass transition 时由 comet-state.sh 写入的 timestamp。 |
created_at | Date string (YYYY-MM-DD) or null | Change 创建日期,由 comet-state.sh init 自动设置。 |
Artifact Path 字段
| 字段 | 允许值 | 含义 |
|---|---|---|
design_doc | File path or null | Phase 2 产出的 Superpowers Design Doc(technical RFC)路径。Brainstorming 完成后由 comet-design 写入。 |
plan | File path or null | Phase 3 产出的 Superpowers implementation plan 路径。生成 plan file 时写入。 |
base_ref | Git commit SHA or null | Change init 时记录的 Git commit SHA。在没有 plan 时用于 scale assessment。 |
handoff_context | File path or null | 离开 Phase 2 时由 comet-handoff.sh 生成的 design-context JSON package 路径。用于将可追踪的 OpenSpec context 传入 Superpowers。 |
handoff_hash | SHA-256 hex string or null | handoff context file 的 hash,由 comet-handoff.sh 记录。Guard 会在 build phase 开始前验证此 hash。 |
可选和 Override 字段
| 字段 | 允许值 | 含义 |
|---|---|---|
direct_override | true, false | 允许在 full workflow 中使用 build_mode: direct。必须显式设置为 true;没有此 flag 时,guard 会阻止 full workflows 使用 direct mode。 |
build_command | Shell command string or null | Project build command。如果已设置,comet-guard.sh 会在 build-phase validation 期间先运行它并打印失败输出。 |
verify_command | Shell command string or null | Project verification command。Verify guard 会先运行它;如果不存在,则回退到 build_command。 |
State Machine Constraints
The build_pause Field
build_pause 是只在 build 阶段内部使用的特殊 marker,用于记录一次有意的阶段中暂停。它 不是 execution mode,绝不能赋值给 build_mode。
| Value | 含义 |
|---|---|
null | 当前没有 pause。正常 build execution。 |
plan-ready | Implementation plan 已生成。用户选择在此暂停,通常是为了在开始执行前切换 AI models,并且尚未选择 isolation 或 build_mode。 |
plan-ready pause 时:
- Comet 检测到
build_pause: plan-ready,并确认plan中路径指向的 plan file 存在。 - 现有 plan 会原样复用,不会重新生成。
- 系统会提示用户选择
isolation和build_mode以继续。 - 两者都选择后,
build_pause会清除为null,execution 恢复。
build_pause: plan-ready 但 plan file 缺失,Comet 会进入 corrupted-state recovery flow,并可能重新生成 plan。
State Transitions 如何工作
Agents 使用comet-state.sh 通过 state transitions 推进 .comet.yaml。不允许直接编辑 YAML,所有 state writes 都要通过该脚本,以确保 schema validity、enum correctness 和一致的 field co-updates。
实践中,大多数 transitions 会在 phase exits 时由 comet-guard.sh --apply 自动触发。--apply flag 会指示 guard 验证 exit conditions;如果通过,则在内部调用 comet-state.sh transition。必要时你也可以直接触发 transitions:
| Event | 对 .comet.yaml 的影响 |
|---|---|
open-complete | 设置 phase: design |
design-complete | 设置 phase: build,写入 handoff_context 和 handoff_hash |
build-complete | 设置 phase: verify |
verify-pass | 设置 verify_result: pass,写入 verified_at timestamp |
verify-fail | 设置 verify_result: fail |
archived | 设置 archived: true、phase: archive |
$COMET_BASH 和 $COMET_STATE 是由 comet-env.sh 导出的环境变量。始终先 source 这个 helper,并在整个会话中使用这些变量,而不是硬编码 script paths:
Guard vs. Direct Transition
| 方法 | 何时使用 |
|---|---|
comet-guard.sh <name> <phase> --apply | 阶段结束时使用。先验证 exit conditions,然后应用 transition |
comet-state.sh transition <name> <event> | 当不需要 guard validation 时直接更新 state(例如 recovery flows、script internals) |
comet-state.sh transition 会绕过 validation,只有在调用上下文已经独立验证 preconditions 时才应这样做。