Files
Agent-Tools/adapters/tools/opencode.yaml
T
总工 a2fd5e369b Wave 2.1: 返工黑屏/安装进度/官方配置三层/文档深度/真机列表
老板实测 5 条修复:DiagTab Hooks 黑屏、安装三阶段进度、配置按官方字段三层分组、FR-09 中文文档、detectCliAll 接入列表页。
2026-08-25 11:57:10 +08:00

169 lines
5.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# AgentDock 适配器 · OpenCodeopencode.ai)(Wave 2.1
# 数据依据:调研底稿 agent-cli-survey-2026-08-24.mdOpenCode 章节)+ 架构 §3.3
# ============================================================
id: opencode
name: OpenCode
name_zh: OpenCode
vendor: opencode.ai
status: available
adapter_version: 1.1.0
license: MIT
platforms:
windows:
architectures: [x64]
notes: 原生支持(choco/scoop/exe,无需 WSL
linux:
distributions: [ubuntu]
architectures: [x64]
official:
homepage: https://opencode.ai
docs: https://opencode.ai/docs
allowed_hosts: [opencode.ai, registry.npmjs.org, github.com, community.chocolatey.org, get.scoop.sh]
runtime_deps: []
install:
preferred: npm
channels:
- id: npm
platforms: [windows, linux]
command: [npm, install, -g, opencode-ai]
package: opencode-ai
elevate: never
post_checks: [detect]
- id: choco
platforms: [windows]
command: [choco, install, opencode]
package: opencode
elevate: required
elevate_reason_zh: choco 安装需要管理员权限写入系统目录
post_checks: [detect]
- id: scoop
platforms: [windows]
command: [scoop, install, opencode]
package: opencode
elevate: never
post_checks: [detect]
- id: official_script
platforms: [linux]
script:
url: https://opencode.ai/install
kind: bash_pipe
elevate: never
post_checks: [detect]
detect:
executable: opencode
version_args: ["--version"]
update:
method: self_update_cmd
command: [opencode, upgrade]
uninstall:
method: npm_uninstall
command: [npm, uninstall, -g, opencode-ai]
keep_config_default: true
authorization:
modes:
- mode: browser_oauth
command: [opencode, auth, login]
notes_zh: 浏览器 OAuthClaude Pro/Max、ChatGPT 订阅等)
- mode: api_key
status_command: [opencode, auth, list]
env_keys: [OPENAI_API_KEY, ANTHROPIC_API_KEY]
notes_zh: 各家 API Keyopencode auth list 可查看凭据
- mode: device_code
notes_zh: GitHub Copilot 设备码登录(github.com/login/device 输码)
# 配置机制(调研底稿 OpenCode 章节):全局 ~/.config/opencode/opencode.jsonJSON,带注释 jsonc 亦可)
# model 字段设默认模型;每个 provider 可单独改 baseURL(含本地 Ollama/LM Studio 等 OpenAI 兼容端点);
# API Key 用环境变量引用接入,也可在 TUI 用 /connect 交互保存(凭据落 ~/.local/share/opencode/auth.json)。
configuration:
files:
- path: "~/.config/opencode/opencode.json"
format: json
scope: user
environment:
- key: OPENAI_API_KEY
sensitive: true
maps_to_field: api_key
- key: ANTHROPIC_API_KEY
sensitive: true
maps_to_field: api_key
fields:
- id: model
label_zh: 默认模型
group: common
help_zh: 官方键 model,全局默认模型(如 anthropic/claude-sonnet-4
required: false
sensitive: false
type: string
storage: file
docs_url: https://opencode.ai/docs/config/
- id: provider
label_zh: 默认 Provider
group: common
help_zh: 官方键 provider,指定默认模型提供方(可选;留空则用模型名推断)
required: false
sensitive: false
type: string
storage: file
docs_url: https://opencode.ai/docs/providers/
- id: api_key
label_zh: API Key
group: auth
help_zh: 存入系统密钥库(对应 OPENAI_API_KEY / ANTHROPIC_API_KEY 等环境变量);也可在 TUI 用 /connect 交互保存
required: false
sensitive: true
type: string
storage: keyring
docs_url: https://opencode.ai/docs/providers/
diagnostics:
- rule_id: path.not_installed
- rule_id: path.not_in_path
- rule_id: version_conflict.multiple_copies
- rule_id: config.corrupt
documentation:
quickstart_zh: 安装后运行 `opencode`,或用 `opencode run "提示词"` 无头执行。
install_zh: 多渠道:npm `opencode-ai`(本适配器默认)、Windows choco/scoop、Linux 官方脚本、Homebrew。桌面版另有原生 .exe 安装器。
auth_zh: 授权面最全:① 纯 API Key(各家环境变量);② 浏览器 OAuthClaude Pro/Max、ChatGPT 订阅);③ 设备码(GitHub Copilotgithub.com/login/device 输码);④ 企业级 OAuth。不绑定特定厂商。
commands:
- cmd: opencode
desc_zh: 启动交互式会话
- cmd: opencode run "提示词"
desc_zh: 无头单次执行
- cmd: opencode run "提示词" --model <模型>
desc_zh: 指定模型无头执行
- cmd: opencode auth login
desc_zh: 浏览器 OAuth 登录
- cmd: opencode auth list
desc_zh: 查看已配置凭据
- cmd: opencode upgrade
desc_zh: 自升级
- cmd: opencode serve
desc_zh: 无头 HTTP 服务器模式
- cmd: opencode --version
desc_zh: 显示版本号
params:
- param: run "提示词"
desc_zh: 一次性执行后退出
- param: --model
desc_zh: 指定模型
- param: --format json
desc_zh: JSON 事件流输出
- param: --auto-approve
desc_zh: 自动批准权限请求
- param: -v / --version
desc_zh: 显示版本号
updated_at: "2026-08-25"
risks_zh:
- 官方未文档化安装包校验(SHA256/签名),适配器不强制校验
- 每个 provider 的 baseURL 高级配置(本地 Ollama/LM Studio 等)本表单不覆盖,以官方 providers 文档为准