Skip to content

fix(cli): forward OpenCode --method and --answer from account add - #37622

Merged
brennanb2025 merged 9 commits into
stablyai:mainfrom
Alonsojrr14:fix/account-add-opencode-method-answer
Nov 3, 2026
Merged

brennanb2025 merged 9 commits into
stablyai:mainfrom
Alonsojrr14:fix/account-add-opencode-method-answer

Conversation

@Alonsojrr14

@Alonsojrr14 Alonsojrr14 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Some OpenCode logins ask follow-up questions, such as which GitHub deployment to use. Without an interactive terminal, orca account add could not answer them, so login stopped before authorization. This forwards OpenCode's method and repeated form-answer flags inside Orca's private account profile.

orca account add --agent opencode --integration github-copilot --method device --answer deploymentType=github.com

The flags answer provider forms; they do not supply an API-key secret, approve a device authorization, or make every authentication method noninteractive.

Changes

  • Forward the method and each key=value answer in order, preserving spaces, empty right-hand values and embedded equals signs. OpenCode validates its own fields and authentication methods.
  • Reject malformed options, including a missing value among repeated answers, before runtime lookup or login. Keep form-answer values out of login-failure messages. These flags remain OpenCode-only.
  • Start generated account logins and the compatibility probe through the existing process launcher. Windows launchers can receive literal form text containing percent signs, ampersands and quotes, with terminal input, JSON output routing and cancellation preserved.
  • Keep isolated credential capture, import after successful login and cleanup on failure. No saved-data or wire-format changes.

Tracked in #37621.

Thanks to Alonso Almeida (@Alonsojrr14) for the original implementation and follow-up fixes; his commits and co-author attribution are retained.

Validation

  • 128 targeted tests pass across seven exact named files: CLI parser, repeatable flags, account handlers, login-command probe, real CLI subprocess checks and the existing skills CLI test. CLI typecheck, lint, formatting, changed-code quality and affected verification baselines pass.
  • Independent correctness and architecture/reference review accepted the repairs. The final test-only correction preserves the earlier runtime evidence; no production changes followed final QA.
  • macOS: real OpenCode existing-key enrollment, capture/import/list/removal, normal picker/stdin/cancellation and bounded real Codex login cancellation pass. A targeted follow-up with real Claude Code 2.1.316 passes auth-prompt launch, attached terminal input, cancellation and pending-profile cleanup. Prior Settings screenshot covers unchanged UI.
  • Windows 11: eight native fixture cases pass through the actual account-add CLI for recognized npm/pnpm shims and unrecognized batch fallback, literal form values, stdin, JSON routing, cancellation, rejection before runtime and cleanup. Fixtures prove transport and handoff, not provider authorization.
  • Earlier real no-TTY method/form forwarding reached device authorization. Completed answer-bearing no-TTY enrollment/import remains unexercised: no inventoried machine has an existing supported sign-in for that flow. Brennan authorized skipping this one completion check on November 3 after the maintainer assessed the separate forwarding, real import and Windows transport evidence; this is a documented validation gap, not a passing runtime result.
  • Full local check:changed is not green: its excessive related-test selection was replaced with exact named tests, and its baseline node typecheck encountered an unrelated GraphQL fixture error. Scoped verification is recorded above. Required CI passes on f0f93ebf80d5b8a8bc9fce5e65435bff40f3dfab, including all twelve unit shards, static analysis/typecheck, packaging and native smoke checks.

Risk

This touches account argument validation and the generated-login launcher. Automated checks, real Mac provider checks and native Windows transport/cancellation checks cover the repaired boundaries. Completed answer-bearing no-TTY authorization remains a validation gap. Terminal commands typed by users are unchanged.

AI disclosure

Original implementation written with Claude Code (Claude Opus 5.5) and reviewed by Alonso. Maintainer repairs reviewed with Codex.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer implementation is copied.

Without a TTY, OpenCode 2 stops at integration forms such as the GitHub
deployment type, and orca account add had no way to answer them.
Forward --method and repeatable --answer key=value to
`opencode auth login --standalone`, rejecting them for other agents
and malformed answers before login starts.

Fixes stablyai#37621

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

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The account add command accepts --method and repeatable --answer options for OpenCode. It validates that these options are used only with OpenCode and that supplied values meet the required formats. The handler adds valid options to the OpenCode login arguments before --standalone. Failure messages redact answer values, while the login process receives the original arguments. The CLI specification and tests cover the options, validation, forwarding, and redaction.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to d7c80

No current-head defect or merge-blocking risk was established in the changed OpenCode login-option paths.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% 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: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: forwarding OpenCode --method and --answer options from account add.
Linked Issues check Passed [#37621] requires OpenCode-only --method and repeatable --answer flags, unchanged forwarding, and rejection of invalid answers before login. account.ts declares both flags and answer as repeat…
Out of Scope Changes check Passed The changes stay within [#37621]. The command specification exposes the requested options. The handler validates and forwards them only for OpenCode. Redaction protects answer values in login errors. …
Description check Passed The description follows the repository template. It explains the change in plain language, lists the mechanism and the reasons for it, and names the linked issue (#37621). It also gives detailed valid…
Full details: Linked Issues check

Explanation

[#37621] requires OpenCode-only --method and repeatable --answer flags, unchanged forwarding, and rejection of invalid answers before login. account.ts declares both flags and answer as repeatable. data-account-commands.ts rejects these flags for non-OpenCode agents, rejects empty or dash-led methods, rejects malformed answers, preserves the original method value, and forwards repeated answers before --standalone. Tests cover argument order, surrounding method whitespace, = in answer values, invalid options, and pre-login rejection. The account handler tests cover non-OpenCode rejection and answer redaction.

Full details: Out of Scope Changes check

Explanation

The changes stay within [#37621]. The command specification exposes the requested options. The handler validates and forwards them only for OpenCode. Redaction protects answer values in login errors. The Windows error helper identifies whether a new login argument or the launcher path caused the existing batch guard failure without exposing values. Tests cover the new forwarding, validation, rejection, and redaction behavior. No unrelated change is demonstrated.

Full details: Description check

Explanation

The description follows the repository template. It explains the change in plain language, lists the mechanism and the reasons for it, and names the linked issue (#37621). It also gives detailed validation evidence on macOS and Windows, a risk statement, and an AI disclosure. The Linked Issue section says "Fixes #" with no number, and "Tracked in #37621" is used instead, so the template field is not filled as written. The Visual Proof section is not marked N/A, and it refers to a prior Settings screenshot without attaching a before/after comparison. The Risk section does not give a risk level or a clear revert procedure. The Testing checkbox for manual testing is not checked, though the body describes manual validation. These are minor gaps and do not make the description largely incomplete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 40.00% 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 5 functions across 6 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

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent 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: 2ab33942-7de5-4c41-82a8-6f097ba97441
Commits

Reviewing files that changed from the base of the PR and between 9bb1b7b and d7c8048.

Files selected for processing: 3
  • src/cli/handlers/account.test.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; 6 remain after this review.

- Redact --answer values in the login failure message, since form
  answers can hold secrets.
- Reject an empty --answer instead of dropping it before validation.
- Reject --method/--answer for Claude and Codex before their login
  starts, not only for Devin.

Refs stablyai#37621

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAGqwhqLekFS97KWFEHG3v
Alonsojrr14 and others added 2 commits November 3, 2026 00:46
…dows

When an OpenCode .cmd launcher is used, a --method or --answer value
containing cmd.exe metacharacters tripped the batch guard, but the error
said the launcher path was the problem. Name the login argument instead,
without echoing its value.

Refs stablyai#37621

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAGqwhqLekFS97KWFEHG3v
A --method, --answer or --integration value starting with a dash, such
as `--answer=--server=http://...`, could be read by OpenCode as its own
flag. Reject dash-led values, and validate login options before the
runtime call so bad input fails without touching the host.

Refs stablyai#37621

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

@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.

Follow-up Comments

Outside diff Forward the --method value unchanged after validation.

149-152: Minor · Functional Correctness · Quick win

Forward the --method value unchanged after validation.

method.trim() removes leading and trailing whitespace only. IDs without such whitespace are unaffected. A value such as device passes the validation and is forwarded as device. The issue requires --method to reach opencode auth login unchanged.

Keep method.trim() in the validation to reject all-whitespace values. Forward method in the argument array.

Suggested fix
-    ...(typeof method === 'string' ? ['--method', method.trim()] : []),
+    ...(typeof method === 'string' ? ['--method', method] : []),

Open the source location

Nitpick Cover multiple answers in the login failure test.

832-842: Trivial · Security & Privacy · Quick win

Cover multiple answers in the login failure test.

The current test checks only one --answer. Add a second answer and assert that both values are redacted while both original values remain in the spawned command.

Suggested fix
 import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { REPEATED_FLAG_SEPARATOR } from '../args'
 
@@
-        ['answer', 'token=secret-value']
+        [
+          'answer',
+          ['token=secret-value', 'note=second-secret'].join(REPEATED_FLAG_SEPARATOR)
+        ]
       ])
     })
-    await expect(failure).rejects.toThrow('--answer token=<redacted> --standalone')
+    await expect(failure).rejects.toThrow(
+      '--answer token=<redacted> --answer note=<redacted> --standalone'
+    )
     await expect(failure).rejects.not.toThrow('secret-value')
+    await expect(failure).rejects.not.toThrow('second-secret')
     expect(spawnMock.mock.calls[0][1]).toContain('token=secret-value')
+    expect(spawnMock.mock.calls[0][1]).toContain('note=second-secret')

Open the source location

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: 097fbecd-9c55-4a7e-80f3-0e09f7ac243d
Commits

Reviewing files that changed from the base of the PR and between 5cb7cba and 2633786.

Files selected for processing: 3
  • src/cli/handlers/account-login-launch-error.ts
  • src/cli/handlers/account.test.ts
  • src/cli/handlers/account.ts
Files skipped from review as they are similar to previous changes: 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.

Trim --method only for validation and pass the value to OpenCode as
given. Apply the same trimmed dash check to --integration, and test that
every --answer value is redacted from the login failure message.

Refs stablyai#37621

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

Copy link
Copy Markdown
Contributor Author

Addressed the two follow-up comments from the review of 2633786fd7 in d7c8048ac8:

  • --method is now forwarded to opencode auth login unchanged. trim() is only used to reject blank or dash-led values. --integration gets the same trimmed dash check.
  • The login failure test now uses two --answer values and checks that both are redacted from the error and both still reach the spawned command.

9bb1b7ba3e also rejects dash-led --method/--answer/--integration values (so something like --answer=--server=... can't be parsed by OpenCode as its own flag), and validates login options before the runtime call.

brennanb2025 and others added 4 commits November 2, 2026 22:43
Reject every missing repeated string value before runtime lookup, and use the shared process launcher for account login and capability probes. Preserve provider form keys and literal values while retaining option-boundary validation.

Co-authored-by: Alonso Almeida <alonsojr1269@gmail.com>
Narrow the expected failure type, explain bounded subprocess deadlines, and remove the obsolete direct-import exception.

Co-authored-by: Alonso Almeida <alonsojr1269@gmail.com>
Retain the exact rejection and exit-code assertions after repeatable values began failing before dispatch.

Co-authored-by: Alonso Almeida <alonsojr1269@gmail.com>
@brennanb2025

brennanb2025 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks, @Alonsojrr14 — the method/form forwarding addresses the missing no-terminal login path. I added two repairs: reject every missing repeated value before login, and use the common process launcher so Windows preserves literal form answers. OpenCode continues to own method/field validation; isolated credential capture and cancellation stay intact.

Validation: 128 targeted tests pass; real OpenCode key enrollment/import and OpenCode/Codex cancellation pass on macOS. Real Claude auth-prompt launch, attached terminal input, cancellation and pending-profile cleanup also pass in the follow-up. Eight native Windows fixture cases pass for literal argv, stdin, JSON routing, cancellation and cleanup. Fixtures verify transport, not provider authorization.

OpenCode completed answer-bearing no-TTY authorization/import waived by Brennan: “Eh. Think it's safe to skip it? We can if so” (November 3, 2026), conditional on my safety assessment. I recommend and accept this narrow exception: the real no-TTY form flow reached device authorization; real key enrollment independently exercised private capture/import/removal; targeted tests and eight native Windows fixture cases cover argument transport and cleanup. Completion of that exact authorization/import combination remains unverified. All other required runs retain their recorded results.

CI passes on f0f93ebf80d5b8a8bc9fce5e65435bff40f3dfab, including all twelve unit shards. Final review is complete on that head. OpenCode/Codex and Windows QA ran on ac2470c7af8d1333a162cb2eac28b74003804f1a; the sole later commit f0f93ebf80d5b8a8bc9fce5e65435bff40f3dfab changes only an existing test’s missing-value diagnostic assertion, so their runtime evidence carries. Real Claude follow-up ran on f0f93eb. Alonso’s thanks and co-author trailer will be preserved in the squash.

For Brennan’s review: repeatable validation · login launch.

QA evidence: actual CLI against real OpenCode/Codex on macOS and the native Windows fixture runtime; reports and logs retained in ~/orca-qa/pr-37622/final-mac-qa-report.md and final-windows-qa-report.md. claude-followup-report.md records the real Claude follow-up. Prior Settings screenshot covers unchanged UI.

Existing behavior observed during QA: raw-mode Claude/OpenCode cancellation can report the provider’s exit 130 as a CLI failure while cleanup succeeds. The same nonzero-exit mapping exists on the merged main baseline; this PR does not change it.

@brennanb2025
brennanb2025 merged commit 3b91fe4 into stablyai:main Nov 3, 2026
46 checks passed
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.

2 participants