From e33d7893694ca583202744b243d5330e0c3ee73e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 28 Jan 2026 12:05:24 +0000 Subject: [PATCH] chore: generate --- packages/opencode/src/cli/cmd/run.ts | 15 ++++++------- packages/opencode/test/cli/auto-mode.test.ts | 22 ++++++++++---------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts index 2c45d5b427..4dfc1c402b 100644 --- a/packages/opencode/src/cli/cmd/run.ts +++ b/packages/opencode/src/cli/cmd/run.ts @@ -91,7 +91,8 @@ export const RunCommand = cmd({ type: "string", describe: "model variant (provider-specific reasoning effort, e.g., high, max, minimal)", }) - .option("auto", { // kilocode_change + .option("auto", { + // kilocode_change type: "boolean", describe: "auto-approve all permissions (for autonomous/pipeline usage)", }) @@ -213,7 +214,7 @@ export const RunCommand = cmd({ if (event.type === "permission.asked") { const permission = event.properties if (permission.sessionID !== sessionID) continue - + // kilocode_change start - In auto mode, automatically approve all permissions without prompting if (args.auto) { await sdk.permission.respond({ @@ -224,7 +225,7 @@ export const RunCommand = cmd({ continue } // kilocode_change end - + const result = await select({ message: `Permission required: ${permission.permission} (${permission.patterns.join(", ")})`, options: [ @@ -315,7 +316,7 @@ export const RunCommand = cmd({ pattern: "*", }, ] - + // kilocode_change start - In auto mode, allow all permissions by default except questions // The question deny rule must come AFTER the wildcard to override it (findLast behavior) const permissions = args.auto @@ -415,11 +416,7 @@ export const RunCommand = cmd({ : undefined const result = await sdk.session.create( - title - ? { title, permission: permissions } - : permissions - ? { permission: permissions } - : {}, + title ? { title, permission: permissions } : permissions ? { permission: permissions } : {}, ) // kilocode_change end return result.data?.id diff --git a/packages/opencode/test/cli/auto-mode.test.ts b/packages/opencode/test/cli/auto-mode.test.ts index 770f58aab2..4fea4aa438 100644 --- a/packages/opencode/test/cli/auto-mode.test.ts +++ b/packages/opencode/test/cli/auto-mode.test.ts @@ -6,7 +6,7 @@ describe("Auto mode flag", () => { // When --auto flag is set, the session should be created with: // 1. Wildcard allow rule for all permissions // 2. Explicit deny rule for questions (to prevent user interaction) - + const autoPermissions = [ { permission: "*", @@ -19,14 +19,14 @@ describe("Auto mode flag", () => { pattern: "*", }, ] - + expect(autoPermissions).toHaveLength(2) - + // First rule: allow all expect(autoPermissions[0].permission).toBe("*") expect(autoPermissions[0].action).toBe("allow") expect(autoPermissions[0].pattern).toBe("*") - + // Second rule: deny questions (comes after wildcard to override it) expect(autoPermissions[1].permission).toBe("question") expect(autoPermissions[1].action).toBe("deny") @@ -36,19 +36,19 @@ describe("Auto mode flag", () => { test("non-auto mode should not set allow-all permissions", () => { // When --auto flag is NOT set, permissions should be undefined or default const normalPermissions = undefined - + expect(normalPermissions).toBeUndefined() }) test("permission evaluation order matters (findLast behavior)", () => { // The permission system uses findLast, so the last matching rule wins // This test verifies that the question deny rule comes AFTER the wildcard - + const autoPermissions = [ { permission: "*", action: "allow" as const, pattern: "*" }, { permission: "question", action: "deny" as const, pattern: "*" }, ] - + // Simulate findLast behavior const findLastMatch = (permission: string) => { for (let i = autoPermissions.length - 1; i >= 0; i--) { @@ -58,18 +58,18 @@ describe("Auto mode flag", () => { } return null } - + // Test that "question" permission resolves to "deny" const questionRule = findLastMatch("question") expect(questionRule?.action).toBe("deny") - + // Test that other permissions resolve to "allow" const bashRule = findLastMatch("bash") expect(bashRule?.action).toBe("allow") - + const editRule = findLastMatch("edit") expect(editRule?.action).toBe("allow") - + const externalDirRule = findLastMatch("external_directory") expect(externalDirRule?.action).toBe("allow") })