(partial: Partial<PlannotatorConfig>)
| 168 | * Creates ~/.plannotator/ directory if needed. |
| 169 | */ |
| 170 | export function saveConfig(partial: Partial<PlannotatorConfig>): void { |
| 171 | try { |
| 172 | const current = loadConfig(); |
| 173 | const mergedDiffOptions = (current.diffOptions || partial.diffOptions) |
| 174 | ? { ...current.diffOptions, ...partial.diffOptions } |
| 175 | : undefined; |
| 176 | const mergedPrompts = mergePromptConfig(current.prompts, partial.prompts); |
| 177 | const merged = { |
| 178 | ...current, |
| 179 | ...partial, |
| 180 | diffOptions: mergedDiffOptions, |
| 181 | prompts: mergedPrompts, |
| 182 | }; |
| 183 | mkdirSync(CONFIG_DIR, { recursive: true }); |
| 184 | writeFileSync(CONFIG_PATH, JSON.stringify(merged, null, 2) + "\n", "utf-8"); |
| 185 | } catch (e) { |
| 186 | process.stderr.write(`[plannotator] Warning: failed to write config.json: ${e}\n`); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Detect the git user name from `git config user.name`. |
no test coverage detected