@decocms/parity 0.35.26 → 0.35.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cli.js +430 -91
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -41,6 +41,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
41
41
  * **Determinism test**: the same recording replayed twice must give identical checks, issues
42
42
  (ids, severity, details, evidence), verdict and score, order included; the corpus suite repeats
43
43
  that for every case.
44
+ * **`parity run --golden <dir>`** uses the prod half of a `--record` recording as the reference
45
+ and captures only cand (`--prod` optional). Prod is not contacted at all: pages, flows, visual
46
+ probes and the resolved config come from the recording, cand is captured at exactly the
47
+ recording's page keys, and prod-origin `fetch` calls made by checks are served only from its
48
+ fetch log. A prod request the recording never saw is reported as `golden.staleRequests` in
49
+ `report.json` and exits 2. Validation (other prod origin, missing viewports, uncovered check
50
+ selection, empty golden, `--pages` outside the golden) exits 2 before any browser work. Recordings
51
+ now also carry the detected `platform` (optional; older recordings still load). See
52
+ `docs/cli.md`.
44
53
 
45
54
  ### Fixed
46
55
 
package/dist/cli.js CHANGED
@@ -90497,6 +90497,7 @@ var PageCapture = z2.object({
90497
90497
  tracePath: z2.string().optional(),
90498
90498
  xRobotsTag: z2.string().nullable().optional(),
90499
90499
  pairKey: z2.string().optional(),
90500
+ pass: z2.enum(["extra", "visual"]).optional(),
90500
90501
  variant: VariantFingerprint.optional()
90501
90502
  });
90502
90503
  var StepCapture = z2.object({
@@ -90855,6 +90856,12 @@ var Run = z2.object({
90855
90856
  cand: z2.object({ cookies: z2.array(z2.string()), headers: z2.array(z2.string()) })
90856
90857
  }).optional(),
90857
90858
  pagePairs: z2.array(PagePairMeasurement).optional(),
90859
+ golden: z2.object({
90860
+ dir: z2.string(),
90861
+ recordedAt: z2.string(),
90862
+ parityVersion: z2.string().optional(),
90863
+ staleRequests: z2.array(z2.string()).optional()
90864
+ }).optional(),
90858
90865
  timings: z2.object({
90859
90866
  totalMs: z2.number(),
90860
90867
  phases: z2.array(z2.object({ phase: z2.string(), durationMs: z2.number() }))
@@ -117487,13 +117494,13 @@ function planTouchCommand(dir, page, opts) {
117487
117494
  }
117488
117495
 
117489
117496
  // src/commands/pr.ts
117490
- import { existsSync as existsSync31, readFileSync as readFileSync40, writeFileSync as writeFileSync33 } from "node:fs";
117491
- import { join as join46 } from "node:path";
117497
+ import { existsSync as existsSync32, readFileSync as readFileSync40, writeFileSync as writeFileSync33 } from "node:fs";
117498
+ import { join as join47 } from "node:path";
117492
117499
  import chalk35 from "chalk";
117493
117500
 
117494
117501
  // src/commands/run.ts
117495
- import { existsSync as existsSync30, readFileSync as readFileSync39, rmSync as rmSync5 } from "node:fs";
117496
- import { join as join45 } from "node:path";
117502
+ import { existsSync as existsSync31, readFileSync as readFileSync39, rmSync as rmSync5 } from "node:fs";
117503
+ import { join as join46, resolve as resolve21 } from "node:path";
117497
117504
  import chalk34 from "chalk";
117498
117505
  import ora8 from "ora";
117499
117506
 
@@ -117564,6 +117571,7 @@ var RecordedContext = z4.object({
117564
117571
  viewports: z4.array(Viewport),
117565
117572
  candIsProduction: z4.boolean().optional(),
117566
117573
  checkNames: z4.array(z4.string()).optional(),
117574
+ platform: z4.string().optional(),
117567
117575
  visualProbes: z4.array(z4.tuple([z4.string(), CaptureResultSchema])).optional(),
117568
117576
  missingFiles: z4.array(MissingFile),
117569
117577
  omittedArtifacts: z4.object({ har: z4.number(), trace: z4.number(), video: z4.number() })
@@ -117585,7 +117593,7 @@ function saveCheckContext(dir, ctx, meta) {
117585
117593
  const missing = [];
117586
117594
  const omitted = { har: 0, trace: 0, video: 0 };
117587
117595
  let n = 0;
117588
- const rel = (p) => {
117596
+ const rel = (p, expectedAbsent = false) => {
117589
117597
  if (p === "")
117590
117598
  return "";
117591
117599
  const hit = copied.get(p);
@@ -117594,7 +117602,7 @@ function saveCheckContext(dir, ctx, meta) {
117594
117602
  const dest = `files/${String(++n).padStart(4, "0")}-${basename5(p)}`;
117595
117603
  if (existsSync29(p))
117596
117604
  copyFileSync(p, join44(dir, dest));
117597
- else
117605
+ else if (!expectedAbsent)
117598
117606
  missing.push({ path: dest, original: p });
117599
117607
  copied.set(p, dest);
117600
117608
  return dest;
@@ -117606,7 +117614,7 @@ function saveCheckContext(dir, ctx, meta) {
117606
117614
  omitted.har++;
117607
117615
  if (tracePath)
117608
117616
  omitted.trace++;
117609
- return { ...rest, screenshotPath: rel(c.screenshotPath) };
117617
+ return { ...rest, screenshotPath: rel(c.screenshotPath, c.pass === "extra") };
117610
117618
  };
117611
117619
  const step = (s) => {
117612
117620
  const { tracePath, screenshotBeforePath, ...rest } = s;
@@ -117631,6 +117639,7 @@ function saveCheckContext(dir, ctx, meta) {
117631
117639
  prodUrl: meta.prodUrl,
117632
117640
  candUrl: meta.candUrl,
117633
117641
  ...meta.checkNames ? { checkNames: meta.checkNames } : {},
117642
+ ...meta.platform ? { platform: meta.platform } : {},
117634
117643
  prodPages: ctx.prodPages.map(page),
117635
117644
  candPages: ctx.candPages.map(page),
117636
117645
  prodFlows: ctx.prodFlows.map(flow),
@@ -117707,6 +117716,7 @@ function loadCheckContext(dir) {
117707
117716
  candUrl: r.candUrl,
117708
117717
  recordedAt: r.recordedAt,
117709
117718
  ...r.checkNames ? { checkNames: r.checkNames } : {},
117719
+ ...r.platform ? { platform: r.platform } : {},
117710
117720
  ...r.parityVersion ? { parityVersion: r.parityVersion } : {}
117711
117721
  },
117712
117722
  fetchLog,
@@ -118140,6 +118150,253 @@ function checkToJsonl(runId, check) {
118140
118150
  };
118141
118151
  }
118142
118152
 
118153
+ // src/engine/golden.ts
118154
+ import { copyFileSync as copyFileSync2, existsSync as existsSync30, mkdirSync as mkdirSync24 } from "node:fs";
118155
+ import { basename as basename6, join as join45 } from "node:path";
118156
+ var GOLDEN_STALE_AFTER_DAYS = 7;
118157
+ var isVisualPage = (p) => p.pass === "visual";
118158
+ var isExtraPage = (p) => p.pass === "extra";
118159
+ function pathname(url) {
118160
+ try {
118161
+ return new URL(url).pathname || "/";
118162
+ } catch {
118163
+ return url;
118164
+ }
118165
+ }
118166
+ function pathAndQuery(url) {
118167
+ try {
118168
+ const u = new URL(url);
118169
+ return (u.pathname || "/") + u.search;
118170
+ } catch {
118171
+ return url;
118172
+ }
118173
+ }
118174
+ var pairKeyOf = (p) => p.pairKey ?? pathAndQuery(p.url);
118175
+ function originOf2(url) {
118176
+ try {
118177
+ return new URL(url).origin;
118178
+ } catch {
118179
+ return null;
118180
+ }
118181
+ }
118182
+ function loadGolden(dir) {
118183
+ try {
118184
+ return { rec: loadCheckContext(dir) };
118185
+ } catch (err) {
118186
+ return { error: `--golden ${dir}: ${err.message}` };
118187
+ }
118188
+ }
118189
+ function planGoldenRun(rec, input) {
118190
+ const errors = [];
118191
+ const warnings = [];
118192
+ const plan = {
118193
+ errors,
118194
+ warnings,
118195
+ visualPaths: [],
118196
+ visualKeys: new Set,
118197
+ extraPaths: [],
118198
+ viewports: new Set(input.viewports),
118199
+ flows: new Set(input.flows)
118200
+ };
118201
+ const { prodPages, candPages, prodFlows, viewports: goldenViewports } = rec.ctx;
118202
+ if (input.prod !== undefined) {
118203
+ const asked = originOf2(input.prod);
118204
+ const held = originOf2(rec.meta.prodUrl);
118205
+ if (asked !== held) {
118206
+ errors.push(`--prod ${input.prod} is not the golden's prod (${rec.meta.prodUrl}): the recording is a capture of a different site. Drop --prod, or record a golden of that site.`);
118207
+ }
118208
+ }
118209
+ const missingViewports = input.viewports.filter((v) => !goldenViewports.includes(v));
118210
+ if (missingViewports.length > 0) {
118211
+ errors.push(`the golden holds viewport(s) ${goldenViewports.join(", ") || "(none)"} but this run asks for ${missingViewports.join(", ")}`);
118212
+ }
118213
+ if (rec.meta.checkNames) {
118214
+ const recorded = new Set(rec.meta.checkNames);
118215
+ const wanted = input.checkNames ?? new Set(Object.keys(ALL_CHECKS_BY_NAME));
118216
+ const uncovered = [...wanted].filter((n) => !recorded.has(n)).sort();
118217
+ if (uncovered.length > 0) {
118218
+ errors.push(`the golden was recorded with a check selection that does not cover ${uncovered.length} check(s) this run executes (${uncovered.join(", ")}); narrow --only/--skip or record a new golden`);
118219
+ }
118220
+ }
118221
+ if (prodPages.length === 0 && prodFlows.length === 0) {
118222
+ errors.push("the golden holds no prod pages and no prod flows: there is nothing to compare against");
118223
+ return plan;
118224
+ }
118225
+ const inFlow = new Set(prodFlows.flatMap((f) => f.pages.map((p) => `${p.viewport} ${p.url} ${p.screenshotPath}`)));
118226
+ const outsideFlows = prodPages.filter((p) => !inFlow.has(`${p.viewport} ${p.url} ${p.screenshotPath}`));
118227
+ if (outsideFlows.length > 0 && !prodPages.some((p) => p.pass !== undefined)) {
118228
+ errors.push("the golden was recorded before the capture pass was stored on each page; record it again");
118229
+ return plan;
118230
+ }
118231
+ const inRun = (p) => plan.viewports.has(p.viewport);
118232
+ if (input.visualPagesLimit > 0) {
118233
+ const goldenVisual = prodPages.filter((p) => isVisualPage(p) && inRun(p));
118234
+ const candPathByKey = new Map;
118235
+ for (const c of candPages) {
118236
+ if (isVisualPage(c) && !candPathByKey.has(pairKeyOf(c))) {
118237
+ candPathByKey.set(pairKeyOf(c), pathAndQuery(c.url));
118238
+ }
118239
+ }
118240
+ const keys = [...new Set(goldenVisual.map(pairKeyOf))];
118241
+ if (input.explicitPages) {
118242
+ const held = new Set(keys);
118243
+ const missing = input.explicitPages.filter((e) => !held.has(e.prod)).map((e) => e.prod);
118244
+ if (missing.length > 0) {
118245
+ errors.push(`the golden holds no prod capture for --pages path(s): ${missing.join(", ")} (it holds: ${keys.join(", ") || "none"}). Record a new golden that includes them.`);
118246
+ } else {
118247
+ plan.visualPaths = input.explicitPages;
118248
+ }
118249
+ } else {
118250
+ plan.visualPaths = keys.slice(0, input.visualPagesLimit).map((k) => ({ prod: k, cand: candPathByKey.get(k) ?? k }));
118251
+ }
118252
+ plan.visualKeys = new Set(plan.visualPaths.map((p) => p.prod));
118253
+ if (plan.visualKeys.size === 0 && errors.length === 0) {
118254
+ warnings.push("the golden holds no visual-pass pages (recorded with --no-visual-diff?): the visual check will be inconclusive");
118255
+ }
118256
+ }
118257
+ if (input.vitalsPagesLimit > 0) {
118258
+ const paths = prodPages.filter((p) => isExtraPage(p) && inRun(p)).map((p) => pathname(p.url));
118259
+ plan.extraPaths = [...new Set(paths)].slice(0, input.vitalsPagesLimit);
118260
+ }
118261
+ const heldFlows = new Set(prodFlows.map((f) => f.flow));
118262
+ const noProdFlow = input.flows.filter((f) => !heldFlows.has(f));
118263
+ if (noProdFlow.length > 0) {
118264
+ warnings.push(`the golden has no prod capture of flow(s) ${noProdFlow.join(", ")}: the cand side of each is reported as unpaired`);
118265
+ }
118266
+ return plan;
118267
+ }
118268
+ function makeRelocator(destDir) {
118269
+ const done = new Map;
118270
+ const taken = new Set;
118271
+ return (p) => {
118272
+ if (p === "")
118273
+ return p;
118274
+ const hit = done.get(p);
118275
+ if (hit !== undefined)
118276
+ return hit;
118277
+ let out = p;
118278
+ if (existsSync30(p)) {
118279
+ mkdirSync24(destDir, { recursive: true });
118280
+ const name = basename6(p).replace(/^\d{4}-/, "");
118281
+ const dot = name.lastIndexOf(".");
118282
+ const stem = dot > 0 ? name.slice(0, dot) : name;
118283
+ const ext = dot > 0 ? name.slice(dot) : "";
118284
+ let candidate = name;
118285
+ for (let n = 2;taken.has(candidate); n++)
118286
+ candidate = `${stem}-${n}${ext}`;
118287
+ taken.add(candidate);
118288
+ out = join45(destDir, candidate);
118289
+ copyFileSync2(p, out);
118290
+ }
118291
+ done.set(p, out);
118292
+ return out;
118293
+ };
118294
+ }
118295
+ function mergeGoldenContext(rec, plan, live, relocate) {
118296
+ const extraKept = (p) => plan.extraPaths.includes(pathname(p.url));
118297
+ const keepPage = (p) => {
118298
+ if (!plan.viewports.has(p.viewport))
118299
+ return false;
118300
+ if (isExtraPage(p))
118301
+ return extraKept(p);
118302
+ if (isVisualPage(p))
118303
+ return plan.visualKeys.has(pairKeyOf(p));
118304
+ return true;
118305
+ };
118306
+ const page = (p) => ({
118307
+ ...p,
118308
+ screenshotPath: relocate(p.screenshotPath)
118309
+ });
118310
+ const step = (s) => ({
118311
+ ...s,
118312
+ screenshotPath: relocate(s.screenshotPath),
118313
+ ...s.screenshotBeforePath !== undefined ? { screenshotBeforePath: relocate(s.screenshotBeforePath) } : {}
118314
+ });
118315
+ const keepFlow = (f) => {
118316
+ if (!plan.viewports.has(f.viewport))
118317
+ return false;
118318
+ const only = f.pages.length === 1 ? f.pages[0] : undefined;
118319
+ if (only && isExtraPage(only))
118320
+ return extraKept(only);
118321
+ return plan.flows.has(f.flow);
118322
+ };
118323
+ const keptPages = rec.ctx.prodPages.filter(keepPage);
118324
+ const pages = [...keptPages.map(page), ...live.pages];
118325
+ const flows = [
118326
+ ...rec.ctx.prodFlows.filter(keepFlow).map((f) => ({
118327
+ ...f,
118328
+ pages: f.pages.map(page),
118329
+ ...f.steps ? { steps: f.steps.map(step) } : {}
118330
+ })),
118331
+ ...live.flows
118332
+ ];
118333
+ let visualProbes;
118334
+ if (live.visualProbes) {
118335
+ visualProbes = new Map;
118336
+ const keptShots = new Set(keptPages.filter(isVisualPage).map((p) => p.screenshotPath));
118337
+ for (const [k, v] of rec.ctx.visualProbes ?? []) {
118338
+ if (!keptShots.has(k))
118339
+ continue;
118340
+ visualProbes.set(relocate(k), {
118341
+ ...v,
118342
+ side: { ...v.side, screenshot: v.side.screenshot ? relocate(v.side.screenshot) : null },
118343
+ repeatScreenshot: v.repeatScreenshot ? relocate(v.repeatScreenshot) : null
118344
+ });
118345
+ }
118346
+ for (const [k, v] of live.visualProbes)
118347
+ visualProbes.set(k, v);
118348
+ }
118349
+ return { pages, flows, visualProbes };
118350
+ }
118351
+ function goldenPlatform(rec) {
118352
+ if (rec.meta.platform)
118353
+ return rec.meta.platform;
118354
+ const home = rec.ctx.prodPages.find((p) => p.html && pathname(p.url) === "/");
118355
+ return home?.html ? detectPlatform({ url: rec.meta.prodUrl, html: home.html }) : "custom";
118356
+ }
118357
+ function installGoldenFetch(log, prodOrigin) {
118358
+ const orig = globalThis.fetch;
118359
+ const replay = createReplayFetch(log);
118360
+ const stale = new Set;
118361
+ const mine = async (input, init) => {
118362
+ const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
118363
+ if (originOf2(raw) !== prodOrigin)
118364
+ return orig(input, init);
118365
+ try {
118366
+ return await replay(input, init);
118367
+ } catch (err) {
118368
+ if (err instanceof UnrecordedFetchError) {
118369
+ stale.add(err.message.replace(/^replay: /, "").replace(/ was not made during the recorded run$/, ""));
118370
+ }
118371
+ throw err;
118372
+ }
118373
+ };
118374
+ globalThis.fetch = mine;
118375
+ return {
118376
+ stale: () => [...stale].sort(),
118377
+ restore: () => {
118378
+ if (globalThis.fetch === mine)
118379
+ globalThis.fetch = orig;
118380
+ }
118381
+ };
118382
+ }
118383
+ function goldenAge(recordedAt, now = Date.now()) {
118384
+ const ms = now - Date.parse(recordedAt);
118385
+ if (!Number.isFinite(ms))
118386
+ return { text: "age unknown", warn: true };
118387
+ const hours = Math.max(0, ms) / 3600000;
118388
+ const text = hours < 48 ? `${Math.round(hours)}h old` : `${Math.round(hours / 24)} days old`;
118389
+ return { text, warn: hours / 24 > GOLDEN_STALE_AFTER_DAYS };
118390
+ }
118391
+ function goldenReportField(dir, meta, stale) {
118392
+ return {
118393
+ dir,
118394
+ recordedAt: meta.recordedAt,
118395
+ ...meta.parityVersion ? { parityVersion: meta.parityVersion } : {},
118396
+ ...stale.length > 0 ? { staleRequests: stale } : {}
118397
+ };
118398
+ }
118399
+
118143
118400
  // src/util/heartbeat.ts
118144
118401
  function startHeartbeat(opts) {
118145
118402
  const intervalMs = opts.intervalMs ?? 30000;
@@ -118590,7 +118847,14 @@ function readRunChecks(reportPath) {
118590
118847
  }
118591
118848
  }
118592
118849
  async function runCommand(rawOpts) {
118593
- if (!rawOpts.prod) {
118850
+ const goldenLoaded = rawOpts.golden ? loadGolden(rawOpts.golden) : undefined;
118851
+ if (goldenLoaded && "error" in goldenLoaded) {
118852
+ console.error(chalk34.red(` ${goldenLoaded.error}`));
118853
+ return 2;
118854
+ }
118855
+ const goldenRec = goldenLoaded?.rec;
118856
+ const userProd = rawOpts.prod;
118857
+ if (!rawOpts.prod && !goldenRec) {
118594
118858
  const target = rawOpts.cand ?? "<url>";
118595
118859
  console.error(`${chalk34.yellow("Single-site run?")} \`parity run\` compares two URLs (prod↔cand).
118596
118860
  For one site, use: ${chalk34.cyan(`parity e2e --url ${target}`)}
@@ -118598,6 +118862,8 @@ async function runCommand(rawOpts) {
118598
118862
  return 2;
118599
118863
  }
118600
118864
  const opts = applyPreset(rawOpts);
118865
+ if (goldenRec)
118866
+ opts.prod = goldenRec.meta.prodUrl;
118601
118867
  if (opts.record) {
118602
118868
  try {
118603
118869
  assertRecordDirFree(opts.record);
@@ -118649,6 +118915,8 @@ async function runCommand(rawOpts) {
118649
118915
  let profile;
118650
118916
  if (opts.profile === "commerce" || opts.profile === "content") {
118651
118917
  profile = opts.profile;
118918
+ } else if (goldenRec) {
118919
+ profile = goldenRec.ctx.rc.profile ?? "commerce";
118652
118920
  } else {
118653
118921
  const pv = opts.viewports.split(",")[0]?.trim() || "mobile";
118654
118922
  earlyProdHtml = await fetchHomeHtml(opts.prod, pv, pinFetchHeaders(pins.prod));
@@ -118708,7 +118976,41 @@ async function runCommand(rawOpts) {
118708
118976
  }
118709
118977
  const viewports = opts.viewports.split(",").map((s) => s.trim());
118710
118978
  const failOn = opts.failOn.split(",").map((s) => s.trim()).filter(Boolean);
118711
- const rc = loadParityRc();
118979
+ let explicitForGolden = null;
118980
+ if (goldenRec) {
118981
+ try {
118982
+ explicitForGolden = resolveExplicitPages(opts.pagesFile, opts.pages);
118983
+ } catch (err) {
118984
+ console.error(chalk34.red(` ${err.message}`));
118985
+ return 2;
118986
+ }
118987
+ }
118988
+ const goldenPlan = goldenRec ? planGoldenRun(goldenRec, {
118989
+ prod: userProd,
118990
+ viewports,
118991
+ checkNames: hasSelection ? selection.checkNames : undefined,
118992
+ flows,
118993
+ explicitPages: explicitForGolden,
118994
+ visualPagesLimit: resolveVisualPagesLimit(opts, explicitForGolden?.length ?? null),
118995
+ vitalsPagesLimit: opts.vitalsPages ?? (isLocalhost(opts.cand) ? 3 : 10)
118996
+ }) : undefined;
118997
+ if (goldenRec && goldenPlan) {
118998
+ if (goldenPlan.errors.length > 0) {
118999
+ console.error(chalk34.red(` --golden ${opts.golden}: cannot use this recording:`));
119000
+ for (const e of goldenPlan.errors)
119001
+ console.error(chalk34.red(` - ${e}`));
119002
+ return 2;
119003
+ }
119004
+ const age = goldenAge(goldenRec.meta.recordedAt);
119005
+ const line = ` prod: from golden ${opts.golden} (recorded ${goldenRec.meta.recordedAt}, ${age.text}) — prod is not captured by this run`;
119006
+ console.log(age.warn ? chalk34.yellow(`${line}; older than a week, prod may have moved`) : chalk34.dim(line));
119007
+ for (const w of goldenPlan.warnings)
119008
+ console.log(chalk34.yellow(` ! ${w}`));
119009
+ if (goldenRec.missingFiles.length > 0) {
119010
+ console.log(chalk34.yellow(` ! ${goldenRec.missingFiles.length} file(s) the golden references were missing when it was saved`));
119011
+ }
119012
+ }
119013
+ const rc = goldenRec ? structuredClone(goldenRec.ctx.rc) : loadParityRc();
118712
119014
  rc.profile = profile;
118713
119015
  rc.cep = isContentProfile ? "" : opts.cep || rc.cep;
118714
119016
  if (typeof opts.addToCartTimeout === "number" && Number.isFinite(opts.addToCartTimeout)) {
@@ -118724,7 +119026,7 @@ async function runCommand(rawOpts) {
118724
119026
  console.log(chalk34.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
118725
119027
  }
118726
119028
  const primaryViewport = viewports[0] ?? "mobile";
118727
- const preflight = await preflightCheck(opts.prod, opts.cand, primaryViewport, pins);
119029
+ const preflight = await preflightCheck(opts.prod, opts.cand, primaryViewport, pins, Boolean(goldenRec));
118728
119030
  if (!preflight.ok) {
118729
119031
  console.error(chalk34.red(`
118730
119032
  ✖ pre-flight falhou:`));
@@ -118737,7 +119039,9 @@ async function runCommand(rawOpts) {
118737
119039
  const learned = loadLearned();
118738
119040
  const learnedBefore = JSON.stringify(learned);
118739
119041
  let platform = "custom";
118740
- const prodHomeHtml = earlyProdHtml ?? await fetchHomeHtml(opts.prod, primaryViewport, pinFetchHeaders(pins.prod));
119042
+ const prodHomeHtml = goldenRec ? null : earlyProdHtml ?? await fetchHomeHtml(opts.prod, primaryViewport, pinFetchHeaders(pins.prod));
119043
+ if (goldenRec)
119044
+ platform = goldenPlatform(goldenRec);
118741
119045
  if (prodHomeHtml) {
118742
119046
  platform = detectPlatform({ url: opts.prod, html: prodHomeHtml });
118743
119047
  if (platform !== "custom") {
@@ -118747,7 +119051,7 @@ async function runCommand(rawOpts) {
118747
119051
  const prodHost = hostOf4(opts.prod);
118748
119052
  let promotedCount = 0;
118749
119053
  let deprecatedCount = 0;
118750
- const wantsAutoSelectors = opts.autoSelectors !== false && isLlmAvailable();
119054
+ const wantsAutoSelectors = opts.autoSelectors !== false && isLlmAvailable() && !goldenRec;
118751
119055
  let discoveryBrowser = null;
118752
119056
  if (wantsAutoSelectors) {
118753
119057
  discoveryBrowser = await runSelectorDiscoveryPass({
@@ -118810,6 +119114,7 @@ async function runCommand(rawOpts) {
118810
119114
  let currentPhase = "launch";
118811
119115
  let shuttingDown = false;
118812
119116
  const partialChecks = [];
119117
+ let goldenFetch;
118813
119118
  const forceCloseBrowser = async (b, capMs) => {
118814
119119
  if (!b)
118815
119120
  return;
@@ -118885,8 +119190,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
118885
119190
  if (opts.warmup) {
118886
119191
  const warmupSpinner = ora8("Warmup: bustando cache em prod + cand…").start();
118887
119192
  const result = await warmupTargets({
118888
- urls: [opts.prod, opts.cand],
118889
- headersFor: [pinFetchHeaders(pins.prod), pinFetchHeaders(pins.cand)],
119193
+ urls: goldenRec ? [opts.cand] : [opts.prod, opts.cand],
119194
+ headersFor: goldenRec ? [pinFetchHeaders(pins.cand)] : [pinFetchHeaders(pins.prod), pinFetchHeaders(pins.cand)],
118890
119195
  viewports,
118891
119196
  bypassCache: opts.bypassCache !== false
118892
119197
  });
@@ -118901,11 +119206,12 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
118901
119206
  }
118902
119207
  }
118903
119208
  const traceEnabled = process.env.PARITY_TRACE === "1";
119209
+ const liveSides = goldenRec ? ["cand"] : ["prod", "cand"];
118904
119210
  const runOneSide = async (viewport, side) => {
118905
119211
  const baseUrl = side === "prod" ? opts.prod : opts.cand;
118906
119212
  const harEnabled = process.env.PARITY_HAR === "1";
118907
- const harPath = harEnabled ? join45(paths.harDir, `${viewport}-${side}.har`) : undefined;
118908
- const tracePath = traceEnabled ? join45(paths.tracesDir, `${viewport}-${side}.zip`) : null;
119213
+ const harPath = harEnabled ? join46(paths.harDir, `${viewport}-${side}.har`) : undefined;
119214
+ const tracePath = traceEnabled ? join46(paths.tracesDir, `${viewport}-${side}.zip`) : null;
118909
119215
  const ctx = await newContext(browser, {
118910
119216
  viewport,
118911
119217
  harPath,
@@ -118982,7 +119288,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
118982
119288
  };
118983
119289
  const runOneViewport = async (viewport) => {
118984
119290
  const [prodResult, candResult] = await Promise.all([
118985
- runOneSide(viewport, "prod"),
119291
+ goldenRec ? { captures: [], pages: [] } : runOneSide(viewport, "prod"),
118986
119292
  runOneSide(viewport, "cand")
118987
119293
  ]);
118988
119294
  for (const r of [prodResult, candResult]) {
@@ -119031,7 +119337,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119031
119337
  baseText: "Coletando vitals em páginas extras…"
119032
119338
  });
119033
119339
  try {
119034
- const allUrls = await resolveSitemapUrls(opts.prod);
119340
+ const allUrls = goldenRec ? [] : await resolveSitemapUrls(opts.prod);
119035
119341
  const visitedPaths = new Set;
119036
119342
  for (const p of allPageCaptures) {
119037
119343
  try {
@@ -119053,7 +119359,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119053
119359
  arr.push(p);
119054
119360
  buckets.set(seg, arr);
119055
119361
  }
119056
- const extraPaths = [];
119362
+ const extraPaths = goldenPlan ? [...goldenPlan.extraPaths] : [];
119057
119363
  const keys = [...buckets.keys()];
119058
119364
  let idx = 0;
119059
119365
  while (extraPaths.length < vitalsPagesLimit && keys.some((k) => (buckets.get(k)?.length ?? 0) > 0)) {
@@ -119069,7 +119375,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119069
119375
  const tasks = [];
119070
119376
  for (const viewport of mobileOnly) {
119071
119377
  for (const path of extraPaths) {
119072
- for (const side of ["prod", "cand"]) {
119378
+ for (const side of liveSides) {
119073
119379
  tasks.push({ path, viewport, side });
119074
119380
  }
119075
119381
  }
@@ -119118,6 +119424,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119118
119424
  if (!cap) {
119119
119425
  return;
119120
119426
  }
119427
+ cap.pass = "extra";
119121
119428
  allPageCaptures.push(cap);
119122
119429
  allFlowCaptures.push({
119123
119430
  flow: "homepage",
@@ -119164,11 +119471,11 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119164
119471
  baseText: visualSpinnerBaseText
119165
119472
  });
119166
119473
  try {
119167
- const visualPaths = explicitPaths ?? (await discoverPagesFromSitemap(opts.prod, { sampleSize: visualPagesLimit })).all.map((p) => ({ prod: p.path, cand: p.path }));
119474
+ const visualPaths = explicitPaths ?? (goldenPlan ? goldenPlan.visualPaths : (await discoverPagesFromSitemap(opts.prod, { sampleSize: visualPagesLimit })).all.map((p) => ({ prod: p.path, cand: p.path })));
119168
119475
  const tasks = [];
119169
119476
  for (const viewport of viewports) {
119170
119477
  for (const pair of visualPaths) {
119171
- for (const side of ["prod", "cand"]) {
119478
+ for (const side of liveSides) {
119172
119479
  tasks.push({
119173
119480
  path: side === "prod" ? pair.prod : pair.cand,
119174
119481
  pairKey: pair.prod,
@@ -119212,8 +119519,9 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119212
119519
  scrollToLoad: true,
119213
119520
  pairKey: task.pairKey
119214
119521
  });
119522
+ cap.pass = "visual";
119215
119523
  allPageCaptures.push(cap);
119216
- if (existsSync30(screenshotPath)) {
119524
+ if (existsSync31(screenshotPath)) {
119217
119525
  visualProbes.set(screenshotPath, await probeFullPage(page, screenshotPath, task.side === "prod" ? screenshotPath.replace(/\.png$/, "-repeat.png") : null));
119218
119526
  }
119219
119527
  } finally {
@@ -119244,6 +119552,18 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119244
119552
  const w = vitalsWarm.stats;
119245
119553
  console.log(chalk34.dim(` vitals warm-up: ${w.pages} page(s), ${w.loads} load(s)${w.failed ? `, ${w.failed} failed` : ""}, +${(w.totalMs / 1000).toFixed(1)}s summed across captures`));
119246
119554
  }
119555
+ if (goldenRec && goldenPlan) {
119556
+ const merged = mergeGoldenContext(goldenRec, goldenPlan, {
119557
+ pages: allPageCaptures,
119558
+ flows: allFlowCaptures,
119559
+ visualProbes: visualPagesLimit > 0 ? visualProbes : undefined
119560
+ }, makeRelocator(paths.screenshotsDir));
119561
+ allPageCaptures.splice(0, allPageCaptures.length, ...merged.pages);
119562
+ allFlowCaptures.splice(0, allFlowCaptures.length, ...merged.flows);
119563
+ visualProbes.clear();
119564
+ for (const [k, v] of merged.visualProbes ?? [])
119565
+ visualProbes.set(k, v);
119566
+ }
119247
119567
  currentPhase = "checks";
119248
119568
  setSpinnerLabel("Rodando checks…");
119249
119569
  spinner.start();
@@ -119261,13 +119581,15 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119261
119581
  candIsProduction: opts.candIsProduction
119262
119582
  };
119263
119583
  let recordedOk = false;
119584
+ let goldenStale = [];
119264
119585
  if (opts.record) {
119265
119586
  try {
119266
119587
  saveCheckContext(opts.record, checkCtx, {
119267
119588
  prodUrl: opts.prod,
119268
119589
  candUrl: opts.cand,
119269
119590
  parityVersion: getPackageVersion(),
119270
- checkNames: hasSelection ? [...selection.checkNames] : undefined
119591
+ checkNames: hasSelection ? [...selection.checkNames] : undefined,
119592
+ platform
119271
119593
  });
119272
119594
  recordedOk = true;
119273
119595
  } catch (err) {
@@ -119275,6 +119597,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119275
119597
  }
119276
119598
  }
119277
119599
  const runChecks = () => runAllChecks(checkCtx, partialChecks, hasSelection ? selection.checkNames : undefined);
119600
+ goldenFetch = goldenRec ? installGoldenFetch(goldenRec.fetchLog, new URL(opts.prod).origin) : undefined;
119278
119601
  let checks;
119279
119602
  if (recordedOk && opts.record) {
119280
119603
  const { result, log } = await recordFetch(runChecks);
@@ -119288,6 +119611,10 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119288
119611
  } else {
119289
119612
  checks = await runChecks();
119290
119613
  }
119614
+ if (goldenFetch) {
119615
+ goldenStale = goldenFetch.stale();
119616
+ goldenFetch.restore();
119617
+ }
119291
119618
  checksHb.stop();
119292
119619
  stampPhase("checks");
119293
119620
  spinner.succeed(`Checks concluídos (${checks.length})`);
@@ -119399,7 +119726,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119399
119726
  prodPinned: !isEmptyPin(pins.prod)
119400
119727
  })),
119401
119728
  pinned: isEmptyPin(pins.prod) && isEmptyPin(pins.cand) ? undefined : { prod: pinNames(pins.prod), cand: pinNames(pins.cand) },
119402
- pagePairs
119729
+ pagePairs,
119730
+ golden: goldenRec ? goldenReportField(resolve21(opts.golden), goldenRec.meta, goldenStale) : undefined
119403
119731
  };
119404
119732
  const reportStart = performance.now();
119405
119733
  const reportWhere = writeRunReport(paths, run, Boolean(opts.html || opts.open));
@@ -119417,6 +119745,11 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119417
119745
  verdict: { status: verdict.status, score: verdict.score, scoreVersion: SCORE_VERSION }
119418
119746
  });
119419
119747
  printSummary8(run, reportWhere, { promotedCount, deprecatedCount, platform });
119748
+ if (run.golden) {
119749
+ const age = goldenAge(run.golden.recordedAt);
119750
+ const say = age.warn ? chalk34.yellow : chalk34.dim;
119751
+ console.log(say(` prod from golden ${run.golden.dir} (${age.text}); prod was not recaptured`));
119752
+ }
119420
119753
  console.log(`
119421
119754
  ${formatTimingsSummary(runTimings, buildFlowBreakdown(allFlowCaptures))}`);
119422
119755
  if (pagePairs) {
@@ -119435,6 +119768,11 @@ ${formatPagePairTable(pagePairs)}`);
119435
119768
  console.log(chalk34.red(failOnGate.message));
119436
119769
  return 1;
119437
119770
  }
119771
+ if (goldenStale.length > 0) {
119772
+ console.log(chalk34.red(`
119773
+ ✖ golden is stale for: ${goldenStale.join(", ")} — a check asked prod for something the recording never saw, so its result rests on no data; record a new golden (report.json golden.staleRequests)`));
119774
+ return 2;
119775
+ }
119438
119776
  if (opts.open) {
119439
119777
  const { default: open } = await import("open");
119440
119778
  await open(paths.reportHtml).catch(() => {
@@ -119457,6 +119795,7 @@ ${formatPagePairTable(pagePairs)}`);
119457
119795
  clearTimeout(globalTimeoutTimer);
119458
119796
  process.removeListener("SIGINT", onSignal);
119459
119797
  process.removeListener("SIGTERM", onSignal);
119798
+ goldenFetch?.restore();
119460
119799
  if (browser)
119461
119800
  await browser.close().catch(() => {
119462
119801
  return;
@@ -119523,7 +119862,7 @@ function parsePagePair(entry) {
119523
119862
  }
119524
119863
  function resolveExplicitPages(pagesFile, pagesList) {
119525
119864
  if (pagesFile) {
119526
- if (!existsSync30(pagesFile)) {
119865
+ if (!existsSync31(pagesFile)) {
119527
119866
  throw new Error(`--pages-file não encontrado: ${pagesFile}`);
119528
119867
  }
119529
119868
  const raw = readFileSync39(pagesFile, "utf-8");
@@ -119618,7 +119957,7 @@ async function runWithConcurrency2(items, workers, fn) {
119618
119957
  }
119619
119958
  }));
119620
119959
  }
119621
- async function preflightCheck(prodUrl, candUrl, viewport, pins) {
119960
+ async function preflightCheck(prodUrl, candUrl, viewport, pins, skipProd = false) {
119622
119961
  const spinner = ora8("Pre-flight: verificando URLs…").start();
119623
119962
  const errors = [];
119624
119963
  const ua = userAgentFor(viewport);
@@ -119683,7 +120022,7 @@ async function preflightCheck(prodUrl, candUrl, viewport, pins) {
119683
120022
  await probeWithFetch(label, url);
119684
120023
  }
119685
120024
  }
119686
- await Promise.all([probe("prod", prodUrl), probe("cand", candUrl)]);
120025
+ await Promise.all([skipProd ? undefined : probe("prod", prodUrl), probe("cand", candUrl)]);
119687
120026
  await browser?.close().catch(() => {});
119688
120027
  if (errors.length > 0) {
119689
120028
  spinner.fail("Pre-flight falhou");
@@ -119859,8 +120198,8 @@ async function prCommand(opts) {
119859
120198
  return runCode || 1;
119860
120199
  }
119861
120200
  const latest = runs[0];
119862
- const reportJsonPath = join46(opts.output, "runs", latest.id, "report.json");
119863
- if (!existsSync31(reportJsonPath)) {
120201
+ const reportJsonPath = join47(opts.output, "runs", latest.id, "report.json");
120202
+ if (!existsSync32(reportJsonPath)) {
119864
120203
  console.error(chalk35.red(`report.json not found at ${reportJsonPath}`));
119865
120204
  return runCode || 1;
119866
120205
  }
@@ -119944,7 +120283,7 @@ function moduleTableLines(run) {
119944
120283
  }
119945
120284
 
119946
120285
  // src/commands/prompt.ts
119947
- import { existsSync as existsSync32, writeFileSync as writeFileSync34 } from "node:fs";
120286
+ import { existsSync as existsSync33, writeFileSync as writeFileSync34 } from "node:fs";
119948
120287
  import chalk36 from "chalk";
119949
120288
 
119950
120289
  // src/report/prompt-builder.ts
@@ -120072,7 +120411,7 @@ function promptCommand(runId, opts) {
120072
120411
  if (opts.out) {
120073
120412
  writeFileSync34(opts.out, md, "utf8");
120074
120413
  console.log(chalk36.green(`✔ prompt salvo em ${opts.out}`));
120075
- if (existsSync32(opts.out)) {
120414
+ if (existsSync33(opts.out)) {
120076
120415
  const sizeKb = (md.length / 1024).toFixed(1);
120077
120416
  console.log(chalk36.dim(` ${md.length} chars (${sizeKb} KB)`));
120078
120417
  }
@@ -120083,12 +120422,12 @@ function promptCommand(runId, opts) {
120083
120422
  }
120084
120423
 
120085
120424
  // src/commands/qa.ts
120086
- import { existsSync as existsSync36, readFileSync as readFileSync43 } from "node:fs";
120087
- import { basename as basename6, dirname as dirname10, join as join50 } from "node:path";
120425
+ import { existsSync as existsSync37, readFileSync as readFileSync43 } from "node:fs";
120426
+ import { basename as basename7, dirname as dirname10, join as join51 } from "node:path";
120088
120427
  import chalk38 from "chalk";
120089
120428
 
120090
120429
  // src/board/sweep-cards.ts
120091
- import { existsSync as existsSync33, readFileSync as readFileSync41 } from "node:fs";
120430
+ import { existsSync as existsSync34, readFileSync as readFileSync41 } from "node:fs";
120092
120431
  var QA_PREFIX = "[QA]";
120093
120432
  var CARD_BODY_MAX = 1200;
120094
120433
  var CLOSED = new Set(["done", "archived", "merged"]);
@@ -120415,7 +120754,7 @@ function readSpecs(entries) {
120415
120754
  const out = {};
120416
120755
  for (const e of entries)
120417
120756
  for (const ev of e.issue?.evidence ?? [])
120418
- if (ev.kind === "spec" && existsSync33(ev.path))
120757
+ if (ev.kind === "spec" && existsSync34(ev.path))
120419
120758
  out[ev.path] = readFileSync41(ev.path, "utf8");
120420
120759
  return out;
120421
120760
  }
@@ -120440,7 +120779,7 @@ function plannedEvidenceUrls(entries, run, cfg) {
120440
120779
  return {};
120441
120780
  const out = {};
120442
120781
  for (const p of cardEvidencePaths(entries))
120443
- if (existsSync33(p))
120782
+ if (existsSync34(p))
120444
120783
  out[p] = `${base}/fs/org/read?path=${encodeURIComponent(evidenceLibraryPath(p, run))}`;
120445
120784
  return out;
120446
120785
  }
@@ -120448,7 +120787,7 @@ async function uploadEvidence(entries, run, cfg, call, opts) {
120448
120787
  const upload = opts.upload ?? ((local, lib) => uploadToLibrary(cfg, local, lib, call));
120449
120788
  const out = {};
120450
120789
  for (const p of cardEvidencePaths(entries)) {
120451
- if (!existsSync33(p))
120790
+ if (!existsSync34(p))
120452
120791
  continue;
120453
120792
  const url = await upload(p, evidenceLibraryPath(p, run));
120454
120793
  if (url)
@@ -120464,8 +120803,8 @@ function truncate6(s, n) {
120464
120803
  }
120465
120804
 
120466
120805
  // src/commands/sweep.ts
120467
- import { existsSync as existsSync35, readFileSync as readFileSync42, writeFileSync as writeFileSync35 } from "node:fs";
120468
- import { join as join49 } from "node:path";
120806
+ import { existsSync as existsSync36, readFileSync as readFileSync42, writeFileSync as writeFileSync35 } from "node:fs";
120807
+ import { join as join50 } from "node:path";
120469
120808
  import chalk37 from "chalk";
120470
120809
  import { z as z5 } from "zod";
120471
120810
 
@@ -120813,7 +121152,7 @@ function a11yIssues(results) {
120813
121152
  }
120814
121153
 
120815
121154
  // src/engine/menu-audit.ts
120816
- import { join as join47 } from "node:path";
121155
+ import { join as join48 } from "node:path";
120817
121156
  var MAX_LINKS = 40;
120818
121157
  async function collectLinks(page, origin, scope) {
120819
121158
  const raw = await page.evaluate((sel) => {
@@ -120942,7 +121281,7 @@ async function probeMenuLinks(url, opts = {}) {
120942
121281
  try {
120943
121282
  for (const link of [...links.values()].slice(0, MAX_LINKS)) {
120944
121283
  const slug = new URL(link.href).pathname.replace(/[^a-z0-9]+/gi, "-").replace(/^-|-$/g, "");
120945
- const shot = opts.screenshotsDir ? join47(opts.screenshotsDir, `menu-${slug || "root"}.jpg`) : undefined;
121284
+ const shot = opts.screenshotsDir ? join48(opts.screenshotsDir, `menu-${slug || "root"}.jpg`) : undefined;
120946
121285
  out.push(await visit(page, link, shot));
120947
121286
  }
120948
121287
  } finally {
@@ -121029,21 +121368,21 @@ function menuLinkIssues(visits) {
121029
121368
 
121030
121369
  // src/engine/regression-specs.ts
121031
121370
  import { spawnSync as spawnSync2 } from "node:child_process";
121032
- import { existsSync as existsSync34 } from "node:fs";
121033
- import { join as join48, resolve as resolve21 } from "node:path";
121371
+ import { existsSync as existsSync35 } from "node:fs";
121372
+ import { join as join49, resolve as resolve22 } from "node:path";
121034
121373
  import { stripVTControlCharacters } from "node:util";
121035
121374
  function runRegressionSpecs(repoDirArg, baseUrl) {
121036
- const repoDir = resolve21(repoDirArg);
121037
- const dir = join48(repoDir, "tests", "qa");
121038
- if (!existsSync34(dir))
121375
+ const repoDir = resolve22(repoDirArg);
121376
+ const dir = join49(repoDir, "tests", "qa");
121377
+ if (!existsSync35(dir))
121039
121378
  return null;
121040
121379
  spawnSync2("npx", ["playwright", "install", "chromium"], {
121041
121380
  cwd: repoDir,
121042
121381
  encoding: "utf8",
121043
121382
  timeout: 10 * 60000
121044
121383
  });
121045
- const config = join48(dir, "playwright.config.ts");
121046
- const args = existsSync34(config) ? ["playwright", "test", "-c", config, "--reporter=json"] : ["playwright", "test", "tests/qa", "--reporter=json"];
121384
+ const config = join49(dir, "playwright.config.ts");
121385
+ const args = existsSync35(config) ? ["playwright", "test", "-c", config, "--reporter=json"] : ["playwright", "test", "tests/qa", "--reporter=json"];
121047
121386
  const res = spawnSync2("npx", args, {
121048
121387
  cwd: repoDir,
121049
121388
  env: { ...process.env, BASE_URL: baseUrl, CI: "1" },
@@ -121281,8 +121620,8 @@ async function addProbeFindings(url, runDir, reportJson, rc, json, specsRepo) {
121281
121620
  { label: "busca", selectors: selectorsFor("searchTrigger", { rc }) },
121282
121621
  { label: "menu", selectors: HAMBURGER_SELECTORS }
121283
121622
  ]).catch(() => []);
121284
- const menu = await probeMenuLinks(url, { screenshotsDir: join49(runDir, "screenshots") }).catch(() => []);
121285
- writeFileSync35(join49(runDir, "menu-links.json"), `${JSON.stringify(menu, null, 2)}
121623
+ const menu = await probeMenuLinks(url, { screenshotsDir: join50(runDir, "screenshots") }).catch(() => []);
121624
+ writeFileSync35(join50(runDir, "menu-links.json"), `${JSON.stringify(menu, null, 2)}
121286
121625
  `, "utf8");
121287
121626
  const listing = menu.find((v) => v.listingUi && v.products > 0);
121288
121627
  const a11y = await probeA11y(url, listing ? new URL(listing.link.href).pathname : undefined).catch(() => []);
@@ -121340,8 +121679,8 @@ function readUnverified(reportJson) {
121340
121679
  var SEVERITIES = ["critical", "high", "medium", "low"];
121341
121680
  var SWEEPER_ISSUES_FILE = "sweeper-issues.json";
121342
121681
  function readSweeperIssues(runDir) {
121343
- const path = join49(runDir, SWEEPER_ISSUES_FILE);
121344
- if (!existsSync35(path))
121682
+ const path = join50(runDir, SWEEPER_ISSUES_FILE);
121683
+ if (!existsSync36(path))
121345
121684
  return { issues: [], dropped: new Set };
121346
121685
  const parsed = z5.object({
121347
121686
  issues: agentIssues,
@@ -121368,8 +121707,8 @@ function normalizeAgentIssue(raw) {
121368
121707
  }
121369
121708
  var agentIssues = z5.preprocess((v) => Array.isArray(v) ? v.map(normalizeAgentIssue) : v, z5.array(Issue).default([]));
121370
121709
  function readCardReview(runDir) {
121371
- const path = join49(runDir, CARD_REVIEW_FILE);
121372
- if (!existsSync35(path))
121710
+ const path = join50(runDir, CARD_REVIEW_FILE);
121711
+ if (!existsSync36(path))
121373
121712
  return { issues: [], hold: new Map };
121374
121713
  const parsed = z5.object({
121375
121714
  issues: agentIssues,
@@ -121431,12 +121770,12 @@ async function sweepFileCommand(opts) {
121431
121770
  for (const i of agent.issues)
121432
121771
  for (const e of i.evidence ?? [])
121433
121772
  if (!e.path.startsWith("/"))
121434
- e.path = join49(paths.runDir, e.path);
121773
+ e.path = join50(paths.runDir, e.path);
121435
121774
  const review = readCardReview(paths.runDir);
121436
121775
  for (const i of review.issues)
121437
121776
  for (const e of i.evidence ?? [])
121438
121777
  if (!e.path.startsWith("/"))
121439
- e.path = join49(paths.runDir, e.path);
121778
+ e.path = join50(paths.runDir, e.path);
121440
121779
  const { issues, held } = applyCardReview(mergeIssues(report.allIssues ?? [], agent.issues, agent.dropped), review);
121441
121780
  const info = {
121442
121781
  runId,
@@ -121575,7 +121914,7 @@ async function qaFileCommand(opts) {
121575
121914
  console.error(chalk38.red(`--min-severity ${opts.minSeverity}: use ${SEVERITIES2.join("|")}`));
121576
121915
  return 2;
121577
121916
  }
121578
- if (!existsSync36(opts.issues)) {
121917
+ if (!existsSync37(opts.issues)) {
121579
121918
  console.error(chalk38.red(`${opts.issues}: not found`));
121580
121919
  return 2;
121581
121920
  }
@@ -121590,7 +121929,7 @@ async function qaFileCommand(opts) {
121590
121929
  for (const i of [...parsed.data, ...review.issues])
121591
121930
  for (const e of i.evidence ?? [])
121592
121931
  if (!e.path.startsWith("/"))
121593
- e.path = join50(dir, e.path);
121932
+ e.path = join51(dir, e.path);
121594
121933
  const { issues, held } = applyCardReview(parsed.data, review);
121595
121934
  const cfg = studioConfigFromEnv();
121596
121935
  if (!cfg) {
@@ -121598,7 +121937,7 @@ async function qaFileCommand(opts) {
121598
121937
  return 2;
121599
121938
  }
121600
121939
  const info = {
121601
- runId: basename6(opts.issues).replace(/\.json$/, ""),
121940
+ runId: basename7(opts.issues).replace(/\.json$/, ""),
121602
121941
  source: "parity qa",
121603
121942
  url: opts.url,
121604
121943
  timestamp: new Date().toISOString(),
@@ -121645,8 +121984,8 @@ async function qaFileCommand(opts) {
121645
121984
  }
121646
121985
 
121647
121986
  // src/commands/report.ts
121648
- import { existsSync as existsSync37, readFileSync as readFileSync44, writeFileSync as writeFileSync36 } from "node:fs";
121649
- import { join as join51, resolve as resolve22 } from "node:path";
121987
+ import { existsSync as existsSync38, readFileSync as readFileSync44, writeFileSync as writeFileSync36 } from "node:fs";
121988
+ import { join as join52, resolve as resolve23 } from "node:path";
121650
121989
  import chalk39 from "chalk";
121651
121990
  import open3 from "open";
121652
121991
 
@@ -122297,12 +122636,12 @@ var REMOVED_SECTIONS = {
122297
122636
  prompt: "use `parity prompt <runId>` for the LLM-ready Markdown."
122298
122637
  };
122299
122638
  function resolveRunPaths(output, runIdOrDir) {
122300
- if (existsSync37(join51(runIdOrDir, "report.json")))
122301
- return runPathsFor(resolve22(runIdOrDir));
122639
+ if (existsSync38(join52(runIdOrDir, "report.json")))
122640
+ return runPathsFor(resolve23(runIdOrDir));
122302
122641
  return getRunPaths(output, runIdOrDir);
122303
122642
  }
122304
122643
  function ensureReportHtml(paths) {
122305
- if (existsSync37(paths.reportHtml))
122644
+ if (existsSync38(paths.reportHtml))
122306
122645
  return { path: paths.reportHtml, rendered: false };
122307
122646
  const run = loadRunDir(paths.runDir);
122308
122647
  writeRunReportHtml(paths.runDir, renderHtmlReport(run, paths.runDir));
@@ -122332,7 +122671,7 @@ async function reportCommand(runId, opts) {
122332
122671
  }
122333
122672
  }
122334
122673
  const html = renderDeckHtml(buildDeckModel(run, plan), opts.lang ?? "en");
122335
- const dest = opts.out ?? join51(paths.runDir, "deck.html");
122674
+ const dest = opts.out ?? join52(paths.runDir, "deck.html");
122336
122675
  writeFileSync36(dest, html, "utf8");
122337
122676
  console.log(`${chalk39.green("✓")} deck → ${dest}`);
122338
122677
  if (opts.open) {
@@ -122675,8 +123014,8 @@ async function rerenderCommand(opts) {
122675
123014
  import chalk41 from "chalk";
122676
123015
 
122677
123016
  // src/replay/outcome.ts
122678
- import { existsSync as existsSync38, readFileSync as readFileSync45, writeFileSync as writeFileSync38 } from "node:fs";
122679
- import { join as join52 } from "node:path";
123017
+ import { existsSync as existsSync39, readFileSync as readFileSync45, writeFileSync as writeFileSync38 } from "node:fs";
123018
+ import { join as join53 } from "node:path";
122680
123019
  import { z as z6 } from "zod";
122681
123020
  var EXPECTED_FILE = "expected.json";
122682
123021
  var ReplayOutcome = z6.object({
@@ -122700,14 +123039,14 @@ function buildOutcome(checks, issues, verdict, parityVersion) {
122700
123039
  };
122701
123040
  }
122702
123041
  function readExpected(dir) {
122703
- const file = join52(dir, EXPECTED_FILE);
122704
- if (!existsSync38(file))
123042
+ const file = join53(dir, EXPECTED_FILE);
123043
+ if (!existsSync39(file))
122705
123044
  throw new Error(`${file} not found (record the expectation with --update-expected)`);
122706
123045
  return ReplayOutcome.parse(JSON.parse(readFileSync45(file, "utf8")));
122707
123046
  }
122708
123047
  function writeExpected(dir, outcome) {
122709
- const file = join52(dir, EXPECTED_FILE);
122710
- const notes = existsSync38(file) ? readExpected(dir).notes : undefined;
123048
+ const file = join53(dir, EXPECTED_FILE);
123049
+ const notes = existsSync39(file) ? readExpected(dir).notes : undefined;
122711
123050
  const { notes: _drop, ...rest } = outcome;
122712
123051
  writeFileSync38(file, `${JSON.stringify({ ...rest, ...notes !== undefined ? { notes } : {} }, null, 2)}
122713
123052
  `, "utf8");
@@ -122745,9 +123084,9 @@ function formatDiff(d) {
122745
123084
  }
122746
123085
 
122747
123086
  // src/replay/replay.ts
122748
- import { mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync2, rmSync as rmSync6 } from "node:fs";
123087
+ import { mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync2, rmSync as rmSync6 } from "node:fs";
122749
123088
  import { tmpdir as tmpdir3 } from "node:os";
122750
- import { join as join53 } from "node:path";
123089
+ import { join as join54 } from "node:path";
122751
123090
  class NothingToJudgeError extends Error {
122752
123091
  name = "NothingToJudgeError";
122753
123092
  }
@@ -122759,8 +123098,8 @@ async function replayRecording(dir, opts = {}) {
122759
123098
  throw new NothingToJudgeError(`nothing was compared: ${dir} holds no page pairs and no flows`);
122760
123099
  }
122761
123100
  const ownsOutDir = opts.outDir === undefined;
122762
- const outDir = opts.outDir ?? mkdtempSync2(join53(tmpdir3(), "parity-replay-"));
122763
- mkdirSync24(outDir, { recursive: true });
123101
+ const outDir = opts.outDir ?? mkdtempSync2(join54(tmpdir3(), "parity-replay-"));
123102
+ mkdirSync25(outDir, { recursive: true });
122764
123103
  const ctx = { ...rec.ctx, outDir };
122765
123104
  const unrecorded = new Set;
122766
123105
  const restore = replayFetch(rec.fetchLog);
@@ -122877,7 +123216,7 @@ async function replayCommand(dir, opts) {
122877
123216
  }
122878
123217
 
122879
123218
  // src/commands/serve.ts
122880
- import { existsSync as existsSync39 } from "node:fs";
123219
+ import { existsSync as existsSync40 } from "node:fs";
122881
123220
  import chalk42 from "chalk";
122882
123221
  async function serveRunAndBlock(runDir, opts = {}) {
122883
123222
  let handle;
@@ -122925,7 +123264,7 @@ async function serveRunAndBlock(runDir, opts = {}) {
122925
123264
  }
122926
123265
  async function serveCommand(runId, opts) {
122927
123266
  const paths = getRunPaths(opts.output, runId);
122928
- if (!existsSync39(paths.runDir)) {
123267
+ if (!existsSync40(paths.runDir)) {
122929
123268
  console.error(chalk42.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
122930
123269
  return 1;
122931
123270
  }
@@ -123798,8 +124137,8 @@ async function studioCommentCommand(opts, call = callTool2) {
123798
124137
 
123799
124138
  // src/commands/drift.ts
123800
124139
  import { spawnSync as spawnSync3 } from "node:child_process";
123801
- import { existsSync as existsSync40, readFileSync as readFileSync46 } from "node:fs";
123802
- import { resolve as resolve23 } from "node:path";
124140
+ import { existsSync as existsSync41, readFileSync as readFileSync46 } from "node:fs";
124141
+ import { resolve as resolve24 } from "node:path";
123803
124142
  import chalk46 from "chalk";
123804
124143
  var DRIFT_EXCLUDES = [":!.deco"];
123805
124144
  var SHA_RE = /^[0-9a-f]{7,64}$/i;
@@ -123918,7 +124257,7 @@ function computeDrift(inputs, opts) {
123918
124257
  const fail = (code, message) => ({ error: { code, message } });
123919
124258
  if (headRef.startsWith("-"))
123920
124259
  return fail("bad_head", `head "${headRef}" looks like a flag`);
123921
- if (!existsSync40(source))
124260
+ if (!existsSync41(source))
123922
124261
  return fail("not_a_repo", `${source} does not exist`);
123923
124262
  const inside = git(source, ["rev-parse", "--is-inside-work-tree"]);
123924
124263
  if (!inside.ok || inside.stdout.trim() !== "true") {
@@ -123986,7 +124325,7 @@ function computeDrift(inputs, opts) {
123986
124325
  };
123987
124326
  }
123988
124327
  function loadState(path) {
123989
- if (!existsSync40(path))
124328
+ if (!existsSync41(path))
123990
124329
  return null;
123991
124330
  try {
123992
124331
  return JSON.parse(readFileSync46(path, "utf8"));
@@ -123997,7 +124336,7 @@ function loadState(path) {
123997
124336
  function runDrift(flags) {
123998
124337
  let state = null;
123999
124338
  if (!(flags.source && flags.base)) {
124000
- const loaded = loadState(resolve23(flags.state ?? ".parity/migration.json"));
124339
+ const loaded = loadState(resolve24(flags.state ?? ".parity/migration.json"));
124001
124340
  if (loaded && "error" in loaded)
124002
124341
  return loaded;
124003
124342
  state = loaded;
@@ -124166,9 +124505,9 @@ function varianceCommand(opts) {
124166
124505
  }
124167
124506
 
124168
124507
  // src/commands/vitals.ts
124169
- import { existsSync as existsSync41, readFileSync as readFileSync47, writeFileSync as writeFileSync39 } from "node:fs";
124508
+ import { existsSync as existsSync42, readFileSync as readFileSync47, writeFileSync as writeFileSync39 } from "node:fs";
124170
124509
  import { availableParallelism } from "node:os";
124171
- import { join as join54 } from "node:path";
124510
+ import { join as join55 } from "node:path";
124172
124511
  import chalk48 from "chalk";
124173
124512
  import ora9 from "ora";
124174
124513
 
@@ -124217,7 +124556,7 @@ async function agenticNav(ctx) {
124217
124556
  note: "no Lighthouse data (run without --no-lighthouse)"
124218
124557
  });
124219
124558
  }
124220
- const candOrigin = originOf2(ctx.candPages);
124559
+ const candOrigin = originOf3(ctx.candPages);
124221
124560
  const llms = candOrigin ? await fetchLlmsTxtQuality(candOrigin) : null;
124222
124561
  const llmsOk = !!llms?.wellFormed;
124223
124562
  pillars.push({
@@ -124249,7 +124588,7 @@ async function agenticNav(ctx) {
124249
124588
  data: { agentic: { passed, total: applicable.length, pillars } }
124250
124589
  };
124251
124590
  }
124252
- function originOf2(pages) {
124591
+ function originOf3(pages) {
124253
124592
  for (const p of pages) {
124254
124593
  try {
124255
124594
  return new URL(p.url).origin;
@@ -124513,7 +124852,7 @@ async function vitalsCommand(opts) {
124513
124852
  });
124514
124853
  progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
124515
124854
  if (opts.lighthouse !== false) {
124516
- const lhDir = join54(paths.runDir, "lighthouse");
124855
+ const lhDir = join55(paths.runDir, "lighthouse");
124517
124856
  const lhCap = opts.lighthouseConcurrency ?? Math.max(1, Math.min(2, Math.floor(availableParallelism() / 2)));
124518
124857
  const done = tasks.filter((t) => !!t.capture);
124519
124858
  const lhT0 = Date.now();
@@ -124602,7 +124941,7 @@ async function vitalsCommand(opts) {
124602
124941
  writeRunReportJson(paths.runDir, run);
124603
124942
  const html = renderHtmlReport(run, paths.runDir);
124604
124943
  writeRunReportHtml(paths.runDir, html);
124605
- writeFileSync39(join54(paths.runDir, "vitals.json"), `${JSON.stringify({
124944
+ writeFileSync39(join55(paths.runDir, "vitals.json"), `${JSON.stringify({
124606
124945
  schemaVersion: "0.1",
124607
124946
  prodUrl: opts.prod,
124608
124947
  candUrl: opts.cand,
@@ -124708,7 +125047,7 @@ async function discoverPagePaths2(prodUrl, opts) {
124708
125047
  function parseUrlList(input) {
124709
125048
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
124710
125049
  const path = input.replace(/^file:\/\//, "");
124711
- if (existsSync41(path)) {
125050
+ if (existsSync42(path)) {
124712
125051
  return readFileSync47(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
124713
125052
  }
124714
125053
  }
@@ -124745,7 +125084,7 @@ program.command("run").description([
124745
125084
  " visual-pages=5, auto-selectors=ON (if LLM), learn=ON, visual-diff=ON,",
124746
125085
  " warmup=OFF, vitals warm=ON, bypass-cache=OFF, fail-on=critical (exit 1 if hit)."
124747
125086
  ].join(`
124748
- `)).option("--prod <url>", "Production URL (source of truth, e.g. Fresh site). Omit for a single site — the run will point you to `parity e2e` (issue #141).").requiredOption("--cand <url>", "Candidate URL (migrated site, e.g. TanStack)").option("--preset <name>", "Bundle of defaults: smoke (fast, ~30s, no LLM) | full (deep audit) | ci (CI-tuned)").option("--flows <list>", "Comma-separated flows: homepage,plp,pdp,purchase-journey", "purchase-journey").option("--viewports <list>", "Comma-separated viewports: mobile,desktop", "mobile,desktop").option("--cep <cep>", "CEP for shipping calculation", "01310-100").option("--prod-cookie <name=value>", "Cookie set on every prod browser context and plain request; repeatable. Pins prod to one A/B variant (e.g. a Fresh-vs-TanStack bucket cookie) so the run does not compare whichever build each fresh context drew. Values are redacted in logs and report.json.", collectCookie, []).option("--cand-cookie <name=value>", "Same as --prod-cookie, for the candidate side", collectCookie, []).option("--prod-header <Name: value>", "Request header sent on every prod request (all origins — no credentials); repeatable. The header twin of --prod-cookie. Values are redacted in logs and report.json.", collectHeader, []).option("--cand-header <Name: value>", "Same as --prod-header, for the candidate side", collectHeader, []).option("--add-to-cart-timeout <ms>", "How long (ms) the add-to-cart step polls for a success signal before failing. Default 3000. Raise/lower to match your site's success-toast lifetime (issue #143).", (v) => Number(v)).option("--runs <n>", "Repeat each measurement N times (median)", "1").option("--baseline <name>", "Compare against a saved baseline").option("--output <dir>", "Output directory", "./parity-output").option("--fail-on <severities>", "Comma-separated severities that cause exit 1 (default: critical)", "critical").option("--html", "Also write report.html (off by default: render it later with `parity report <runId>`)", false).option("--open", "Write report.html and open it after the run completes (implies --html)", false).option("--no-auto-selectors", "Disable LLM-based selector discovery (uses defaults instead)").option("--refresh-selectors", "Bypass selector cache and re-run discovery", false).option("--no-learn", "Don't write to learned-selectors.json (read-only mode)").option("--vitals-pages <n>", "Extra pages from sitemap to crawl for Vitals coverage, beyond what --flows/--pages already cover (default 10). These are auto-sampled and can add significant unrelated noise to findings — pass 0 to scope the run to only the pages you explicitly requested.", (v) => Number(v), 10).option("--max-viewport-concurrency <n>", "How many viewports run concurrently during collect (default 2: mobile+desktop together). Set to 1 if you hit OOM with many viewports.", (v) => Number(v), 2).option("--visual-pages <n>", "Pages to compare visually with the heatmap engine — pixel diff + box-tree diff, no LLM (home + sampled PLPs/PDPs from sitemap, default 5)", (v) => Number(v), 5).option("--pages <list>", 'Comma-separated paths to compare visually (overrides sitemap discovery). E.g. "/,/account,/p/some-product". Use "prod->cand" for a page that lives at DIFFERENT paths on each side (partial migration), e.g. "/encimera-gc60/p->/ar-condicionado-12k/p". Use this when you want deterministic coverage instead of sampled. Scopes the visual-diff + vitals-extra-pages passes ONLY — the flows crawl (--flows, default purchase-journey) discovers its own target pages independently and ignores this flag. To scope which page(s) a flow visits, use --flows to pick a lighter flow and/or set the matching *UrlHint (e.g. plpUrlHint) in .parityrc.json. Issue #178.').option("--pages-file <path>", `Read paths to compare visually from a text file (one entry per line). Lines starting with # are ignored. Accepts the same "prod->cand" pair syntax as --pages. Overrides --pages when both are present. Same visual-diff/vitals-only scope as --pages — see that flag's help. Issue #178.`).option("--no-visual-diff", "Skip the visual diff capture pass entirely").option("--no-cache", "Deprecated, no effect (the visual verdict cache is gone).").option("--clear-cache", "Deprecated, no effect (the visual verdict cache is gone).", false).option("--bypass-cache", "Bypass CDN/edge caches AND the browser's own HTTP cache (CDP cache-disable), forcing a cold-visit fetch. Use right after a deploy to avoid false failures from stale CF edge content, or to approximate Lighthouse/CrUX-comparable TTFB/FCP/LCP numbers — without this flag, parity's vitals are a warm-connection/cache-enabled ('repeat visit') measurement, not a cold first-visit one, so they aren't directly comparable 1:1 to Lighthouse.", false).option("--warmup", "Before measurement, hit each target URL once (per viewport) with a cache-buster so the Worker serves a fresh response. Recommended after deploys.", false).option("--no-warm", "Don't warm each side's URL before measuring vitals. By default every vitals-measured page is loaded once on BOTH sides first, in a throwaway page (same device + cookies), so a cold edge/loader cache on whichever side hit the route first isn't reported as a Web Vitals or CLS regression. Ignored under --bypass-cache, which measures cold on purpose. Distinct from --warmup (a cache-busted homepage hit after a deploy).").option("--accept-prod-quirks", "Demote prod-side cart-empty journey failures (VTEX session quirk) from failed to skipped. The cart-reveal-mode-divergence check still emits critical if prod/cand markup intents differ, so this flag never masks a real regression. See issue #12.", false).option("--cand-is-production", "Cand is the final production domain, not a staging host. Disables staging detection (cand on another host with noindex everywhere), so noindex/nofollow on cand is critical and third-party origins missing on cand are high again.", false).option("--record <dir>", "Save the exact input the checks ran on (captures with full page HTML, resolved config, visual probes, screenshots, and the fetches the checks made) into <dir>, which must be new or empty. Contains full HTML and screenshots of both sites: do not commit it.").option("--llm-timeout <seconds>", "Deprecated, no effect: topIssues is ranked deterministically now, there is no LLM aggregation call to time out.").option("--keep-runs <n>", "After the run, delete all but the n newest runs of this prod/cand host pair under --output (other host pairs, runs without a readable report.json and baseline-referenced runs are never touched). 0 keeps everything. Default: 10.", (v) => Number(v), 10).option("--timeout <minutes>", "Hard wall-clock cap for the whole run (minutes). On expiry, parity writes a partial report and exits 130. Default: 30. Issue #56.", (v) => Number(v), 30).option("--flow <name>", "Alias for --flows when running a single flow (e.g. --flow cart). Issue #53.").option("--json <path|->", "Emit JSON-Lines (one line per check) to the given file path, or '-' for stdout. Schema versioned via leading metadata line. Issue #53.").option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Only affects LLM-generated content (issues, explain, prompts) — the static HTML report stays in English. Issue #67.").option("--llm <provider>", "Force LLM provider: anthropic | openrouter | claude-code | none. Default: auto-detect (anthropic key → openrouter key → local claude CLI → none). Issue #66.").option("--llm-model <overrides>", "Per-feature model override, e.g. visual-diff=claude-opus-5,explain=claude-opus-5. Features: selector-discovery, step-recovery, search-terms, plp-matching, pdp-matching, section-understanding, visual-diff, explain, component-detection. Issue #66.").option("--llm-tier-default <tier>", "Override the default tier (haiku | sonnet | opus) for every feature that doesn't have a per-feature override. Issue #66.").option("--llm-model-default <model>", "Force every LLM call to use this exact model ID, ignoring per-feature defaults. Issue #66.").option("--llm-premium", "Bump the reasoning-heavy features (explain/visual-diff) to opus. Defaults are sonnet-first for cost/latency (opus blew the 60s timeout on most runs); opt into opus for hard fixes. Issue #256.").option("--no-interactive", "Disable the interactive selector prompt that auto-fires in a TTY without an LLM provider. Use in scripts and CI where stdin is technically a TTY but you don't want to pause. Issue #72.").option("--only <modules>", "Scope the run to these modules and/or single checks (comma-separated). Module names: e2e, seo, visual, vitals, cache, console, html, network. Single-check granularity via `check:<name>`, e.g. `--only e2e,check:cache-coverage`. Run `parity list modules` for the full check/flow mapping. Default: all modules. M3 module selection.").option("--skip <modules>", "Subtract these modules and/or single checks (comma-separated, same syntax as --only) from whatever base set was chosen (all modules, or --only's set if both are given). M3 module selection.").option("--why <text>", "Free-text reason for this run's scope, stored in report.json as `selectionReason`. Purely informational. M3 module selection.").option("--profile <type>", "Site profile: commerce | content. Scopes modules/flows/CEP. `content` (blog/custom site with no storefront) drops the e2e purchase journey, scopes flows to the homepage, and skips CEP. Auto-detected from the platform when omitted. Issues #254/#255.").action(async (opts) => {
125087
+ `)).option("--prod <url>", "Production URL (source of truth, e.g. Fresh site). Omit for a single site — the run will point you to `parity e2e` (issue #141).").requiredOption("--cand <url>", "Candidate URL (migrated site, e.g. TanStack)").option("--preset <name>", "Bundle of defaults: smoke (fast, ~30s, no LLM) | full (deep audit) | ci (CI-tuned)").option("--flows <list>", "Comma-separated flows: homepage,plp,pdp,purchase-journey", "purchase-journey").option("--viewports <list>", "Comma-separated viewports: mobile,desktop", "mobile,desktop").option("--cep <cep>", "CEP for shipping calculation", "01310-100").option("--prod-cookie <name=value>", "Cookie set on every prod browser context and plain request; repeatable. Pins prod to one A/B variant (e.g. a Fresh-vs-TanStack bucket cookie) so the run does not compare whichever build each fresh context drew. Values are redacted in logs and report.json.", collectCookie, []).option("--cand-cookie <name=value>", "Same as --prod-cookie, for the candidate side", collectCookie, []).option("--prod-header <Name: value>", "Request header sent on every prod request (all origins — no credentials); repeatable. The header twin of --prod-cookie. Values are redacted in logs and report.json.", collectHeader, []).option("--cand-header <Name: value>", "Same as --prod-header, for the candidate side", collectHeader, []).option("--add-to-cart-timeout <ms>", "How long (ms) the add-to-cart step polls for a success signal before failing. Default 3000. Raise/lower to match your site's success-toast lifetime (issue #143).", (v) => Number(v)).option("--runs <n>", "Repeat each measurement N times (median)", "1").option("--baseline <name>", "Compare against a saved baseline").option("--output <dir>", "Output directory", "./parity-output").option("--fail-on <severities>", "Comma-separated severities that cause exit 1 (default: critical)", "critical").option("--html", "Also write report.html (off by default: render it later with `parity report <runId>`)", false).option("--open", "Write report.html and open it after the run completes (implies --html)", false).option("--no-auto-selectors", "Disable LLM-based selector discovery (uses defaults instead)").option("--refresh-selectors", "Bypass selector cache and re-run discovery", false).option("--no-learn", "Don't write to learned-selectors.json (read-only mode)").option("--vitals-pages <n>", "Extra pages from sitemap to crawl for Vitals coverage, beyond what --flows/--pages already cover (default 10). These are auto-sampled and can add significant unrelated noise to findings — pass 0 to scope the run to only the pages you explicitly requested.", (v) => Number(v), 10).option("--max-viewport-concurrency <n>", "How many viewports run concurrently during collect (default 2: mobile+desktop together). Set to 1 if you hit OOM with many viewports.", (v) => Number(v), 2).option("--visual-pages <n>", "Pages to compare visually with the heatmap engine — pixel diff + box-tree diff, no LLM (home + sampled PLPs/PDPs from sitemap, default 5)", (v) => Number(v), 5).option("--pages <list>", 'Comma-separated paths to compare visually (overrides sitemap discovery). E.g. "/,/account,/p/some-product". Use "prod->cand" for a page that lives at DIFFERENT paths on each side (partial migration), e.g. "/encimera-gc60/p->/ar-condicionado-12k/p". Use this when you want deterministic coverage instead of sampled. Scopes the visual-diff + vitals-extra-pages passes ONLY — the flows crawl (--flows, default purchase-journey) discovers its own target pages independently and ignores this flag. To scope which page(s) a flow visits, use --flows to pick a lighter flow and/or set the matching *UrlHint (e.g. plpUrlHint) in .parityrc.json. Issue #178.').option("--pages-file <path>", `Read paths to compare visually from a text file (one entry per line). Lines starting with # are ignored. Accepts the same "prod->cand" pair syntax as --pages. Overrides --pages when both are present. Same visual-diff/vitals-only scope as --pages — see that flag's help. Issue #178.`).option("--no-visual-diff", "Skip the visual diff capture pass entirely").option("--no-cache", "Deprecated, no effect (the visual verdict cache is gone).").option("--clear-cache", "Deprecated, no effect (the visual verdict cache is gone).", false).option("--bypass-cache", "Bypass CDN/edge caches AND the browser's own HTTP cache (CDP cache-disable), forcing a cold-visit fetch. Use right after a deploy to avoid false failures from stale CF edge content, or to approximate Lighthouse/CrUX-comparable TTFB/FCP/LCP numbers — without this flag, parity's vitals are a warm-connection/cache-enabled ('repeat visit') measurement, not a cold first-visit one, so they aren't directly comparable 1:1 to Lighthouse.", false).option("--warmup", "Before measurement, hit each target URL once (per viewport) with a cache-buster so the Worker serves a fresh response. Recommended after deploys.", false).option("--no-warm", "Don't warm each side's URL before measuring vitals. By default every vitals-measured page is loaded once on BOTH sides first, in a throwaway page (same device + cookies), so a cold edge/loader cache on whichever side hit the route first isn't reported as a Web Vitals or CLS regression. Ignored under --bypass-cache, which measures cold on purpose. Distinct from --warmup (a cache-busted homepage hit after a deploy).").option("--accept-prod-quirks", "Demote prod-side cart-empty journey failures (VTEX session quirk) from failed to skipped. The cart-reveal-mode-divergence check still emits critical if prod/cand markup intents differ, so this flag never masks a real regression. See issue #12.", false).option("--cand-is-production", "Cand is the final production domain, not a staging host. Disables staging detection (cand on another host with noindex everywhere), so noindex/nofollow on cand is critical and third-party origins missing on cand are high again.", false).option("--record <dir>", "Save the exact input the checks ran on (captures with full page HTML, resolved config, visual probes, screenshots, and the fetches the checks made) into <dir>, which must be new or empty. Contains full HTML and screenshots of both sites: do not commit it.").option("--golden <dir>", "Use the PROD half of a `--record` recording as the reference and capture only cand (--prod becomes optional). Pages come from the recording, prod-origin fetches by the checks are served from it, and a prod request it never saw is reported as stale (exit 2). Never written to. See docs/cli.md.").option("--llm-timeout <seconds>", "Deprecated, no effect: topIssues is ranked deterministically now, there is no LLM aggregation call to time out.").option("--keep-runs <n>", "After the run, delete all but the n newest runs of this prod/cand host pair under --output (other host pairs, runs without a readable report.json and baseline-referenced runs are never touched). 0 keeps everything. Default: 10.", (v) => Number(v), 10).option("--timeout <minutes>", "Hard wall-clock cap for the whole run (minutes). On expiry, parity writes a partial report and exits 130. Default: 30. Issue #56.", (v) => Number(v), 30).option("--flow <name>", "Alias for --flows when running a single flow (e.g. --flow cart). Issue #53.").option("--json <path|->", "Emit JSON-Lines (one line per check) to the given file path, or '-' for stdout. Schema versioned via leading metadata line. Issue #53.").option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Only affects LLM-generated content (issues, explain, prompts) — the static HTML report stays in English. Issue #67.").option("--llm <provider>", "Force LLM provider: anthropic | openrouter | claude-code | none. Default: auto-detect (anthropic key → openrouter key → local claude CLI → none). Issue #66.").option("--llm-model <overrides>", "Per-feature model override, e.g. visual-diff=claude-opus-5,explain=claude-opus-5. Features: selector-discovery, step-recovery, search-terms, plp-matching, pdp-matching, section-understanding, visual-diff, explain, component-detection. Issue #66.").option("--llm-tier-default <tier>", "Override the default tier (haiku | sonnet | opus) for every feature that doesn't have a per-feature override. Issue #66.").option("--llm-model-default <model>", "Force every LLM call to use this exact model ID, ignoring per-feature defaults. Issue #66.").option("--llm-premium", "Bump the reasoning-heavy features (explain/visual-diff) to opus. Defaults are sonnet-first for cost/latency (opus blew the 60s timeout on most runs); opt into opus for hard fixes. Issue #256.").option("--no-interactive", "Disable the interactive selector prompt that auto-fires in a TTY without an LLM provider. Use in scripts and CI where stdin is technically a TTY but you don't want to pause. Issue #72.").option("--only <modules>", "Scope the run to these modules and/or single checks (comma-separated). Module names: e2e, seo, visual, vitals, cache, console, html, network. Single-check granularity via `check:<name>`, e.g. `--only e2e,check:cache-coverage`. Run `parity list modules` for the full check/flow mapping. Default: all modules. M3 module selection.").option("--skip <modules>", "Subtract these modules and/or single checks (comma-separated, same syntax as --only) from whatever base set was chosen (all modules, or --only's set if both are given). M3 module selection.").option("--why <text>", "Free-text reason for this run's scope, stored in report.json as `selectionReason`. Purely informational. M3 module selection.").option("--profile <type>", "Site profile: commerce | content. Scopes modules/flows/CEP. `content` (blog/custom site with no storefront) drops the e2e purchase journey, scopes flows to the homepage, and skips CEP. Auto-detected from the platform when omitted. Issues #254/#255.").action(async (opts) => {
124749
125088
  if (opts.flow) {
124750
125089
  opts.flows = opts.flow;
124751
125090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.35.26",
3
+ "version": "0.35.27",
4
4
  "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",