| #!/usr/bin/env tsx |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import path from 'node:path'; |
| import fs from 'node:fs'; |
| import { collectInventory } from './utils/eval-inventory.js'; |
| import { |
| summarizeReports, |
| formatReportSummary, |
| formatReportSummaryJson, |
| } from './utils/eval-report.js'; |
|
|
| async function main() { |
| const args = process.argv.slice(2); |
|
|
| const jsonFlagIndex = args.indexOf('--json'); |
| const jsonMode = jsonFlagIndex !== -1; |
| if (jsonMode) args.splice(jsonFlagIndex, 1); |
|
|
| const rootFlagIndex = args.indexOf('--root'); |
| let repoRoot: string | undefined; |
| if (rootFlagIndex !== -1) { |
| repoRoot = args[rootFlagIndex + 1]; |
| if (repoRoot === undefined || repoRoot.startsWith('--')) { |
| console.error('Error: --root requires a valid directory path.'); |
| process.exit(1); |
| } |
| args.splice(rootFlagIndex, 2); |
| } |
|
|
| const resolvedRoot = repoRoot ? path.resolve(repoRoot) : process.cwd(); |
|
|
| |
| const reportsDirArg = args.find((a) => !a.startsWith('--')); |
| const reportsDir = reportsDirArg |
| ? path.resolve(reportsDirArg) |
| : path.join(resolvedRoot, 'evals', 'logs'); |
|
|
| if (!fs.existsSync(reportsDir)) { |
| console.error(`Error: Reports directory does not exist: ${reportsDir}`); |
| process.exit(1); |
| } |
|
|
| |
| let inventory; |
| try { |
| inventory = await collectInventory(resolvedRoot); |
| } catch { |
| |
| } |
|
|
| const summary = await summarizeReports(reportsDir, inventory); |
|
|
| if (jsonMode) { |
| console.log(formatReportSummaryJson(summary, resolvedRoot)); |
| } else { |
| console.log(formatReportSummary(summary, resolvedRoot)); |
| } |
| } |
|
|
| main().catch((error) => { |
| console.error('Fatal error:', error); |
| process.exit(1); |
| }); |
|
|