chore: cleanup external_dir perm logic (#11845)

This commit is contained in:
Aiden Cline
2026-02-02 16:43:55 -06:00
committed by GitHub
parent 5e3162b7f4
commit 188cc24bfc
4 changed files with 53 additions and 16 deletions

View File

@@ -128,7 +128,10 @@ export const BashTool = Tool.define("bash", async () => {
process.platform === "win32" && resolved.match(/^\/[a-z]\//)
? resolved.replace(/^\/([a-z])\//, (_, drive) => `${drive.toUpperCase()}:\\`).replace(/\//g, "\\")
: resolved
if (!Instance.containsPath(normalized)) directories.add(normalized)
if (!Instance.containsPath(normalized)) {
const dir = (await Filesystem.isDir(normalized)) ? normalized : path.dirname(normalized)
directories.add(dir)
}
}
}
}
@@ -141,10 +144,11 @@ export const BashTool = Tool.define("bash", async () => {
}
if (directories.size > 0) {
const globs = Array.from(directories).map((dir) => path.join(dir, "*"))
await ctx.ask({
permission: "external_directory",
patterns: Array.from(directories),
always: Array.from(directories).map((x) => path.dirname(x) + "*"),
patterns: globs,
always: globs,
metadata: {},
})
}