跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    jackmazac

    Host Adapter

    v0.1.0可观测与分析
    @mazac-fox/opencode-host-adapter

    Defensive 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

    GitHub 星标

    0

    月装机量

    10

    近 7 天 5

    综合评分SCORE

    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"]
    }

    opencode 启动时会通过内嵌运行时自动加载 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 as tool.execute.before fleet propagation (output wins key overlaps); use in hook plugins that read args before the merged shape exists on output.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