(newSettings: Partial<Settings>)
| 125 | * Save settings to file system (merges with existing settings) |
| 126 | */ |
| 127 | export const saveSettings = (newSettings: Partial<Settings>): void => { |
| 128 | const settingsPath = getSettingsPath() |
| 129 | |
| 130 | try { |
| 131 | ensureConfigDirExists() |
| 132 | |
| 133 | // Load existing settings and merge |
| 134 | const existingSettings = loadSettings() |
| 135 | const mergedSettings = { ...existingSettings, ...newSettings } |
| 136 | |
| 137 | fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2)) |
| 138 | } catch (error) { |
| 139 | logger.debug( |
| 140 | { |
| 141 | error: error instanceof Error ? error.message : String(error), |
| 142 | }, |
| 143 | 'Error saving settings', |
| 144 | ) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Load the saved agent mode preference |
no test coverage detected