# 任务定义格式

> 任务是具有以下结构的 JSON 对象：

Source: https://bifrost5.com/zh/foundry/docs/task-schema/

# 任务定义格式

Information

Describe an idea in plain words and get back a checked, ready-to-run task list from the Production-Grade planning companion.

[See editions](/zh/foundry/docs/editions)

任务是具有以下结构的 JSON 对象：

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `task_id` | string | 是 | 唯一标识符 |
| `project_id` | string | 是 | `sandbox/` 下的沙箱目录名称 |
| `intent` | string | 是 | 简短描述 |
| `tool` | string | 否 | `cursor` \| `gemini` \| `copilot` \| `codex` \| `claude` \| `ollama`。用于覆盖默认模型提供方；缺省时由执行策略决定。 |
| `instructions` | string | 是 | 面向智能体的详细指令 |
| `acceptance_criteria` | string[] | 是 | 必须全部满足方可视为完成 |
| `retry_policy` | object | 否 | `max_retries`、`backoff_strategy` (linear \| exponential) |
| `status` | string | 否 | `pending` \| `in_progress` \| `completed` \| `blocked` |
| `working_directory` | string | 否 | 相对于沙箱根目录的路径 |
| `agent_mode` | string | 否 | 例如 `opus-4.5`、`auto` |
| `affects_files` | string[] | 是（并发模式） | 此任务会修改的文件列表，用于文件锁机制 |
| `depends_on` | string[] | 否 | 必须前置完成的任务 ID；依赖条件全部满足后将自动推进 |
| `test_command` | string | 否 | 用于验证结果的测试命令 |
| `tests_required` | boolean | 否 | 测试是否必须通过 |

## 任务文件示例

```
[
  {
    "task_id": "frontend-001",
    "intent": "Extend existing React component",
    "tool": "gemini",
    "instructions": "Extend the existing App.tsx component to add user authentication.",
    "acceptance_criteria": [
      "App.tsx includes authentication logic",
      "Uses existing React Router setup"
    ],
    "retry_policy": { "max_retries": 2 },
    "status": "pending"
  }
]
```

## 任务生命周期

**待处理** → **进行中** → **已完成**（通过验证）或 **已阻塞**（达到最大重试次数后失败）。
