From 278bea66de3c0d018ad618a6de8b5d38ff08a25b Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 16 Sep 2026 11:02:19 +0800 Subject: [PATCH 1/2] fix: yield to billion-context native mode via action-time env re-check (#405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native mode (billion-context #820/#824) writes BILLION_CONTEXT_NATIVE at the plugin's module evaluation — possibly after ACP setup sampled env — and never touches provider baseURLs, so no pre-existing self-disable signal could see it. - lib/bili-proxy.ts: pure detectBiliEnvYield()/describeBiliEnvYield() covering both owner markers (launcher precedence), injectable env for tests - index.ts: setup fast path covers both markers; guard() and config hook re-sample env at action time with one-time log per source; deny-tools block extracted to a shared helper - lib/compress/types.ts: resolveToolContext() throws when a marker is set at action time — single chokepoint gating all five ACP tools - tests/bili-native-yield.test.ts: 10 tests (unit + integration through the real factory); mutation-checked: 7/10 fail on master, 10/10 pass with fix --- .../DESIGN.md | 64 ++++ .../REQ.md | 53 +++ .../WORKLOG.md | 43 +++ index.ts | 71 +++- lib/bili-proxy.ts | 47 +++ lib/compress/types.ts | 13 + tests/bili-native-yield.test.ts | 339 ++++++++++++++++++ 7 files changed, 616 insertions(+), 14 deletions(-) create mode 100644 devlog/2026-09-16_billion-context-native-yield/DESIGN.md create mode 100644 devlog/2026-09-16_billion-context-native-yield/REQ.md create mode 100644 devlog/2026-09-16_billion-context-native-yield/WORKLOG.md create mode 100644 tests/bili-native-yield.test.ts diff --git a/devlog/2026-09-16_billion-context-native-yield/DESIGN.md b/devlog/2026-09-16_billion-context-native-yield/DESIGN.md new file mode 100644 index 00000000..257c0e4d --- /dev/null +++ b/devlog/2026-09-16_billion-context-native-yield/DESIGN.md @@ -0,0 +1,64 @@ +# DESIGN - Yield to billion-context native mode via action-time env re-check + +- Task ID: `2026-09-16_billion-context-native-yield` +- Home Repo: `opencode-acp` +- Created: 2026-09-16 +- Status: Accepted + +## 1. Problem Statement + +- **What problem are we solving?** ACP cannot detect that billion-context owns compression in **native** mode (OpenCode 2.x package plugin): every existing self-disable signal (`BILLION_CONTEXT_PROXY` sampled once at setup; `/bili/` prefix in configured provider baseURL) is statically sampled before/without the native-mode ownership marker ever becoming visible. Result: double compression (#405). +- **Why now?**: billion-context PR #824 (native mode, open) ships a synchronous ownership marker specifically so standalone extensions like ACP can back off — ACP must consume it before that PR merges or the double-compression window goes live. + +## 2. Goals & Non-Goals + +- **Goals**: + - Detect both owner markers (`BILLION_CONTEXT_PROXY` launcher, `BILLION_CONTEXT_NATIVE` native) at action time, not just startup. + - On detection: reuse the existing yield path (deny ACP tools in config hook + no-op all guarded hooks + one-time log); tools additionally throw at execute time. + - Non-latching: unsetting the marker restores ACP (mirrors existing `/bili/` flag semantics). + - Zero state-format/API breakage; hot path stays O(1) with no I/O. +- **Non-Goals**: + - No installer-side reconciliation of third-party plugin entries (billion-context repo scope). + - No health-probe/port-based proxy discovery. + - No changes to compression pipeline internals. + +## 3. Current Architecture + +- **How it works today**: + ``` + opencode process start + └─ plugin factory (index.ts) + ├─ sample process.env.BILLION_CONTEXT_PROXY ONCE → return {} if set [launcher mode only] + ├─ register hooks wrapped in guard(disabledByBiliProxy flag) + └─ config hook: findBiliProxyProviders(baseURL "/bili/") → set flag + deny tools [manual mode only] + ``` +- **Pain points**: both signals are point-in-time samples. Native mode writes its marker later (module evaluation order vs ACP setup) and never touches baseURL → undetectable. + +## 4. Proposed Architecture + +- **Overview**: + ``` + every ACP action re-samples env via detectBiliEnvYield(): + setup fast path : marker set → factory returns {} (existing pattern, extended to 2 vars) + guard(hook call) : marker set → no-op + one-time log (NEW lazy branch) + config hook run : marker set → deny 5 tools, skip wiring (NEW lazy branch, shared denyAcpTools helper) + resolveToolContext(): marker set → throw "disabled" error (NEW; single chokepoint for all 5 tools) + ``` +- **Key components**: + - `lib/bili-proxy.ts`: `detectBiliEnvYield(env?) → "launcher" | "native" | null` (pure, injectable env), `describeBiliEnvYield(source)`, constants `BILI_PROXY_ENV_VAR` / `BILI_NATIVE_ENV_VAR`. Launcher precedence (native bootstrap refuses to run while the launcher var is set). + - `index.ts`: closure-level `noteEnvYield()` dedups logging per source per factory instance (guard runs on every LLM request). + - `lib/compress/types.ts`: `resolveToolContext()` gate — first statement of every tool execute, so one check covers compress/decompress/search_context/acp_status/acp_context_recap without touching the five tool files. +- **Data flow**: no new data structures; `process.env` remains the sole carrier of the cross-plugin contract. Precedence chain when multiple signals are active: any signal yields; for logging/description, `disabledByBiliProxy` (/bili/) branch keeps its own message, env branches use `describeBiliEnvYield`. + +## 5. Alternatives Considered + +| Option | Verdict | Why | +| ----------------------------------------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| Wrap each tool's `execute` in index.ts with a typed wrapper | Rejected | Requires SDK type gymnastics for 5 tools; `resolveToolContext` gives identical coverage at one existing chokepoint with zero signature changes | +| Poll a file/port to discover the native proxy | Rejected | I/O on hot path, race-prone, and the env marker is the agreed synchronous contract already shipped on the billion-context side | +| Latch disable permanently once detected | Rejected | Breaks parity with the existing non-latched `/bili/` semantics (config reload restores ACP); tests assert the restore path | +| Check only in the config hook | Insufficient | Config runs are discrete events; a tool call between the marker landing and the next config run would still act — hence the `resolveToolContext` gate | + +## 6. Backward Compatibility + +- Persisted state format: unchanged. Internal `dcp` tags: unchanged. Exported APIs: additive only (new exports in `lib/bili-proxy`). Existing log message for `/bili/` detection: verbatim preserved. Launcher-mode behavior: identical outcome, same log wording family. diff --git a/devlog/2026-09-16_billion-context-native-yield/REQ.md b/devlog/2026-09-16_billion-context-native-yield/REQ.md new file mode 100644 index 00000000..0a55b10d --- /dev/null +++ b/devlog/2026-09-16_billion-context-native-yield/REQ.md @@ -0,0 +1,53 @@ +# REQ - Yield to billion-context native mode via action-time env re-check + +- Task ID: `2026-09-16_billion-context-native-yield` +- Home Repo: `opencode-acp` +- Created: 2026-09-16 +- Status: InProgress +- Priority: P1 +- Owner: ranxianglei (agent: ework-daemon) +- References: https://github.com/ranxianglei/opencode-acp/issues/405 · source analysis: ranxianglei/billion-context#820 · marker provided by ranxianglei/billion-context PR #824 + +## 1. Background & Problem Statement + +- **Context**: billion-context adds an OpenCode 2.x host-native mode (`opencode-native`, PR #824): a package-installed plugin bootstraps its own proxy and replaces model-API requests at `http.request` time (new Request object pointing at `/bili/`; `Request.url` is readonly, #810). If opencode-acp is loaded alongside it, both compress → violates the single-compression-owner principle. +- **Current behavior (symptom)**: ACP's self-disable signals are all sampled statically at setup/config time: + 1. `index.ts` setup check reads `BILLION_CONTEXT_PROXY` once — in native mode that var is written only AFTER async proxy bootstrap, so setup misses it. + 2. The config hook / `lib/bili-proxy.ts` rely on `/bili/` in provider `baseURL` — native mode never touches configured baseURL, so the signal is invisible. + - Result: launcher mode and manual-wiring mode yield correctly; **native mode has no detectable signal at all** → double compression for users with both plugins installed. +- **Expected behavior**: ACP yields (deny tools + no-op hooks + one-time log) whenever billion-context owns compression in this process, regardless of when the ownership marker appears relative to ACP setup. +- **Impact**: Users with `opencode-acp` + `/plugins/billion-context` installed get double compression in native mode until the billion-context installer reconciles third-party entries (`bili plugin install opencode` does not currently remove the opencode-acp entry) — this fix is the safety net. + +## 2. Reproduction (if applicable) + +- **Environment**: any host with opencode 2.x + ACP plugin + billion-context native plugin installed simultaneously. +- **Minimal reproduction steps**: + 1. Install both plugins so both load in one opencode process. + 2. Start opencode directly (no `bili` launcher). + 3. Observe: ACP stays fully active while the native plugin also compresses via the proxy. +- **Relevant configuration**: none specific — failure is structural (signal timing), independent of ACP config values. + +## 3. Constraints & Non-Goals + +- **Constraints**: + - Backward compatibility: persisted state format, internal `dcp` tags, exported APIs unchanged. Existing launcher/manual-mode yield behavior must be byte-for-byte preserved (existing tests green). + - Performance requirements: env reads are O(1); guard runs on every LLM request — no new I/O, no log spam (one-time log per source per factory instance). + - Marker contract (billion-context side, verified on branch `2026-09-15_opencode-native-plugin`): `markNativeHost()` sets `process.env.BILLION_CONTEXT_NATIVE = "opencode"` synchronously at module evaluation, first-writer-wins, gated by `nativeBootstrapGate`. +- **Non-Goals** (explicitly out of scope): + - Changing the billion-context installer to remove third-party plugin entries (their repo's problem). + - Detecting the proxy by probing ports/health endpoints (env marker is the agreed synchronous contract). + - Any state-persistence changes. + +## 4. Acceptance Criteria (must be testable) + +- **Correctness**: + - [x] `detectBiliEnvYield(env?)` pure function returns `"launcher"` / `"native"` / `null` with launcher precedence; unit-tested. + - [x] Setup-time fast path: either marker set before factory run → factory returns `{}` (no hooks/tools), one-time log. + - [x] Marker set AFTER factory run (the #405 race): next config run denies all 5 ACP tools and skips command/primary_tools wiring; all guarded hooks (system/messages/text.complete/command/event) become no-ops. + - [x] Tool execute gate: with either marker set, every ACP tool's execute throws a clear "disabled" error (shared `resolveToolContext` chokepoint covers all five tools). + - [x] `BILLION_CONTEXT_PROXY` is re-read at action time too (launcher marker landing late yields identically). + - [x] Re-enable: unsetting the marker restores full ACP behavior (config wiring + ID injection + tool gate passes). + - [x] Exactly one yield log line per source per factory instance across repeated hook invocations. + - [x] Pre-existing `bili-proxy-integration.test.ts` (manual `/bili/` mode) still passes unchanged. +- **Performance / Stability**: + - [x] No new I/O on the hot path; `npm run typecheck`, `npm test`, `npm run build` all pass. diff --git a/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md b/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md new file mode 100644 index 00000000..20efdbca --- /dev/null +++ b/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md @@ -0,0 +1,43 @@ +# WORKLOG - Yield to billion-context native mode via action-time env re-check + +- Task ID: `2026-09-16_billion-context-native-yield` +- Home Repo: `opencode-acp` +- Status: InProgress +- Updated: 2026-09-16 11:10 + +## 1. Summary + +- **What was done**: Added action-time (lazy) detection of billion-context ownership markers (`BILLION_CONTEXT_PROXY`, `BILLION_CONTEXT_NATIVE`) at every ACP action point — setup fast path, hook guard, config hook, and the shared tool entry point — so ACP yields to billion-context in launcher AND native modes regardless of plugin load order. +- **Why**: In native mode (billion-context #820/#824) the ownership marker is written asynchronously/after ACP setup, and configured provider baseURLs never carry `/bili/`, so all pre-existing static-sampling signals missed it → double compression (#405). +- **Behavior / compatibility changes**: Yes — new yield path for a previously undetectable scenario; all existing behavior (launcher env check, `/bili/` baseURL detection, logs) preserved. No state-format or API changes. +- **Risk level**: Low + +## 2. Change Log + +### Commits + +| Commit | Description | +| ------ | ------------------------------------------------------------------------------ | +| TBD | feat: yield to billion-context native mode via action-time env re-check (#405) | + +### Key Files + +- `lib/bili-proxy.ts` — new pure `detectBiliEnvYield(env?)` + `describeBiliEnvYield(source)` + exported env-var name constants; documents the cross-repo marker timing contract. +- `index.ts` — setup early-return now covers both markers; `guard()` re-samples env per call with one-time log per source; config hook re-samples env each run and denies all 5 ACP tools via extracted `denyAcpTools()` helper (shared with the existing `/bili/` branch). +- `lib/compress/types.ts` — `resolveToolContext()` (first statement of every ACP tool's execute) now throws a clear "disabled" error when either marker is set at action time — defense-in-depth covering all five tools at one chokepoint. +- `tests/bili-native-yield.test.ts` — new: unit tests for the pure detector + integration tests through the real factory (setup fast path ×2 markers, runtime marker → deny/no-op/tool-throws, launcher parity, re-enable, one-time log). + +## 3. Design & Implementation Notes + +- Marker contract verified against billion-context branch `2026-09-15_opencode-native-plugin`: `src/agent/native-bootstrap.ts` `markNativeHost()` sets `env.BILLION_CONTEXT_NATIVE = "opencode"` synchronously at module evaluation (before any await, first-writer-wins); called from `src/agent/opencode-native.ts:160` guarded by `nativeBootstrapGate` (which refuses to run when `BILLION_CONTEXT_PROXY` is already set — hence launcher precedence in `detectBiliEnvYield`). +- Why three sampling points: setup = cheap full bail-out when load order favors us; guard/config-hook = covers the race where the native module evaluates after ACP setup (hooks no-op + tools removed from LLM list); `resolveToolContext` = covers the residual window where a tool call lands after the last config run but before opencode re-applies permissions. +- One-time log dedup is per factory instance (closure var `announcedEnvYieldSource`) because `guard()` runs on every LLM request. +- The `/bili/` branch keeps its original log message verbatim (no hidden external dependency assumed, but no reason to churn it). + +## 4. Verification + +- [x] `npm run typecheck` — clean +- [x] `npm test` — 1273 pass / 0 fail (new file adds 10 tests, all green) +- [x] `npm run build` — success +- [x] Mutation check: with `index.ts` + `lib/compress/types.ts` reverted to master, 7/10 new tests FAIL; with the fix, 10/10 PASS +- [x] `format:check`: repo baseline already fails (450 files pre-existing drift); only NEW files formatted with prettier, tracked files untouched to keep the diff clean diff --git a/index.ts b/index.ts index 3221637a..026fbc3e 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,6 @@ /** ACP version, injected at build time by tsup define */ declare const ACP_VERSION: string | undefined -import type { Plugin } from "@opencode-ai/plugin" +import type { Config, Plugin } from "@opencode-ai/plugin" import { getConfig } from "./lib/config" import { createAcpStatusTool, @@ -25,7 +25,11 @@ import { createTextCompleteHandler, } from "./lib/hooks" import { configureClientAuth, isSecureMode } from "./lib/auth" -import { findBiliProxyProviders } from "./lib/bili-proxy" +import { + describeBiliEnvYield, + detectBiliEnvYield, + findBiliProxyProviders, +} from "./lib/bili-proxy" import { startAutoUpdate } from "./lib/update" const server: Plugin = (async (ctx) => { @@ -35,9 +39,13 @@ const server: Plugin = (async (ctx) => { return {} } - if (process.env.BILLION_CONTEXT_PROXY) { + // [FIX #405] Fast path covering BOTH owner markers (launcher + native). + // Markers written after this point are still caught by the action-time + // re-sampling in guard() / config hook / resolveToolContext. + const setupBiliYield = detectBiliEnvYield() + if (setupBiliYield) { console.log( - "[opencode-acp] disabled: BILLION_CONTEXT_PROXY detected — proxy handles compression", + `[opencode-acp] disabled: ${describeBiliEnvYield(setupBiliYield)} detected — billion-context handles compression`, ) return {} } @@ -115,10 +123,32 @@ const server: Plugin = (async (ctx) => { // compression alone. Assigned (not latched) so a config reload that // removes the proxy restores ACP behavior. let disabledByBiliProxy = false + + // [FIX #405] Env owner markers are re-sampled at every action (hook call, + // config run, tool call) instead of trusting the setup-time snapshot: + // native mode writes BILLION_CONTEXT_NATIVE at the billion-context + // plugin's module evaluation, which can land after ACP setup. One-time + // log per source (the guard runs on every LLM request — no log spam). + let announcedEnvYieldSource: string | undefined + const noteEnvYield = (source: string | null) => { + if (source === null || announcedEnvYieldSource === source) return + announcedEnvYieldSource = source + console.log( + `[opencode-acp] disabled: ${source} detected — billion-context handles compression`, + ) + } + const guard = (fn: (...args: TArgs) => Promise) => - (...args: TArgs): Promise => - disabledByBiliProxy ? Promise.resolve() : fn(...args) + (...args: TArgs): Promise => { + if (disabledByBiliProxy) return Promise.resolve() + const envYield = detectBiliEnvYield() + if (envYield !== null) { + noteEnvYield(describeBiliEnvYield(envYield)) + return Promise.resolve() + } + return fn(...args) + } return { "experimental.chat.system.transform": guard( @@ -162,14 +192,9 @@ const server: Plugin = (async (ctx) => { // BILLION_CONTEXT_PROXY env-var guard. Denying the ACP tools // removes them from the LLM tool list (verified against a live // opencode instance), and the guard flag no-ops every hook. - const biliMatches = findBiliProxyProviders(opencodeConfig.provider) - disabledByBiliProxy = biliMatches.length > 0 - if (biliMatches.length > 0) { - console.log( - "[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + - biliMatches.map((m) => m.provider).join(", ") + - ") — proxy handles compression", - ) + // [FIX #405] Env owner markers are re-sampled here too: the + // native-mode marker may appear only after ACP setup sampled env. + const denyAcpTools = (opencodeConfig: Config) => { const permission = opencodeConfig.permission ?? {} opencodeConfig.permission = { ...permission, @@ -179,6 +204,24 @@ const server: Plugin = (async (ctx) => { acp_status: "deny", acp_context_recap: "deny", } as typeof permission + } + + const envYield = detectBiliEnvYield() + if (envYield !== null) { + noteEnvYield(describeBiliEnvYield(envYield)) + denyAcpTools(opencodeConfig) + return + } + + const biliMatches = findBiliProxyProviders(opencodeConfig.provider) + disabledByBiliProxy = biliMatches.length > 0 + if (biliMatches.length > 0) { + console.log( + "[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + + biliMatches.map((m) => m.provider).join(", ") + + ") — proxy handles compression", + ) + denyAcpTools(opencodeConfig) return } diff --git a/lib/bili-proxy.ts b/lib/bili-proxy.ts index 972a6268..eebb0d4d 100644 --- a/lib/bili-proxy.ts +++ b/lib/bili-proxy.ts @@ -56,3 +56,50 @@ export function findBiliProxyProviders(provider: unknown): BiliProxyMatch[] { } return matches } + +/** + * [FIX #405] Process-env ownership markers left by billion-context. + * + * Two owner modes are invisible to the provider-config signal above: + * + * - Launcher mode (`bili `): sets `BILLION_CONTEXT_PROXY` for the + * launched child process. ACP's setup-time sample catches it only if the + * variable already exists when the plugin factory runs — re-sampling env at + * action time removes that timing assumption entirely. + * + * - Native mode (billion-context opencode-native plugin, #820/#824): the + * plugin replaces model-API requests at `http.request` time, so the + * configured provider baseURL never contains `/bili/`, and + * `BILLION_CONTEXT_PROXY` is written only after the async proxy bootstrap. + * The native entry marks ownership synchronously at module evaluation + * (`markNativeHost()`, first-writer-wins) — but that evaluation can still + * land AFTER ACP's setup sampled env, depending on plugin load order. + * + * Consumers must therefore sample env at ACTION time (hook invocations, + * config runs, tool calls) and never trust a startup snapshot. + */ +export const BILI_PROXY_ENV_VAR = "BILLION_CONTEXT_PROXY" +export const BILI_NATIVE_ENV_VAR = "BILLION_CONTEXT_NATIVE" + +export type BiliEnvYield = "launcher" | "native" + +/** + * Detect a billion-context ownership marker in the given environment + * (defaults to `process.env`). Pure — safe to unit test. + * + * Returns `"launcher"` when `BILLION_CONTEXT_PROXY` is set (takes precedence — + * native bootstrap refuses to run while it is set, so both cannot normally + * coexist), `"native"` when only `BILLION_CONTEXT_NATIVE` is set, else `null`. + */ +export function detectBiliEnvYield(env: Record = process.env): BiliEnvYield | null { + if (env[BILI_PROXY_ENV_VAR]) return "launcher" + if (env[BILI_NATIVE_ENV_VAR]) return "native" + return null +} + +/** Human-readable ownership source for logs and error messages. */ +export function describeBiliEnvYield(source: BiliEnvYield): string { + return source === "native" + ? "BILLION_CONTEXT_NATIVE set (billion-context native mode)" + : "BILLION_CONTEXT_PROXY set (billion-context launcher mode)" +} diff --git a/lib/compress/types.ts b/lib/compress/types.ts index 706e3404..ba78983c 100644 --- a/lib/compress/types.ts +++ b/lib/compress/types.ts @@ -1,4 +1,5 @@ import type { PluginConfig } from "../config" +import { describeBiliEnvYield, detectBiliEnvYield } from "../bili-proxy" import type { Logger } from "../logger" import type { PromptStore } from "../prompts/store" import type { CompressionBlock, CompressionMode, SessionState, WithParts } from "../state" @@ -27,6 +28,18 @@ export function resolveToolContext( factoryCtx: ToolFactoryContext, sessionID: string, ): ToolContext { + // [FIX #405] Action-time owner re-check (defense-in-depth for every ACP + // tool — all five execute() bodies enter through here): the config hook + // denies the tools once billion-context claims ownership, but the + // native-mode marker can land after the last config run. No tool may act + // after the handoff. + const biliYield = detectBiliEnvYield() + if (biliYield !== null) { + throw new Error( + `ACP is disabled in this process — ${describeBiliEnvYield(biliYield)}. ` + + "billion-context owns context compression; do not call ACP tools again.", + ) + } const state = factoryCtx.registry.get(sessionID) if (!state) { throw new Error( diff --git a/tests/bili-native-yield.test.ts b/tests/bili-native-yield.test.ts new file mode 100644 index 00000000..151c5769 --- /dev/null +++ b/tests/bili-native-yield.test.ts @@ -0,0 +1,339 @@ +/** + * Tests for the #405 billion-context owner-marker yield: ACP must back off + * when billion-context owns compression in this process, detected by + * re-sampling env markers at ACTION time (not just at setup): + * + * - BILLION_CONTEXT_PROXY (launcher mode) + * - BILLION_CONTEXT_NATIVE (native mode; written at the billion-context + * plugin's module evaluation, which can land AFTER ACP setup) + * + * Coverage: setup-time fast path (factory returns {}), marker landing after + * factory init (config hook denies tools + every hook no-op + tool execute + * throws), launcher marker likewise, re-enable after unsetting, one-time log. + */ + +import assert from "node:assert/strict" +import test from "node:test" +import { join } from "node:path" +import { tmpdir } from "node:os" +import { mkdirSync, writeFileSync } from "node:fs" +import type { PluginInput, Hooks, Config, ToolContext } from "@opencode-ai/plugin" +import type { WithParts } from "../lib/state" +import { describeBiliEnvYield, detectBiliEnvYield } from "../lib/bili-proxy" + +const testDataHome = join(tmpdir(), `opencode-acp-bilinat-data-${process.pid}`) +const testConfigHome = join(tmpdir(), `opencode-acp-bilinat-config-${process.pid}`) + +// Must be set BEFORE importing ../index: lib/config.ts captures +// XDG_CONFIG_HOME into a module-level constant at import time. +process.env.XDG_DATA_HOME = testDataHome +process.env.XDG_CONFIG_HOME = testConfigHome +delete process.env.BILLION_CONTEXT_PROXY +delete process.env.BILLION_CONTEXT_NATIVE +delete process.env.OPENCODE_CONFIG_DIR +delete process.env.OPENCODE_SERVER_PASSWORD + +mkdirSync(join(testConfigHome, "opencode"), { recursive: true }) +writeFileSync( + join(testConfigHome, "opencode", "acp.jsonc"), + JSON.stringify({ autoUpdate: false }), + "utf-8", +) +mkdirSync(testDataHome, { recursive: true }) + +const { default: plugin } = await import("../index") + +function makeCtx(): PluginInput { + const client = { + config: { + providers: async () => ({ data: { providers: [] } }), + get: async () => ({ data: {} }), + }, + session: { + get: async () => ({ data: {} }), + messages: async () => ({ data: [] }), + }, + tui: { showToast: async () => {} }, + } + return { + client: client as PluginInput["client"], + project: { path: testDataHome }, + directory: testDataHome, + worktree: testDataHome, + experimental_workspace: { register: () => {} }, + serverUrl: new URL("http://127.0.0.1:1"), + $: { command: async () => "" } as PluginInput["$"], + } +} + +const ACP_TOOLS = ["compress", "decompress", "search_context", "acp_status", "acp_context_recap"] + +function makeUserMessage(id: string, text: string, sessionId: string): WithParts { + return { + info: { + id, + sessionID: sessionId, + role: "user", + agent: "assistant", + time: { created: Date.now() }, + model: { providerID: "test-provider", modelID: "test-model" }, + } as WithParts["info"], + parts: [{ type: "text", text, id: `${id}-p1`, sessionID: sessionId, messageID: id }], + } +} + +function makeToolCtx(): ToolContext { + return { + sessionID: "session-nat-1", + messageID: "msg-nat-1", + agent: "assistant", + directory: testDataHome, + worktree: testDataHome, + abort: new AbortController().signal, + metadata: () => {}, + ask: async () => {}, + } +} + +async function makeHooks(): Promise { + const hooks = await plugin(makeCtx()) + assert.ok(hooks.config, "plugin factory must register a config hook") + return hooks +} + +const VALID_RANGE_ARGS = { + content: [{ startId: "m00001", endId: "m00002", summary: "test summary" }], +} + +const PLAIN_CONFIG: Config = { + provider: { openai: { options: { baseURL: "https://api.openai.com/v1" } } }, +} + +test("detectBiliEnvYield: pure detection and precedence", () => { + assert.equal(detectBiliEnvYield({}), null) + assert.equal(detectBiliEnvYield({ BILLION_CONTEXT_PROXY: "" }), null) + assert.equal(detectBiliEnvYield({ BILLION_CONTEXT_NATIVE: "" }), null) + assert.equal(detectBiliEnvYield({ BILLION_CONTEXT_PROXY: "http://127.0.0.1:8787" }), "launcher") + assert.equal(detectBiliEnvYield({ BILLION_CONTEXT_NATIVE: "opencode" }), "native") + // Launcher wins when both are set (native bootstrap refuses to run while + // BILLION_CONTEXT_PROXY is set, so both cannot normally coexist). + assert.equal( + detectBiliEnvYield({ + BILLION_CONTEXT_PROXY: "http://127.0.0.1:8787", + BILLION_CONTEXT_NATIVE: "opencode", + }), + "launcher", + ) +}) + +test("describeBiliEnvYield: log message wording", () => { + assert.match(describeBiliEnvYield("native"), /BILLION_CONTEXT_NATIVE/) + assert.match(describeBiliEnvYield("launcher"), /BILLION_CONTEXT_PROXY/) +}) + +test("setup-time native marker: factory yields immediately (fast path)", async () => { + process.env.BILLION_CONTEXT_NATIVE = "opencode" + try { + const hooks = await plugin(makeCtx()) + assert.equal(hooks.config, undefined, "no config hook when the marker is set at setup") + assert.equal(hooks.tool, undefined, "no tools registered when the marker is set at setup") + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } +}) + +test("setup-time launcher marker: factory yields immediately (fast path)", async () => { + process.env.BILLION_CONTEXT_PROXY = "http://127.0.0.1:8787" + try { + const hooks = await plugin(makeCtx()) + assert.equal(hooks.config, undefined) + assert.equal(hooks.tool, undefined) + } finally { + delete process.env.BILLION_CONTEXT_PROXY + } +}) + +test("runtime native marker: config hook denies all ACP tools and skips wiring", async () => { + const hooks = await makeHooks() + process.env.BILLION_CONTEXT_NATIVE = "opencode" + try { + const opencodeConfig: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(opencodeConfig) + + for (const toolName of ACP_TOOLS) { + assert.equal( + (opencodeConfig.permission as Record)[toolName], + "deny", + `permission.${toolName} must be "deny" when the native marker is set`, + ) + } + assert.equal( + opencodeConfig.command?.["acp"], + undefined, + "/acp command must not be registered when yielded", + ) + assert.equal( + opencodeConfig.experimental?.primary_tools, + undefined, + "primary_tools must not be touched when yielded", + ) + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } +}) + +test("runtime native marker: every ACP hook is a no-op", async () => { + const hooks = await makeHooks() + process.env.BILLION_CONTEXT_NATIVE = "opencode" + try { + const opencodeConfig: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(opencodeConfig) + + const messages = [ + makeUserMessage("msg-1", "hello world", "session-nat-2"), + makeUserMessage("msg-2", "second message", "session-nat-2"), + ] + const output = { messages } + await hooks["experimental.chat.messages.transform"]!({}, output) + assert.equal(output.messages[0].parts[0].text, "hello world") + assert.equal(output.messages[1].parts[0].text, "second message") + + const system: string[] = ["base system prompt"] + await hooks["experimental.chat.system.transform"]!( + { + sessionID: "session-nat-2", + model: { providerID: "anthropic", id: "claude", limit: { context: 200000 } }, + }, + { system }, + ) + assert.equal(system.length, 1) + assert.equal(system[0], "base system prompt") + + const textOutput = { text: "m00001 b0 some refs" } + await hooks["experimental.text.complete"]!( + { sessionID: "session-nat-2", messageID: "msg-1", partID: "part-1" }, + textOutput, + ) + assert.equal(textOutput.text, "m00001 b0 some refs") + + await hooks.event!({ + event: { type: "session.idle", properties: { sessionID: "session-nat-2" } }, + }) + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } +}) + +test("runtime native marker: tool execute throws instead of acting", async () => { + const hooks = await makeHooks() + process.env.BILLION_CONTEXT_NATIVE = "opencode" + try { + const compressTool = hooks.tool?.compress + assert.ok(compressTool, "compress tool must be registered before the marker lands") + await assert.rejects( + () => compressTool.execute(VALID_RANGE_ARGS, makeToolCtx()), + /disabled in this process[\s\S]*BILLION_CONTEXT_NATIVE/, + ) + // Second tool proves the shared resolveToolContext gate covers all five. + const recapTool = hooks.tool?.acp_context_recap + assert.ok(recapTool, "acp_context_recap tool must be registered") + await assert.rejects( + () => recapTool.execute({}, makeToolCtx()), + /disabled in this process[\s\S]*BILLION_CONTEXT_NATIVE/, + ) + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } +}) + +test("runtime launcher marker: same yield behavior (env re-read at action time)", async () => { + const hooks = await makeHooks() + process.env.BILLION_CONTEXT_PROXY = "http://127.0.0.1:8787" + try { + const opencodeConfig: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(opencodeConfig) + assert.equal((opencodeConfig.permission as Record)["compress"], "deny") + + const output = { messages: [makeUserMessage("msg-1", "hello world", "session-nat-3")] } + await hooks["experimental.chat.messages.transform"]!({}, output) + assert.equal(output.messages[0].parts[0].text, "hello world") + + const compressTool = hooks.tool?.compress + assert.ok(compressTool) + await assert.rejects( + () => compressTool.execute(VALID_RANGE_ARGS, makeToolCtx()), + /disabled in this process[\s\S]*BILLION_CONTEXT_PROXY/, + ) + } finally { + delete process.env.BILLION_CONTEXT_PROXY + } +}) + +test("re-enable: unsetting the marker restores ACP behavior", async () => { + const hooks = await makeHooks() + + process.env.BILLION_CONTEXT_NATIVE = "opencode" + const whileDisabled: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(whileDisabled) + assert.equal((whileDisabled.permission as Record)["compress"], "deny") + delete process.env.BILLION_CONTEXT_NATIVE + + // Simulate the marker disappearing (e.g. the native plugin was removed and + // the process is restarted into a clean env): ACP must resume. + const restored: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(restored) + assert.equal(restored.command?.["acp"]?.description, "Show available ACP commands") + assert.equal((restored.permission as Record)["compress"], "allow") + + const output = { messages: [makeUserMessage("msg-1", "hello world", "session-nat-4")] } + await hooks["experimental.chat.messages.transform"]!({}, output) + const text = output.messages[0].parts[0].text as string + assert.ok( + text.includes("dcp-message-id"), + `ACP ID injection must resume after the marker is unset, got: ${JSON.stringify(text)}`, + ) + + // The tool must get PAST the yield gate (it then fails on missing session + // state — proof the gate no longer fires). + const compressTool = hooks.tool?.compress + assert.ok(compressTool) + await assert.rejects( + () => compressTool.execute(VALID_RANGE_ARGS, makeToolCtx()), + /no initialized state/, + ) +}) + +test("yield announcement is logged exactly once per source", async () => { + const logs: string[] = [] + const originalLog = console.log + console.log = (...args: unknown[]) => { + logs.push(args.map(String).join(" ")) + } + try { + const hooks = await makeHooks() + process.env.BILLION_CONTEXT_NATIVE = "opencode" + try { + await hooks.config!(structuredClone(PLAIN_CONFIG)) + const output = { messages: [makeUserMessage("msg-1", "hi", "session-nat-5")] } + await hooks["experimental.chat.messages.transform"]!({}, output) + await hooks["experimental.chat.messages.transform"]!({}, output) + await hooks.event!({ + event: { type: "session.idle", properties: { sessionID: "session-nat-5" } }, + }) + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } + } finally { + console.log = originalLog + } + + const yieldLogs = logs.filter( + (line) => + line.includes("[opencode-acp] disabled:") && line.includes("BILLION_CONTEXT_NATIVE"), + ) + assert.equal( + yieldLogs.length, + 1, + `expected exactly one yield log, got: ${JSON.stringify(logs)}`, + ) +}) From 32d94ac877965aeb9308fde07b0be33bb3e6f700 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 16 Sep 2026 11:24:33 +0800 Subject: [PATCH 2/2] fix: address PR #406 dual-agent review findings (#405) - prettier: collapse index.ts import line, wrap detectBiliEnvYield signature (F1) - config hook: compute disabledByBiliProxy before either branch so the flag is never stale when an env marker and a /bili/ provider change together (F2) - restore master's exact launcher log wording via new biliYieldLogMessage() (F4) - tests: tool-gate now covers all 5 tools; hooks-no-op covers command.execute.before; re-enable test wrapped in try/finally; sibling bili-proxy-integration test also clears BILLION_CONTEXT_NATIVE --- .../WORKLOG.md | 32 +++++++++--- index.ts | 30 +++++------ lib/bili-proxy.ts | 13 ++++- tests/bili-native-yield.test.ts | 50 ++++++++++++------- tests/bili-proxy-integration.test.ts | 1 + 5 files changed, 84 insertions(+), 42 deletions(-) diff --git a/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md b/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md index 20efdbca..c8a98cc8 100644 --- a/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md +++ b/devlog/2026-09-16_billion-context-native-yield/WORKLOG.md @@ -16,16 +16,18 @@ ### Commits -| Commit | Description | -| ------ | ------------------------------------------------------------------------------ | -| TBD | feat: yield to billion-context native mode via action-time env re-check (#405) | +| Commit | Description | +| ----------- | ------------------------------------------------------------------------------ | +| 278bea6 | feat: yield to billion-context native mode via action-time env re-check (#405) | +| (this rev.) | fix: address PR #406 dual-agent review findings | ### Key Files -- `lib/bili-proxy.ts` — new pure `detectBiliEnvYield(env?)` + `describeBiliEnvYield(source)` + exported env-var name constants; documents the cross-repo marker timing contract. +- `lib/bili-proxy.ts` — new pure `detectBiliEnvYield(env?)` + `describeBiliEnvYield(source)` + `biliYieldLogMessage(source)` (single source of truth for the console announcement; keeps the launcher wording byte-identical to master) + exported env-var name constants; documents the cross-repo marker timing contract. - `index.ts` — setup early-return now covers both markers; `guard()` re-samples env per call with one-time log per source; config hook re-samples env each run and denies all 5 ACP tools via extracted `denyAcpTools()` helper (shared with the existing `/bili/` branch). - `lib/compress/types.ts` — `resolveToolContext()` (first statement of every ACP tool's execute) now throws a clear "disabled" error when either marker is set at action time — defense-in-depth covering all five tools at one chokepoint. -- `tests/bili-native-yield.test.ts` — new: unit tests for the pure detector + integration tests through the real factory (setup fast path ×2 markers, runtime marker → deny/no-op/tool-throws, launcher parity, re-enable, one-time log). +- `tests/bili-native-yield.test.ts` — new: unit tests for the pure detector + integration tests through the real factory (setup fast path ×2 markers, runtime marker → deny/no-op/tool-throws for ALL five tools, launcher parity, re-enable, one-time log). +- `tests/bili-proxy-integration.test.ts` — one line: also `delete process.env.BILLION_CONTEXT_NATIVE` in the pre-import env setup (the new setup fast path would otherwise break this suite if the host env carried the marker). ## 3. Design & Implementation Notes @@ -40,4 +42,22 @@ - [x] `npm test` — 1273 pass / 0 fail (new file adds 10 tests, all green) - [x] `npm run build` — success - [x] Mutation check: with `index.ts` + `lib/compress/types.ts` reverted to master, 7/10 new tests FAIL; with the fix, 10/10 PASS -- [x] `format:check`: repo baseline already fails (450 files pre-existing drift); only NEW files formatted with prettier, tracked files untouched to keep the diff clean +- [x] `format:check`: repo baseline already fails (~450 files pre-existing drift, left untouched); new files fully prettier-formatted; two targeted prettier fixes applied to tracked files per review (import line in `index.ts`, wrapped signature in `lib/bili-proxy.ts`) + +## 5. Review Round (PR #406, dual-agent) + +Two independent agents reviewed source + tests. Dispositions: + +| Finding | Severity | Disposition | +| ------- | -------- | ----------- | +| Prettier violations introduced in tracked files (import block >100 cols, unwrapped signature) | low | Fixed — collapsed import to one line, wrapped `detectBiliEnvYield` signature | +| Env branch returned before assigning `disabledByBiliProxy` → stale-flag edge when an env marker and a `/bili/` provider appear/disappear together | low | Fixed — flag computed before either branch (invariant documented in code) | +| Launcher log wording drifted from master (hidden external dependency risk) | info | Fixed — `biliYieldLogMessage()` restores the exact master string for launcher | +| Fail-closed tradeoff not documented (marker set but billion-context bootstrap later fails → ACP stays off until restart) | info | Documented in PR body (chosen over fail-open double-compression risk) | +| Tool-gate test covered only 2 of 5 tools | test | Fixed — all five tools exercised through the shared `resolveToolContext` gate | +| Hooks-no-op test missed `command.execute.before` | test | Fixed — invocation added, asserts output parts stay empty | +| Re-enable test lacked try/finally around the env mutation (demonstrated cascade failures) | test | Fixed | +| Sibling `bili-proxy-integration.test.ts` didn't clean `BILLION_CONTEXT_NATIVE` | test | Fixed — one-line delete in pre-import setup | +| `announcedEnvYieldSource` never resets (cosmetic: re-announce if marker toggles off/on within one process lifetime) | info | Accepted — detection itself is live every call; only the announcement dedup is sticky | + +Re-verified after fixes: `npm run typecheck` clean, `npm test` 1273/1273, `npm run build` OK, new test file prettier-clean. diff --git a/index.ts b/index.ts index 026fbc3e..8f85f736 100644 --- a/index.ts +++ b/index.ts @@ -25,11 +25,8 @@ import { createTextCompleteHandler, } from "./lib/hooks" import { configureClientAuth, isSecureMode } from "./lib/auth" -import { - describeBiliEnvYield, - detectBiliEnvYield, - findBiliProxyProviders, -} from "./lib/bili-proxy" +import { biliYieldLogMessage, detectBiliEnvYield, findBiliProxyProviders } from "./lib/bili-proxy" +import type { BiliEnvYield } from "./lib/bili-proxy" import { startAutoUpdate } from "./lib/update" const server: Plugin = (async (ctx) => { @@ -44,9 +41,7 @@ const server: Plugin = (async (ctx) => { // re-sampling in guard() / config hook / resolveToolContext. const setupBiliYield = detectBiliEnvYield() if (setupBiliYield) { - console.log( - `[opencode-acp] disabled: ${describeBiliEnvYield(setupBiliYield)} detected — billion-context handles compression`, - ) + console.log(biliYieldLogMessage(setupBiliYield)) return {} } @@ -129,13 +124,11 @@ const server: Plugin = (async (ctx) => { // native mode writes BILLION_CONTEXT_NATIVE at the billion-context // plugin's module evaluation, which can land after ACP setup. One-time // log per source (the guard runs on every LLM request — no log spam). - let announcedEnvYieldSource: string | undefined - const noteEnvYield = (source: string | null) => { + let announcedEnvYieldSource: BiliEnvYield | undefined + const noteEnvYield = (source: BiliEnvYield | null) => { if (source === null || announcedEnvYieldSource === source) return announcedEnvYieldSource = source - console.log( - `[opencode-acp] disabled: ${source} detected — billion-context handles compression`, - ) + console.log(biliYieldLogMessage(source)) } const guard = @@ -144,7 +137,7 @@ const server: Plugin = (async (ctx) => { if (disabledByBiliProxy) return Promise.resolve() const envYield = detectBiliEnvYield() if (envYield !== null) { - noteEnvYield(describeBiliEnvYield(envYield)) + noteEnvYield(envYield) return Promise.resolve() } return fn(...args) @@ -206,15 +199,18 @@ const server: Plugin = (async (ctx) => { } as typeof permission } + // Flag is computed before either branch so it is never stale when + // an env marker and a /bili/ provider appear/disappear together. + const biliMatches = findBiliProxyProviders(opencodeConfig.provider) + disabledByBiliProxy = biliMatches.length > 0 + const envYield = detectBiliEnvYield() if (envYield !== null) { - noteEnvYield(describeBiliEnvYield(envYield)) + noteEnvYield(envYield) denyAcpTools(opencodeConfig) return } - const biliMatches = findBiliProxyProviders(opencodeConfig.provider) - disabledByBiliProxy = biliMatches.length > 0 if (biliMatches.length > 0) { console.log( "[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + diff --git a/lib/bili-proxy.ts b/lib/bili-proxy.ts index eebb0d4d..f3abe634 100644 --- a/lib/bili-proxy.ts +++ b/lib/bili-proxy.ts @@ -91,15 +91,24 @@ export type BiliEnvYield = "launcher" | "native" * native bootstrap refuses to run while it is set, so both cannot normally * coexist), `"native"` when only `BILLION_CONTEXT_NATIVE` is set, else `null`. */ -export function detectBiliEnvYield(env: Record = process.env): BiliEnvYield | null { +export function detectBiliEnvYield( + env: Record = process.env, +): BiliEnvYield | null { if (env[BILI_PROXY_ENV_VAR]) return "launcher" if (env[BILI_NATIVE_ENV_VAR]) return "native" return null } -/** Human-readable ownership source for logs and error messages. */ +/** Human-readable ownership source for error messages thrown by tool gates. */ export function describeBiliEnvYield(source: BiliEnvYield): string { return source === "native" ? "BILLION_CONTEXT_NATIVE set (billion-context native mode)" : "BILLION_CONTEXT_PROXY set (billion-context launcher mode)" } + +/** Console announcement text per ownership source (callers log once each). */ +export function biliYieldLogMessage(source: BiliEnvYield): string { + return source === "native" + ? "[opencode-acp] disabled: BILLION_CONTEXT_NATIVE detected — billion-context native mode handles compression" + : "[opencode-acp] disabled: BILLION_CONTEXT_PROXY detected — proxy handles compression" +} diff --git a/tests/bili-native-yield.test.ts b/tests/bili-native-yield.test.ts index 151c5769..a3de0a0b 100644 --- a/tests/bili-native-yield.test.ts +++ b/tests/bili-native-yield.test.ts @@ -219,6 +219,13 @@ test("runtime native marker: every ACP hook is a no-op", async () => { await hooks.event!({ event: { type: "session.idle", properties: { sessionID: "session-nat-2" } }, }) + + const commandOutput = { parts: [] } + await hooks["command.execute.before"]!( + { command: "acp", sessionID: "session-nat-2", arguments: "context" }, + commandOutput, + ) + assert.equal(commandOutput.parts.length, 0) } finally { delete process.env.BILLION_CONTEXT_NATIVE } @@ -228,19 +235,25 @@ test("runtime native marker: tool execute throws instead of acting", async () => const hooks = await makeHooks() process.env.BILLION_CONTEXT_NATIVE = "opencode" try { - const compressTool = hooks.tool?.compress - assert.ok(compressTool, "compress tool must be registered before the marker lands") - await assert.rejects( - () => compressTool.execute(VALID_RANGE_ARGS, makeToolCtx()), - /disabled in this process[\s\S]*BILLION_CONTEXT_NATIVE/, - ) - // Second tool proves the shared resolveToolContext gate covers all five. - const recapTool = hooks.tool?.acp_context_recap - assert.ok(recapTool, "acp_context_recap tool must be registered") - await assert.rejects( - () => recapTool.execute({}, makeToolCtx()), - /disabled in this process[\s\S]*BILLION_CONTEXT_NATIVE/, - ) + // The yield check runs before arg validation, so minimal args suffice; + // each entry proves the shared resolveToolContext gate covers its tool. + const toolCalls: Array<[string, () => Promise]> = [ + ["compress", () => hooks.tool!.compress!.execute(VALID_RANGE_ARGS, makeToolCtx())], + ["decompress", () => hooks.tool!.decompress!.execute({}, makeToolCtx())], + [ + "search_context", + () => hooks.tool!.search_context!.execute({ query: "test" }, makeToolCtx()), + ], + ["acp_status", () => hooks.tool!.acp_status!.execute({}, makeToolCtx())], + ["acp_context_recap", () => hooks.tool!.acp_context_recap!.execute({}, makeToolCtx())], + ] + for (const [name, invoke] of toolCalls) { + await assert.rejects( + invoke, + /disabled in this process[\s\S]*BILLION_CONTEXT_NATIVE/, + `${name} execute must yield when the native marker is set`, + ) + } } finally { delete process.env.BILLION_CONTEXT_NATIVE } @@ -273,10 +286,13 @@ test("re-enable: unsetting the marker restores ACP behavior", async () => { const hooks = await makeHooks() process.env.BILLION_CONTEXT_NATIVE = "opencode" - const whileDisabled: Config = structuredClone(PLAIN_CONFIG) - await hooks.config!(whileDisabled) - assert.equal((whileDisabled.permission as Record)["compress"], "deny") - delete process.env.BILLION_CONTEXT_NATIVE + try { + const whileDisabled: Config = structuredClone(PLAIN_CONFIG) + await hooks.config!(whileDisabled) + assert.equal((whileDisabled.permission as Record)["compress"], "deny") + } finally { + delete process.env.BILLION_CONTEXT_NATIVE + } // Simulate the marker disappearing (e.g. the native plugin was removed and // the process is restarted into a clean env): ACP must resume. diff --git a/tests/bili-proxy-integration.test.ts b/tests/bili-proxy-integration.test.ts index e289ea48..0634e87c 100644 --- a/tests/bili-proxy-integration.test.ts +++ b/tests/bili-proxy-integration.test.ts @@ -27,6 +27,7 @@ const testConfigHome = join(tmpdir(), `opencode-acp-bili-config-${process.pid}`) process.env.XDG_DATA_HOME = testDataHome process.env.XDG_CONFIG_HOME = testConfigHome delete process.env.BILLION_CONTEXT_PROXY +delete process.env.BILLION_CONTEXT_NATIVE delete process.env.OPENCODE_CONFIG_DIR delete process.env.OPENCODE_SERVER_PASSWORD