feat(cli): add yolo permission alias

This commit is contained in:
opencode-agent[bot]
2026-06-20 23:27:34 +00:00
parent d99f86b28d
commit 46c75db883
10 changed files with 152 additions and 89 deletions
@@ -72,47 +72,50 @@ Positionals:
message message to send [array] [default: []]
Options:
-h, --help show help [boolean]
-v, --version show version number [boolean]
--print-logs print logs to stderr [boolean]
--log-level log level [string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
--pure run without external plugins [boolean]
--command the command to run, use message for args [string]
-c, --continue continue the last session [boolean]
-s, --session session id to continue [string]
--fork fork the session before continuing (requires --continue or
--session) [boolean]
--share share the session [boolean]
-m, --model model to use in the format of provider/model [string]
--agent agent to use [string]
--format format: default (formatted) or json (raw JSON events)
-h, --help show help [boolean]
-v, --version show version number [boolean]
--print-logs print logs to stderr [boolean]
--log-level log level
[string] [choices: "DEBUG", "INFO", "WARN", "ERROR"]
--pure run without external plugins [boolean]
--command the command to run, use message for args [string]
-c, --continue continue the last session [boolean]
-s, --session session id to continue [string]
--fork fork the session before continuing (requires
--continue or --session) [boolean]
--share share the session [boolean]
-m, --model model to use in the format of provider/model [string]
--agent agent to use [string]
--format format: default (formatted) or json (raw JSON events)
[string] [choices: "default", "json"] [default: "default"]
-f, --file file(s) to attach to message [array]
--title title for the session (uses truncated prompt if no value
provided) [string]
--attach attach to a running opencode server (e.g.,
http://localhost:4096) [string]
-p, --password basic auth password (defaults to OPENCODE_SERVER_PASSWORD)
[string]
-u, --username basic auth username (defaults to OPENCODE_SERVER_USERNAME or
'opencode') [string]
--dir directory to run in, path on remote server if attaching
[string]
--port port for the local server (defaults to random port if no value
provided) [number]
--variant model variant (provider-specific reasoning effort, e.g., high,
max, minimal) [string]
--thinking show thinking blocks [boolean]
--replay replay interactive session history on resume and after resize
(use --no-replay to disable) [boolean] [default: true]
--replay-limit cap visible interactive replay to the newest N messages
[number]
-i, --interactive run in direct interactive split-footer mode
-f, --file file(s) to attach to message [array]
--title title for the session (uses truncated prompt if no
value provided) [string]
--attach attach to a running opencode server (e.g.,
http://localhost:4096) [string]
-p, --password basic auth password (defaults to
OPENCODE_SERVER_PASSWORD) [string]
-u, --username basic auth username (defaults to
OPENCODE_SERVER_USERNAME or 'opencode') [string]
--dir directory to run in, path on remote server if
attaching [string]
--port port for the local server (defaults to random port if
no value provided) [number]
--variant model variant (provider-specific reasoning effort,
e.g., high, max, minimal) [string]
--thinking show thinking blocks [boolean]
--replay replay interactive session history on resume and after
resize (use --no-replay to disable)
[boolean] [default: true]
--replay-limit cap visible interactive replay to the newest N
messages [number]
-i, --interactive run in direct interactive split-footer mode
[boolean] [default: false]
--dangerously-skip-permissions auto-approve permissions that are not explicitly denied
(dangerous!) [boolean] [default: false]
--demo enable direct interactive demo slash commands; pass one as the
message to run it immediately [boolean] [default: false]"
--dangerously-skip-permissions, --yolo auto-approve permissions that are not explicitly
denied (dangerous!) [boolean] [default: false]
--demo enable direct interactive demo slash commands; pass
one as the message to run it immediately
[boolean] [default: false]"
`;
exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode debug --help 1`] = `
@@ -102,6 +102,8 @@ describe("opencode CLI help-text snapshots", () => {
const topLevel = yield* opencode.spawn(["--help"], { env: SNAPSHOT_ENV })
expect(topLevel.exitCode).toBe(0)
expect(topLevel.stderr.endsWith(EOL)).toBe(true)
expect(topLevel.stderr).toContain("--dangerously-skip-permissions")
expect(topLevel.stderr).toContain("--yolo")
const argvs: Array<readonly string[]> = [...TOP_LEVEL.map((c) => [c] as const), ...SUBCOMMANDS]
@@ -14,6 +14,7 @@ describe("RuntimeFlags", () => {
const flags = yield* readFlags.pipe(Effect.provide(fromConfig({})))
expect(flags.autoShare).toBe(false)
expect(flags.dangerouslySkipPermissions).toBe(false)
}),
)
@@ -23,6 +24,7 @@ describe("RuntimeFlags", () => {
Effect.provide(
fromConfig({
OPENCODE_PURE: "true",
OPENCODE_DANGEROUSLY_SKIP_PERMISSIONS: "true",
OPENCODE_DISABLE_DEFAULT_PLUGINS: "true",
OPENCODE_AUTO_SHARE: "true",
OPENCODE_DISABLE_EMBEDDED_WEB_UI: "true",
@@ -39,6 +41,7 @@ describe("RuntimeFlags", () => {
)
expect(flags.pure).toBe(true)
expect(flags.dangerouslySkipPermissions).toBe(true)
expect(flags.autoShare).toBe(true)
expect(flags.disableDefaultPlugins).toBe(true)
expect(flags.disableEmbeddedWebUi).toBe(true)
+45 -7
View File
@@ -11,16 +11,21 @@ import { InstanceStore } from "../../src/project/instance-store"
import { TestInstance, tmpdirScoped } from "../fixture/fixture"
import { testEffect } from "../lib/effect"
import { MessageID, SessionID } from "../../src/session/schema"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
const events = EventV2Bridge.defaultLayer
const noopBootstrap = Layer.succeed(InstanceBootstrap.Service, InstanceBootstrap.Service.of({ run: Effect.void }))
const env = Layer.mergeAll(
Permission.layer.pipe(Layer.provide(Database.defaultLayer), Layer.provide(events)),
events,
CrossSpawnSpawner.defaultLayer,
InstanceStore.defaultLayer.pipe(Layer.provide(noopBootstrap)),
)
const it = testEffect(env)
const makeEnv = (flags: Partial<RuntimeFlags.Info> = {}) => {
const runtimeFlags = RuntimeFlags.layer(flags)
return Layer.mergeAll(
Permission.layer.pipe(Layer.provide(Database.defaultLayer), Layer.provide(events), Layer.provide(runtimeFlags)),
events,
CrossSpawnSpawner.defaultLayer,
InstanceStore.defaultLayer.pipe(Layer.provide(noopBootstrap)),
)
}
const it = testEffect(makeEnv())
const dangerousIt = testEffect(makeEnv({ dangerouslySkipPermissions: true }))
const rejectAll = (message?: string) =>
Effect.gen(function* () {
@@ -613,6 +618,39 @@ it.instance(
{ git: true },
)
dangerousIt.instance(
"ask - resolves ask rules when dangerous permission skipping is enabled",
() =>
ask({
sessionID: SessionID.make("session_test"),
permission: "bash",
patterns: ["ls"],
metadata: {},
always: [],
ruleset: [{ permission: "bash", pattern: "*", action: "ask" }],
}),
{ git: true },
)
dangerousIt.instance(
"ask - preserves deny rules when dangerous permission skipping is enabled",
() =>
Effect.gen(function* () {
const err = yield* fail(
ask({
sessionID: SessionID.make("session_test"),
permission: "bash",
patterns: ["rm -rf /"],
metadata: {},
always: [],
ruleset: [{ permission: "bash", pattern: "*", action: "deny" }],
}),
)
expect(err).toBeInstanceOf(PermissionV1.DeniedError)
}),
{ git: true },
)
it.instance(
"ask - adds request to pending list",
() =>