OpenCode 知识库
OpenCode 可以合并组织、用户、项目与 managed config,加载 AGENTS.md 和 instruction files,委派 primary agents 与 subagents,并调用本地或远程 MCP tools。这些层解释执行方式,但不会让 session summary 自动成为 canonical。
配置优先级
记录 OpenCode Agent 权限前,先解析实际生效的 config。
OpenCode 合并 remote organization defaults、global config、custom paths、project config、`.opencode` directories、inline content 与 managed settings。保留解析后的输入和 repository revision,不要拿某一个文件代表整个 runtime。
来自 .well-known 的组织默认值
用户偏好与 runtime defaults
仓库专属 config 与 files
管理员强制的最高优先级 policy
Rules 与 instructions
AGENTS.md 管行为,instruction references 不能变成事实仓库。
OpenCode 加载项目与全局 AGENTS.md,支持 Claude-compatible fallback,也能通过 instructions array 引用本地文件或远程 URL。团队指导随仓库提交,个人偏好留在 global,变化事实从 owner 查询。
修改该 package 后运行 focused tests。
客户审批已完成,production 正常。
Agent topology
Primary agents、subagents 与 hidden system agents 形成不同证据链。
Build 与 Plan 是 primary agents;General、Explore、Scout 是 subagents;compaction、title、summary agents 处理隐藏支持任务。记录谁执行、谁委派,以及哪套 tool permissions 生效。
| Agent role | 典型权限 | 需要保留的证据 |
|---|---|---|
| Build | 写入与执行 | Diffs、commands、tests |
| Plan | 受限写入的分析 | Plan 与引用仓库上下文 |
| General | 委派多步骤工作 | Task boundary 与返回工件 |
| Explore / Scout | 只读发现 | 检查过的 files 或外部来源 |
| Hidden system agents | 上下文支持 | 必要时保留 summary provenance |
Permission resolution
Allow、ask、deny 决定 tool 能否运行,不会批准最终记录。
Permissions 可以是 global、pattern-based、agent-specific;最后匹配规则生效。Auto mode 会改变 ask,但不会覆盖 explicit deny。对重要动作保留实际解析规则。
匹配的 allow / ask / deny
必要时用户批准
动作与响应被记录
Diff、test 或外部回读
负责人接受共享状态
Skills 与 MCP
Skills 提供流程,MCP 提供外部 tools;两者都不应暗中拥有当前业务状态。
Skills 从 project、global 与兼容 Agent 目录按需加载。MCP servers 可以是 local/remote、使用 OAuth,并按 global 或 agent 控制。Skill 内容与 MCP identity 要分别固定。
Procedure、templates、scripts、checklists
Tools、resources、authorization、runtime response
已接受结果、owner、lifecycle
Sessions 与 sharing
共享 OpenCode conversation 是协作上下文,不是持久 system of record。
Session link 暴露对话和输出,可作为 provenance;长期记录只提升一条精简结果,并附 source refs、准确 repository revision、verification 与负责人决定。
运行证据
不复制整段 conversation,也能重建实际 runtime。
精简 evidence bundle 应包含 config layers、instructions、agent topology、permissions、Skills、MCP calls、repository state 与 validation。
config_digest解析后的 config 与 precedenceinstruction_refsAGENTS.md 与额外 instructionsagent_tracePrimary 与 delegated agentspermission_trace重要 tools 的实际规则tool_evidenceBuilt-in 与 MCP responsesrepository_refCommit、worktree、diffverificationTests 与外部检查已审核结果
提升 decision-sized result,不搬运 config files 或 session transcript。
OpenCode session 被 compact、分享或删除后,这条记录仍应可理解。
outcome_key结果的稳定身份session_refOpenCode session 与 agent traceconfig_refResolved config digestsource_refsCode、docs、外部 recordsproposed_state精简结果解释owner接受责任人decision接受、有条件接受、拒绝、已替代next_review_at时效检查点实际问题
OpenCode 知识库常见问题
Busabase 会取代 AGENTS.md 吗?
不会。AGENTS.md 指导 OpenCode 行为;Busabase 保存少量已审核结果。
证据应该引用哪个 config file?
引用解析后的 config 与相关 source layers,不只引用 project file。
Auto mode 会绕过 deny 吗?
当前文档明确说明 explicit deny 仍然生效。
Subagent 可以批准自己的结果吗?
Tool permission 可以让它执行,record acceptance 仍由 owner 决定。
Shared session link 可以作为 canonical evidence 吗?
可以作为 provenance,但还要有能跨越链接和 retention 变化的仓库与外部验证。
从一套 resolved runtime 开始
记录 OpenCode 怎样行动,只审核其他团队需要的状态。
选择一个完成的 OpenCode session,解析 config 与 permissions,附上验证,然后提交一条 outcome,不提交整段 transcript。

