From 2a3ed89600e4922bbc661491766e75ff33148e8e Mon Sep 17 00:00:00 2001 From: Brian La Plume Date: Wed, 28 Oct 2026 12:14:38 -0700 Subject: [PATCH] refactor(config-protection): build targetPaths without mutation --- scripts/hooks/config-protection.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/hooks/config-protection.js b/scripts/hooks/config-protection.js index a6aa9180e..6adbdfbae 100644 --- a/scripts/hooks/config-protection.js +++ b/scripts/hooks/config-protection.js @@ -172,14 +172,10 @@ function run(inputOrRaw, options = {}) { */ function targetPaths(toolInput) { const shared = toolInput?.file_path || toolInput?.file || ''; - const paths = new Set(); - if (typeof shared === 'string' && shared) paths.add(shared); const edits = Array.isArray(toolInput?.edits) ? toolInput.edits : []; - for (const edit of edits) { - const entryPath = edit && typeof edit === 'object' ? edit.file_path : undefined; - if (typeof entryPath === 'string' && entryPath) paths.add(entryPath); - } - return [...paths]; + const entryPaths = edits.map(edit => (edit && typeof edit === 'object' ? edit.file_path : undefined)); + const candidates = [shared, ...entryPaths].filter(p => typeof p === 'string' && p); + return [...new Set(candidates)]; } function checkTarget(filePath) {