fix(acp): include external directory permission context (#30567)

This commit is contained in:
Shoubhit Dash
2026-06-03 19:05:28 +05:30
committed by GitHub
parent fc62b3dc48
commit e707e416ed
5 changed files with 79 additions and 8 deletions

View File

@@ -263,9 +263,14 @@ const parse = Effect.fn("ShellTool.parse")(function* (command: string, ps: boole
return tree
})
const ask = Effect.fn("ShellTool.ask")(function* (ctx: Tool.Context, scan: Scan) {
const ask = Effect.fn("ShellTool.ask")(function* (
ctx: Tool.Context,
scan: Scan,
input: { command: string; description: string },
) {
if (scan.dirs.size > 0) {
const globs = Array.from(scan.dirs).map((dir) => {
const directories = Array.from(scan.dirs)
const globs = directories.map((dir) => {
if (process.platform === "win32") return FSUtil.normalizePathPattern(path.join(dir, "*"))
return path.join(dir, "*")
})
@@ -273,7 +278,12 @@ const ask = Effect.fn("ShellTool.ask")(function* (ctx: Tool.Context, scan: Scan)
permission: "external_directory",
patterns: globs,
always: globs,
metadata: {},
metadata: {
command: input.command,
description: input.description,
directories,
patterns: globs,
},
})
}
@@ -282,7 +292,10 @@ const ask = Effect.fn("ShellTool.ask")(function* (ctx: Tool.Context, scan: Scan)
permission: ShellID.ToolID,
patterns: Array.from(scan.patterns),
always: Array.from(scan.always),
metadata: {},
metadata: {
command: input.command,
description: input.description,
},
})
})
@@ -625,7 +638,7 @@ export const ShellTool = Tool.define(
)
const scan = yield* collect(tree.rootNode, cwd, ps, shell, instanceCtx)
if (!containsPath(cwd, instanceCtx)) scan.dirs.add(cwd)
yield* ask(ctx, scan)
yield* ask(ctx, scan, params)
}),
)