OpenCode 2.x resolves a bare plugin package name through the package main field (dist/index.js, the CLI — no default export), so the entry form the installer wrote for 2.x hosts ("billion-context" under the plugins key) never loads: Plugin must export a default definition / on 2.2.5 a TypeError at /reload. Verified against the real @opencode/cli 2.1.0 binary (Linux): plural+bare does load there, but both field reports are Windows and the dir-shim form is proven on all four combinations (Linux/Windows x 2.1.0/2.2.5), so the installer now writes the shim dir (<configDir>/plugins/billion-context/index.js re-exporting this install dist/agent/opencode-native.js) for every 2.x host and any dev build; 1.x npm installs keep the portable bare name. Legacy bare entries in a 2.x config migrate automatically; a stale shim is regenerated to point at the current root; update messages read the shim target to tell npm-root installs from checkouts. README en/zh + clients docs en/zh: manual-install instructions split by host generation.
Found while verifying #1670 on a machine whose PATH shadows opencode v2
(a stray node_modules/.bin walk by npm test): the idempotent-rerun note
was the hardcoded string "plugin present", but tests build the
expectation from pickPluginKey(detectOpencodeMajor()) — so any host with
opencode 2.x failed three install tests. The note now names the effective
key ("plugin present" / "plugins present"), and the v1-shaped dev-form
e2e pins BILI_CLIENT_BIN to an unresolvable path (probe fails soft to
major 1) so it never depends on the host binary. The e2e-registry v2
stub assertion follows the new wording.
Bare rmSync(dir, {recursive, force}) in test teardowns throws ENOTEMPTY on
loaded CI runners when a spawned child recreates entries between readdir and
rmdir (observed: issue1086-chain T3 on ubuntu-latest Node 22, run
36520549393). Node's rimraf only retries transient errors when maxRetries is
set, so a shared tests/tmp-rm.ts rmrf() with maxRetries:10/retryDelay:50 now
replaces all 354 bare recursive teardown calls across 91 test files, matching
the precedent already at issue1086-chain-self-exemption.test.ts:663. Orphaned
named rmSync imports dropped where no longer used. Test-only change.
- applyOpencodePluginEntry now operates on the RAW plugin value: object
entries ({package, options}), map-form plugins with per-key options and
odd scalars survive install in form and position; a strings-only
projection is never written back
- 'plugin present' short-circuits BEFORE any write — an idempotent
install no longer rewrites (and mangles) the key
- opencodeRemove drops the key only when NOTHING raw survives, and keeps
map form; foreign entries are no longer collapsed to bare keys
- backup re-snapshots on every write whose pre-write bytes differ from
bili's own last output (.bili-last sidecar hash): user edits refresh
the backup, bili's consecutive writes do not — the install→upgrade→
remove restore chain still yields the user's pre-install value
- codex/omp write paths funnel through the same writeConfigText discipline
Fixes#1002
- package.json: explicit exports { ".": dist/index.js, "./server":
dist/agent/opencode-native.js } — opencode's loader tries <pkg>/server
first (verified in the shipped @opencode/cli 2.0.7 binary), so the bare
name no longer falls back to main and runs the CLI in-host
- plugin install opencode: origin-aware — npm installs (package root under
node_modules) write the bare package name (host-managed via Npm.add,
portable config); checkout/dev installs keep the local shim dir and say
so in the output; remove/status handle both forms; re-run migrates
- tests: 8 new cases (origin table, both forms fresh/migrate/idempotent,
full install/remove/status e2e); docs EN+ZH