// opencode adapter for scripts/archive-gate.sh: before the bash tool runs, // hand it the command and refuse the call with the gate's message when the // gate refuses. The rule and the message live in the script, so every // harness refuses the same archive for the same reason; Claude Code's // adapter is .claude/hooks/archive-gate.sh. import type { Plugin } from "@opencode-ai/plugin" export const ArchiveGate: Plugin = async ({ $, directory }) => ({ "tool.execute.before": async (input, output) => { if (input.tool !== "bash") return const command = String(output.args?.command ?? "") if (command === "") return const result = await $`${directory}/scripts/archive-gate.sh ${command}`.nothrow().quiet() if (result.exitCode !== 0) { throw new Error(result.stderr.toString() || result.stdout.toString()) } }, })