Skip to content

fix(cli): refuse OpenCode 1.x before managed account login - #35956

Closed
Alonsojrr14 wants to merge 2 commits into
stablyai:mainfrom
Alonsojrr14:fix/opencode-account-add-requires-opencode-2
Closed

Alonsojrr14 wants to merge 2 commits into
stablyai:mainfrom
Alonsojrr14:fix/opencode-account-add-requires-opencode-2

Conversation

@Alonsojrr14

Copy link
Copy Markdown
Contributor

ELI5

Adding an OpenCode account in Orca only works with OpenCode 2. With OpenCode 1.x installed, Orca crashed into OpenCode's help screen and gave no reason. Now Orca checks first and says what's wrong.

What Changed

Before: orca account add --agent opencode always ran opencode auth login --standalone. OpenCode 1.x (the current latest on npm, 1.19.5) has no --standalone, so it printed its help and the command failed with `opencode auth login --standalone` exited with code 1.

After: before starting the login, the CLI runs opencode auth login --help. If the output has no --standalone, it stops with:

Managed OpenCode accounts need OpenCode 2. The installed opencode has no auth login --standalone (OpenCode 1.x). Install OpenCode 2, or sign in with opencode auth login.

Mechanism: addDataAccount takes a readLoginHelp probe next to the existing login callback. account.ts implements it with the same command resolution, Windows batch spawn args and PATH setup as runAgentLoginInTerminal. If the probe can't run at all, it returns null and the login goes ahead as before, so a missing binary still gets the existing "Is it installed and on PATH?" error.

Why

Just dropping --standalone for 1.x would not work: the account capture reads OpenCode 2's isolated credential database, so the login would succeed and the import would fail later with a less clear error. Checking the help output instead of --version also works for the 0.0.0-beta-* / 0.0.0-dev-* builds on npm, whose version numbers say nothing about the major.

Linked Issue

Fixes #35953

Visual Proof

N/A: CLI-only change, no UI. The before and after terminal output is quoted above.

Testing

  • vitest on src/cli/handlers/data-account-commands.test.ts and src/cli/handlers/account*: 39 passed, including the new "refuses OpenCode 1.x before starting login" case.

  • oxlint on the changed files and the CLI typecheck project (config/tsconfig.tc.cli.json) pass.

  • On macOS (arm64) with opencode-ai@1.19.5, I ran the same resolution and probe code against the real binary: it resolved /usr/local/bin/opencode, read the help, and found no --standalone.

  • Not tested on Linux, Windows or over SSH. The probe reuses the existing cross-platform spawn helpers, and account add already rejects remote selection flags.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude Code (Claude Opus 5.5). I reviewed the change and the test results.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q9uoqirRAeE1XCUTzQTV47

`orca account add --agent opencode` always ran `opencode auth login --standalone`.
OpenCode 1.x has no `--standalone`, so it printed its help and exited 1 with no
hint about why. Probe `opencode auth login --help` first and explain that managed
OpenCode accounts need OpenCode 2.

Fixes stablyai#35953

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9uoqirRAeE1XCUTzQTV47
@Alonsojrr14

Alonsojrr14 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

After opening this I found something that makes me think it may only treat the symptom, so I'd like to check the intended behavior before going further.

src/shared/tui-agent-config.ts models the two OpenCode lines as separate agents with separate binaries:

  • opencode uses the opencode binary (composer captures from 1.18.32, so the 1.x line)
  • opencode2 uses detectCmd: 'opencode2' and launches opencode2 --standalone

But orca account add --agent opencode runs opencode auth login --standalone, which pairs the 1.x binary with a 2.x-only flag. So the actual bug may be the binary name, not a missing version check.

Questions:

  1. Are managed OpenCode accounts meant only for OpenCode 2? If so, should account add call opencode2 auth login --standalone, the binary Orca already uses to launch OpenCode 2?

  2. Or should they also cover OpenCode 1.x, which would need a different login and capture path (1.x has no --standalone, and the capture reads OpenCode 2's credential database)?

  3. Where are users expected to get the opencode2 binary? Edit: found it. OpenCode 2 ships as the v2.x GitHub releases (anomalyco/opencode, e.g. v2.2.1), not on npm, where latest is still 1.19.5. opencode auth login --help on v2.2.1 does list --standalone. With v2.2.1 installed as opencode (and linked as opencode2), Orca's resolveCliCommand('opencode') resolves to it. So today the command only works when the opencode on PATH is 2.x, which is why question 1 matters.

    Edit 2: confirmed end to end. With v2.2.1 as opencode on PATH (macOS arm64, Orca 1.4.242), orca account add --agent opencode --integration github-copilot --label copilot completed the device-code login in the isolated directory and saved the account; orca account list --agent opencode shows it as active. One more thing I hit: without a TTY, OpenCode 2 stops at the GitHub deployment-type form ("Authentication form input requires an interactive terminal"), and account add has no way to pass OpenCode's --method / --answer, so --integration alone isn't enough for non-interactive use.

Depending on the answer, I can change this PR to resolve opencode2 first, and keep the help probe only as a fallback that runs after a failed login (so the happy path doesn't pay for an extra process), with an error that names opencode2. Or close it if you'd rather fix it differently.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issues remain.

Summary

Adds a help check before managed OpenCode login and rejects installations without --standalone.

  • OpenCode account setup checks for standalone login support first.

Reviews (2) · Last reviewed commit: "fix(cli): treat a failed OpenCode help p..." · Reviewed by Greptile

Comment thread src/cli/handlers/account.ts Resolved
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The OpenCode account-add flow reads opencode auth login --help before creating a temporary login directory. It rejects non-null help output that lacks --standalone. If help capture fails, the callback returns null and the check passes. Other providers skip this check. Tests cover incompatible help output and the updated callback.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 78ee0

The change refuses OpenCode 1.x and adds a help probe, but it still probes and launches a hard-coded opencode command. Users whose OpenCode 2 install exposes only opencode2 cannot complete managed account enrollment. The intended executable should be settled and used for both the probe and the login before merge.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #35953 expects orca account add --agent opencode to start the OpenCode login flow and save the account. The reviewed code probes opencode auth login --help, then throws when the output lacks… Implement a compatible OpenCode 1.x login and account-capture path that starts login and saves the account, or update issue #35953 to accept refusal with guidance as the required outcome.
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title "fix(cli): refuse OpenCode 1.x before managed account login" names the main change: the CLI now stops managed OpenCode account login when the installed OpenCode is 1.x. It matches the change…
Description check Passed The description follows the template. It has ELI5, What Changed (before/after with the mechanism), Why (including why dropping --standalone alone would not work and why help output is used instead of …
Out of Scope Changes check Passed The changes remain within issue #35953. The probe reuses the existing command resolution and spawn setup. The OpenCode compatibility check and focused test support handling of the reported unsupported…
Full details: Title check

Explanation

The title "fix(cli): refuse OpenCode 1.x before managed account login" names the main change: the CLI now stops managed OpenCode account login when the installed OpenCode is 1.x. It matches the changeset, which adds a help probe in addDataAccount and the account.ts helper. It is specific and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the template. It has ELI5, What Changed (before/after with the mechanism), Why (including why dropping --standalone alone would not work and why help output is used instead of --version), Linked Issue (Fixes #35953), Visual Proof marked N/A with a reason, Testing with steps and platforms actually tested, AI Disclosure, the agent skill boundary, and a checklist. Gaps: the template's Linked Issue note asks for a real issue, which is provided. The final pnpm lint/typecheck/test/build checklist item is unchecked, and the Testing section does not list pnpm build or pnpm test as run. The Review and Notes sections are left as template text. The description is mostly complete.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #35953. The probe reuses the existing command resolution and spawn setup. The OpenCode compatibility check and focused test support handling of the reported unsupported flag. No unrelated change is shown.

Full details: Linked Issues check

Explanation

Issue #35953 expects orca account add --agent opencode to start the OpenCode login flow and save the account. The reviewed code probes opencode auth login --help, then throws when the output lacks --standalone. The test confirms that OpenCode 1.x login does not start. The PR provides a clearer error, but it does not meet the linked issue's stated expected outcome.

Resolution

Implement a compatible OpenCode 1.x login and account-capture path that starts login and saves the account, or update issue #35953 to accept refusal with guidance as the required outcome.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4dc2e0fa-cf61-4c92-92ff-a24583757ee7
Commits

Reviewing files that changed from the base of the PR and between 0bd7ecf and a6319d8.

Files selected for processing: 3
  • src/cli/handlers/account.ts
  • src/cli/handlers/data-account-commands.test.ts
  • src/cli/handlers/data-account-commands.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/cli/handlers/account.ts Resolved
A launcher that starts but exits nonzero printed an error without
`--standalone`, which was reported as OpenCode 1.x. OpenCode 1.x exits 0
on `auth login --help`, so it is still refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9uoqirRAeE1XCUTzQTV47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Use the OpenCode 2 command for both enrollment operations. · account.ts:281

src/cli/handlers/account.ts:281
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Use the OpenCode 2 command for both enrollment operations.

addDataAccount probes opencode and later starts login with the same hard-coded executable. A supported installation that provides opencode2 therefore receives an inconclusive probe result and then attempts to launch the missing opencode command.

Resolve the OpenCode 2 executable once and use it for both the help probe and login. Keep opencode as the backend provider key for accounts.addDataFromHome.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 56b92270-caf5-470c-adc7-5c3983559096
Commits

Reviewing files that changed from the base of the PR and between a6319d8 and 78ee0c3.

Files selected for processing: 1
  • src/cli/handlers/account.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@Alonsojrr14

Copy link
Copy Markdown
Contributor Author

Superseded by #36292, which landed the fix (resolving opencode2 first, with the help probe for --standalone). Closing this one.

@Alonsojrr14 Alonsojrr14 closed this Nov 3, 2026
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.

[Bug]: orca account add --agent opencode runs 'opencode auth login --standalone', a flag OpenCode doesn't have

1 participant