openclaw/scripts/vitest-pair-benchmark.mts
Peter Steinberger 9491d5a5a3
refactor(scripts): deslop scripts/lib (#159362)
* refactor(scripts): deslop scripts/lib

Consolidate script lifecycle, scenario, planner, report, release and
packaging helpers while retaining CLI and publication contracts.

Keep config-boundary source caches within one scan so repeated in-process
checks observe edits. Carry extracted helpers through selective fixtures
and iOS scope routing. Leave PR tooling and its library import closure intact.

* fix(scripts): retain sanitizer fast path after helper cleanup

* fix(scripts): model watchdog shell consumer in dead-code checks
2026-09-27 17:13:58 -07:00

56 lines
1.8 KiB
TypeScript

#!/usr/bin/env node
import path from "node:path";
import { fileURLToPath } from "node:url";
import {
assertSingleWorkflowAttempt,
loadBenchmarkManifest,
withTerminalManifest,
} from "./lib/vitest-pair-benchmark-contract.mts";
import { runVitestPairBenchmark } from "./lib/vitest-pair-benchmark.mts";
function parseArgs(argv: string[]) {
const values = new Map<string, string>();
for (let index = 0; index < argv.length; index += 2) {
const name = argv[index];
const value = argv[index + 1];
if (!name?.startsWith("--") || value === undefined) {
throw new Error(`invalid argument near ${name ?? "<end>"}`);
}
values.set(name.slice(2), value);
}
const required = (name: string) => {
const value = values.get(name);
if (!value) {
throw new Error(`--${name} is required`);
}
return value;
};
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
return {
baselineDir: required("baseline"),
baselineSha: required("baseline-sha"),
candidateDir: required("candidate"),
candidateSha: required("candidate-sha"),
manifestPath:
values.get("manifest") ?? path.join(scriptDir, "vitest-pair-benchmark-lanes.json"),
outputDir: required("output"),
pnpmBin: required("pnpm-bin"),
runAttempt: required("run-attempt"),
scratchDir: required("scratch"),
};
}
const options = parseArgs(process.argv.slice(2));
await withTerminalManifest(options.outputDir, async () => {
assertSingleWorkflowAttempt(options.runAttempt);
await runVitestPairBenchmark({
baselineDir: options.baselineDir,
baselineSha: options.baselineSha,
candidateDir: options.candidateDir,
candidateSha: options.candidateSha,
manifest: loadBenchmarkManifest(options.manifestPath),
outputDir: options.outputDir,
pnpmBin: options.pnpmBin,
scratchDir: options.scratchDir,
});
});