OpenCode 是一个开源的 AI 编码代理。它提供终端界面、桌面应用和 IDE 扩展等多种使用方式。
Installation 安装
# YOLO 一次性
curl -fsSL https://opencode.ai/install | bash
# Package managers
npm i -g opencode-ai@latest # or bun/pnpm/yarn
bun install -g opencode-ai
bun add -g opencode-ai
pnpm install -g opencode-ai
yarn global add opencode-ai
scoop install opencode # Windows 虽然 OpenCode 可以直接在 Windows 上运行,但我们推荐使用WSL
choco install opencode # Windows
brew install anomalyco/tap/opencode # macOS and Linux (recommended, always up to date)
brew install opencode # macOS and Linux (official brew formula, updated less更新频率较低)
sudo pacman -S opencode # Arch Linux (Stable)
paru -S opencode-bin # Arch Linux (Latest from AUR)
paru -S opencode
mise use -g opencode # Any OS
mise use -g github:anomalyco/opencode
nix run nixpkgs#opencode # or github:anomalyco/opencode for latest dev branch
使用 Docker
docker run -it --rm ghcr.io/anomalyco/opencode
Desktop App (BETA) 桌面应用(测试版)
OpenCode is also available as a desktop application. OpenCode 也可以作为桌面应用程序使用。
Agents 代理
OpenCode includes two built-in agents you can switch between with the Tab key. OpenCode 包含两个内置代理,您可以使用 Tab 键在它们之间切换。你会在右下角看到模式指示器。
build - Default, full-access agent for development work 构建 - 默认的全权限代理,用于开发工作
plan - Read-only agent for analysis and code exploration 计划 - 仅读代理,用于分析和代码探索
Also included is a general subagent for complex searches and multistep tasks. This is used internally and can be invoked using @general in messages. 还包括一个用于复杂搜索和多步骤任务的通用子代理。这用于内部,可以通过在消息中使用 @general 来调用。
How is this different from Claude Code?
这与 Claude Code 有何不同?
It's very similar to Claude Code in terms of capability. Here are the key differences: 在能力方面非常相似。以下是主要区别:
100% open source 100% 开源
Not coupled to any provider. OpenCode can be used with Claude, OpenAI, Google, or even local models. As models evolve, the gaps between them will close and pricing will drop, so being provider-agnostic is important. 不与任何供应商绑定。 OpenCode 可以与 Claude、OpenAI、Google 或本地模型一起使用。随着模型的发展,它们之间的差距将缩小,价格也将下降,因此保持供应商无关性非常重要。
Out-of-the-box LSP support 开箱即用的 LSP 支持 (Language Server Protocol)
A focus on TUI. OpenCode is built by neovim users and the creators of terminal.shop; we are going to push the limits of what's possible in the terminal. 专注于 TUI。OpenCode 是由 neovim 用户和 terminal.shop 的创建者构建的;我们将推动终端可能性的极限。
A client/server architecture. This, for example, can allow OpenCode to run on your computer while you drive it remotely from a mobile app, meaning that the TUI frontend is just one of the possible clients. 客户端/服务器架构。这可以允许 OpenCode 在您的计算机上运行,同时可以通过移动应用程序远程控制它,TUI 前端只是可能的客户端之一。
TUI (Terminal User Interface)终端用户界面
使用
/connect 登录
进入项目目录后
opencode
/init OpenCode 会分析你的项目并在项目根目录创建一个 AGENTS.md 文件。
可以使用 /undo 命令来撤销修改。
你与 OpenCode 的对话可以与团队分享。
/share
将图片拖放到终端中即可将其添加到提示词中。
我可以使用现有的 AI 订阅吗?
可以,OpenCode 支持所有主流提供商的订阅计划。您可以使用您的 Claude Pro/Max, ChatGPT Plus/Pro, 或 GitHub Copilot 订阅。