Repository navigation
fix: launch OpenCode 2 without the --model flag it no longer accepts - #12
Merged
Merged
Conversation
OpenCode 2's terminal interface dropped --model, so `apex run opencode` failed with "Unrecognized flag: --model". apex now reads `opencode --version`: OpenCode 1 keeps --model; OpenCode 2 starts a private server with --standalone and gets the model through OPENCODE_CONFIG_CONTENT (merged into any inline config already set). The shared background service never sees the child's environment, so --standalone is what makes both the model and the gateway key reach it. OpenCode 2 only accepts flags after a subcommand, so they follow one (`opencode run --standalone ...`). The init summary shows the matching expansion.
Review follow-ups: --standalone goes to the interface, `run` and `mini` and is left off other subcommands (`auth list` rejected it). The version is read from a line of its own, init reuses the binary detect found, the key check is its own function, and each launch carries its summary note.
The inline config is read with the same JSONC parser as config files, so a comment or trailing comma OpenCode itself accepts no longer stops the launch. The v2 env is built in launchOptions like Claude's, the version plumbing helper is gone, and openCodeMajor answers 1 without a binary.
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.
Problem
After upgrading to OpenCode 2,
apex run opencodefails:OpenCode 2's terminal interface has no
--modelflag (onlyrunandminido).Fix
apex run opencodenow checksopencode --version(1.18.34in v1,opencode v2.0.29in v2):opencode --model <provider>/<model>.opencode --standalonewithOPENCODE_CONFIG_CONTENT='{"model":"<provider>/<model>"}'. If you already setOPENCODE_CONFIG_CONTENT, the model is merged into it. If that value isn't a JSON object, apex stops with an error.--standaloneis required. By default OpenCode 2 connects to a shared background service, which never sees the child's environment, so it would ignore both the inline model and the gateway key the config references.--standalonefollowsrunandmini(apex run opencode -- run "hi"→opencode run --standalone hi). A directory argument still starts the interface with--standalone, and other subcommands (auth list,models, …) are passed through untouched, since most of them reject the flag.The init summary shows the matching expansion (
opencode --standalone (OPENCODE_CONFIG_CONTENT model set)for v2).Verification
npm test: 66/66 pass, including a new test with a fakeopencodethat reports v1, v2 or an unreadable version.--standalone, the inline config model was used (exported session showedopenai/gpt-5.5fromOPENCODE_CONFIG_CONTENT). Without--standalone, the background service ignored it.apex run --provider callstack opencode -- run …ran oncallstack.ai/callstack/Apex.--modelbefore the subcommand, which v1 accepts.