OpenCode完整设置指南
配置文件、插件、MCP服务器和系统提示,用于在任何机器上复制完整的OpenCode设置。
目录结构
opencode-setup/
├── README.md (this file)
├── opencode-config/
│ ├── opencode.json (main config — models, plugins, MCPs, permissions)
│ ├── antigravity.json (multi-account rotation config)
│ ├── oh-my-opencode.json (agent orchestration & model overrides)
│ ├── compound-engineering.json (skills, commands, categories)
│ └── config.yaml (global rules, delegation standards, profiles)
├── mcp-servers/
│ ├── server-list.md
│ └── mcp-reference.sh
├── plugins/
│ ├── oh-my-opencode/ (multi-agent orchestration)
│ ├── antigravity-auth/ (Google account rotation)
│ ├── opencode-dcp/ (dynamic context pruning)
│ ├── safety-net/ (destructive command blocking)
│ ├── rate-limit-fallback/ (auto model fallback on rate limit)
│ ├── notifier/ (OS notifications)
│ ├── langfuse/ (LLM observability & tracing)
│ ├── compound-engineering/ (AI dev tools & workflows)
│ ├── preload-skills/ (contextual skill loading)
│ ├── security-plugin/ (security guardrails & vuln scanning)
│ ├── token-monitor/ (token usage analytics)
│ └── envsitter-guard/ (secrets protection)
├── project-templates/
│ └── project-config.yaml
├── setup-instructions.md
├── system-prompts.md
├── QUICK-REFERENCE.md
├── agents-list.md
└── export-checklist.md快速开始
自动设置(推荐)
# 1. Clone this repo
git clone https://github.com/GAIn-Tech/opencode-setup.git
cd opencode-setup
# 2. Run setup (strict, resilient: installs, links, syncs config, verifies portability)
bun run setup
# 3. Start OpenCode
opencode手动设置
- 安装OpenCode:
npm install -g opencode - 安装Bun:安装Bun
1.3.9(必须匹配.bun-version) - 克隆此仓库:
git clone https://github.com/GAIn-Tech/opencode-setup.git - 运行安装程序:
cd opencode-setup && bun run setup - 验证帐户:
opencode→ antigravity插件处理OAuth
看 安装.md 了解详细的安装说明。
开发容器(可选)
如果使用VS代码开发容器/代码空间,则可以在中使用基线配置 .devcontainer/devcontainer.json.
postCreateCommand跑bun run setup.postStartCommand跑bun run verify(非严格环境变量配置文件)。- 运行时机密通过以下方式从主机环境传递
remoteEnv(GITHUB_TOKEN,TAVILY_API_KEY,SUPERMEMORY_API_KEY). - 在Windows上,保持对命名卷的依赖关系(
node_modulesmount)以避免绑定挂载性能问题。 - 容器对工作区文件强制执行LF行结尾。
当前堆栈
插件
| 插件 | 目的 |
|---|---|
oh-my-opencode@latest | 多代理编排(8个命名代理,46个技能,22个命令) |
opencode-antigravity-auth@latest | 谷歌账户轮换(3个账户,混合策略) |
opencode-supermemory@latest | 持久跨会话内存 |
@tarquinen/opencode-dcp@latest | 动态上下文修剪——减少令牌使用 |
cc-safety-net@latest | 阻止破坏性的git/文件系统命令 |
@azumag/opencode-rate-limit-fallback@latest | 根据速率限制自动切换型号 |
@mohak34/opencode-notifier@latest | 任务完成/错误的操作系统通知 |
opencode-plugin-langfuse@latest | LLM跟踪、即时版本控制、成本跟踪 |
opencode-plugin-preload-skills@latest | 情境技能加载——每个任务只加载相关技能 |
envsitter-guard@latest | 防止读取.env文件--机密保护 |
opencode-antigravity-quota@latest | 反重力配额可见性 |
opencode-pty@latest | 交互式/后台过程控制 |
MCP服务器
| 服务器 | 类型 | 用途 |
|---|---|---|
tavily | 本地 | 网络搜索、提取、爬行、研究 |
supermemory | 远程 | 跨会话的持久内存 |
context7 | 远程 | 最新的库文档 |
playwright | 本地 | 浏览器自动化和测试 |
sequentialthinking | 局部 | 增强逐步推理 |
websearch | 本地 | Web搜索(备份) |
grep | local | 在GitHub仓库中搜索代码 |
github | local | GitHub API(问题、PR、转发) |
distill | 基于AST的本地智能上下文压缩(节省50-70%的令牌) |
模型
| 模型 | 提供者 | 用例 |
|---|---|---|
kimi-k2.5-free | 登月 | 默认/自由层机械任务 |
gemini-2.5-flash | 谷歌 | 琐碎的任务,快速查找 |
antigravity-gemini-3-flash | 反重力 | 常规开发工作、探索、研究 |
claude-sonnet-4-5 | Anthropic | 复杂推理,多文件重构 |
claude-sonnet-4-5-thinking | Anthropic | 深入分析、调试、优化 |
claude-opus-4-6 | 人类学 | 建筑决策、系统设计 |
claude-opus-4-6-thinking | 人择 | 关键/高风险,安全审计 |
执行模式
- 拉尔夫·卢普:坚持到完成
- 超工作循环:最大并行执行
- 后台任务:异步子代理调度
- 群集:协调多代理执行
- 管道:顺序代理链
关键文件位置
| 文件 | 位置 | 目的 |
|---|---|---|
opencode.json | ~/.config/opencode/ | 主要配置(型号、插件、MCP) |
antigravity.json | ~/.config/opencode/ | 帐户轮换设置 |
oh-my-opencode.json | ~/.config/opencode/ | 规范命名代理注册表和模型覆盖 |
compound-engineering.json | ~/.config/opencode/ | 技能、命令、类别 |
config.yaml | ~/.opencode/ | 全球规则和授权标准 |
docs/architecture/cli-mcp-surface-policy.md | docs/architecture/ | CLI、MCP、混合或仅库包表面的决策策略 |
global-rules/*.mdc | ~/.opencode/ | 模型委托、协调、开发标准 |
skills/*/SKILL.md | ~/.config/opencode/ | 46技能定义 |
新机器上的设置
看 setup-instructions.md 了解详细的分步说明。
