@decocms/parity 0.35.7 → 0.35.8
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.
- package/AGENTS.md +1 -1
- package/dist/cli.js +321 -474
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -85993,7 +85993,8 @@ var ModuleVerdict = z2.object({
|
|
|
85993
85993
|
medium: z2.number(),
|
|
85994
85994
|
low: z2.number(),
|
|
85995
85995
|
checksRun: z2.number(),
|
|
85996
|
-
pagesAnalyzed: z2.number()
|
|
85996
|
+
pagesAnalyzed: z2.number(),
|
|
85997
|
+
uncappedScore: z2.number().optional()
|
|
85997
85998
|
});
|
|
85998
85999
|
var RunCaveat = z2.object({
|
|
85999
86000
|
id: z2.string(),
|
|
@@ -87130,8 +87131,21 @@ var REPORT_CSS = `
|
|
|
87130
87131
|
.tile.state-warn { --tile-state: var(--state-warn); }
|
|
87131
87132
|
.tile.state-fail { --tile-state: var(--state-bad); }
|
|
87132
87133
|
.tile.state-info { --tile-state: var(--state-info); }
|
|
87133
|
-
|
|
87134
|
-
.
|
|
87134
|
+
/* Score breakdown + visual parity line (dashboard) */
|
|
87135
|
+
.visual-parity { margin: 6px 0 2px; font-size: 15px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
|
|
87136
|
+
.visual-parity span { font-size: 12px; color: var(--text-muted); }
|
|
87137
|
+
.score-breakdown { margin-bottom: 16px; }
|
|
87138
|
+
.sb-capped { font-size: 13px; color: var(--state-bad); background: var(--surface-overlay); border-left: 3px solid var(--state-bad); padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
|
|
87139
|
+
.sb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
87140
|
+
.sb-table th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border-default); }
|
|
87141
|
+
.sb-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-default); vertical-align: top; color: var(--text-primary); }
|
|
87142
|
+
.sb-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
87143
|
+
.sb-table small { color: var(--text-muted); }
|
|
87144
|
+
.sb-status { font-size: 11px; font-weight: 600; text-transform: uppercase; }
|
|
87145
|
+
.sb-cap { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
|
|
87146
|
+
.sb-lost { display: flex; align-items: center; gap: 8px; min-width: 180px; }
|
|
87147
|
+
.sb-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-overlay); overflow: hidden; }
|
|
87148
|
+
.sb-bar span { display: block; height: 100%; background: var(--state-bad); }
|
|
87135
87149
|
|
|
87136
87150
|
/* Cards */
|
|
87137
87151
|
.card {
|
|
@@ -87273,34 +87287,6 @@ var REPORT_CSS = `
|
|
|
87273
87287
|
.agentic-pillar { margin-top: 14px; }
|
|
87274
87288
|
.agentic-pillar-head { font-weight: 600; margin-bottom: 6px; }
|
|
87275
87289
|
|
|
87276
|
-
/* Side-by-side iframes */
|
|
87277
|
-
.sbs-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
|
|
87278
|
-
.sbs-toolbar button { background: var(--surface-overlay); color: var(--text-primary); border: 1px solid var(--border-default); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
|
|
87279
|
-
.sbs-toolbar button.active { background: var(--accent-action); color: var(--on-accent); border-color: var(--accent-action); }
|
|
87280
|
-
.sbs-toolbar button:hover { border-color: var(--accent-action); }
|
|
87281
|
-
/* Inferred URL pair — captured on only one side. Issue #77. */
|
|
87282
|
-
.sbs-toolbar button.sbs-btn-inferred { opacity: 0.7; border-style: dashed; }
|
|
87283
|
-
.sbs-toolbar .sbs-btn-flag {
|
|
87284
|
-
display: inline-block;
|
|
87285
|
-
margin-left: 4px;
|
|
87286
|
-
background: var(--state-warn);
|
|
87287
|
-
color: var(--surface-base);
|
|
87288
|
-
font-size: 10px;
|
|
87289
|
-
font-weight: 700;
|
|
87290
|
-
padding: 0 6px;
|
|
87291
|
-
border-radius: 8px;
|
|
87292
|
-
}
|
|
87293
|
-
.sbs-toolbar .label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
|
|
87294
|
-
.sbs-toolbar .toolbar-right { margin-left: auto; font-size: 11px; color: var(--text-muted); }
|
|
87295
|
-
.sbs-container { display: flex; gap: 16px; justify-content: center; align-items: flex-start; }
|
|
87296
|
-
.sbs-frame { display: flex; flex-direction: column; flex-shrink: 0; }
|
|
87297
|
-
.sbs-frame .frame-title { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
|
|
87298
|
-
.sbs-frame .frame-url { text-align: center; font-size: 11px; color: var(--text-muted); margin-bottom: 8px; word-break: break-all; max-width: 375px; }
|
|
87299
|
-
.sbs-iframe { width: 375px; height: 78vh; border: 1px solid var(--border-default); border-radius: 12px; background: white; }
|
|
87300
|
-
.sbs-status { font-size: 12px; padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }
|
|
87301
|
-
.sbs-status.ok { background: rgba(46,194,126,0.12); color: var(--state-good); border: 1px solid rgba(46,194,126,0.3); }
|
|
87302
|
-
.sbs-status.warn { background: rgba(245,166,35,0.12); color: var(--state-warn); border: 1px solid rgba(245,166,35,0.3); }
|
|
87303
|
-
|
|
87304
87290
|
/* LLM Prompt panel */
|
|
87305
87291
|
.prompt-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
|
|
87306
87292
|
.prompt-toolbar button { background: var(--accent-action); color: var(--on-accent); border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
|
|
@@ -88118,8 +88104,7 @@ var REPORT_CSS = `
|
|
|
88118
88104
|
/* Accessibility — keyboard focus rings. Issue #81. */
|
|
88119
88105
|
.nav-item:focus-visible,
|
|
88120
88106
|
.action-btn:focus-visible,
|
|
88121
|
-
.copy-btn:focus-visible
|
|
88122
|
-
.sbs-toolbar button:focus-visible {
|
|
88107
|
+
.copy-btn:focus-visible {
|
|
88123
88108
|
outline: 2px solid var(--accent-action);
|
|
88124
88109
|
outline-offset: 2px;
|
|
88125
88110
|
}
|
|
@@ -88157,7 +88142,6 @@ var REPORT_CSS = `
|
|
|
88157
88142
|
}
|
|
88158
88143
|
.health-score { margin: 0 auto; }
|
|
88159
88144
|
.tiles { grid-template-columns: repeat(2, 1fr); }
|
|
88160
|
-
.sbs-container { flex-direction: column; }
|
|
88161
88145
|
}
|
|
88162
88146
|
|
|
88163
88147
|
/* Print */
|
|
@@ -88461,69 +88445,6 @@ var REPORT_JS = `
|
|
|
88461
88445
|
if (ev.key === 'Escape' && lb.classList.contains('open')) close();
|
|
88462
88446
|
});
|
|
88463
88447
|
})();
|
|
88464
|
-
|
|
88465
|
-
// ---- Side-by-side iframe controller ----
|
|
88466
|
-
var sbsState = window.__parity_sbs || {};
|
|
88467
|
-
var proxyBase = window.__parity_proxy; // set by 'parity serve' on the served page
|
|
88468
|
-
// Side-by-side is mobile-only today. When the proxy is active, force the
|
|
88469
|
-
// upstream response to render at the mobile breakpoint by appending
|
|
88470
|
-
// viewport=mobile — the proxy strips X-Frame-Options AND injects a 375
|
|
88471
|
-
// viewport meta + mobile UA. Issue #70.
|
|
88472
|
-
function proxied(u) { return proxyBase ? proxyBase + encodeURIComponent(u) + '&viewport=mobile' : u; }
|
|
88473
|
-
var statusEl = document.getElementById('sbs-status');
|
|
88474
|
-
if (statusEl) {
|
|
88475
|
-
statusEl.textContent = proxyBase
|
|
88476
|
-
? '✓ proxy server active — iframes bypass X-Frame-Options'
|
|
88477
|
-
: '⚠ no proxy (file://) — sites with X-Frame-Options will appear empty. Run "parity serve <runId>" to start the local proxy.';
|
|
88478
|
-
statusEl.className = proxyBase ? 'sbs-status ok' : 'sbs-status warn';
|
|
88479
|
-
}
|
|
88480
|
-
if (sbsState.pairs && sbsState.pairs.length > 0) {
|
|
88481
|
-
var current = 0;
|
|
88482
|
-
var syncEnabled = true;
|
|
88483
|
-
var btns = document.querySelectorAll('[data-sbs-btn]');
|
|
88484
|
-
var iframeProd = document.getElementById('sbs-prod');
|
|
88485
|
-
var iframeCand = document.getElementById('sbs-cand');
|
|
88486
|
-
var urlProdEl = document.getElementById('sbs-url-prod');
|
|
88487
|
-
var urlCandEl = document.getElementById('sbs-url-cand');
|
|
88488
|
-
var syncToggle = document.getElementById('sbs-sync');
|
|
88489
|
-
|
|
88490
|
-
function load(idx) {
|
|
88491
|
-
current = idx;
|
|
88492
|
-
var pair = sbsState.pairs[idx];
|
|
88493
|
-
if (!pair) return;
|
|
88494
|
-
iframeProd.src = proxied(pair.prodUrl);
|
|
88495
|
-
iframeCand.src = proxied(pair.candUrl);
|
|
88496
|
-
urlProdEl.textContent = pair.prodUrl;
|
|
88497
|
-
urlCandEl.textContent = pair.candUrl;
|
|
88498
|
-
btns.forEach(function(b) {
|
|
88499
|
-
b.classList.toggle('active', b.dataset.sbsBtn === String(idx));
|
|
88500
|
-
});
|
|
88501
|
-
}
|
|
88502
|
-
btns.forEach(function(b) {
|
|
88503
|
-
b.addEventListener('click', function() { load(Number(b.dataset.sbsBtn)); });
|
|
88504
|
-
});
|
|
88505
|
-
if (syncToggle) {
|
|
88506
|
-
syncToggle.addEventListener('change', function() { syncEnabled = syncToggle.checked; });
|
|
88507
|
-
}
|
|
88508
|
-
var syncing = false;
|
|
88509
|
-
function attachScroll(src, dst) {
|
|
88510
|
-
try {
|
|
88511
|
-
src.contentWindow.addEventListener('scroll', function() {
|
|
88512
|
-
if (!syncEnabled || syncing) return;
|
|
88513
|
-
syncing = true;
|
|
88514
|
-
try { dst.contentWindow.scrollTo(src.contentWindow.scrollX, src.contentWindow.scrollY); } catch (e) {}
|
|
88515
|
-
setTimeout(function() { syncing = false; }, 30);
|
|
88516
|
-
}, { passive: true });
|
|
88517
|
-
} catch (e) {}
|
|
88518
|
-
}
|
|
88519
|
-
function tryAttach() {
|
|
88520
|
-
attachScroll(iframeProd, iframeCand);
|
|
88521
|
-
attachScroll(iframeCand, iframeProd);
|
|
88522
|
-
}
|
|
88523
|
-
iframeProd.addEventListener('load', tryAttach);
|
|
88524
|
-
iframeCand.addEventListener('load', tryAttach);
|
|
88525
|
-
if (sbsState.pairs.length > 0) load(0);
|
|
88526
|
-
}
|
|
88527
88448
|
})();
|
|
88528
88449
|
`.trim();
|
|
88529
88450
|
var THEME_BOOT = `try{var t=localStorage.getItem('parity-theme');if(t!=='light'&&t!=='dark')t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';document.documentElement.setAttribute('data-theme',t)}catch(e){}`;
|
|
@@ -97536,7 +97457,8 @@ function computeModuleVerdicts(checks, issues) {
|
|
|
97536
97457
|
const checksFailed = modChecks.filter((c) => c.status === "fail").length;
|
|
97537
97458
|
const checksWarn = modChecks.filter((c) => c.status === "warn").length;
|
|
97538
97459
|
const pagesAnalyzed = derivePagesAnalyzed(modChecks, modIssues);
|
|
97539
|
-
|
|
97460
|
+
const uncappedScore = computeScore(modIssues, { pagesAnalyzed }).score;
|
|
97461
|
+
let score = uncappedScore;
|
|
97540
97462
|
const status = counts.critical > 0 || checksFailed > 0 ? "fail" : counts.high > 0 || checksWarn > 0 ? "warn" : "pass";
|
|
97541
97463
|
if (status === "fail")
|
|
97542
97464
|
score = Math.min(score, FAIL_SCORE_CAP);
|
|
@@ -97549,12 +97471,16 @@ function computeModuleVerdicts(checks, issues) {
|
|
|
97549
97471
|
medium: counts.medium,
|
|
97550
97472
|
low: counts.low,
|
|
97551
97473
|
checksRun: modChecks.length,
|
|
97552
|
-
pagesAnalyzed
|
|
97474
|
+
pagesAnalyzed,
|
|
97475
|
+
uncappedScore
|
|
97553
97476
|
});
|
|
97554
97477
|
}
|
|
97555
97478
|
result.sort((a, b) => a.module.localeCompare(b.module));
|
|
97556
97479
|
return result;
|
|
97557
97480
|
}
|
|
97481
|
+
function moduleWeight(mv) {
|
|
97482
|
+
return Math.max(1, mv.pagesAnalyzed);
|
|
97483
|
+
}
|
|
97558
97484
|
function computeCompositeVerdict(moduleVerdicts, checks, issues) {
|
|
97559
97485
|
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
97560
97486
|
for (const i of issues)
|
|
@@ -97567,7 +97493,7 @@ function computeCompositeVerdict(moduleVerdicts, checks, issues) {
|
|
|
97567
97493
|
let weightSum = 0;
|
|
97568
97494
|
let totalPagesAnalyzed = 0;
|
|
97569
97495
|
for (const mv of moduleVerdicts) {
|
|
97570
|
-
const weight =
|
|
97496
|
+
const weight = moduleWeight(mv);
|
|
97571
97497
|
weightedScoreSum += mv.score * weight;
|
|
97572
97498
|
weightSum += weight;
|
|
97573
97499
|
totalPagesAnalyzed = Math.max(totalPagesAnalyzed, mv.pagesAnalyzed);
|
|
@@ -97593,6 +97519,38 @@ function computeCompositeVerdict(moduleVerdicts, checks, issues) {
|
|
|
97593
97519
|
modulesRun: moduleVerdicts.map((mv) => mv.module).sort()
|
|
97594
97520
|
};
|
|
97595
97521
|
}
|
|
97522
|
+
function explainCompositeScore(moduleVerdicts, verdict, checks) {
|
|
97523
|
+
if (moduleVerdicts.length === 0 || verdict.status === "inconclusive")
|
|
97524
|
+
return null;
|
|
97525
|
+
const weightSum = moduleVerdicts.reduce((s, mv) => s + moduleWeight(mv), 0);
|
|
97526
|
+
const failedChecks = (mod) => checks.filter((c) => c.status === "fail" && (mod === undefined || moduleOfCheck(c.name) === mod)).map((c) => c.name);
|
|
97527
|
+
const criticalNote = (n) => n > 0 ? [`${n} critical issue${n === 1 ? "" : "s"}`] : [];
|
|
97528
|
+
const modules = moduleVerdicts.map((mv) => {
|
|
97529
|
+
const weightShare = moduleWeight(mv) / weightSum;
|
|
97530
|
+
const capBound = mv.status === "fail" && (mv.uncappedScore !== undefined ? mv.uncappedScore > mv.score : mv.score === FAIL_SCORE_CAP);
|
|
97531
|
+
return {
|
|
97532
|
+
module: mv.module,
|
|
97533
|
+
score: mv.score,
|
|
97534
|
+
status: mv.status,
|
|
97535
|
+
weight: moduleWeight(mv),
|
|
97536
|
+
weightShare,
|
|
97537
|
+
pointsLost: (100 - mv.score) * weightShare,
|
|
97538
|
+
cappedBy: capBound ? [...failedChecks(mv.module), ...criticalNote(mv.critical)] : []
|
|
97539
|
+
};
|
|
97540
|
+
}).sort((a, b) => b.pointsLost - a.pointsLost || a.module.localeCompare(b.module));
|
|
97541
|
+
const uncappedScore = Math.round(moduleVerdicts.reduce((s, mv) => s + mv.score * moduleWeight(mv), 0) / weightSum);
|
|
97542
|
+
const failed = verdict.status === "fail";
|
|
97543
|
+
if ((failed ? Math.min(uncappedScore, FAIL_SCORE_CAP) : uncappedScore) !== verdict.score) {
|
|
97544
|
+
return null;
|
|
97545
|
+
}
|
|
97546
|
+
return {
|
|
97547
|
+
modules,
|
|
97548
|
+
uncappedScore,
|
|
97549
|
+
score: verdict.score,
|
|
97550
|
+
capped: failed && uncappedScore > FAIL_SCORE_CAP,
|
|
97551
|
+
failedBy: failed ? [...failedChecks(), ...criticalNote(verdict.critical)] : []
|
|
97552
|
+
};
|
|
97553
|
+
}
|
|
97596
97554
|
|
|
97597
97555
|
// src/extract/loader-props.ts
|
|
97598
97556
|
var LOADER_RE = /(^|\/)loaders\//;
|
|
@@ -98033,7 +97991,6 @@ var TAB_HELP = {
|
|
|
98033
97991
|
summary: "Migration health at a glance. Score, blocking issues, and a tile per check category. Click a tile to jump to the corresponding tab.",
|
|
98034
97992
|
visualdiff: "Per-page pixel + semantic diff between prod and cand screenshots. Pages that didn't change are auto-skipped via the cross-run cache. LLM Vision interprets the heatmap when ANTHROPIC_API_KEY or a local claude CLI is available.",
|
|
98035
97993
|
seo: "Robots.txt, sitemap, and per-page meta-tag parity between prod and cand. Red rows diverge. Catches noindex / canonical / og:* / JSON-LD regressions that silently destroy organic traffic.",
|
|
98036
|
-
sidebyside: "Live mobile iframe of prod vs cand, with synchronized scroll. Requires `parity serve <runId>` to bypass X-Frame-Options. Mobile viewport is forced via the proxy (Issue #70).",
|
|
98037
97994
|
issues: "Flat list of every issue surfaced by any check, sorted by severity. The Top issues block on the Dashboard is the LLM-aggregated, deduped version of this list.",
|
|
98038
97995
|
vitals: "Web Vitals (LCP / FCP / TTFB / INP / CLS) per page, prod vs cand. Δ green = cand better; Δ red = regression. Mobile is the default measurement viewport.",
|
|
98039
97996
|
cache: "Cache hit rate and missed opportunities on cand. Opportunities = static assets with hashed URLs returning MISS — adding a cache rule for them is usually free perf.",
|
|
@@ -98072,6 +98029,7 @@ function renderDashboard2(run) {
|
|
|
98072
98029
|
</div>
|
|
98073
98030
|
<div class="dash-hero-info">
|
|
98074
98031
|
<div class="verdict-text ${v.status}">${statusLabel}</div>
|
|
98032
|
+
${renderVisualParity(run)}
|
|
98075
98033
|
${inconclusive ? "" : deltaChip}
|
|
98076
98034
|
${renderAcceptedFindings(run)}
|
|
98077
98035
|
<div class="verdict-sub">${inconclusive ? "Nothing was measured — 0 checks ran, so this run says nothing about parity." : `${v.critical + v.high} blocking issue${v.critical + v.high !== 1 ? "s" : ""} ${v.critical > 0 ? `(${v.critical} critical)` : ""}`}</div>
|
|
@@ -98084,7 +98042,7 @@ function renderDashboard2(run) {
|
|
|
98084
98042
|
</div>
|
|
98085
98043
|
</div>
|
|
98086
98044
|
|
|
98087
|
-
${
|
|
98045
|
+
${renderScoreBreakdown(run)}
|
|
98088
98046
|
|
|
98089
98047
|
<div class="tiles">
|
|
98090
98048
|
${tiles.map((t) => renderTile(t)).join("")}
|
|
@@ -98100,17 +98058,45 @@ function renderAcceptedFindings(run) {
|
|
|
98100
98058
|
const stale = a.stale.map((e) => `<div style="color:var(--state-warn);font-size:12px;margin-top:2px">⚠ stale acceptance (matched nothing): ${escapeHtml([e.check, e.id, e.page, e.match].filter(Boolean).join(" · "))} — ${escapeHtml(e.note)}</div>`).join("");
|
|
98101
98059
|
return line + stale;
|
|
98102
98060
|
}
|
|
98103
|
-
|
|
98104
|
-
|
|
98061
|
+
var STATUS_COLOR = {
|
|
98062
|
+
pass: "var(--state-good)",
|
|
98063
|
+
warn: "var(--state-warn)",
|
|
98064
|
+
fail: "var(--state-bad)"
|
|
98065
|
+
};
|
|
98066
|
+
function renderVisualParity(run) {
|
|
98067
|
+
const vd = run.visualDiff;
|
|
98068
|
+
if (!vd || vd.pagesChecked === 0)
|
|
98105
98069
|
return "";
|
|
98106
|
-
const
|
|
98107
|
-
|
|
98108
|
-
|
|
98109
|
-
|
|
98110
|
-
|
|
98111
|
-
|
|
98112
|
-
|
|
98113
|
-
|
|
98070
|
+
const all = vd.pagesPassed === vd.pagesChecked;
|
|
98071
|
+
return `<div class="visual-parity" style="color:${all ? STATUS_COLOR.pass : STATUS_COLOR.warn}">
|
|
98072
|
+
<strong>Visual: ${vd.pagesPassed} of ${vd.pagesChecked} page${vd.pagesChecked === 1 ? "" : "s"} match prod</strong>
|
|
98073
|
+
<span>${all ? "no visual difference found" : `${vd.pagesChecked - vd.pagesPassed} with differences — see Visual Diff`}</span>
|
|
98074
|
+
</div>`;
|
|
98075
|
+
}
|
|
98076
|
+
function renderScoreBreakdown(run) {
|
|
98077
|
+
const ex = explainCompositeScore(run.moduleVerdicts ?? [], run.verdict, run.checks);
|
|
98078
|
+
if (!ex)
|
|
98079
|
+
return "";
|
|
98080
|
+
const totalLost = ex.modules.reduce((s, m) => s + m.pointsLost, 0);
|
|
98081
|
+
const maxLost = Math.max(...ex.modules.map((m) => m.pointsLost), 0.0001);
|
|
98082
|
+
const capNote = (by) => by.length > 0 ? `<div class="sb-cap">held at ${FAIL_SCORE_CAP} by FAIL: ${escapeHtml(by.join(", "))}</div>` : "";
|
|
98083
|
+
const rows = ex.modules.map((m) => `<tr>
|
|
98084
|
+
<td><strong>${escapeHtml(m.module)}</strong>${capNote(m.cappedBy)}</td>
|
|
98085
|
+
<td><span class="sb-status" style="color:${STATUS_COLOR[m.status]}">${m.status}</span></td>
|
|
98086
|
+
<td class="num" style="color:${STATUS_COLOR[m.status]}">${m.score}</td>
|
|
98087
|
+
<td class="num">${Math.round(m.weightShare * 100)}%<small> · ${m.weight} page${m.weight === 1 ? "" : "s"}</small></td>
|
|
98088
|
+
<td><div class="sb-lost"><span class="sb-bar"><span style="width:${(m.pointsLost / maxLost * 100).toFixed(1)}%"></span></span><span class="num">−${m.pointsLost.toFixed(1)}</span></div></td>
|
|
98089
|
+
</tr>`).join("");
|
|
98090
|
+
const headline = ex.capped ? `<div class="sb-capped">Capped at ${FAIL_SCORE_CAP}: the modules average ${ex.uncappedScore}, but any FAIL holds the score at ${FAIL_SCORE_CAP} or below. Triggered by ${escapeHtml(ex.failedBy.join(", "))}.</div>` : "";
|
|
98091
|
+
return `<div class="card score-breakdown">
|
|
98092
|
+
<h2>Why ${ex.score}?</h2>
|
|
98093
|
+
<div class="hint">${ex.uncappedScore} = 100 − ${totalLost.toFixed(1)} points lost, each module weighted by the pages it analyzed.${ex.failedBy.length > 0 && !ex.capped ? ` The verdict is FAIL, but the ${FAIL_SCORE_CAP} cap does not bind: the modules already average below it.` : ""}</div>
|
|
98094
|
+
${headline}
|
|
98095
|
+
<table class="sb-table">
|
|
98096
|
+
<thead><tr><th>Module</th><th>Status</th><th class="num">Score</th><th class="num">Weight</th><th>Points lost</th></tr></thead>
|
|
98097
|
+
<tbody>${rows}</tbody>
|
|
98098
|
+
</table>
|
|
98099
|
+
</div>`;
|
|
98114
98100
|
}
|
|
98115
98101
|
function buildTiles(run) {
|
|
98116
98102
|
const tiles = [];
|
|
@@ -99208,105 +99194,6 @@ function renderPromptPanel(run) {
|
|
|
99208
99194
|
<div class="prompt-md" id="prompt-md">${escapeHtml(md)}</div>
|
|
99209
99195
|
</div>`;
|
|
99210
99196
|
}
|
|
99211
|
-
function classifyPath2(path, isFirstNonHome) {
|
|
99212
|
-
const lower = path.toLowerCase();
|
|
99213
|
-
if (/\/(checkout|finalizar|finalize)/.test(lower))
|
|
99214
|
-
return "checkout";
|
|
99215
|
-
if (/\/(cart|carrinho|sacola|bag)/.test(lower))
|
|
99216
|
-
return "cart";
|
|
99217
|
-
if (/\/(c|category|collections|categoria|departamento)\//.test(lower) || /\/loja\//.test(lower))
|
|
99218
|
-
return "plp";
|
|
99219
|
-
if (/\/(p|product|produto)\//.test(lower) || /\/dp\//.test(lower))
|
|
99220
|
-
return "pdp";
|
|
99221
|
-
return isFirstNonHome ? "plp" : "pdp";
|
|
99222
|
-
}
|
|
99223
|
-
function buildSideBySidePairs(run) {
|
|
99224
|
-
if (!run.prodUrl)
|
|
99225
|
-
return [];
|
|
99226
|
-
const slots = {
|
|
99227
|
-
home: { prodPath: "/", candPath: "/" }
|
|
99228
|
-
};
|
|
99229
|
-
for (const side of ["prod", "cand"]) {
|
|
99230
|
-
let seenNonHome = false;
|
|
99231
|
-
for (const fc of run.flowCaptures) {
|
|
99232
|
-
if (fc.side !== side || fc.viewport !== "mobile")
|
|
99233
|
-
continue;
|
|
99234
|
-
for (const p of fc.pages) {
|
|
99235
|
-
const path = pathOf5(p.url);
|
|
99236
|
-
if (path === "/" || path === "")
|
|
99237
|
-
continue;
|
|
99238
|
-
const role = classifyPath2(path, !seenNonHome);
|
|
99239
|
-
seenNonHome = true;
|
|
99240
|
-
if (role === "other")
|
|
99241
|
-
continue;
|
|
99242
|
-
if (!slots[role])
|
|
99243
|
-
slots[role] = {};
|
|
99244
|
-
const slot = slots[role];
|
|
99245
|
-
if (!slot)
|
|
99246
|
-
continue;
|
|
99247
|
-
const key = side === "prod" ? "prodPath" : "candPath";
|
|
99248
|
-
if (!slot[key])
|
|
99249
|
-
slot[key] = path;
|
|
99250
|
-
}
|
|
99251
|
-
}
|
|
99252
|
-
}
|
|
99253
|
-
const order = [
|
|
99254
|
-
["home", "Home"],
|
|
99255
|
-
["plp", "PLP"],
|
|
99256
|
-
["pdp", "PDP"],
|
|
99257
|
-
["cart", "Cart"],
|
|
99258
|
-
["checkout", "Checkout"]
|
|
99259
|
-
];
|
|
99260
|
-
const pairs = [];
|
|
99261
|
-
for (const [role, label] of order) {
|
|
99262
|
-
const slot = slots[role];
|
|
99263
|
-
if (!slot)
|
|
99264
|
-
continue;
|
|
99265
|
-
const prodPath = slot.prodPath ?? slot.candPath;
|
|
99266
|
-
const candPath = slot.candPath ?? slot.prodPath;
|
|
99267
|
-
if (!prodPath || !candPath)
|
|
99268
|
-
continue;
|
|
99269
|
-
const bothCaptured = slot.prodPath && slot.candPath;
|
|
99270
|
-
pairs.push({
|
|
99271
|
-
label,
|
|
99272
|
-
prodUrl: new URL(prodPath, run.prodUrl).toString(),
|
|
99273
|
-
candUrl: new URL(candPath, run.candUrl).toString(),
|
|
99274
|
-
inferred: !bothCaptured,
|
|
99275
|
-
tooltip: !bothCaptured ? "Path captured on one side only; the other iframe falls back to the same path. May 404 if the migrated site uses different routing." : undefined
|
|
99276
|
-
});
|
|
99277
|
-
}
|
|
99278
|
-
return pairs;
|
|
99279
|
-
}
|
|
99280
|
-
function renderSideBySidePanel(run) {
|
|
99281
|
-
const pairs = buildSideBySidePairs(run);
|
|
99282
|
-
if (pairs.length === 0) {
|
|
99283
|
-
return `<div class="empty">No captured URLs available for side-by-side view.</div>`;
|
|
99284
|
-
}
|
|
99285
|
-
return `
|
|
99286
|
-
<div class="card">
|
|
99287
|
-
<h2>Side-by-side mobile</h2>
|
|
99288
|
-
<div class="hint">Compare prod (Fresh, left) with cand (TanStack, right) in mobile viewport. Scroll sync works when the proxy is active OR when the site implements a <code>postMessage</code> handler.</div>
|
|
99289
|
-
<div id="sbs-status" class="sbs-status warn">loading…</div>
|
|
99290
|
-
<div class="sbs-toolbar">
|
|
99291
|
-
${pairs.map((p, i) => `<button data-sbs-btn="${i}"${p.inferred ? ` class="sbs-btn-inferred" title="${escapeHtml(p.tooltip ?? "")}"` : ""}>${escapeHtml(p.label)}${p.inferred ? ' <span class="sbs-btn-flag">?</span>' : ""}</button>`).join("")}
|
|
99292
|
-
<label class="label"><input type="checkbox" id="sbs-sync" checked/> Synchronized scroll</label>
|
|
99293
|
-
<div class="toolbar-right">tip: use <code>parity serve <runId></code> to bypass X-Frame-Options</div>
|
|
99294
|
-
</div>
|
|
99295
|
-
<div class="sbs-container">
|
|
99296
|
-
<div class="sbs-frame">
|
|
99297
|
-
<div class="frame-title">prod (Fresh)</div>
|
|
99298
|
-
<div class="frame-url" id="sbs-url-prod">${escapeHtml(pairs[0].prodUrl)}</div>
|
|
99299
|
-
<iframe id="sbs-prod" class="sbs-iframe" src="" sandbox="allow-same-origin allow-scripts allow-forms allow-popups" loading="lazy"></iframe>
|
|
99300
|
-
</div>
|
|
99301
|
-
<div class="sbs-frame">
|
|
99302
|
-
<div class="frame-title">cand (TanStack)</div>
|
|
99303
|
-
<div class="frame-url" id="sbs-url-cand">${escapeHtml(pairs[0].candUrl)}</div>
|
|
99304
|
-
<iframe id="sbs-cand" class="sbs-iframe" src="" sandbox="allow-same-origin allow-scripts allow-forms allow-popups" loading="lazy"></iframe>
|
|
99305
|
-
</div>
|
|
99306
|
-
</div>
|
|
99307
|
-
<script>window.__parity_sbs = ${JSON.stringify({ pairs })};</script>
|
|
99308
|
-
</div>`;
|
|
99309
|
-
}
|
|
99310
99197
|
var LLM_ONLY_TABS = new Set(["visualdiff", "prompt"]);
|
|
99311
99198
|
function hasAnyLlmOutput(run) {
|
|
99312
99199
|
if (run.visualDiff?.results.some((p) => p.llmCalled))
|
|
@@ -99319,7 +99206,6 @@ function buildNav(run) {
|
|
|
99319
99206
|
{ tab: "summary", label: "Dashboard", icon: "\uD83C\uDFE0" },
|
|
99320
99207
|
{ tab: "visualdiff", label: "Visual Diff", icon: "\uD83D\uDDBC", count: run.visualDiff?.pagesWithDiffs },
|
|
99321
99208
|
{ tab: "seo", label: "SEO", icon: "\uD83D\uDD0D", count: run.seo?.issues.length },
|
|
99322
|
-
{ tab: "sidebyside", label: "Side-by-side", icon: "⇆" },
|
|
99323
99209
|
{ tab: "issues", label: "Issues", icon: "⚠", count: run.issues.length },
|
|
99324
99210
|
{ tab: "vitals", label: "Vitals", icon: "\uD83D\uDCCA" },
|
|
99325
99211
|
{ tab: "cache", label: "Cache", icon: "\uD83D\uDCBE" },
|
|
@@ -99398,10 +99284,6 @@ function renderHtmlReport(run, runDir) {
|
|
|
99398
99284
|
${tabHelp(TAB_HELP.seo)}
|
|
99399
99285
|
${renderSeoPanel(run, runDir)}
|
|
99400
99286
|
</section>
|
|
99401
|
-
<section class="panel" data-panel="sidebyside">
|
|
99402
|
-
${tabHelp(TAB_HELP.sidebyside)}
|
|
99403
|
-
${renderSideBySidePanel(run)}
|
|
99404
|
-
</section>
|
|
99405
99287
|
<section class="panel" data-panel="issues">
|
|
99406
99288
|
${tabHelp(TAB_HELP.issues)}
|
|
99407
99289
|
${renderIssuesPanel(run, runDir)}
|
|
@@ -102622,7 +102504,7 @@ function taskShot(planDir, id, side) {
|
|
|
102622
102504
|
// src/server/proxy-server.ts
|
|
102623
102505
|
import { existsSync as existsSync19, readFileSync as readFileSync23, statSync as statSync2 } from "node:fs";
|
|
102624
102506
|
import { createServer } from "node:http";
|
|
102625
|
-
import { extname,
|
|
102507
|
+
import { extname, normalize as normalize2, resolve as resolve8, sep } from "node:path";
|
|
102626
102508
|
var MIME2 = {
|
|
102627
102509
|
".html": "text/html; charset=utf-8",
|
|
102628
102510
|
".css": "text/css; charset=utf-8",
|
|
@@ -102725,25 +102607,10 @@ async function handleRequest(req, res, runDir) {
|
|
|
102725
102607
|
return;
|
|
102726
102608
|
}
|
|
102727
102609
|
if (path === "/" || path === "/index.html") {
|
|
102728
|
-
return
|
|
102610
|
+
return serveStatic(res, runDir, "/report.html");
|
|
102729
102611
|
}
|
|
102730
102612
|
return serveStatic(res, runDir, path);
|
|
102731
102613
|
}
|
|
102732
|
-
function serveReportHtml(res, runDir) {
|
|
102733
|
-
const filePath = join24(runDir, "report.html");
|
|
102734
|
-
if (!existsSync19(filePath)) {
|
|
102735
|
-
res.statusCode = 404;
|
|
102736
|
-
res.end("report.html not found");
|
|
102737
|
-
return;
|
|
102738
|
-
}
|
|
102739
|
-
const html = readFileSync23(filePath, "utf8");
|
|
102740
|
-
const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
|
|
102741
|
-
const out = html.includes("</head>") ? html.replace("</head>", `${inject}</head>`) : `${inject}${html}`;
|
|
102742
|
-
res.statusCode = 200;
|
|
102743
|
-
res.setHeader("content-type", "text/html; charset=utf-8");
|
|
102744
|
-
res.setHeader("cache-control", "no-store");
|
|
102745
|
-
res.end(out);
|
|
102746
|
-
}
|
|
102747
102614
|
function serveStatic(res, runDir, path) {
|
|
102748
102615
|
const safePath = normalize2(path).replace(/^[/\\]+/, "");
|
|
102749
102616
|
const filePath = resolve8(runDir, safePath);
|
|
@@ -115428,14 +115295,14 @@ function planTouchCommand(dir, page, opts) {
|
|
|
115428
115295
|
}
|
|
115429
115296
|
|
|
115430
115297
|
// src/commands/pr.ts
|
|
115431
|
-
import { existsSync as
|
|
115298
|
+
import { existsSync as existsSync31, readFileSync as readFileSync41, writeFileSync as writeFileSync33 } from "node:fs";
|
|
115432
115299
|
import { join as join46 } from "node:path";
|
|
115433
|
-
import
|
|
115300
|
+
import chalk35 from "chalk";
|
|
115434
115301
|
|
|
115435
115302
|
// src/commands/run.ts
|
|
115436
|
-
import { existsSync as
|
|
115303
|
+
import { existsSync as existsSync30, readFileSync as readFileSync40, unlinkSync as unlinkSync4 } from "node:fs";
|
|
115437
115304
|
import { join as join45 } from "node:path";
|
|
115438
|
-
import
|
|
115305
|
+
import chalk34 from "chalk";
|
|
115439
115306
|
import ora8 from "ora";
|
|
115440
115307
|
|
|
115441
115308
|
// src/diff/score-band.ts
|
|
@@ -116022,70 +115889,6 @@ function formatMs(ms) {
|
|
|
116022
115889
|
return `${min}m${sec.toString().padStart(2, "0")}s`;
|
|
116023
115890
|
}
|
|
116024
115891
|
|
|
116025
|
-
// src/commands/serve.ts
|
|
116026
|
-
import { existsSync as existsSync30 } from "node:fs";
|
|
116027
|
-
import chalk34 from "chalk";
|
|
116028
|
-
async function serveRunAndBlock(runDir, opts = {}) {
|
|
116029
|
-
let handle;
|
|
116030
|
-
try {
|
|
116031
|
-
handle = await startProxyServer(runDir, { port: opts.port });
|
|
116032
|
-
} catch (err) {
|
|
116033
|
-
console.error(chalk34.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
|
|
116034
|
-
return 2;
|
|
116035
|
-
}
|
|
116036
|
-
const label = opts.label ?? "parity serve";
|
|
116037
|
-
console.log("");
|
|
116038
|
-
console.log(chalk34.bold(` ${label}`));
|
|
116039
|
-
console.log(` ${chalk34.green("●")} ${handle.url}`);
|
|
116040
|
-
console.log(chalk34.dim(` Servindo: ${runDir}`));
|
|
116041
|
-
console.log(chalk34.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
|
|
116042
|
-
console.log(chalk34.dim(` Ctrl+C pra parar (2x pra forçar saída).
|
|
116043
|
-
`));
|
|
116044
|
-
if (opts.open !== false) {
|
|
116045
|
-
const { default: open } = await import("open");
|
|
116046
|
-
await open(handle.url).catch(() => {
|
|
116047
|
-
return;
|
|
116048
|
-
});
|
|
116049
|
-
}
|
|
116050
|
-
let shuttingDown = false;
|
|
116051
|
-
const onSignal = () => {
|
|
116052
|
-
if (shuttingDown) {
|
|
116053
|
-
process.stderr.write(`
|
|
116054
|
-
forçando saída.
|
|
116055
|
-
`);
|
|
116056
|
-
process.exit(130);
|
|
116057
|
-
}
|
|
116058
|
-
shuttingDown = true;
|
|
116059
|
-
process.stderr.write(`
|
|
116060
|
-
parando servidor…
|
|
116061
|
-
`);
|
|
116062
|
-
handle.close().catch(() => {
|
|
116063
|
-
return;
|
|
116064
|
-
});
|
|
116065
|
-
setTimeout(() => process.exit(0), 300);
|
|
116066
|
-
};
|
|
116067
|
-
process.on("SIGINT", onSignal);
|
|
116068
|
-
process.on("SIGTERM", onSignal);
|
|
116069
|
-
await new Promise(() => {});
|
|
116070
|
-
return 0;
|
|
116071
|
-
}
|
|
116072
|
-
async function serveCommand(runId, opts) {
|
|
116073
|
-
const paths = getRunPaths(opts.output, runId);
|
|
116074
|
-
if (!existsSync30(paths.runDir)) {
|
|
116075
|
-
console.error(chalk34.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
|
|
116076
|
-
return 1;
|
|
116077
|
-
}
|
|
116078
|
-
if (!existsSync30(paths.reportHtml)) {
|
|
116079
|
-
console.error(chalk34.red(`✖ report.html não existe em ${paths.runDir}`));
|
|
116080
|
-
return 1;
|
|
116081
|
-
}
|
|
116082
|
-
return serveRunAndBlock(paths.runDir, {
|
|
116083
|
-
port: opts.port,
|
|
116084
|
-
open: opts.open,
|
|
116085
|
-
label: `parity serve · ${runId}`
|
|
116086
|
-
});
|
|
116087
|
-
}
|
|
116088
|
-
|
|
116089
115892
|
// src/commands/run.ts
|
|
116090
115893
|
var PRESETS = {
|
|
116091
115894
|
smoke: {
|
|
@@ -116252,14 +116055,14 @@ function readRunChecks(reportPath) {
|
|
|
116252
116055
|
async function runCommand(rawOpts) {
|
|
116253
116056
|
if (!rawOpts.prod) {
|
|
116254
116057
|
const target = rawOpts.cand ?? "<url>";
|
|
116255
|
-
console.error(`${
|
|
116256
|
-
For one site, use: ${
|
|
116058
|
+
console.error(`${chalk34.yellow("Single-site run?")} \`parity run\` compares two URLs (prod↔cand).
|
|
116059
|
+
For one site, use: ${chalk34.cyan(`parity e2e --url ${target}`)}
|
|
116257
116060
|
(runs the functional flows + all checks in single-site mode — no prod baseline needed).`);
|
|
116258
116061
|
return 2;
|
|
116259
116062
|
}
|
|
116260
116063
|
let opts = applyPreset(rawOpts);
|
|
116261
116064
|
if (rawOpts.preset) {
|
|
116262
|
-
console.log(
|
|
116065
|
+
console.log(chalk34.dim(` preset: ${rawOpts.preset}`));
|
|
116263
116066
|
}
|
|
116264
116067
|
if (opts.pt)
|
|
116265
116068
|
setLlmLanguage("pt");
|
|
@@ -116267,14 +116070,14 @@ async function runCommand(rawOpts) {
|
|
|
116267
116070
|
disableInteractive();
|
|
116268
116071
|
const llmCfgErr = applyLlmOptions(opts);
|
|
116269
116072
|
if (llmCfgErr) {
|
|
116270
|
-
console.error(
|
|
116073
|
+
console.error(chalk34.red(` ${llmCfgErr}`));
|
|
116271
116074
|
return 2;
|
|
116272
116075
|
}
|
|
116273
116076
|
const llmStillAvailable = isLlmAvailable();
|
|
116274
116077
|
const preSmart = opts;
|
|
116275
116078
|
opts = applySmartDefaults(opts, llmStillAvailable);
|
|
116276
116079
|
if (!llmStillAvailable && opts.visualPages !== preSmart.visualPages) {
|
|
116277
|
-
console.log(
|
|
116080
|
+
console.log(chalk34.dim(" visual-pages auto-set to 0 (no LLM available — analysis layer would be skipped; opt in with --visual-pages N)"));
|
|
116278
116081
|
}
|
|
116279
116082
|
let interactivePromptShown = false;
|
|
116280
116083
|
if (!opts.only && !opts.skip && !rawOpts.preset) {
|
|
@@ -116300,14 +116103,14 @@ async function runCommand(rawOpts) {
|
|
|
116300
116103
|
if (isContentProfile && !opts.only && !opts.skip) {
|
|
116301
116104
|
opts.only = "seo,visual,vitals,cache,console,html,network";
|
|
116302
116105
|
moduleDropReason = "profile: content → e2e module dropped (commerce purchase-journey/cart make no sense on a content site); pass --profile commerce to force";
|
|
116303
|
-
console.log(
|
|
116106
|
+
console.log(chalk34.yellow(` INCONCLUSIVE: ${moduleDropReason}`));
|
|
116304
116107
|
}
|
|
116305
116108
|
const selection = resolveSelection({ only: opts.only, skip: opts.skip });
|
|
116306
116109
|
if (selection.errors.length > 0) {
|
|
116307
|
-
console.error(
|
|
116110
|
+
console.error(chalk34.red(" --only/--skip: invalid value(s):"));
|
|
116308
116111
|
for (const e of selection.errors)
|
|
116309
|
-
console.error(
|
|
116310
|
-
console.error(
|
|
116112
|
+
console.error(chalk34.red(` - ${e}`));
|
|
116113
|
+
console.error(chalk34.dim(`
|
|
116311
116114
|
valid modules: ${Object.keys(MODULES).join(", ")}`));
|
|
116312
116115
|
return 2;
|
|
116313
116116
|
}
|
|
@@ -116319,14 +116122,14 @@ async function runCommand(rawOpts) {
|
|
|
116319
116122
|
const explicitFlows = userSetFlows ? opts.flows.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
116320
116123
|
const scoped = resolveScopedFlows({ explicitFlows, selectionFlows: selection.flows });
|
|
116321
116124
|
flows = scoped.flows;
|
|
116322
|
-
console.log(
|
|
116125
|
+
console.log(chalk34.dim(` modules: ${selection.modules.join(", ") || "(none)"} → flows: ${flows.join(",")}${explicitFlows.length > 0 ? " (scoped by --flows)" : ""}`));
|
|
116323
116126
|
if (scoped.starved.length > 0) {
|
|
116324
|
-
console.log(
|
|
116127
|
+
console.log(chalk34.yellow(` ! --flows leaves out ${scoped.starved.join(",")}, which the selected modules capture from — those checks may have nothing to analyze`));
|
|
116325
116128
|
}
|
|
116326
116129
|
} else {
|
|
116327
116130
|
flows = opts.flows.split(",").map((s) => s.trim());
|
|
116328
116131
|
if (!interactivePromptShown) {
|
|
116329
|
-
console.log(
|
|
116132
|
+
console.log(chalk34.dim(" no --only/--skip given — running ALL modules; pass --only to scope the run for a lighter/faster result"));
|
|
116330
116133
|
}
|
|
116331
116134
|
}
|
|
116332
116135
|
if (isContentProfile) {
|
|
@@ -116335,16 +116138,16 @@ async function runCommand(rawOpts) {
|
|
|
116335
116138
|
if (!flows.includes("homepage"))
|
|
116336
116139
|
flows.unshift("homepage");
|
|
116337
116140
|
if (before !== flows.join(",")) {
|
|
116338
|
-
console.log(
|
|
116141
|
+
console.log(chalk34.dim(` profile: content → flows scoped to ${flows.join(",")} (dropped plp/pdp; was: ${before}); CEP skipped`));
|
|
116339
116142
|
}
|
|
116340
116143
|
}
|
|
116341
116144
|
const pagesScopeWarning = pagesFlowsScopeWarning(opts, flows);
|
|
116342
116145
|
if (pagesScopeWarning) {
|
|
116343
|
-
console.log(
|
|
116146
|
+
console.log(chalk34.dim(` ${pagesScopeWarning}`));
|
|
116344
116147
|
}
|
|
116345
116148
|
if (hasSelection) {
|
|
116346
116149
|
for (const note of applySelectionDefaults(opts, selection.modules)) {
|
|
116347
|
-
console.log(
|
|
116150
|
+
console.log(chalk34.dim(` ${note}`));
|
|
116348
116151
|
}
|
|
116349
116152
|
}
|
|
116350
116153
|
const viewports = opts.viewports.split(",").map((s) => s.trim());
|
|
@@ -116358,37 +116161,37 @@ async function runCommand(rawOpts) {
|
|
|
116358
116161
|
const ignore = loadParityIgnore();
|
|
116359
116162
|
if (opts.clearCache) {
|
|
116360
116163
|
const cacheFile = join45(opts.output, "cache", "verdicts.json");
|
|
116361
|
-
if (
|
|
116164
|
+
if (existsSync30(cacheFile)) {
|
|
116362
116165
|
try {
|
|
116363
116166
|
unlinkSync4(cacheFile);
|
|
116364
|
-
console.log(
|
|
116167
|
+
console.log(chalk34.dim(` cache wiped: ${cacheFile}`));
|
|
116365
116168
|
} catch (err) {
|
|
116366
|
-
console.log(
|
|
116169
|
+
console.log(chalk34.yellow(` cache wipe falhou: ${err.message}`));
|
|
116367
116170
|
}
|
|
116368
116171
|
}
|
|
116369
116172
|
}
|
|
116370
116173
|
const llmTimeoutRaw = opts.llmTimeout ?? 60;
|
|
116371
116174
|
if (!Number.isFinite(llmTimeoutRaw)) {
|
|
116372
|
-
console.error(
|
|
116175
|
+
console.error(chalk34.red(` --llm-timeout inválido: "${opts.llmTimeout}" não é um número`));
|
|
116373
116176
|
return 2;
|
|
116374
116177
|
}
|
|
116375
116178
|
const llmTimeoutSec = Math.max(5, Math.floor(llmTimeoutRaw));
|
|
116376
116179
|
if (isLlmAvailable()) {
|
|
116377
|
-
console.log(
|
|
116180
|
+
console.log(chalk34.dim(` llm: ${providerLabel()} (timeout=${llmTimeoutSec}s)`));
|
|
116378
116181
|
} else {
|
|
116379
|
-
console.log(
|
|
116182
|
+
console.log(chalk34.dim(" llm: offline (LLM keys ausentes — agregação heurística)"));
|
|
116380
116183
|
}
|
|
116381
116184
|
if (isInteractiveMode()) {
|
|
116382
|
-
console.log(
|
|
116185
|
+
console.log(chalk34.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
|
|
116383
116186
|
}
|
|
116384
116187
|
const primaryViewport = viewports[0] ?? "mobile";
|
|
116385
116188
|
const preflight = await preflightCheck(opts.prod, opts.cand, primaryViewport);
|
|
116386
116189
|
if (!preflight.ok) {
|
|
116387
|
-
console.error(
|
|
116190
|
+
console.error(chalk34.red(`
|
|
116388
116191
|
✖ pre-flight falhou:`));
|
|
116389
116192
|
for (const err of preflight.errors)
|
|
116390
|
-
console.error(
|
|
116391
|
-
console.error(
|
|
116193
|
+
console.error(chalk34.red(` - ${err}`));
|
|
116194
|
+
console.error(chalk34.dim(`
|
|
116392
116195
|
dica: verifique se as URLs estão corretas e acessíveis`));
|
|
116393
116196
|
return 2;
|
|
116394
116197
|
}
|
|
@@ -116399,7 +116202,7 @@ async function runCommand(rawOpts) {
|
|
|
116399
116202
|
if (prodHomeHtml) {
|
|
116400
116203
|
platform = detectPlatform({ url: opts.prod, html: prodHomeHtml });
|
|
116401
116204
|
if (platform !== "custom") {
|
|
116402
|
-
console.log(
|
|
116205
|
+
console.log(chalk34.dim(` Detected platform: ${platform}`));
|
|
116403
116206
|
}
|
|
116404
116207
|
}
|
|
116405
116208
|
const prodHost = hostOf3(opts.prod);
|
|
@@ -116434,11 +116237,11 @@ async function runCommand(rawOpts) {
|
|
|
116434
116237
|
viewports,
|
|
116435
116238
|
timestamp
|
|
116436
116239
|
});
|
|
116437
|
-
console.log(
|
|
116240
|
+
console.log(chalk34.bold(`
|
|
116438
116241
|
parity run ${runId}`));
|
|
116439
|
-
console.log(
|
|
116440
|
-
console.log(
|
|
116441
|
-
console.log(
|
|
116242
|
+
console.log(chalk34.dim(` prod: ${opts.prod}`));
|
|
116243
|
+
console.log(chalk34.dim(` cand: ${opts.cand}`));
|
|
116244
|
+
console.log(chalk34.dim(` profile: ${profile} · flows: ${flows.join(", ")} · viewports: ${viewports.join(", ")}${rc.cep ? ` · CEP: ${rc.cep}` : ""}
|
|
116442
116245
|
`));
|
|
116443
116246
|
const spinner = ora8("Launching browser…").start();
|
|
116444
116247
|
let browser = null;
|
|
@@ -116450,7 +116253,7 @@ async function runCommand(rawOpts) {
|
|
|
116450
116253
|
const min = Math.floor(elapsedSec / 60);
|
|
116451
116254
|
const sec = elapsedSec % 60;
|
|
116452
116255
|
const mmss = `${min.toString().padStart(2, "0")}:${sec.toString().padStart(2, "0")}`;
|
|
116453
|
-
spinner.text = `${
|
|
116256
|
+
spinner.text = `${chalk34.dim(`⏱ ${mmss} ·`)} ${currentSpinnerLabel}`;
|
|
116454
116257
|
};
|
|
116455
116258
|
const setSpinnerLabel = (label) => {
|
|
116456
116259
|
currentSpinnerLabel = label;
|
|
@@ -116570,8 +116373,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
116570
116373
|
for (const flow of flows) {
|
|
116571
116374
|
const flowStart = Date.now();
|
|
116572
116375
|
let lastStepTotal = 0;
|
|
116573
|
-
const sideTag = side === "prod" ?
|
|
116574
|
-
const prefix = `${
|
|
116376
|
+
const sideTag = side === "prod" ? chalk34.cyan("prod") : chalk34.magenta("cand");
|
|
116377
|
+
const prefix = `${chalk34.dim(`[${viewport}/`)}${sideTag}${chalk34.dim("]")}`;
|
|
116575
116378
|
setSpinnerLabel(`${prefix} ${flow}: starting…`);
|
|
116576
116379
|
const cap = await runFlow(flow, {
|
|
116577
116380
|
baseUrl,
|
|
@@ -116588,7 +116391,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
116588
116391
|
onStep: (event) => {
|
|
116589
116392
|
if (event.phase === "start") {
|
|
116590
116393
|
lastStepTotal = event.total;
|
|
116591
|
-
setSpinnerLabel(`${prefix} ${flow} ${
|
|
116394
|
+
setSpinnerLabel(`${prefix} ${flow} ${chalk34.dim(`${event.index}/${event.total}`)} ${event.name}…`);
|
|
116592
116395
|
}
|
|
116593
116396
|
}
|
|
116594
116397
|
});
|
|
@@ -116597,18 +116400,18 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
116597
116400
|
const target = lastStepTotal || recorded;
|
|
116598
116401
|
const failed = cap.steps?.find((s) => s.status === "failed");
|
|
116599
116402
|
const lastStep = cap.steps?.[cap.steps.length - 1];
|
|
116600
|
-
const elapsedDim =
|
|
116601
|
-
const counts = target > 0 ?
|
|
116403
|
+
const elapsedDim = chalk34.dim(`${((Date.now() - flowStart) / 1000).toFixed(1)}s`);
|
|
116404
|
+
const counts = target > 0 ? chalk34.dim(`${okSteps}/${target}`) : "";
|
|
116602
116405
|
let glyph;
|
|
116603
116406
|
let detail;
|
|
116604
116407
|
if (failed) {
|
|
116605
|
-
glyph =
|
|
116606
|
-
detail = `stopped at ${
|
|
116408
|
+
glyph = chalk34.red("✗");
|
|
116409
|
+
detail = `stopped at ${chalk34.yellow(failed.name)}`;
|
|
116607
116410
|
} else if (target > 0 && okSteps < target) {
|
|
116608
|
-
glyph =
|
|
116609
|
-
detail = lastStep ? `ended at ${
|
|
116411
|
+
glyph = chalk34.yellow("▴");
|
|
116412
|
+
detail = lastStep ? `ended at ${chalk34.dim(lastStep.name)}` : "incomplete";
|
|
116610
116413
|
} else {
|
|
116611
|
-
glyph =
|
|
116414
|
+
glyph = chalk34.green("✓");
|
|
116612
116415
|
detail = "";
|
|
116613
116416
|
}
|
|
116614
116417
|
const summary = `${glyph} ${prefix} ${flow} ${counts} ${detail} ${elapsedDim}`.replace(/\s+/g, " ").trim();
|
|
@@ -116670,7 +116473,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
|
|
|
116670
116473
|
const vitalsPagesLimit = opts.vitalsPages ?? vitalsPagesDefault;
|
|
116671
116474
|
const vitalsRuns = Math.max(1, Number.parseInt(opts.runs, 10) || 1);
|
|
116672
116475
|
if (candIsDevServer && vitalsPagesLimit > 0) {
|
|
116673
|
-
console.log(
|
|
116476
|
+
console.log(chalk34.dim(` cand=localhost detectado — vitals-pages=${vitalsPagesLimit}, networkidle desabilitado (issue #55)`));
|
|
116674
116477
|
}
|
|
116675
116478
|
if (browser && vitalsPagesLimit > 0) {
|
|
116676
116479
|
currentPhase = "vitals-pages";
|
|
@@ -117048,23 +116851,20 @@ ${formatTimingsSummary(runTimings, buildFlowBreakdown(allFlowCaptures))}`);
|
|
|
117048
116851
|
${formatPagePairTable(pagePairs)}`);
|
|
117049
116852
|
const missed = pagePairs.filter((p) => !p.match).length;
|
|
117050
116853
|
if (missed > 0) {
|
|
117051
|
-
console.log(
|
|
116854
|
+
console.log(chalk34.red(`
|
|
117052
116855
|
✖ ${missed}/${pagePairs.length} requested page pair(s) were not measured as requested — this report describes other pages; fix the URLs or the capture`));
|
|
117053
116856
|
}
|
|
117054
116857
|
}
|
|
117055
116858
|
const failOnGate = evaluateFailOnGate(remainingIssues, failOn, verdict.status);
|
|
117056
116859
|
if (failOnGate.exitCode === 1) {
|
|
117057
|
-
console.log(
|
|
116860
|
+
console.log(chalk34.red(failOnGate.message));
|
|
117058
116861
|
return 1;
|
|
117059
116862
|
}
|
|
117060
116863
|
if (opts.open) {
|
|
117061
|
-
|
|
117062
|
-
|
|
117063
|
-
|
|
117064
|
-
|
|
117065
|
-
browser = null;
|
|
117066
|
-
}
|
|
117067
|
-
return await serveRunAndBlock(paths.runDir, { label: `parity run · ${runId}` });
|
|
116864
|
+
const { default: open } = await import("open");
|
|
116865
|
+
await open(paths.reportHtml).catch(() => {
|
|
116866
|
+
return;
|
|
116867
|
+
});
|
|
117068
116868
|
}
|
|
117069
116869
|
return 0;
|
|
117070
116870
|
} catch (err) {
|
|
@@ -117124,7 +116924,7 @@ function parsePagePair(entry) {
|
|
|
117124
116924
|
}
|
|
117125
116925
|
function resolveExplicitPages(pagesFile, pagesList) {
|
|
117126
116926
|
if (pagesFile) {
|
|
117127
|
-
if (!
|
|
116927
|
+
if (!existsSync30(pagesFile)) {
|
|
117128
116928
|
throw new Error(`--pages-file não encontrado: ${pagesFile}`);
|
|
117129
116929
|
}
|
|
117130
116930
|
const raw = readFileSync40(pagesFile, "utf-8");
|
|
@@ -117345,10 +117145,10 @@ function hostOf3(url) {
|
|
|
117345
117145
|
function printSummary8(run, htmlPath, meta) {
|
|
117346
117146
|
const { verdict } = run;
|
|
117347
117147
|
const inconclusive = verdict.status === "inconclusive";
|
|
117348
|
-
const emoji = inconclusive ?
|
|
117349
|
-
const score = inconclusive ?
|
|
117148
|
+
const emoji = inconclusive ? chalk34.dim("○") : verdict.status === "pass" ? chalk34.green("✔") : verdict.status === "warn" ? chalk34.yellow("⚠") : chalk34.red("✖");
|
|
117149
|
+
const score = inconclusive ? chalk34.dim("—") : verdict.status === "pass" ? chalk34.green(verdict.score) : verdict.status === "warn" ? chalk34.yellow(verdict.score) : chalk34.red(verdict.score);
|
|
117350
117150
|
const prev = run.previousRun;
|
|
117351
|
-
const scoreDelta = !prev ?
|
|
117151
|
+
const scoreDelta = !prev ? chalk34.dim(" (sem run anterior comparável)") : prev.scoreDelta > 0 ? chalk34.green(` (+${prev.scoreDelta} vs run anterior: ${prev.score})`) : prev.scoreDelta < 0 ? chalk34.red(` (${prev.scoreDelta} vs run anterior: ${prev.score})`) : chalk34.dim(` (= run anterior: ${prev.score})`);
|
|
117352
117152
|
console.log("");
|
|
117353
117153
|
if (inconclusive) {
|
|
117354
117154
|
const why = run.pagePairs?.some((p) => !p.match) ? "the requested --pages were not measured (table below)" : "nothing was measured (0 checks ran)";
|
|
@@ -117358,52 +117158,52 @@ function printSummary8(run, htmlPath, meta) {
|
|
|
117358
117158
|
console.log(` ${emoji} parity ${verdict.status.toUpperCase()} · score ${score}/100${accepted}${scoreDelta}`);
|
|
117359
117159
|
}
|
|
117360
117160
|
for (const e of run.acceptedFindings?.stale ?? []) {
|
|
117361
|
-
console.log(` ${
|
|
117161
|
+
console.log(` ${chalk34.yellow("⚠")} stale acceptance (matched nothing — \`parity accept remove\`): ${[e.check, e.id, e.page, e.match].filter(Boolean).join(" · ")} — ${e.note}`);
|
|
117362
117162
|
}
|
|
117363
|
-
console.log(` checks: ${
|
|
117364
|
-
console.log(` issues: ${
|
|
117163
|
+
console.log(` checks: ${chalk34.green(verdict.checksPassed)} pass · ${chalk34.red(verdict.checksFailed)} fail · ${chalk34.dim(`${verdict.checksSkipped} skipped`)}`);
|
|
117164
|
+
console.log(` issues: ${chalk34.red(verdict.critical)} critical · ${chalk34.yellow(verdict.high)} high · ${verdict.medium} medium · ${chalk34.dim(`${verdict.low} low`)}`);
|
|
117365
117165
|
const band = run.scoreBand;
|
|
117366
117166
|
const bandLine = band ? formatScoreBand(band) : null;
|
|
117367
117167
|
if (band && bandLine) {
|
|
117368
|
-
console.log(` ${
|
|
117168
|
+
console.log(` ${chalk34.dim(bandLine)}`);
|
|
117369
117169
|
const caveat = scoreBandCaveat(band);
|
|
117370
117170
|
if (caveat)
|
|
117371
|
-
console.log(` ${
|
|
117171
|
+
console.log(` ${chalk34.yellow("⚠")} ${caveat}`);
|
|
117372
117172
|
}
|
|
117373
117173
|
for (const c of run.caveats ?? []) {
|
|
117374
|
-
const mark = c.level === "warn" ?
|
|
117174
|
+
const mark = c.level === "warn" ? chalk34.yellow("⚠") : chalk34.dim("ℹ");
|
|
117375
117175
|
console.log(` ${mark} ${c.summary}`);
|
|
117376
117176
|
}
|
|
117377
117177
|
if (run.moduleVerdicts && run.moduleVerdicts.length > 0) {
|
|
117378
117178
|
const perModule = run.moduleVerdicts.map((mv) => {
|
|
117379
|
-
const colored = mv.status === "pass" ?
|
|
117179
|
+
const colored = mv.status === "pass" ? chalk34.green(mv.score) : mv.status === "warn" ? chalk34.yellow(mv.score) : chalk34.red(mv.score);
|
|
117380
117180
|
return `${mv.module} ${colored}`;
|
|
117381
117181
|
}).join(" · ");
|
|
117382
117182
|
console.log(` modules: ${perModule} → composite ${score}`);
|
|
117383
117183
|
}
|
|
117384
117184
|
if (run.visualDiff) {
|
|
117385
117185
|
const vd = run.visualDiff;
|
|
117386
|
-
const parityIcon = vd.parityOk ?
|
|
117387
|
-
const parityLabel = vd.parityOk ?
|
|
117388
|
-
const cacheNote = vd.pagesFromCache > 0 ?
|
|
117389
|
-
console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${
|
|
117186
|
+
const parityIcon = vd.parityOk ? chalk34.green("✔") : chalk34.red("✖");
|
|
117187
|
+
const parityLabel = vd.parityOk ? chalk34.green("OK") : chalk34.red("DIFFS");
|
|
117188
|
+
const cacheNote = vd.pagesFromCache > 0 ? chalk34.dim(` · ${vd.pagesFromCache} cached`) : "";
|
|
117189
|
+
console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${chalk34.red(vd.pagesWithDiffs)} diffs · ${chalk34.green(vd.pagesPassed)} pass${cacheNote}`);
|
|
117390
117190
|
}
|
|
117391
117191
|
if (run.topIssues.length > 0) {
|
|
117392
117192
|
console.log("");
|
|
117393
|
-
console.log(
|
|
117193
|
+
console.log(chalk34.bold(" Top issues:"));
|
|
117394
117194
|
for (const g of groupIssues(run.topIssues).slice(0, 5)) {
|
|
117395
117195
|
const i = g.sample;
|
|
117396
|
-
const sev = i.severity === "critical" ?
|
|
117397
|
-
const pagesNote = g.pages.length > 1 ?
|
|
117196
|
+
const sev = i.severity === "critical" ? chalk34.red(`[${i.severity}]`) : i.severity === "high" ? chalk34.yellow(`[${i.severity}]`) : chalk34.dim(`[${i.severity}]`);
|
|
117197
|
+
const pagesNote = g.pages.length > 1 ? chalk34.dim(` (${g.pages.length} páginas)`) : "";
|
|
117398
117198
|
console.log(` ${sev} ${i.summary}${pagesNote}`);
|
|
117399
117199
|
}
|
|
117400
117200
|
}
|
|
117401
117201
|
if (meta.promotedCount > 0 || meta.deprecatedCount > 0) {
|
|
117402
117202
|
console.log("");
|
|
117403
|
-
console.log(
|
|
117203
|
+
console.log(chalk34.dim(` \uD83D\uDCDA learned-selectors [${meta.platform}]: ${chalk34.green(`+${meta.promotedCount}`)} promoted · ${chalk34.yellow(meta.deprecatedCount)} deprecated`));
|
|
117404
117204
|
}
|
|
117405
117205
|
console.log("");
|
|
117406
|
-
console.log(
|
|
117206
|
+
console.log(chalk34.dim(` → ${htmlPath}`));
|
|
117407
117207
|
console.log("");
|
|
117408
117208
|
}
|
|
117409
117209
|
|
|
@@ -117427,26 +117227,26 @@ async function prCommand(opts) {
|
|
|
117427
117227
|
preset: opts.preset ?? "ci",
|
|
117428
117228
|
open: false
|
|
117429
117229
|
};
|
|
117430
|
-
console.log(
|
|
117431
|
-
console.log(
|
|
117230
|
+
console.log(chalk35.dim(` prod : ${opts.prod}`));
|
|
117231
|
+
console.log(chalk35.dim(` preview : ${opts.preview}`));
|
|
117432
117232
|
console.log("");
|
|
117433
117233
|
const runCode = await runCommand(runOpts);
|
|
117434
117234
|
const runs = listRuns(opts.output);
|
|
117435
117235
|
if (runs.length === 0) {
|
|
117436
|
-
console.error(
|
|
117236
|
+
console.error(chalk35.red("no run was produced — cannot build PR comment"));
|
|
117437
117237
|
return runCode || 1;
|
|
117438
117238
|
}
|
|
117439
117239
|
const latest = runs[0];
|
|
117440
117240
|
const reportJsonPath = join46(opts.output, "runs", latest.id, "report.json");
|
|
117441
|
-
if (!
|
|
117442
|
-
console.error(
|
|
117241
|
+
if (!existsSync31(reportJsonPath)) {
|
|
117242
|
+
console.error(chalk35.red(`report.json not found at ${reportJsonPath}`));
|
|
117443
117243
|
return runCode || 1;
|
|
117444
117244
|
}
|
|
117445
117245
|
const run = JSON.parse(readFileSync41(reportJsonPath, "utf8"));
|
|
117446
117246
|
const markdown = buildPrComment(run, opts);
|
|
117447
117247
|
if (opts.out) {
|
|
117448
117248
|
writeFileSync33(opts.out, markdown, "utf8");
|
|
117449
|
-
console.log(
|
|
117249
|
+
console.log(chalk35.dim(` wrote PR comment: ${opts.out}`));
|
|
117450
117250
|
} else {
|
|
117451
117251
|
process.stdout.write(`
|
|
117452
117252
|
${markdown}
|
|
@@ -117456,7 +117256,7 @@ ${markdown}
|
|
|
117456
117256
|
try {
|
|
117457
117257
|
writeFileSync33(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
|
|
117458
117258
|
} catch (err) {
|
|
117459
|
-
console.error(
|
|
117259
|
+
console.error(chalk35.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
|
|
117460
117260
|
}
|
|
117461
117261
|
}
|
|
117462
117262
|
return runCode;
|
|
@@ -117516,14 +117316,14 @@ function buildPrComment(run, opts) {
|
|
|
117516
117316
|
}
|
|
117517
117317
|
|
|
117518
117318
|
// src/commands/prompt.ts
|
|
117519
|
-
import { existsSync as
|
|
117520
|
-
import
|
|
117319
|
+
import { existsSync as existsSync32, writeFileSync as writeFileSync34 } from "node:fs";
|
|
117320
|
+
import chalk36 from "chalk";
|
|
117521
117321
|
function promptCommand(runId, opts) {
|
|
117522
117322
|
let run;
|
|
117523
117323
|
try {
|
|
117524
117324
|
run = loadRun(opts.output, runId);
|
|
117525
117325
|
} catch (err) {
|
|
117526
|
-
console.error(
|
|
117326
|
+
console.error(chalk36.red(`✖ ${err.message}`));
|
|
117527
117327
|
return 1;
|
|
117528
117328
|
}
|
|
117529
117329
|
const md = buildLlmPrompt(run, {
|
|
@@ -117532,10 +117332,10 @@ function promptCommand(runId, opts) {
|
|
|
117532
117332
|
});
|
|
117533
117333
|
if (opts.out) {
|
|
117534
117334
|
writeFileSync34(opts.out, md, "utf8");
|
|
117535
|
-
console.log(
|
|
117536
|
-
if (
|
|
117335
|
+
console.log(chalk36.green(`✔ prompt salvo em ${opts.out}`));
|
|
117336
|
+
if (existsSync32(opts.out)) {
|
|
117537
117337
|
const sizeKb = (md.length / 1024).toFixed(1);
|
|
117538
|
-
console.log(
|
|
117338
|
+
console.log(chalk36.dim(` ${md.length} chars (${sizeKb} KB)`));
|
|
117539
117339
|
}
|
|
117540
117340
|
} else {
|
|
117541
117341
|
process.stdout.write(md);
|
|
@@ -117544,12 +117344,12 @@ function promptCommand(runId, opts) {
|
|
|
117544
117344
|
}
|
|
117545
117345
|
|
|
117546
117346
|
// src/commands/qa.ts
|
|
117547
|
-
import { existsSync as
|
|
117347
|
+
import { existsSync as existsSync36, readFileSync as readFileSync44 } from "node:fs";
|
|
117548
117348
|
import { basename as basename6, dirname as dirname10, join as join50 } from "node:path";
|
|
117549
|
-
import
|
|
117349
|
+
import chalk38 from "chalk";
|
|
117550
117350
|
|
|
117551
117351
|
// src/board/sweep-cards.ts
|
|
117552
|
-
import { existsSync as
|
|
117352
|
+
import { existsSync as existsSync33, readFileSync as readFileSync42 } from "node:fs";
|
|
117553
117353
|
var QA_PREFIX = "[QA]";
|
|
117554
117354
|
var CARD_BODY_MAX = 1200;
|
|
117555
117355
|
var CLOSED = new Set(["done", "archived", "merged"]);
|
|
@@ -117876,7 +117676,7 @@ function readSpecs(entries) {
|
|
|
117876
117676
|
const out = {};
|
|
117877
117677
|
for (const e of entries)
|
|
117878
117678
|
for (const ev of e.issue?.evidence ?? [])
|
|
117879
|
-
if (ev.kind === "spec" &&
|
|
117679
|
+
if (ev.kind === "spec" && existsSync33(ev.path))
|
|
117880
117680
|
out[ev.path] = readFileSync42(ev.path, "utf8");
|
|
117881
117681
|
return out;
|
|
117882
117682
|
}
|
|
@@ -117901,7 +117701,7 @@ function plannedEvidenceUrls(entries, run, cfg) {
|
|
|
117901
117701
|
return {};
|
|
117902
117702
|
const out = {};
|
|
117903
117703
|
for (const p of cardEvidencePaths(entries))
|
|
117904
|
-
if (
|
|
117704
|
+
if (existsSync33(p))
|
|
117905
117705
|
out[p] = `${base}/fs/org/read?path=${encodeURIComponent(evidenceLibraryPath(p, run))}`;
|
|
117906
117706
|
return out;
|
|
117907
117707
|
}
|
|
@@ -117909,7 +117709,7 @@ async function uploadEvidence(entries, run, cfg, call, opts) {
|
|
|
117909
117709
|
const upload = opts.upload ?? ((local, lib) => uploadToLibrary(cfg, local, lib, call));
|
|
117910
117710
|
const out = {};
|
|
117911
117711
|
for (const p of cardEvidencePaths(entries)) {
|
|
117912
|
-
if (!
|
|
117712
|
+
if (!existsSync33(p))
|
|
117913
117713
|
continue;
|
|
117914
117714
|
const url = await upload(p, evidenceLibraryPath(p, run));
|
|
117915
117715
|
if (url)
|
|
@@ -117925,9 +117725,9 @@ function truncate6(s, n) {
|
|
|
117925
117725
|
}
|
|
117926
117726
|
|
|
117927
117727
|
// src/commands/sweep.ts
|
|
117928
|
-
import { existsSync as
|
|
117728
|
+
import { existsSync as existsSync35, readFileSync as readFileSync43, writeFileSync as writeFileSync35 } from "node:fs";
|
|
117929
117729
|
import { join as join49 } from "node:path";
|
|
117930
|
-
import
|
|
117730
|
+
import chalk37 from "chalk";
|
|
117931
117731
|
import { z as z4 } from "zod";
|
|
117932
117732
|
|
|
117933
117733
|
// ../../node_modules/.bun/@axe-core+playwright@4.14.0+61592b2670ac03c8/node_modules/@axe-core/playwright/dist/index.mjs
|
|
@@ -118490,13 +118290,13 @@ function menuLinkIssues(visits) {
|
|
|
118490
118290
|
|
|
118491
118291
|
// src/engine/regression-specs.ts
|
|
118492
118292
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
118493
|
-
import { existsSync as
|
|
118293
|
+
import { existsSync as existsSync34 } from "node:fs";
|
|
118494
118294
|
import { join as join48, resolve as resolve20 } from "node:path";
|
|
118495
118295
|
import { stripVTControlCharacters } from "node:util";
|
|
118496
118296
|
function runRegressionSpecs(repoDirArg, baseUrl) {
|
|
118497
118297
|
const repoDir = resolve20(repoDirArg);
|
|
118498
118298
|
const dir = join48(repoDir, "tests", "qa");
|
|
118499
|
-
if (!
|
|
118299
|
+
if (!existsSync34(dir))
|
|
118500
118300
|
return null;
|
|
118501
118301
|
spawnSync2("npx", ["playwright", "install", "chromium"], {
|
|
118502
118302
|
cwd: repoDir,
|
|
@@ -118504,7 +118304,7 @@ function runRegressionSpecs(repoDirArg, baseUrl) {
|
|
|
118504
118304
|
timeout: 10 * 60000
|
|
118505
118305
|
});
|
|
118506
118306
|
const config = join48(dir, "playwright.config.ts");
|
|
118507
|
-
const args =
|
|
118307
|
+
const args = existsSync34(config) ? ["playwright", "test", "-c", config, "--reporter=json"] : ["playwright", "test", "tests/qa", "--reporter=json"];
|
|
118508
118308
|
const res = spawnSync2("npx", args, {
|
|
118509
118309
|
cwd: repoDir,
|
|
118510
118310
|
env: { ...process.env, BASE_URL: baseUrl, CI: "1" },
|
|
@@ -118646,16 +118446,16 @@ async function sweepCommand(opts) {
|
|
|
118646
118446
|
const trend = annotateTrend(opts.output, done.runId);
|
|
118647
118447
|
if (!opts.json) {
|
|
118648
118448
|
if (trend) {
|
|
118649
|
-
console.log(
|
|
118449
|
+
console.log(chalk37.dim(` trend vs ${trend.previousRunId}: ${trend.new} new · ${trend.recurring} recurring · ${trend.resolved} resolved`));
|
|
118650
118450
|
} else {
|
|
118651
|
-
console.log(
|
|
118451
|
+
console.log(chalk37.dim(" trend: first sweep of this host"));
|
|
118652
118452
|
}
|
|
118653
118453
|
const missed = missedFloors(readReport(done.reportJson) ?? { flowCaptures: [] });
|
|
118654
118454
|
if (missed.length)
|
|
118655
|
-
console.log(
|
|
118455
|
+
console.log(chalk37.yellow(` não alcançado (${missed.length}): ${missed.join(", ")}`));
|
|
118656
118456
|
const unverified = readUnverified(done.reportJson);
|
|
118657
118457
|
if (unverified.length) {
|
|
118658
|
-
console.log(
|
|
118458
|
+
console.log(chalk37.yellow(` não verificado (${unverified.length}): ${unverified.slice(0, 8).join(", ")}${unverified.length > 8 ? "…" : ""}`));
|
|
118659
118459
|
}
|
|
118660
118460
|
}
|
|
118661
118461
|
if (opts.board) {
|
|
@@ -118769,7 +118569,7 @@ async function addProbeFindings(url, runDir, reportJson, rc, json, specsRepo) {
|
|
|
118769
118569
|
`, "utf8");
|
|
118770
118570
|
if (!json) {
|
|
118771
118571
|
for (const i of issues)
|
|
118772
|
-
console.log(
|
|
118572
|
+
console.log(chalk37[i.inconclusive ? "yellow" : "red"](` ${i.summary}`));
|
|
118773
118573
|
}
|
|
118774
118574
|
}
|
|
118775
118575
|
function missedFloors(report) {
|
|
@@ -118802,7 +118602,7 @@ var SEVERITIES = ["critical", "high", "medium", "low"];
|
|
|
118802
118602
|
var SWEEPER_ISSUES_FILE = "sweeper-issues.json";
|
|
118803
118603
|
function readSweeperIssues(runDir) {
|
|
118804
118604
|
const path = join49(runDir, SWEEPER_ISSUES_FILE);
|
|
118805
|
-
if (!
|
|
118605
|
+
if (!existsSync35(path))
|
|
118806
118606
|
return { issues: [], dropped: new Set };
|
|
118807
118607
|
const parsed = z4.object({
|
|
118808
118608
|
issues: agentIssues,
|
|
@@ -118830,7 +118630,7 @@ function normalizeAgentIssue(raw) {
|
|
|
118830
118630
|
var agentIssues = z4.preprocess((v) => Array.isArray(v) ? v.map(normalizeAgentIssue) : v, z4.array(Issue).default([]));
|
|
118831
118631
|
function readCardReview(runDir) {
|
|
118832
118632
|
const path = join49(runDir, CARD_REVIEW_FILE);
|
|
118833
|
-
if (!
|
|
118633
|
+
if (!existsSync35(path))
|
|
118834
118634
|
return { issues: [], hold: new Map };
|
|
118835
118635
|
const parsed = z4.object({
|
|
118836
118636
|
issues: agentIssues,
|
|
@@ -118864,28 +118664,28 @@ function mergeIssues(report, agent, dropped) {
|
|
|
118864
118664
|
}
|
|
118865
118665
|
async function sweepFileCommand(opts) {
|
|
118866
118666
|
if ((opts.board ?? "studio") !== "studio") {
|
|
118867
|
-
console.error(
|
|
118667
|
+
console.error(chalk37.red(`--board ${opts.board}: only "studio" is supported`));
|
|
118868
118668
|
return 2;
|
|
118869
118669
|
}
|
|
118870
118670
|
const minSeverity = opts.minSeverity ?? "medium";
|
|
118871
118671
|
if (!SEVERITIES.includes(minSeverity)) {
|
|
118872
|
-
console.error(
|
|
118672
|
+
console.error(chalk37.red(`--min-severity ${opts.minSeverity}: use ${SEVERITIES.join("|")}`));
|
|
118873
118673
|
return 2;
|
|
118874
118674
|
}
|
|
118875
118675
|
const runId = opts.run ?? listRuns(opts.output).find((r) => readReport(r.reportPath)?.mode === "sweep")?.id;
|
|
118876
118676
|
if (!runId) {
|
|
118877
|
-
console.error(
|
|
118677
|
+
console.error(chalk37.red(`no sweep run in ${opts.output} — run \`parity sweep --url …\` first`));
|
|
118878
118678
|
return 2;
|
|
118879
118679
|
}
|
|
118880
118680
|
const paths = getRunPaths(opts.output, runId);
|
|
118881
118681
|
const report = readReport(paths.reportJson);
|
|
118882
118682
|
if (!report || report.mode !== "sweep") {
|
|
118883
|
-
console.error(
|
|
118683
|
+
console.error(chalk37.red(`${runId} is not a sweep run`));
|
|
118884
118684
|
return 2;
|
|
118885
118685
|
}
|
|
118886
118686
|
const cfg = studioConfigFromEnv();
|
|
118887
118687
|
if (!cfg) {
|
|
118888
|
-
console.error(
|
|
118688
|
+
console.error(chalk37.red(`Studio not configured — ${STUDIO_LOGIN_HINT}; org via PARITY_STUDIO_ORG or PARITY_STUDIO_URL.`));
|
|
118889
118689
|
return 2;
|
|
118890
118690
|
}
|
|
118891
118691
|
const agent = readSweeperIssues(paths.runDir);
|
|
@@ -118931,7 +118731,7 @@ async function sweepFileCommand(opts) {
|
|
|
118931
118731
|
allowAutomation: opts.allowAutomation
|
|
118932
118732
|
});
|
|
118933
118733
|
} catch (err) {
|
|
118934
|
-
console.error(
|
|
118734
|
+
console.error(chalk37.red(err instanceof Error ? err.message : String(err)));
|
|
118935
118735
|
return 1;
|
|
118936
118736
|
}
|
|
118937
118737
|
if (opts.json) {
|
|
@@ -118948,14 +118748,14 @@ async function sweepFileCommand(opts) {
|
|
|
118948
118748
|
}));
|
|
118949
118749
|
return 0;
|
|
118950
118750
|
}
|
|
118951
|
-
const head = opts.yes ?
|
|
118751
|
+
const head = opts.yes ? chalk37.bold(" filed on the Studio board") : chalk37.bold(" dry run — add --yes to file");
|
|
118952
118752
|
console.log(`
|
|
118953
118753
|
${head} (run ${runId}, ≥ ${minSeverity}${agent.issues.length ? `, +${agent.issues.length} from sweeper` : ""})`);
|
|
118954
118754
|
for (const e of result.entries) {
|
|
118955
|
-
const tag = e.action === "create" ?
|
|
118755
|
+
const tag = e.action === "create" ? chalk37.green("create ") : e.action === "update" ? chalk37.yellow("update ") : e.action === "regression" ? chalk37.red("regress") : chalk37.dim("skip ");
|
|
118956
118756
|
console.log(` ${tag} ${e.title}`);
|
|
118957
118757
|
}
|
|
118958
|
-
console.log(
|
|
118758
|
+
console.log(chalk37.dim(` ${result.created} created · ${result.updated} updated · ${result.regressions} regressions · ${result.skipped} skipped${result.summaryRef ? ` · summary ${result.summaryRef}` : ""}`));
|
|
118959
118759
|
return 0;
|
|
118960
118760
|
}
|
|
118961
118761
|
function countTotals(issues) {
|
|
@@ -119005,11 +118805,11 @@ async function sweepScheduleCommand(opts) {
|
|
|
119005
118805
|
console.log(JSON.stringify(job));
|
|
119006
118806
|
return 0;
|
|
119007
118807
|
}
|
|
119008
|
-
console.log(
|
|
118808
|
+
console.log(chalk37.bold(`
|
|
119009
118809
|
control-plane JOB_CREATE payload (monthly sweep)
|
|
119010
118810
|
`));
|
|
119011
118811
|
console.log(JSON.stringify(job, null, 2));
|
|
119012
|
-
console.log(
|
|
118812
|
+
console.log(chalk37.dim([
|
|
119013
118813
|
"",
|
|
119014
118814
|
" How to create it:",
|
|
119015
118815
|
" • from Claude Code with the parity plugin: /parity:sweep schedule … (calls the deco-control-plane MCP `JOB_CREATE` with this payload)",
|
|
@@ -119028,22 +118828,22 @@ async function sweepScheduleCommand(opts) {
|
|
|
119028
118828
|
var SEVERITIES2 = ["critical", "high", "medium", "low"];
|
|
119029
118829
|
async function qaFileCommand(opts) {
|
|
119030
118830
|
if ((opts.board ?? "studio") !== "studio") {
|
|
119031
|
-
console.error(
|
|
118831
|
+
console.error(chalk38.red(`--board ${opts.board}: only "studio" is supported`));
|
|
119032
118832
|
return 2;
|
|
119033
118833
|
}
|
|
119034
118834
|
const minSeverity = opts.minSeverity ?? "medium";
|
|
119035
118835
|
if (!SEVERITIES2.includes(minSeverity)) {
|
|
119036
|
-
console.error(
|
|
118836
|
+
console.error(chalk38.red(`--min-severity ${opts.minSeverity}: use ${SEVERITIES2.join("|")}`));
|
|
119037
118837
|
return 2;
|
|
119038
118838
|
}
|
|
119039
|
-
if (!
|
|
119040
|
-
console.error(
|
|
118839
|
+
if (!existsSync36(opts.issues)) {
|
|
118840
|
+
console.error(chalk38.red(`${opts.issues}: not found`));
|
|
119041
118841
|
return 2;
|
|
119042
118842
|
}
|
|
119043
118843
|
const raw = JSON.parse(readFileSync44(opts.issues, "utf8"));
|
|
119044
118844
|
const parsed = agentIssues.safeParse(Array.isArray(raw) ? raw : raw?.issues);
|
|
119045
118845
|
if (!parsed.success) {
|
|
119046
|
-
console.error(
|
|
118846
|
+
console.error(chalk38.red(`${opts.issues}: ${parsed.error.message}`));
|
|
119047
118847
|
return 2;
|
|
119048
118848
|
}
|
|
119049
118849
|
const dir = dirname10(opts.issues);
|
|
@@ -119055,7 +118855,7 @@ async function qaFileCommand(opts) {
|
|
|
119055
118855
|
const { issues, held } = applyCardReview(parsed.data, review);
|
|
119056
118856
|
const cfg = studioConfigFromEnv();
|
|
119057
118857
|
if (!cfg) {
|
|
119058
|
-
console.error(
|
|
118858
|
+
console.error(chalk38.red(`Studio not configured — ${STUDIO_LOGIN_HINT}`));
|
|
119059
118859
|
return 2;
|
|
119060
118860
|
}
|
|
119061
118861
|
const info = {
|
|
@@ -119091,24 +118891,24 @@ async function qaFileCommand(opts) {
|
|
|
119091
118891
|
}));
|
|
119092
118892
|
return 0;
|
|
119093
118893
|
}
|
|
119094
|
-
console.log(
|
|
118894
|
+
console.log(chalk38.bold(`
|
|
119095
118895
|
${opts.yes ? "filed on the Studio board" : "dry run — add --yes to file"}`));
|
|
119096
118896
|
for (const e of result.entries)
|
|
119097
118897
|
console.log(` ${e.action.padEnd(10)} ${e.title}`);
|
|
119098
118898
|
for (const h of held)
|
|
119099
|
-
console.log(
|
|
119100
|
-
console.log(
|
|
118899
|
+
console.log(chalk38.dim(` ${h}`));
|
|
118900
|
+
console.log(chalk38.dim(` ${result.created} created · ${result.updated} updated · ${result.regressions} regressions`));
|
|
119101
118901
|
return 0;
|
|
119102
118902
|
} catch (err) {
|
|
119103
|
-
console.error(
|
|
118903
|
+
console.error(chalk38.red(err instanceof Error ? err.message : String(err)));
|
|
119104
118904
|
return 1;
|
|
119105
118905
|
}
|
|
119106
118906
|
}
|
|
119107
118907
|
|
|
119108
118908
|
// src/commands/report.ts
|
|
119109
|
-
import { existsSync as
|
|
118909
|
+
import { existsSync as existsSync37, readFileSync as readFileSync45, writeFileSync as writeFileSync36 } from "node:fs";
|
|
119110
118910
|
import { join as join51 } from "node:path";
|
|
119111
|
-
import
|
|
118911
|
+
import chalk39 from "chalk";
|
|
119112
118912
|
import open3 from "open";
|
|
119113
118913
|
|
|
119114
118914
|
// src/report/deck-template.ts
|
|
@@ -119634,7 +119434,6 @@ var ALL_REPORT_SECTIONS = [
|
|
|
119634
119434
|
"summary",
|
|
119635
119435
|
"visualdiff",
|
|
119636
119436
|
"seo",
|
|
119637
|
-
"sidebyside",
|
|
119638
119437
|
"issues",
|
|
119639
119438
|
"vitals",
|
|
119640
119439
|
"cache",
|
|
@@ -119669,7 +119468,8 @@ function extractJsonSection(run, section) {
|
|
|
119669
119468
|
candUrl: run.candUrl,
|
|
119670
119469
|
verdict: run.verdict,
|
|
119671
119470
|
topIssues: run.topIssues,
|
|
119672
|
-
durationMs: run.durationMs
|
|
119471
|
+
durationMs: run.durationMs,
|
|
119472
|
+
scoreBreakdown: explainCompositeScore(run.moduleVerdicts ?? [], run.verdict, run.checks)
|
|
119673
119473
|
};
|
|
119674
119474
|
case "visualdiff":
|
|
119675
119475
|
return run.visualDiff ?? null;
|
|
@@ -119695,8 +119495,6 @@ function extractJsonSection(run, section) {
|
|
|
119695
119495
|
return extractPagesSlice(run);
|
|
119696
119496
|
case "console":
|
|
119697
119497
|
return run.checks.filter((c) => c.name === "console-errors-baseline").flatMap((c) => c.issues);
|
|
119698
|
-
case "sidebyside":
|
|
119699
|
-
return extractSideBySideSlice(run);
|
|
119700
119498
|
case "prompt":
|
|
119701
119499
|
return {
|
|
119702
119500
|
runId: run.id,
|
|
@@ -119753,26 +119551,6 @@ function extractPagesSlice(run) {
|
|
|
119753
119551
|
}
|
|
119754
119552
|
return rows;
|
|
119755
119553
|
}
|
|
119756
|
-
function extractSideBySideSlice(run) {
|
|
119757
|
-
const pairs = [];
|
|
119758
|
-
for (const fc of run.flowCaptures) {
|
|
119759
|
-
for (const p of fc.pages) {
|
|
119760
|
-
if (p.side !== "prod")
|
|
119761
|
-
continue;
|
|
119762
|
-
const candPath = pathOf7(p.url);
|
|
119763
|
-
const cand = fc.pages.find((q) => q.side === "cand" && pathOf7(q.url) === candPath && q.viewport === p.viewport);
|
|
119764
|
-
if (!cand)
|
|
119765
|
-
continue;
|
|
119766
|
-
pairs.push({
|
|
119767
|
-
label: `${candPath || "/"} · ${p.viewport}`,
|
|
119768
|
-
prodUrl: p.url,
|
|
119769
|
-
candUrl: cand.url,
|
|
119770
|
-
viewport: p.viewport
|
|
119771
|
-
});
|
|
119772
|
-
}
|
|
119773
|
-
}
|
|
119774
|
-
return pairs;
|
|
119775
|
-
}
|
|
119776
119554
|
function pathOf7(url) {
|
|
119777
119555
|
try {
|
|
119778
119556
|
return new URL(url).pathname || "/";
|
|
@@ -119789,7 +119567,7 @@ async function reportCommand(runId, opts) {
|
|
|
119789
119567
|
try {
|
|
119790
119568
|
run = loadRun(opts.output, runId);
|
|
119791
119569
|
} catch (err) {
|
|
119792
|
-
console.error(
|
|
119570
|
+
console.error(chalk39.red(`failed to load run: ${err.message}`));
|
|
119793
119571
|
return 1;
|
|
119794
119572
|
}
|
|
119795
119573
|
let plan = null;
|
|
@@ -119797,29 +119575,33 @@ async function reportCommand(runId, opts) {
|
|
|
119797
119575
|
try {
|
|
119798
119576
|
plan = loadPlan(opts.planDir);
|
|
119799
119577
|
} catch (err) {
|
|
119800
|
-
console.error(
|
|
119578
|
+
console.error(chalk39.red(`failed to read migration-plan.json: ${err.message}`));
|
|
119801
119579
|
return 1;
|
|
119802
119580
|
}
|
|
119803
119581
|
if (!plan) {
|
|
119804
|
-
console.error(
|
|
119582
|
+
console.error(chalk39.red(`no migration-plan.json in ${opts.planDir}`));
|
|
119805
119583
|
return 1;
|
|
119806
119584
|
}
|
|
119807
119585
|
}
|
|
119808
119586
|
const html = renderDeckHtml(buildDeckModel(run, plan), opts.lang ?? "en");
|
|
119809
119587
|
const dest = opts.out ?? join51(paths.runDir, "deck.html");
|
|
119810
119588
|
writeFileSync36(dest, html, "utf8");
|
|
119811
|
-
console.log(`${
|
|
119589
|
+
console.log(`${chalk39.green("✓")} deck → ${dest}`);
|
|
119812
119590
|
if (opts.open) {
|
|
119813
119591
|
await open3(dest).catch((err) => {
|
|
119814
|
-
console.error(
|
|
119592
|
+
console.error(chalk39.red(`failed to open: ${err.message}`));
|
|
119815
119593
|
});
|
|
119816
119594
|
}
|
|
119817
119595
|
return 0;
|
|
119818
119596
|
}
|
|
119819
119597
|
if (opts.section) {
|
|
119598
|
+
if (opts.section === "sidebyside") {
|
|
119599
|
+
console.error(chalk39.yellow("⚠ section `sidebyside` was removed from the report — use `parity cockpit --prod <url> --cand <url>` for the live prod × cand view."));
|
|
119600
|
+
return 1;
|
|
119601
|
+
}
|
|
119820
119602
|
if (!ALL_REPORT_SECTIONS.includes(opts.section)) {
|
|
119821
|
-
console.error(
|
|
119822
|
-
console.error(
|
|
119603
|
+
console.error(chalk39.red(`unknown section "${opts.section}"`));
|
|
119604
|
+
console.error(chalk39.gray(` valid: ${ALL_REPORT_SECTIONS.join(", ")}`));
|
|
119823
119605
|
return 1;
|
|
119824
119606
|
}
|
|
119825
119607
|
if (opts.json) {
|
|
@@ -119827,40 +119609,40 @@ async function reportCommand(runId, opts) {
|
|
|
119827
119609
|
const run = loadRun(opts.output, runId);
|
|
119828
119610
|
const payload = extractReportSection({ kind: "json", section: opts.section, run });
|
|
119829
119611
|
if (payload === null) {
|
|
119830
|
-
console.error(
|
|
119612
|
+
console.error(chalk39.red(`section "${opts.section}" not present in this run`));
|
|
119831
119613
|
return 1;
|
|
119832
119614
|
}
|
|
119833
119615
|
process.stdout.write(`${JSON.stringify(payload, null, 2)}
|
|
119834
119616
|
`);
|
|
119835
119617
|
return 0;
|
|
119836
119618
|
} catch (err) {
|
|
119837
|
-
console.error(
|
|
119619
|
+
console.error(chalk39.red(`failed to load run: ${err.message}`));
|
|
119838
119620
|
return 1;
|
|
119839
119621
|
}
|
|
119840
119622
|
}
|
|
119841
|
-
if (!
|
|
119842
|
-
console.error(
|
|
119623
|
+
if (!existsSync37(paths.reportHtml)) {
|
|
119624
|
+
console.error(chalk39.red(`report.html not found at ${paths.reportHtml}`));
|
|
119843
119625
|
return 1;
|
|
119844
119626
|
}
|
|
119845
119627
|
const html = readFileSync45(paths.reportHtml, "utf8");
|
|
119846
119628
|
const slice = extractReportSection({ kind: "html", section: opts.section, html });
|
|
119847
119629
|
if (slice === null) {
|
|
119848
|
-
console.error(
|
|
119630
|
+
console.error(chalk39.red(`section "${opts.section}" not present in this report`));
|
|
119849
119631
|
return 1;
|
|
119850
119632
|
}
|
|
119851
119633
|
process.stdout.write(slice);
|
|
119852
119634
|
return 0;
|
|
119853
119635
|
}
|
|
119854
|
-
console.log(
|
|
119636
|
+
console.log(chalk39.dim(`opening ${paths.reportHtml}`));
|
|
119855
119637
|
await open3(paths.reportHtml).catch((err) => {
|
|
119856
|
-
console.error(
|
|
119638
|
+
console.error(chalk39.red(`failed to open: ${err.message}`));
|
|
119857
119639
|
});
|
|
119858
119640
|
return 0;
|
|
119859
119641
|
}
|
|
119860
119642
|
|
|
119861
119643
|
// src/commands/rerender.ts
|
|
119862
119644
|
import { writeFileSync as writeFileSync37 } from "node:fs";
|
|
119863
|
-
import
|
|
119645
|
+
import chalk40 from "chalk";
|
|
119864
119646
|
function analyzeFrames(before, frames, opts = {}) {
|
|
119865
119647
|
const threshold = opts.flashWhite ?? Math.min(97, before.white + 20);
|
|
119866
119648
|
const flashes = [];
|
|
@@ -119942,7 +119724,7 @@ function visibleImagesInPage() {
|
|
|
119942
119724
|
var SKELETON = "[class*='skeleton' i], .animate-pulse, [aria-busy='true'], .loading";
|
|
119943
119725
|
async function rerenderCommand(opts) {
|
|
119944
119726
|
if (!opts.selector && !opts.text) {
|
|
119945
|
-
console.error(
|
|
119727
|
+
console.error(chalk40.red("pass --selector or --text"));
|
|
119946
119728
|
return 2;
|
|
119947
119729
|
}
|
|
119948
119730
|
const browser = await launchBrowser({ headless: true });
|
|
@@ -120023,7 +119805,7 @@ async function rerenderCommand(opts) {
|
|
|
120023
119805
|
t0 = Date.now();
|
|
120024
119806
|
const clicked = await target.click({ timeout: 5000 }).then(() => true).catch(() => false);
|
|
120025
119807
|
if (!clicked) {
|
|
120026
|
-
console.error(
|
|
119808
|
+
console.error(chalk40.yellow("target not clickable — nothing measured"));
|
|
120027
119809
|
return 2;
|
|
120028
119810
|
}
|
|
120029
119811
|
await page.waitForTimeout(opts.settleMs);
|
|
@@ -120110,20 +119892,20 @@ async function rerenderCommand(opts) {
|
|
|
120110
119892
|
console.log(JSON.stringify({ url: opts.url, action: opts.selector ?? opts.text, ...report }));
|
|
120111
119893
|
return 0;
|
|
120112
119894
|
}
|
|
120113
|
-
console.log(
|
|
119895
|
+
console.log(chalk40.bold(`
|
|
120114
119896
|
click ${opts.selector ?? `"${opts.text}"`} on ${urlBefore}`));
|
|
120115
119897
|
if (report.urlAfter !== urlBefore)
|
|
120116
119898
|
console.log(` url → ${report.urlAfter}`);
|
|
120117
119899
|
console.log(` ${requests.length} request(s): ${requests.slice(0, 6).join(" · ")}`);
|
|
120118
119900
|
for (const r of regions.slice(0, 10))
|
|
120119
|
-
console.log(` ${r.remounted ?
|
|
119901
|
+
console.log(` ${r.remounted ? chalk40.red("REMOUNTED") : "changed "} ${r.region.padEnd(48)} +${r.added}/-${r.removed} attrs ${r.attrs} text ${r.text}`);
|
|
120120
119902
|
for (const s of report.skeletons)
|
|
120121
|
-
console.log(
|
|
119903
|
+
console.log(chalk40.yellow(` skeletons ×${s.count} in ${s.region}`));
|
|
120122
119904
|
const [b0, a0] = [report.visibleImages.before[0], report.visibleImages.after[0]];
|
|
120123
119905
|
console.log(b0 === a0 ? ` main visible image unchanged: ${a0 ?? "none"}` : ` main visible image: ${b0 ?? "none"} → ${a0 ?? "none"}`);
|
|
120124
119906
|
for (const f of flashes)
|
|
120125
|
-
console.log(
|
|
120126
|
-
console.log(
|
|
119907
|
+
console.log(chalk40.red(` white flash +${f.from}–${f.to}ms (peak ${f.peakWhite.toFixed(0)}% white)`));
|
|
119908
|
+
console.log(chalk40.dim(` settled at +${settledAt ?? "?"}ms · ${post.length} frames${opts.sheet ? ` · sheet ${opts.sheet}` : ""}`));
|
|
120127
119909
|
return 0;
|
|
120128
119910
|
} finally {
|
|
120129
119911
|
await browser.close().catch(() => {
|
|
@@ -120132,6 +119914,70 @@ async function rerenderCommand(opts) {
|
|
|
120132
119914
|
}
|
|
120133
119915
|
}
|
|
120134
119916
|
|
|
119917
|
+
// src/commands/serve.ts
|
|
119918
|
+
import { existsSync as existsSync38 } from "node:fs";
|
|
119919
|
+
import chalk41 from "chalk";
|
|
119920
|
+
async function serveRunAndBlock(runDir, opts = {}) {
|
|
119921
|
+
let handle;
|
|
119922
|
+
try {
|
|
119923
|
+
handle = await startProxyServer(runDir, { port: opts.port });
|
|
119924
|
+
} catch (err) {
|
|
119925
|
+
console.error(chalk41.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
|
|
119926
|
+
return 2;
|
|
119927
|
+
}
|
|
119928
|
+
const label = opts.label ?? "parity serve";
|
|
119929
|
+
console.log("");
|
|
119930
|
+
console.log(chalk41.bold(` ${label}`));
|
|
119931
|
+
console.log(` ${chalk41.green("●")} ${handle.url}`);
|
|
119932
|
+
console.log(chalk41.dim(` Servindo: ${runDir}`));
|
|
119933
|
+
console.log(chalk41.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
|
|
119934
|
+
console.log(chalk41.dim(` Ctrl+C pra parar (2x pra forçar saída).
|
|
119935
|
+
`));
|
|
119936
|
+
if (opts.open !== false) {
|
|
119937
|
+
const { default: open } = await import("open");
|
|
119938
|
+
await open(handle.url).catch(() => {
|
|
119939
|
+
return;
|
|
119940
|
+
});
|
|
119941
|
+
}
|
|
119942
|
+
let shuttingDown = false;
|
|
119943
|
+
const onSignal = () => {
|
|
119944
|
+
if (shuttingDown) {
|
|
119945
|
+
process.stderr.write(`
|
|
119946
|
+
forçando saída.
|
|
119947
|
+
`);
|
|
119948
|
+
process.exit(130);
|
|
119949
|
+
}
|
|
119950
|
+
shuttingDown = true;
|
|
119951
|
+
process.stderr.write(`
|
|
119952
|
+
parando servidor…
|
|
119953
|
+
`);
|
|
119954
|
+
handle.close().catch(() => {
|
|
119955
|
+
return;
|
|
119956
|
+
});
|
|
119957
|
+
setTimeout(() => process.exit(0), 300);
|
|
119958
|
+
};
|
|
119959
|
+
process.on("SIGINT", onSignal);
|
|
119960
|
+
process.on("SIGTERM", onSignal);
|
|
119961
|
+
await new Promise(() => {});
|
|
119962
|
+
return 0;
|
|
119963
|
+
}
|
|
119964
|
+
async function serveCommand(runId, opts) {
|
|
119965
|
+
const paths = getRunPaths(opts.output, runId);
|
|
119966
|
+
if (!existsSync38(paths.runDir)) {
|
|
119967
|
+
console.error(chalk41.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
|
|
119968
|
+
return 1;
|
|
119969
|
+
}
|
|
119970
|
+
if (!existsSync38(paths.reportHtml)) {
|
|
119971
|
+
console.error(chalk41.red(`✖ report.html não existe em ${paths.runDir}`));
|
|
119972
|
+
return 1;
|
|
119973
|
+
}
|
|
119974
|
+
return serveRunAndBlock(paths.runDir, {
|
|
119975
|
+
port: opts.port,
|
|
119976
|
+
open: opts.open,
|
|
119977
|
+
label: `parity serve · ${runId}`
|
|
119978
|
+
});
|
|
119979
|
+
}
|
|
119980
|
+
|
|
120135
119981
|
// src/commands/states.ts
|
|
120136
119982
|
import chalk42 from "chalk";
|
|
120137
119983
|
var ROOT_ATTR = "data-parity-states";
|
|
@@ -121834,13 +121680,14 @@ program.command("studio").description("Work the deco Studio task board: list tas
|
|
|
121834
121680
|
}));
|
|
121835
121681
|
registerCommands(program.command("cms").description(`${DESCRIPTION} Same as the standalone \`vtex-cms\` bin.`));
|
|
121836
121682
|
registerCatalogCommands(program.command("catalog").description(`${CATALOG_DESCRIPTION} Same as the standalone \`catalog\` bin.`));
|
|
121837
|
-
program.command("serve").argument("<runId>", "Run ID to serve").description("Spawns a local HTTP server that serves
|
|
121683
|
+
program.command("serve").argument("<runId>", "Run ID to serve").description("[deprecated: use `parity report <runId>` to open a report, `parity cockpit` for the live prod × cand view] Spawns a local HTTP server that serves a run directory. It existed for the report's Side-by-side tab, which moved to the cockpit.").option("--output <dir>", "Output directory where runs live", "./parity-output").option("--port <n>", "Fixed port (default: auto-pick free port)", (v) => Number(v)).option("--no-open", "Don't open the browser automatically").action(async (runId, opts) => {
|
|
121684
|
+
deprecatedNotice("serve", "report <runId> (or `parity cockpit`)");
|
|
121838
121685
|
process.exit(await serveCommand(runId, opts));
|
|
121839
121686
|
});
|
|
121840
121687
|
program.command("event").argument("<type>", "Event type: phase-change | dispatch | bench | score | note | …").description("Record a migration event into <dir>/events.jsonl — the sanctioned emission path for hooks and the orchestrator. The cockpit daemon tails this file into its live activity feed.").option("--dir <dir>", "Directory holding events.jsonl (the target's .parity/)", ".parity").option("--data <json>", `JSON object of event fields, e.g. '{"agent":"porter","component":"hero"}'`).action((type, opts) => {
|
|
121841
121688
|
process.exit(eventCommand(type, opts));
|
|
121842
121689
|
});
|
|
121843
|
-
program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo,
|
|
121690
|
+
program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo, issues, vitals, cache, checks, prompt, pages, console, network, diff.").option("--json", "Pair with --section to emit a normalized JSON projection of the section (from report.json) instead of the raw HTML slice.").option("--deck", "Render the presentation deck instead: one topic per full-viewport page, advanced sideways, in a single self-contained HTML file. For showing the result to someone rather than debugging it. Issue #290.", false).option("--out <path>", "Where to write the deck (default: deck.html in the run dir)").option("--lang <pt|en>", "Initial deck language; the in-page toggle still switches live", "en").option("--open", "Open the rendered deck in the browser", false).option("--plan-dir <dir>", "With --deck: dir holding migration-plan.json. Adds the component heat map (grouped by page, plus global) and the block-by-block table. Without it those pages are omitted, not drawn empty. Issue #291.").action(async (runId, opts) => {
|
|
121844
121691
|
process.exit(await reportCommand(runId, {
|
|
121845
121692
|
output: opts.output,
|
|
121846
121693
|
section: opts.section,
|