mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 15:19:36 +00:00
111 lines
3.6 KiB
TypeScript
111 lines
3.6 KiB
TypeScript
import { runQaParityReportCommand } from "../extensions/qa-lab/src/cli.runtime.ts";
|
|
|
|
type Options = {
|
|
baselineLabel?: string;
|
|
baselineSummary?: string;
|
|
candidateLabel?: string;
|
|
candidateSummary?: string;
|
|
outputDir?: string;
|
|
repoRoot?: string;
|
|
runtimeAxis?: boolean;
|
|
summary?: string;
|
|
tokenEfficiency?: boolean;
|
|
};
|
|
|
|
function takeValue(args: string[], index: number, flag: string): string {
|
|
const value = args[index + 1];
|
|
if (!value || value.startsWith("-")) {
|
|
throw new Error(`${flag} requires a value.`);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function parseArgs(args: string[]): Options {
|
|
const opts: Options = {};
|
|
for (let index = 0; index < args.length; index += 1) {
|
|
const arg = args[index];
|
|
switch (arg) {
|
|
case "--help":
|
|
case "-h":
|
|
process.stdout.write(`Usage: openclaw qa parity-report [options]
|
|
|
|
Options:
|
|
--candidate-summary <path> Candidate qa-suite-summary.json path
|
|
--baseline-summary <path> Baseline qa-suite-summary.json path
|
|
--candidate-label <label> Candidate display label
|
|
--baseline-label <label> Baseline display label
|
|
--runtime-axis Interpret --summary as a runtime-pair summary
|
|
--summary <path> Runtime-axis qa-suite-summary.json path
|
|
--token-efficiency Also write the runtime token-efficiency report
|
|
--repo-root <path> Repository root to target
|
|
--output-dir <path> Artifact directory for the parity report
|
|
-h, --help Display help
|
|
`);
|
|
process.exit(0);
|
|
case "--baseline-label":
|
|
opts.baselineLabel = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--baseline-summary":
|
|
opts.baselineSummary = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--candidate-label":
|
|
opts.candidateLabel = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--candidate-summary":
|
|
opts.candidateSummary = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--output-dir":
|
|
opts.outputDir = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--repo-root":
|
|
opts.repoRoot = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--runtime-axis":
|
|
opts.runtimeAxis = true;
|
|
break;
|
|
case "--summary":
|
|
opts.summary = takeValue(args, index, arg);
|
|
index += 1;
|
|
break;
|
|
case "--token-efficiency":
|
|
opts.tokenEfficiency = true;
|
|
break;
|
|
default:
|
|
throw new Error(`Unknown qa parity-report option: ${arg}`);
|
|
}
|
|
}
|
|
return opts;
|
|
}
|
|
|
|
const opts = parseArgs(process.argv.slice(2));
|
|
if (opts.runtimeAxis) {
|
|
if (!opts.summary) {
|
|
throw new Error("--summary is required when --runtime-axis is set.");
|
|
}
|
|
} else {
|
|
if (!opts.candidateSummary) {
|
|
throw new Error("--candidate-summary is required.");
|
|
}
|
|
if (!opts.baselineSummary) {
|
|
throw new Error("--baseline-summary is required.");
|
|
}
|
|
}
|
|
|
|
await runQaParityReportCommand({
|
|
...(opts.baselineSummary ? { baselineSummary: opts.baselineSummary } : {}),
|
|
...(opts.candidateSummary ? { candidateSummary: opts.candidateSummary } : {}),
|
|
...(opts.baselineLabel ? { baselineLabel: opts.baselineLabel } : {}),
|
|
...(opts.candidateLabel ? { candidateLabel: opts.candidateLabel } : {}),
|
|
...(opts.outputDir ? { outputDir: opts.outputDir } : {}),
|
|
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
|
|
...(opts.runtimeAxis ? { runtimeAxis: opts.runtimeAxis } : {}),
|
|
...(opts.summary ? { summary: opts.summary } : {}),
|
|
...(opts.tokenEfficiency ? { tokenEfficiency: opts.tokenEfficiency } : {}),
|
|
});
|