@decocms/parity 0.35.12 → 0.35.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.
package/AGENTS.md CHANGED
@@ -56,7 +56,7 @@ Do **not** fake single-site with `parity run --prod X --cand X` — it runs ever
56
56
  // A FAIL from high findings keeps status "fail" but the score stays the formula — "91 · FAIL" is valid;
57
57
  // read status for the gate, score for progress. It's a progress meter: it RISES as issues get fixed.
58
58
  previousRun?: { id, timestamp, score, scoreDelta }, // trend vs last comparable run (same hosts + scoreVersion)
59
- topIssues: Issue[], // LLM-ranked, deduplicated; usually 5-10 items
59
+ topIssues: Issue[], // one per root cause (issue group), by severity then pages hit; ≤10, real ids + evidence
60
60
  issues: Issue[], // all raw issues from every check
61
61
  checks: CheckResult[], // one per check; .data has structured details
62
62
  visualDiff: {
@@ -102,9 +102,9 @@ The visual module runs on the `parity heatmap` engine — deterministic, no LLM.
102
102
  The most useful flow for an AI agent is:
103
103
 
104
104
  1. Run `parity run --preset full` → wait → read `report.json`
105
- 2. For each `topIssue` with severity ≥ high, open the file(s) referenced in `suggestedFix`
105
+ 2. For each `topIssue` with severity ≥ high, open its `evidence[]` and follow `suggestedFix` when the check set one; `parity explain <runId> <issueId>` for an LLM deep-dive on one issue
106
106
  3. For visual diffs: read `visualDiff.results[].findings` (element + property + px) and `.sectionsOnlyInProd` — the latter are Deco sections present in prod's DOM but missing in cand. Most likely cause: not registered in `src/setup.ts → registerSections()`.
107
- 4. For console errors: read `issues[].evidence[]` for HAR paths; the failed request is usually the root cause.
107
+ 4. For console errors: read `issues[].details` and the matching `flowCaptures[].network` rows; the failed request is usually the root cause. (HARs are not recorded by default — `PARITY_HAR=1` writes `har/<viewport>-<side>.har` for a human to open.)
108
108
  5. Re-run `parity journey` (cheaper) after each fix to confirm.
109
109
 
110
110
  **Important:** prod is the source of truth. Never modify prod-side code to make tests pass — always fix cand.
@@ -113,11 +113,11 @@ The most useful flow for an AI agent is:
113
113
 
114
114
  If neither `ANTHROPIC_API_KEY` nor `OPENROUTER_API_KEY` is set:
115
115
 
116
- - `topIssues` will fall back to deterministic severity-sorted merge (still useful)
116
+ - `topIssues` is unaffected — it is ranked deterministically from the issue groups, never by an LLM
117
117
  - the visual module is unaffected — it never used an LLM (heatmap engine)
118
118
  - Selector discovery is skipped; defaults from `.parityrc.json` or platform heuristics kick in
119
119
 
120
- The CLI never fails just because the LLM is unavailable. Issues will still be reported, just less polished.
120
+ The CLI never fails just because the LLM is unavailable.
121
121
 
122
122
  ## Cost-conscious usage
123
123
 
@@ -125,7 +125,7 @@ The visual module costs no LLM calls. In tight loops:
125
125
 
126
126
  - Use `--preset smoke` first (no LLM, ~30s) to validate the URLs respond
127
127
  - Use `--no-visual-diff` if you only care about functional checks
128
- - Use `parity journey` (no aggregation step) for the tightest CI loop
128
+ - Use `parity journey` (one flow, no visual pass) for the tightest CI loop
129
129
  - Use `parity heatmap` on the one page you just fixed instead of a whole run
130
130
 
131
131
  ## Picking which pages to verify
package/README.md CHANGED
@@ -73,9 +73,9 @@ Three providers, auto-detected in this order — **none required** if you have t
73
73
  2. `OPENROUTER_API_KEY` — OpenRouter
74
74
  3. **Local `claude` CLI** — uses [`@anthropic-ai/claude-agent-sdk`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk); goes through your existing Claude plan. No env vars needed
75
75
 
76
- Force with `--llm <anthropic|openrouter|claude-code|none|auto>`. Override per-feature with `--llm-model visual-diff=claude-opus-5,explain=claude-opus-5`, or flatten everything to one tier with `--llm-tier-default <haiku|sonnet|opus>`. Default tiers: **Sonnet** for selector discovery / recovery / matching / vision / aggregation (the structural-reasoning calls), **Haiku** for short copy-list classification (`search-terms`), **Opus** for `explain`. Cost-conscious? Try `--llm-tier-default haiku` and bump features back to Sonnet selectively if you hit selector misses.
76
+ Force with `--llm <anthropic|openrouter|claude-code|none|auto>`. Override per-feature with `--llm-model visual-diff=claude-opus-5,explain=claude-opus-5`, or flatten everything to one tier with `--llm-tier-default <haiku|sonnet|opus>`. Default tiers: **Sonnet** for selector discovery / recovery / matching / vision (the structural-reasoning calls), **Haiku** for short copy-list classification (`search-terms`), **Opus** for `explain`. Cost-conscious? Try `--llm-tier-default haiku` and bump features back to Sonnet selectively if you hit selector misses.
77
77
 
78
- Without any provider, the CLI still runs and outputs raw check results — only the LLM-tagged tabs (Visual Diff, LLM Prompt) hide themselves and a banner explains why.
78
+ Without any provider, the CLI still runs and outputs raw check results.
79
79
 
80
80
  ## Output
81
81
 
@@ -84,8 +84,8 @@ Without any provider, the CLI still runs and outputs raw check results — only
84
84
  ├── report.html # links to screenshots/ by relative path — keep the two together
85
85
  ├── report.json # structured output for agents / CI / tooling
86
86
  ├── screenshots/ # per-page, per-viewport, per-side; includes pixelmatch heatmaps
87
- ├── har/ # Playwright HARs (one per viewport/side)
88
- └── traces/ # Playwright traces — drag into trace.playwright.dev
87
+ ├── har/ # Playwright HARs, one per viewport/side — only with PARITY_HAR=1
88
+ └── traces/ # Playwright traces (drag into trace.playwright.dev) — only with PARITY_TRACE=1
89
89
  ```
90
90
 
91
91
  ## Presets
package/dist/cli.js CHANGED
@@ -36662,7 +36662,6 @@ var init_models = __esm(() => {
36662
36662
  "pdp-matching",
36663
36663
  "section-understanding",
36664
36664
  "visual-diff",
36665
- "issue-aggregation",
36666
36665
  "explain",
36667
36666
  "component-detection"
36668
36667
  ];
@@ -36674,13 +36673,11 @@ var init_models = __esm(() => {
36674
36673
  "pdp-matching": "sonnet",
36675
36674
  "section-understanding": "sonnet",
36676
36675
  "visual-diff": "sonnet",
36677
- "issue-aggregation": "sonnet",
36678
36676
  explain: "sonnet",
36679
36677
  "component-detection": "sonnet"
36680
36678
  };
36681
36679
  PREMIUM_FEATURE_TIER = {
36682
36680
  explain: "opus",
36683
- "issue-aggregation": "opus",
36684
36681
  "visual-diff": "opus"
36685
36682
  };
36686
36683
  PROVIDER_MODELS = {
@@ -91031,7 +91028,7 @@ var REPORT_CSS = `
91031
91028
  .agentic-pillar { margin-top: 14px; }
91032
91029
  .agentic-pillar-head { font-weight: 600; margin-bottom: 6px; }
91033
91030
 
91034
- /* LLM Prompt panel */
91031
+ /* Markdown prompt toolbar + body (Visual Diff panel) */
91035
91032
  .prompt-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
91036
91033
  .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; }
91037
91034
  .prompt-toolbar button:hover { opacity: 0.9; }
@@ -92088,34 +92085,6 @@ var REPORT_JS = `
92088
92085
  if (fCache) fCache.addEventListener('change', applyFilters);
92089
92086
  })();
92090
92087
 
92091
- // ---- LLM Prompt: copy + download ----
92092
- var copyBtn = document.getElementById('prompt-copy');
92093
- var dlBtn = document.getElementById('prompt-download');
92094
- var promptEl = document.getElementById('prompt-md');
92095
- var feedback = document.getElementById('prompt-feedback');
92096
- if (copyBtn && promptEl) {
92097
- copyBtn.addEventListener('click', function() {
92098
- var text = promptEl.textContent || '';
92099
- var done = function() {
92100
- feedback.textContent = '✓ copiado!';
92101
- feedback.classList.add('show');
92102
- setTimeout(function() { feedback.classList.remove('show'); }, 2000);
92103
- };
92104
- if (navigator.clipboard) navigator.clipboard.writeText(text).then(done).catch(done);
92105
- });
92106
- }
92107
- if (dlBtn && promptEl) {
92108
- dlBtn.addEventListener('click', function() {
92109
- var text = promptEl.textContent || '';
92110
- var blob = new Blob([text], { type: 'text/markdown' });
92111
- var a = document.createElement('a');
92112
- a.href = URL.createObjectURL(blob);
92113
- a.download = 'parity-prompt.md';
92114
- a.click();
92115
- setTimeout(function() { URL.revokeObjectURL(a.href); }, 1000);
92116
- });
92117
- }
92118
-
92119
92088
  // ---- Visual Diff: prompt copy/download ----
92120
92089
  (function() {
92121
92090
  var vCopy = document.getElementById('vprompt-copy');
@@ -92424,8 +92393,8 @@ function pathOf4(url) {
92424
92393
  }
92425
92394
 
92426
92395
  // src/storage/fs.ts
92427
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync9, readdirSync, writeFileSync as writeFileSync8 } from "node:fs";
92428
- import { join as join7 } from "node:path";
92396
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync9, readdirSync, rmSync, writeFileSync as writeFileSync8 } from "node:fs";
92397
+ import { dirname as dirname4, join as join7 } from "node:path";
92429
92398
  function newRunId() {
92430
92399
  return new Date().toISOString().replace(/[:.]/g, "-").replace("T", "T");
92431
92400
  }
@@ -92497,19 +92466,19 @@ function sameModuleSet(a, b) {
92497
92466
  return false;
92498
92467
  return true;
92499
92468
  }
92469
+ function hostOf2(url) {
92470
+ try {
92471
+ return new URL(url).hostname;
92472
+ } catch {
92473
+ return url;
92474
+ }
92475
+ }
92500
92476
  function findPreviousRun(outputDir, opts) {
92501
92477
  return findComparableRuns(outputDir, opts, 1)[0] ?? null;
92502
92478
  }
92503
92479
  function findComparableRuns(outputDir, opts, limit) {
92504
- const hostOf = (url) => {
92505
- try {
92506
- return new URL(url).hostname;
92507
- } catch {
92508
- return url;
92509
- }
92510
- };
92511
- const prodHost = hostOf(opts.prodUrl);
92512
- const candHost = hostOf(opts.candUrl);
92480
+ const prodHost = hostOf2(opts.prodUrl);
92481
+ const candHost = hostOf2(opts.candUrl);
92513
92482
  const out = [];
92514
92483
  for (const entry of listRuns(outputDir)) {
92515
92484
  if (out.length >= limit)
@@ -92524,7 +92493,7 @@ function findComparableRuns(outputDir, opts, limit) {
92524
92493
  continue;
92525
92494
  if (opts.scoreVersion !== undefined && raw.verdict.scoreVersion !== opts.scoreVersion)
92526
92495
  continue;
92527
- if (hostOf(raw.prodUrl ?? "") !== prodHost || hostOf(raw.candUrl ?? "") !== candHost)
92496
+ if (hostOf2(raw.prodUrl ?? "") !== prodHost || hostOf2(raw.candUrl ?? "") !== candHost)
92528
92497
  continue;
92529
92498
  if (opts.modulesRun && opts.modulesRun.length > 0) {
92530
92499
  const candidateModules = raw.verdict?.modulesRun ?? [];
@@ -92559,6 +92528,26 @@ function listRuns(outputDir) {
92559
92528
  }).sort((a, b) => b.id.localeCompare(a.id));
92560
92529
  return entries;
92561
92530
  }
92531
+ function pruneRuns(outputDir, opts) {
92532
+ const prodHost = hostOf2(opts.prodUrl);
92533
+ const candHost = hostOf2(opts.candUrl);
92534
+ const samePair = listRuns(outputDir).filter((entry) => {
92535
+ try {
92536
+ const raw = JSON.parse(readFileSync9(entry.reportPath, "utf8"));
92537
+ return hostOf2(raw.prodUrl ?? "") === prodHost && hostOf2(raw.candUrl ?? "") === candHost;
92538
+ } catch {
92539
+ return false;
92540
+ }
92541
+ });
92542
+ const pruned = [];
92543
+ for (const entry of samePair.slice(opts.keep)) {
92544
+ if (opts.protect.has(entry.id))
92545
+ continue;
92546
+ rmSync(dirname4(entry.reportPath), { recursive: true, force: true });
92547
+ pruned.push(entry.id);
92548
+ }
92549
+ return pruned;
92550
+ }
92562
92551
 
92563
92552
  // src/util/pages.ts
92564
92553
  import chalk6 from "chalk";
@@ -94774,6 +94763,13 @@ async function measureProductCards(page) {
94774
94763
 
94775
94764
  // src/engine/flows/purchase-journey.ts
94776
94765
  var PURCHASE_JOURNEY_TOTAL_STEPS = 9;
94766
+ async function beforeShot(ctx, page, label) {
94767
+ if (!ctx.beforeShots)
94768
+ return;
94769
+ const path = screenshotPath(ctx, label);
94770
+ await screenshotStable(page, { path, fullPage: false });
94771
+ return path;
94772
+ }
94777
94773
  var DEFAULT_ADD_TO_CART_CONFIRM_MS = 3000;
94778
94774
  function resolveAddToCartConfirmMs(rc) {
94779
94775
  const v = rc.addToCartConfirmMs;
@@ -94917,8 +94913,7 @@ async function flowPurchaseJourney(ctx) {
94917
94913
  reportStart(4, "select-variant");
94918
94914
  const t4 = Date.now();
94919
94915
  const beforeUrl4 = page.url();
94920
- const spBefore4 = screenshotPath(ctx, "pj-4-select-variant-before");
94921
- await screenshotStable(page, { path: spBefore4, fullPage: false });
94916
+ const spBefore4 = await beforeShot(ctx, page, "pj-4-select-variant-before");
94922
94917
  const variantResult = await selectVariant(page, ctx);
94923
94918
  let variantLlmAction = null;
94924
94919
  if (variantResult.actions.length === 0 && variantResult.variantRequired && budget.remaining > 0) {
@@ -94985,8 +94980,7 @@ async function flowPurchaseJourney(ctx) {
94985
94980
  if (cepInputPdp) {
94986
94981
  const t5 = Date.now();
94987
94982
  const beforeUrl5 = page.url();
94988
- const spBefore5 = screenshotPath(ctx, "pj-5-shipping-pdp-before");
94989
- await screenshotStable(page, { path: spBefore5, fullPage: false });
94983
+ const spBefore5 = await beforeShot(ctx, page, "pj-5-shipping-pdp-before");
94990
94984
  const ok = await fillCep(page, cepInputPdp, ctx.rc.cep);
94991
94985
  const sp = screenshotPath(ctx, "pj-5-shipping-pdp");
94992
94986
  await screenshotStable(page, { path: sp, fullPage: false });
@@ -95039,8 +95033,7 @@ async function flowPurchaseJourney(ctx) {
95039
95033
  }
95040
95034
  const t6 = Date.now();
95041
95035
  const beforeUrl6 = page.url();
95042
- const spBefore6 = screenshotPath(ctx, "pj-6-add-cart-before");
95043
- await screenshotStable(page, { path: spBefore6, fullPage: false });
95036
+ const spBefore6 = await beforeShot(ctx, page, "pj-6-add-cart-before");
95044
95037
  const cartCountBefore = await readCartCount(page, ctx);
95045
95038
  const drawersBefore = await visibleDrawerSelectors(page, ctx);
95046
95039
  const cartWatch = watchCartMutation(page);
@@ -95127,8 +95120,7 @@ async function flowPurchaseJourney(ctx) {
95127
95120
  reportStart(7, "open-minicart");
95128
95121
  const t7 = Date.now();
95129
95122
  const beforeUrl7 = page.url();
95130
- const spBefore7 = screenshotPath(ctx, "pj-7-minicart-before");
95131
- await screenshotStable(page, { path: spBefore7, fullPage: false });
95123
+ const spBefore7 = await beforeShot(ctx, page, "pj-7-minicart-before");
95132
95124
  let cartOpenMethod = "failed";
95133
95125
  let miniText = "";
95134
95126
  let cartRevealMode = "unknown";
@@ -95272,8 +95264,7 @@ async function flowPurchaseJourney(ctx) {
95272
95264
  if (cepInputCart) {
95273
95265
  const t8 = Date.now();
95274
95266
  const beforeUrl8 = page.url();
95275
- const spBefore8 = screenshotPath(ctx, "pj-8-shipping-cart-before");
95276
- await screenshotStable(page, { path: spBefore8, fullPage: false });
95267
+ const spBefore8 = await beforeShot(ctx, page, "pj-8-shipping-cart-before");
95277
95268
  const ok = await fillCep(page, cepInputCart, ctx.rc.cep);
95278
95269
  const sp8 = screenshotPath(ctx, "pj-8-shipping-cart");
95279
95270
  await screenshotStable(page, { path: sp8, fullPage: false });
@@ -95350,8 +95341,7 @@ async function flowPurchaseJourney(ctx) {
95350
95341
  reportEnd(9, "go-checkout", "skipped", 0, "no checkout button found");
95351
95342
  return { pages, steps };
95352
95343
  }
95353
- const spBefore9 = screenshotPath(ctx, "pj-9-checkout-before");
95354
- await screenshotStable(page, { path: spBefore9, fullPage: false });
95344
+ const spBefore9 = await beforeShot(ctx, page, "pj-9-checkout-before");
95355
95345
  await Promise.race([
95356
95346
  dismissOverlays(page, ctx),
95357
95347
  new Promise((resolve) => setTimeout(resolve, 4000))
@@ -99177,119 +99167,13 @@ function groupIssues(issues) {
99177
99167
  }
99178
99168
  return [...groups.values()].sort((a, b) => SEVERITY_RANK3[a.severity] - SEVERITY_RANK3[b.severity] || b.count - a.count);
99179
99169
  }
99180
-
99181
- // src/report/prompt-builder.ts
99182
- var SEVERITY_ORDER2 = {
99183
- critical: 0,
99184
- high: 1,
99185
- medium: 2,
99186
- low: 3
99187
- };
99188
- var SEVERITY_EMOJI = {
99189
- critical: "\uD83D\uDD34",
99190
- high: "\uD83D\uDFE0",
99191
- medium: "\uD83D\uDFE1",
99192
- low: "⚪"
99193
- };
99194
- function buildLlmPrompt(run, opts = {}) {
99195
- const minSev = opts.minSeverity ?? "low";
99196
- const limit = opts.limit ?? 20;
99197
- const baseIssues = run.topIssues.length > 0 ? run.topIssues : run.issues;
99198
- const filtered = baseIssues.filter((i) => SEVERITY_ORDER2[i.severity] <= SEVERITY_ORDER2[minSev]).sort((a, b) => SEVERITY_ORDER2[a.severity] - SEVERITY_ORDER2[b.severity]).slice(0, limit);
99199
- return buildPromptInner(run, filtered, baseIssues.length);
99200
- }
99201
- function buildPromptInner(run, issues, totalIssues) {
99202
- const v = run.verdict;
99203
- const sections = [];
99204
- sections.push(`# Migration Parity Report — ${run.id}
99205
-
99206
- You are reviewing the result of an automated E2E parity test between two versions of a site:
99207
-
99208
- - **prod (source of truth):** ${run.prodUrl} — running the old framework (Deno Fresh + Preact)
99209
- - **cand (candidate):** ${run.candUrl} — migrated version on the new stack (TanStack Start + React + Cloudflare Workers)
99210
-
99211
- The test ran flows \`${run.flows.join(", ")}\` in viewports \`${run.viewports.join(", ")}\` using CEP \`${run.cep}\`. Total duration: ${(run.durationMs / 1000).toFixed(1)}s.
99212
-
99213
- ## Verdict
99214
-
99215
- - **Status:** ${v.status.toUpperCase()}
99216
- - **Parity score:** ${v.score}/100
99217
- - **Issues:** ${v.critical} critical · ${v.high} high · ${v.medium} medium · ${v.low} low
99218
- - **Checks:** ${v.checksRun} run (${v.checksPassed} pass · ${v.checksFailed} fail · ${v.checksSkipped} skipped)
99219
-
99220
- The cand version must behave as close as possible to prod. Every divergence below is a regression unless explicitly intentional in the migration. Your job is to help me decide which to fix first and how.
99221
-
99222
- ---
99223
-
99224
- ## Top ${issues.length} of ${totalIssues} issues (ranked by severity)
99225
- `);
99226
- if (issues.length === 0) {
99227
- sections.push(`
99228
- _No issues at or above the requested severity._
99229
- `);
99230
- } else {
99231
- for (const [idx, issue] of issues.entries()) {
99232
- sections.push(renderIssueBlock(idx + 1, issue));
99233
- }
99234
- }
99235
- sections.push(`
99236
- ---
99237
-
99238
- ## What I need from you
99239
-
99240
- For each issue above, in order of severity:
99241
-
99242
- 1. **Diagnose** the most likely root cause specific to a Fresh → TanStack Start migration of a Deco storefront. Common patterns include:
99243
- - \`useDevice\` / \`usePlatform\` hydration mismatch (server returns one, client another)
99244
- - Section not registered in \`registerSections()\` in \`src/setup.ts\`
99245
- - Loader returning a different shape (different VTEX/Shopify endpoint mapping in @decocms/apps-start)
99246
- - Cache profile not covering this route type in \`@decocms/start\` (\`routeCacheDefaults\`)
99247
- - VTEX cookies not propagating (\`vtexFetchWithCookies\` issue) — affects cart, shipping
99248
- - Image helper or CDN URL drift, or lost \`preload\` on hero image
99249
- - \`<head>\` meta tags hoist not running server-side
99250
- 2. **Propose a concrete fix** — file path, what to change, why. If two fixes are plausible, list both.
99251
- 3. **Flag dependencies** between issues (e.g. "fixing #2 will likely fix #5 too").
99252
- 4. **Rank execution order** for me: which fix unlocks the most other fixes? Which is cheapest?
99253
-
99254
- Be terse. Skip preamble. If an issue is ambiguous, say what extra information you'd need from me (a HAR file, a specific page screenshot, a code path) and I'll fetch it.
99255
-
99256
- Don't suggest generic best practices — only fixes tied to specific issues above.
99257
- `);
99258
- return sections.join(`
99259
- `);
99260
- }
99261
- function renderIssueBlock(idx, issue) {
99262
- const lines = [];
99263
- const emoji = SEVERITY_EMOJI[issue.severity];
99264
- lines.push(`### ${idx}. ${emoji} [${issue.severity.toUpperCase()}] ${issue.summary}`, "", `- **Category:** \`${issue.category}\` · **Check:** \`${issue.check}\`${issue.page ? ` · **Page:** \`${humanKey2(issue.page)}\`` : ""}`);
99265
- if (issue.details) {
99266
- lines.push("", "**Details:**", "", "```", issue.details, "```");
99267
- }
99268
- if (issue.reproduction) {
99269
- lines.push("", "**Reproduction:**", "", issue.reproduction);
99270
- }
99271
- if (issue.suggestedFix) {
99272
- lines.push("", "**Suggested fix (preliminary):**", "", issue.suggestedFix);
99273
- }
99274
- if (issue.evidence && issue.evidence.length > 0) {
99275
- const refs = issue.evidence.map((e) => `\`${e.path}\`${e.label ? ` (${e.label})` : ""}`).join(", ");
99276
- lines.push("", `**Evidence:** ${refs}`);
99277
- }
99278
- lines.push("", "");
99279
- return lines.join(`
99280
- `);
99281
- }
99282
- function humanKey2(key) {
99283
- const parts = key.split("::");
99284
- const path = parts[0] ?? key;
99285
- const viewport = parts[1] ?? "";
99286
- const niceName = path === "/" || path === "" ? "Home" : path;
99287
- return viewport ? `${niceName} · ${viewport}` : niceName;
99170
+ function rankTopIssues(issues, limit = 10) {
99171
+ return groupIssues(issues).sort((a, b) => SEVERITY_RANK3[a.severity] - SEVERITY_RANK3[b.severity] || b.pages.length - a.pages.length || b.count - a.count).slice(0, limit).map((g) => g.sample);
99288
99172
  }
99289
99173
 
99290
99174
  // src/report/visual-prompt-builder.ts
99291
99175
  import { relative as relative4 } from "node:path";
99292
- var SEVERITY_ORDER3 = {
99176
+ var SEVERITY_ORDER2 = {
99293
99177
  critical: 0,
99294
99178
  high: 1,
99295
99179
  medium: 2,
@@ -99312,7 +99196,7 @@ function pageMaxSeverity(page) {
99312
99196
  const sevs = severities(page);
99313
99197
  if (sevs.length === 0)
99314
99198
  return null;
99315
- return sevs.reduce((best, s) => SEVERITY_ORDER3[s] < SEVERITY_ORDER3[best] ? s : best);
99199
+ return sevs.reduce((best, s) => SEVERITY_ORDER2[s] < SEVERITY_ORDER2[best] ? s : best);
99316
99200
  }
99317
99201
  function buildVisualPrompt(run, runDir, opts = {}) {
99318
99202
  const minSev = opts.minSeverity ?? "low";
@@ -99327,7 +99211,7 @@ function buildVisualPrompt(run, runDir, opts = {}) {
99327
99211
  }
99328
99212
  const rank = (p) => {
99329
99213
  const sev = pageMaxSeverity(p);
99330
- return sev ? SEVERITY_ORDER3[sev] : p.verdict === "failed" ? 4 : 99;
99214
+ return sev ? SEVERITY_ORDER2[sev] : p.verdict === "failed" ? 4 : 99;
99331
99215
  };
99332
99216
  const pages = summary.results.filter((p) => {
99333
99217
  if (includePassed)
@@ -99335,7 +99219,7 @@ function buildVisualPrompt(run, runDir, opts = {}) {
99335
99219
  if (p.verdict === "failed")
99336
99220
  return true;
99337
99221
  const sev = pageMaxSeverity(p);
99338
- return sev !== null && SEVERITY_ORDER3[sev] <= SEVERITY_ORDER3[minSev];
99222
+ return sev !== null && SEVERITY_ORDER2[sev] <= SEVERITY_ORDER2[minSev];
99339
99223
  }).sort((a, b) => rank(a) - rank(b));
99340
99224
  if (pages.length === 0) {
99341
99225
  sections.push(`_All ${summary.pagesChecked} compared pages are identical to prod._`);
@@ -99514,7 +99398,6 @@ var TAB_HELP = {
99514
99398
  vitals: "Web Vitals (LCP / FCP / TTFB / INP / CLS) per page, prod vs cand. Δ green = cand better; Δ red = regression. Mobile is the default measurement viewport.",
99515
99399
  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.",
99516
99400
  checks: "Every check that ran in this run, with pass/fail status, duration, and one-line summary. Useful for narrowing down which check produced a confusing issue.",
99517
- prompt: "Copy-pasteable Markdown prompt that you can drop into any LLM (Claude, ChatGPT, etc.) to get a prioritized fix list. Includes issue context + migration-specific hints.",
99518
99401
  pages: "Every URL parity actually captured during the run, with status code and viewport. Use this to confirm coverage when a check reports something unexpected.",
99519
99402
  console: "JS console errors and network failures that fired on cand but not on prod. New errors are usually hydration mismatches, missing API endpoints, or broken third-party scripts.",
99520
99403
  network: "Every request captured on cand: type, status, size, cache decision. Sortable + filterable. Use this to spot bundle bloat or unexpected third-party calls.",
@@ -100742,22 +100625,6 @@ function renderSeoIssuesCard(issues, runDir) {
100742
100625
  ${issues.map((i) => renderIssue2(i, runDir)).join("")}
100743
100626
  </div>`;
100744
100627
  }
100745
- function renderPromptPanel(run) {
100746
- const md = buildLlmPrompt(run, { limit: 20 });
100747
- const charCount = md.length;
100748
- return `
100749
- <div class="card">
100750
- <h2>LLM prompt</h2>
100751
- <div class="hint">Ready to paste into Claude / ChatGPT / any chat. Lists ranked issues + migration context + specific diagnose-and-fix instructions.</div>
100752
- <div class="prompt-toolbar">
100753
- <button id="prompt-copy">\uD83D\uDCCB Copy markdown</button>
100754
- <button class="secondary" id="prompt-download">⬇ Download .md</button>
100755
- <span class="feedback" id="prompt-feedback"></span>
100756
- <div class="right">${charCount.toLocaleString("en-US")} chars · ${(charCount / 1024).toFixed(1)} KB</div>
100757
- </div>
100758
- <div class="prompt-md" id="prompt-md">${escapeHtml(md)}</div>
100759
- </div>`;
100760
- }
100761
100628
  function buildNav(run) {
100762
100629
  const vd = run.visualDiff;
100763
100630
  const entries = [
@@ -100786,7 +100653,6 @@ function buildNav(run) {
100786
100653
  { tab: "vitals", label: "Vitals", icon: "\uD83D\uDCCA" },
100787
100654
  { tab: "cache", label: "Cache", icon: "\uD83D\uDCBE" },
100788
100655
  { tab: "checks", label: "Checks", icon: "✓", count: run.checks.length },
100789
- { tab: "prompt", label: "Prompt LLM", icon: "\uD83E\uDD16" },
100790
100656
  { tab: "pages", label: "Pages", icon: "\uD83D\uDCC4" },
100791
100657
  { tab: "console", label: "Console", icon: "\uD83D\uDD27" },
100792
100658
  { tab: "network", label: "Network", icon: "\uD83C\uDF10" }
@@ -100871,7 +100737,6 @@ function renderHtmlReport(run, runDir) {
100871
100737
  ${tabHelp(TAB_HELP.checks)}
100872
100738
  ${renderChecksTable(run)}
100873
100739
  </section>
100874
- <section class="panel" data-panel="prompt">${tabHelp(TAB_HELP.prompt)}${renderPromptPanel(run)}</section>
100875
100740
  <section class="panel" data-panel="pages">
100876
100741
  ${tabHelp(TAB_HELP.pages)}
100877
100742
  ${renderPagesTable2(run)}
@@ -101922,7 +101787,7 @@ import chalk14 from "chalk";
101922
101787
  // src/server/cockpit.ts
101923
101788
  import { readFileSync as readFileSync23 } from "node:fs";
101924
101789
  import { createServer as createServer2 } from "node:http";
101925
- import { dirname as dirname5, join as join24, resolve as resolve10 } from "node:path";
101790
+ import { dirname as dirname6, join as join24, resolve as resolve10 } from "node:path";
101926
101791
 
101927
101792
  // src/server/cockpit-actions.ts
101928
101793
  import { spawn as spawn2 } from "node:child_process";
@@ -102966,13 +102831,13 @@ import {
102966
102831
  readdirSync as readdirSync5,
102967
102832
  realpathSync,
102968
102833
  renameSync as renameSync2,
102969
- rmSync,
102834
+ rmSync as rmSync2,
102970
102835
  statSync,
102971
102836
  symlinkSync,
102972
102837
  unlinkSync as unlinkSync3,
102973
102838
  writeFileSync as writeFileSync20
102974
102839
  } from "node:fs";
102975
- import { dirname as dirname4, join as join22, resolve as resolve8 } from "node:path";
102840
+ import { dirname as dirname5, join as join22, resolve as resolve8 } from "node:path";
102976
102841
  import { fileURLToPath } from "node:url";
102977
102842
  var VIEWPORT = {
102978
102843
  mobile: { width: 412, height: 839 },
@@ -102987,7 +102852,7 @@ function validTaskId(id) {
102987
102852
  return /^[\w-]{6,64}$/.test(id);
102988
102853
  }
102989
102854
  function pluginDir() {
102990
- const root = resolve8(dirname4(fileURLToPath(import.meta.url)), "../../../..");
102855
+ const root = resolve8(dirname5(fileURLToPath(import.meta.url)), "../../../..");
102991
102856
  return existsSync17(join22(root, ".claude-plugin", "plugin.json")) ? root : null;
102992
102857
  }
102993
102858
  function targetDir(planDir) {
@@ -102996,7 +102861,7 @@ function targetDir(planDir) {
102996
102861
  if (typeof state?.target?.dir === "string" && existsSync17(state.target.dir))
102997
102862
  return state.target.dir;
102998
102863
  } catch {}
102999
- return dirname4(resolve8(planDir));
102864
+ return dirname5(resolve8(planDir));
103000
102865
  }
103001
102866
  function withPath(base, path) {
103002
102867
  try {
@@ -103786,7 +103651,7 @@ function autoMergePrs(planDir) {
103786
103651
  writeFileSync20(join22(dir, "pr-merge.json"), JSON.stringify({ at, ok: false, error: err.message.split(`
103787
103652
  `)[0] }));
103788
103653
  }
103789
- rmSync(join22(dir, "pr.json"), { force: true });
103654
+ rmSync2(join22(dir, "pr.json"), { force: true });
103790
103655
  } else if (pr.checks.failed > 0 && !existsSync17(join22(dir, "ci-retry.json"))) {
103791
103656
  writeFileSync20(join22(dir, "ci-retry.json"), JSON.stringify({ at, failing: pr.checks.failing }));
103792
103657
  retryTask(planDir, t.id, `CI failed on PR #${pr.number}: ${pr.checks.failing.join(", ")}.${waivers.length ? ` Not waivable: ${waivers.filter((w) => !w.waived).map((w) => w.why).join("; ")}.` : ""} Read the failing job logs, fix on the same branch, push, wait for every check, then merge.`);
@@ -103809,7 +103674,7 @@ function prInfo(branch, repo, dir, ended, fresh = false) {
103809
103674
  encoding: "utf8",
103810
103675
  timeout: 1e4,
103811
103676
  stdio: ["ignore", "pipe", "ignore"],
103812
- env: { ...process.env, ...ghEnv(getSettings(dirname4(dirname4(dir))).githubUser) }
103677
+ env: { ...process.env, ...ghEnv(getSettings(dirname5(dirname5(dir))).githubUser) }
103813
103678
  });
103814
103679
  const j = JSON.parse(out);
103815
103680
  info = {
@@ -104003,7 +103868,7 @@ function readTask(planDir, id) {
104003
103868
  const branch = verdict?.branch ?? fr.branch ?? null;
104004
103869
  let delivery = null;
104005
103870
  if (branch) {
104006
- const repo = task.worktree && existsSync17(task.worktree) ? task.worktree : targetDir(dirname4(dirname4(dir)));
103871
+ const repo = task.worktree && existsSync17(task.worktree) ? task.worktree : targetDir(dirname5(dirname5(dir)));
104007
103872
  const baseSha = task.base?.sha ?? fr.base;
104008
103873
  const git = (...a) => {
104009
103874
  try {
@@ -104608,7 +104473,7 @@ function targetDirOf(planDir) {
104608
104473
  if (typeof st?.target?.dir === "string")
104609
104474
  return st.target.dir;
104610
104475
  } catch {}
104611
- return dirname5(resolve10(planDir));
104476
+ return dirname6(resolve10(planDir));
104612
104477
  }
104613
104478
 
104614
104479
  // src/commands/cockpit.ts
@@ -104924,7 +104789,7 @@ async function contentFreshnessCommand(opts) {
104924
104789
 
104925
104790
  // src/commands/css-modules.ts
104926
104791
  import { readFileSync as readFileSync24, readdirSync as readdirSync6 } from "node:fs";
104927
- import { basename as basename3, dirname as dirname6, join as join25, resolve as resolve12 } from "node:path";
104792
+ import { basename as basename3, dirname as dirname7, join as join25, resolve as resolve12 } from "node:path";
104928
104793
  import chalk18 from "chalk";
104929
104794
  var SKIP_DIRS2 = new Set(["node_modules", ".git", ".next", ".faststore", "dist", "build"]);
104930
104795
  var MODULE_RE = /\.module\.(scss|sass|css)$/;
@@ -104952,7 +104817,7 @@ function scanCssModules(root) {
104952
104817
  scan.modules++;
104953
104818
  const classes = declaredClasses(readFileSync24(mod, "utf8"));
104954
104819
  const modName = basename3(mod);
104955
- for (const file of components.filter((c) => dirname6(c) === dirname6(mod))) {
104820
+ for (const file of components.filter((c) => dirname7(c) === dirname7(mod))) {
104956
104821
  const src = readFileSync24(file, "utf8");
104957
104822
  const imp = src.match(new RegExp(`import\\s+(\\w+)\\s+from\\s+["'][^"']*${modName.replace(/\./g, "\\.")}["']`));
104958
104823
  if (!imp)
@@ -108461,7 +108326,7 @@ async function e2eCommand(opts) {
108461
108326
  const ignore = loadParityIgnore();
108462
108327
  const learned = loadLearned();
108463
108328
  const learnedBefore = JSON.stringify(learned);
108464
- const host = hostOf2(opts.url);
108329
+ const host = hostOf3(opts.url);
108465
108330
  const primaryViewport = viewports[0] ?? "mobile";
108466
108331
  const failOn = (opts.failOn || "critical,high").split(",").map((s) => s.trim()).filter(Boolean);
108467
108332
  const runId = newRunId();
@@ -108769,7 +108634,7 @@ async function collectFlowVideos(flowVideos, videosDir, viewport) {
108769
108634
  entry.cap.videoPaths = paths;
108770
108635
  }
108771
108636
  }
108772
- function hostOf2(url) {
108637
+ function hostOf3(url) {
108773
108638
  try {
108774
108639
  return new URL(url).hostname;
108775
108640
  } catch {
@@ -108831,11 +108696,11 @@ import chalk20 from "chalk";
108831
108696
 
108832
108697
  // src/events.ts
108833
108698
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync16 } from "node:fs";
108834
- import { dirname as dirname7, join as join28 } from "node:path";
108699
+ import { dirname as dirname8, join as join28 } from "node:path";
108835
108700
  function emitEvent(dir, type, data = {}) {
108836
108701
  try {
108837
108702
  const file = join28(dir, "events.jsonl");
108838
- mkdirSync16(dirname7(file), { recursive: true });
108703
+ mkdirSync16(dirname8(file), { recursive: true });
108839
108704
  const event = { ts: new Date().toISOString(), type, ...data };
108840
108705
  appendFileSync2(file, `${JSON.stringify(event)}
108841
108706
  `);
@@ -110315,7 +110180,7 @@ function formatPatch(patch) {
110315
110180
 
110316
110181
  // src/commands/ios.ts
110317
110182
  import { execFileSync as execFileSync4 } from "node:child_process";
110318
- import { existsSync as existsSync21, mkdirSync as mkdirSync20, readFileSync as readFileSync27, rmSync as rmSync2, writeFileSync as writeFileSync26 } from "node:fs";
110183
+ import { existsSync as existsSync21, mkdirSync as mkdirSync20, readFileSync as readFileSync27, rmSync as rmSync3, writeFileSync as writeFileSync26 } from "node:fs";
110319
110184
  import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
110320
110185
  import { join as join32, resolve as resolve15 } from "node:path";
110321
110186
  import chalk25 from "chalk";
@@ -110698,9 +110563,9 @@ async function iosCommand(opts) {
110698
110563
  simctl("shutdown", device.udid);
110699
110564
  } catch {}
110700
110565
  }
110701
- rmSync2(scratch, { recursive: true, force: true });
110566
+ rmSync3(scratch, { recursive: true, force: true });
110702
110567
  if (existsSync21(LOCK) && Number(readFileSync27(LOCK, "utf8")) === process.pid)
110703
- rmSync2(LOCK);
110568
+ rmSync3(LOCK);
110704
110569
  }
110705
110570
  const missing = Object.entries(found).filter(([, v]) => v !== true).map(([k]) => k);
110706
110571
  let diff = null;
@@ -110819,7 +110684,8 @@ async function journeyCommand(opts) {
110819
110684
  platform,
110820
110685
  recoveryBudget: 3,
110821
110686
  onStep: onStepFor(viewport, side),
110822
- acceptProdQuirks: opts.acceptProdQuirks
110687
+ acceptProdQuirks: opts.acceptProdQuirks,
110688
+ beforeShots: true
110823
110689
  });
110824
110690
  return cap;
110825
110691
  } finally {
@@ -111824,11 +111690,11 @@ import { resolve as resolve17 } from "node:path";
111824
111690
 
111825
111691
  // src/util/version.ts
111826
111692
  import { readFileSync as readFileSync29 } from "node:fs";
111827
- import { dirname as dirname8, resolve as resolve16 } from "node:path";
111693
+ import { dirname as dirname9, resolve as resolve16 } from "node:path";
111828
111694
  import { fileURLToPath as fileURLToPath2 } from "node:url";
111829
111695
  function getPackageVersion() {
111830
111696
  try {
111831
- const here = dirname8(fileURLToPath2(import.meta.url));
111697
+ const here = dirname9(fileURLToPath2(import.meta.url));
111832
111698
  for (const up of ["..", "../..", "../../.."]) {
111833
111699
  try {
111834
111700
  const pkgPath = resolve16(here, up, "package.json");
@@ -112220,7 +112086,7 @@ async function mcpCommand(opts) {
112220
112086
  }
112221
112087
 
112222
112088
  // src/commands/migrate.ts
112223
- import { existsSync as existsSync28, mkdirSync as mkdirSync22, readFileSync as readFileSync35, rmSync as rmSync3, writeFileSync as writeFileSync31 } from "node:fs";
112089
+ import { existsSync as existsSync28, mkdirSync as mkdirSync22, readFileSync as readFileSync35, rmSync as rmSync4, writeFileSync as writeFileSync31 } from "node:fs";
112224
112090
  import { relative as relative5, resolve as resolve19 } from "node:path";
112225
112091
  import chalk31 from "chalk";
112226
112092
  import open2 from "open";
@@ -114612,13 +114478,13 @@ async function captureViewportVariants(browser, url, extraViewports, captured, r
114612
114478
  const dir = resolve19(componentDir, vp);
114613
114479
  const d = deltas.find((x) => x.viewport === vp);
114614
114480
  if (!d || d.absent || d.failed)
114615
- rmSync3(dir, { recursive: true, force: true });
114481
+ rmSync4(dir, { recursive: true, force: true });
114616
114482
  if (!d)
114617
114483
  continue;
114618
114484
  if (d.html !== undefined)
114619
114485
  writeFileSync31(resolve19(dir, "component.html"), d.html, "utf8");
114620
114486
  if (!d.keepScreenshot)
114621
- rmSync3(resolve19(dir, "screenshot.png"), { force: true });
114487
+ rmSync4(resolve19(dir, "screenshot.png"), { force: true });
114622
114488
  variants.push({
114623
114489
  viewport: vp,
114624
114490
  ...d.absent ? { absent: true } : {},
@@ -115829,7 +115695,7 @@ import { join as join45 } from "node:path";
115829
115695
  import chalk35 from "chalk";
115830
115696
 
115831
115697
  // src/commands/run.ts
115832
- import { existsSync as existsSync29, readFileSync as readFileSync38 } from "node:fs";
115698
+ import { existsSync as existsSync29, readFileSync as readFileSync38, rmSync as rmSync5 } from "node:fs";
115833
115699
  import { join as join44 } from "node:path";
115834
115700
  import chalk34 from "chalk";
115835
115701
  import ora8 from "ora";
@@ -115928,113 +115794,6 @@ function readLine2(prompt) {
115928
115794
  });
115929
115795
  }
115930
115796
 
115931
- // src/llm/aggregate-issues.ts
115932
- init_client();
115933
- var REPORT_ISSUES_TOOL = {
115934
- name: "report_issues",
115935
- description: "Report a prioritized list of aggregated issues from the parity run.",
115936
- input_schema: {
115937
- type: "object",
115938
- properties: {
115939
- issues: {
115940
- type: "array",
115941
- items: {
115942
- type: "object",
115943
- properties: {
115944
- id: { type: "string" },
115945
- severity: { type: "string", enum: ["critical", "high", "medium", "low"] },
115946
- category: {
115947
- type: "string",
115948
- enum: ["functional", "visual", "performance", "seo", "console", "network"]
115949
- },
115950
- page: { type: "string" },
115951
- check: { type: "string" },
115952
- summary: { type: "string" },
115953
- details: { type: "string" },
115954
- reproduction: { type: "string" },
115955
- suggestedFix: { type: "string" }
115956
- },
115957
- required: ["id", "severity", "category", "check", "summary"]
115958
- }
115959
- }
115960
- },
115961
- required: ["issues"]
115962
- }
115963
- };
115964
- async function aggregateIssues(input) {
115965
- if (!isLlmAvailable())
115966
- return fallbackAggregate(input);
115967
- const failedChecks = input.checks.filter((c) => c.status === "fail" || c.status === "warn");
115968
- if (failedChecks.length === 0)
115969
- return [];
115970
- const rawIssues = input.checks.flatMap((c) => c.issues);
115971
- const userContent = JSON.stringify({
115972
- run: {
115973
- id: input.runId,
115974
- prod: input.prodUrl,
115975
- cand: input.candUrl,
115976
- viewports: input.viewports,
115977
- flows: input.flows
115978
- },
115979
- checks_summary: failedChecks.map((c) => ({
115980
- name: c.name,
115981
- status: c.status,
115982
- severity: c.severity,
115983
- summary: c.summary,
115984
- issueCount: c.issues.length,
115985
- data: c.data
115986
- })),
115987
- raw_issues: rawIssues.map((i) => ({
115988
- id: i.id,
115989
- severity: i.severity,
115990
- category: i.category,
115991
- page: i.page,
115992
- check: i.check,
115993
- summary: i.summary,
115994
- details: i.details
115995
- }))
115996
- }, null, 2);
115997
- const parsed = await callTool({
115998
- feature: "issue-aggregation",
115999
- systemPrompt: ISSUE_AGGREGATOR_SYSTEM_PROMPT,
116000
- userText: `Analise os resultados abaixo e produza issues priorizadas via report_issues.
116001
-
116002
- ${userContent}`,
116003
- maxTokens: 4096,
116004
- timeoutMs: input.timeoutMs,
116005
- tool: {
116006
- name: REPORT_ISSUES_TOOL.name,
116007
- description: REPORT_ISSUES_TOOL.description,
116008
- inputSchema: REPORT_ISSUES_TOOL.input_schema
116009
- }
116010
- });
116011
- if (!parsed)
116012
- return fallbackAggregate(input);
116013
- return (parsed.issues ?? []).filter((i) => i.id && i.severity && i.category && i.check && i.summary).map((i) => ({
116014
- id: i.id,
116015
- severity: i.severity,
116016
- category: i.category,
116017
- page: i.page,
116018
- check: i.check,
116019
- summary: i.summary,
116020
- details: i.details,
116021
- reproduction: i.reproduction,
116022
- suggestedFix: i.suggestedFix,
116023
- evidence: []
116024
- }));
116025
- }
116026
- function fallbackAggregate(input) {
116027
- const seen = new Map;
116028
- for (const c of input.checks) {
116029
- for (const i of c.issues) {
116030
- if (!seen.has(i.id))
116031
- seen.set(i.id, i);
116032
- }
116033
- }
116034
- const order = { critical: 0, high: 1, medium: 2, low: 3 };
116035
- return [...seen.values()].sort((a, b) => order[a.severity] - order[b.severity]).slice(0, 10);
116036
- }
116037
-
116038
115797
  // src/commands/run.ts
116039
115798
  init_client();
116040
115799
 
@@ -116680,16 +116439,10 @@ async function runCommand(rawOpts) {
116680
116439
  rc.addToCartConfirmMs = opts.addToCartTimeout;
116681
116440
  }
116682
116441
  const ignore = loadParityIgnore();
116683
- const llmTimeoutRaw = opts.llmTimeout ?? 60;
116684
- if (!Number.isFinite(llmTimeoutRaw)) {
116685
- console.error(chalk34.red(` --llm-timeout inválido: "${opts.llmTimeout}" não é um número`));
116686
- return 2;
116687
- }
116688
- const llmTimeoutSec = Math.max(5, Math.floor(llmTimeoutRaw));
116689
116442
  if (isLlmAvailable()) {
116690
- console.log(chalk34.dim(` llm: ${providerLabel()} (timeout=${llmTimeoutSec}s)`));
116443
+ console.log(chalk34.dim(` llm: ${providerLabel()}`));
116691
116444
  } else {
116692
- console.log(chalk34.dim(" llm: offline (LLM keys ausentes — agregação heurística)"));
116445
+ console.log(chalk34.dim(" llm: offline (LLM keys ausentes — selector discovery pulado)"));
116693
116446
  }
116694
116447
  if (isInteractiveMode()) {
116695
116448
  console.log(chalk34.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
@@ -116715,7 +116468,7 @@ async function runCommand(rawOpts) {
116715
116468
  console.log(chalk34.dim(` Detected platform: ${platform}`));
116716
116469
  }
116717
116470
  }
116718
- const prodHost = hostOf3(opts.prod);
116471
+ const prodHost = hostOf4(opts.prod);
116719
116472
  let promotedCount = 0;
116720
116473
  let deprecatedCount = 0;
116721
116474
  const wantsAutoSelectors = opts.autoSelectors !== false && isLlmAvailable();
@@ -116864,7 +116617,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
116864
116617
  if (result.failed.length === 0) {
116865
116618
  warmupSpinner.succeed(`Warmup ok — ${result.succeeded}/${result.attempted} workers serviram resposta fresca`);
116866
116619
  } else if (result.succeeded > 0) {
116867
- const failureSummary = result.failed.slice(0, 3).map((f) => `${f.viewport}/${hostOf3(f.url)} (${f.reason})`).join("; ");
116620
+ const failureSummary = result.failed.slice(0, 3).map((f) => `${f.viewport}/${hostOf4(f.url)} (${f.reason})`).join("; ");
116868
116621
  warmupSpinner.warn(`Warmup parcial — ${result.succeeded}/${result.attempted} ok; ${result.failed.length} falha(s): ${failureSummary}`);
116869
116622
  } else {
116870
116623
  const firstReason = result.failed[0]?.reason ?? "unknown";
@@ -116874,7 +116627,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
116874
116627
  const traceEnabled = process.env.PARITY_TRACE === "1";
116875
116628
  const runOneSide = async (viewport, side) => {
116876
116629
  const baseUrl = side === "prod" ? opts.prod : opts.cand;
116877
- const harPath = join44(paths.harDir, `${viewport}-${side}.har`);
116630
+ const harEnabled = process.env.PARITY_HAR === "1";
116631
+ const harPath = harEnabled ? join44(paths.harDir, `${viewport}-${side}.har`) : undefined;
116878
116632
  const tracePath = traceEnabled ? join44(paths.tracesDir, `${viewport}-${side}.zip`) : null;
116879
116633
  const ctx = await newContext(browser, {
116880
116634
  viewport,
@@ -117231,6 +116985,12 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
117231
116985
  checksHb.stop();
117232
116986
  stampPhase("checks");
117233
116987
  spinner.succeed(`Checks concluídos (${checks.length})`);
116988
+ if (process.env.PARITY_KEEP_ARTIFACTS !== "1") {
116989
+ for (const probe of visualProbes.values()) {
116990
+ if (probe.repeatScreenshot)
116991
+ rmSync5(probe.repeatScreenshot, { force: true });
116992
+ }
116993
+ }
117234
116994
  if (jsonl) {
117235
116995
  for (const c of checks)
117236
116996
  jsonl.write(checkToJsonl(runId, c));
@@ -117239,24 +116999,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
117239
116999
  const acceptance = applyAcceptedFindings(checks, ignore.expectedDivergences ?? []);
117240
117000
  const remainingChecks = withoutAccepted(checks);
117241
117001
  const remainingIssues = remainingChecks.flatMap((c) => c.issues);
117242
- currentPhase = "llm-aggregate";
117243
- setSpinnerLabel(isLlmAvailable() ? `Agregando issues via LLM (${providerLabel()}, timeout=${llmTimeoutSec}s)…` : "Agregando issues (modo offline — sem LLM keys)…");
117244
- spinner.start();
117245
- const llmHb = attachSpinnerHeartbeat(spinner, {
117246
- baseText: isLlmAvailable() ? "Agregando issues via LLM (Sonnet 4.6)…" : "Agregando issues (modo offline)…"
117247
- });
117248
- const topIssues = await aggregateIssues({
117249
- runId,
117250
- prodUrl: opts.prod,
117251
- candUrl: opts.cand,
117252
- viewports,
117253
- flows,
117254
- checks: remainingChecks,
117255
- timeoutMs: llmTimeoutSec * 1000
117256
- });
117257
- llmHb.stop();
117258
- stampPhase("llm-aggregate");
117259
- spinner.succeed(`${topIssues.length} issue(s) priorizada(s)`);
117002
+ const topIssues = rankTopIssues(remainingIssues);
117260
117003
  currentPhase = "report";
117261
117004
  const pagesAnalyzed = pairCaptures(checkCtx.prodPages, checkCtx.candPages).pairs.length;
117262
117005
  const scoreOf = (c, i) => {
@@ -117385,6 +117128,7 @@ ${formatTimingsSummary(runTimings, buildFlowBreakdown(allFlowCaptures))}`);
117385
117128
  ${formatPagePairTable(pagePairs)}`);
117386
117129
  const missed = pagePairs.filter((p) => !p.match).length;
117387
117130
  if (missed > 0) {
117131
+ pruneOldRuns(opts, runId);
117388
117132
  console.log(chalk34.red(`
117389
117133
  ✖ ${missed}/${pagePairs.length} requested page pair(s) were not measured as requested — this report describes other pages; fix the URLs or the capture`));
117390
117134
  }
@@ -117423,6 +117167,30 @@ ${formatPagePairTable(pagePairs)}`);
117423
117167
  jsonl?.close();
117424
117168
  }
117425
117169
  }
117170
+ function pruneOldRuns(opts, runId) {
117171
+ const keep = opts.keepRuns ?? 10;
117172
+ if (!Number.isFinite(keep) || keep <= 0)
117173
+ return;
117174
+ const protect = new Set([runId]);
117175
+ for (const b of listBaselines()) {
117176
+ try {
117177
+ protect.add(JSON.parse(readFileSync38(b.path, "utf8")).fromRunId);
117178
+ } catch {}
117179
+ }
117180
+ try {
117181
+ const pruned = pruneRuns(opts.output, {
117182
+ prodUrl: opts.prod,
117183
+ candUrl: opts.cand,
117184
+ keep,
117185
+ protect
117186
+ });
117187
+ if (pruned.length > 0) {
117188
+ console.log(chalk34.dim(` --keep-runs ${keep}: removed ${pruned.length} older run(s): ${pruned.join(", ")}`));
117189
+ }
117190
+ } catch (err) {
117191
+ console.log(chalk34.yellow(` --keep-runs: pruning skipped (${err.message})`));
117192
+ }
117193
+ }
117426
117194
  function buildPartialRun(args) {
117427
117195
  const allIssues = args.checks.flatMap((c) => c.issues);
117428
117196
  const verdict = computeVerdict(args.checks, allIssues);
@@ -117437,7 +117205,7 @@ function buildPartialRun(args) {
117437
117205
  cep: args.cep,
117438
117206
  durationMs: Date.now() - args.startedAt,
117439
117207
  verdict,
117440
- topIssues: [],
117208
+ topIssues: rankTopIssues(allIssues),
117441
117209
  issues: allIssues,
117442
117210
  checks: args.checks,
117443
117211
  flowCaptures: args.flowCaptures,
@@ -117669,7 +117437,7 @@ function findPdpCapture(flows, side) {
117669
117437
  }
117670
117438
  return;
117671
117439
  }
117672
- function hostOf3(url) {
117440
+ function hostOf4(url) {
117673
117441
  try {
117674
117442
  return new URL(url).hostname;
117675
117443
  } catch {
@@ -117742,7 +117510,7 @@ function printSummary8(run, htmlPath, meta) {
117742
117510
  }
117743
117511
 
117744
117512
  // src/commands/pr.ts
117745
- var SEVERITY_EMOJI2 = {
117513
+ var SEVERITY_EMOJI = {
117746
117514
  critical: "\uD83D\uDD34",
117747
117515
  high: "\uD83D\uDFE0",
117748
117516
  medium: "\uD83D\uDFE1",
@@ -117839,7 +117607,7 @@ function buildPrComment(run, opts) {
117839
117607
  for (const g of topGroups) {
117840
117608
  const i = g.sample;
117841
117609
  const where = g.pages.length > 1 ? ` · ${g.pages.length} pages` : i.page ? ` · page: \`${i.page}\`` : "";
117842
- lines.push(`- ${SEVERITY_EMOJI2[i.severity]} \`${i.category}\` · **${i.summary}** _(check: \`${i.check}\`${where})_`);
117610
+ lines.push(`- ${SEVERITY_EMOJI[i.severity]} \`${i.category}\` · **${i.summary}** _(check: \`${i.check}\`${where})_`);
117843
117611
  }
117844
117612
  }
117845
117613
  lines.push("");
@@ -117852,6 +117620,117 @@ function buildPrComment(run, opts) {
117852
117620
  // src/commands/prompt.ts
117853
117621
  import { existsSync as existsSync31, writeFileSync as writeFileSync33 } from "node:fs";
117854
117622
  import chalk36 from "chalk";
117623
+
117624
+ // src/report/prompt-builder.ts
117625
+ var SEVERITY_ORDER3 = {
117626
+ critical: 0,
117627
+ high: 1,
117628
+ medium: 2,
117629
+ low: 3
117630
+ };
117631
+ var SEVERITY_EMOJI2 = {
117632
+ critical: "\uD83D\uDD34",
117633
+ high: "\uD83D\uDFE0",
117634
+ medium: "\uD83D\uDFE1",
117635
+ low: "⚪"
117636
+ };
117637
+ function buildLlmPrompt(run, opts = {}) {
117638
+ const minSev = opts.minSeverity ?? "low";
117639
+ const limit = opts.limit ?? 20;
117640
+ const baseIssues = run.topIssues.length > 0 ? run.topIssues : run.issues;
117641
+ const filtered = baseIssues.filter((i) => SEVERITY_ORDER3[i.severity] <= SEVERITY_ORDER3[minSev]).sort((a, b) => SEVERITY_ORDER3[a.severity] - SEVERITY_ORDER3[b.severity]).slice(0, limit);
117642
+ return buildPromptInner(run, filtered, baseIssues.length);
117643
+ }
117644
+ function buildPromptInner(run, issues, totalIssues) {
117645
+ const v = run.verdict;
117646
+ const sections = [];
117647
+ sections.push(`# Migration Parity Report — ${run.id}
117648
+
117649
+ You are reviewing the result of an automated E2E parity test between two versions of a site:
117650
+
117651
+ - **prod (source of truth):** ${run.prodUrl} — running the old framework (Deno Fresh + Preact)
117652
+ - **cand (candidate):** ${run.candUrl} — migrated version on the new stack (TanStack Start + React + Cloudflare Workers)
117653
+
117654
+ The test ran flows \`${run.flows.join(", ")}\` in viewports \`${run.viewports.join(", ")}\` using CEP \`${run.cep}\`. Total duration: ${(run.durationMs / 1000).toFixed(1)}s.
117655
+
117656
+ ## Verdict
117657
+
117658
+ - **Status:** ${v.status.toUpperCase()}
117659
+ - **Parity score:** ${v.score}/100
117660
+ - **Issues:** ${v.critical} critical · ${v.high} high · ${v.medium} medium · ${v.low} low
117661
+ - **Checks:** ${v.checksRun} run (${v.checksPassed} pass · ${v.checksFailed} fail · ${v.checksSkipped} skipped)
117662
+
117663
+ The cand version must behave as close as possible to prod. Every divergence below is a regression unless explicitly intentional in the migration. Your job is to help me decide which to fix first and how.
117664
+
117665
+ ---
117666
+
117667
+ ## Top ${issues.length} of ${totalIssues} issues (ranked by severity)
117668
+ `);
117669
+ if (issues.length === 0) {
117670
+ sections.push(`
117671
+ _No issues at or above the requested severity._
117672
+ `);
117673
+ } else {
117674
+ for (const [idx, issue] of issues.entries()) {
117675
+ sections.push(renderIssueBlock(idx + 1, issue));
117676
+ }
117677
+ }
117678
+ sections.push(`
117679
+ ---
117680
+
117681
+ ## What I need from you
117682
+
117683
+ For each issue above, in order of severity:
117684
+
117685
+ 1. **Diagnose** the most likely root cause specific to a Fresh → TanStack Start migration of a Deco storefront. Common patterns include:
117686
+ - \`useDevice\` / \`usePlatform\` hydration mismatch (server returns one, client another)
117687
+ - Section not registered in \`registerSections()\` in \`src/setup.ts\`
117688
+ - Loader returning a different shape (different VTEX/Shopify endpoint mapping in @decocms/apps-start)
117689
+ - Cache profile not covering this route type in \`@decocms/start\` (\`routeCacheDefaults\`)
117690
+ - VTEX cookies not propagating (\`vtexFetchWithCookies\` issue) — affects cart, shipping
117691
+ - Image helper or CDN URL drift, or lost \`preload\` on hero image
117692
+ - \`<head>\` meta tags hoist not running server-side
117693
+ 2. **Propose a concrete fix** — file path, what to change, why. If two fixes are plausible, list both.
117694
+ 3. **Flag dependencies** between issues (e.g. "fixing #2 will likely fix #5 too").
117695
+ 4. **Rank execution order** for me: which fix unlocks the most other fixes? Which is cheapest?
117696
+
117697
+ Be terse. Skip preamble. If an issue is ambiguous, say what extra information you'd need from me (a HAR file, a specific page screenshot, a code path) and I'll fetch it.
117698
+
117699
+ Don't suggest generic best practices — only fixes tied to specific issues above.
117700
+ `);
117701
+ return sections.join(`
117702
+ `);
117703
+ }
117704
+ function renderIssueBlock(idx, issue) {
117705
+ const lines = [];
117706
+ const emoji = SEVERITY_EMOJI2[issue.severity];
117707
+ lines.push(`### ${idx}. ${emoji} [${issue.severity.toUpperCase()}] ${issue.summary}`, "", `- **Category:** \`${issue.category}\` · **Check:** \`${issue.check}\`${issue.page ? ` · **Page:** \`${humanKey2(issue.page)}\`` : ""}`);
117708
+ if (issue.details) {
117709
+ lines.push("", "**Details:**", "", "```", issue.details, "```");
117710
+ }
117711
+ if (issue.reproduction) {
117712
+ lines.push("", "**Reproduction:**", "", issue.reproduction);
117713
+ }
117714
+ if (issue.suggestedFix) {
117715
+ lines.push("", "**Suggested fix (preliminary):**", "", issue.suggestedFix);
117716
+ }
117717
+ if (issue.evidence && issue.evidence.length > 0) {
117718
+ const refs = issue.evidence.map((e) => `\`${e.path}\`${e.label ? ` (${e.label})` : ""}`).join(", ");
117719
+ lines.push("", `**Evidence:** ${refs}`);
117720
+ }
117721
+ lines.push("", "");
117722
+ return lines.join(`
117723
+ `);
117724
+ }
117725
+ function humanKey2(key) {
117726
+ const parts = key.split("::");
117727
+ const path = parts[0] ?? key;
117728
+ const viewport = parts[1] ?? "";
117729
+ const niceName = path === "/" || path === "" ? "Home" : path;
117730
+ return viewport ? `${niceName} · ${viewport}` : niceName;
117731
+ }
117732
+
117733
+ // src/commands/prompt.ts
117855
117734
  function promptCommand(runId, opts) {
117856
117735
  let run;
117857
117736
  try {
@@ -117879,7 +117758,7 @@ function promptCommand(runId, opts) {
117879
117758
 
117880
117759
  // src/commands/qa.ts
117881
117760
  import { existsSync as existsSync35, readFileSync as readFileSync42 } from "node:fs";
117882
- import { basename as basename5, dirname as dirname9, join as join49 } from "node:path";
117761
+ import { basename as basename5, dirname as dirname10, join as join49 } from "node:path";
117883
117762
  import chalk38 from "chalk";
117884
117763
 
117885
117764
  // src/board/sweep-cards.ts
@@ -117893,7 +117772,7 @@ var SEVERITY_RANK6 = {
117893
117772
  medium: 2,
117894
117773
  low: 3
117895
117774
  };
117896
- function hostOf4(url) {
117775
+ function hostOf5(url) {
117897
117776
  try {
117898
117777
  return new URL(url).host;
117899
117778
  } catch {
@@ -118010,7 +117889,7 @@ function evidenceRef(path, run) {
118010
117889
  return `${run.artifactsUrl.replace(/\/$/, "")}/${rel}`;
118011
117890
  }
118012
117891
  function summaryCardTitle(run) {
118013
- return `${QA_PREFIX} Sweep ${hostOf4(run.url)} ${monthOf(run.timestamp)}`;
117892
+ return `${QA_PREFIX} Sweep ${hostOf5(run.url)} ${monthOf(run.timestamp)}`;
118014
117893
  }
118015
117894
  function summaryCardBody(run, filed, belowThreshold) {
118016
117895
  const t = run.totals;
@@ -118217,7 +118096,7 @@ function readSpecs(entries) {
118217
118096
  function evidenceLibraryPath(p, run) {
118218
118097
  const idx = Math.max(p.indexOf("/screenshots/"), p.indexOf("/videos/"));
118219
118098
  const rel = idx >= 0 ? p.slice(idx + 1) : p.split("/").pop() ?? p;
118220
- return `parity-sweep/${hostOf4(run.url)}/${run.runId}/${rel}`;
118099
+ return `parity-sweep/${hostOf5(run.url)}/${run.runId}/${rel}`;
118221
118100
  }
118222
118101
  function cardEvidencePaths(entries) {
118223
118102
  const paths = new Set;
@@ -119027,7 +118906,7 @@ function findPreviousSweep(outputDir, host, excludeRunId) {
119027
118906
  if (r.id === excludeRunId)
119028
118907
  continue;
119029
118908
  const rep = readReport(r.reportPath);
119030
- if (!rep || rep.mode !== "sweep" || hostOf4(rep.url) !== host)
118909
+ if (!rep || rep.mode !== "sweep" || hostOf5(rep.url) !== host)
119031
118910
  continue;
119032
118911
  return { runId: r.id, report: rep };
119033
118912
  }
@@ -119048,7 +118927,7 @@ function annotateTrend(outputDir, runId) {
119048
118927
  const report = readReport(paths.reportJson);
119049
118928
  if (!report)
119050
118929
  return null;
119051
- const prev = findPreviousSweep(outputDir, hostOf4(report.url), runId);
118930
+ const prev = findPreviousSweep(outputDir, hostOf5(report.url), runId);
119052
118931
  if (!prev) {
119053
118932
  report.trend = null;
119054
118933
  writeFileSync34(paths.reportJson, `${JSON.stringify(report, null, 2)}
@@ -119305,7 +119184,7 @@ function countTotals(issues) {
119305
119184
  var DEFAULT_SWEEP_IMAGE = "ghcr.io/decocms/parity";
119306
119185
  var DEFAULT_SWEEP_CRON = "0 6 1 * *";
119307
119186
  function buildScheduleJob(opts) {
119308
- const host = hostOf4(opts.url);
119187
+ const host = hostOf5(opts.url);
119309
119188
  const args = ["sweep", "--url", opts.url, "--board", "studio", "--yes", "--json"];
119310
119189
  if (opts.maxPages)
119311
119190
  args.push("--max-pages", String(opts.maxPages));
@@ -119380,7 +119259,7 @@ async function qaFileCommand(opts) {
119380
119259
  console.error(chalk38.red(`${opts.issues}: ${parsed.error.message}`));
119381
119260
  return 2;
119382
119261
  }
119383
- const dir = dirname9(opts.issues);
119262
+ const dir = dirname10(opts.issues);
119384
119263
  const review = readCardReview(dir);
119385
119264
  for (const i of [...parsed.data, ...review.issues])
119386
119265
  for (const e of i.evidence ?? [])
@@ -119767,7 +119646,7 @@ function renderDeckHtml(model, lang = "en") {
119767
119646
  const pages = [];
119768
119647
  pages.push(`<section class="page cover"><div class="page-inner">
119769
119648
  <div class="eyebrow">${L2("Relatório de migração", "Migration report", lang)}</div>
119770
- <h1 class="cover-h1">${esc3(hostOf5(model.candUrl))}<br/><span class="dim">${esc3(hostOf5(model.prodUrl))}</span> → <span class="lime-ink">${esc3(hostOf5(model.candUrl))}</span></h1>
119649
+ <h1 class="cover-h1">${esc3(hostOf6(model.candUrl))}<br/><span class="dim">${esc3(hostOf6(model.prodUrl))}</span> → <span class="lime-ink">${esc3(hostOf6(model.candUrl))}</span></h1>
119771
119650
  <div class="cover-meta">
119772
119651
  <div><b>${model.score}</b><small>${L2("score parity", "parity score", lang)}</small></div>
119773
119652
  <div><b>${esc3(model.status)}</b><small>${L2("veredito", "verdict", lang)}</small></div>
@@ -119814,7 +119693,7 @@ function renderDeckHtml(model, lang = "en") {
119814
119693
  <style>${DECK_CSS}</style>
119815
119694
  </head><body>
119816
119695
  <div class="nav">
119817
- <b>parity · ${esc3(hostOf5(model.candUrl))}</b>
119696
+ <b>parity · ${esc3(hostOf6(model.candUrl))}</b>
119818
119697
  <span class="spacer"></span>
119819
119698
  <div class="dots"><!-- filled by DECK_JS, one per page --></div>
119820
119699
  <span class="counter"></span>
@@ -119824,7 +119703,7 @@ function renderDeckHtml(model, lang = "en") {
119824
119703
  <script>${DECK_JS}</script>
119825
119704
  </body></html>`;
119826
119705
  }
119827
- function hostOf5(raw) {
119706
+ function hostOf6(raw) {
119828
119707
  try {
119829
119708
  return new URL(raw).host;
119830
119709
  } catch {
@@ -119972,7 +119851,6 @@ var ALL_REPORT_SECTIONS = [
119972
119851
  "vitals",
119973
119852
  "cache",
119974
119853
  "checks",
119975
- "prompt",
119976
119854
  "pages",
119977
119855
  "console",
119978
119856
  "network",
@@ -120029,12 +119907,6 @@ function extractJsonSection(run, section) {
120029
119907
  return extractPagesSlice(run);
120030
119908
  case "console":
120031
119909
  return run.checks.filter((c) => c.name === "console-errors-baseline").flatMap((c) => c.issues);
120032
- case "prompt":
120033
- return {
120034
- runId: run.id,
120035
- topIssuesCount: run.topIssues.length,
120036
- hint: "Use `parity prompt <runId>` to materialize the LLM-ready Markdown."
120037
- };
120038
119910
  case "diff":
120039
119911
  return run.baseline?.delta ?? null;
120040
119912
  }
@@ -120094,6 +119966,10 @@ function pathOf7(url) {
120094
119966
  }
120095
119967
 
120096
119968
  // src/commands/report.ts
119969
+ var REMOVED_SECTIONS = {
119970
+ sidebyside: "use `parity cockpit --prod <url> --cand <url>` for the live prod × cand view.",
119971
+ prompt: "use `parity prompt <runId>` for the LLM-ready Markdown."
119972
+ };
120097
119973
  async function reportCommand(runId, opts) {
120098
119974
  const paths = getRunPaths(opts.output, runId);
120099
119975
  if (opts.deck) {
@@ -120129,8 +120005,9 @@ async function reportCommand(runId, opts) {
120129
120005
  return 0;
120130
120006
  }
120131
120007
  if (opts.section) {
120132
- if (opts.section === "sidebyside") {
120133
- console.error(chalk39.yellow("⚠ section `sidebyside` was removed from the report — use `parity cockpit --prod <url> --cand <url>` for the live prod × cand view."));
120008
+ const movedTo = REMOVED_SECTIONS[opts.section];
120009
+ if (movedTo) {
120010
+ console.error(chalk39.yellow(`⚠ section \`${opts.section}\` was removed from the report — ${movedTo}`));
120134
120011
  return 1;
120135
120012
  }
120136
120013
  if (!ALL_REPORT_SECTIONS.includes(opts.section)) {
@@ -122074,7 +121951,7 @@ program.command("run").description([
122074
121951
  " visual-pages=5, auto-selectors=ON (if LLM), learn=ON, visual-diff=ON,",
122075
121952
  " warmup=OFF, vitals warm=ON, bypass-cache=OFF, fail-on=critical (exit 1 if hit)."
122076
121953
  ].join(`
122077
- `)).option("--prod <url>", "Production URL (source of truth, e.g. Fresh site). Omit for a single site — the run will point you to `parity e2e` (issue #141).").requiredOption("--cand <url>", "Candidate URL (migrated site, e.g. TanStack)").option("--preset <name>", "Bundle of defaults: smoke (fast, ~30s, no LLM) | full (deep audit) | ci (CI-tuned)").option("--flows <list>", "Comma-separated flows: homepage,plp,pdp,purchase-journey", "purchase-journey").option("--viewports <list>", "Comma-separated viewports: mobile,desktop", "mobile,desktop").option("--cep <cep>", "CEP for shipping calculation", "01310-100").option("--add-to-cart-timeout <ms>", "How long (ms) the add-to-cart step polls for a success signal before failing. Default 3000. Raise/lower to match your site's success-toast lifetime (issue #143).", (v) => Number(v)).option("--runs <n>", "Repeat each measurement N times (median)", "1").option("--baseline <name>", "Compare against a saved baseline").option("--output <dir>", "Output directory", "./parity-output").option("--fail-on <severities>", "Comma-separated severities that cause exit 1 (default: critical)", "critical").option("--open", "Open the HTML report after the run completes", false).option("--no-auto-selectors", "Disable LLM-based selector discovery (uses defaults instead)").option("--refresh-selectors", "Bypass selector cache and re-run discovery", false).option("--no-learn", "Don't write to learned-selectors.json (read-only mode)").option("--vitals-pages <n>", "Extra pages from sitemap to crawl for Vitals coverage, beyond what --flows/--pages already cover (default 10). These are auto-sampled and can add significant unrelated noise to findings — pass 0 to scope the run to only the pages you explicitly requested.", (v) => Number(v), 10).option("--max-viewport-concurrency <n>", "How many viewports run concurrently during collect (default 2: mobile+desktop together). Set to 1 if you hit OOM with many viewports.", (v) => Number(v), 2).option("--visual-pages <n>", "Pages to compare visually with the heatmap engine — pixel diff + box-tree diff, no LLM (home + sampled PLPs/PDPs from sitemap, default 5)", (v) => Number(v), 5).option("--pages <list>", 'Comma-separated paths to compare visually (overrides sitemap discovery). E.g. "/,/account,/p/some-product". Use "prod->cand" for a page that lives at DIFFERENT paths on each side (partial migration), e.g. "/encimera-gc60/p->/ar-condicionado-12k/p". Use this when you want deterministic coverage instead of sampled. Scopes the visual-diff + vitals-extra-pages passes ONLY — the flows crawl (--flows, default purchase-journey) discovers its own target pages independently and ignores this flag. To scope which page(s) a flow visits, use --flows to pick a lighter flow and/or set the matching *UrlHint (e.g. plpUrlHint) in .parityrc.json. Issue #178.').option("--pages-file <path>", `Read paths to compare visually from a text file (one entry per line). Lines starting with # are ignored. Accepts the same "prod->cand" pair syntax as --pages. Overrides --pages when both are present. Same visual-diff/vitals-only scope as --pages — see that flag's help. Issue #178.`).option("--no-visual-diff", "Skip the visual diff capture pass entirely").option("--no-cache", "Deprecated, no effect (the visual verdict cache is gone).").option("--clear-cache", "Deprecated, no effect (the visual verdict cache is gone).", false).option("--bypass-cache", "Bypass CDN/edge caches AND the browser's own HTTP cache (CDP cache-disable), forcing a cold-visit fetch. Use right after a deploy to avoid false failures from stale CF edge content, or to approximate Lighthouse/CrUX-comparable TTFB/FCP/LCP numbers — without this flag, parity's vitals are a warm-connection/cache-enabled ('repeat visit') measurement, not a cold first-visit one, so they aren't directly comparable 1:1 to Lighthouse.", false).option("--warmup", "Before measurement, hit each target URL once (per viewport) with a cache-buster so the Worker serves a fresh response. Recommended after deploys.", false).option("--no-warm", "Don't warm each side's URL before measuring vitals. By default every vitals-measured page is loaded once on BOTH sides first, in a throwaway page (same device + cookies), so a cold edge/loader cache on whichever side hit the route first isn't reported as a Web Vitals or CLS regression. Ignored under --bypass-cache, which measures cold on purpose. Distinct from --warmup (a cache-busted homepage hit after a deploy).").option("--accept-prod-quirks", "Demote prod-side cart-empty journey failures (VTEX session quirk) from failed to skipped. The cart-reveal-mode-divergence check still emits critical if prod/cand markup intents differ, so this flag never masks a real regression. See issue #12.", false).option("--cand-is-production", "Cand is the final production domain, not a staging host. Disables staging detection (cand on another host with noindex everywhere), so noindex/nofollow on cand is critical and third-party origins missing on cand are high again.", false).option("--llm-timeout <seconds>", "Hard timeout for the LLM aggregation call (seconds). The run completes in offline mode if the LLM hangs past this. Default: 60.", (v) => Number(v), 60).option("--timeout <minutes>", "Hard wall-clock cap for the whole run (minutes). On expiry, parity writes a partial report and exits 130. Default: 30. Issue #56.", (v) => Number(v), 30).option("--flow <name>", "Alias for --flows when running a single flow (e.g. --flow cart). Issue #53.").option("--json <path|->", "Emit JSON-Lines (one line per check) to the given file path, or '-' for stdout. Schema versioned via leading metadata line. Issue #53.").option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Only affects LLM-generated content (issues, explain, prompts) — the static HTML report stays in English. Issue #67.").option("--llm <provider>", "Force LLM provider: anthropic | openrouter | claude-code | none. Default: auto-detect (anthropic key → openrouter key → local claude CLI → none). Issue #66.").option("--llm-model <overrides>", "Per-feature model override, e.g. visual-diff=claude-opus-5,explain=claude-opus-5. Features: selector-discovery, step-recovery, search-terms, plp-matching, pdp-matching, section-understanding, visual-diff, issue-aggregation, explain, component-detection. Issue #66.").option("--llm-tier-default <tier>", "Override the default tier (haiku | sonnet | opus) for every feature that doesn't have a per-feature override. Issue #66.").option("--llm-model-default <model>", "Force every LLM call to use this exact model ID, ignoring per-feature defaults. Issue #66.").option("--llm-premium", "Bump the reasoning-heavy features (explain/issue-aggregation/visual-diff) to opus. Defaults are sonnet-first for cost/latency (opus blew the 60s timeout on most runs); opt into opus for hard fixes. Issue #256.").option("--no-interactive", "Disable the interactive selector prompt that auto-fires in a TTY without an LLM provider. Use in scripts and CI where stdin is technically a TTY but you don't want to pause. Issue #72.").option("--only <modules>", "Scope the run to these modules and/or single checks (comma-separated). Module names: e2e, seo, visual, vitals, cache, console, html, network. Single-check granularity via `check:<name>`, e.g. `--only e2e,check:cache-coverage`. Run `parity list modules` for the full check/flow mapping. Default: all modules. M3 module selection.").option("--skip <modules>", "Subtract these modules and/or single checks (comma-separated, same syntax as --only) from whatever base set was chosen (all modules, or --only's set if both are given). M3 module selection.").option("--why <text>", "Free-text reason for this run's scope, stored in report.json as `selectionReason`. Purely informational. M3 module selection.").option("--profile <type>", "Site profile: commerce | content. Scopes modules/flows/CEP. `content` (blog/custom site with no storefront) drops the e2e purchase journey, scopes flows to the homepage, and skips CEP. Auto-detected from the platform when omitted. Issues #254/#255.").action(async (opts) => {
121954
+ `)).option("--prod <url>", "Production URL (source of truth, e.g. Fresh site). Omit for a single site — the run will point you to `parity e2e` (issue #141).").requiredOption("--cand <url>", "Candidate URL (migrated site, e.g. TanStack)").option("--preset <name>", "Bundle of defaults: smoke (fast, ~30s, no LLM) | full (deep audit) | ci (CI-tuned)").option("--flows <list>", "Comma-separated flows: homepage,plp,pdp,purchase-journey", "purchase-journey").option("--viewports <list>", "Comma-separated viewports: mobile,desktop", "mobile,desktop").option("--cep <cep>", "CEP for shipping calculation", "01310-100").option("--add-to-cart-timeout <ms>", "How long (ms) the add-to-cart step polls for a success signal before failing. Default 3000. Raise/lower to match your site's success-toast lifetime (issue #143).", (v) => Number(v)).option("--runs <n>", "Repeat each measurement N times (median)", "1").option("--baseline <name>", "Compare against a saved baseline").option("--output <dir>", "Output directory", "./parity-output").option("--fail-on <severities>", "Comma-separated severities that cause exit 1 (default: critical)", "critical").option("--open", "Open the HTML report after the run completes", false).option("--no-auto-selectors", "Disable LLM-based selector discovery (uses defaults instead)").option("--refresh-selectors", "Bypass selector cache and re-run discovery", false).option("--no-learn", "Don't write to learned-selectors.json (read-only mode)").option("--vitals-pages <n>", "Extra pages from sitemap to crawl for Vitals coverage, beyond what --flows/--pages already cover (default 10). These are auto-sampled and can add significant unrelated noise to findings — pass 0 to scope the run to only the pages you explicitly requested.", (v) => Number(v), 10).option("--max-viewport-concurrency <n>", "How many viewports run concurrently during collect (default 2: mobile+desktop together). Set to 1 if you hit OOM with many viewports.", (v) => Number(v), 2).option("--visual-pages <n>", "Pages to compare visually with the heatmap engine — pixel diff + box-tree diff, no LLM (home + sampled PLPs/PDPs from sitemap, default 5)", (v) => Number(v), 5).option("--pages <list>", 'Comma-separated paths to compare visually (overrides sitemap discovery). E.g. "/,/account,/p/some-product". Use "prod->cand" for a page that lives at DIFFERENT paths on each side (partial migration), e.g. "/encimera-gc60/p->/ar-condicionado-12k/p". Use this when you want deterministic coverage instead of sampled. Scopes the visual-diff + vitals-extra-pages passes ONLY — the flows crawl (--flows, default purchase-journey) discovers its own target pages independently and ignores this flag. To scope which page(s) a flow visits, use --flows to pick a lighter flow and/or set the matching *UrlHint (e.g. plpUrlHint) in .parityrc.json. Issue #178.').option("--pages-file <path>", `Read paths to compare visually from a text file (one entry per line). Lines starting with # are ignored. Accepts the same "prod->cand" pair syntax as --pages. Overrides --pages when both are present. Same visual-diff/vitals-only scope as --pages — see that flag's help. Issue #178.`).option("--no-visual-diff", "Skip the visual diff capture pass entirely").option("--no-cache", "Deprecated, no effect (the visual verdict cache is gone).").option("--clear-cache", "Deprecated, no effect (the visual verdict cache is gone).", false).option("--bypass-cache", "Bypass CDN/edge caches AND the browser's own HTTP cache (CDP cache-disable), forcing a cold-visit fetch. Use right after a deploy to avoid false failures from stale CF edge content, or to approximate Lighthouse/CrUX-comparable TTFB/FCP/LCP numbers — without this flag, parity's vitals are a warm-connection/cache-enabled ('repeat visit') measurement, not a cold first-visit one, so they aren't directly comparable 1:1 to Lighthouse.", false).option("--warmup", "Before measurement, hit each target URL once (per viewport) with a cache-buster so the Worker serves a fresh response. Recommended after deploys.", false).option("--no-warm", "Don't warm each side's URL before measuring vitals. By default every vitals-measured page is loaded once on BOTH sides first, in a throwaway page (same device + cookies), so a cold edge/loader cache on whichever side hit the route first isn't reported as a Web Vitals or CLS regression. Ignored under --bypass-cache, which measures cold on purpose. Distinct from --warmup (a cache-busted homepage hit after a deploy).").option("--accept-prod-quirks", "Demote prod-side cart-empty journey failures (VTEX session quirk) from failed to skipped. The cart-reveal-mode-divergence check still emits critical if prod/cand markup intents differ, so this flag never masks a real regression. See issue #12.", false).option("--cand-is-production", "Cand is the final production domain, not a staging host. Disables staging detection (cand on another host with noindex everywhere), so noindex/nofollow on cand is critical and third-party origins missing on cand are high again.", false).option("--llm-timeout <seconds>", "Deprecated, no effect: topIssues is ranked deterministically now, there is no LLM aggregation call to time out.").option("--keep-runs <n>", "After the run, delete all but the n newest runs of this prod/cand host pair under --output (other host pairs, runs without a readable report.json and baseline-referenced runs are never touched). 0 keeps everything. Default: 10.", (v) => Number(v), 10).option("--timeout <minutes>", "Hard wall-clock cap for the whole run (minutes). On expiry, parity writes a partial report and exits 130. Default: 30. Issue #56.", (v) => Number(v), 30).option("--flow <name>", "Alias for --flows when running a single flow (e.g. --flow cart). Issue #53.").option("--json <path|->", "Emit JSON-Lines (one line per check) to the given file path, or '-' for stdout. Schema versioned via leading metadata line. Issue #53.").option("--pt", "Tell the LLM to respond in Brazilian Portuguese. Only affects LLM-generated content (issues, explain, prompts) — the static HTML report stays in English. Issue #67.").option("--llm <provider>", "Force LLM provider: anthropic | openrouter | claude-code | none. Default: auto-detect (anthropic key → openrouter key → local claude CLI → none). Issue #66.").option("--llm-model <overrides>", "Per-feature model override, e.g. visual-diff=claude-opus-5,explain=claude-opus-5. Features: selector-discovery, step-recovery, search-terms, plp-matching, pdp-matching, section-understanding, visual-diff, explain, component-detection. Issue #66.").option("--llm-tier-default <tier>", "Override the default tier (haiku | sonnet | opus) for every feature that doesn't have a per-feature override. Issue #66.").option("--llm-model-default <model>", "Force every LLM call to use this exact model ID, ignoring per-feature defaults. Issue #66.").option("--llm-premium", "Bump the reasoning-heavy features (explain/visual-diff) to opus. Defaults are sonnet-first for cost/latency (opus blew the 60s timeout on most runs); opt into opus for hard fixes. Issue #256.").option("--no-interactive", "Disable the interactive selector prompt that auto-fires in a TTY without an LLM provider. Use in scripts and CI where stdin is technically a TTY but you don't want to pause. Issue #72.").option("--only <modules>", "Scope the run to these modules and/or single checks (comma-separated). Module names: e2e, seo, visual, vitals, cache, console, html, network. Single-check granularity via `check:<name>`, e.g. `--only e2e,check:cache-coverage`. Run `parity list modules` for the full check/flow mapping. Default: all modules. M3 module selection.").option("--skip <modules>", "Subtract these modules and/or single checks (comma-separated, same syntax as --only) from whatever base set was chosen (all modules, or --only's set if both are given). M3 module selection.").option("--why <text>", "Free-text reason for this run's scope, stored in report.json as `selectionReason`. Purely informational. M3 module selection.").option("--profile <type>", "Site profile: commerce | content. Scopes modules/flows/CEP. `content` (blog/custom site with no storefront) drops the e2e purchase journey, scopes flows to the homepage, and skips CEP. Auto-detected from the platform when omitted. Issues #254/#255.").action(async (opts) => {
122078
121955
  if (opts.flow) {
122079
121956
  opts.flows = opts.flow;
122080
121957
  }
@@ -122220,7 +122097,7 @@ program.command("serve").argument("<runId>", "Run ID to serve").description("[de
122220
122097
  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) => {
122221
122098
  process.exit(eventCommand(type, opts));
122222
122099
  });
122223
- 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) => {
122100
+ 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, 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) => {
122224
122101
  process.exit(await reportCommand(runId, {
122225
122102
  output: opts.output,
122226
122103
  section: opts.section,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.35.12",
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.",
3
+ "version": "0.35.14",
4
+ "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {