Skip to content

Quickstart for OpenCode Users ​

Kompile supports OpenCode (opencode) as both a native standard-chat provider and a managed passthrough agent. You can keep OpenCode's own multi-provider catalog (opencode/<model>, opencode-go/<model>, or any provider configured inside OpenCode) while adding Kompile's Enforcer, Judge, persistent memory, code index, LSP gate, and isolated subagent workers.

Prerequisites ​

  • Kompile CLI installed (Installation & Updates)
  • opencode installed and on your PATH (or install from chat via /install opencode)

You don't need to remember provider or model flags. Run the interactive wizard once to connect OpenCode, pick a model from OpenCode's catalog, and save your defaults — after that, just run kompile chat:

bash
cd /path/to/your/repo
kompile chat             # Launches SetupWizard on first run (or `kompile chat --setup` anytime)

In SetupWizard, choose Standard Chat → OpenCode (or Passthrough → opencode). You can also sign in or switch credentials at any time with bare kompile auth login (or /auth inside chat).


1. Authenticate ​

OpenCode supports two authentication setups with Kompile — both selectable inside kompile auth login (or /auth inside chat):

  1. OpenCode's own CLI login (native): Pick OpenCode in kompile auth login (or run kompile auth login opencode, which delegates directly to opencode auth login). Kompile does not store or inspect OpenCode's native credentials.
  2. Kompile-managed OpenCode API key (for OpenCode Go / Console usage tracking): Store an OpenCode API key in Kompile's credential store via /auth (or kompile auth login) when you want Kompile to bill per-message usage and query OpenCode Go's live quota meters (https://opencode.ai/inference/go/v1/usage) in /usage.

IMPORTANT

Understand OpenCode's billing split (opencode/ vs opencode-go/):

  • opencode/<model> (OpenCode Console / Zen) bills your Console credit balance at https://console.opencode.ai.
  • opencode-go/<model> (e.g., opencode-go/glm-5.2) draws from your OpenCode Go subscription allowance (5-hour rolling + weekly meters).

Picking an opencode/<model> when you only have an OpenCode Go subscription (and zero Console credit) fails with a billing-route error, not a bad API key.


2. Start chatting ​

Once saved via kompile chat --setup, simply run kompile chat. Direct CLI commands for scripts or one-off overrides:

bash
cd /path/to/your/repo

# Interactive setup wizard
kompile chat --setup

# Direct CLI overrides
kompile chat --provider opencode
kompile chat --provider opencode --model opencode-go/glm-5.2
kompile chat --mode passthrough --agent opencode
kompile passthrough --agent opencode

(Note: --dangerously-skip-permissions is used automatically on opencode run one-shot launches, never on OpenCode's interactive TUI where that flag is invalid.)


3. How resolve_model works with OpenCode ​

Before delegating work to a subagent, Kompile agents call resolve_model (zero-cost route discovery — no model turn, no login, no silent account fallback):

  1. resolve_model action=providers: Lists opencode alongside any other registered providers, showing its native transport and active login/API-key state.
  2. resolve_model action=families: Shows ModelRouting's model-family table for direct HTTP providers.
  3. resolve_model action=models provider=opencode [query=<substring>]: Lists OpenCode's available models (such as opencode-go/... or opencode/...), omits any model banned by /subagent-config, and returns taskArguments ready for task, multi_task, or quorum_task.

How your vendor of choice is preserved ​

OpenCode owns its own namespaced model catalog (opencode/..., opencode-go/..., and any provider routes configured in OpenCode). Because of that, SubagentChatConfig explicitly disables cross-provider auto-routing when your active provider is opencode (!child.isOpenCodeNative()):

  • When your chat runs on provider=opencode and a subagent specifies a model without changing provider, Kompile keeps the child on opencode rather than diverting it to another vendor.
  • To dispatch a worker onto a different vendor (for example, openai/gpt-5.6-luna or fireworks/...), pass provider=<id> explicitly (or configure /subagent-config role-route).

WARNING

Never make top-tier models like Opus or Fable (or Astra / Neon) a subagent unless you are sure of the cost. OpenCode lets you pick from dozens of upstream models — routing parallel subagents onto frontier models (*opus*, *fable*, *astra*, *neon*) quickly drains Console credits or Go allowances.

How Kompile isolates OpenCode workers ​

When Kompile spawns an OpenCode subagent worker, it automatically applies strict surface containment:

  • Kompile-only tool surface: Sets OPENCODE_CONFIG_CONTENT permissions to {"*":"deny","kompile_*":"allow"} so zero OpenCode built-in tools load — the worker sees only Kompile's MCP tools (kompile_<tool>, always including kompile_progress).
  • Lean context injection: Tune whether Kompile injects project AGENTS.md or replaces OpenCode's vendor system prompt per runtime via /subagent-config agents-md opencode auto|include|skip and /subagent-config vendor-prompt opencode replace|include (auto skips duplicating AGENTS.md because OpenCode reads it directly).
  • Credential rule: An OpenCode worker that names no credential bills Kompile's active OpenCode API key if one is stored (enabling per-message usage tracking); otherwise it uses OpenCode's own CLI login.
text
/subagent-config ban *opus*
/subagent-config ban *fable*
/subagent-config ban *astra*
/subagent-config ban *neon*
/subagent-config route opencode/opencode-go/glm-5.2
/subagent-config per-session 4
/subagent-config cost-budget 2.00
/subagent-config preload-tools read,grep,glob,edit,write,bash

Or pair an OpenCode lead with a dedicated cross-vendor worker (e.g., OpenAI Luna or Fireworks/Together):

text
/subagent-config role-route explorer openai/gpt-5.6-luna auth=oauth credential=default

Importing & resuming OpenCode sessions ​

Kompile's opencode adapter reads OpenCode conversations directly from its SQLite database (~/.local/share/opencode/opencode.db on Linux — honoring XDG_DATA_HOME — ~/Library/Application Support/opencode/opencode.db on macOS, %LOCALAPPDATA%\opencode\opencode.db on Windows, or ~/.opencode/opencode.db):

bash
# Import existing OpenCode sessions into Kompile's portable store
kompile session import --source=opencode
kompile agent chat-import sync --source=opencode

# Browse and resume natively in OpenCode (--session <id>) or hand off to another agent
kompile resume --filter-source opencode
kompile resume -t <session-uuid> --agent opencode      # Resumes in OpenCode
kompile resume -t <session-uuid> --agent kompile       # Continue in Kompile Standard Chat
kompile resume-all --agent opencode                    # Restore recent OpenCode windows

When handing a long conversation into OpenCode from another vendor (e.g., Claude, Codex, or Antigravity), CrossAgentResumeCompactor queries OpenCode's live model metadata (OpenCodeModelMetadataResolver) so the exported handoff is sized accurately to your target OpenCode model's context window.

See Import & Resume for full CLI, /resume, and MCP details.

Common gotchas ​

  • Billing error on opencode/<model> with OpenCode Go: Switch to an opencode-go/<model> model via /model (e.g., opencode-go/glm-5.2) or fund Console credits at https://console.opencode.ai.
  • Quota tracking in /usage: OpenCode's native login is opaque to Kompile. Connect an OpenCode API key via /auth if you want /usage to display OpenCode Go's 5-hour rolling and weekly allowance meters.

Next steps ​

Released under the Apache-2.0 License.