11import { readFileSync , writeFileSync , existsSync } from 'fs' ;
2- import { parse as parseYaml , stringify as yamlStringify } from 'yaml' ;
32import { parseConfigFile , REGIONS , type Config , type ConfigFile , type Region } from './schema' ;
43import { ensureConfigDir , getConfigPath } from './paths' ;
54import { detectOutputFormat , type OutputFormat } from '../output/formatter' ;
@@ -9,15 +8,15 @@ export function readConfigFile(): ConfigFile {
98 const path = getConfigPath ( ) ;
109 if ( ! existsSync ( path ) ) return { } ;
1110 try {
12- return parseConfigFile ( parseYaml ( readFileSync ( path , 'utf-8' ) ) ) ;
11+ return parseConfigFile ( JSON . parse ( readFileSync ( path , 'utf-8' ) ) ) ;
1312 } catch {
1413 return { } ;
1514 }
1615}
1716
1817export async function writeConfigFile ( data : Record < string , unknown > ) : Promise < void > {
1918 await ensureConfigDir ( ) ;
20- writeFileSync ( getConfigPath ( ) , yamlStringify ( data ) , { mode : 0o600 } ) ;
19+ writeFileSync ( getConfigPath ( ) , JSON . stringify ( data , null , 2 ) + '\n' , { mode : 0o600 } ) ;
2120}
2221
2322export function loadConfig ( flags : GlobalFlags ) : Config {
@@ -31,7 +30,6 @@ export function loadConfig(flags: GlobalFlags): Config {
3130 const cachedRegion = file . region ;
3231 const region = ( explicitRegion || cachedRegion || 'global' ) as Region ;
3332
34- // Re-detect if: no explicit region AND (no cached region OR key fingerprint changed)
3533 const activeKey = apiKey || fileApiKey || envApiKey ;
3634 const keyFingerprint = activeKey ? activeKey . slice ( 0 , 8 ) : undefined ;
3735 const needsRegionDetection = ! explicitRegion
0 commit comments