# OpenCode

**OpenCode** 是由 Anomaly Innovations, Inc. 开发的一款开源终端 AI 编程代理，它将大语言模型与开发者的本地代码库连接起来，使代理能够读取和编辑文件、运行 shell 命令，并完成多步骤编程任务。它用 [TypeScript](https://www.edgepedia.org/zh/typescript) 编写，以 MIT 许可证发布，支持超过 75 家大语言模型提供商，包括本地托管的模型。<sup>[1](https://github.com/anomalyco/opencode)</sup><sup> • </sup><sup>[2](https://dev.opencode.ai/docs/providers)</sup> 该项目提供终端界面、桌面应用，并在第 2 版中提供 Web 应用。<sup>[3](https://opencode.ai/v2/docs)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 由 Anomaly Innovations, Inc. 开发的开源终端 AI 编程代理；MIT 许可证，TypeScript<sup>[1](https://github.com/anomalyco/opencode)</sup><sup> • </sup><sup>[4](https://dev.opencode.ai/legal/terms-of-service)</sup> |
| 模型支持 | 通过 AI SDK 和 Models.dev 支持 75+ 家大语言模型提供商，包括本地模型；凭据存储在 `~/.local/share/opencode/auth.json`<sup>[2](https://dev.opencode.ai/docs/providers)</sup> |
| 内置代理 | `build`（完全访问权限）和 `plan`（只读，拒绝编辑，执行 bash 前会询问），用 Tab 键切换<sup>[1](https://github.com/anomalyco/opencode)</sup> |
| 采用情况 | 月活跃用户从约 65 万增长到近 800 万，日活跃用户近 100 万；GitHub 星标约 213,000<sup>[5](https://newsletter.pragmaticengineer.com/p/opencode)</sup><sup> • </sup><sup>[1](https://github.com/anomalyco/opencode)</sup> |
| 安全态势 | 该代理未运行在沙箱中；权限系统会提示确认，但不属于安全隔离<sup>[6](https://github.com/anomalyco/opencode/security)</sup> |
| 商业方案 | OpenCode Zen 按量付费（最低余额 $20，另加 $1.23 信用卡处理费）和 OpenCode Go，每月 $10<sup>[7](https://opencode.ai/zen)</sup><sup> • </sup><sup>[3](https://opencode.ai/v2/docs)</sup> |
| 当前版本 | v1.19.0 于 2026 年 10 月 11 日发布；OpenCode 2 可通过 `opencode upgrade --major` 获取<sup>[8](https://github.com/anomalyco/opencode/releases)</sup> |

## 历史

OpenCode 有两个仓库来源。Kujtim Hoxha（Kujtim Hoxha）于 2025 年 3 月 16 日创建了第一个仓库 `opencode-ai/opencode`，用 Go 编写。大约六周后，2025 年 4 月 30 日，SST（Serverless Stack）背后的团队创建了同名第二个项目 `sst/opencode`，用 TypeScript 重写。两者并行发展，社区问题如“两个并行仓库”（2025 年 5 月）和“这是来自 SST 的吗？”（2025 年 6 月）记录了由此产生的混淆，包括发现 opencode.ai 域名指向 SST 仓库而非原仓库。<sup>[9](https://opencode.io.vn/blog/opencode-100k-stars-github/)</sup>

SST 一侧的仓库发展更快，最终成为正式项目。它被转移到 Anomaly Innovations 旗下的 `anomalyco/opencode`，原 Go 仓库于 2025 年 9 月 18 日归档，约有 10,900 个星标。Hoxha 于同年 7 月离开项目，宣布他与 Charm 团队以新名称 Crush 继续这项工作。<sup>[9](https://opencode.io.vn/blog/opencode-100k-stars-github/)</sup> 后来的一次文档提交确认，从 `sst/opencode` 到 `anomalyco/opencode` 的迁移是同一仓库的重命名，而非分叉，旧路径会发出 301 重定向。<sup>[10](https://gitea.jordbo.se/joakimp/opencode-devbox/commit/2ac84fa4fb6f9212a9872ec6113158ff9ccb47c5?show-outdated=&style=unified&whitespace=ignore-eol)</sup>

OpenCode 联合创始人 Dax Raad（Dax Raad）将项目的增长部分归因于定位：当时没有竞争性编程代理占据开源这一类别，团队先发布了一个足够好的框架，在获得市场份额后再加以改进。他还表示，团队将 Anthropic 封禁 [Claude Code](https://www.edgepedia.org/zh/claude-code) 集成的举措转化为增长杠杆，与 OpenAI 及其他模型提供商建立了合作。<sup>[5](https://newsletter.pragmaticengineer.com/p/opencode)</sup>

## 功能

**模型无关的提供商。** OpenCode 使用 Vercel AI SDK 和 Models.dev 目录来支持超过 75 家大语言模型提供商，并可运行本地模型。提供商通过 `/connect` 命令添加，并在 `opencode.json` 文件中配置，其中 `baseURL` 选项支持代理和自定义端点，`blacklist` 或 `whitelist` 数组可让模型在选择器中隐藏。<sup>[2](https://dev.opencode.ai/docs/providers)</sup> 对于不想管理提供商配置的用户，OpenCode Zen 提供一组由团队针对编程代理进行测试和基准评测后精选的模型，按量付费，最低余额 $20，另加 $1.23 信用卡处理费。<sup>[7](https://opencode.ai/zen)</sup>

**代理与权限。** 默认附带两个内置主代理：`build`，用于开发工作的完全访问代理；`plan`，只读代理，拒绝文件编辑，并在运行 bash 命令前请求许可。自定义代理定义为 Markdown 文件或 JSONC 配置条目，结合系统提示、模型偏好和权限；子代理在具有全新上下文的子会话中运行。<sup>[1](https://github.com/anomalyco/opencode)</sup><sup> • </sup><sup>[11](https://docs.opencode.ai/docs/agents/)</sup> 权限系统支持按工具设置 `allow`、`ask` 和 `deny` 操作，通配符模式匹配覆盖内置、自定义和 MCP 工具，并支持按命令的 bash 规则，例如允许 `git diff` 而在 `git push` 前询问。<sup>[11](https://docs.opencode.ai/docs/agents/)</sup>

**无沙箱。** 项目的安全政策明确说明，OpenCode 不会将代理放入沙箱：权限系统作为一种用户体验功能存在，让用户了解代理正在做什么，而非安全隔离，需要真正隔离的用户被建议在 Docker 容器或虚拟机中运行 OpenCode。服务器模式为可选加入；如果没有 `OPENCODE_SERVER_PASSWORD` 设置，HTTP 服务器将以未认证方式运行并发出警告。<sup>[6](https://github.com/anomalyco/opencode/security)</sup>

## 采用情况与基准测试

OpenCode 是按使用量增长最快的 AI 开发者工具之一：《实用工程师》（The Pragmatic Engineer）在 2026 年 5 月对联合创始人 Dax Raad 的采访中报道，月活跃用户从约 65 万增长到近 800 万，日活跃用户近 100 万。<sup>[5](https://newsletter.pragmaticengineer.com/p/opencode)</sup> GitHub 仓库在 2026 年初突破 171,000 个星标，到 2026 年 10 月约有 213,000 个星标和 28,500 个分叉。<sup>[12](https://www.firecrawl.dev/blog/claude-code-vs-opencode)</sup><sup> • </sup><sup>[1](https://github.com/anomalyco/opencode)</sup> OpenCode 也是采用 Anthropic 的 Agent Skills 作为开放标准的编程代理之一，与 [Cursor](https://www.edgepedia.org/zh/cursor-coding-agent)、Goose 和 Amp 并列。<sup>[13](https://www.techradar.com/pro/anthropic-takes-the-fight-to-openai-with-enterprise-ai-tools-and-theyre-going-open-source-too)</sup>

基准测试结果在很大程度上取决于与框架搭配的模型。一项代理式 CLI 工具比较报告称，OpenCode 获得最高综合得分（81.6%），并且是所有有能力代理中每任务成本最低的，为 $1.03。<sup>[14](https://aimultiple.com/agentic-cli)</sup> Builder.io 的一项控制变量测试保持模型不变（Claude Sonnet 4.5），发现 Claude Code 更快，四项任务用时 9 分 9 秒对 16 分 20 秒，而 OpenCode 编写了更多测试，94 对 73，并运行了完整的现有测试套件；同一测试发现 OpenCode 内的三个模型都在未被要求的情况下重新格式化了现有代码，产生了夹杂大量无关改动的差异。<sup>[12](https://www.firecrawl.dev/blog/claude-code-vs-opencode)</sup> 关于框架效应的学术研究发现，框架选择会导致每解决一个任务所用的 token 数相差高达 40 倍，而配对通过率差异保持在 0 到 8 个百分点之间，并识别出与模型无关的 OpenCode 失败指纹，即耗尽时间上限的空闲循环；值得注意的是，OpenCode 不强制在提交前通过测试，如一些问题报告所述，尽管配置了批准提示，仍在用户验证前提交和推送。<sup>[15](https://arxiv.org/abs/2607.22585)</sup><sup> • </sup><sup>[24](https://github.com/anomalyco/opencode/issues/48751)</sup>

已记录的问题中包括第 #3176 号问题：在管理会话时，代理对工作目录中的每个文件执行了 `git add .`，既未检查仓库大小，也未检查 `.gitignore` 规则，且未向用户请求许可，导致一个包含 54,000 个文件、体积达 45 GB 的仓库性能严重下降。<sup>[16](https://techstackups.com/comparisons/coding-agent-harness-comparison-2026/)</sup>

## 安全事件

该仓库已发布三份安全公告。2026 年 1 月，GHSA-c83v-7274-4vgp（CVE-2026-22813，严重，CVSS 9.4）描述了恶意网站如何滥用 Web UI 的服务器 URL 覆盖，在 `http://localhost:4096` 上实现跨站脚本攻击，然后通过 API 的 `/pty/` 端点运行任意命令；1.1.10 之前的版本受到影响。<sup>[17](https://github.com/advisories/GHSA-c83v-7274-4vgp)</sup> 一份配套的高危公告 GHSA-vxw4-wv6m-9hhh 涉及通过未认证的 HTTP 服务器执行任意命令。<sup>[18](https://github.com/anomalyco/opencode/security/advisories/)</sup>

2026 年 9 月，GHSA-632h-h47v-g4x4（高危）显示，网页可以向 `opencode serve` 的 `/global/upgrade` 端点发送跨站请求，该端点接受通用 npm 包说明符作为目标，会安装攻击者控制的包，其生命周期脚本以用户权限运行。通过 npm、pnpm 或 Bun 安装的 1.14.30 至 1.18.21 版本受到影响；1.18.22 版本将目标验证为语义化版本，并增加了内容感知的请求解析。Datadog Security Labs 报告称，82 个受影响版本在 9 月 17 日至 23 日期间获得超过 647,000 次下载，约占该时段 OpenCode 下载量的 38.9%。<sup>[19](https://github.com/anomalyco/opencode/security/advisories/GHSA-632h-h47v-g4x4)</sup><sup> • </sup><sup>[20](https://securebulletin.com/opencode-web-interface-flaw-let-hostile-sites-run-commands-on-developer-pcs/)</sup>

## 版本与商业

2026 年 10 月 11 日发布的 1.19.0 版本增加了 `opencode upgrade --major` 以迁移到 OpenCode 2，并将更新方式改为通过 `/update` 手动安装，而非自动安装。<sup>[8](https://github.com/anomalyco/opencode/releases)</sup> OpenCode 2 基于 Effect 框架构建，提供终端界面、桌面应用或通过 `opencode pair` 访问的 Web 应用，并引入了“动作-资源-效果”语句的权限模型以及实验性二进制策略，后者只会收紧权限允许的范围。<sup>[3](https://opencode.ai/v2/docs)</sup><sup> • </sup><sup>[21](https://dev.opencode.ai/v2/docs/policies)</sup> 第 1 版和第 2 版都使用 `opencode` 命令，在默认名称下无法并排安装。<sup>[22](https://docs.opencode.ai/docs/)</sup>

商业方面通过 Anomaly Innovations, Inc. 运营，该公司持有 SOC 2 Type 1 和 Type 2 合规认证，并将其使命描述为开发具有本地优先执行能力的开源开发者工具。<sup>[23](https://trust.opencode.ai/)</sup> 除了 Zen 按量付费外，OpenCode Go 是每月 $10 的订阅服务，授予对开源模型的访问权限。<sup>[3](https://opencode.ai/v2/docs)</sup>

## References

1. [anomalyco/opencode: The open source coding agent, GitHub](https://github.com/anomalyco/opencode)
2. [Providers | OpenCode documentation](https://dev.opencode.ai/docs/providers)
3. [Intro | OpenCode 2 documentation](https://opencode.ai/v2/docs)
4. [OpenCode Terms of Use, Anomaly Innovations, Inc.](https://dev.opencode.ai/legal/terms-of-service)
5. [Building OpenCode with Dax Raad, The Pragmatic Engineer](https://newsletter.pragmaticengineer.com/p/opencode)
6. [Security policy, anomalyco/opencode, GitHub](https://github.com/anomalyco/opencode/security)
7. [OpenCode Zen: reliable optimized models for coding agents](https://opencode.ai/zen)
8. [Releases, anomalyco/opencode, GitHub](https://github.com/anomalyco/opencode/releases)
9. [OpenCode vượt 180.000 Stars trên GitHub, OpenCode Vietnam](https://opencode.io.vn/blog/opencode-100k-stars-github/)
10. [docs(AGENTS): clarify opencode repo moved sst->anomalyco (not a fork)](https://gitea.jordbo.se/joakimp/opencode-devbox/commit/2ac84fa4fb6f9212a9872ec6113158ff9ccb47c5?show-outdated=&style=unified&whitespace=ignore-eol)
11. [Agents | OpenCode documentation](https://docs.opencode.ai/docs/agents/)
12. [Claude Code vs OpenCode: Which Terminal AI Coding Agent Should You Use?, Firecrawl](https://www.firecrawl.dev/blog/claude-code-vs-opencode)
13. [Anthropic takes the fight to OpenAI with enterprise AI tools, TechRadar](https://www.techradar.com/pro/anthropic-takes-the-fight-to-openai-with-enterprise-ai-tools-and-theyre-going-open-source-too)
14. [Agentic CLI Tools Compared: Claude Code vs Cline vs Aider, AIMultiple](https://aimultiple.com/agentic-cli)
15. [The Scaffold Effect in Coding Agents: Harness Choice as a Hidden Variable, arXiv](https://arxiv.org/abs/2607.22585)
16. [Coding Agent Harness Comparison 2026, Tech Stackups](https://techstackups.com/comparisons/coding-agent-harness-comparison-2026/)
17. [CVE-2026-22813 / GHSA-c83v-7274-4vgp, GitHub Advisory Database](https://github.com/advisories/GHSA-c83v-7274-4vgp)
18. [Security Advisories, anomalyco/opencode, GitHub](https://github.com/anomalyco/opencode/security/advisories/)
19. [GHSA-632h-h47v-g4x4: Cross-site OpenCode server upgrade request, GitHub Advisory](https://github.com/anomalyco/opencode/security/advisories/GHSA-632h-h47v-g4x4)
20. [OpenCode Web Interface Flaw Let Hostile Sites Run Commands on Developer PCs, Secure Bulletin](https://securebulletin.com/opencode-web-interface-flaw-let-hostile-sites-run-commands-on-developer-pcs/)
21. [Policies | OpenCode 2 documentation](https://dev.opencode.ai/v2/docs/policies)
22. [Intro | AI coding agent built for the terminal, OpenCode docs](https://docs.opencode.ai/docs/)
23. [Anomaly Innovations, Inc Security Trust Center](https://trust.opencode.ai/)
24. [Agent commits and pushes untested/incomplete changes without user approval despite global permission config · Issue #48751 · anomalyco/opencode](https://github.com/anomalyco/opencode/issues/48751)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 19, 2026; Oct 15, 2026 · Edited: Sep 19, 2026; Oct 11, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › AI companies, people, and products › AI products and assistants › AI agents and developer tools

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/opencode

English original: https://www.edgepedia.org/opencode
