import { existsSync, readFileSync } from "fs"; import { join } from "path"; export interface SkillConfig { ignorePatterns: string[]; smallPackageThreshold: number; llmProvider: "openai" | "kimi" | "pi"; llmModel: string; llmBaseUrl?: string; contextBudget: number; autoInjectPrompt: boolean; tagCap: number; workflowHintCap: number; } export const DEFAULT_CONFIG: SkillConfig = { ignorePatterns: [ "node_modules", ".git", "dist", "build", "coverage", ".next", ".venv", "__pycache__", ".DS_Store", "*.log", ".pi-map.md", ".pi-map.index.md", ".cache", "tmp", "temp", ".tmp", ".turbo", ".parcel-cache", ".eslintcache", ".prettiercache", ], smallPackageThreshold: 10, llmProvider: "openai", llmModel: "gpt-4o-mini", contextBudget: 4000, autoInjectPrompt: true, tagCap: 8, workflowHintCap: 5, }; export function loadConfig(cwd: string = process.cwd()): SkillConfig { const configPath = join(cwd, ".pi-project-map.json"); if (existsSync(configPath)) { try { const content = readFileSync(configPath, "utf8"); const userConfig = JSON.parse(content); return { ...DEFAULT_CONFIG, ...userConfig }; } catch { // Fall through to default } } return DEFAULT_CONFIG; }