From c4572a25fb8202a02f405c30e6dac0b0bb3163d1 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 9 Feb 2026 11:59:50 +0900 Subject: [PATCH] fix(config-manager): skip string literals when counting braces in JSONC provider replacement --- src/cli/config-manager/add-provider-config.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/cli/config-manager/add-provider-config.ts b/src/cli/config-manager/add-provider-config.ts index a7a195f41..1e49ab49f 100644 --- a/src/cli/config-manager/add-provider-config.ts +++ b/src/cli/config-manager/add-provider-config.ts @@ -61,9 +61,25 @@ export function addProviderConfig(config: InstallConfig): ConfigMergeResult { } else { let depth = 0 let braceEnd = braceStart + let inString = false + let escape = false for (let i = braceStart; i < content.length; i++) { - if (content[i] === "{") depth++ - else if (content[i] === "}") { + const ch = content[i] + if (escape) { + escape = false + continue + } + if (ch === "\\") { + escape = true + continue + } + if (ch === '"') { + inString = !inString + continue + } + if (inString) continue + if (ch === "{") depth++ + else if (ch === "}") { depth-- if (depth === 0) { braceEnd = i