feat(installer): add --opencode target#223
Merged
Merged
Conversation
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>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/anthropicprovider talks to it unmodified.What's in the diff
install/install.sh— new--opencodeflag, picker entry (option 3), per-target scope path resolution, and awrite_opencode_config()helper that jq-merges a managedprovider.weaveblock intoopencode.json. Dispatch block parallels the existing--codexbranch (health ping, key validation, gitignore for project scope,OPENCODE_CONFIG=hint for--dirinstalls).install/uninstall.sh—--opencodestrip path. Structurally removesprovider.weaveand the top-levelmodelonly when it points atweave/...; deletes the file if nothing non-schema remains.README.md,install/README.md, andinstall/npm/README.mdupdated with the new flag, scope paths, and onboarding flow.Config layout
~/.config/opencode/opencode.json(honors$XDG_CONFIG_HOME)<repo>/opencode.json(gitignored, per-teammate key)--dir <d><d>/opencode.json(caller setsOPENCODE_CONFIG)Managed block:
Top-level
modelis set toweave/claude-sonnet-4-6only 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.shandbash -n install/uninstall.shclean--opencode --dir <tmp> --non-interactive) — file 0600, well-formed, identity headers landedopencode.jsonthat already has a user-chosenmodeland an unrelatedprovider.openai— both preserved,weavemerged alongsideopencodeCLI installed (smoke tests ran withoutopencodeon PATH; CLI presence is a warning, not a hard fail)Follow-ups (not in this PR)
syncrouterinstall/install_template.shmirror sync once this merges@workweave/routernpm package version after merge🤖 Generated with Claude Code