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)
opencodeinstalled and on yourPATH(or install from chat via/install opencode)
Fastest setup (interactive wizard — recommended)
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:
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):
- OpenCode's own CLI login (native): Pick OpenCode in
kompile auth login(or runkompile auth login opencode, which delegates directly toopencode auth login). Kompile does not store or inspect OpenCode's native credentials. - Kompile-managed OpenCode API key (for OpenCode Go / Console usage tracking): Store an OpenCode API key in Kompile's credential store via
/auth(orkompile 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 athttps://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:
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):
resolve_model action=providers: Listsopencodealongside any other registered providers, showing its native transport and active login/API-key state.resolve_model action=families: ShowsModelRouting's model-family table for direct HTTP providers.resolve_model action=models provider=opencode [query=<substring>]: Lists OpenCode's available models (such asopencode-go/...oropencode/...), omits any model banned by/subagent-config, and returnstaskArgumentsready fortask,multi_task, orquorum_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=opencodeand a subagent specifies amodelwithout changingprovider, Kompile keeps the child onopencoderather than diverting it to another vendor. - To dispatch a worker onto a different vendor (for example,
openai/gpt-5.6-lunaorfireworks/...), passprovider=<id>explicitly (or configure/subagent-config role-route).
4. Recommended subagent configuration (/subagent-config)
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_CONTENTpermissions to{"*":"deny","kompile_*":"allow"}so zero OpenCode built-in tools load — the worker sees only Kompile's MCP tools (kompile_<tool>, always includingkompile_progress). - Lean context injection: Tune whether Kompile injects project
AGENTS.mdor replaces OpenCode's vendor system prompt per runtime via/subagent-config agents-md opencode auto|include|skipand/subagent-config vendor-prompt opencode replace|include(autoskips duplicatingAGENTS.mdbecause 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.
Recommended OpenCode configuration
/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,bashOr pair an OpenCode lead with a dedicated cross-vendor worker (e.g., OpenAI Luna or Fireworks/Together):
/subagent-config role-route explorer openai/gpt-5.6-luna auth=oauth credential=defaultImporting & 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):
# 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 windowsWhen 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 anopencode-go/<model>model via/model(e.g.,opencode-go/glm-5.2) or fund Console credits athttps://console.opencode.ai. - Quota tracking in
/usage: OpenCode's native login is opaque to Kompile. Connect an OpenCode API key via/authif you want/usageto display OpenCode Go's 5-hour rolling and weekly allowance meters.