> 完整文档索引请参见 [llms.txt](/llms.txt)

![OpenCode 官网首页](https://c456.com/our-assets/129/1796145304/a21382ac053a7b1c93c2a63a09b2e61d26b98de6d101ccec5bd53c41896e54ee "c456:asset/129")

*[OpenCode](https://opencode.ai) — 官网首页。*

**OpenCode** 是开源 AI 编码 Agent，可在终端 TUI、桌面应用或 IDE 扩展中使用。支持任意 LLM 提供商（Anthropic、OpenAI、Google、OpenRouter、本地 OpenAI 兼容端点等），通过 `opencode.json` 配置模型、权限与**插件**。Plan / Build 模式、项目级 `AGENTS.md`、`/init` 初始化均为内置能力。

**官网**：https://opencode.ai

## 安装与初始化

```bash
curl -fsSL https://opencode.ai/install | bash
# 或：npm install -g opencode-ai
```

进入项目目录后：

```bash
opencode
/connect    # 配置 API Key（TUI 内）
/init       # 分析项目并生成 AGENTS.md
```

全局配置路径：`~/.config/opencode/opencode.json`；项目级可放 `.opencode/opencode.json`，**就近合并、项目覆盖全局**。

## 配置文件要点

| 字段 | 作用 |
|---|---|
| `model` / `small_model` | 默认主模型与小模型 |
| `provider` | 各厂商 baseURL、apiKey、模型列表 |
| `plugin` | **插件数组**（见下文集成） |
| `agent` | 自定义子 Agent（model、permission 等） |
| `permission` | 工具权限（edit、bash、webfetch 等） |

## 集成 Oh My OpenAgent（oh-my-opencode）

**Oh My OpenAgent**（npm 仍名 `oh-my-opencode`）为 OpenCode 提供 11 个分工 Agent、8 个 Category 任务目录、内置 MCP、Hashline 编辑、`ultrawork` 模式等。详见 [C456 #195 Oh My OpenAgent 速查](https://c456.com/intakes/195)。

### 安装

推荐让 Agent 按官方指南安装（会检测订阅并生成 agent→model 映射）：

```bash
bunx oh-my-openagent install
```

安装器会在 `opencode.json` 的 `plugin` 中注册 `"oh-my-openagent"`（或兼容旧名 `oh-my-opencode`），并生成 `~/.config/opencode/oh-my-openagent.json` 供各 Agent / Category 覆盖模型。

**验证**：

```bash
bunx oh-my-openagent doctor
```

**注意**：勿用 `npm install -g` 全局安装；勿用 `bunx omo`（会解析到无关 npm 包）。

### 使用要点

- 输入 **`ultrawork`** 或 **`ulw`** 激活全套编排
- `/start-work` 走 Prometheus 规划 + Atlas 执行
- Agent / Category 说明见 [#195](https://c456.com/intakes/195)

## 集成 Superpowers

**Superpowers** 注入 TDD、brainstorm、writing-plans、subagent-driven-development 等 **Skills 与工作流**。详见 [C456 Superpowers 工具页](https://c456.com/intakes/197)。

在 `opencode.json` 的 `plugin` 数组追加：

```json
"superpowers@git+https://github.com/obra/superpowers.git"
```

重启 OpenCode。验证：询问「Tell me about your superpowers」，或用 `skill` 工具列出 `superpowers/*` 技能。

Superpowers 与 Oh My OpenAgent **可同时启用**：前者管**工程纪律与 Skills**，后者管**多 Agent 编排与模型路由**，职责互补。

## 推荐组合配置示例

以下为**同时启用两个插件**的最小示例（模型与 provider 请按自己的 Key 填写）：

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openrouter/your-default-model",
  "small_model": "openrouter/your-small-model",
  "provider": {
    "openrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://openrouter.ai/api/v1"
      },
      "models": {
        "your-default-model": { "name": "Default" }
      }
    }
  },
  "plugin": [
    "oh-my-openagent@latest",
    "superpowers@git+https://github.com/obra/superpowers.git"
  ]
}
```

**分工建议**：

| 能力 | 由谁提供 |
|---|---|
| 多 Agent 委派、Category 选模型、内置 MCP | Oh My OpenAgent |
| 先 brainstorm / 写计划 / TDD / code review 流程 | Superpowers |
| 底层读写文件、bash、LSP | OpenCode 原生 |

**可选**：在 `oh-my-openagent.json` 里为 sisyphus、explore 等单独指定模型；Superpowers 的 project skills 放在 `.opencode/skills/`，优先级高于内置。

## 插件加载顺序与排错

1. 修改 `plugin` 后**重启 OpenCode**
2. Oh My OpenAgent：`bunx oh-my-openagent doctor`
3. Superpowers：`opencode run --print-logs "hello" 2>&1 | grep -i superpowers`
4. 列出技能：对话中让 Agent 调用 **`skill`** 工具

若 git 插件在 Windows 安装失败，Superpowers 文档提供 npm 本地路径回退方案。

## 适用场景

- 要**开源、可自托管 provider** 的终端编码 Agent
- 需要 **Plan/Build**、项目 `AGENTS.md`、多模型混用
- 希望 **Oh My OpenAgent（编排）+ Superpowers（流程）** 叠在同一 harness

## 不太适合

- 只要 Claude Code / Cursor 官方一体化、不愿维护 JSON 配置
- 仅需 Codex CLI 轻量插件（Oh My OpenAgent 有单独的 Codex Light 版 `npx lazycodex-ai install`，与 OpenCode Ultimate 版不同）

## 下一步

- 文档：https://opencode.ai/docs
- Oh My OpenAgent：https://github.com/code-yeongyu/oh-my-openagent · [C456 #195](https://c456.com/intakes/195)
- Superpowers：https://github.com/obra/superpowers · [C456 #197](https://c456.com/intakes/197)