@decocms/parity 0.28.5 → 0.29.0

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 +1161 -596
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -56579,48 +56579,577 @@ function printResult(result, meta) {
56579
56579
  }
56580
56580
  }
56581
56581
 
56582
- // src/commands/compare.ts
56582
+ // src/commands/cms.ts
56583
+ import { existsSync as existsSync13, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync12 } from "node:fs";
56584
+ import { dirname as dirname4, join as join18 } from "node:path";
56583
56585
  import chalk6 from "chalk";
56586
+
56587
+ // src/cms/client.ts
56588
+ import { homedir as homedir2 } from "node:os";
56589
+ import { join as join15 } from "node:path";
56590
+ import { readFileSync as readFileSync13 } from "node:fs";
56591
+ var MANAGE = "api/content-platform/manage";
56592
+ var SCHEMAS = "api/content-platform/schemas";
56593
+ function tokenFromVtexSession(home = homedir2()) {
56594
+ try {
56595
+ const raw = readFileSync13(join15(home, ".config", "configstore", "vtex.json"), "utf8");
56596
+ const token = JSON.parse(raw).token;
56597
+ return token && token.length > 0 ? token : null;
56598
+ } catch {
56599
+ return null;
56600
+ }
56601
+ }
56602
+ function cmsConfigFromEnv(env = process.env, home = homedir2()) {
56603
+ const account = env.PARITY_CMS_ACCOUNT;
56604
+ const store = env.PARITY_CMS_STORE;
56605
+ const token = env.PARITY_CMS_TOKEN ?? tokenFromVtexSession(home);
56606
+ if (!account || !store || !token)
56607
+ return null;
56608
+ return { account, store, token };
56609
+ }
56610
+ function baseUrl(cfg) {
56611
+ return `https://${cfg.account}.myvtex.com`;
56612
+ }
56613
+ var callCms = async (cfg, req) => {
56614
+ const method = req.method ?? "GET";
56615
+ const res = await fetch(`${baseUrl(cfg)}/${req.path}`, {
56616
+ method,
56617
+ headers: {
56618
+ authorization: `Bearer ${cfg.token}`,
56619
+ accept: "application/json",
56620
+ ...req.body === undefined ? {} : { "content-type": "application/json" }
56621
+ },
56622
+ ...req.body === undefined ? {} : { body: JSON.stringify(req.body) }
56623
+ });
56624
+ const text3 = await res.text().catch(() => "");
56625
+ if (!res.ok) {
56626
+ throw new Error(`${method} ${req.path}: HTTP ${res.status} ${text3.slice(0, 300)}`);
56627
+ }
56628
+ return text3 ? JSON.parse(text3) : {};
56629
+ };
56630
+ async function listBranches(cfg, call = callCms) {
56631
+ return call(cfg, { path: `${MANAGE}/${cfg.account}/${cfg.store}/branches` });
56632
+ }
56633
+ async function listEntries(cfg, opts = {}, call = callCms) {
56634
+ const params = new URLSearchParams({
56635
+ contentTypes: opts.contentType ?? "",
56636
+ page: "1",
56637
+ pageSize: String(opts.pageSize ?? 100)
56638
+ });
56639
+ const res = await call(cfg, {
56640
+ path: `${MANAGE}/${cfg.account}/entries?${params}`
56641
+ });
56642
+ return res.entries ?? [];
56643
+ }
56644
+ async function getLastVersion(cfg, args, call = callCms) {
56645
+ const { contentType, entryId, branchId } = args;
56646
+ const at = (branch) => call(cfg, {
56647
+ path: `${MANAGE}/${cfg.account}/${cfg.store}/${contentType}/entries/${entryId}/last-version?branchId=${branch}`
56648
+ });
56649
+ try {
56650
+ return await at(branchId);
56651
+ } catch (err) {
56652
+ const missing = err instanceof Error && /ENTRY_VERSIONS_NOT_FOUND/.test(err.message);
56653
+ if (!missing || branchId === "main")
56654
+ throw err;
56655
+ const base = await at("main");
56656
+ return { ...base, branchId, inheritedFromMain: true };
56657
+ }
56658
+ }
56659
+ async function commitEntry(cfg, input, call = callCms) {
56660
+ if (!input.baseHash) {
56661
+ throw new Error("commitEntry: baseHash is required — it is the lock against clobbering a concurrent edit");
56662
+ }
56663
+ return call(cfg, {
56664
+ path: `${MANAGE}/${cfg.account}/${cfg.store}/branches/${input.branchId}/commits`,
56665
+ method: "POST",
56666
+ body: {
56667
+ author: input.author,
56668
+ contentTypeId: input.contentTypeId,
56669
+ message: input.message,
56670
+ data: input.data,
56671
+ entryId: input.entryId,
56672
+ entryName: input.entryName,
56673
+ baseHash: input.baseHash,
56674
+ identifierKeys: input.identifierKeys ?? null,
56675
+ search_keywords: input.searchKeywords ?? null
56676
+ }
56677
+ });
56678
+ }
56679
+ async function undoEntry(cfg, args, call = callCms) {
56680
+ await call(cfg, {
56681
+ path: `${MANAGE}/${cfg.account}/${cfg.store}/branches/${args.branchId}/entries/${args.entryId}/undo`,
56682
+ method: "DELETE"
56683
+ });
56684
+ }
56685
+ async function getContentTypes(cfg, call = callCms) {
56686
+ return call(cfg, {
56687
+ path: `${SCHEMAS}/${cfg.account}.${cfg.store}/content-types`
56688
+ });
56689
+ }
56690
+
56691
+ // src/cms/authoring.ts
56692
+ function collectionToArray(node2) {
56693
+ if (Array.isArray(node2))
56694
+ return node2;
56695
+ if (node2 && typeof node2 === "object") {
56696
+ const values = node2.values;
56697
+ if (values && typeof values === "object") {
56698
+ return Object.values(values);
56699
+ }
56700
+ }
56701
+ return [];
56702
+ }
56703
+ function sectionsOf(data2) {
56704
+ if (!data2)
56705
+ return [];
56706
+ return collectionToArray(data2.sections).map((s) => ({
56707
+ id: s.id ?? null,
56708
+ componentKey: String(s.$componentKey ?? "?"),
56709
+ position: typeof s.$position === "number" ? s.$position : null
56710
+ })).sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
56711
+ }
56712
+ function summarizeSections(data2) {
56713
+ if (!data2)
56714
+ return [];
56715
+ const sections = collectionToArray(data2.sections);
56716
+ return sectionsOf(data2).map((s) => {
56717
+ const raw = sections.find((x) => x.id === s.id) ?? {};
56718
+ const counts = Object.entries(raw).filter(([, v]) => collectionToArray(v).length > 0).map(([k, v]) => `${k}=${collectionToArray(v).length}`);
56719
+ return counts.length > 0 ? `${s.componentKey} (${counts.join(", ")})` : s.componentKey;
56720
+ });
56721
+ }
56722
+
56723
+ // src/cms/session.ts
56724
+ import { existsSync as existsSync11, readFileSync as readFileSync14 } from "node:fs";
56725
+ import { homedir as homedir3 } from "node:os";
56726
+ import { delimiter, join as join16 } from "node:path";
56727
+ function sessionFile(home) {
56728
+ return join16(home, ".config", "configstore", "vtex.json");
56729
+ }
56730
+ function expiryOf(token) {
56731
+ const payload = token.split(".")[1];
56732
+ if (!payload)
56733
+ return null;
56734
+ try {
56735
+ const json = Buffer.from(payload.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8");
56736
+ const exp = JSON.parse(json).exp;
56737
+ return typeof exp === "number" ? exp : null;
56738
+ } catch {
56739
+ return null;
56740
+ }
56741
+ }
56742
+ function readVtexSession(home = homedir3()) {
56743
+ try {
56744
+ const raw = JSON.parse(readFileSync14(sessionFile(home), "utf8"));
56745
+ const token = typeof raw.token === "string" ? raw.token : "";
56746
+ if (!token)
56747
+ return null;
56748
+ return {
56749
+ token,
56750
+ account: typeof raw.account === "string" ? raw.account : null,
56751
+ login: typeof raw.login === "string" ? raw.login : null,
56752
+ expiresAt: expiryOf(token)
56753
+ };
56754
+ } catch {
56755
+ return null;
56756
+ }
56757
+ }
56758
+ function vtexCliInstalled(env = process.env) {
56759
+ const dirs = (env.PATH ?? "").split(delimiter).filter(Boolean);
56760
+ return dirs.some((dir) => existsSync11(join16(dir, "vtex")));
56761
+ }
56762
+ function sessionState(expectedAccount, env = process.env, home = homedir3(), now = Date.now()) {
56763
+ if (env.PARITY_CMS_TOKEN)
56764
+ return { status: "env-token" };
56765
+ const session = readVtexSession(home);
56766
+ if (!session)
56767
+ return vtexCliInstalled(env) ? { status: "logged-out" } : { status: "no-cli" };
56768
+ if (session.expiresAt !== null && session.expiresAt * 1000 <= now) {
56769
+ return { status: "expired", session };
56770
+ }
56771
+ if (expectedAccount && session.account && session.account !== expectedAccount) {
56772
+ return { status: "wrong-account", session, expected: expectedAccount };
56773
+ }
56774
+ return { status: "ok", session };
56775
+ }
56776
+ function sessionAdvice(state, expectedAccount = "<account>") {
56777
+ switch (state.status) {
56778
+ case "no-cli":
56779
+ return [
56780
+ "The VTEX toolbelt is not installed, so there is no way to get a session token.",
56781
+ " npm i -g vtex",
56782
+ ` vtex login ${expectedAccount}`
56783
+ ].join(`
56784
+ `);
56785
+ case "logged-out":
56786
+ return [
56787
+ "Not logged into VTEX.",
56788
+ ` vtex login ${expectedAccount}`,
56789
+ " (opens a browser for SSO — a human has to complete it)"
56790
+ ].join(`
56791
+ `);
56792
+ case "expired":
56793
+ return [
56794
+ `VTEX session expired${state.session.login ? ` for ${state.session.login}` : ""} — the toolbelt token lasts about a day.`,
56795
+ ` vtex login ${expectedAccount}`
56796
+ ].join(`
56797
+ `);
56798
+ case "wrong-account":
56799
+ return [
56800
+ `Logged into "${state.session.account}", but this run targets "${state.expected}". Wrong-account requests answer 401, which looks like a broken token.`,
56801
+ ` vtex login ${state.expected}`
56802
+ ].join(`
56803
+ `);
56804
+ default:
56805
+ return "";
56806
+ }
56807
+ }
56808
+ function describeSession(state) {
56809
+ if (state.status === "env-token")
56810
+ return "using PARITY_CMS_TOKEN";
56811
+ if (state.status !== "ok")
56812
+ return "";
56813
+ const { login, account, expiresAt } = state.session;
56814
+ const left = expiresAt === null ? "" : ` · expires in ${Math.max(0, Math.round((expiresAt * 1000 - Date.now()) / 3600000))}h`;
56815
+ return `${login ?? "?"} on ${account ?? "?"}${left}`;
56816
+ }
56817
+
56818
+ // src/cms/schema.ts
56819
+ import { readFileSync as readFileSync15, readdirSync as readdirSync3, existsSync as existsSync12 } from "node:fs";
56820
+ import { join as join17 } from "node:path";
56821
+ function publishedComponentKeys(contentType) {
56822
+ const items = contentType?.properties?.sections?.items;
56823
+ const anyOf = items?.anyOf ?? [];
56824
+ return anyOf.map((s) => String(s.$componentKey ?? "")).filter(Boolean);
56825
+ }
56826
+ function localComponentKeys(repoDir, contentType) {
56827
+ const dir = join17(repoDir, "cms", "faststore", "pages");
56828
+ if (!existsSync12(dir))
56829
+ return null;
56830
+ const wanted = `cms_content_type__${contentType.toLowerCase()}.jsonc`;
56831
+ const file = readdirSync3(dir).find((f) => f.toLowerCase() === wanted);
56832
+ if (!file)
56833
+ return null;
56834
+ const raw = readFileSync15(join17(dir, file), "utf8");
56835
+ const start = raw.indexOf('"sections"');
56836
+ if (start < 0)
56837
+ return [];
56838
+ return [...raw.slice(start).matchAll(/"#\/components\/([A-Za-z0-9_-]+)"/g)].map((m) => m[1] ?? "").filter(Boolean);
56839
+ }
56840
+ function schemaDrift(published, repoDir) {
56841
+ const drift = [];
56842
+ for (const [contentType, schema] of Object.entries(published)) {
56843
+ const local = localComponentKeys(repoDir, contentType);
56844
+ if (!local)
56845
+ continue;
56846
+ const remote = publishedComponentKeys(schema);
56847
+ const missingOnAccount = local.filter((k) => !remote.includes(k));
56848
+ const missingInRepo = remote.filter((k) => !local.includes(k));
56849
+ if (missingOnAccount.length > 0 || missingInRepo.length > 0) {
56850
+ drift.push({ contentType, missingOnAccount, missingInRepo });
56851
+ }
56852
+ }
56853
+ return drift;
56854
+ }
56855
+ function unrenderableSections(usedKeys, contentType) {
56856
+ const allowed = publishedComponentKeys(contentType);
56857
+ if (allowed.length === 0)
56858
+ return [];
56859
+ return [...new Set(usedKeys.filter((k) => !allowed.includes(k)))];
56860
+ }
56861
+
56862
+ // src/commands/cms.ts
56863
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
56864
+ function config() {
56865
+ const account = process.env.PARITY_CMS_ACCOUNT;
56866
+ const store = process.env.PARITY_CMS_STORE;
56867
+ if (!account || !store) {
56868
+ console.error(chalk6.red("Missing target. Set PARITY_CMS_ACCOUNT and PARITY_CMS_STORE (the store id, not the account)."));
56869
+ return null;
56870
+ }
56871
+ const state = sessionState(account);
56872
+ if (state.status !== "ok" && state.status !== "env-token") {
56873
+ console.error(chalk6.red(sessionAdvice(state, account)));
56874
+ return null;
56875
+ }
56876
+ const cfg = cmsConfigFromEnv();
56877
+ if (!cfg) {
56878
+ console.error(chalk6.red("Could not read a VTEX token. Run `vtex login` or set PARITY_CMS_TOKEN."));
56879
+ }
56880
+ return cfg;
56881
+ }
56882
+ function fail(err) {
56883
+ console.error(chalk6.red(err instanceof Error ? err.message : String(err)));
56884
+ return 1;
56885
+ }
56886
+ function resolveBranch(branch, allowMain) {
56887
+ if (!branch)
56888
+ return new Error("--branch <id> is required. `parity cms ls --branches` lists them.");
56889
+ if (branch === "main") {
56890
+ return allowMain ? "main" : new Error("Refusing to write to main. Use a working branch, or pass --allow-main.");
56891
+ }
56892
+ if (!UUID.test(branch)) {
56893
+ return new Error(`"${branch}" is not a branch id. Branch names do not address a branch — pass the uuid from \`parity cms ls --branches\`.`);
56894
+ }
56895
+ return branch;
56896
+ }
56897
+ async function cmsDoctorCommand(opts, call = callCms) {
56898
+ const cfg = config();
56899
+ if (!cfg)
56900
+ return 1;
56901
+ const session = describeSession(sessionState(process.env.PARITY_CMS_ACCOUNT));
56902
+ try {
56903
+ const types = await getContentTypes(cfg, call);
56904
+ const drift = schemaDrift(types, opts.repo);
56905
+ if (opts.json) {
56906
+ console.log(JSON.stringify({ session, contentTypes: Object.keys(types), drift }, null, 2));
56907
+ return drift.some((d) => d.missingOnAccount.length > 0) ? 1 : 0;
56908
+ }
56909
+ if (session)
56910
+ console.log(`${chalk6.green("✓")} ${session}`);
56911
+ const blocking = drift.filter((d) => d.missingOnAccount.length > 0);
56912
+ if (blocking.length === 0) {
56913
+ console.log(`${chalk6.green("✓")} every section the repo declares is published on the account`);
56914
+ }
56915
+ for (const d of blocking) {
56916
+ console.log(`${chalk6.red("✗")} ${d.contentType}: ${d.missingOnAccount.join(", ")} ${chalk6.dim("— in the repo, not on the account. Upload the schema (`faststore cms-sync`) or it renders nothing.")}`);
56917
+ }
56918
+ for (const d of drift.filter((x) => x.missingInRepo.length > 0)) {
56919
+ console.log(`${chalk6.gray("·")} ${d.contentType}: ${d.missingInRepo.length} section(s) published but not in the repo ${chalk6.dim("(usually core components the repo never overrode)")}`);
56920
+ }
56921
+ return blocking.length > 0 ? 1 : 0;
56922
+ } catch (err) {
56923
+ return fail(err);
56924
+ }
56925
+ }
56926
+ async function cmsLsCommand(opts, call = callCms) {
56927
+ const cfg = config();
56928
+ if (!cfg)
56929
+ return 1;
56930
+ try {
56931
+ if (opts.branches) {
56932
+ const branches = await listBranches(cfg, call);
56933
+ if (opts.json)
56934
+ console.log(JSON.stringify(branches, null, 2));
56935
+ else
56936
+ for (const b of branches)
56937
+ console.log(`${b.id} ${b.name}`);
56938
+ return 0;
56939
+ }
56940
+ const entries = await listEntries(cfg, { contentType: opts.contentType }, call);
56941
+ if (opts.json) {
56942
+ console.log(JSON.stringify(entries, null, 2));
56943
+ return 0;
56944
+ }
56945
+ for (const e of entries) {
56946
+ const slug = e.search_keywords?.find((k) => k.startsWith("/")) ?? "";
56947
+ console.log(`${e.id} ${e.contentTypeId.padEnd(14)} ${slug.padEnd(34)} ${e.name}`);
56948
+ }
56949
+ return 0;
56950
+ } catch (err) {
56951
+ return fail(err);
56952
+ }
56953
+ }
56954
+ async function cmsPullCommand(opts, call = callCms) {
56955
+ const cfg = config();
56956
+ if (!cfg)
56957
+ return 1;
56958
+ const branch = resolveBranch(opts.branch, true);
56959
+ if (branch instanceof Error)
56960
+ return fail(branch);
56961
+ try {
56962
+ const version = await getLastVersion(cfg, { contentType: opts.contentType, entryId: opts.entry, branchId: branch }, call);
56963
+ const out = opts.out ?? join18("parity-output", "cms", `${opts.contentType}-${opts.entry}.json`);
56964
+ mkdirSync9(dirname4(out), { recursive: true });
56965
+ writeFileSync12(out, `${JSON.stringify(version, null, 2)}
56966
+ `);
56967
+ if (opts.json) {
56968
+ console.log(JSON.stringify({ out, sections: sectionsOf(version.data).length }, null, 2));
56969
+ return 0;
56970
+ }
56971
+ console.log(`${chalk6.green("✓")} ${out}`);
56972
+ if (version.inheritedFromMain) {
56973
+ console.log(chalk6.dim(" (this branch has no changes to this entry yet — content read from main)"));
56974
+ }
56975
+ for (const line of summarizeSections(version.data))
56976
+ console.log(` ${line}`);
56977
+ return 0;
56978
+ } catch (err) {
56979
+ return fail(err);
56980
+ }
56981
+ }
56982
+ function readPulled(file) {
56983
+ if (!existsSync13(file))
56984
+ return new Error(`No such file: ${file}`);
56985
+ try {
56986
+ return JSON.parse(readFileSync16(file, "utf8"));
56987
+ } catch (err) {
56988
+ return new Error(`${file} is not valid JSON: ${err instanceof Error ? err.message : err}`);
56989
+ }
56990
+ }
56991
+ async function cmsDiffCommand(opts, call = callCms) {
56992
+ const cfg = config();
56993
+ if (!cfg)
56994
+ return 1;
56995
+ const local = readPulled(opts.file);
56996
+ if (local instanceof Error)
56997
+ return fail(local);
56998
+ try {
56999
+ const remote = await getLastVersion(cfg, {
57000
+ contentType: local.contentType,
57001
+ entryId: local.entryId,
57002
+ branchId: opts.branch ?? local.branchId
57003
+ }, call);
57004
+ const changed = JSON.stringify(local.data) !== JSON.stringify(remote.data);
57005
+ const stale = remote.baseHash !== local.baseHash;
57006
+ const result = {
57007
+ changed,
57008
+ stale,
57009
+ local: summarizeSections(local.data),
57010
+ remote: summarizeSections(remote.data)
57011
+ };
57012
+ if (opts.json) {
57013
+ console.log(JSON.stringify(result, null, 2));
57014
+ return changed ? 1 : 0;
57015
+ }
57016
+ if (!changed) {
57017
+ console.log(`${chalk6.green("✓")} no changes`);
57018
+ return 0;
57019
+ }
57020
+ console.log(chalk6.yellow("remote → local (what push would write)"));
57021
+ const width = Math.max(result.local.length, result.remote.length);
57022
+ for (let i = 0;i < width; i += 1) {
57023
+ const l = result.local[i] ?? chalk6.dim("—");
57024
+ const r = result.remote[i] ?? chalk6.dim("—");
57025
+ console.log(` ${l === r ? chalk6.gray(l) : `${chalk6.red(r)} → ${chalk6.green(l)}`}`);
57026
+ }
57027
+ if (stale) {
57028
+ console.log(chalk6.yellow("! the remote moved since this was pulled — pull again before pushing, or the commit is rejected"));
57029
+ }
57030
+ return 1;
57031
+ } catch (err) {
57032
+ return fail(err);
57033
+ }
57034
+ }
57035
+ async function cmsPushCommand(opts, call = callCms) {
57036
+ const cfg = config();
57037
+ if (!cfg)
57038
+ return 1;
57039
+ const local = readPulled(opts.file);
57040
+ if (local instanceof Error)
57041
+ return fail(local);
57042
+ const branch = resolveBranch(opts.branch ?? local.branchId, Boolean(opts.allowMain));
57043
+ if (branch instanceof Error)
57044
+ return fail(branch);
57045
+ try {
57046
+ const types = await getContentTypes(cfg, call);
57047
+ const used = sectionsOf(local.data).map((s) => s.componentKey);
57048
+ const unrenderable = unrenderableSections(used, types[local.contentType]);
57049
+ if (unrenderable.length > 0) {
57050
+ return fail(new Error(`${unrenderable.join(", ")} not published on this account — the commit would succeed and render nothing. Upload the schema first (\`faststore cms-sync\`), or run \`parity cms doctor\`.`));
57051
+ }
57052
+ const remote = await getLastVersion(cfg, { contentType: local.contentType, entryId: local.entryId, branchId: branch }, call);
57053
+ if (remote.baseHash !== local.baseHash) {
57054
+ return fail(new Error(`Stale: pulled at ${local.baseHash.slice(0, 12)}, remote is at ${remote.baseHash.slice(0, 12)}. Pull again.`));
57055
+ }
57056
+ if (!opts.yes) {
57057
+ console.log(chalk6.yellow("dry run — nothing written. Pass --yes to commit."));
57058
+ for (const line of summarizeSections(local.data))
57059
+ console.log(` ${line}`);
57060
+ console.log(chalk6.dim(` branch ${branch} · entry ${local.entryId} · ${local.contentType}`));
57061
+ return 0;
57062
+ }
57063
+ const backup = join18("parity-output", "cms-backups", `${local.entryId}-${remote.baseHash.slice(0, 12)}.json`);
57064
+ mkdirSync9(dirname4(backup), { recursive: true });
57065
+ writeFileSync12(backup, `${JSON.stringify(remote, null, 2)}
57066
+ `);
57067
+ const commit = await commitEntry(cfg, {
57068
+ branchId: branch,
57069
+ contentTypeId: local.contentType,
57070
+ entryId: local.entryId,
57071
+ entryName: local.entryName,
57072
+ baseHash: local.baseHash,
57073
+ data: local.data,
57074
+ message: opts.message ?? "parity cms push",
57075
+ author: opts.author ?? "parity",
57076
+ identifierKeys: local.identifierKeys,
57077
+ searchKeywords: local.searchKeywords
57078
+ }, call);
57079
+ if (opts.json) {
57080
+ console.log(JSON.stringify({ commit, backup }, null, 2));
57081
+ return 0;
57082
+ }
57083
+ console.log(`${chalk6.green("✓")} commit ${commit.id} on ${branch}`);
57084
+ console.log(chalk6.dim(` rollback: parity cms undo --entry ${local.entryId} --branch ${branch}`));
57085
+ console.log(chalk6.dim(` backup: ${backup}`));
57086
+ return 0;
57087
+ } catch (err) {
57088
+ return fail(err);
57089
+ }
57090
+ }
57091
+ async function cmsUndoCommand(opts, call = callCms) {
57092
+ const cfg = config();
57093
+ if (!cfg)
57094
+ return 1;
57095
+ const branch = resolveBranch(opts.branch, Boolean(opts.allowMain));
57096
+ if (branch instanceof Error)
57097
+ return fail(branch);
57098
+ if (!opts.yes) {
57099
+ console.log(chalk6.yellow(`dry run — would drop ${opts.entry} changes on ${branch}. Pass --yes.`));
57100
+ return 0;
57101
+ }
57102
+ try {
57103
+ await undoEntry(cfg, { branchId: branch, entryId: opts.entry }, call);
57104
+ console.log(`${chalk6.green("✓")} ${opts.entry} reverted on ${branch}`);
57105
+ return 0;
57106
+ } catch (err) {
57107
+ return fail(err);
57108
+ }
57109
+ }
57110
+
57111
+ // src/commands/compare.ts
57112
+ import chalk7 from "chalk";
56584
57113
  function compareCommand(runId, baselineName, output) {
56585
57114
  try {
56586
57115
  const run = loadRun(output, runId);
56587
57116
  const baseline = loadBaseline(baselineName);
56588
57117
  const delta = compareToBaseline(run, baseline);
56589
- console.log(chalk6.bold(`
57118
+ console.log(chalk7.bold(`
56590
57119
  Delta ${runId} vs baseline "${baselineName}"`));
56591
- console.log(` ${chalk6.green("✓ resolved")}: ${delta.resolved.length}`);
56592
- console.log(` ${chalk6.yellow("+ new")}: ${delta.new.length}`);
56593
- console.log(` ${chalk6.red("⚠ regressed")}: ${delta.regressions.length}`);
57120
+ console.log(` ${chalk7.green("✓ resolved")}: ${delta.resolved.length}`);
57121
+ console.log(` ${chalk7.yellow("+ new")}: ${delta.new.length}`);
57122
+ console.log(` ${chalk7.red("⚠ regressed")}: ${delta.regressions.length}`);
56594
57123
  if (delta.new.length > 0) {
56595
- console.log(chalk6.bold(`
57124
+ console.log(chalk7.bold(`
56596
57125
  Novos issue ids:`));
56597
57126
  for (const id of delta.new)
56598
57127
  console.log(` - ${id}`);
56599
57128
  }
56600
57129
  if (delta.regressions.length > 0) {
56601
- console.log(chalk6.bold(`
57130
+ console.log(chalk7.bold(`
56602
57131
  Regressões (severity piorou):`));
56603
57132
  for (const id of delta.regressions)
56604
57133
  console.log(` - ${id}`);
56605
57134
  }
56606
57135
  return 0;
56607
57136
  } catch (err) {
56608
- console.error(chalk6.red(`✖ ${err.message}`));
57137
+ console.error(chalk7.red(`✖ ${err.message}`));
56609
57138
  return 1;
56610
57139
  }
56611
57140
  }
56612
57141
 
56613
57142
  // src/commands/console.ts
56614
- import chalk7 from "chalk";
57143
+ import chalk8 from "chalk";
56615
57144
  async function consoleCommand(opts) {
56616
57145
  const viewport = parseViewport2(opts.viewport);
56617
57146
  if (!viewport) {
56618
- console.error(chalk7.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
57147
+ console.error(chalk8.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
56619
57148
  return 2;
56620
57149
  }
56621
57150
  const waitMs = Number.parseInt(opts.wait, 10);
56622
57151
  if (!Number.isFinite(waitMs) || waitMs < 0) {
56623
- console.error(chalk7.red(`--wait inválido: ${opts.wait}`));
57152
+ console.error(chalk8.red(`--wait inválido: ${opts.wait}`));
56624
57153
  return 2;
56625
57154
  }
56626
57155
  const filter4 = parseFilter(opts.filter);
@@ -56628,7 +57157,7 @@ async function consoleCommand(opts) {
56628
57157
  try {
56629
57158
  url = new URL(opts.url);
56630
57159
  } catch {
56631
- console.error(chalk7.red(`--url inválido: ${opts.url}`));
57160
+ console.error(chalk8.red(`--url inválido: ${opts.url}`));
56632
57161
  return 2;
56633
57162
  }
56634
57163
  const browser = await launchBrowser({ headless: true });
@@ -56677,24 +57206,24 @@ function printResults(entries, meta) {
56677
57206
  return;
56678
57207
  }
56679
57208
  if (entries.length === 0) {
56680
- console.log(chalk7.dim(` ${meta.viewport} · ${meta.url}
57209
+ console.log(chalk8.dim(` ${meta.viewport} · ${meta.url}
56681
57210
  nenhuma entrada de console nos filtros pedidos`));
56682
57211
  return;
56683
57212
  }
56684
- console.log(chalk7.bold(`
57213
+ console.log(chalk8.bold(`
56685
57214
  ${meta.viewport} · ${meta.url}`));
56686
- console.log(chalk7.dim(` ${entries.length} entrada(s)
57215
+ console.log(chalk8.dim(` ${entries.length} entrada(s)
56687
57216
  `));
56688
57217
  for (const e of entries) {
56689
- const tag = e.type === "error" ? chalk7.red("[error ]") : e.type === "warning" ? chalk7.yellow("[warn ]") : chalk7.dim(`[${e.type.padEnd(7)}]`);
56690
- const loc = e.location ? chalk7.dim(` ← ${e.location}`) : "";
57218
+ const tag = e.type === "error" ? chalk8.red("[error ]") : e.type === "warning" ? chalk8.yellow("[warn ]") : chalk8.dim(`[${e.type.padEnd(7)}]`);
57219
+ const loc = e.location ? chalk8.dim(` ← ${e.location}`) : "";
56691
57220
  const text3 = e.text.length > 400 ? `${e.text.slice(0, 397)}...` : e.text;
56692
57221
  console.log(` ${tag} ${text3}${loc}`);
56693
57222
  }
56694
57223
  }
56695
57224
 
56696
57225
  // src/commands/css-trace.ts
56697
- import chalk8 from "chalk";
57226
+ import chalk9 from "chalk";
56698
57227
  async function tracePage(page, url, selector, settleMs) {
56699
57228
  await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 });
56700
57229
  await page.waitForLoadState("load", { timeout: 12000 }).catch(() => {
@@ -56805,35 +57334,35 @@ function applyFilter(result, filter4) {
56805
57334
  return { ...result, computed, rules };
56806
57335
  }
56807
57336
  function printResult2(result, header) {
56808
- console.log(chalk8.bold(`
57337
+ console.log(chalk9.bold(`
56809
57338
  ${header}`));
56810
- console.log(chalk8.dim(`URL: ${result.url}`));
56811
- console.log(chalk8.dim(`Selector: ${result.selector}`));
57339
+ console.log(chalk9.dim(`URL: ${result.url}`));
57340
+ console.log(chalk9.dim(`Selector: ${result.selector}`));
56812
57341
  if (!result.found) {
56813
- console.log(chalk8.red("✖ Element not found"));
57342
+ console.log(chalk9.red("✖ Element not found"));
56814
57343
  return;
56815
57344
  }
56816
57345
  const computedKeys = Object.keys(result.computed);
56817
57346
  if (computedKeys.length > 0) {
56818
- console.log(chalk8.bold(`
57347
+ console.log(chalk9.bold(`
56819
57348
  Computed:`));
56820
57349
  for (const k of computedKeys) {
56821
- console.log(` ${chalk8.cyan(k)}: ${result.computed[k]}`);
57350
+ console.log(` ${chalk9.cyan(k)}: ${result.computed[k]}`);
56822
57351
  }
56823
57352
  }
56824
57353
  if (result.rules.length === 0) {
56825
- console.log(chalk8.yellow(`
57354
+ console.log(chalk9.yellow(`
56826
57355
  No matching rules after filter.`));
56827
57356
  return;
56828
57357
  }
56829
- console.log(chalk8.bold(`
57358
+ console.log(chalk9.bold(`
56830
57359
  Rules (ordered by CDP — most specific last):`));
56831
57360
  for (const r of result.rules) {
56832
- const inheritLabel = r.inheritedFromDistance !== undefined ? chalk8.yellow(` ↑ inherited from ancestor (${r.inheritedFromDistance})`) : "";
56833
- console.log(` ${chalk8.magenta(r.source)}${inheritLabel}`);
56834
- console.log(` ${chalk8.green(r.selector)} {`);
57361
+ const inheritLabel = r.inheritedFromDistance !== undefined ? chalk9.yellow(` ↑ inherited from ancestor (${r.inheritedFromDistance})`) : "";
57362
+ console.log(` ${chalk9.magenta(r.source)}${inheritLabel}`);
57363
+ console.log(` ${chalk9.green(r.selector)} {`);
56835
57364
  for (const p of r.properties) {
56836
- const bang = p.important ? chalk8.red(" !important") : "";
57365
+ const bang = p.important ? chalk9.red(" !important") : "";
56837
57366
  console.log(` ${p.name}: ${p.value}${bang};`);
56838
57367
  }
56839
57368
  console.log(" }");
@@ -56854,38 +57383,38 @@ function printComparison(prod, cand) {
56854
57383
  printResult2(prod, "── PROD ──────────────────────────────────────────────");
56855
57384
  printResult2(cand, "── CAND ──────────────────────────────────────────────");
56856
57385
  const diffs = diffComputed(prod, cand);
56857
- console.log(chalk8.bold(`
57386
+ console.log(chalk9.bold(`
56858
57387
  ── DIFF (computed) ───────────────────────────────────`));
56859
57388
  if (diffs.length === 0) {
56860
- console.log(chalk8.green(" No computed-style differences in the filtered set."));
57389
+ console.log(chalk9.green(" No computed-style differences in the filtered set."));
56861
57390
  return;
56862
57391
  }
56863
57392
  for (const d of diffs) {
56864
- console.log(` ${chalk8.cyan(d.property)}`);
56865
- console.log(` prod: ${chalk8.green(d.prod ?? "(unset)")}`);
56866
- console.log(` cand: ${chalk8.red(d.cand ?? "(unset)")}`);
57393
+ console.log(` ${chalk9.cyan(d.property)}`);
57394
+ console.log(` prod: ${chalk9.green(d.prod ?? "(unset)")}`);
57395
+ console.log(` cand: ${chalk9.red(d.cand ?? "(unset)")}`);
56867
57396
  }
56868
57397
  }
56869
57398
  async function cssTraceCommand(opts) {
56870
57399
  const viewport = opts.viewport ?? "desktop";
56871
57400
  const settleMs = opts.settleMs ?? 1500;
56872
57401
  if (!opts.selector) {
56873
- console.error(chalk8.red("--selector is required"));
57402
+ console.error(chalk9.red("--selector is required"));
56874
57403
  return 1;
56875
57404
  }
56876
57405
  const hasUrl = !!opts.url;
56877
57406
  const hasProd = !!opts.prod;
56878
57407
  const hasCand = !!opts.cand;
56879
57408
  if (hasUrl && (hasProd || hasCand)) {
56880
- console.error(chalk8.red("--url is mutually exclusive with --prod / --cand. Pass one mode only."));
57409
+ console.error(chalk9.red("--url is mutually exclusive with --prod / --cand. Pass one mode only."));
56881
57410
  return 1;
56882
57411
  }
56883
57412
  if (hasProd && !hasCand || !hasProd && hasCand) {
56884
- console.error(chalk8.red("Comparison mode needs both --prod and --cand (got only one)."));
57413
+ console.error(chalk9.red("Comparison mode needs both --prod and --cand (got only one)."));
56885
57414
  return 1;
56886
57415
  }
56887
57416
  if (!hasUrl && !hasProd && !hasCand) {
56888
- console.error(chalk8.red("Provide either --url or both --prod and --cand."));
57417
+ console.error(chalk9.red("Provide either --url or both --prod and --cand."));
56889
57418
  return 1;
56890
57419
  }
56891
57420
  const isCompare = hasProd && hasCand;
@@ -56936,7 +57465,7 @@ async function cssTraceCommand(opts) {
56936
57465
  }
56937
57466
  return 0;
56938
57467
  } catch (err) {
56939
- console.error(chalk8.red(`Error: ${err.message}`));
57468
+ console.error(chalk9.red(`Error: ${err.message}`));
56940
57469
  return 1;
56941
57470
  } finally {
56942
57471
  await browser?.close().catch(() => {
@@ -56946,9 +57475,9 @@ async function cssTraceCommand(opts) {
56946
57475
  }
56947
57476
 
56948
57477
  // src/commands/e2e.ts
56949
- import { writeFileSync as writeFileSync13 } from "node:fs";
57478
+ import { writeFileSync as writeFileSync14 } from "node:fs";
56950
57479
  import { spawn as spawn2 } from "node:child_process";
56951
- import chalk9 from "chalk";
57480
+ import chalk10 from "chalk";
56952
57481
  import ora5 from "ora";
56953
57482
 
56954
57483
  // src/engine/flows/cart-interactions.ts
@@ -57898,8 +58427,8 @@ async function flowLogin(ctx) {
57898
58427
 
57899
58428
  // src/llm/resolve-search-terms.ts
57900
58429
  init_client();
57901
- import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
57902
- import { join as join15 } from "node:path";
58430
+ import { existsSync as existsSync14, mkdirSync as mkdirSync10, readFileSync as readFileSync17, writeFileSync as writeFileSync13 } from "node:fs";
58431
+ import { join as join19 } from "node:path";
57903
58432
  var CACHE_DIR2 = ".parity-cache";
57904
58433
  var FALLBACK_TERMS = ["produto", "preto", "promocao"];
57905
58434
  function makeNoResults(runId) {
@@ -57979,10 +58508,10 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57979
58508
  }
57980
58509
  const host = safeHost3(url);
57981
58510
  const cacheDir = opts.cacheDir ?? CACHE_DIR2;
57982
- const cachePath = join15(cacheDir, `search-terms-${host}.json`);
57983
- if (!opts.noCache && existsSync11(cachePath)) {
58511
+ const cachePath = join19(cacheDir, `search-terms-${host}.json`);
58512
+ if (!opts.noCache && existsSync14(cachePath)) {
57984
58513
  try {
57985
- const cached = JSON.parse(readFileSync13(cachePath, "utf8"));
58514
+ const cached = JSON.parse(readFileSync17(cachePath, "utf8"));
57986
58515
  if (cached.withResults?.trim()) {
57987
58516
  return { withResults: cached.withResults.trim(), noResults };
57988
58517
  }
@@ -57990,9 +58519,9 @@ async function resolveSearchTerms(url, html3, opts = {}) {
57990
58519
  }
57991
58520
  const suggested = await suggestTermViaLlm(url, html3);
57992
58521
  if (suggested) {
57993
- if (!existsSync11(cacheDir))
57994
- mkdirSync9(cacheDir, { recursive: true });
57995
- writeFileSync12(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
58522
+ if (!existsSync14(cacheDir))
58523
+ mkdirSync10(cacheDir, { recursive: true });
58524
+ writeFileSync13(cachePath, `${JSON.stringify({ withResults: suggested, source: "llm" }, null, 2)}
57996
58525
  `, "utf8");
57997
58526
  return { withResults: suggested, noResults };
57998
58527
  }
@@ -58033,8 +58562,8 @@ ${capturedHtml}`;
58033
58562
  }
58034
58563
  return false;
58035
58564
  }
58036
- function searchUrlFor(baseUrl, term, path = "/search") {
58037
- const u = new URL(path, baseUrl);
58565
+ function searchUrlFor(baseUrl2, term, path = "/search") {
58566
+ const u = new URL(path, baseUrl2);
58038
58567
  u.searchParams.set("q", term);
58039
58568
  return u.toString();
58040
58569
  }
@@ -58775,14 +59304,14 @@ async function fetchHomeHtml(url, viewport = "desktop") {
58775
59304
  return null;
58776
59305
  }
58777
59306
  }
58778
- function firstProductHrefFromPlpHtml(html3, baseUrl) {
59307
+ function firstProductHrefFromPlpHtml(html3, baseUrl2) {
58779
59308
  const patterns = [/href="([^"]+\/p(?:\?[^"]*|\/[^"]+|))"/i, /href="([^"]+\/products\/[^"]+)"/i];
58780
59309
  for (const re of patterns) {
58781
59310
  const match = re.exec(html3);
58782
59311
  const href = match?.[1];
58783
59312
  if (href) {
58784
59313
  try {
58785
- return new URL(href, baseUrl).toString();
59314
+ return new URL(href, baseUrl2).toString();
58786
59315
  } catch {}
58787
59316
  }
58788
59317
  }
@@ -59008,19 +59537,19 @@ var DEFAULT_E2E_FLOWS = [
59008
59537
  async function e2eCommand(opts) {
59009
59538
  const viewports = parseViewports(opts.viewports);
59010
59539
  if (viewports.length === 0) {
59011
- console.error(chalk9.red(`--viewports inválido: ${opts.viewports} (use mobile,desktop,tablet)`));
59540
+ console.error(chalk10.red(`--viewports inválido: ${opts.viewports} (use mobile,desktop,tablet)`));
59012
59541
  return 2;
59013
59542
  }
59014
- let baseUrl;
59543
+ let baseUrl2;
59015
59544
  try {
59016
- baseUrl = new URL(opts.url);
59545
+ baseUrl2 = new URL(opts.url);
59017
59546
  } catch {
59018
- console.error(chalk9.red(`--url inválido: ${opts.url}`));
59547
+ console.error(chalk10.red(`--url inválido: ${opts.url}`));
59019
59548
  return 2;
59020
59549
  }
59021
59550
  const flows2 = parseFlows(opts.flows);
59022
59551
  if (flows2.length === 0) {
59023
- console.error(chalk9.red(`--flows inválido: ${opts.flows}`));
59552
+ console.error(chalk10.red(`--flows inválido: ${opts.flows}`));
59024
59553
  return 2;
59025
59554
  }
59026
59555
  const rc = loadParityRc();
@@ -59051,12 +59580,12 @@ async function e2eCommand(opts) {
59051
59580
  const paths = createRunDir(opts.output, runId);
59052
59581
  const startedAt = Date.now();
59053
59582
  if (!opts.json) {
59054
- console.log(chalk9.bold(`
59583
+ console.log(chalk10.bold(`
59055
59584
  parity e2e ${runId}`));
59056
- console.log(chalk9.dim(` url: ${opts.url}`));
59057
- console.log(chalk9.dim(` flows: ${flows2.join(", ")}`));
59058
- console.log(chalk9.dim(` viewports: ${viewports.join(", ")}`));
59059
- console.log(chalk9.dim(` cep: ${rc.cep}
59585
+ console.log(chalk10.dim(` url: ${opts.url}`));
59586
+ console.log(chalk10.dim(` flows: ${flows2.join(", ")}`));
59587
+ console.log(chalk10.dim(` viewports: ${viewports.join(", ")}`));
59588
+ console.log(chalk10.dim(` cep: ${rc.cep}
59060
59589
  `));
59061
59590
  }
59062
59591
  let platform = "custom";
@@ -59064,7 +59593,7 @@ async function e2eCommand(opts) {
59064
59593
  if (homeHtml) {
59065
59594
  platform = detectPlatform({ url: opts.url, html: homeHtml });
59066
59595
  if (platform !== "custom" && !opts.json) {
59067
- console.log(chalk9.dim(` Detected platform: ${platform}`));
59596
+ console.log(chalk10.dim(` Detected platform: ${platform}`));
59068
59597
  }
59069
59598
  }
59070
59599
  const wantsAutoSelectors = opts.autoSelectors !== false && isLlmAvailable();
@@ -59151,7 +59680,7 @@ async function e2eCommand(opts) {
59151
59680
  saveLearned(learned);
59152
59681
  }
59153
59682
  if (allPages.length === 0) {
59154
- console.error(chalk9.red(`
59683
+ console.error(chalk10.red(`
59155
59684
  ✖ nenhuma captura completada`));
59156
59685
  return 2;
59157
59686
  }
@@ -59210,8 +59739,8 @@ async function e2eCommand(opts) {
59210
59739
  generatedAt: new Date().toISOString(),
59211
59740
  durationMs
59212
59741
  });
59213
- writeFileSync13(paths.reportHtml, html3, "utf8");
59214
- writeFileSync13(paths.reportJson, `${JSON.stringify({
59742
+ writeFileSync14(paths.reportHtml, html3, "utf8");
59743
+ writeFileSync14(paths.reportJson, `${JSON.stringify({
59215
59744
  runId,
59216
59745
  mode: "e2e",
59217
59746
  url: opts.url,
@@ -59275,17 +59804,17 @@ function parseFlows(raw) {
59275
59804
  }
59276
59805
  function printSummary4(result, reportPath) {
59277
59806
  const { totals } = result;
59278
- const verdict = totals.critical > 0 ? chalk9.red.bold("✖ FAIL") : totals.high > 0 ? chalk9.red("✖ FAIL") : totals.issues > 0 ? chalk9.yellow("⚠ WARN") : chalk9.green.bold("✓ PASS");
59807
+ const verdict = totals.critical > 0 ? chalk10.red.bold("✖ FAIL") : totals.high > 0 ? chalk10.red("✖ FAIL") : totals.issues > 0 ? chalk10.yellow("⚠ WARN") : chalk10.green.bold("✓ PASS");
59279
59808
  console.log(`
59280
59809
  ${verdict}`);
59281
59810
  console.log(` ${totals.pages} página(s) · ${totals.issues} issue(s)`);
59282
- console.log(` ${chalk9.red(`${totals.critical} critical`)} · ${chalk9.red(`${totals.high} high`)} · ${chalk9.yellow(`${totals.medium} medium`)} · ${chalk9.dim(`${totals.low} low`)}`);
59811
+ console.log(` ${chalk10.red(`${totals.critical} critical`)} · ${chalk10.red(`${totals.high} high`)} · ${chalk10.yellow(`${totals.medium} medium`)} · ${chalk10.dim(`${totals.low} low`)}`);
59283
59812
  const top = result.allIssues.slice(0, 5);
59284
59813
  if (top.length > 0) {
59285
59814
  console.log(`
59286
59815
  Top issues:`);
59287
59816
  for (const issue of top) {
59288
- const sevTag = issue.severity === "critical" ? chalk9.red.bold("[critical]") : issue.severity === "high" ? chalk9.red("[high] ") : issue.severity === "medium" ? chalk9.yellow("[medium] ") : chalk9.dim("[low] ");
59817
+ const sevTag = issue.severity === "critical" ? chalk10.red.bold("[critical]") : issue.severity === "high" ? chalk10.red("[high] ") : issue.severity === "medium" ? chalk10.yellow("[medium] ") : chalk10.dim("[low] ");
59289
59818
  console.log(` ${sevTag} ${issue.summary.slice(0, 200)}`);
59290
59819
  }
59291
59820
  }
@@ -59301,7 +59830,7 @@ async function openReport2(path) {
59301
59830
 
59302
59831
  // src/commands/explain.ts
59303
59832
  init_client();
59304
- import chalk10 from "chalk";
59833
+ import chalk11 from "chalk";
59305
59834
 
59306
59835
  // src/llm/system-prompt.ts
59307
59836
  var ISSUE_AGGREGATOR_SYSTEM_PROMPT = `
@@ -59386,17 +59915,17 @@ Cada issue tem:
59386
59915
  // src/commands/explain.ts
59387
59916
  async function explainCommand(runId, issueId, output) {
59388
59917
  if (!isLlmAvailable()) {
59389
- console.error(chalk10.red("Nenhuma API key de LLM encontrada — set ANTHROPIC_API_KEY ou OPENROUTER_API_KEY."));
59918
+ console.error(chalk11.red("Nenhuma API key de LLM encontrada — set ANTHROPIC_API_KEY ou OPENROUTER_API_KEY."));
59390
59919
  return 1;
59391
59920
  }
59392
59921
  const run = loadRun(output, runId);
59393
59922
  const issue = run.issues.find((i) => i.id === issueId) || run.topIssues.find((i) => i.id === issueId);
59394
59923
  if (!issue) {
59395
- console.error(chalk10.red(`Issue não encontrada: ${issueId}`));
59924
+ console.error(chalk11.red(`Issue não encontrada: ${issueId}`));
59396
59925
  return 1;
59397
59926
  }
59398
59927
  const checks = run.checks.filter((c) => c.issues.some((i) => i.id === issueId || i.check === issue.check));
59399
- console.log(chalk10.dim(`Consultando LLM…
59928
+ console.log(chalk11.dim(`Consultando LLM…
59400
59929
  `));
59401
59930
  const text3 = await callMessage({
59402
59931
  feature: "explain",
@@ -59416,13 +59945,13 @@ ${JSON.stringify(checks.map((c) => ({ name: c.name, status: c.status, summary: c
59416
59945
  }
59417
59946
 
59418
59947
  // src/commands/extract.ts
59419
- import { mkdirSync as mkdirSync13 } from "node:fs";
59948
+ import { mkdirSync as mkdirSync14 } from "node:fs";
59420
59949
  import { resolve as resolve4 } from "node:path";
59421
- import chalk12 from "chalk";
59950
+ import chalk13 from "chalk";
59422
59951
 
59423
59952
  // src/llm/section-understanding.ts
59424
59953
  init_client();
59425
- import { readFileSync as readFileSync14 } from "node:fs";
59954
+ import { readFileSync as readFileSync18 } from "node:fs";
59426
59955
  var SUMMARIZE_TOOL = {
59427
59956
  name: "summarize_understanding",
59428
59957
  description: "Return a single paragraph describing what you understood from the section diff signals. NO code — only diagnosis.",
@@ -59460,7 +59989,7 @@ async function invokeUnderstandingSummary(input) {
59460
59989
  return null;
59461
59990
  let markdown;
59462
59991
  try {
59463
- markdown = readFileSync14(input.markdownPath, "utf8");
59992
+ markdown = readFileSync18(input.markdownPath, "utf8");
59464
59993
  } catch (err) {
59465
59994
  console.error(`[section-understanding] failed to read markdown: ${err.message}`);
59466
59995
  return null;
@@ -59470,7 +59999,7 @@ async function invokeUnderstandingSummary(input) {
59470
59999
  if (!p)
59471
60000
  continue;
59472
60001
  try {
59473
- const buf = readFileSync14(p);
60002
+ const buf = readFileSync18(p);
59474
60003
  images.push({ base64: buf.toString("base64"), mediaType: "image/png" });
59475
60004
  } catch (err) {
59476
60005
  console.error(`[section-understanding] skipping image ${p}: ${err.message}`);
@@ -59747,20 +60276,20 @@ function collectCandidatesInPage() {
59747
60276
  }
59748
60277
 
59749
60278
  // src/extract/exporters/json.ts
59750
- import { writeFileSync as writeFileSync14 } from "node:fs";
59751
- import { join as join16 } from "node:path";
60279
+ import { writeFileSync as writeFileSync15 } from "node:fs";
60280
+ import { join as join20 } from "node:path";
59752
60281
  var jsonExporter = {
59753
60282
  name: "json",
59754
60283
  async export(bundle, outDir) {
59755
- const path = join16(outDir, "manifest.json");
59756
- writeFileSync14(path, `${JSON.stringify(bundle, null, 2)}
60284
+ const path = join20(outDir, "manifest.json");
60285
+ writeFileSync15(path, `${JSON.stringify(bundle, null, 2)}
59757
60286
  `, "utf8");
59758
60287
  }
59759
60288
  };
59760
60289
 
59761
60290
  // src/extract/exporters/markdown.ts
59762
- import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync15 } from "node:fs";
59763
- import { join as join17 } from "node:path";
60291
+ import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync16 } from "node:fs";
60292
+ import { join as join21 } from "node:path";
59764
60293
 
59765
60294
  // src/extract/naming.ts
59766
60295
  function componentDirName(role, index2) {
@@ -59774,13 +60303,13 @@ var markdownExporter = {
59774
60303
  async export(bundle, outDir) {
59775
60304
  const dirNames = bundle.components.map((c, i) => componentDirName(c.role, i + 1));
59776
60305
  const indexMd = renderIndex(bundle, dirNames);
59777
- writeFileSync15(join17(outDir, "index.md"), indexMd, "utf8");
60306
+ writeFileSync16(join21(outDir, "index.md"), indexMd, "utf8");
59778
60307
  bundle.components.forEach((component, i) => {
59779
60308
  const dirName = dirNames[i];
59780
- const componentDir = join17(outDir, "components", dirName);
59781
- mkdirSync10(componentDir, { recursive: true });
60309
+ const componentDir = join21(outDir, "components", dirName);
60310
+ mkdirSync11(componentDir, { recursive: true });
59782
60311
  const readme = renderComponentReadme(bundle, component);
59783
- writeFileSync15(join17(componentDir, "README.md"), readme, "utf8");
60312
+ writeFileSync16(join21(componentDir, "README.md"), readme, "utf8");
59784
60313
  });
59785
60314
  }
59786
60315
  };
@@ -59887,7 +60416,7 @@ function truncateHtml(html3, max) {
59887
60416
  }
59888
60417
 
59889
60418
  // src/extract/extract-component.ts
59890
- import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync16 } from "node:fs";
60419
+ import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync17 } from "node:fs";
59891
60420
 
59892
60421
  // src/engine/section-capture.ts
59893
60422
  init_esm10();
@@ -60129,7 +60658,7 @@ async function captureSectionScreenshot(page, selector, outPath, preCapturedFull
60129
60658
  // src/extract/extract-component.ts
60130
60659
  var LINK_CAP = 30;
60131
60660
  async function extractComponent(page, component, opts) {
60132
- mkdirSync11(opts.outDir, { recursive: true });
60661
+ mkdirSync12(opts.outDir, { recursive: true });
60133
60662
  const artifacts = await captureSectionArtifacts(page, {
60134
60663
  selector: component.selector,
60135
60664
  wantHtml: true,
@@ -60150,8 +60679,8 @@ async function extractComponent(page, component, opts) {
60150
60679
  links: capLinks(links, LINK_CAP),
60151
60680
  textContent: textContent2
60152
60681
  };
60153
- writeFileSync16(`${opts.outDir}/component.html`, extracted.html, "utf8");
60154
- writeFileSync16(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60682
+ writeFileSync17(`${opts.outDir}/component.html`, extracted.html, "utf8");
60683
+ writeFileSync17(`${opts.outDir}/styles.json`, `${JSON.stringify(computedStyles ?? {}, null, 2)}
60155
60684
  `, "utf8");
60156
60685
  return extracted;
60157
60686
  }
@@ -60239,19 +60768,19 @@ function capLinks(links, max) {
60239
60768
  }
60240
60769
 
60241
60770
  // src/commands/section.ts
60242
- import { mkdirSync as mkdirSync12 } from "node:fs";
60771
+ import { mkdirSync as mkdirSync13 } from "node:fs";
60243
60772
  import { resolve as resolve3 } from "node:path";
60244
- import chalk11 from "chalk";
60773
+ import chalk12 from "chalk";
60245
60774
  import * as diff from "diff";
60246
60775
  import prettier from "prettier";
60247
60776
 
60248
60777
  // src/diff/heatmap-regions.ts
60249
- import { readFileSync as readFileSync15 } from "node:fs";
60778
+ import { readFileSync as readFileSync19 } from "node:fs";
60250
60779
  import { PNG as PNG4 } from "pngjs";
60251
60780
  var DEFAULT_MAX_HOTSPOTS = 5;
60252
60781
  var DEFAULT_MIN_COMPONENT_PIXELS = 50;
60253
60782
  function analyzeHeatmapRegions(pngPath, opts = {}) {
60254
- const png = PNG4.sync.read(readFileSync15(pngPath));
60783
+ const png = PNG4.sync.read(readFileSync19(pngPath));
60255
60784
  return analyzeHeatmapBuffer(png.data, png.width, png.height, opts);
60256
60785
  }
60257
60786
  function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
@@ -60364,8 +60893,8 @@ function analyzeHeatmapBuffer(data2, width, height, opts = {}) {
60364
60893
  }
60365
60894
 
60366
60895
  // src/diff/section-bundle.ts
60367
- import { writeFileSync as writeFileSync17 } from "node:fs";
60368
- import { basename as basename2, dirname as dirname4, join as join18, relative as relative3 } from "node:path";
60896
+ import { writeFileSync as writeFileSync18 } from "node:fs";
60897
+ import { basename as basename2, dirname as dirname5, join as join22, relative as relative3 } from "node:path";
60369
60898
  function buildStyleDeltas(input) {
60370
60899
  const cs = input.computedStyles;
60371
60900
  if (!cs)
@@ -60409,12 +60938,12 @@ function assembleSectionDiffBundle(input) {
60409
60938
  boundingRects: styleResultsToRects(input.computedStyles),
60410
60939
  styleDeltas
60411
60940
  };
60412
- const jsonPath = join18(input.outDir, `${input.filePrefix}-bundle.json`);
60413
- writeFileSync17(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60941
+ const jsonPath = join22(input.outDir, `${input.filePrefix}-bundle.json`);
60942
+ writeFileSync18(jsonPath, `${JSON.stringify(json, mapReplacer, 2)}
60414
60943
  `, "utf8");
60415
60944
  const markdown = renderMarkdownBundle(input, styleDeltas);
60416
- const markdownPath = join18(input.outDir, `${input.filePrefix}-prompt.md`);
60417
- writeFileSync17(markdownPath, markdown, "utf8");
60945
+ const markdownPath = join22(input.outDir, `${input.filePrefix}-prompt.md`);
60946
+ writeFileSync18(markdownPath, markdown, "utf8");
60418
60947
  const summary = oneLineSummary(input, styleDeltas);
60419
60948
  return { jsonPath, markdownPath, summary };
60420
60949
  }
@@ -60562,7 +61091,7 @@ function renderMarkdownBundle(input, deltas) {
60562
61091
  }
60563
61092
  function relativeOrAbs(outDir, absPath) {
60564
61093
  try {
60565
- if (dirname4(absPath) === outDir)
61094
+ if (dirname5(absPath) === outDir)
60566
61095
  return basename2(absPath);
60567
61096
  return relative3(outDir, absPath);
60568
61097
  } catch {
@@ -60597,20 +61126,20 @@ function capDiff(diff, maxLines) {
60597
61126
  async function sectionCommand(opts) {
60598
61127
  const viewport = parseViewport3(opts.viewport);
60599
61128
  if (!viewport) {
60600
- console.error(chalk11.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
61129
+ console.error(chalk12.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
60601
61130
  return 2;
60602
61131
  }
60603
61132
  const waitMs = Number.parseInt(opts.wait, 10);
60604
61133
  if (!Number.isFinite(waitMs) || waitMs < 0) {
60605
- console.error(chalk11.red(`--wait inválido: ${opts.wait}`));
61134
+ console.error(chalk12.red(`--wait inválido: ${opts.wait}`));
60606
61135
  return 2;
60607
61136
  }
60608
61137
  if (!opts.selector || opts.selector.trim().length === 0) {
60609
- console.error(chalk11.red("--selector é obrigatório"));
61138
+ console.error(chalk12.red("--selector é obrigatório"));
60610
61139
  return 2;
60611
61140
  }
60612
61141
  if (!isValidUrl(opts.prod) || !isValidUrl(opts.cand)) {
60613
- console.error(chalk11.red("--prod ou --cand inválido"));
61142
+ console.error(chalk12.red("--prod ou --cand inválido"));
60614
61143
  return 2;
60615
61144
  }
60616
61145
  const candSelector = opts.candSelector?.trim() || opts.selector;
@@ -60626,7 +61155,7 @@ async function sectionCommand(opts) {
60626
61155
  };
60627
61156
  if (want.heatmap)
60628
61157
  want.screenshot = true;
60629
- mkdirSync12(opts.outDir, { recursive: true });
61158
+ mkdirSync13(opts.outDir, { recursive: true });
60630
61159
  const hash2 = hashSelector(opts.selector);
60631
61160
  const filePrefix = `section-${hash2}-${viewport}`;
60632
61161
  const screenshotPaths = {
@@ -60826,17 +61355,17 @@ function verdict(prod, cand) {
60826
61355
  async function printResults2(args) {
60827
61356
  const { opts, viewport, candSelector, prodSide, candSide, screenshotPaths, want } = args;
60828
61357
  const crossSelector = candSelector !== opts.selector;
60829
- console.log(chalk11.bold(`
61358
+ console.log(chalk12.bold(`
60830
61359
  parity section`));
60831
61360
  if (crossSelector) {
60832
- console.log(chalk11.dim(` selector: ${opts.selector} (prod)`));
60833
- console.log(chalk11.dim(` ${candSelector} (cand)`));
61361
+ console.log(chalk12.dim(` selector: ${opts.selector} (prod)`));
61362
+ console.log(chalk12.dim(` ${candSelector} (cand)`));
60834
61363
  } else {
60835
- console.log(chalk11.dim(` selector: ${opts.selector}`));
61364
+ console.log(chalk12.dim(` selector: ${opts.selector}`));
60836
61365
  }
60837
- console.log(chalk11.dim(` viewport: ${viewport}`));
60838
- console.log(chalk11.dim(` prod: ${opts.prod}`));
60839
- console.log(chalk11.dim(` cand: ${opts.cand}`));
61366
+ console.log(chalk12.dim(` viewport: ${viewport}`));
61367
+ console.log(chalk12.dim(` prod: ${opts.prod}`));
61368
+ console.log(chalk12.dim(` cand: ${opts.cand}`));
60840
61369
  console.log("");
60841
61370
  if (want.html) {
60842
61371
  await printHtmlDiff(prodSide, candSide, crossSelector ? `${opts.selector} → ${candSelector}` : opts.selector);
@@ -60847,22 +61376,22 @@ async function printResults2(args) {
60847
61376
  printScreenshotPaths(prodSide, candSide, screenshotPaths);
60848
61377
  }
60849
61378
  async function printHtmlDiff(prod, cand, selector) {
60850
- console.log(chalk11.bold(" HTML diff"));
61379
+ console.log(chalk12.bold(" HTML diff"));
60851
61380
  if (prod.htmlError) {
60852
- console.log(chalk11.red(` prod: ${prod.htmlError}`));
61381
+ console.log(chalk12.red(` prod: ${prod.htmlError}`));
60853
61382
  return;
60854
61383
  }
60855
61384
  if (cand.htmlError) {
60856
- console.log(chalk11.red(` cand: ${cand.htmlError}`));
61385
+ console.log(chalk12.red(` cand: ${cand.htmlError}`));
60857
61386
  return;
60858
61387
  }
60859
61388
  if (!prod.html || !cand.html) {
60860
- console.log(chalk11.dim(" (nenhum lado tem HTML disponível)"));
61389
+ console.log(chalk12.dim(" (nenhum lado tem HTML disponível)"));
60861
61390
  return;
60862
61391
  }
60863
61392
  const [prodFmt, candFmt] = await Promise.all([formatHtml(prod.html), formatHtml(cand.html)]);
60864
61393
  if (prodFmt === candFmt) {
60865
- console.log(chalk11.green(" ✓ idêntico após pretty-print"));
61394
+ console.log(chalk12.green(" ✓ idêntico após pretty-print"));
60866
61395
  console.log("");
60867
61396
  return;
60868
61397
  }
@@ -60871,17 +61400,17 @@ async function printHtmlDiff(prod, cand, selector) {
60871
61400
  console.log("");
60872
61401
  }
60873
61402
  function printStylesDiff(prod, cand) {
60874
- console.log(chalk11.bold(" Computed styles diff"));
61403
+ console.log(chalk12.bold(" Computed styles diff"));
60875
61404
  if (!prod.styles || !cand.styles) {
60876
- console.log(chalk11.dim(" (styles não foram coletados)"));
61405
+ console.log(chalk12.dim(" (styles não foram coletados)"));
60877
61406
  return;
60878
61407
  }
60879
61408
  if (!prod.styles.found) {
60880
- console.log(chalk11.red(` prod: ${prod.styles.error}`));
61409
+ console.log(chalk12.red(` prod: ${prod.styles.error}`));
60881
61410
  return;
60882
61411
  }
60883
61412
  if (!cand.styles.found) {
60884
- console.log(chalk11.red(` cand: ${cand.styles.error}`));
61413
+ console.log(chalk12.red(` cand: ${cand.styles.error}`));
60885
61414
  return;
60886
61415
  }
60887
61416
  const rows = [];
@@ -60908,27 +61437,27 @@ function printStylesDiff(prod, cand) {
60908
61437
  });
60909
61438
  }
60910
61439
  if (rows.length === 0) {
60911
- console.log(chalk11.green(" ✓ todos os SECTION_STYLE_KEYS são iguais"));
61440
+ console.log(chalk12.green(" ✓ todos os SECTION_STYLE_KEYS são iguais"));
60912
61441
  console.log("");
60913
61442
  return;
60914
61443
  }
60915
61444
  const keyWidth = Math.max(...rows.map((r) => r.key.length));
60916
61445
  for (const r of rows) {
60917
- console.log(` ${chalk11.cyan(r.key.padEnd(keyWidth))} ${chalk11.red(`prod=${r.prod || "(vazio)"}`)} ${chalk11.green(`cand=${r.cand || "(vazio)"}`)}`);
61446
+ console.log(` ${chalk12.cyan(r.key.padEnd(keyWidth))} ${chalk12.red(`prod=${r.prod || "(vazio)"}`)} ${chalk12.green(`cand=${r.cand || "(vazio)"}`)}`);
60918
61447
  }
60919
61448
  console.log("");
60920
61449
  }
60921
61450
  function printScreenshotPaths(prod, cand, paths) {
60922
- console.log(chalk11.bold(" Screenshots"));
61451
+ console.log(chalk12.bold(" Screenshots"));
60923
61452
  if (prod.screenshotError) {
60924
- console.log(chalk11.red(` prod: ${prod.screenshotError}`));
61453
+ console.log(chalk12.red(` prod: ${prod.screenshotError}`));
60925
61454
  } else if (prod.screenshotTaken) {
60926
- console.log(` prod: ${chalk11.dim(paths.prod)}`);
61455
+ console.log(` prod: ${chalk12.dim(paths.prod)}`);
60927
61456
  }
60928
61457
  if (cand.screenshotError) {
60929
- console.log(chalk11.red(` cand: ${cand.screenshotError}`));
61458
+ console.log(chalk12.red(` cand: ${cand.screenshotError}`));
60930
61459
  } else if (cand.screenshotTaken) {
60931
- console.log(` cand: ${chalk11.dim(paths.cand)}`);
61460
+ console.log(` cand: ${chalk12.dim(paths.cand)}`);
60932
61461
  }
60933
61462
  console.log("");
60934
61463
  }
@@ -60951,13 +61480,13 @@ function colorPatch(patch) {
60951
61480
  if (line.startsWith("Index:") || line.startsWith("==="))
60952
61481
  continue;
60953
61482
  if (line.startsWith("---") || line.startsWith("+++"))
60954
- out.push(chalk11.dim(line));
61483
+ out.push(chalk12.dim(line));
60955
61484
  else if (line.startsWith("@@"))
60956
- out.push(chalk11.cyan(line));
61485
+ out.push(chalk12.cyan(line));
60957
61486
  else if (line.startsWith("+"))
60958
- out.push(chalk11.green(line));
61487
+ out.push(chalk12.green(line));
60959
61488
  else if (line.startsWith("-"))
60960
- out.push(chalk11.red(line));
61489
+ out.push(chalk12.red(line));
60961
61490
  else
60962
61491
  out.push(line);
60963
61492
  }
@@ -61026,7 +61555,7 @@ async function buildPromptBundle(args) {
61026
61555
  }
61027
61556
  async function maybeRunLlmSummary(args) {
61028
61557
  if (!isUnderstandingAvailable()) {
61029
- console.warn(chalk11.yellow(" --llm-summary pulado: nenhum ANTHROPIC_API_KEY ou OPENROUTER_API_KEY configurado."));
61558
+ console.warn(chalk12.yellow(" --llm-summary pulado: nenhum ANTHROPIC_API_KEY ou OPENROUTER_API_KEY configurado."));
61030
61559
  return null;
61031
61560
  }
61032
61561
  const result = await invokeUnderstandingSummary({
@@ -61038,42 +61567,42 @@ async function maybeRunLlmSummary(args) {
61038
61567
  return result?.summary ?? null;
61039
61568
  }
61040
61569
  function printHeatmap(state, heatmapPath) {
61041
- console.log(chalk11.bold(" Heatmap"));
61570
+ console.log(chalk12.bold(" Heatmap"));
61042
61571
  if (state.error) {
61043
- console.log(chalk11.yellow(` ${state.error}`));
61572
+ console.log(chalk12.yellow(` ${state.error}`));
61044
61573
  console.log("");
61045
61574
  return;
61046
61575
  }
61047
61576
  if (!state.analysis) {
61048
- console.log(chalk11.dim(" (sem dados de heatmap)"));
61577
+ console.log(chalk12.dim(" (sem dados de heatmap)"));
61049
61578
  console.log("");
61050
61579
  return;
61051
61580
  }
61052
61581
  const a = state.analysis;
61053
61582
  const pct = (a.pctDiff * 100).toFixed(2);
61054
- console.log(` ${chalk11.cyan("diffPixels")}: ${a.diffPixels} (${pct}%)`);
61583
+ console.log(` ${chalk12.cyan("diffPixels")}: ${a.diffPixels} (${pct}%)`);
61055
61584
  if (a.boundingBox) {
61056
61585
  const bb = a.boundingBox;
61057
- console.log(` ${chalk11.cyan("boundingBox")}: x=${bb.x} y=${bb.y} w=${bb.width} h=${bb.height}`);
61586
+ console.log(` ${chalk12.cyan("boundingBox")}: x=${bb.x} y=${bb.y} w=${bb.width} h=${bb.height}`);
61058
61587
  }
61059
61588
  if (a.hotspots.length > 0) {
61060
- console.log(` ${chalk11.cyan("hotspots")}:`);
61589
+ console.log(` ${chalk12.cyan("hotspots")}:`);
61061
61590
  for (const h of a.hotspots.slice(0, 5)) {
61062
61591
  console.log(` (${h.x}, ${h.y}) ${h.width}×${h.height} — ${h.pixelCount} px`);
61063
61592
  }
61064
61593
  }
61065
- console.log(` ${chalk11.dim(`heatmap: ${heatmapPath}`)}`);
61594
+ console.log(` ${chalk12.dim(`heatmap: ${heatmapPath}`)}`);
61066
61595
  console.log("");
61067
61596
  }
61068
61597
  function printBundlePaths(b) {
61069
- console.log(chalk11.bold(" Bundle"));
61070
- console.log(` ${chalk11.cyan("summary")}: ${b.summary}`);
61071
- console.log(` ${chalk11.cyan("json")}: ${chalk11.dim(b.jsonPath)}`);
61072
- console.log(` ${chalk11.cyan("prompt")}: ${chalk11.dim(b.markdownPath)}`);
61598
+ console.log(chalk12.bold(" Bundle"));
61599
+ console.log(` ${chalk12.cyan("summary")}: ${b.summary}`);
61600
+ console.log(` ${chalk12.cyan("json")}: ${chalk12.dim(b.jsonPath)}`);
61601
+ console.log(` ${chalk12.cyan("prompt")}: ${chalk12.dim(b.markdownPath)}`);
61073
61602
  console.log("");
61074
61603
  }
61075
61604
  function printLlmSummary(summary) {
61076
- console.log(chalk11.bold(" What the LLM understood"));
61605
+ console.log(chalk12.bold(" What the LLM understood"));
61077
61606
  console.log(` ${summary.split(`
61078
61607
  `).join(`
61079
61608
  `)}`);
@@ -61084,16 +61613,16 @@ function printLlmSummary(summary) {
61084
61613
  async function extractCommand(opts) {
61085
61614
  const viewport = parseViewport3(opts.viewport);
61086
61615
  if (!viewport) {
61087
- console.error(chalk12.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
61616
+ console.error(chalk13.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
61088
61617
  return 2;
61089
61618
  }
61090
61619
  if (!isValidUrl2(opts.url)) {
61091
- console.error(chalk12.red(`--url inválido: ${opts.url}`));
61620
+ console.error(chalk13.red(`--url inválido: ${opts.url}`));
61092
61621
  return 2;
61093
61622
  }
61094
61623
  const format = normalizeFormat(opts.format);
61095
61624
  if (!format) {
61096
- console.error(chalk12.red(`--format inválido: ${opts.format} (use md|json|both)`));
61625
+ console.error(chalk13.red(`--format inválido: ${opts.format} (use md|json|both)`));
61097
61626
  return 2;
61098
61627
  }
61099
61628
  const allowlist = parseAllowlist(opts.components);
@@ -61101,12 +61630,12 @@ async function extractCommand(opts) {
61101
61630
  const timestamp = new Date().toISOString();
61102
61631
  const runDirTimestamp = timestamp.replace(/[:.]/g, "-");
61103
61632
  const runDir = resolve4(opts.outDir, host, runDirTimestamp);
61104
- mkdirSync13(runDir, { recursive: true });
61633
+ mkdirSync14(runDir, { recursive: true });
61105
61634
  const browser = await launchBrowser({ headless: true });
61106
61635
  try {
61107
61636
  const resolvedPages = await resolvePages(opts.url, opts.pages);
61108
61637
  if (resolvedPages.length === 0) {
61109
- console.error(chalk12.red("nenhuma página resolvida a partir de --pages"));
61638
+ console.error(chalk13.red("nenhuma página resolvida a partir de --pages"));
61110
61639
  return 1;
61111
61640
  }
61112
61641
  let globalIndex = 0;
@@ -61190,27 +61719,27 @@ async function extractCommand(opts) {
61190
61719
  }
61191
61720
  }
61192
61721
  function printResults3(runDir, bundle) {
61193
- console.log(chalk12.bold(`
61722
+ console.log(chalk13.bold(`
61194
61723
  parity extract`));
61195
- console.log(chalk12.dim(` url: ${bundle.url}`));
61196
- console.log(chalk12.dim(` viewport: ${bundle.viewport}`));
61197
- console.log(chalk12.dim(` pages: ${bundle.pages?.length ?? 0}`));
61198
- console.log(chalk12.dim(` out: ${runDir}`));
61724
+ console.log(chalk13.dim(` url: ${bundle.url}`));
61725
+ console.log(chalk13.dim(` viewport: ${bundle.viewport}`));
61726
+ console.log(chalk13.dim(` pages: ${bundle.pages?.length ?? 0}`));
61727
+ console.log(chalk13.dim(` out: ${runDir}`));
61199
61728
  console.log("");
61200
- console.log(chalk12.bold(` ${bundle.components.length} component(s) detected:`));
61729
+ console.log(chalk13.bold(` ${bundle.components.length} component(s) detected:`));
61201
61730
  for (const c of bundle.components) {
61202
- console.log(` ${chalk12.cyan(c.role.padEnd(24))} ${chalk12.dim(c.selector)}`);
61731
+ console.log(` ${chalk13.cyan(c.role.padEnd(24))} ${chalk13.dim(c.selector)}`);
61203
61732
  }
61204
61733
  console.log("");
61205
61734
  }
61206
- async function resolvePages(baseUrl, pagesSpec) {
61735
+ async function resolvePages(baseUrl2, pagesSpec) {
61207
61736
  const tokens = (pagesSpec ?? "/").split(",").map((s) => s.trim()).filter(Boolean);
61208
61737
  const specs = tokens.length > 0 ? tokens : ["/"];
61209
61738
  const out = [];
61210
61739
  let cachedPlp;
61211
61740
  const resolvePlp = async () => {
61212
61741
  if (cachedPlp === undefined)
61213
- cachedPlp = await discoverPlpFromHome(baseUrl);
61742
+ cachedPlp = await discoverPlpFromHome(baseUrl2);
61214
61743
  return cachedPlp;
61215
61744
  };
61216
61745
  for (const token of specs) {
@@ -61233,7 +61762,7 @@ async function resolvePages(baseUrl, pagesSpec) {
61233
61762
  continue;
61234
61763
  }
61235
61764
  try {
61236
- out.push({ token, url: new URL(token, baseUrl).toString() });
61765
+ out.push({ token, url: new URL(token, baseUrl2).toString() });
61237
61766
  } catch {}
61238
61767
  }
61239
61768
  return out;
@@ -61312,23 +61841,23 @@ async function fixCommand(opts) {
61312
61841
 
61313
61842
  // src/commands/html.ts
61314
61843
  init_esm10();
61315
- import chalk13 from "chalk";
61844
+ import chalk14 from "chalk";
61316
61845
  import * as diff2 from "diff";
61317
61846
  import prettier2 from "prettier";
61318
61847
  async function htmlCommand(opts) {
61319
61848
  const viewport = parseViewport4(opts.viewport);
61320
61849
  if (!viewport) {
61321
- console.error(chalk13.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
61850
+ console.error(chalk14.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
61322
61851
  return 2;
61323
61852
  }
61324
61853
  const waitMs = parseWaitMs(opts.wait);
61325
61854
  if (waitMs === null) {
61326
- console.error(chalk13.red(`--wait inválido: ${opts.wait} (precisa ser inteiro >= 0)`));
61855
+ console.error(chalk14.red(`--wait inválido: ${opts.wait} (precisa ser inteiro >= 0)`));
61327
61856
  return 2;
61328
61857
  }
61329
61858
  const mode = resolveMode(opts);
61330
61859
  if (mode.kind === "error") {
61331
- console.error(chalk13.red(mode.message));
61860
+ console.error(chalk14.red(mode.message));
61332
61861
  return 2;
61333
61862
  }
61334
61863
  const browser = await launchBrowser({ headless: true });
@@ -61337,11 +61866,11 @@ async function htmlCommand(opts) {
61337
61866
  const html3 = await fetchSnapshot(browser, mode.url, viewport, waitMs);
61338
61867
  const piece = extractSelector(html3, opts.selector);
61339
61868
  if (piece.error) {
61340
- console.error(chalk13.red(piece.error));
61869
+ console.error(chalk14.red(piece.error));
61341
61870
  return 2;
61342
61871
  }
61343
61872
  if (piece.warning)
61344
- console.error(chalk13.yellow(` ⚠ ${piece.warning}`));
61873
+ console.error(chalk14.yellow(` ⚠ ${piece.warning}`));
61345
61874
  const finalText = await maybePretty(piece.html, opts.pretty === true);
61346
61875
  if (opts.json) {
61347
61876
  console.log(JSON.stringify({
@@ -61362,17 +61891,17 @@ async function htmlCommand(opts) {
61362
61891
  const prodPiece = extractSelector(prodHtml, opts.selector);
61363
61892
  const candPiece = extractSelector(candHtml, opts.selector);
61364
61893
  if (prodPiece.error) {
61365
- console.error(chalk13.red(`prod: ${prodPiece.error}`));
61894
+ console.error(chalk14.red(`prod: ${prodPiece.error}`));
61366
61895
  return 2;
61367
61896
  }
61368
61897
  if (candPiece.error) {
61369
- console.error(chalk13.red(`cand: ${candPiece.error}`));
61898
+ console.error(chalk14.red(`cand: ${candPiece.error}`));
61370
61899
  return 2;
61371
61900
  }
61372
61901
  if (prodPiece.warning)
61373
- console.error(chalk13.yellow(` ⚠ prod: ${prodPiece.warning}`));
61902
+ console.error(chalk14.yellow(` ⚠ prod: ${prodPiece.warning}`));
61374
61903
  if (candPiece.warning)
61375
- console.error(chalk13.yellow(` ⚠ cand: ${candPiece.warning}`));
61904
+ console.error(chalk14.yellow(` ⚠ cand: ${candPiece.warning}`));
61376
61905
  const [prodFmt, candFmt] = await Promise.all([
61377
61906
  maybePretty(prodPiece.html, opts.pretty !== false),
61378
61907
  maybePretty(candPiece.html, opts.pretty !== false)
@@ -61520,19 +62049,19 @@ function formatPatch(patch) {
61520
62049
  if (line.startsWith("Index:") || line.startsWith("==="))
61521
62050
  continue;
61522
62051
  if (line.startsWith("---") || line.startsWith("+++")) {
61523
- out.push(chalk13.dim(line));
62052
+ out.push(chalk14.dim(line));
61524
62053
  continue;
61525
62054
  }
61526
62055
  if (line.startsWith("@@")) {
61527
- out.push(chalk13.cyan(line));
62056
+ out.push(chalk14.cyan(line));
61528
62057
  continue;
61529
62058
  }
61530
62059
  if (line.startsWith("+")) {
61531
- out.push(chalk13.green(line));
62060
+ out.push(chalk14.green(line));
61532
62061
  continue;
61533
62062
  }
61534
62063
  if (line.startsWith("-")) {
61535
- out.push(chalk13.red(line));
62064
+ out.push(chalk14.red(line));
61536
62065
  continue;
61537
62066
  }
61538
62067
  out.push(line);
@@ -61542,15 +62071,15 @@ function formatPatch(patch) {
61542
62071
  }
61543
62072
 
61544
62073
  // src/commands/journey.ts
61545
- import { writeFileSync as writeFileSync18 } from "node:fs";
61546
- import { join as join19 } from "node:path";
61547
- import chalk14 from "chalk";
62074
+ import { writeFileSync as writeFileSync19 } from "node:fs";
62075
+ import { join as join23 } from "node:path";
62076
+ import chalk15 from "chalk";
61548
62077
  import ora6 from "ora";
61549
62078
  init_client();
61550
62079
  async function journeyCommand(opts) {
61551
62080
  const viewports = opts.viewports.split(",").map((s) => s.trim()).filter((s) => s === "mobile" || s === "desktop");
61552
62081
  if (viewports.length === 0) {
61553
- console.error(chalk14.red("Nenhum viewport válido (use mobile,desktop)"));
62082
+ console.error(chalk15.red("Nenhum viewport válido (use mobile,desktop)"));
61554
62083
  return 2;
61555
62084
  }
61556
62085
  const rc = loadParityRc();
@@ -61560,13 +62089,13 @@ async function journeyCommand(opts) {
61560
62089
  const runId = newRunId();
61561
62090
  const paths = createRunDir(opts.output, runId);
61562
62091
  if (!opts.json) {
61563
- console.log(chalk14.bold(`
62092
+ console.log(chalk15.bold(`
61564
62093
  parity journey ${runId}`));
61565
- console.log(chalk14.dim(` prod: ${opts.prod}`));
61566
- console.log(chalk14.dim(` cand: ${opts.cand}`));
61567
- console.log(chalk14.dim(` viewports: ${viewports.join(", ")} · CEP: ${rc.cep}`));
62094
+ console.log(chalk15.dim(` prod: ${opts.prod}`));
62095
+ console.log(chalk15.dim(` cand: ${opts.cand}`));
62096
+ console.log(chalk15.dim(` viewports: ${viewports.join(", ")} · CEP: ${rc.cep}`));
61568
62097
  if (isLlmAvailable())
61569
- console.log(chalk14.dim(` llm: ${providerLabel()}`));
62098
+ console.log(chalk15.dim(` llm: ${providerLabel()}`));
61570
62099
  console.log("");
61571
62100
  }
61572
62101
  let platform = "custom";
@@ -61600,20 +62129,20 @@ async function journeyCommand(opts) {
61600
62129
  const onStepFor = (viewport, side) => (event) => {
61601
62130
  if (opts.json)
61602
62131
  return;
61603
- const sideTag = side === "prod" ? chalk14.cyan("prod") : chalk14.magenta("cand");
61604
- const prefix = ` ${chalk14.dim(`[${viewport}/`)}${sideTag}${chalk14.dim("]")}`;
62132
+ const sideTag = side === "prod" ? chalk15.cyan("prod") : chalk15.magenta("cand");
62133
+ const prefix = ` ${chalk15.dim(`[${viewport}/`)}${sideTag}${chalk15.dim("]")}`;
61605
62134
  if (event.phase === "start") {
61606
- console.log(`${prefix} ${chalk14.dim(`${event.index}/${event.total}`)} ▶ ${chalk14.bold(stepLabel(event.name))}`);
62135
+ console.log(`${prefix} ${chalk15.dim(`${event.index}/${event.total}`)} ▶ ${chalk15.bold(stepLabel(event.name))}`);
61607
62136
  } else {
61608
- const glyph = event.status === "ok" ? chalk14.green("✓") : event.status === "skipped" ? chalk14.yellow("○") : chalk14.red("✗");
61609
- const noteText = event.note ? chalk14.dim(` (${event.note})`) : "";
61610
- const time = chalk14.dim(`${(event.durationMs / 1000).toFixed(1)}s`);
61611
- console.log(`${prefix} ${chalk14.dim(`${event.index}/${event.total}`)} ${glyph} ${stepLabel(event.name)} ${time}${noteText}`);
62137
+ const glyph = event.status === "ok" ? chalk15.green("✓") : event.status === "skipped" ? chalk15.yellow("○") : chalk15.red("✗");
62138
+ const noteText = event.note ? chalk15.dim(` (${event.note})`) : "";
62139
+ const time = chalk15.dim(`${(event.durationMs / 1000).toFixed(1)}s`);
62140
+ console.log(`${prefix} ${chalk15.dim(`${event.index}/${event.total}`)} ${glyph} ${stepLabel(event.name)} ${time}${noteText}`);
61612
62141
  }
61613
62142
  };
61614
62143
  async function runOneSide(browserInstance, viewport, side) {
61615
- const baseUrl = side === "prod" ? opts.prod : opts.cand;
61616
- const tracePath = join19(paths.tracesDir, `${viewport}-${side}.zip`);
62144
+ const baseUrl2 = side === "prod" ? opts.prod : opts.cand;
62145
+ const tracePath = join23(paths.tracesDir, `${viewport}-${side}.zip`);
61617
62146
  const ctx = await newContext(browserInstance, {
61618
62147
  viewport,
61619
62148
  tracesDir: paths.tracesDir,
@@ -61622,7 +62151,7 @@ async function journeyCommand(opts) {
61622
62151
  await installVitalsCollector(ctx);
61623
62152
  try {
61624
62153
  const cap = await runFlow("purchase-journey", {
61625
- baseUrl,
62154
+ baseUrl: baseUrl2,
61626
62155
  side,
61627
62156
  viewport,
61628
62157
  rc,
@@ -61647,7 +62176,7 @@ async function journeyCommand(opts) {
61647
62176
  spinner?.succeed("Browser pronto");
61648
62177
  for (const viewport of viewports) {
61649
62178
  if (!opts.json)
61650
- console.log(chalk14.bold(`
62179
+ console.log(chalk15.bold(`
61651
62180
  ── ${viewport} ─────────────────────────────────────────────`));
61652
62181
  const [prodCap, candCap] = await Promise.all([
61653
62182
  runOneSide(browser, viewport, "prod"),
@@ -61682,11 +62211,11 @@ async function journeyCommand(opts) {
61682
62211
  if (totalDeprecated > 0)
61683
62212
  bits.push(`${totalDeprecated} depreciado(s)`);
61684
62213
  if (bits.length > 0)
61685
- console.log(chalk14.dim(` learned-selectors atualizado: ${bits.join(", ")}`));
62214
+ console.log(chalk15.dim(` learned-selectors atualizado: ${bits.join(", ")}`));
61686
62215
  }
61687
62216
  } catch (err) {
61688
62217
  if (!opts.json) {
61689
- console.warn(chalk14.yellow(` warn: failed to persist learned-selectors: ${err.message}`));
62218
+ console.warn(chalk15.yellow(` warn: failed to persist learned-selectors: ${err.message}`));
61690
62219
  }
61691
62220
  }
61692
62221
  }
@@ -61705,9 +62234,9 @@ async function journeyCommand(opts) {
61705
62234
  if (opts.github)
61706
62235
  emitGithubAnnotations(failures);
61707
62236
  if (opts.junit) {
61708
- writeFileSync18(opts.junit, buildJUnit(rows, failures), "utf8");
62237
+ writeFileSync19(opts.junit, buildJUnit(rows, failures), "utf8");
61709
62238
  if (!opts.json)
61710
- console.log(chalk14.dim(` → JUnit XML: ${opts.junit}`));
62239
+ console.log(chalk15.dim(` → JUnit XML: ${opts.junit}`));
61711
62240
  }
61712
62241
  return failures.some((f) => f.critical) ? 1 : 0;
61713
62242
  } catch (err) {
@@ -61772,14 +62301,14 @@ function collectFailures(rows) {
61772
62301
  function printTable(viewports, rows) {
61773
62302
  console.log("");
61774
62303
  for (const viewport of viewports) {
61775
- console.log(chalk14.bold(` [${viewport}]`));
62304
+ console.log(chalk15.bold(` [${viewport}]`));
61776
62305
  const vrows = rows.filter((r) => r.viewport === viewport);
61777
62306
  for (const r of vrows) {
61778
62307
  const label = PJ_STEP_LABELS_NUMBERED[r.name] ?? r.name;
61779
62308
  const p = statusGlyph(r.prod?.status);
61780
62309
  const c = statusGlyph(r.cand?.status);
61781
- const status = r.prod?.status === "ok" && r.cand?.status !== "ok" ? chalk14.red("FAILED") : "";
61782
- const note = r.cand?.status === "failed" || r.cand?.status === "skipped" ? chalk14.dim(`(${r.cand?.note ?? r.cand?.status})`) : "";
62310
+ const status = r.prod?.status === "ok" && r.cand?.status !== "ok" ? chalk15.red("FAILED") : "";
62311
+ const note = r.cand?.status === "failed" || r.cand?.status === "skipped" ? chalk15.dim(`(${r.cand?.note ?? r.cand?.status})`) : "";
61783
62312
  console.log(` ${label.padEnd(24)} prod ${p} cand ${c} ${status} ${note}`);
61784
62313
  }
61785
62314
  console.log("");
@@ -61787,12 +62316,12 @@ function printTable(viewports, rows) {
61787
62316
  }
61788
62317
  function statusGlyph(status) {
61789
62318
  if (!status)
61790
- return chalk14.dim("—");
62319
+ return chalk15.dim("—");
61791
62320
  if (status === "ok")
61792
- return chalk14.green("✓");
62321
+ return chalk15.green("✓");
61793
62322
  if (status === "skipped")
61794
- return chalk14.yellow("○");
61795
- return chalk14.red("✗");
62323
+ return chalk15.yellow("○");
62324
+ return chalk15.red("✗");
61796
62325
  }
61797
62326
  function printSummary5(rows, failures, htmlPath) {
61798
62327
  const byViewport = new Map;
@@ -61803,25 +62332,25 @@ function printSummary5(rows, failures, htmlPath) {
61803
62332
  v.passed++;
61804
62333
  byViewport.set(r.viewport, v);
61805
62334
  }
61806
- console.log(chalk14.bold(" Summary:"));
62335
+ console.log(chalk15.bold(" Summary:"));
61807
62336
  for (const [vp, { passed, total }] of byViewport) {
61808
- const stat = passed === total ? chalk14.green("✓") : chalk14.yellow(`${passed}/${total}`);
62337
+ const stat = passed === total ? chalk15.green("✓") : chalk15.yellow(`${passed}/${total}`);
61809
62338
  console.log(` ${vp.padEnd(8)} ${stat} steps em cand`);
61810
62339
  }
61811
62340
  if (failures.length > 0) {
61812
62341
  const crit = failures.filter((f) => f.critical).length;
61813
62342
  console.log("");
61814
- console.log(chalk14.red(` ✗ ${failures.length} step(s) divergent(es) (${crit} crítico)`));
62343
+ console.log(chalk15.red(` ✗ ${failures.length} step(s) divergent(es) (${crit} crítico)`));
61815
62344
  for (const f of failures) {
61816
- const tag = f.critical ? chalk14.red("[critical]") : chalk14.yellow("[warn]");
62345
+ const tag = f.critical ? chalk15.red("[critical]") : chalk15.yellow("[warn]");
61817
62346
  console.log(` ${tag} [${f.viewport}] ${f.step}: ${f.reason}`);
61818
62347
  }
61819
62348
  } else {
61820
62349
  console.log("");
61821
- console.log(chalk14.green(" ✓ jornada completa em cand"));
62350
+ console.log(chalk15.green(" ✓ jornada completa em cand"));
61822
62351
  }
61823
62352
  console.log("");
61824
- console.log(chalk14.dim(` → ${htmlPath}`));
62353
+ console.log(chalk15.dim(` → ${htmlPath}`));
61825
62354
  console.log("");
61826
62355
  }
61827
62356
  function emitGithubAnnotations(failures) {
@@ -62056,26 +62585,26 @@ function safeHost5(url) {
62056
62585
  }
62057
62586
 
62058
62587
  // src/commands/learned.ts
62059
- import chalk15 from "chalk";
62588
+ import chalk16 from "chalk";
62060
62589
  init_client();
62061
62590
  function learnedStats() {
62062
62591
  const lib = loadLearned();
62063
62592
  const stats = statsFromLib(lib);
62064
62593
  if (stats.platforms.length === 0) {
62065
- console.log(chalk15.dim(`Biblioteca vazia: ${LEARNED_PATH}`));
62066
- console.log(chalk15.dim("Rode `parity run ...` em algum site para começar a popular."));
62594
+ console.log(chalk16.dim(`Biblioteca vazia: ${LEARNED_PATH}`));
62595
+ console.log(chalk16.dim("Rode `parity run ...` em algum site para começar a popular."));
62067
62596
  return 0;
62068
62597
  }
62069
- console.log(chalk15.bold(`
62598
+ console.log(chalk16.bold(`
62070
62599
  learned-selectors stats (${LEARNED_PATH})
62071
62600
  `));
62072
62601
  for (const p of stats.platforms) {
62073
- const staleNote = p.staleSelectors > 0 ? ` · ${chalk15.yellow(`${p.staleSelectors} stale`)}` : "";
62074
- console.log(`${chalk15.cyan(p.platform)}: ${p.activeSelectors} active (${p.verifiedSelectors} verified, ${p.llmGuessSelectors} llm-guess) · ${chalk15.dim(`${p.deprecatedSelectors} deprecated`)}${staleNote}`);
62602
+ const staleNote = p.staleSelectors > 0 ? ` · ${chalk16.yellow(`${p.staleSelectors} stale`)}` : "";
62603
+ console.log(`${chalk16.cyan(p.platform)}: ${p.activeSelectors} active (${p.verifiedSelectors} verified, ${p.llmGuessSelectors} llm-guess) · ${chalk16.dim(`${p.deprecatedSelectors} deprecated`)}${staleNote}`);
62075
62604
  for (const top of p.topByKey) {
62076
62605
  const sr = `${(top.successRate * 100).toFixed(0)}%`;
62077
- const originTag = top.origin === "llm-guess" ? chalk15.yellow(" [guess]") : "";
62078
- console.log(` ${chalk15.dim(top.key.padEnd(18))} ${chalk15.green(sr.padStart(4))} ${chalk15.dim(`(${top.hosts} hosts)`)} ${top.selector}${originTag}`);
62606
+ const originTag = top.origin === "llm-guess" ? chalk16.yellow(" [guess]") : "";
62607
+ console.log(` ${chalk16.dim(top.key.padEnd(18))} ${chalk16.green(sr.padStart(4))} ${chalk16.dim(`(${top.hosts} hosts)`)} ${top.selector}${originTag}`);
62079
62608
  }
62080
62609
  console.log("");
62081
62610
  }
@@ -62083,10 +62612,10 @@ learned-selectors stats (${LEARNED_PATH})
62083
62612
  }
62084
62613
  async function learnedValidate(url) {
62085
62614
  if (!isLlmAvailable()) {
62086
- console.error(chalk15.red(" ✖ nenhuma chave de LLM configurada (ANTHROPIC_API_KEY / OPENROUTER_API_KEY) — discovery precisa do LLM"));
62615
+ console.error(chalk16.red(" ✖ nenhuma chave de LLM configurada (ANTHROPIC_API_KEY / OPENROUTER_API_KEY) — discovery precisa do LLM"));
62087
62616
  return 2;
62088
62617
  }
62089
- console.log(chalk15.dim(` Baixando home de ${url}…`));
62618
+ console.log(chalk16.dim(` Baixando home de ${url}…`));
62090
62619
  let html3;
62091
62620
  try {
62092
62621
  const res = await fetch(url, {
@@ -62095,20 +62624,20 @@ async function learnedValidate(url) {
62095
62624
  });
62096
62625
  html3 = res.ok ? await res.text() : null;
62097
62626
  } catch (err) {
62098
- console.error(chalk15.red(` ✖ falha ao baixar ${url}: ${err.message}`));
62627
+ console.error(chalk16.red(` ✖ falha ao baixar ${url}: ${err.message}`));
62099
62628
  return 2;
62100
62629
  }
62101
62630
  if (!html3) {
62102
- console.error(chalk15.red(` ✖ falha ao baixar ${url} (HTTP não-2xx ou erro de rede)`));
62631
+ console.error(chalk16.red(` ✖ falha ao baixar ${url} (HTTP não-2xx ou erro de rede)`));
62103
62632
  return 2;
62104
62633
  }
62105
- console.log(chalk15.dim(" Descobrindo seletores via LLM…"));
62634
+ console.log(chalk16.dim(" Descobrindo seletores via LLM…"));
62106
62635
  const discovered = await discoverSelectorsFromUrl(url, html3, { noCache: true });
62107
62636
  if (!discovered) {
62108
- console.error(chalk15.red(" ✖ LLM não retornou seletores"));
62637
+ console.error(chalk16.red(" ✖ LLM não retornou seletores"));
62109
62638
  return 2;
62110
62639
  }
62111
- console.log(chalk15.dim(" Validando ao vivo (browser headless)…"));
62640
+ console.log(chalk16.dim(" Validando ao vivo (browser headless)…"));
62112
62641
  let browser = null;
62113
62642
  try {
62114
62643
  browser = await launchBrowser({ headless: true });
@@ -62118,7 +62647,7 @@ async function learnedValidate(url) {
62118
62647
  const { validated } = await validateSelectors(page, discovered);
62119
62648
  await ctx.close();
62120
62649
  const lowConfidence = new Set(discovered.lowConfidenceKeys ?? []);
62121
- console.log(chalk15.bold(`
62650
+ console.log(chalk16.bold(`
62122
62651
  learned validate — ${url}
62123
62652
  `));
62124
62653
  for (const key of Object.keys(discovered)) {
@@ -62126,17 +62655,17 @@ learned validate — ${url}
62126
62655
  continue;
62127
62656
  const selector = discovered[key];
62128
62657
  if (!selector) {
62129
- console.log(` ${chalk15.dim(key.padEnd(20))} ${chalk15.dim("(vazio — LLM não detectou)")}`);
62658
+ console.log(` ${chalk16.dim(key.padEnd(20))} ${chalk16.dim("(vazio — LLM não detectou)")}`);
62130
62659
  continue;
62131
62660
  }
62132
- const state = validated[key] === true ? chalk15.green("validated") : validated[key] === false ? chalk15.red("not-validated") : chalk15.yellow("not-checked");
62133
- const guessTag = lowConfidence.has(key) ? chalk15.yellow(" [low-confidence]") : "";
62661
+ const state = validated[key] === true ? chalk16.green("validated") : validated[key] === false ? chalk16.red("not-validated") : chalk16.yellow("not-checked");
62662
+ const guessTag = lowConfidence.has(key) ? chalk16.yellow(" [low-confidence]") : "";
62134
62663
  console.log(` ${key.padEnd(20)} ${state.padEnd(22)} ${selector}${guessTag}`);
62135
62664
  }
62136
62665
  console.log("");
62137
62666
  return 0;
62138
62667
  } catch (err) {
62139
- console.error(chalk15.red(` ✖ validação ao vivo falhou: ${err.message}`));
62668
+ console.error(chalk16.red(` ✖ validação ao vivo falhou: ${err.message}`));
62140
62669
  return 2;
62141
62670
  } finally {
62142
62671
  if (browser)
@@ -62145,20 +62674,20 @@ learned validate — ${url}
62145
62674
  }
62146
62675
 
62147
62676
  // src/commands/list.ts
62148
- import chalk16 from "chalk";
62677
+ import chalk17 from "chalk";
62149
62678
  function listModulesCommand(json) {
62150
62679
  if (json) {
62151
62680
  console.log(JSON.stringify(MODULES, null, 2));
62152
62681
  return 0;
62153
62682
  }
62154
62683
  for (const mod of Object.values(MODULES)) {
62155
- console.log(` ${chalk16.bold(mod.name)} ${chalk16.dim(mod.description)}`);
62684
+ console.log(` ${chalk17.bold(mod.name)} ${chalk17.dim(mod.description)}`);
62156
62685
  console.log(` checks: ${mod.checks.join(", ")}`);
62157
62686
  console.log(` flows: ${mod.flows.join(", ")}`);
62158
62687
  if (mod.needsSitemapPages)
62159
- console.log(chalk16.dim(" needs sitemap-page crawling"));
62688
+ console.log(chalk17.dim(" needs sitemap-page crawling"));
62160
62689
  if (mod.needsLlm)
62161
- console.log(chalk16.dim(" needs an LLM pass for full value"));
62690
+ console.log(chalk17.dim(" needs an LLM pass for full value"));
62162
62691
  console.log("");
62163
62692
  }
62164
62693
  return 0;
@@ -62166,26 +62695,26 @@ function listModulesCommand(json) {
62166
62695
  function listCommand(output) {
62167
62696
  const runs = listRuns(output);
62168
62697
  if (runs.length === 0) {
62169
- console.log(chalk16.dim(`Nenhum run salvo em ${output}`));
62698
+ console.log(chalk17.dim(`Nenhum run salvo em ${output}`));
62170
62699
  return 0;
62171
62700
  }
62172
62701
  for (const r of runs) {
62173
62702
  try {
62174
62703
  const run = loadRun(output, r.id);
62175
62704
  const v = run.verdict;
62176
- const status = v.status === "pass" ? chalk16.green(v.status) : v.status === "warn" ? chalk16.yellow(v.status) : chalk16.red(v.status);
62177
- console.log(` ${chalk16.bold(r.id)} ${status} score=${v.score} critical=${v.critical} high=${v.high} ${chalk16.dim(r.timestamp)}`);
62705
+ const status = v.status === "pass" ? chalk17.green(v.status) : v.status === "warn" ? chalk17.yellow(v.status) : chalk17.red(v.status);
62706
+ console.log(` ${chalk17.bold(r.id)} ${status} score=${v.score} critical=${v.critical} high=${v.high} ${chalk17.dim(r.timestamp)}`);
62178
62707
  } catch {
62179
- console.log(` ${chalk16.bold(r.id)} ${chalk16.dim("(report.json ausente)")}`);
62708
+ console.log(` ${chalk17.bold(r.id)} ${chalk17.dim("(report.json ausente)")}`);
62180
62709
  }
62181
62710
  }
62182
62711
  return 0;
62183
62712
  }
62184
62713
 
62185
62714
  // src/commands/migrate.ts
62186
- import { existsSync as existsSync15, mkdirSync as mkdirSync16, readFileSync as readFileSync20, writeFileSync as writeFileSync24 } from "node:fs";
62715
+ import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync24, writeFileSync as writeFileSync25 } from "node:fs";
62187
62716
  import { resolve as resolve5 } from "node:path";
62188
- import chalk17 from "chalk";
62717
+ import chalk18 from "chalk";
62189
62718
  import open from "open";
62190
62719
 
62191
62720
  // src/migrate/pdp-discovery.ts
@@ -62199,26 +62728,26 @@ var PLATFORM_PATTERNS = {
62199
62728
  "vtex-fs": [/href="([^"]*\/p(?:\?[^"]*|\/[^"]+|))"/gi]
62200
62729
  };
62201
62730
  var ACTION_URL = /(Wishlist|Cart|MiniCart|Login|Account|Address|Order|Compare)-|add-?to-?/i;
62202
- function acceptProductUrl(href, baseUrl) {
62731
+ function acceptProductUrl(href, baseUrl2) {
62203
62732
  if (ACTION_URL.test(href))
62204
62733
  return null;
62205
62734
  try {
62206
- return new URL(href, baseUrl).toString();
62735
+ return new URL(href, baseUrl2).toString();
62207
62736
  } catch {
62208
62737
  return null;
62209
62738
  }
62210
62739
  }
62211
- function firstProductHref(html3, baseUrl, platform) {
62740
+ function firstProductHref(html3, baseUrl2, platform) {
62212
62741
  const patterns = platform ? PLATFORM_PATTERNS[platform] ?? [] : [];
62213
62742
  for (const re of patterns) {
62214
62743
  re.lastIndex = 0;
62215
62744
  for (let m = re.exec(html3);m; m = re.exec(html3)) {
62216
- const url = m[1] ? acceptProductUrl(m[1], baseUrl) : null;
62745
+ const url = m[1] ? acceptProductUrl(m[1], baseUrl2) : null;
62217
62746
  if (url)
62218
62747
  return url;
62219
62748
  }
62220
62749
  }
62221
- return firstProductHrefFromPlpHtml(html3, baseUrl);
62750
+ return firstProductHrefFromPlpHtml(html3, baseUrl2);
62222
62751
  }
62223
62752
 
62224
62753
  // src/engine/sitemap-discover.ts
@@ -62629,23 +63158,23 @@ function compactComponentHtml(html3, maxChars = COMPONENT_HTML_MAX_CHARS) {
62629
63158
  }
62630
63159
 
62631
63160
  // src/migrate/exporters/json.ts
62632
- import { writeFileSync as writeFileSync19 } from "node:fs";
62633
- import { join as join20 } from "node:path";
63161
+ import { writeFileSync as writeFileSync20 } from "node:fs";
63162
+ import { join as join24 } from "node:path";
62634
63163
  var jsonExporter2 = {
62635
63164
  name: "json",
62636
63165
  async export(bundle, outDir) {
62637
- writeFileSync19(join20(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
63166
+ writeFileSync20(join24(outDir, "manifest.json"), `${JSON.stringify(bundle, null, 2)}
62638
63167
  `, "utf8");
62639
63168
  }
62640
63169
  };
62641
63170
 
62642
63171
  // src/migrate/exporters/markdown.ts
62643
- import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync21 } from "node:fs";
62644
- import { join as join22 } from "node:path";
63172
+ import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync22 } from "node:fs";
63173
+ import { join as join26 } from "node:path";
62645
63174
 
62646
63175
  // src/migrate/vtex/content-assets.ts
62647
- import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync20 } from "node:fs";
62648
- import { join as join21 } from "node:path";
63176
+ import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync21 } from "node:fs";
63177
+ import { join as join25 } from "node:path";
62649
63178
  var MAX_IMAGES = 150;
62650
63179
  var IMG_EXT = /\.(jpe?g|png|webp|gif|svg|avif)(\?|#|$)/i;
62651
63180
  var VTEX_ASSET = /vtexassets\.com|vteximg\.com\.br|\/arquivos\/(ids|assets)\//i;
@@ -62665,23 +63194,23 @@ function isImageRef(s) {
62665
63194
  return true;
62666
63195
  return v.startsWith("/") && !v.startsWith("//") && (IMG_EXT.test(v) || VTEX_ASSET.test(v) || v.startsWith("/img/"));
62667
63196
  }
62668
- function resolveRef(ref, baseUrl) {
63197
+ function resolveRef(ref, baseUrl2) {
62669
63198
  const v = ref.trim();
62670
63199
  try {
62671
63200
  if (v.startsWith("//"))
62672
63201
  return `https:${v}`;
62673
- return new URL(v, baseUrl).toString();
63202
+ return new URL(v, baseUrl2).toString();
62674
63203
  } catch {
62675
63204
  return null;
62676
63205
  }
62677
63206
  }
62678
- function collectImageRefs(blocks, baseUrl) {
63207
+ function collectImageRefs(blocks, baseUrl2) {
62679
63208
  const out = {};
62680
63209
  const walk = (v) => {
62681
63210
  if (typeof v === "string") {
62682
63211
  const s = v.trim();
62683
63212
  if (isImageRef(s) && !(s in out)) {
62684
- const abs = resolveRef(s, baseUrl);
63213
+ const abs = resolveRef(s, baseUrl2);
62685
63214
  if (abs)
62686
63215
  out[s] = abs;
62687
63216
  }
@@ -62754,8 +63283,8 @@ async function downloadContentImages(urls, runDir, fetchBytes) {
62754
63283
  const map2 = {};
62755
63284
  if (urls.length === 0)
62756
63285
  return { map: map2, downloaded: 0, skipped: 0 };
62757
- const dir = join21(runDir, "assets", "content");
62758
- mkdirSync14(dir, { recursive: true });
63286
+ const dir = join25(runDir, "assets", "content");
63287
+ mkdirSync15(dir, { recursive: true });
62759
63288
  const used = new Set;
62760
63289
  const take = urls.slice(0, MAX_IMAGES);
62761
63290
  let downloaded = 0;
@@ -62764,7 +63293,7 @@ async function downloadContentImages(urls, runDir, fetchBytes) {
62764
63293
  if (!got)
62765
63294
  continue;
62766
63295
  const name = contentImageName(url, i, used);
62767
- writeFileSync20(join21(dir, name), got.buf);
63296
+ writeFileSync21(join25(dir, name), got.buf);
62768
63297
  map2[url] = `assets/content/${name}`;
62769
63298
  downloaded++;
62770
63299
  }
@@ -62779,16 +63308,16 @@ var markdownExporter2 = {
62779
63308
  const notes = [];
62780
63309
  bundle.components.forEach((component, i) => {
62781
63310
  const dirName = dirNames[i];
62782
- const componentDir = join22(outDir, "components", dirName);
62783
- mkdirSync15(componentDir, { recursive: true });
63311
+ const componentDir = join26(outDir, "components", dirName);
63312
+ mkdirSync16(componentDir, { recursive: true });
62784
63313
  const compact = compactComponentHtml(component.html);
62785
63314
  if (compact.collapsed > 0)
62786
63315
  notes.push(`\`${dirName}\`: collapsed ${compact.collapsed} repeated child element(s)`);
62787
63316
  if (compact.truncated)
62788
63317
  notes.push(`\`${dirName}\`: HTML truncated to fit the per-component token ceiling`);
62789
- writeFileSync21(join22(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
63318
+ writeFileSync22(join26(componentDir, "README.md"), renderComponentReadme2(bundle.url, component, compact.html), "utf8");
62790
63319
  });
62791
- writeFileSync21(join22(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
63320
+ writeFileSync22(join26(outDir, "index.md"), renderIndex2(bundle, notes), "utf8");
62792
63321
  }
62793
63322
  };
62794
63323
  function renderIndex2(bundle, notes) {
@@ -62990,8 +63519,8 @@ function escapePipes2(s) {
62990
63519
  }
62991
63520
 
62992
63521
  // src/migrate/exporters/html.ts
62993
- import { readFileSync as readFileSync16, writeFileSync as writeFileSync22 } from "node:fs";
62994
- import { join as join23 } from "node:path";
63522
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync23 } from "node:fs";
63523
+ import { join as join27 } from "node:path";
62995
63524
 
62996
63525
  // src/migrate/targets/faststore-v4.ts
62997
63526
  function pickBreakpointTiers(breakpoints) {
@@ -63311,9 +63840,9 @@ var TARGET_NAMES = Object.keys(TARGETS);
63311
63840
  var htmlExporter = {
63312
63841
  name: "html",
63313
63842
  async export(bundle, outDir) {
63314
- writeFileSync22(join23(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
63315
- const inline = (p) => p ? dataUri2(join23(outDir, p)) ?? p : null;
63316
- writeFileSync22(join23(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
63843
+ writeFileSync23(join27(outDir, "index.html"), renderHtml(bundle, (p) => p ?? null), "utf8");
63844
+ const inline = (p) => p ? dataUri2(join27(outDir, p)) ?? p : null;
63845
+ writeFileSync23(join27(outDir, "report.html"), renderHtml(bundle, inline), "utf8");
63317
63846
  }
63318
63847
  };
63319
63848
  var MIME2 = {
@@ -63331,7 +63860,7 @@ function dataUri2(absPath) {
63331
63860
  const mime = MIME2[ext];
63332
63861
  if (!mime)
63333
63862
  return null;
63334
- return `data:${mime};base64,${readFileSync16(absPath).toString("base64")}`;
63863
+ return `data:${mime};base64,${readFileSync20(absPath).toString("base64")}`;
63335
63864
  } catch {
63336
63865
  return null;
63337
63866
  }
@@ -63635,8 +64164,8 @@ function buildMigrationPrompt(bundle, playbook, source) {
63635
64164
  }
63636
64165
 
63637
64166
  // src/migrate/plan.ts
63638
- import { existsSync as existsSync12, readFileSync as readFileSync17, writeFileSync as writeFileSync23 } from "node:fs";
63639
- import { join as join24 } from "node:path";
64167
+ import { existsSync as existsSync15, readFileSync as readFileSync21, writeFileSync as writeFileSync24 } from "node:fs";
64168
+ import { join as join28 } from "node:path";
63640
64169
  function dedupe(names) {
63641
64170
  return [...new Set(names)];
63642
64171
  }
@@ -63728,13 +64257,13 @@ function mergePlanDecisions(fresh, previous) {
63728
64257
  var PLAN_FILE = "migration-plan.json";
63729
64258
  var SETTLED = new Set(["done", "as-is", "upgrade", "skipped"]);
63730
64259
  function loadPlan(dir) {
63731
- const p = join24(dir, PLAN_FILE);
63732
- if (!existsSync12(p))
64260
+ const p = join28(dir, PLAN_FILE);
64261
+ if (!existsSync15(p))
63733
64262
  return null;
63734
- return JSON.parse(readFileSync17(p, "utf8"));
64263
+ return JSON.parse(readFileSync21(p, "utf8"));
63735
64264
  }
63736
64265
  function savePlan(dir, plan) {
63737
- writeFileSync23(join24(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
64266
+ writeFileSync24(join28(dir, PLAN_FILE), `${JSON.stringify(plan, null, 2)}
63738
64267
  `, "utf8");
63739
64268
  }
63740
64269
  function setComponentStatus(plan, name, status) {
@@ -63969,12 +64498,12 @@ function syntheticSourceComponents(plan) {
63969
64498
  }
63970
64499
 
63971
64500
  // src/migrate/sources/deco-fresh.ts
63972
- import { existsSync as existsSync13, readFileSync as readFileSync18 } from "node:fs";
63973
- import { join as join26 } from "node:path";
64501
+ import { existsSync as existsSync16, readFileSync as readFileSync22 } from "node:fs";
64502
+ import { join as join30 } from "node:path";
63974
64503
 
63975
64504
  // src/migrate/sources/walk.ts
63976
- import { readdirSync as readdirSync3 } from "node:fs";
63977
- import { join as join25 } from "node:path";
64505
+ import { readdirSync as readdirSync4 } from "node:fs";
64506
+ import { join as join29 } from "node:path";
63978
64507
  var SKIP = new Set([
63979
64508
  "node_modules",
63980
64509
  ".git",
@@ -63990,7 +64519,7 @@ function walkFiles(dir, exts) {
63990
64519
  const recurse = (abs, rel) => {
63991
64520
  let entries;
63992
64521
  try {
63993
- entries = readdirSync3(abs, { withFileTypes: true });
64522
+ entries = readdirSync4(abs, { withFileTypes: true });
63994
64523
  } catch {
63995
64524
  return;
63996
64525
  }
@@ -64001,7 +64530,7 @@ function walkFiles(dir, exts) {
64001
64530
  continue;
64002
64531
  const childRel = rel ? `${rel}/${e.name}` : e.name;
64003
64532
  if (e.isDirectory()) {
64004
- recurse(join25(abs, e.name), childRel);
64533
+ recurse(join29(abs, e.name), childRel);
64005
64534
  } else if (exts.some((ext) => e.name.endsWith(ext))) {
64006
64535
  out.push(childRel);
64007
64536
  }
@@ -64013,15 +64542,15 @@ function walkFiles(dir, exts) {
64013
64542
 
64014
64543
  // src/migrate/sources/deco-fresh.ts
64015
64544
  function isDecoFresh(repoDir) {
64016
- const denoJson = join26(repoDir, "deno.json");
64017
- const denoJsonc = join26(repoDir, "deno.jsonc");
64018
- const file = existsSync13(denoJson) ? denoJson : existsSync13(denoJsonc) ? denoJsonc : null;
64545
+ const denoJson = join30(repoDir, "deno.json");
64546
+ const denoJsonc = join30(repoDir, "deno.jsonc");
64547
+ const file = existsSync16(denoJson) ? denoJson : existsSync16(denoJsonc) ? denoJsonc : null;
64019
64548
  if (!file)
64020
64549
  return false;
64021
- if (!existsSync13(join26(repoDir, "fresh.gen.ts")))
64550
+ if (!existsSync16(join30(repoDir, "fresh.gen.ts")))
64022
64551
  return false;
64023
64552
  try {
64024
- return readFileSync18(file, "utf8").includes("@deco/deco");
64553
+ return readFileSync22(file, "utf8").includes("@deco/deco");
64025
64554
  } catch {
64026
64555
  return false;
64027
64556
  }
@@ -64029,13 +64558,13 @@ function isDecoFresh(repoDir) {
64029
64558
  var GLOBAL_HINT = /\b(header|footer|navbar|menu|topbar)\b/i;
64030
64559
  function inventory(repoDir) {
64031
64560
  const components = [];
64032
- const sectionsDir = join26(repoDir, "sections");
64033
- if (existsSync13(sectionsDir)) {
64561
+ const sectionsDir = join30(repoDir, "sections");
64562
+ if (existsSync16(sectionsDir)) {
64034
64563
  for (const rel of walkFiles(sectionsDir, [".tsx"])) {
64035
64564
  const key2 = rel.replace(/\.tsx$/, "");
64036
64565
  components.push({
64037
64566
  name: key2,
64038
- file: join26("sections", rel),
64567
+ file: join30("sections", rel),
64039
64568
  role: "section",
64040
64569
  scope: GLOBAL_HINT.test(key2) ? "global" : "page"
64041
64570
  });
@@ -64044,9 +64573,9 @@ function inventory(repoDir) {
64044
64573
  const notes = [
64045
64574
  "Source: Deco on Fresh/Deno (Preact + signals, JSX). Sections are the CMS unit."
64046
64575
  ];
64047
- if (existsSync13(join26(repoDir, "islands")))
64576
+ if (existsSync16(join30(repoDir, "islands")))
64048
64577
  notes.push("Has islands/ — client-interactive components.");
64049
- if (existsSync13(join26(repoDir, "loaders")))
64578
+ if (existsSync16(join30(repoDir, "loaders")))
64050
64579
  notes.push("Has loaders/ — server data functions to port.");
64051
64580
  return { components, notes };
64052
64581
  }
@@ -64086,14 +64615,14 @@ captured HTML/computed-styles as the source of truth for structure and styling.`
64086
64615
  };
64087
64616
 
64088
64617
  // src/migrate/sources/vtex-io.ts
64089
- import { existsSync as existsSync14, readFileSync as readFileSync19 } from "node:fs";
64090
- import { join as join27 } from "node:path";
64618
+ import { existsSync as existsSync17, readFileSync as readFileSync23 } from "node:fs";
64619
+ import { join as join31 } from "node:path";
64091
64620
  function readManifest(repoDir) {
64092
- const file = join27(repoDir, "manifest.json");
64093
- if (!existsSync14(file))
64621
+ const file = join31(repoDir, "manifest.json");
64622
+ if (!existsSync17(file))
64094
64623
  return null;
64095
64624
  try {
64096
- return JSON.parse(readFileSync19(file, "utf8"));
64625
+ return JSON.parse(readFileSync23(file, "utf8"));
64097
64626
  } catch {
64098
64627
  return null;
64099
64628
  }
@@ -64114,14 +64643,14 @@ function blockName(id) {
64114
64643
  }
64115
64644
  var GLOBAL_HINT2 = /header|footer|menu|minicart|navbar/i;
64116
64645
  function inventory2(repoDir) {
64117
- const blocksDir = join27(repoDir, "store", "blocks");
64646
+ const blocksDir = join31(repoDir, "store", "blocks");
64118
64647
  const seen = new Map;
64119
- if (existsSync14(blocksDir)) {
64648
+ if (existsSync17(blocksDir)) {
64120
64649
  for (const rel of walkFiles(blocksDir, [".json", ".jsonc"])) {
64121
- const abs = join27(blocksDir, rel);
64650
+ const abs = join31(blocksDir, rel);
64122
64651
  let parsed;
64123
64652
  try {
64124
- parsed = JSON.parse(stripJsonc(readFileSync19(abs, "utf8")));
64653
+ parsed = JSON.parse(stripJsonc(readFileSync23(abs, "utf8")));
64125
64654
  } catch {
64126
64655
  continue;
64127
64656
  }
@@ -64131,7 +64660,7 @@ function inventory2(repoDir) {
64131
64660
  continue;
64132
64661
  seen.set(name, {
64133
64662
  name,
64134
- file: join27("store", "blocks", rel),
64663
+ file: join31("store", "blocks", rel),
64135
64664
  role: "section",
64136
64665
  scope: GLOBAL_HINT2.test(name) ? "global" : "page"
64137
64666
  });
@@ -64650,29 +65179,29 @@ async function captureInteractions(page, selector) {
64650
65179
  async function migrateCommand(opts) {
64651
65180
  const viewport = parseViewport3(opts.viewport);
64652
65181
  if (!viewport) {
64653
- console.error(chalk17.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
65182
+ console.error(chalk18.red(`viewport inválido: ${opts.viewport} (use mobile|desktop|tablet)`));
64654
65183
  return 2;
64655
65184
  }
64656
65185
  const viewports = (opts.viewports ? opts.viewports.split(",") : [opts.viewport]).map((v) => parseViewport3(v.trim())).filter((v) => Boolean(v));
64657
65186
  if (viewports.length === 0) {
64658
- console.error(chalk17.red(`--viewports inválido: ${opts.viewports}`));
65187
+ console.error(chalk18.red(`--viewports inválido: ${opts.viewports}`));
64659
65188
  return 2;
64660
65189
  }
64661
65190
  const primaryViewport = viewports[0];
64662
65191
  if (!isValidUrl4(opts.url)) {
64663
- console.error(chalk17.red(`--url inválido: ${opts.url}`));
65192
+ console.error(chalk18.red(`--url inválido: ${opts.url}`));
64664
65193
  return 2;
64665
65194
  }
64666
65195
  const format = normalizeFormat2(opts.format);
64667
65196
  if (!format) {
64668
- console.error(chalk17.red(`--format inválido: ${opts.format} (use md|json|both)`));
65197
+ console.error(chalk18.red(`--format inválido: ${opts.format} (use md|json|both)`));
64669
65198
  return 2;
64670
65199
  }
64671
65200
  let playbook;
64672
65201
  if (opts.target) {
64673
65202
  playbook = getTargetPlaybook(opts.target);
64674
65203
  if (!playbook) {
64675
- console.error(chalk17.red(`--target inválido: ${opts.target} (disponíveis: ${TARGET_NAMES.join(", ")})`));
65204
+ console.error(chalk18.red(`--target inválido: ${opts.target} (disponíveis: ${TARGET_NAMES.join(", ")})`));
64676
65205
  return 2;
64677
65206
  }
64678
65207
  }
@@ -64682,24 +65211,24 @@ async function migrateCommand(opts) {
64682
65211
  if (opts.sourceKind) {
64683
65212
  const s = getSource(opts.sourceKind);
64684
65213
  if (!s) {
64685
- console.error(chalk17.red(`--source-kind inválido: ${opts.sourceKind} (disponíveis: ${SOURCE_KINDS.join(", ")})`));
65214
+ console.error(chalk18.red(`--source-kind inválido: ${opts.sourceKind} (disponíveis: ${SOURCE_KINDS.join(", ")})`));
64686
65215
  return 2;
64687
65216
  }
64688
65217
  source = s;
64689
65218
  }
64690
65219
  if (opts.source) {
64691
- if (!existsSync15(opts.source)) {
64692
- console.error(chalk17.red(`--source não encontrado: ${opts.source}`));
65220
+ if (!existsSync18(opts.source)) {
65221
+ console.error(chalk18.red(`--source não encontrado: ${opts.source}`));
64693
65222
  return 2;
64694
65223
  }
64695
65224
  if (!opts.sourceKind)
64696
65225
  source = detectSource(opts.source);
64697
65226
  sourceInventory = source.inventory(opts.source);
64698
- console.log(chalk17.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
65227
+ console.log(chalk18.dim(` source: ${source.label} — ${sourceInventory.components.length} component(s) from code`));
64699
65228
  }
64700
65229
  const host = safeHost6(opts.url);
64701
65230
  const runDir = resolve5(opts.outDir, host);
64702
- mkdirSync16(runDir, { recursive: true });
65231
+ mkdirSync17(runDir, { recursive: true });
64703
65232
  const browser = await launchBrowser({ headless: true });
64704
65233
  try {
64705
65234
  const themePath = resolve5(runDir, "theme.json");
@@ -64712,17 +65241,17 @@ async function migrateCommand(opts) {
64712
65241
  let screenshots;
64713
65242
  let vtexBlocks = null;
64714
65243
  let contentMap = {};
64715
- if (!opts.refresh && existsSync15(themePath) && existsSync15(assetsPath)) {
65244
+ if (!opts.refresh && existsSync18(themePath) && existsSync18(assetsPath)) {
64716
65245
  theme = readJson(themePath);
64717
65246
  const meta = readJson(assetsPath);
64718
65247
  platform = meta.platform;
64719
65248
  stack = meta.stack ?? null;
64720
65249
  assets = meta.assets;
64721
65250
  screenshots = meta.screenshots ?? [];
64722
- console.log(chalk17.dim(" phase 1 theme+assets: cached"));
65251
+ console.log(chalk18.dim(" phase 1 theme+assets: cached"));
64723
65252
  } else {
64724
- console.log(chalk17.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
64725
- mkdirSync16(resolve5(runDir, "screenshots"), { recursive: true });
65253
+ console.log(chalk18.dim(` phase 1 theme+assets: scraping (${viewports.join(", ")})…`));
65254
+ mkdirSync17(resolve5(runDir, "screenshots"), { recursive: true });
64726
65255
  const samples = [];
64727
65256
  screenshots = [];
64728
65257
  let platformSeen = null;
@@ -64757,7 +65286,7 @@ async function migrateCommand(opts) {
64757
65286
  platformSeen = detectPlatform({ url: opts.url, html: pageHtml });
64758
65287
  const cookieNames = await ctx.cookies().then((cs) => cs.map((c) => c.name).join("; ")).catch(() => "");
64759
65288
  stack = classifyLiveStack(pageHtml, cookieNames);
64760
- console.log(chalk17.dim(` stack: ${describeStack(stack)}`));
65289
+ console.log(chalk18.dim(` stack: ${describeStack(stack)}`));
64761
65290
  const rawAssets = await collectSiteAssets(page);
64762
65291
  const fetchBytes = async (url) => await browserFetchBytes(page, url) ?? await nodeFetchBytes(url);
64763
65292
  assetsResolved = await downloadSiteAssets(rawAssets, runDir, fetchBytes);
@@ -64782,18 +65311,18 @@ async function migrateCommand(opts) {
64782
65311
  theme = aggregateTheme(mergeRawThemeSamples(samples));
64783
65312
  platform = platformSeen ?? "custom";
64784
65313
  assets = assetsResolved;
64785
- writeFileSync24(themePath, `${JSON.stringify(theme, null, 2)}
65314
+ writeFileSync25(themePath, `${JSON.stringify(theme, null, 2)}
64786
65315
  `, "utf8");
64787
- writeFileSync24(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
65316
+ writeFileSync25(assetsPath, `${JSON.stringify({ platform, stack, assets, screenshots }, null, 2)}
64788
65317
  `, "utf8");
64789
65318
  }
64790
65319
  const sitemapPath = resolve5(runDir, "sitemap.json");
64791
65320
  let resolvedPages;
64792
- if (!opts.refresh && existsSync15(sitemapPath)) {
65321
+ if (!opts.refresh && existsSync18(sitemapPath)) {
64793
65322
  resolvedPages = readJson(sitemapPath).pages;
64794
- console.log(chalk17.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
65323
+ console.log(chalk18.dim(` phase 2 sitemap: cached (${resolvedPages.length} page(s))`));
64795
65324
  } else {
64796
- console.log(chalk17.dim(" phase 2 sitemap: resolving pages…"));
65325
+ console.log(chalk18.dim(" phase 2 sitemap: resolving pages…"));
64797
65326
  const ctx = await newContext(browser, { viewport: primaryViewport });
64798
65327
  const page = await ctx.newPage();
64799
65328
  let sitemapUrls = [];
@@ -64821,27 +65350,27 @@ async function migrateCommand(opts) {
64821
65350
  a[p.kind] = (a[p.kind] ?? 0) + 1;
64822
65351
  return a;
64823
65352
  }, {});
64824
- console.log(chalk17.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
65353
+ console.log(chalk18.dim(` phase 2 sitemap: +${sampled.length} sampled (${Object.entries(byKind).map(([k, n]) => `${n} ${k}`).join(", ")})`));
64825
65354
  }
64826
- writeFileSync24(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
65355
+ writeFileSync25(sitemapPath, `${JSON.stringify({ pages: resolvedPages, sitemapUrls: classified }, null, 2)}
64827
65356
  `, "utf8");
64828
65357
  }
64829
65358
  if (resolvedPages.length === 0) {
64830
- console.error(chalk17.red("nenhuma página resolvida a partir de --pages"));
65359
+ console.error(chalk18.red("nenhuma página resolvida a partir de --pages"));
64831
65360
  return 1;
64832
65361
  }
64833
65362
  const capturePath = resolve5(runDir, "capture.json");
64834
65363
  let pages;
64835
65364
  let components;
64836
- if (!opts.refresh && existsSync15(capturePath)) {
65365
+ if (!opts.refresh && existsSync18(capturePath)) {
64837
65366
  const cached = readJson(capturePath);
64838
65367
  pages = cached.pages;
64839
65368
  components = cached.components;
64840
65369
  vtexBlocks = cached.vtexBlocks ?? null;
64841
65370
  contentMap = cached.contentMap ?? {};
64842
- console.log(chalk17.dim(` phase 3 components: cached (${components.length})`));
65371
+ console.log(chalk18.dim(` phase 3 components: cached (${components.length})`));
64843
65372
  } else {
64844
- console.log(chalk17.dim(" phase 3 components: capturing…"));
65373
+ console.log(chalk18.dim(" phase 3 components: capturing…"));
64845
65374
  ({ pages, components, vtexBlocks, contentMap } = await capturePages(browser, primaryViewport, resolvedPages, theme, {
64846
65375
  allowlist,
64847
65376
  llm: !opts.noLlm,
@@ -64849,14 +65378,14 @@ async function migrateCommand(opts) {
64849
65378
  baseUrl: opts.url,
64850
65379
  vtexScrape: opts.source ? source.kind === "vtex-io" : true
64851
65380
  }));
64852
- writeFileSync24(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
65381
+ writeFileSync25(capturePath, `${JSON.stringify({ pages, components, vtexBlocks, contentMap }, null, 2)}
64853
65382
  `, "utf8");
64854
65383
  }
64855
65384
  if (vtexBlocks)
64856
- writeFileSync24(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
65385
+ writeFileSync25(blocksPath, `${JSON.stringify(vtexBlocks, null, 2)}
64857
65386
  `, "utf8");
64858
65387
  if (Object.keys(contentMap).length)
64859
- writeFileSync24(resolve5(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
65388
+ writeFileSync25(resolve5(runDir, "content-assets.json"), `${JSON.stringify(contentMap, null, 2)}
64860
65389
  `, "utf8");
64861
65390
  const bundle = {
64862
65391
  url: opts.url,
@@ -64882,10 +65411,10 @@ async function migrateCommand(opts) {
64882
65411
  const plan = merged.plan;
64883
65412
  savePlan(runDir, plan);
64884
65413
  if (merged.carried.length) {
64885
- console.log(chalk17.gray(` plan: carried ${merged.carried.length} recorded decision(s) forward`));
65414
+ console.log(chalk18.gray(` plan: carried ${merged.carried.length} recorded decision(s) forward`));
64886
65415
  }
64887
65416
  if (merged.droppedWithDecisions.length) {
64888
- console.log(chalk17.yellow(` plan: ${merged.droppedWithDecisions.length} component(s) with recorded decisions are no longer in the capture — ${merged.droppedWithDecisions.join(", ")}`));
65417
+ console.log(chalk18.yellow(` plan: ${merged.droppedWithDecisions.length} component(s) with recorded decisions are no longer in the capture — ${merged.droppedWithDecisions.join(", ")}`));
64889
65418
  }
64890
65419
  bundle.components.push(...syntheticSourceComponents(plan));
64891
65420
  if (format === "json" || format === "both")
@@ -64893,17 +65422,17 @@ async function migrateCommand(opts) {
64893
65422
  if (format === "md" || format === "both") {
64894
65423
  await markdownExporter2.export(bundle, runDir);
64895
65424
  await htmlExporter.export(bundle, runDir);
64896
- writeFileSync24(resolve5(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
65425
+ writeFileSync25(resolve5(runDir, "MIGRATION_PROMPT.md"), buildMigrationPrompt(bundle, playbook, {
64897
65426
  playbook: source.playbook,
64898
65427
  notes: sourceInventory.notes
64899
65428
  }), "utf8");
64900
65429
  }
64901
65430
  const targetTheme = opts.target ? getTargetTheme(opts.target) : null;
64902
65431
  if (targetTheme) {
64903
- writeFileSync24(resolve5(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
65432
+ writeFileSync25(resolve5(runDir, targetTheme.filename), targetTheme.build(theme), "utf8");
64904
65433
  }
64905
65434
  if (bundle.vtex) {
64906
- writeFileSync24(resolve5(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
65435
+ writeFileSync25(resolve5(runDir, "component-map.json"), `${JSON.stringify(bundle.vtex.map, null, 2)}
64907
65436
  `, "utf8");
64908
65437
  }
64909
65438
  if (opts.json) {
@@ -65012,21 +65541,21 @@ async function capturePages(browser, viewport, resolvedPages, theme, cfg) {
65012
65541
  contentMap
65013
65542
  };
65014
65543
  }
65015
- async function resolvePages2(page, baseUrl, pagesSpec, homeHtml, platform) {
65544
+ async function resolvePages2(page, baseUrl2, pagesSpec, homeHtml, platform) {
65016
65545
  const tokens = (pagesSpec ?? "/,category-auto,pdp-auto").split(",").map((s) => s.trim()).filter(Boolean);
65017
65546
  const out = [];
65018
- const plp = pickPlpFromHomeHtml(homeHtml, baseUrl);
65547
+ const plp = pickPlpFromHomeHtml(homeHtml, baseUrl2);
65019
65548
  for (const token of tokens) {
65020
65549
  if (token === "category-auto") {
65021
65550
  if (plp)
65022
65551
  out.push({ path: token, url: plp, kind: "plp" });
65023
65552
  else
65024
- console.warn(chalk17.yellow(" ⚠ category-auto: nenhuma PLP descoberta na home"));
65553
+ console.warn(chalk18.yellow(" ⚠ category-auto: nenhuma PLP descoberta na home"));
65025
65554
  continue;
65026
65555
  }
65027
65556
  if (token === "pdp-auto") {
65028
65557
  if (!plp) {
65029
- console.warn(chalk17.yellow(" ⚠ pdp-auto: sem PLP pra derivar PDP"));
65558
+ console.warn(chalk18.yellow(" ⚠ pdp-auto: sem PLP pra derivar PDP"));
65030
65559
  continue;
65031
65560
  }
65032
65561
  let html3 = null;
@@ -65043,19 +65572,19 @@ async function resolvePages2(page, baseUrl, pagesSpec, homeHtml, platform) {
65043
65572
  if (pdp)
65044
65573
  out.push({ path: token, url: pdp, kind: "pdp" });
65045
65574
  else
65046
- console.warn(chalk17.yellow(" ⚠ pdp-auto: nenhum produto encontrado na PLP"));
65575
+ console.warn(chalk18.yellow(" ⚠ pdp-auto: nenhum produto encontrado na PLP"));
65047
65576
  continue;
65048
65577
  }
65049
65578
  try {
65050
- const url = new URL(token, baseUrl).toString();
65579
+ const url = new URL(token, baseUrl2).toString();
65051
65580
  out.push({ path: token, url, kind: kindOf(url) });
65052
65581
  } catch {}
65053
65582
  }
65054
65583
  return out;
65055
65584
  }
65056
- async function discoverSitemapUrls(page, baseUrl) {
65585
+ async function discoverSitemapUrls(page, baseUrl2) {
65057
65586
  try {
65058
- const origin = new URL(baseUrl).origin;
65587
+ const origin = new URL(baseUrl2).origin;
65059
65588
  const rootXml = await browserFetchText(page, `${origin}/sitemap.xml`);
65060
65589
  if (!rootXml)
65061
65590
  return [];
@@ -65157,31 +65686,31 @@ function kindOf(url) {
65157
65686
  }
65158
65687
  }
65159
65688
  function printResults4(runDir, bundle) {
65160
- console.log(chalk17.bold(`
65689
+ console.log(chalk18.bold(`
65161
65690
  parity migrate`));
65162
- console.log(chalk17.dim(` url: ${bundle.url}`));
65163
- console.log(chalk17.dim(` platform: ${bundle.platform}${bundle.target ? ` → ${bundle.target}` : ""}`));
65164
- console.log(chalk17.dim(` viewports:${(bundle.viewports ?? [bundle.viewport]).join(", ")}`));
65165
- console.log(chalk17.dim(` theme: primary=${bundle.theme.colors.primary ?? "—"} text=${bundle.theme.colors.text ?? "—"}`));
65166
- console.log(chalk17.dim(` assets: logo=${bundle.assets.logo ? "✓" : "✗"} favicon=${bundle.assets.favicon ? "✓" : "✗"} icons=${bundle.assets.icons.length} fonts=${bundle.assets.fontFiles.length}`));
65691
+ console.log(chalk18.dim(` url: ${bundle.url}`));
65692
+ console.log(chalk18.dim(` platform: ${bundle.platform}${bundle.target ? ` → ${bundle.target}` : ""}`));
65693
+ console.log(chalk18.dim(` viewports:${(bundle.viewports ?? [bundle.viewport]).join(", ")}`));
65694
+ console.log(chalk18.dim(` theme: primary=${bundle.theme.colors.primary ?? "—"} text=${bundle.theme.colors.text ?? "—"}`));
65695
+ console.log(chalk18.dim(` assets: logo=${bundle.assets.logo ? "✓" : "✗"} favicon=${bundle.assets.favicon ? "✓" : "✗"} icons=${bundle.assets.icons.length} fonts=${bundle.assets.fontFiles.length}`));
65167
65696
  if (bundle.vtex) {
65168
65697
  const mapped = bundle.vtex.map.filter((m) => m.strategy === "mapped").length;
65169
65698
  const withContent = bundle.vtex.blocks.filter((x) => x.props).length;
65170
65699
  const contentImgs = countContentImages(bundle.vtex.blocks);
65171
- console.log(chalk17.dim(` vtex io: ${bundle.vtex.blocks.length} blocks (${withContent} with CMS content, ${contentImgs} content images local) · ${mapped}/${bundle.vtex.map.length} mapped`));
65700
+ console.log(chalk18.dim(` vtex io: ${bundle.vtex.blocks.length} blocks (${withContent} with CMS content, ${contentImgs} content images local) · ${mapped}/${bundle.vtex.map.length} mapped`));
65172
65701
  }
65173
- console.log(chalk17.dim(` pages: ${bundle.pages.map((p) => p.kind).join(", ") || "—"}`));
65174
- console.log(chalk17.dim(` out: ${runDir}`));
65702
+ console.log(chalk18.dim(` pages: ${bundle.pages.map((p) => p.kind).join(", ") || "—"}`));
65703
+ console.log(chalk18.dim(` out: ${runDir}`));
65175
65704
  console.log("");
65176
- console.log(chalk17.bold(` ${bundle.components.length} component(s):`));
65705
+ console.log(chalk18.bold(` ${bundle.components.length} component(s):`));
65177
65706
  for (const c of bundle.components) {
65178
- console.log(` ${chalk17.cyan(`${c.scope}/${c.role}`.padEnd(28))} ${chalk17.dim(`${c.tailwind.length} tw · ${c.interactions.length} interactions`)}`);
65707
+ console.log(` ${chalk18.cyan(`${c.scope}/${c.role}`.padEnd(28))} ${chalk18.dim(`${c.tailwind.length} tw · ${c.interactions.length} interactions`)}`);
65179
65708
  }
65180
65709
  console.log("");
65181
65710
  }
65182
65711
  function readJson(path) {
65183
65712
  try {
65184
- return JSON.parse(readFileSync20(path, "utf8"));
65713
+ return JSON.parse(readFileSync24(path, "utf8"));
65185
65714
  } catch {
65186
65715
  return null;
65187
65716
  }
@@ -65227,8 +65756,8 @@ function sleep2(ms) {
65227
65756
  }
65228
65757
 
65229
65758
  // src/commands/plan.ts
65230
- import { readFileSync as readFileSync21 } from "node:fs";
65231
- import chalk18 from "chalk";
65759
+ import { readFileSync as readFileSync25 } from "node:fs";
65760
+ import chalk19 from "chalk";
65232
65761
 
65233
65762
  // src/board/studio.ts
65234
65763
  var LANE_TO_STUDIO = {
@@ -65390,56 +65919,56 @@ var STATUSES = ["pending", "partial", "done", "as-is", "upgrade", "skipped"];
65390
65919
  var PAGE_STATUSES = ["pending", "code", "done", "skipped"];
65391
65920
  function planSetStatusCommand(dir, name, status) {
65392
65921
  if (!STATUSES.includes(status)) {
65393
- console.error(chalk18.red(`Invalid status "${status}". Use one of: ${STATUSES.join(", ")}`));
65922
+ console.error(chalk19.red(`Invalid status "${status}". Use one of: ${STATUSES.join(", ")}`));
65394
65923
  return 1;
65395
65924
  }
65396
65925
  const plan = loadPlan(dir);
65397
65926
  if (!plan) {
65398
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65927
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65399
65928
  return 1;
65400
65929
  }
65401
65930
  const component = setComponentStatus(plan, name, status);
65402
65931
  if (!component) {
65403
- console.error(chalk18.red(`No component matching "${name}" in the plan`));
65932
+ console.error(chalk19.red(`No component matching "${name}" in the plan`));
65404
65933
  return 1;
65405
65934
  }
65406
65935
  savePlan(dir, plan);
65407
- console.log(`${chalk18.green("✓")} ${component.name} → ${status}`);
65936
+ console.log(`${chalk19.green("✓")} ${component.name} → ${status}`);
65408
65937
  if ((status === "upgrade" || status === "as-is") && !component.reference) {
65409
- console.log(chalk18.yellow(` no reason recorded — run \`parity plan set-reference ${component.name} --note "<why>"${status === "upgrade" ? " --url <reference site>" : ""}\``));
65938
+ console.log(chalk19.yellow(` no reason recorded — run \`parity plan set-reference ${component.name} --note "<why>"${status === "upgrade" ? " --url <reference site>" : ""}\``));
65410
65939
  }
65411
65940
  return 0;
65412
65941
  }
65413
65942
  function planSetPageStatusCommand(dir, path, status) {
65414
65943
  if (!PAGE_STATUSES.includes(status)) {
65415
- console.error(chalk18.red(`Invalid status "${status}". Use one of: ${PAGE_STATUSES.join(", ")}`));
65944
+ console.error(chalk19.red(`Invalid status "${status}". Use one of: ${PAGE_STATUSES.join(", ")}`));
65416
65945
  return 1;
65417
65946
  }
65418
65947
  const plan = loadPlan(dir);
65419
65948
  if (!plan) {
65420
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65949
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65421
65950
  return 1;
65422
65951
  }
65423
65952
  const page = setPageStatus(plan, path, status);
65424
65953
  if (!page) {
65425
- console.error(chalk18.red(`No page matching "${path}" in the plan`));
65954
+ console.error(chalk19.red(`No page matching "${path}" in the plan`));
65426
65955
  return 1;
65427
65956
  }
65428
65957
  savePlan(dir, plan);
65429
- console.log(`${chalk18.green("✓")} ${page.path} → ${status}`);
65958
+ console.log(`${chalk19.green("✓")} ${page.path} → ${status}`);
65430
65959
  return 0;
65431
65960
  }
65432
65961
  var DISPOSITION_STYLE = {
65433
- build: chalk18.red,
65434
- validate: chalk18.yellow,
65435
- upgrade: chalk18.cyan,
65436
- "as-is": chalk18.gray,
65437
- settled: chalk18.green
65962
+ build: chalk19.red,
65963
+ validate: chalk19.yellow,
65964
+ upgrade: chalk19.cyan,
65965
+ "as-is": chalk19.gray,
65966
+ settled: chalk19.green
65438
65967
  };
65439
65968
  function planSetReferenceCommand(dir, name, opts) {
65440
65969
  const plan = loadPlan(dir);
65441
65970
  if (!plan) {
65442
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65971
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65443
65972
  return 1;
65444
65973
  }
65445
65974
  const component = setComponentReference(plan, name, {
@@ -65448,76 +65977,76 @@ function planSetReferenceCommand(dir, name, opts) {
65448
65977
  note: opts.note
65449
65978
  });
65450
65979
  if (!component) {
65451
- console.error(chalk18.red(`No component matching "${name}" in the plan`));
65980
+ console.error(chalk19.red(`No component matching "${name}" in the plan`));
65452
65981
  return 1;
65453
65982
  }
65454
65983
  savePlan(dir, plan);
65455
- console.log(`${chalk18.green("✓")} ${component.name} → reference ${component.reference?.url}`);
65984
+ console.log(`${chalk19.green("✓")} ${component.name} → reference ${component.reference?.url}`);
65456
65985
  return 0;
65457
65986
  }
65458
65987
  function planVerifyCommand(dir, name, verdict2, opts) {
65459
65988
  if (verdict2 !== "pass" && verdict2 !== "fail") {
65460
- console.error(chalk18.red(`Invalid verdict "${verdict2}". Use pass or fail.`));
65989
+ console.error(chalk19.red(`Invalid verdict "${verdict2}". Use pass or fail.`));
65461
65990
  return 1;
65462
65991
  }
65463
65992
  const plan = loadPlan(dir);
65464
65993
  if (!plan) {
65465
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65994
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65466
65995
  return 1;
65467
65996
  }
65468
65997
  const component = setComponentVerified(plan, name, verdict2, opts.at ?? new Date().toISOString(), opts.note);
65469
65998
  if (!component) {
65470
- console.error(chalk18.red(`No component matching "${name}" in the plan`));
65999
+ console.error(chalk19.red(`No component matching "${name}" in the plan`));
65471
66000
  return 1;
65472
66001
  }
65473
66002
  savePlan(dir, plan);
65474
- const mark = verdict2 === "pass" ? chalk18.green("✓") : chalk18.red("✗");
66003
+ const mark = verdict2 === "pass" ? chalk19.green("✓") : chalk19.red("✗");
65475
66004
  console.log(`${mark} ${component.name} → ${verdict2} (against ${component.verified?.against})`);
65476
66005
  return 0;
65477
66006
  }
65478
66007
  function planMergeCommand(dir, sourceDir) {
65479
66008
  const fresh = loadPlan(sourceDir);
65480
66009
  if (!fresh) {
65481
- console.error(chalk18.red(`No migration-plan.json found in ${sourceDir}`));
66010
+ console.error(chalk19.red(`No migration-plan.json found in ${sourceDir}`));
65482
66011
  return 1;
65483
66012
  }
65484
66013
  const existing = loadPlan(dir);
65485
66014
  const { plan, carried, droppedWithDecisions } = mergePlanDecisions(fresh, existing);
65486
66015
  savePlan(dir, plan);
65487
66016
  if (!existing) {
65488
- console.log(`${chalk18.green("✓")} plan written to ${dir} (nothing to merge)`);
66017
+ console.log(`${chalk19.green("✓")} plan written to ${dir} (nothing to merge)`);
65489
66018
  return 0;
65490
66019
  }
65491
- console.log(`${chalk18.green("✓")} merged into ${dir} — ${carried.length} decision(s) kept`);
66020
+ console.log(`${chalk19.green("✓")} merged into ${dir} — ${carried.length} decision(s) kept`);
65492
66021
  if (droppedWithDecisions.length) {
65493
- console.log(chalk18.yellow(` no longer in the capture, decisions lost: ${droppedWithDecisions.join(", ")}`));
66022
+ console.log(chalk19.yellow(` no longer in the capture, decisions lost: ${droppedWithDecisions.join(", ")}`));
65494
66023
  }
65495
66024
  return 0;
65496
66025
  }
65497
66026
  function planPageCommand(dir, path, opts) {
65498
66027
  const plan = loadPlan(dir);
65499
66028
  if (!plan) {
65500
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
66029
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65501
66030
  return 1;
65502
66031
  }
65503
66032
  const page = pagePlan(plan, path, opts.cand);
65504
66033
  if (!page) {
65505
- console.error(chalk18.red(`No page matching "${path}" in the plan`));
65506
- console.error(chalk18.gray(` known pages: ${plan.pages.map((p) => p.path).join(", ")}`));
66034
+ console.error(chalk19.red(`No page matching "${path}" in the plan`));
66035
+ console.error(chalk19.gray(` known pages: ${plan.pages.map((p) => p.path).join(", ")}`));
65507
66036
  return 1;
65508
66037
  }
65509
66038
  if (opts.json) {
65510
66039
  console.log(JSON.stringify(page, null, 2));
65511
66040
  return 0;
65512
66041
  }
65513
- console.log(chalk18.bold(`
65514
- ${page.path} ${chalk18.gray(`(${page.kind})`)} — ${page.status}`) + (page.ready ? chalk18.green(" ready") : ""));
66042
+ console.log(chalk19.bold(`
66043
+ ${page.path} ${chalk19.gray(`(${page.kind})`)} — ${page.status}`) + (page.ready ? chalk19.green(" ready") : ""));
65515
66044
  if (page.tasks === null) {
65516
- console.log(chalk18.yellow("\n This plan has no page/component edges — it predates them. Re-run `parity migrate` to get per-page work.\n"));
66045
+ console.log(chalk19.yellow("\n This plan has no page/component edges — it predates them. Re-run `parity migrate` to get per-page work.\n"));
65517
66046
  return 0;
65518
66047
  }
65519
66048
  if (page.tasks.length === 0) {
65520
- console.log(chalk18.gray(`
66049
+ console.log(chalk19.gray(`
65521
66050
  The capture saw no components on this page.
65522
66051
  `));
65523
66052
  return 0;
@@ -65528,20 +66057,20 @@ ${page.path} ${chalk18.gray(`(${page.kind})`)} — ${page.status}`) + (page.read
65528
66057
  if (!rows.length)
65529
66058
  continue;
65530
66059
  console.log(`
65531
- ${DISPOSITION_STYLE[d](chalk18.bold(d))} (${rows.length})`);
66060
+ ${DISPOSITION_STYLE[d](chalk19.bold(d))} (${rows.length})`);
65532
66061
  for (const t of rows) {
65533
- console.log(` ${t.name} ${chalk18.gray(`(${t.scope}, ${t.origin}, ${t.status})`)}`);
66062
+ console.log(` ${t.name} ${chalk19.gray(`(${t.scope}, ${t.origin}, ${t.status})`)}`);
65534
66063
  if (t.note)
65535
- console.log(chalk18.gray(` why: ${t.note}`));
66064
+ console.log(chalk19.gray(` why: ${t.note}`));
65536
66065
  if (t.against?.kind === "reference") {
65537
- console.log(chalk18.cyan(` reference: ${t.against.url}`));
66066
+ console.log(chalk19.cyan(` reference: ${t.against.url}`));
65538
66067
  }
65539
66068
  if (t.command)
65540
- console.log(chalk18.gray(` $ ${t.command}`));
66069
+ console.log(chalk19.gray(` $ ${t.command}`));
65541
66070
  }
65542
66071
  }
65543
66072
  if (page.counts.validate > 0 && !opts.cand) {
65544
- console.log(chalk18.yellow("\n Pass --cand <url> to get runnable `parity section` commands."));
66073
+ console.log(chalk19.yellow("\n Pass --cand <url> to get runnable `parity section` commands."));
65545
66074
  }
65546
66075
  console.log("");
65547
66076
  return 0;
@@ -65549,8 +66078,8 @@ ${DISPOSITION_STYLE[d](chalk18.bold(d))} (${rows.length})`);
65549
66078
  function planStatusCommand(dir, asJson) {
65550
66079
  const plan = loadPlan(dir);
65551
66080
  if (!plan) {
65552
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65553
- console.error(chalk18.yellow("Run `parity migrate --url <prod>` first — without a plan there is no inventory."));
66081
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
66082
+ console.error(chalk19.yellow("Run `parity migrate --url <prod>` first — without a plan there is no inventory."));
65554
66083
  return 1;
65555
66084
  }
65556
66085
  const p = planProgress(plan);
@@ -65559,49 +66088,49 @@ function planStatusCommand(dir, asJson) {
65559
66088
  return 0;
65560
66089
  }
65561
66090
  const c = p.components;
65562
- console.log(chalk18.bold(`
66091
+ console.log(chalk19.bold(`
65563
66092
  Migration plan — ${plan.url}${plan.target.name ? ` → ${plan.target.name}` : ""}`));
65564
66093
  console.log(`
65565
- ${chalk18.bold("Components")} (${c.total}): ` + `${chalk18.green(`${c.byStatus.done} done`)}, ` + `${chalk18.yellow(`${c.byStatus.partial} partial`)}, ` + `${chalk18.red(`${c.byStatus.pending} pending`)}, ` + `${chalk18.cyan(`${c.byStatus.upgrade} upgrade`)}, ` + `${chalk18.gray(`${c.byStatus["as-is"]} as-is`)}, ` + `${chalk18.gray(`${c.byStatus.skipped} skipped`)}`);
66094
+ ${chalk19.bold("Components")} (${c.total}): ` + `${chalk19.green(`${c.byStatus.done} done`)}, ` + `${chalk19.yellow(`${c.byStatus.partial} partial`)}, ` + `${chalk19.red(`${c.byStatus.pending} pending`)}, ` + `${chalk19.cyan(`${c.byStatus.upgrade} upgrade`)}, ` + `${chalk19.gray(`${c.byStatus["as-is"]} as-is`)}, ` + `${chalk19.gray(`${c.byStatus.skipped} skipped`)}`);
65566
66095
  if (c.accepted.upgrade.length) {
65567
- console.log(chalk18.cyan(` deliberately ahead of prod: ${c.accepted.upgrade.join(", ")}`));
66096
+ console.log(chalk19.cyan(` deliberately ahead of prod: ${c.accepted.upgrade.join(", ")}`));
65568
66097
  }
65569
66098
  if (c.accepted.asIs.length) {
65570
- console.log(chalk18.gray(` divergence accepted: ${c.accepted.asIs.join(", ")}`));
66099
+ console.log(chalk19.gray(` divergence accepted: ${c.accepted.asIs.join(", ")}`));
65571
66100
  }
65572
66101
  if (c.settled.length) {
65573
- console.log(chalk18.gray(` no work needed: ${c.settled.join(", ")}`));
66102
+ console.log(chalk19.gray(` no work needed: ${c.settled.join(", ")}`));
65574
66103
  }
65575
66104
  for (const r of c.remaining) {
65576
- const tag = r.status === "partial" ? chalk18.yellow("partial") : chalk18.red("pending");
65577
- console.log(` ${tag} ${r.name} ${chalk18.gray(`(${r.scope}, ${r.origin})`)}`);
66105
+ const tag = r.status === "partial" ? chalk19.yellow("partial") : chalk19.red("pending");
66106
+ console.log(` ${tag} ${r.name} ${chalk19.gray(`(${r.scope}, ${r.origin})`)}`);
65578
66107
  }
65579
66108
  const pg = p.pages;
65580
66109
  console.log(`
65581
- ${chalk18.bold("Pages")} (${pg.total}): ` + `${chalk18.green(`${pg.byStatus.done} done`)}, ` + `${chalk18.yellow(`${pg.byStatus.code} code-only`)}, ` + `${chalk18.red(`${pg.byStatus.pending} pending`)}, ` + `${chalk18.gray(`${pg.byStatus.skipped} skipped`)}`);
66110
+ ${chalk19.bold("Pages")} (${pg.total}): ` + `${chalk19.green(`${pg.byStatus.done} done`)}, ` + `${chalk19.yellow(`${pg.byStatus.code} code-only`)}, ` + `${chalk19.red(`${pg.byStatus.pending} pending`)}, ` + `${chalk19.gray(`${pg.byStatus.skipped} skipped`)}`);
65582
66111
  if (pg.awaitingContent.length) {
65583
- console.log(chalk18.yellow(` awaiting CMS content: ${pg.awaitingContent.join(", ")}`));
66112
+ console.log(chalk19.yellow(` awaiting CMS content: ${pg.awaitingContent.join(", ")}`));
65584
66113
  }
65585
66114
  for (const r of pg.remaining.filter((r2) => r2.status === "pending")) {
65586
- console.log(` ${chalk18.red("pending")} ${r.path} ${chalk18.gray(`(${r.kind})`)}`);
66115
+ console.log(` ${chalk19.red("pending")} ${r.path} ${chalk19.gray(`(${r.kind})`)}`);
65587
66116
  }
65588
66117
  console.log("");
65589
66118
  return 0;
65590
66119
  }
65591
66120
  var COLUMN_ORDER = ["triage", "backlog", "building", "review", "done"];
65592
66121
  var COLUMN_STYLE = {
65593
- triage: chalk18.magenta,
65594
- backlog: chalk18.red,
65595
- building: chalk18.yellow,
65596
- review: chalk18.cyan,
65597
- done: chalk18.green,
65598
- skipped: chalk18.gray
66122
+ triage: chalk19.magenta,
66123
+ backlog: chalk19.red,
66124
+ building: chalk19.yellow,
66125
+ review: chalk19.cyan,
66126
+ done: chalk19.green,
66127
+ skipped: chalk19.gray
65599
66128
  };
65600
66129
  async function planBoardCommand(dir, opts) {
65601
66130
  const plan = loadPlan(dir);
65602
66131
  if (!plan) {
65603
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
65604
- console.error(chalk18.yellow("Run `parity migrate --url <prod>` first — no plan, no board."));
66132
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
66133
+ console.error(chalk19.yellow("Run `parity migrate --url <prod>` first — no plan, no board."));
65605
66134
  return 1;
65606
66135
  }
65607
66136
  const board = planBoard(plan, opts.cand);
@@ -65609,46 +66138,46 @@ async function planBoardCommand(dir, opts) {
65609
66138
  console.log(JSON.stringify(board, null, 2));
65610
66139
  return 0;
65611
66140
  }
65612
- console.log(chalk18.bold(`
66141
+ console.log(chalk19.bold(`
65613
66142
  Board — ${board.url}`));
65614
- console.log(chalk18.gray(`${board.sampled} sampled page(s) — the capture's sample, not every URL on the site.`));
66143
+ console.log(chalk19.gray(`${board.sampled} sampled page(s) — the capture's sample, not every URL on the site.`));
65615
66144
  if (board.shell.length) {
65616
66145
  console.log(`
65617
- ${chalk18.bold("shell")} ${chalk18.gray("(global — blocks every page)")}: ${chalk18.yellow(board.shell.join(", "))}`);
66146
+ ${chalk19.bold("shell")} ${chalk19.gray("(global — blocks every page)")}: ${chalk19.yellow(board.shell.join(", "))}`);
65618
66147
  }
65619
66148
  for (const column of COLUMN_ORDER) {
65620
66149
  const cards = board.columns[column];
65621
66150
  if (!cards.length)
65622
66151
  continue;
65623
66152
  console.log(`
65624
- ${COLUMN_STYLE[column](chalk18.bold(column))} (${cards.length})`);
66153
+ ${COLUMN_STYLE[column](chalk19.bold(column))} (${cards.length})`);
65625
66154
  for (const card of cards) {
65626
- console.log(` ${card.path} ${chalk18.gray(`(${card.kind})`)}`);
66155
+ console.log(` ${card.path} ${chalk19.gray(`(${card.kind})`)}`);
65627
66156
  if (card.blockers.length) {
65628
- console.log(chalk18.gray(` blocked by: ${card.blockers.join(", ")}`));
66157
+ console.log(chalk19.gray(` blocked by: ${card.blockers.join(", ")}`));
65629
66158
  }
65630
66159
  }
65631
66160
  }
65632
66161
  const skipped = board.columns.skipped;
65633
66162
  if (skipped.length) {
65634
66163
  console.log(`
65635
- ${chalk18.gray(`skipped (${skipped.length}): ${skipped.map((c) => c.path).join(", ")}`)}`);
66164
+ ${chalk19.gray(`skipped (${skipped.length}): ${skipped.map((c) => c.path).join(", ")}`)}`);
65636
66165
  }
65637
66166
  if (board.unassigned.length) {
65638
66167
  console.log(`
65639
- ${chalk18.bold("no page")} ${chalk18.gray("(in the code, not seen on any sampled page)")}
65640
- ${chalk18.gray(board.unassigned.join(", "))}`);
66168
+ ${chalk19.bold("no page")} ${chalk19.gray("(in the code, not seen on any sampled page)")}
66169
+ ${chalk19.gray(board.unassigned.join(", "))}`);
65641
66170
  }
65642
66171
  console.log("");
65643
66172
  if (opts.board === "studio") {
65644
66173
  const cfg = studioConfigFromEnv();
65645
66174
  if (!cfg) {
65646
- console.log(chalk18.yellow(`Studio board skipped — set PARITY_STUDIO_URL and PARITY_STUDIO_TOKEN. Showing the terminal board instead.
66175
+ console.log(chalk19.yellow(`Studio board skipped — set PARITY_STUDIO_URL and PARITY_STUDIO_TOKEN. Showing the terminal board instead.
65647
66176
  `));
65648
66177
  return 0;
65649
66178
  }
65650
66179
  try {
65651
- const fixes = opts.fixes ? JSON.parse(readFileSync21(opts.fixes, "utf8")) : undefined;
66180
+ const fixes = opts.fixes ? JSON.parse(readFileSync25(opts.fixes, "utf8")) : undefined;
65652
66181
  const synced = await syncBoardToStudio(board, cfg, { repo: opts.repo, fixes });
65653
66182
  let stored = 0;
65654
66183
  for (const [path, id] of Object.entries(synced.ids)) {
@@ -65657,10 +66186,10 @@ ${chalk18.bold("no page")} ${chalk18.gray("(in the code, not seen on any sampled
65657
66186
  }
65658
66187
  if (stored)
65659
66188
  savePlan(dir, plan);
65660
- console.log(chalk18.green(`Studio board synced — ${synced.created} created, ${synced.updated} updated, ${synced.skipped} skipped.
66189
+ console.log(chalk19.green(`Studio board synced — ${synced.created} created, ${synced.updated} updated, ${synced.skipped} skipped.
65661
66190
  `));
65662
66191
  } catch (err) {
65663
- console.log(chalk18.yellow(`Studio board unavailable (${err instanceof Error ? err.message : String(err)}). Showing the terminal board instead.
66192
+ console.log(chalk19.yellow(`Studio board unavailable (${err instanceof Error ? err.message : String(err)}). Showing the terminal board instead.
65664
66193
  `));
65665
66194
  }
65666
66195
  }
@@ -65669,27 +66198,27 @@ ${chalk18.bold("no page")} ${chalk18.gray("(in the code, not seen on any sampled
65669
66198
  async function planNotesCommand(dir, opts) {
65670
66199
  const plan = loadPlan(dir);
65671
66200
  if (!plan) {
65672
- console.error(chalk18.red(`No migration-plan.json found in ${dir}`));
66201
+ console.error(chalk19.red(`No migration-plan.json found in ${dir}`));
65673
66202
  return 1;
65674
66203
  }
65675
66204
  const cfg = studioConfigFromEnv();
65676
66205
  if (!cfg) {
65677
- console.error(chalk18.yellow("Studio not configured — set PARITY_STUDIO_URL and PARITY_STUDIO_TOKEN."));
66206
+ console.error(chalk19.yellow("Studio not configured — set PARITY_STUDIO_URL and PARITY_STUDIO_TOKEN."));
65678
66207
  return 1;
65679
66208
  }
65680
66209
  if (opts.post) {
65681
66210
  const page = plan.pages.find((p) => p.path === opts.page);
65682
66211
  if (!page?.boardItemId) {
65683
- console.error(chalk18.red(`No synced card for page "${opts.page}" — run \`parity plan board --board studio\` first`));
66212
+ console.error(chalk19.red(`No synced card for page "${opts.page}" — run \`parity plan board --board studio\` first`));
65684
66213
  return 1;
65685
66214
  }
65686
66215
  await postParityComment(page.boardItemId, opts.post, cfg);
65687
- console.log(`${chalk18.green("✓")} comment posted on ${page.path}`);
66216
+ console.log(`${chalk19.green("✓")} comment posted on ${page.path}`);
65688
66217
  return 0;
65689
66218
  }
65690
66219
  const pages = plan.pages.filter((p) => p.boardItemId).filter((p) => !opts.page || p.path === opts.page).map((p) => ({ path: p.path, boardItemId: p.boardItemId }));
65691
66220
  if (!pages.length) {
65692
- console.error(chalk18.yellow("No page has a synced card yet — run `parity plan board --board studio` first."));
66221
+ console.error(chalk19.yellow("No page has a synced card yet — run `parity plan board --board studio` first."));
65693
66222
  return 1;
65694
66223
  }
65695
66224
  const notes = await fetchClientNotes(pages, cfg);
@@ -65698,33 +66227,33 @@ async function planNotesCommand(dir, opts) {
65698
66227
  return 0;
65699
66228
  }
65700
66229
  if (!notes.length) {
65701
- console.log(chalk18.gray(`
66230
+ console.log(chalk19.gray(`
65702
66231
  No open client notes.
65703
66232
  `));
65704
66233
  return 0;
65705
66234
  }
65706
- console.log(chalk18.bold(`
66235
+ console.log(chalk19.bold(`
65707
66236
  Client notes (${notes.length})`));
65708
66237
  for (const n of notes) {
65709
66238
  console.log(`
65710
- ${chalk18.cyan(n.path)} ${chalk18.gray(n.createdAt)}`);
66239
+ ${chalk19.cyan(n.path)} ${chalk19.gray(n.createdAt)}`);
65711
66240
  for (const line of n.body.split(`
65712
66241
  `))
65713
66242
  console.log(` ${line}`);
65714
66243
  }
65715
- console.log(chalk18.gray('\nThese are PROPOSALS. Apply with `parity plan set-reference` / `set-status`, then confirm with `parity plan notes --page <path> --post "<what you did>"`.\n'));
66244
+ console.log(chalk19.gray('\nThese are PROPOSALS. Apply with `parity plan set-reference` / `set-status`, then confirm with `parity plan notes --page <path> --post "<what you did>"`.\n'));
65716
66245
  return 0;
65717
66246
  }
65718
66247
 
65719
66248
  // src/commands/pr.ts
65720
- import { existsSync as existsSync19, readFileSync as readFileSync24, writeFileSync as writeFileSync25 } from "node:fs";
65721
- import { join as join30 } from "node:path";
65722
- import chalk21 from "chalk";
66249
+ import { existsSync as existsSync22, readFileSync as readFileSync28, writeFileSync as writeFileSync26 } from "node:fs";
66250
+ import { join as join34 } from "node:path";
66251
+ import chalk22 from "chalk";
65723
66252
 
65724
66253
  // src/commands/run.ts
65725
- import { existsSync as existsSync18, readFileSync as readFileSync23, unlinkSync as unlinkSync3 } from "node:fs";
65726
- import { join as join29 } from "node:path";
65727
- import chalk20 from "chalk";
66254
+ import { existsSync as existsSync21, readFileSync as readFileSync27, unlinkSync as unlinkSync3 } from "node:fs";
66255
+ import { join as join33 } from "node:path";
66256
+ import chalk21 from "chalk";
65728
66257
  import ora7 from "ora";
65729
66258
 
65730
66259
  // src/engine/interactive-module-prompt.ts
@@ -66261,13 +66790,13 @@ function formatMs(ms) {
66261
66790
  }
66262
66791
 
66263
66792
  // src/commands/serve.ts
66264
- import { existsSync as existsSync17 } from "node:fs";
66265
- import chalk19 from "chalk";
66793
+ import { existsSync as existsSync20 } from "node:fs";
66794
+ import chalk20 from "chalk";
66266
66795
 
66267
66796
  // src/server/proxy-server.ts
66268
- import { existsSync as existsSync16, readFileSync as readFileSync22, statSync } from "node:fs";
66797
+ import { existsSync as existsSync19, readFileSync as readFileSync26, statSync } from "node:fs";
66269
66798
  import { createServer } from "node:http";
66270
- import { extname, join as join28, normalize as normalize3, resolve as resolve6, sep } from "node:path";
66799
+ import { extname, join as join32, normalize as normalize3, resolve as resolve6, sep } from "node:path";
66271
66800
  var MIME3 = {
66272
66801
  ".html": "text/html; charset=utf-8",
66273
66802
  ".css": "text/css; charset=utf-8",
@@ -66304,7 +66833,7 @@ var STRIPPED_REQUEST_HEADERS = new Set([
66304
66833
  ]);
66305
66834
  async function startProxyServer(runDir, opts = {}) {
66306
66835
  const absRunDir = resolve6(runDir);
66307
- if (!existsSync16(absRunDir)) {
66836
+ if (!existsSync19(absRunDir)) {
66308
66837
  throw new Error(`Run directory not found: ${runDir}`);
66309
66838
  }
66310
66839
  const server = createServer((req, res) => {
@@ -66361,13 +66890,13 @@ async function handleRequest(req, res, runDir) {
66361
66890
  return serveStatic(res, runDir, path);
66362
66891
  }
66363
66892
  function serveReportHtml(res, runDir) {
66364
- const filePath = join28(runDir, "report.html");
66365
- if (!existsSync16(filePath)) {
66893
+ const filePath = join32(runDir, "report.html");
66894
+ if (!existsSync19(filePath)) {
66366
66895
  res.statusCode = 404;
66367
66896
  res.end("report.html not found");
66368
66897
  return;
66369
66898
  }
66370
- const html3 = readFileSync22(filePath, "utf8");
66899
+ const html3 = readFileSync26(filePath, "utf8");
66371
66900
  const inject = `<script>window.__parity_proxy = "/proxy?url=";</script>`;
66372
66901
  const out = html3.includes("</head>") ? html3.replace("</head>", `${inject}</head>`) : `${inject}${html3}`;
66373
66902
  res.statusCode = 200;
@@ -66383,7 +66912,7 @@ function serveStatic(res, runDir, path) {
66383
66912
  res.end("forbidden");
66384
66913
  return;
66385
66914
  }
66386
- if (!existsSync16(filePath)) {
66915
+ if (!existsSync19(filePath)) {
66387
66916
  res.statusCode = 404;
66388
66917
  res.end("not found");
66389
66918
  return;
@@ -66398,7 +66927,7 @@ function serveStatic(res, runDir, path) {
66398
66927
  res.statusCode = 200;
66399
66928
  res.setHeader("content-type", MIME3[ext] ?? "application/octet-stream");
66400
66929
  res.setHeader("cache-control", "no-store");
66401
- res.end(readFileSync22(filePath));
66930
+ res.end(readFileSync26(filePath));
66402
66931
  }
66403
66932
  async function proxyRequest(req, res, targetUrl, opts = {}) {
66404
66933
  let target;
@@ -66496,16 +67025,16 @@ async function serveRunAndBlock(runDir, opts = {}) {
66496
67025
  try {
66497
67026
  handle = await startProxyServer(runDir, { port: opts.port });
66498
67027
  } catch (err) {
66499
- console.error(chalk19.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
67028
+ console.error(chalk20.red(` ✖ Falha ao iniciar servidor: ${err.message}`));
66500
67029
  return 2;
66501
67030
  }
66502
67031
  const label = opts.label ?? "parity serve";
66503
67032
  console.log("");
66504
- console.log(chalk19.bold(` ${label}`));
66505
- console.log(` ${chalk19.green("●")} ${handle.url}`);
66506
- console.log(chalk19.dim(` Servindo: ${runDir}`));
66507
- console.log(chalk19.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
66508
- console.log(chalk19.dim(` Ctrl+C pra parar (2x pra forçar saída).
67033
+ console.log(chalk20.bold(` ${label}`));
67034
+ console.log(` ${chalk20.green("●")} ${handle.url}`);
67035
+ console.log(chalk20.dim(` Servindo: ${runDir}`));
67036
+ console.log(chalk20.dim(` Proxy de iframes: ${handle.url}proxy?url=<encoded>`));
67037
+ console.log(chalk20.dim(` Ctrl+C pra parar (2x pra forçar saída).
66509
67038
  `));
66510
67039
  if (opts.open !== false) {
66511
67040
  const { default: open2 } = await import("open");
@@ -66537,12 +67066,12 @@ async function serveRunAndBlock(runDir, opts = {}) {
66537
67066
  }
66538
67067
  async function serveCommand(runId, opts) {
66539
67068
  const paths = getRunPaths(opts.output, runId);
66540
- if (!existsSync17(paths.runDir)) {
66541
- console.error(chalk19.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
67069
+ if (!existsSync20(paths.runDir)) {
67070
+ console.error(chalk20.red(`✖ Run não encontrado: ${runId} (em ${opts.output})`));
66542
67071
  return 1;
66543
67072
  }
66544
- if (!existsSync17(paths.reportHtml)) {
66545
- console.error(chalk19.red(`✖ report.html não existe em ${paths.runDir}`));
67073
+ if (!existsSync20(paths.reportHtml)) {
67074
+ console.error(chalk20.red(`✖ report.html não existe em ${paths.runDir}`));
66546
67075
  return 1;
66547
67076
  }
66548
67077
  return serveRunAndBlock(paths.runDir, {
@@ -66679,14 +67208,14 @@ function evaluateFailOnGate(allIssues, failOn) {
66679
67208
  async function runCommand(rawOpts) {
66680
67209
  if (!rawOpts.prod) {
66681
67210
  const target = rawOpts.cand ?? "<url>";
66682
- console.error(`${chalk20.yellow("Single-site run?")} \`parity run\` compares two URLs (prod↔cand).
66683
- For one site, use: ${chalk20.cyan(`parity e2e --url ${target}`)}
67211
+ console.error(`${chalk21.yellow("Single-site run?")} \`parity run\` compares two URLs (prod↔cand).
67212
+ For one site, use: ${chalk21.cyan(`parity e2e --url ${target}`)}
66684
67213
  (runs the functional flows + all checks in single-site mode — no prod baseline needed).`);
66685
67214
  return 2;
66686
67215
  }
66687
67216
  let opts = applyPreset(rawOpts);
66688
67217
  if (rawOpts.preset) {
66689
- console.log(chalk20.dim(` preset: ${rawOpts.preset}`));
67218
+ console.log(chalk21.dim(` preset: ${rawOpts.preset}`));
66690
67219
  }
66691
67220
  if (opts.pt)
66692
67221
  setLlmLanguage("pt");
@@ -66694,14 +67223,14 @@ async function runCommand(rawOpts) {
66694
67223
  disableInteractive();
66695
67224
  const llmCfgErr = applyLlmOptions(opts);
66696
67225
  if (llmCfgErr) {
66697
- console.error(chalk20.red(` ${llmCfgErr}`));
67226
+ console.error(chalk21.red(` ${llmCfgErr}`));
66698
67227
  return 2;
66699
67228
  }
66700
67229
  const llmStillAvailable = isLlmAvailable();
66701
67230
  const preSmart = opts;
66702
67231
  opts = applySmartDefaults(opts, llmStillAvailable);
66703
67232
  if (!llmStillAvailable && opts.visualPages !== preSmart.visualPages) {
66704
- console.log(chalk20.dim(" visual-pages auto-set to 0 (no LLM available — analysis layer would be skipped; opt in with --visual-pages N)"));
67233
+ console.log(chalk21.dim(" visual-pages auto-set to 0 (no LLM available — analysis layer would be skipped; opt in with --visual-pages N)"));
66705
67234
  }
66706
67235
  let interactivePromptShown = false;
66707
67236
  if (!opts.only && !opts.skip && !rawOpts.preset) {
@@ -66725,14 +67254,14 @@ async function runCommand(rawOpts) {
66725
67254
  const isContentProfile = profile === "content";
66726
67255
  if (isContentProfile && !opts.only && !opts.skip) {
66727
67256
  opts.only = "seo,visual,vitals,cache,console,html,network";
66728
- console.log(chalk20.dim(" profile: content → skipping e2e module (commerce purchase-journey/cart make no sense on a content site); pass --profile commerce to force"));
67257
+ console.log(chalk21.dim(" profile: content → skipping e2e module (commerce purchase-journey/cart make no sense on a content site); pass --profile commerce to force"));
66729
67258
  }
66730
67259
  const selection = resolveSelection({ only: opts.only, skip: opts.skip });
66731
67260
  if (selection.errors.length > 0) {
66732
- console.error(chalk20.red(" --only/--skip: invalid value(s):"));
67261
+ console.error(chalk21.red(" --only/--skip: invalid value(s):"));
66733
67262
  for (const e of selection.errors)
66734
- console.error(chalk20.red(` - ${e}`));
66735
- console.error(chalk20.dim(`
67263
+ console.error(chalk21.red(` - ${e}`));
67264
+ console.error(chalk21.dim(`
66736
67265
  valid modules: ${Object.keys(MODULES).join(", ")}`));
66737
67266
  return 2;
66738
67267
  }
@@ -66743,11 +67272,11 @@ async function runCommand(rawOpts) {
66743
67272
  if (hasSelection) {
66744
67273
  const explicitFlows = userSetFlows ? opts.flows.split(",").map((s) => s.trim()).filter(Boolean) : [];
66745
67274
  flows2 = Array.from(new Set([...explicitFlows, ...selection.flows]));
66746
- console.log(chalk20.dim(` modules: ${selection.modules.join(", ") || "(none)"} → flows: ${flows2.join(",")}`));
67275
+ console.log(chalk21.dim(` modules: ${selection.modules.join(", ") || "(none)"} → flows: ${flows2.join(",")}`));
66747
67276
  } else {
66748
67277
  flows2 = opts.flows.split(",").map((s) => s.trim());
66749
67278
  if (!interactivePromptShown) {
66750
- console.log(chalk20.dim(" no --only/--skip given — running ALL modules; pass --only to scope the run for a lighter/faster result"));
67279
+ console.log(chalk21.dim(" no --only/--skip given — running ALL modules; pass --only to scope the run for a lighter/faster result"));
66751
67280
  }
66752
67281
  }
66753
67282
  if (isContentProfile) {
@@ -66756,12 +67285,12 @@ async function runCommand(rawOpts) {
66756
67285
  if (!flows2.includes("homepage"))
66757
67286
  flows2.unshift("homepage");
66758
67287
  if (before2 !== flows2.join(",")) {
66759
- console.log(chalk20.dim(` profile: content → flows scoped to ${flows2.join(",")} (dropped plp/pdp; was: ${before2}); CEP skipped`));
67288
+ console.log(chalk21.dim(` profile: content → flows scoped to ${flows2.join(",")} (dropped plp/pdp; was: ${before2}); CEP skipped`));
66760
67289
  }
66761
67290
  }
66762
67291
  const pagesScopeWarning = pagesFlowsScopeWarning(opts, flows2);
66763
67292
  if (pagesScopeWarning) {
66764
- console.log(chalk20.dim(` ${pagesScopeWarning}`));
67293
+ console.log(chalk21.dim(` ${pagesScopeWarning}`));
66765
67294
  }
66766
67295
  if (hasSelection) {
66767
67296
  const needsSitemapPages = selection.modules.some((m) => MODULES[m].needsSitemapPages);
@@ -66770,12 +67299,12 @@ async function runCommand(rawOpts) {
66770
67299
  const VISUAL_PAGES_DEFAULT = 5;
66771
67300
  if (!needsSitemapPages && opts.vitalsPages === VITALS_PAGES_DEFAULT) {
66772
67301
  opts.vitalsPages = 0;
66773
- console.log(chalk20.dim(" vitals-pages auto-set to 0 (no selected module needs sitemap-page crawling)"));
67302
+ console.log(chalk21.dim(" vitals-pages auto-set to 0 (no selected module needs sitemap-page crawling)"));
66774
67303
  }
66775
67304
  if (!needsLlmPass && opts.visualPages === VISUAL_PAGES_DEFAULT) {
66776
67305
  opts.visualPages = 0;
66777
67306
  opts.noVisualDiff = true;
66778
- console.log(chalk20.dim(" visual-pages auto-set to 0 (no selected module needs the visual-diff pass)"));
67307
+ console.log(chalk21.dim(" visual-pages auto-set to 0 (no selected module needs the visual-diff pass)"));
66779
67308
  }
66780
67309
  }
66781
67310
  const viewports = opts.viewports.split(",").map((s) => s.trim());
@@ -66788,38 +67317,38 @@ async function runCommand(rawOpts) {
66788
67317
  }
66789
67318
  const ignore = loadParityIgnore();
66790
67319
  if (opts.clearCache) {
66791
- const cacheFile = join29(opts.output, "cache", "verdicts.json");
66792
- if (existsSync18(cacheFile)) {
67320
+ const cacheFile = join33(opts.output, "cache", "verdicts.json");
67321
+ if (existsSync21(cacheFile)) {
66793
67322
  try {
66794
67323
  unlinkSync3(cacheFile);
66795
- console.log(chalk20.dim(` cache wiped: ${cacheFile}`));
67324
+ console.log(chalk21.dim(` cache wiped: ${cacheFile}`));
66796
67325
  } catch (err) {
66797
- console.log(chalk20.yellow(` cache wipe falhou: ${err.message}`));
67326
+ console.log(chalk21.yellow(` cache wipe falhou: ${err.message}`));
66798
67327
  }
66799
67328
  }
66800
67329
  }
66801
67330
  const llmTimeoutRaw = opts.llmTimeout ?? 60;
66802
67331
  if (!Number.isFinite(llmTimeoutRaw)) {
66803
- console.error(chalk20.red(` --llm-timeout inválido: "${opts.llmTimeout}" não é um número`));
67332
+ console.error(chalk21.red(` --llm-timeout inválido: "${opts.llmTimeout}" não é um número`));
66804
67333
  return 2;
66805
67334
  }
66806
67335
  const llmTimeoutSec = Math.max(5, Math.floor(llmTimeoutRaw));
66807
67336
  if (isLlmAvailable()) {
66808
- console.log(chalk20.dim(` llm: ${providerLabel()} (timeout=${llmTimeoutSec}s)`));
67337
+ console.log(chalk21.dim(` llm: ${providerLabel()} (timeout=${llmTimeoutSec}s)`));
66809
67338
  } else {
66810
- console.log(chalk20.dim(" llm: offline (LLM keys ausentes — agregação heurística)"));
67339
+ console.log(chalk21.dim(" llm: offline (LLM keys ausentes — agregação heurística)"));
66811
67340
  }
66812
67341
  if (isInteractiveMode()) {
66813
- console.log(chalk20.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
67342
+ console.log(chalk21.dim(" interactive: enabled — TTY + no LLM. Missing selectors will pause to prompt (disable with --no-interactive). Issue #72."));
66814
67343
  }
66815
67344
  const primaryViewport = viewports[0] ?? "mobile";
66816
67345
  const preflight = await preflightCheck(opts.prod, opts.cand, primaryViewport);
66817
67346
  if (!preflight.ok) {
66818
- console.error(chalk20.red(`
67347
+ console.error(chalk21.red(`
66819
67348
  ✖ pre-flight falhou:`));
66820
67349
  for (const err of preflight.errors)
66821
- console.error(chalk20.red(` - ${err}`));
66822
- console.error(chalk20.dim(`
67350
+ console.error(chalk21.red(` - ${err}`));
67351
+ console.error(chalk21.dim(`
66823
67352
  dica: verifique se as URLs estão corretas e acessíveis`));
66824
67353
  return 2;
66825
67354
  }
@@ -66830,7 +67359,7 @@ async function runCommand(rawOpts) {
66830
67359
  if (prodHomeHtml) {
66831
67360
  platform = detectPlatform({ url: opts.prod, html: prodHomeHtml });
66832
67361
  if (platform !== "custom") {
66833
- console.log(chalk20.dim(` Detected platform: ${platform}`));
67362
+ console.log(chalk21.dim(` Detected platform: ${platform}`));
66834
67363
  }
66835
67364
  }
66836
67365
  const prodHost = hostOf3(opts.prod);
@@ -66865,11 +67394,11 @@ async function runCommand(rawOpts) {
66865
67394
  viewports,
66866
67395
  timestamp
66867
67396
  });
66868
- console.log(chalk20.bold(`
67397
+ console.log(chalk21.bold(`
66869
67398
  parity run ${runId}`));
66870
- console.log(chalk20.dim(` prod: ${opts.prod}`));
66871
- console.log(chalk20.dim(` cand: ${opts.cand}`));
66872
- console.log(chalk20.dim(` profile: ${profile} · flows: ${flows2.join(", ")} · viewports: ${viewports.join(", ")}${rc.cep ? ` · CEP: ${rc.cep}` : ""}
67399
+ console.log(chalk21.dim(` prod: ${opts.prod}`));
67400
+ console.log(chalk21.dim(` cand: ${opts.cand}`));
67401
+ console.log(chalk21.dim(` profile: ${profile} · flows: ${flows2.join(", ")} · viewports: ${viewports.join(", ")}${rc.cep ? ` · CEP: ${rc.cep}` : ""}
66873
67402
  `));
66874
67403
  const spinner = ora7("Launching browser…").start();
66875
67404
  let browser = null;
@@ -66881,7 +67410,7 @@ async function runCommand(rawOpts) {
66881
67410
  const min = Math.floor(elapsedSec / 60);
66882
67411
  const sec = elapsedSec % 60;
66883
67412
  const mmss = `${min.toString().padStart(2, "0")}:${sec.toString().padStart(2, "0")}`;
66884
- spinner.text = `${chalk20.dim(`⏱ ${mmss} ·`)} ${currentSpinnerLabel}`;
67413
+ spinner.text = `${chalk21.dim(`⏱ ${mmss} ·`)} ${currentSpinnerLabel}`;
66885
67414
  };
66886
67415
  const setSpinnerLabel = (label) => {
66887
67416
  currentSpinnerLabel = label;
@@ -66984,9 +67513,9 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
66984
67513
  }
66985
67514
  const traceEnabled = process.env.PARITY_TRACE === "1";
66986
67515
  const runOneSide = async (viewport, side) => {
66987
- const baseUrl = side === "prod" ? opts.prod : opts.cand;
66988
- const harPath = join29(paths.harDir, `${viewport}-${side}.har`);
66989
- const tracePath = traceEnabled ? join29(paths.tracesDir, `${viewport}-${side}.zip`) : null;
67516
+ const baseUrl2 = side === "prod" ? opts.prod : opts.cand;
67517
+ const harPath = join33(paths.harDir, `${viewport}-${side}.har`);
67518
+ const tracePath = traceEnabled ? join33(paths.tracesDir, `${viewport}-${side}.zip`) : null;
66990
67519
  const ctx = await newContext(browser, {
66991
67520
  viewport,
66992
67521
  harPath,
@@ -67001,11 +67530,11 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67001
67530
  for (const flow of flows2) {
67002
67531
  const flowStart = Date.now();
67003
67532
  let lastStepTotal = 0;
67004
- const sideTag = side === "prod" ? chalk20.cyan("prod") : chalk20.magenta("cand");
67005
- const prefix = `${chalk20.dim(`[${viewport}/`)}${sideTag}${chalk20.dim("]")}`;
67533
+ const sideTag = side === "prod" ? chalk21.cyan("prod") : chalk21.magenta("cand");
67534
+ const prefix = `${chalk21.dim(`[${viewport}/`)}${sideTag}${chalk21.dim("]")}`;
67006
67535
  setSpinnerLabel(`${prefix} ${flow}: starting…`);
67007
67536
  const cap = await runFlow(flow, {
67008
- baseUrl,
67537
+ baseUrl: baseUrl2,
67009
67538
  side,
67010
67539
  viewport,
67011
67540
  rc,
@@ -67019,7 +67548,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67019
67548
  onStep: (event) => {
67020
67549
  if (event.phase === "start") {
67021
67550
  lastStepTotal = event.total;
67022
- setSpinnerLabel(`${prefix} ${flow} ${chalk20.dim(`${event.index}/${event.total}`)} ${event.name}…`);
67551
+ setSpinnerLabel(`${prefix} ${flow} ${chalk21.dim(`${event.index}/${event.total}`)} ${event.name}…`);
67023
67552
  }
67024
67553
  }
67025
67554
  });
@@ -67028,18 +67557,18 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67028
67557
  const target = lastStepTotal || recorded;
67029
67558
  const failed = cap.steps?.find((s) => s.status === "failed");
67030
67559
  const lastStep = cap.steps?.[cap.steps.length - 1];
67031
- const elapsedDim = chalk20.dim(`${((Date.now() - flowStart) / 1000).toFixed(1)}s`);
67032
- const counts = target > 0 ? chalk20.dim(`${okSteps}/${target}`) : "";
67560
+ const elapsedDim = chalk21.dim(`${((Date.now() - flowStart) / 1000).toFixed(1)}s`);
67561
+ const counts = target > 0 ? chalk21.dim(`${okSteps}/${target}`) : "";
67033
67562
  let glyph;
67034
67563
  let detail;
67035
67564
  if (failed) {
67036
- glyph = chalk20.red("✗");
67037
- detail = `stopped at ${chalk20.yellow(failed.name)}`;
67565
+ glyph = chalk21.red("✗");
67566
+ detail = `stopped at ${chalk21.yellow(failed.name)}`;
67038
67567
  } else if (target > 0 && okSteps < target) {
67039
- glyph = chalk20.yellow("▴");
67040
- detail = lastStep ? `ended at ${chalk20.dim(lastStep.name)}` : "incomplete";
67568
+ glyph = chalk21.yellow("▴");
67569
+ detail = lastStep ? `ended at ${chalk21.dim(lastStep.name)}` : "incomplete";
67041
67570
  } else {
67042
- glyph = chalk20.green("✓");
67571
+ glyph = chalk21.green("✓");
67043
67572
  detail = "";
67044
67573
  }
67045
67574
  const summary = `${glyph} ${prefix} ${flow} ${counts} ${detail} ${elapsedDim}`.replace(/\s+/g, " ").trim();
@@ -67101,7 +67630,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67101
67630
  const vitalsPagesLimit = opts.vitalsPages ?? vitalsPagesDefault;
67102
67631
  const vitalsRuns = Math.max(1, Number.parseInt(opts.runs, 10) || 1);
67103
67632
  if (candIsDevServer && vitalsPagesLimit > 0) {
67104
- console.log(chalk20.dim(` cand=localhost detectado — vitals-pages=${vitalsPagesLimit}, networkidle desabilitado (issue #55)`));
67633
+ console.log(chalk21.dim(` cand=localhost detectado — vitals-pages=${vitalsPagesLimit}, networkidle desabilitado (issue #55)`));
67105
67634
  }
67106
67635
  if (browser && vitalsPagesLimit > 0) {
67107
67636
  currentPhase = "vitals-pages";
@@ -67155,9 +67684,9 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67155
67684
  }
67156
67685
  let done = 0;
67157
67686
  await runWithConcurrency2(tasks, 4, async (task) => {
67158
- const baseUrl = task.side === "prod" ? opts.prod : opts.cand;
67159
- const fullUrl = new URL(task.path, baseUrl).toString();
67160
- const targetIsDevServer = isLocalhost(baseUrl);
67687
+ const baseUrl2 = task.side === "prod" ? opts.prod : opts.cand;
67688
+ const fullUrl = new URL(task.path, baseUrl2).toString();
67689
+ const targetIsDevServer = isLocalhost(baseUrl2);
67161
67690
  const PER_TASK_WALLCLOCK_MS = 35000 + Math.max(0, vitalsRuns - 1) * 8000;
67162
67691
  try {
67163
67692
  const ctx = await newContext(browser, {
@@ -67256,8 +67785,8 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67256
67785
  visualSpinner.text = `Visual diff: capturando ${tasks.length} screenshot(s) (${visualPaths.length} páginas × ${viewports.length} viewport(s) × 2 sides)…`;
67257
67786
  let done = 0;
67258
67787
  await runWithConcurrency2(tasks, 4, async (task) => {
67259
- const baseUrl = task.side === "prod" ? opts.prod : opts.cand;
67260
- const fullUrl = new URL(task.path, baseUrl).toString();
67788
+ const baseUrl2 = task.side === "prod" ? opts.prod : opts.cand;
67789
+ const fullUrl = new URL(task.path, baseUrl2).toString();
67261
67790
  const safePath3 = task.path.replace(/[/?&=]+/g, "_") || "_root";
67262
67791
  const screenshotPath2 = `${paths.screenshotsDir}/visual-${safePath3}-${task.viewport}-${task.side}.png`;
67263
67792
  try {
@@ -67308,7 +67837,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67308
67837
  setSpinnerLabel("Rodando checks…");
67309
67838
  spinner.start();
67310
67839
  const checksHb = attachSpinnerHeartbeat(spinner, { baseText: "Rodando checks…" });
67311
- const cacheDir = join29(opts.output, "cache");
67840
+ const cacheDir = join33(opts.output, "cache");
67312
67841
  const checkCtx = {
67313
67842
  prodPages: allPageCaptures.filter((p) => p.side === "prod"),
67314
67843
  candPages: allPageCaptures.filter((p) => p.side === "cand"),
@@ -67438,7 +67967,7 @@ ${formatTimingsSummary(partialTimings, buildFlowBreakdown(allFlowCaptures))}
67438
67967
  ${formatTimingsSummary(runTimings, buildFlowBreakdown(allFlowCaptures))}`);
67439
67968
  const failOnGate = evaluateFailOnGate(allIssues, failOn);
67440
67969
  if (failOnGate.exitCode === 1) {
67441
- console.log(chalk20.red(failOnGate.message));
67970
+ console.log(chalk21.red(failOnGate.message));
67442
67971
  return 1;
67443
67972
  }
67444
67973
  if (opts.open) {
@@ -67508,10 +68037,10 @@ function parsePagePair(entry) {
67508
68037
  }
67509
68038
  function resolveExplicitPages(pagesFile, pagesList) {
67510
68039
  if (pagesFile) {
67511
- if (!existsSync18(pagesFile)) {
68040
+ if (!existsSync21(pagesFile)) {
67512
68041
  throw new Error(`--pages-file não encontrado: ${pagesFile}`);
67513
68042
  }
67514
- const raw = readFileSync23(pagesFile, "utf-8");
68043
+ const raw = readFileSync27(pagesFile, "utf-8");
67515
68044
  const lines = raw.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
67516
68045
  return lines.map(parsePagePair);
67517
68046
  }
@@ -67662,48 +68191,48 @@ function hostOf3(url) {
67662
68191
  }
67663
68192
  function printSummary6(run, htmlPath, meta) {
67664
68193
  const { verdict: verdict2 } = run;
67665
- const emoji = verdict2.status === "pass" ? chalk20.green("✔") : verdict2.status === "warn" ? chalk20.yellow("⚠") : chalk20.red("✖");
67666
- const score = verdict2.status === "pass" ? chalk20.green(verdict2.score) : verdict2.status === "warn" ? chalk20.yellow(verdict2.score) : chalk20.red(verdict2.score);
68194
+ const emoji = verdict2.status === "pass" ? chalk21.green("✔") : verdict2.status === "warn" ? chalk21.yellow("⚠") : chalk21.red("✖");
68195
+ const score = verdict2.status === "pass" ? chalk21.green(verdict2.score) : verdict2.status === "warn" ? chalk21.yellow(verdict2.score) : chalk21.red(verdict2.score);
67667
68196
  const prev2 = run.previousRun;
67668
- const scoreDelta = !prev2 ? chalk20.dim(" (sem run anterior comparável)") : prev2.scoreDelta > 0 ? chalk20.green(` (+${prev2.scoreDelta} vs run anterior: ${prev2.score})`) : prev2.scoreDelta < 0 ? chalk20.red(` (${prev2.scoreDelta} vs run anterior: ${prev2.score})`) : chalk20.dim(` (= run anterior: ${prev2.score})`);
68197
+ const scoreDelta = !prev2 ? chalk21.dim(" (sem run anterior comparável)") : prev2.scoreDelta > 0 ? chalk21.green(` (+${prev2.scoreDelta} vs run anterior: ${prev2.score})`) : prev2.scoreDelta < 0 ? chalk21.red(` (${prev2.scoreDelta} vs run anterior: ${prev2.score})`) : chalk21.dim(` (= run anterior: ${prev2.score})`);
67669
68198
  console.log("");
67670
68199
  console.log(` ${emoji} parity ${verdict2.status.toUpperCase()} · score ${score}/100${scoreDelta}`);
67671
- console.log(` checks: ${chalk20.green(verdict2.checksPassed)} pass · ${chalk20.red(verdict2.checksFailed)} fail · ${chalk20.dim(`${verdict2.checksSkipped} skipped`)}`);
67672
- console.log(` issues: ${chalk20.red(verdict2.critical)} critical · ${chalk20.yellow(verdict2.high)} high · ${verdict2.medium} medium · ${chalk20.dim(`${verdict2.low} low`)}`);
68200
+ console.log(` checks: ${chalk21.green(verdict2.checksPassed)} pass · ${chalk21.red(verdict2.checksFailed)} fail · ${chalk21.dim(`${verdict2.checksSkipped} skipped`)}`);
68201
+ console.log(` issues: ${chalk21.red(verdict2.critical)} critical · ${chalk21.yellow(verdict2.high)} high · ${verdict2.medium} medium · ${chalk21.dim(`${verdict2.low} low`)}`);
67673
68202
  for (const c of run.caveats ?? []) {
67674
- const mark = c.level === "warn" ? chalk20.yellow("⚠") : chalk20.dim("ℹ");
68203
+ const mark = c.level === "warn" ? chalk21.yellow("⚠") : chalk21.dim("ℹ");
67675
68204
  console.log(` ${mark} ${c.summary}`);
67676
68205
  }
67677
68206
  if (run.moduleVerdicts && run.moduleVerdicts.length > 0) {
67678
68207
  const perModule = run.moduleVerdicts.map((mv) => {
67679
- const colored = mv.status === "pass" ? chalk20.green(mv.score) : mv.status === "warn" ? chalk20.yellow(mv.score) : chalk20.red(mv.score);
68208
+ const colored = mv.status === "pass" ? chalk21.green(mv.score) : mv.status === "warn" ? chalk21.yellow(mv.score) : chalk21.red(mv.score);
67680
68209
  return `${mv.module} ${colored}`;
67681
68210
  }).join(" · ");
67682
68211
  console.log(` modules: ${perModule} → composite ${score}`);
67683
68212
  }
67684
68213
  if (run.visualDiff) {
67685
68214
  const vd = run.visualDiff;
67686
- const parityIcon = vd.parityOk ? chalk20.green("✔") : chalk20.red("✖");
67687
- const parityLabel = vd.parityOk ? chalk20.green("OK") : chalk20.red("DIFFS");
67688
- const cacheNote = vd.pagesFromCache > 0 ? chalk20.dim(` · ${vd.pagesFromCache} cached`) : "";
67689
- console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${chalk20.red(vd.pagesWithDiffs)} diffs · ${chalk20.green(vd.pagesPassed)} pass${cacheNote}`);
68215
+ const parityIcon = vd.parityOk ? chalk21.green("✔") : chalk21.red("✖");
68216
+ const parityLabel = vd.parityOk ? chalk21.green("OK") : chalk21.red("DIFFS");
68217
+ const cacheNote = vd.pagesFromCache > 0 ? chalk21.dim(` · ${vd.pagesFromCache} cached`) : "";
68218
+ console.log(` visual: ${parityIcon} parityOk=${parityLabel} · ${vd.pagesChecked} pages · ${chalk21.red(vd.pagesWithDiffs)} diffs · ${chalk21.green(vd.pagesPassed)} pass${cacheNote}`);
67690
68219
  }
67691
68220
  if (run.topIssues.length > 0) {
67692
68221
  console.log("");
67693
- console.log(chalk20.bold(" Top issues:"));
68222
+ console.log(chalk21.bold(" Top issues:"));
67694
68223
  for (const g of groupIssues(run.topIssues).slice(0, 5)) {
67695
68224
  const i = g.sample;
67696
- const sev = i.severity === "critical" ? chalk20.red(`[${i.severity}]`) : i.severity === "high" ? chalk20.yellow(`[${i.severity}]`) : chalk20.dim(`[${i.severity}]`);
67697
- const pagesNote = g.pages.length > 1 ? chalk20.dim(` (${g.pages.length} páginas)`) : "";
68225
+ const sev = i.severity === "critical" ? chalk21.red(`[${i.severity}]`) : i.severity === "high" ? chalk21.yellow(`[${i.severity}]`) : chalk21.dim(`[${i.severity}]`);
68226
+ const pagesNote = g.pages.length > 1 ? chalk21.dim(` (${g.pages.length} páginas)`) : "";
67698
68227
  console.log(` ${sev} ${i.summary}${pagesNote}`);
67699
68228
  }
67700
68229
  }
67701
68230
  if (meta.promotedCount > 0 || meta.deprecatedCount > 0) {
67702
68231
  console.log("");
67703
- console.log(chalk20.dim(` \uD83D\uDCDA learned-selectors [${meta.platform}]: ${chalk20.green(`+${meta.promotedCount}`)} promoted · ${chalk20.yellow(meta.deprecatedCount)} deprecated`));
68232
+ console.log(chalk21.dim(` \uD83D\uDCDA learned-selectors [${meta.platform}]: ${chalk21.green(`+${meta.promotedCount}`)} promoted · ${chalk21.yellow(meta.deprecatedCount)} deprecated`));
67704
68233
  }
67705
68234
  console.log("");
67706
- console.log(chalk20.dim(` → ${htmlPath}`));
68235
+ console.log(chalk21.dim(` → ${htmlPath}`));
67707
68236
  console.log("");
67708
68237
  }
67709
68238
 
@@ -67727,26 +68256,26 @@ async function prCommand(opts) {
67727
68256
  preset: opts.preset ?? "ci",
67728
68257
  open: false
67729
68258
  };
67730
- console.log(chalk21.dim(` prod : ${opts.prod}`));
67731
- console.log(chalk21.dim(` preview : ${opts.preview}`));
68259
+ console.log(chalk22.dim(` prod : ${opts.prod}`));
68260
+ console.log(chalk22.dim(` preview : ${opts.preview}`));
67732
68261
  console.log("");
67733
68262
  const runCode = await runCommand(runOpts);
67734
68263
  const runs = listRuns(opts.output);
67735
68264
  if (runs.length === 0) {
67736
- console.error(chalk21.red("no run was produced — cannot build PR comment"));
68265
+ console.error(chalk22.red("no run was produced — cannot build PR comment"));
67737
68266
  return runCode || 1;
67738
68267
  }
67739
68268
  const latest = runs[0];
67740
- const reportJsonPath = join30(opts.output, "runs", latest.id, "report.json");
67741
- if (!existsSync19(reportJsonPath)) {
67742
- console.error(chalk21.red(`report.json not found at ${reportJsonPath}`));
68269
+ const reportJsonPath = join34(opts.output, "runs", latest.id, "report.json");
68270
+ if (!existsSync22(reportJsonPath)) {
68271
+ console.error(chalk22.red(`report.json not found at ${reportJsonPath}`));
67743
68272
  return runCode || 1;
67744
68273
  }
67745
- const run = JSON.parse(readFileSync24(reportJsonPath, "utf8"));
68274
+ const run = JSON.parse(readFileSync28(reportJsonPath, "utf8"));
67746
68275
  const markdown = buildPrComment(run, opts);
67747
68276
  if (opts.out) {
67748
- writeFileSync25(opts.out, markdown, "utf8");
67749
- console.log(chalk21.dim(` wrote PR comment: ${opts.out}`));
68277
+ writeFileSync26(opts.out, markdown, "utf8");
68278
+ console.log(chalk22.dim(` wrote PR comment: ${opts.out}`));
67750
68279
  } else {
67751
68280
  process.stdout.write(`
67752
68281
  ${markdown}
@@ -67754,9 +68283,9 @@ ${markdown}
67754
68283
  }
67755
68284
  if (opts.github && process.env.GITHUB_STEP_SUMMARY) {
67756
68285
  try {
67757
- writeFileSync25(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
68286
+ writeFileSync26(process.env.GITHUB_STEP_SUMMARY, markdown, { flag: "a" });
67758
68287
  } catch (err) {
67759
- console.error(chalk21.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
68288
+ console.error(chalk22.yellow(`failed to write GITHUB_STEP_SUMMARY: ${err.message}`));
67760
68289
  }
67761
68290
  }
67762
68291
  return runCode;
@@ -67815,14 +68344,14 @@ function buildPrComment(run, opts) {
67815
68344
  }
67816
68345
 
67817
68346
  // src/commands/prompt.ts
67818
- import { existsSync as existsSync20, writeFileSync as writeFileSync26 } from "node:fs";
67819
- import chalk22 from "chalk";
68347
+ import { existsSync as existsSync23, writeFileSync as writeFileSync27 } from "node:fs";
68348
+ import chalk23 from "chalk";
67820
68349
  function promptCommand(runId, opts) {
67821
68350
  let run;
67822
68351
  try {
67823
68352
  run = loadRun(opts.output, runId);
67824
68353
  } catch (err) {
67825
- console.error(chalk22.red(`✖ ${err.message}`));
68354
+ console.error(chalk23.red(`✖ ${err.message}`));
67826
68355
  return 1;
67827
68356
  }
67828
68357
  const md = buildLlmPrompt(run, {
@@ -67830,11 +68359,11 @@ function promptCommand(runId, opts) {
67830
68359
  limit: opts.limit
67831
68360
  });
67832
68361
  if (opts.out) {
67833
- writeFileSync26(opts.out, md, "utf8");
67834
- console.log(chalk22.green(`✔ prompt salvo em ${opts.out}`));
67835
- if (existsSync20(opts.out)) {
68362
+ writeFileSync27(opts.out, md, "utf8");
68363
+ console.log(chalk23.green(`✔ prompt salvo em ${opts.out}`));
68364
+ if (existsSync23(opts.out)) {
67836
68365
  const sizeKb = (md.length / 1024).toFixed(1);
67837
- console.log(chalk22.dim(` ${md.length} chars (${sizeKb} KB)`));
68366
+ console.log(chalk23.dim(` ${md.length} chars (${sizeKb} KB)`));
67838
68367
  }
67839
68368
  } else {
67840
68369
  process.stdout.write(md);
@@ -67843,9 +68372,9 @@ function promptCommand(runId, opts) {
67843
68372
  }
67844
68373
 
67845
68374
  // src/commands/report.ts
67846
- import { existsSync as existsSync21, readFileSync as readFileSync25, writeFileSync as writeFileSync27 } from "node:fs";
67847
- import { join as join31 } from "node:path";
67848
- import chalk23 from "chalk";
68375
+ import { existsSync as existsSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync28 } from "node:fs";
68376
+ import { join as join35 } from "node:path";
68377
+ import chalk24 from "chalk";
67849
68378
  import open2 from "open";
67850
68379
 
67851
68380
  // src/report/deck-template.ts
@@ -68435,24 +68964,24 @@ async function reportCommand(runId, opts) {
68435
68964
  try {
68436
68965
  run = loadRun(opts.output, runId);
68437
68966
  } catch (err) {
68438
- console.error(chalk23.red(`failed to load run: ${err.message}`));
68967
+ console.error(chalk24.red(`failed to load run: ${err.message}`));
68439
68968
  return 1;
68440
68969
  }
68441
68970
  const html3 = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
68442
- const dest = opts.out ?? join31(paths.runDir, "deck.html");
68443
- writeFileSync27(dest, html3, "utf8");
68444
- console.log(`${chalk23.green("✓")} deck → ${dest}`);
68971
+ const dest = opts.out ?? join35(paths.runDir, "deck.html");
68972
+ writeFileSync28(dest, html3, "utf8");
68973
+ console.log(`${chalk24.green("✓")} deck → ${dest}`);
68445
68974
  if (opts.open) {
68446
68975
  await open2(dest).catch((err) => {
68447
- console.error(chalk23.red(`failed to open: ${err.message}`));
68976
+ console.error(chalk24.red(`failed to open: ${err.message}`));
68448
68977
  });
68449
68978
  }
68450
68979
  return 0;
68451
68980
  }
68452
68981
  if (opts.section) {
68453
68982
  if (!ALL_REPORT_SECTIONS.includes(opts.section)) {
68454
- console.error(chalk23.red(`unknown section "${opts.section}"`));
68455
- console.error(chalk23.gray(` valid: ${ALL_REPORT_SECTIONS.join(", ")}`));
68983
+ console.error(chalk24.red(`unknown section "${opts.section}"`));
68984
+ console.error(chalk24.gray(` valid: ${ALL_REPORT_SECTIONS.join(", ")}`));
68456
68985
  return 1;
68457
68986
  }
68458
68987
  if (opts.json) {
@@ -68460,42 +68989,42 @@ async function reportCommand(runId, opts) {
68460
68989
  const run = loadRun(opts.output, runId);
68461
68990
  const payload = extractReportSection({ kind: "json", section: opts.section, run });
68462
68991
  if (payload === null) {
68463
- console.error(chalk23.red(`section "${opts.section}" not present in this run`));
68992
+ console.error(chalk24.red(`section "${opts.section}" not present in this run`));
68464
68993
  return 1;
68465
68994
  }
68466
68995
  process.stdout.write(`${JSON.stringify(payload, null, 2)}
68467
68996
  `);
68468
68997
  return 0;
68469
68998
  } catch (err) {
68470
- console.error(chalk23.red(`failed to load run: ${err.message}`));
68999
+ console.error(chalk24.red(`failed to load run: ${err.message}`));
68471
69000
  return 1;
68472
69001
  }
68473
69002
  }
68474
- if (!existsSync21(paths.reportHtml)) {
68475
- console.error(chalk23.red(`report.html not found at ${paths.reportHtml}`));
69003
+ if (!existsSync24(paths.reportHtml)) {
69004
+ console.error(chalk24.red(`report.html not found at ${paths.reportHtml}`));
68476
69005
  return 1;
68477
69006
  }
68478
- const html3 = readFileSync25(paths.reportHtml, "utf8");
69007
+ const html3 = readFileSync29(paths.reportHtml, "utf8");
68479
69008
  const slice2 = extractReportSection({ kind: "html", section: opts.section, html: html3 });
68480
69009
  if (slice2 === null) {
68481
- console.error(chalk23.red(`section "${opts.section}" not present in this report`));
69010
+ console.error(chalk24.red(`section "${opts.section}" not present in this report`));
68482
69011
  return 1;
68483
69012
  }
68484
69013
  process.stdout.write(slice2);
68485
69014
  return 0;
68486
69015
  }
68487
- console.log(chalk23.dim(`opening ${paths.reportHtml}`));
69016
+ console.log(chalk24.dim(`opening ${paths.reportHtml}`));
68488
69017
  await open2(paths.reportHtml).catch((err) => {
68489
- console.error(chalk23.red(`failed to open: ${err.message}`));
69018
+ console.error(chalk24.red(`failed to open: ${err.message}`));
68490
69019
  });
68491
69020
  return 0;
68492
69021
  }
68493
69022
 
68494
69023
  // src/commands/vitals.ts
68495
- import { existsSync as existsSync22, readFileSync as readFileSync26, writeFileSync as writeFileSync28 } from "node:fs";
69024
+ import { existsSync as existsSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync29 } from "node:fs";
68496
69025
  import { availableParallelism } from "node:os";
68497
- import { join as join32 } from "node:path";
68498
- import chalk24 from "chalk";
69026
+ import { join as join36 } from "node:path";
69027
+ import chalk25 from "chalk";
68499
69028
  import ora8 from "ora";
68500
69029
 
68501
69030
  // src/checks/agentic-nav.ts
@@ -68793,10 +69322,10 @@ async function vitalsCommand(opts) {
68793
69322
  const runId = newRunId();
68794
69323
  const paths = createRunDir(opts.output, runId);
68795
69324
  const t0 = Date.now();
68796
- console.log(chalk24.bold(`
69325
+ console.log(chalk25.bold(`
68797
69326
  parity vitals ${runId}`));
68798
- console.log(chalk24.dim(` prod: ${opts.prod}`));
68799
- console.log(chalk24.dim(` cand: ${opts.cand}`));
69327
+ console.log(chalk25.dim(` prod: ${opts.prod}`));
69328
+ console.log(chalk25.dim(` cand: ${opts.cand}`));
68800
69329
  const discoverSpinner = ora8("Descobrindo páginas…").start();
68801
69330
  const pagePaths = await discoverPagePaths2(opts.prod, opts);
68802
69331
  if (pagePaths.length === 0) {
@@ -68828,12 +69357,12 @@ async function vitalsCommand(opts) {
68828
69357
  completed++;
68829
69358
  const elapsed = ((Date.now() - t0) / 1000).toFixed(0);
68830
69359
  const etaSec = completed > 0 ? Math.round((Date.now() - t0) / completed * (total - completed) / 1000) : 0;
68831
- progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk24.cyan("prod") : chalk24.magenta("cand")} ${task.path} (${task.viewport})`;
69360
+ progress.text = `${completed}/${total} · ${elapsed}s · ETA ${etaSec}s · ${task.side === "prod" ? chalk25.cyan("prod") : chalk25.magenta("cand")} ${task.path} (${task.viewport})`;
68832
69361
  }
68833
69362
  });
68834
69363
  progress.succeed(`${total} capture(s) em ${((Date.now() - t0) / 1000).toFixed(1)}s`);
68835
69364
  if (opts.lighthouse !== false) {
68836
- const lhDir = join32(paths.runDir, "lighthouse");
69365
+ const lhDir = join36(paths.runDir, "lighthouse");
68837
69366
  const lhCap = opts.lighthouseConcurrency ?? Math.max(1, Math.min(2, Math.floor(availableParallelism() / 2)));
68838
69367
  const done = tasks.filter((t) => !!t.capture);
68839
69368
  const lhT0 = Date.now();
@@ -68857,7 +69386,7 @@ async function vitalsCommand(opts) {
68857
69386
  }
68858
69387
  lhCompleted++;
68859
69388
  const elapsed = ((Date.now() - lhT0) / 1000).toFixed(0);
68860
- lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk24.cyan("prod") : chalk24.magenta("cand")} ${task.path} (${task.viewport})`;
69389
+ lhProgress.text = `Lighthouse ${lhCompleted}/${done.length} · ${elapsed}s · ${task.side === "prod" ? chalk25.cyan("prod") : chalk25.magenta("cand")} ${task.path} (${task.viewport})`;
68861
69390
  });
68862
69391
  lhProgress.succeed(`Lighthouse ${done.length} página(s) em ${((Date.now() - lhT0) / 1000).toFixed(1)}s`);
68863
69392
  }
@@ -68924,7 +69453,7 @@ async function vitalsCommand(opts) {
68924
69453
  writeRunReportJson(paths.runDir, run);
68925
69454
  const html3 = renderHtmlReport(run, paths.runDir);
68926
69455
  writeRunReportHtml(paths.runDir, html3);
68927
- writeFileSync28(join32(paths.runDir, "vitals.json"), `${JSON.stringify({
69456
+ writeFileSync29(join36(paths.runDir, "vitals.json"), `${JSON.stringify({
68928
69457
  schemaVersion: "0.1",
68929
69458
  prodUrl: opts.prod,
68930
69459
  candUrl: opts.cand,
@@ -68937,8 +69466,8 @@ async function vitalsCommand(opts) {
68937
69466
  `, "utf8");
68938
69467
  printSummary7(vitalsResult, cacheResult, scoresResult, oppsResult, agenticResult);
68939
69468
  console.log("");
68940
- console.log(chalk24.dim(` → ${paths.reportHtml}`));
68941
- console.log(chalk24.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
69469
+ console.log(chalk25.dim(` → ${paths.reportHtml}`));
69470
+ console.log(chalk25.dim(` \uD83D\uDCA1 use 'parity serve ${runId}' pra preview iframe`));
68942
69471
  console.log("");
68943
69472
  if (opts.open) {
68944
69473
  const { default: open3 } = await import("open");
@@ -69028,8 +69557,8 @@ async function discoverPagePaths2(prodUrl, opts) {
69028
69557
  function parseUrlList(input) {
69029
69558
  if (input.startsWith("file:") || input.endsWith(".txt") || input.endsWith(".list")) {
69030
69559
  const path = input.replace(/^file:\/\//, "");
69031
- if (existsSync22(path)) {
69032
- return readFileSync26(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
69560
+ if (existsSync25(path)) {
69561
+ return readFileSync30(path, "utf8").split(/\r?\n/).map((s) => s.trim()).filter((s) => s && !s.startsWith("#")).map((s) => s.startsWith("/") ? s : `/${s}`);
69033
69562
  }
69034
69563
  }
69035
69564
  return input.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.startsWith("/") || s.startsWith("http") ? s : `/${s}`);
@@ -69047,7 +69576,7 @@ async function runWithConcurrency3(items, workers, fn) {
69047
69576
  }
69048
69577
  function printSummary7(vitals, cache, scores, opportunities, agentic) {
69049
69578
  console.log("");
69050
- console.log(chalk24.bold(" Summary:"));
69579
+ console.log(chalk25.bold(" Summary:"));
69051
69580
  console.log(` ${vitals.summary}`);
69052
69581
  console.log(` ${cache.summary}`);
69053
69582
  if (scores.status !== "skipped")
@@ -69059,16 +69588,16 @@ function printSummary7(vitals, cache, scores, opportunities, agentic) {
69059
69588
  }
69060
69589
 
69061
69590
  // src/util/version.ts
69062
- import { readFileSync as readFileSync27 } from "node:fs";
69063
- import { dirname as dirname5, resolve as resolve7 } from "node:path";
69591
+ import { readFileSync as readFileSync31 } from "node:fs";
69592
+ import { dirname as dirname6, resolve as resolve7 } from "node:path";
69064
69593
  import { fileURLToPath } from "node:url";
69065
69594
  function getPackageVersion() {
69066
69595
  try {
69067
- const here = dirname5(fileURLToPath(import.meta.url));
69596
+ const here = dirname6(fileURLToPath(import.meta.url));
69068
69597
  for (const up of ["..", "../..", "../../.."]) {
69069
69598
  try {
69070
69599
  const pkgPath = resolve7(here, up, "package.json");
69071
- const raw = readFileSync27(pkgPath, "utf8");
69600
+ const raw = readFileSync31(pkgPath, "utf8");
69072
69601
  const parsed = JSON.parse(raw);
69073
69602
  if (parsed.name === "@decocms/parity" && typeof parsed.version === "string") {
69074
69603
  return parsed.version;
@@ -69161,6 +69690,42 @@ program.command("plan").description("Inspect/update the migration-plan.json comp
69161
69690
  })).addCommand(new Command("verify").description("Record that a component was actually compared against its reference. A `done` row with no verification only means the code exists.").argument("<name>", "Component name (case- and separator-insensitive)").argument("<verdict>", "pass | fail").option("--note <text>", "What was seen").option("--at <iso>", "Timestamp (default: now)").option("--dir <path>", "Directory holding migration-plan.json (default: the target repo's .parity/)", ".parity").action((name, verdict2, opts) => {
69162
69691
  process.exit(planVerifyCommand(opts.dir, name, verdict2, { note: opts.note, at: opts.at }));
69163
69692
  }));
69693
+ program.command("cms").description("Read and write VTEX Content Platform entries — the CMS behind FastStore v4. Every write is a commit on a branch carrying the baseHash it was read at, so a concurrent edit fails the commit instead of silently winning. Needs PARITY_CMS_ACCOUNT + PARITY_CMS_STORE and a `vtex login` session (or PARITY_CMS_TOKEN).").addCommand(new Command("doctor").description("Compare the sections the repo declares against the ones published on the account. A section that exists in code but was never uploaded commits fine and renders nothing — this is the check that catches it.").option("--repo <path>", "Repo holding cms/faststore/pages/", ".").option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
69694
+ process.exit(await cmsDoctorCommand({ repo: opts.repo, json: Boolean(opts.json) }));
69695
+ })).addCommand(new Command("ls").description("List entries, or branches with --branches. Branch ids are what every write needs.").option("--content-type <name>", "Filter by content type (home, landingPage, plp, ...)").option("--branches", "List branches instead of entries", false).option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
69696
+ process.exit(await cmsLsCommand({
69697
+ contentType: opts.contentType,
69698
+ branches: Boolean(opts.branches),
69699
+ json: Boolean(opts.json)
69700
+ }));
69701
+ })).addCommand(new Command("pull").description("Write one entry to a local JSON file, in the authoring shape. The file carries entryId, contentType, branch and baseHash, so push needs no flags.").requiredOption("--content-type <name>", "home, landingPage, plp, ...").requiredOption("--entry <id>", "Entry id (from `parity cms ls`)").requiredOption("--branch <id>", "Branch id, or main").option("--out <path>", "Output file (default: parity-output/cms/<contentType>-<entry>.json)").option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
69702
+ process.exit(await cmsPullCommand({
69703
+ contentType: opts.contentType,
69704
+ entry: opts.entry,
69705
+ branch: opts.branch,
69706
+ out: opts.out,
69707
+ json: Boolean(opts.json)
69708
+ }));
69709
+ })).addCommand(new Command("diff").description("Compare a pulled file against the branch it came from. Exit 1 when they differ.").requiredOption("--file <path>", "File written by `parity cms pull`").option("--branch <id>", "Compare against a different branch").option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
69710
+ process.exit(await cmsDiffCommand({ file: opts.file, branch: opts.branch, json: Boolean(opts.json) }));
69711
+ })).addCommand(new Command("push").description("Commit a pulled file back. Dry run unless --yes. Refuses main without --allow-main, refuses a stale baseHash, refuses sections the account cannot render, and backs the remote up before writing.").requiredOption("--file <path>", "File written by `parity cms pull`").option("--branch <id>", "Target branch (default: the branch in the file)").option("--message <text>", "Commit message", "parity cms push").option("--author <email>", "Commit author", "parity").option("--yes", "Actually write. Without it, this is a dry run.", false).option("--allow-main", "Permit committing straight to main", false).option("--json", "Emit structured JSON instead of human-readable text", false).action(async (opts) => {
69712
+ process.exit(await cmsPushCommand({
69713
+ file: opts.file,
69714
+ branch: opts.branch,
69715
+ message: opts.message,
69716
+ author: opts.author,
69717
+ yes: Boolean(opts.yes),
69718
+ allowMain: Boolean(opts.allowMain),
69719
+ json: Boolean(opts.json)
69720
+ }));
69721
+ })).addCommand(new Command("undo").description("Drop an entry's changes on a branch — the platform's own rollback. Dry run unless --yes.").requiredOption("--entry <id>", "Entry id").requiredOption("--branch <id>", "Branch id").option("--yes", "Actually revert. Without it, this is a dry run.", false).option("--allow-main", "Permit reverting on main", false).action(async (opts) => {
69722
+ process.exit(await cmsUndoCommand({
69723
+ entry: opts.entry,
69724
+ branch: opts.branch,
69725
+ yes: Boolean(opts.yes),
69726
+ allowMain: Boolean(opts.allowMain)
69727
+ }));
69728
+ }));
69164
69729
  program.command("serve").argument("<runId>", "Run ID to serve").description("Spawns a local HTTP server that serves the report and proxies external iframes (strips X-Frame-Options/CSP), making the Side-by-side tab functional for any site.").option("--output <dir>", "Output directory where runs live", "./parity-output").option("--port <n>", "Fixed port (default: auto-pick free port)", (v) => Number(v)).option("--no-open", "Don't open the browser automatically").action(async (runId, opts) => {
69165
69730
  process.exit(await serveCommand(runId, opts));
69166
69731
  });