@decocms/parity 0.26.18 → 0.26.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +351 -233
  2. package/package.json +1 -2
package/dist/cli.js CHANGED
@@ -36865,16 +36865,12 @@ var init_claude_agent_sdk = __esm(() => {
36865
36865
  // src/llm/client.ts
36866
36866
  var exports_client = {};
36867
36867
  __export(exports_client, {
36868
- LLM_MODEL_ANTHROPIC: () => LLM_MODEL_ANTHROPIC,
36869
- LLM_MODEL_OPENROUTER: () => LLM_MODEL_OPENROUTER,
36870
36868
  callMessage: () => callMessage,
36871
36869
  callTool: () => callTool,
36872
36870
  disableLlm: () => disableLlm,
36873
- getLlmLanguage: () => getLlmLanguage,
36874
36871
  getProvider: () => getProvider,
36875
36872
  isLlmAvailable: () => isLlmAvailable,
36876
36873
  providerLabel: () => providerLabel,
36877
- providerName: () => providerName,
36878
36874
  resetLlmState: () => resetLlmState,
36879
36875
  setForcedProvider: () => setForcedProvider,
36880
36876
  setLlmLanguage: () => setLlmLanguage,
@@ -36927,16 +36923,9 @@ function providerLabel() {
36927
36923
  const models = snapshotResolved(p);
36928
36924
  return `${p} (selectors=${models["selector-discovery"]}, visual=${models["visual-diff"]}, fix=${models.explain})`;
36929
36925
  }
36930
- function providerName() {
36931
- const p = getProvider();
36932
- return p ?? "none";
36933
- }
36934
36926
  function setLlmLanguage(lang) {
36935
36927
  llmLanguage = lang;
36936
36928
  }
36937
- function getLlmLanguage() {
36938
- return llmLanguage;
36939
- }
36940
36929
  function withLanguage(userText) {
36941
36930
  if (llmLanguage === "pt") {
36942
36931
  return `${userText}
@@ -37268,12 +37257,10 @@ async function callOpenRouterMessage(params, model, timeoutMs) {
37268
37257
  clear();
37269
37258
  }
37270
37259
  }
37271
- var LLM_MODEL_ANTHROPIC, LLM_MODEL_OPENROUTER, forcedProvider = null, llmDisabled = false, llmLanguage = "en", MAX_CONCURRENT_LLM_CALLS = 3, activeLlmCalls = 0, llmQueue;
37260
+ var forcedProvider = null, llmDisabled = false, llmLanguage = "en", MAX_CONCURRENT_LLM_CALLS = 3, activeLlmCalls = 0, llmQueue;
37272
37261
  var init_client = __esm(() => {
37273
37262
  init_models();
37274
37263
  init_claude_agent_sdk();
37275
- LLM_MODEL_ANTHROPIC = PROVIDER_MODELS.anthropic.sonnet;
37276
- LLM_MODEL_OPENROUTER = PROVIDER_MODELS.openrouter.sonnet;
37277
37264
  llmQueue = [];
37278
37265
  });
37279
37266
 
@@ -37390,12 +37377,8 @@ var init_html_compact = __esm(() => {
37390
37377
  // src/llm/component-refine.ts
37391
37378
  var exports_component_refine = {};
37392
37379
  __export(exports_component_refine, {
37393
- isComponentRefineLlmAvailable: () => isComponentRefineLlmAvailable,
37394
37380
  refineComponentsWithLlm: () => refineComponentsWithLlm
37395
37381
  });
37396
- function isComponentRefineLlmAvailable() {
37397
- return isLlmAvailable();
37398
- }
37399
37382
  async function refineComponentsWithLlm(page, candidates) {
37400
37383
  if (candidates.length === 0)
37401
37384
  return null;
@@ -42155,7 +42138,7 @@ function baselineUnset(name) {
42155
42138
  }
42156
42139
 
42157
42140
  // src/commands/benchmark.ts
42158
- import { writeFileSync as writeFileSync7 } from "node:fs";
42141
+ import { writeFileSync as writeFileSync8 } from "node:fs";
42159
42142
  import { join as join10 } from "node:path";
42160
42143
  import chalk3 from "chalk";
42161
42144
  import ora2 from "ora";
@@ -42531,6 +42514,110 @@ function isLocalhost(rawUrl) {
42531
42514
  }
42532
42515
  }
42533
42516
 
42517
+ // src/engine/interactive-selector-prompt.ts
42518
+ init_client();
42519
+ import { execSync } from "node:child_process";
42520
+ import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "node:fs";
42521
+ import { resolve } from "node:path";
42522
+ import { createInterface } from "node:readline";
42523
+ var forceDisabled = false;
42524
+ function disableInteractive() {
42525
+ forceDisabled = true;
42526
+ }
42527
+ function isInteractiveMode() {
42528
+ if (forceDisabled)
42529
+ return false;
42530
+ if (!process.stdout.isTTY || !process.stdin.isTTY)
42531
+ return false;
42532
+ if (isLlmAvailable())
42533
+ return false;
42534
+ return true;
42535
+ }
42536
+ var PARITYRC_FILENAME = ".parityrc.json";
42537
+ async function promptForSelector(input) {
42538
+ const cwd = input.cwd ?? process.cwd();
42539
+ printContextHeader(input);
42540
+ const selector = await readLine("Selector for this step (or blank to skip): ");
42541
+ if (!selector?.trim()) {
42542
+ console.log(" (no selector entered — continuing without override)");
42543
+ return null;
42544
+ }
42545
+ const trimmed = selector.trim();
42546
+ const rcPath = resolve(cwd, PARITYRC_FILENAME);
42547
+ writeSelectorOverride(rcPath, input.selectorKey, trimmed);
42548
+ console.log(` ✓ wrote selectors.${input.selectorKey} = ${trimmed} → ${rcPath}`);
42549
+ tryOpenInEditor(rcPath);
42550
+ return trimmed;
42551
+ }
42552
+ function buildStructuredError(input) {
42553
+ return {
42554
+ kind: "missing-selector",
42555
+ selectorKey: input.selectorKey,
42556
+ intendedAction: input.intendedAction,
42557
+ alreadyTried: input.alreadyTried,
42558
+ pageUrl: input.pageUrl,
42559
+ htmlSnapshot: input.htmlSnapshot.slice(0, 2000),
42560
+ suggestedRcPath: resolve(input.cwd ?? process.cwd(), PARITYRC_FILENAME)
42561
+ };
42562
+ }
42563
+ function printContextHeader(input) {
42564
+ const bar = "─".repeat(60);
42565
+ console.log("");
42566
+ console.log(bar);
42567
+ console.log(`⚠ Selector missing: ${input.selectorKey}`);
42568
+ console.log(bar);
42569
+ console.log(` step: ${input.intendedAction}`);
42570
+ console.log(` page: ${input.pageUrl}`);
42571
+ if (input.alreadyTried.length > 0) {
42572
+ console.log(` tried: ${input.alreadyTried.slice(0, 5).join(", ")}`);
42573
+ }
42574
+ console.log("");
42575
+ console.log(" HTML snapshot (top of page):");
42576
+ const lines = input.htmlSnapshot.split(`
42577
+ `).slice(0, 25);
42578
+ for (const ln of lines)
42579
+ console.log(` | ${ln}`);
42580
+ if (input.htmlSnapshot.split(`
42581
+ `).length > 25)
42582
+ console.log(" | … (truncated)");
42583
+ console.log("");
42584
+ }
42585
+ function readLine(prompt) {
42586
+ return new Promise((resolveLine) => {
42587
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
42588
+ rl.question(prompt, (answer) => {
42589
+ rl.close();
42590
+ resolveLine(answer);
42591
+ });
42592
+ rl.on("SIGINT", () => {
42593
+ rl.close();
42594
+ resolveLine(null);
42595
+ });
42596
+ });
42597
+ }
42598
+ function writeSelectorOverride(rcPath, key, value) {
42599
+ let current = {};
42600
+ if (existsSync4(rcPath)) {
42601
+ try {
42602
+ const parsed = JSON.parse(readFileSync3(rcPath, "utf8"));
42603
+ if (parsed && typeof parsed === "object")
42604
+ current = parsed;
42605
+ } catch {
42606
+ console.log(` ⚠ existing ${PARITYRC_FILENAME} was not valid JSON; overwriting.`);
42607
+ }
42608
+ }
42609
+ current.selectors = { ...current.selectors ?? {}, [key]: value };
42610
+ writeFileSync5(rcPath, `${JSON.stringify(current, null, 2)}
42611
+ `, "utf8");
42612
+ }
42613
+ function tryOpenInEditor(rcPath) {
42614
+ if (process.platform !== "darwin")
42615
+ return;
42616
+ try {
42617
+ execSync(`open ${JSON.stringify(rcPath)}`, { stdio: "ignore" });
42618
+ } catch {}
42619
+ }
42620
+
42534
42621
  // src/llm/pick-plp.ts
42535
42622
  init_client();
42536
42623
  var PATH_BLOCKLIST = [
@@ -42606,7 +42693,7 @@ ${candidates.map((c, i) => `${i}. "${c.text}" → ${c.href}`).join(`
42606
42693
  }
42607
42694
 
42608
42695
  // src/learned/repo.ts
42609
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync3, renameSync, writeFileSync as writeFileSync5 } from "node:fs";
42696
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync6 } from "node:fs";
42610
42697
  import { dirname as dirname2 } from "node:path";
42611
42698
  import { z as z2 } from "zod";
42612
42699
  var SelectorKey = z2.enum([
@@ -42679,10 +42766,10 @@ function emptyLib() {
42679
42766
  return { schemaVersion: "0.1", platforms: {} };
42680
42767
  }
42681
42768
  function loadLearned(path = DEFAULT_PATH) {
42682
- if (!existsSync4(path))
42769
+ if (!existsSync5(path))
42683
42770
  return emptyLib();
42684
42771
  try {
42685
- const raw = JSON.parse(readFileSync3(path, "utf8"));
42772
+ const raw = JSON.parse(readFileSync4(path, "utf8"));
42686
42773
  return LearnedSelectors.parse(raw);
42687
42774
  } catch (err) {
42688
42775
  console.warn(`[learned] failed to parse ${path}: ${err.message}, starting fresh`);
@@ -42691,10 +42778,10 @@ function loadLearned(path = DEFAULT_PATH) {
42691
42778
  }
42692
42779
  function saveLearned(lib, path = DEFAULT_PATH) {
42693
42780
  const dir = dirname2(path);
42694
- if (dir && dir !== "." && !existsSync4(dir))
42781
+ if (dir && dir !== "." && !existsSync5(dir))
42695
42782
  mkdirSync4(dir, { recursive: true });
42696
42783
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
42697
- writeFileSync5(tmp, `${JSON.stringify(lib, null, 2)}
42784
+ writeFileSync6(tmp, `${JSON.stringify(lib, null, 2)}
42698
42785
  `, "utf8");
42699
42786
  renameSync(tmp, path);
42700
42787
  }
@@ -43223,7 +43310,7 @@ async function screenshotStable(page, opts) {
43223
43310
  stabilizeCarousels(page).catch(() => {
43224
43311
  return;
43225
43312
  }),
43226
- new Promise((resolve) => setTimeout(resolve, 3000))
43313
+ new Promise((resolve2) => setTimeout(resolve2, 3000))
43227
43314
  ]);
43228
43315
  const isJpeg = /\.jpe?g$/i.test(opts.path);
43229
43316
  await page.screenshot({
@@ -43246,7 +43333,7 @@ function dlog2(ctx, msg) {
43246
43333
  function withCap(p, capMs, fallback) {
43247
43334
  return Promise.race([
43248
43335
  p.catch(() => fallback),
43249
- new Promise((resolve) => setTimeout(() => resolve(fallback), capMs))
43336
+ new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
43250
43337
  ]);
43251
43338
  }
43252
43339
  var VARIANT_REQUIRED_TEXT_PATTERNS = [
@@ -43467,6 +43554,34 @@ async function findElement(page, ctx, opts) {
43467
43554
  return { ...recovered, recoveredByLlm: true };
43468
43555
  }
43469
43556
  }
43557
+ if (opts.key) {
43558
+ const supplied = await resolveMissingSelector(page, opts.key, opts.intent, tried);
43559
+ if (supplied) {
43560
+ const el = page.locator(supplied).first();
43561
+ if (await el.isVisible({ timeout: 2000 }).catch(() => false)) {
43562
+ return { locator: el, selector: supplied, recoveredByLlm: false };
43563
+ }
43564
+ }
43565
+ }
43566
+ return null;
43567
+ }
43568
+ var reportedMissing = new Set;
43569
+ async function resolveMissingSelector(page, key, intent, tried) {
43570
+ const input = {
43571
+ selectorKey: key,
43572
+ intendedAction: intent,
43573
+ alreadyTried: tried,
43574
+ pageUrl: page.url(),
43575
+ htmlSnapshot: await page.content().catch(() => "")
43576
+ };
43577
+ if (isInteractiveMode()) {
43578
+ return await promptForSelector(input).catch(() => null);
43579
+ }
43580
+ if (reportedMissing.has(key))
43581
+ return null;
43582
+ reportedMissing.add(key);
43583
+ process.stderr.write(`${JSON.stringify(buildStructuredError(input))}
43584
+ `);
43470
43585
  return null;
43471
43586
  }
43472
43587
  async function attemptRecovery(page, _ctx, stepName, intendedAction, alreadyTried, diagnostics) {
@@ -43902,7 +44017,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43902
44017
  if (viewport === "desktop") {
43903
44018
  try {
43904
44019
  const observedHoverDrawer = await page.evaluate(async () => {
43905
- return await new Promise((resolve) => {
44020
+ return await new Promise((resolve2) => {
43906
44021
  const selectorMatch = (el) => {
43907
44022
  if (!(el instanceof HTMLElement))
43908
44023
  return false;
@@ -43916,13 +44031,13 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43916
44031
  for (const n of Array.from(m.addedNodes)) {
43917
44032
  if (n instanceof Element && selectorMatch(n)) {
43918
44033
  observer.disconnect();
43919
- resolve(true);
44034
+ resolve2(true);
43920
44035
  return;
43921
44036
  }
43922
44037
  }
43923
44038
  if (m.type === "attributes" && m.target instanceof Element && selectorMatch(m.target)) {
43924
44039
  observer.disconnect();
43925
- resolve(true);
44040
+ resolve2(true);
43926
44041
  return;
43927
44042
  }
43928
44043
  }
@@ -43935,7 +44050,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43935
44050
  });
43936
44051
  setTimeout(() => {
43937
44052
  observer.disconnect();
43938
- resolve(false);
44053
+ resolve2(false);
43939
44054
  }, 600);
43940
44055
  });
43941
44056
  });
@@ -44065,7 +44180,7 @@ async function openMinicart(page, trigger, ctx, expectedProductTitle) {
44065
44180
  dlog2(ctx, ` openMinicart: starting — trigger=${trigger.selector} title=${expectedProductTitle?.slice(0, 40) ?? "none"} revealBudget=${revealBudget}ms`);
44066
44181
  await Promise.race([
44067
44182
  dismissOverlays(page, ctx),
44068
- new Promise((resolve) => setTimeout(resolve, 4000))
44183
+ new Promise((resolve2) => setTimeout(resolve2, 4000))
44069
44184
  ]);
44070
44185
  dlog2(ctx, " openMinicart: dismissOverlays done — checking alreadyOpen…");
44071
44186
  await page.waitForTimeout(800);
@@ -44416,10 +44531,10 @@ async function waitForCartMutation(page, ctx, predicate, capMs = 2500) {
44416
44531
  if (predicate(totals))
44417
44532
  return totals;
44418
44533
  if (responseSeen) {
44419
- await new Promise((resolve) => setTimeout(resolve, 300));
44534
+ await new Promise((resolve2) => setTimeout(resolve2, 300));
44420
44535
  return await parseCartTotals(page, ctx);
44421
44536
  }
44422
- await new Promise((resolve) => setTimeout(resolve, 250));
44537
+ await new Promise((resolve2) => setTimeout(resolve2, 250));
44423
44538
  totals = await parseCartTotals(page, ctx);
44424
44539
  }
44425
44540
  return totals;
@@ -45341,7 +45456,7 @@ async function flowPurchaseJourney(ctx) {
45341
45456
  await screenshotStable(page, { path: spBefore9, fullPage: false });
45342
45457
  await Promise.race([
45343
45458
  dismissOverlays(page, ctx),
45344
- new Promise((resolve) => setTimeout(resolve, 4000))
45459
+ new Promise((resolve2) => setTimeout(resolve2, 4000))
45345
45460
  ]);
45346
45461
  let usedSelector = checkoutHit.selector;
45347
45462
  let clickedText = await checkoutHit.locator.innerText().catch(() => "");
@@ -45681,7 +45796,7 @@ async function validateAddToCart(page, ctx, cartCountBefore, beforeUrl) {
45681
45796
 
45682
45797
  // src/engine/lighthouse.ts
45683
45798
  import { spawn } from "node:child_process";
45684
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync4 } from "node:fs";
45799
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "node:fs";
45685
45800
  import { join as join7 } from "node:path";
45686
45801
  var AGENT_A11Y_AUDIT_IDS = [
45687
45802
  "button-name",
@@ -45792,7 +45907,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
45792
45907
  "--quiet",
45793
45908
  "--max-wait-for-load=90000"
45794
45909
  ];
45795
- const { code, stderr } = await new Promise((resolve) => {
45910
+ const { code, stderr } = await new Promise((resolve2) => {
45796
45911
  const proc = spawn("npx", args, {
45797
45912
  shell: true,
45798
45913
  stdio: ["ignore", "ignore", "pipe"],
@@ -45802,12 +45917,12 @@ async function measureLighthouseOnce(url, opts, attempt) {
45802
45917
  proc.stderr.on("data", (chunk) => {
45803
45918
  stderrBuf += chunk.toString();
45804
45919
  });
45805
- proc.on("close", (exitCode) => resolve({ code: exitCode ?? 1, stderr: stderrBuf }));
45806
- proc.on("error", (err) => resolve({ code: 1, stderr: err.message }));
45920
+ proc.on("close", (exitCode) => resolve2({ code: exitCode ?? 1, stderr: stderrBuf }));
45921
+ proc.on("error", (err) => resolve2({ code: 1, stderr: err.message }));
45807
45922
  });
45808
45923
  let report;
45809
45924
  try {
45810
- report = JSON.parse(readFileSync4(outPath, "utf-8"));
45925
+ report = JSON.parse(readFileSync5(outPath, "utf-8"));
45811
45926
  } catch (err) {
45812
45927
  return {
45813
45928
  error: code !== 0 ? `lighthouse exit ${code}: ${stderr.slice(0, 200)}` : `parse failed: ${err.message}`
@@ -47035,14 +47150,14 @@ async function runSideBenchmarkContent(opts) {
47035
47150
  }
47036
47151
 
47037
47152
  // src/ignore/parser.ts
47038
- import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
47153
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
47039
47154
  import { join as join8 } from "node:path";
47040
47155
  function loadParityRc(cwd = process.cwd()) {
47041
47156
  const path = join8(cwd, ".parityrc.json");
47042
- if (!existsSync5(path))
47157
+ if (!existsSync6(path))
47043
47158
  return ParityRc.parse({});
47044
47159
  try {
47045
- const raw = JSON.parse(readFileSync5(path, "utf8"));
47160
+ const raw = JSON.parse(readFileSync6(path, "utf8"));
47046
47161
  return ParityRc.parse(raw);
47047
47162
  } catch (err) {
47048
47163
  console.warn(`[parity] failed to parse ${path}: ${err.message}`);
@@ -47051,10 +47166,10 @@ function loadParityRc(cwd = process.cwd()) {
47051
47166
  }
47052
47167
  function loadParityIgnore(cwd = process.cwd()) {
47053
47168
  const path = join8(cwd, ".parityignore");
47054
- if (!existsSync5(path))
47169
+ if (!existsSync6(path))
47055
47170
  return ParityIgnore.parse({});
47056
47171
  try {
47057
- const raw = JSON.parse(readFileSync5(path, "utf8"));
47172
+ const raw = JSON.parse(readFileSync6(path, "utf8"));
47058
47173
  return ParityIgnore.parse(raw);
47059
47174
  } catch (err) {
47060
47175
  console.warn(`[parity] failed to parse ${path}: ${err.message}`);
@@ -47165,7 +47280,7 @@ init_client();
47165
47280
  init_client();
47166
47281
  init_html_compact();
47167
47282
  init_html_compact();
47168
- import { existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync6, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
47283
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync7, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "node:fs";
47169
47284
  import { join as join9 } from "node:path";
47170
47285
  import { z as z3 } from "zod";
47171
47286
  var CACHE_DIR = ".parity-cache";
@@ -47435,7 +47550,7 @@ async function discoverSelectors(urls, html3, opts = {}) {
47435
47550
  const cacheDir = opts.cacheDir ?? CACHE_DIR;
47436
47551
  const cachePath = join9(cacheDir, `selectors-${host}.json`);
47437
47552
  const fingerprint = computeHtmlFingerprint(html3.home);
47438
- if (!opts.noCache && existsSync6(cachePath)) {
47553
+ if (!opts.noCache && existsSync7(cachePath)) {
47439
47554
  const cached = readCacheEntry(cachePath, fingerprint);
47440
47555
  if (cached)
47441
47556
  return cached.selectors;
@@ -47484,7 +47599,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
47484
47599
  console.warn(`[discover-selectors] checkout_button == minicart_trigger (\`${selectors.checkoutButton}\`); dropping to avoid step-9 misclick`);
47485
47600
  selectors.checkoutButton = undefined;
47486
47601
  }
47487
- if (!existsSync6(cacheDir))
47602
+ if (!existsSync7(cacheDir))
47488
47603
  mkdirSync6(cacheDir, { recursive: true });
47489
47604
  const entry = {
47490
47605
  schemaVersion: CACHE_SCHEMA_VERSION,
@@ -47492,7 +47607,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
47492
47607
  htmlFingerprint: fingerprint,
47493
47608
  selectors
47494
47609
  };
47495
- writeFileSync6(cachePath, `${JSON.stringify(entry, null, 2)}
47610
+ writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
47496
47611
  `, "utf8");
47497
47612
  return selectors;
47498
47613
  }
@@ -47506,7 +47621,7 @@ function cacheTtlMs() {
47506
47621
  function readCacheEntry(cachePath, currentFingerprint) {
47507
47622
  let parsed;
47508
47623
  try {
47509
- parsed = JSON.parse(readFileSync6(cachePath, "utf8"));
47624
+ parsed = JSON.parse(readFileSync7(cachePath, "utf8"));
47510
47625
  } catch {
47511
47626
  console.warn(`[discover-selectors] cache corrompido em ${cachePath}; redescubrindo`);
47512
47627
  try {
@@ -47533,14 +47648,14 @@ function readCacheEntry(cachePath, currentFingerprint) {
47533
47648
  function persistSelectorValidation(homeUrl, validated, cacheDir = CACHE_DIR) {
47534
47649
  const host = safeHost(homeUrl);
47535
47650
  const cachePath = join9(cacheDir, `selectors-${host}.json`);
47536
- if (!existsSync6(cachePath))
47651
+ if (!existsSync7(cachePath))
47537
47652
  return;
47538
47653
  try {
47539
- const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(readFileSync6(cachePath, "utf8")));
47654
+ const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(readFileSync7(cachePath, "utf8")));
47540
47655
  if (!parsed.success)
47541
47656
  return;
47542
47657
  const entry = { ...parsed.data, validated };
47543
- writeFileSync6(cachePath, `${JSON.stringify(entry, null, 2)}
47658
+ writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
47544
47659
  `, "utf8");
47545
47660
  } catch {}
47546
47661
  }
@@ -47577,7 +47692,7 @@ function safeHost(url) {
47577
47692
  }
47578
47693
 
47579
47694
  // src/report/benchmark-html.ts
47580
- import { readFileSync as readFileSync7 } from "node:fs";
47695
+ import { readFileSync as readFileSync8 } from "node:fs";
47581
47696
  var MIME = {
47582
47697
  ".png": "image/png",
47583
47698
  ".jpg": "image/jpeg",
@@ -47592,7 +47707,7 @@ function dataUri(absPath) {
47592
47707
  const mime = MIME[ext];
47593
47708
  if (!mime)
47594
47709
  return null;
47595
- return `data:${mime};base64,${readFileSync7(absPath).toString("base64")}`;
47710
+ return `data:${mime};base64,${readFileSync8(absPath).toString("base64")}`;
47596
47711
  } catch {
47597
47712
  return null;
47598
47713
  }
@@ -48283,10 +48398,10 @@ async function benchmarkCommand(opts) {
48283
48398
  logo,
48284
48399
  sides
48285
48400
  };
48286
- writeFileSync7(paths.reportJson, `${JSON.stringify(report, null, 2)}
48401
+ writeFileSync8(paths.reportJson, `${JSON.stringify(report, null, 2)}
48287
48402
  `, "utf8");
48288
48403
  const html3 = renderBenchmarkHtml(report, { lang });
48289
- writeFileSync7(paths.reportHtml, html3, "utf8");
48404
+ writeFileSync8(paths.reportHtml, html3, "utf8");
48290
48405
  printSummary2(report);
48291
48406
  console.log(chalk3.dim(` → ${paths.reportHtml}`));
48292
48407
  console.log(chalk3.dim(` → HAR: ${paths.harDir}/user-navigation-benchmark-*.har`));
@@ -48326,7 +48441,7 @@ function printSummary2(report) {
48326
48441
  }
48327
48442
 
48328
48443
  // src/commands/cache.ts
48329
- import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
48444
+ import { existsSync as existsSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
48330
48445
  import { join as join13 } from "node:path";
48331
48446
  import chalk4 from "chalk";
48332
48447
  import ora3 from "ora";
@@ -49065,7 +49180,6 @@ var SPA_NAVIGATION_STEP_LABELS = {
49065
49180
  "navigate-via-spa": "Navegar para outra categoria via SPA (client-side)",
49066
49181
  "verify-section-parity": "Verificar paridade de sections (SPA nav vs F5 do mesmo destino)"
49067
49182
  };
49068
- var SPA_NAVIGATION_CRITICAL_STEPS = new Set(["verify-section-parity"]);
49069
49183
 
49070
49184
  // src/checks/cart-interactions-flow.ts
49071
49185
  function cartInteractionsFlow(ctx) {
@@ -52970,11 +53084,11 @@ function skip6(start, summary) {
52970
53084
  }
52971
53085
 
52972
53086
  // src/checks/visual-regression.ts
52973
- import { existsSync as existsSync8, mkdirSync as mkdirSync8 } from "node:fs";
53087
+ import { existsSync as existsSync9, mkdirSync as mkdirSync8 } from "node:fs";
52974
53088
  import { basename, join as join12 } from "node:path";
52975
53089
 
52976
53090
  // src/diff/visual.ts
52977
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
53091
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "node:fs";
52978
53092
  import pixelmatch from "pixelmatch";
52979
53093
  import { PNG } from "pngjs";
52980
53094
  var DEFAULTS = {
@@ -52983,8 +53097,8 @@ var DEFAULTS = {
52983
53097
  };
52984
53098
  function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
52985
53099
  const cfg = { ...DEFAULTS, ...opts };
52986
- const prod = PNG.sync.read(readFileSync8(prodPath));
52987
- const cand = PNG.sync.read(readFileSync8(candPath));
53100
+ const prod = PNG.sync.read(readFileSync9(prodPath));
53101
+ const cand = PNG.sync.read(readFileSync9(candPath));
52988
53102
  const width = Math.min(prod.width, cand.width);
52989
53103
  const height = Math.min(prod.height, cand.height);
52990
53104
  const prodCropped = cropPng(prod, width, height);
@@ -52993,7 +53107,7 @@ function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
52993
53107
  const diffPixels = pixelmatch(prodCropped.data, candCropped.data, diff.data, width, height, {
52994
53108
  threshold: cfg.threshold
52995
53109
  });
52996
- writeFileSync8(heatmapPath, PNG.sync.write(diff));
53110
+ writeFileSync9(heatmapPath, PNG.sync.write(diff));
52997
53111
  const totalPixels = width * height;
52998
53112
  const pctDiff = totalPixels > 0 ? diffPixels / totalPixels : 0;
52999
53113
  const passed = pctDiff <= cfg.maxPctDiff;
@@ -53025,7 +53139,7 @@ init_client();
53025
53139
 
53026
53140
  // src/llm/visual-semantic-diff.ts
53027
53141
  init_client();
53028
- import { readFileSync as readFileSync9 } from "node:fs";
53142
+ import { readFileSync as readFileSync10 } from "node:fs";
53029
53143
  import { PNG as PNG2 } from "pngjs";
53030
53144
  var MAX_HEIGHT = 8000;
53031
53145
  var LLM_PROMPT_VERSION = "v4-text-caution";
@@ -53170,7 +53284,7 @@ Se NÃO houver diferenças relevantes (só ruído), retorne differences: []. Nã
53170
53284
  Cap 8 diferenças por análise — só as que mais importam.
53171
53285
  `.trim();
53172
53286
  function loadCroppedPngBase64(path, maxHeight = MAX_HEIGHT) {
53173
- const png = PNG2.sync.read(readFileSync9(path));
53287
+ const png = PNG2.sync.read(readFileSync10(path));
53174
53288
  if (png.height <= maxHeight) {
53175
53289
  return PNG2.sync.write(png).toString("base64");
53176
53290
  }
@@ -53289,13 +53403,13 @@ function partitionExpectedSections(sections, expected) {
53289
53403
 
53290
53404
  // src/checks/lib/parity-cache.ts
53291
53405
  import { createHash as createHash2 } from "node:crypto";
53292
- import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
53406
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
53293
53407
  import { dirname as dirname3, join as join11 } from "node:path";
53294
53408
  function hashScreenshotPair(prodPath, candPath, promptVersion) {
53295
53409
  const h = createHash2("sha256");
53296
- h.update(readFileSync10(prodPath));
53410
+ h.update(readFileSync11(prodPath));
53297
53411
  h.update("|");
53298
- h.update(readFileSync10(candPath));
53412
+ h.update(readFileSync11(candPath));
53299
53413
  h.update("|");
53300
53414
  h.update(promptVersion);
53301
53415
  return h.digest("hex");
@@ -53305,10 +53419,10 @@ function cacheFilePath(cacheDir) {
53305
53419
  }
53306
53420
  function readCache(cacheDir) {
53307
53421
  const file = cacheFilePath(cacheDir);
53308
- if (!existsSync7(file))
53422
+ if (!existsSync8(file))
53309
53423
  return {};
53310
53424
  try {
53311
- const raw = readFileSync10(file, "utf-8");
53425
+ const raw = readFileSync11(file, "utf-8");
53312
53426
  const parsed = JSON.parse(raw);
53313
53427
  if (parsed && typeof parsed === "object")
53314
53428
  return parsed;
@@ -53320,7 +53434,7 @@ function readCache(cacheDir) {
53320
53434
  function writeCache(cacheDir, cache) {
53321
53435
  const file = cacheFilePath(cacheDir);
53322
53436
  mkdirSync7(dirname3(file), { recursive: true });
53323
- writeFileSync9(file, JSON.stringify(cache, null, 2));
53437
+ writeFileSync10(file, JSON.stringify(cache, null, 2));
53324
53438
  }
53325
53439
  function getCacheEntry(cache, hash2, currentPromptVersion) {
53326
53440
  const entry = cache[hash2];
@@ -53433,7 +53547,7 @@ async function visualRegressionKeyframes(ctx) {
53433
53547
  const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
53434
53548
  const issues = [];
53435
53549
  const diffDir = join12(ctx.outDir, "screenshots");
53436
- if (!existsSync8(diffDir))
53550
+ if (!existsSync9(diffDir))
53437
53551
  mkdirSync8(diffDir, { recursive: true });
53438
53552
  const expectedDivergences = ctx.ignore.expectedDivergences ?? [];
53439
53553
  const useLlm = isLlmAvailable();
@@ -53442,7 +53556,7 @@ async function visualRegressionKeyframes(ctx) {
53442
53556
  const cache = ctx.cacheDir && !ctx.noCache ? readCache(ctx.cacheDir) : {};
53443
53557
  const prepared = [];
53444
53558
  for (const pair of pairs) {
53445
- if (!existsSync8(pair.prod.screenshotPath) || !existsSync8(pair.cand.screenshotPath)) {
53559
+ if (!existsSync9(pair.prod.screenshotPath) || !existsSync9(pair.cand.screenshotPath)) {
53446
53560
  continue;
53447
53561
  }
53448
53562
  const heatmapName = `diff-${pair.viewport}-${basename(pair.key.replace(/[/:]/g, "_"))}.png`;
@@ -56171,7 +56285,7 @@ async function cacheCommand(opts) {
56171
56285
  writeRunReportJson(paths.runDir, run);
56172
56286
  const html3 = renderHtmlReport(run, paths.runDir);
56173
56287
  writeRunReportHtml(paths.runDir, html3);
56174
- writeFileSync10(join13(paths.runDir, "cache.json"), `${JSON.stringify({
56288
+ writeFileSync11(join13(paths.runDir, "cache.json"), `${JSON.stringify({
56175
56289
  schemaVersion: "0.1",
56176
56290
  prodUrl: opts.prod,
56177
56291
  candUrl: opts.cand,
@@ -56231,8 +56345,8 @@ async function discoverPagePaths(prodUrl, opts, limit) {
56231
56345
  if (opts.urls) {
56232
56346
  if (opts.urls.endsWith(".txt") || opts.urls.endsWith(".list") || opts.urls.startsWith("file:")) {
56233
56347
  const path = opts.urls.replace(/^file:\/\//, "");
56234
- if (existsSync9(path)) {
56235
- return readFileSync11(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
56348
+ if (existsSync10(path)) {
56349
+ return readFileSync12(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
56236
56350
  }
56237
56351
  }
56238
56352
  return opts.urls.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -56836,7 +56950,7 @@ async function cssTraceCommand(opts) {
56836
56950
  }
56837
56951
 
56838
56952
  // src/commands/e2e.ts
56839
- import { writeFileSync as writeFileSync12 } from "node:fs";
56953
+ import { writeFileSync as writeFileSync13 } from "node:fs";
56840
56954
  import { spawn as spawn2 } from "node:child_process";
56841
56955
  import chalk9 from "chalk";
56842
56956
  import ora5 from "ora";
@@ -57788,7 +57902,7 @@ async function flowLogin(ctx) {
57788
57902
 
57789
57903
  // src/llm/resolve-search-terms.ts
57790
57904
  init_client();
57791
- import { existsSync as existsSync10, mkdirSync as mkdirSync9, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
57905
+ import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
57792
57906
  import { join as join15 } from "node:path";
57793
57907
  var CACHE_DIR2 = ".parity-cache";
57794
57908
  var FALLBACK_TERMS = ["produto", "preto", "promocao"];
@@ -57870,9 +57984,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57870
57984
  const host = safeHost3(url);
57871
57985
  const cacheDir = opts.cacheDir ?? CACHE_DIR2;
57872
57986
  const cachePath = join15(cacheDir, `search-terms-${host}.json`);
57873
- if (!opts.noCache && existsSync10(cachePath)) {
57987
+ if (!opts.noCache && existsSync11(cachePath)) {
57874
57988
  try {
57875
- const cached = JSON.parse(readFileSync12(cachePath, "utf8"));
57989
+ const cached = JSON.parse(readFileSync13(cachePath, "utf8"));
57876
57990
  if (cached.withResults?.trim()) {
57877
57991
  return { withResults: cached.withResults.trim(), noResults };
57878
57992
  }
@@ -57880,9 +57994,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57880
57994
  }
57881
57995
  const suggested = await suggestTermViaLlm(url, html3);
57882
57996
  if (suggested) {
57883
- if (!existsSync10(cacheDir))
57997
+ if (!existsSync11(cacheDir))
57884
57998
  mkdirSync9(cacheDir, { recursive: true });
57885
- writeFileSync11(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
57999
+ writeFileSync12(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
57886
58000
  `, "utf8");
57887
58001
  return { withResults: suggested, noResults };
57888
58002
  }
@@ -58573,10 +58687,10 @@ async function runFlow(flow, ctx) {
58573
58687
  });
58574
58688
  let timer;
58575
58689
  let cleanup = Promise.resolve();
58576
- const timeoutPromise = new Promise((resolve) => {
58690
+ const timeoutPromise = new Promise((resolve2) => {
58577
58691
  timer = setTimeout(() => {
58578
58692
  const pages = ctx.ctx.pages();
58579
- resolve(finalize(flow, ctx, [], [
58693
+ resolve2(finalize(flow, ctx, [], [
58580
58694
  {
58581
58695
  step: 0,
58582
58696
  name: "flow-timeout",
@@ -58625,7 +58739,7 @@ var PROBE_TIMEOUT_MS = 2000;
58625
58739
  function withTimeout(p, capMs, fallback) {
58626
58740
  return Promise.race([
58627
58741
  p.catch(() => fallback),
58628
- new Promise((resolve) => setTimeout(() => resolve(fallback), capMs))
58742
+ new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
58629
58743
  ]);
58630
58744
  }
58631
58745
  function selectorKeysOf(selectors) {
@@ -59100,8 +59214,8 @@ async function e2eCommand(opts) {
59100
59214
  generatedAt: new Date().toISOString(),
59101
59215
  durationMs
59102
59216
  });
59103
- writeFileSync12(paths.reportHtml, html3, "utf8");
59104
- writeFileSync12(paths.reportJson, `${JSON.stringify({
59217
+ writeFileSync13(paths.reportHtml, html3, "utf8");
59218
+ writeFileSync13(paths.reportJson, `${JSON.stringify({
59105
59219
  runId,
59106
59220
  mode: "e2e",
59107
59221
  url: opts.url,
@@ -59307,12 +59421,12 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
59307
59421
 
59308
59422
  // src/commands/extract.ts
59309
59423
  import { mkdirSync as mkdirSync13 } from "node:fs";
59310
- import { resolve as resolve2 } from "node:path";
59424
+ import { resolve as resolve3 } from "node:path";
59311
59425
  import chalk12 from "chalk";
59312
59426
 
59313
59427
  // src/llm/section-understanding.ts
59314
59428
  init_client();
59315
- import { readFileSync as readFileSync13 } from "node:fs";
59429
+ import { readFileSync as readFileSync14 } from "node:fs";
59316
59430
  var SUMMARIZE_TOOL = {
59317
59431
  name: "summarize_understanding",
59318
59432
  description: "Return a single paragraph describing what you understood from the section diff signals. NO code — only diagnosis.",
@@ -59350,7 +59464,7 @@ async function invokeUnderstandingSummary(input) {
59350
59464
  return null;
59351
59465
  let markdown;
59352
59466
  try {
59353
- markdown = readFileSync13(input.markdownPath, "utf8");
59467
+ markdown = readFileSync14(input.markdownPath, "utf8");
59354
59468
  } catch (err) {
59355
59469
  console.error(`[section-understanding] failed to read markdown: ${err.message}`);
59356
59470
  return null;
@@ -59360,7 +59474,7 @@ async function invokeUnderstandingSummary(input) {
59360
59474
  if (!p)
59361
59475
  continue;
59362
59476
  try {
59363
- const buf = readFileSync13(p);
59477
+ const buf = readFileSync14(p);
59364
59478
  images.push({ base64: buf.toString("base64"), mediaType: "image/png" });
59365
59479
  } catch (err) {
59366
59480
  console.error(`[section-understanding] skipping image ${p}: ${err.message}`);
@@ -59637,19 +59751,19 @@ function collectCandidatesInPage() {
59637
59751
  }
59638
59752
 
59639
59753
  // src/extract/exporters/json.ts
59640
- import { writeFileSync as writeFileSync13 } from "node:fs";
59754
+ import { writeFileSync as writeFileSync14 } from "node:fs";
59641
59755
  import { join as join16 } from "node:path";
59642
59756
  var jsonExporter = {
59643
59757
  name: "json",
59644
59758
  async export(bundle, outDir) {
59645
59759
  const path = join16(outDir, "manifest.json");
59646
- writeFileSync13(path, `${JSON.stringify(bundle, null, 2)}
59760
+ writeFileSync14(path, `${JSON.stringify(bundle, null, 2)}
59647
59761
  `, "utf8");
59648
59762
  }
59649
59763
  };
59650
59764
 
59651
59765
  // src/extract/exporters/markdown.ts
59652
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync14 } from "node:fs";
59766
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync15 } from "node:fs";
59653
59767
  import { join as join17 } from "node:path";
59654
59768
 
59655
59769
  // src/extract/naming.ts
@@ -59664,13 +59778,13 @@ var markdownExporter = {
59664
59778
  async export(bundle, outDir) {
59665
59779
  const dirNames = bundle.components.map((c, i) => componentDirName(c.role, i + 1));
59666
59780
  const indexMd = renderIndex(bundle, dirNames);
59667
- writeFileSync14(join17(outDir, "index.md"), indexMd, "utf8");
59781
+ writeFileSync15(join17(outDir, "index.md"), indexMd, "utf8");
59668
59782
  bundle.components.forEach((component, i) => {
59669
59783
  const dirName = dirNames[i];
59670
59784
  const componentDir = join17(outDir, "components", dirName);
59671
59785
  mkdirSync10(componentDir, { recursive: true });
59672
59786
  const readme = renderComponentReadme(bundle, component);
59673
- writeFileSync14(join17(componentDir, "README.md"), readme, "utf8");
59787
+ writeFileSync15(join17(componentDir, "README.md"), readme, "utf8");
59674
59788
  });
59675
59789
  }
59676
59790
  };
@@ -59777,7 +59891,7 @@ function truncateHtml(html3, max) {
59777
59891
  }
59778
59892
 
59779
59893
  // src/extract/extract-component.ts
59780
- import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync15 } from "node:fs";
59894
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync16 } from "node:fs";
59781
59895
 
59782
59896
  // src/engine/section-capture.ts
59783
59897
  init_esm10();
@@ -60040,8 +60154,8 @@ async function extractComponent(page, component, opts) {
60040
60154
  links: capLinks(links, LINK_CAP),
60041
60155
  textContent: textContent2
60042
60156
  };
60043
- writeFileSync15(`${opts.outDir}/component.html`, extracted.html, "utf8");
60044
- writeFileSync15(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60157
+ writeFileSync16(`${opts.outDir}/component.html`, extracted.html, "utf8");
60158
+ writeFileSync16(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60045
60159
  `, "utf8");
60046
60160
  return extracted;
60047
60161
  }
@@ -60130,18 +60244,18 @@ function capLinks(links, max) {
60130
60244
 
60131
60245
  // src/commands/section.ts
60132
60246
  import { mkdirSync as mkdirSync12 } from "node:fs";
60133
- import { resolve } from "node:path";
60247
+ import { resolve as resolve2 } from "node:path";
60134
60248
  import chalk11 from "chalk";
60135
60249
  import * as diff from "diff";
60136
60250
  import prettier from "prettier";
60137
60251
 
60138
60252
  // src/diff/heatmap-regions.ts
60139
- import { readFileSync as readFileSync14 } from "node:fs";
60253
+ import { readFileSync as readFileSync15 } from "node:fs";
60140
60254
  import { PNG as PNG4 } from "pngjs";
60141
60255
  var DEFAULT_MAX_HOTSPOTS = 5;
60142
60256
  var DEFAULT_MIN_COMPONENT_PIXELS = 50;
60143
60257
  function analyzeHeatmapRegions(pngPath, opts = {}) {
60144
- const png = PNG4.sync.read(readFileSync14(pngPath));
60258
+ const png = PNG4.sync.read(readFileSync15(pngPath));
60145
60259
  return analyzeHeatmapBuffer(png.data, png.width, png.height, opts);
60146
60260
  }
60147
60261
  function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
@@ -60254,7 +60368,7 @@ function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
60254
60368
  }
60255
60369
 
60256
60370
  // src/diff/section-bundle.ts
60257
- import { writeFileSync as writeFileSync16 } from "node:fs";
60371
+ import { writeFileSync as writeFileSync17 } from "node:fs";
60258
60372
  import { basename as basename2, dirname as dirname4, join as join18, relative as relative3 } from "node:path";
60259
60373
  function buildStyleDeltas(input) {
60260
60374
  const cs = input.computedStyles;
@@ -60300,11 +60414,11 @@ function assembleSectionDiffBundle(input) {
60300
60414
  styleDeltas
60301
60415
  };
60302
60416
  const jsonPath = join18(input.outDir, `${input.filePrefix}-bundle.json`);
60303
- writeFileSync16(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60417
+ writeFileSync17(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60304
60418
  `, "utf8");
60305
60419
  const markdown = renderMarkdownBundle(input, styleDeltas);
60306
60420
  const markdownPath = join18(input.outDir, `${input.filePrefix}-prompt.md`);
60307
- writeFileSync16(markdownPath, markdown, "utf8");
60421
+ writeFileSync17(markdownPath, markdown, "utf8");
60308
60422
  const summary = oneLineSummary(input, styleDeltas);
60309
60423
  return { jsonPath, markdownPath, summary };
60310
60424
  }
@@ -60520,10 +60634,10 @@ async function sectionCommand(opts) {
60520
60634
  const hash2 = hashSelector(opts.selector);
60521
60635
  const filePrefix = `section-${hash2}-${viewport}`;
60522
60636
  const screenshotPaths = {
60523
- prod: resolve(opts.outDir, `${filePrefix}-prod.png`),
60524
- cand: resolve(opts.outDir, `${filePrefix}-cand.png`)
60637
+ prod: resolve2(opts.outDir, `${filePrefix}-prod.png`),
60638
+ cand: resolve2(opts.outDir, `${filePrefix}-cand.png`)
60525
60639
  };
60526
- const heatmapPath = resolve(opts.outDir, `${filePrefix}-heatmap.png`);
60640
+ const heatmapPath = resolve2(opts.outDir, `${filePrefix}-heatmap.png`);
60527
60641
  const browser = await launchBrowser({ headless: true });
60528
60642
  try {
60529
60643
  const [prodSide, candSide] = await Promise.all([
@@ -60620,7 +60734,7 @@ async function gatherSide(browser, opts) {
60620
60734
  stabilizeCarousels(page).catch(() => {
60621
60735
  return;
60622
60736
  }),
60623
- new Promise((resolve2) => setTimeout(resolve2, 3000))
60737
+ new Promise((resolve3) => setTimeout(resolve3, 3000))
60624
60738
  ]);
60625
60739
  if (opts.wantScreenshot) {
60626
60740
  const scrollBudget = 30000;
@@ -60628,13 +60742,13 @@ async function gatherSide(browser, opts) {
60628
60742
  scrollFullPage(page, scrollBudget).catch(() => {
60629
60743
  return;
60630
60744
  }),
60631
- new Promise((resolve2) => setTimeout(resolve2, scrollBudget + 2000))
60745
+ new Promise((resolve3) => setTimeout(resolve3, scrollBudget + 2000))
60632
60746
  ]);
60633
60747
  await Promise.race([
60634
60748
  waitForSkeletonsToResolve(page, 5000).catch(() => {
60635
60749
  return;
60636
60750
  }),
60637
- new Promise((resolve2) => setTimeout(resolve2, 5000))
60751
+ new Promise((resolve3) => setTimeout(resolve3, 5000))
60638
60752
  ]);
60639
60753
  }
60640
60754
  const artifacts = await captureSectionArtifacts(page, {
@@ -60990,7 +61104,7 @@ async function extractCommand(opts) {
60990
61104
  const host = safeHost4(opts.url);
60991
61105
  const timestamp = new Date().toISOString();
60992
61106
  const runDirTimestamp = timestamp.replace(/[:.]/g, "-");
60993
- const runDir = resolve2(opts.outDir, host, runDirTimestamp);
61107
+ const runDir = resolve3(opts.outDir, host, runDirTimestamp);
60994
61108
  mkdirSync13(runDir, { recursive: true });
60995
61109
  const browser = await launchBrowser({ headless: true });
60996
61110
  try {
@@ -61037,7 +61151,7 @@ async function extractCommand(opts) {
61037
61151
  for (const component of detected) {
61038
61152
  globalIndex++;
61039
61153
  const dirName = componentDirName(component.role, globalIndex);
61040
- const componentDir = resolve2(runDir, "components", dirName);
61154
+ const componentDir = resolve3(runDir, "components", dirName);
61041
61155
  const extracted = await extractComponent(page, component, {
61042
61156
  outDir: componentDir,
61043
61157
  index: globalIndex,
@@ -61432,7 +61546,7 @@ function formatPatch(patch) {
61432
61546
  }
61433
61547
 
61434
61548
  // src/commands/journey.ts
61435
- import { writeFileSync as writeFileSync17 } from "node:fs";
61549
+ import { writeFileSync as writeFileSync18 } from "node:fs";
61436
61550
  import { join as join19 } from "node:path";
61437
61551
  import chalk14 from "chalk";
61438
61552
  import ora6 from "ora";
@@ -61595,7 +61709,7 @@ async function journeyCommand(opts) {
61595
61709
  if (opts.github)
61596
61710
  emitGithubAnnotations(failures);
61597
61711
  if (opts.junit) {
61598
- writeFileSync17(opts.junit, buildJUnit(rows, failures), "utf8");
61712
+ writeFileSync18(opts.junit, buildJUnit(rows, failures), "utf8");
61599
61713
  if (!opts.json)
61600
61714
  console.log(chalk14.dim(` → JUnit XML: ${opts.junit}`));
61601
61715
  }
@@ -62073,8 +62187,8 @@ function listCommand(output) {
62073
62187
  }
62074
62188
 
62075
62189
  // src/commands/migrate.ts
62076
- import { existsSync as existsSync14, mkdirSync as mkdirSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync23 } from "node:fs";
62077
- import { resolve as resolve3 } from "node:path";
62190
+ import { existsSync as existsSync15, mkdirSync as mkdirSync16, readFileSync as readFileSync20, writeFileSync as writeFileSync24 } from "node:fs";
62191
+ import { resolve as resolve4 } from "node:path";
62078
62192
  import chalk17 from "chalk";
62079
62193
  import open from "open";
62080
62194
 
@@ -62519,22 +62633,22 @@ function compactComponentHtml(html3, maxChars = COMPONENT_HTML_MAX_CHARS) {
62519
62633
  }
62520
62634
 
62521
62635
  // src/migrate/exporters/json.ts
62522
- import { writeFileSync as writeFileSync18 } from "node:fs";
62636
+ import { writeFileSync as writeFileSync19 } from "node:fs";
62523
62637
  import { join as join20 } from "node:path";
62524
62638
  var jsonExporter2 = {
62525
62639
  name: "json",
62526
62640
  async export(bundle, outDir) {
62527
- writeFileSync18(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
62641
+ writeFileSync19(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
62528
62642
  `, "utf8");
62529
62643
  }
62530
62644
  };
62531
62645
 
62532
62646
  // src/migrate/exporters/markdown.ts
62533
- import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync20 } from "node:fs";
62647
+ import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync21 } from "node:fs";
62534
62648
  import { join as join22 } from "node:path";
62535
62649
 
62536
62650
  // src/migrate/vtex/content-assets.ts
62537
- import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync19 } from "node:fs";
62651
+ import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync20 } from "node:fs";
62538
62652
  import { join as join21 } from "node:path";
62539
62653
  var MAX_IMAGES = 150;
62540
62654
  var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
@@ -62654,7 +62768,7 @@ async function downloadContentImages(urls, runDir, fetchBytes) {
62654
62768
  if (!got)
62655
62769
  continue;
62656
62770
  const name = contentImageName(url, i, used);
62657
- writeFileSync19(join21(dir, name), got.buf);
62771
+ writeFileSync20(join21(dir, name), got.buf);
62658
62772
  map2[url] = `assets/content/${name}`;
62659
62773
  downloaded++;
62660
62774
  }
@@ -62676,9 +62790,9 @@ var markdownExporter2 = {
62676
62790
  notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
62677
62791
  if (compact.truncated)
62678
62792
  notes.push(`\`${dirName}\`: HTML truncated to fit the per-component token ceiling`);
62679
- writeFileSync20(join22(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
62793
+ writeFileSync21(join22(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
62680
62794
  });
62681
- writeFileSync20(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
62795
+ writeFileSync21(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
62682
62796
  }
62683
62797
  };
62684
62798
  function renderIndex2(bundle, notes) {
@@ -62880,7 +62994,7 @@ function escapePipes2(s) {
62880
62994
  }
62881
62995
 
62882
62996
  // src/migrate/exporters/html.ts
62883
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync21 } from "node:fs";
62997
+ import { readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
62884
62998
  import { join as join23 } from "node:path";
62885
62999
 
62886
63000
  // src/migrate/targets/faststore-v4.ts
@@ -63201,9 +63315,9 @@ var TARGET_NAMES = Object.keys(TARGETS);
63201
63315
  var htmlExporter = {
63202
63316
  name: "html",
63203
63317
  async export(bundle, outDir) {
63204
- writeFileSync21(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
63318
+ writeFileSync22(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
63205
63319
  const inline = (p) => p ? dataUri2(join23(outDir, p)) ?? p : null;
63206
- writeFileSync21(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
63320
+ writeFileSync22(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
63207
63321
  }
63208
63322
  };
63209
63323
  var MIME2 = {
@@ -63221,7 +63335,7 @@ function dataUri2(absPath) {
63221
63335
  const mime = MIME2[ext];
63222
63336
  if (!mime)
63223
63337
  return null;
63224
- return `data:${mime};base64,${readFileSync15(absPath).toString("base64")}`;
63338
+ return `data:${mime};base64,${readFileSync16(absPath).toString("base64")}`;
63225
63339
  } catch {
63226
63340
  return null;
63227
63341
  }
@@ -63525,7 +63639,7 @@ function buildMigrationPrompt(bundle, playbook, source) {
63525
63639
  }
63526
63640
 
63527
63641
  // src/migrate/plan.ts
63528
- import { existsSync as existsSync11, readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
63642
+ import { existsSync as existsSync12, readFileSync as readFileSync17, writeFileSync as writeFileSync23 } from "node:fs";
63529
63643
  import { join as join24 } from "node:path";
63530
63644
  function dedupe(names) {
63531
63645
  return [...new Set(names)];
@@ -63617,12 +63731,12 @@ var PLAN_FILE = "migration-plan.json";
63617
63731
  var SETTLED = new Set(["done", "as-is", "upgrade", "skipped"]);
63618
63732
  function loadPlan(dir) {
63619
63733
  const p = join24(dir, PLAN_FILE);
63620
- if (!existsSync11(p))
63734
+ if (!existsSync12(p))
63621
63735
  return null;
63622
- return JSON.parse(readFileSync16(p, "utf8"));
63736
+ return JSON.parse(readFileSync17(p, "utf8"));
63623
63737
  }
63624
63738
  function savePlan(dir, plan) {
63625
- writeFileSync22(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
63739
+ writeFileSync23(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
63626
63740
  `, "utf8");
63627
63741
  }
63628
63742
  function setComponentStatus(plan, name, status) {
@@ -63801,7 +63915,7 @@ function syntheticSourceComponents(plan) {
63801
63915
  }
63802
63916
 
63803
63917
  // src/migrate/sources/deco-fresh.ts
63804
- import { existsSync as existsSync12, readFileSync as readFileSync17 } from "node:fs";
63918
+ import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
63805
63919
  import { join as join26 } from "node:path";
63806
63920
 
63807
63921
  // src/migrate/sources/walk.ts
@@ -63847,13 +63961,13 @@ function walkFiles(dir, exts) {
63847
63961
  function isDecoFresh(repoDir) {
63848
63962
  const denoJson = join26(repoDir, "deno.json");
63849
63963
  const denoJsonc = join26(repoDir, "deno.jsonc");
63850
- const file = existsSync12(denoJson) ? denoJson : existsSync12(denoJsonc) ? denoJsonc : null;
63964
+ const file = existsSync13(denoJson) ? denoJson : existsSync13(denoJsonc) ? denoJsonc : null;
63851
63965
  if (!file)
63852
63966
  return false;
63853
- if (!existsSync12(join26(repoDir, "fresh.gen.ts")))
63967
+ if (!existsSync13(join26(repoDir, "fresh.gen.ts")))
63854
63968
  return false;
63855
63969
  try {
63856
- return readFileSync17(file, "utf8").includes("@deco/deco");
63970
+ return readFileSync18(file, "utf8").includes("@deco/deco");
63857
63971
  } catch {
63858
63972
  return false;
63859
63973
  }
@@ -63862,7 +63976,7 @@ var GLOBAL_HINT = /\b(header|footer|navbar|menu|topbar)\b/i;
63862
63976
  function inventory(repoDir) {
63863
63977
  const components = [];
63864
63978
  const sectionsDir = join26(repoDir, "sections");
63865
- if (existsSync12(sectionsDir)) {
63979
+ if (existsSync13(sectionsDir)) {
63866
63980
  for (const rel of walkFiles(sectionsDir, [".tsx"])) {
63867
63981
  const key2 = rel.replace(/\.tsx$/, "");
63868
63982
  components.push({
@@ -63876,9 +63990,9 @@ function inventory(repoDir) {
63876
63990
  const notes = [
63877
63991
  "Source: Deco on Fresh/Deno (Preact + signals, JSX). Sections are the CMS unit."
63878
63992
  ];
63879
- if (existsSync12(join26(repoDir, "islands")))
63993
+ if (existsSync13(join26(repoDir, "islands")))
63880
63994
  notes.push("Has islands/ — client-interactive components.");
63881
- if (existsSync12(join26(repoDir, "loaders")))
63995
+ if (existsSync13(join26(repoDir, "loaders")))
63882
63996
  notes.push("Has loaders/ — server data functions to port.");
63883
63997
  return { components, notes };
63884
63998
  }
@@ -63918,14 +64032,14 @@ captured HTML/computed-styles as the source of truth for structure and styling.`
63918
64032
  };
63919
64033
 
63920
64034
  // src/migrate/sources/vtex-io.ts
63921
- import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
64035
+ import { existsSync as existsSync14, readFileSync as readFileSync19 } from "node:fs";
63922
64036
  import { join as join27 } from "node:path";
63923
64037
  function readManifest(repoDir) {
63924
64038
  const file = join27(repoDir, "manifest.json");
63925
- if (!existsSync13(file))
64039
+ if (!existsSync14(file))
63926
64040
  return null;
63927
64041
  try {
63928
- return JSON.parse(readFileSync18(file, "utf8"));
64042
+ return JSON.parse(readFileSync19(file, "utf8"));
63929
64043
  } catch {
63930
64044
  return null;
63931
64045
  }
@@ -63948,12 +64062,12 @@ var GLOBAL_HINT2 = /header|footer|menu|minicart|navbar/i;
63948
64062
  function inventory2(repoDir) {
63949
64063
  const blocksDir = join27(repoDir, "store", "blocks");
63950
64064
  const seen = new Map;
63951
- if (existsSync13(blocksDir)) {
64065
+ if (existsSync14(blocksDir)) {
63952
64066
  for (const rel of walkFiles(blocksDir, [".json", ".jsonc"])) {
63953
64067
  const abs = join27(blocksDir, rel);
63954
64068
  let parsed;
63955
64069
  try {
63956
- parsed = JSON.parse(stripJsonc(readFileSync18(abs, "utf8")));
64070
+ parsed = JSON.parse(stripJsonc(readFileSync19(abs, "utf8")));
63957
64071
  } catch {
63958
64072
  continue;
63959
64073
  }
@@ -64520,7 +64634,7 @@ async function migrateCommand(opts) {
64520
64634
  source = s;
64521
64635
  }
64522
64636
  if (opts.source) {
64523
- if (!existsSync14(opts.source)) {
64637
+ if (!existsSync15(opts.source)) {
64524
64638
  console.error(chalk17.red(`--source não encontrado: ${opts.source}`));
64525
64639
  return 2;
64526
64640
  }
@@ -64530,13 +64644,13 @@ async function migrateCommand(opts) {
64530
64644
  console.log(chalk17.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
64531
64645
  }
64532
64646
  const host = safeHost6(opts.url);
64533
- const runDir = resolve3(opts.outDir, host);
64647
+ const runDir = resolve4(opts.outDir, host);
64534
64648
  mkdirSync16(runDir, { recursive: true });
64535
64649
  const browser = await launchBrowser({ headless: true });
64536
64650
  try {
64537
- const themePath = resolve3(runDir, "theme.json");
64538
- const assetsPath = resolve3(runDir, "assets.json");
64539
- const blocksPath = resolve3(runDir, "blocks.json");
64651
+ const themePath = resolve4(runDir, "theme.json");
64652
+ const assetsPath = resolve4(runDir, "assets.json");
64653
+ const blocksPath = resolve4(runDir, "blocks.json");
64540
64654
  let theme;
64541
64655
  let platform;
64542
64656
  let stack = null;
@@ -64544,7 +64658,7 @@ async function migrateCommand(opts) {
64544
64658
  let screenshots;
64545
64659
  let vtexBlocks = null;
64546
64660
  let contentMap = {};
64547
- if (!opts.refresh && existsSync14(themePath) && existsSync14(assetsPath)) {
64661
+ if (!opts.refresh && existsSync15(themePath) && existsSync15(assetsPath)) {
64548
64662
  theme = readJson(themePath);
64549
64663
  const meta = readJson(assetsPath);
64550
64664
  platform = meta.platform;
@@ -64554,7 +64668,7 @@ async function migrateCommand(opts) {
64554
64668
  console.log(chalk17.dim(" phase 1 theme+assets: cached"));
64555
64669
  } else {
64556
64670
  console.log(chalk17.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
64557
- mkdirSync16(resolve3(runDir, "screenshots"), { recursive: true });
64671
+ mkdirSync16(resolve4(runDir, "screenshots"), { recursive: true });
64558
64672
  const samples = [];
64559
64673
  screenshots = [];
64560
64674
  let platformSeen = null;
@@ -64580,7 +64694,7 @@ async function migrateCommand(opts) {
64580
64694
  sleep2(5000)
64581
64695
  ]);
64582
64696
  samples.push(await scrapeThemeSamples(page));
64583
- const shot = resolve3(runDir, "screenshots", `${vp}.png`);
64697
+ const shot = resolve4(runDir, "screenshots", `${vp}.png`);
64584
64698
  await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
64585
64699
  return;
64586
64700
  });
@@ -64594,7 +64708,7 @@ async function migrateCommand(opts) {
64594
64708
  const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
64595
64709
  assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
64596
64710
  if (rawAssets.logo?.type === "svg" || rawAssets.logo && !assetsResolved.logo) {
64597
- const logoPng = resolve3(runDir, "assets", "logo.png");
64711
+ const logoPng = resolve4(runDir, "assets", "logo.png");
64598
64712
  const ok = await page.locator("[data-parity-logo]").first().screenshot({ path: logoPng, timeout: 8000 }).then(() => true).catch(() => false);
64599
64713
  if (ok) {
64600
64714
  assetsResolved.logo = "assets/logo.png";
@@ -64614,14 +64728,14 @@ async function migrateCommand(opts) {
64614
64728
  theme = aggregateTheme(mergeRawThemeSamples(samples));
64615
64729
  platform = platformSeen ?? "custom";
64616
64730
  assets = assetsResolved;
64617
- writeFileSync23(themePath, `${JSON.stringify(theme, null, 2)}
64731
+ writeFileSync24(themePath, `${JSON.stringify(theme, null, 2)}
64618
64732
  `, "utf8");
64619
- writeFileSync23(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64733
+ writeFileSync24(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64620
64734
  `, "utf8");
64621
64735
  }
64622
- const sitemapPath = resolve3(runDir, "sitemap.json");
64736
+ const sitemapPath = resolve4(runDir, "sitemap.json");
64623
64737
  let resolvedPages;
64624
- if (!opts.refresh && existsSync14(sitemapPath)) {
64738
+ if (!opts.refresh && existsSync15(sitemapPath)) {
64625
64739
  resolvedPages = readJson(sitemapPath).pages;
64626
64740
  console.log(chalk17.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
64627
64741
  } else {
@@ -64655,17 +64769,17 @@ async function migrateCommand(opts) {
64655
64769
  }, {});
64656
64770
  console.log(chalk17.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
64657
64771
  }
64658
- writeFileSync23(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
64772
+ writeFileSync24(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
64659
64773
  `, "utf8");
64660
64774
  }
64661
64775
  if (resolvedPages.length === 0) {
64662
64776
  console.error(chalk17.red("nenhuma página resolvida a partir de --pages"));
64663
64777
  return 1;
64664
64778
  }
64665
- const capturePath = resolve3(runDir, "capture.json");
64779
+ const capturePath = resolve4(runDir, "capture.json");
64666
64780
  let pages;
64667
64781
  let components;
64668
- if (!opts.refresh && existsSync14(capturePath)) {
64782
+ if (!opts.refresh && existsSync15(capturePath)) {
64669
64783
  const cached = readJson(capturePath);
64670
64784
  pages = cached.pages;
64671
64785
  components = cached.components;
@@ -64681,14 +64795,14 @@ async function migrateCommand(opts) {
64681
64795
  baseUrl: opts.url,
64682
64796
  vtexScrape: opts.source ? source.kind === "vtex-io" : true
64683
64797
  }));
64684
- writeFileSync23(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
64798
+ writeFileSync24(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
64685
64799
  `, "utf8");
64686
64800
  }
64687
64801
  if (vtexBlocks)
64688
- writeFileSync23(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64802
+ writeFileSync24(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64689
64803
  `, "utf8");
64690
64804
  if (Object.keys(contentMap).length)
64691
- writeFileSync23(resolve3(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64805
+ writeFileSync24(resolve4(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64692
64806
  `, "utf8");
64693
64807
  const bundle = {
64694
64808
  url: opts.url,
@@ -64725,17 +64839,17 @@ async function migrateCommand(opts) {
64725
64839
  if (format === "md" || format === "both") {
64726
64840
  await markdownExporter2.export(bundle, runDir);
64727
64841
  await htmlExporter.export(bundle, runDir);
64728
- writeFileSync23(resolve3(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64842
+ writeFileSync24(resolve4(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64729
64843
  playbook: source.playbook,
64730
64844
  notes: sourceInventory.notes
64731
64845
  }), "utf8");
64732
64846
  }
64733
64847
  const targetTheme = opts.target ? getTargetTheme(opts.target) : null;
64734
64848
  if (targetTheme) {
64735
- writeFileSync23(resolve3(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64849
+ writeFileSync24(resolve4(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64736
64850
  }
64737
64851
  if (bundle.vtex) {
64738
- writeFileSync23(resolve3(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64852
+ writeFileSync24(resolve4(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64739
64853
  `, "utf8");
64740
64854
  }
64741
64855
  if (opts.json) {
@@ -64744,7 +64858,7 @@ async function migrateCommand(opts) {
64744
64858
  }
64745
64859
  printResults4(runDir, bundle);
64746
64860
  if (opts.open && format !== "json") {
64747
- await open(resolve3(runDir, "report.html")).catch(() => {
64861
+ await open(resolve4(runDir, "report.html")).catch(() => {
64748
64862
  return;
64749
64863
  });
64750
64864
  }
@@ -64799,7 +64913,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
64799
64913
  if (global)
64800
64914
  seenGlobalRoles.add(component.role);
64801
64915
  const idx = components.length + 1;
64802
- const componentDir = resolve3(cfg.runDir, "components", componentDirName(component.role, idx));
64916
+ const componentDir = resolve4(cfg.runDir, "components", componentDirName(component.role, idx));
64803
64917
  const extracted = await extractComponent(page, component, {
64804
64918
  outDir: componentDir,
64805
64919
  index: idx,
@@ -65013,7 +65127,7 @@ function printResults4(runDir, bundle) {
65013
65127
  }
65014
65128
  function readJson(path) {
65015
65129
  try {
65016
- return JSON.parse(readFileSync19(path, "utf8"));
65130
+ return JSON.parse(readFileSync20(path, "utf8"));
65017
65131
  } catch {
65018
65132
  return null;
65019
65133
  }
@@ -65264,18 +65378,18 @@ ${chalk18.bold("Pages")} (${pg.total}): ` + `${chalk18.green(`${pg.byStatus.done
65264
65378
  }
65265
65379
 
65266
65380
  // src/commands/pr.ts
65267
- import { existsSync as existsSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync24 } from "node:fs";
65381
+ import { existsSync as existsSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync25 } from "node:fs";
65268
65382
  import { join as join30 } from "node:path";
65269
65383
  import chalk21 from "chalk";
65270
65384
 
65271
65385
  // src/commands/run.ts
65272
- import { existsSync as existsSync17, readFileSync as readFileSync21, unlinkSync as unlinkSync3 } from "node:fs";
65386
+ import { existsSync as existsSync18, readFileSync as readFileSync22, unlinkSync as unlinkSync3 } from "node:fs";
65273
65387
  import { join as join29 } from "node:path";
65274
65388
  import chalk20 from "chalk";
65275
65389
  import ora7 from "ora";
65276
65390
 
65277
65391
  // src/engine/interactive-module-prompt.ts
65278
- import { createInterface } from "node:readline";
65392
+ import { createInterface as createInterface2 } from "node:readline";
65279
65393
  var ALL_MODULE_NAMES2 = Object.keys(MODULES);
65280
65394
  async function promptForModuleSelection() {
65281
65395
  console.log("");
@@ -65286,7 +65400,7 @@ async function promptForModuleSelection() {
65286
65400
  console.log(` [x] ${i + 1}. ${name.padEnd(8)} — ${def.description}`);
65287
65401
  });
65288
65402
  console.log("");
65289
- const answer = await readLine(" Type numbers to UNCHECK (comma-separated), or press Enter to run all: ");
65403
+ const answer = await readLine2(" Type numbers to UNCHECK (comma-separated), or press Enter to run all: ");
65290
65404
  if (answer === null) {
65291
65405
  console.log(" (aborted — running all modules)");
65292
65406
  return ALL_MODULE_NAMES2;
@@ -65303,9 +65417,9 @@ async function promptForModuleSelection() {
65303
65417
  console.log(` running: ${selected.join(", ")}`);
65304
65418
  return selected;
65305
65419
  }
65306
- function readLine(prompt) {
65420
+ function readLine2(prompt) {
65307
65421
  return new Promise((resolveLine) => {
65308
- const rl = createInterface({ input: process.stdin, output: process.stdout });
65422
+ const rl = createInterface2({ input: process.stdin, output: process.stdout });
65309
65423
  rl.question(prompt, (ans) => {
65310
65424
  rl.close();
65311
65425
  resolveLine(ans);
@@ -65317,22 +65431,6 @@ function readLine(prompt) {
65317
65431
  });
65318
65432
  }
65319
65433
 
65320
- // src/engine/interactive-selector-prompt.ts
65321
- init_client();
65322
- var forceDisabled = false;
65323
- function disableInteractive() {
65324
- forceDisabled = true;
65325
- }
65326
- function isInteractiveMode() {
65327
- if (forceDisabled)
65328
- return false;
65329
- if (!process.stdout.isTTY || !process.stdin.isTTY)
65330
- return false;
65331
- if (isLlmAvailable())
65332
- return false;
65333
- return true;
65334
- }
65335
-
65336
65434
  // src/llm/aggregate-issues.ts
65337
65435
  init_client();
65338
65436
  var REPORT_ISSUES_TOOL = {
@@ -65824,13 +65922,13 @@ function formatMs(ms) {
65824
65922
  }
65825
65923
 
65826
65924
  // src/commands/serve.ts
65827
- import { existsSync as existsSync16 } from "node:fs";
65925
+ import { existsSync as existsSync17 } from "node:fs";
65828
65926
  import chalk19 from "chalk";
65829
65927
 
65830
65928
  // src/server/proxy-server.ts
65831
- import { existsSync as existsSync15, readFileSync as readFileSync20, statSync } from "node:fs";
65929
+ import { existsSync as existsSync16, readFileSync as readFileSync21, statSync } from "node:fs";
65832
65930
  import { createServer } from "node:http";
65833
- import { extname, join as join28, normalize as normalize3, resolve as resolve4, sep } from "node:path";
65931
+ import { extname, join as join28, normalize as normalize3, resolve as resolve5, sep } from "node:path";
65834
65932
  var MIME3 = {
65835
65933
  ".html": "text/html; charset=utf-8",
65836
65934
  ".css": "text/css; charset=utf-8",
@@ -65866,8 +65964,8 @@ var STRIPPED_REQUEST_HEADERS = new Set([
65866
65964
  "origin"
65867
65965
  ]);
65868
65966
  async function startProxyServer(runDir, opts = {}) {
65869
- const absRunDir = resolve4(runDir);
65870
- if (!existsSync15(absRunDir)) {
65967
+ const absRunDir = resolve5(runDir);
65968
+ if (!existsSync16(absRunDir)) {
65871
65969
  throw new Error(`Run directory not found: ${runDir}`);
65872
65970
  }
65873
65971
  const server = createServer((req, res) => {
@@ -65878,9 +65976,9 @@ async function startProxyServer(runDir, opts = {}) {
65878
65976
  } catch {}
65879
65977
  });
65880
65978
  });
65881
- await new Promise((resolve5, reject) => {
65979
+ await new Promise((resolve6, reject) => {
65882
65980
  server.once("error", reject);
65883
- server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve5());
65981
+ server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve6());
65884
65982
  });
65885
65983
  const addr = server.address();
65886
65984
  const port = typeof addr === "object" && addr ? addr.port : 0;
@@ -65888,13 +65986,13 @@ async function startProxyServer(runDir, opts = {}) {
65888
65986
  return {
65889
65987
  port,
65890
65988
  url: `http://${host}:${port}/`,
65891
- close: () => new Promise((resolve5) => {
65989
+ close: () => new Promise((resolve6) => {
65892
65990
  try {
65893
65991
  server.closeAllConnections?.();
65894
65992
  server.closeIdleConnections?.();
65895
65993
  } catch {}
65896
- server.close(() => resolve5());
65897
- setTimeout(() => resolve5(), 1000);
65994
+ server.close(() => resolve6());
65995
+ setTimeout(() => resolve6(), 1000);
65898
65996
  })
65899
65997
  };
65900
65998
  }
@@ -65925,12 +66023,12 @@ async function handleRequest(req, res, runDir) {
65925
66023
  }
65926
66024
  function serveReportHtml(res, runDir) {
65927
66025
  const filePath = join28(runDir, "report.html");
65928
- if (!existsSync15(filePath)) {
66026
+ if (!existsSync16(filePath)) {
65929
66027
  res.statusCode = 404;
65930
66028
  res.end("report.html not found");
65931
66029
  return;
65932
66030
  }
65933
- const html3 = readFileSync20(filePath, "utf8");
66031
+ const html3 = readFileSync21(filePath, "utf8");
65934
66032
  const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
65935
66033
  const out = html3.includes("</head>") ? html3.replace("</head>", `${inject}</head>`) : `${inject}${html3}`;
65936
66034
  res.statusCode = 200;
@@ -65940,13 +66038,13 @@ function serveReportHtml(res, runDir) {
65940
66038
  }
65941
66039
  function serveStatic(res, runDir, path) {
65942
66040
  const safePath3 = normalize3(path).replace(/^[/\\]+/, "");
65943
- const filePath = resolve4(runDir, safePath3);
66041
+ const filePath = resolve5(runDir, safePath3);
65944
66042
  if (!filePath.startsWith(runDir + sep) && filePath !== runDir) {
65945
66043
  res.statusCode = 403;
65946
66044
  res.end("forbidden");
65947
66045
  return;
65948
66046
  }
65949
- if (!existsSync15(filePath)) {
66047
+ if (!existsSync16(filePath)) {
65950
66048
  res.statusCode = 404;
65951
66049
  res.end("not found");
65952
66050
  return;
@@ -65961,7 +66059,7 @@ function serveStatic(res, runDir, path) {
65961
66059
  res.statusCode = 200;
65962
66060
  res.setHeader("content-type", MIME3[ext] ?? "application/octet-stream");
65963
66061
  res.setHeader("cache-control", "no-store");
65964
- res.end(readFileSync20(filePath));
66062
+ res.end(readFileSync21(filePath));
65965
66063
  }
65966
66064
  async function proxyRequest(req, res, targetUrl, opts = {}) {
65967
66065
  let target;
@@ -66100,11 +66198,11 @@ async function serveRunAndBlock(runDir, opts = {}) {
66100
66198
  }
66101
66199
  async function serveCommand(runId, opts) {
66102
66200
  const paths = getRunPaths(opts.output, runId);
66103
- if (!existsSync16(paths.runDir)) {
66201
+ if (!existsSync17(paths.runDir)) {
66104
66202
  console.error(chalk19.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
66105
66203
  return 1;
66106
66204
  }
66107
- if (!existsSync16(paths.reportHtml)) {
66205
+ if (!existsSync17(paths.reportHtml)) {
66108
66206
  console.error(chalk19.red(`✖ report.html não existe em ${paths.runDir}`));
66109
66207
  return 1;
66110
66208
  }
@@ -66352,7 +66450,7 @@ async function runCommand(rawOpts) {
66352
66450
  const ignore = loadParityIgnore();
66353
66451
  if (opts.clearCache) {
66354
66452
  const cacheFile = join29(opts.output, "cache", "verdicts.json");
66355
- if (existsSync17(cacheFile)) {
66453
+ if (existsSync18(cacheFile)) {
66356
66454
  try {
66357
66455
  unlinkSync3(cacheFile);
66358
66456
  console.log(chalk20.dim(` cache wiped: ${cacheFile}`));
@@ -66469,7 +66567,7 @@ async function runCommand(rawOpts) {
66469
66567
  b.close().catch(() => {
66470
66568
  return;
66471
66569
  }),
66472
- new Promise((resolve5) => setTimeout(resolve5, capMs))
66570
+ new Promise((resolve6) => setTimeout(resolve6, capMs))
66473
66571
  ]);
66474
66572
  };
66475
66573
  const shutdown = async (reason) => {
@@ -66745,8 +66843,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
66745
66843
  noNetworkIdle: targetIsDevServer,
66746
66844
  runs: vitalsRuns
66747
66845
  }),
66748
- new Promise((resolve5) => {
66749
- const t = setTimeout(() => resolve5(null), PER_TASK_WALLCLOCK_MS);
66846
+ new Promise((resolve6) => {
66847
+ const t = setTimeout(() => resolve6(null), PER_TASK_WALLCLOCK_MS);
66750
66848
  t.unref?.();
66751
66849
  })
66752
66850
  ]);
@@ -67071,10 +67169,10 @@ function parsePagePair(entry) {
67071
67169
  }
67072
67170
  function resolveExplicitPages(pagesFile, pagesList) {
67073
67171
  if (pagesFile) {
67074
- if (!existsSync17(pagesFile)) {
67172
+ if (!existsSync18(pagesFile)) {
67075
67173
  throw new Error(`--pages-file não encontrado: ${pagesFile}`);
67076
67174
  }
67077
- const raw = readFileSync21(pagesFile, "utf-8");
67175
+ const raw = readFileSync22(pagesFile, "utf-8");
67078
67176
  const lines = raw.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
67079
67177
  return lines.map(parsePagePair);
67080
67178
  }
@@ -67301,14 +67399,14 @@ async function prCommand(opts) {
67301
67399
  }
67302
67400
  const latest = runs[0];
67303
67401
  const reportJsonPath = join30(opts.output, "runs", latest.id, "report.json");
67304
- if (!existsSync18(reportJsonPath)) {
67402
+ if (!existsSync19(reportJsonPath)) {
67305
67403
  console.error(chalk21.red(`report.json not found at ${reportJsonPath}`));
67306
67404
  return runCode || 1;
67307
67405
  }
67308
- const run = JSON.parse(readFileSync22(reportJsonPath, "utf8"));
67406
+ const run = JSON.parse(readFileSync23(reportJsonPath, "utf8"));
67309
67407
  const markdown = buildPrComment(run, opts);
67310
67408
  if (opts.out) {
67311
- writeFileSync24(opts.out, markdown, "utf8");
67409
+ writeFileSync25(opts.out, markdown, "utf8");
67312
67410
  console.log(chalk21.dim(` wrote PR comment: ${opts.out}`));
67313
67411
  } else {
67314
67412
  process.stdout.write(`
@@ -67317,7 +67415,7 @@ ${markdown}
67317
67415
  }
67318
67416
  if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
67319
67417
  try {
67320
- writeFileSync24(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
67418
+ writeFileSync25(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
67321
67419
  } catch (err) {
67322
67420
  console.error(chalk21.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
67323
67421
  }
@@ -67378,7 +67476,7 @@ function buildPrComment(run, opts) {
67378
67476
  }
67379
67477
 
67380
67478
  // src/commands/prompt.ts
67381
- import { existsSync as existsSync19, writeFileSync as writeFileSync25 } from "node:fs";
67479
+ import { existsSync as existsSync20, writeFileSync as writeFileSync26 } from "node:fs";
67382
67480
  import chalk22 from "chalk";
67383
67481
  function promptCommand(runId, opts) {
67384
67482
  let run;
@@ -67393,9 +67491,9 @@ function promptCommand(runId, opts) {
67393
67491
  limit: opts.limit
67394
67492
  });
67395
67493
  if (opts.out) {
67396
- writeFileSync25(opts.out, md, "utf8");
67494
+ writeFileSync26(opts.out, md, "utf8");
67397
67495
  console.log(chalk22.green(`✔ prompt salvo em ${opts.out}`));
67398
- if (existsSync19(opts.out)) {
67496
+ if (existsSync20(opts.out)) {
67399
67497
  const sizeKb = (md.length / 1024).toFixed(1);
67400
67498
  console.log(chalk22.dim(` ${md.length} chars (${sizeKb} KB)`));
67401
67499
  }
@@ -67406,7 +67504,7 @@ function promptCommand(runId, opts) {
67406
67504
  }
67407
67505
 
67408
67506
  // src/commands/report.ts
67409
- import { existsSync as existsSync20, readFileSync as readFileSync23, writeFileSync as writeFileSync26 } from "node:fs";
67507
+ import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
67410
67508
  import { join as join31 } from "node:path";
67411
67509
  import chalk23 from "chalk";
67412
67510
  import open2 from "open";
@@ -67839,6 +67937,21 @@ function bySeverity(a, b) {
67839
67937
  }
67840
67938
 
67841
67939
  // src/report/extract-section.ts
67940
+ var ALL_REPORT_SECTIONS = [
67941
+ "summary",
67942
+ "visualdiff",
67943
+ "seo",
67944
+ "sidebyside",
67945
+ "issues",
67946
+ "vitals",
67947
+ "cache",
67948
+ "checks",
67949
+ "prompt",
67950
+ "pages",
67951
+ "console",
67952
+ "network",
67953
+ "diff"
67954
+ ];
67842
67955
  function extractReportSection(input) {
67843
67956
  if (input.kind === "html")
67844
67957
  return extractHtmlSection(input.html, input.section);
@@ -67988,7 +68101,7 @@ async function reportCommand(runId, opts) {
67988
68101
  }
67989
68102
  const html3 = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
67990
68103
  const dest = opts.out ?? join31(paths.runDir, "deck.html");
67991
- writeFileSync26(dest, html3, "utf8");
68104
+ writeFileSync27(dest, html3, "utf8");
67992
68105
  console.log(`${chalk23.green("✓")} deck → ${dest}`);
67993
68106
  if (opts.open) {
67994
68107
  await open2(dest).catch((err) => {
@@ -67998,6 +68111,11 @@ async function reportCommand(runId, opts) {
67998
68111
  return 0;
67999
68112
  }
68000
68113
  if (opts.section) {
68114
+ if (!ALL_REPORT_SECTIONS.includes(opts.section)) {
68115
+ console.error(chalk23.red(`unknown section "${opts.section}"`));
68116
+ console.error(chalk23.gray(` valid: ${ALL_REPORT_SECTIONS.join(", ")}`));
68117
+ return 1;
68118
+ }
68001
68119
  if (opts.json) {
68002
68120
  try {
68003
68121
  const run = loadRun(opts.output, runId);
@@ -68014,11 +68132,11 @@ async function reportCommand(runId, opts) {
68014
68132
  return 1;
68015
68133
  }
68016
68134
  }
68017
- if (!existsSync20(paths.reportHtml)) {
68135
+ if (!existsSync21(paths.reportHtml)) {
68018
68136
  console.error(chalk23.red(`report.html not found at ${paths.reportHtml}`));
68019
68137
  return 1;
68020
68138
  }
68021
- const html3 = readFileSync23(paths.reportHtml, "utf8");
68139
+ const html3 = readFileSync24(paths.reportHtml, "utf8");
68022
68140
  const slice2 = extractReportSection({ kind: "html", section: opts.section, html: html3 });
68023
68141
  if (slice2 === null) {
68024
68142
  console.error(chalk23.red(`section "${opts.section}" not present in this report`));
@@ -68035,7 +68153,7 @@ async function reportCommand(runId, opts) {
68035
68153
  }
68036
68154
 
68037
68155
  // src/commands/vitals.ts
68038
- import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
68156
+ import { existsSync as existsSync22, readFileSync as readFileSync25, writeFileSync as writeFileSync28 } from "node:fs";
68039
68157
  import { availableParallelism } from "node:os";
68040
68158
  import { join as join32 } from "node:path";
68041
68159
  import chalk24 from "chalk";
@@ -68467,7 +68585,7 @@ async function vitalsCommand(opts) {
68467
68585
  writeRunReportJson(paths.runDir, run);
68468
68586
  const html3 = renderHtmlReport(run, paths.runDir);
68469
68587
  writeRunReportHtml(paths.runDir, html3);
68470
- writeFileSync27(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
68588
+ writeFileSync28(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
68471
68589
  schemaVersion: "0.1",
68472
68590
  prodUrl: opts.prod,
68473
68591
  candUrl: opts.cand,
@@ -68571,8 +68689,8 @@ async function discoverPagePaths2(prodUrl, opts) {
68571
68689
  function parseUrlList(input) {
68572
68690
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
68573
68691
  const path = input.replace(/^file:\/\//, "");
68574
- if (existsSync21(path)) {
68575
- return readFileSync24(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
68692
+ if (existsSync22(path)) {
68693
+ return readFileSync25(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
68576
68694
  }
68577
68695
  }
68578
68696
  return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -68602,16 +68720,16 @@ function printSummary7(vitals, cache, scores, opportunities, agentic) {
68602
68720
  }
68603
68721
 
68604
68722
  // src/util/version.ts
68605
- import { readFileSync as readFileSync25 } from "node:fs";
68606
- import { dirname as dirname5, resolve as resolve5 } from "node:path";
68723
+ import { readFileSync as readFileSync26 } from "node:fs";
68724
+ import { dirname as dirname5, resolve as resolve6 } from "node:path";
68607
68725
  import { fileURLToPath } from "node:url";
68608
68726
  function getPackageVersion() {
68609
68727
  try {
68610
68728
  const here = dirname5(fileURLToPath(import.meta.url));
68611
68729
  for (const up of ["..", "../..", "../../.."]) {
68612
68730
  try {
68613
- const pkgPath = resolve5(here, up, "package.json");
68614
- const raw = readFileSync25(pkgPath, "utf8");
68731
+ const pkgPath = resolve6(here, up, "package.json");
68732
+ const raw = readFileSync26(pkgPath, "utf8");
68615
68733
  const parsed = JSON.parse(raw);
68616
68734
  if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
68617
68735
  return parsed.version;