diff --git a/package.json b/package.json index 66923b8f2b..7ebb4185ee 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "@inquirer/prompts": "^8.2.1", "commander": "^14.0.2", "firecrawl": "4.24.0", + "strip-json-comments": "^5.0.0", "yaml": "^2.9.0", "zod-to-json-schema": "3.24.6" } diff --git a/src/utils/web-defaults.ts b/src/utils/web-defaults.ts index 1419acf6ac..bcb3df449f 100644 --- a/src/utils/web-defaults.ts +++ b/src/utils/web-defaults.ts @@ -1,6 +1,7 @@ import { promises as fs } from 'fs'; import os from 'os'; import path from 'path'; +import stripJsonComments from 'strip-json-comments'; const CLAUDE_DENY_TOOLS = ['WebSearch', 'WebFetch'] as const; const CODEX_WEB_SEARCH_DISABLED = 'web_search = "disabled"'; @@ -37,12 +38,6 @@ async function writeText(filePath: string, content: string): Promise { await fs.writeFile(filePath, content, 'utf8'); } -function removeJsonComments(content: string): string { - return content - .replace(/\/\*[\s\S]*?\*\//g, '') - .replace(/(^|[^:\\])\/\/.*$/gm, '$1'); -} - async function configureClaudeDefaults( undo: boolean ): Promise { @@ -52,7 +47,7 @@ async function configureClaudeDefaults( if (existing && existing.trim()) { try { - config = JSON.parse(removeJsonComments(existing)); + config = JSON.parse(stripJsonComments(existing)); } catch { return { agent: 'Claude Code',