@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
近 7 天 5
21.7
生态多维模型
3 个月前
2026-05-21
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mazac-fox/opencode-host-adapter@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@mazac-fox/opencode-host-adapter@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @mazac-fox/opencode-host-adapteropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
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