Skip to content

Commit 66994bd

Browse files
Apply PR #12633: feat(tui): add auto-accept mode for permission requests
2 parents 0136500 + 5792a80 commit 66994bd

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

packages/opencode/src/agent/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const layer = Layer.effect(
9494
question: "deny",
9595
plan_enter: "deny",
9696
plan_exit: "deny",
97+
edit: "ask",
9798
// mirrors github.com/github/gitignore Node.gitignore pattern for .env files
9899
read: {
99100
"*": "allow",

packages/opencode/src/cli/cmd/run.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ export const RunCommand = cmd({
367367
action: "deny",
368368
pattern: "*",
369369
},
370+
{
371+
permission: "edit",
372+
action: "allow",
373+
pattern: "*",
374+
},
370375
]
371376

372377
function title() {

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function Prompt(props: PromptProps) {
106106
const renderer = useRenderer()
107107
const { theme, syntax } = useTheme()
108108
const kv = useKV()
109+
const [autoaccept, setAutoaccept] = kv.signal<"none" | "edit">("permission_auto_accept", "edit")
109110
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
110111
const list = createMemo(() => props.placeholders?.normal ?? [])
111112
const shell = createMemo(() => props.placeholders?.shell ?? [])
@@ -1226,6 +1227,11 @@ export function Prompt(props: PromptProps) {
12261227
{props.right}
12271228
</box>
12281229
</Show>
1230+
<Show when={autoaccept() === "edit"}>
1231+
<text>
1232+
<span style={{ fg: theme.warning }}>autoedit</span>
1233+
</text>
1234+
</Show>
12291235
</box>
12301236
</box>
12311237
</box>

packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface DialogSelectOption<T = any> {
3737
title: string
3838
value: T
3939
description?: string
40+
search?: string
4041
footer?: JSX.Element | string
4142
category?: string
4243
categoryView?: JSX.Element
@@ -93,8 +94,8 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
9394
// users typically search by the item name, and not its category.
9495
const result = fuzzysort
9596
.go(needle, options, {
96-
keys: ["title", "category"],
97-
scoreFn: (r) => r[0].score * 2 + r[1].score,
97+
keys: ["title", "category", "search"],
98+
scoreFn: (r) => r[0].score * 2 + r[1].score + r[2].score,
9899
})
99100
.map((x) => x.obj)
100101

packages/opencode/test/agent/agent.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ test("agent permission config merges with defaults", async () => {
224224
expect(build).toBeDefined()
225225
// Specific pattern is denied
226226
expect(Permission.evaluate("bash", "rm -rf *", build!.permission).action).toBe("deny")
227-
// Edit still allowed
228-
expect(evalPerm(build, "edit")).toBe("allow")
227+
// Edit still asks (default behavior)
228+
expect(evalPerm(build, "edit")).toBe("ask")
229229
},
230230
})
231231
})

0 commit comments

Comments
 (0)