| 20 | * @returns Plugin configuration |
| 21 | */ |
| 22 | export function loadPluginConfig(): PluginConfig { |
| 23 | try { |
| 24 | if (!existsSync(CONFIG_PATH)) { |
| 25 | return DEFAULT_CONFIG; |
| 26 | } |
| 27 | |
| 28 | const fileContent = readFileSync(CONFIG_PATH, "utf-8"); |
| 29 | const userConfig = JSON.parse(fileContent) as Partial<PluginConfig>; |
| 30 | |
| 31 | // Merge with defaults |
| 32 | return { |
| 33 | ...DEFAULT_CONFIG, |
| 34 | ...userConfig, |
| 35 | }; |
| 36 | } catch (error) { |
| 37 | console.warn( |
| 38 | `[arctic-codex-plugin] Failed to load config from ${CONFIG_PATH}:`, |
| 39 | (error as Error).message |
| 40 | ); |
| 41 | return DEFAULT_CONFIG; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Get the effective CODEX_MODE setting |