@decocms/parity 0.26.17 → 0.26.19

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 +693 -510
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -42155,7 +42155,7 @@ function baselineUnset(name) {
42155
42155
  }
42156
42156
 
42157
42157
  // src/commands/benchmark.ts
42158
- import { writeFileSync as writeFileSync7 } from "node:fs";
42158
+ import { writeFileSync as writeFileSync8 } from "node:fs";
42159
42159
  import { join as join10 } from "node:path";
42160
42160
  import chalk3 from "chalk";
42161
42161
  import ora2 from "ora";
@@ -42531,6 +42531,110 @@ function isLocalhost(rawUrl) {
42531
42531
  }
42532
42532
  }
42533
42533
 
42534
+ // src/engine/interactive-selector-prompt.ts
42535
+ init_client();
42536
+ import { execSync } from "node:child_process";
42537
+ import { existsSync as existsSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "node:fs";
42538
+ import { resolve } from "node:path";
42539
+ import { createInterface } from "node:readline";
42540
+ var forceDisabled = false;
42541
+ function disableInteractive() {
42542
+ forceDisabled = true;
42543
+ }
42544
+ function isInteractiveMode() {
42545
+ if (forceDisabled)
42546
+ return false;
42547
+ if (!process.stdout.isTTY || !process.stdin.isTTY)
42548
+ return false;
42549
+ if (isLlmAvailable())
42550
+ return false;
42551
+ return true;
42552
+ }
42553
+ var PARITYRC_FILENAME = ".parityrc.json";
42554
+ async function promptForSelector(input) {
42555
+ const cwd = input.cwd ?? process.cwd();
42556
+ printContextHeader(input);
42557
+ const selector = await readLine("Selector for this step (or blank to skip): ");
42558
+ if (!selector?.trim()) {
42559
+ console.log(" (no selector entered — continuing without override)");
42560
+ return null;
42561
+ }
42562
+ const trimmed = selector.trim();
42563
+ const rcPath = resolve(cwd, PARITYRC_FILENAME);
42564
+ writeSelectorOverride(rcPath, input.selectorKey, trimmed);
42565
+ console.log(` ✓ wrote selectors.${input.selectorKey} = ${trimmed} → ${rcPath}`);
42566
+ tryOpenInEditor(rcPath);
42567
+ return trimmed;
42568
+ }
42569
+ function buildStructuredError(input) {
42570
+ return {
42571
+ kind: "missing-selector",
42572
+ selectorKey: input.selectorKey,
42573
+ intendedAction: input.intendedAction,
42574
+ alreadyTried: input.alreadyTried,
42575
+ pageUrl: input.pageUrl,
42576
+ htmlSnapshot: input.htmlSnapshot.slice(0, 2000),
42577
+ suggestedRcPath: resolve(input.cwd ?? process.cwd(), PARITYRC_FILENAME)
42578
+ };
42579
+ }
42580
+ function printContextHeader(input) {
42581
+ const bar = "─".repeat(60);
42582
+ console.log("");
42583
+ console.log(bar);
42584
+ console.log(`⚠ Selector missing: ${input.selectorKey}`);
42585
+ console.log(bar);
42586
+ console.log(` step: ${input.intendedAction}`);
42587
+ console.log(` page: ${input.pageUrl}`);
42588
+ if (input.alreadyTried.length > 0) {
42589
+ console.log(` tried: ${input.alreadyTried.slice(0, 5).join(", ")}`);
42590
+ }
42591
+ console.log("");
42592
+ console.log(" HTML snapshot (top of page):");
42593
+ const lines = input.htmlSnapshot.split(`
42594
+ `).slice(0, 25);
42595
+ for (const ln of lines)
42596
+ console.log(` | ${ln}`);
42597
+ if (input.htmlSnapshot.split(`
42598
+ `).length > 25)
42599
+ console.log(" | … (truncated)");
42600
+ console.log("");
42601
+ }
42602
+ function readLine(prompt) {
42603
+ return new Promise((resolveLine) => {
42604
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
42605
+ rl.question(prompt, (answer) => {
42606
+ rl.close();
42607
+ resolveLine(answer);
42608
+ });
42609
+ rl.on("SIGINT", () => {
42610
+ rl.close();
42611
+ resolveLine(null);
42612
+ });
42613
+ });
42614
+ }
42615
+ function writeSelectorOverride(rcPath, key, value) {
42616
+ let current = {};
42617
+ if (existsSync4(rcPath)) {
42618
+ try {
42619
+ const parsed = JSON.parse(readFileSync3(rcPath, "utf8"));
42620
+ if (parsed && typeof parsed === "object")
42621
+ current = parsed;
42622
+ } catch {
42623
+ console.log(` ⚠ existing ${PARITYRC_FILENAME} was not valid JSON; overwriting.`);
42624
+ }
42625
+ }
42626
+ current.selectors = { ...current.selectors ?? {}, [key]: value };
42627
+ writeFileSync5(rcPath, `${JSON.stringify(current, null, 2)}
42628
+ `, "utf8");
42629
+ }
42630
+ function tryOpenInEditor(rcPath) {
42631
+ if (process.platform !== "darwin")
42632
+ return;
42633
+ try {
42634
+ execSync(`open ${JSON.stringify(rcPath)}`, { stdio: "ignore" });
42635
+ } catch {}
42636
+ }
42637
+
42534
42638
  // src/llm/pick-plp.ts
42535
42639
  init_client();
42536
42640
  var PATH_BLOCKLIST = [
@@ -42606,7 +42710,7 @@ ${candidates.map((c, i) => `${i}. "${c.text}" → ${c.href}`).join(`
42606
42710
  }
42607
42711
 
42608
42712
  // src/learned/repo.ts
42609
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync3, renameSync, writeFileSync as writeFileSync5 } from "node:fs";
42713
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync6 } from "node:fs";
42610
42714
  import { dirname as dirname2 } from "node:path";
42611
42715
  import { z as z2 } from "zod";
42612
42716
  var SelectorKey = z2.enum([
@@ -42679,10 +42783,10 @@ function emptyLib() {
42679
42783
  return { schemaVersion: "0.1", platforms: {} };
42680
42784
  }
42681
42785
  function loadLearned(path = DEFAULT_PATH) {
42682
- if (!existsSync4(path))
42786
+ if (!existsSync5(path))
42683
42787
  return emptyLib();
42684
42788
  try {
42685
- const raw = JSON.parse(readFileSync3(path, "utf8"));
42789
+ const raw = JSON.parse(readFileSync4(path, "utf8"));
42686
42790
  return LearnedSelectors.parse(raw);
42687
42791
  } catch (err) {
42688
42792
  console.warn(`[learned] failed to parse ${path}: ${err.message}, starting fresh`);
@@ -42691,10 +42795,10 @@ function loadLearned(path = DEFAULT_PATH) {
42691
42795
  }
42692
42796
  function saveLearned(lib, path = DEFAULT_PATH) {
42693
42797
  const dir = dirname2(path);
42694
- if (dir && dir !== "." && !existsSync4(dir))
42798
+ if (dir && dir !== "." && !existsSync5(dir))
42695
42799
  mkdirSync4(dir, { recursive: true });
42696
42800
  const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
42697
- writeFileSync5(tmp, `${JSON.stringify(lib, null, 2)}
42801
+ writeFileSync6(tmp, `${JSON.stringify(lib, null, 2)}
42698
42802
  `, "utf8");
42699
42803
  renameSync(tmp, path);
42700
42804
  }
@@ -43223,7 +43327,7 @@ async function screenshotStable(page, opts) {
43223
43327
  stabilizeCarousels(page).catch(() => {
43224
43328
  return;
43225
43329
  }),
43226
- new Promise((resolve) => setTimeout(resolve, 3000))
43330
+ new Promise((resolve2) => setTimeout(resolve2, 3000))
43227
43331
  ]);
43228
43332
  const isJpeg = /\.jpe?g$/i.test(opts.path);
43229
43333
  await page.screenshot({
@@ -43246,7 +43350,7 @@ function dlog2(ctx, msg) {
43246
43350
  function withCap(p, capMs, fallback) {
43247
43351
  return Promise.race([
43248
43352
  p.catch(() => fallback),
43249
- new Promise((resolve) => setTimeout(() => resolve(fallback), capMs))
43353
+ new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
43250
43354
  ]);
43251
43355
  }
43252
43356
  var VARIANT_REQUIRED_TEXT_PATTERNS = [
@@ -43467,6 +43571,34 @@ async function findElement(page, ctx, opts) {
43467
43571
  return { ...recovered, recoveredByLlm: true };
43468
43572
  }
43469
43573
  }
43574
+ if (opts.key) {
43575
+ const supplied = await resolveMissingSelector(page, opts.key, opts.intent, tried);
43576
+ if (supplied) {
43577
+ const el = page.locator(supplied).first();
43578
+ if (await el.isVisible({ timeout: 2000 }).catch(() => false)) {
43579
+ return { locator: el, selector: supplied, recoveredByLlm: false };
43580
+ }
43581
+ }
43582
+ }
43583
+ return null;
43584
+ }
43585
+ var reportedMissing = new Set;
43586
+ async function resolveMissingSelector(page, key, intent, tried) {
43587
+ const input = {
43588
+ selectorKey: key,
43589
+ intendedAction: intent,
43590
+ alreadyTried: tried,
43591
+ pageUrl: page.url(),
43592
+ htmlSnapshot: await page.content().catch(() => "")
43593
+ };
43594
+ if (isInteractiveMode()) {
43595
+ return await promptForSelector(input).catch(() => null);
43596
+ }
43597
+ if (reportedMissing.has(key))
43598
+ return null;
43599
+ reportedMissing.add(key);
43600
+ process.stderr.write(`${JSON.stringify(buildStructuredError(input))}
43601
+ `);
43470
43602
  return null;
43471
43603
  }
43472
43604
  async function attemptRecovery(page, _ctx, stepName, intendedAction, alreadyTried, diagnostics) {
@@ -43902,7 +44034,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43902
44034
  if (viewport === "desktop") {
43903
44035
  try {
43904
44036
  const observedHoverDrawer = await page.evaluate(async () => {
43905
- return await new Promise((resolve) => {
44037
+ return await new Promise((resolve2) => {
43906
44038
  const selectorMatch = (el) => {
43907
44039
  if (!(el instanceof HTMLElement))
43908
44040
  return false;
@@ -43916,13 +44048,13 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43916
44048
  for (const n of Array.from(m.addedNodes)) {
43917
44049
  if (n instanceof Element && selectorMatch(n)) {
43918
44050
  observer.disconnect();
43919
- resolve(true);
44051
+ resolve2(true);
43920
44052
  return;
43921
44053
  }
43922
44054
  }
43923
44055
  if (m.type === "attributes" && m.target instanceof Element && selectorMatch(m.target)) {
43924
44056
  observer.disconnect();
43925
- resolve(true);
44057
+ resolve2(true);
43926
44058
  return;
43927
44059
  }
43928
44060
  }
@@ -43935,7 +44067,7 @@ async function detectCartRevealMode(page, trigger, drawerAlreadyOpen, viewport)
43935
44067
  });
43936
44068
  setTimeout(() => {
43937
44069
  observer.disconnect();
43938
- resolve(false);
44070
+ resolve2(false);
43939
44071
  }, 600);
43940
44072
  });
43941
44073
  });
@@ -44065,7 +44197,7 @@ async function openMinicart(page, trigger, ctx, expectedProductTitle) {
44065
44197
  dlog2(ctx, ` openMinicart: starting — trigger=${trigger.selector} title=${expectedProductTitle?.slice(0, 40) ?? "none"} revealBudget=${revealBudget}ms`);
44066
44198
  await Promise.race([
44067
44199
  dismissOverlays(page, ctx),
44068
- new Promise((resolve) => setTimeout(resolve, 4000))
44200
+ new Promise((resolve2) => setTimeout(resolve2, 4000))
44069
44201
  ]);
44070
44202
  dlog2(ctx, " openMinicart: dismissOverlays done — checking alreadyOpen…");
44071
44203
  await page.waitForTimeout(800);
@@ -44416,10 +44548,10 @@ async function waitForCartMutation(page, ctx, predicate, capMs = 2500) {
44416
44548
  if (predicate(totals))
44417
44549
  return totals;
44418
44550
  if (responseSeen) {
44419
- await new Promise((resolve) => setTimeout(resolve, 300));
44551
+ await new Promise((resolve2) => setTimeout(resolve2, 300));
44420
44552
  return await parseCartTotals(page, ctx);
44421
44553
  }
44422
- await new Promise((resolve) => setTimeout(resolve, 250));
44554
+ await new Promise((resolve2) => setTimeout(resolve2, 250));
44423
44555
  totals = await parseCartTotals(page, ctx);
44424
44556
  }
44425
44557
  return totals;
@@ -45341,7 +45473,7 @@ async function flowPurchaseJourney(ctx) {
45341
45473
  await screenshotStable(page, { path: spBefore9, fullPage: false });
45342
45474
  await Promise.race([
45343
45475
  dismissOverlays(page, ctx),
45344
- new Promise((resolve) => setTimeout(resolve, 4000))
45476
+ new Promise((resolve2) => setTimeout(resolve2, 4000))
45345
45477
  ]);
45346
45478
  let usedSelector = checkoutHit.selector;
45347
45479
  let clickedText = await checkoutHit.locator.innerText().catch(() => "");
@@ -45681,7 +45813,7 @@ async function validateAddToCart(page, ctx, cartCountBefore, beforeUrl) {
45681
45813
 
45682
45814
  // src/engine/lighthouse.ts
45683
45815
  import { spawn } from "node:child_process";
45684
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync4 } from "node:fs";
45816
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync5 } from "node:fs";
45685
45817
  import { join as join7 } from "node:path";
45686
45818
  var AGENT_A11Y_AUDIT_IDS = [
45687
45819
  "button-name",
@@ -45792,7 +45924,7 @@ async function measureLighthouseOnce(url, opts, attempt) {
45792
45924
  "--quiet",
45793
45925
  "--max-wait-for-load=90000"
45794
45926
  ];
45795
- const { code, stderr } = await new Promise((resolve) => {
45927
+ const { code, stderr } = await new Promise((resolve2) => {
45796
45928
  const proc = spawn("npx", args, {
45797
45929
  shell: true,
45798
45930
  stdio: ["ignore", "ignore", "pipe"],
@@ -45802,12 +45934,12 @@ async function measureLighthouseOnce(url, opts, attempt) {
45802
45934
  proc.stderr.on("data", (chunk) => {
45803
45935
  stderrBuf += chunk.toString();
45804
45936
  });
45805
- proc.on("close", (exitCode) => resolve({ code: exitCode ?? 1, stderr: stderrBuf }));
45806
- proc.on("error", (err) => resolve({ code: 1, stderr: err.message }));
45937
+ proc.on("close", (exitCode) => resolve2({ code: exitCode ?? 1, stderr: stderrBuf }));
45938
+ proc.on("error", (err) => resolve2({ code: 1, stderr: err.message }));
45807
45939
  });
45808
45940
  let report;
45809
45941
  try {
45810
- report = JSON.parse(readFileSync4(outPath, "utf-8"));
45942
+ report = JSON.parse(readFileSync5(outPath, "utf-8"));
45811
45943
  } catch (err) {
45812
45944
  return {
45813
45945
  error: code !== 0 ? `lighthouse exit ${code}: ${stderr.slice(0, 200)}` : `parse failed: ${err.message}`
@@ -47035,14 +47167,14 @@ async function runSideBenchmarkContent(opts) {
47035
47167
  }
47036
47168
 
47037
47169
  // src/ignore/parser.ts
47038
- import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
47170
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
47039
47171
  import { join as join8 } from "node:path";
47040
47172
  function loadParityRc(cwd = process.cwd()) {
47041
47173
  const path = join8(cwd, ".parityrc.json");
47042
- if (!existsSync5(path))
47174
+ if (!existsSync6(path))
47043
47175
  return ParityRc.parse({});
47044
47176
  try {
47045
- const raw = JSON.parse(readFileSync5(path, "utf8"));
47177
+ const raw = JSON.parse(readFileSync6(path, "utf8"));
47046
47178
  return ParityRc.parse(raw);
47047
47179
  } catch (err) {
47048
47180
  console.warn(`[parity] failed to parse ${path}: ${err.message}`);
@@ -47051,10 +47183,10 @@ function loadParityRc(cwd = process.cwd()) {
47051
47183
  }
47052
47184
  function loadParityIgnore(cwd = process.cwd()) {
47053
47185
  const path = join8(cwd, ".parityignore");
47054
- if (!existsSync5(path))
47186
+ if (!existsSync6(path))
47055
47187
  return ParityIgnore.parse({});
47056
47188
  try {
47057
- const raw = JSON.parse(readFileSync5(path, "utf8"));
47189
+ const raw = JSON.parse(readFileSync6(path, "utf8"));
47058
47190
  return ParityIgnore.parse(raw);
47059
47191
  } catch (err) {
47060
47192
  console.warn(`[parity] failed to parse ${path}: ${err.message}`);
@@ -47165,7 +47297,7 @@ init_client();
47165
47297
  init_client();
47166
47298
  init_html_compact();
47167
47299
  init_html_compact();
47168
- import { existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync6, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
47300
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync7, unlinkSync as unlinkSync2, writeFileSync as writeFileSync7 } from "node:fs";
47169
47301
  import { join as join9 } from "node:path";
47170
47302
  import { z as z3 } from "zod";
47171
47303
  var CACHE_DIR = ".parity-cache";
@@ -47435,7 +47567,7 @@ async function discoverSelectors(urls, html3, opts = {}) {
47435
47567
  const cacheDir = opts.cacheDir ?? CACHE_DIR;
47436
47568
  const cachePath = join9(cacheDir, `selectors-${host}.json`);
47437
47569
  const fingerprint = computeHtmlFingerprint(html3.home);
47438
- if (!opts.noCache && existsSync6(cachePath)) {
47570
+ if (!opts.noCache && existsSync7(cachePath)) {
47439
47571
  const cached = readCacheEntry(cachePath, fingerprint);
47440
47572
  if (cached)
47441
47573
  return cached.selectors;
@@ -47484,7 +47616,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
47484
47616
  console.warn(`[discover-selectors] checkout_button == minicart_trigger (\`${selectors.checkoutButton}\`); dropping to avoid step-9 misclick`);
47485
47617
  selectors.checkoutButton = undefined;
47486
47618
  }
47487
- if (!existsSync6(cacheDir))
47619
+ if (!existsSync7(cacheDir))
47488
47620
  mkdirSync6(cacheDir, { recursive: true });
47489
47621
  const entry = {
47490
47622
  schemaVersion: CACHE_SCHEMA_VERSION,
@@ -47492,7 +47624,7 @@ ${compactHtmlForSelectors(html3.pdp, PDP_MAX_CHARS)}
47492
47624
  htmlFingerprint: fingerprint,
47493
47625
  selectors
47494
47626
  };
47495
- writeFileSync6(cachePath, `${JSON.stringify(entry, null, 2)}
47627
+ writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
47496
47628
  `, "utf8");
47497
47629
  return selectors;
47498
47630
  }
@@ -47506,7 +47638,7 @@ function cacheTtlMs() {
47506
47638
  function readCacheEntry(cachePath, currentFingerprint) {
47507
47639
  let parsed;
47508
47640
  try {
47509
- parsed = JSON.parse(readFileSync6(cachePath, "utf8"));
47641
+ parsed = JSON.parse(readFileSync7(cachePath, "utf8"));
47510
47642
  } catch {
47511
47643
  console.warn(`[discover-selectors] cache corrompido em ${cachePath}; redescubrindo`);
47512
47644
  try {
@@ -47533,14 +47665,14 @@ function readCacheEntry(cachePath, currentFingerprint) {
47533
47665
  function persistSelectorValidation(homeUrl, validated, cacheDir = CACHE_DIR) {
47534
47666
  const host = safeHost(homeUrl);
47535
47667
  const cachePath = join9(cacheDir, `selectors-${host}.json`);
47536
- if (!existsSync6(cachePath))
47668
+ if (!existsSync7(cachePath))
47537
47669
  return;
47538
47670
  try {
47539
- const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(readFileSync6(cachePath, "utf8")));
47671
+ const parsed = SelectorCacheEntrySchema.safeParse(JSON.parse(readFileSync7(cachePath, "utf8")));
47540
47672
  if (!parsed.success)
47541
47673
  return;
47542
47674
  const entry = { ...parsed.data, validated };
47543
- writeFileSync6(cachePath, `${JSON.stringify(entry, null, 2)}
47675
+ writeFileSync7(cachePath, `${JSON.stringify(entry, null, 2)}
47544
47676
  `, "utf8");
47545
47677
  } catch {}
47546
47678
  }
@@ -47577,7 +47709,7 @@ function safeHost(url) {
47577
47709
  }
47578
47710
 
47579
47711
  // src/report/benchmark-html.ts
47580
- import { readFileSync as readFileSync7 } from "node:fs";
47712
+ import { readFileSync as readFileSync8 } from "node:fs";
47581
47713
  var MIME = {
47582
47714
  ".png": "image/png",
47583
47715
  ".jpg": "image/jpeg",
@@ -47592,7 +47724,7 @@ function dataUri(absPath) {
47592
47724
  const mime = MIME[ext];
47593
47725
  if (!mime)
47594
47726
  return null;
47595
- return `data:${mime};base64,${readFileSync7(absPath).toString("base64")}`;
47727
+ return `data:${mime};base64,${readFileSync8(absPath).toString("base64")}`;
47596
47728
  } catch {
47597
47729
  return null;
47598
47730
  }
@@ -48283,10 +48415,10 @@ async function benchmarkCommand(opts) {
48283
48415
  logo,
48284
48416
  sides
48285
48417
  };
48286
- writeFileSync7(paths.reportJson, `${JSON.stringify(report, null, 2)}
48418
+ writeFileSync8(paths.reportJson, `${JSON.stringify(report, null, 2)}
48287
48419
  `, "utf8");
48288
48420
  const html3 = renderBenchmarkHtml(report, { lang });
48289
- writeFileSync7(paths.reportHtml, html3, "utf8");
48421
+ writeFileSync8(paths.reportHtml, html3, "utf8");
48290
48422
  printSummary2(report);
48291
48423
  console.log(chalk3.dim(` → ${paths.reportHtml}`));
48292
48424
  console.log(chalk3.dim(` → HAR: ${paths.harDir}/user-navigation-benchmark-*.har`));
@@ -48326,7 +48458,7 @@ function printSummary2(report) {
48326
48458
  }
48327
48459
 
48328
48460
  // src/commands/cache.ts
48329
- import { existsSync as existsSync9, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
48461
+ import { existsSync as existsSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
48330
48462
  import { join as join13 } from "node:path";
48331
48463
  import chalk4 from "chalk";
48332
48464
  import ora3 from "ora";
@@ -52970,11 +53102,11 @@ function skip6(start, summary) {
52970
53102
  }
52971
53103
 
52972
53104
  // src/checks/visual-regression.ts
52973
- import { existsSync as existsSync8, mkdirSync as mkdirSync8 } from "node:fs";
53105
+ import { existsSync as existsSync9, mkdirSync as mkdirSync8 } from "node:fs";
52974
53106
  import { basename, join as join12 } from "node:path";
52975
53107
 
52976
53108
  // src/diff/visual.ts
52977
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
53109
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "node:fs";
52978
53110
  import pixelmatch from "pixelmatch";
52979
53111
  import { PNG } from "pngjs";
52980
53112
  var DEFAULTS = {
@@ -52983,8 +53115,8 @@ var DEFAULTS = {
52983
53115
  };
52984
53116
  function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
52985
53117
  const cfg = { ...DEFAULTS, ...opts };
52986
- const prod = PNG.sync.read(readFileSync8(prodPath));
52987
- const cand = PNG.sync.read(readFileSync8(candPath));
53118
+ const prod = PNG.sync.read(readFileSync9(prodPath));
53119
+ const cand = PNG.sync.read(readFileSync9(candPath));
52988
53120
  const width = Math.min(prod.width, cand.width);
52989
53121
  const height = Math.min(prod.height, cand.height);
52990
53122
  const prodCropped = cropPng(prod, width, height);
@@ -52993,7 +53125,7 @@ function diffScreenshots(prodPath, candPath, heatmapPath, opts = {}) {
52993
53125
  const diffPixels = pixelmatch(prodCropped.data, candCropped.data, diff.data, width, height, {
52994
53126
  threshold: cfg.threshold
52995
53127
  });
52996
- writeFileSync8(heatmapPath, PNG.sync.write(diff));
53128
+ writeFileSync9(heatmapPath, PNG.sync.write(diff));
52997
53129
  const totalPixels = width * height;
52998
53130
  const pctDiff = totalPixels > 0 ? diffPixels / totalPixels : 0;
52999
53131
  const passed = pctDiff <= cfg.maxPctDiff;
@@ -53025,7 +53157,7 @@ init_client();
53025
53157
 
53026
53158
  // src/llm/visual-semantic-diff.ts
53027
53159
  init_client();
53028
- import { readFileSync as readFileSync9 } from "node:fs";
53160
+ import { readFileSync as readFileSync10 } from "node:fs";
53029
53161
  import { PNG as PNG2 } from "pngjs";
53030
53162
  var MAX_HEIGHT = 8000;
53031
53163
  var LLM_PROMPT_VERSION = "v4-text-caution";
@@ -53170,7 +53302,7 @@ Se NÃO houver diferenças relevantes (só ruído), retorne differences: []. Nã
53170
53302
  Cap 8 diferenças por análise — só as que mais importam.
53171
53303
  `.trim();
53172
53304
  function loadCroppedPngBase64(path, maxHeight = MAX_HEIGHT) {
53173
- const png = PNG2.sync.read(readFileSync9(path));
53305
+ const png = PNG2.sync.read(readFileSync10(path));
53174
53306
  if (png.height <= maxHeight) {
53175
53307
  return PNG2.sync.write(png).toString("base64");
53176
53308
  }
@@ -53289,13 +53421,13 @@ function partitionExpectedSections(sections, expected) {
53289
53421
 
53290
53422
  // src/checks/lib/parity-cache.ts
53291
53423
  import { createHash as createHash2 } from "node:crypto";
53292
- import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
53424
+ import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "node:fs";
53293
53425
  import { dirname as dirname3, join as join11 } from "node:path";
53294
53426
  function hashScreenshotPair(prodPath, candPath, promptVersion) {
53295
53427
  const h = createHash2("sha256");
53296
- h.update(readFileSync10(prodPath));
53428
+ h.update(readFileSync11(prodPath));
53297
53429
  h.update("|");
53298
- h.update(readFileSync10(candPath));
53430
+ h.update(readFileSync11(candPath));
53299
53431
  h.update("|");
53300
53432
  h.update(promptVersion);
53301
53433
  return h.digest("hex");
@@ -53305,10 +53437,10 @@ function cacheFilePath(cacheDir) {
53305
53437
  }
53306
53438
  function readCache(cacheDir) {
53307
53439
  const file = cacheFilePath(cacheDir);
53308
- if (!existsSync7(file))
53440
+ if (!existsSync8(file))
53309
53441
  return {};
53310
53442
  try {
53311
- const raw = readFileSync10(file, "utf-8");
53443
+ const raw = readFileSync11(file, "utf-8");
53312
53444
  const parsed = JSON.parse(raw);
53313
53445
  if (parsed && typeof parsed === "object")
53314
53446
  return parsed;
@@ -53320,7 +53452,7 @@ function readCache(cacheDir) {
53320
53452
  function writeCache(cacheDir, cache) {
53321
53453
  const file = cacheFilePath(cacheDir);
53322
53454
  mkdirSync7(dirname3(file), { recursive: true });
53323
- writeFileSync9(file, JSON.stringify(cache, null, 2));
53455
+ writeFileSync10(file, JSON.stringify(cache, null, 2));
53324
53456
  }
53325
53457
  function getCacheEntry(cache, hash2, currentPromptVersion) {
53326
53458
  const entry = cache[hash2];
@@ -53433,7 +53565,7 @@ async function visualRegressionKeyframes(ctx) {
53433
53565
  const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
53434
53566
  const issues = [];
53435
53567
  const diffDir = join12(ctx.outDir, "screenshots");
53436
- if (!existsSync8(diffDir))
53568
+ if (!existsSync9(diffDir))
53437
53569
  mkdirSync8(diffDir, { recursive: true });
53438
53570
  const expectedDivergences = ctx.ignore.expectedDivergences ?? [];
53439
53571
  const useLlm = isLlmAvailable();
@@ -53442,7 +53574,7 @@ async function visualRegressionKeyframes(ctx) {
53442
53574
  const cache = ctx.cacheDir && !ctx.noCache ? readCache(ctx.cacheDir) : {};
53443
53575
  const prepared = [];
53444
53576
  for (const pair of pairs) {
53445
- if (!existsSync8(pair.prod.screenshotPath) || !existsSync8(pair.cand.screenshotPath)) {
53577
+ if (!existsSync9(pair.prod.screenshotPath) || !existsSync9(pair.cand.screenshotPath)) {
53446
53578
  continue;
53447
53579
  }
53448
53580
  const heatmapName = `diff-${pair.viewport}-${basename(pair.key.replace(/[/:]/g, "_"))}.png`;
@@ -56171,7 +56303,7 @@ async function cacheCommand(opts) {
56171
56303
  writeRunReportJson(paths.runDir, run);
56172
56304
  const html3 = renderHtmlReport(run, paths.runDir);
56173
56305
  writeRunReportHtml(paths.runDir, html3);
56174
- writeFileSync10(join13(paths.runDir, "cache.json"), `${JSON.stringify({
56306
+ writeFileSync11(join13(paths.runDir, "cache.json"), `${JSON.stringify({
56175
56307
  schemaVersion: "0.1",
56176
56308
  prodUrl: opts.prod,
56177
56309
  candUrl: opts.cand,
@@ -56231,8 +56363,8 @@ async function discoverPagePaths(prodUrl, opts, limit) {
56231
56363
  if (opts.urls) {
56232
56364
  if (opts.urls.endsWith(".txt") || opts.urls.endsWith(".list") || opts.urls.startsWith("file:")) {
56233
56365
  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}`);
56366
+ if (existsSync10(path)) {
56367
+ return readFileSync12(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
56236
56368
  }
56237
56369
  }
56238
56370
  return opts.urls.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -56836,7 +56968,7 @@ async function cssTraceCommand(opts) {
56836
56968
  }
56837
56969
 
56838
56970
  // src/commands/e2e.ts
56839
- import { writeFileSync as writeFileSync12 } from "node:fs";
56971
+ import { writeFileSync as writeFileSync13 } from "node:fs";
56840
56972
  import { spawn as spawn2 } from "node:child_process";
56841
56973
  import chalk9 from "chalk";
56842
56974
  import ora5 from "ora";
@@ -57788,7 +57920,7 @@ async function flowLogin(ctx) {
57788
57920
 
57789
57921
  // src/llm/resolve-search-terms.ts
57790
57922
  init_client();
57791
- import { existsSync as existsSync10, mkdirSync as mkdirSync9, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
57923
+ import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
57792
57924
  import { join as join15 } from "node:path";
57793
57925
  var CACHE_DIR2 = ".parity-cache";
57794
57926
  var FALLBACK_TERMS = ["produto", "preto", "promocao"];
@@ -57870,9 +58002,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57870
58002
  const host = safeHost3(url);
57871
58003
  const cacheDir = opts.cacheDir ?? CACHE_DIR2;
57872
58004
  const cachePath = join15(cacheDir, `search-terms-${host}.json`);
57873
- if (!opts.noCache && existsSync10(cachePath)) {
58005
+ if (!opts.noCache && existsSync11(cachePath)) {
57874
58006
  try {
57875
- const cached = JSON.parse(readFileSync12(cachePath, "utf8"));
58007
+ const cached = JSON.parse(readFileSync13(cachePath, "utf8"));
57876
58008
  if (cached.withResults?.trim()) {
57877
58009
  return { withResults: cached.withResults.trim(), noResults };
57878
58010
  }
@@ -57880,9 +58012,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57880
58012
  }
57881
58013
  const suggested = await suggestTermViaLlm(url, html3);
57882
58014
  if (suggested) {
57883
- if (!existsSync10(cacheDir))
58015
+ if (!existsSync11(cacheDir))
57884
58016
  mkdirSync9(cacheDir, { recursive: true });
57885
- writeFileSync11(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
58017
+ writeFileSync12(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
57886
58018
  `, "utf8");
57887
58019
  return { withResults: suggested, noResults };
57888
58020
  }
@@ -58573,10 +58705,10 @@ async function runFlow(flow, ctx) {
58573
58705
  });
58574
58706
  let timer;
58575
58707
  let cleanup = Promise.resolve();
58576
- const timeoutPromise = new Promise((resolve) => {
58708
+ const timeoutPromise = new Promise((resolve2) => {
58577
58709
  timer = setTimeout(() => {
58578
58710
  const pages = ctx.ctx.pages();
58579
- resolve(finalize(flow, ctx, [], [
58711
+ resolve2(finalize(flow, ctx, [], [
58580
58712
  {
58581
58713
  step: 0,
58582
58714
  name: "flow-timeout",
@@ -58625,7 +58757,7 @@ var PROBE_TIMEOUT_MS = 2000;
58625
58757
  function withTimeout(p, capMs, fallback) {
58626
58758
  return Promise.race([
58627
58759
  p.catch(() => fallback),
58628
- new Promise((resolve) => setTimeout(() => resolve(fallback), capMs))
58760
+ new Promise((resolve2) => setTimeout(() => resolve2(fallback), capMs))
58629
58761
  ]);
58630
58762
  }
58631
58763
  function selectorKeysOf(selectors) {
@@ -59100,8 +59232,8 @@ async function e2eCommand(opts) {
59100
59232
  generatedAt: new Date().toISOString(),
59101
59233
  durationMs
59102
59234
  });
59103
- writeFileSync12(paths.reportHtml, html3, "utf8");
59104
- writeFileSync12(paths.reportJson, `${JSON.stringify({
59235
+ writeFileSync13(paths.reportHtml, html3, "utf8");
59236
+ writeFileSync13(paths.reportJson, `${JSON.stringify({
59105
59237
  runId,
59106
59238
  mode: "e2e",
59107
59239
  url: opts.url,
@@ -59307,12 +59439,12 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
59307
59439
 
59308
59440
  // src/commands/extract.ts
59309
59441
  import { mkdirSync as mkdirSync13 } from "node:fs";
59310
- import { resolve as resolve2 } from "node:path";
59442
+ import { resolve as resolve3 } from "node:path";
59311
59443
  import chalk12 from "chalk";
59312
59444
 
59313
59445
  // src/llm/section-understanding.ts
59314
59446
  init_client();
59315
- import { readFileSync as readFileSync13 } from "node:fs";
59447
+ import { readFileSync as readFileSync14 } from "node:fs";
59316
59448
  var SUMMARIZE_TOOL = {
59317
59449
  name: "summarize_understanding",
59318
59450
  description: "Return a single paragraph describing what you understood from the section diff signals. NO code — only diagnosis.",
@@ -59350,7 +59482,7 @@ async function invokeUnderstandingSummary(input) {
59350
59482
  return null;
59351
59483
  let markdown;
59352
59484
  try {
59353
- markdown = readFileSync13(input.markdownPath, "utf8");
59485
+ markdown = readFileSync14(input.markdownPath, "utf8");
59354
59486
  } catch (err) {
59355
59487
  console.error(`[section-understanding] failed to read markdown: ${err.message}`);
59356
59488
  return null;
@@ -59360,7 +59492,7 @@ async function invokeUnderstandingSummary(input) {
59360
59492
  if (!p)
59361
59493
  continue;
59362
59494
  try {
59363
- const buf = readFileSync13(p);
59495
+ const buf = readFileSync14(p);
59364
59496
  images.push({ base64: buf.toString("base64"), mediaType: "image/png" });
59365
59497
  } catch (err) {
59366
59498
  console.error(`[section-understanding] skipping image ${p}: ${err.message}`);
@@ -59637,19 +59769,19 @@ function collectCandidatesInPage() {
59637
59769
  }
59638
59770
 
59639
59771
  // src/extract/exporters/json.ts
59640
- import { writeFileSync as writeFileSync13 } from "node:fs";
59772
+ import { writeFileSync as writeFileSync14 } from "node:fs";
59641
59773
  import { join as join16 } from "node:path";
59642
59774
  var jsonExporter = {
59643
59775
  name: "json",
59644
59776
  async export(bundle, outDir) {
59645
59777
  const path = join16(outDir, "manifest.json");
59646
- writeFileSync13(path, `${JSON.stringify(bundle, null, 2)}
59778
+ writeFileSync14(path, `${JSON.stringify(bundle, null, 2)}
59647
59779
  `, "utf8");
59648
59780
  }
59649
59781
  };
59650
59782
 
59651
59783
  // src/extract/exporters/markdown.ts
59652
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync14 } from "node:fs";
59784
+ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync15 } from "node:fs";
59653
59785
  import { join as join17 } from "node:path";
59654
59786
 
59655
59787
  // src/extract/naming.ts
@@ -59664,13 +59796,13 @@ var markdownExporter = {
59664
59796
  async export(bundle, outDir) {
59665
59797
  const dirNames = bundle.components.map((c, i) => componentDirName(c.role, i + 1));
59666
59798
  const indexMd = renderIndex(bundle, dirNames);
59667
- writeFileSync14(join17(outDir, "index.md"), indexMd, "utf8");
59799
+ writeFileSync15(join17(outDir, "index.md"), indexMd, "utf8");
59668
59800
  bundle.components.forEach((component, i) => {
59669
59801
  const dirName = dirNames[i];
59670
59802
  const componentDir = join17(outDir, "components", dirName);
59671
59803
  mkdirSync10(componentDir, { recursive: true });
59672
59804
  const readme = renderComponentReadme(bundle, component);
59673
- writeFileSync14(join17(componentDir, "README.md"), readme, "utf8");
59805
+ writeFileSync15(join17(componentDir, "README.md"), readme, "utf8");
59674
59806
  });
59675
59807
  }
59676
59808
  };
@@ -59777,7 +59909,7 @@ function truncateHtml(html3, max) {
59777
59909
  }
59778
59910
 
59779
59911
  // src/extract/extract-component.ts
59780
- import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync15 } from "node:fs";
59912
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync16 } from "node:fs";
59781
59913
 
59782
59914
  // src/engine/section-capture.ts
59783
59915
  init_esm10();
@@ -60040,8 +60172,8 @@ async function extractComponent(page, component, opts) {
60040
60172
  links: capLinks(links, LINK_CAP),
60041
60173
  textContent: textContent2
60042
60174
  };
60043
- writeFileSync15(`${opts.outDir}/component.html`, extracted.html, "utf8");
60044
- writeFileSync15(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60175
+ writeFileSync16(`${opts.outDir}/component.html`, extracted.html, "utf8");
60176
+ writeFileSync16(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60045
60177
  `, "utf8");
60046
60178
  return extracted;
60047
60179
  }
@@ -60130,18 +60262,18 @@ function capLinks(links, max) {
60130
60262
 
60131
60263
  // src/commands/section.ts
60132
60264
  import { mkdirSync as mkdirSync12 } from "node:fs";
60133
- import { resolve } from "node:path";
60265
+ import { resolve as resolve2 } from "node:path";
60134
60266
  import chalk11 from "chalk";
60135
60267
  import * as diff from "diff";
60136
60268
  import prettier from "prettier";
60137
60269
 
60138
60270
  // src/diff/heatmap-regions.ts
60139
- import { readFileSync as readFileSync14 } from "node:fs";
60271
+ import { readFileSync as readFileSync15 } from "node:fs";
60140
60272
  import { PNG as PNG4 } from "pngjs";
60141
60273
  var DEFAULT_MAX_HOTSPOTS = 5;
60142
60274
  var DEFAULT_MIN_COMPONENT_PIXELS = 50;
60143
60275
  function analyzeHeatmapRegions(pngPath, opts = {}) {
60144
- const png = PNG4.sync.read(readFileSync14(pngPath));
60276
+ const png = PNG4.sync.read(readFileSync15(pngPath));
60145
60277
  return analyzeHeatmapBuffer(png.data, png.width, png.height, opts);
60146
60278
  }
60147
60279
  function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
@@ -60254,7 +60386,7 @@ function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
60254
60386
  }
60255
60387
 
60256
60388
  // src/diff/section-bundle.ts
60257
- import { writeFileSync as writeFileSync16 } from "node:fs";
60389
+ import { writeFileSync as writeFileSync17 } from "node:fs";
60258
60390
  import { basename as basename2, dirname as dirname4, join as join18, relative as relative3 } from "node:path";
60259
60391
  function buildStyleDeltas(input) {
60260
60392
  const cs = input.computedStyles;
@@ -60300,11 +60432,11 @@ function assembleSectionDiffBundle(input) {
60300
60432
  styleDeltas
60301
60433
  };
60302
60434
  const jsonPath = join18(input.outDir, `${input.filePrefix}-bundle.json`);
60303
- writeFileSync16(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60435
+ writeFileSync17(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60304
60436
  `, "utf8");
60305
60437
  const markdown = renderMarkdownBundle(input, styleDeltas);
60306
60438
  const markdownPath = join18(input.outDir, `${input.filePrefix}-prompt.md`);
60307
- writeFileSync16(markdownPath, markdown, "utf8");
60439
+ writeFileSync17(markdownPath, markdown, "utf8");
60308
60440
  const summary = oneLineSummary(input, styleDeltas);
60309
60441
  return { jsonPath, markdownPath, summary };
60310
60442
  }
@@ -60520,10 +60652,10 @@ async function sectionCommand(opts) {
60520
60652
  const hash2 = hashSelector(opts.selector);
60521
60653
  const filePrefix = `section-${hash2}-${viewport}`;
60522
60654
  const screenshotPaths = {
60523
- prod: resolve(opts.outDir, `${filePrefix}-prod.png`),
60524
- cand: resolve(opts.outDir, `${filePrefix}-cand.png`)
60655
+ prod: resolve2(opts.outDir, `${filePrefix}-prod.png`),
60656
+ cand: resolve2(opts.outDir, `${filePrefix}-cand.png`)
60525
60657
  };
60526
- const heatmapPath = resolve(opts.outDir, `${filePrefix}-heatmap.png`);
60658
+ const heatmapPath = resolve2(opts.outDir, `${filePrefix}-heatmap.png`);
60527
60659
  const browser = await launchBrowser({ headless: true });
60528
60660
  try {
60529
60661
  const [prodSide, candSide] = await Promise.all([
@@ -60620,7 +60752,7 @@ async function gatherSide(browser, opts) {
60620
60752
  stabilizeCarousels(page).catch(() => {
60621
60753
  return;
60622
60754
  }),
60623
- new Promise((resolve2) => setTimeout(resolve2, 3000))
60755
+ new Promise((resolve3) => setTimeout(resolve3, 3000))
60624
60756
  ]);
60625
60757
  if (opts.wantScreenshot) {
60626
60758
  const scrollBudget = 30000;
@@ -60628,13 +60760,13 @@ async function gatherSide(browser, opts) {
60628
60760
  scrollFullPage(page, scrollBudget).catch(() => {
60629
60761
  return;
60630
60762
  }),
60631
- new Promise((resolve2) => setTimeout(resolve2, scrollBudget + 2000))
60763
+ new Promise((resolve3) => setTimeout(resolve3, scrollBudget + 2000))
60632
60764
  ]);
60633
60765
  await Promise.race([
60634
60766
  waitForSkeletonsToResolve(page, 5000).catch(() => {
60635
60767
  return;
60636
60768
  }),
60637
- new Promise((resolve2) => setTimeout(resolve2, 5000))
60769
+ new Promise((resolve3) => setTimeout(resolve3, 5000))
60638
60770
  ]);
60639
60771
  }
60640
60772
  const artifacts = await captureSectionArtifacts(page, {
@@ -60990,7 +61122,7 @@ async function extractCommand(opts) {
60990
61122
  const host = safeHost4(opts.url);
60991
61123
  const timestamp = new Date().toISOString();
60992
61124
  const runDirTimestamp = timestamp.replace(/[:.]/g, "-");
60993
- const runDir = resolve2(opts.outDir, host, runDirTimestamp);
61125
+ const runDir = resolve3(opts.outDir, host, runDirTimestamp);
60994
61126
  mkdirSync13(runDir, { recursive: true });
60995
61127
  const browser = await launchBrowser({ headless: true });
60996
61128
  try {
@@ -61037,7 +61169,7 @@ async function extractCommand(opts) {
61037
61169
  for (const component of detected) {
61038
61170
  globalIndex++;
61039
61171
  const dirName = componentDirName(component.role, globalIndex);
61040
- const componentDir = resolve2(runDir, "components", dirName);
61172
+ const componentDir = resolve3(runDir, "components", dirName);
61041
61173
  const extracted = await extractComponent(page, component, {
61042
61174
  outDir: componentDir,
61043
61175
  index: globalIndex,
@@ -61432,7 +61564,7 @@ function formatPatch(patch) {
61432
61564
  }
61433
61565
 
61434
61566
  // src/commands/journey.ts
61435
- import { writeFileSync as writeFileSync17 } from "node:fs";
61567
+ import { writeFileSync as writeFileSync18 } from "node:fs";
61436
61568
  import { join as join19 } from "node:path";
61437
61569
  import chalk14 from "chalk";
61438
61570
  import ora6 from "ora";
@@ -61595,7 +61727,7 @@ async function journeyCommand(opts) {
61595
61727
  if (opts.github)
61596
61728
  emitGithubAnnotations(failures);
61597
61729
  if (opts.junit) {
61598
- writeFileSync17(opts.junit, buildJUnit(rows, failures), "utf8");
61730
+ writeFileSync18(opts.junit, buildJUnit(rows, failures), "utf8");
61599
61731
  if (!opts.json)
61600
61732
  console.log(chalk14.dim(` → JUnit XML: ${opts.junit}`));
61601
61733
  }
@@ -62073,8 +62205,8 @@ function listCommand(output) {
62073
62205
  }
62074
62206
 
62075
62207
  // 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";
62208
+ import { existsSync as existsSync15, mkdirSync as mkdirSync16, readFileSync as readFileSync20, writeFileSync as writeFileSync24 } from "node:fs";
62209
+ import { resolve as resolve4 } from "node:path";
62078
62210
  import chalk17 from "chalk";
62079
62211
  import open from "open";
62080
62212
 
@@ -62519,22 +62651,22 @@ function compactComponentHtml(html3, maxChars = COMPONENT_HTML_MAX_CHARS) {
62519
62651
  }
62520
62652
 
62521
62653
  // src/migrate/exporters/json.ts
62522
- import { writeFileSync as writeFileSync18 } from "node:fs";
62654
+ import { writeFileSync as writeFileSync19 } from "node:fs";
62523
62655
  import { join as join20 } from "node:path";
62524
62656
  var jsonExporter2 = {
62525
62657
  name: "json",
62526
62658
  async export(bundle, outDir) {
62527
- writeFileSync18(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
62659
+ writeFileSync19(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
62528
62660
  `, "utf8");
62529
62661
  }
62530
62662
  };
62531
62663
 
62532
62664
  // src/migrate/exporters/markdown.ts
62533
- import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync20 } from "node:fs";
62665
+ import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync21 } from "node:fs";
62534
62666
  import { join as join22 } from "node:path";
62535
62667
 
62536
62668
  // src/migrate/vtex/content-assets.ts
62537
- import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync19 } from "node:fs";
62669
+ import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync20 } from "node:fs";
62538
62670
  import { join as join21 } from "node:path";
62539
62671
  var MAX_IMAGES = 150;
62540
62672
  var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
@@ -62654,7 +62786,7 @@ async function downloadContentImages(urls, runDir, fetchBytes) {
62654
62786
  if (!got)
62655
62787
  continue;
62656
62788
  const name = contentImageName(url, i, used);
62657
- writeFileSync19(join21(dir, name), got.buf);
62789
+ writeFileSync20(join21(dir, name), got.buf);
62658
62790
  map2[url] = `assets/content/${name}`;
62659
62791
  downloaded++;
62660
62792
  }
@@ -62676,9 +62808,9 @@ var markdownExporter2 = {
62676
62808
  notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
62677
62809
  if (compact.truncated)
62678
62810
  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");
62811
+ writeFileSync21(join22(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
62680
62812
  });
62681
- writeFileSync20(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
62813
+ writeFileSync21(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
62682
62814
  }
62683
62815
  };
62684
62816
  function renderIndex2(bundle, notes) {
@@ -62880,53 +63012,369 @@ function escapePipes2(s) {
62880
63012
  }
62881
63013
 
62882
63014
  // src/migrate/exporters/html.ts
62883
- import { readFileSync as readFileSync15, writeFileSync as writeFileSync21 } from "node:fs";
63015
+ import { readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
62884
63016
  import { join as join23 } from "node:path";
62885
- var htmlExporter = {
62886
- name: "html",
62887
- async export(bundle, outDir) {
62888
- writeFileSync21(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
62889
- const inline = (p) => p ? dataUri2(join23(outDir, p)) ?? p : null;
62890
- writeFileSync21(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
62891
- }
62892
- };
62893
- var MIME2 = {
62894
- ".png": "image/png",
62895
- ".jpg": "image/jpeg",
62896
- ".jpeg": "image/jpeg",
62897
- ".webp": "image/webp",
62898
- ".gif": "image/gif",
62899
- ".svg": "image/svg+xml",
62900
- ".ico": "image/x-icon"
62901
- };
62902
- function dataUri2(absPath) {
62903
- try {
62904
- const ext = absPath.slice(absPath.lastIndexOf(".")).toLowerCase();
62905
- const mime = MIME2[ext];
62906
- if (!mime)
62907
- return null;
62908
- return `data:${mime};base64,${readFileSync15(absPath).toString("base64")}`;
62909
- } catch {
62910
- return null;
62911
- }
63017
+
63018
+ // src/migrate/targets/faststore-v4.ts
63019
+ function pickBreakpointTiers(breakpoints) {
63020
+ const px = breakpoints.map((b) => ({ raw: b, n: Number.parseFloat(b) })).filter((b) => Number.isFinite(b.n));
63021
+ const used = new Set;
63022
+ const nearest = (target) => {
63023
+ let best = null;
63024
+ for (const b of px) {
63025
+ if (used.has(b.raw))
63026
+ continue;
63027
+ const d = Math.abs(b.n - target);
63028
+ if (!best || d < best.d)
63029
+ best = { raw: b.raw, d };
63030
+ }
63031
+ if (best)
63032
+ used.add(best.raw);
63033
+ return best?.raw ?? null;
63034
+ };
63035
+ return {
63036
+ phone: nearest(480),
63037
+ tablet: nearest(768),
63038
+ notebook: nearest(1024),
63039
+ desktop: nearest(1280)
63040
+ };
62912
63041
  }
62913
- function esc2(s) {
62914
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
63042
+ function buildFastStoreTheme(theme) {
63043
+ const lines = [];
63044
+ const put = (token, value) => {
63045
+ if (value)
63046
+ lines.push(` ${token}: ${value};`);
63047
+ };
63048
+ const fonts = theme.typography.fontFamilies;
63049
+ const radii = theme.radii;
63050
+ const bp = theme.breakpoints;
63051
+ put("--fs-color-primary-bkg", theme.colors.primary);
63052
+ put("--fs-color-accent-0", theme.colors.secondary);
63053
+ put("--fs-color-text", theme.colors.text);
63054
+ put("--fs-color-body-bkg", theme.colors.background);
63055
+ put("--fs-text-face-body", fonts[0]);
63056
+ put("--fs-text-face-title", fonts[1] ?? fonts[0]);
63057
+ put("--fs-border-radius-medium", radii[Math.floor(radii.length / 2)]);
63058
+ put("--fs-shadow", theme.shadows[0]);
63059
+ const tiers = pickBreakpointTiers(bp);
63060
+ put("--fs-grid-breakpoint-phone", tiers.phone);
63061
+ put("--fs-grid-breakpoint-tablet", tiers.tablet);
63062
+ put("--fs-grid-breakpoint-notebook", tiers.notebook);
63063
+ put("--fs-grid-breakpoint-desktop", tiers.desktop);
63064
+ return [
63065
+ "// custom-theme.scss — starter generated by `parity migrate --target faststore`.",
63066
+ "// Brand tokens only; adjust and extend against @faststore/ui global tokens.",
63067
+ ".theme {",
63068
+ ...lines,
63069
+ "}",
63070
+ ""
63071
+ ].join(`
63072
+ `);
62915
63073
  }
62916
- function swatch(label, value) {
62917
- if (!value)
62918
- return `<div class="sw"><div class="chip empty"></div><b>${label}</b><span>—</span></div>`;
62919
- return `<div class="sw"><div class="chip" style="background:${esc2(value)}"></div><b>${label}</b><span>${esc2(value)}</span></div>`;
63074
+ var faststore = `## Target: VTEX FastStore (v4)
63075
+
63076
+ Generate the migrated storefront as a FastStore v4 project. Do NOT hand-roll the
63077
+ scaffold — use the official CLI, then fill in sections from the components below.
63078
+
63079
+ ### Setup (once)
63080
+ - Requirements + project setup: https://developers.vtex.com/docs/guides/faststore/getting-started-requirements
63081
+ - Project structure overview: https://developers.vtex.com/docs/guides/faststore/project-structure-overview
63082
+ - \`yarn install\` then \`yarn dev\` → dev store at http://localhost:3000
63083
+
63084
+ ### CLI (@faststore/cli)
63085
+ - \`faststore dev\` — local dev server (localhost:3000)
63086
+ - \`faststore build\` — production build
63087
+ - \`faststore generate\` — regenerate schema + TS types after changes
63088
+ - \`faststore cms-sync\` — sync the \`cms/\` folder with the Headless CMS
63089
+
63090
+ ### Styling — IMPORTANT: FastStore does NOT use Tailwind
63091
+ FastStore v4 styles with **SCSS design tokens + \`data-fs-*\` attributes**, not
63092
+ utility classes. The Tailwind classes in each component README are a convenience
63093
+ approximation — treat the **raw computed styles in manifest.json as the source
63094
+ of truth** for exact values. Package split: \`@faststore/components\` (structure/
63095
+ behavior, unstyled) · \`@faststore/ui\` (styles + design tokens) · \`@faststore/core\`
63096
+ (sections/pages).
63097
+
63098
+ - **Theme** → a starter \`custom-theme.scss\` was generated in this snapshot from
63099
+ the extracted brand tokens. Drop it in \`src/themes/\` and refine. Token map used:
63100
+
63101
+ | Extracted | FastStore global token |
63102
+ | --- | --- |
63103
+ | primary | \`--fs-color-primary-bkg\` |
63104
+ | secondary | \`--fs-color-accent-0\` |
63105
+ | text | \`--fs-color-text\` |
63106
+ | background | \`--fs-color-body-bkg\` |
63107
+ | font (body/title) | \`--fs-text-face-body\` / \`--fs-text-face-title\` |
63108
+ | radius | \`--fs-border-radius-medium\` |
63109
+ | shadow | \`--fs-shadow\` |
63110
+ | breakpoints | \`--fs-grid-breakpoint-phone|tablet|notebook|desktop\` |
63111
+
63112
+ Do NOT override \`--fs-spacing-*\`/\`--fs-text-size-*\` (structural scale).
63113
+ Global tokens: https://developers.vtex.com/docs/guides/faststore/global-tokens-overview
63114
+ - **Per-component styling** → override via each component's \`data-fs-*\` attribute
63115
+ in SCSS (e.g. \`[data-fs-product-shelf]\`), not utility classes.
63116
+ Styling a component: https://developers.vtex.com/docs/guides/faststore/using-themes-components
63117
+
63118
+ ### Icons — Phosphor
63119
+ FastStore ships Phosphor icons via the \`<Icon>\` component (\`data-fs-icon\`, \`weight\`
63120
+ prop: thin|light|regular|bold). Map each entry in this snapshot's **icon inventory**
63121
+ to a Phosphor icon id; add any missing ones as custom icons.
63122
+ - Iconography: https://developers.vtex.com/docs/guides/faststore/reference-icons
63123
+ - Adding custom icons: https://developers.vtex.com/docs/guides/faststore/atoms-icon
63124
+
63125
+ ### Brand assets
63126
+ - Logo + favicon (and apple-touch-icon / OG image) were downloaded to \`assets/\`
63127
+ in this snapshot — drop them into the FastStore project's \`public/\` and wire the
63128
+ logo into the Navbar/Header section.
63129
+
63130
+ ### Where components go — section structure
63131
+ Each detected component → a FastStore section:
63132
+ - \`src/components/<SectionName>.tsx\` (the React section)
63133
+ - register it in \`src/components/index.tsx\` (the components entry)
63134
+ - add its schema to \`cms/faststore/sections.json\` (form editors use in the CMS)
63135
+ - **Global components** (header/footer/minicart) render on every page;
63136
+ **page components** (home/PLP/PDP) go into the matching page content type.
63137
+ - After adding/editing sections: \`faststore generate\` then \`faststore cms-sync\`.
63138
+ - Splitting a legacy CMS structure into components/content-types is supported by
63139
+ \`vtex content split-components\` and \`vtex content split-content-types\`.
63140
+ - Creating a section: https://developers.vtex.com/docs/guides/faststore/building-sections-creating-a-new-section
63141
+ - Headless CMS model: https://developers.vtex.com/docs/guides/faststore/headless-cms-overview
63142
+ - Creating sections: https://developers.vtex.com/docs/guides/faststore/creating-a-new-section-and-content-type
63143
+
63144
+ ### e2e
63145
+ Use the suggested selectors (per component, mapped to known commerce keys) to
63146
+ seed Playwright/Cypress smoke tests on the migrated store.`;
63147
+
63148
+ // src/migrate/targets/faststore-next.ts
63149
+ function buildFastStoreNextTheme(theme) {
63150
+ return buildTailwindTheme(theme, [
63151
+ "/* Brand tokens — starter generated by `parity migrate --target faststore-next`. */",
63152
+ "/* Adjust names to match whatever this template's own tailwind.css already declares */",
63153
+ "/* under @theme inline — don't introduce a second, parallel token set. */"
63154
+ ]);
62920
63155
  }
62921
- function domainOf2(url) {
62922
- try {
62923
- return new URL(url).hostname.replace(/^www\./, "");
62924
- } catch {
62925
- return url;
62926
- }
63156
+ function buildTailwindTheme(theme, header) {
63157
+ const lines = [];
63158
+ const put = (token, value) => {
63159
+ if (value)
63160
+ lines.push(` ${token}: ${value};`);
63161
+ };
63162
+ const fonts = theme.typography.fontFamilies;
63163
+ const radii = theme.radii;
63164
+ const bp = theme.breakpoints;
63165
+ put("--color-brand-primary", theme.colors.primary);
63166
+ put("--color-brand-secondary", theme.colors.secondary);
63167
+ put("--color-brand-text", theme.colors.text);
63168
+ put("--color-brand-background", theme.colors.background);
63169
+ put("--font-body", fonts[0]);
63170
+ put("--font-heading", fonts[1] ?? fonts[0]);
63171
+ put("--radius-brand", radii[Math.floor(radii.length / 2)]);
63172
+ put("--shadow-brand", theme.shadows[0]);
63173
+ const tiers = pickBreakpointTiers(bp);
63174
+ put("--breakpoint-phone", tiers.phone);
63175
+ put("--breakpoint-tablet", tiers.tablet);
63176
+ put("--breakpoint-notebook", tiers.notebook);
63177
+ put("--breakpoint-desktop", tiers.desktop);
63178
+ return [...header, "@theme {", ...lines, "}", ""].join(`
63179
+ `);
62927
63180
  }
62928
- function chips(items) {
62929
- return items.length ? items.map((i) => `<code>${esc2(i)}</code>`).join(" ") : "<em>none</em>";
63181
+ var faststoreNext = `## Target: FastStore Next
63182
+
63183
+ Next.js App Router on \`@faststore/api\`/\`sdk\`/\`ui\` — no \`@faststore/cli\`/\`core\`,
63184
+ Deco CMS decofiles as the content source. This is a DIFFERENT target from
63185
+ \`faststore-v4\` (which scaffolds \`@faststore/cli\` + the VTEX Headless CMS) —
63186
+ don't mix their playbooks. Load \`skills/target-faststore-next/SKILL.md\` for
63187
+ the full picture; this is the condensed version.
63188
+
63189
+ ### Bootstrap
63190
+ - Scaffold by copying \`deco-sites/faststore-next-template\` (clone, copy the
63191
+ tree, re-init git, set the new remote) — NOT the bare FastStore starter.
63192
+ It ships the platform layer (PLP pagination/ISR, gradual-cutover proxy,
63193
+ native Synerise+VTEX-fallback search, WebOps deploy accommodations) —
63194
+ reinventing any of those from scratch is exactly what the template exists
63195
+ to avoid.
63196
+ - \`bun dev\` — localhost:3000 · \`bun run build\` — prod build (runs \`generate\`
63197
+ first) · \`bun run generate:deco\` — after adding/changing a section,
63198
+ restart dev after.
63199
+ - Set \`discovery.config.js\`'s \`api.storeId\` (public, client-bundled — not a
63200
+ secret) to the source VTEX account (the \`*.vtexassets.com\` subdomain in
63201
+ \`blocks.json\`, or the account id from \`window.__RUNTIME__\` on a live
63202
+ vtex-io source).
63203
+
63204
+ ### Styling — Tailwind v4, not SCSS
63205
+ No \`--fs-*\` token contract (that's the other target). A starter
63206
+ \`@theme\` block was generated in this snapshot from the extracted brand
63207
+ tokens — merge it into the template's own \`src/styles/tailwind.css\`
63208
+ \`@theme inline\` block rather than adding a second token layer. Token map
63209
+ used: primary/secondary/text/background colors, body/heading fonts, one
63210
+ mid-scale radius, first shadow, and the four nearest-canonical breakpoint
63211
+ tiers (phone/tablet/notebook/desktop) picked from the extracted breakpoint
63212
+ list.
63213
+
63214
+ ### Icons
63215
+ Sprite-based (\`public/sprites-v2.svg\` + the template's \`Icon\` component,
63216
+ a typed union in \`icons.ts\`) — not Phosphor, not per-icon SVG files. Add
63217
+ missing icons to the sprite + the union type.
63218
+
63219
+ ### Brand assets
63220
+ Logo/favicon downloaded to \`assets/\` in this snapshot — the template ships
63221
+ a generic placeholder at \`public/brand/logo-placeholder.svg\`; replace it
63222
+ and wire it into \`src/components/header/{Desktop,Mobile}Header.tsx\`.
63223
+
63224
+ ### Where components go — this target's 3-point-invariant equivalent
63225
+ Every section needs all three or the CMS silently drops it:
63226
+ 1. The component in \`src/components/sections/<Path>/<Name>.tsx\` — its typed
63227
+ \`Props\` export IS the CMS schema (no separate \`.jsonc\` to hand-write).
63228
+ 2. The shim in \`src/sections/<Path>.tsx\` — thin re-export,
63229
+ \`export { default } from "src/components/sections/<Path>/<Name>"\`, plus
63230
+ convention exports (\`sync\`, \`layout\`, \`cache\`, …). The file's PATH is
63231
+ the Studio block key.
63232
+ 3. \`bun run generate:deco\` to regenerate \`.deco/*.gen.*\`.
63233
+ Global vs page-scoped: \`layout = true\` sections (Header/Footer) resolve
63234
+ once and cache across navigations; everything else is page content.
63235
+
63236
+ ### Editability gate (check every ported section)
63237
+ Does it read from its decofile, or did the port hardcode the captured
63238
+ content into JSX? Trivial/empty \`Props\` or literal strings >~25 chars in
63239
+ the component body means a merchant can't edit it in Studio — visually
63240
+ identical to prod, but a CMS regression \`parity\`'s screenshot/HTML diff
63241
+ cannot see.
63242
+
63243
+ ### Rendering — decide this BEFORE porting the first section
63244
+ CMS data renders SSR; product/search data renders CSR when the site uses a
63245
+ third-party search provider (its requests are shopper-session-dependent and
63246
+ browser-only). This is an architecture decision made once, up front — do
63247
+ not let \`parity\` flag the resulting SSR/CSR delta as a regression against
63248
+ a source that server-rendered products.
63249
+
63250
+ ### Deploy
63251
+ WebOps builds straight from \`discovery.config.js\` + \`package.json\`
63252
+ scripts — no CLI, no deploy workflow to create. Two accommodations that
63253
+ look wrong to a generic Node reviewer but are load-bearing: build-time
63254
+ tooling sits in \`dependencies\` (WebOps production installs skip
63255
+ \`devDependencies\`), and branch names can't contain a second \`/\`.`;
63256
+
63257
+ // src/migrate/targets/tanstack-deco.ts
63258
+ function buildTanstackDecoTheme(theme) {
63259
+ return buildTailwindTheme(theme, [
63260
+ "/* Brand tokens — starter generated by `parity migrate --target tanstack-deco`. */",
63261
+ "/* Reconcile with the template's own tailwind.css @theme block and, if the site uses a",
63262
+ " CMS-editable Theme section, with that block's values — three parallel token sets is",
63263
+ " worse than none. */"
63264
+ ]);
63265
+ }
63266
+ var tanstackDeco = `## Target: TanStack Start + Deco CMS
63267
+
63268
+ Generate the migrated storefront as a TanStack Start / Cloudflare Workers site using
63269
+ the @decocms/* packages. Scaffold from the official template before porting sections.
63270
+
63271
+ ### Setup (once)
63272
+ - Clone: \`gh repo clone decocms/tanstack-storefront <name>\`
63273
+ - Install: \`bun install\`
63274
+ - Dev: \`bun run dev\` → http://localhost:5173
63275
+
63276
+ ### CLI (@faststore/cli is NOT used here — this is TanStack)
63277
+ - \`bun run dev\` local dev server (Vite + Cloudflare Workers)
63278
+ - \`bun run build\` production build
63279
+ - \`bun run predev\` regenerate types + invoke stubs (run after adding sections)
63280
+
63281
+ ### Sections — the CMS unit (mirror of Fresh's sections/)
63282
+ Each component from the capture → a section in \`src/components/sections/<Name>.tsx\`.
63283
+ Three things must stay in sync (TypeScript enforces this at build time):
63284
+ 1. Export in \`src/components/index.tsx\` (the key IS the CMS block type).
63285
+ 2. \`export const schema\` on the component (Zod — replaces Fresh's JSDoc annotations).
63286
+ 3. A loader in \`src/loaders/\` when the section needs server data.
63287
+
63288
+ ### Styling
63289
+ TanStack Deco uses **Tailwind** (utility classes) and CSS Modules for overrides,
63290
+ NOT SCSS design-token variables (that's FastStore v4). The captured Tailwind classes
63291
+ per component are the starting point; cross-check against the prod screenshots.
63292
+
63293
+ ### Commerce (VTEX)
63294
+ \`@decocms/apps-vtex\` provides loaders and hooks. Import from there instead of
63295
+ writing raw GraphQL/REST. Key hooks: \`useCart\`, \`useUser\`, \`useProduct\`.
63296
+
63297
+ ### After porting each section
63298
+ \`bun run predev\` — regenerates \`src/components/manifest.gen.ts\` and
63299
+ \`src/invoke.gen.ts\`. A missing entry here is a 404 in the Deco admin.`;
63300
+
63301
+ // src/migrate/targets/index.ts
63302
+ var FASTSTORE_V4 = {
63303
+ playbook: faststore,
63304
+ theme: { filename: "custom-theme.scss", build: buildFastStoreTheme }
63305
+ };
63306
+ var FASTSTORE_NEXT = {
63307
+ playbook: faststoreNext,
63308
+ theme: { filename: "theme.css", build: buildFastStoreNextTheme }
63309
+ };
63310
+ var TANSTACK_DECO = {
63311
+ playbook: tanstackDeco,
63312
+ theme: { filename: "theme.css", build: buildTanstackDecoTheme }
63313
+ };
63314
+ var TARGETS = {
63315
+ faststore: FASTSTORE_V4,
63316
+ "faststore-v4": FASTSTORE_V4,
63317
+ "faststore-next": FASTSTORE_NEXT,
63318
+ tanstack: TANSTACK_DECO,
63319
+ "tanstack-deco": TANSTACK_DECO
63320
+ };
63321
+ function getTarget(name) {
63322
+ return Object.hasOwn(TARGETS, name) ? TARGETS[name] : undefined;
63323
+ }
63324
+ function getTargetPlaybook(name) {
63325
+ return getTarget(name)?.playbook;
63326
+ }
63327
+ function getTargetTheme(name) {
63328
+ return getTarget(name)?.theme ?? null;
63329
+ }
63330
+ var TARGET_NAMES = Object.keys(TARGETS);
63331
+
63332
+ // src/migrate/exporters/html.ts
63333
+ var htmlExporter = {
63334
+ name: "html",
63335
+ async export(bundle, outDir) {
63336
+ writeFileSync22(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
63337
+ const inline = (p) => p ? dataUri2(join23(outDir, p)) ?? p : null;
63338
+ writeFileSync22(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
63339
+ }
63340
+ };
63341
+ var MIME2 = {
63342
+ ".png": "image/png",
63343
+ ".jpg": "image/jpeg",
63344
+ ".jpeg": "image/jpeg",
63345
+ ".webp": "image/webp",
63346
+ ".gif": "image/gif",
63347
+ ".svg": "image/svg+xml",
63348
+ ".ico": "image/x-icon"
63349
+ };
63350
+ function dataUri2(absPath) {
63351
+ try {
63352
+ const ext = absPath.slice(absPath.lastIndexOf(".")).toLowerCase();
63353
+ const mime = MIME2[ext];
63354
+ if (!mime)
63355
+ return null;
63356
+ return `data:${mime};base64,${readFileSync16(absPath).toString("base64")}`;
63357
+ } catch {
63358
+ return null;
63359
+ }
63360
+ }
63361
+ function esc2(s) {
63362
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
63363
+ }
63364
+ function swatch(label, value) {
63365
+ if (!value)
63366
+ return `<div class="sw"><div class="chip empty"></div><b>${label}</b><span>—</span></div>`;
63367
+ return `<div class="sw"><div class="chip" style="background:${esc2(value)}"></div><b>${label}</b><span>${esc2(value)}</span></div>`;
63368
+ }
63369
+ function domainOf2(url) {
63370
+ try {
63371
+ return new URL(url).hostname.replace(/^www\./, "");
63372
+ } catch {
63373
+ return url;
63374
+ }
63375
+ }
63376
+ function chips(items) {
63377
+ return items.length ? items.map((i) => `<code>${esc2(i)}</code>`).join(" ") : "<em>none</em>";
62930
63378
  }
62931
63379
  function stackMeta(b) {
62932
63380
  const s = b.stack;
@@ -63081,13 +63529,19 @@ ${favSrc ? `<link rel="icon" href="${esc2(favSrc)}">` : ""}
63081
63529
  <h2>Files</h2>
63082
63530
  <a href="MIGRATION_PROMPT.md">MIGRATION_PROMPT.md</a>
63083
63531
  <a href="index.md">index.md</a>
63084
- ${b.target === "faststore" ? '<a href="custom-theme.scss">custom-theme.scss</a>' : ""}
63532
+ ${themeLink(b.target)}
63085
63533
  ${b.vtex ? '<a href="component-map.json">component-map.json</a> <a href="blocks.json">blocks.json</a>' : ""}
63086
63534
  <a href="manifest.json">manifest.json (full)</a>
63087
63535
  </section>
63088
63536
 
63089
63537
  </main></body></html>`;
63090
63538
  }
63539
+ function themeLink(target) {
63540
+ const theme = target ? getTargetTheme(target) : null;
63541
+ if (!theme)
63542
+ return "";
63543
+ return `<a href="${theme.filename}">${theme.filename}</a>`;
63544
+ }
63091
63545
 
63092
63546
  // src/migrate/sources/classify.ts
63093
63547
  var has2 = (re, text3) => re.test(text3);
@@ -63203,7 +63657,7 @@ function buildMigrationPrompt(bundle, playbook, source) {
63203
63657
  }
63204
63658
 
63205
63659
  // src/migrate/plan.ts
63206
- import { existsSync as existsSync11, readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
63660
+ import { existsSync as existsSync12, readFileSync as readFileSync17, writeFileSync as writeFileSync23 } from "node:fs";
63207
63661
  import { join as join24 } from "node:path";
63208
63662
  function dedupe(names) {
63209
63663
  return [...new Set(names)];
@@ -63295,12 +63749,12 @@ var PLAN_FILE = "migration-plan.json";
63295
63749
  var SETTLED = new Set(["done", "as-is", "upgrade", "skipped"]);
63296
63750
  function loadPlan(dir) {
63297
63751
  const p = join24(dir, PLAN_FILE);
63298
- if (!existsSync11(p))
63752
+ if (!existsSync12(p))
63299
63753
  return null;
63300
- return JSON.parse(readFileSync16(p, "utf8"));
63754
+ return JSON.parse(readFileSync17(p, "utf8"));
63301
63755
  }
63302
63756
  function savePlan(dir, plan) {
63303
- writeFileSync22(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
63757
+ writeFileSync23(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
63304
63758
  `, "utf8");
63305
63759
  }
63306
63760
  function setComponentStatus(plan, name, status) {
@@ -63478,264 +63932,8 @@ function syntheticSourceComponents(plan) {
63478
63932
  }));
63479
63933
  }
63480
63934
 
63481
- // src/migrate/targets/faststore-v4.ts
63482
- function pickBreakpointTiers(breakpoints) {
63483
- const px = breakpoints.map((b) => ({ raw: b, n: Number.parseFloat(b) })).filter((b) => Number.isFinite(b.n));
63484
- const used = new Set;
63485
- const nearest = (target) => {
63486
- let best = null;
63487
- for (const b of px) {
63488
- if (used.has(b.raw))
63489
- continue;
63490
- const d = Math.abs(b.n - target);
63491
- if (!best || d < best.d)
63492
- best = { raw: b.raw, d };
63493
- }
63494
- if (best)
63495
- used.add(best.raw);
63496
- return best?.raw ?? null;
63497
- };
63498
- return {
63499
- phone: nearest(480),
63500
- tablet: nearest(768),
63501
- notebook: nearest(1024),
63502
- desktop: nearest(1280)
63503
- };
63504
- }
63505
- function buildFastStoreTheme(theme) {
63506
- const lines = [];
63507
- const put = (token, value) => {
63508
- if (value)
63509
- lines.push(` ${token}: ${value};`);
63510
- };
63511
- const fonts = theme.typography.fontFamilies;
63512
- const radii = theme.radii;
63513
- const bp = theme.breakpoints;
63514
- put("--fs-color-primary-bkg", theme.colors.primary);
63515
- put("--fs-color-accent-0", theme.colors.secondary);
63516
- put("--fs-color-text", theme.colors.text);
63517
- put("--fs-color-body-bkg", theme.colors.background);
63518
- put("--fs-text-face-body", fonts[0]);
63519
- put("--fs-text-face-title", fonts[1] ?? fonts[0]);
63520
- put("--fs-border-radius-medium", radii[Math.floor(radii.length / 2)]);
63521
- put("--fs-shadow", theme.shadows[0]);
63522
- const tiers = pickBreakpointTiers(bp);
63523
- put("--fs-grid-breakpoint-phone", tiers.phone);
63524
- put("--fs-grid-breakpoint-tablet", tiers.tablet);
63525
- put("--fs-grid-breakpoint-notebook", tiers.notebook);
63526
- put("--fs-grid-breakpoint-desktop", tiers.desktop);
63527
- return [
63528
- "// custom-theme.scss — starter generated by `parity migrate --target faststore`.",
63529
- "// Brand tokens only; adjust and extend against @faststore/ui global tokens.",
63530
- ".theme {",
63531
- ...lines,
63532
- "}",
63533
- ""
63534
- ].join(`
63535
- `);
63536
- }
63537
- var faststore = `## Target: VTEX FastStore (v4)
63538
-
63539
- Generate the migrated storefront as a FastStore v4 project. Do NOT hand-roll the
63540
- scaffold — use the official CLI, then fill in sections from the components below.
63541
-
63542
- ### Setup (once)
63543
- - Requirements + project setup: https://developers.vtex.com/docs/guides/faststore/getting-started-requirements
63544
- - Project structure overview: https://developers.vtex.com/docs/guides/faststore/project-structure-overview
63545
- - \`yarn install\` then \`yarn dev\` → dev store at http://localhost:3000
63546
-
63547
- ### CLI (@faststore/cli)
63548
- - \`faststore dev\` — local dev server (localhost:3000)
63549
- - \`faststore build\` — production build
63550
- - \`faststore generate\` — regenerate schema + TS types after changes
63551
- - \`faststore cms-sync\` — sync the \`cms/\` folder with the Headless CMS
63552
-
63553
- ### Styling — IMPORTANT: FastStore does NOT use Tailwind
63554
- FastStore v4 styles with **SCSS design tokens + \`data-fs-*\` attributes**, not
63555
- utility classes. The Tailwind classes in each component README are a convenience
63556
- approximation — treat the **raw computed styles in manifest.json as the source
63557
- of truth** for exact values. Package split: \`@faststore/components\` (structure/
63558
- behavior, unstyled) · \`@faststore/ui\` (styles + design tokens) · \`@faststore/core\`
63559
- (sections/pages).
63560
-
63561
- - **Theme** → a starter \`custom-theme.scss\` was generated in this snapshot from
63562
- the extracted brand tokens. Drop it in \`src/themes/\` and refine. Token map used:
63563
-
63564
- | Extracted | FastStore global token |
63565
- | --- | --- |
63566
- | primary | \`--fs-color-primary-bkg\` |
63567
- | secondary | \`--fs-color-accent-0\` |
63568
- | text | \`--fs-color-text\` |
63569
- | background | \`--fs-color-body-bkg\` |
63570
- | font (body/title) | \`--fs-text-face-body\` / \`--fs-text-face-title\` |
63571
- | radius | \`--fs-border-radius-medium\` |
63572
- | shadow | \`--fs-shadow\` |
63573
- | breakpoints | \`--fs-grid-breakpoint-phone|tablet|notebook|desktop\` |
63574
-
63575
- Do NOT override \`--fs-spacing-*\`/\`--fs-text-size-*\` (structural scale).
63576
- Global tokens: https://developers.vtex.com/docs/guides/faststore/global-tokens-overview
63577
- - **Per-component styling** → override via each component's \`data-fs-*\` attribute
63578
- in SCSS (e.g. \`[data-fs-product-shelf]\`), not utility classes.
63579
- Styling a component: https://developers.vtex.com/docs/guides/faststore/using-themes-components
63580
-
63581
- ### Icons — Phosphor
63582
- FastStore ships Phosphor icons via the \`<Icon>\` component (\`data-fs-icon\`, \`weight\`
63583
- prop: thin|light|regular|bold). Map each entry in this snapshot's **icon inventory**
63584
- to a Phosphor icon id; add any missing ones as custom icons.
63585
- - Iconography: https://developers.vtex.com/docs/guides/faststore/reference-icons
63586
- - Adding custom icons: https://developers.vtex.com/docs/guides/faststore/atoms-icon
63587
-
63588
- ### Brand assets
63589
- - Logo + favicon (and apple-touch-icon / OG image) were downloaded to \`assets/\`
63590
- in this snapshot — drop them into the FastStore project's \`public/\` and wire the
63591
- logo into the Navbar/Header section.
63592
-
63593
- ### Where components go — section structure
63594
- Each detected component → a FastStore section:
63595
- - \`src/components/<SectionName>.tsx\` (the React section)
63596
- - register it in \`src/components/index.tsx\` (the components entry)
63597
- - add its schema to \`cms/faststore/sections.json\` (form editors use in the CMS)
63598
- - **Global components** (header/footer/minicart) render on every page;
63599
- **page components** (home/PLP/PDP) go into the matching page content type.
63600
- - After adding/editing sections: \`faststore generate\` then \`faststore cms-sync\`.
63601
- - Splitting a legacy CMS structure into components/content-types is supported by
63602
- \`vtex content split-components\` and \`vtex content split-content-types\`.
63603
- - Creating a section: https://developers.vtex.com/docs/guides/faststore/building-sections-creating-a-new-section
63604
- - Headless CMS model: https://developers.vtex.com/docs/guides/faststore/headless-cms-overview
63605
- - Creating sections: https://developers.vtex.com/docs/guides/faststore/creating-a-new-section-and-content-type
63606
-
63607
- ### e2e
63608
- Use the suggested selectors (per component, mapped to known commerce keys) to
63609
- seed Playwright/Cypress smoke tests on the migrated store.`;
63610
-
63611
- // src/migrate/targets/faststore-next.ts
63612
- var faststoreNext = `## Target: FastStore Next
63613
-
63614
- Next.js App Router on \`@faststore/api\`/\`sdk\`/\`ui\` — no \`@faststore/cli\`/\`core\`,
63615
- Deco CMS decofiles as the content source. This is a DIFFERENT target from
63616
- \`faststore-v4\` (which scaffolds \`@faststore/cli\` + the VTEX Headless CMS) —
63617
- don't mix their playbooks. Load \`skills/target-faststore-next/SKILL.md\` for
63618
- the full picture; this is the condensed version.
63619
-
63620
- ### Bootstrap
63621
- - Scaffold by copying \`deco-sites/faststore-next-template\` (clone, copy the
63622
- tree, re-init git, set the new remote) — NOT the bare FastStore starter.
63623
- It ships the platform layer (PLP pagination/ISR, gradual-cutover proxy,
63624
- native Synerise+VTEX-fallback search, WebOps deploy accommodations) —
63625
- reinventing any of those from scratch is exactly what the template exists
63626
- to avoid.
63627
- - \`bun dev\` — localhost:3000 · \`bun run build\` — prod build (runs \`generate\`
63628
- first) · \`bun run generate:deco\` — after adding/changing a section,
63629
- restart dev after.
63630
- - Set \`discovery.config.js\`'s \`api.storeId\` (public, client-bundled — not a
63631
- secret) to the source VTEX account (the \`*.vtexassets.com\` subdomain in
63632
- \`blocks.json\`, or the account id from \`window.__RUNTIME__\` on a live
63633
- vtex-io source).
63634
-
63635
- ### Styling — Tailwind v4, not SCSS
63636
- No \`--fs-*\` token contract (that's the other target). A starter
63637
- \`@theme\` block was generated in this snapshot from the extracted brand
63638
- tokens — merge it into the template's own \`src/styles/tailwind.css\`
63639
- \`@theme inline\` block rather than adding a second token layer. Token map
63640
- used: primary/secondary/text/background colors, body/heading fonts, one
63641
- mid-scale radius, first shadow, and the four nearest-canonical breakpoint
63642
- tiers (phone/tablet/notebook/desktop) picked from the extracted breakpoint
63643
- list.
63644
-
63645
- ### Icons
63646
- Sprite-based (\`public/sprites-v2.svg\` + the template's \`Icon\` component,
63647
- a typed union in \`icons.ts\`) — not Phosphor, not per-icon SVG files. Add
63648
- missing icons to the sprite + the union type.
63649
-
63650
- ### Brand assets
63651
- Logo/favicon downloaded to \`assets/\` in this snapshot — the template ships
63652
- a generic placeholder at \`public/brand/logo-placeholder.svg\`; replace it
63653
- and wire it into \`src/components/header/{Desktop,Mobile}Header.tsx\`.
63654
-
63655
- ### Where components go — this target's 3-point-invariant equivalent
63656
- Every section needs all three or the CMS silently drops it:
63657
- 1. The component in \`src/components/sections/<Path>/<Name>.tsx\` — its typed
63658
- \`Props\` export IS the CMS schema (no separate \`.jsonc\` to hand-write).
63659
- 2. The shim in \`src/sections/<Path>.tsx\` — thin re-export,
63660
- \`export { default } from "src/components/sections/<Path>/<Name>"\`, plus
63661
- convention exports (\`sync\`, \`layout\`, \`cache\`, …). The file's PATH is
63662
- the Studio block key.
63663
- 3. \`bun run generate:deco\` to regenerate \`.deco/*.gen.*\`.
63664
- Global vs page-scoped: \`layout = true\` sections (Header/Footer) resolve
63665
- once and cache across navigations; everything else is page content.
63666
-
63667
- ### Editability gate (check every ported section)
63668
- Does it read from its decofile, or did the port hardcode the captured
63669
- content into JSX? Trivial/empty \`Props\` or literal strings >~25 chars in
63670
- the component body means a merchant can't edit it in Studio — visually
63671
- identical to prod, but a CMS regression \`parity\`'s screenshot/HTML diff
63672
- cannot see.
63673
-
63674
- ### Rendering — decide this BEFORE porting the first section
63675
- CMS data renders SSR; product/search data renders CSR when the site uses a
63676
- third-party search provider (its requests are shopper-session-dependent and
63677
- browser-only). This is an architecture decision made once, up front — do
63678
- not let \`parity\` flag the resulting SSR/CSR delta as a regression against
63679
- a source that server-rendered products.
63680
-
63681
- ### Deploy
63682
- WebOps builds straight from \`discovery.config.js\` + \`package.json\`
63683
- scripts — no CLI, no deploy workflow to create. Two accommodations that
63684
- look wrong to a generic Node reviewer but are load-bearing: build-time
63685
- tooling sits in \`dependencies\` (WebOps production installs skip
63686
- \`devDependencies\`), and branch names can't contain a second \`/\`.`;
63687
-
63688
- // src/migrate/targets/tanstack-deco.ts
63689
- var tanstackDeco = `## Target: TanStack Start + Deco CMS
63690
-
63691
- Generate the migrated storefront as a TanStack Start / Cloudflare Workers site using
63692
- the @decocms/* packages. Scaffold from the official template before porting sections.
63693
-
63694
- ### Setup (once)
63695
- - Clone: \`gh repo clone decocms/tanstack-storefront <name>\`
63696
- - Install: \`bun install\`
63697
- - Dev: \`bun run dev\` → http://localhost:5173
63698
-
63699
- ### CLI (@faststore/cli is NOT used here — this is TanStack)
63700
- - \`bun run dev\` local dev server (Vite + Cloudflare Workers)
63701
- - \`bun run build\` production build
63702
- - \`bun run predev\` regenerate types + invoke stubs (run after adding sections)
63703
-
63704
- ### Sections — the CMS unit (mirror of Fresh's sections/)
63705
- Each component from the capture → a section in \`src/components/sections/<Name>.tsx\`.
63706
- Three things must stay in sync (TypeScript enforces this at build time):
63707
- 1. Export in \`src/components/index.tsx\` (the key IS the CMS block type).
63708
- 2. \`export const schema\` on the component (Zod — replaces Fresh's JSDoc annotations).
63709
- 3. A loader in \`src/loaders/\` when the section needs server data.
63710
-
63711
- ### Styling
63712
- TanStack Deco uses **Tailwind** (utility classes) and CSS Modules for overrides,
63713
- NOT SCSS design-token variables (that's FastStore v4). The captured Tailwind classes
63714
- per component are the starting point; cross-check against the prod screenshots.
63715
-
63716
- ### Commerce (VTEX)
63717
- \`@decocms/apps-vtex\` provides loaders and hooks. Import from there instead of
63718
- writing raw GraphQL/REST. Key hooks: \`useCart\`, \`useUser\`, \`useProduct\`.
63719
-
63720
- ### After porting each section
63721
- \`bun run predev\` — regenerates \`src/components/manifest.gen.ts\` and
63722
- \`src/invoke.gen.ts\`. A missing entry here is a 404 in the Deco admin.`;
63723
-
63724
- // src/migrate/targets/index.ts
63725
- var TARGETS = {
63726
- faststore,
63727
- "faststore-v4": faststore,
63728
- "faststore-next": faststoreNext,
63729
- tanstack: tanstackDeco,
63730
- "tanstack-deco": tanstackDeco
63731
- };
63732
- function getTargetPlaybook(name) {
63733
- return Object.hasOwn(TARGETS, name) ? TARGETS[name] : undefined;
63734
- }
63735
- var TARGET_NAMES = Object.keys(TARGETS);
63736
-
63737
63935
  // src/migrate/sources/deco-fresh.ts
63738
- import { existsSync as existsSync12, readFileSync as readFileSync17 } from "node:fs";
63936
+ import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
63739
63937
  import { join as join26 } from "node:path";
63740
63938
 
63741
63939
  // src/migrate/sources/walk.ts
@@ -63781,13 +63979,13 @@ function walkFiles(dir, exts) {
63781
63979
  function isDecoFresh(repoDir) {
63782
63980
  const denoJson = join26(repoDir, "deno.json");
63783
63981
  const denoJsonc = join26(repoDir, "deno.jsonc");
63784
- const file = existsSync12(denoJson) ? denoJson : existsSync12(denoJsonc) ? denoJsonc : null;
63982
+ const file = existsSync13(denoJson) ? denoJson : existsSync13(denoJsonc) ? denoJsonc : null;
63785
63983
  if (!file)
63786
63984
  return false;
63787
- if (!existsSync12(join26(repoDir, "fresh.gen.ts")))
63985
+ if (!existsSync13(join26(repoDir, "fresh.gen.ts")))
63788
63986
  return false;
63789
63987
  try {
63790
- return readFileSync17(file, "utf8").includes("@deco/deco");
63988
+ return readFileSync18(file, "utf8").includes("@deco/deco");
63791
63989
  } catch {
63792
63990
  return false;
63793
63991
  }
@@ -63796,7 +63994,7 @@ var GLOBAL_HINT = /\b(header|footer|navbar|menu|topbar)\b/i;
63796
63994
  function inventory(repoDir) {
63797
63995
  const components = [];
63798
63996
  const sectionsDir = join26(repoDir, "sections");
63799
- if (existsSync12(sectionsDir)) {
63997
+ if (existsSync13(sectionsDir)) {
63800
63998
  for (const rel of walkFiles(sectionsDir, [".tsx"])) {
63801
63999
  const key2 = rel.replace(/\.tsx$/, "");
63802
64000
  components.push({
@@ -63810,9 +64008,9 @@ function inventory(repoDir) {
63810
64008
  const notes = [
63811
64009
  "Source: Deco on Fresh/Deno (Preact + signals, JSX). Sections are the CMS unit."
63812
64010
  ];
63813
- if (existsSync12(join26(repoDir, "islands")))
64011
+ if (existsSync13(join26(repoDir, "islands")))
63814
64012
  notes.push("Has islands/ — client-interactive components.");
63815
- if (existsSync12(join26(repoDir, "loaders")))
64013
+ if (existsSync13(join26(repoDir, "loaders")))
63816
64014
  notes.push("Has loaders/ — server data functions to port.");
63817
64015
  return { components, notes };
63818
64016
  }
@@ -63852,14 +64050,14 @@ captured HTML/computed-styles as the source of truth for structure and styling.`
63852
64050
  };
63853
64051
 
63854
64052
  // src/migrate/sources/vtex-io.ts
63855
- import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
64053
+ import { existsSync as existsSync14, readFileSync as readFileSync19 } from "node:fs";
63856
64054
  import { join as join27 } from "node:path";
63857
64055
  function readManifest(repoDir) {
63858
64056
  const file = join27(repoDir, "manifest.json");
63859
- if (!existsSync13(file))
64057
+ if (!existsSync14(file))
63860
64058
  return null;
63861
64059
  try {
63862
- return JSON.parse(readFileSync18(file, "utf8"));
64060
+ return JSON.parse(readFileSync19(file, "utf8"));
63863
64061
  } catch {
63864
64062
  return null;
63865
64063
  }
@@ -63882,12 +64080,12 @@ var GLOBAL_HINT2 = /header|footer|menu|minicart|navbar/i;
63882
64080
  function inventory2(repoDir) {
63883
64081
  const blocksDir = join27(repoDir, "store", "blocks");
63884
64082
  const seen = new Map;
63885
- if (existsSync13(blocksDir)) {
64083
+ if (existsSync14(blocksDir)) {
63886
64084
  for (const rel of walkFiles(blocksDir, [".json", ".jsonc"])) {
63887
64085
  const abs = join27(blocksDir, rel);
63888
64086
  let parsed;
63889
64087
  try {
63890
- parsed = JSON.parse(stripJsonc(readFileSync18(abs, "utf8")));
64088
+ parsed = JSON.parse(stripJsonc(readFileSync19(abs, "utf8")));
63891
64089
  } catch {
63892
64090
  continue;
63893
64091
  }
@@ -64454,7 +64652,7 @@ async function migrateCommand(opts) {
64454
64652
  source = s;
64455
64653
  }
64456
64654
  if (opts.source) {
64457
- if (!existsSync14(opts.source)) {
64655
+ if (!existsSync15(opts.source)) {
64458
64656
  console.error(chalk17.red(`--source não encontrado: ${opts.source}`));
64459
64657
  return 2;
64460
64658
  }
@@ -64464,13 +64662,13 @@ async function migrateCommand(opts) {
64464
64662
  console.log(chalk17.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
64465
64663
  }
64466
64664
  const host = safeHost6(opts.url);
64467
- const runDir = resolve3(opts.outDir, host);
64665
+ const runDir = resolve4(opts.outDir, host);
64468
64666
  mkdirSync16(runDir, { recursive: true });
64469
64667
  const browser = await launchBrowser({ headless: true });
64470
64668
  try {
64471
- const themePath = resolve3(runDir, "theme.json");
64472
- const assetsPath = resolve3(runDir, "assets.json");
64473
- const blocksPath = resolve3(runDir, "blocks.json");
64669
+ const themePath = resolve4(runDir, "theme.json");
64670
+ const assetsPath = resolve4(runDir, "assets.json");
64671
+ const blocksPath = resolve4(runDir, "blocks.json");
64474
64672
  let theme;
64475
64673
  let platform;
64476
64674
  let stack = null;
@@ -64478,7 +64676,7 @@ async function migrateCommand(opts) {
64478
64676
  let screenshots;
64479
64677
  let vtexBlocks = null;
64480
64678
  let contentMap = {};
64481
- if (!opts.refresh && existsSync14(themePath) && existsSync14(assetsPath)) {
64679
+ if (!opts.refresh && existsSync15(themePath) && existsSync15(assetsPath)) {
64482
64680
  theme = readJson(themePath);
64483
64681
  const meta = readJson(assetsPath);
64484
64682
  platform = meta.platform;
@@ -64488,7 +64686,7 @@ async function migrateCommand(opts) {
64488
64686
  console.log(chalk17.dim(" phase 1 theme+assets: cached"));
64489
64687
  } else {
64490
64688
  console.log(chalk17.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
64491
- mkdirSync16(resolve3(runDir, "screenshots"), { recursive: true });
64689
+ mkdirSync16(resolve4(runDir, "screenshots"), { recursive: true });
64492
64690
  const samples = [];
64493
64691
  screenshots = [];
64494
64692
  let platformSeen = null;
@@ -64514,7 +64712,7 @@ async function migrateCommand(opts) {
64514
64712
  sleep2(5000)
64515
64713
  ]);
64516
64714
  samples.push(await scrapeThemeSamples(page));
64517
- const shot = resolve3(runDir, "screenshots", `${vp}.png`);
64715
+ const shot = resolve4(runDir, "screenshots", `${vp}.png`);
64518
64716
  await page.screenshot({ path: shot, fullPage: true, animations: "disabled", timeout: 15000 }).then(() => screenshots.push({ viewport: vp, path: `screenshots/${vp}.png` })).catch(() => {
64519
64717
  return;
64520
64718
  });
@@ -64528,7 +64726,7 @@ async function migrateCommand(opts) {
64528
64726
  const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
64529
64727
  assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
64530
64728
  if (rawAssets.logo?.type === "svg" || rawAssets.logo && !assetsResolved.logo) {
64531
- const logoPng = resolve3(runDir, "assets", "logo.png");
64729
+ const logoPng = resolve4(runDir, "assets", "logo.png");
64532
64730
  const ok = await page.locator("[data-parity-logo]").first().screenshot({ path: logoPng, timeout: 8000 }).then(() => true).catch(() => false);
64533
64731
  if (ok) {
64534
64732
  assetsResolved.logo = "assets/logo.png";
@@ -64548,14 +64746,14 @@ async function migrateCommand(opts) {
64548
64746
  theme = aggregateTheme(mergeRawThemeSamples(samples));
64549
64747
  platform = platformSeen ?? "custom";
64550
64748
  assets = assetsResolved;
64551
- writeFileSync23(themePath, `${JSON.stringify(theme, null, 2)}
64749
+ writeFileSync24(themePath, `${JSON.stringify(theme, null, 2)}
64552
64750
  `, "utf8");
64553
- writeFileSync23(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64751
+ writeFileSync24(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64554
64752
  `, "utf8");
64555
64753
  }
64556
- const sitemapPath = resolve3(runDir, "sitemap.json");
64754
+ const sitemapPath = resolve4(runDir, "sitemap.json");
64557
64755
  let resolvedPages;
64558
- if (!opts.refresh && existsSync14(sitemapPath)) {
64756
+ if (!opts.refresh && existsSync15(sitemapPath)) {
64559
64757
  resolvedPages = readJson(sitemapPath).pages;
64560
64758
  console.log(chalk17.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
64561
64759
  } else {
@@ -64589,17 +64787,17 @@ async function migrateCommand(opts) {
64589
64787
  }, {});
64590
64788
  console.log(chalk17.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
64591
64789
  }
64592
- writeFileSync23(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
64790
+ writeFileSync24(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
64593
64791
  `, "utf8");
64594
64792
  }
64595
64793
  if (resolvedPages.length === 0) {
64596
64794
  console.error(chalk17.red("nenhuma página resolvida a partir de --pages"));
64597
64795
  return 1;
64598
64796
  }
64599
- const capturePath = resolve3(runDir, "capture.json");
64797
+ const capturePath = resolve4(runDir, "capture.json");
64600
64798
  let pages;
64601
64799
  let components;
64602
- if (!opts.refresh && existsSync14(capturePath)) {
64800
+ if (!opts.refresh && existsSync15(capturePath)) {
64603
64801
  const cached = readJson(capturePath);
64604
64802
  pages = cached.pages;
64605
64803
  components = cached.components;
@@ -64615,14 +64813,14 @@ async function migrateCommand(opts) {
64615
64813
  baseUrl: opts.url,
64616
64814
  vtexScrape: opts.source ? source.kind === "vtex-io" : true
64617
64815
  }));
64618
- writeFileSync23(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
64816
+ writeFileSync24(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
64619
64817
  `, "utf8");
64620
64818
  }
64621
64819
  if (vtexBlocks)
64622
- writeFileSync23(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64820
+ writeFileSync24(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64623
64821
  `, "utf8");
64624
64822
  if (Object.keys(contentMap).length)
64625
- writeFileSync23(resolve3(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64823
+ writeFileSync24(resolve4(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64626
64824
  `, "utf8");
64627
64825
  const bundle = {
64628
64826
  url: opts.url,
@@ -64659,16 +64857,17 @@ async function migrateCommand(opts) {
64659
64857
  if (format === "md" || format === "both") {
64660
64858
  await markdownExporter2.export(bundle, runDir);
64661
64859
  await htmlExporter.export(bundle, runDir);
64662
- writeFileSync23(resolve3(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64860
+ writeFileSync24(resolve4(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64663
64861
  playbook: source.playbook,
64664
64862
  notes: sourceInventory.notes
64665
64863
  }), "utf8");
64666
64864
  }
64667
- if (opts.target === "faststore") {
64668
- writeFileSync23(resolve3(runDir, "custom-theme.scss"), buildFastStoreTheme(theme), "utf8");
64865
+ const targetTheme = opts.target ? getTargetTheme(opts.target) : null;
64866
+ if (targetTheme) {
64867
+ writeFileSync24(resolve4(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64669
64868
  }
64670
64869
  if (bundle.vtex) {
64671
- writeFileSync23(resolve3(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64870
+ writeFileSync24(resolve4(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64672
64871
  `, "utf8");
64673
64872
  }
64674
64873
  if (opts.json) {
@@ -64677,7 +64876,7 @@ async function migrateCommand(opts) {
64677
64876
  }
64678
64877
  printResults4(runDir, bundle);
64679
64878
  if (opts.open && format !== "json") {
64680
- await open(resolve3(runDir, "report.html")).catch(() => {
64879
+ await open(resolve4(runDir, "report.html")).catch(() => {
64681
64880
  return;
64682
64881
  });
64683
64882
  }
@@ -64732,7 +64931,7 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
64732
64931
  if (global)
64733
64932
  seenGlobalRoles.add(component.role);
64734
64933
  const idx = components.length + 1;
64735
- const componentDir = resolve3(cfg.runDir, "components", componentDirName(component.role, idx));
64934
+ const componentDir = resolve4(cfg.runDir, "components", componentDirName(component.role, idx));
64736
64935
  const extracted = await extractComponent(page, component, {
64737
64936
  outDir: componentDir,
64738
64937
  index: idx,
@@ -64946,7 +65145,7 @@ function printResults4(runDir, bundle) {
64946
65145
  }
64947
65146
  function readJson(path) {
64948
65147
  try {
64949
- return JSON.parse(readFileSync19(path, "utf8"));
65148
+ return JSON.parse(readFileSync20(path, "utf8"));
64950
65149
  } catch {
64951
65150
  return null;
64952
65151
  }
@@ -65197,18 +65396,18 @@ ${chalk18.bold("Pages")} (${pg.total}): ` + `${chalk18.green(`${pg.byStatus.done
65197
65396
  }
65198
65397
 
65199
65398
  // src/commands/pr.ts
65200
- import { existsSync as existsSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync24 } from "node:fs";
65399
+ import { existsSync as existsSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync25 } from "node:fs";
65201
65400
  import { join as join30 } from "node:path";
65202
65401
  import chalk21 from "chalk";
65203
65402
 
65204
65403
  // src/commands/run.ts
65205
- import { existsSync as existsSync17, readFileSync as readFileSync21, unlinkSync as unlinkSync3 } from "node:fs";
65404
+ import { existsSync as existsSync18, readFileSync as readFileSync22, unlinkSync as unlinkSync3 } from "node:fs";
65206
65405
  import { join as join29 } from "node:path";
65207
65406
  import chalk20 from "chalk";
65208
65407
  import ora7 from "ora";
65209
65408
 
65210
65409
  // src/engine/interactive-module-prompt.ts
65211
- import { createInterface } from "node:readline";
65410
+ import { createInterface as createInterface2 } from "node:readline";
65212
65411
  var ALL_MODULE_NAMES2 = Object.keys(MODULES);
65213
65412
  async function promptForModuleSelection() {
65214
65413
  console.log("");
@@ -65219,7 +65418,7 @@ async function promptForModuleSelection() {
65219
65418
  console.log(` [x] ${i + 1}. ${name.padEnd(8)} — ${def.description}`);
65220
65419
  });
65221
65420
  console.log("");
65222
- const answer = await readLine(" Type numbers to UNCHECK (comma-separated), or press Enter to run all: ");
65421
+ const answer = await readLine2(" Type numbers to UNCHECK (comma-separated), or press Enter to run all: ");
65223
65422
  if (answer === null) {
65224
65423
  console.log(" (aborted — running all modules)");
65225
65424
  return ALL_MODULE_NAMES2;
@@ -65236,9 +65435,9 @@ async function promptForModuleSelection() {
65236
65435
  console.log(` running: ${selected.join(", ")}`);
65237
65436
  return selected;
65238
65437
  }
65239
- function readLine(prompt) {
65438
+ function readLine2(prompt) {
65240
65439
  return new Promise((resolveLine) => {
65241
- const rl = createInterface({ input: process.stdin, output: process.stdout });
65440
+ const rl = createInterface2({ input: process.stdin, output: process.stdout });
65242
65441
  rl.question(prompt, (ans) => {
65243
65442
  rl.close();
65244
65443
  resolveLine(ans);
@@ -65250,22 +65449,6 @@ function readLine(prompt) {
65250
65449
  });
65251
65450
  }
65252
65451
 
65253
- // src/engine/interactive-selector-prompt.ts
65254
- init_client();
65255
- var forceDisabled = false;
65256
- function disableInteractive() {
65257
- forceDisabled = true;
65258
- }
65259
- function isInteractiveMode() {
65260
- if (forceDisabled)
65261
- return false;
65262
- if (!process.stdout.isTTY || !process.stdin.isTTY)
65263
- return false;
65264
- if (isLlmAvailable())
65265
- return false;
65266
- return true;
65267
- }
65268
-
65269
65452
  // src/llm/aggregate-issues.ts
65270
65453
  init_client();
65271
65454
  var REPORT_ISSUES_TOOL = {
@@ -65757,13 +65940,13 @@ function formatMs(ms) {
65757
65940
  }
65758
65941
 
65759
65942
  // src/commands/serve.ts
65760
- import { existsSync as existsSync16 } from "node:fs";
65943
+ import { existsSync as existsSync17 } from "node:fs";
65761
65944
  import chalk19 from "chalk";
65762
65945
 
65763
65946
  // src/server/proxy-server.ts
65764
- import { existsSync as existsSync15, readFileSync as readFileSync20, statSync } from "node:fs";
65947
+ import { existsSync as existsSync16, readFileSync as readFileSync21, statSync } from "node:fs";
65765
65948
  import { createServer } from "node:http";
65766
- import { extname, join as join28, normalize as normalize3, resolve as resolve4, sep } from "node:path";
65949
+ import { extname, join as join28, normalize as normalize3, resolve as resolve5, sep } from "node:path";
65767
65950
  var MIME3 = {
65768
65951
  ".html": "text/html; charset=utf-8",
65769
65952
  ".css": "text/css; charset=utf-8",
@@ -65799,8 +65982,8 @@ var STRIPPED_REQUEST_HEADERS = new Set([
65799
65982
  "origin"
65800
65983
  ]);
65801
65984
  async function startProxyServer(runDir, opts = {}) {
65802
- const absRunDir = resolve4(runDir);
65803
- if (!existsSync15(absRunDir)) {
65985
+ const absRunDir = resolve5(runDir);
65986
+ if (!existsSync16(absRunDir)) {
65804
65987
  throw new Error(`Run directory not found: ${runDir}`);
65805
65988
  }
65806
65989
  const server = createServer((req, res) => {
@@ -65811,9 +65994,9 @@ async function startProxyServer(runDir, opts = {}) {
65811
65994
  } catch {}
65812
65995
  });
65813
65996
  });
65814
- await new Promise((resolve5, reject) => {
65997
+ await new Promise((resolve6, reject) => {
65815
65998
  server.once("error", reject);
65816
- server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve5());
65999
+ server.listen(opts.port ?? 0, opts.host ?? "127.0.0.1", () => resolve6());
65817
66000
  });
65818
66001
  const addr = server.address();
65819
66002
  const port = typeof addr === "object" && addr ? addr.port : 0;
@@ -65821,13 +66004,13 @@ async function startProxyServer(runDir, opts = {}) {
65821
66004
  return {
65822
66005
  port,
65823
66006
  url: `http://${host}:${port}/`,
65824
- close: () => new Promise((resolve5) => {
66007
+ close: () => new Promise((resolve6) => {
65825
66008
  try {
65826
66009
  server.closeAllConnections?.();
65827
66010
  server.closeIdleConnections?.();
65828
66011
  } catch {}
65829
- server.close(() => resolve5());
65830
- setTimeout(() => resolve5(), 1000);
66012
+ server.close(() => resolve6());
66013
+ setTimeout(() => resolve6(), 1000);
65831
66014
  })
65832
66015
  };
65833
66016
  }
@@ -65858,12 +66041,12 @@ async function handleRequest(req, res, runDir) {
65858
66041
  }
65859
66042
  function serveReportHtml(res, runDir) {
65860
66043
  const filePath = join28(runDir, "report.html");
65861
- if (!existsSync15(filePath)) {
66044
+ if (!existsSync16(filePath)) {
65862
66045
  res.statusCode = 404;
65863
66046
  res.end("report.html not found");
65864
66047
  return;
65865
66048
  }
65866
- const html3 = readFileSync20(filePath, "utf8");
66049
+ const html3 = readFileSync21(filePath, "utf8");
65867
66050
  const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
65868
66051
  const out = html3.includes("</head>") ? html3.replace("</head>", `${inject}</head>`) : `${inject}${html3}`;
65869
66052
  res.statusCode = 200;
@@ -65873,13 +66056,13 @@ function serveReportHtml(res, runDir) {
65873
66056
  }
65874
66057
  function serveStatic(res, runDir, path) {
65875
66058
  const safePath3 = normalize3(path).replace(/^[/\\]+/, "");
65876
- const filePath = resolve4(runDir, safePath3);
66059
+ const filePath = resolve5(runDir, safePath3);
65877
66060
  if (!filePath.startsWith(runDir + sep) && filePath !== runDir) {
65878
66061
  res.statusCode = 403;
65879
66062
  res.end("forbidden");
65880
66063
  return;
65881
66064
  }
65882
- if (!existsSync15(filePath)) {
66065
+ if (!existsSync16(filePath)) {
65883
66066
  res.statusCode = 404;
65884
66067
  res.end("not found");
65885
66068
  return;
@@ -65894,7 +66077,7 @@ function serveStatic(res, runDir, path) {
65894
66077
  res.statusCode = 200;
65895
66078
  res.setHeader("content-type", MIME3[ext] ?? "application/octet-stream");
65896
66079
  res.setHeader("cache-control", "no-store");
65897
- res.end(readFileSync20(filePath));
66080
+ res.end(readFileSync21(filePath));
65898
66081
  }
65899
66082
  async function proxyRequest(req, res, targetUrl, opts = {}) {
65900
66083
  let target;
@@ -66033,11 +66216,11 @@ async function serveRunAndBlock(runDir, opts = {}) {
66033
66216
  }
66034
66217
  async function serveCommand(runId, opts) {
66035
66218
  const paths = getRunPaths(opts.output, runId);
66036
- if (!existsSync16(paths.runDir)) {
66219
+ if (!existsSync17(paths.runDir)) {
66037
66220
  console.error(chalk19.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
66038
66221
  return 1;
66039
66222
  }
66040
- if (!existsSync16(paths.reportHtml)) {
66223
+ if (!existsSync17(paths.reportHtml)) {
66041
66224
  console.error(chalk19.red(`✖ report.html não existe em ${paths.runDir}`));
66042
66225
  return 1;
66043
66226
  }
@@ -66285,7 +66468,7 @@ async function runCommand(rawOpts) {
66285
66468
  const ignore = loadParityIgnore();
66286
66469
  if (opts.clearCache) {
66287
66470
  const cacheFile = join29(opts.output, "cache", "verdicts.json");
66288
- if (existsSync17(cacheFile)) {
66471
+ if (existsSync18(cacheFile)) {
66289
66472
  try {
66290
66473
  unlinkSync3(cacheFile);
66291
66474
  console.log(chalk20.dim(` cache wiped: ${cacheFile}`));
@@ -66402,7 +66585,7 @@ async function runCommand(rawOpts) {
66402
66585
  b.close().catch(() => {
66403
66586
  return;
66404
66587
  }),
66405
- new Promise((resolve5) => setTimeout(resolve5, capMs))
66588
+ new Promise((resolve6) => setTimeout(resolve6, capMs))
66406
66589
  ]);
66407
66590
  };
66408
66591
  const shutdown = async (reason) => {
@@ -66678,8 +66861,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
66678
66861
  noNetworkIdle: targetIsDevServer,
66679
66862
  runs: vitalsRuns
66680
66863
  }),
66681
- new Promise((resolve5) => {
66682
- const t = setTimeout(() => resolve5(null), PER_TASK_WALLCLOCK_MS);
66864
+ new Promise((resolve6) => {
66865
+ const t = setTimeout(() => resolve6(null), PER_TASK_WALLCLOCK_MS);
66683
66866
  t.unref?.();
66684
66867
  })
66685
66868
  ]);
@@ -67004,10 +67187,10 @@ function parsePagePair(entry) {
67004
67187
  }
67005
67188
  function resolveExplicitPages(pagesFile, pagesList) {
67006
67189
  if (pagesFile) {
67007
- if (!existsSync17(pagesFile)) {
67190
+ if (!existsSync18(pagesFile)) {
67008
67191
  throw new Error(`--pages-file não encontrado: ${pagesFile}`);
67009
67192
  }
67010
- const raw = readFileSync21(pagesFile, "utf-8");
67193
+ const raw = readFileSync22(pagesFile, "utf-8");
67011
67194
  const lines = raw.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
67012
67195
  return lines.map(parsePagePair);
67013
67196
  }
@@ -67234,14 +67417,14 @@ async function prCommand(opts) {
67234
67417
  }
67235
67418
  const latest = runs[0];
67236
67419
  const reportJsonPath = join30(opts.output, "runs", latest.id, "report.json");
67237
- if (!existsSync18(reportJsonPath)) {
67420
+ if (!existsSync19(reportJsonPath)) {
67238
67421
  console.error(chalk21.red(`report.json not found at ${reportJsonPath}`));
67239
67422
  return runCode || 1;
67240
67423
  }
67241
- const run = JSON.parse(readFileSync22(reportJsonPath, "utf8"));
67424
+ const run = JSON.parse(readFileSync23(reportJsonPath, "utf8"));
67242
67425
  const markdown = buildPrComment(run, opts);
67243
67426
  if (opts.out) {
67244
- writeFileSync24(opts.out, markdown, "utf8");
67427
+ writeFileSync25(opts.out, markdown, "utf8");
67245
67428
  console.log(chalk21.dim(` wrote PR comment: ${opts.out}`));
67246
67429
  } else {
67247
67430
  process.stdout.write(`
@@ -67250,7 +67433,7 @@ ${markdown}
67250
67433
  }
67251
67434
  if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
67252
67435
  try {
67253
- writeFileSync24(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
67436
+ writeFileSync25(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
67254
67437
  } catch (err) {
67255
67438
  console.error(chalk21.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
67256
67439
  }
@@ -67311,7 +67494,7 @@ function buildPrComment(run, opts) {
67311
67494
  }
67312
67495
 
67313
67496
  // src/commands/prompt.ts
67314
- import { existsSync as existsSync19, writeFileSync as writeFileSync25 } from "node:fs";
67497
+ import { existsSync as existsSync20, writeFileSync as writeFileSync26 } from "node:fs";
67315
67498
  import chalk22 from "chalk";
67316
67499
  function promptCommand(runId, opts) {
67317
67500
  let run;
@@ -67326,9 +67509,9 @@ function promptCommand(runId, opts) {
67326
67509
  limit: opts.limit
67327
67510
  });
67328
67511
  if (opts.out) {
67329
- writeFileSync25(opts.out, md, "utf8");
67512
+ writeFileSync26(opts.out, md, "utf8");
67330
67513
  console.log(chalk22.green(`✔ prompt salvo em ${opts.out}`));
67331
- if (existsSync19(opts.out)) {
67514
+ if (existsSync20(opts.out)) {
67332
67515
  const sizeKb = (md.length / 1024).toFixed(1);
67333
67516
  console.log(chalk22.dim(` ${md.length} chars (${sizeKb} KB)`));
67334
67517
  }
@@ -67339,7 +67522,7 @@ function promptCommand(runId, opts) {
67339
67522
  }
67340
67523
 
67341
67524
  // src/commands/report.ts
67342
- import { existsSync as existsSync20, readFileSync as readFileSync23, writeFileSync as writeFileSync26 } from "node:fs";
67525
+ import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
67343
67526
  import { join as join31 } from "node:path";
67344
67527
  import chalk23 from "chalk";
67345
67528
  import open2 from "open";
@@ -67921,7 +68104,7 @@ async function reportCommand(runId, opts) {
67921
68104
  }
67922
68105
  const html3 = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
67923
68106
  const dest = opts.out ?? join31(paths.runDir, "deck.html");
67924
- writeFileSync26(dest, html3, "utf8");
68107
+ writeFileSync27(dest, html3, "utf8");
67925
68108
  console.log(`${chalk23.green("✓")} deck → ${dest}`);
67926
68109
  if (opts.open) {
67927
68110
  await open2(dest).catch((err) => {
@@ -67947,11 +68130,11 @@ async function reportCommand(runId, opts) {
67947
68130
  return 1;
67948
68131
  }
67949
68132
  }
67950
- if (!existsSync20(paths.reportHtml)) {
68133
+ if (!existsSync21(paths.reportHtml)) {
67951
68134
  console.error(chalk23.red(`report.html not found at ${paths.reportHtml}`));
67952
68135
  return 1;
67953
68136
  }
67954
- const html3 = readFileSync23(paths.reportHtml, "utf8");
68137
+ const html3 = readFileSync24(paths.reportHtml, "utf8");
67955
68138
  const slice2 = extractReportSection({ kind: "html", section: opts.section, html: html3 });
67956
68139
  if (slice2 === null) {
67957
68140
  console.error(chalk23.red(`section "${opts.section}" not present in this report`));
@@ -67968,7 +68151,7 @@ async function reportCommand(runId, opts) {
67968
68151
  }
67969
68152
 
67970
68153
  // src/commands/vitals.ts
67971
- import { existsSync as existsSync21, readFileSync as readFileSync24, writeFileSync as writeFileSync27 } from "node:fs";
68154
+ import { existsSync as existsSync22, readFileSync as readFileSync25, writeFileSync as writeFileSync28 } from "node:fs";
67972
68155
  import { availableParallelism } from "node:os";
67973
68156
  import { join as join32 } from "node:path";
67974
68157
  import chalk24 from "chalk";
@@ -68400,7 +68583,7 @@ async function vitalsCommand(opts) {
68400
68583
  writeRunReportJson(paths.runDir, run);
68401
68584
  const html3 = renderHtmlReport(run, paths.runDir);
68402
68585
  writeRunReportHtml(paths.runDir, html3);
68403
- writeFileSync27(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
68586
+ writeFileSync28(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
68404
68587
  schemaVersion: "0.1",
68405
68588
  prodUrl: opts.prod,
68406
68589
  candUrl: opts.cand,
@@ -68504,8 +68687,8 @@ async function discoverPagePaths2(prodUrl, opts) {
68504
68687
  function parseUrlList(input) {
68505
68688
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
68506
68689
  const path = input.replace(/^file:\/\//, "");
68507
- if (existsSync21(path)) {
68508
- return readFileSync24(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
68690
+ if (existsSync22(path)) {
68691
+ return readFileSync25(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
68509
68692
  }
68510
68693
  }
68511
68694
  return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -68535,16 +68718,16 @@ function printSummary7(vitals, cache, scores, opportunities, agentic) {
68535
68718
  }
68536
68719
 
68537
68720
  // src/util/version.ts
68538
- import { readFileSync as readFileSync25 } from "node:fs";
68539
- import { dirname as dirname5, resolve as resolve5 } from "node:path";
68721
+ import { readFileSync as readFileSync26 } from "node:fs";
68722
+ import { dirname as dirname5, resolve as resolve6 } from "node:path";
68540
68723
  import { fileURLToPath } from "node:url";
68541
68724
  function getPackageVersion() {
68542
68725
  try {
68543
68726
  const here = dirname5(fileURLToPath(import.meta.url));
68544
68727
  for (const up of ["..", "../..", "../../.."]) {
68545
68728
  try {
68546
- const pkgPath = resolve5(here, up, "package.json");
68547
- const raw = readFileSync25(pkgPath, "utf8");
68729
+ const pkgPath = resolve6(here, up, "package.json");
68730
+ const raw = readFileSync26(pkgPath, "utf8");
68548
68731
  const parsed = JSON.parse(raw);
68549
68732
  if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
68550
68733
  return parsed.version;