跳转到主要内容
Comet 的关键功能之一,是能够在不丢失进度的情况下恢复中断的 workflow。每个 phase transition 都记录在 .comet.yaml 中,因此 AI agent 可以从磁盘而不是 conversation history 重建当前 state。你不需要记住自己停在哪里,Comet 会读取文件。

Resume 如何工作

  1. 在之前工作的同一项目目录中打开你的 AI 编程工具
  2. 输入 /comet,无需参数。
  3. Comet 运行 openspec list --json,发现项目中的所有 active changes。
  4. 对找到的每个 active change,Comet 会读取其 .comet.yaml,判断 phase、build mode、verification status 和其他 workflow state。
  5. 如果只有一个 active change:Comet 会自动选择它,并直接进入 phase detection。
  6. 如果有多个 active changes:Comet 会列出它们,让你选择要恢复哪一个。
  7. Comet 会从检测到的 phase 恢复执行,并自动推进后续 phases,直到到达 decision point 或 workflow 完成。

Phase detection 逻辑

Comet 会按顺序检查 .comet.yaml fields。第一个匹配条件决定恢复点:
.comet.yaml 中的条件采取的操作
archived: true(或 change 已移动到 archive directory)Workflow complete,没有需要恢复的内容
verify_result: passarchived 不是 true恢复到 → /comet-archive
verify_result: failPause,请你选择修复问题还是接受 deviation
phase: verify tasks.md 中所有 tasks 已勾选恢复到 → /comet-verify
phase: build Design Doc 存在但 plan/execution 未完成根据 workflow 字段恢复到 → /comet-hotfix/comet-tweak/comet-build
phase: design active change 存在但尚无 Design Doc恢复到 → /comet-design
phase: open active change 存在但 .comet.yaml 缺失恢复到 → /comet-open
未找到 active change重新开始 → /comet-open
如果 .comet.yaml metadata 与文件实际状态冲突,Comet 会使用可验证的 file state as the source of truth,并在继续前修正 .comet.yaml

Dirty Worktree Handling

如果恢复时 working directory 中有 uncommitted changes,Comet 会检查这些 changes 的来源,并根据 dirty-worktree protocol 处理。它会判断未提交工作是否属于当前 change、是否需要 stash,或是否表示继续前应处理的 out-of-scope expansion。

Special Case: build_pause: plan-ready Resume

当你在 plan generation 后暂停以切换 AI models(例如从 planning model 切到 coding model)时,Comet 会在 .comet.yaml 中记录 build_pause: plan-ready 恢复时,Comet 会对此进行特殊处理:
  • 检测 .comet.yaml 中的 build_pause: plan-ready
  • 复用你的现有 plan,不会重新生成
  • 验证 plan file 是否仍存在于磁盘上;如果缺失,则处理 corrupted state 或提供重新生成选项
  • 返回到你选择 isolation methodbranchworktree)和 execution modedirectsubagent-driven-development 等)的步骤
这意味着即使你故意在该 checkpoint 中断 workflow,planning work 也不会丢失。

Comet 在 Resume 时不会做什么

  • 不会依赖 conversation history 来判断当前 phase
  • 不会要求你描述之前在做什么
  • 不会从头重新检查所有项目文件(而是直接读取 .comet.yaml 和 file state)
Comet 从不信任 conversation history 来进行 phase detection。每次 context resume 时,它都会重新读取 .comet.yaml 和 file state。无论 session 中断了多久,期间发生了多少无关对话,恢复都能保持可靠。