Repository navigation
Commit 90c5e06
* 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
File tree
- bin
- docs
- agdr
- harnesses
- harness-adapters/opencode
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
| |||
147 | 167 | | |
148 | 168 | | |
149 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
150 | 197 | | |
151 | 198 | | |
152 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | 16 | | |
6 | 17 | | |
7 | 18 | | |
8 | 19 | | |
9 | | - | |
| 20 | + | |
10 | 21 | | |
11 | 22 | | |
12 | 23 | | |
13 | | - | |
| 24 | + | |
14 | 25 | | |
15 | | - | |
| 26 | + | |
16 | 27 | | |
17 | 28 | | |
18 | 29 | | |
| |||
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
25 | | - | |
| 36 | + | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
| |||
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | | - | |
36 | | - | |
| 46 | + | |
| 47 | + | |
37 | 48 | | |
38 | 49 | | |
39 | 50 | | |
| |||
0 commit comments