Add Restore Default Claude CLI button to settings page

Co-authored-by: simon-ami <102378134+simon-ami@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-11 11:54:13 +00:00
parent 66c80452e3
commit 8eba68e47a
5 changed files with 104 additions and 2 deletions

View File

@@ -83,6 +83,35 @@ export async function updateClaudeConfig(updates) {
}
}
/**
* Replace the global Claude CLI configuration entirely
* Unlike updateClaudeConfig, this replaces the config instead of merging.
*
* @param {Object} config - The new configuration to write
* @returns {Promise<Object>} The written configuration
*/
export async function replaceClaudeConfig(config) {
const configPath = getClaudeConfigPath();
// 1. Ensure .claude directory exists
const configDir = path.dirname(configPath);
try {
await fs.mkdir(configDir, { recursive: true });
} catch (error) {
// Ignore if exists
}
// 2. Write config directly (no merge)
try {
await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf8');
logger.info(`[ClaudeConfig] Replaced config at ${configPath}`);
return config;
} catch (error) {
logger.error(`[ClaudeConfig] Failed to write config:`, error.message);
throw error;
}
}
/**
* Simple deep merge for objects
*/