Skip to content

Add OpenCode and MiMo Code backends over ACP (#408) - #432

Merged
BunsDev merged 2 commits into
mainfrom
opencode-backend
Oct 28, 2026
Merged

BunsDev merged 2 commits into
mainfrom
opencode-backend

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #408.

What

Two new thread backends, OpenCode and MiMo Code (Xiaomi's OpenCode fork, binary mimo), driven through their Agent Client Protocol server (opencode acp --pure, mimo acp --pure) the way Codex runs through codex app-server. One class, apps/desktop/src/main/engine/backends/acp.ts, serves both.

  • One shared server per backend; a session per thread is the resume handle (session/resume, else session/load with the replayed history discarded; an unknown session starts afresh with a notice).
  • session/request_permission is answered through Modex's approval cards, rules and thread policies. A command is the shell tool with a $ command title; an edit carries its path and never its content. The answer is the request's own option (allow_once / allow_always / reject).
  • Stop sends session/cancel; the prompt answers cancelled and the turn is interrupted. Only a second Stop kills the shared server.
  • Modes are agents injected inline through OPENCODE_CONFIG_CONTENT / MIMOCODE_CONFIG_CONTENT (merged over the person's own config; nothing written to disk; self-update and transcript sharing off): Chat denies edits, Agent allows them, Full access asks nothing, Plan pins the built-in plan agent. A refused set_mode fails the turn, so no turn runs looser than asked.
  • Settings: cards for both, executable overrides verified by --version, default model selects, routing toggles; health is auth list's credential count; the model list is <cli> models.
  • Transcript, sidebar, failure card, usage ledger, approval rule preview, routines and the companion accept the new ids.

Not wired (documented in docs/opencode.md)

Confined Code Review turns are refused (they stay on Claude); Modex's knowledge, Space and image tools are not attached (their instructions go in as text with a notice); no question cards; no efforts in the model list; no cache measurements (Auto assumes an effort or fast change clears it).

For Val

AGENTS.md's CLI-only sentence now names all four CLIs: "Real models run only through the claude, codex, opencode and mimo CLIs (the last two over their acp server)". The CLIs reach their configured providers and OpenCode's free-model gateway as they do from a terminal; Modex adds no network call of its own and never sees a credential (sign-in stays opencode auth login / mimo auth login in a terminal).

Evidence

  • docs/reviews/2026-10-28-opencode-acp.json: raw ACP probes on OpenCode 1.19.5 (capabilities, text turn, cancel in 16 ms, resume, plan-mode write refused, build-mode edit asks, Modex's modex-chat write refused / shell asks and is denied, modex-agent write runs, modex-full shell runs).
  • docs/reviews/2026-10-28-mimo-acp.json: MiMo Code 0.1.16 handshake, session, Modex agents listed as modes, set_mode; with no credentials a prompt ends with no text and no tokens.
  • docs/reviews/2026-10-28-opencode-backend-live.json: the compiled backend driving the real OpenCode on its free model: health, 9 models, text turn, Chat-mode shell denied through the approval path (nothing written), Agent-mode write without a prompt, Stop confirmed 17 ms after cancel.
  • apps/desktop/test/acp-backend.test.ts: 13 unit tests on a scripted ACP server (config injection, mode/model/effort setup, streaming, permission mapping for all three answers, edit approvals without content, cancel, resume once per server and the unknown-session fallback, load replay discarded, refused mode fails, confinement refused, server exit, unoffered client requests declined, health and model probes, tool-call mapping).

pnpm build && pnpm test green locally (2041 desktop tests). Playwright e2e: 464 passed, 7 skipped on the first commit, with 6 failures that the second commit fixes (the Settings executable rows threw on a health map without the new ids; the stale-account spec now counts four cards). backend-health.spec.ts and code-review-agent.spec.ts pass after the fix; the full run is on CI.

🤖 Generated with Claude Code

Two new thread backends drive the OpenCode CLI and Xiaomi's MiMo Code fork
through their Agent Client Protocol server (`opencode acp --pure`,
`mimo acp --pure`), the way Codex runs through `codex app-server`: one shared
server per backend, a session per thread as the resume handle,
`session/request_permission` answered through Modex's approval cards, rules and
policies, and Stop as `session/cancel`.

Modex's modes are agents injected inline through the CLI's config variable:
Chat denies edits, Agent allows them, Full access asks nothing, Plan pins the
built-in plan agent. A refused mode fails the turn. Settings gets cards,
verified executable overrides and default models for both; health reads
`auth list`'s credential count and the model list is `<cli> models`.

Not wired: confined Code Review turns (refused), Modex's knowledge, Space and
image tools, question cards, efforts in the model list.

Accepted live on OpenCode 1.19.5 and MiMo Code 0.1.16 (docs/opencode.md,
docs/reviews/2026-10-28-opencode-*.json, -mimo-acp.json). AGENTS.md's CLI-only
rule now names all four CLIs.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 28, 2026 6:23pm UTC

Request Review

A stubbed or older backends:health result has no opencode/mimo entries; the
executable-path rows now read them optionally instead of throwing and taking
the Coding CLIs section down. The stale-account e2e counts all four cards.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 7a01df2 opencode-backend da65d3b +/-
66% 66% 0%
View coverage of the 10 most impacted files.
File main 7a01df2 opencode-backend da65d3b +/-
apps/desktop/sr...ine/cli-path.ts 93% 93% 0%
apps/desktop/sr...ngine/runner.ts 98% 98% 0%
apps/desktop/sr...uting/policy.ts 99% 99% 0%
apps/desktop/sr...ate-recovery.ts 100% 100% 0%
apps/desktop/sr...vals/preview.ts 100% 100% 0%
apps/desktop/sr...ne/companion.ts 98% 98% 0%
apps/desktop/sr...ine/routines.ts 99% 99% 0%
apps/desktop/sr...engine/store.ts 100% 100% 0%
apps/desktop/sr...shared/types.ts 100% 100% 0%
apps/desktop/sr...backends/acp.ts 0% 91% +91%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@BunsDev
BunsDev added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit afd50ef Oct 28, 2026
13 checks passed
@BunsDev
BunsDev deleted the opencode-backend branch October 28, 2026 20:29

This branch was successfully deployed

1 active deployment
Preview — da65d3b8 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

open code/mimo code support

2 participants