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
/**
* rollout/blocks.mjs — build the block dedup ledger (Phase 2).
*
* Reads coverage/pages.json (produced by inventory.mjs) and derives the set of
* DISTINCT blocks across the whole site — the dedup unit. Each distinct block is
* converted to an EDS block (or the /nav + /footer chrome documents) exactly ONCE; this
* ledger + plan.mjs make that dedup a driving step, not a post-hoc reconcile.
*
* Dedup signal (Phase 2): brand-module ids carried per page in the _meta.json
* sidecar `modules[]` (shared by construction) + chrome (header/nav/footer,
* site-wide singletons) + widgets (`widgets[] {id, href}`: kind `widget`, code at
* widgets/<path>/<name>.html, no document rows — the page carries one link). Finer section-archetype dedup via structural signatures
* is a later refinement; the `signature` field is reserved for it.
*
* Idempotent: existing block delivery status is preserved; a `default-content` mapping (a module
* that needs no block) keeps its name whatever its status.
*
* Usage: node skills/rollout/scripts/blocks.mjs [--out <rolloutDir>] (default stardust/rollout)
*
* Reads <out>/coverage/pages.json (required — run inventory.mjs first). Writes
* <out>/coverage/blocks.json (the ledger) and refreshes lastRun.blocks in <out>/rollout.json
* when that file exists. The summary goes to stdout. Exit 1 when pages.json is missing.
*/
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { readJSON, writeJSON, edsName, kindOf, blockCounts, widgetCodePath, DEFAULT_CONTENT } from './lib.mjs';
// --help prints this file's usage header, so an agent never reads the source to learn the flags.
if (process.argv.includes('--help') || process.argv.includes('-h')) {
const src = readFileSync(new URL(import.meta.url), 'utf8');
const header = src.match(/\/\*\*[\s\S]*?\*\//);
console.log(header ? header[0].replace(/^\/\*\*\s*|\s*\*\/$/g, '').replace(/^\s*\* ?/gm, '').trim() : 'no usage header');
process.exit(0);
}
const i = process.argv.indexOf('--out');
const OUT = i !== -1 && process.argv[i + 1] ? process.argv[i + 1] : 'stardust/rollout';
const STARDUST_VERSION = (readJSON(join(OUT, 'rollout.json'), {})._provenance || {}).stardustVersion || '0.0.0';
const pagesDoc = readJSON(join(OUT, 'coverage', 'pages.json'));
if (!pagesDoc) {
console.error(`rollout blocks: ${join(OUT, 'coverage', 'pages.json')} not found — run inventory.mjs first.`);
process.exit(1);
}
const pages = pagesDoc.pages || [];
const blocksPath = join(OUT, 'coverage', 'blocks.json');
const prior = new Map(((readJSON(blocksPath, { blocks: [] }) || {}).blocks || []).map((b) => [b.id, b]));
// Aggregate block instances across pages.
const agg = new Map(); // id -> { templates:Set, pages:[], count, kind, href }
const tally = (p, id, extra) => {
if (!agg.has(id)) agg.set(id, { templates: new Set(), pages: [], count: 0, ...extra });
const a = agg.get(id);
a.count += 1;
a.pages.push(p.slug);
if (p.templateId) a.templates.add(p.templateId);
};
for (const p of pages) {
for (const id of p.blocks || []) tally(p, id, { kind: kindOf(id) });
for (const w of p.widgets || []) tally(p, w.id, { kind: 'widget', href: w.href });
}
const now = new Date().toISOString();
const blocks = [...agg.entries()].map(([id, a]) => {
const { kind } = a;
const codePath = kind === 'chrome' ? `fragments/${edsName(id)}.html` : kind === 'widget' ? widgetCodePath(a.href) : null;
const p = prior.get(id);
const delivery = (p && p.delivery) || {
status: 'pending',
edsBlockName: kind === 'chrome' ? null : kind === 'widget' ? id : edsName(id), // a widget's class is its file stem verbatim (reservedStem is the lint's job)
blockPath: codePath,
convertedAt: null,
};
// Keep the derived EDS name fresh for not-yet-converted blocks — never over a default-content
// mapping, which is a resolved decision (no block to build) even while its status reads pending.
if (delivery.status === 'pending' && delivery.edsBlockName !== DEFAULT_CONTENT) {
delivery.edsBlockName = kind === 'chrome' ? null : edsName(id);
delivery.blockPath = codePath || delivery.blockPath || null;
}
return {
id,
label: id,
kind,
signature: `${kind}:${id}`,
source: null,
usedByTemplates: [...a.templates].sort(),
usedByPages: [...new Set(a.pages)].sort(),
instanceCount: a.count,
delivery,
};
}).sort((x, y) => x.id.localeCompare(y.id));
writeJSON(blocksPath, {
_provenance: { writtenBy: 'stardust:rollout/blocks', writtenAt: now, readArtifacts: [join(OUT, 'coverage', 'pages.json')], stardustVersion: STARDUST_VERSION },
generatedAt: now,
blocks,
});
// Refresh the block counts in rollout.json.
const configPath = join(OUT, 'rollout.json');
const config = readJSON(configPath);
if (config) {
config.lastRun = { ...(config.lastRun || {}), blocks: blockCounts(blocks) };
writeJSON(configPath, config);
}
const modules = blocks.filter((b) => b.kind === 'module');
const chrome = blocks.filter((b) => b.kind === 'chrome');
const widgets = blocks.filter((b) => b.kind === 'widget');
console.log(`rollout blocks → ${blocksPath}`);
console.log('='.repeat(60));
console.log(`Distinct blocks ${blocks.length} (${modules.length} module · ${chrome.length} chrome/fragment · ${widgets.length} widget)`);
console.log(`Reuse leverage ${pages.reduce((n, p) => n + (p.blocks || []).length + (p.widgets || []).length, 0)} instances → ${blocks.length} conversions`);
const top = [...modules].sort((a, b) => b.instanceCount - a.instanceCount).slice(0, 6);
if (top.length) console.log(`Most reused ${top.map((b) => `${b.id}×${b.instanceCount}`).join(', ')}`);
if (chrome.length) console.log(`Fragments ${chrome.map((b) => b.id).join(', ')}`);
if (widgets.length) console.log(`Widgets ${widgets.map((b) => `${b.id} → ${b.delivery.blockPath}`).join(', ')} (code only; no document rows)`);.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