@decocms/parity 0.23.1 → 0.23.2
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/CHANGELOG.md +14 -0
- package/dist/cli.js +567 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
* **Deco page-discovery fallback.** When a site ships no `/sitemap.xml` (404) — common on deco storefronts — `resolveSitemapUrls` falls back to the deco pages loader (`/live/invoke/website/loaders/pages.ts`) to discover CMS-configured content pages instead of collapsing to just the home page. Page-discovery callers (vitals/run/cache/benchmark) get it automatically; the SEO audit opts out (`decoFallback: false`) so it still sees — and reports — the true sitemap state. (#264)
|
|
13
|
+
* **SEO absolute-gap insights** in `seo-deep-audit`, surfaced even when prod and cand share the gap (a migration is the moment to fix): `seo:sitemap-absent` (neither side serves `/sitemap.xml`), `seo:robots-no-sitemap-directive` (robots.txt declares no `Sitemap:`), `seo:llms-txt-absent` (no `/llms.txt` manifest for AI crawlers). SPA `index.html` fallbacks served for these routes are correctly treated as absent, not present. (#264)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
* **`parity vitals` now measures via Lighthouse by default** (Slow 4G + 4× CPU throttle), so its numbers match PageSpeed instead of the optimistic warm Playwright collector — the root cause of "run says 100 but PageSpeed fails". Runs in two ordered phases: a fast parallel Playwright pass (HTML/cache/network structure) then a low-concurrency Lighthouse pass (Lighthouse *measures* CPU, so parallel runs contend and inflate results). `--no-lighthouse` restores the fast unthrottled collector for iteration; `--lighthouse-concurrency <n>` tunes the cap (default cores/2, capped 2). (#264)
|
|
18
|
+
* **Lighthouse category scores.** `parity vitals` (Lighthouse mode) now runs `accessibility`, `best-practices` and `seo` alongside `performance` (same run, cheap static audits) and surfaces all four as 0–100 PageSpeed-style chips (prod vs cand) in the Vitals tab + `report.json` `lhScores` + `vitals.json` `scores`. Previously it captured performance only. (#264)
|
|
19
|
+
* **`lighthouse-scores` check — parity-or-better on every category.** Flags when a cand Lighthouse category score drops below prod (beyond 3-point jitter), not just performance — e.g. accessibility 90→76. Enforces the migration goal of equal-or-better across performance/accessibility/best-practices/seo. New `a11y` issue category. (#264)
|
|
20
|
+
* **Vitals report polish.** Category scores now render as PageSpeed-style SVG ring gauges (cand as the gauge, `prod N · ▲/▼Δ` beneath so "equal or better" reads at a glance), matching the benchmark report's visual language. (#264)
|
|
21
|
+
* **`agentic-nav` check + "Navegação agêntica" report panel.** A composite mirroring PageSpeed's in-development category: (1) agent accessibility — Lighthouse accessibility-tree audits an AI agent relies on (`button-name`, `link-name`, `label`, `image-alt`, `aria-*`), with failing elements listed; (2) llms.txt quality — a well-formed `/llms.txt` per llmstxt.org (H1 + sections/links; SPA HTML fallbacks rejected). Renders a passed/total tally + per-pillar detail in the Vitals tab. (#264)
|
|
22
|
+
* **Lighthouse opportunities are now preserved and surfaced.** The actionable audits Lighthouse already computes (render-blocking, unused JS, oversized images, lazy LCP…) are deduped across cand pages, persisted on each `PageCapture.lhOpportunities` + in `vitals.json`, and rendered in the report's Vitals tab (biggest savings first) — reaching both the user and the `perf-optimizer` agent. TBT is now carried on `WebVitals` and shown when present. (#264)
|
|
23
|
+
|
|
10
24
|
## [0.22.0] — 2026-08-19
|
|
11
25
|
|
|
12
26
|
### Added
|
package/dist/cli.js
CHANGED
|
@@ -39729,6 +39729,33 @@ var REPORT_CSS = `
|
|
|
39729
39729
|
.delta-bad { color: var(--state-bad); font-weight: 600; }
|
|
39730
39730
|
.delta-neutral { color: var(--text-muted); }
|
|
39731
39731
|
|
|
39732
|
+
/* Lighthouse category score chips */
|
|
39733
|
+
.lh-scores { margin-bottom: 14px; }
|
|
39734
|
+
.lh-score { display: inline-block; min-width: 34px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; text-align: center; }
|
|
39735
|
+
.lh-good { background: #e6f4ea; color: #137333; }
|
|
39736
|
+
.lh-avg { background: #fef7e0; color: #b06000; }
|
|
39737
|
+
.lh-poor { background: #fce8e6; color: #c5221f; }
|
|
39738
|
+
.lh-na { background: var(--border-default); color: var(--text-muted); }
|
|
39739
|
+
|
|
39740
|
+
/* Lighthouse category rings (PageSpeed-style) */
|
|
39741
|
+
.lh-rings { display: flex; flex-wrap: wrap; gap: 28px; margin: 4px 0 22px; }
|
|
39742
|
+
.ring-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 84px; }
|
|
39743
|
+
.ring { display: block; }
|
|
39744
|
+
.ring-track { stroke: rgba(255,255,255,0.10); }
|
|
39745
|
+
.ring-arc { stroke: currentColor; transition: stroke-dasharray .3s; }
|
|
39746
|
+
.ring-num { fill: currentColor; font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
|
|
39747
|
+
.ring-good { color: #32d583; }
|
|
39748
|
+
.ring-avg { color: #fdb022; }
|
|
39749
|
+
.ring-poor { color: #f97066; }
|
|
39750
|
+
.ring-na { color: var(--text-muted); }
|
|
39751
|
+
.ring-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
|
|
39752
|
+
.ring-sub { font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
39753
|
+
|
|
39754
|
+
/* Agentic navigation */
|
|
39755
|
+
.agentic-head { margin-bottom: 6px; }
|
|
39756
|
+
.agentic-pillar { margin-top: 14px; }
|
|
39757
|
+
.agentic-pillar-head { font-weight: 600; margin-bottom: 6px; }
|
|
39758
|
+
|
|
39732
39759
|
/* Side-by-side iframes */
|
|
39733
39760
|
.sbs-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
|
|
39734
39761
|
.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; }
|
|
@@ -41107,6 +41134,7 @@ function renderDashboard(r) {
|
|
|
41107
41134
|
functional: 0,
|
|
41108
41135
|
visual: 0,
|
|
41109
41136
|
performance: 0,
|
|
41137
|
+
a11y: 0,
|
|
41110
41138
|
seo: 0,
|
|
41111
41139
|
console: 0,
|
|
41112
41140
|
network: 0
|
|
@@ -41220,6 +41248,7 @@ var Category = z.enum([
|
|
|
41220
41248
|
"functional",
|
|
41221
41249
|
"visual",
|
|
41222
41250
|
"performance",
|
|
41251
|
+
"a11y",
|
|
41223
41252
|
"seo",
|
|
41224
41253
|
"console",
|
|
41225
41254
|
"network"
|
|
@@ -41241,7 +41270,28 @@ var WebVitals = z.object({
|
|
|
41241
41270
|
cls: z.number().nullable(),
|
|
41242
41271
|
fcp: z.number().nullable(),
|
|
41243
41272
|
ttfb: z.number().nullable(),
|
|
41244
|
-
inp: z.number().nullable()
|
|
41273
|
+
inp: z.number().nullable(),
|
|
41274
|
+
tbt: z.number().nullable().optional()
|
|
41275
|
+
});
|
|
41276
|
+
var LhScores = z.object({
|
|
41277
|
+
performance: z.number().nullable(),
|
|
41278
|
+
accessibility: z.number().nullable(),
|
|
41279
|
+
bestPractices: z.number().nullable(),
|
|
41280
|
+
seo: z.number().nullable()
|
|
41281
|
+
});
|
|
41282
|
+
var AgentA11yAudit = z.object({
|
|
41283
|
+
id: z.string(),
|
|
41284
|
+
title: z.string(),
|
|
41285
|
+
score: z.number().nullable(),
|
|
41286
|
+
elements: z.array(z.object({ selector: z.string(), snippet: z.string() }))
|
|
41287
|
+
});
|
|
41288
|
+
var LhOpportunity = z.object({
|
|
41289
|
+
id: z.string(),
|
|
41290
|
+
title: z.string(),
|
|
41291
|
+
savingsMs: z.number(),
|
|
41292
|
+
savingsBytes: z.number(),
|
|
41293
|
+
displayValue: z.string().optional(),
|
|
41294
|
+
score: z.number().nullable()
|
|
41245
41295
|
});
|
|
41246
41296
|
var WebVitalStat = z.object({
|
|
41247
41297
|
median: z.number(),
|
|
@@ -41287,6 +41337,9 @@ var PageCapture = z.object({
|
|
|
41287
41337
|
vitals: WebVitals,
|
|
41288
41338
|
vitalsStats: WebVitalsStats.optional(),
|
|
41289
41339
|
vitalsFullPage: WebVitals.optional(),
|
|
41340
|
+
lhOpportunities: z.array(LhOpportunity).optional(),
|
|
41341
|
+
lhScores: LhScores.optional(),
|
|
41342
|
+
agentA11y: z.array(AgentA11yAudit).optional(),
|
|
41290
41343
|
console: z.array(ConsoleEntry),
|
|
41291
41344
|
network: z.array(NetworkEntry),
|
|
41292
41345
|
screenshotPath: z.string(),
|
|
@@ -45612,6 +45665,33 @@ async function validateAddToCart(page, ctx, cartCountBefore, beforeUrl) {
|
|
|
45612
45665
|
import { spawn } from "node:child_process";
|
|
45613
45666
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
45614
45667
|
import { join as join7 } from "node:path";
|
|
45668
|
+
var AGENT_A11Y_AUDIT_IDS = [
|
|
45669
|
+
"button-name",
|
|
45670
|
+
"link-name",
|
|
45671
|
+
"label",
|
|
45672
|
+
"image-alt",
|
|
45673
|
+
"input-image-alt",
|
|
45674
|
+
"select-name",
|
|
45675
|
+
"aria-required-attr",
|
|
45676
|
+
"aria-valid-attr",
|
|
45677
|
+
"aria-valid-attr-value",
|
|
45678
|
+
"aria-command-name",
|
|
45679
|
+
"aria-input-field-name",
|
|
45680
|
+
"aria-toggle-field-name",
|
|
45681
|
+
"form-field-multiple-labels"
|
|
45682
|
+
];
|
|
45683
|
+
function extractAgentA11y(audits) {
|
|
45684
|
+
const out = [];
|
|
45685
|
+
for (const id of AGENT_A11Y_AUDIT_IDS) {
|
|
45686
|
+
const a = audits[id];
|
|
45687
|
+
if (!a)
|
|
45688
|
+
continue;
|
|
45689
|
+
const score = typeof a.score === "number" ? a.score : null;
|
|
45690
|
+
const elements = (a.details?.items ?? []).map((it) => it?.node).filter((n) => !!n).slice(0, 5).map((n) => ({ selector: n.selector ?? "", snippet: n.snippet ?? "" }));
|
|
45691
|
+
out.push({ id, title: a.title ?? id, score, elements });
|
|
45692
|
+
}
|
|
45693
|
+
return out;
|
|
45694
|
+
}
|
|
45615
45695
|
var ACTIONABLE_AUDIT_IDS = new Set([
|
|
45616
45696
|
"render-blocking-resources",
|
|
45617
45697
|
"unused-javascript",
|
|
@@ -45681,7 +45761,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
|
|
|
45681
45761
|
url,
|
|
45682
45762
|
"--output=json",
|
|
45683
45763
|
`--output-path=${outPath}`,
|
|
45684
|
-
"--only-categories=performance",
|
|
45764
|
+
"--only-categories=performance,accessibility,best-practices,seo",
|
|
45685
45765
|
`--form-factor=${formFactor}`,
|
|
45686
45766
|
...formFactor === "desktop" ? [
|
|
45687
45767
|
"--screenEmulation.mobile=false",
|
|
@@ -45723,13 +45803,22 @@ async function measureLighthouseOnce(url, opts, attempt) {
|
|
|
45723
45803
|
if (lcp === null) {
|
|
45724
45804
|
return { error: "no LCP value despite no runtimeError" };
|
|
45725
45805
|
}
|
|
45806
|
+
const cat = report.categories ?? {};
|
|
45807
|
+
const pct = (c) => typeof c?.score === "number" ? Math.round(c.score * 100) : null;
|
|
45726
45808
|
return {
|
|
45727
45809
|
lcp,
|
|
45728
45810
|
cls: audits["cumulative-layout-shift"]?.numericValue ?? null,
|
|
45729
45811
|
fcp: audits["first-contentful-paint"]?.numericValue ?? null,
|
|
45730
45812
|
ttfb: audits["server-response-time"]?.numericValue ?? null,
|
|
45731
45813
|
tbt: audits["total-blocking-time"]?.numericValue ?? null,
|
|
45732
|
-
opportunities: extractOpportunities(audits)
|
|
45814
|
+
opportunities: extractOpportunities(audits),
|
|
45815
|
+
scores: {
|
|
45816
|
+
performance: pct(cat.performance),
|
|
45817
|
+
accessibility: pct(cat.accessibility),
|
|
45818
|
+
bestPractices: pct(cat["best-practices"]),
|
|
45819
|
+
seo: pct(cat.seo)
|
|
45820
|
+
},
|
|
45821
|
+
agentA11y: extractAgentA11y(audits)
|
|
45733
45822
|
};
|
|
45734
45823
|
}
|
|
45735
45824
|
|
|
@@ -48610,13 +48699,57 @@ function parseSitemap(xml2) {
|
|
|
48610
48699
|
} catch {}
|
|
48611
48700
|
return out;
|
|
48612
48701
|
}
|
|
48613
|
-
async function
|
|
48702
|
+
async function fetchDecoPages(baseUrl, timeoutMs = 15000) {
|
|
48703
|
+
const url = new URL("/live/invoke/website/loaders/pages.ts", baseUrl).toString();
|
|
48704
|
+
const controller = new AbortController;
|
|
48705
|
+
const t = setTimeout(() => controller.abort(), timeoutMs);
|
|
48706
|
+
try {
|
|
48707
|
+
const res = await fetch(url, {
|
|
48708
|
+
signal: controller.signal,
|
|
48709
|
+
headers: {
|
|
48710
|
+
"User-Agent": "Mozilla/5.0 (compatible; parity-cli/0.1; +https://github.com/decocms/parity)"
|
|
48711
|
+
},
|
|
48712
|
+
redirect: "follow"
|
|
48713
|
+
});
|
|
48714
|
+
if (!res.ok)
|
|
48715
|
+
return [];
|
|
48716
|
+
const data2 = await res.json();
|
|
48717
|
+
return parseDecoPages(data2, baseUrl);
|
|
48718
|
+
} catch {
|
|
48719
|
+
return [];
|
|
48720
|
+
} finally {
|
|
48721
|
+
clearTimeout(t);
|
|
48722
|
+
}
|
|
48723
|
+
}
|
|
48724
|
+
function parseDecoPages(data2, baseUrl) {
|
|
48725
|
+
if (!Array.isArray(data2))
|
|
48726
|
+
return [];
|
|
48727
|
+
const seen = new Set;
|
|
48728
|
+
const out = [];
|
|
48729
|
+
for (const entry of data2) {
|
|
48730
|
+
const tpl = entry?.pathTemplate;
|
|
48731
|
+
if (typeof tpl !== "string" || !tpl.startsWith("/"))
|
|
48732
|
+
continue;
|
|
48733
|
+
if (/[:*{}]/.test(tpl))
|
|
48734
|
+
continue;
|
|
48735
|
+
if (seen.has(tpl) || out.length >= MAX_URLS)
|
|
48736
|
+
continue;
|
|
48737
|
+
seen.add(tpl);
|
|
48738
|
+
try {
|
|
48739
|
+
out.push(new URL(tpl, baseUrl).toString());
|
|
48740
|
+
} catch {}
|
|
48741
|
+
}
|
|
48742
|
+
return out;
|
|
48743
|
+
}
|
|
48744
|
+
async function resolveSitemapUrls(baseUrl, hintUrl, opts) {
|
|
48745
|
+
const fallback = opts?.decoFallback !== false;
|
|
48746
|
+
const deco = () => fallback ? fetchDecoPages(baseUrl) : [];
|
|
48614
48747
|
const root2 = await fetchSitemap(baseUrl, hintUrl);
|
|
48615
48748
|
if (!root2)
|
|
48616
|
-
return
|
|
48749
|
+
return deco();
|
|
48617
48750
|
const parsed = parseSitemap(root2.xml);
|
|
48618
48751
|
if (!parsed.isIndex)
|
|
48619
|
-
return parsed.urls;
|
|
48752
|
+
return parsed.urls.length > 0 ? parsed.urls : deco();
|
|
48620
48753
|
const all = [];
|
|
48621
48754
|
for (const child of parsed.childSitemaps.slice(0, 20)) {
|
|
48622
48755
|
if (all.length >= MAX_URLS)
|
|
@@ -48631,7 +48764,7 @@ async function resolveSitemapUrls(baseUrl, hintUrl) {
|
|
|
48631
48764
|
all.push(u);
|
|
48632
48765
|
}
|
|
48633
48766
|
}
|
|
48634
|
-
return all;
|
|
48767
|
+
return all.length > 0 ? all : deco();
|
|
48635
48768
|
}
|
|
48636
48769
|
function diffSitemap(prodUrls, candUrls) {
|
|
48637
48770
|
const prodSet = new Set(prodUrls);
|
|
@@ -51859,6 +51992,7 @@ async function seoDeepAudit(ctx) {
|
|
|
51859
51992
|
issues.push(...robotsIssues);
|
|
51860
51993
|
const { issues: sitemapIssues, sitemap } = await checkSitemapStructured(state, pairs.map((p) => p.cand));
|
|
51861
51994
|
issues.push(...sitemapIssues);
|
|
51995
|
+
issues.push(...await checkLlmsTxt(state));
|
|
51862
51996
|
const seo = {
|
|
51863
51997
|
pages: pageSnapshots,
|
|
51864
51998
|
robotsTxt,
|
|
@@ -52148,14 +52282,35 @@ async function checkRobotsTxt(state) {
|
|
|
52148
52282
|
summary: `robots.txt em prod declara sitemap(s) ausente(s) em cand: ${diff.sitemapDiff.onlyProd.join(", ")}`
|
|
52149
52283
|
});
|
|
52150
52284
|
}
|
|
52285
|
+
if (parseRobots(candTxt).sitemaps.length === 0) {
|
|
52286
|
+
out.push({
|
|
52287
|
+
id: "seo:robots-no-sitemap-directive",
|
|
52288
|
+
severity: "low",
|
|
52289
|
+
category: "seo",
|
|
52290
|
+
check: "seo-deep-audit",
|
|
52291
|
+
summary: "robots.txt do cand não declara nenhum Sitemap:",
|
|
52292
|
+
details: "Adicione `Sitemap: https://<host>/sitemap.xml` ao robots.txt para acelerar a descoberta por crawlers."
|
|
52293
|
+
});
|
|
52294
|
+
}
|
|
52151
52295
|
return out;
|
|
52152
52296
|
}
|
|
52153
52297
|
async function checkSitemap(state, candPages) {
|
|
52154
52298
|
const out = [];
|
|
52155
52299
|
const [prodUrls, candUrls] = await Promise.all([
|
|
52156
|
-
resolveSitemapUrls(state.prodBaseUrl),
|
|
52157
|
-
resolveSitemapUrls(state.candBaseUrl)
|
|
52300
|
+
resolveSitemapUrls(state.prodBaseUrl, undefined, { decoFallback: false }),
|
|
52301
|
+
resolveSitemapUrls(state.candBaseUrl, undefined, { decoFallback: false })
|
|
52158
52302
|
]);
|
|
52303
|
+
if (prodUrls.length === 0 && candUrls.length === 0) {
|
|
52304
|
+
out.push({
|
|
52305
|
+
id: "seo:sitemap-absent",
|
|
52306
|
+
severity: "medium",
|
|
52307
|
+
category: "seo",
|
|
52308
|
+
check: "seo-deep-audit",
|
|
52309
|
+
summary: "Nenhum dos lados serve /sitemap.xml — lacuna de SEO",
|
|
52310
|
+
details: "Nem prod nem cand respondem em /sitemap.xml. Crawlers dependem de descoberta por links (menos confiável para páginas profundas). Publique um sitemap.xml no cand e declare-o no robots.txt — a migração é a hora de corrigir."
|
|
52311
|
+
});
|
|
52312
|
+
return out;
|
|
52313
|
+
}
|
|
52159
52314
|
if (prodUrls.length > 0 && candUrls.length === 0) {
|
|
52160
52315
|
out.push({
|
|
52161
52316
|
id: "seo:sitemap-missing",
|
|
@@ -52209,6 +52364,47 @@ ${diff.onlyProdSample.join(`
|
|
|
52209
52364
|
}
|
|
52210
52365
|
return out;
|
|
52211
52366
|
}
|
|
52367
|
+
async function checkLlmsTxt(state) {
|
|
52368
|
+
const [prod, cand] = await Promise.all([
|
|
52369
|
+
hasLlmsTxt(state.prodBaseUrl),
|
|
52370
|
+
hasLlmsTxt(state.candBaseUrl)
|
|
52371
|
+
]);
|
|
52372
|
+
if (cand)
|
|
52373
|
+
return [];
|
|
52374
|
+
return [
|
|
52375
|
+
{
|
|
52376
|
+
id: "seo:llms-txt-absent",
|
|
52377
|
+
severity: "low",
|
|
52378
|
+
category: "seo",
|
|
52379
|
+
check: "seo-deep-audit",
|
|
52380
|
+
summary: prod ? "/llms.txt presente em prod mas ausente em cand" : "Nenhum dos lados serve /llms.txt — oportunidade de SEO para IA",
|
|
52381
|
+
details: "llms.txt orienta crawlers de LLM sobre o conteúdo do site (https://llmstxt.org). Publicá-lo no cand melhora a descoberta por assistentes de IA — a migração é a hora de adicionar."
|
|
52382
|
+
}
|
|
52383
|
+
];
|
|
52384
|
+
}
|
|
52385
|
+
async function hasLlmsTxt(baseUrl, timeoutMs = 1e4) {
|
|
52386
|
+
const url = new URL("/llms.txt", baseUrl).toString();
|
|
52387
|
+
const controller = new AbortController;
|
|
52388
|
+
const t = setTimeout(() => controller.abort(), timeoutMs);
|
|
52389
|
+
try {
|
|
52390
|
+
const res = await fetch(url, {
|
|
52391
|
+
signal: controller.signal,
|
|
52392
|
+
redirect: "follow",
|
|
52393
|
+
headers: { "User-Agent": "parity-cli/0.1" }
|
|
52394
|
+
});
|
|
52395
|
+
if (!res.ok)
|
|
52396
|
+
return false;
|
|
52397
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
52398
|
+
const body = await res.text();
|
|
52399
|
+
if (ct.includes("text/html") || body.trimStart().startsWith("<"))
|
|
52400
|
+
return false;
|
|
52401
|
+
return body.trim().length > 0;
|
|
52402
|
+
} catch {
|
|
52403
|
+
return false;
|
|
52404
|
+
} finally {
|
|
52405
|
+
clearTimeout(t);
|
|
52406
|
+
}
|
|
52407
|
+
}
|
|
52212
52408
|
async function checkRobotsTxtStructured(state) {
|
|
52213
52409
|
const issues = await checkRobotsTxt(state);
|
|
52214
52410
|
const [prodTxt, candTxt] = await Promise.all([
|
|
@@ -52233,8 +52429,8 @@ async function checkRobotsTxtStructured(state) {
|
|
|
52233
52429
|
async function checkSitemapStructured(state, candPages) {
|
|
52234
52430
|
const issues = await checkSitemap(state, candPages);
|
|
52235
52431
|
const [prodUrls, candUrls] = await Promise.all([
|
|
52236
|
-
resolveSitemapUrls(state.prodBaseUrl),
|
|
52237
|
-
resolveSitemapUrls(state.candBaseUrl)
|
|
52432
|
+
resolveSitemapUrls(state.prodBaseUrl, undefined, { decoFallback: false }),
|
|
52433
|
+
resolveSitemapUrls(state.candBaseUrl, undefined, { decoFallback: false })
|
|
52238
52434
|
]);
|
|
52239
52435
|
const diff = diffSitemap(prodUrls, candUrls);
|
|
52240
52436
|
return {
|
|
@@ -54395,10 +54591,13 @@ function renderVitalsPanel(run) {
|
|
|
54395
54591
|
for (const p of fc.pages) {
|
|
54396
54592
|
const key = pathOf3(p.url);
|
|
54397
54593
|
const entry = pageVitals.get(key) ?? { viewport: p.viewport };
|
|
54398
|
-
if (p.side === "prod")
|
|
54594
|
+
if (p.side === "prod") {
|
|
54399
54595
|
entry.prod = p.vitals;
|
|
54400
|
-
|
|
54596
|
+
entry.prodScores = p.lhScores;
|
|
54597
|
+
} else {
|
|
54401
54598
|
entry.cand = p.vitals;
|
|
54599
|
+
entry.candScores = p.lhScores;
|
|
54600
|
+
}
|
|
54402
54601
|
pageVitals.set(key, entry);
|
|
54403
54602
|
}
|
|
54404
54603
|
}
|
|
@@ -54431,6 +54630,7 @@ function renderVitalsPanel(run) {
|
|
|
54431
54630
|
return `
|
|
54432
54631
|
<div class="card">
|
|
54433
54632
|
<h2>${escapeHtml(title)}</h2>
|
|
54633
|
+
${renderCategoryScores(entry.prodScores, entry.candScores)}
|
|
54434
54634
|
<table class="vitals-table">
|
|
54435
54635
|
<thead>
|
|
54436
54636
|
<tr>
|
|
@@ -54445,13 +54645,125 @@ function renderVitalsPanel(run) {
|
|
|
54445
54645
|
${metricRow("FCP (First Contentful Paint)", entry.prod?.fcp, entry.cand?.fcp, "ms", true)}
|
|
54446
54646
|
${metricRow("TTFB (Time to First Byte)", entry.prod?.ttfb, entry.cand?.ttfb, "ms", true)}
|
|
54447
54647
|
${metricRow("INP (Interaction to Next Paint)", entry.prod?.inp, entry.cand?.inp, "ms", true)}
|
|
54648
|
+
${entry.prod?.tbt != null || entry.cand?.tbt != null ? metricRow("TBT (Total Blocking Time)", entry.prod?.tbt, entry.cand?.tbt, "ms", true) : ""}
|
|
54448
54649
|
${metricRow("CLS (Cumulative Layout Shift)", entry.prod?.cls, entry.cand?.cls, "score", true)}
|
|
54449
54650
|
</tbody>
|
|
54450
54651
|
</table>
|
|
54451
54652
|
<div class="hint">prod = Fresh (source of truth) · cand = TanStack · green Δ = cand better than prod · red Δ = regression</div>
|
|
54452
54653
|
</div>`;
|
|
54453
54654
|
});
|
|
54454
|
-
return cards.join("");
|
|
54655
|
+
return renderAgenticNav(run) + cards.join("") + renderVitalsOpportunities(run);
|
|
54656
|
+
}
|
|
54657
|
+
function renderAgenticNav(run) {
|
|
54658
|
+
const data2 = run.checks?.find((c) => c.name === "agentic-nav")?.data;
|
|
54659
|
+
const a = data2?.agentic;
|
|
54660
|
+
if (!a || a.total === 0)
|
|
54661
|
+
return "";
|
|
54662
|
+
const tallyCls = a.passed === a.total ? "lh-good" : a.passed === 0 ? "lh-poor" : "lh-avg";
|
|
54663
|
+
const blocks = a.pillars.map((p) => {
|
|
54664
|
+
const icon = !p.applicable ? "—" : p.ok ? "✅" : "▲";
|
|
54665
|
+
const auditRows = (p.failingAudits ?? []).map((au) => `
|
|
54666
|
+
<tr>
|
|
54667
|
+
<td>${escapeHtml(au.title)}</td>
|
|
54668
|
+
<td>${au.elements.map((e) => `<code>${escapeHtml(e.selector || e.snippet.slice(0, 80))}</code>`).join("<br>")}</td>
|
|
54669
|
+
</tr>`).join("");
|
|
54670
|
+
const table = auditRows ? `<table class="vitals-table"><thead><tr><th>Failed audit</th><th>Failing element</th></tr></thead><tbody>${auditRows}</tbody></table>` : "";
|
|
54671
|
+
return `
|
|
54672
|
+
<div class="agentic-pillar">
|
|
54673
|
+
<div class="agentic-pillar-head">${icon} ${escapeHtml(p.label)}${p.note ? ` <span class="hint">(${escapeHtml(p.note)})</span>` : ""}</div>
|
|
54674
|
+
${table}
|
|
54675
|
+
</div>`;
|
|
54676
|
+
}).join("");
|
|
54677
|
+
return `
|
|
54678
|
+
<div class="card">
|
|
54679
|
+
<div class="agentic-head">
|
|
54680
|
+
<span class="lh-score ${tallyCls}">${a.passed}/${a.total}</span>
|
|
54681
|
+
<h2 style="display:inline;margin-left:10px">Agentic navigation</h2>
|
|
54682
|
+
</div>
|
|
54683
|
+
<div class="hint">Checks that keep the site navigable by AI agents (agent accessibility + llms.txt). Category still in development.</div>
|
|
54684
|
+
${blocks}
|
|
54685
|
+
</div>`;
|
|
54686
|
+
}
|
|
54687
|
+
function scoreBand(v) {
|
|
54688
|
+
return v >= 90 ? "good" : v >= 50 ? "avg" : "poor";
|
|
54689
|
+
}
|
|
54690
|
+
function scoreRing(value) {
|
|
54691
|
+
if (value == null) {
|
|
54692
|
+
return `<svg class="ring ring-na" viewBox="0 0 64 64" width="60" height="60" aria-hidden="true"><circle class="ring-track" cx="32" cy="32" r="26" fill="none" stroke-width="6"/><text x="32" y="32" class="ring-num" text-anchor="middle" dominant-baseline="central">—</text></svg>`;
|
|
54693
|
+
}
|
|
54694
|
+
const r = 26;
|
|
54695
|
+
const circ = 2 * Math.PI * r;
|
|
54696
|
+
const dash = value / 100 * circ;
|
|
54697
|
+
return `<svg class="ring ring-${scoreBand(value)}" viewBox="0 0 64 64" width="60" height="60" role="img">
|
|
54698
|
+
<circle class="ring-track" cx="32" cy="32" r="${r}" fill="none" stroke-width="6"/>
|
|
54699
|
+
<circle class="ring-arc" cx="32" cy="32" r="${r}" fill="none" stroke-width="6" stroke-linecap="round" stroke-dasharray="${dash.toFixed(1)} ${(circ - dash).toFixed(1)}" transform="rotate(-90 32 32)"/>
|
|
54700
|
+
<text x="32" y="32" class="ring-num" text-anchor="middle" dominant-baseline="central">${value}</text>
|
|
54701
|
+
</svg>`;
|
|
54702
|
+
}
|
|
54703
|
+
function renderCategoryScores(prod, cand) {
|
|
54704
|
+
if (!prod && !cand)
|
|
54705
|
+
return "";
|
|
54706
|
+
const cats = [
|
|
54707
|
+
["Performance", "performance"],
|
|
54708
|
+
["Accessibility", "accessibility"],
|
|
54709
|
+
["Best Practices", "bestPractices"],
|
|
54710
|
+
["SEO", "seo"]
|
|
54711
|
+
];
|
|
54712
|
+
const cells = cats.map(([label, key]) => {
|
|
54713
|
+
const c = cand?.[key];
|
|
54714
|
+
const p = prod?.[key];
|
|
54715
|
+
let sub = `<span class="ring-sub dim">—</span>`;
|
|
54716
|
+
if (c != null && p != null) {
|
|
54717
|
+
const d = c - p;
|
|
54718
|
+
const tone = d < -3 ? "delta-bad" : d > 3 ? "delta-good" : "delta-neutral";
|
|
54719
|
+
const arrow = d > 0 ? "▲" : d < 0 ? "▼" : "=";
|
|
54720
|
+
sub = `<span class="ring-sub ${tone}">prod ${p} · ${arrow}${d > 0 ? "+" : ""}${d}</span>`;
|
|
54721
|
+
} else if (p != null) {
|
|
54722
|
+
sub = `<span class="ring-sub dim">prod ${p}</span>`;
|
|
54723
|
+
}
|
|
54724
|
+
return `
|
|
54725
|
+
<div class="ring-cell">
|
|
54726
|
+
${scoreRing(c)}
|
|
54727
|
+
<span class="ring-label">${label}</span>
|
|
54728
|
+
${sub}
|
|
54729
|
+
</div>`;
|
|
54730
|
+
}).join("");
|
|
54731
|
+
return `<div class="lh-rings">${cells}</div>`;
|
|
54732
|
+
}
|
|
54733
|
+
function renderVitalsOpportunities(run) {
|
|
54734
|
+
const byId = new Map;
|
|
54735
|
+
for (const fc of run.flowCaptures) {
|
|
54736
|
+
if (fc.side !== "cand")
|
|
54737
|
+
continue;
|
|
54738
|
+
for (const p of fc.pages) {
|
|
54739
|
+
for (const o of p.lhOpportunities ?? []) {
|
|
54740
|
+
const prev2 = byId.get(o.id);
|
|
54741
|
+
if (!prev2 || o.savingsMs > prev2.savingsMs)
|
|
54742
|
+
byId.set(o.id, o);
|
|
54743
|
+
}
|
|
54744
|
+
}
|
|
54745
|
+
}
|
|
54746
|
+
if (byId.size === 0)
|
|
54747
|
+
return "";
|
|
54748
|
+
const opps = [...byId.values()].sort((a, b) => b.savingsMs - a.savingsMs || b.savingsBytes - a.savingsBytes);
|
|
54749
|
+
const rows = opps.map((o) => `
|
|
54750
|
+
<tr>
|
|
54751
|
+
<td>${escapeHtml(o.title)}</td>
|
|
54752
|
+
<td class="num">${o.savingsMs > 0 ? `${o.savingsMs}ms` : "—"}</td>
|
|
54753
|
+
<td class="num">${o.savingsBytes > 0 ? `${(o.savingsBytes / 1024).toFixed(0)} KB` : "—"}</td>
|
|
54754
|
+
<td>${o.displayValue ? escapeHtml(o.displayValue) : ""}</td>
|
|
54755
|
+
</tr>`).join("");
|
|
54756
|
+
return `
|
|
54757
|
+
<div class="card">
|
|
54758
|
+
<h2>⚡ Lighthouse opportunities (cand)</h2>
|
|
54759
|
+
<div class="hint">Actionable audits from the throttled Lighthouse pass, deduped across pages, biggest wins first. What to fix to close the gap with PageSpeed.</div>
|
|
54760
|
+
<table class="vitals-table">
|
|
54761
|
+
<thead>
|
|
54762
|
+
<tr><th>Opportunity</th><th class="num">Est. savings</th><th class="num">Bytes</th><th>Detail</th></tr>
|
|
54763
|
+
</thead>
|
|
54764
|
+
<tbody>${rows}</tbody>
|
|
54765
|
+
</table>
|
|
54766
|
+
</div>`;
|
|
54455
54767
|
}
|
|
54456
54768
|
function formatVital2(v, unit) {
|
|
54457
54769
|
if (v == null)
|
|
@@ -66176,9 +66488,194 @@ async function reportCommand(runId, opts) {
|
|
|
66176
66488
|
|
|
66177
66489
|
// src/commands/vitals.ts
|
|
66178
66490
|
import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync26 } from "node:fs";
|
|
66491
|
+
import { availableParallelism } from "node:os";
|
|
66179
66492
|
import { join as join31 } from "node:path";
|
|
66180
66493
|
import chalk24 from "chalk";
|
|
66181
66494
|
import ora8 from "ora";
|
|
66495
|
+
|
|
66496
|
+
// src/checks/agentic-nav.ts
|
|
66497
|
+
async function agenticNav(ctx) {
|
|
66498
|
+
const start = Date.now();
|
|
66499
|
+
const issues = [];
|
|
66500
|
+
const pillars = [];
|
|
66501
|
+
const withA11y = ctx.candPages.filter((p) => p.agentA11y && p.agentA11y.length > 0);
|
|
66502
|
+
if (withA11y.length > 0) {
|
|
66503
|
+
const byId = new Map;
|
|
66504
|
+
for (const p of withA11y) {
|
|
66505
|
+
for (const a of p.agentA11y ?? []) {
|
|
66506
|
+
const prev2 = byId.get(a.id);
|
|
66507
|
+
if (!prev2 || a.score === 0 && prev2.score !== 0)
|
|
66508
|
+
byId.set(a.id, a);
|
|
66509
|
+
}
|
|
66510
|
+
}
|
|
66511
|
+
const failing = [...byId.values()].filter((a) => a.score === 0);
|
|
66512
|
+
pillars.push({
|
|
66513
|
+
key: "agent-a11y",
|
|
66514
|
+
label: "Agent accessibility",
|
|
66515
|
+
ok: failing.length === 0,
|
|
66516
|
+
applicable: true,
|
|
66517
|
+
failingAudits: failing
|
|
66518
|
+
});
|
|
66519
|
+
if (failing.length > 0) {
|
|
66520
|
+
issues.push({
|
|
66521
|
+
id: "agentic:a11y-tree",
|
|
66522
|
+
severity: "medium",
|
|
66523
|
+
category: "a11y",
|
|
66524
|
+
check: "agentic-nav",
|
|
66525
|
+
summary: `Árvore de acessibilidade mal estruturada para agentes: ${failing.map((f) => f.id).join(", ")}`,
|
|
66526
|
+
details: failing.map((f) => `${f.title}
|
|
66527
|
+
${f.elements.map((e) => e.selector).filter(Boolean).join(`
|
|
66528
|
+
`)}`).join(`
|
|
66529
|
+
`)
|
|
66530
|
+
});
|
|
66531
|
+
}
|
|
66532
|
+
} else {
|
|
66533
|
+
pillars.push({
|
|
66534
|
+
key: "agent-a11y",
|
|
66535
|
+
label: "Agent accessibility",
|
|
66536
|
+
ok: false,
|
|
66537
|
+
applicable: false,
|
|
66538
|
+
note: "no Lighthouse data (run without --no-lighthouse)"
|
|
66539
|
+
});
|
|
66540
|
+
}
|
|
66541
|
+
const candOrigin = originOf3(ctx.candPages);
|
|
66542
|
+
const llms = candOrigin ? await fetchLlmsTxtQuality(candOrigin) : null;
|
|
66543
|
+
const llmsOk = !!llms?.wellFormed;
|
|
66544
|
+
pillars.push({
|
|
66545
|
+
key: "llms-txt",
|
|
66546
|
+
label: "llms.txt follows recommendations",
|
|
66547
|
+
ok: llmsOk,
|
|
66548
|
+
applicable: true,
|
|
66549
|
+
note: llms?.reason
|
|
66550
|
+
});
|
|
66551
|
+
if (!llmsOk) {
|
|
66552
|
+
issues.push({
|
|
66553
|
+
id: "agentic:llms-txt",
|
|
66554
|
+
severity: "low",
|
|
66555
|
+
category: "seo",
|
|
66556
|
+
check: "agentic-nav",
|
|
66557
|
+
summary: llms?.present ? "O arquivo llms.txt não segue as recomendações" : "cand não serve /llms.txt",
|
|
66558
|
+
details: `${llms?.reason ?? "ausente"}. Veja https://llmstxt.org — um H1 de título, um resumo em blockquote e seções com links.`
|
|
66559
|
+
});
|
|
66560
|
+
}
|
|
66561
|
+
const applicable = pillars.filter((p) => p.applicable);
|
|
66562
|
+
const passed = applicable.filter((p) => p.ok).length;
|
|
66563
|
+
return {
|
|
66564
|
+
name: "agentic-nav",
|
|
66565
|
+
status: applicable.length === 0 ? "skipped" : passed === applicable.length ? "pass" : "fail",
|
|
66566
|
+
severity: "medium",
|
|
66567
|
+
durationMs: Date.now() - start,
|
|
66568
|
+
summary: `Navegação agêntica: ${passed}/${applicable.length} verificações`,
|
|
66569
|
+
issues,
|
|
66570
|
+
data: { agentic: { passed, total: applicable.length, pillars } }
|
|
66571
|
+
};
|
|
66572
|
+
}
|
|
66573
|
+
function originOf3(pages) {
|
|
66574
|
+
for (const p of pages) {
|
|
66575
|
+
try {
|
|
66576
|
+
return new URL(p.url).origin;
|
|
66577
|
+
} catch {}
|
|
66578
|
+
}
|
|
66579
|
+
return null;
|
|
66580
|
+
}
|
|
66581
|
+
async function fetchLlmsTxtQuality(origin, timeoutMs = 1e4) {
|
|
66582
|
+
const url = new URL("/llms.txt", origin).toString();
|
|
66583
|
+
const controller = new AbortController;
|
|
66584
|
+
const t = setTimeout(() => controller.abort(), timeoutMs);
|
|
66585
|
+
try {
|
|
66586
|
+
const res = await fetch(url, {
|
|
66587
|
+
signal: controller.signal,
|
|
66588
|
+
redirect: "follow",
|
|
66589
|
+
headers: { "User-Agent": "parity-cli/0.1" }
|
|
66590
|
+
});
|
|
66591
|
+
if (!res.ok)
|
|
66592
|
+
return { present: false, wellFormed: false, reason: `HTTP ${res.status}` };
|
|
66593
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
66594
|
+
const body = await res.text();
|
|
66595
|
+
if (ct.includes("text/html") || body.trimStart().startsWith("<")) {
|
|
66596
|
+
return {
|
|
66597
|
+
present: false,
|
|
66598
|
+
wellFormed: false,
|
|
66599
|
+
reason: "route returns HTML (SPA fallback), not an llms.txt"
|
|
66600
|
+
};
|
|
66601
|
+
}
|
|
66602
|
+
return assessLlmsTxt(body);
|
|
66603
|
+
} catch {
|
|
66604
|
+
return { present: false, wellFormed: false, reason: "fetch failed" };
|
|
66605
|
+
} finally {
|
|
66606
|
+
clearTimeout(t);
|
|
66607
|
+
}
|
|
66608
|
+
}
|
|
66609
|
+
function assessLlmsTxt(body) {
|
|
66610
|
+
const text3 = body.trim();
|
|
66611
|
+
if (text3.length === 0)
|
|
66612
|
+
return { present: false, wellFormed: false, reason: "empty" };
|
|
66613
|
+
const lines = text3.split(/\r?\n/);
|
|
66614
|
+
const firstMeaningful = lines.find((l) => l.trim().length > 0) ?? "";
|
|
66615
|
+
const hasH1 = /^#\s+\S/.test(firstMeaningful.trim());
|
|
66616
|
+
const hasLinks = /\[[^\]]+\]\([^)]+\)/.test(text3);
|
|
66617
|
+
const hasSection = /^##\s+\S/m.test(text3);
|
|
66618
|
+
const wellFormed = hasH1 && (hasLinks || hasSection);
|
|
66619
|
+
const missing = [];
|
|
66620
|
+
if (!hasH1)
|
|
66621
|
+
missing.push("H1 title (`# Title`)");
|
|
66622
|
+
if (!hasLinks && !hasSection)
|
|
66623
|
+
missing.push("`##` sections or `[text](url)` links");
|
|
66624
|
+
return {
|
|
66625
|
+
present: true,
|
|
66626
|
+
wellFormed,
|
|
66627
|
+
reason: wellFormed ? "ok" : `missing ${missing.join(" and ")}`
|
|
66628
|
+
};
|
|
66629
|
+
}
|
|
66630
|
+
|
|
66631
|
+
// src/checks/lighthouse-scores.ts
|
|
66632
|
+
var CATEGORIES = [
|
|
66633
|
+
{ key: "performance", label: "Performance" },
|
|
66634
|
+
{ key: "accessibility", label: "Acessibilidade" },
|
|
66635
|
+
{ key: "bestPractices", label: "Práticas recomendadas" },
|
|
66636
|
+
{ key: "seo", label: "SEO" }
|
|
66637
|
+
];
|
|
66638
|
+
var REGRESSION_DELTA = 3;
|
|
66639
|
+
function lighthouseScores(ctx) {
|
|
66640
|
+
const start = Date.now();
|
|
66641
|
+
const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
|
|
66642
|
+
const issues = [];
|
|
66643
|
+
for (const pair of pairs) {
|
|
66644
|
+
const prod = pair.prod.lhScores;
|
|
66645
|
+
const cand = pair.cand.lhScores;
|
|
66646
|
+
if (!prod || !cand)
|
|
66647
|
+
continue;
|
|
66648
|
+
for (const { key: key2, label } of CATEGORIES) {
|
|
66649
|
+
const p = prod[key2];
|
|
66650
|
+
const c = cand[key2];
|
|
66651
|
+
if (p == null || c == null)
|
|
66652
|
+
continue;
|
|
66653
|
+
const delta = c - p;
|
|
66654
|
+
if (delta >= -REGRESSION_DELTA)
|
|
66655
|
+
continue;
|
|
66656
|
+
issues.push({
|
|
66657
|
+
id: `lh-score:${key2}:${pair.key}`,
|
|
66658
|
+
severity: -delta >= 10 ? "high" : "medium",
|
|
66659
|
+
category: key2 === "seo" ? "seo" : key2 === "accessibility" ? "a11y" : "performance",
|
|
66660
|
+
page: pair.key,
|
|
66661
|
+
check: "lighthouse-scores",
|
|
66662
|
+
summary: `${label} regrediu em ${pair.key}: cand ${c} vs prod ${p} (${delta})`,
|
|
66663
|
+
details: `Objetivo da migração é igual ou melhor. ${label}: prod=${p}, cand=${c}. Recupere pelo menos o nível de prod.`
|
|
66664
|
+
});
|
|
66665
|
+
}
|
|
66666
|
+
}
|
|
66667
|
+
const hasScores = pairs.some((p) => p.prod.lhScores && p.cand.lhScores);
|
|
66668
|
+
return {
|
|
66669
|
+
name: "lighthouse-scores",
|
|
66670
|
+
status: !hasScores ? "skipped" : issues.length > 0 ? "fail" : "pass",
|
|
66671
|
+
severity: "medium",
|
|
66672
|
+
durationMs: Date.now() - start,
|
|
66673
|
+
summary: !hasScores ? "Sem scores Lighthouse (rode sem --no-lighthouse)" : `${pairs.length} página(s), ${issues.length} regressão(ões) de categoria`,
|
|
66674
|
+
issues
|
|
66675
|
+
};
|
|
66676
|
+
}
|
|
66677
|
+
|
|
66678
|
+
// src/commands/vitals.ts
|
|
66182
66679
|
async function vitalsCommand(opts) {
|
|
66183
66680
|
const viewports = opts.viewports.split(",").map((s) => s.trim()).filter((s) => s === "mobile" || s === "desktop");
|
|
66184
66681
|
const concurrency = Math.max(1, Math.min(opts.concurrency ?? 4, 8));
|
|
@@ -66224,6 +66721,35 @@ async function vitalsCommand(opts) {
|
|
|
66224
66721
|
}
|
|
66225
66722
|
});
|
|
66226
66723
|
progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
|
|
66724
|
+
if (opts.lighthouse !== false) {
|
|
66725
|
+
const lhDir = join31(paths.runDir, "lighthouse");
|
|
66726
|
+
const lhCap = opts.lighthouseConcurrency ?? Math.max(1, Math.min(2, Math.floor(availableParallelism() / 2)));
|
|
66727
|
+
const done = tasks.filter((t) => !!t.capture);
|
|
66728
|
+
const lhT0 = Date.now();
|
|
66729
|
+
let lhCompleted = 0;
|
|
66730
|
+
const lhProgress = ora8(`Lighthouse 0/${done.length} (throttled Slow 4G + 4× CPU · ~40s/página · ${lhCap} paralelo)`).start();
|
|
66731
|
+
await runWithConcurrency3(done.map((task, i) => ({ task, i })), lhCap, async ({ task, i }) => {
|
|
66732
|
+
const url = new URL(task.path, task.side === "prod" ? opts.prod : opts.cand).toString();
|
|
66733
|
+
const result = await measureLighthouse(url, {
|
|
66734
|
+
outDir: lhDir,
|
|
66735
|
+
id: `${task.side}-${task.viewport}-${i}`,
|
|
66736
|
+
formFactor: task.viewport === "desktop" ? "desktop" : "mobile"
|
|
66737
|
+
});
|
|
66738
|
+
if (!("error" in result)) {
|
|
66739
|
+
task.capture.vitals = lhToWebVitals(result);
|
|
66740
|
+
if (result.opportunities)
|
|
66741
|
+
task.capture.lhOpportunities = result.opportunities;
|
|
66742
|
+
if (result.scores)
|
|
66743
|
+
task.capture.lhScores = result.scores;
|
|
66744
|
+
if (result.agentA11y)
|
|
66745
|
+
task.capture.agentA11y = result.agentA11y;
|
|
66746
|
+
}
|
|
66747
|
+
lhCompleted++;
|
|
66748
|
+
const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
|
|
66749
|
+
lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk24.cyan("prod") : chalk24.magenta("cand")} ${task.path} (${task.viewport})`;
|
|
66750
|
+
});
|
|
66751
|
+
lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
|
|
66752
|
+
}
|
|
66227
66753
|
const allPageCaptures = tasks.map((t) => t.capture).filter((c) => !!c);
|
|
66228
66754
|
const flowCaptures = [];
|
|
66229
66755
|
for (const viewport of viewports) {
|
|
@@ -66260,7 +66786,9 @@ async function vitalsCommand(opts) {
|
|
|
66260
66786
|
};
|
|
66261
66787
|
const vitalsResult = webVitalsMobile(checkCtx);
|
|
66262
66788
|
const cacheResult = cacheCoverage(checkCtx);
|
|
66263
|
-
const
|
|
66789
|
+
const scoresResult = lighthouseScores(checkCtx);
|
|
66790
|
+
const agenticResult = await agenticNav(checkCtx);
|
|
66791
|
+
const checks = [vitalsResult, cacheResult, scoresResult, agenticResult];
|
|
66264
66792
|
const allIssues = checks.flatMap((c) => c.issues);
|
|
66265
66793
|
const verdict2 = computeVerdict(checks, allIssues, {
|
|
66266
66794
|
pagesAnalyzed: pairCaptures(checkCtx.prodPages, checkCtx.candPages).pairs.length
|
|
@@ -66290,10 +66818,12 @@ async function vitalsCommand(opts) {
|
|
|
66290
66818
|
candUrl: opts.cand,
|
|
66291
66819
|
pagesAnalyzed: pagePaths.length,
|
|
66292
66820
|
vitalsCheck: vitalsResult.data,
|
|
66293
|
-
cacheCheck: cacheResult.data
|
|
66821
|
+
cacheCheck: cacheResult.data,
|
|
66822
|
+
scores: checkCtx.candPages.filter((p) => p.lhScores).map((p) => ({ path: new URL(p.url).pathname, ...p.lhScores })),
|
|
66823
|
+
opportunities: aggregateOpportunities(checkCtx.candPages)
|
|
66294
66824
|
}, null, 2)}
|
|
66295
66825
|
`, "utf8");
|
|
66296
|
-
printSummary7(vitalsResult, cacheResult);
|
|
66826
|
+
printSummary7(vitalsResult, cacheResult, scoresResult, agenticResult);
|
|
66297
66827
|
console.log("");
|
|
66298
66828
|
console.log(chalk24.dim(` → ${paths.reportHtml}`));
|
|
66299
66829
|
console.log(chalk24.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
|
|
@@ -66343,6 +66873,20 @@ async function captureVitalsPage(browser, viewport, side, url, screenshotsDir, r
|
|
|
66343
66873
|
});
|
|
66344
66874
|
}
|
|
66345
66875
|
}
|
|
66876
|
+
function lhToWebVitals(s) {
|
|
66877
|
+
return { lcp: s.lcp, cls: s.cls, fcp: s.fcp, ttfb: s.ttfb, inp: null, tbt: s.tbt ?? null };
|
|
66878
|
+
}
|
|
66879
|
+
function aggregateOpportunities(pages) {
|
|
66880
|
+
const byId = new Map;
|
|
66881
|
+
for (const p of pages) {
|
|
66882
|
+
for (const o of p.lhOpportunities ?? []) {
|
|
66883
|
+
const prev2 = byId.get(o.id);
|
|
66884
|
+
if (!prev2 || o.savingsMs > prev2.savingsMs)
|
|
66885
|
+
byId.set(o.id, o);
|
|
66886
|
+
}
|
|
66887
|
+
}
|
|
66888
|
+
return [...byId.values()].sort((a, b) => b.savingsMs - a.savingsMs || b.savingsBytes - a.savingsBytes);
|
|
66889
|
+
}
|
|
66346
66890
|
async function discoverPagePaths2(prodUrl, opts) {
|
|
66347
66891
|
if (opts.urls)
|
|
66348
66892
|
return parseUrlList(opts.urls);
|
|
@@ -66400,11 +66944,15 @@ async function runWithConcurrency3(items, workers, fn) {
|
|
|
66400
66944
|
}
|
|
66401
66945
|
}));
|
|
66402
66946
|
}
|
|
66403
|
-
function printSummary7(vitals, cache) {
|
|
66947
|
+
function printSummary7(vitals, cache, scores, agentic) {
|
|
66404
66948
|
console.log("");
|
|
66405
66949
|
console.log(chalk24.bold(" Summary:"));
|
|
66406
66950
|
console.log(` ${vitals.summary}`);
|
|
66407
66951
|
console.log(` ${cache.summary}`);
|
|
66952
|
+
if (scores.status !== "skipped")
|
|
66953
|
+
console.log(` ${scores.summary}`);
|
|
66954
|
+
if (agentic.status !== "skipped")
|
|
66955
|
+
console.log(` ${agentic.summary}`);
|
|
66408
66956
|
}
|
|
66409
66957
|
|
|
66410
66958
|
// src/util/version.ts
|
|
@@ -66506,7 +67054,7 @@ program.command("pr").description("CI/CD entry point: compare a PR preview URL a
|
|
|
66506
67054
|
program.command("cache").description("Cache analysis focused on cand. Crawls N pages (lighter than `vitals`: no screenshots, no vitals, no scroll), groups requests by category, lists MISS-asset opportunities.").requiredOption("--prod <url>", "Production URL (optional reference)").requiredOption("--cand <url>", "Candidate URL (foco)").option("--urls <list-or-file>", "Comma-separated paths or .txt file (1/line). Overrides sitemap.").option("--pages <n>", "Max pages to crawl from sitemap", (v) => Number(v), 30).option("--viewports <list>", "mobile,desktop", "mobile").option("--concurrency <n>", "Parallel workers (1-8)", (v) => Number(v), 6).option("--cand-only", "Skip prod entirely (faster, no comparison)", false).option("--output <dir>", "Output directory", "./parity-output").option("--open", "Open the HTML report when done", false).action(async (opts) => {
|
|
66507
67055
|
process.exit(await cacheCommand(opts));
|
|
66508
67056
|
});
|
|
66509
|
-
program.command("vitals").description("Crawls multiple pages (via sitemap.xml or --urls) and compares Web Vitals prod vs cand on each. HTML output with the top worst/best expanded.").requiredOption("--prod <url>", "Production URL (base)").requiredOption("--cand <url>", "Candidate URL (base)").option("--urls <list-or-file>", "Comma-separated paths or .txt file (1/line). Overrides sitemap discovery.").option("--limit <n>", "Max pages discovered from sitemap.xml", (v) => Number(v), 20).option("--viewports <list>", "mobile,desktop", "mobile").option("--concurrency <n>", "Parallel workers (1-8)", (v) => Number(v), 4).option("--runs <n>", "Repeat each page's vitals navigation N times and compare against the median (reduces run-to-run jitter false positives). Default 1 (no repeat). Issue #179.", (v) => Number(v), 1).option("--output <dir>", "Output directory", "./parity-output").option("--open", "Open the HTML report when done", false).action(async (opts) => {
|
|
67057
|
+
program.command("vitals").description("Crawls multiple pages (via sitemap.xml or --urls) and compares Web Vitals prod vs cand on each. HTML output with the top worst/best expanded.").requiredOption("--prod <url>", "Production URL (base)").requiredOption("--cand <url>", "Candidate URL (base)").option("--urls <list-or-file>", "Comma-separated paths or .txt file (1/line). Overrides sitemap discovery.").option("--limit <n>", "Max pages discovered from sitemap.xml", (v) => Number(v), 20).option("--viewports <list>", "mobile,desktop", "mobile").option("--concurrency <n>", "Parallel workers (1-8)", (v) => Number(v), 4).option("--runs <n>", "Repeat each page's vitals navigation N times and compare against the median (reduces run-to-run jitter false positives). Default 1 (no repeat). Issue #179.", (v) => Number(v), 1).option("--no-lighthouse", "Skip Lighthouse and use the fast warm Playwright collector (unthrottled — NOT comparable to PageSpeed). For fast iteration only. Default: Lighthouse (Slow 4G + 4× CPU) so numbers match PageSpeed. #264.").option("--lighthouse-concurrency <n>", "Parallel Lighthouse processes. Low by default (cores/2, capped 2) — Lighthouse measures CPU, so more parallelism inflates the numbers.", (v) => Number(v)).option("--output <dir>", "Output directory", "./parity-output").option("--open", "Open the HTML report when done", false).action(async (opts) => {
|
|
66510
67058
|
process.exit(await vitalsCommand(opts));
|
|
66511
67059
|
});
|
|
66512
67060
|
program.command("journey").description("CI-friendly: runs only the purchase journey (home → PLP → PDP → shipping → cart → cart shipping → checkout) and compares prod vs cand step by step.").requiredOption("--prod <url>", "Production URL").requiredOption("--cand <url>", "Candidate URL").option("--viewports <list>", "mobile,desktop", "mobile").option("--cep <cep>", "CEP for shipping calc", "01310-100").option("--output <dir>", "Output directory for runs/<id>/", "./parity-output").option("--junit <file>", "Write JUnit XML to this path").option("--github", "Emit GitHub Actions annotations (::error, ::warning) for failures").option("--json", "Emit a one-line JSON status object to stdout (machine-readable)").option("--no-report", "Skip writing report.html / report.json").option("--no-auto-selectors", "Skip LLM-based selector discovery").option("--accept-prod-quirks", "Demote prod-side cart-empty journey failures (VTEX session quirk) from failed to skipped. The cart-reveal-mode-divergence check still emits critical if prod/cand markup intents differ, so this flag never masks a real regression. See issue #12.", false).option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Issue #67.").action(async (opts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
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",
|