recover

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Recover Workflow Context

恢复工作流上下文

Restore workflow state and todo items from checkpoint files after context compaction or session loss.
会话压缩或丢失后,从检查点文件恢复工作流状态和待办事项。

Usage

使用场景

Use this command when:
  • Context was compacted and you've lost track of the workflow
  • Session was interrupted and needs to resume
  • Todo items need to be restored from a checkpoint
  • The automatic recovery didn't trigger
在以下情况使用此命令:
  • 上下文已被压缩,你无法追踪工作流进度
  • 会话被中断,需要恢复
  • 需要从检查点恢复待办事项
  • 自动恢复未触发

Recovery Process

恢复流程

Step 1: Find Latest Checkpoint

步骤1:查找最新检查点

Look for checkpoint files in the reports directory:
bash
ls -la plans/reports/memory-checkpoint-*.md | tail -5
Or search for all recent checkpoints:
bash
find plans -name "memory-checkpoint-*.md" -mmin -60 | head -5
在reports目录中查找检查点文件:
bash
ls -la plans/reports/memory-checkpoint-*.md | tail -5
或者搜索所有最近60分钟内的检查点:
bash
find plans -name "memory-checkpoint-*.md" -mmin -60 | head -5

Step 2: Read Checkpoint File

步骤2:读取检查点文件

Read the most recent checkpoint to understand the saved state:
Read the checkpoint file at: plans/reports/memory-checkpoint-YYMMDD-HHMMSS.md
读取最新的检查点文件,了解已保存的状态:
读取路径为以下位置的检查点文件:plans/reports/memory-checkpoint-YYMMDD-HHMMSS.md

Step 3: Extract Recovery Metadata

步骤3:提取恢复元数据

The checkpoint file contains a JSON metadata block at the end:
json
{
  "sessionId": "...",
  "activePlan": "plans/YYMMDD-slug/",
  "workflowType": "feature",
  "currentStep": "cook",
  "remainingSteps": ["test", "code-review"],
  "pendingTodos": [...]
}
检查点文件末尾包含一个JSON元数据块:
json
{
  "sessionId": "...",
  "activePlan": "plans/YYMMDD-slug/",
  "workflowType": "feature",
  "currentStep": "cook",
  "remainingSteps": ["test", "code-review"],
  "pendingTodos": [...]
}

Step 4: Restore Todo Items

步骤4:恢复待办事项

IMMEDIATELY call TodoWrite with the pending todos from the checkpoint.
立即调用TodoWrite,传入检查点中的待办事项。

Step 5: Read Active Plan (if exists)

步骤5:读取活跃计划(如果存在)

If
activePlan
is set in the metadata, read the plan file.
如果元数据中设置了
activePlan
,请读取该计划文件。

Step 6: Continue Workflow

步骤6:继续工作流

Resume from the
currentStep
identified in the metadata. Execute the remaining workflow steps in order.
从元数据中确定的
currentStep
恢复工作流,按顺序执行剩余的工作流步骤。

Recovery Checklist

恢复检查清单

  • Located most recent checkpoint file
  • Read checkpoint content
  • Extracted recovery metadata JSON
  • Restored todo items via TodoWrite
  • Read active plan (if applicable)
  • Identified current workflow step
  • Ready to continue from interrupted step
  • 找到最新的检查点文件
  • 读取检查点内容
  • 提取恢复元数据JSON
  • 通过TodoWrite恢复待办事项
  • 读取活跃计划(如适用)
  • 确定当前工作流步骤
  • 准备从中断步骤继续

Automatic vs Manual Recovery

自动恢复 vs 手动恢复

ScenarioRecovery TypeTrigger
Session resume after compactAutomatic
session-resume.cjs
hook
New session in same directoryManualThis
/recover
command
Explicit user requestManualThis
/recover
command
No workflow state foundManualThis
/recover
command
场景恢复类型触发条件
压缩后恢复会话自动
session-resume.cjs
钩子
同一目录下启动新会话手动
/recover
命令
用户明确请求恢复手动
/recover
命令
未找到工作流状态手动
/recover
命令

Related Commands

相关命令

  • /checkpoint
    - Create a manual checkpoint (before expected loss)
  • /compact
    - Manually trigger context compaction
  • /context
    - Load project context
  • /watzup
    - Generate progress summary

IMPORTANT Task Planning Notes (MUST FOLLOW)
  • Always plan and break work into many small todo tasks
  • Always add a final review todo task to verify work quality and identify fixes/enhancements
  • /checkpoint
    - 创建手动检查点(在预期丢失前执行)
  • /compact
    - 手动触发上下文压缩
  • /context
    - 加载项目上下文
  • /watzup
    - 生成进度摘要

重要任务规划注意事项(必须遵守)
  • 始终将工作规划并拆分为多个小的待办任务
  • 始终添加一个最终审核待办任务,以验证工作质量并确定需要修复/优化的内容