fix: gate edit_file by diffEnabled

This commit is contained in:
Hannes Rudolph 2025-12-21 18:55:49 -07:00
parent 33f3e402e5
commit 172dd91a19
2 changed files with 15 additions and 1 deletions

View file

@ -751,7 +751,16 @@ export async function presentAssistantMessage(cline: Task) {
block.name as ToolName,
mode ?? defaultModeSlug,
customModes ?? [],
{ apply_diff: cline.diffEnabled },
{
// diffEnabled should gate ALL edit operations (both XML legacy apply_diff and native edit_file)
apply_diff: cline.diffEnabled,
edit_file: cline.diffEnabled,
edit_file_roo: cline.diffEnabled,
edit_file_anthropic: cline.diffEnabled,
edit_file_grok: cline.diffEnabled,
edit_file_gemini: cline.diffEnabled,
edit_file_codex: cline.diffEnabled,
},
block.params,
stateExperiments,
includedTools,

View file

@ -167,6 +167,11 @@ describe("mode-validator", () => {
// Even in code mode which allows all tools, disabled requirement should take precedence
expect(isToolAllowedForMode("write_to_file", codeMode, [], requirements)).toBe(false)
})
it("can gate native unified edit tool (edit_file)", () => {
const requirements = { edit_file: false }
expect(isToolAllowedForMode("edit_file", codeMode, [], requirements)).toBe(false)
})
})
})