import { existsSync, readFileSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; /** Same file Kimchi CLI uses (~/.config/kimchi/config.json). */ export function readKimchiCliApiKey(): string | undefined { const path = join(homedir(), ".config", "kimchi", "config.json"); if (!existsSync(path)) return undefined; try { const raw = JSON.parse(readFileSync(path, "utf-8")) as { apiKey?: string }; const key = raw.apiKey?.trim(); return key || undefined; } catch { return undefined; } }