mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 22:32:28 +00:00
ask instead of throwing tool error if file is outside cwd
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user