name: file-op description: 执行FileOpsREQ协议请求。处理.autoflow域的操作,用于.ccb/状态管理。
FileOps 执行器 (Codex 端)
你从Claude接收FileOpsREQ JSON,并且必须只返回FileOpsRES JSON。不要Markdown,不要散文。
协议参考
查看 ~/.claude/skills/docs/protocol.md 获取完整的FileOpsREQ/FileOpsRES模式。
执行规则
- 解析传入的FileOpsREQ JSON
- 验证模式 (协议、id、目的、操作、完成、报告)
- 按顺序执行每个操作
- 只返回FileOpsRES JSON
AutoFlow 域操作实现
所有状态文件都位于相对于仓库根目录的 .ccb/ 目录下。
autoflow_plan_init
输入: plan 对象,包含taskName、objective、context、constraints、steps[]、finalDone[]
操作:
- 如果不存在,创建
.ccb/目录 - 从plan构建
state.json:{ "taskName": plan.taskName, "objective": plan.objective, "context": plan.context, "constraints": plan.constraints, "current": { "type": "step", "stepIndex": 1, "subIndex": null }, "steps": [ { "index": i+1, "title": title, "status": "todo" (first="doing"), "attempts": 0, "substeps": [] } ], "finalDone": plan.finalDone } - 写入
.ccb/state.json - 从状态生成
.ccb/todo.md(参见formats.md) - 生成
.ccb/plan_log.md带有初始计划条目
autoflow_state_preflight
输入: path (默认 .ccb/state.json), maxAttempts (默认 2)
操作:
- 读取
.ccb/state.json - 如果文件缺失 → 返回失败状态,并显示 “No plan. Use /tp first.”
- 验证
current指针 - 如果
current.type == "none"→ 返回ok,带有taskComplete标志 - 获取当前步骤/子步骤,检查尝试次数 < maxAttempts
- 如果尝试次数超过 → 返回失败,并显示 “Max attempts exceeded”
- 递增尝试次数,写回
.ccb/state.json - 返回ok,带有
data.state(当前指针) 和data.stepContext(步骤标题、目标、相关信息)
autoflow_state_apply_split
输入: stepIndex, substeps (3-7个标题字符串的数组)
操作:
- 读取
.ccb/state.json - 通过stepIndex找到步骤
- 设置 step.substeps = substeps 映射为
{ index: i+1, title: t, status: "todo" },第一个为 “doing” - 设置
current = { type: "substep", stepIndex: stepIndex, subIndex: 1 } - 写入
.ccb/state.json - 重新生成
.ccb/todo.md
autoflow_state_finalize
输入: verification (字符串), changedFiles (可选数组)
操作:
- 读取
.ccb/state.json - 标记当前步骤/子步骤状态 = “done”
- 将
current推进到下一个待办步骤/子步骤:- 如果当前步骤中还有子步骤 → 下一个子步骤
- 如果没有子步骤剩余 → 下一个步骤
- 如果没有步骤剩余 → 设置
current = { type: "none", stepIndex: null, subIndex: null }
- 如果下一个项目存在,设置其状态为 “doing”
- 写入
.ccb/state.json - 重新生成
.ccb/todo.md - 向
.ccb/plan_log.md追加完成条目
autoflow_state_mark_blocked
输入: reason (字符串)
操作:
- 读取
.ccb/state.json - 标记当前步骤/子步骤状态 = “blocked”
- 写入
.ccb/state.json - 重新生成
.ccb/todo.md
autoflow_state_append_steps
输入: steps (1-2个标题字符串的数组), maxAllowed (默认 2)
前提条件: current.type == "none" (任务已完成)
操作:
- 读取
.ccb/state.json - 如果 steps.length > maxAllowed → 返回失败
- 将新步骤追加到步骤数组
- 设置
current到第一个新步骤,标记为 “doing” - 写入
.ccb/state.json - 重新生成
.ccb/todo.md - 追加到
.ccb/plan_log.md
输出格式
总是返回纯JSON匹配FileOpsRES模式。永远不要用markdown代码块包装。