[Bug]: OpenCode provider incompatible with OpenCode V2 CLI (`Unrecognized flag: --dir`)

Open Beginner friendly
#1,707 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@blackmammoth is already working on this.

Since Nov 3, 2026.

  • #1729 by @blackmammoth — open

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

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

bug OSS

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

  1. Install OpenCode V2 (opencode >= 2.0.0).
  2. Configure cloudcli to use OpenCode as the provider.
  3. 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:
  1. --dir / --directory / --cwd removed:
    In OpenCode V2, opencode run determines the workspace directory strictly from the process working directory (process.cwd()). Because cloudcli already passes { cwd: workingDir } to spawn(), the --dir flag is both unsupported and redundant.
  2. --variant removed:
    OpenCode V2 encodes variants directly into the model identifier (e.g., provider/model#variant) rather than accepting a separate --variant flag.
  3. OPENCODE_PERMISSION env var deprecated:
    The OPENCODE_PERMISSION environment variable used for edit permissions in V1 is no longer recognized in V2. V2 utilizes structured permission rules (e.g. via OPENCODE_CONFIG_CONTENT or 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:

  1. Remove the --dir flag (cloudcli already specifies cwd: workingDir when spawning).
  2. Append resolvedEffort to 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

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from siteboon/claudecodeui

All issues in siteboon/claudecodeui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.