Skip to content

Commit 90c5e06

Browse files
feat(#1956): port the opencode gate adapter to the V2 plugin API (#1959)
* feat: port the opencode gate adapter to the V2 plugin API opencode 2.x rejects a V1 plugin whose default export is a bare `async (input) => hooks` factory: Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Expected object at ["default"])) The loader validates the default export as `{ id, setup }` (or `{ id, effect }`), so the adapter has to be ported, not reconfigured. Until now the gateway silently failed OPEN: opencode logged a WARN and carried on, so none of the bash gates ran. - the default export is now `{ id: "apexyard.gates", setup }` - the hook is registered with `ctx.tool.hook("execute.before", ...)` - the handler receives one `{ tool, input }` event, not `(input, output)` - the ops root resolves from `ctx.location.directory` - V2 renamed the command tool bash -> shell and the edit/write file argument filePath -> path. Both vocabularies are accepted, because a gate wire only fires on an exact tool-id match: the wrong id would leave every Bash-wired gate matching nothing, with no error anywhere - the native session id (#1783) is carried from the V2 event, so the marker-path and APEXYARD_SESSION_ID behaviour is unchanged - the install-layout smoke test now asserts the V2 definition shape and that setup registers a hook, so this regression cannot return silently Verified live against opencode 2.1.4. A real agent turn's fabricated `gh pr merge` was refused by the unmodified block-unreviewed-merge.sh through the V2 dispatch path: loader -> setup -> shell event -> wires -> event.input.command -> hook. Refs #1956 * docs: split the README intro sentences per the writing profile Advisory writing-profile cleanup on the paragraph this PR touches: no semicolon in prose, and no sentence over 25 words. * fix(#1956): close the patch gate hole and restore V1 support Addresses the Rex + Hakim review on #1959. - `patch`: opencode 2.x ships a `patch` tool that adds, updates, moves and deletes files under the `edit` permission. It matched no gate at all, so `require-active-ticket`, `block-protected-target-writes`, `require-migration-ticket` and the reviewer-marker guards were skipped silently. It is now routed to `.claude/hooks/dispatch-apply-patch.sh`, which re-runs every Edit/Write check once per target path. `patch` and `apply_patch` both map, and `buildToolInput` hands the envelope over as `command`. - Dual entrypoint: the default export keeps `{ id, setup }` for V2 and adds `server()` for opencode 1.18.29+. One package, both generations. The object is written literally because `Plugin.define` is identity and a runtime import of `@opencode/plugin` would make the file unloadable on 1.x, where that package does not exist. - Session id: the `unset CLAUDE_CODE_SESSION_ID` prefix is now always emitted, even when no native id is present, so an inherited Claude Code id cannot win the marker-path resolver again (#1783). - Init warning: the wiring check now also names a file-writing tool the host registers but no wire matches. That hole cannot be found by walking the gate table. - `@opencode/plugin` moves to devDependencies. It is imported type-only, so the installed plugin needs no runtime dependency, and the 302-package install surface leaves the governance host. - Installer rejects an empty or path-escaping `--name` before `rm -rf`. - Docs: all three pages state the V1 + V2 matrix and the V2 directory requirement for configured local plugin paths. The stale `batch` bypass note is removed; anomalyco/opencode#5894 is closed and describes subagent hook bypass, not a `batch` tool. Tests: 68 pass (patch routing, dual entrypoint, no-session prefix, plus the existing V2 suite). Smoke scripts pass, including the new `server()` check. * test(#1956): cover a subagent-shaped V2 event The ticket's design note asked for a subagent event, since a subagent runs under its own session id. The event carries agent, messageID and id as well as tool/sessionID/input; the handler must ignore the extras and pass the child session id through to the hook. * docs(#1956): correct the dual-support claims and patch wording Second delta from the Rex review on #1959. - The installer warned that "a V2 definition will not load on opencode 1.x" and told 1.x users to pin 0.1.0. That is false now: the shipped object carries `server()`, which 1.18.29+ calls. The warning now fires only for a 1.x older than 1.18.29, the only version that cannot load an object entrypoint. - `docs/harnesses/opencode.md` claimed live proof on both generations. The V2 path is live-proven; the V1 `server()` path is unit- and smoke-covered. It now says so. - "There is no hand-maintained gate list" was no longer true: the patch wire cannot come from settings.json and is added explicitly. Both docs name that single exception. - The derive-gates comments said the patch wire pointed at `dispatch-bash.sh` and that the envelope went there. It points at `dispatch-apply-patch.sh`, because the adapter cannot pass `--shell-alias-only`. - `patchRoutingGates` now skips itself when a fork already wires an `apply_patch` gate for the same hook, so the hook cannot run twice. - Register the hook before the advisory wiring warnings. A host that throws synchronously from `tool.list()` can no longer leave the session with no gate registered. - Tests: 70. Adds coverage for the host-tool-list warning branch. * fix(#1956): tighten patch de-duplication and the version guard Third delta from the Rex review on #1959. - `patchRoutingGates` now skips itself only when an existing gate already wires the patch dispatcher for `patch`/`apply_patch`. Keying on the hook path alone would have dropped the patch wire in a fork that wires that script for `edit` only. Both branches now have tests. - The installer version guard also covers a major version below 1. It previously stayed silent for `0.9.0`. - The remaining docs now name the patch-routing exception, and attribute `apply_patch` to the Codex path that is evidenced in-repo rather than to Claude Code as well. - Test count corrected to 70, then 72 with the two de-duplication tests. * docs(#1956): fix the 29 docs-lint writing faults docs lint (strict) reported 29 writing-profile faults in the two opencode docs: 18 passive voice, 10 sentences over 25 words, 1 list step over 20 words. Both files now pass `node bin/docs-lint.mjs --strict` with zero findings. - docs/opencode-adapter.md (16): active voice for the rejection, the patch-routing wire, the loader's single-file skip, the layout invariant, the live chain and the V1 coverage; the long API-surface, live-chain and verification sentences split. - docs/harnesses/opencode.md (13): same treatment for the V1 status line, the id-set acceptance, the imperative-API explanation, the delegated enforcement paragraph, the gate-derivation exception, the dispatcher description, and the flat-copy crash note. No claims changed; wording only. * docs(#1956): split two semicolon sentences the advisory check flagged The advisory writing-profile check (bin/check-writing-profile.sh) flags semicolons in prose. Two were introduced by the docs-lint fix; split them. The two remaining advisory findings in these files predate this branch. `node bin/docs-lint.mjs --strict`: 0 findings. * fix(#1956): send the session cwd to the gate hooks Relative patch and edit targets were checked against the ops root instead of the directory opencode writes into. Send ctx.location.directory (V1: input.directory) as the payload cwd and run the hook there. Also block a patch call with no envelope, read only filePath on V1, normalise namespaced tool ids, correct the V1 floor to 1.3.4 (verified by running 1.3.3 and 1.3.4), and record the port in AgDR-0092. Refs #1956 * docs(#1956): clear the writing-profile advisories Split the semicolon joins and overlong sentences introduced with the #1956 AgDR update and the cwd documentation. Refs #1956 * fix(#1956): fail closed outside the ops root and on missing edit paths Rex A1: running the bash checks from a session directory outside the ops root made them exit without enforcing in APEXYARD_OPS_ROOT mode. Fall back to the ops root there, so a patch cannot run ungoverned. Hakim A3: an edit or write with no target path now blocks instead of skipping every gate. Hakim A2: keep the raw tool id when its dotted tail is empty. Correct the docs on which hook reads `.cwd`, and the AgDR decision count. Refs #1956 * docs(#1956): split the ops-root fallback sentence Refs #1956 --------- Co-authored-by: atlas-apex <[email protected]>
1 parent 6cd6ca9 commit 90c5e06

17 files changed

Lines changed: 5560 additions & 880 deletions

‎bin/install-opencode-adapter.sh‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
# target shape. See `bin/install-pi-adapter.sh` for the pi-flavored sibling
4444
# of this script; the two are near-identical except for the discovery
4545
# directory name and default target path.
46+
#
47+
# WHAT IT INSTALLS SERVES BOTH PLUGIN GENERATIONS
48+
# ------------------------------------------------
49+
# The shipped `index.ts` default-exports one object: `{ id, setup }` for
50+
# opencode 2.x, plus `server()` for the object entrypoint opencode 1.3.4+
51+
# accepts. `setup` registers `ctx.tool.hook("execute.before", …)`; `server`
52+
# returns the V1 `{ "tool.execute.before": … }` hooks. The script warns only
53+
# when the `opencode` on PATH predates 1.3.4, the first release verified to
54+
# load an object entrypoint. 1.3.3 and earlier require a factory function and
55+
# fail with "fn3 is not a function".
4656

4757
set -euo pipefail
4858

@@ -110,6 +120,16 @@ ADAPTER_SRC="$ROOT/harness-adapters/opencode/src"
110120
SHARED_CORE="$ROOT/harness-adapters/_shared/derive-gates-core.ts"
111121
[ -z "$TARGET_DIR" ] && TARGET_DIR="$(pwd)/.opencode/plugins"
112122

123+
# The install path is deleted with `rm -rf "$TARGET_DIR/$NAME"` below, so a
124+
# blank or path-escaping --name must be rejected rather than expanding to the
125+
# target dir itself.
126+
case "$NAME" in
127+
""|.|..|*/*)
128+
echo "ERROR: --name must be a single non-empty path segment (got: '$NAME') — it is removed with rm -rf under the target dir." >&2
129+
exit 2
130+
;;
131+
esac
132+
113133
for f in index.ts gate-dispatcher.ts derive-gates.ts resolve-ops-root.ts; do
114134
[ -f "$ADAPTER_SRC/$f" ] || { echo "ERROR: expected source file not found: $ADAPTER_SRC/$f" >&2; exit 1; }
115135
done
@@ -147,6 +167,33 @@ if [ "$(basename "$TARGET_DIR")" = "plugin" ]; then
147167
echo "WARNING: --target-dir ends in the singular 'plugin' — opencode's real, live-verified discovery dir is PLURAL ('plugins'). Continuing, but opencode will not find this install unless '$TARGET_DIR' is itself scanned." >&2
148168
fi
149169

170+
# The adapter serves BOTH plugin generations from one default export: a
171+
# `{ id, setup }` definition for opencode 2.x, plus a `server()` member for
172+
# the object entrypoint opencode 1.3.4+ accepts. 1.3.3 and earlier require a
173+
# factory function, so they cannot load this object entrypoint at all. Warn
174+
# about that at install time rather than leaving it to a "failed to load
175+
# plugin" WARN in the server log.
176+
if command -v opencode >/dev/null 2>&1; then
177+
# Real output is a bare version ("1.17.16") on 1.x and a prefixed version
178+
# ("opencode v2.1.4") on 2.x. Accept both; the old pattern required the
179+
# prefix, so the warning never fired on a real 1.x install.
180+
OC_VERSION="$(opencode --version 2>/dev/null | sed -n 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -n 1)"
181+
case "${OC_VERSION:-}" in
182+
''|*[!0-9.]*) : ;; # unparseable/absent version — say nothing rather than guess
183+
*)
184+
OC_MAJOR="${OC_VERSION%%.*}"
185+
OC_REST="${OC_VERSION#*.}"
186+
OC_MINOR="${OC_REST%%.*}"
187+
OC_PATCH="${OC_REST#*.}"
188+
if [ "$OC_MAJOR" -lt 1 ] || { [ "$OC_MAJOR" -eq 1 ] && { [ "$OC_MINOR" -lt 3 ] || { [ "$OC_MINOR" -eq 3 ] && [ "$OC_PATCH" -lt 4 ]; }; }; }; then
189+
echo "WARNING: the 'opencode' on PATH reports $OC_VERSION, which predates 1.3.4." >&2
190+
echo " This adapter serves opencode 1.x through the object entrypoint's server() member," >&2
191+
echo " and 1.3.4 is the first release verified to load an object entrypoint. Upgrade opencode." >&2
192+
fi
193+
;;
194+
esac
195+
fi
196+
150197
echo "Installed the apexyard opencode gate adapter:"
151198
echo " $DEST/index.ts <- opencode's ONLY discovered entry for this subdirectory"
152199
echo " $DEST/gate-dispatcher.ts"

‎docs/agdr/AgDR-0092-opencode-gate-adapter.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ The identical class of bug, independently confirmed the same day, also hit the p
5151

5252
**Artifacts**: `harness-adapters/opencode/src/index.ts`, `bin/install-opencode-adapter.sh`, `harness-adapters/opencode/test/smoke-install-layout.sh`, `harness-adapters/opencode/README.md` + `docs/opencode-adapter.md` (install sections rewritten), Bug: me2resh/apexyard#844.
5353

54+
## Update (#1956)
55+
56+
**The adapter now serves opencode 2.x and keeps a V1 entrypoint. Several decisions recorded above changed. This section records the new ones and the evidence.**
57+
58+
1. **One dual-generation default export, written as a literal.** The plugin default-exports `{ id: "apexyard.gates", setup, server }`. opencode 2.x validates the definition and calls `setup(ctx)`. opencode 1.x calls `server(input)`. The object is written literally rather than as `{ ...Plugin.define(...), server }`. `Plugin.define` is an identity function, and a runtime import of `@opencode/plugin` would make the file unloadable on 1.x, where that package does not exist. `import type` is erased, so the V1 path keeps zero runtime dependencies.
59+
2. **The dependency moved from the V1 runtime package to a type-only V2 devDependency.** `@opencode-ai/plugin` is gone. `@opencode/plugin` 2.x is a devDependency imported with `import type` only. The installed adapter has no runtime import of it, so the lockfile growth is a development cost, not an install cost.
60+
3. **The patch-routing wire is the one hand-maintained exception to "zero gate-table drift".** opencode's `patch` tool (and the legacy `apply_patch` id) writes files under the `edit` permission. `settings.json` cannot express the wire, because Claude Code and Codex reach `apply_patch` through the `*` matcher plus `dispatch-bash.sh --shell-alias-only`, and this adapter runs hooks without that flag. `patchRoutingGates` adds the wire explicitly and points it at `.claude/hooks/dispatch-apply-patch.sh`, which re-runs every Edit/Write check once per target path. Before the wire existed, a V2 `patch` call ran no gate at all. The adapter also warns at init when the host registers a file-writing tool that no wire routes.
61+
4. **Both tool vocabularies are carried side by side, not version-probed.** V2 renamed the command tool `bash` → `shell` and the edit/write argument `filePath` → `path`. A gate wire fires only on an exact id match, so the wrong single id fails open with no error. The V1 handler reads `filePath` only, matching `dev`, so a decoy `path` cannot redirect a V1 Edit/Write check.
62+
5. **The hook payload carries a top-level `cwd`.** It is `ctx.location.directory` on V2 and `input.directory` on V1, and it is also the hook subprocess's working directory. `dispatch-apply-patch.sh` and `block-protected-target-writes.sh` read the field directly. `require-active-ticket.sh` resolves relative targets from the subprocess working directory. Sending only the ops root misjudged a relative `src/a.ts` under `workspace/<project>` as `<ops-root>/src/a.ts`. When the session directory sits outside the ops root, both fall back to the ops root. That is `APEXYARD_OPS_ROOT` mode, where the bash checks need the ops root to find their own wiring.
63+
6. **The supported V1 floor is 1.3.4, not 1.18.29.** Running the release binaries with an object-entrypoint probe sets the floor. 1.3.3 fails with `fn3 is not a function`. 1.3.4 loads the object and calls `server()`. The install script's version guard now parses both real output shapes (`1.17.16` and `opencode v2.1.4`) and warns below 1.3.4. The previous pattern required the literal word `opencode` followed by a space, so it never fired on a real 1.x install.
64+
7. **The `batch`-bypass note above is withdrawn.** anomalyco/opencode#5894 is CLOSED, and its subject is subagent tool calls bypassing `tool.execute.before`, not a `batch` tool. The note was wrong on both counts and is removed from the shipped docs.
65+
66+
**Artifacts**: `harness-adapters/opencode/src/{gate-dispatcher,derive-gates}.ts`, `bin/install-opencode-adapter.sh`, `harness-adapters/opencode/test/{gate-dispatcher,installer-version}.test.ts`, `docs/opencode-adapter.md`, `docs/harnesses/opencode.md`, `harness-adapters/opencode/README.md`. Feature: me2resh/apexyard#1956.
67+
5468
## Artifacts
5569

5670
- `harness-adapters/opencode/src/derive-gates.ts` — the settings.json parser / gate-table deriver

‎docs/harnesses/opencode.md‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
# Harness support: opencode
22

3-
**Status:** ✅ **Live-proven (2026-07-09):** the delegated `block-git-add-all.sh` blocked a real `opencode run --auto` model turn's `git add -A` (verbatim hook output, nothing staged). Adapter merged (#821 → PR #839, [AgDR-0092](../agdr/AgDR-0092-opencode-gate-adapter.md)). Install shape hardened in #845.
3+
**Status:** ✅ **Live-proven on opencode 2.1.4.** 2026-07-09: the delegated `block-git-add-all.sh` blocked a real `opencode run --auto` model turn's `git add -A` (verbatim hook output, nothing staged), on the then-current 1.x plugin API. 2026-11-04: on opencode 2.1.4 the V2 path blocked a real agent turn's fabricated `gh pr merge` through `block-unreviewed-merge.sh` (#1956). `server()` serves the V1 path again. Unit tests and a smoke script cover it, not a fresh live 1.x run. Adapter merged (#821 → PR #839, [AgDR-0092](../agdr/AgDR-0092-opencode-gate-adapter.md)). Install shape hardened in #845.
4+
5+
## Supported plugin APIs
6+
7+
One package serves both generations. The default export carries `{ id, setup }` for opencode 2.x and a `server()` member for opencode 1.3.4+. Running the release binaries verifies the 1.3.4 floor: 1.3.3 fails with `fn3 is not a function`, and 1.3.4 loads the object and calls `server()`.
8+
9+
| opencode | API | Entry point | Tool ids |
10+
|----------|-----|-------------|----------|
11+
| 2.x | V2 | `setup(ctx)` → `ctx.tool.hook("execute.before", …)` | `shell`, `patch`, `edit`, `write`, `read`, `glob`, `grep` |
12+
| 1.3.4+ | V1 | `server()` → `{ "tool.execute.before": … }` | `bash`, `apply_patch`, `edit`, `write`, `read`, `glob`, `grep` |
13+
14+
The adapter accepts both id sets on either runtime, so a gate cannot silently stop matching after an opencode upgrade. V2 requires a configured local plugin path to be a **directory**. The loader skips a single-file path and logs a warning.
415

516
## Verification
617

718
A credentialed opencode session, run with `--auto`, issued `git add -A` during a real model turn. The delegated bash gate refused it with exit 2, and staged nothing. This is the live end-to-end proof required by the [rebrand trigger](README.md#rebrand-trigger), rather than a mock or a by-construction test. opencode is one of three adapters, with pi and Codex, that cleared that bar.
819

9-
**How opencode reaches the gate:** it exposes an **imperative plugin API**, so the gate runs inside opencode's own `tool.execute.before` event during the real turn. Its precondition for enforcement is `--auto` (so the tool call reaches that event rather than going through the approval flow first). That is the opencode analog of pi's `-a` and Codex's hook-trust. The governance stays single-source. The plugin is a thin transport that shells out to the **unmodified `.claude/hooks/*.sh`** and blocks the tool call when a hook exits `2`. Full install/usage in **[`docs/opencode-adapter.md`](../opencode-adapter.md)** (linked here, not duplicated).
20+
**How opencode reaches the gate:** opencode exposes an **imperative plugin API**. The gate therefore runs inside opencode's own pre-execution tool hook during the real turn (`execute.before` on V2, `tool.execute.before` on V1). Its precondition for enforcement is `--auto` (so the tool call reaches that hook rather than going through the approval flow first). That is the opencode analog of pi's `-a` and Codex's hook-trust. The governance stays single-source. The plugin is a thin transport that shells out to the **unmodified `.claude/hooks/*.sh`** and blocks the tool call when a hook exits `2`. Full install/usage in **[`docs/opencode-adapter.md`](../opencode-adapter.md)** (linked here, not duplicated).
1021

1122
## Enforcement vs advisory today
1223

13-
**Delegated (blocking, by construction):** on `tool.execute.before`, the plugin builds Claude-Code-shaped stdin, execs the matching bash hook, and **throws to deny** on exit 2. That covers the two-marker merge gate (all five wired merge-command shapes, including both #47 variants), red-CI block, ticket-first, and secrets/leak-protection. Fail-closed is real. An execution-layer failure (spawn error, killed hook, no exit status) also denies. 43 hermetic unit tests plus a smoke script driving the real `block-unreviewed-merge.sh` to a genuine block back the transport.
24+
**Delegated (blocking, by construction):** the pre-execution tool hook builds Claude-Code-shaped stdin and execs the matching bash hook. The plugin **throws to deny** on exit 2. That covers the two-marker merge gate (all five wired merge-command shapes, including both #47 variants), red-CI block, ticket-first, and secrets/leak-protection. Fail-closed is real. An execution-layer failure (spawn error, killed hook, no exit status) also denies. The adapter routes a `patch` call through `dispatch-apply-patch.sh`. That script re-runs every Edit/Write check once per target path, so a multi-file patch cannot step around those gates. 84 hermetic unit tests plus two smoke scripts back the transport. One is a genuine block from the real `block-unreviewed-merge.sh`. The other checks the shipped install layout's V2 definition shape.
1425

15-
**Gate derivation is drift-proof:** the plugin **derives its gate table from `.claude/settings.json` at load time**. There is no hand-maintained gate list. A new gate wired in `settings.json` reaches opencode automatically with zero adapter changes. (This is the convergence pattern planned for the pi adapter. See #840.)
26+
**Gate derivation is drift-proof, with one named exception:** the plugin **derives its gate table from `.claude/settings.json` at load time**. There is no hand-maintained gate list, except the single patch-routing wire. That wire cannot come from `settings.json` (see `patchRoutingGates` in `src/gate-dispatcher.ts`), so the adapter adds it explicitly. The plugin also warns at init when the host registers a file-writing tool that no wire routes. A new gate wired in `settings.json` reaches opencode automatically with zero adapter changes. (This is the convergence pattern planned for the pi adapter. See #840.)
1627

1728
**Advisory:** `AGENTS.md` carries the advisory governance bridge, per opencode's own convention.
1829

@@ -22,7 +33,7 @@ A credentialed opencode session, run with `--auto`, issued `git add -A` during a
2233

2334
- `src/derive-gates.ts`: parses `.claude/settings.json` PreToolUse wiring into the gate table at plugin init.
2435
- `src/resolve-ops-root.ts`: the same ops-fork anchor-walk the hooks use. Loading outside an apexyard fork is a clean no-op.
25-
- `src/gate-dispatcher.ts`: builds `{"tool_name", "tool_input": {"command"|"filePath"}}` stdin, `execFile`s the hook (argv array, args via stdin only: no shell interpolation), throws on exit 2 or execution failure.
36+
- `src/gate-dispatcher.ts`: builds `{"tool_name", "tool_input": {"command"|"file_path"}, "cwd"}` stdin from the V2 `{ tool, input }` event (or V1's `(input, output)`). `cwd` is `ctx.location.directory` (V1: `input.directory`), and the hook subprocess runs there, so relative targets resolve against the tree opencode writes into. It `execFile`s the hook (argv array, args via stdin only: no shell interpolation) and throws on exit 2 or execution failure. It also exports the dual `{ id, setup }` + `server()` plugin definition.
2637

2738
## How to install
2839

@@ -32,8 +43,8 @@ bash bin/install-opencode-adapter.sh
3243

3344
That writes the adapter into `.opencode/plugins/apexyard/`: a **subdirectory** shape, not a flat file copy. Both details are load-bearing and had live confirmation against opencode 1.17.16 (#844/#845):
3445

35-
- The discovery directory is **plural**: `.opencode/plugins/`. The singular `.opencode/plugin/` silently loads nothing.
36-
- Every file must sit inside the one subdirectory behind a re-export `index.ts` shim. A flat `cp` of the adapter + its helper modules crashes opencode at startup. The reason is that opencode treats every exported function of a discovered file as a candidate plugin factory.
46+
- The discovery directory is **plural**: `.opencode/plugins/`. V1's singular `.opencode/plugin/` silently loads nothing. V2 accepts both forms, and plural is its documented layout.
47+
- Every file must sit inside the one subdirectory behind a re-export `index.ts` shim. A flat `cp` of the adapter + its helper modules crashed opencode 1.x at startup. V1 treated every exported function of a discovered file as a candidate plugin factory. V2 validates only the `default` export, so that crash mode is gone. The layout stays anyway, so a closed export surface remains a structural invariant.
3748

3849
Full reference: [`docs/opencode-adapter.md`](../opencode-adapter.md).
3950

0 commit comments

Comments
 (0)