⚙️ 第六章:配置系统

掌握 OpenCode 的配置方法,优化你的开发环境

📖 6.1 配置文件位置

位置 说明 优先级
~/.config/opencode/opencode.json 用户主配置
~/.config/opencode/opencode.jsonc 带注释的配置
项目目录 .opencode.json 项目级配置
~/.opencode.json 用户根目录配置

📋 6.2 完整配置示例

{ "$schema": "https://opencode.ai/config.json", "instructions": [], "permission": { "read": "allow", "write": "allow", "edit": "allow", "bash": "allow" }, "theme": "opencode", "model": "anthropic/claude-sonnet-4-20250514", "autoupdate": true, "agent": { "build": { "mode": "primary", "model": "anthropic/claude-sonnet-4-20250514", "tools": { "write": true, "edit": true, "bash": true } } } }

🎨 6.3 主题配置

支持的主题:opencode, dark, light

"theme": "opencode" // 或 "dark", "light"

✅ 本章小结

  • 了解配置文件优先级
  • 掌握完整配置结构
  • 学会配置主题和模型
← 返回首页 下一章:实战案例 →