mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Addresses every issue surfaced during hands-on live-mode testing. ## Injection across multi-page sites - Config schema: `file` → `files: string[]` so multi-page static sites can opt into script-tag injection across every HTML entry the browser loads. - `live-inject.mjs` loops the array, reports per-file results, and refuses silently with `config_invalid` if the schema is stale. - `insertBefore` switched from first-match to last-match (lastIndexOf) so the anchor lands at the true close of `</body>`, not the first one embedded inside a `<pre><code>` documentation sample. ## Source-vs-generated detection - New `is-generated.mjs` helper: gitignore check + generated-header markers. Edge-case `generatedFiles` config dropped — the two real signals cover every project shape we tested. - `live-wrap.mjs` excludes generated files from auto-search and returns clear fallback errors: `file_is_generated`, `element_not_in_source` (with `generatedMatch` path), and `element_not_found`. - `live-accept.mjs` refuses to persist into generated files; returns `mode: "fallback"` so the agent takes over via the Handle fallback flow. ## Accept correctness - `extractVariant` / `extractOriginal` now skip `<style>` regions when matching markers. Previous regex substring match treated `@scope ([data-impeccable-variant="N"])` in CSS as the target HTML div, capturing garbage and producing orphan CSS that rendered as prose on the page. - On accept, the chosen variant's content is wrapped in `<div data-impeccable-variant="N" style="display: contents">` so the carbonize block's `@scope` selectors keep matching. Users see the accepted design immediately; no pre-carbonize dead state. ## Browser-side UI - `positionBar` gains a third case: when the selected element is taller than the viewport, pin the bar to a stable viewport anchor instead of teleporting between top and bottom as the user scrolls. - No-HMR source-fetch path (`injectVariantsFromSource`) now calls `hideShaderOverlay()` on state transition to CYCLING. Previously the shader kept running after variants arrived via the fetch fallback. - `pickVariantContent` helper replaces fragile `> :first-child` selection for outline positioning. Skips non-visual tags (style, script, link, meta, template) and falls back to the variant div itself when a variant contains multiple visual children. - `resumeSession` re-captures and restarts the shader overlay when the page reloads mid-generation (Bun HTML HMR does a full reload and destroys the canvas). - MutationObserver re-anchors `selectedElement` when the original element is detached by HMR, preventing zero-rect highlight drift. ## Skill docs - `live.md` reframes `config.files` as "the HTML files the browser actually loads" and documents the regen-wipes-inject caveat for multi-page generator projects. - New Handle fallback section covers the three wrap error shapes and how the agent should manually wrap for preview and commit to real source on accept. - Handle accept documents the new `data-impeccable-variant` wrapper and the carbonize agent's duty to strip it. ## Prefetch feature (landed but disabled) A `prefetch` event fires from the browser on first CONFIGURING per route so the agent can pre-Read the source file before Go. Real latency win in the linger-before-Go case but costs a harness round trip when Go fires quickly. Disabled via a `PREFETCH_ENABLED = false` flag in `live-browser.js`; server validator and skill dispatch stay so re- enabling (with a browser-side debounce) is a one-line change. ## Harness guidance Earlier skill rewrite compressed two load-bearing instructions: - Restored prescriptive wording for "open the tab via Chrome MCP before the first poll" and the Claude Code background-poll policy. - Flag-mapping for `live-wrap` rewritten as explicit bullets so models don't collapse `--element-id`/`--classes`/`--tag` into a single `--query` argument. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>