工具
xiaohui
收录

OpenCode | 开源终端 AI 编码 Agent · 集成 Oh My OpenAgent 与 Superpowers

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

官网https://opencode.ai

安装与初始化

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

进入项目目录后:

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 速查

安装

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

bunx oh-my-openagent install

安装器会在 opencode.jsonplugin 中注册 "oh-my-openagent"(或兼容旧名 oh-my-opencode),并生成 ~/.config/opencode/oh-my-openagent.json 供各 Agent / Category 覆盖模型。

验证

bunx oh-my-openagent doctor

注意:勿用 npm install -g 全局安装;勿用 bunx omo(会解析到无关 npm 包)。

使用要点

  • 输入 ultraworkulw 激活全套编排
  • /start-work 走 Prometheus 规划 + Atlas 执行
  • Agent / Category 说明见 #195

集成 Superpowers

Superpowers 注入 TDD、brainstorm、writing-plans、subagent-driven-development 等 Skills 与工作流。详见 C456 Superpowers 工具页

opencode.jsonplugin 数组追加:

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

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

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

推荐组合配置示例

以下为同时启用两个插件的最小示例(模型与 provider 请按自己的 Key 填写):

{
  "$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 选模型、内置 MCPOh My OpenAgent
先 brainstorm / 写计划 / TDD / code review 流程Superpowers
底层读写文件、bash、LSPOpenCode 原生

可选:在 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 版不同)

下一步

与其它条目的关联

信号、工具、渠道、打法可互相引用;点各卡片右上角加号可弹窗录入,未登录时会提示登录。补全后此处会显示可点链接。

信号

暂无关联的信号。请点右上角加号快速录入;未登录时会提示先登录。补全后在此显示可点链接。

工具

暂无关联的工具。请点右上角加号快速录入;未登录时会提示先登录。补全后在此显示可点链接。

渠道

暂无关联的渠道。请点右上角加号快速录入;未登录时会提示先登录。补全后在此显示可点链接。

打法

暂无关联的打法。请点右上角加号快速录入;未登录时会提示先登录。补全后在此显示可点链接。