import { homedir } from "os" import { join } from "path" /** Read the ANTHROPIC_API_KEY from ~/.env. Returns undefined if not found. */ export async function getApiKey(): Promise { const envFile = Bun.file(join(homedir(), ".env")) if (!(await envFile.exists())) return undefined const envContent = await envFile.text() return envContent.match(/^(?:export\s+)?ANTHROPIC_API_KEY=["']?([^"'\s]+)["']?/m)?.[1] }