@mazac-fox/opencode-host-adapterDefensive wrapper for OpenCode plugins. Validates tool definitions, wraps execute in try/catch, filters bad system-transform output, and emits structured telemetry. Catches the codemem-style 'undefined is not an object (evaluating n._zod.def)' bug at regi
0
10
5 in 7 days
21.7
Multi-signal model
3 months ago
2026-05-21
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mazac-fox/opencode-host-adapter@0.1.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mazac-fox/opencode-host-adapter@0.1.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D @mazac-fox/opencode-host-adapteropencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Defensive boundary for OpenCode plugins: validate tool definitions and runtime args, wrap execution with structured failures, preserve OpenCode cancellation signals, propagate fleet correlation IDs, normalize hook outputs, and append canonical NDJSON telemetry.
Re-exports @mazac-fox/opencode-fleet-contracts (fleetContracts / /contracts).
What it does
wrapPlugin(plugin, { name, ... })— production path for fleet plugins.mergeToolExecuteBeforeHookArgs(inputArgs, outputArgs)— same merge semantics astool.execute.beforefleet propagation (output wins key overlaps); use in hook plugins that read args before the merged shape exists onoutput.args.runPluginContractTests— loadability, tool shape, telemetry, arg validation harness.validateToolDefinitions— CI preflight without loading OpenCode.
No product logic (memory, locks, plans, graphs). Boundary options, error codes, and invariants: CONTRIBUTING.md, AGENTS.md.
Host Adapter does not impose arbitrary tool execution deadlines. Plugin and runtime owners are responsible for cancellation policy; Host Adapter only preserves caller-provided ctx.abort / ctx.signal signals while wrapping execution.
Quick start
bun add @mazac-fox/opencode-host-adapter
import { wrapPlugin } from "@mazac-fox/opencode-host-adapter";
export default wrapPlugin(MyPlugin, { name: "my-plugin" });
Development
bun install
bun run typecheck
bun test
Breaking boundary behavior: extend tests first; ripple to Conductor, Engram, Codemem, Fleet as needed. AGENTS.md.
License
MIT