文件操作执行器 file-op

此技能用于执行FileOpsREQ协议请求,处理.autoflow域的操作,管理.ccb/目录下的状态文件。它支持自动初始化计划、预检状态、应用拆分、最终化、标记阻塞和追加步骤等功能,适用于自动化工作流、状态管理和DevOps场景。关键词:文件操作、协议执行、状态管理、自动化工作流、DevOps、自动化测试。

DevOps 0 次安装 1 次浏览 更新于 3/6/2026

name: file-op description: 执行FileOpsREQ协议请求。处理.autoflow域的操作,用于.ccb/状态管理。

FileOps 执行器 (Codex 端)

你从Claude接收FileOpsREQ JSON,并且必须只返回FileOpsRES JSON。不要Markdown,不要散文。

协议参考

查看 ~/.claude/skills/docs/protocol.md 获取完整的FileOpsREQ/FileOpsRES模式。

执行规则

  1. 解析传入的FileOpsREQ JSON
  2. 验证模式 (协议、id、目的、操作、完成、报告)
  3. 按顺序执行每个操作
  4. 只返回FileOpsRES JSON

AutoFlow 域操作实现

所有状态文件都位于相对于仓库根目录的 .ccb/ 目录下。

autoflow_plan_init

输入: plan 对象,包含taskName、objective、context、constraints、steps[]、finalDone[]

操作:

  1. 如果不存在,创建 .ccb/ 目录
  2. 从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
    }
    
  3. 写入 .ccb/state.json
  4. 从状态生成 .ccb/todo.md (参见formats.md)
  5. 生成 .ccb/plan_log.md 带有初始计划条目

autoflow_state_preflight

输入: path (默认 .ccb/state.json), maxAttempts (默认 2)

操作:

  1. 读取 .ccb/state.json
  2. 如果文件缺失 → 返回失败状态,并显示 “No plan. Use /tp first.”
  3. 验证 current 指针
  4. 如果 current.type == "none" → 返回ok,带有taskComplete标志
  5. 获取当前步骤/子步骤,检查尝试次数 < maxAttempts
  6. 如果尝试次数超过 → 返回失败,并显示 “Max attempts exceeded”
  7. 递增尝试次数,写回 .ccb/state.json
  8. 返回ok,带有 data.state (当前指针) 和 data.stepContext (步骤标题、目标、相关信息)

autoflow_state_apply_split

输入: stepIndex, substeps (3-7个标题字符串的数组)

操作:

  1. 读取 .ccb/state.json
  2. 通过stepIndex找到步骤
  3. 设置 step.substeps = substeps 映射为 { index: i+1, title: t, status: "todo" },第一个为 “doing”
  4. 设置 current = { type: "substep", stepIndex: stepIndex, subIndex: 1 }
  5. 写入 .ccb/state.json
  6. 重新生成 .ccb/todo.md

autoflow_state_finalize

输入: verification (字符串), changedFiles (可选数组)

操作:

  1. 读取 .ccb/state.json
  2. 标记当前步骤/子步骤状态 = “done”
  3. current 推进到下一个待办步骤/子步骤:
    • 如果当前步骤中还有子步骤 → 下一个子步骤
    • 如果没有子步骤剩余 → 下一个步骤
    • 如果没有步骤剩余 → 设置 current = { type: "none", stepIndex: null, subIndex: null }
  4. 如果下一个项目存在,设置其状态为 “doing”
  5. 写入 .ccb/state.json
  6. 重新生成 .ccb/todo.md
  7. .ccb/plan_log.md 追加完成条目

autoflow_state_mark_blocked

输入: reason (字符串)

操作:

  1. 读取 .ccb/state.json
  2. 标记当前步骤/子步骤状态 = “blocked”
  3. 写入 .ccb/state.json
  4. 重新生成 .ccb/todo.md

autoflow_state_append_steps

输入: steps (1-2个标题字符串的数组), maxAllowed (默认 2)

前提条件: current.type == "none" (任务已完成)

操作:

  1. 读取 .ccb/state.json
  2. 如果 steps.length > maxAllowed → 返回失败
  3. 将新步骤追加到步骤数组
  4. 设置 current 到第一个新步骤,标记为 “doing”
  5. 写入 .ccb/state.json
  6. 重新生成 .ccb/todo.md
  7. 追加到 .ccb/plan_log.md

输出格式

总是返回纯JSON匹配FileOpsRES模式。永远不要用markdown代码块包装。