@decocms/parity 0.35.24 → 0.35.26

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 +12 -1
  2. package/dist/cli.js +460 -113
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -32,6 +32,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
32
32
  (`sitemap` | `links` | `explicit`, profile + evidence, templates with example
33
33
  URLs, what the cap left out). All plan additions are optional, so existing plans
34
34
  still load and `parity plan merge` carries them.
35
+ * **`parity replay <dir>`** re-runs the checks on a `--record` recording with no browser and scores
36
+ them with the same code as `parity run`. `--expect` / `--update-expected` pin the outcome (check
37
+ statuses, issue ids, verdict status) in `<dir>/expected.json`; exit 2 means nothing could be
38
+ judged (never a pass). A request the recording never saw fails the check and is named. A corpus
39
+ suite (`tests/corpus/corpus.test.ts`, `PARITY_CORPUS_DIR`) replays a directory of reviewed
40
+ recordings kept in a separate private repository. See `docs/reports.md`.
41
+ * **Determinism test**: the same recording replayed twice must give identical checks, issues
42
+ (ids, severity, details, evidence), verdict and score, order included; the corpus suite repeats
43
+ that for every case.
35
44
 
36
45
  ### Fixed
37
46
 
@@ -86,7 +95,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
86
95
  a `commerce` site profile; a content site's listing or about page is `other`.
87
96
  `pages[].kindEvidence` records the decision. `category-auto` no longer hard-codes
88
97
  `plp`.
89
-
98
+ * **`checks[]`, and the `issues[]` derived from it, are in registration order** instead of
99
+ completion order, so `report.json` and the JSONL stream no longer reorder between runs of the
100
+ same input. Results still land in the crash-safety array as each check finishes.
90
101
 
91
102
  ### Changed
92
103
 
package/dist/cli.js CHANGED
@@ -75779,7 +75779,7 @@ import {
75779
75779
  registerCommands as registerCatalogCommands
75780
75780
  } from "@decocms/catalog";
75781
75781
  import { DESCRIPTION, registerCommands } from "@decocms/vtex-cms";
75782
- import chalk48 from "chalk";
75782
+ import chalk49 from "chalk";
75783
75783
  import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commander";
75784
75784
 
75785
75785
  // src/commands/ab-detect.ts
@@ -90193,23 +90193,29 @@ function getCheckByName(name) {
90193
90193
  }
90194
90194
  async function runAllChecks(ctx, outResults, checkFilter) {
90195
90195
  const results = outResults ?? [];
90196
- const checksToRun = checkFilter ? Array.from(checkFilter).map((name) => getCheckByName(name)).filter((c) => c !== undefined) : ALL_CHECKS;
90197
- await Promise.all(checksToRun.map(async (check) => {
90196
+ const checksToRun = checkFilter ? Array.from(checkFilter).map((name) => getCheckByName(name)).filter((c) => c !== undefined).sort((a, b) => ALL_CHECKS.indexOf(a) - ALL_CHECKS.indexOf(b)) : ALL_CHECKS;
90197
+ const rank = new Map;
90198
+ const push = (r, i) => {
90199
+ rank.set(r, i);
90200
+ results.push(r);
90201
+ };
90202
+ await Promise.all(checksToRun.map(async (check, i) => {
90198
90203
  const start = Date.now();
90199
90204
  try {
90200
90205
  const r = await check(ctx);
90201
- results.push({ ...r, durationMs: r.durationMs || Date.now() - start });
90206
+ push({ ...r, durationMs: r.durationMs || Date.now() - start }, i);
90202
90207
  } catch (err) {
90203
- results.push({
90208
+ push({
90204
90209
  name: check.name || "anonymous-check",
90205
90210
  status: "fail",
90206
90211
  severity: "medium",
90207
90212
  durationMs: Date.now() - start,
90208
90213
  summary: `check threw: ${err.message}`,
90209
90214
  issues: []
90210
- });
90215
+ }, i);
90211
90216
  }
90212
90217
  }));
90218
+ results.sort((a, b) => (rank.get(a) ?? -1) - (rank.get(b) ?? -1));
90213
90219
  return results;
90214
90220
  }
90215
90221
 
@@ -117649,6 +117655,65 @@ function saveCheckContext(dir, ctx, meta) {
117649
117655
  RecordedContext.parse(recorded);
117650
117656
  writeFileSync32(join44(dir, CONTEXT_FILE), JSON.stringify(recorded), "utf8");
117651
117657
  }
117658
+ function loadCheckContext(dir) {
117659
+ const file = join44(dir, CONTEXT_FILE);
117660
+ if (!existsSync29(file))
117661
+ throw new Error(`${dir} holds no recording (${CONTEXT_FILE} not found)`);
117662
+ const raw = JSON.parse(readFileSync38(file, "utf8"));
117663
+ if (raw.formatVersion !== FORMAT_VERSION) {
117664
+ throw new Error(`${file}: unsupported recording formatVersion ${JSON.stringify(raw.formatVersion)} (this parity reads ${FORMAT_VERSION})`);
117665
+ }
117666
+ const r = RecordedContext.parse(raw);
117667
+ const root = resolve20(dir);
117668
+ const abs = (p) => p === "" || isAbsolute(p) ? p : join44(root, p);
117669
+ const absOpt = (p) => p ? abs(p) : p;
117670
+ const page = (c) => ({ ...c, screenshotPath: abs(c.screenshotPath) });
117671
+ const step = (s) => ({
117672
+ ...s,
117673
+ screenshotPath: abs(s.screenshotPath),
117674
+ ...s.screenshotBeforePath !== undefined ? { screenshotBeforePath: abs(s.screenshotBeforePath) } : {}
117675
+ });
117676
+ const flow = (f) => ({
117677
+ ...f,
117678
+ pages: f.pages.map(page),
117679
+ ...f.steps ? { steps: f.steps.map(step) } : {}
117680
+ });
117681
+ const fetchFile = join44(dir, FETCH_FILE);
117682
+ if (!existsSync29(fetchFile)) {
117683
+ throw new Error(`${dir} is an incomplete recording: ${FETCH_FILE} is missing (the run stopped during checks?)`);
117684
+ }
117685
+ const fetchLog = FetchLogSchema.parse(JSON.parse(readFileSync38(fetchFile, "utf8")));
117686
+ return {
117687
+ ctx: {
117688
+ prodPages: r.prodPages.map(page),
117689
+ candPages: r.candPages.map(page),
117690
+ prodFlows: r.prodFlows.map(flow),
117691
+ candFlows: r.candFlows.map(flow),
117692
+ rc: r.rc,
117693
+ ignore: r.ignore,
117694
+ viewports: r.viewports,
117695
+ ...r.candIsProduction !== undefined ? { candIsProduction: r.candIsProduction } : {},
117696
+ visualProbes: r.visualProbes ? new Map(r.visualProbes.map(([k, v]) => [
117697
+ abs(k),
117698
+ {
117699
+ ...v,
117700
+ side: { ...v.side, screenshot: absOpt(v.side.screenshot) },
117701
+ repeatScreenshot: absOpt(v.repeatScreenshot)
117702
+ }
117703
+ ])) : undefined
117704
+ },
117705
+ meta: {
117706
+ prodUrl: r.prodUrl,
117707
+ candUrl: r.candUrl,
117708
+ recordedAt: r.recordedAt,
117709
+ ...r.checkNames ? { checkNames: r.checkNames } : {},
117710
+ ...r.parityVersion ? { parityVersion: r.parityVersion } : {}
117711
+ },
117712
+ fetchLog,
117713
+ missingFiles: r.missingFiles,
117714
+ omittedArtifacts: r.omittedArtifacts
117715
+ };
117716
+ }
117652
117717
  var FetchEntry = z4.object({
117653
117718
  method: z4.string(),
117654
117719
  url: z4.string(),
@@ -117728,6 +117793,61 @@ function saveFetchLog(dir, log) {
117728
117793
  writeFileSync32(join44(dir, FETCH_FILE), JSON.stringify(log), "utf8");
117729
117794
  }
117730
117795
 
117796
+ class UnrecordedFetchError extends Error {
117797
+ name = "UnrecordedFetchError";
117798
+ constructor(method, url) {
117799
+ super(`replay: ${method} ${url} was not made during the recorded run`);
117800
+ }
117801
+ }
117802
+ function createReplayFetch(log) {
117803
+ const queues = new Map;
117804
+ for (const e of log.entries) {
117805
+ const k = `${e.method} ${e.url}`;
117806
+ const q = queues.get(k);
117807
+ if (q)
117808
+ q.push(e);
117809
+ else
117810
+ queues.set(k, [e]);
117811
+ }
117812
+ const cursor = new Map;
117813
+ return async (input, init) => {
117814
+ const { method, url } = reqParts(input, init);
117815
+ const k = `${method} ${url}`;
117816
+ const q = queues.get(k);
117817
+ if (!q)
117818
+ throw new UnrecordedFetchError(method, url);
117819
+ const i = cursor.get(k) ?? 0;
117820
+ cursor.set(k, Math.min(i + 1, q.length - 1));
117821
+ const e = q[i];
117822
+ if (e.error) {
117823
+ const err = e.error.name === "TypeError" ? new TypeError(e.error.message) : new Error(e.error.message);
117824
+ err.name = e.error.name;
117825
+ if (e.error.cause)
117826
+ err.cause = { code: e.error.cause };
117827
+ throw err;
117828
+ }
117829
+ const status = e.status ?? 200;
117830
+ let body = null;
117831
+ if (e.bodyError) {
117832
+ const msg = e.bodyError;
117833
+ body = new ReadableStream({ start: (c) => c.error(new Error(msg)) });
117834
+ } else if (e.body && !NULL_BODY.has(status)) {
117835
+ body = "text" in e.body ? e.body.text : Buffer.from(e.body.base64, "base64");
117836
+ }
117837
+ const res = new Response(body, { status, statusText: e.statusText, headers: e.headers });
117838
+ Object.defineProperty(res, "url", { value: e.finalUrl ?? url });
117839
+ Object.defineProperty(res, "redirected", { value: e.redirected ?? false });
117840
+ return res;
117841
+ };
117842
+ }
117843
+ function replayFetch(log) {
117844
+ const orig = globalThis.fetch;
117845
+ globalThis.fetch = createReplayFetch(log);
117846
+ return () => {
117847
+ globalThis.fetch = orig;
117848
+ };
117849
+ }
117850
+
117731
117851
  // src/diff/score-band.ts
117732
117852
  var uniq = (xs) => [...new Set(xs)];
117733
117853
  function computeScoreBand(current, priors, opts = {}) {
@@ -117822,6 +117942,34 @@ function readLine2(prompt) {
117822
117942
  });
117823
117943
  }
117824
117944
 
117945
+ // src/engine/score-run.ts
117946
+ function scoreChecks(checks, ignore, pages) {
117947
+ const allIssues = checks.flatMap((c) => c.issues);
117948
+ const acceptance = applyAcceptedFindings(checks, ignore.expectedDivergences ?? []);
117949
+ const remainingChecks = withoutAccepted(checks);
117950
+ const remainingIssues = remainingChecks.flatMap((c) => c.issues);
117951
+ const pagesAnalyzed = pairCaptures(pages.prodPages, pages.candPages).pairs.length;
117952
+ const scoreOf = (c, i) => {
117953
+ const mv = computeModuleVerdicts(c, i);
117954
+ return {
117955
+ moduleVerdicts: mv,
117956
+ verdict: mv.length > 0 ? computeCompositeVerdict(mv, c, i) : computeVerdict(c, i, { pagesAnalyzed })
117957
+ };
117958
+ };
117959
+ const scored = scoreOf(remainingChecks, remainingIssues);
117960
+ if (acceptance.accepted > 0)
117961
+ scored.verdict.rawScore = scoreOf(checks, allIssues).verdict.score;
117962
+ return {
117963
+ allIssues,
117964
+ acceptance,
117965
+ remainingChecks,
117966
+ remainingIssues,
117967
+ pagesAnalyzed,
117968
+ moduleVerdicts: scored.moduleVerdicts,
117969
+ verdict: scored.verdict
117970
+ };
117971
+ }
117972
+
117825
117973
  // src/commands/run.ts
117826
117974
  init_client();
117827
117975
 
@@ -119153,26 +119301,17 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
119153
119301
  for (const c of checks)
119154
119302
  jsonl.write(checkToJsonl(runId, c));
119155
119303
  }
119156
- const allIssues = checks.flatMap((c) => c.issues);
119157
- const acceptance = applyAcceptedFindings(checks, ignore.expectedDivergences ?? []);
119158
- const remainingChecks = withoutAccepted(checks);
119159
- const remainingIssues = remainingChecks.flatMap((c) => c.issues);
119304
+ const {
119305
+ allIssues,
119306
+ acceptance,
119307
+ remainingIssues,
119308
+ moduleVerdicts,
119309
+ verdict: scored
119310
+ } = scoreChecks(checks, ignore, checkCtx);
119160
119311
  const topIssues = rankTopIssues(remainingIssues);
119161
119312
  currentPhase = "report";
119162
- const pagesAnalyzed = pairCaptures(checkCtx.prodPages, checkCtx.candPages).pairs.length;
119163
- const scoreOf = (c, i) => {
119164
- const mv = computeModuleVerdicts(c, i);
119165
- return {
119166
- moduleVerdicts: mv,
119167
- verdict: mv.length > 0 ? computeCompositeVerdict(mv, c, i) : computeVerdict(c, i, { pagesAnalyzed })
119168
- };
119169
- };
119170
- const scored = scoreOf(remainingChecks, remainingIssues);
119171
- const { moduleVerdicts } = scored;
119172
- if (acceptance.accepted > 0)
119173
- scored.verdict.rawScore = scoreOf(checks, allIssues).verdict.score;
119174
119313
  const pagePairs = explicitPaths ? measurePagePairs(explicitPaths, viewports, { prod: opts.prod, cand: opts.cand }, allPageCaptures) : undefined;
119175
- const verdict = verdictForPagePairs(scored.verdict, pagePairs);
119314
+ const verdict = verdictForPagePairs(scored, pagePairs);
119176
119315
  if (moduleDropReason) {
119177
119316
  verdict.modulesSkipped = [{ module: "e2e", reason: moduleDropReason }];
119178
119317
  }
@@ -122532,24 +122671,229 @@ async function rerenderCommand(opts) {
122532
122671
  }
122533
122672
  }
122534
122673
 
122535
- // src/commands/serve.ts
122536
- import { existsSync as existsSync38 } from "node:fs";
122674
+ // src/commands/replay.ts
122537
122675
  import chalk41 from "chalk";
122676
+
122677
+ // 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";
122680
+ import { z as z6 } from "zod";
122681
+ var EXPECTED_FILE = "expected.json";
122682
+ var ReplayOutcome = z6.object({
122683
+ formatVersion: z6.literal(1),
122684
+ parityVersion: z6.string(),
122685
+ generatedAt: z6.string(),
122686
+ checks: z6.record(z6.string(), z6.string()),
122687
+ issues: z6.array(z6.string()),
122688
+ verdict: z6.object({ status: z6.string(), score: z6.number() }),
122689
+ notes: z6.string().optional()
122690
+ });
122691
+ function buildOutcome(checks, issues, verdict, parityVersion) {
122692
+ const byName = Object.fromEntries([...checks].sort((a, b) => a.name.localeCompare(b.name)).map((c) => [c.name, c.status]));
122693
+ return {
122694
+ formatVersion: 1,
122695
+ parityVersion,
122696
+ generatedAt: new Date().toISOString(),
122697
+ checks: byName,
122698
+ issues: [...new Set(issues.map((i) => i.id))].sort(),
122699
+ verdict: { status: verdict.status, score: verdict.score }
122700
+ };
122701
+ }
122702
+ function readExpected(dir) {
122703
+ const file = join52(dir, EXPECTED_FILE);
122704
+ if (!existsSync38(file))
122705
+ throw new Error(`${file} not found (record the expectation with --update-expected)`);
122706
+ return ReplayOutcome.parse(JSON.parse(readFileSync45(file, "utf8")));
122707
+ }
122708
+ function writeExpected(dir, outcome) {
122709
+ const file = join52(dir, EXPECTED_FILE);
122710
+ const notes = existsSync38(file) ? readExpected(dir).notes : undefined;
122711
+ const { notes: _drop, ...rest } = outcome;
122712
+ writeFileSync38(file, `${JSON.stringify({ ...rest, ...notes !== undefined ? { notes } : {} }, null, 2)}
122713
+ `, "utf8");
122714
+ }
122715
+ function diffOutcome(expected, actual) {
122716
+ const names = [
122717
+ ...new Set([...Object.keys(expected.checks), ...Object.keys(actual.checks)])
122718
+ ].sort();
122719
+ const statusChanged = names.filter((n) => expected.checks[n] !== actual.checks[n]).map((check) => ({
122720
+ check,
122721
+ expected: expected.checks[check] ?? "(absent)",
122722
+ actual: actual.checks[check] ?? "(absent)"
122723
+ }));
122724
+ const exp = new Set(expected.issues);
122725
+ const act = new Set(actual.issues);
122726
+ return {
122727
+ statusChanged,
122728
+ issuesAdded: [...act].filter((i) => !exp.has(i)).sort(),
122729
+ issuesRemoved: [...exp].filter((i) => !act.has(i)).sort(),
122730
+ ...expected.verdict.status !== actual.verdict.status ? { verdictChanged: { expected: expected.verdict.status, actual: actual.verdict.status } } : {},
122731
+ ...expected.verdict.score !== actual.verdict.score ? { scoreChanged: { expected: expected.verdict.score, actual: actual.verdict.score } } : {}
122732
+ };
122733
+ }
122734
+ function outcomeMatches(d) {
122735
+ return d.statusChanged.length === 0 && d.issuesAdded.length === 0 && d.issuesRemoved.length === 0 && !d.verdictChanged;
122736
+ }
122737
+ function formatDiff(d) {
122738
+ return [
122739
+ ...d.statusChanged.map((s) => `check ${s.check}: ${s.expected} -> ${s.actual}`),
122740
+ ...d.issuesAdded.map((i) => `issue added: ${i}`),
122741
+ ...d.issuesRemoved.map((i) => `issue removed: ${i}`),
122742
+ ...d.verdictChanged ? [`verdict: ${d.verdictChanged.expected} -> ${d.verdictChanged.actual}`] : [],
122743
+ ...d.scoreChanged ? [`score (informational): ${d.scoreChanged.expected} -> ${d.scoreChanged.actual}`] : []
122744
+ ];
122745
+ }
122746
+
122747
+ // src/replay/replay.ts
122748
+ import { mkdirSync as mkdirSync24, mkdtempSync as mkdtempSync2, rmSync as rmSync6 } from "node:fs";
122749
+ import { tmpdir as tmpdir3 } from "node:os";
122750
+ import { join as join53 } from "node:path";
122751
+ class NothingToJudgeError extends Error {
122752
+ name = "NothingToJudgeError";
122753
+ }
122754
+ async function replayRecording(dir, opts = {}) {
122755
+ const rec = loadCheckContext(dir);
122756
+ const pagePairs = pairCaptures(rec.ctx.prodPages, rec.ctx.candPages).pairs.length;
122757
+ const flows = rec.ctx.prodFlows.length + rec.ctx.candFlows.length;
122758
+ if (pagePairs === 0 && flows === 0) {
122759
+ throw new NothingToJudgeError(`nothing was compared: ${dir} holds no page pairs and no flows`);
122760
+ }
122761
+ const ownsOutDir = opts.outDir === undefined;
122762
+ const outDir = opts.outDir ?? mkdtempSync2(join53(tmpdir3(), "parity-replay-"));
122763
+ mkdirSync24(outDir, { recursive: true });
122764
+ const ctx = { ...rec.ctx, outDir };
122765
+ const unrecorded = new Set;
122766
+ const restore = replayFetch(rec.fetchLog);
122767
+ const replayed = globalThis.fetch;
122768
+ globalThis.fetch = async (input, init) => {
122769
+ try {
122770
+ return await replayed(input, init);
122771
+ } catch (err) {
122772
+ if (err instanceof UnrecordedFetchError)
122773
+ unrecorded.add(err.message.replace(/^replay: /, ""));
122774
+ throw err;
122775
+ }
122776
+ };
122777
+ let checks;
122778
+ try {
122779
+ checks = await runAllChecks(ctx, undefined, rec.meta.checkNames ? new Set(rec.meta.checkNames) : undefined);
122780
+ } finally {
122781
+ restore();
122782
+ if (ownsOutDir)
122783
+ rmSync6(outDir, { recursive: true, force: true });
122784
+ }
122785
+ if (checks.length === 0) {
122786
+ throw new NothingToJudgeError(`nothing was compared: no check ran (recorded selection: ${rec.meta.checkNames?.join(", ") ?? "all"})`);
122787
+ }
122788
+ if (unrecorded.size === 0 && checks.every((c) => c.status === "skipped")) {
122789
+ throw new NothingToJudgeError(`nothing was compared: every check was skipped (${checks.length} checks)`);
122790
+ }
122791
+ const scored = scoreChecks(checks, ctx.ignore, ctx);
122792
+ return {
122793
+ checks,
122794
+ issues: scored.allIssues,
122795
+ verdict: scored.verdict,
122796
+ meta: rec.meta,
122797
+ missingFiles: rec.missingFiles,
122798
+ unrecordedFetches: [...unrecorded].sort(),
122799
+ incomplete: unrecorded.size > 0,
122800
+ pagePairs,
122801
+ outcome: buildOutcome(checks, scored.allIssues, scored.verdict, getPackageVersion())
122802
+ };
122803
+ }
122804
+
122805
+ // src/commands/replay.ts
122806
+ async function replayCommand(dir, opts) {
122807
+ const say = (s) => opts.json ? console.error(s) : console.log(s);
122808
+ if (opts.expect && opts.updateExpected) {
122809
+ console.error("replay: --expect and --update-expected are mutually exclusive");
122810
+ return 2;
122811
+ }
122812
+ let r;
122813
+ try {
122814
+ if (opts.expect)
122815
+ readExpected(dir);
122816
+ r = await replayRecording(dir, { outDir: opts.out });
122817
+ } catch (err) {
122818
+ console.error(chalk41.red(`replay: ${err.message}`));
122819
+ return 2;
122820
+ }
122821
+ if (r.incomplete) {
122822
+ if (opts.json) {
122823
+ console.log(JSON.stringify({ incomplete: true, unrecordedFetches: r.unrecordedFetches, meta: r.meta }, null, 2));
122824
+ }
122825
+ console.error(chalk41.red("replay: INCOMPLETE - the recording predates a request the checks now make; re-record it. Requests not in the recording:"));
122826
+ for (const u of r.unrecordedFetches)
122827
+ console.error(chalk41.red(` ${u}`));
122828
+ return 2;
122829
+ }
122830
+ let diffLines;
122831
+ let code = 0;
122832
+ if (opts.updateExpected) {
122833
+ try {
122834
+ writeExpected(dir, r.outcome);
122835
+ } catch (err) {
122836
+ console.error(chalk41.red(`replay: ${err.message}`));
122837
+ return 2;
122838
+ }
122839
+ } else if (opts.expect) {
122840
+ const d = diffOutcome(readExpected(dir), r.outcome);
122841
+ diffLines = formatDiff(d);
122842
+ if (!outcomeMatches(d))
122843
+ code = 1;
122844
+ }
122845
+ if (opts.json) {
122846
+ console.log(JSON.stringify({
122847
+ meta: r.meta,
122848
+ outcome: r.outcome,
122849
+ verdict: r.verdict,
122850
+ pagePairs: r.pagePairs,
122851
+ missingFiles: r.missingFiles,
122852
+ ...diffLines ? { matches: code === 0, diff: diffLines } : {}
122853
+ }, null, 2));
122854
+ return code;
122855
+ }
122856
+ const v = r.verdict;
122857
+ const mark = v.status === "inconclusive" ? chalk41.dim("○") : v.status === "pass" ? chalk41.green("✔") : v.status === "warn" ? chalk41.yellow("⚠") : chalk41.red("✖");
122858
+ const score = v.status === "inconclusive" ? "—" : v.score;
122859
+ say(` ${mark} parity ${v.status.toUpperCase()} · score ${score}/100 · ${r.pagePairs} page pairs`);
122860
+ say(` checks: ${v.checksPassed} pass · ${v.checksFailed} fail · ${v.checksSkipped} skipped`);
122861
+ say(` issues: ${v.critical} critical · ${v.high} high · ${v.medium} medium · ${v.low} low`);
122862
+ say(chalk41.dim(` recorded ${r.meta.recordedAt} with parity ${r.meta.parityVersion ?? "(unknown version)"}`));
122863
+ if (r.missingFiles.length > 0) {
122864
+ say(chalk41.yellow(` ${r.missingFiles.length} referenced file(s) were missing when this was recorded; checks that read them judged less than a full run`));
122865
+ }
122866
+ if (opts.updateExpected)
122867
+ say(chalk41.dim(" expected.json written"));
122868
+ if (diffLines) {
122869
+ if (code === 0)
122870
+ say(chalk41.green(" matches expected.json"));
122871
+ else
122872
+ say(chalk41.red(" differs from expected.json:"));
122873
+ for (const l of diffLines)
122874
+ say(` ${l}`);
122875
+ }
122876
+ return code;
122877
+ }
122878
+
122879
+ // src/commands/serve.ts
122880
+ import { existsSync as existsSync39 } from "node:fs";
122881
+ import chalk42 from "chalk";
122538
122882
  async function serveRunAndBlock(runDir, opts = {}) {
122539
122883
  let handle;
122540
122884
  try {
122541
122885
  handle = await startProxyServer(runDir, { port: opts.port });
122542
122886
  } catch (err) {
122543
- console.error(chalk41.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
122887
+ console.error(chalk42.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
122544
122888
  return 2;
122545
122889
  }
122546
122890
  const label = opts.label ?? "parity serve";
122547
122891
  console.log("");
122548
- console.log(chalk41.bold(` ${label}`));
122549
- console.log(` ${chalk41.green("●")} ${handle.url}`);
122550
- console.log(chalk41.dim(` Servindo: ${runDir}`));
122551
- console.log(chalk41.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
122552
- console.log(chalk41.dim(` Ctrl+C pra parar (2x pra forçar saída).
122892
+ console.log(chalk42.bold(` ${label}`));
122893
+ console.log(` ${chalk42.green("●")} ${handle.url}`);
122894
+ console.log(chalk42.dim(` Servindo: ${runDir}`));
122895
+ console.log(chalk42.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
122896
+ console.log(chalk42.dim(` Ctrl+C pra parar (2x pra forçar saída).
122553
122897
  `));
122554
122898
  if (opts.open !== false) {
122555
122899
  const { default: open } = await import("open");
@@ -122581,14 +122925,14 @@ async function serveRunAndBlock(runDir, opts = {}) {
122581
122925
  }
122582
122926
  async function serveCommand(runId, opts) {
122583
122927
  const paths = getRunPaths(opts.output, runId);
122584
- if (!existsSync38(paths.runDir)) {
122585
- console.error(chalk41.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
122928
+ if (!existsSync39(paths.runDir)) {
122929
+ console.error(chalk42.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
122586
122930
  return 1;
122587
122931
  }
122588
122932
  try {
122589
122933
  ensureReportHtml(paths);
122590
122934
  } catch (err) {
122591
- console.error(chalk41.red(`✖ não foi possível gerar report.html: ${err.message}`));
122935
+ console.error(chalk42.red(`✖ não foi possível gerar report.html: ${err.message}`));
122592
122936
  return 1;
122593
122937
  }
122594
122938
  return serveRunAndBlock(paths.runDir, {
@@ -122599,7 +122943,7 @@ async function serveCommand(runId, opts) {
122599
122943
  }
122600
122944
 
122601
122945
  // src/commands/states.ts
122602
- import chalk42 from "chalk";
122946
+ import chalk43 from "chalk";
122603
122947
  var ROOT_ATTR = "data-parity-states";
122604
122948
  var rootSelector = (i) => `[${ROOT_ATTR}="${i}"]`;
122605
122949
  function resolveStateRoots(args) {
@@ -122908,7 +123252,7 @@ function statesVerdict(counts) {
122908
123252
  async function statesCommand(opts) {
122909
123253
  const viewport = parseViewport(opts.viewport);
122910
123254
  if (!viewport) {
122911
- console.error(chalk42.red(`--viewport inválido: ${opts.viewport}`));
123255
+ console.error(chalk43.red(`--viewport inválido: ${opts.viewport}`));
122912
123256
  return 2;
122913
123257
  }
122914
123258
  const waitMs = Number.parseInt(opts.wait, 10) || 0;
@@ -122918,12 +123262,12 @@ async function statesCommand(opts) {
122918
123262
  const prodSelector = opts.prodSelector?.trim() || opts.selector?.trim();
122919
123263
  const candSelector = opts.candSelector?.trim() || opts.selector?.trim();
122920
123264
  if (!prodSelector || !candSelector) {
122921
- console.error(chalk42.red(" informe --selector (ambos os lados) ou --prod-selector e --cand-selector"));
123265
+ console.error(chalk43.red(" informe --selector (ambos os lados) ou --prod-selector e --cand-selector"));
122922
123266
  return 2;
122923
123267
  }
122924
123268
  const { aliases, note: aliasNote } = resolveAliases(opts.planDir);
122925
123269
  if (aliasNote)
122926
- console.log(chalk42.dim(` ${aliasNote}`));
123270
+ console.log(chalk43.dim(` ${aliasNote}`));
122927
123271
  const browser = await launchBrowser({ headless: true });
122928
123272
  try {
122929
123273
  const [prodSide, candSide] = await Promise.all([
@@ -122948,7 +123292,7 @@ async function statesCommand(opts) {
122948
123292
  ]);
122949
123293
  if (prodSide.baseError || candSide.baseError) {
122950
123294
  const which = prodSide.baseError ? `prod: ${prodSide.baseError}` : `cand: ${candSide.baseError}`;
122951
- console.error(chalk42.red(` não foi possível ler o componente — ${which}`));
123295
+ console.error(chalk43.red(` não foi possível ler o componente — ${which}`));
122952
123296
  return 2;
122953
123297
  }
122954
123298
  for (const [name, side, sel] of [
@@ -122957,13 +123301,13 @@ async function statesCommand(opts) {
122957
123301
  ]) {
122958
123302
  const r = side.resolution;
122959
123303
  if (r?.kind === "ambiguous") {
122960
- console.error(chalk42.red(` ${name}: ${sel} matches ${r.total} visible elements and none looks like a product card (image + link + price). Narrow it to one:`));
123304
+ console.error(chalk43.red(` ${name}: ${sel} matches ${r.total} visible elements and none looks like a product card (image + link + price). Narrow it to one:`));
122961
123305
  for (const sample of r.samples)
122962
- console.error(chalk42.dim(` ${sample}`));
123306
+ console.error(chalk43.dim(` ${sample}`));
122963
123307
  return 2;
122964
123308
  }
122965
123309
  if (!r || r.kind === "none") {
122966
- console.error(chalk42.red(` ${name}: ${sel} matches no visible element${r?.error ? ` — ${r.error}` : ""}`));
123310
+ console.error(chalk43.red(` ${name}: ${sel} matches no visible element${r?.error ? ` — ${r.error}` : ""}`));
122967
123311
  return 2;
122968
123312
  }
122969
123313
  }
@@ -123045,21 +123389,21 @@ async function statesCommand(opts) {
123045
123389
  ]) {
123046
123390
  const caveat = data.settle && formatSettleCaveat(name, data.settle);
123047
123391
  if (caveat)
123048
- console.log(chalk42.yellow(` ${caveat}`));
123392
+ console.log(chalk43.yellow(` ${caveat}`));
123049
123393
  }
123050
123394
  if (cardMode) {
123051
123395
  console.log("");
123052
- console.log(chalk42.bold(` Product cards: ${pairing.pairs.length} pair(s) — ${pairing.pairs.map(([p, c]) => `prod #${p + 1} ↔ cand #${c + 1}`).join(", ") || "none"}`));
123396
+ console.log(chalk43.bold(` Product cards: ${pairing.pairs.length} pair(s) — ${pairing.pairs.map(([p, c]) => `prod #${p + 1} ↔ cand #${c + 1}`).join(", ") || "none"}`));
123053
123397
  for (const [name, side] of [
123054
123398
  ["prod", prodSide],
123055
123399
  ["cand", candSide]
123056
123400
  ]) {
123057
123401
  const r = side.resolution;
123058
123402
  if (r?.kind === "cards" && r.ignored > 0) {
123059
- console.log(chalk42.dim(` ${name}: ${r.ignored} matched element(s) are not product cards and were ignored`));
123403
+ console.log(chalk43.dim(` ${name}: ${r.ignored} matched element(s) are not product cards and were ignored`));
123060
123404
  }
123061
123405
  if (r?.kind === "single" && !r.isCard) {
123062
- console.log(chalk42.yellow(` ${name}: the selector names one element that is not a product card; it is never paired with a card`));
123406
+ console.log(chalk43.yellow(` ${name}: the selector names one element that is not a product card; it is never paired with a card`));
123063
123407
  }
123064
123408
  }
123065
123409
  const unpaired = [
@@ -123067,65 +123411,65 @@ async function statesCommand(opts) {
123067
123411
  ...pairing.unpairedCand.map((i) => `cand #${i + 1}`)
123068
123412
  ];
123069
123413
  if (unpaired.length)
123070
- console.log(chalk42.dim(` UNPAIRED cards: ${unpaired.join(", ")} — not compared`));
123414
+ console.log(chalk43.dim(` UNPAIRED cards: ${unpaired.join(", ")} — not compared`));
123071
123415
  if (pairing.pairs.length === 0) {
123072
- console.log(chalk42.yellow(" INCONCLUSIVE — no card paired, so nothing was compared."));
123416
+ console.log(chalk43.yellow(" INCONCLUSIVE — no card paired, so nothing was compared."));
123073
123417
  }
123074
123418
  }
123075
123419
  console.log("");
123076
- console.log(chalk42.bold(" Declared motion"));
123420
+ console.log(chalk43.bold(" Declared motion"));
123077
123421
  if (!motion) {
123078
123422
  const err = prodFlat.motionError ?? candFlat.motionError ?? "nothing paired";
123079
- console.log(chalk42.yellow(` não foi possível comparar — ${err}`));
123423
+ console.log(chalk43.yellow(` não foi possível comparar — ${err}`));
123080
123424
  } else {
123081
123425
  for (const line of formatMotionDiff(motion).split(`
123082
123426
  `))
123083
123427
  console.log(` ${line}`);
123084
123428
  }
123085
123429
  console.log("");
123086
- console.log(chalk42.bold(` Hover effects (${prodFlat.effects.length} prod / ${candFlat.effects.length} cand)`));
123430
+ console.log(chalk43.bold(` Hover effects (${prodFlat.effects.length} prod / ${candFlat.effects.length} cand)`));
123087
123431
  const nothing = effects.lost.length === 0 && effects.changed.length === 0 && effects.added.length === 0 && effects.unpaired.length === 0;
123088
123432
  if (nothing && !exercised) {
123089
- console.log(chalk42.yellow(" INCONCLUSIVE — no hover changed anything on either side, so nothing was exercised. Check the selector holds an interactive element."));
123433
+ console.log(chalk43.yellow(" INCONCLUSIVE — no hover changed anything on either side, so nothing was exercised. Check the selector holds an interactive element."));
123090
123434
  } else if (nothing) {
123091
123435
  console.log(" clean — every hover that changes something in prod changes the same in cand");
123092
123436
  }
123093
123437
  for (const e of effects.lost) {
123094
- console.log(chalk42.red(` LOST ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; cand's element was hovered and moved nothing`));
123438
+ console.log(chalk43.red(` LOST ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; cand's element was hovered and moved nothing`));
123095
123439
  }
123096
123440
  for (const { prod, extra, notComparable, onElement } of effects.changed) {
123097
123441
  console.log(` DIFFERS ${prod.target}${prod.label ? ` (${prod.label})` : ""}`);
123098
123442
  if (onElement.length) {
123099
- console.log(chalk42.yellow(` prod also moves [${onElement.join(", ")}] on the element itself`));
123443
+ console.log(chalk43.yellow(` prod also moves [${onElement.join(", ")}] on the element itself`));
123100
123444
  }
123101
123445
  if (extra.length)
123102
123446
  console.log(` cand also moves [${extra.join(", ")}]`);
123103
123447
  if (notComparable.length) {
123104
- console.log(chalk42.dim(` not comparable: [${notComparable.join(", ")}] — prod's hover renumbered ${prod.renumberedNodes} of the changed paths, so these were read on elements that are not the same ones before and after. Bench the component, or pick a selector whose subtree the hover does not restructure.`));
123448
+ console.log(chalk43.dim(` not comparable: [${notComparable.join(", ")}] — prod's hover renumbered ${prod.renumberedNodes} of the changed paths, so these were read on elements that are not the same ones before and after. Bench the component, or pick a selector whose subtree the hover does not restructure.`));
123105
123449
  }
123106
123450
  if (onElement.length === 0 && extra.length === 0) {
123107
- console.log(chalk42.dim(" nothing comparable differs."));
123451
+ console.log(chalk43.dim(" nothing comparable differs."));
123108
123452
  }
123109
123453
  }
123110
123454
  for (const e of effects.unpaired) {
123111
- console.log(chalk42.dim(` UNPAIRED ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; no matching element found on the cand side (not a defect — the port may have changed the element, or it is outside --selector)`));
123455
+ console.log(chalk43.dim(` UNPAIRED ${e.target}${e.label ? ` (${e.label})` : ""} — prod moves [${e.properties.join(", ")}]; no matching element found on the cand side (not a defect — the port may have changed the element, or it is outside --selector)`));
123112
123456
  }
123113
123457
  for (const e of effects.added) {
123114
123458
  console.log(` ADDED ${e.target} — cand moves [${e.properties.join(", ")}]; prod does not`);
123115
123459
  }
123116
123460
  if (effects.unpaired.length > 0 && effects.lost.length === 0 && effects.changed.length === 0) {
123117
123461
  console.log("");
123118
- console.log(chalk42.yellow(` ${effects.unpaired.length} prod effect(s) had no counterpart and NOTHING paired. That is a pairing failure, not a set of defects — check --selector contains the same component on both sides, and that ported roots carry data-section.`));
123462
+ console.log(chalk43.yellow(` ${effects.unpaired.length} prod effect(s) had no counterpart and NOTHING paired. That is a pairing failure, not a set of defects — check --selector contains the same component on both sides, and that ported roots carry data-section.`));
123119
123463
  }
123120
123464
  const prodAmbient = prodSide.roots.reduce((n, r) => n + r.ambient, 0);
123121
123465
  const candAmbient = candSide.roots.reduce((n, r) => n + r.ambient, 0);
123122
123466
  if (prodAmbient > 0 || candAmbient > 0) {
123123
- console.log(chalk42.dim(` ${prodAmbient} prod / ${candAmbient} cand node+property pair(s) were moving with no interaction (carousel, autoplaying video, anything on a timer) and were subtracted. A large count means --selector contains something animating on its own; narrow it.`));
123467
+ console.log(chalk43.dim(` ${prodAmbient} prod / ${candAmbient} cand node+property pair(s) were moving with no interaction (carousel, autoplaying video, anything on a timer) and were subtracted. A large count means --selector contains something animating on its own; narrow it.`));
123124
123468
  }
123125
123469
  for (const cap of caps)
123126
- console.log(chalk42.yellow(` CAPPED — ${cap}; absence of a finding is not proof`));
123470
+ console.log(chalk43.yellow(` CAPPED — ${cap}; absence of a finding is not proof`));
123127
123471
  if (truncated) {
123128
- console.log(chalk42.dim(" TRUNCATED — box-tree or motion node cap hit; absence of a finding is not proof"));
123472
+ console.log(chalk43.dim(" TRUNCATED — box-tree or motion node cap hit; absence of a finding is not proof"));
123129
123473
  }
123130
123474
  return inconclusive || effects.lost.length > 0 || (motion?.findings.length ?? 0) > 0 ? 1 : 0;
123131
123475
  } finally {
@@ -123137,7 +123481,7 @@ async function statesCommand(opts) {
123137
123481
 
123138
123482
  // src/commands/stress.ts
123139
123483
  import { createHash as createHash3 } from "node:crypto";
123140
- import chalk43 from "chalk";
123484
+ import chalk44 from "chalk";
123141
123485
  var STATIC = /\.(png|jpe?g|webp|avif|gif|svg|woff2?|ttf|css|js|map|ico)(\?|$)/i;
123142
123486
  function analyzeStress(requests, extra) {
123143
123487
  const groups = new Map;
@@ -123167,7 +123511,7 @@ function analyzeStress(requests, extra) {
123167
123511
  }
123168
123512
  async function stressCommand(opts) {
123169
123513
  if (!opts.selector && !opts.text) {
123170
- console.error(chalk43.red("pass --selector or --text"));
123514
+ console.error(chalk44.red("pass --selector or --text"));
123171
123515
  return 2;
123172
123516
  }
123173
123517
  const browser = await launchBrowser({ headless: true });
@@ -123194,7 +123538,7 @@ async function stressCommand(opts) {
123194
123538
  const target = (opts.selector ? page.locator(opts.selector) : page.getByText(opts.text, { exact: true })).filter({ visible: true }).first();
123195
123539
  const box = await target.boundingBox().catch(() => null);
123196
123540
  if (!box) {
123197
- console.error(chalk43.yellow("target matched no visible element — nothing was stressed"));
123541
+ console.error(chalk44.yellow("target matched no visible element — nothing was stressed"));
123198
123542
  return 2;
123199
123543
  }
123200
123544
  const handle = await target.elementHandle().catch(() => null);
@@ -123245,17 +123589,17 @@ async function stressCommand(opts) {
123245
123589
  console.log(JSON.stringify({ url: opts.url, target: opts.selector ?? opts.text, ...report }));
123246
123590
  return 0;
123247
123591
  }
123248
- console.log(chalk43.bold(`
123592
+ console.log(chalk44.bold(`
123249
123593
  ${opts.times} clicks on ${opts.selector ?? `"${opts.text}"`}`));
123250
123594
  console.log(` ${report.requests} request(s), ${report.mutations} mutating · disabled after 1st click: ${report.disabledAfterFirstClick ?? "?"}`);
123251
123595
  for (const d of report.duplicates)
123252
- console.log(chalk43.yellow(` ×${d.count} ${d.method} ${d.url.slice(0, 110)} [${d.statuses.join(",")}]`));
123596
+ console.log(chalk44.yellow(` ×${d.count} ${d.method} ${d.url.slice(0, 110)} [${d.statuses.join(",")}]`));
123253
123597
  for (const f of report.failed.filter((f) => !report.duplicates.includes(f)))
123254
- console.log(chalk43.red(` failed ${f.method} ${f.url.slice(0, 110)} [${f.statuses.join(",")}]`));
123598
+ console.log(chalk44.red(` failed ${f.method} ${f.url.slice(0, 110)} [${f.statuses.join(",")}]`));
123255
123599
  for (const e of report.consoleErrors.slice(0, 5))
123256
- console.log(chalk43.red(` console: ${e}`));
123600
+ console.log(chalk44.red(` console: ${e}`));
123257
123601
  if (opts.screenshot)
123258
- console.log(chalk43.dim(` final state: ${opts.screenshot}`));
123602
+ console.log(chalk44.dim(` final state: ${opts.screenshot}`));
123259
123603
  return 0;
123260
123604
  } finally {
123261
123605
  await browser.close().catch(() => {
@@ -123266,18 +123610,18 @@ async function stressCommand(opts) {
123266
123610
 
123267
123611
  // src/commands/studio.ts
123268
123612
  import { execFileSync as execFileSync6 } from "node:child_process";
123269
- import chalk44 from "chalk";
123613
+ import chalk45 from "chalk";
123270
123614
  var CLOSED2 = new Set(["done", "archived", "merged"]);
123271
123615
  var PRIORITY_RANK = { urgent: 0, high: 1, medium: 2, low: 3, none: 4 };
123272
123616
  function config() {
123273
123617
  const cfg = studioConfigFromEnv();
123274
123618
  if (!cfg) {
123275
- console.error(chalk44.red(`Studio not configured — ${STUDIO_LOGIN_HINT}. The org comes from PARITY_STUDIO_URL (…/api/<org>/mcp/self) or PARITY_STUDIO_ORG.`));
123619
+ console.error(chalk45.red(`Studio not configured — ${STUDIO_LOGIN_HINT}. The org comes from PARITY_STUDIO_URL (…/api/<org>/mcp/self) or PARITY_STUDIO_ORG.`));
123276
123620
  }
123277
123621
  return cfg;
123278
123622
  }
123279
123623
  function fail2(err) {
123280
- console.error(chalk44.red(err instanceof Error ? err.message : String(err)));
123624
+ console.error(chalk45.red(err instanceof Error ? err.message : String(err)));
123281
123625
  return 1;
123282
123626
  }
123283
123627
  function seq(t) {
@@ -123285,7 +123629,7 @@ function seq(t) {
123285
123629
  }
123286
123630
  function line(t) {
123287
123631
  const tags = [t.type, t.priority && t.priority !== "none" ? t.priority : null].filter(Boolean).join("·");
123288
- return `${chalk44.bold(seq(t).padEnd(6))} ${t.status.padEnd(12)} ${chalk44.dim(`[${tags}]`.padEnd(16))} ${t.title}${t.repo ? chalk44.dim(` ${t.repo}`) : ""}`;
123632
+ return `${chalk45.bold(seq(t).padEnd(6))} ${t.status.padEnd(12)} ${chalk45.dim(`[${tags}]`.padEnd(16))} ${t.title}${t.repo ? chalk45.dim(` ${t.repo}`) : ""}`;
123289
123633
  }
123290
123634
  async function resolveTask(cfg, ref, call) {
123291
123635
  const board = await listTasks2(cfg, call);
@@ -123309,13 +123653,13 @@ async function studioTasksCommand(opts, call = callTool2) {
123309
123653
  return 0;
123310
123654
  }
123311
123655
  if (board.items.length === 0) {
123312
- console.log(chalk44.yellow("The board is empty."));
123656
+ console.log(chalk45.yellow("The board is empty."));
123313
123657
  return 0;
123314
123658
  }
123315
123659
  for (const t of limited)
123316
123660
  console.log(line(t));
123317
123661
  const hidden = board.items.length - shown.length;
123318
- console.log(chalk44.dim(` ${shown.length} of ${board.items.length} task(s)${limited.length < shown.length ? `, first ${limited.length} shown` : ""}${hidden > 0 && !statuses && !opts.all ? ` · ${hidden} done/archived/merged or filtered out (--all shows them)` : ""}`));
123662
+ console.log(chalk45.dim(` ${shown.length} of ${board.items.length} task(s)${limited.length < shown.length ? `, first ${limited.length} shown` : ""}${hidden > 0 && !statuses && !opts.all ? ` · ${hidden} done/archived/merged or filtered out (--all shows them)` : ""}`));
123319
123663
  return 0;
123320
123664
  } catch (err) {
123321
123665
  return fail2(err);
@@ -123339,23 +123683,23 @@ async function studioShowCommand(opts, call = callTool2) {
123339
123683
  return 0;
123340
123684
  }
123341
123685
  console.log(line(task));
123342
- console.log(chalk44.dim(` id ${task.id}${task.statusSince ? ` · in ${task.status} since ${task.statusSince}` : ""}`));
123686
+ console.log(chalk45.dim(` id ${task.id}${task.statusSince ? ` · in ${task.status} since ${task.statusSince}` : ""}`));
123343
123687
  if (task.description)
123344
123688
  console.log(`
123345
123689
  ${task.description}
123346
123690
  `);
123347
123691
  if (prs === null)
123348
- console.log(chalk44.dim(" (could not read linked PRs)"));
123692
+ console.log(chalk45.dim(" (could not read linked PRs)"));
123349
123693
  for (const pr of prs ?? []) {
123350
123694
  const state = pr.merged ? "merged" : pr.draft ? "draft" : pr.state ?? "?";
123351
- console.log(` PR ${state.padEnd(7)} ${pr.url}${pr.title ? chalk44.dim(` ${pr.title}`) : ""}`);
123695
+ console.log(` PR ${state.padEnd(7)} ${pr.url}${pr.title ? chalk45.dim(` ${pr.title}`) : ""}`);
123352
123696
  }
123353
123697
  const open = comments.filter((c) => !c.resolved);
123354
123698
  if (open.length)
123355
- console.log(chalk44.bold(`
123699
+ console.log(chalk45.bold(`
123356
123700
  Comments (${open.length} open)`));
123357
123701
  for (const c of open)
123358
- console.log(` ${chalk44.dim(c.createdAt)} ${c.body.replace(/\n/g, `
123702
+ console.log(` ${chalk45.dim(c.createdAt)} ${c.body.replace(/\n/g, `
123359
123703
  `)}`);
123360
123704
  return 0;
123361
123705
  } catch (err) {
@@ -123374,7 +123718,7 @@ async function guardedMove(cfg, task, columns, to, opts, call) {
123374
123718
  if (!valid.includes(to))
123375
123719
  return fail2(new Error(`"${to}" is not a column of this board: ${valid.join(", ")}.`));
123376
123720
  if (task.status === to) {
123377
- console.log(chalk44.dim(`${seq(task)} is already in ${to}.`));
123721
+ console.log(chalk45.dim(`${seq(task)} is already in ${to}.`));
123378
123722
  return 0;
123379
123723
  }
123380
123724
  const automated = await automatedColumns(cfg, call);
@@ -123382,16 +123726,16 @@ async function guardedMove(cfg, task, columns, to, opts, call) {
123382
123726
  return fail2(new Error(`The "${to}" column has an automation: landing ${seq(task)} there starts the board's agent on it. Pass --allow-automation if that is the point.`));
123383
123727
  }
123384
123728
  if (!opts.yes) {
123385
- console.log(chalk44.yellow("dry run — nothing changed. Pass --yes."));
123729
+ console.log(chalk45.yellow("dry run — nothing changed. Pass --yes."));
123386
123730
  console.log(` ${seq(task)} ${task.status} → ${to} ${task.title}`);
123387
123731
  if (opts.comment)
123388
- console.log(chalk44.dim(` and comment: ${PARITY_COMMENT_PREFIX} ${opts.comment}`));
123732
+ console.log(chalk45.dim(` and comment: ${PARITY_COMMENT_PREFIX} ${opts.comment}`));
123389
123733
  return 0;
123390
123734
  }
123391
123735
  await moveTask(cfg, task.id, to, call);
123392
123736
  if (opts.comment)
123393
123737
  await postParityComment(task.id, opts.comment, cfg, call);
123394
- console.log(`${chalk44.green("✓")} ${seq(task)} ${task.status} → ${to} ${task.title}`);
123738
+ console.log(`${chalk45.green("✓")} ${seq(task)} ${task.status} → ${to} ${task.title}`);
123395
123739
  return 0;
123396
123740
  }
123397
123741
  async function studioTakeCommand(opts, call = callTool2) {
@@ -123440,12 +123784,12 @@ async function studioCommentCommand(opts, call = callTool2) {
123440
123784
  if (found instanceof Error)
123441
123785
  return fail2(found);
123442
123786
  if (!opts.yes) {
123443
- console.log(chalk44.yellow("dry run — nothing posted. Pass --yes."));
123787
+ console.log(chalk45.yellow("dry run — nothing posted. Pass --yes."));
123444
123788
  console.log(` on ${seq(found.task)}: ${PARITY_COMMENT_PREFIX} ${body}`);
123445
123789
  return 0;
123446
123790
  }
123447
123791
  await postParityComment(found.task.id, body, cfg, call);
123448
- console.log(`${chalk44.green("✓")} commented on ${seq(found.task)}`);
123792
+ console.log(`${chalk45.green("✓")} commented on ${seq(found.task)}`);
123449
123793
  return 0;
123450
123794
  } catch (err) {
123451
123795
  return fail2(err);
@@ -123454,9 +123798,9 @@ async function studioCommentCommand(opts, call = callTool2) {
123454
123798
 
123455
123799
  // src/commands/drift.ts
123456
123800
  import { spawnSync as spawnSync3 } from "node:child_process";
123457
- import { existsSync as existsSync39, readFileSync as readFileSync45 } from "node:fs";
123801
+ import { existsSync as existsSync40, readFileSync as readFileSync46 } from "node:fs";
123458
123802
  import { resolve as resolve23 } from "node:path";
123459
- import chalk45 from "chalk";
123803
+ import chalk46 from "chalk";
123460
123804
  var DRIFT_EXCLUDES = [":!.deco"];
123461
123805
  var SHA_RE = /^[0-9a-f]{7,64}$/i;
123462
123806
  function resolveDriftInputs(state, flags) {
@@ -123574,7 +123918,7 @@ function computeDrift(inputs, opts) {
123574
123918
  const fail = (code, message) => ({ error: { code, message } });
123575
123919
  if (headRef.startsWith("-"))
123576
123920
  return fail("bad_head", `head "${headRef}" looks like a flag`);
123577
- if (!existsSync39(source))
123921
+ if (!existsSync40(source))
123578
123922
  return fail("not_a_repo", `${source} does not exist`);
123579
123923
  const inside = git(source, ["rev-parse", "--is-inside-work-tree"]);
123580
123924
  if (!inside.ok || inside.stdout.trim() !== "true") {
@@ -123642,10 +123986,10 @@ function computeDrift(inputs, opts) {
123642
123986
  };
123643
123987
  }
123644
123988
  function loadState(path) {
123645
- if (!existsSync39(path))
123989
+ if (!existsSync40(path))
123646
123990
  return null;
123647
123991
  try {
123648
- return JSON.parse(readFileSync45(path, "utf8"));
123992
+ return JSON.parse(readFileSync46(path, "utf8"));
123649
123993
  } catch (err) {
123650
123994
  return { error: { code: "state_unreadable", message: `${path}: ${err.message}` } };
123651
123995
  }
@@ -123669,7 +124013,7 @@ function driftCommand(flags) {
123669
124013
  if (flags.json)
123670
124014
  console.log(JSON.stringify({ error: r.error }));
123671
124015
  else
123672
- console.error(chalk45.red(` could not measure drift [${r.error.code}]: ${r.error.message}`));
124016
+ console.error(chalk46.red(` could not measure drift [${r.error.code}]: ${r.error.message}`));
123673
124017
  return 2;
123674
124018
  }
123675
124019
  if (flags.json) {
@@ -123688,7 +124032,7 @@ function driftCommand(flags) {
123688
124032
  }
123689
124033
 
123690
124034
  // src/commands/variance.ts
123691
- import chalk46 from "chalk";
124035
+ import chalk47 from "chalk";
123692
124036
 
123693
124037
  // src/diff/variance.ts
123694
124038
  var uniq2 = (xs) => [...new Set(xs)];
@@ -123792,7 +124136,7 @@ function formatVariance(report, opts = {}) {
123792
124136
  // src/commands/variance.ts
123793
124137
  function varianceCommand(opts) {
123794
124138
  if (opts.runIds.length < 2) {
123795
- console.error(chalk46.red(" informe pelo menos 2 runs: parity variance <runIdA> <runIdB> [...]"));
124139
+ console.error(chalk47.red(" informe pelo menos 2 runs: parity variance <runIdA> <runIdB> [...]"));
123796
124140
  return 2;
123797
124141
  }
123798
124142
  const budget = Number.parseFloat(opts.scoreBudget ?? "1");
@@ -123801,7 +124145,7 @@ function varianceCommand(opts) {
123801
124145
  try {
123802
124146
  runs.push(loadRun(opts.output, id));
123803
124147
  } catch (err) {
123804
- console.error(chalk46.red(` ✖ ${err.message}`));
124148
+ console.error(chalk47.red(` ✖ ${err.message}`));
123805
124149
  return 2;
123806
124150
  }
123807
124151
  }
@@ -123810,7 +124154,7 @@ function varianceCommand(opts) {
123810
124154
  console.log(JSON.stringify({ ...report, stable: isStable(report, budget), scoreBudget: budget }));
123811
124155
  } else {
123812
124156
  console.log("");
123813
- console.log(chalk46.bold(" Score variance"));
124157
+ console.log(chalk47.bold(" Score variance"));
123814
124158
  for (const line of formatVariance(report, { scoreBudget: budget }).split(`
123815
124159
  `)) {
123816
124160
  console.log(` ${line}`);
@@ -123822,10 +124166,10 @@ function varianceCommand(opts) {
123822
124166
  }
123823
124167
 
123824
124168
  // src/commands/vitals.ts
123825
- import { existsSync as existsSync40, readFileSync as readFileSync46, writeFileSync as writeFileSync38 } from "node:fs";
124169
+ import { existsSync as existsSync41, readFileSync as readFileSync47, writeFileSync as writeFileSync39 } from "node:fs";
123826
124170
  import { availableParallelism } from "node:os";
123827
- import { join as join52 } from "node:path";
123828
- import chalk47 from "chalk";
124171
+ import { join as join54 } from "node:path";
124172
+ import chalk48 from "chalk";
123829
124173
  import ora9 from "ora";
123830
124174
 
123831
124175
  // src/checks/agentic-nav.ts
@@ -124129,10 +124473,10 @@ async function vitalsCommand(opts) {
124129
124473
  const runId = newRunId();
124130
124474
  const paths = createRunDir(opts.output, runId);
124131
124475
  const t0 = Date.now();
124132
- console.log(chalk47.bold(`
124476
+ console.log(chalk48.bold(`
124133
124477
  parity vitals ${runId}`));
124134
- console.log(chalk47.dim(` prod: ${opts.prod}`));
124135
- console.log(chalk47.dim(` cand: ${opts.cand}`));
124478
+ console.log(chalk48.dim(` prod: ${opts.prod}`));
124479
+ console.log(chalk48.dim(` cand: ${opts.cand}`));
124136
124480
  const discoverSpinner = ora9("Descobrindo páginas…").start();
124137
124481
  const pagePaths = await discoverPagePaths2(opts.prod, opts);
124138
124482
  if (pagePaths.length === 0) {
@@ -124164,12 +124508,12 @@ async function vitalsCommand(opts) {
124164
124508
  completed++;
124165
124509
  const elapsed = ((Date.now() - t0) / 1000).toFixed(0);
124166
124510
  const etaSec = completed > 0 ? Math.round((Date.now() - t0) / completed * (total - completed) / 1000) : 0;
124167
- progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk47.cyan("prod") : chalk47.magenta("cand")} ${task.path} (${task.viewport})`;
124511
+ progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk48.cyan("prod") : chalk48.magenta("cand")} ${task.path} (${task.viewport})`;
124168
124512
  }
124169
124513
  });
124170
124514
  progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
124171
124515
  if (opts.lighthouse !== false) {
124172
- const lhDir = join52(paths.runDir, "lighthouse");
124516
+ const lhDir = join54(paths.runDir, "lighthouse");
124173
124517
  const lhCap = opts.lighthouseConcurrency ?? Math.max(1, Math.min(2, Math.floor(availableParallelism() / 2)));
124174
124518
  const done = tasks.filter((t) => !!t.capture);
124175
124519
  const lhT0 = Date.now();
@@ -124193,7 +124537,7 @@ async function vitalsCommand(opts) {
124193
124537
  }
124194
124538
  lhCompleted++;
124195
124539
  const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
124196
- lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk47.cyan("prod") : chalk47.magenta("cand")} ${task.path} (${task.viewport})`;
124540
+ lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk48.cyan("prod") : chalk48.magenta("cand")} ${task.path} (${task.viewport})`;
124197
124541
  });
124198
124542
  lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
124199
124543
  }
@@ -124258,7 +124602,7 @@ async function vitalsCommand(opts) {
124258
124602
  writeRunReportJson(paths.runDir, run);
124259
124603
  const html = renderHtmlReport(run, paths.runDir);
124260
124604
  writeRunReportHtml(paths.runDir, html);
124261
- writeFileSync38(join52(paths.runDir, "vitals.json"), `${JSON.stringify({
124605
+ writeFileSync39(join54(paths.runDir, "vitals.json"), `${JSON.stringify({
124262
124606
  schemaVersion: "0.1",
124263
124607
  prodUrl: opts.prod,
124264
124608
  candUrl: opts.cand,
@@ -124271,8 +124615,8 @@ async function vitalsCommand(opts) {
124271
124615
  `, "utf8");
124272
124616
  printSummary9(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
124273
124617
  console.log("");
124274
- console.log(chalk47.dim(` → ${paths.reportHtml}`));
124275
- console.log(chalk47.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
124618
+ console.log(chalk48.dim(` → ${paths.reportHtml}`));
124619
+ console.log(chalk48.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
124276
124620
  console.log("");
124277
124621
  if (opts.open) {
124278
124622
  const { default: open } = await import("open");
@@ -124364,15 +124708,15 @@ async function discoverPagePaths2(prodUrl, opts) {
124364
124708
  function parseUrlList(input) {
124365
124709
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
124366
124710
  const path = input.replace(/^file:\/\//, "");
124367
- if (existsSync40(path)) {
124368
- return readFileSync46(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
124711
+ if (existsSync41(path)) {
124712
+ return readFileSync47(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
124369
124713
  }
124370
124714
  }
124371
124715
  return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
124372
124716
  }
124373
124717
  function printSummary9(vitals, cache, scores, opportunities, agentic) {
124374
124718
  console.log("");
124375
- console.log(chalk47.bold(" Summary:"));
124719
+ console.log(chalk48.bold(" Summary:"));
124376
124720
  console.log(` ${vitals.summary}`);
124377
124721
  console.log(` ${cache.summary}`);
124378
124722
  if (scores.status !== "skipped")
@@ -124436,10 +124780,10 @@ sweep.addCommand(new Command("regress").description("Run only the store's tests/
124436
124780
  if (opts.json)
124437
124781
  console.log(JSON.stringify({ url: opts.url, issues }));
124438
124782
  else if (!issues.length)
124439
- console.log(chalk48.green(" regression suite: all passed"));
124783
+ console.log(chalk49.green(" regression suite: all passed"));
124440
124784
  else
124441
124785
  for (const i of issues)
124442
- console.log((i.inconclusive ? chalk48.yellow : chalk48.red)(` ${i.summary}`));
124786
+ console.log((i.inconclusive ? chalk49.yellow : chalk49.red)(` ${i.summary}`));
124443
124787
  process.exit(regressed ? 1 : unverified ? 2 : 0);
124444
124788
  }));
124445
124789
  sweep.addCommand(new Command("file").description("File an existing sweep run's findings on the Studio board (default: the newest sweep run). Merges <run>/sweeper-issues.json written by the `sweeper` agent. Dry run unless --yes.").option("--run <runId>", "Sweep run id (default: newest sweep in --output)").option("--output <dir>", "Output directory", "./parity-output").option("--board <name>", "Board: studio", "studio").option("--yes", "Actually create/update cards", false).option("--allow-automation", "File even if the board's triage column starts an agent", false).option("--min-severity <sev>", "critical|high|medium|low", "medium").option("--repo <owner/name>", "Repository to put on the cards").option("--artifacts-url <url>", "Public base URL for this run's artifacts").option("--json", "Emit JSON", false).action(async (opts) => {
@@ -124455,6 +124799,9 @@ program.command("baseline").description("Manage baselines").addCommand(new Comma
124455
124799
  })).addCommand(new Command("unset").argument("<name>", "Baseline name to remove").action((name) => {
124456
124800
  process.exit(baselineUnset(name));
124457
124801
  })).addCommand(buildCompareCommand("diff", false));
124802
+ program.command("replay").description("Re-run the checks on a recording made with `parity run --record <dir>`, with no browser. Exit 0 = replayed (and matched expected.json with --expect), 1 = differs from expected.json, 2 = nothing could be judged (not a recording, incomplete, nothing compared, no expected.json).").argument("<dir>", "Recording directory").option("--json", "Emit structured JSON", false).option("--out <dir>", "Keep artifacts (diff PNGs) here instead of a temp dir removed afterwards").option("--expect", "Compare the outcome with <dir>/expected.json", false).option("--update-expected", "Write <dir>/expected.json from this replay (keeps its notes)", false).action(async (dir, opts) => {
124803
+ process.exit(await replayCommand(dir, opts));
124804
+ });
124458
124805
  program.command("accept").description("Record findings the USER accepted as-is, in .parityignore. They stay in the report but leave the headline score (`rawScore` keeps them). Never run by an agent on its own — accepting is how a real gap disappears from view.").addCommand(new Command("add").description("Accept every finding in a scope. Scope = --check and/or --id, narrowed by --page and --match. No --page = every page.").option("--check <name>", "Check name (meta-seo-parity) or module (network)").option("--id <issueId>", "One issue id (only stable ids are worth accepting)").option("--page <key>", "Only this page key, e.g. /::desktop").option("--match <text>", "Only findings whose summary/details contain this (case-insensitive)").requiredOption("--note <why>", "Why the difference is accepted — required").action((opts) => {
124459
124806
  process.exit(acceptAdd(opts));
124460
124807
  })).addCommand(new Command("list").description("List recorded acceptances with their index").action(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.35.24",
3
+ "version": "0.35.26",
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",