build:{name:"build",description:"The default agent. Executes tools based on configured permissions.",options:{},permission:PermissionNext.merge(defaults,PermissionNext.fromConfig({question:"allow",plan_enter:"allow",}),user, ),mode:"primary",native:true,},
plan Agent 是 build 的"只读版"——它可以阅读代码、搜索文件、与用户讨论方案,但禁止编辑任何文件,唯一的例外是 .opencode/plans/ 目录下的计划文件。
这种设计实现了一种"先规划、后执行"的工作流:
用户进入 Plan 模式(通过 plan_enter 工具或 /plan 命令)。
Agent 切换到 plan 角色,只能读取和分析代码。
Agent 制定计划并写入 .opencode/plans/ 目录。
用户确认后,Agent 退出 Plan 模式(plan_exit)回到 build 角色开始执行。
系统会在模式切换时注入相应的 Prompt:进入 Plan 模式时注入 plan.txt(强调只读约束),退出时注入 build-switch.txt(解除只读限制)。
6.2.3 general Agent:通用子 Agent
general 是默认的子 Agent——当主 Agent 使用 Task 工具委托子任务但不指定特定 Agent 时,就会使用 general。
值得注意的是,general禁用了 Todo 工具(todoread 和 todowrite 设为 "deny")。这是因为 Todo 列表是主 Agent 的协调工具,子 Agent 管理自己的 Todo 会导致 Todo 列表混乱——多个子 Agent 同时修改同一个 Todo 列表可能产生冲突。
general: {
name: "general",
description: `General-purpose agent for researching complex questions
and executing multi-step tasks. Use this agent to execute
multiple units of work in parallel.`,
permission: PermissionNext.merge(
defaults,
PermissionNext.fromConfig({
todoread: "deny",
todowrite: "deny",
}),
user,
),
options: {},
mode: "subagent",
native: true,
},
You are a file search specialist. You excel at thoroughly navigating
and exploring codebases.
Your strengths:
- Rapidly finding files using glob patterns
- Searching code and text with powerful regex patterns
- Reading and analyzing file contents
Guidelines:
- Do not create any files, or run bash commands that modify
the user's system state in any way