





























@@ -1,5 +1,6 @@
11#!/usr/bin/env node
223+// Runs plugin lifecycle and gateway QA gauntlet probes with timing metrics.
34import { spawn } from "node:child_process";
45import fs from "node:fs";
56import os from "node:os";
@@ -34,6 +35,9 @@ const DEFAULT_QA_PLUGIN_CHUNK_SIZE = 12;
3435const COMMAND_OUTPUT_MAX_BUFFER_BYTES = 16 * 1024 * 1024;
3536const ANSI_PATTERN = new RegExp(String.raw`\u001B\[[0-9;]*m`, "gu");
363738+/**
39+ * Parses plugin gateway gauntlet CLI arguments and env defaults.
40+ */
3741export function parseArgs(argv) {
3842const args = stripLeadingPackageManagerSeparator(argv);
3943const options = {
@@ -226,6 +230,9 @@ function readOptionalNonNegativeIntEnv(name) {
226230return raw ? parseNonNegativeInt(raw, name) : undefined;
227231}
228232233+/**
234+ * Builds the command that prepares QA runtime artifacts before gauntlet probes.
235+ */
229236export function createGauntletPrebuildCommand(repoRoot) {
230237return {
231238command: process.execPath,
@@ -255,6 +262,9 @@ function chunkArray(values, chunkSize) {
255262return chunks;
256263}
257264265+/**
266+ * Converts an output path to a repo-relative path, rejecting paths outside the repo.
267+ */
258268export function toRepoRelativePath(repoRoot, absolutePath) {
259269const relativePath = path.relative(repoRoot, absolutePath);
260270if (!relativePath || relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
@@ -303,6 +313,9 @@ function timeWrapperArgs(command, args) {
303313return { command: "/usr/bin/time", args: ["-v", command, ...args], mode: "gnu" };
304314}
305315316+/**
317+ * Parses `/usr/bin/time` output into wall, CPU, and RSS metrics.
318+ */
306319export function parseTimedMetrics(stderr, wallMs, mode) {
307320let userSeconds = null;
308321let systemSeconds = null;
@@ -374,10 +387,16 @@ function writeCommandLog(params) {
374387return logPath;
375388}
376389390+/**
391+ * Runs a measured command through the live process implementation.
392+ */
377393export async function runMeasuredCommand(params) {
378394return await runMeasuredCommandLive(params);
379395}
380396397+/**
398+ * Runs one command with optional timing wrapper, bounded output, and log capture.
399+ */
381400export function runMeasuredCommandLive(params) {
382401const { command, args, mode } =
383402params.timeMode === "none"
@@ -600,6 +619,9 @@ export function runMeasuredCommandLive(params) {
600619});
601620}
602621622+/**
623+ * Reports whether gauntlet result rows contain work beyond the prebuild step.
624+ */
603625export function hasGauntletWorkRows(rows) {
604626return rows.some((row) => row.phase !== "prebuild");
605627}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。