Background
PR #824 delivered opencode v2 support; #850/#885 added the proxy / launcher / native-spawn modes plus the /acp command. But bili pi users get a fundamentally better shape: the agent-side plugin owns compression locally — no proxy hop, no BILLION_CONTEXT_PROXY, wire traffic goes straight to the real upstream. opencode v2 had no equivalent (its "native" mode still self-spawns a proxy).
User request (paraphrased from session): "bili pi is what we want — bili opencode is the remote mode. pi implements modes 1 (proxy) + 2 (launcher); make opencode match, with pure-local mode 3." Reference for the pure-local shape: https://github.com/ranxianglei/opencode-acp
What this adds
src/agent/opencode-local.ts — an opencode v2 plugin that runs the acp-kernel compression pipeline IN-PROCESS:
- session registry keyed by conversation id,
session.hook rebuilds the wire view through the kernel (folded messages, acp tags on text parts)
chat.params.tools injects the kernel's compress/decompress/acp_status tool set; chat.parameters enforces the compress system prompt
- tool execution goes through the kernel (
executeTool), so acp_status renders the same panel as /acp
- No proxy, no MITM, no env vars: the user's model config is untouched; context compression happens between opencode and the model, invisible on the wire except tags
Verification done
- unit tests (
tests/opencode-local.test.ts, 11 tests) + full suite 1673 pass
- Docker-isolated E2E with real opencode v2 + local sglang upstream: 4 postures (proxy / launcher / native-spawn / pure local) all green
- compression stress test in-container: model read ~200K tokens of real source, self-triggered compress 7 times (105K folded), refs strictly monotonic, no id reuse, two successful recall-from-summary answers, no tag leakage
Fixes ride on the same branch and are recorded in #906 (abort-guard, system-array push).
Background
PR #824 delivered opencode v2 support; #850/#885 added the proxy / launcher / native-spawn modes plus the /acp command. But
bili piusers get a fundamentally better shape: the agent-side plugin owns compression locally — no proxy hop, noBILLION_CONTEXT_PROXY, wire traffic goes straight to the real upstream. opencode v2 had no equivalent (its "native" mode still self-spawns a proxy).User request (paraphrased from session): "bili pi is what we want — bili opencode is the remote mode. pi implements modes 1 (proxy) + 2 (launcher); make opencode match, with pure-local mode 3." Reference for the pure-local shape: https://github.com/ranxianglei/opencode-acp
What this adds
src/agent/opencode-local.ts— an opencode v2 plugin that runs the acp-kernel compression pipeline IN-PROCESS:session.hookrebuilds the wire view through the kernel (folded messages,acptags on text parts)chat.params.toolsinjects the kernel's compress/decompress/acp_status tool set;chat.parametersenforces the compress system promptexecuteTool), soacp_statusrenders the same panel as/acpVerification done
tests/opencode-local.test.ts, 11 tests) + full suite 1673 passFixes ride on the same branch and are recorded in #906 (abort-guard, system-array push).