Skip to content
This repository was archived by the owner on Sep 2, 2026. It is now read-only.

fix(opencode): enable YOLO permission mode via OPENCODE_CONFIG_CONTENT - #90

Merged
64ix merged 1 commit into
mainfrom
64ix/issue-85-opencode-yolo
Aug 26, 2026
Merged

64ix merged 1 commit into
mainfrom
64ix/issue-85-opencode-yolo

Conversation

@64ix

@64ix 64ix commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

YOLO permission mode had no effect on OpenCode launches: opencode was absent from YOLO_TUI_AGENT_ARGS, and its one Claude-style bypass flag (--dangerously-skip-permissions) is already stripped as unsupported in tui-agent-launch-defaults.ts. OpenCode models permissions in its own JSON config, not via a CLI flag, so the fix delivers an allow-all permission block through opencode's own inline-config env var, OPENCODE_CONFIG_CONTENT, added to the existing YOLO_TUI_AGENT_ENV map (the same mechanism already used for goose's GOOSE_MODE).

Closes #85

Mechanism

Researched against the installed opencode CLI (1.18.23) rather than guessing:

  • opencode --help shows no --config flag on the default/TUI command, and no bare --dangerously-skip-permissions-equivalent that opencode's own launch mode supports without also disabling other approvals.
  • OpenCode's config schema (https://opencode.ai/config.json) documents a top-level permission field accepting either "allow" or a per-tool { "*": "allow" } object.
  • OpenCode reads OPENCODE_CONFIG_CONTENT as an inline-JSON config override — one of its documented config sources, applied after global/project/.opencode config, before only managed/system config.
  • Verified empirically: OPENCODE_CONFIG_CONTENT='{"permission":"allow"}' opencode debug config resolves the merged permission field to {"*":"allow"} — confirmed with and without an existing project opencode.json present.

This lands as an env var, not a config file write, so it needs no path.join, no WSL argv handling, and no local/SSH branching: agentEnv already flows through src/shared/tui-agent-startup.ts into the generic PTY spawn env used uniformly for local, WSL, and SSH-remote launches (the same path goose's GOOSE_MODE already relies on). The payload never appears in the visible launch command — it rides the invisible spawn env only (asserted in tests).

Problem -> Resolution

  • Problem: the issue's own suggested alternative (--config flag or a generated project/global config file) would require host-local file writes and platform-specific path handling, breaking on SSH-remote opencode launches where Orca's main process cannot write to the execution host's filesystem. -> Resolution: use OPENCODE_CONFIG_CONTENT, an inline-JSON env var that opencode itself already supports, riding the existing cross-host agentEnv delivery path with zero new host-specific code.
  • Problem: opencode does expose a --auto CLI flag ("auto-approve permissions that are not explicitly denied") that superficially resembles a YOLO bypass. -> Resolution: not used — the issue explicitly rules out a CLI-flag shape for opencode, and the config-based permission: allow mechanism is documented, verified, and endpoint-agnostic, so it was preferred over the CLI flag.
  • Problem: opencode's permission merge is shallow — if a user's own opencode.json already sets an explicit key (e.g. "bash": "ask"), YOLO's "*":"allow" doesn't override that explicit key. -> Resolution: accepted as opencode's own merge semantics (verified), consistent with how other agents' custom configuration outside Orca's launch layer is respected rather than overridden.

Acceptance Criteria

Criterion Verdict Evidence
YOLO ON: opencode launches without interactive permission prompts ok OPENCODE_CONFIG_CONTENT set to {"permission":"allow"}; verified live against opencode 1.18.23 that this resolves to permission: {"*":"allow"} via opencode debug config
YOLO OFF: current behavior unchanged ok opencode was previously absent from YOLO_TUI_AGENT_ENV; applyAgentPermissionMode({mode:'manual', ...}) resets agentDefaultEnv.opencode to {}, so no env var is set — test: src/shared/tui-agent-permissions.test.ts ("turns opencode yolo off back to an empty env")
Custom user args for opencode still respected ok opencode is not in YOLO_TUI_AGENT_ARGS (only YOLO_TUI_AGENT_ENV), so custom agentArgs (e.g. --agent build) pass through untouched alongside the YOLO env var — test: src/shared/tui-agent-startup-opencode-permission.test.ts ("keeps a custom opencode agent flag alongside the YOLO permission env var")

Files changed

  • src/shared/tui-agent-permissions.ts — add opencode: { OPENCODE_CONFIG_CONTENT } to YOLO_TUI_AGENT_ENV
  • src/shared/tui-agent-permissions.test.ts — opencode-specific permission-mode resolution tests
  • src/shared/tui-agent-startup-opencode-permission.test.ts (new) — startup-plan plumbing tests: env delivered, custom args preserved, payload never leaks into the visible launch command, YOLO-off omits the var entirely

QA Plan

  • Targeted vitest run green: ./node_modules/.bin/vitest run --config config/vitest.config.ts src/shared/tui-agent-permissions.test.ts src/shared/tui-agent-startup.test.ts src/shared/tui-agent-startup-opencode-permission.test.ts — 84 tests passed
  • pnpm run typecheck — passed
  • rtk proxy pnpm run lint — passed (oxlint, type-aware audit, reliability gates, max-lines ratchet, localization checks all green)
  • No user-visible strings changed, so sync:localization-catalog was not needed
  • Manually verified against the real installed opencode binary (1.18.23) that OPENCODE_CONFIG_CONTENT actually resolves to an allow-all permission config, both with and without a competing project opencode.json

opencode models permissions through its JSON config, not a CLI bypass
flag, and its Claude-style flag is already stripped as unsupported.
Deliver an allow-all permission block via OPENCODE_CONFIG_CONTENT (the
agent's own inline-config env var) on the existing YOLO_TUI_AGENT_ENV
path, so it rides the same endpoint-agnostic agentEnv delivery already
used for goose's GOOSE_MODE — no code path needs to know local vs WSL
vs SSH.

Verified against the installed opencode 1.18.23:
  OPENCODE_CONFIG_CONTENT='{"permission":"allow"}' opencode debug config
resolves permission to {"*":"allow"}.

Refs #85
@64ix
64ix merged commit 3bbf4ca into main Aug 26, 2026
12 of 16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YOLO permission mode has no effect on OpenCode launches

1 participant