[Bug]: OpenCode provider incompatible with OpenCode V2 CLI (`Unrecognized flag: --dir`)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
- Domain
- ai-infra-agents, backend
Research direction
The argument list for opencode run is built in server/modules/providers/list/opencode/opencode-runtime.provider.js, around lines 258-274. Read that block first, then the assertion at opencode-runtime.provider.test.js:113 that checks the launched args. Done means the spawned args no longer include --dir or --variant, the effort is appended to the model as model#variant, and the updated unit test passes. Check the model#variant format against the linked V2 CLI docs before relying on it.
Written by the indexing model from the issue text.
Description
Description
When attempting to use the OpenCode provider with OpenCode V2 (>= 2.0.0, tested on 2.2.3), chat requests fail immediately upon spawning the OpenCode process due to unsupported command-line flags.
The OpenCode runtime provider currently passes V1 CLI arguments (notably --dir and --variant), which have been deprecated and removed in OpenCode V2.
Environment
- cloudcli version:
1.37.6 - OpenCode version:
2.2.3(V2) - OS: Linux (reproducible across platforms)
Steps to Reproduce
- Install OpenCode V2 (
opencode >= 2.0.0). - Configure cloudcli to use OpenCode as the provider.
- Start a chat session or send a prompt via cloudcli.
Actual Behavior
The spawned OpenCode process exits immediately with the following error:
ERROR
Unrecognized flag: --dir in command opencode run
Followed by the opencode run --help usage output.
Expected Behavior
cloudcli should successfully invoke OpenCode V2 without failing on legacy CLI flags.
Root Cause
In server/modules/providers/list/opencode/opencode-runtime.provider.js (lines ~258–274), the argument list for opencode run is constructed using V1 conventions:
const args = ['run', '--format', 'json'];
// OpenCode's `run` command owns workspace selection through `--dir`.
args.push('--dir', workingDir);
if (providerSessionId) args.push('--session', providerSessionId);
if (resolvedModel) args.push('--model', resolvedModel);
if (resolvedEffort) args.push('--variant', resolvedEffort);
Breaking changes in OpenCode V2:
--dir/--directory/--cwdremoved:
In OpenCode V2,opencode rundetermines the workspace directory strictly from the process working directory (process.cwd()). Because cloudcli already passes{ cwd: workingDir }tospawn(), the--dirflag is both unsupported and redundant.--variantremoved:
OpenCode V2 encodes variants directly into the model identifier (e.g.,provider/model#variant) rather than accepting a separate--variantflag.OPENCODE_PERMISSIONenv var deprecated:
TheOPENCODE_PERMISSIONenvironment variable used for edit permissions in V1 is no longer recognized in V2. V2 utilizes structured permission rules (e.g. viaOPENCODE_CONFIG_CONTENTor configuration file policies), though V2's default base policy allows all actions by default.
Proposed Fix
Update server/modules/providers/list/opencode/opencode-runtime.provider.js:
- Remove the
--dirflag (cloudcli already specifiescwd: workingDirwhen spawning). - Append
resolvedEffortto the model name if present instead of passing--variant.
- const args = ['run', '--format', 'json'];
- // OpenCode's `run` command owns workspace selection through `--dir`.
- args.push('--dir', workingDir);
- if (providerSessionId) args.push('--session', providerSessionId);
- if (resolvedModel) args.push('--model', resolvedModel);
- if (resolvedEffort) args.push('--variant', resolvedEffort);
+ const args = ['run', '--format', 'json'];
+ if (providerSessionId) {
+ args.push('--session', providerSessionId);
+ }
+ if (resolvedModel) {
+ args.push('--model', resolvedEffort ? `${resolvedModel}#${resolvedEffort}` : resolvedModel);
+ }
Corresponding Test Updates
Update unit test assertions expecting the old flag layout (such as server/modules/providers/list/opencode/opencode-runtime.provider.test.js:113):
- assert.deepEqual(launchedArgs.slice(0, 4), ['run', '--format', 'json', '--dir']);
+ assert.deepEqual(launchedArgs.slice(0, 3), ['run', '--format', 'json']);
Additional Context & References
- OpenCode CLI reference: https://opencode.ai/v2/docs/cli
- OpenCode V2 migration guide: https://opencode.ai/v2/docs/migrate-v1
- OpenCode V2 permissions documentation: https://opencode.ai/v2/docs/permissions
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 2k
- Avg merge
- 22h 45m
- Merged PRs (30d)
- 44
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from siteboon/claudecodeui
-
NP OSS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
siteboon/claudecodeui#1905 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement OSS
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
siteboon/claudecodeui#1904 ·
Maintainers usually reply within 1 day
-
Slash command menu: Enter within the 150 ms filter debounce runs the most-used command instead of the typed onePossibly taken @blackmammoth claimed this 43 days ago. OpenNP
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
siteboon/claudecodeui#1560 ·
Maintainers usually reply within 1 day
-
Web push never reaches iPhones: Apple rejects the VAPID subject mailto:[email protected] (403 BadJwtToken)Possibly taken @blackmammoth claimed this 43 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
siteboon/claudecodeui#1550 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
siteboon/claudecodeui#1547 ·
Maintainers usually reply within 1 day
All issues in siteboon/claudecodeui
Similar issues
-
Media browser returns "Not found" for repositories using the SHA-256 object formatPossibly taken @adamchodera claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Follow-ups from #312Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
janhesters/remixcn#318 ·
Maintainers usually reply within 1 day
-
Interceptor LaunchTestProfile.sh: no Windows (Git Bash/MSYS) branch, test profile never launchesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
danielmiessler/LifeOS#3150 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Make the "%" unit spacing the same in the web and in A10Possibly taken @kragent66-glitch claimed this today. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maiychrus25/OpenTea-DX-OS#226 · 1 comment ·