Skip to content

Commit d6fe15b

Browse files
author
Eric Wheeler
committed
hack: force apply_diff for existing files
1 parent 4619a26 commit d6fe15b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/core/tools/writeToFileTool.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ export async function writeToFileTool(
6969
const fullPath = relPath ? path.resolve(cline.cwd, removeClosingTag("path", relPath)) : ""
7070
const isOutsideWorkspace = isPathOutsideWorkspace(fullPath)
7171

72+
if (fileExists) {
73+
pushToolResult(
74+
formatResponse.toolError(
75+
`File '${relPath}' already exists, write_to_file failed: You must use the 'apply_diff' tool to change an existing file.`,
76+
),
77+
)
78+
return
79+
}
80+
7281
const sharedMessageProps: ClineSayTool = {
7382
tool: fileExists ? "editedExistingFile" : "newFileCreated",
7483
path: getReadablePath(cline.cwd, removeClosingTag("path", relPath)),

0 commit comments

Comments
 (0)