Skip to content

feat(installer): add --opencode target#223

Merged
steventohme merged 1 commit into
mainfrom
steven/installer-opencode-support
May 21, 2026
Merged

feat(installer): add --opencode target#223
steventohme merged 1 commit into
mainfrom
steven/installer-opencode-support

Conversation

@steventohme
Copy link
Copy Markdown
Collaborator

Summary

Adds opencode (https://opencode.ai) as a third install target alongside Claude Code and Codex. One command — npx @workweave/router --opencode — and opencode routes through the Weave Router. No router-side change needed; the router speaks Anthropic Messages natively, so opencode's bundled @ai-sdk/anthropic provider talks to it unmodified.

What's in the diff

  • install/install.sh — new --opencode flag, picker entry (option 3), per-target scope path resolution, and a write_opencode_config() helper that jq-merges a managed provider.weave block into opencode.json. Dispatch block parallels the existing --codex branch (health ping, key validation, gitignore for project scope, OPENCODE_CONFIG= hint for --dir installs).
  • install/uninstall.sh--opencode strip path. Structurally removes provider.weave and the top-level model only when it points at weave/...; deletes the file if nothing non-schema remains.
  • READMEs — root README.md, install/README.md, and install/npm/README.md updated with the new flag, scope paths, and onboarding flow.

Config layout

Scope Path
user ~/.config/opencode/opencode.json (honors $XDG_CONFIG_HOME)
project <repo>/opencode.json (gitignored, per-teammate key)
--dir <d> <d>/opencode.json (caller sets OPENCODE_CONFIG)

Managed block:

"provider": {
  "weave": {
    "npm": "@ai-sdk/anthropic",
    "name": "Weave Router",
    "options": {
      "baseURL": "https://router.workweave.ai/v1",
      "headers": {
        "X-Weave-Router-Key": "rk_...",
        "X-App": "opencode",
        "X-Weave-User-Email": "...",
        "X-Weave-User-Name": "..."
      }
    },
    "models": { "claude-opus-4-7": {...}, "claude-sonnet-4-6": {...}, "claude-haiku-4-5": {...} }
  }
}

Top-level model is set to weave/claude-sonnet-4-6 only when the user hasn't already chosen one. Other providers, MCP servers, agents, and unrelated keys are preserved across re-install / uninstall.

Test plan

  • bash -n install/install.sh and bash -n install/uninstall.sh clean
  • Fresh install (--opencode --dir <tmp> --non-interactive) — file 0600, well-formed, identity headers landed
  • Idempotent re-install over an opencode.json that already has a user-chosen model and an unrelated provider.openai — both preserved, weave merged alongside
  • Full roundtrip: install → uninstall preserves user data
  • Uninstall on a clean-install file deletes it (no zero-key artifact)
  • Live test with the opencode CLI installed (smoke tests ran without opencode on PATH; CLI presence is a warning, not a hard fail)

Follow-ups (not in this PR)

  • WorkWeave-side gitlink bump + syncrouterinstall/install_template.sh mirror sync once this merges
  • Bump @workweave/router npm package version after merge

🤖 Generated with Claude Code

Wires opencode (https://opencode.ai) into the same one-command installer
that already handles Claude Code and Codex. Parallel structure to the
existing --codex branch: new arg flag, picker entry, scope-aware path
resolution, write_opencode_config helper, dispatch block with /health
ping + key validation, and a matching strip path in uninstall.sh.

opencode reads ~/.config/opencode/opencode.json (user) or <repo>/opencode.json
(project). The merged `provider.weave` entry uses opencode's bundled
@ai-sdk/anthropic provider — the router speaks Anthropic Messages
natively, so no router-side change is needed. Identity headers
(X-Weave-Router-Key, X-Weave-User-Email, X-Weave-User-Name, X-App=opencode)
ride alongside in options.headers.

Re-install rewrites only the managed provider block; other providers,
agents, MCP entries, and the user's top-level `model` choice are
preserved. Uninstall structurally removes `provider.weave` (and `model`
only when it points at `weave/...`), then deletes the file if nothing
non-schema remains.

READMEs (root + install/ + install/npm/) updated. Smoke-tested fresh
install, idempotent re-install over an opencode.json with an unrelated
provider, and full roundtrip uninstall.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@steventohme steventohme merged commit bec409a into main May 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant