(opts: {
cwd: string;
signal?: AbortSignal;
timeoutMs?: number;
})
| 224 | * capture must never block the task. |
| 225 | */ |
| 226 | export async function captureBaseline(opts: { |
| 227 | cwd: string; |
| 228 | signal?: AbortSignal; |
| 229 | timeoutMs?: number; |
| 230 | }): Promise<Diagnostic[]> { |
| 231 | try { |
| 232 | const rootFiles = await detectProjectFiles(opts.cwd); |
| 233 | // Baseline EVERY language's checker (one per language), in parallel, so the post-edit |
| 234 | // verify can subtract pre-existing debt for whichever language(s) the model touches. |
| 235 | // Per-file checkers (php -l) are skipped: linting the whole project to baseline is |
| 236 | // costly and near-useless — a working project has no syntax errors, so any the agent |
| 237 | // introduces are by definition new. |
| 238 | const specs = pickCheckers(rootFiles).filter(s => !s.perFile); |
| 239 | if (specs.length === 0) return []; |
| 240 | const timeoutMs = opts.timeoutMs ?? 120_000; |
| 241 | const perChecker = await Promise.all(specs.map(async spec => { |
| 242 | try { |
| 243 | const run = await runChecker(spec.argv, opts.cwd, timeoutMs, opts.signal); |
| 244 | if (run.spawnError || run.code === 127) return [] as Diagnostic[]; |
| 245 | return spec.parse(checkerText(spec, run)); |
| 246 | } catch { |
| 247 | return [] as Diagnostic[]; |
| 248 | } |
| 249 | })); |
| 250 | return perChecker.flat(); |
| 251 | } catch { |
| 252 | return []; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | /** Re-export so callers don't need to import the registry directly. */ |
| 257 | export { CHECKERS }; |
no test coverage detected