Skip to content

CodePatrol INIT 2

CodePatrol edited this page Aug 25, 2026 · 6 revisions

INIT-2: Use OpenCode as the agent harness instead of Claude

Replace Claude (Anthropic Agent SDK) as the default NanoClaw agent harness on this install with OpenCode. Sessions still run in Apple Container / Docker; only the in-container planner changes. Do not rewrite the two-DB IO model or the poll loop.

Current state:

  • Provider resolution is sessions.agent_provider → container_configs.provider → 'claude' (src/container-runner.ts resolveProviderName).
  • Trunk bakes only Claude: container/agent-runner/src/providers/index.ts imports ./claude.js; src/providers/index.ts has no OpenCode host config.
  • OpenCode is skill-installed from the providers branch via /add-opencode: copy host+container provider files, append barrel imports, pin @opencode-ai/sdk and opencode-ai CLI to the same exact version, registration tests, ./container/build.sh.
  • Host passes OPENCODE_* and an XDG mount only when the effective provider is opencode. Credentials stay in OneCLI (host-pattern secrets), never in .env or container env.
  • README still advertises Claude Code as the native harness.

Must change:

  1. Install the OpenCode provider payload (do not invent a second provider). Follow the /add-opencode skill: fetch providers, copy listed files, wire both barrels, pin CLI+SDK together, run registration + pin-guard tests, rebuild the agent image.
  2. Default this install to opencode. New groups and unset provider must resolve to opencode. Claude remains via ncl groups config update --provider claude (same seam as NANOCLAW_RUNTIME_DRIVER=docker). Do not hardcode OpenCode outside resolveProviderName / container_configs.
  3. Wire host config: OPENCODE_PROVIDER / OPENCODE_MODEL (and optional small model, context/output limits, modalities), ANTHROPIC_BASE_URL for non-anthropic upstreams, OneCLI secret grant for the chosen API host. Existing groups that should switch: ncl groups config update --provider opencode then restart; run /migrate-memory first if a group still has legacy Claude memory.
  4. Update operator docs: README "Best harness" copy, setup/debug notes, provider-migration. Do not revive frozen branches.

Out of scope: rewriting agent-runner IO, changing Apple Container/Docker selection, merging skill/apple-container, installing extra model providers beyond OpenCode.

Acceptance: with Claude not required, a session using provider opencode starts, heartbeats, and delivers a credentialed reply; ncl groups config update --provider claude still selects Claude; registration tests and CLI/SDK pin guard pass; image builds.

Status: active

Waves

  • WAVE-2.1: Install OpenCode provider payload (accepted)
    • WORK-2.1.1: Copy OpenCode files and wire barrels (accepted)
    • WORK-2.1.2: Pin CLI and SDK together and rebuild (accepted)
  • WAVE-2.2: Default provider is opencode (accepted)
    • WORK-2.2.1: Unset provider resolves to opencode (accepted)
  • WAVE-2.3: Host wiring and operator docs (planning)
    • WORK-2.3.1: OPENCODE_* host config, OneCLI, docs (pending)

Clone this wiki locally