Anti-AI-slop design skill for Claude Code, Cursor, and Codex.
CSS
The kept check closes five gaps a polish test found; a polish leaves spacing alone
Youssef636442c27e76
diff --git a/skills/hallmark/references/flow.md b/skills/hallmark/references/flow.mdindex 39c5d24..f849c34 100644--- a/skills/hallmark/references/flow.md+++ b/skills/hallmark/references/flow.md@@ -24,6 +24,8 @@ Hallmark will preserve: font stack, palette, spacing scale.Hallmark will introduce: shape, theme, gates, hero discipline, slots.```+The cache is the same block as JSON: `{ "scanned": "<date>", "findings": { "fonts": "…", "palette": "…", "motion": "…", "spacing": "…", "framework": "…" }, "preserve": [], "introduce": [] }`. An audit introduces nothing and says so.+## Component scopeSignals: the brief names one element (button, input, form, card, modal, dropdown, tooltip, select, checkbox, switch, tab strip, chip, badge, banner, snackbar, popover, slider, date picker, avatar, a single nav or footer); the brief is short and refers to one element; the target file is one component; the user says "just the X". Two signals: component. Ambiguous ("a pricing section"): ask once, *One pricing card, or the whole pricing page?*, defaulting to component.@@ -65,8 +67,8 @@ The Picks block drops Shape, Hero and Sections and names the screen instead: `ScTwo runs fix a page in place instead of building one: a polish (`redesign.md`) and signal 8, below. Enter at Step 7 over the files as they stand, with five differences:- **Infer the genre first** from the finished page and say so in one line; ambiguous between two, name both and apply only the universal gates.-- **Fix in place, and only the material half:** tokens, colour, type, motion, states, contrast, single elements (delete an eyebrow, add a focus ring, flatten a gradient, tint a grey). **Never restructure:** no moving sections, no re-picking a system, no swapping a nav.-- **Structural findings print, they do not get rebuilt:** 8 (page shape), 32 (archetype repeat), 42 (chrome), 44 (the fold). A short list with file:line and a one-line fix each; the user decides whether any of it earns a deeper redesign.+- **Fix in place, and only the material half:** tokens, colour, type, motion, states, contrast, single elements (fold an eyebrow into its heading, add a focus ring, flatten a gradient, tint a grey). **Never restructure:** no moving sections, no re-picking a system, no swapping a nav.+- **Structural findings print, they do not get rebuilt:** 6b and 44 (the hero and the fold), 8 (page shape), 9 (section rhythm), 32 (archetype repeat), 42 (chrome), 58 (the screen budget). A short list with file:line and a one-line fix each; the user decides whether any of it earns a deeper redesign.- **The log:** a polish logs its redesign entry; a signal 8 sweep logs nothing, since Hallmark built nothing and nothing rotates.- **The check stamp** replaces the build stamp as the first line of CSS, so gate 20 reads it. Its last line says who built the page: `built: the project · redesign: polish`, or `built: external (reference archive)`.diff --git a/skills/hallmark/references/gates.md b/skills/hallmark/references/gates.mdindex ea90667..332c592 100644--- a/skills/hallmark/references/gates.md+++ b/skills/hallmark/references/gates.md@@ -191,7 +191,7 @@ The gates above that a script cannot settle, with enough to judge them well.**47c, imitation material.** The question is whether the thing pretends. A `data-slot` placeholder labelled "your screenshot" does not pretend; a styled-div dashboard with invented figures does. Geometry that is geometry (a diagram, a chart, an animated line) is a first-class medium; geometry pretending to be a picture is the tell. Grids and stripes need a canvas, a map or a measuring tool under them.-**54, the eyebrow test.** Small type before a heading survives only when it carries a fact, a destination or an identifier the reader would otherwise lack. Delete the line and read the page: if nothing was lost but a name for what comes next, it was an eyebrow. The fix is never bare deletion; `craft.md` § Opening a section has twelve other ways in.+**54, the eyebrow test.** Small type before a heading survives only when it carries a fact, a destination or an identifier the reader would otherwise lack. Delete the line and read the page: if nothing was lost but a name for what comes next, it was an eyebrow. The fix is never bare deletion; `craft.md` § Opening a section has twelve other ways in, and where the heading under it is figurative the plain label becomes the heading.**58, the screen budget.** Nobody reads a landing page. A visitor takes one idea per screen or leaves. About 80 words per 900px window, labels and cells included; the hero is a headline, one sentence and its actions.diff --git a/skills/hallmark/references/redesign.md b/skills/hallmark/references/redesign.mdindex 4eb16d5..141d6b7 100644--- a/skills/hallmark/references/redesign.md+++ b/skills/hallmark/references/redesign.md@@ -7,8 +7,8 @@ Loaded when the request opens with `redesign` or `audit`, or plainly asks to red- **The content.** Every fact, claim, name, price, date and quote the page states. Figures, quotes and logos already on the page are the user's material: carried over as found, never added to, and listed in the handoff for the user to verify.- **The wiring.** Every link, form field, action, handler, route, id and test hook; every script, data call and analytics call. Edit markup inside the component that owns it. Never move logic, rename a prop, or drop a `name`, an `id`, a `key`, an `href` or a `data-testid` that a script or a test reads.- **The files.** No file deleted, no route removed and no component tree replaced without a file-level plan the user approved, and no test edited to make the redesign pass. Documents in the repo (a README, a brief, a deck) explain the product; they are not page copy. In a git project, start from a clean tree, `.hallmark/` aside (ask the user to commit or stash; never do it for them), so the redesign is one diff they can read and revert.-- **The brand.** A logo, a brand colour and a brand face the pre-flight finds stay at every depth unless the user lets them go; a real brand runs `brand-truth.md`. A locked `design.md` is the system at every depth.-- **The words,** unless a gate names them. Wording that fails a copy gate (19, 58, 63, 69) is tightened from the facts already on the page, and the handoff lists every changed line, before and after. Terms, disclaimers and consent text are never reworded. When the user says to keep every word, stamp `copy: verbatim`: 19, 58 and 69 then report as notes.+- **The brand.** A logo, a brand colour and a brand face the pre-flight finds stay at every depth unless the user lets them go; their values come from the project's own files, never from memory. A locked `design.md` is the system at every depth.+- **The words,** unless a gate names them. Wording that fails a copy gate (19, 54, 58, 63, 69) is tightened from the facts already on the page, and the handoff lists every changed line, before and after. An eyebrow is never just deleted: where its heading is figurative, the plain label becomes the heading or folds into it (*Opening hours* over *When to find us* becomes *Opening hours*). Terms, disclaimers and consent text are never reworded. When the user says to keep every word, stamp `copy: verbatim`: 19, 58 and 69 then report as notes.## Depth@@ -58,8 +58,9 @@ Then the build rows the depth reaches: Theme at restyle and full (dealt, `brand`## Build-- **Polish** is `flow.md` § The sweep, on the user's own page: fix in place, single elements and tokens, never restructure, under the check stamp with `built: the project · redesign: polish`.-- **Where the layout stays** (polish and restyle), the stamp's `redesign:` field tells sloplint to report the layout gates (6b, 8, 9, 32, 42, 44a, 44c, 58) as notes. Print them for the user with the depth that would settle them; do not rebuild them.+- **Polish** is `flow.md` § The sweep, on the user's own page: fix in place, single elements and tokens, never restructure, under the check stamp with `built: the project · redesign: polish`. It loads `gates.md` § 1 to § 5 and `patterns.md`, `interaction-and-states.md` when the page has a form, and from `craft.md` only the section a finding points at.+- **Where the layout stays** (polish and restyle), the stamp's `redesign:` field tells sloplint to report the layout gates (6b, 8, 9, 32, 42, 44a, 44c, 58) as notes; at polish the spacing gates (24b, 59) too, so a polish does not re-space a site it was asked to keep. Print them for the user with the depth that would settle them; do not rebuild them.+- **The stylesheet is the redesign's to edit.** The append-only rule guards a project's stylesheet from a build, not from its own redesign; the framework's directives still stay where they are.- **Restyle and full** start from the scaffold: `tokens.css` and `base.css` imported below the project's own styles and mapped onto the project's token names (a Tailwind theme, shadcn variables: `export-formats.md`). Pass the depth so the stamp carries it: `theme.mjs scaffold <slug> --redesign <depth>`. A kept brand takes `scaffold --brand --redesign <depth>` and fills the tokens from the palette and faces the pre-flight found (no `check`: the coordinates are the user's); otherwise the deal runs as in Step 3. Then the shared components and the chrome, then the pages, the most visited first, each swept before the next.- **More than one page** at restyle or full: lock the system first (`design-md.md`). Every page reads it and the variety rule inverts: pages share theme, type and accent, and differ only in shape. Past three pages, give each page to its own subagent where the harness has them, with `design.md`, the page's files and this file.- **Full depth** runs the hero stage and the hero review. Polish and restyle skip both.@@ -68,7 +69,7 @@ Then the build rows the depth reaches: Theme at restyle and full (dealt, `brand`1. The sweep, against the record: `sloplint <target> --render --kept`. Anything the page had and no longer has is a `FAIL kept` (a link, a field, a form action, a handler, a test hook, a selector a script still queries) or a `WARN kept` (a heading, a figure, an image, an id). Restore it, or record what the user agreed to lose: `/* Hallmark · dropped /blog, #team · the user is retiring the blog and the team section */`. The run also writes `.hallmark/compare.html`, the before and after screenshots side by side: give the user its path.2. The project's own checks, where it has them: the type check, the build, the tests. A redesign that breaks one is not finished.-3. The finish review also takes the `before` screenshots and answers what the old page did better (`review-finish.md`).+3. The finish review also takes the `before` screenshots and answers what the old page did better (`review-finish.md`). A polish hands it only the full pages at 1440, before and after, and takes at most five findings. A finding that is a plain defect (a misalignment, a broken glyph, a label that lies) is fixed at any depth; one that asks for a new composition joins the layout findings.4. The log entry carries `mode: redesign`, `depth` and `scope` (page, site or app), plus the build's fields at full depth.5. The handoff, ahead of the material ask:@@ -80,6 +81,7 @@ Kept 14/14 links · 5/5 fields · 9/9 handlers · 11/11 headings · every fiChanged the system: colour, type, radius, motion, the controlsDropped noneLayout 2 findings a full redesign would settle (8, 42), listed below+Next say *redesign it fully* to recompose the pagesYours 2 claims kept as found ("50,000+ teams", the Acme quote) · 4 lines reworded, listed belowCompare .hallmark/compare.html```diff --git a/skills/hallmark/scripts/sloplint-render.mjs b/skills/hallmark/scripts/sloplint-render.mjsindex 607fe7f..822a109 100644--- a/skills/hallmark/scripts/sloplint-render.mjs+++ b/skills/hallmark/scripts/sloplint-render.mjs@@ -10,7 +10,7 @@ const slugOf = (t) => isUrl(t) ? t.replace(/^https?:\/\//, '').replace(/[^\w.-]+const SHOTS = [];let SHOT_DIR = 'shots';-const frames = (page) => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)))).catch(() => {});+const frames = (page) => page.evaluate(async () => { if (document.fonts && document.fonts.status !== 'loaded') await Promise.race([document.fonts.ready, new Promise((r) => setTimeout(r, 3000))]); await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))); }).catch(() => {});function contrast(a, b) {const lin = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);const Y = (c) => 0.2126 * lin(c[0]) + 0.7152 * lin(c[1]) + 0.0722 * lin(c[2]);@@ -169,7 +169,7 @@ export async function renderCheck(htmlFiles, metaIn) {if (!heroOnly) {await page.setViewport({ width: 1440, height: 900 });await frames(page);- inventories[file] = await page.evaluate(inventory).catch(() => null);+ inventories[file] = await page.evaluate(inventory, (meta.selectors && meta.selectors[file]) || []).catch(() => null);const quality = await page.evaluate(observeQuality, meta.scope).catch(() => []);const hidden = await page.evaluate(observeOcclusion).catch(() => []);for (const f of [...quality, ...hidden]) findings.push({ ...f, file, line: 1, evidence: `[1440px] ${f.evidence}` });@@ -288,7 +288,7 @@ ${body}return made;}-function inventory() {+function inventory(selectors) {const base = location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1);const key = (raw) => {try {@@ -305,12 +305,21 @@ function inventory() {const links = uniq([...document.querySelectorAll('a[href]')].map((a) => a.getAttribute('href')).filter((h) => h && h.trim() && h.trim() !== '#').map(key));const fields = uniq([...document.querySelectorAll('input[name], select[name], textarea[name], button[name]')].map((f) => f.getAttribute('name')));const actions = uniq([...document.querySelectorAll('form[action]')].map((f) => `${(f.getAttribute('method') || 'get').toLowerCase()} ${key(f.getAttribute('action'))}`));+ const forms = [...document.querySelectorAll('form')].map((f, i) => ({+ key: f.id ? `#${f.id}` : f.getAttribute('action') ? `${(f.getAttribute('method') || 'get').toLowerCase()} ${key(f.getAttribute('action'))}` : `form ${i + 1}`,+ attrs: [`method=${(f.getAttribute('method') || 'get').toLowerCase()}`, f.getAttribute('action') ? `action=${key(f.getAttribute('action'))}` : '', f.hasAttribute('novalidate') ? 'novalidate' : ''].filter(Boolean),+ fields: uniq([...f.querySelectorAll('input[name], select[name], textarea[name]')].map((c) => c.getAttribute('name'))),+ hidden: uniq([...f.querySelectorAll('input[type="hidden"][name]')].map((c) => `${c.getAttribute('name')}=${c.getAttribute('value') || ''}`)),+ submits: f.querySelectorAll('button:not([type]), button[type="submit"], input[type="submit"], input[type="image"]').length,+ controls: uniq([...f.querySelectorAll('button, input, select, textarea')].map((c) => `${c.tagName.toLowerCase()}${c.getAttribute('type') ? `[type=${c.getAttribute('type')}]` : ''}${c.getAttribute('name') ? `[name=${c.getAttribute('name')}]` : ''}`)),+ }));+ const hooked = (selectors || []).filter((x) => { try { return !!document.querySelector(x); } catch { return false; } });const headings = uniq([...document.querySelectorAll('h1, h2, h3, h4')].filter((h) => !quiet(h)).map((h) => text(h).toLowerCase()).filter((t) => t.length > 1));const body = text(document.body);const figures = uniq((body.match(/[$€£¥]\s?\d[\d,.]*\+?[kKmM]?|\b\d[\d,.]*\s?%|\b\d[\d,.]*[kKmM]?\+(?=\s|$)|\b\d{1,3}(?:,\d{3})+\b|\b\d{1,2}[:.]\d{2}\s?(?:am|pm)?\b|\b(?:19|20)\d{2}\b|\b\d+(?:\.\d+)?\s(?:hours?|minutes?|mins?|days?|weeks?|months?|years?|seconds?|ms|km|kg|g|ml|mm|cm|gb|mb|tb|x)\b|\+?\d[\d\s().-]{7,}\d/gi) || []).map((t) => t.replace(/\s+/g, '').toLowerCase()));const images = uniq([...document.querySelectorAll('img[src]')].map((i) => (i.getAttribute('src') || '').split('?')[0].split('/').pop()));const controls = document.querySelectorAll('button, [role="button"], input[type="submit"], input[type="button"], select, textarea, input:not([type="hidden"])').length;- return { links, fields, actions, headings, figures, images, controls, words: body ? body.split(' ').length : 0 };+ return { links, fields, actions, forms, hooked, headings, figures, images, controls, words: body ? body.split(' ').length : 0 };}function focusRing() {diff --git a/skills/hallmark/scripts/sloplint.mjs b/skills/hallmark/scripts/sloplint.mjsindex 2182135..5fb288d 100644--- a/skills/hallmark/scripts/sloplint.mjs+++ b/skills/hallmark/scripts/sloplint.mjs@@ -884,6 +884,7 @@ let VERBATIM = false;let APPSCREEN = false;let LAYOUT_KEPT = false;const STRUCTURAL = new Set(['6b', '8', '9', '32', '42', '44a', '44c', '58']);+const SPACING = new Set(['24b', '59']);const COPY_GATES = new Set(['19', '58', '69']);const findings = [];@@ -897,7 +898,7 @@ function report(gate, grade, file, line, evidence, fix) {const b = baseGate(g);const waived = WAIVED.has(b) || WAIVED.has(gateNumber(b));if (VERBATIM && COPY_GATES.has(gateNumber(b)) && (grade === 'FAIL' || grade === 'WARN')) grade = 'NOTE';- if (LAYOUT_KEPT && (STRUCTURAL.has(b) || STRUCTURAL.has(gateNumber(b))) && grade !== 'NOTE') grade = 'NOTE';+ if (LAYOUT_KEPT && (STRUCTURAL.has(b) || STRUCTURAL.has(gateNumber(b)) || (LAYOUT_KEPT === 'polish' && SPACING.has(b))) && grade !== 'NOTE') grade = 'NOTE';if (grade === 'FAIL') {if (tier === 'ledger') grade = 'NOTE';else if (tier === 'reflex') grade = waived ? 'WAIVED' : 'REFLEX';@@ -912,7 +913,7 @@ function applyWaivers(ctx, dir) {WAIVED = new Set(); ANSWERED = new Set(); DISMISSED = new Set();VERBATIM = /\bcopy:\s*verbatim\b/i.test(ctx.stampText);APPSCREEN = /\bshape:\s*app screen\b/i.test(ctx.stampText);- LAYOUT_KEPT = /\bredesign:\s*(?:polish|restyle)\b/i.test(ctx.stampText);+ LAYOUT_KEPT = (/\bredesign:\s*(polish|restyle)\b/i.exec(ctx.stampText) || [])[1]?.toLowerCase() || false;const re = /\/\*\s*Hallmark\s*·\s*waive\s+(\d{1,2}[a-z]{0,3}|F\d+)\s*·\s*([^·*]+?)\s*·\s*([^*]+?)\s*\*\//gi;const claims = [...ctx.stampText.matchAll(re)].map((m) => ({id: m[1], evidence: m[2].trim(), reason: m[3].trim(), raw: m[0],@@ -4049,9 +4050,9 @@ if (opts.render) {if (!htmlFiles.length && !opts.urls.length) renderNotRun = 'no HTML page to render; pass --url for a running dev server';else try {const mod = await import(new URL('./sloplint-render.mjs', import.meta.url).href);- const extra = await mod.renderCheck([...htmlFiles, ...opts.urls], { genre: opts.genre, postureByFile, heroPostureByFile, stage: opts.stage, scope: opts.scope === 'app' || [...waiversByKey.values()].some((x) => x.APPSCREEN) ? 'app' : opts.scope, before: opts.before });+ const extra = await mod.renderCheck([...htmlFiles, ...opts.urls], { genre: opts.genre, postureByFile, heroPostureByFile, stage: opts.stage, selectors: opts.before || opts.kept ? Object.fromEntries([...new Set(contexts.flatMap(([, c]) => c.docs))].filter((d) => d.kind === 'html').map((d) => [d.file, scriptSelectors(d)])) : {}, scope: opts.scope === 'app' || [...waiversByKey.values()].some((x) => x.APPSCREEN) ? 'app' : opts.scope, before: opts.before });domInventories = extra.inventories || {};- const allWaivers = { WAIVED: new Set([...waiversByKey.values()].flatMap((x) => [...x.WAIVED])), ANSWERED: new Set([...waiversByKey.values()].flatMap((x) => [...x.ANSWERED])), DISMISSED: new Set([...waiversByKey.values()].flatMap((x) => [...(x.DISMISSED || [])])), VERBATIM: [...waiversByKey.values()].some((x) => x.VERBATIM), APPSCREEN: [...waiversByKey.values()].some((x) => x.APPSCREEN), LAYOUT_KEPT: [...waiversByKey.values()].some((x) => x.LAYOUT_KEPT) };+ const allWaivers = { WAIVED: new Set([...waiversByKey.values()].flatMap((x) => [...x.WAIVED])), ANSWERED: new Set([...waiversByKey.values()].flatMap((x) => [...x.ANSWERED])), DISMISSED: new Set([...waiversByKey.values()].flatMap((x) => [...(x.DISMISSED || [])])), VERBATIM: [...waiversByKey.values()].some((x) => x.VERBATIM), APPSCREEN: [...waiversByKey.values()].some((x) => x.APPSCREEN), LAYOUT_KEPT: [...waiversByKey.values()].map((x) => x.LAYOUT_KEPT).find(Boolean) || false };for (const f of extra) {const w = /^https?:/.test(f.file) ? allWaivers : (waiversByKey.get(f.file) || waiversByKey.get(dirname(f.file)));WAIVED = w ? w.WAIVED : new Set();@@ -4059,7 +4060,7 @@ if (opts.render) {DISMISSED = w ? (w.DISMISSED || new Set()) : new Set();VERBATIM = !!(w && w.VERBATIM);APPSCREEN = !!(w && w.APPSCREEN);- LAYOUT_KEPT = !!(w && w.LAYOUT_KEPT);+ LAYOUT_KEPT = (w && w.LAYOUT_KEPT) || false;report(f.gate, f.grade === 'REFLEX' ? 'FAIL' : f.grade, f.file, f.line, f.evidence, f.fix);}for (const x of extra.failed || []) { WAIVED = new Set(); ANSWERED = new Set(); DISMISSED = new Set(); VERBATIM = false; APPSCREEN = false; LAYOUT_KEPT = false; report('render', 'FAIL', x.file, 1, `the page did not render (${trunc(x.message, 60)}); its render gates did not run`, 'Fix the page or the URL and rerun; an unrendered page is never a pass'); }@@ -4074,7 +4075,7 @@ const squash = (t) => t.replace(/\s+/g, ' ').trim();const escRe = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');function wiringOf(src) {const body = src.replace(/<!--[\s\S]*?-->/g, '');- const w = { handlers: [], links: [], fields: [], hooks: [], ids: [] };+ const w = { handlers: [], links: [], fields: [], hooks: [], ids: [], scripts: [] };const val = String.raw`("[^"]*"|'[^']*'|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})`;for (const m of body.matchAll(new RegExp(String.raw`(?<![\w-])(on[A-Z]\w*|on:[\w|]+|@[a-z][\w.:-]*|v-on:[\w.:-]+|on(?:click|submit|change|input|keydown|keyup|blur|focus))\s*=\s*` + val, 'g'))) w.handlers.push(`${m[1]}=${squash(m[2])}`);for (const m of body.matchAll(new RegExp(String.raw`(?<![\w:-])(?:href|to|action)\s*=\s*` + val, 'g'))) { const v = squash(m[1]).replace(/^["']|["']$/g, '').replace(/^\.\//, ''); if (v && v !== '#') w.links.push(v); }@@ -4085,24 +4086,33 @@ function wiringOf(src) {for (const m of body.matchAll(/\bregister\(\s*["']([\w.-]+)["']/g)) w.fields.push(m[1]);for (const m of body.matchAll(new RegExp(String.raw`\bdata-(?:testid|test|cy|qa|track[\w-]*|analytics[\w-]*|event[\w-]*|gtm[\w-]*)\s*=\s*` + val, 'g'))) w.hooks.push(squash(m[1]).replace(/^["']|["']$/g, ''));for (const m of body.matchAll(/(?<![\w-])id\s*=\s*["']([^"'{}\s]+)["']/g)) w.ids.push(m[1]);+ for (const m of body.matchAll(/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi)) w.scripts.push(m[1].split('?')[0].replace(/^\.\//, ''));return w;}-function scriptHooks(doc) {+function scriptText(doc) {const raw = doc.raw || doc.src;- const markup = raw.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, '');- let js = [...raw.matchAll(/<script\b(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi)].map((m) => m[1]).join('\n');+ let js = [...raw.matchAll(/<script\b(?![^>]*\bsrc\s*=)(?![^>]*application\/(?:ld\+)?json)[^>]*>([\s\S]*?)<\/script>/gi)].map((m) => m[1]).join('\n');for (const m of raw.matchAll(/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi)) {if (/^(?:https?:)?\/\//.test(m[1])) continue;try { js += '\n' + readFileSync(resolve(dirname(doc.file), m[1].split('?')[0]), 'utf8'); } catch {}}+ return js;+}+function scriptSelectors(doc) {+ const js = scriptText(doc);const sels = new Set();for (const m of js.matchAll(/getElementById\(\s*["'`]([\w-]+)["'`]/g)) sels.add('#' + m[1]);- for (const m of js.matchAll(/(?:querySelector(?:All)?|closest|matches)\(\s*["'`]([^"'`]+)["'`]/g)) for (const t of m[1].matchAll(/#[\w-]+|\.[A-Za-z_][\w-]*|\[data-[\w-]+/g)) sels.add(t[0][0] === '[' ? t[0] + ']' : t[0]);- const has = (sel) => sel[0] === '#' ? new RegExp(`(?<![\\w-])id\\s*=\\s*["']${escRe(sel.slice(1))}["']`).test(markup)- : sel[0] === '.' ? new RegExp(`(?<![\\w-])class\\s*=\\s*["'][^"']*(?<![\\w-])${escRe(sel.slice(1))}(?![\\w-])`).test(markup)- : markup.includes(sel.slice(1, -1));- const queried = [...sels].sort();- return { queried, hooked: queried.filter(has) };+ for (const m of js.matchAll(/(?:querySelector(?:All)?|closest|matches)\(\s*(["'`])((?:(?!\1)[^\\\n])+)\1/g)) if (!m[2].includes('${')) sels.add(m[2].trim());+ return [...sels].sort();+}+function scriptHooks(doc) {+ const markup = (doc.raw || doc.src).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, '');+ const has = (tok) => tok[0] === '#' ? new RegExp(`(?<![\\w-])id\\s*=\\s*["']${escRe(tok.slice(1))}["']`).test(markup)+ : tok[0] === '.' ? new RegExp(`(?<![\\w-])class\\s*=\\s*["'][^"']*(?<![\\w-])${escRe(tok.slice(1))}(?![\\w-])`).test(markup)+ : markup.includes(tok.slice(1));+ const queried = scriptSelectors(doc);+ const tokens = (sel) => [...sel.matchAll(/#[\w-]+|\.[A-Za-z_][\w-]*|\[data-[\w-]+/g)].map((t) => t[0]);+ return { queried, hooked: queried.filter((sel) => { const t = tokens(sel); return t.length > 0 && t.every(has); }) };}function takeInventory() {const docs = [...new Set(contexts.flatMap(([, c]) => c.docs))];@@ -4111,7 +4121,13 @@ function takeInventory() {const pages = {};for (const [file, inv] of Object.entries(domInventories)) if (inv) pages[/^https?:/.test(file) ? file : rel(file)] = inv;const scripts = {};- for (const d of docs) if (d.kind === 'html') { const h = scriptHooks(d); if (h.queried.length) scripts[rel(d.file)] = h; }+ for (const d of docs) if (d.kind === 'html') {+ const h = scriptHooks(d);+ const dom = domInventories[d.file];+ if (dom && Array.isArray(dom.hooked)) h.dom = dom.hooked;+ h.hides = /\.hidden\s*=|["'`]hidden["'`]/.test(scriptText(d));+ if (h.queried.length || h.hides) scripts[rel(d.file)] = h;+ }return { files: byFile, wiring: unionWiring(Object.values(byFile)), scripts, pages };}function unionWiring(list) {@@ -4137,7 +4153,7 @@ if (opts.kept) {if (allowed.some((t) => x.toLowerCase() === t || (t.length >= 4 && x.toLowerCase().includes(t)))) { if (cat) (acked[cat] ||= new Set()).add(x); return false; }return true;});- const hard = { links: new Set(), fields: new Set(), 'form actions': new Set(), handlers: new Set(), 'test hooks': new Set() };+ const hard = { links: new Set(), fields: new Set(), forms: new Set(), handlers: new Set(), 'test hooks': new Set(), scripts: new Set() };const soft = { headings: new Set(), figures: new Set(), images: new Set(), ids: new Set() };const total = { links: new Set(was.wiring.links), fields: new Set(was.wiring.fields), handlers: new Set(was.wiring.handlers), 'test hooks': new Set(was.wiring.hooks), headings: new Set(), figures: new Set() };for (const x of gone(was.wiring.links, now.wiring.links, 'links')) hard.links.add(x);@@ -4145,6 +4161,7 @@ if (opts.kept) {for (const x of gone(was.wiring.handlers, now.wiring.handlers, 'handlers')) hard.handlers.add(x);for (const x of gone(was.wiring.hooks, now.wiring.hooks, 'test hooks')) hard['test hooks'].add(x);for (const x of gone(was.wiring.ids, now.wiring.ids)) soft.ids.add(x);+ for (const [f, w] of Object.entries(was.files || {})) if (now.files[f]) for (const x of gone(w.scripts, now.files[f].scripts)) hard.scripts.add(`${x} on ${f}`);const skipped = [];let wordsWas = 0, wordsNow = 0;for (const [k, b] of Object.entries(was.pages || {})) {@@ -4155,8 +4172,8 @@ if (opts.kept) {for (const x of b.headings || []) total.headings.add(x);for (const x of b.figures || []) total.figures.add(x);for (const x of gone(b.links, [...a.links, ...now.wiring.links], 'links')) hard.links.add(x);- for (const x of gone(b.fields, [...a.fields, ...now.wiring.fields], 'fields')) hard.fields.add(x);- for (const x of gone(b.actions, a.actions)) hard['form actions'].add(x);+ for (const x of gone(b.fields, a.fields, 'fields')) hard.fields.add(x);+ for (const x of gone(b.actions, a.actions)) hard.forms.add(x);for (const x of gone(b.headings, a.headings, 'headings')) soft.headings.add(x);for (const x of gone(b.figures, a.figures, 'figures')) soft.figures.add(x);for (const x of gone(b.images, a.images)) soft.images.add(x);@@ -4164,18 +4181,38 @@ if (opts.kept) {}const list = (set, n = 8) => { const a = [...set]; return a.slice(0, n).map((x) => trunc(x, 48)).join(', ') + (a.length > n ? ` and ${a.length - n} more` : ''); };const fix = 'Restore each one, or record it in the stamp: /* Hallmark · dropped <item>, <item> · <the reason, in the user\'s words> */';- for (const [k, set] of Object.entries(hard)) if (set.size) report('kept', 'FAIL', SNAP, 1, `${k} the page had before and no longer has: ${list(set)}`, fix);+ total['script hooks'] = new Set(); hard['script hooks'] = new Set();for (const [f, h] of Object.entries(was.scripts || {})) {+ if (outside.includes(f)) continue;const n = now.scripts[f];- const unhooked = n ? h.hooked.filter((x) => n.queried.includes(x) && !n.hooked.includes(x)) : [];- if (unhooked.length) report('kept', 'FAIL', resolve(f), 1, `a script still queries ${list(unhooked)}, which this page's markup no longer has`, 'Keep the ids, classes and data attributes scripts query, or change the script with the markup');+ const both = n && h.dom && n.dom;+ const had = both ? h.dom : h.hooked;+ for (const x of had) total['script hooks'].add(`${f} ${x}`);+ const unhooked = n ? had.filter((x) => n.queried.includes(x) && !(both ? n.dom : n.hooked).includes(x)) : [];+ for (const x of unhooked) hard['script hooks'].add(`${f} ${x}`);+ }+ const guard = contexts.some(([, c]) => c.rules.some((r) => /\[hidden\]/.test(r.selector) && r.decls.some((d) => d.prop === 'display' && /none/.test(d.value))));+ if (!guard && Object.values(now.scripts).some((h) => h.hides)) report('kept', 'FAIL', SNAP, 1, 'a script hides elements with the hidden attribute and no rule pins it, so any display rule shows them again', 'Add [hidden] { display: none !important; } to the stylesheet');+ for (const [k, b] of Object.entries(was.pages || {})) {+ const a = now.pages[k];+ if (!a) continue;+ for (const bf of b.forms || []) {+ const af = (a.forms || []).find((x) => x.key === bf.key) || (a.forms || []).find((x) => x.attrs.join() === bf.attrs.join());+ if (!af) { if (!allowed.includes(bf.key.toLowerCase())) hard.forms.add(`the form ${bf.key} on ${k}`); continue; }+ for (const x of bf.fields) if (!af.fields.includes(x) && !allowed.includes(x.toLowerCase())) hard.fields.add(`${x} in ${bf.key} on ${k}`);+ for (const x of bf.hidden) if (!af.hidden.includes(x)) hard.fields.add(`hidden ${x} in ${bf.key} on ${k}`);+ for (const x of bf.attrs) if (!af.attrs.includes(x)) hard.forms.add(`${x} on ${bf.key} (${k})`);+ if (bf.submits && !af.submits) hard.forms.add(`a submit control in ${bf.key} (${k})`);+ for (const x of bf.controls || []) if (!(af.controls || []).includes(x) && !allowed.some((t) => x.toLowerCase().includes(t) && t.length >= 4)) hard.forms.add(`${x} in ${bf.key} (${k})`);+ }}+ for (const [k, set] of Object.entries(hard)) if (set.size) report('kept', 'FAIL', SNAP, 1, k === 'script hooks' ? `a script still queries what its page no longer has: ${list(set)}` : k === 'forms' ? `a form lost what it had before: ${list(set)}` : `${k} the page had before and no longer has: ${list(set)}`, k === 'script hooks' ? 'Keep the ids, classes and attributes scripts query, or change the script with the markup' : fix);for (const [k, set] of Object.entries(soft)) if (set.size) report('kept', 'WARN', SNAP, 1, `${k} gone or reworded since the before record: ${list(set)}`, 'Confirm each was meant to go, restore it, or record it as dropped in the stamp');if (wordsWas > 80 && wordsNow < wordsWas * 0.6) report('kept', 'WARN', SNAP, 1, `the pages hold ${wordsNow} words where they held ${wordsWas}`, 'Check that no section of content was dropped');if (skipped.length) report('kept', 'WARN', SNAP, 1, `not compared, because this run did not render them: ${list(skipped, 4)}`, 'Render the same pages or URLs the before record holds');if (outside.length) report('kept', 'WARN', SNAP, 1, `not compared, because this run did not read them: ${list(outside, 4)}`, 'Run --kept on the same target as --before');const lostOf = (k) => (hard[k] || soft[k]).size;- keptLine = { parts: ['links', 'fields', 'handlers', 'test hooks', 'headings', 'figures'].filter((k) => total[k].size).map((k) => { const d = acked[k] ? acked[k].size : 0; return `${k} ${Math.max(0, total[k].size - lostOf(k) - d)}/${total[k].size}${d ? ` (${d} dropped on record)` : ''}`; }), was: was.summary || null };+ keptLine = { parts: ['links', 'fields', 'handlers', 'test hooks', 'script hooks', 'headings', 'figures'].filter((k) => total[k].size).map((k) => { const d = acked[k] ? acked[k].size : 0; return `${k} ${Math.max(0, total[k].size - lostOf(k) - d)}/${total[k].size}${d ? ` (${d} dropped on record)` : ''}`; }), was: was.summary || null };}}@@ -4272,4 +4309,5 @@ if (opts.json) {if (compareNote) console.log(compareNote);if (beforeLine) console.log(beforeLine);}-process.exit(!opts.before && (fails > 0 || reflex > 0) ? 1 : 0);+const exitCode = !opts.before && (fails > 0 || reflex > 0) ? 1 : 0;+if (process.stdout.writableLength) process.stdout.once('drain', () => process.exit(exitCode)); else process.exit(exitCode);diff --git a/skills/hallmark/scripts/theme.mjs b/skills/hallmark/scripts/theme.mjsindex 02693aa..62fc6d8 100644--- a/skills/hallmark/scripts/theme.mjs+++ b/skills/hallmark/scripts/theme.mjs@@ -253,6 +253,7 @@ p { margin: 0; text-wrap: pretty; }p:not([class]) { max-width: 65ch; }img, video { max-width: 100%; height: auto; display: block; }svg { display: block; }+[hidden] { display: none !important; }button, input, select, textarea { font: inherit; }.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); box-sizing: border-box; }.num, .figure, td.num { font-variant-numeric: tabular-nums; }