跳到主要内容Skip to main content
← Tools

OpenCodeOpenCode

OpenCode
编程 终端 本地 开源 partial lifecycle: active 核验Checked 2026-10-08

MIT 许可的多 provider 编程 harness。它运行 bash 命令前会询问权限,并支持 ACP 载入。

An MIT-licensed multi-provider programming harness that asks permission before running bash commands, and supports loading via ACP.

适合与不适合When to use it, when not to

需要多 provider 可切换、重视 bash 命令执行前确认的用户。 ACP 生态参与者。

不适合需要完全免打扰的自动化场景—— 执行命令前询问会打断流程,需确认 YOLO 模式的具体开关方式。

Users who need switchable multiple providers and who care about confirmation before bash commands run. Participants in the ACP ecosystem.

Not a fit for fully unattended automation — asking before each command interrupts the flow; the exact switch for YOLO mode was not verified.

中文生态China availability 国产 / 国内可直接用 / 备案状态 · 快照domestic / direct access / CAC filing · snapshot 2026-10-20

出品属地Origin
国外出品foreign-made 国外主体(网信办公示名单未见对应备案主体)。foreign entity (no matching filing entity in the CAC registry).
国内使用Direct access
大陆可直连direct OK 官网仓库在 GitHub,大陆直连波动(同日实测 200/000 混合);npm / PyPI 安装源实测稳定可达。Hosted on GitHub — direct reachability from mainland fluctuates (200/000 mixed on the same day); npm / PyPI install routes measured stable.
备案状态CAC filing
未见于备案名单not in filing list:未见于网信办公示名单(2026-10-20 检索 13 批附件,https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm);该产品未面向大陆公众提供服务,备案不适用。not in the CAC public registry (13 batch attachments searched 2026-10-20, https://www.cac.gov.cn/2024-04/02/c_1713729983803145.htm); the product does not serve the mainland public, so filing does not apply.

备案信息以网信办《生成式人工智能服务已备案信息》公示名单为准(按批次滚动更新,本站只抄编号不解读);「大陆可直连」是本站从大陆网络直连实测的结果,不是厂商承诺。GitHub 类站点当日实测有波动,口径写在依据里。Filing status is quoted from the CAC public registry (updated batch by batch; this site copies the number and does not interpret it). "Direct access" is this site's own reachability measurement from a mainland network, not a vendor promise. GitHub-hosted sites fluctuated on the measurement day — the note says so.

固定坐标系Fixed coordinate system

8 个维度dimensions, 与同分区其他对象逐项可比each comparable item by item against others in the same section.

模型与开放条件Model & openness

多 provider 接入的编程 harness。官方 models 与 providers 页原文: OpenCode 用 AI SDK 与 Models.dev,支持 75+ LLM 提供商, 也支持运行本地模型。目录含:

  • 302.AI
  • Amazon Bedrock
  • Anthropic
  • Azure OpenAI
  • DeepSeek
  • Google Vertex AI
  • Groq
  • Hugging Face
  • llama.cpp
  • LM Studio
  • Ollama
  • OpenAI
  • OpenRouter
  • xAI
  • Z.AI
  • ZenMux 等。

凭据经 /connect 存入 ~/.local/share/opencode/auth.json;

可用 enabled_providers / disabled_providers 白黑名单, 也能自定义 provider(npm + baseURL,含 OpenAI 兼容); 另有官方精选清单 OpenCode Zen。本地模型可接——

官方点名 llama.cpp、LM Studio、Ollama、Atomic Chat。

注意:用 Claude Pro/Max 订阅接入时,这不是 Anthropic 官方支持的用法。

运行位置Where it runs

本地进程,在终端运行。提供多平台安装方式(macOS Homebrew / Windows Scoop 等)。 生命周期绑定终端会话。

本地文件Local files

面向真实代码仓库的编程能力。read/edit/write/grep/glob 直接读写工作区。grep/glob 底层用 ripgrep,默认遵循 .gitignore。

访问范围默认限定在启动时的工作目录——越界路径须在 permission 里用 external_directory 显式放行(如 ~/projects/personal/**)。

read 默认 allow,但 .env / .env.* 默认 deny(.env.example allow)。 @ 键可模糊搜索项目文件;文件变动有 watcher(可配 ignore)。

符号能力来自 LSP 工具(实验性):需 OPENCODE_EXPERIMENTAL_LSP_TOOL=true 并自配 LSP 服务器,支持 goToDefinition / findReferences / hover 等。

官方未见代码库向量化索引的描述(已查 tools / config / permissions 页)。

关机后的任务Tasks after shutdown

终端形态,本地进程,生命周期绑定会话。

官方另有 opencode serve(无头 HTTP 服务器)。 还有 opencode web 与桌面应用。它们都跑在你自己的机器上。 它们为客户提供会话 API,含 prompt_async 异步发送。执行环境归你自己, 不是厂商托管云。

官方未见「客户端关闭后仍继续 / 关机续跑」的云端后台能力 (已查 server 页与 docs 概览)。

工具与扩展Tools & extensions

内置工具官方逐项列出:

  • bash
  • edit
  • write
  • read
  • grep
  • glob
  • lsp(实验性)
  • patch
  • skill
  • todowrite
  • webfetch
  • websearch(Exa,需 OpenCode 提供商或 OPENCODE_ENABLE_EXA)
  • question

另有 task 派发子代理。

内置代理含:

  • build
  • plan
  • general
  • explore
  • scout
  • compaction
  • title
  • summary

MCP 接入方式已核到: 本地 type:"local" 与远程 type:"remote" 两类,支持 OAuth 动态客户端注册(RFC 7591)与 opencode mcp auth 等命令; 还支持自定义工具与插件(hooks)。

上下文与记忆Context & memory

ACP(Agent Client Protocol)载入能力是其差异化设计—— 在恢复与分叉时保留模型、effort 与模式边界。

会话机制已核到:/session API 支持创建、fork(在某条消息处分叉)、 revert/unrevert 与 summarize。TUI 有 /undo、/redo、/share。

压缩策略官方给了配置——compaction 项:

  • auto(默认 true,上下文满时自动压缩会话)
  • prune(删旧工具输出省 token,默认 false)
  • reserved(压缩缓冲)

另有 compaction / title / summary 三个内置代理。

权限与限制Permissions & limits

权限策略已核到:permission 配置决定每个操作是自动运行、 提示审批还是阻止,三档 "allow" / "ask" / "deny"。

可按工具细粒度配置,支持通配符与对象语法(如 bash 的 git * allow、rm * deny,最后匹配的规则优先)。

可配权限键:

  • read
  • edit(涵盖 edit、write、patch)
  • glob
  • grep
  • bash
  • task
  • skill
  • lsp
  • webfetch
  • websearch
  • external_directory
  • doom_loop

默认值宽松:多数 allow, doom_loop 与 external_directory 为 ask;read 为 allow 但 .env / .env.* 默认 deny。

官方 config 页亦称「默认允许所有操作,无需明确批准」。

审批 UI 给 once / always / reject。它可对每个代理单独覆盖。

v1.1.1 起旧版 tools 布尔配置并入 permission。

适合什么任务Best for

需要多 provider 可切换、且重视命令执行前确认的用户。 ACP 生态参与者。

头号误解Top misconception

  • 把 provider 支持列表当成有额度,连接器可用不等于有模型订阅权限Reading the provider support list as entitlement — a connector being available is not the same as having a model subscription
  • 以为默认全权执行命令,README 提到 bash 命令前会询问Assuming it executes commands with full rights by default — the README says it asks before bash commands
  • 以为可以用某个 provider 就免费,模型费用仍需自付Assuming access to a provider means it is free — model costs are still yours

未知项清单Known unknowns

  • YOLO 模式的具体开关与风险
  • 子代理的调度方式与 token 开销
  • 大仓库在「无向量化索引(靠 ripgrep / LSP)」路线下的实际表现

证据来源Evidence sources

判断可回到以下一手源复核。本站核验日Every judgement can be rechecked against the primary sources below. Verified on 2026-10-08,内容更新日content updated on 2026-10-08。

类型Type名称Name链接Link
repoOpenCode · 仓库 READMEhttps://github.com/sst/opencode
changelogOpenCode · Releases(v1.18.33 @ 2026-09-28)https://github.com/sst/opencode/releases
changelogOpenCode · 官方站 Changeloghttps://opencode.ai/changelog
docsOpenCode · 官方文档https://opencode.ai/docs
docsOpenCode · 官方文档 · 提供商(75+ provider、目录、自定义 provider、凭据存储)https://opencode.ai/docs/providers
docsOpenCode · 官方文档 · 模型(75+ provider、本地模型、默认模型与变体)https://opencode.ai/docs/models
docsOpenCode · 官方文档 · 权限(allow/ask/deny、细粒度规则、external_directory、默认值)https://opencode.ai/docs/permissions
docsOpenCode · 官方文档 · 工具(内置工具清单、子代理、MCP、自定义工具)https://opencode.ai/docs/tools
docsOpenCode · 官方文档 · MCP 服务器(本地/远程、OAuth、管理)https://opencode.ai/docs/mcp-servers
docsOpenCode · 官方文档 · 配置(compaction、watcher、permission、server)https://opencode.ai/docs/config
docsOpenCode · 官方文档 · 服务器(opencode serve、会话 API、fork/summarize)https://opencode.ai/docs/server

实测记录Measured runs

本站尚未完成实测。测试协议见 tasks/_protocol.md。

实测建议:这个工具的实测重点应放在 「命令执行前的询问」这个设计在长任务中的实际打断成本—— 这是它与全权执行类工具的核心工作流差异。

变更记录说明

版本日期
v1.18.332026-09-28

更新频率很高(release 与 changelog 都在 09-28)。

权限设计:执行前询问

这是本条目最值得注意的一条,来自 README:

`` Asks permission before running bash commands ``

多数终端 agent 默认自动执行命令,OpenCode 默认会问。

这降低了「模型误删文件 / 误跑危险命令」的风险, 代价是打断流程。README 另有 YOLO 相关内容, 推测是可选的免询问模式,但具体开关方式本次未核验,记为未知。

子代理能力

`` Also included is a general subagent for complex searches and multistep tasks. ``

内置一个通用子代理,用于复杂搜索与多步任务。 这让它能处理「先调研再动手」这类需要多轮的任务。

子代理的具体调度方式与 token 开销本次未核验。

ACP:Agent Client Protocol

这是它的架构亮点:

`` ACP 载入、恢复、分叉时保留模型、effort 和模式边界 ``

「分叉时保留模型与 effort」这个细节值得注意—— 很多工具分叉后会丢失设置,导致每次都要重设。

稳定性修复是重要信号

参考 AgentClash 对 OpenCode v1.18.33 的核验记录(09-28), 该版本包含四项修复:

1. Cloudflare 超时控制 2. MCP 浏览器启动失败反馈 3. 调试凭据脱敏 4. Gemini 推理参数修正

四项里两项与权限/可靠性相关(凭据脱敏、MCP 启动失败反馈)。 这说明项目的可靠性投入在权限与可诊断性上, 但也说明这些方面曾经出过问题。

权限定级说明

confidence: partial 的原因:

  • ✅ 已核验:仓库、许可(MIT)、最新版本与日期、star 数(210,642,本分区最高)、权限策略(allow/ask/deny 细粒度)、ACP、安装方式;A6.2 本轮补:75+ provider 与本地模型、内置工具清单与 MCP 接入方式、compaction 上下文策略
  • ❌ 未核验:YOLO 模式的具体开关方式、子代理的调度细节与 token 开销

相关条目Related entries

本页由This page is generated from the ai-agent-guide 数据层生成(CC BY 4.0)。data layer (CC BY 4.0). 方法论与坐标系定义见仓库内 METHODOLOGY.md。