jido_opencode is a jido_harness adapter for the OpenCode CLI.
This package maps OpenCode JSON output into normalized Jido.Harness.Event structs and publishes runtime contract metadata for harness execution flows.
Add dependencies:
{:jido_harness, github: "agentjido/jido_harness", branch: "main", override: true}
{:jido_opencode, github: "agentjido/jido_opencode", branch: "main"}This repo is currently aligned as part of the GitHub-based harness package set rather than a Hex release line.
Then install deps:
mix deps.getRun directly:
{:ok, stream} = Jido.OpenCode.run("Return exactly: OK", cwd: "/repo")
events = Enum.to_list(stream)Run via harness:
request = Jido.Harness.RunRequest.new!(%{prompt: "Summarize changes", cwd: "/repo"})
{:ok, stream} = Jido.Harness.run(:opencode, request)- Optional env:
ZAI_API_KEYwhen using env-based Z.AI auth - Optional env:
ZAI_BASE_URL(defaulted in runtime contract tohttps://api.z.ai/api/anthropic)OPENCODE_MODEL(defaulted tozai-coding-plan/glm-4.5-air)
- CLI:
opencode(install vianpm install -g opencode-ai)
Helpful tasks:
mix opencode.install
mix opencode.compat
mix opencode.smoke "Return exactly: JIDO_OPENCODE_SMOKE_OK"Current adapter behavior is intentionally conservative:
streaming?isfalsein v1 (run/2is buffered-first)cancellation?isfalse- Scope is Z.AI-focused runtime contract support
Apache-2.0
jido_opencode is the OpenCode adapter package for jido_harness, currently scoped to Z.AI-compatible runtime/auth flows using the installed zai-coding-plan/* provider models.
- Unit/contract tests:
mix test - Full quality gate:
mix quality - Optional live checks:
mix opencode.install && mix opencode.compat && mix opencode.smoke "hello"
jido_opencode includes an opt-in live adapter test that runs the real OpenCode CLI through the harness adapter path:
mix test --include integration test/jido_opencode/integration/adapter_live_integration_test.exsThe test auto-loads .env and is excluded from default mix test runs.
Environment knobs:
ZAI_API_KEYwhen using env-based OpenCode authZAI_BASE_URLandOPENCODE_MODELfor custom endpoint/model selectionJIDO_OPENCODE_LIVE_PROMPTto override the default promptJIDO_OPENCODE_LIVE_CWDto override the working directoryJIDO_OPENCODE_LIVE_MODELto force a specific modelJIDO_OPENCODE_LIVE_TIMEOUT_MSto extend the per-run timeoutJIDO_OPENCODE_REQUIRE_SUCCESS=1to fail unless the terminal event is successfulJIDO_OPENCODE_CLI_PATHto target a non-default OpenCode CLI binary