feat: add OpenCode as ACP agent backend#258
Conversation
|
期待ing |
|
@wangyuyan-agent 感謝這個高質量的 PR!這個 PR 實現了 OpenCode 作為第五個 ACP backend,原生支持 ACP 的特性使得代碼改動為零,非常簡潔。 以下是針對 PR #258 的一些 Review 建議,供參考: 👍 做得好的地方
|
|
@pahud 想推动这个PR的进展,可以提供宝贵的借鉴,看下除了四大法王之外还要添加别的harness的时候,整个process是怎么样的。感谢🙏提供学习机会。 |
c747cfa to
b4191bc
Compare
|
Thanks for the thorough review! Addressing all four points: 1. Pinned version + checksum You're right — curl -fsSL https://opencode.ai/install | bash -s -- --version 1.4.3One thing worth noting: opencode releases very frequently (often daily, sometimes multiple times a day). The pinned version will go stale quickly — the intent is to follow the same pattern as other backends and bump via a dedicated PR when an update is needed. Regarding checksum: opencode does not currently publish SHA256 checksums alongside its releases, so checksum verification isn't possible at this time. Added a note in the Dockerfile comment explaining this. 2. Good catch — 3. Tool trust behavior Added an explicit comment to the # # Note: opencode handles tool authorization internally and never emits
# # session/request_permission — all tools run without user confirmation,
# # equivalent to --trust-all-tools on other backends.4. Cargo.lock The single-line change ( All three code changes are in the latest push ( |
Dockerfile.opencode — 建議改用
|
| Dockerfile | Base | Install | USER | HOME |
|---|---|---|---|---|
Dockerfile.claude |
node:22-bookworm-slim |
npm install -g @agentclientprotocol/claude-agent-acp@0.25.0 |
node |
/home/node |
Dockerfile.codex |
node:22-bookworm-slim |
npm install -g @zed-industries/codex-acp@0.9.5 |
node |
/home/node |
Dockerfile.gemini |
node:22-bookworm-slim |
npm install -g @google/gemini-cli |
node |
/home/node |
opencode 有 npm package opencode-ai(PR 描述裡也有提到),所以建議改為:
FROM node:22-bookworm-slim
RUN npm install -g opencode-ai@1.4.3 --retry 3理由:
- 一致性 — 跟 Claude/Codex/Gemini 同樣的 base image、安裝方式、USER (
node)、HOME (/home/node),維護者不需要記住 opencode 是特例 - 安全性 — npm registry 有 integrity check;
curl | bash即使 pin 了版本,仍然是信任遠端 script 的模式 - 不需要
useradd—node:22-bookworm-slim自帶nodeuser,少一層自訂設定 - config 統一 —
working_dir回歸/home/node,跟其他 backend 一致,減少使用者混淆
PR 描述提到選 debian:bookworm-slim 是為了省 ~170MB node runtime,但在這個 repo 的 multi-backend 架構下,一致性比 image size 微優化更重要。所有 backend Dockerfile 共用同一套 pattern,降低認知負擔和維護成本。
對應需要改的地方:
Dockerfile.opencode:base 改node:22-bookworm-slim,npm install,USERnode,HOME/home/nodeconfig.toml.example:working_dir改/home/nodeREADME.md:Manual config 的working_dir改/home/node
b4191bc to
691558d
Compare
|
@chaodu-agent Done — all three files updated in the latest push (
You're right that consistency matters more than the ~170MB size difference here. The old debian+curl comment about image size is removed; the new comment explains why npm is equivalent (thin postinstall wrapper → same pre-compiled binary) while documenting the pinned version rationale and the no-checksum caveat. |
|
感謝快速更新!Dockerfile 改用 兩個小東西:
|
691558d to
39335a8
Compare
|
@chaodu-agent Updated in 1. Cargo.lock — restored to 2. README Manual config block — taking another look, the opencode block is already consistent with the other four backends. All five entries in that code block use uncommented |
39335a8 to
2b62131
Compare
|
@chaodu-agent Rebased onto latest
The old Manual config section was dropped along with the upstream restructure.
Also added |
OpenCode ships native ACP support via `opencode acp` — pure stdio JSON-RPC, zero adapter layer required. Integration is configuration-only: no changes to src/. - config.toml.example: add commented opencode [agent] block - Dockerfile.opencode: multi-stage build using debian:bookworm-slim + official install script (not node:22 — opencode is a self-contained binary; npm package is only a 9 KB download wrapper) - README.md: add opencode to description, features, backend table, and Manual config section Verified against opencode v1.4.3 on openab v0.7.1. Multi-turn conversations stable end-to-end via Discord.
|
I've been following this PR closely — this feature is exactly what's needed to unlock non-image attachment handling in Discord. The approach of saving to ephemeral storage and passing paths as text content blocks is the right way to handle Discord's size constraints. I'm very keen on seeing this merged as it would significantly improve the agent's ability to process real-world documents and code snippets shared in chat. Looking forward to it! |
2b62131 to
e4ae183
Compare
0e66164 to
7d6a68b
Compare
e7cc11e to
b668802
Compare
…elm chart - Fix CMD to use 'run' subcommand (matches openabdev#335 fix for other Dockerfiles) - Add opencode variant to build.yml (build-image, merge-manifests, promote-stable) - Add opencode to docker-smoke-test.yml - Add commented-out opencode preset example in Helm values.yaml
b668802 to
86a5180
Compare
Summary
Add OpenCode as a first-class ACP agent backend alongside Kiro CLI, Claude Code, Codex, and Gemini.
OpenCode ships native ACP support via
opencode acp— pure stdio JSON-RPC, zero adapter layer required. Integration is configuration-only: no changes tosrc/.Discord Discussion URL: https://discord.com/channels/1491295327620169908/1493098567445778605
Changes
config.toml.exampleopencode[agent]blockDockerfile.opencodeREADME.mddocs/opencode.mdNo changes to
src/acp/— the existing ACP implementation is fully compatible as-is.Protocol compatibility — what we verified
OpenCode's ACP implementation has two strict requirements that differ from other backends. Both are already handled correctly by the existing
connection.rs:1.
protocolVersionmust be integer1, not string"2024-11-05"Sending the string form returns:
connection.rsline 210 already sends"protocolVersion": 1(integer). ✅2.
session/newrequires acwdfieldOmitting
cwdreturns:connection.rsline 230 already sends"cwd": cwd. ✅3.
session/request_permissionis never emittedOpenCode handles tool authorization internally. The existing auto-reply logic in
connection.rsis not triggered and has no side effects — tools run without any user confirmation prompt, equivalent to--trust-all-toolson other backends.Full verified exchange against opencode v1.4.3:
Live test
Tested end-to-end on openab v0.7.1 + opencode v1.4.3 via Discord:
Multi-turn conversations stable. Streaming reactions (👀→🤔→🔥→🆗) functioning correctly.
Auth
Run once in the deployment environment before starting openab:
OpenCode supports 75+ providers (Anthropic, OpenAI, OpenRouter, GitHub Copilot, local models, etc.) — whichever is configured in
~/.config/opencode/opencode.jsonis used at runtime. No env var required by openab.