ask instead of throwing tool error if file is outside cwd

This commit is contained in:
Aiden Cline
2025-11-05 16:09:36 -06:00
parent c59ec71918
commit d425723249
4 changed files with 53 additions and 4 deletions

View File

@@ -54,7 +54,19 @@ export const PatchTool = Tool.define("patch", {
const filePath = path.resolve(Instance.directory, hunk.path)
if (!Filesystem.contains(Instance.directory, filePath)) {
throw new Error(`File ${filePath} is not in the current working directory`)
const parentDir = path.dirname(filePath)
await Permission.ask({
type: "external-directory",
pattern: parentDir,
sessionID: ctx.sessionID,
messageID: ctx.messageID,
callID: ctx.callID,
title: `Patch file outside working directory: ${filePath}`,
metadata: {
filepath: filePath,
parentDir,
},
})
}
switch (hunk.type) {