AI Explore.Source.Templates

One HTML document for Search, AI answers, and browser agents.

Switch to Simplified Chinese

OpenCode 配置文件 opencode.json 详解

  • 高森 模型产品
  • 齐岚 开发者体验

Published September 22, 2026

opencode.json 是 OpenCode 的主配置:默认供应商与模型、权限、LSP、MCP、命令和 UI。用户目录放个人习惯,项目根放团队约定。两层合并时以文档的覆盖规则为准,通常项目更具体。Key 用环境变量占位。提交前检查 diff,避免把本机路径和 Token 带进仓库。字段名随版本演进,以当前 schema / 文档为准,本页讲结构而不是抄死某一版全文。

  • 本机习惯 用户级
  • 仓库约定 项目级
  • 环境变量 密钥

改完用官方校验或先开一个只读会话,确认默认供应商是你想要的。

最常改的块#

  • model / provider 默认值。
  • 工具与命令权限。
  • MCP 服务器列表。
  • 忽略目录(依赖、构建产物)。

要点#

  • 项目约定进仓库,密钥不进。
  • 改默认供应商比堆很多 Key 重要。
  • 字段以当前文档为准。

Was this helpful?

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. Figures are original to this site.

Last updated 2026-09-22.