@decocms/parity 0.33.57 → 0.33.58

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 +107 -5
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -70969,6 +70969,46 @@ function findingsTable(findings, omitted, lang) {
70969
70969
  const tail = omitted > 0 ? `<p class="annotation">${L2(`+${omitted} achado(s) além dos mostrados — veja report.json.`, `+${omitted} more finding(s) beyond those shown — see report.json.`, lang)}</p>` : "";
70970
70970
  return `<table class="grid compact"><thead><tr><th>${L2("Sev", "Sev", lang)}</th><th>${L2("Categoria", "Category", lang)}</th><th>${L2("Achado", "Finding", lang)}</th></tr></thead><tbody>${rows}</tbody></table>${tail}`;
70971
70971
  }
70972
+ var CELL_CLASS = {
70973
+ ok: "cell-ok",
70974
+ new: "cell-new",
70975
+ warn: "cell-warn",
70976
+ gap: "cell-gap"
70977
+ };
70978
+ var PILL_CLASS = {
70979
+ ok: "pill-good",
70980
+ new: "pill-lime",
70981
+ warn: "pill-warn",
70982
+ gap: "pill-bad"
70983
+ };
70984
+ function blockPages(blocks, lang) {
70985
+ const eyebrow = L2("Blocos", "Blocks", lang);
70986
+ if (blocks.rows.length === 0) {
70987
+ return [
70988
+ page(eyebrow, L2("Mapa de calor dos componentes", "Component heat map", lang), `<p class="annotation">${L2("O migration-plan.json foi lido, mas não lista nenhum componente — não há o que mostrar aqui.", "migration-plan.json was read but lists no components — there is nothing to show here.", lang)}</p>`)
70989
+ ];
70990
+ }
70991
+ const byName = new Map(blocks.rows.map((r) => [r.component, r]));
70992
+ const legend = `<div class="legend">${[
70993
+ ["ok", "feito", "done"],
70994
+ ["new", "upgrade", "upgrade"],
70995
+ ["warn", "parcial / as-is / skipped", "partial / as-is / skipped"],
70996
+ ["gap", "pendente", "pending"]
70997
+ ].map(([tone, pt, en]) => `<span class="lg"><i class="cell ${CELL_CLASS[tone]}"></i>${L2(pt, en, lang)}</span>`).join("")}</div>`;
70998
+ const zones = blocks.zones.map((z) => {
70999
+ const label = z.zone === "global" ? L2("Global (header, footer, nav)", "Global (header, footer, nav)", lang) : z.zone === "unassigned" ? L2("Sem página", "Unassigned", lang) : esc3(z.zone);
71000
+ const cells = z.components.map((name) => {
71001
+ const tone = byName.get(name)?.tone ?? "gap";
71002
+ return `<div class="cell ${CELL_CLASS[tone]}">${esc3(name)}</div>`;
71003
+ }).join("");
71004
+ return `<div class="zone"><div class="zone-head"><b>${label}</b><span class="zone-score num">${z.settled}/${z.components.length}</span></div><div class="cells">${cells}</div></div>`;
71005
+ }).join("");
71006
+ const rows = blocks.rows.map((r) => `<tr><td>${esc3(r.component)}</td><td>${esc3(r.role)}</td><td><span class="pill ${PILL_CLASS[r.tone]}">${esc3(r.status)}</span></td><td>${r.verified ? esc3(r.verified) : "—"}</td><td>${esc3(r.note)}</td></tr>`).join("");
71007
+ return [
71008
+ page(eyebrow, L2("Mapa de calor dos componentes", "Component heat map", lang), legend + zones, L2(`${blocks.rows.length} componentes do migration-plan.json, agrupados pela página em que a captura os viu. O placar de cada zona conta done e upgrade.`, `${blocks.rows.length} components from migration-plan.json, grouped by the page the capture saw them on. Each zone's score counts done and upgrade.`, lang)),
71009
+ page(eyebrow, L2("Bloco a bloco", "Block by block", lang), `<table class="grid compact"><thead><tr><th>${L2("Componente", "Component", lang)}</th><th>${L2("Papel", "Role", lang)}</th><th>${L2("Status", "Status", lang)}</th><th>${L2("Verificado", "Verified", lang)}</th><th>${L2("Nota", "Note", lang)}</th></tr></thead><tbody>${rows}</tbody></table>`, L2("Status como o plano registra. Verificado vazio (—) quer dizer que ninguém mediu, não que passou.", "Status as the plan records it. An empty verified (—) means nobody measured it, not that it passed.", lang))
71010
+ ];
71011
+ }
70972
71012
  function renderDeckHtml(model, lang = "en") {
70973
71013
  const pages = [];
70974
71014
  pages.push(`<section class="page cover"><div class="page-inner">
@@ -70987,6 +71027,8 @@ function renderDeckHtml(model, lang = "en") {
70987
71027
  }
70988
71028
  const moduleRows = model.modules.map((m) => `<tr><td>${esc3(m.module)}</td><td><b class="num">${m.score}</b></td><td><span class="pill pill-${m.tone === "good" ? "good" : m.tone === "warn" ? "warn" : m.tone === "neutral" ? "neutral" : "bad"}">${esc3(m.status)}</span></td></tr>`).join("");
70989
71029
  pages.push(page(L2("Sumário executivo", "Executive summary", lang), L2("Onde a migração está", "Where the migration stands", lang), tiles(model.headline, lang) + (moduleRows ? `<h3 class="sub">${L2("Score por módulo", "Score per module", lang)}</h3>` + `<table class="grid"><tbody>${moduleRows}</tbody></table>` : "")));
71030
+ if (model.blocks)
71031
+ pages.push(...blockPages(model.blocks, lang));
70990
71032
  pages.push(page(L2("Achados", "Findings", lang), L2("O que a validação encontrou", "What the validation found", lang), findingsTable(model.findings, model.findingsOmitted, lang)));
70991
71033
  if (model.visual) {
70992
71034
  pages.push(page(L2("Visual", "Visual", lang), L2("Paridade visual", "Visual parity", lang), tiles([
@@ -71050,7 +71092,52 @@ function toneForStatus(status) {
71050
71092
  return "neutral";
71051
71093
  return "bad";
71052
71094
  }
71053
- function buildDeckModel(run) {
71095
+ var TONE_BY_STATUS = {
71096
+ done: "ok",
71097
+ upgrade: "new",
71098
+ partial: "warn",
71099
+ "as-is": "warn",
71100
+ skipped: "warn",
71101
+ pending: "gap"
71102
+ };
71103
+ function buildDeckBlocks(plan) {
71104
+ const rows = plan.components.map((c) => ({
71105
+ component: c.name,
71106
+ role: c.role,
71107
+ status: c.status,
71108
+ tone: TONE_BY_STATUS[c.status] ?? "gap",
71109
+ verified: c.verified?.verdict ?? null,
71110
+ note: c.reference?.note ?? ""
71111
+ }));
71112
+ const byKey = new Map(rows.map((r) => [key(r.component), r]));
71113
+ const isGlobal = new Set(rows.filter((_, i) => plan.components[i]?.scope === "global"));
71114
+ const zones = [];
71115
+ const push = (zone, members) => {
71116
+ if (members.length === 0)
71117
+ return;
71118
+ zones.push({
71119
+ zone,
71120
+ components: members.map((m) => m.component),
71121
+ settled: members.filter((m) => m.tone === "ok" || m.tone === "new").length
71122
+ });
71123
+ };
71124
+ push("global", [...isGlobal]);
71125
+ const placed = new Set;
71126
+ for (const page of plan.pages) {
71127
+ const members = new Set;
71128
+ for (const name of page.components ?? []) {
71129
+ const row = byKey.get(key(name));
71130
+ if (row && !isGlobal.has(row))
71131
+ members.add(row);
71132
+ }
71133
+ for (const m of members)
71134
+ placed.add(m);
71135
+ push(page.path, [...members]);
71136
+ }
71137
+ push("unassigned", rows.filter((r) => !isGlobal.has(r) && !placed.has(r)));
71138
+ return { rows, zones };
71139
+ }
71140
+ function buildDeckModel(run, plan = null) {
71054
71141
  const v = run.verdict;
71055
71142
  const source = run.topIssues.length > 0 ? run.topIssues : run.issues;
71056
71143
  const ranked = [...source].sort(bySeverity);
@@ -71109,7 +71196,8 @@ function buildDeckModel(run) {
71109
71196
  pagesChecked: run.visualDiff.pagesChecked,
71110
71197
  pagesPassed: run.visualDiff.pagesPassed,
71111
71198
  pagesWithDiffs: run.visualDiff.pagesWithDiffs
71112
- } : null
71199
+ } : null,
71200
+ blocks: plan ? buildDeckBlocks(plan) : null
71113
71201
  };
71114
71202
  }
71115
71203
  var SEVERITY_ORDER4 = { critical: 0, high: 1, medium: 2, low: 3 };
@@ -71283,7 +71371,20 @@ async function reportCommand(runId, opts) {
71283
71371
  console.error(chalk27.red(`failed to load run: ${err.message}`));
71284
71372
  return 1;
71285
71373
  }
71286
- const html = renderDeckHtml(buildDeckModel(run), opts.lang ?? "en");
71374
+ let plan = null;
71375
+ if (opts.planDir) {
71376
+ try {
71377
+ plan = loadPlan(opts.planDir);
71378
+ } catch (err) {
71379
+ console.error(chalk27.red(`failed to read migration-plan.json: ${err.message}`));
71380
+ return 1;
71381
+ }
71382
+ if (!plan) {
71383
+ console.error(chalk27.red(`no migration-plan.json in ${opts.planDir}`));
71384
+ return 1;
71385
+ }
71386
+ }
71387
+ const html = renderDeckHtml(buildDeckModel(run, plan), opts.lang ?? "en");
71287
71388
  const dest = opts.out ?? join36(paths.runDir, "deck.html");
71288
71389
  writeFileSync28(dest, html, "utf8");
71289
71390
  console.log(`${chalk27.green("✓")} deck → ${dest}`);
@@ -77557,7 +77658,7 @@ program.command("serve").argument("<runId>", "Run ID to serve").description("Spa
77557
77658
  program.command("event").argument("<type>", "Event type: phase-change | dispatch | bench | score | note | …").description("Record a migration event into <dir>/events.jsonl — the sanctioned emission path for hooks and the orchestrator. The cockpit daemon tails this file into its live activity feed.").option("--dir <dir>", "Directory holding events.jsonl (the target's .parity/)", ".parity").option("--data <json>", `JSON object of event fields, e.g. '{"agent":"porter","component":"hero"}'`).action((type, opts) => {
77558
77659
  process.exit(eventCommand(type, opts));
77559
77660
  });
77560
- program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo, sidebyside, issues, vitals, cache, checks, prompt, pages, console, network, diff.").option("--json", "Pair with --section to emit a normalized JSON projection of the section (from report.json) instead of the raw HTML slice.").option("--deck", "Render the presentation deck instead: one topic per full-viewport page, advanced sideways, in a single self-contained HTML file. For showing the result to someone rather than debugging it. Issue #290.", false).option("--out <path>", "Where to write the deck (default: deck.html in the run dir)").option("--lang <pt|en>", "Initial deck language; the in-page toggle still switches live", "en").option("--open", "Open the rendered deck in the browser", false).action(async (runId, opts) => {
77661
+ program.command("report").argument("<runId>", "Run ID to open").description("Open the HTML report for a run in the default browser. With --section, extract a single tab to stdout instead — useful for agents that need just the SEO/Network/Vitals slice without parsing the whole report. Issue #74.").option("--output <dir>", "Output directory", "./parity-output").option("--section <name>", "Extract one tab to stdout instead of opening the report. Valid names: summary, visualdiff, seo, sidebyside, issues, vitals, cache, checks, prompt, pages, console, network, diff.").option("--json", "Pair with --section to emit a normalized JSON projection of the section (from report.json) instead of the raw HTML slice.").option("--deck", "Render the presentation deck instead: one topic per full-viewport page, advanced sideways, in a single self-contained HTML file. For showing the result to someone rather than debugging it. Issue #290.", false).option("--out <path>", "Where to write the deck (default: deck.html in the run dir)").option("--lang <pt|en>", "Initial deck language; the in-page toggle still switches live", "en").option("--open", "Open the rendered deck in the browser", false).option("--plan-dir <dir>", "With --deck: dir holding migration-plan.json. Adds the component heat map (grouped by page, plus global) and the block-by-block table. Without it those pages are omitted, not drawn empty. Issue #291.").action(async (runId, opts) => {
77561
77662
  process.exit(await reportCommand(runId, {
77562
77663
  output: opts.output,
77563
77664
  section: opts.section,
@@ -77565,7 +77666,8 @@ program.command("report").argument("<runId>", "Run ID to open").description("Ope
77565
77666
  deck: Boolean(opts.deck),
77566
77667
  out: opts.out,
77567
77668
  lang: opts.lang === "pt" ? "pt" : "en",
77568
- open: Boolean(opts.open)
77669
+ open: Boolean(opts.open),
77670
+ planDir: opts.planDir
77569
77671
  }));
77570
77672
  });
77571
77673
  function buildCompareCommand(name, deprecated) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/parity",
3
- "version": "0.33.57",
3
+ "version": "0.33.58",
4
4
  "description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with an LLM-ranked HTML report.",
5
5
  "type": "module",
6
6
  "license": "MIT",