@tangle-network/agent-app 0.60.89 → 0.60.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TVGL2OAC.js → chunk-KQ3UATBB.js} +425 -6
- package/dist/chunk-KQ3UATBB.js.map +1 -0
- package/dist/signoff/cli.js +6 -3
- package/dist/signoff/cli.js.map +1 -1
- package/dist/signoff/index.d.ts +2 -0
- package/dist/signoff/index.js +31 -3
- package/dist/signoff/surface-ladder-cli.d.ts +7 -0
- package/dist/signoff/surface-ladder.d.ts +141 -0
- package/dist/workspace-export/engine.d.ts +2 -0
- package/dist/workspace-export/index.js +15 -6
- package/dist/workspace-export/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-TVGL2OAC.js.map +0 -1
|
@@ -443,7 +443,7 @@ function runCommand(options) {
|
|
|
443
443
|
killGraceMs = DEFAULT_KILL_GRACE_MS,
|
|
444
444
|
onData
|
|
445
445
|
} = options;
|
|
446
|
-
return new Promise((
|
|
446
|
+
return new Promise((resolve6, reject) => {
|
|
447
447
|
const startedAt = Date.now();
|
|
448
448
|
const buffer = new BoundedOutput(maxOutputBytes);
|
|
449
449
|
let timedOut = false;
|
|
@@ -493,7 +493,7 @@ function runCommand(options) {
|
|
|
493
493
|
});
|
|
494
494
|
child.on("close", (code, sig) => {
|
|
495
495
|
cleanup();
|
|
496
|
-
|
|
496
|
+
resolve6({
|
|
497
497
|
command,
|
|
498
498
|
cwd,
|
|
499
499
|
// A signalled process reports code `null`; 128+n is the shell's own
|
|
@@ -1130,9 +1130,9 @@ function formatSignoffReport(report) {
|
|
|
1130
1130
|
` ${report.install.exitCode === 0 ? "ok " : "FAIL"} ${"install".padEnd(width)} ${ms(report.install.durationMs).padStart(8)}`
|
|
1131
1131
|
);
|
|
1132
1132
|
for (const step of report.steps) {
|
|
1133
|
-
const
|
|
1133
|
+
const window2 = step.startedAtMs === null || step.finishedAtMs === null ? "" : ` [${ms(step.startedAtMs)} \u2192 ${ms(step.finishedAtMs)}]`;
|
|
1134
1134
|
lines.push(
|
|
1135
|
-
` ${statusMark(step.status)} ${step.name.padEnd(width)} ${ms(step.durationMs).padStart(8)} ${step.attempts.length} run(s)${
|
|
1135
|
+
` ${statusMark(step.status)} ${step.name.padEnd(width)} ${ms(step.durationMs).padStart(8)} ${step.attempts.length} run(s)${window2}${seedList(step)}`
|
|
1136
1136
|
);
|
|
1137
1137
|
}
|
|
1138
1138
|
lines.push("");
|
|
@@ -1438,6 +1438,411 @@ ${shellAlignmentUsage()}
|
|
|
1438
1438
|
return report.findings.length ? 1 : 0;
|
|
1439
1439
|
}
|
|
1440
1440
|
|
|
1441
|
+
// src/signoff/surface-ladder.ts
|
|
1442
|
+
var SURFACE_LADDER_MIN_DELTA_L = 3;
|
|
1443
|
+
var SURFACE_LADDER_MIN_BORDER_CONTRAST = 3;
|
|
1444
|
+
var SURFACE_LADDER_MAX_WORDS = 12;
|
|
1445
|
+
function composite(top, bottom) {
|
|
1446
|
+
const a = Math.min(1, Math.max(0, top[3]));
|
|
1447
|
+
return [0, 1, 2].map((i) => top[i] * a + bottom[i] * (1 - a));
|
|
1448
|
+
}
|
|
1449
|
+
function linear(channel) {
|
|
1450
|
+
const c = channel / 255;
|
|
1451
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
1452
|
+
}
|
|
1453
|
+
function oklchL(rgb) {
|
|
1454
|
+
const [r, g, b] = rgb.map(linear);
|
|
1455
|
+
const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b;
|
|
1456
|
+
const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b;
|
|
1457
|
+
const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b;
|
|
1458
|
+
return 100 * (0.2104542553 * Math.cbrt(l) + 0.793617785 * Math.cbrt(m) - 0.0040720468 * Math.cbrt(s));
|
|
1459
|
+
}
|
|
1460
|
+
function contrastRatio(a, b) {
|
|
1461
|
+
const luminance = (c) => {
|
|
1462
|
+
const [r, g, bl] = c.map(linear);
|
|
1463
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * bl;
|
|
1464
|
+
};
|
|
1465
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
1466
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
1467
|
+
}
|
|
1468
|
+
function surfaceDeltaL(box) {
|
|
1469
|
+
return oklchL(composite(box.fill, box.parent)) - oklchL(box.parent);
|
|
1470
|
+
}
|
|
1471
|
+
function judgeSurfaceLadder(sample, limits = {}) {
|
|
1472
|
+
const minDeltaL = limits.minDeltaL ?? SURFACE_LADDER_MIN_DELTA_L;
|
|
1473
|
+
const minBorder = limits.minBorderContrast ?? SURFACE_LADDER_MIN_BORDER_CONTRAST;
|
|
1474
|
+
const maxWords = limits.maxWords ?? SURFACE_LADDER_MAX_WORDS;
|
|
1475
|
+
const where = { route: sample.route, width: sample.width, theme: sample.theme };
|
|
1476
|
+
const findings = [];
|
|
1477
|
+
for (const box of sample.boxes) {
|
|
1478
|
+
const delta = surfaceDeltaL(box);
|
|
1479
|
+
if (Math.abs(delta) < minDeltaL) {
|
|
1480
|
+
findings.push({
|
|
1481
|
+
...where,
|
|
1482
|
+
rule: box.kind === "card" ? "card-step" : "field-step",
|
|
1483
|
+
target: box.label,
|
|
1484
|
+
value: round1(Math.abs(delta)),
|
|
1485
|
+
limit: minDeltaL,
|
|
1486
|
+
reason: `${box.kind} is \u0394L ${signed(delta)} against ${box.parentLabel} (needs |\u0394L| \u2265 ${minDeltaL})`
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
if (box.kind === "field" && box.border) {
|
|
1490
|
+
const ratio = contrastRatio(composite(box.border, box.parent), box.parent);
|
|
1491
|
+
if (ratio < minBorder) {
|
|
1492
|
+
findings.push({
|
|
1493
|
+
...where,
|
|
1494
|
+
rule: "field-border",
|
|
1495
|
+
target: box.label,
|
|
1496
|
+
value: round2(ratio),
|
|
1497
|
+
limit: minBorder,
|
|
1498
|
+
reason: `field border is ${round2(ratio)}:1 against ${box.parentLabel} (needs ${minBorder}:1)`
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
for (const block of sample.copy) {
|
|
1504
|
+
if (block.words > maxWords) {
|
|
1505
|
+
findings.push({
|
|
1506
|
+
...where,
|
|
1507
|
+
rule: "card-copy",
|
|
1508
|
+
target: `${block.card} \u203A ${block.label}`,
|
|
1509
|
+
value: block.words,
|
|
1510
|
+
limit: maxWords,
|
|
1511
|
+
reason: `card body copy is ${block.words} words (max ${maxWords}): "${block.text}"`
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return findings;
|
|
1516
|
+
}
|
|
1517
|
+
function round1(value) {
|
|
1518
|
+
return Math.round(value * 10) / 10;
|
|
1519
|
+
}
|
|
1520
|
+
function round2(value) {
|
|
1521
|
+
return Math.round(value * 100) / 100;
|
|
1522
|
+
}
|
|
1523
|
+
function signed(value) {
|
|
1524
|
+
return `${value >= 0 ? "+" : ""}${round1(value)}`;
|
|
1525
|
+
}
|
|
1526
|
+
function collectSurfaceLadder() {
|
|
1527
|
+
const canvas = document.createElement("canvas");
|
|
1528
|
+
canvas.width = 1;
|
|
1529
|
+
canvas.height = 1;
|
|
1530
|
+
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
1531
|
+
const parseCache = /* @__PURE__ */ new Map();
|
|
1532
|
+
const parse = (css) => {
|
|
1533
|
+
const hit = parseCache.get(css);
|
|
1534
|
+
if (hit !== void 0) return hit;
|
|
1535
|
+
let out = null;
|
|
1536
|
+
const m = css.match(/^rgba?\(([^)]+)\)$/);
|
|
1537
|
+
if (m) {
|
|
1538
|
+
const parts = m[1].split(/[\s,/]+/).filter(Boolean).map((p) => p.endsWith("%") ? Number.parseFloat(p) / 100 : Number(p));
|
|
1539
|
+
out = [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0, parts[3] ?? 1];
|
|
1540
|
+
} else if (ctx && css && css !== "none") {
|
|
1541
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
1542
|
+
ctx.fillStyle = "#000";
|
|
1543
|
+
ctx.fillStyle = css;
|
|
1544
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
1545
|
+
const d = ctx.getImageData(0, 0, 1, 1).data;
|
|
1546
|
+
out = [d[0], d[1], d[2], d[3] / 255];
|
|
1547
|
+
}
|
|
1548
|
+
parseCache.set(css, out);
|
|
1549
|
+
return out;
|
|
1550
|
+
};
|
|
1551
|
+
const PAINT_ALPHA = 0.1;
|
|
1552
|
+
const blend = (top, bottom) => [0, 1, 2].map((i) => top[i] * top[3] + bottom[i] * (1 - top[3]));
|
|
1553
|
+
const describe = (el) => {
|
|
1554
|
+
const id = el.id ? `#${el.id}` : "";
|
|
1555
|
+
const slot = el.getAttribute("data-slot") ? `[data-slot=${el.getAttribute("data-slot")}]` : "";
|
|
1556
|
+
const role = el.getAttribute("role") ? `[role=${el.getAttribute("role")}]` : "";
|
|
1557
|
+
const classes = typeof el.className === "string" ? el.className.trim().split(/\s+/).filter((c) => c && !c.includes(":") && !c.includes("[") && !c.includes("/")).slice(0, 3).map((c) => `.${c}`).join("") : "";
|
|
1558
|
+
return `${el.tagName.toLowerCase()}${id}${slot}${role}${classes}`;
|
|
1559
|
+
};
|
|
1560
|
+
const visible = (el, style, rect) => rect.width > 0 && rect.height > 0 && style.visibility !== "hidden" && style.display !== "none" && Number(style.opacity) !== 0;
|
|
1561
|
+
const effective = /* @__PURE__ */ new Map();
|
|
1562
|
+
const canvasColor = () => {
|
|
1563
|
+
for (const el of [document.body, document.documentElement]) {
|
|
1564
|
+
const fill = parse(getComputedStyle(el).backgroundColor);
|
|
1565
|
+
if (fill && fill[3] >= PAINT_ALPHA) return [fill[0], fill[1], fill[2]];
|
|
1566
|
+
}
|
|
1567
|
+
return matchMedia("(prefers-color-scheme: dark)").matches ? [18, 18, 18] : [255, 255, 255];
|
|
1568
|
+
};
|
|
1569
|
+
const root = canvasColor();
|
|
1570
|
+
const effectiveOf = (el) => {
|
|
1571
|
+
if (!el) return { color: root, painter: null };
|
|
1572
|
+
const known = effective.get(el);
|
|
1573
|
+
if (known) return known;
|
|
1574
|
+
const below = effectiveOf(el.parentElement);
|
|
1575
|
+
const fill = parse(getComputedStyle(el).backgroundColor);
|
|
1576
|
+
const result = fill && fill[3] >= PAINT_ALPHA ? { color: blend(fill, below.color), painter: el } : below;
|
|
1577
|
+
effective.set(el, result);
|
|
1578
|
+
return result;
|
|
1579
|
+
};
|
|
1580
|
+
const fieldSelector = 'input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]), textarea, [role="combobox"], [role="searchbox"], .focus-field-within';
|
|
1581
|
+
const overlay = '[role="dialog"],[role="menu"],[role="listbox"],[role="tooltip"],[data-radix-popper-content-wrapper]';
|
|
1582
|
+
const media = /* @__PURE__ */ new Set(["IMG", "VIDEO", "CANVAS", "SVG", "svg", "IFRAME", "PICTURE"]);
|
|
1583
|
+
const scope = Array.from(document.querySelectorAll('main, [role="main"]'));
|
|
1584
|
+
const roots = scope.length ? scope.filter((el) => !scope.some((o) => o !== el && o.contains(el))) : [document.body];
|
|
1585
|
+
const boxes = [];
|
|
1586
|
+
const cards = [];
|
|
1587
|
+
for (const el of roots.flatMap((r) => Array.from(r.querySelectorAll("*")))) {
|
|
1588
|
+
if (media.has(el.tagName) || el.closest(overlay)) continue;
|
|
1589
|
+
const style = getComputedStyle(el);
|
|
1590
|
+
const rect = el.getBoundingClientRect();
|
|
1591
|
+
if (!visible(el, style, rect)) continue;
|
|
1592
|
+
const isField = el.matches(fieldSelector);
|
|
1593
|
+
const fill = parse(style.backgroundColor) ?? [0, 0, 0, 0];
|
|
1594
|
+
const painted = fill[3] >= PAINT_ALPHA;
|
|
1595
|
+
const base = { label: describe(el), top: rect.top + window.scrollY, left: rect.left, width: rect.width, height: rect.height, fill };
|
|
1596
|
+
if (isField) {
|
|
1597
|
+
if (rect.width < 40 || rect.height < 20) continue;
|
|
1598
|
+
if (!painted && el.parentElement?.closest(".focus-field-within")) continue;
|
|
1599
|
+
const parent2 = effectiveOf(el.parentElement);
|
|
1600
|
+
const sides = ["Top", "Bottom", "Left", "Right"];
|
|
1601
|
+
const side = sides.find((s) => Number.parseFloat(style.getPropertyValue(`border-${s.toLowerCase()}-width`)) > 0 && style.getPropertyValue(`border-${s.toLowerCase()}-style`) !== "none");
|
|
1602
|
+
const borderFill = side ? parse(style.getPropertyValue(`border-${side.toLowerCase()}-color`)) : null;
|
|
1603
|
+
const border = borderFill && borderFill[3] > 0 ? borderFill : null;
|
|
1604
|
+
boxes.push({ kind: "field", ...base, parent: parent2.color, parentLabel: parent2.painter ? describe(parent2.painter) : "(canvas)", border });
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
if (!painted || rect.height <= 80 || rect.width < 120) continue;
|
|
1608
|
+
const radius = Math.max(...["border-top-left-radius", "border-top-right-radius", "border-bottom-left-radius", "border-bottom-right-radius"].map((p) => Number.parseFloat(style.getPropertyValue(p)) || 0));
|
|
1609
|
+
if (radius < 6) continue;
|
|
1610
|
+
const parent = effectiveOf(el.parentElement);
|
|
1611
|
+
const words = (el.innerText || "").split(/\s+/).filter(Boolean).length;
|
|
1612
|
+
boxes.push({ kind: "card", ...base, parent: parent.color, parentLabel: parent.painter ? describe(parent.painter) : "(canvas)", border: null, words });
|
|
1613
|
+
cards.push({ el, label: base.label });
|
|
1614
|
+
}
|
|
1615
|
+
const copySelector = '[data-slot="card-description"], p';
|
|
1616
|
+
const transcript = '[data-timeline-step], .prose, [role="log"], pre, code';
|
|
1617
|
+
const copy = [];
|
|
1618
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1619
|
+
for (const el of roots.flatMap((r) => Array.from(r.querySelectorAll(copySelector)))) {
|
|
1620
|
+
if (seen.has(el) || el.closest(overlay) || el.closest(transcript) || el.closest(fieldSelector) || el.parentElement?.closest('[data-slot="card-description"]')) continue;
|
|
1621
|
+
seen.add(el);
|
|
1622
|
+
const style = getComputedStyle(el);
|
|
1623
|
+
if (!visible(el, style, el.getBoundingClientRect())) continue;
|
|
1624
|
+
let card;
|
|
1625
|
+
for (let p = el.parentElement; p && !card; p = p.parentElement) card = cards.find((c) => c.el === p);
|
|
1626
|
+
if (!card) continue;
|
|
1627
|
+
const text = (el.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
1628
|
+
const words = text ? text.split(" ").length : 0;
|
|
1629
|
+
copy.push({ label: describe(el), card: card.label, words, text: text.length > 90 ? `${text.slice(0, 87)}\u2026` : text });
|
|
1630
|
+
}
|
|
1631
|
+
return { boxes, copy };
|
|
1632
|
+
}
|
|
1633
|
+
function summarizeSurfacePage(sample, findings) {
|
|
1634
|
+
const mine = findings.filter((f) => f.route === sample.route && f.width === sample.width && f.theme === sample.theme);
|
|
1635
|
+
const count = (rule) => mine.filter((f) => f.rule === rule).length;
|
|
1636
|
+
const deltas = (kind) => sample.boxes.filter((b) => b.kind === kind).map((b) => Math.abs(surfaceDeltaL(b)));
|
|
1637
|
+
const min = (values) => values.length ? round1(Math.min(...values)) : null;
|
|
1638
|
+
const cardWords = sample.boxes.filter((b) => b.kind === "card").map((b) => b.words ?? 0).sort((a, b) => a - b);
|
|
1639
|
+
return {
|
|
1640
|
+
route: sample.route,
|
|
1641
|
+
width: sample.width,
|
|
1642
|
+
theme: sample.theme,
|
|
1643
|
+
cards: deltas("card").length,
|
|
1644
|
+
flatCards: count("card-step"),
|
|
1645
|
+
minCardDeltaL: min(deltas("card")),
|
|
1646
|
+
fields: deltas("field").length,
|
|
1647
|
+
flatFields: count("field-step"),
|
|
1648
|
+
minFieldDeltaL: min(deltas("field")),
|
|
1649
|
+
weakBorders: count("field-border"),
|
|
1650
|
+
copyBlocks: sample.copy.length,
|
|
1651
|
+
longCopy: count("card-copy"),
|
|
1652
|
+
maxCopyWords: sample.copy.length ? Math.max(...sample.copy.map((c) => c.words)) : null,
|
|
1653
|
+
medianCardWords: cardWords.length ? cardWords[Math.floor(cardWords.length / 2)] : null
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
var PHONE_HEIGHT2 = 844;
|
|
1657
|
+
var DESKTOP_HEIGHT2 = 900;
|
|
1658
|
+
async function checkSurfaceLadder(options) {
|
|
1659
|
+
const { chromium } = await import("playwright");
|
|
1660
|
+
const widths = options.widths ?? [1440, 390];
|
|
1661
|
+
const themes = options.themes ?? ["light", "dark"];
|
|
1662
|
+
const browser = await chromium.launch();
|
|
1663
|
+
const samples = [];
|
|
1664
|
+
const findings = [];
|
|
1665
|
+
try {
|
|
1666
|
+
for (const width of widths) {
|
|
1667
|
+
for (const theme of themes) {
|
|
1668
|
+
const context = await browser.newContext({
|
|
1669
|
+
viewport: { width, height: width < 768 ? PHONE_HEIGHT2 : DESKTOP_HEIGHT2 },
|
|
1670
|
+
colorScheme: theme,
|
|
1671
|
+
reducedMotion: "reduce",
|
|
1672
|
+
...options.storageState ? { storageState: options.storageState } : {}
|
|
1673
|
+
});
|
|
1674
|
+
if (options.themeScript) {
|
|
1675
|
+
await context.addInitScript({ content: `(() => { const theme = ${JSON.stringify(theme)}; ${options.themeScript} })()` });
|
|
1676
|
+
}
|
|
1677
|
+
const page = await context.newPage();
|
|
1678
|
+
for (const route of options.routes) {
|
|
1679
|
+
await page.goto(new URL(route, options.baseUrl).toString(), { waitUntil: "domcontentloaded" });
|
|
1680
|
+
await page.waitForSelector(options.readySelector ?? "[data-shell-header]", { state: "visible", timeout: 15e3 }).catch(() => void 0);
|
|
1681
|
+
await page.waitForLoadState("networkidle", { timeout: 3e3 }).catch(() => void 0);
|
|
1682
|
+
if (options.injectCss) await page.addStyleTag({ content: options.injectCss });
|
|
1683
|
+
await page.evaluate(() => document.fonts?.ready);
|
|
1684
|
+
await page.waitForTimeout(600);
|
|
1685
|
+
const collected = await page.evaluate(collectSurfaceLadder);
|
|
1686
|
+
const sample = { route, width, theme, ...collected };
|
|
1687
|
+
samples.push(sample);
|
|
1688
|
+
const found = judgeSurfaceLadder(sample, options);
|
|
1689
|
+
findings.push(...found);
|
|
1690
|
+
if (found.length && options.screenshotDir) {
|
|
1691
|
+
const name = `${route.replace(/[^a-z0-9]+/gi, "_").replace(/^_|_$/g, "") || "root"}-${width}-${theme}.png`;
|
|
1692
|
+
await page.screenshot({ path: `${options.screenshotDir}/${name}`, fullPage: true, timeout: 1e4, animations: "disabled" }).catch(() => void 0);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
await context.close();
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
} finally {
|
|
1699
|
+
await browser.close();
|
|
1700
|
+
}
|
|
1701
|
+
const countsByRule = { "card-step": 0, "field-step": 0, "field-border": 0, "card-copy": 0 };
|
|
1702
|
+
for (const f of findings) countsByRule[f.rule] += 1;
|
|
1703
|
+
return { samples, pages: samples.map((s) => summarizeSurfacePage(s, findings)), findings, countsByRule };
|
|
1704
|
+
}
|
|
1705
|
+
function formatSurfaceLadderReport(report) {
|
|
1706
|
+
const c = report.countsByRule;
|
|
1707
|
+
const lines = [
|
|
1708
|
+
`surface ladder: ${report.pages.length} pages, ${report.findings.length} failures (card-step ${c["card-step"]}, field-step ${c["field-step"]}, field-border ${c["field-border"]}, card-copy ${c["card-copy"]})`,
|
|
1709
|
+
" route | width | theme | cards flat/total (min |\u0394L|) | fields flat/total (min |\u0394L|) | weak borders | long copy/blocks (max words) | median card words"
|
|
1710
|
+
];
|
|
1711
|
+
for (const p of report.pages) {
|
|
1712
|
+
lines.push(` ${p.route} | ${p.width} | ${p.theme} | ${p.flatCards}/${p.cards} (${p.minCardDeltaL ?? "\u2013"}) | ${p.flatFields}/${p.fields} (${p.minFieldDeltaL ?? "\u2013"}) | ${p.weakBorders} | ${p.longCopy}/${p.copyBlocks} (${p.maxCopyWords ?? "\u2013"}) | ${p.medianCardWords ?? "\u2013"}`);
|
|
1713
|
+
}
|
|
1714
|
+
for (const f of report.findings) lines.push(` FAIL ${f.rule} ${f.route} @${f.width} ${f.theme}: ${f.target} ${f.reason}`);
|
|
1715
|
+
if (!report.findings.length) lines.push(" ok: every card and field steps off its parent, field borders read, and card copy is one short line");
|
|
1716
|
+
return lines.join("\n");
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
// src/signoff/surface-ladder-cli.ts
|
|
1720
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
|
|
1721
|
+
import { dirname as dirname4, resolve as resolve5 } from "path";
|
|
1722
|
+
function surfaceLadderUsage() {
|
|
1723
|
+
return [
|
|
1724
|
+
"Usage: agent-app-signoff surface-ladder --base-url <url> --route <path> [--route <path> ...] [options]",
|
|
1725
|
+
"",
|
|
1726
|
+
" --widths <w,w> viewport widths (default 1440,390)",
|
|
1727
|
+
" --themes <t,t> light,dark (default both)",
|
|
1728
|
+
" --storage-state <file> Playwright storage state for an authenticated app",
|
|
1729
|
+
" --theme-script <file> JS run before each page loads with `theme` in scope",
|
|
1730
|
+
" --ready <selector> wait for this after navigation (default [data-shell-header])",
|
|
1731
|
+
" --tolerance <L> minimum |\u0394L| (OKLCH L x100) for a card or field (default 3)",
|
|
1732
|
+
" --min-border-contrast <r> minimum field border contrast against its parent (default 3)",
|
|
1733
|
+
" --max-words <n> maximum words in one card body-copy element (default 12)",
|
|
1734
|
+
" --inject-css <file> calibration only: add this stylesheet to each page before measuring",
|
|
1735
|
+
" --screenshots <dir> screenshot each failing page here",
|
|
1736
|
+
" --json <path> write every sample and finding"
|
|
1737
|
+
].join("\n");
|
|
1738
|
+
}
|
|
1739
|
+
var SurfaceLadderUsageError = class extends Error {
|
|
1740
|
+
};
|
|
1741
|
+
function parseSurfaceLadderArgs(argv) {
|
|
1742
|
+
const routes = [];
|
|
1743
|
+
let baseUrl;
|
|
1744
|
+
const out = {};
|
|
1745
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
1746
|
+
const flag = argv[index];
|
|
1747
|
+
const take = () => {
|
|
1748
|
+
const value = argv[index + 1];
|
|
1749
|
+
if (value === void 0) throw new SurfaceLadderUsageError(`${flag} needs a value`);
|
|
1750
|
+
index += 1;
|
|
1751
|
+
return value;
|
|
1752
|
+
};
|
|
1753
|
+
const nonNegative = () => {
|
|
1754
|
+
const n = Number(take());
|
|
1755
|
+
if (!(n >= 0)) throw new SurfaceLadderUsageError(`${flag} needs a non-negative number`);
|
|
1756
|
+
return n;
|
|
1757
|
+
};
|
|
1758
|
+
switch (flag) {
|
|
1759
|
+
case "--base-url":
|
|
1760
|
+
baseUrl = take();
|
|
1761
|
+
break;
|
|
1762
|
+
case "--route":
|
|
1763
|
+
routes.push(take());
|
|
1764
|
+
break;
|
|
1765
|
+
case "--widths":
|
|
1766
|
+
out.widths = take().split(",").map((w) => {
|
|
1767
|
+
const n = Number(w);
|
|
1768
|
+
if (!Number.isInteger(n) || n < 200) throw new SurfaceLadderUsageError(`--widths needs integers of at least 200, got "${w}"`);
|
|
1769
|
+
return n;
|
|
1770
|
+
});
|
|
1771
|
+
break;
|
|
1772
|
+
case "--themes":
|
|
1773
|
+
out.themes = take().split(",").map((t) => {
|
|
1774
|
+
if (t !== "light" && t !== "dark") throw new SurfaceLadderUsageError(`--themes takes light and dark, got "${t}"`);
|
|
1775
|
+
return t;
|
|
1776
|
+
});
|
|
1777
|
+
break;
|
|
1778
|
+
case "--storage-state":
|
|
1779
|
+
out.storageState = resolve5(take());
|
|
1780
|
+
break;
|
|
1781
|
+
case "--theme-script":
|
|
1782
|
+
out.themeScript = readFileSync6(resolve5(take()), "utf8");
|
|
1783
|
+
break;
|
|
1784
|
+
case "--ready":
|
|
1785
|
+
out.readySelector = take();
|
|
1786
|
+
break;
|
|
1787
|
+
case "--tolerance":
|
|
1788
|
+
out.minDeltaL = nonNegative();
|
|
1789
|
+
break;
|
|
1790
|
+
case "--min-border-contrast":
|
|
1791
|
+
out.minBorderContrast = nonNegative();
|
|
1792
|
+
break;
|
|
1793
|
+
case "--max-words": {
|
|
1794
|
+
const n = Number(take());
|
|
1795
|
+
if (!Number.isInteger(n) || n < 1) throw new SurfaceLadderUsageError("--max-words needs a positive integer");
|
|
1796
|
+
out.maxWords = n;
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
case "--inject-css":
|
|
1800
|
+
out.injectCss = readFileSync6(resolve5(take()), "utf8");
|
|
1801
|
+
break;
|
|
1802
|
+
case "--screenshots":
|
|
1803
|
+
out.screenshotDir = resolve5(take());
|
|
1804
|
+
break;
|
|
1805
|
+
case "--json":
|
|
1806
|
+
out.jsonPath = take();
|
|
1807
|
+
break;
|
|
1808
|
+
default:
|
|
1809
|
+
throw new SurfaceLadderUsageError(`unknown option: ${flag}`);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (!baseUrl) throw new SurfaceLadderUsageError("--base-url is required");
|
|
1813
|
+
if (!routes.length) throw new SurfaceLadderUsageError("at least one --route is required");
|
|
1814
|
+
return { ...out, baseUrl, routes };
|
|
1815
|
+
}
|
|
1816
|
+
async function runSurfaceLadderCli(argv) {
|
|
1817
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
1818
|
+
process.stdout.write(`${surfaceLadderUsage()}
|
|
1819
|
+
`);
|
|
1820
|
+
return 0;
|
|
1821
|
+
}
|
|
1822
|
+
let options;
|
|
1823
|
+
try {
|
|
1824
|
+
options = parseSurfaceLadderArgs(argv);
|
|
1825
|
+
} catch (error) {
|
|
1826
|
+
if (!(error instanceof SurfaceLadderUsageError)) throw error;
|
|
1827
|
+
process.stderr.write(`agent-app-signoff surface-ladder: ${error.message}
|
|
1828
|
+
|
|
1829
|
+
${surfaceLadderUsage()}
|
|
1830
|
+
`);
|
|
1831
|
+
return 2;
|
|
1832
|
+
}
|
|
1833
|
+
if (options.screenshotDir) mkdirSync4(options.screenshotDir, { recursive: true });
|
|
1834
|
+
const report = await checkSurfaceLadder(options);
|
|
1835
|
+
if (options.jsonPath) {
|
|
1836
|
+
const abs = resolve5(options.jsonPath);
|
|
1837
|
+
mkdirSync4(dirname4(abs), { recursive: true });
|
|
1838
|
+
writeFileSync4(abs, `${JSON.stringify(report, null, 2)}
|
|
1839
|
+
`);
|
|
1840
|
+
}
|
|
1841
|
+
process.stdout.write(`${formatSurfaceLadderReport(report)}
|
|
1842
|
+
`);
|
|
1843
|
+
return report.findings.length ? 1 : 0;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1441
1846
|
export {
|
|
1442
1847
|
WORKER_COMPATIBILITY_DATE_FLOOR,
|
|
1443
1848
|
checkWorkerDefaults,
|
|
@@ -1452,6 +1857,20 @@ export {
|
|
|
1452
1857
|
checkShellAlignment,
|
|
1453
1858
|
formatShellAlignmentReport,
|
|
1454
1859
|
parseShellAlignmentArgs,
|
|
1455
|
-
runShellAlignmentCli
|
|
1860
|
+
runShellAlignmentCli,
|
|
1861
|
+
SURFACE_LADDER_MIN_DELTA_L,
|
|
1862
|
+
SURFACE_LADDER_MIN_BORDER_CONTRAST,
|
|
1863
|
+
SURFACE_LADDER_MAX_WORDS,
|
|
1864
|
+
composite,
|
|
1865
|
+
oklchL,
|
|
1866
|
+
contrastRatio,
|
|
1867
|
+
surfaceDeltaL,
|
|
1868
|
+
judgeSurfaceLadder,
|
|
1869
|
+
collectSurfaceLadder,
|
|
1870
|
+
summarizeSurfacePage,
|
|
1871
|
+
checkSurfaceLadder,
|
|
1872
|
+
formatSurfaceLadderReport,
|
|
1873
|
+
parseSurfaceLadderArgs,
|
|
1874
|
+
runSurfaceLadderCli
|
|
1456
1875
|
};
|
|
1457
|
-
//# sourceMappingURL=chunk-
|
|
1876
|
+
//# sourceMappingURL=chunk-KQ3UATBB.js.map
|