Skip to content

Clone any website into a pixel-accurate Next.js app with AI — Playwright-measured extraction (no eyeballing), spec-gated parallel builder agents, and scored pixel-diff QA at phone/tablet/desktop. Works with Claude Code, Cursor, Copilot + 9 more.

feat(manifest): scripts self-report stage transitions (T6)

Mahanaicoach47335d8cae2d
diff --git a/.amazonq/cli-agents/clone-website.json b/.amazonq/cli-agents/clone-website.json
index a209cb1..3b4c8d1 100644
--- a/.amazonq/cli-agents/clone-website.json
+++ b/.amazonq/cli-agents/clone-website.json
@@ -1,7 +1,7 @@
{
"name": "clone-website",
"description": "Reverse-engineer and clone a full multi-page website as a pixel-accurate Next.js replica",
- "prompt": "# Clone Website\n\nReverse-engineer and rebuild **the target URL (plus any extra instructions) provided by the user** as a pixel-accurate, multi-page Next.js clone.\n\nYou are a **foreman walking the job site**: scripts do the measuring, you do the judgment, specs are the contract, builder agents do the construction, and the pixel-diff score decides when you're done. Extraction and construction overlap — dispatch builders as soon as a section's spec passes lint, then keep extracting.\n\n## Resume Check (ALWAYS FIRST)\n\n```bash\nnode scripts/manifest.mjs status\n```\n\nIf a manifest exists, this is a **resumed run**: skip everything already done (`node scripts/manifest.mjs next` tells you where to continue). If not, this is a fresh run — start at Phase 0.\n\n## Scope Defaults\n\n- **Fidelity:** pixel-accurate — colors, spacing, typography, animations, interactions\n- **In scope:** every confirmed page, visual layout, component structure, interactions, responsive behavior (phone 390 / iPad 768 / PC 1440), real content and assets\n- **Out of scope:** real backend, auth, databases, forms that actually submit (mock them)\n- **Content goes in `src/data/*.ts`** — components take props; page files wire data to components. This keeps the clone restylable later (see `/restyle`).\n\nUser-provided instructions override these defaults.\n\n## Tooling\n\nThe scripts do the mechanical work — **use them instead of hand-measuring via browser MCP**:\n\n| Script | Purpose |\n|---|---|\n| **`node scripts/extract/page.mjs <url> [--no-site-files]`** | **THE WORKHORSE — one call, 3 page loads total.** Auto-detects sections, then produces `tokens.json` + `css.json` (skip on later pages with `--no-site-files`), `assets.json` + downloads to `public/`, `responsive.json` (all 3 viewports), a full computed-style walk per section (`sections/<name>.json`), and full-page **and** per-section screenshots at phone/iPad/PC. Accepts explicit `--selector \"css\" --name x` pairs to override detection. Everything is measured from the SAME page state, so numbers, walks and screenshots can never disagree |\n| `node scripts/extract/crawl.mjs <url> [--max 25]` | Discover pages (sitemap + nav links) → `docs/research/<host>/sitemap.json` |\n| `node scripts/extract/section.mjs <url> --selector \"css\" [--name x] --state scroll:600\\|click:sel\\|hover:sel [--viewport pc\\|ipad\\|phone]` | **State captures** (page.mjs covers the default state). Captures a second state and diffs them (element styles *and* `::before`/`::after`), waiting for the section's real transition duration. `--selector`/`--name` repeat — one page load for all |\n| `node scripts/extract/probe.mjs <url> --selector \"css\" [--selector \"css2\"] [--props a,b,c]` / `probe.mjs --route </r>` | Exact computed values for specific selectors at all 3 viewports, as a markdown table with a **varies** column — paste straight into a spec's Responsive section. **`--route` probes EVERY registered section of a page in one call (3 loads total, plus a `probe-<section>.json` per section) — never probe section-by-section** |\n| `node scripts/extract/screenshot.mjs <url> [--selector css --name x ...]` | Extra screenshots at phone/iPad/PC (page.mjs already shot everything once). `--selector`/`--name` repeat — one call, 3 loads, N sections |\n| `node scripts/extract/tokens.mjs` / `css.mjs` / `assets.mjs` / `responsive.mjs` | Single-purpose re-runs of one page.mjs output when something needs refreshing |\n| `node scripts/resolve-walk.mjs <sections-json> [--node <path>]` | Reader for section-walk JSON (compact or legacy): indexed outline of the tree, and fully resolved computed styles for any one node. Use this instead of reading the raw JSON — walks are stored compact (style dictionary + inherited-prop pruning) |\n| `node scripts/diff.mjs --original <url> --clone <url> [--selector css] --viewport all [--threshold 95]` | Scored pixel diff, original vs clone. **`--viewport all` scores pc+ipad+phone in one call**, and the per-viewport **band breakdown names the y-range where the mismatch lives** — read it before guessing at causes. **Batched sweep: `--route </r>` (or repeated `--section name=css`) scores every section of a page from ONE load per side per viewport.** Original-side shots are cached 24h, so fix-iteration re-diffs only re-render the clone (`--fresh-original` to override) |\n| **`node scripts/spec-scaffold.mjs --route <r> --section <name>`** (or `--all`) | **Generates the mechanical spec sections** (frontmatter, DOM, computed styles, assets, text, responsive) straight from the extraction JSON into `docs/research/components/<route-slug>/<name>.spec.md`, leaving `<!-- AGENT: fill -->` blocks for the judgment parts. Never transcribe JSON values by hand |\n| `node scripts/lint-spec.mjs <spec.md\\|dir>` | Mechanical spec-completeness gate — must pass before ANY builder dispatch |\n| `node scripts/manifest.mjs <cmd>` | Pipeline state: init / add-page / add-section / set / status / next |\n\n**Screenshots come in two sizes.** Every screenshot the scripts produce gets a 640px-wide `-review.png` twin (when the full-res is wider). **Open the `-review.png` for judgment work** — reviewing sections, comparing pages, inspecting failing diff bands; it's visually sufficient at half the cost. Full-res files are for pixelmatch and for builder-agent prompts only.\n\nBrowser MCP (Chrome MCP, Playwright MCP — if available) is for **judgment work only**: watching how the page behaves while scrolling, exploring what's clickable, understanding an animation. Numbers always come from the scripts. If no browser MCP is available, the scripts alone are sufficient — use extra `screenshot.mjs` and `section.mjs --state` calls to observe behavior.\n\nThe scripts are plain Node CLIs — any coding agent can run them. Playwright's Chromium auto-installs on the first script run (or run `npm run setup` once). If your tool has no subagent/worktree support, skip the dispatch mechanics and build each section yourself, sequentially, from the same lint-passing specs — every quality gate still applies.\n\n## Guiding Principles\n\n1. **Completeness beats speed.** A builder that has to guess a color, font size, or padding value means extraction failed. Extract one more property rather than ship an incomplete spec.\n2. **Small tasks, perfect results.** One focused component per builder. Spec body over 150 lines = split the section (lint-spec enforces this).\n3. **Real content, real assets.** Actual text via the section walker, actual files via `assets.mjs`. Watch for **layered images** — a hero that looks like one image is often background + overlay + foreground; `assets.json` records sibling counts and z-index for exactly this reason.\n4. **Foundation first.** Tokens, fonts, types, icons, and shared chrome (header/footer) before any page section.\n5. **Extract how it looks AND how it behaves.** Every interactive element needs before/after states with exact values — `section.mjs --state` produces the diff mechanically.\n6. **Identify the interaction model before building.** Scroll-driven vs click-driven confusion is the most expensive mistake in cloning — a wrong call means a rewrite, not a CSS fix. Scroll first without clicking and watch; only then click. Record the model in the spec frontmatter.\n7. **Responsive is measured, never guessed — at all three widths.** Fill every spec's Responsive section from `responsive.json` + `probe.mjs`, with real numbers for phone AND iPad AND pc. Never write \"iPad: same as desktop\": most production sites step their root font-size at breakpoints, so *every* padding, margin, and font size changes even when the layout looks identical. A spec that only nails desktop produces a clone that scores ~98% at 1440px and ~91% at 390px. `lint-spec.mjs` rejects vague responsive sections.\n\n8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.\n9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.\n10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.\n11. **The manifest is updated at every stage transition.** That's what makes the run resumable.\n\n## Phase 0 — Crawl & Scope\n\n1. Verify the base builds: `npm run build`.\n2. `node scripts/extract/crawl.mjs <url> --max 25`\n3. Show the user the discovered pages (route + source). **Ask which to clone** — recommend: start page + nav pages, skip legal/utility pages unless asked. Default cap ~10.\n4. Initialize state:\n ```bash\n node scripts/manifest.mjs init <url>\n node scripts/manifest.mjs add-page --url <url> --route / # per confirmed page\n ```\n\n## Phase 1 — Recon (one page.mjs call per page)\n\n1. **First page:** `node scripts/extract/page.mjs <start-url>` — produces tokens, css, assets+downloads, responsive signatures, per-section walks, and every screenshot in one shot (3 page loads).\n2. **Every other confirmed page:** `node scripts/extract/page.mjs <url> --no-site-files` (tokens/css are site-wide; everything else is per-page). Downloads dedupe across pages automatically — files already in `public/` are skipped.\n3. **Review the detected sections** in each run's stdout summary (name, selector, pc height, headline responsive change). Detection is a heuristic: if a \"section\" is really two, or two are really one, re-run with explicit `--selector \"css\" --name x` pairs. Section names become spec/component names — when detection got the sections RIGHT but the names wrong (`section-3` fallbacks), **don't re-extract**: `node scripts/extract/page.mjs --rename section-3=hero,section-4=features` renames the JSONs, probe files, screenshots, responsive.json and manifest entries in place with zero page loads.\n4. **Interaction sweep** (judgment work — browser MCP if available): scroll each page slowly top to bottom. Does the header change? Do elements animate in? Auto-switching tabs? Scroll-snap? Smooth-scroll lib (`tokens.json` flags `.lenis`/Locomotive)? Then click every tab/pill/accordion and note what changes. Then hover. `css.json`'s `interactiveStates` lists every :hover/:focus rule the stylesheet defines — use it as the checklist of what to probe. Record findings in `docs/research/<host>/BEHAVIORS.md`.\n5. **Shared chrome detection:** compare screenshots across pages — header/nav/footer that repeat become SHARED components (`SiteHeader`, `SiteFooter`), extracted once from the page where they're most complete.\n\n**Per page — topology:** map every distinct section top to bottom with a working name, its selector, its interaction model (static / click-driven / scroll-driven / hover-driven / time-driven / mixed), and layer notes (sticky? overlay? z-index?). Save `docs/research/<host>/PAGE_TOPOLOGY.md`, then register each section:\n```bash\nnode scripts/manifest.mjs add-section --route / --name hero --selector \"section.hero\"\n```\n\n## Phase 2 — Foundation (sequential, you do it yourself)\n\n1. **Fonts** in `src/app/layout.tsx` via `next/font/google` or `next/font/local` (downloaded fonts are in `public/fonts/`) — families/weights from `tokens.json`\n2. **`globals.css`**: map the target's palette onto the shadcn `:root` token names; add custom properties for colors that don't map; add global keyframes, scroll-snap, smooth-scroll setup found in recon\n3. **TypeScript interfaces** in `src/types/` for the content structures you observed\n4. **Icons**: convert the deduplicated `inlineSvgs` from `assets.json` into named components in `src/components/icons.tsx` (named by function: `LogoIcon`, `ArrowRightIcon`…)\n5. **SEO**: favicons/OG from `public/seo/` wired into `layout.tsx` metadata\n6. Verify `npm run build`, then build **shared chrome** (header/footer) first — full spec → lint → builder cycle like any section, since every page depends on them.\n\n## Phase 3 — Per-Section Loop (extract → spec → lint → dispatch → merge)\n\nWork through `manifest.mjs next` until no sections remain. For each section:\n\n### 3a. Extract\n\n**The default state is already extracted** — Phase 1's page.mjs run wrote\n`sections/<name>.json`, `responsive.json`, and all screenshots.\n\n**First time you enter Phase 3 for a page, probe ALL its sections in ONE call** (3\npage loads total instead of 3 per section — never probe section-by-section):\n\n```bash\nnode scripts/extract/probe.mjs --route <r> # every registered section + probe-<section>.json each\n# add key children in the same call when a spec will need them:\nnode scripts/extract/probe.mjs --route <r> --selector \"<sel> h2\" --selector \"<sel> .card\"\n```\n\nSlice the per-section tables into each spec's Responsive section as you write it.\nPer section, only one thing remains:\n\n```bash\n# Per discovered behavior — one call per state (batch selectors sharing a trigger):\nnode scripts/extract/section.mjs <page-url> --selector \"<sel>\" --name <name>-hover --state hover:\".card\"\nnode scripts/extract/section.mjs <page-url> --selector \"<sel>\" --name <name>-scrolled --state scroll:600\n# per tab/pill state: --state click:\".tab-2\" etc. EVERY state, not just the default.\n```\nState captures wait for the section's actual transition duration, so a slow fade is\nrecorded at its end value, not mid-flight — check `settleMs` in the output if a diff\nlooks wrong. The `diff` array covers `::before`/`::after` too, which is where hover\noverlays usually live. Captures are **diff-only**: `diff` lists changed props (plus\n`(text)`/`(classes)` changes), and `added`/`removed` carry subtrees that exist in\nonly one state with their styles inline — conditionally-rendered dropdowns and\npanels land there. Pass `--audit` to also store the full before/after trees. Cross-check discovered behaviors against `css.json`'s\n`interactiveStates` — a :hover rule in the stylesheet with no captured state means\nthe extraction is not done.\n\nMark: `manifest.mjs set --route <r> --section <name> --stage extracted`\n\n### 3b. Write the spec — scaffold first, judgment second\n\n```bash\nnode scripts/spec-scaffold.mjs --route <r> --section <name> # or --all for the whole route\n```\n\nThis generates `docs/research/components/<route-slug>/<name>.spec.md` with every\n**mechanical** section already filled from the extraction JSON — frontmatter, DOM\nStructure, Computed Styles, Assets, Text Content, Responsive Behavior — and any\ncaptured states listed as reference data. **Never transcribe values from the JSON\nby hand**: the scaffold is generated from the same files and can't mistype.\n\nYou fill ONLY the `<!-- AGENT: fill -->` blocks — the judgment calls:\n\n- `interaction_model:` in the frontmatter (static | click-driven | scroll-driven | hover-driven | time-driven | mixed)\n- `## States & Behaviors` — per behavior: Trigger / State A / State B / Transition + the implementation approach (CSS transition, IntersectionObserver, …). The scaffold lists each captured state's trigger/settle/diff summary as reference\n- `## Per-State Content` — full content per state for tabbed/stateful sections, or \"N/A — static\"\n- `## Notes` — builder guidance: component split, `src/data/` shape, gotchas\n\nAn unfilled scaffold fails lint-spec on purpose (invalid interaction_model), so it\ncan never reach a builder. Correct a generated section only when it's wrong about\nthe page — don't restyle it.\n\n### 3c. Lint gate\n```bash\nnode scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md\n```\nFails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.\n\n### 3d. Dispatch builder agent (worktree)\n\nEvery builder receives IN ITS PROMPT (never \"go read the file\"):\n- The **full spec file contents inline**\n- The screenshot paths (all 3 viewports)\n- Shared imports available: `cn()`, `icons.tsx` components, shadcn `ui/` primitives, types from `src/types/`\n- The target file path, and the data file to create in `src/data/` if the section has content collections\n- The rule: verify `npx tsc --noEmit` passes before finishing\n- **The ground-truth rule:** \"`docs/research/<host>/sections/<name>.json` and `responsive.json` are ground truth. If this spec contradicts them, follow the JSON and report the discrepancy.\" Builders reliably catch spec errors this way — treat their reports as corrections to make to the spec file. Walk JSON is stored compact — builders resolve any node's full styles with `node scripts/resolve-walk.mjs <json> --node <path>` instead of parsing the styleTable by hand.\n\nComplex section (3+ distinct sub-components) → one builder per sub-component + one for the wrapper, sub-components first. **Don't wait** — while builders run, extract the next section.\n\n### 3e. Merge\nAs builders finish: merge worktree → `npm run typecheck && npm run lint` → fix errors immediately → `manifest.mjs set … --stage merged`. tsc catches the cross-worktree breaks (imports, prop types) that per-merge builds used to catch, in a fraction of the time.\n\n**Once, after roughly half the page's sections are merged: run a full `npm run build` checkpoint.** It catches build-only failures (server/client component violations, route exports, metadata) while they're still cheap to bisect. Don't build after every merge.\n\n## Phase 4 — Page Assembly\n\nPer page: create `src/app/<route>/page.tsx` importing its section components with data from `src/data/`, plus page-level behaviors (scroll-snap, observers, smooth scroll). Shared chrome mounts in `layout.tsx` or a route group layout. Wire internal nav links to the cloned routes. `npm run build` must pass.\n\n## Phase 5 — Scored QA Loop\n\nStart the clone: `npm run dev` (background). Then **score the whole page's sections in ONE batched call** (one load per side per viewport instead of one per section):\n\n```bash\nnode scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all\nnode scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport\n```\n\n**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:\n\n```bash\nnode scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector \"<sel>\" --viewport all --name <name>\n```\n\n- **Pass = ≥95% on all three viewports** → `--stage qa_passed`\n- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff\n- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking\n- Max 3 fix iterations per section, then record the gap honestly and move on\n- **Text-heavy sections at phone width often plateau at 90–95%** when the target's font isn't available on Google Fonts (e.g. Source Sans Pro → Source Sans 3). Different metrics = different wrap points = unavoidable pixel drift. Confirm the layout matches, note the substitution, and accept it.\n- **A score that's high at pc but low at ipad/phone is always a responsive-spec problem**, not a styling bug. Re-run `probe.mjs` on the section and fill in the values the spec was missing.\n- Finally, test behaviors manually: scroll, click every tab, hover — screenshots can't verify motion; you must\n\nWhole-page diffs (`--selector` omitted) at all 3 viewports close out each page.\n\n## What NOT to Do\n\n- **Don't build click-tabs when the original is scroll-driven** (or vice versa). Scroll first, watch, then click. Wrong model = rewrite.\n- **Don't extract only the default state.** Every tab clicked, every hover captured, header at scroll 0 AND past the trigger.\n- **Don't miss layered/overlay images** — check `siblingImgs` and z-index hints in `assets.json`.\n- **Don't build HTML mockups of things that are actually `<video>`, Lottie, or canvas.** Check first.\n- **Don't approximate (\"looks like text-lg\").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.\n- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.\n- **Don't reference docs from builder prompts** — spec contents go inline.\n- **Don't skip the manifest updates.** An untracked run can't resume.\n- **Don't hardcode content in components.** Content → `src/data/`, components take props.\n- **Don't write \"same as desktop\" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.\n- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.\n- **Don't trust the spec over the extraction JSON.** The judgment sections are hand-written and can drift; `sections/*.json` is machine-measured (and the mechanical spec sections are generated from it).\n- **Don't declare done without QA scores.** \"Looks right\" is not a number.\n\n## Completion Report\n\n- Pages cloned (routes) · sections built · spec files written (must match section count)\n- Assets downloaded (from `assets.json` download log, including failures)\n- Final QA score table per section × viewport (from `manifest.mjs status`)\n- `npm run build` result\n- Known gaps and any section that couldn't reach 95%\n- Suggest next step: `/restyle` to rebrand the clone with your own identity",
+ "prompt": "# Clone Website\n\nReverse-engineer and rebuild **the target URL (plus any extra instructions) provided by the user** as a pixel-accurate, multi-page Next.js clone.\n\nYou are a **foreman walking the job site**: scripts do the measuring, you do the judgment, specs are the contract, builder agents do the construction, and the pixel-diff score decides when you're done. Extraction and construction overlap — dispatch builders as soon as a section's spec passes lint, then keep extracting.\n\n## Resume Check (ALWAYS FIRST)\n\n```bash\nnode scripts/manifest.mjs status\n```\n\nIf a manifest exists, this is a **resumed run**: skip everything already done (`node scripts/manifest.mjs next` tells you where to continue). If not, this is a fresh run — start at Phase 0.\n\n## Scope Defaults\n\n- **Fidelity:** pixel-accurate — colors, spacing, typography, animations, interactions\n- **In scope:** every confirmed page, visual layout, component structure, interactions, responsive behavior (phone 390 / iPad 768 / PC 1440), real content and assets\n- **Out of scope:** real backend, auth, databases, forms that actually submit (mock them)\n- **Content goes in `src/data/*.ts`** — components take props; page files wire data to components. This keeps the clone restylable later (see `/restyle`).\n\nUser-provided instructions override these defaults.\n\n## Tooling\n\nThe scripts do the mechanical work — **use them instead of hand-measuring via browser MCP**:\n\n| Script | Purpose |\n|---|---|\n| **`node scripts/extract/page.mjs <url> [--no-site-files]`** | **THE WORKHORSE — one call, 3 page loads total.** Auto-detects sections, then produces `tokens.json` + `css.json` (skip on later pages with `--no-site-files`), `assets.json` + downloads to `public/`, `responsive.json` (all 3 viewports), a full computed-style walk per section (`sections/<name>.json`), and full-page **and** per-section screenshots at phone/iPad/PC. Accepts explicit `--selector \"css\" --name x` pairs to override detection. Everything is measured from the SAME page state, so numbers, walks and screenshots can never disagree |\n| `node scripts/extract/crawl.mjs <url> [--max 25]` | Discover pages (sitemap + nav links) → `docs/research/<host>/sitemap.json` |\n| `node scripts/extract/section.mjs <url> --selector \"css\" [--name x] --state scroll:600\\|click:sel\\|hover:sel [--viewport pc\\|ipad\\|phone]` | **State captures** (page.mjs covers the default state). Captures a second state and diffs them (element styles *and* `::before`/`::after`), waiting for the section's real transition duration. `--selector`/`--name` repeat — one page load for all |\n| `node scripts/extract/probe.mjs <url> --selector \"css\" [--selector \"css2\"] [--props a,b,c]` / `probe.mjs --route </r>` | Exact computed values for specific selectors at all 3 viewports, as a markdown table with a **varies** column — paste straight into a spec's Responsive section. **`--route` probes EVERY registered section of a page in one call (3 loads total, plus a `probe-<section>.json` per section) — never probe section-by-section** |\n| `node scripts/extract/screenshot.mjs <url> [--selector css --name x ...]` | Extra screenshots at phone/iPad/PC (page.mjs already shot everything once). `--selector`/`--name` repeat — one call, 3 loads, N sections |\n| `node scripts/extract/tokens.mjs` / `css.mjs` / `assets.mjs` / `responsive.mjs` | Single-purpose re-runs of one page.mjs output when something needs refreshing |\n| `node scripts/resolve-walk.mjs <sections-json> [--node <path>]` | Reader for section-walk JSON (compact or legacy): indexed outline of the tree, and fully resolved computed styles for any one node. Use this instead of reading the raw JSON — walks are stored compact (style dictionary + inherited-prop pruning) |\n| `node scripts/diff.mjs --original <url> --clone <url> [--selector css] --viewport all [--threshold 95]` | Scored pixel diff, original vs clone. **`--viewport all` scores pc+ipad+phone in one call**, and the per-viewport **band breakdown names the y-range where the mismatch lives** — read it before guessing at causes. **Batched sweep: `--route </r>` (or repeated `--section name=css`) scores every section of a page from ONE load per side per viewport.** Original-side shots are cached 24h, so fix-iteration re-diffs only re-render the clone (`--fresh-original` to override) |\n| **`node scripts/spec-scaffold.mjs --route <r> --section <name>`** (or `--all`) | **Generates the mechanical spec sections** (frontmatter, DOM, computed styles, assets, text, responsive) straight from the extraction JSON into `docs/research/components/<route-slug>/<name>.spec.md`, leaving `<!-- AGENT: fill -->` blocks for the judgment parts. Never transcribe JSON values by hand |\n| `node scripts/lint-spec.mjs <spec.md\\|dir>` | Mechanical spec-completeness gate — must pass before ANY builder dispatch |\n| `node scripts/manifest.mjs <cmd>` | Pipeline state: init / add-page / add-section / set / status / next |\n\n**Screenshots come in two sizes.** Every screenshot the scripts produce gets a 640px-wide `-review.png` twin (when the full-res is wider). **Open the `-review.png` for judgment work** — reviewing sections, comparing pages, inspecting failing diff bands; it's visually sufficient at half the cost. Full-res files are for pixelmatch and for builder-agent prompts only.\n\nBrowser MCP (Chrome MCP, Playwright MCP — if available) is for **judgment work only**: watching how the page behaves while scrolling, exploring what's clickable, understanding an animation. Numbers always come from the scripts. If no browser MCP is available, the scripts alone are sufficient — use extra `screenshot.mjs` and `section.mjs --state` calls to observe behavior.\n\nThe scripts are plain Node CLIs — any coding agent can run them. Playwright's Chromium auto-installs on the first script run (or run `npm run setup` once). If your tool has no subagent/worktree support, skip the dispatch mechanics and build each section yourself, sequentially, from the same lint-passing specs — every quality gate still applies.\n\n## Guiding Principles\n\n1. **Completeness beats speed.** A builder that has to guess a color, font size, or padding value means extraction failed. Extract one more property rather than ship an incomplete spec.\n2. **Small tasks, perfect results.** One focused component per builder. Spec body over 150 lines = split the section (lint-spec enforces this).\n3. **Real content, real assets.** Actual text via the section walker, actual files via `assets.mjs`. Watch for **layered images** — a hero that looks like one image is often background + overlay + foreground; `assets.json` records sibling counts and z-index for exactly this reason.\n4. **Foundation first.** Tokens, fonts, types, icons, and shared chrome (header/footer) before any page section.\n5. **Extract how it looks AND how it behaves.** Every interactive element needs before/after states with exact values — `section.mjs --state` produces the diff mechanically.\n6. **Identify the interaction model before building.** Scroll-driven vs click-driven confusion is the most expensive mistake in cloning — a wrong call means a rewrite, not a CSS fix. Scroll first without clicking and watch; only then click. Record the model in the spec frontmatter.\n7. **Responsive is measured, never guessed — at all three widths.** Fill every spec's Responsive section from `responsive.json` + `probe.mjs`, with real numbers for phone AND iPad AND pc. Never write \"iPad: same as desktop\": most production sites step their root font-size at breakpoints, so *every* padding, margin, and font size changes even when the layout looks identical. A spec that only nails desktop produces a clone that scores ~98% at 1440px and ~91% at 390px. `lint-spec.mjs` rejects vague responsive sections.\n\n8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.\n9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.\n10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.\n11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.\n\n## Phase 0 — Crawl & Scope\n\n1. Verify the base builds: `npm run build`.\n2. `node scripts/extract/crawl.mjs <url> --max 25`\n3. Show the user the discovered pages (route + source). **Ask which to clone** — recommend: start page + nav pages, skip legal/utility pages unless asked. Default cap ~10.\n4. Initialize state:\n ```bash\n node scripts/manifest.mjs init <url>\n node scripts/manifest.mjs add-page --url <url> --route / # per confirmed page\n ```\n\n## Phase 1 — Recon (one page.mjs call per page)\n\n1. **First page:** `node scripts/extract/page.mjs <start-url>` — produces tokens, css, assets+downloads, responsive signatures, per-section walks, and every screenshot in one shot (3 page loads).\n2. **Every other confirmed page:** `node scripts/extract/page.mjs <url> --no-site-files` (tokens/css are site-wide; everything else is per-page). Downloads dedupe across pages automatically — files already in `public/` are skipped.\n3. **Review the detected sections** in each run's stdout summary (name, selector, pc height, headline responsive change). Detection is a heuristic: if a \"section\" is really two, or two are really one, re-run with explicit `--selector \"css\" --name x` pairs. Section names become spec/component names — when detection got the sections RIGHT but the names wrong (`section-3` fallbacks), **don't re-extract**: `node scripts/extract/page.mjs --rename section-3=hero,section-4=features` renames the JSONs, probe files, screenshots, responsive.json and manifest entries in place with zero page loads.\n4. **Interaction sweep** (judgment work — browser MCP if available): scroll each page slowly top to bottom. Does the header change? Do elements animate in? Auto-switching tabs? Scroll-snap? Smooth-scroll lib (`tokens.json` flags `.lenis`/Locomotive)? Then click every tab/pill/accordion and note what changes. Then hover. `css.json`'s `interactiveStates` lists every :hover/:focus rule the stylesheet defines — use it as the checklist of what to probe. Record findings in `docs/research/<host>/BEHAVIORS.md`.\n5. **Shared chrome detection:** compare screenshots across pages — header/nav/footer that repeat become SHARED components (`SiteHeader`, `SiteFooter`), extracted once from the page where they're most complete.\n\n**Per page — topology:** map every distinct section top to bottom with a working name, its selector, its interaction model (static / click-driven / scroll-driven / hover-driven / time-driven / mixed), and layer notes (sticky? overlay? z-index?). Save `docs/research/<host>/PAGE_TOPOLOGY.md`, then register each section:\n```bash\nnode scripts/manifest.mjs add-section --route / --name hero --selector \"section.hero\"\n```\n\n## Phase 2 — Foundation (sequential, you do it yourself)\n\n1. **Fonts** in `src/app/layout.tsx` via `next/font/google` or `next/font/local` (downloaded fonts are in `public/fonts/`) — families/weights from `tokens.json`\n2. **`globals.css`**: map the target's palette onto the shadcn `:root` token names; add custom properties for colors that don't map; add global keyframes, scroll-snap, smooth-scroll setup found in recon\n3. **TypeScript interfaces** in `src/types/` for the content structures you observed\n4. **Icons**: convert the deduplicated `inlineSvgs` from `assets.json` into named components in `src/components/icons.tsx` (named by function: `LogoIcon`, `ArrowRightIcon`…)\n5. **SEO**: favicons/OG from `public/seo/` wired into `layout.tsx` metadata\n6. Verify `npm run build`, then build **shared chrome** (header/footer) first — full spec → lint → builder cycle like any section, since every page depends on them.\n\n## Phase 3 — Per-Section Loop (extract → spec → lint → dispatch → merge)\n\nWork through `manifest.mjs next` until no sections remain. For each section:\n\n### 3a. Extract\n\n**The default state is already extracted** — Phase 1's page.mjs run wrote\n`sections/<name>.json`, `responsive.json`, and all screenshots.\n\n**First time you enter Phase 3 for a page, probe ALL its sections in ONE call** (3\npage loads total instead of 3 per section — never probe section-by-section):\n\n```bash\nnode scripts/extract/probe.mjs --route <r> # every registered section + probe-<section>.json each\n# add key children in the same call when a spec will need them:\nnode scripts/extract/probe.mjs --route <r> --selector \"<sel> h2\" --selector \"<sel> .card\"\n```\n\nSlice the per-section tables into each spec's Responsive section as you write it.\nPer section, only one thing remains:\n\n```bash\n# Per discovered behavior — one call per state (batch selectors sharing a trigger):\nnode scripts/extract/section.mjs <page-url> --selector \"<sel>\" --name <name>-hover --state hover:\".card\"\nnode scripts/extract/section.mjs <page-url> --selector \"<sel>\" --name <name>-scrolled --state scroll:600\n# per tab/pill state: --state click:\".tab-2\" etc. EVERY state, not just the default.\n```\nState captures wait for the section's actual transition duration, so a slow fade is\nrecorded at its end value, not mid-flight — check `settleMs` in the output if a diff\nlooks wrong. The `diff` array covers `::before`/`::after` too, which is where hover\noverlays usually live. Captures are **diff-only**: `diff` lists changed props (plus\n`(text)`/`(classes)` changes), and `added`/`removed` carry subtrees that exist in\nonly one state with their styles inline — conditionally-rendered dropdowns and\npanels land there. Pass `--audit` to also store the full before/after trees. Cross-check discovered behaviors against `css.json`'s\n`interactiveStates` — a :hover rule in the stylesheet with no captured state means\nthe extraction is not done.\n\n(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)\n\n### 3b. Write the spec — scaffold first, judgment second\n\n```bash\nnode scripts/spec-scaffold.mjs --route <r> --section <name> # or --all for the whole route\n```\n\nThis generates `docs/research/components/<route-slug>/<name>.spec.md` with every\n**mechanical** section already filled from the extraction JSON — frontmatter, DOM\nStructure, Computed Styles, Assets, Text Content, Responsive Behavior — and any\ncaptured states listed as reference data. **Never transcribe values from the JSON\nby hand**: the scaffold is generated from the same files and can't mistype.\n\nYou fill ONLY the `<!-- AGENT: fill -->` blocks — the judgment calls:\n\n- `interaction_model:` in the frontmatter (static | click-driven | scroll-driven | hover-driven | time-driven | mixed)\n- `## States & Behaviors` — per behavior: Trigger / State A / State B / Transition + the implementation approach (CSS transition, IntersectionObserver, …). The scaffold lists each captured state's trigger/settle/diff summary as reference\n- `## Per-State Content` — full content per state for tabbed/stateful sections, or \"N/A — static\"\n- `## Notes` — builder guidance: component split, `src/data/` shape, gotchas\n\nAn unfilled scaffold fails lint-spec on purpose (invalid interaction_model), so it\ncan never reach a builder. Correct a generated section only when it's wrong about\nthe page — don't restyle it.\n\n### 3c. Lint gate\n```bash\nnode scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md\n```\nFails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).\n\n### 3d. Dispatch builder agent (worktree)\n\nEvery builder receives IN ITS PROMPT (never \"go read the file\"):\n- The **full spec file contents inline**\n- The screenshot paths (all 3 viewports)\n- Shared imports available: `cn()`, `icons.tsx` components, shadcn `ui/` primitives, types from `src/types/`\n- The target file path, and the data file to create in `src/data/` if the section has content collections\n- The rule: verify `npx tsc --noEmit` passes before finishing\n- **The ground-truth rule:** \"`docs/research/<host>/sections/<name>.json` and `responsive.json` are ground truth. If this spec contradicts them, follow the JSON and report the discrepancy.\" Builders reliably catch spec errors this way — treat their reports as corrections to make to the spec file. Walk JSON is stored compact — builders resolve any node's full styles with `node scripts/resolve-walk.mjs <json> --node <path>` instead of parsing the styleTable by hand.\n\nComplex section (3+ distinct sub-components) → one builder per sub-component + one for the wrapper, sub-components first. **Don't wait** — while builders run, extract the next section.\n\n### 3e. Merge\nAs builders finish: merge worktree → `npm run typecheck && npm run lint` → fix errors immediately → `manifest.mjs set … --stage merged`. tsc catches the cross-worktree breaks (imports, prop types) that per-merge builds used to catch, in a fraction of the time.\n\n**Once, after roughly half the page's sections are merged: run a full `npm run build` checkpoint.** It catches build-only failures (server/client component violations, route exports, metadata) while they're still cheap to bisect. Don't build after every merge.\n\n## Phase 4 — Page Assembly\n\nPer page: create `src/app/<route>/page.tsx` importing its section components with data from `src/data/`, plus page-level behaviors (scroll-snap, observers, smooth scroll). Shared chrome mounts in `layout.tsx` or a route group layout. Wire internal nav links to the cloned routes. `npm run build` must pass.\n\n## Phase 5 — Scored QA Loop\n\nStart the clone: `npm run dev` (background). Then **score the whole page's sections in ONE batched call** (one load per side per viewport instead of one per section):\n\n```bash\nnode scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all\n```\n\nThe `--route` sweep records every score in the manifest itself and advances\nsections whose three viewports all clear 95% to `qa_passed` — no separate\nmanifest commands during QA.\n\n**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:\n\n```bash\nnode scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector \"<sel>\" --viewport all --name <name>\n```\n\n- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)\n- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff\n- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking\n- Max 3 fix iterations per section, then record the gap honestly and move on\n- **Text-heavy sections at phone width often plateau at 90–95%** when the target's font isn't available on Google Fonts (e.g. Source Sans Pro → Source Sans 3). Different metrics = different wrap points = unavoidable pixel drift. Confirm the layout matches, note the substitution, and accept it.\n- **A score that's high at pc but low at ipad/phone is always a responsive-spec problem**, not a styling bug. Re-run `probe.mjs` on the section and fill in the values the spec was missing.\n- Finally, test behaviors manually: scroll, click every tab, hover — screenshots can't verify motion; you must\n\nWhole-page diffs (`--selector` omitted) at all 3 viewports close out each page.\n\n## What NOT to Do\n\n- **Don't build click-tabs when the original is scroll-driven** (or vice versa). Scroll first, watch, then click. Wrong model = rewrite.\n- **Don't extract only the default state.** Every tab clicked, every hover captured, header at scroll 0 AND past the trigger.\n- **Don't miss layered/overlay images** — check `siblingImgs` and z-index hints in `assets.json`.\n- **Don't build HTML mockups of things that are actually `<video>`, Lottie, or canvas.** Check first.\n- **Don't approximate (\"looks like text-lg\").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.\n- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.\n- **Don't reference docs from builder prompts** — spec contents go inline.\n- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.\n- **Don't hardcode content in components.** Content → `src/data/`, components take props.\n- **Don't write \"same as desktop\" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.\n- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.\n- **Don't trust the spec over the extraction JSON.** The judgment sections are hand-written and can drift; `sections/*.json` is machine-measured (and the mechanical spec sections are generated from it).\n- **Don't declare done without QA scores.** \"Looks right\" is not a number.\n\n## Completion Report\n\n- Pages cloned (routes) · sections built · spec files written (must match section count)\n- Assets downloaded (from `assets.json` download log, including failures)\n- Final QA score table per section × viewport (from `manifest.mjs status`)\n- `npm run build` result\n- Known gaps and any section that couldn't reach 95%\n- Suggest next step: `/restyle` to rebrand the clone with your own identity",
"fileContext": [
"AGENTS.md",
"docs/research/**"
diff --git a/.augment/commands/clone-website.md b/.augment/commands/clone-website.md
index a8ae8da..063702d 100644
--- a/.augment/commands/clone-website.md
+++ b/.augment/commands/clone-website.md
@@ -65,7 +65,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -137,7 +137,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -166,7 +166,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -195,16 +195,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -223,7 +226,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.claude/skills/clone-website/SKILL.md b/.claude/skills/clone-website/SKILL.md
index 72445f5..87d3867 100644
--- a/.claude/skills/clone-website/SKILL.md
+++ b/.claude/skills/clone-website/SKILL.md
@@ -65,7 +65,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -137,7 +137,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -166,7 +166,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -195,16 +195,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -223,7 +226,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.codex/skills/clone-website/SKILL.md b/.codex/skills/clone-website/SKILL.md
index 72445f5..87d3867 100644
--- a/.codex/skills/clone-website/SKILL.md
+++ b/.codex/skills/clone-website/SKILL.md
@@ -65,7 +65,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -137,7 +137,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -166,7 +166,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -195,16 +195,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -223,7 +226,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.continue/commands/clone-website.md b/.continue/commands/clone-website.md
index dbbb5f9..2661e7b 100644
--- a/.continue/commands/clone-website.md
+++ b/.continue/commands/clone-website.md
@@ -66,7 +66,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -138,7 +138,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -167,7 +167,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -196,16 +196,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -224,7 +227,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.cursor/commands/clone-website.md b/.cursor/commands/clone-website.md
index 853b6c6..44f0580 100644
--- a/.cursor/commands/clone-website.md
+++ b/.cursor/commands/clone-website.md
@@ -63,7 +63,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -135,7 +135,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -164,7 +164,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -193,16 +193,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -221,7 +224,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.gemini/commands/clone-website.toml b/.gemini/commands/clone-website.toml
index b23dadf..5b0aeb4 100644
--- a/.gemini/commands/clone-website.toml
+++ b/.gemini/commands/clone-website.toml
@@ -65,7 +65,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -137,7 +137,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -166,7 +166,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -195,16 +195,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -223,7 +226,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.github/skills/clone-website/SKILL.md b/.github/skills/clone-website/SKILL.md
index 72445f5..87d3867 100644
--- a/.github/skills/clone-website/SKILL.md
+++ b/.github/skills/clone-website/SKILL.md
@@ -65,7 +65,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -137,7 +137,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -166,7 +166,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -195,16 +195,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -223,7 +226,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.opencode/commands/clone-website.md b/.opencode/commands/clone-website.md
index af93754..ad12fc9 100644
--- a/.opencode/commands/clone-website.md
+++ b/.opencode/commands/clone-website.md
@@ -64,7 +64,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -136,7 +136,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -165,7 +165,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -194,16 +194,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -222,7 +225,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/.windsurf/workflows/clone-website.md b/.windsurf/workflows/clone-website.md
index 05c4067..1c0953b 100644
--- a/.windsurf/workflows/clone-website.md
+++ b/.windsurf/workflows/clone-website.md
@@ -61,7 +61,7 @@ The scripts are plain Node CLIs — any coding agent can run them. Playwright's
8. **The extraction JSON is ground truth; the spec is a summary of it.** If a builder finds the spec disagreeing with `sections/<name>.json` or `responsive.json`, the JSON wins — say so explicitly in every builder prompt and have the builder report the discrepancy so you can correct the spec.
9. **Spec files are the contract.** No spec → no builder. lint-spec must pass → then dispatch.
10. **The build must always compile.** Builders verify `npx tsc --noEmit`; you verify `npm run typecheck && npm run lint` after every merge. Full `npm run build` runs only at checkpoints (Phase 0, end of Phase 2, once mid-way through Phase 3, Phase 4, completion) — it takes 30–60s and running it per merge serializes otherwise-parallel builders.
-11. **The manifest is updated at every stage transition.** That's what makes the run resumable.
+11. **The manifest tracks every stage transition.** The scripts self-report the transitions they own — page.mjs marks `extracted` (and registers new sections), lint-spec marks `specd` on pass, diff.mjs `--route` sweeps record scores and `qa_passed`. You update only the stages no script can see: `built` and `merged` (via `manifest.mjs set`), which also remains the manual override for anything else.
## Phase 0 — Crawl & Scope
@@ -133,7 +133,7 @@ panels land there. Pass `--audit` to also store the full before/after trees. Cro
`interactiveStates` — a :hover rule in the stylesheet with no captured state means
the extraction is not done.
-Mark: `manifest.mjs set --route <r> --section <name> --stage extracted`
+(No manifest command needed — page.mjs already marked the section `extracted` when it wrote the walk.)
### 3b. Write the spec — scaffold first, judgment second
@@ -162,7 +162,7 @@ the page — don't restyle it.
```bash
node scripts/lint-spec.mjs docs/research/components/<route-slug>/<name>.spec.md
```
-Fails → extract more. Passes → `manifest.mjs set … --stage specd` and dispatch.
+Fails → extract more. Passes → dispatch (lint-spec records the `specd` stage in the manifest itself).
### 3d. Dispatch builder agent (worktree)
@@ -191,16 +191,19 @@ Start the clone: `npm run dev` (background). Then **score the whole page's secti
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --route <r> --viewport all
-node scripts/manifest.mjs set --route <r> --section <name> --score pc=<match> # per section × viewport
```
+The `--route` sweep records every score in the manifest itself and advances
+sections whose three viewports all clear 95% to `qa_passed` — no separate
+manifest commands during QA.
+
**Fix iterations stay single-section** — the original-side shots captured by the sweep are cached, so a re-diff only re-renders the clone:
```bash
node scripts/diff.mjs --original <orig-page-url> --clone http://localhost:3000<route> --selector "<sel>" --viewport all --name <name>
```
-- **Pass = ≥95% on all three viewports** → `--stage qa_passed`
+- **Pass = ≥95% on all three viewports** (diff.mjs sets `qa_passed` automatically on a `--route` sweep)
- Below 95% → **read the band breakdown first**: it names the y-range where the mismatch lives, so you inspect that band of the diff image in `docs/research/qa/` (open the `-review.png` copy diff.mjs writes for failing sections) instead of eyeballing the whole section. Then check the spec (wrong extraction → re-extract and fix; right spec, wrong build → fix component), re-diff
- A large height mismatch reported by diff.mjs = missing content or wrong spacing — fix before pixel-tweaking
- Max 3 fix iterations per section, then record the gap honestly and move on
@@ -219,7 +222,7 @@ Whole-page diffs (`--selector` omitted) at all 3 viewports close out each page.
- **Don't approximate ("looks like text-lg").** Use the walker's exact computed values; use arbitrary values (`text-[17px]`) when Tailwind's scale doesn't match.
- **Don't dispatch a builder without a lint-passing spec.** No exceptions — that's the whole quality model.
- **Don't reference docs from builder prompts** — spec contents go inline.
-- **Don't skip the manifest updates.** An untracked run can't resume.
+- **Don't skip the `built`/`merged` manifest updates.** Extraction, spec and QA stages self-report, but no script can see a merge — an untracked run can't resume.
- **Don't hardcode content in components.** Content → `src/data/`, components take props.
- **Don't write "same as desktop" in a Responsive section.** Root font-size steps at breakpoints on most real sites, so every number changes. Run `probe.mjs` and write the real values for all three widths — lint-spec now rejects vague responsive sections.
- **Don't forget `::before` / `::after`.** They carry hero overlays, heading underline bars, and icon glyphs. `section.mjs` captures them under a `pseudo` key — if a spec has none and the screenshot shows decorations, extraction was incomplete.
diff --git a/CLAUDE.md b/CLAUDE.md
index 6dbf165..227e684 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -19,7 +19,7 @@ Template for cloning any multi-page website into this Next.js codebase, then reb
- **Content lives in `src/data/*.ts`, never hardcoded in components.** Components take props. This is what makes `/restyle` possible — copy swaps without touching layout.
- Pages: `src/app/<route>/page.tsx` wires data → components. Shared header/footer mount in layouts.
- `docs/research/` holds extraction artifacts (JSON, specs, manifest) — auditable, never hand-edited except spec files.
-- `docs/research/manifest.json` is the pipeline state. Update it at every stage transition; check it first on any clone-related task (`node scripts/manifest.mjs status`).
+- `docs/research/manifest.json` is the pipeline state. The extraction/spec/QA scripts self-report their stage transitions; update `built`/`merged` manually. Check it first on any clone-related task (`node scripts/manifest.mjs status`).
- Specs (`docs/research/components/**/*.spec.md`) must pass `node scripts/lint-spec.mjs` before any builder agent is dispatched.
- All extraction numbers come from `scripts/` (computed styles, real column counts, pixel diffs) — never estimated by eye.
diff --git a/scripts/diff.mjs b/scripts/diff.mjs
index 574f5e4..aa0dec2 100644
--- a/scripts/diff.mjs
+++ b/scripts/diff.mjs
@@ -47,6 +47,7 @@ import {
parseArgs,
toList,
} from "./lib.mjs";
+import { selfReport, findPage, findSection, advanceStage, updatePageStatus } from "./manifest-lib.mjs";
const args = parseArgs(process.argv.slice(2));
@@ -280,6 +281,38 @@ if (args.original && args.clone) {
}
}
output = { route: args.route && args.route !== true ? args.route : null, sections: sectionResults };
+
+ // A --route sweep IS the QA measurement — record per-viewport scores in the
+ // manifest and advance sections whose three viewports all clear the
+ // threshold to qa_passed, instead of leaving that to a separate command.
+ if (output.route) {
+ const qaThreshold = args.threshold ? Number(args.threshold) : 95;
+ let scored = 0, passed = 0;
+ selfReport((m) => {
+ const p = findPage(m, output.route);
+ if (!p) return false;
+ let changed = false;
+ for (const s of sections) {
+ const sec = findSection(p, s.name);
+ if (!sec) continue;
+ for (const vp of vpNames) {
+ const r = sectionResults[s.name].viewports[vp];
+ if (r && !r.error) {
+ sec.scores[vp] = r.match;
+ changed = true;
+ scored++;
+ }
+ }
+ if (["pc", "ipad", "phone"].every((v) => typeof sec.scores[v] === "number" && sec.scores[v] >= qaThreshold)) {
+ if (advanceStage(sec, "qa_passed")) passed++;
+ changed = true;
+ }
+ }
+ if (changed) updatePageStatus(p);
+ return changed;
+ });
+ if (scored) console.error(` ✓ manifest: ${scored} score(s) recorded${passed ? `, ${passed} section(s) → qa_passed` : ""}`);
+ }
} else {
// Single live mode.
const name = args.name || slugify(args.selector || "page");
diff --git a/scripts/extract/page.mjs b/scripts/extract/page.mjs
index e0c3a36..9c5938b 100644
--- a/scripts/extract/page.mjs
+++ b/scripts/extract/page.mjs
@@ -60,6 +60,7 @@ import {
nameFromSelector,
} from "./collectors.mjs";
import { compactWalk, toLegacy } from "./walk-format.mjs";
+import { selfReport, findPage, findSection, advanceStage, updatePageStatus, routeOfUrl } from "../manifest-lib.mjs";
const t0 = Date.now();
const args = parseArgs(process.argv.slice(2));
@@ -248,6 +249,32 @@ for (const s of sections) {
}
}
+// Self-report: the walks above ARE the extraction, so the script does its own
+// bookkeeping — registering any section the manifest doesn't know yet and
+// advancing known ones to `extracted`. No manifest (or untracked route) = no-op.
+{
+ let registered = 0, advanced = 0;
+ selfReport((m) => {
+ const p = findPage(m, routeOfUrl(url));
+ if (!p) return false;
+ for (const s of sections) {
+ if (walks[s.selector]?.error) continue;
+ let sec = findSection(p, s.name);
+ if (!sec) {
+ sec = { name: s.name, selector: s.selector, stage: "discovered", spec: null, component: null, scores: {} };
+ p.sections.push(sec);
+ registered++;
+ }
+ if (advanceStage(sec, "extracted")) advanced++;
+ }
+ if (registered || advanced) updatePageStatus(p);
+ return registered || advanced;
+ });
+ if (registered || advanced) {
+ console.error(` ✓ manifest: ${advanced} section(s) marked extracted${registered ? `, ${registered} newly registered` : ""}`);
+ }
+}
+
// ── 5. Downloads + screenshots overlap (network vs browser work) ────────────
const jobs = [];
diff --git a/scripts/lint-spec.mjs b/scripts/lint-spec.mjs
index 31035f6..5332de7 100644
--- a/scripts/lint-spec.mjs
+++ b/scripts/lint-spec.mjs
@@ -6,7 +6,8 @@
// node scripts/lint-spec.mjs docs/research/components (lints every *.spec.md inside)
// Exit 1 if any spec fails.
import { readFileSync, statSync, readdirSync, existsSync } from "node:fs";
-import { join } from "node:path";
+import { join, basename, dirname, relative, isAbsolute } from "node:path";
+import { selfReport, findPage, findSection, advanceStage } from "./manifest-lib.mjs";
const REQUIRED_FRONTMATTER = ["component", "target", "page", "screenshot", "interaction_model", "states", "assets", "responsive"];
const INTERACTION_MODELS = ["static", "click-driven", "scroll-driven", "hover-driven", "time-driven", "mixed"];
@@ -142,9 +143,34 @@ for (const file of files) {
errors.forEach((e) => console.log(` ERROR: ${e}`));
} else {
console.log(`✓ ${file}`);
+ markSpecd(file);
}
warnings.forEach((w) => console.log(` warn: ${w}`));
}
+// A passing lint IS the "specd" stage transition — report it to the manifest
+// instead of relying on a separate agent command. Spec paths follow
+// components/<route-slug>/<name>.spec.md; when the slug doesn't invert to a
+// route cleanly (nested routes), fall back to the unique section name.
+function markSpecd(file) {
+ const name = basename(file).replace(/\.spec\.md$/, "");
+ const slug = basename(dirname(file));
+ const specPath = isAbsolute(file) ? relative(process.cwd(), file) : file;
+ const reported = selfReport((m) => {
+ let page = findPage(m, slug === "home" ? "/" : `/${slug}`);
+ let sec = findSection(page, name);
+ if (!sec) {
+ const hits = m.pages.flatMap((p) => p.sections.filter((s) => s.name === name).map((s) => [p, s]));
+ if (hits.length === 1) [page, sec] = hits[0];
+ }
+ if (!sec) return false;
+ const advanced = advanceStage(sec, "specd");
+ const pathChanged = sec.spec !== specPath;
+ sec.spec = specPath;
+ return advanced || pathChanged;
+ });
+ if (reported) console.log(` manifest: ${name} → specd`);
+}
+
console.log(`\n${files.length - failed}/${files.length} specs pass`);
process.exit(failed ? 1 : 0);
diff --git a/scripts/manifest-lib.mjs b/scripts/manifest-lib.mjs
new file mode 100644
index 0000000..bc7150f
--- /dev/null
+++ b/scripts/manifest-lib.mjs
@@ -0,0 +1,73 @@
+// Shared manifest IO — used by the manifest.mjs CLI and by the scripts that
+// self-report pipeline progress (page.mjs -> extracted, lint-spec.mjs -> specd,
+// diff.mjs -> scores + qa_passed). During the benchmark the manifest lagged
+// reality because every update was a separate agent command; the scripts now do
+// their own bookkeeping at the moment the work happens.
+//
+// Deliberately dependency-free (no lib.mjs import): lint-spec must not pay a
+// playwright module load just to flip a stage.
+import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
+
+export const MANIFEST_FILE = "docs/research/manifest.json";
+export const STAGES = ["discovered", "extracted", "specd", "built", "merged", "qa_passed"];
+
+export function loadManifest() {
+ if (!existsSync(MANIFEST_FILE)) return null;
+ return JSON.parse(readFileSync(MANIFEST_FILE, "utf8"));
+}
+
+export function saveManifest(m) {
+ m.updatedAt = new Date().toISOString();
+ mkdirSync("docs/research", { recursive: true });
+ writeFileSync(MANIFEST_FILE, JSON.stringify(m, null, 2) + "\n");
+}
+
+export function findPage(m, route) {
+ return m?.pages?.find((p) => p.route === route) || null;
+}
+
+export function findSection(page, name) {
+ return page?.sections?.find((s) => s.name === name) || null;
+}
+
+// URL pathname -> route, mirroring lib.mjs routeOf without importing it.
+export function routeOfUrl(url) {
+ try {
+ const p = new URL(url).pathname.replace(/\/+$/, "");
+ return p === "" ? "/" : p;
+ } catch {
+ return null;
+ }
+}
+
+// Auto-reporters only ever move a section FORWARD. A re-run of an early-phase
+// script must not demote a section a human (or a later script) already
+// advanced — manual `manifest.mjs set` remains the override for that.
+export function advanceStage(section, stage) {
+ if (STAGES.indexOf(stage) > STAGES.indexOf(section.stage)) {
+ section.stage = stage;
+ return true;
+ }
+ return false;
+}
+
+export function updatePageStatus(page) {
+ page.status =
+ page.sections.length && page.sections.every((s) => s.stage === "qa_passed") ? "done" : "in_progress";
+}
+
+// Wrapper for self-reporting scripts: no manifest -> silent no-op; a broken
+// manifest must never take down the actual work. `fn(m)` returns truthy when
+// it changed something worth saving.
+export function selfReport(fn) {
+ try {
+ const m = loadManifest();
+ if (!m) return false;
+ const changed = fn(m);
+ if (changed) saveManifest(m);
+ return !!changed;
+ } catch (e) {
+ console.error(` (manifest self-report skipped: ${e.message})`);
+ return false;
+ }
+}
diff --git a/scripts/manifest.mjs b/scripts/manifest.mjs
index 266a96f..99c455e 100644
--- a/scripts/manifest.mjs
+++ b/scripts/manifest.mjs
@@ -13,29 +13,23 @@
// node scripts/manifest.mjs set --route / --section hero --score pc=96.2
// node scripts/manifest.mjs status
// node scripts/manifest.mjs next
-import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from "node:fs";
+import { existsSync, rmSync } from "node:fs";
import { parseArgs, CACHE_DIR } from "./lib.mjs";
-
-const FILE = "docs/research/manifest.json";
-const STAGES = ["discovered", "extracted", "specd", "built", "merged", "qa_passed"];
+import { MANIFEST_FILE as FILE, STAGES, loadManifest, saveManifest as save, findPage as findPageIn } from "./manifest-lib.mjs";
const [cmd, ...rest] = process.argv.slice(2);
const args = parseArgs(rest);
const load = () => {
- if (!existsSync(FILE)) {
+ const m = loadManifest();
+ if (!m) {
console.error(`No manifest at ${FILE} — run: node scripts/manifest.mjs init <url>`);
process.exit(1);
}
- return JSON.parse(readFileSync(FILE, "utf8"));
-};
-const save = (m) => {
- m.updatedAt = new Date().toISOString();
- mkdirSync("docs/research", { recursive: true });
- writeFileSync(FILE, JSON.stringify(m, null, 2) + "\n");
+ return m;
};
const findPage = (m, route) => {
- const p = m.pages.find((p) => p.route === route);
+ const p = findPageIn(m, route);
if (!p) {
console.error(`Page not found: ${route}. Pages: ${m.pages.map((p) => p.route).join(", ") || "(none)"}`);
process.exit(1);