@decocms/parity 0.26.13 → 0.26.14

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 (2) hide show
  1. package/dist/cli.js +128 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -41598,6 +41598,12 @@ var ModuleVerdict = z.object({
41598
41598
  checksRun: z.number(),
41599
41599
  pagesAnalyzed: z.number()
41600
41600
  });
41601
+ var RunCaveat = z.object({
41602
+ id: z.string(),
41603
+ level: z.enum(["warn", "info"]),
41604
+ summary: z.string(),
41605
+ detail: z.string()
41606
+ });
41601
41607
  var Run = z.object({
41602
41608
  schemaVersion: z.literal("0.1"),
41603
41609
  id: z.string(),
@@ -41631,6 +41637,7 @@ var Run = z.object({
41631
41637
  }).optional(),
41632
41638
  partial: z.boolean().optional(),
41633
41639
  partialReason: z.string().optional(),
41640
+ caveats: z.array(RunCaveat).optional(),
41634
41641
  timings: z.object({
41635
41642
  totalMs: z.number(),
41636
41643
  phases: z.array(z.object({ phase: z.string(), durationMs: z.number() }))
@@ -50529,6 +50536,10 @@ async function ssrNoJs(ctx) {
50529
50536
  }
50530
50537
  const prodHome = pickHome5(ctx.prodPages);
50531
50538
  const prodText = prodHome ? await fetchSsrText(prodHome.finalUrl) : null;
50539
+ const candIsDevServer = isLocalhost(candHome.finalUrl);
50540
+ const devServerNote = candIsDevServer ? `
50541
+
50542
+ ⚠ Medido contra um dev server, onde várias frameworks renderizam client-side por padrão. Reconfirme num build de produção antes de tratar isto como defeito.` : "";
50532
50543
  if (candText.length < 200) {
50533
50544
  issues.push({
50534
50545
  id: "ssr:blank",
@@ -50536,7 +50547,8 @@ async function ssrNoJs(ctx) {
50536
50547
  category: "functional",
50537
50548
  check: "ssr-no-js",
50538
50549
  summary: `SSR do candidato rende só ${candText.length} chars de texto — página em branco sem JS (CLS alto, SEO/acessibilidade quebrados)`,
50539
- details: "Todo o conteúdo carrega client-side. Marque seções above-the-fold com `export const neverDefer = true` ou adicione LoadingFallback."
50550
+ details: `Todo o conteúdo carrega client-side. Marque seções above-the-fold com \`export const neverDefer = true\` ou adicione LoadingFallback.${devServerNote}`,
50551
+ ...candIsDevServer ? { inconclusive: true } : {}
50540
50552
  });
50541
50553
  } else if (prodText !== null && prodText.length > 0 && candText.length < prodText.length * 0.3) {
50542
50554
  issues.push({
@@ -50544,10 +50556,11 @@ async function ssrNoJs(ctx) {
50544
50556
  severity: "high",
50545
50557
  category: "functional",
50546
50558
  check: "ssr-no-js",
50547
- summary: `SSR do candidato tem <30% do texto do prod (${candText.length} vs ${prodText.length} chars) — maioria do conteúdo é client-only`
50559
+ summary: `SSR do candidato tem <30% do texto do prod (${candText.length} vs ${prodText.length} chars) — maioria do conteúdo é client-only`,
50560
+ ...candIsDevServer ? { inconclusive: true, details: devServerNote.trim() } : {}
50548
50561
  });
50549
50562
  }
50550
- const status = issues.some((i) => i.severity === "critical") ? "fail" : issues.length > 0 ? "warn" : "pass";
50563
+ const status = issues.some((i) => i.severity === "critical" && !i.inconclusive) ? "fail" : issues.length > 0 ? "warn" : "pass";
50551
50564
  return {
50552
50565
  name: "ssr-no-js",
50553
50566
  status,
@@ -55884,6 +55897,7 @@ function renderHtmlReport(run, runDir) {
55884
55897
  </div>
55885
55898
  </header>
55886
55899
  ${run.partial ? `<div style="background:#7c2d12;color:#fed7aa;padding:12px 24px;border-bottom:2px solid #ea580c;font-weight:600">⚠ Partial run — interrupted${run.partialReason ? ` (${escapeHtml(run.partialReason)})` : ""}. Verdict, top-issues, and some sections may be incomplete.</div>` : ""}
55900
+ ${renderCaveats(run)}
55887
55901
  ${countHiddenLlmTabs(run) > 0 ? `<div class="llm-disabled-banner">LLM disabled — ${countHiddenLlmTabs(run)} tab${countHiddenLlmTabs(run) !== 1 ? "s" : ""} hidden (Visual Diff, LLM Prompt). Set <code>ANTHROPIC_API_KEY</code> or log in to the local <code>claude</code> CLI and re-run for semantic analysis.</div>` : ""}
55888
55902
  ${renderTimingsBar(run)}
55889
55903
  <main class="app-main">
@@ -55983,6 +55997,19 @@ function renderTimingsBar(run) {
55983
55997
  <div style="display:flex;flex-direction:column;gap:4px">${rows}</div>
55984
55998
  </div>`;
55985
55999
  }
56000
+ function renderCaveats(run) {
56001
+ const caveats = run.caveats ?? [];
56002
+ if (caveats.length === 0)
56003
+ return "";
56004
+ const rows = caveats.map((c) => {
56005
+ const warn = c.level === "warn";
56006
+ return `<li style="margin:4px 0"><b style="color:${warn ? "#fca5a5" : "#93c5fd"}">${warn ? "⚠" : "ℹ"} ${escapeHtml(c.summary)}</b> <span style="opacity:.85">— ${escapeHtml(c.detail)}</span></li>`;
56007
+ }).join("");
56008
+ return `<div style="background:#1c1917;color:#e7e5e4;padding:12px 24px;border-bottom:1px solid #44403c;font-size:13px">
56009
+ <div style="font-weight:600;margin-bottom:4px">Como ler este run</div>
56010
+ <ul style="margin:0;padding-left:18px;list-style:none">${rows}</ul>
56011
+ </div>`;
56012
+ }
55986
56013
 
55987
56014
  // src/commands/cache.ts
55988
56015
  async function cacheCommand(opts) {
@@ -65512,6 +65539,84 @@ function formatSecs(ms) {
65512
65539
  return `${min}m${sec.toString().padStart(2, "0")}s`;
65513
65540
  }
65514
65541
 
65542
+ // src/engine/run-context.ts
65543
+ function detectRunCaveats(input) {
65544
+ const out = [];
65545
+ if (isLocalhost(input.candUrl)) {
65546
+ out.push({
65547
+ id: "cand-dev-server",
65548
+ level: "warn",
65549
+ summary: "Candidato medido num dev server",
65550
+ detail: "Vitals, cache e bundle de um dev server não são representativos: sem minificação, sem cache de edge, HMR aberto. Reconfirme num build de produção antes de tratar qualquer número de performance como resultado."
65551
+ });
65552
+ }
65553
+ if (isLocalhost(input.prodUrl)) {
65554
+ out.push({
65555
+ id: "prod-dev-server",
65556
+ level: "warn",
65557
+ summary: "Referência (prod) medida num dev server",
65558
+ detail: "O lado de referência também é local, então a comparação mede duas máquinas de desenvolvimento — útil para regressão relativa, não para números absolutos."
65559
+ });
65560
+ }
65561
+ const mismatched = pairedPathMismatches(input.prodPages, input.candPages);
65562
+ if (mismatched.length > 0) {
65563
+ out.push({
65564
+ id: "paths-differ",
65565
+ level: "warn",
65566
+ summary: `${mismatched.length} página(s) comparadas em caminhos diferentes`,
65567
+ detail: `Os dois lados não estão no mesmo conteúdo (${mismatched.slice(0, 3).join(", ")}${mismatched.length > 3 ? "…" : ""}). O módulo visual vai apontar diferenças que são de produto, não de migração — leia estrutura e hierarquia, não conteúdo.`
65568
+ });
65569
+ }
65570
+ if (!input.llmEnabled) {
65571
+ out.push({
65572
+ id: "llm-disabled",
65573
+ level: "info",
65574
+ summary: "Sem provedor de LLM — módulos visuais não rodaram",
65575
+ detail: "Visual diff e ranking de issues dependem de LLM. Sem provedor configurado eles são pulados, então a ausência de achados visuais não significa paridade visual."
65576
+ });
65577
+ }
65578
+ const skipped = input.verdict?.checksSkipped ?? 0;
65579
+ if (skipped > 0) {
65580
+ out.push({
65581
+ id: "checks-skipped",
65582
+ level: "info",
65583
+ summary: `${skipped} de ${input.verdict?.checksRun ?? "?"} checks pulados`,
65584
+ detail: "Um check pulado não é um check que passou. Veja `checks[]` no report.json para quais e por quê."
65585
+ });
65586
+ }
65587
+ if (input.partial) {
65588
+ out.push({
65589
+ id: "partial-run",
65590
+ level: "warn",
65591
+ summary: "Run interrompido — veredito parcial",
65592
+ detail: input.partialReason ? `Parou em: ${input.partialReason}. O que não rodou não conta como aprovado.` : "O que não rodou não conta como aprovado."
65593
+ });
65594
+ }
65595
+ return out;
65596
+ }
65597
+ function pairedPathMismatches(prodPages, candPages) {
65598
+ const out = [];
65599
+ for (const cand of candPages) {
65600
+ if (!cand.pairKey)
65601
+ continue;
65602
+ const prod = prodPages.find((p) => p.pairKey === cand.pairKey);
65603
+ if (!prod)
65604
+ continue;
65605
+ const prodPath = pathOf5(prod.url);
65606
+ const candPath = pathOf5(cand.url);
65607
+ if (prodPath && candPath && prodPath !== candPath)
65608
+ out.push(`${prodPath} → ${candPath}`);
65609
+ }
65610
+ return [...new Set(out)];
65611
+ }
65612
+ function pathOf5(raw) {
65613
+ try {
65614
+ return new URL(raw).pathname;
65615
+ } catch {
65616
+ return null;
65617
+ }
65618
+ }
65619
+
65515
65620
  // src/util/timing.ts
65516
65621
  async function withTiming(fn) {
65517
65622
  const start = performance.now();
@@ -65921,6 +66026,9 @@ function pagesFlowsScopeWarning(opts, flows2) {
65921
66026
  return null;
65922
66027
  return `--pages/--pages-file only scope the visual-diff/vitals passes — the flows crawl (${flows2.join(",")}) discovers its own pages; use --flows or .parityrc.json *UrlHint overrides to scope that.`;
65923
66028
  }
66029
+ function caveatsOrUndefined(caveats) {
66030
+ return caveats.length > 0 ? caveats : undefined;
66031
+ }
65924
66032
  function applySmartDefaults(opts, llmAvailable) {
65925
66033
  if (llmAvailable)
65926
66034
  return opts;
@@ -66741,7 +66849,15 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
66741
66849
  baseline: baselineSection,
66742
66850
  timings: runTimings,
66743
66851
  selectionReason: opts.why,
66744
- moduleVerdicts: moduleVerdicts.length > 0 ? moduleVerdicts : undefined
66852
+ moduleVerdicts: moduleVerdicts.length > 0 ? moduleVerdicts : undefined,
66853
+ caveats: caveatsOrUndefined(detectRunCaveats({
66854
+ prodUrl: opts.prod,
66855
+ candUrl: opts.cand,
66856
+ prodPages: checkCtx.prodPages,
66857
+ candPages: checkCtx.candPages,
66858
+ verdict: verdict2,
66859
+ llmEnabled: llmStillAvailable
66860
+ }))
66745
66861
  };
66746
66862
  const reportStart = performance.now();
66747
66863
  writeRunReportJson(paths.runDir, run);
@@ -66997,6 +67113,10 @@ function printSummary6(run, htmlPath, meta) {
66997
67113
  console.log(` ${emoji} parity ${verdict2.status.toUpperCase()} · score ${score}/100${scoreDelta}`);
66998
67114
  console.log(` checks: ${chalk20.green(verdict2.checksPassed)} pass · ${chalk20.red(verdict2.checksFailed)} fail · ${chalk20.dim(`${verdict2.checksSkipped} skipped`)}`);
66999
67115
  console.log(` issues: ${chalk20.red(verdict2.critical)} critical · ${chalk20.yellow(verdict2.high)} high · ${verdict2.medium} medium · ${chalk20.dim(`${verdict2.low} low`)}`);
67116
+ for (const c of run.caveats ?? []) {
67117
+ const mark = c.level === "warn" ? chalk20.yellow("⚠") : chalk20.dim("ℹ");
67118
+ console.log(` ${mark} ${c.summary}`);
67119
+ }
67000
67120
  if (run.moduleVerdicts && run.moduleVerdicts.length > 0) {
67001
67121
  const perModule = run.moduleVerdicts.map((mv) => {
67002
67122
  const colored = mv.status === "pass" ? chalk20.green(mv.score) : mv.status === "warn" ? chalk20.yellow(mv.score) : chalk20.red(mv.score);
@@ -67240,7 +67360,7 @@ function extractVitalsSlice(run) {
67240
67360
  for (const p of fc.pages) {
67241
67361
  if (!p.vitals)
67242
67362
  continue;
67243
- const k = `${p.side}::${p.viewport}::${pathOf5(p.url)}`;
67363
+ const k = `${p.side}::${p.viewport}::${pathOf6(p.url)}`;
67244
67364
  out[k] = p.vitalsFullPage ? { ...p.vitals, fullPage: p.vitalsFullPage } : p.vitals;
67245
67365
  }
67246
67366
  }
@@ -67285,8 +67405,8 @@ function extractSideBySideSlice(run) {
67285
67405
  for (const p of fc.pages) {
67286
67406
  if (p.side !== "prod")
67287
67407
  continue;
67288
- const candPath = pathOf5(p.url);
67289
- const cand = fc.pages.find((q) => q.side === "cand" && pathOf5(q.url) === candPath && q.viewport === p.viewport);
67408
+ const candPath = pathOf6(p.url);
67409
+ const cand = fc.pages.find((q) => q.side === "cand" && pathOf6(q.url) === candPath && q.viewport === p.viewport);
67290
67410
  if (!cand)
67291
67411
  continue;
67292
67412
  pairs.push({
@@ -67299,7 +67419,7 @@ function extractSideBySideSlice(run) {
67299
67419
  }
67300
67420
  return pairs;
67301
67421
  }
67302
- function pathOf5(url) {
67422
+ function pathOf6(url) {
67303
67423
  try {
67304
67424
  return new URL(url).pathname || "/";
67305
67425
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.26.13",
3
+ "version": "0.26.14",
4
4
  "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",