* Reads + parses a JSON config. Returns null when the file is simply absent * (ENOENT), but on a real parse failure logs a warning and records the path in * `unparseable` so the caller can surface the corruption instead of silently * misreporting the tech stack as "config absent".
(filePath: string, unparseable?: string[])
| 140 | * misreporting the tech stack as "config absent". |
| 141 | */ |
| 142 | async function readJsonOrNull(filePath: string, unparseable?: string[]): Promise<any> { |
| 143 | try { |
| 144 | return JSON.parse(await fs.readFile(filePath, 'utf-8')); |
| 145 | } catch (err: any) { |
| 146 | if (err?.code !== 'ENOENT') { |
| 147 | logger.warn(`Failed to parse ${filePath}: ${err?.message ?? err}`); |
| 148 | unparseable?.push(filePath); |
| 149 | } |
| 150 | return null; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | export class ProjectOverviewTool extends Tool<z.infer<typeof ProjectOverviewArgs>> { |
| 155 | name = 'project_overview'; |