Redesign an existing website to make it better. Built on top of impeccable.
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
#!/usr/bin/env node
// skills/spec/scripts/test/spec-parse.test.mjs — the three parser profiles on fixture HTML: component roots, grid rows from column widths, colctrl columns, lazy images, page signals; the HTML reader (void, raw, implied end tags, template).
// Run: node plugins/stardust/skills/spec/scripts/test/spec-parse.test.mjs
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, readdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const HERE = dirname(fileURLToPath(import.meta.url));
let failed = 0;
const check = (name, fn) => { try { fn(); console.log(`✓ ${name}`); } catch (e) { failed += 1; console.log(`✗ ${name}\n ${e.message.split("\n").join("\n ")}`); } };
const helpCheck = (script) => check(`${script} --help prints usage and writes nothing`, () => {
const cwd = mkdtempSync(join(tmpdir(), "spec-help-"));
const r = spawnSync(process.execPath, ["--no-warnings", join(HERE, "..", script), "--help"], { cwd, encoding: "utf8" });
assert.equal(r.status, 0); assert.ok(r.stdout.includes(script), "usage names the script");
assert.deepEqual(readdirSync(cwd), []); rmSync(cwd, { recursive: true });
});
import { parseHTML, query, textLen, templateOf } from "../lib.mjs";
import { PROFILES, findMain, genericProfile, groupRows, profileFor, topLevel, pageSignals } from "../spec-parse.mjs";
const core = PROFILES["aem-core"];
check("reader: void, raw text, implied <p>, template content skipped", () => { const d = parseHTML(`<div id="m"><p>one<p>two<img src="a.jpg"><script>var x="<div>";</script><template><b>hidden</b></template></div>`); const m = query(d, "#m"); assert.equal(textLen(m), 7); assert.equal(m.children.filter((c) => c.tag === "p").length, 2); });
check("groupRows: 6+6 → one row; 12 alone; 4+4+4 → row", () => { const it = (w) => ({ w }); const g = groupRows([it(6), it(6), it(12), it(4), it(4), it(4)], (x) => x.w, () => false); assert.equal(g.length, 3); assert.equal(g[0].row.length, 2); assert.equal(g[2].row.length, 3); });
check("aem-core tree: container > row of two, lazy image counted", () => { const d = parseHTML(`<main><div class="aem-Grid"><div class="container responsivegrid aem-GridColumn aem-GridColumn--default--12"><div class="aem-Grid"><div class="image aem-GridColumn aem-GridColumn--default--6"><div data-cmp-src="/x.jpg"></div></div><div class="text aem-GridColumn aem-GridColumn--default--6"><p>Hello</p></div></div></div></div></main>`); const t = topLevel(query(d, "main"), core); assert.equal(t[0].c, "container"); assert.equal(t[0].kids[0].c, "row"); assert.deepEqual(t[0].kids[0].cols.map((c) => c[0].c), ["image", "text"]); assert.equal(t[0].kids[0].cols[0][0].imgs, 1); assert.equal(t[0].kids[0].cols[1][0].p, "0.k0.c1.0"); });
check("aem-classic tree: colctrl columns get .c<col>.<i> paths; a c-* class listed first names the root", () => { const d = parseHTML(`<div class="main content"><div class="cols2"><div class="colctrl"><div class="row"><div class="col-md-6"><div class="c-text">a</div></div><div class="col-md-6"><div class="c-image"><img src="x.jpg"></div><div class="c-text">b</div></div></div></div></div><div class="c-hero colctrl">h</div></div>`); const t = topLevel(query(d, ".main"), PROFILES["aem-classic"]); assert.deepEqual(t.map((n) => n.c), ["colctrl:cols2", "c-hero"]); assert.equal(t[0].ncols, 2); assert.deepEqual(t[0].cols.map((col) => col.map((n) => `${n.c}@${n.p}`)), [["c-text@0.c0.0"], ["c-image@0.c1.0", "c-text@0.c1.1"]]); assert.equal(t[1].cols, undefined); });
check("aem-classic in responsive grids: a member takes the name of the component it wraps, widths make rows; extraRoots names prefix-less components", () => {
const html = `<div class="main content"><div class="aem-Grid"><div class="text aem-GridColumn aem-GridColumn--default--6"><div class="c-text">a</div></div><div class="image aem-GridColumn aem-GridColumn--default--6"><div class="c-image"><img src="x.jpg"></div></div></div><div class="buttonset"><a href="/b">b</a></div><div class="c-hero">h</div></div>`;
const tree = (extraRoots) => topLevel(query(parseHTML(html), ".main"), profileFor({ parser: { profile: "aem-classic", extraRoots } }));
const t = tree(undefined);
assert.deepEqual(t.map((n) => [n.c, n.ncols ?? null]), [["row", 2], ["c-hero", null]], "two half-width members are one row; buttonset is not a component without extraRoots");
assert.deepEqual(t[0].cols.map((col) => col.map((n) => [n.c, n.kids?.length ?? 0])), [[["c-text", 0]], [["c-image", 0]]], "named as outside a grid; the wrapped c-* is not a second root");
assert.deepEqual(tree(["buttonset"]).map((n) => n.c), ["row", "buttonset", "c-hero"]);
});
check("signals: scripts, consent domain script, hreflang, json-ld", () => { const h = `<html lang="en"><head><link rel="alternate" hreflang="de" href="/de"><script src="https://cdn.vendor.com/a.js" data-domain-script="1234"></script><script type="application/ld+json">{"@type":"Organization"}</script></head><body data-x="1"><form action="/s?q=1"></form></body></html>`; const s = pageSignals(parseHTML(h), h, "https://example.com"); assert.deepEqual(s.scriptHosts, ["cdn.vendor.com"]); assert.deepEqual(s.otDomainScripts, ["1234"]); assert.deepEqual(s.hreflang, ["de"]); assert.deepEqual(s.jsonld, ["Organization"]); assert.deepEqual(s.forms, ["/s"]); assert.equal(s.bodyData["data-x"], "1"); assert.deepEqual(s.tagIds, []); });
check("signals: Google Consent Mode default from inline scripts only", () => { const on = `<html><head><script>gtag('consent', 'default', { analytics_storage: 'denied' });</script></head><body></body></html>`; const off = `<html><head><script>gtag('consent', 'update', {});</script></head><body><p>'consent','default'</p></body></html>`; assert.equal(pageSignals(parseHTML(on), on, "https://example.com").consentMode, true); assert.equal(pageSignals(parseHTML(off), off, "https://example.com").consentMode, false); });
check("signals: GTM and gtag container ids from inline snippets only", () => { const h = `<html><head><script>(function(w,d,s,l,i){})(window,document,"script","dataLayer","GTM-ABC123");gtag("config","G-XYZ789")</script></head><body><p>GTM-NOTME1</p></body></html>`; assert.deepEqual(pageSignals(parseHTML(h), h, "https://example.com").tagIds, ["GTM-ABC123", "G-XYZ789"]); });
check("templateOf appends path segments when configured", () => { const cfg = { scopePath: "/en/", template: { pathSegments: 2 } }; assert.equal(templateOf({ template: "base", url: "https://example.com/en/home/news/a.html" }, cfg), "base · home/news"); assert.equal(templateOf({ template: "base", url: "https://example.com/en/a.html" }, { scopePath: "/en/" }), "base"); });
check("generic: wrappers skipped, names from attribute, block class, BEM, CSS module, hash prefix, shape", () => { const d = parseHTML(`<body><header>nav</header><div id="app"><div class="wrapper"><section data-component="HeroBanner"><h1>Hi</h1></section><div class="wp-block-cover alignfull"><img src="a.jpg"></div><div class="promo-tile__inner promo-tile--dark">x</div><div class="Card_root__x7k2p mt-6">y</div><div class="qrk1f-w-logos">z</div><section class="relative mx-auto"><h2>T</h2><ul><li>a</li><li>b</li></ul></section><script>var a=1</script><div class="empty"></div></div></div><footer>f</footer></body>`); const { main, isBody } = findMain(d); assert.equal(isBody, true); const t = topLevel(main, genericProfile(), isBody); assert.deepEqual(t.map((n) => n.c), ["hero-banner", "cover", "promo-tile", "card", "logos", "section.h2.list"]); assert.equal(t[0].p, "0"); });
check("generic: kids only for two or more containers; stripPrefix and nameAttrs options", () => { const d = parseHTML(`<main><div class="x9-gallery"><div class="tile">a</div><div class="tile">b</div><p>text</p></div><div class="solo"><div class="one">c</div></div><div data-kind="faq">q</div></main>`); const t = topLevel(query(d, "main"), genericProfile({ stripPrefix: "^x9-", nameAttrs: ["data-kind"] })); assert.equal(t[0].c, "gallery"); assert.deepEqual(t[0].kids.map((k) => k.c), ["tile", "tile"]); assert.equal(t[0].kids[1].p, "0.k1"); assert.equal(t[1].kids, undefined); assert.equal(t[2].c, "faq"); });
check("generic: a block-style class wins over a plain class written before it (Drupal paragraphs)", () => { const d = parseHTML(`<main><div class="paragraph--12 paragraph paragraph--type--text-block">a</div><div class="paragraph paragraph--type--navigation-card">b</div><section class="paragraph paragraph--type--layout"><h2>x</h2><div class="paragraph paragraph--type--text-block">c</div><div class="paragraph paragraph--type--text-block">d</div></section></main>`); const t = topLevel(query(d, "main"), genericProfile()); assert.deepEqual(t.map((x) => x.c), ["text-block", "navigation-card", "section.h2"]); });
check("main fallback chain: [role=main] before body; explicit selector without fallback", () => { const d = parseHTML(`<body><div role="main" id="r"><p>a</p></div></body>`); assert.equal(findMain(d).main.attrs.id, "r"); assert.equal(findMain(d, "#nope").main, null); });
check("templateOf: a path-only rule names the template by its section", () => assert.equal(templateOf({ url: "https://example.com/blog/a" }, { scopePath: "/", template: { pathSegments: 1 } }), "blog"));
helpCheck("spec-parse.mjs");
process.exit(failed ? 1 : 0);.tessl-plugin
skills
audit
reference
deploy
reference
scripts
test
diff
direct
dynamics
extract
migrate
prepare-migration
prototype
assets
motion
fixtures
reference
qa
replica
reference
scripts
test
reskin
rollout
spec
stardust
uplift
reference