OpenCode V2 runs neither the shell-check nor the guard plugin #134

Open
opened 2026-10-17 15:19:48 +02:00 by motoko · 0 comments
Collaborator

Location

.opencode/plugins/shellcheck.js on main at d317dac, and the main-checkout guard plugin that the review-confirmations-and-guards work adds beside it.

Evidence

OpenCode now ships two lines. V1 (opencode-ai, 1.19.3 on 2026-10-16) runs plugins shaped as a function returning {"tool.execute.after": …}, which is the shape shellcheck.js uses. V2 (@opencode/cli, 2.0.32) has a new plugin API: Plugin.define({ id, setup(ctx) }), with ctx.tool.hook("execute.before" | "execute.after", …). In V2 the edit tools take path instead of filePath, and apply_patch is renamed patch. V2's migration guide says: "V1 plugin implementations do not run in V2" (sst/opencode, dev branch, services/www/src/docs/content/build/plugins/migrate-v1.mdx).

Scenario

On OpenCode V2, an agent writes a shell script, and no shell check runs after the write. Once the guard lands, an agent on V2 can also edit a tracked file in the main checkout while it is on the main branch, and nothing refuses it.

Smallest fix

Add a V2 plugin in the Plugin.define shape for each hook, using the V2 tool names and the path argument, and keep the V1 plugins for 1.x. Then teach scripts/verify-agent-config.sh to check the V2 wiring too.

## Location `.opencode/plugins/shellcheck.js` on `main` at d317dac, and the main-checkout guard plugin that the review-confirmations-and-guards work adds beside it. ## Evidence OpenCode now ships two lines. V1 (`opencode-ai`, 1.19.3 on 2026-10-16) runs plugins shaped as a function returning `{"tool.execute.after": …}`, which is the shape `shellcheck.js` uses. V2 (`@opencode/cli`, 2.0.32) has a new plugin API: `Plugin.define({ id, setup(ctx) })`, with `ctx.tool.hook("execute.before" | "execute.after", …)`. In V2 the edit tools take `path` instead of `filePath`, and `apply_patch` is renamed `patch`. V2's migration guide says: "V1 plugin implementations do not run in V2" (sst/opencode, `dev` branch, `services/www/src/docs/content/build/plugins/migrate-v1.mdx`). ## Scenario On OpenCode V2, an agent writes a shell script, and no shell check runs after the write. Once the guard lands, an agent on V2 can also edit a tracked file in the main checkout while it is on the main branch, and nothing refuses it. ## Smallest fix Add a V2 plugin in the `Plugin.define` shape for each hook, using the V2 tool names and the `path` argument, and keep the V1 plugins for 1.x. Then teach `scripts/verify-agent-config.sh` to check the V2 wiring too.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/agent-foundry#134
No description provided.