From dd52a4a39cb225088aa366f03d8bccfa886af392 Mon Sep 17 00:00:00 2001 From: canvrno <46584286+canvrno@users.noreply.github.com> Date: Tue, 2 Dec 2025 15:36:01 -0800 Subject: [PATCH] feat: apply_patch auto approve (#7777) * Added apply_patch to auto approve, strict mode, and minor prompting adjustment * changeset --- .changeset/chubby-lions-mix.md | 5 +++++ src/core/prompts/system-prompt/tools/apply_patch.ts | 4 +++- src/core/task/ToolExecutor.ts | 1 + src/core/task/tools/autoApprove.ts | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/chubby-lions-mix.md diff --git a/.changeset/chubby-lions-mix.md b/.changeset/chubby-lions-mix.md new file mode 100644 index 00000000..334fa4ab --- /dev/null +++ b/.changeset/chubby-lions-mix.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Added apply_patch to auto approve, strict mode, and minor prompting adjustment diff --git a/src/core/prompts/system-prompt/tools/apply_patch.ts b/src/core/prompts/system-prompt/tools/apply_patch.ts index 6f7e1eea..024127c5 100644 --- a/src/core/prompts/system-prompt/tools/apply_patch.ts +++ b/src/core/prompts/system-prompt/tools/apply_patch.ts @@ -30,7 +30,9 @@ EOF Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format. *** [ACTION] File: [path/to/file] -> ACTION can be one of Add, Update, or Delete. -For each snippet of code that needs to be changed, repeat the following: + +In a Add File section, every line of the new file (including blank/empty lines) MUST start with a \`+\` prefix. Do not include any unprefixed lines inside an Add section +In a Update/Delete section, repeat the following for each snippet of code that needs to be changed: [context_before] -> See below for further instructions on context. - [old_code] -> Precede the old code with a minus sign. + [new_code] -> Precede the new, replacement code with a plus sign. diff --git a/src/core/task/ToolExecutor.ts b/src/core/task/ToolExecutor.ts index 647e5359..3728f7cb 100644 --- a/src/core/task/ToolExecutor.ts +++ b/src/core/task/ToolExecutor.ts @@ -302,6 +302,7 @@ export class ToolExecutor { ClineDefaultTool.FILE_NEW, ClineDefaultTool.FILE_EDIT, ClineDefaultTool.NEW_RULE, + ClineDefaultTool.APPLY_PATCH, ] /** diff --git a/src/core/task/tools/autoApprove.ts b/src/core/task/tools/autoApprove.ts index 4346a1ce..889dfc99 100644 --- a/src/core/task/tools/autoApprove.ts +++ b/src/core/task/tools/autoApprove.ts @@ -49,6 +49,7 @@ export class AutoApprove { case ClineDefaultTool.NEW_RULE: case ClineDefaultTool.FILE_NEW: case ClineDefaultTool.FILE_EDIT: + case ClineDefaultTool.APPLY_PATCH: case ClineDefaultTool.BASH: return [true, true] @@ -71,6 +72,7 @@ export class AutoApprove { case ClineDefaultTool.NEW_RULE: case ClineDefaultTool.FILE_NEW: case ClineDefaultTool.FILE_EDIT: + case ClineDefaultTool.APPLY_PATCH: return [autoApprovalSettings.actions.editFiles, autoApprovalSettings.actions.editFilesExternally ?? false] case ClineDefaultTool.BASH: return [