{ "$schema": "https://opencode.ai/config.json", // 只限制 orchestrator(主会话的我)。 // 规则是「最后一条匹配的生效」,所以顺序不能反:先宽泛 ask,再开白名单。 "agents": { "orchestrator": { "permissions": [ // —— 文件编辑:改代码必须先问,改文档自由 —— { "action": "edit", "resource": "*", "effect": "ask" }, { "action": "edit", "resource": "*.md", "effect": "allow" }, // —— 子代理:只放行只读代理 —— // 子代理用自己的权限,不继承父级;不加这条的话,可以把改代码的活 // 转派给 fixer,上面的 edit:ask 就形同虚设。 // // explorer 只读勘察 → 放行 // librarian 外部文档/网络调研 → 放行(写的是报告文件,不是源码) // oracle 架构/风险/调试建议 → 放行,只给建议不落地 // council 多模型共识汇总 → 放行,用得少且一般只提意见 // // 仍被拦下的(会写代码,放行等于开后门): // fixer "implementation specialist" → 实现代码 // designer "design, review, and implementation" → 落地 UI/布局/样式 { "action": "subagent", "resource": "*", "effect": "ask" }, { "action": "subagent", "resource": "explorer", "effect": "allow" }, { "action": "subagent", "resource": "librarian", "effect": "allow" }, { "action": "subagent", "resource": "oracle", "effect": "allow" }, { "action": "subagent", "resource": "council", "effect": "allow" } // ⚠️ 已知缺口:shell 未做任何限制(默认 allow)。 // 因此 Set-Content / > 重定向 / node -e / git apply 等仍可绕过上面的 // edit:ask。这是当前有意接受的现状 —— 要堵需要改成 shell 白名单。 ] } } }