Skip to content

Commit 25f3eef

Browse files
authored
fix: ensure explore subagent has external_directory perm set to ask instead of auto denying (anomalyco#14060)
1 parent 0ca7554 commit 25f3eef

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/opencode/src/agent/agent.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ export namespace Agent {
5252
const cfg = await Config.get()
5353

5454
const skillDirs = await Skill.dirs()
55+
const whitelistedDirs = [Truncate.GLOB, ...skillDirs.map((dir) => path.join(dir, "*"))]
5556
const defaults = PermissionNext.fromConfig({
5657
"*": "allow",
5758
doom_loop: "ask",
5859
external_directory: {
5960
"*": "ask",
60-
[Truncate.GLOB]: "allow",
61-
...Object.fromEntries(skillDirs.map((dir) => [path.join(dir, "*"), "allow"])),
61+
...Object.fromEntries(whitelistedDirs.map((dir) => [dir, "allow"])),
6262
},
6363
question: "deny",
6464
plan_enter: "deny",
@@ -142,7 +142,8 @@ export namespace Agent {
142142
codesearch: "allow",
143143
read: "allow",
144144
external_directory: {
145-
[Truncate.GLOB]: "allow",
145+
"*": "ask",
146+
...Object.fromEntries(whitelistedDirs.map((dir) => [dir, "allow"])),
146147
},
147148
}),
148149
user,

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ test("explore agent denies edit and write", async () => {
7575
})
7676
})
7777

78+
test("explore agent asks for external directories and allows Truncate.GLOB", async () => {
79+
const { Truncate } = await import("../../src/tool/truncation")
80+
await using tmp = await tmpdir()
81+
await Instance.provide({
82+
directory: tmp.path,
83+
fn: async () => {
84+
const explore = await Agent.get("explore")
85+
expect(explore).toBeDefined()
86+
expect(PermissionNext.evaluate("external_directory", "/some/other/path", explore!.permission).action).toBe("ask")
87+
expect(PermissionNext.evaluate("external_directory", Truncate.GLOB, explore!.permission).action).toBe("allow")
88+
},
89+
})
90+
})
91+
7892
test("general agent denies todo tools", async () => {
7993
await using tmp = await tmpdir()
8094
await Instance.provide({

0 commit comments

Comments
 (0)