Skip to content

fix(cli): honor --yolo/--auto in mini and attach modes#42

Merged
CreatorGhost merged 2 commits into
devfrom
yolo-mini-attach
Jul 12, 2026
Merged

fix(cli): honor --yolo/--auto in mini and attach modes#42
CreatorGhost merged 2 commits into
devfrom
yolo-mini-attach

Conversation

@CreatorGhost

@CreatorGhost CreatorGhost commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What

The auto-approve permission flags (--auto, --yolo, --dangerously-skip-permissions) already work for the non-interactive run loop and the main TUI, but were ignored by the mini interactive runtime and absent from attach. This closes those gaps.

Changes

  • stream.transport.ts: when auto is set, the session transport replies "once" to every permission.asked instead of surfacing a footer prompt. Questions still block; explicit deny rules still win (the server rejects them before ever emitting permission.asked).
  • Thread auto through runInteractiveMode / runInteractiveLocalModerunInteractiveRuntimecreateSessionTransport.
  • runMini now forwards auto (was hardcoded false); run's interactive path passes it in.
  • tui and attach mini branches forward the resolved flag to runMini.
  • attach gains --auto/--yolo/--dangerously-skip-permissions and forwards auto to the full-TUI path too.

Tests

  • New stream-transport regression test: auto mode replies once to a permission.asked.
  • Updated the attach help snapshot for the new --auto flag.
  • typecheck 30/30.

Summary by CodeRabbit

  • New Features

    • Added an automatic permission approval option for interactive command-line sessions.
    • Added --auto to enable automatic approval, with additional hidden compatibility flags.
    • The option works in both standard and mini interactive modes, including attached sessions.
    • Permission requests are automatically approved once, while questions and explicit deny rules continue to behave normally.
  • Tests

    • Added coverage confirming automatic approval responds correctly to permission requests.

The auto-approve flags (--auto/--yolo/--dangerously-skip-permissions) were only
handled by the non-interactive run loop and the main TUI; the mini interactive
runtime ignored them (runMini hardcoded auto:false) and attach had no such flag.

Thread auto through runMini, the tui/attach mini branches, and the interactive
runtime into the session stream transport, which now replies "once" to every
permission request when auto is on (questions still block; explicit deny rules
still win). Also add the flags to attach and forward auto to the attach full-TUI.

Adds a stream-transport regression test and updates the attach help snapshot.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@CreatorGhost, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee3f8814-b44f-4290-b4de-e437ae5d85d7

📥 Commits

Reviewing files that changed from the base of the PR and between de06c91 and fa8f2b1.

📒 Files selected for processing (1)
  • packages/opencode/test/cli/run/stream.transport.test.ts
📝 Walkthrough

Walkthrough

The CLI adds auto-approval flags and propagates the resolved setting through runMini, interactive runtimes, and stream transport. When enabled, permission requests receive an automatic "once" reply. A transport test verifies the reply payload.

Changes

Auto Permission Approval

Layer / File(s) Summary
CLI flags and command wiring
packages/opencode/src/cli/cmd/attach.ts, packages/opencode/src/cli/cmd/tui.ts
Adds public and hidden auto-approval flags and passes their resolved value into mini and standard command execution.
Runtime auto propagation
packages/opencode/src/cli/cmd/run.ts, packages/opencode/src/cli/cmd/run/runtime.ts, packages/opencode/src/cli/cmd/run/types.ts
Extends command and runtime inputs with auto and forwards it to interactive runtime and session transport creation.
Automatic permission replies
packages/opencode/src/cli/cmd/run/stream.transport.ts, packages/opencode/test/cli/run/stream.transport.test.ts
Automatically replies "once" to permission requests in auto mode and verifies the SDK reply payload.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant runMini
  participant InteractiveRuntime
  participant StreamTransport
  participant SDK
  CLI->>runMini: pass auto flag
  runMini->>InteractiveRuntime: forward auto
  InteractiveRuntime->>StreamTransport: create transport with auto
  StreamTransport->>SDK: reply permission request with once
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and tests, but it omits the required template sections like issue, change type, and checklist. Rewrite the PR description using the repository template and include issue reference, change type, verification, screenshots if needed, and checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main CLI permission-flag change in mini and attach modes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yolo-mini-attach

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.

@CreatorGhost CreatorGhost merged commit 2c9a102 into dev Jul 12, 2026
2 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/opencode/src/cli/cmd/attach.ts (1)

108-108: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated auto-flag combination into a shared helper.

args.auto || args.yolo || args["dangerously-skip-permissions"] is duplicated here (twice) and again in tui.ts and run.ts. If the combination logic ever changes (e.g., a new hidden alias is added), each call site must be updated in lockstep or behavior silently diverges between attach, tui, and run.

♻️ Suggested shared helper
// e.g. in packages/opencode/src/cli/cmd/run/types.ts
export function resolveAutoApprove(args: {
  auto?: boolean
  yolo?: boolean
  "dangerously-skip-permissions"?: boolean
}): boolean {
  return Boolean(args.auto || args.yolo || args["dangerously-skip-permissions"])
}

Then each call site becomes auto: resolveAutoApprove(args).

As per coding guidelines, "Do not extract single-use helpers preemptively; inline logic unless the helper is reused..." — since this expression is reused across at least four call sites, extraction is justified.

Also applies to: 158-158

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/opencode/src/cli/cmd/attach.ts` at line 108, Extract the repeated
auto-approval expression into a shared resolveAutoApprove helper, using the
existing argument names and returning a boolean. Replace both occurrences in
attach.ts and the corresponding usages in tui.ts and run.ts with this helper,
ensuring all call sites preserve the current behavior and import the shared
symbol.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/opencode/src/cli/cmd/run/stream.transport.ts`:
- Around line 528-535: Update the auto-approval flow around
input.sdk.permission.reply so --auto/--yolo also processes permission requests
already pending from bootstrap or replay, not only live permission.asked events.
Handle reply failures with the session’s retry or error-propagation path instead
of swallowing them, ensuring failed requests do not remain silently blocked.

---

Nitpick comments:
In `@packages/opencode/src/cli/cmd/attach.ts`:
- Line 108: Extract the repeated auto-approval expression into a shared
resolveAutoApprove helper, using the existing argument names and returning a
boolean. Replace both occurrences in attach.ts and the corresponding usages in
tui.ts and run.ts with this helper, ensuring all call sites preserve the current
behavior and import the shared symbol.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5ecb365-dc11-4c45-b949-766bff6b7366

📥 Commits

Reviewing files that changed from the base of the PR and between 2ef3ef4 and de06c91.

⛔ Files ignored due to path filters (1)
  • packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • packages/opencode/src/cli/cmd/attach.ts
  • packages/opencode/src/cli/cmd/run.ts
  • packages/opencode/src/cli/cmd/run/runtime.ts
  • packages/opencode/src/cli/cmd/run/stream.transport.ts
  • packages/opencode/src/cli/cmd/run/types.ts
  • packages/opencode/src/cli/cmd/tui.ts
  • packages/opencode/test/cli/run/stream.transport.test.ts

Comment on lines +528 to +535
// YOLO: auto-approve permission requests without surfacing a prompt.
// Questions are left to the user; explicit deny rules already reject
// server-side before a permission.asked is ever emitted.
if (input.auto && event.type === "permission.asked") {
void input.sdk.permission.reply({ requestID: event.properties.id, reply: "once" }).catch(() => {})
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

echo "== outline =="
ast-grep outline "$FILE" --view expanded || true

echo
echo "== line count =="
wc -l "$FILE"

echo
echo "== relevant slice around 480-620 =="
sed -n '480,620p' "$FILE" | cat -n

Repository: CreatorGhost/TheCode

Length of output: 7901


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

echo "== search for blocker/permission handling =="
rg -n "permission|blocker|seedBlocker|trackBlocker|auto" "$FILE"

echo
echo "== broader related symbols in file =="
sed -n '1,260p' "$FILE" | cat -n

Repository: CreatorGhost/TheCode

Length of output: 12163


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

python3 - <<'PY'
from pathlib import Path
p = Path("packages/opencode/src/cli/cmd/run/stream.transport.ts")
text = p.read_text()
for needle in [
    "seedBlocker(",
    "trackBlocker(",
    "applyEvent(",
    "bootstrap(",
    "replayOnResize(",
    "permission.reply",
]:
    idxs = [i for i in range(len(text)) if text.startswith(needle, i)]
    print(f"{needle}: {len(idxs)}")
    for i in idxs[:5]:
        line = text.count("\n", 0, i) + 1
        print("  line", line)
PY

Repository: CreatorGhost/TheCode

Length of output: 397


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

# Show the exact implementation around permission handling and bootstrapping.
sed -n '260,420p' "$FILE" | cat -n
echo
sed -n '420,620p' "$FILE" | cat -n

Repository: CreatorGhost/TheCode

Length of output: 12835


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

echo "== bootstrap permissions around 600-640 =="
sed -n '600,640p' "$FILE" | cat -n

echo
echo "== replay permissions around 790-815 =="
sed -n '790,815p' "$FILE" | cat -n

echo
echo "== resize restore around 1118-1140 =="
sed -n '1118,1140p' "$FILE" | cat -n

echo
echo "== applyEvent call site around 920-1015 =="
sed -n '920,1015p' "$FILE" | cat -n

echo
echo "== replayOnResize implementation around 1038-1088 =="
sed -n '1038,1088p' "$FILE" | cat -n

Repository: CreatorGhost/TheCode

Length of output: 10695


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

python3 - <<'PY'
from pathlib import Path
p = Path("packages/opencode/src/cli/cmd/run/stream.transport.ts")
lines = p.read_text().splitlines()
for start, end, label in [
    (600, 640, "bootstrap permissions"),
    (790, 815, "replay permissions"),
    (1118, 1140, "resize restore"),
    (920, 1015, "applyEvent call site"),
    (1038, 1088, "replayOnResize implementation"),
]:
    print(f"== {label} ==")
    for i in range(start-1, min(end, len(lines))):
        print(f"{i+1:5d}: {lines[i]}")
    print()
PY

Repository: CreatorGhost/TheCode

Length of output: 10616


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="packages/opencode/src/cli/cmd/run/stream.transport.ts"

python3 - <<'PY'
from pathlib import Path
p = Path("packages/opencode/src/cli/cmd/run/stream.transport.ts")
lines = p.read_text().splitlines()
for start, end, label in [
    (620, 640, "bootstrap permissions"),
    (798, 810, "replay permissions"),
    (1124, 1136, "resize restore"),
    (930, 950, "applyEvent call site"),
    (1040, 1080, "replayOnResize implementation"),
]:
    print(f"== {label} ==")
    for i in range(start-1, min(end, len(lines))):
        print(f"{i+1:5d}: {lines[i]}")
    print()
PY

Repository: CreatorGhost/TheCode

Length of output: 5041


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how permission.asked / permission.replied are reduced into SessionData.
FILE="packages/opencode/src/cli/cmd/run/session-data.ts"

echo "== outline =="
ast-grep outline "$FILE" --view expanded || true

echo
echo "== relevant permission-related slices =="
rg -n "permission\.asked|permission\.replied|question\.asked|question\.replied|question\.rejected|blocker|permissions|questions" "$FILE"

echo
python3 - <<'PY'
from pathlib import Path
p = Path("packages/opencode/src/cli/cmd/run/session-data.ts")
lines = p.read_text().splitlines()
for start, end in [(1, 260), (260, 520)]:
    print(f"== lines {start}-{end} ==")
    for i in range(start-1, min(end, len(lines))):
        print(f"{i+1:5d}: {lines[i]}")
    print()
PY

Repository: CreatorGhost/TheCode

Length of output: 22229


Auto-reply existing permission blockers and handle reply failures

  • Swallowing permission.reply(...) errors leaves the request pending with no retry path; if the auto-reply fails, the session stays blocked.
  • --auto/--yolo only applies to live permission.asked events. Pending permissions seeded during bootstrap/replay still bypass auto-approval, so resumed sessions can remain blocked.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/opencode/src/cli/cmd/run/stream.transport.ts` around lines 528 -
535, Update the auto-approval flow around input.sdk.permission.reply so
--auto/--yolo also processes permission requests already pending from bootstrap
or replay, not only live permission.asked events. Handle reply failures with the
session’s retry or error-propagation path instead of swallowing them, ensuring
failed requests do not remain silently blocked.

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.

1 participant