diff --git a/.cursor/hooks.json b/.cursor/hooks.json index 8dded20..7ce5e64 100644 --- a/.cursor/hooks.json +++ b/.cursor/hooks.json @@ -1,9 +1,10 @@ { "version": 1, "hooks": { - "preToolUse": [ + "postToolUse": [ { - "command": "[ ! -f \".cursor/skills/impeccable/scripts/impeccable\" ] || \".cursor/skills/impeccable/scripts/impeccable\" hook-before-edit", + "command": "[ ! -f \".cursor/skills/impeccable/scripts/impeccable\" ] || \".cursor/skills/impeccable/scripts/impeccable\" hook", + "matcher": "^Write$", "timeout": 5 } ] diff --git a/.cursor/skills/impeccable/SKILL.md b/.cursor/skills/impeccable/SKILL.md index 43e1253..96aa029 100644 --- a/.cursor/skills/impeccable/SKILL.md +++ b/.cursor/skills/impeccable/SKILL.md @@ -1,7 +1,7 @@ --- name: impeccable description: "Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks." -version: 4.7.0 +version: 4.8.0 license: Apache 2.0 --- @@ -18,7 +18,7 @@ Core principles: 2. Load the request's playbook: its Commands-table reference for an explicit/implied sub-command, or [reference/new-work.md](reference/new-work.md) for a new surface or replacement visual world. Inspect target and incumbent visual truth before editing. When the app cannot run, start with committed visual-regression goldens or screenshot fixtures; verify target and freshness against current tokens, CSS, components, or assets, resolve conflicts, and compare theme/variant captures. 3. After resolving analysis and direction, read [reference/craft-floor.md](reference/craft-floor.md) immediately before any UI edit, including small refinements. It carries the quality floor, the absolute bans, and the reflexes no detector catches. Do not load it for planning-only work. -**Launcher unavailable:** On refusal or failure, send a separate message **before the next tool call**: “Context loading did not run; I’ll read the existing project context directly.” Then read existing PRODUCT.md and DESIGN.md without inventing missing context, follow applicable steps 2–3, and continue through permitted tools. This applies to planning and editing; launcher failure alone does not block either. +**Launcher unavailable:** On refusal or failure, send a separate message **before the next tool call**: “Context loading did not run; I’ll read the existing project context directly.” Then read existing PRODUCT.md and DESIGN.md without inventing missing context, follow applicable steps 2–3, including reading [reference/craft-floor.md](reference/craft-floor.md) immediately before any UI edit, and continue through permitted tools. This applies to planning and editing; launcher failure alone does not block either. ## How to design diff --git a/.cursor/skills/impeccable/reference/android.md b/.cursor/skills/impeccable/reference/android.md index 1f67a6b..32a5cf7 100644 --- a/.cursor/skills/impeccable/reference/android.md +++ b/.cursor/skills/impeccable/reference/android.md @@ -42,5 +42,5 @@ Would a fluent Android user trust this app, or trip on off-spec components? The ## Verifying the build - **Screenshots come from the emulator or a connected device, never a browser.** Build and install, then capture with `adb exec-out screencap -p > ` (pick a device with `adb -s ` when several are attached). Capture every device class the app ships to, at least one phone and, when tablets are a target, one tablet, and write the files where the review flow expects them. -- **Dark theme and font scale belong in the pass.** `adb shell cmd uimode night yes` flips the theme; `adb shell settings put system font_scale 1.3` (restore `1.0` after) catches the clipped labels a fixed layout hides; with several targets attached, the capture's `-s ` goes on these commands too. +- **Dark theme and font scale belong in the pass.** `adb shell cmd uimode night yes` flips the theme; `adb shell settings put system font_scale 1.3` (read both settings first with `adb shell cmd uimode night` and `adb shell settings get system font_scale`, and restore them after) catches the clipped labels a fixed layout hides; with several targets attached, the capture's `-s ` goes on these commands too. - **Emulators give breadth; gestures, refresh rates, and performance need hardware.** Say which one produced the evidence. diff --git a/.cursor/skills/impeccable/reference/audit.md b/.cursor/skills/impeccable/reference/audit.md index c1e1506..d8f79f2 100644 --- a/.cursor/skills/impeccable/reference/audit.md +++ b/.cursor/skills/impeccable/reference/audit.md @@ -11,7 +11,7 @@ Run comprehensive checks across 5 dimensions. Score each dimension 0-4 using the ### 1. Accessibility (A11y) **Check for**: -- **Contrast issues**: Text contrast ratios < 4.5:1 (or 7:1 for AAA) +- **Contrast issues**: Text contrast ratios < 4.5:1, or < 3:1 for large text (or 7:1 for AAA) - **Motion sensitivity**: `prefers-reduced-motion` needs an intentional alternative that preserves state change and hierarchy; flag a global `0.01ms` kill that destroys useful feedback, flashing above threshold, and motion that blocks focus, reading, or task completion - **Missing ARIA**: Interactive elements without proper roles, labels, or states - **Keyboard navigation**: Missing focus indicators, illogical tab order, keyboard traps @@ -47,7 +47,7 @@ Run comprehensive checks across 5 dimensions. Score each dimension 0-4 using the **Check for**: - **Fixed widths**: Hard-coded widths that break on mobile -- **Touch targets**: Interactive elements < 44x44px +- **Touch targets**: Interactive elements < 44x44px. WCAG AA (SC 2.5.8) requires at least 24x24 CSS px unless an exception applies: spacing, an equivalent control, inline text, user-agent styling, or an essential size. Spacing passes when a 24 CSS px circle centered on the target's bounding box overlaps no other target and no other undersized target's circle - **Broken touch interaction**: Custom sliders, drag surfaces, and scrollable control strips whose primary gesture fails under touch, that swallow page scroll or lose the drag to it, or that stay stuck after an interrupted gesture. Code tells: mouse-only handlers, no `touch-action` on a pointer-event drag surface, drag state that nothing clears on cancel, lost capture, or blur. Exercise the gesture when a browser tool can synthesize touch (a rendered viewport proves layout, not the gesture), then say what produced the evidence (emulated viewport, synthesized touch, which engine, physical device) and what stayed untested - **Horizontal scroll**: Content overflow on narrow viewports - **Text scaling**: Layouts that break when text size increases diff --git a/.cursor/skills/impeccable/reference/craft-floor.md b/.cursor/skills/impeccable/reference/craft-floor.md index 64a195e..1f2bb82 100644 --- a/.cursor/skills/impeccable/reference/craft-floor.md +++ b/.cursor/skills/impeccable/reference/craft-floor.md @@ -1,6 +1,6 @@ # Craft floor -Load this after the direction is settled, and build without announcing the checklist. A pinned brief or the committed visual world overrides anything here; your own habit does not. When the design hook is active it already enforces the mechanical checks below as you edit: act on its findings instead of re-auditing each rule. +Load this after the direction is settled, and build without announcing the checklist. A pinned brief or the committed visual world overrides anything here except a line marked as a ban; your own habit does not. When the design hook is active it already enforces the mechanical checks below as you edit: act on its findings instead of re-auditing each rule. ## Verify diff --git a/.cursor/skills/impeccable/reference/distill.md b/.cursor/skills/impeccable/reference/distill.md index 757630f..a496971 100644 --- a/.cursor/skills/impeccable/reference/distill.md +++ b/.cursor/skills/impeccable/reference/distill.md @@ -41,7 +41,7 @@ Expect to say no to good ideas to make room for great execution. Systematically remove complexity across these dimensions: ### Information Architecture -- **Reduce scope**: Remove secondary actions, optional features, redundant information +- **Reduce scope**: Remove secondary actions, redundant information - **Progressive disclosure**: Hide complexity behind clear entry points (accordions, modals, step-through flows) - **Combine related actions**: Merge similar buttons, consolidate forms, group related content - **Clear hierarchy**: ONE primary action, few secondary actions, everything else tertiary or hidden @@ -70,11 +70,11 @@ Systematically remove complexity across these dimensions: - **Clear next action**: ONE obvious next action, not five competing ones ### Content Simplification -- **Shorter copy**: Cut every sentence in half, then do it again +- **Shorter copy**: Cut filler, not meaning - **Active voice**: "Save changes" not "Changes will be saved" - **Remove jargon**: Plain language always wins - **Scannable structure**: Short paragraphs, bullet points, clear headings -- **Essential information only**: Remove marketing fluff, legalese, hedging +- **Essential information only**: Remove marketing fluff, hedging - **Remove redundant copy**: No headers restating intros, no repeated explanations, say it once ### Code Simplification diff --git a/.cursor/skills/impeccable/reference/doctor.md b/.cursor/skills/impeccable/reference/doctor.md index 7dc23b6..a09e343 100644 --- a/.cursor/skills/impeccable/reference/doctor.md +++ b/.cursor/skills/impeccable/reference/doctor.md @@ -6,7 +6,7 @@ This is maintenance, not design. Do not redesign anything, do not open files out Three kinds of drift travel under "out of date". Keep them apart: -- **Tool version.** The installed skill is older than the published one. `impeccable context` reports that at boot as `UPDATE_AVAILABLE` and `npx impeccable update` fixes it. Not this command's job. +- **Tool version.** The installed skill is older than the published one. `impeccable context` reports that at boot as `UPDATE_AVAILABLE` and `npx impeccable update` fixes it, or the harness's plugin manager for a plugin install. Not this command's job. - **Schema drift.** An artifact was written by an older Impeccable: fields nothing reads, fields now expected, files in retired locations. Mechanical, and this command repairs most of it. - **Truth drift.** The code moved on and the document no longer describes it. No file comparison settles this. `document` owns DESIGN.md, `init` owns PRODUCT.md, and this command's job is to hand them a specific gap rather than a vague suspicion. diff --git a/.cursor/skills/impeccable/reference/document.md b/.cursor/skills/impeccable/reference/document.md index 9da0bc7..ec75b7c 100644 --- a/.cursor/skills/impeccable/reference/document.md +++ b/.cursor/skills/impeccable/reference/document.md @@ -17,10 +17,10 @@ colors: typography: display: fontFamily: "Cormorant Garamond, Georgia, serif" - fontSize: "clamp(2.5rem, 7vw, 4.5rem)" + fontSize: "4.5rem" fontWeight: 300 lineHeight: 1 - letterSpacing: "normal" + letterSpacing: "0em" body: # ... rounded: @@ -325,7 +325,7 @@ If the project has **no component library yet** (bare landing page, new project) #### Tonal ramps -For each color token, generate an 8-step `tonalRamp` array: dark to light, same hue and chroma, stepped lightness from ~15% to ~95%. The panel renders this as a strip under the swatch. If the project already defines a tonal scale (Material `surface-container-low` family, Tailwind-style `blue-50..blue-900`), use those values. Otherwise synthesize in OKLCH. +For each color token, generate an 8-step `tonalRamp` array: dark to light, same hue, chroma reduced near white and black, stepped lightness from ~15% to ~95%. The panel renders this as a strip under the swatch. If the project already defines a tonal scale (Material `surface-container-low` family, Tailwind-style `blue-50..blue-900`), use those values. Otherwise synthesize in OKLCH. #### Narrative mapping diff --git a/.cursor/skills/impeccable/reference/harden.md b/.cursor/skills/impeccable/reference/harden.md index 426b2d5..e7183cf 100644 --- a/.cursor/skills/impeccable/reference/harden.md +++ b/.cursor/skills/impeccable/reference/harden.md @@ -109,6 +109,25 @@ border-inline-end: 1px solid; /* Not border-right */ [dir="rtl"] .arrow { transform: scaleX(-1); } ``` +**Arabic-script specifics** (Arabic, Persian, Urdu, Pashto, Kurdish): +- Preserve Zero-Width Non-Joiner (U+200C). Persian and Kurdish use ZWNJ between compound-word parts to break cursive joining while keeping the word together. A filter or sanitizer that strips it changes meaning. Never normalize it away. +- Handle Yeh and Kaf variants. Persian uses ی (U+06CC) and ک (U+06A9), while Arabic uses ي (U+064A) and ك (U+0643). Preserve the original form in storage. For search and validation, treat the corresponding letters as equivalent so that Arabic-keyboard input matches Persian text. Rejecting one variant locks out users whose keyboard sends the other. +- Support locale-aware digits. Persian (`fa-IR`) and Arabic locales use Eastern Arabic-Indic numerals (۰-۹ and ٠-٩). Use `Intl.NumberFormat` with the correct locale rather than hardcoding Western digits. + +```javascript +// ✅ Locale-aware digit formatting +new Intl.NumberFormat('fa-IR').format(1234); // ۱٬۲۳۴ +new Intl.NumberFormat('ar-SA').format(1234); // ١٬٢٣٤ +``` + +- Respect calendar systems. Persian users expect the Solar Hijri (Jalali) calendar; many Arabic-speaking users expect the Hijri (Islamic) calendar. Use `Intl.DateTimeFormat` with the appropriate locale or calendar parameter. + +```javascript +// ✅ Locale-appropriate calendar +new Intl.DateTimeFormat('fa-IR').format(new Date()); +new Intl.DateTimeFormat('ar-SA-u-ca-islamic').format(new Date()); +``` + **Character set support**: - Use UTF-8 encoding everywhere - Test with Chinese/Japanese/Korean (CJK) characters diff --git a/.cursor/skills/impeccable/reference/hooks.md b/.cursor/skills/impeccable/reference/hooks.md index 71c4d44..6544c7f 100644 --- a/.cursor/skills/impeccable/reference/hooks.md +++ b/.cursor/skills/impeccable/reference/hooks.md @@ -2,9 +2,9 @@ Manage the **design detector hook** for the current project. -The hook runs the impeccable design detector on direct file edits to design-relevant files (`.tsx`, `.jsx`, `.html`, `.vue`, `.svelte`, `.astro`, `.css`, `.scss`, `.sass`, `.less`, `.ts`, `.js`). Claude Code, Codex, and GitHub Copilot use a post-tool-use hook and push a short system reminder into the agent's context after the edit; findings get a correction prompt, pending issues get a re-nudge, and clean UI-ish files get a short ack unless quiet mode is on (`hook.quiet` in config). Plain `.ts` and `.js` files are still scanned, but stay quiet unless the detector finds something. Cursor uses `preToolUse` to block bad proposed writes before they land and stays silent when it allows a clean write. Grok Build fires the same PostToolUse scan to mark touched files, then surfaces findings on Stop `additionalContext`. Do not expect a Grok per-edit reminder: Grok discards that stdout. +The hook runs the impeccable design detector on direct file edits to design-relevant files (`.tsx`, `.jsx`, `.html`, `.vue`, `.svelte`, `.astro`, `.css`, `.scss`, `.sass`, `.less`, `.ts`, `.js`). Claude Code, Codex, Cursor, and GitHub Copilot use a post-tool-use hook and push a short system reminder into the agent's context after the edit; findings get a correction prompt, pending issues get a re-nudge, and clean UI-ish files get a short ack unless quiet mode is on (`hook.quiet` in config). Plain `.ts` and `.js` files are still scanned, but stay quiet unless the detector finds something. Grok Build fires the same PostToolUse scan to mark touched files, then surfaces findings on Stop `additionalContext`. Do not expect a Grok per-edit reminder: Grok discards that stdout. -The detector rules run in two tiers. The per-edit hook surfaces only the immediate tier: mechanical, unambiguous problems worth interrupting an edit for, such as broken images, overflowing content, contrast and legibility failures, gradient text, glow shadows, and design-system drift. Everything else (copy cadence, palette and typography taste, layout rhythm) is deferred to a deep pass on the `Stop` hook event, which runs the full rule set over every UI file touched in the session and surfaces the remaining findings once, deduplicated against what the per-edit pass already reported. A session with nothing left to report stops silently. Set `hook.perEditRules` to `"all"` in `.impeccable/config.json` to restore the full rule set on every edit. The Stop deep pass is wired for Claude Code, Codex, and Grok Build, which dispatch a native `Stop` hook event. Cursor does not get one (its stop hook is not consistently dispatched; the pre-write gate covers it), and GitHub Copilot's stop-style events do not feed context back to the model, so they keep the full detector per edit. Grok also fires an observe-only Stop with `reason: "shutdown"` after `end_turn`; skip that one, scan only `end_turn`. +The detector rules run in two tiers. The per-edit hook surfaces only the immediate tier: mechanical, unambiguous problems worth interrupting an edit for, such as broken images, overflowing content, contrast and legibility failures, gradient text, glow shadows, and design-system drift. Everything else (copy cadence, palette and typography taste, layout rhythm) is deferred to a deep pass on the `Stop` hook event, which runs the full rule set over every UI file touched in the session and surfaces the remaining findings once, deduplicated against what the per-edit pass already reported. A session with nothing left to report stops silently. Set `hook.perEditRules` to `"all"` in `.impeccable/config.json` to restore the full rule set on every edit. The Stop deep pass is wired for Claude Code, Codex, and Grok Build, which dispatch a native `Stop` hook event. Cursor does not get one (its `stop` hook can only answer with a follow-up user message), and GitHub Copilot's stop-style events do not feed context back to the model, so they keep the full detector per edit. Grok also fires an observe-only Stop with `reason: "shutdown"` after `end_turn`; skip that one, scan only `end_turn`. Every hook is a mechanical pass. The reflexes no scanner catches live in [craft-floor.md](craft-floor.md), which the skill loads before it edits UI, so they apply whether or not a hook is wired. A session with no automatic hook gets one `MANUAL_DETECTOR_REQUIRED` directive from `impeccable context` asking for a single detector run at the end. @@ -16,7 +16,7 @@ Manual `.cursor/skills/impeccable/scripts/impeccable detect` scans use the same Supported harnesses: Claude Code (`.claude/settings.local.json` for a project-scope install; `~/.claude/settings.json` for a user-scope install; a project hook moved into shared `.claude/settings.json` is honored in place too), Codex (`.codex/hooks.json` in the project), Cursor (`.cursor/hooks.json` in the project), Grok Build (`.grok/hooks/impeccable.json` in the project; requires `/hooks-trust` or `--trust`), and GitHub Copilot (`.github/hooks/impeccable.json` in the project, a team-shared committed file that both the Copilot CLI and the cloud agent read). For the Copilot CLI, repo-level hooks fire once `.github/hooks/impeccable.json` is committed to the repository's default branch. -On **Cursor**, `preToolUse` checks proposed Write/Edit/Shell write content and denies only when the real detector finds an issue. The denial message is visible to the agent as the tool error, so the agent can reconsider before the bad write lands. +On **Cursor**, the hook runs on `postToolUse` for the `Write` tool (every agent file edit) and returns its reminder as `additional_context`, which Cursor adds after the tool result. Projects set up before this ran a `preToolUse` gate (`hook-before-edit`) that blocked bad writes before they landed; that gate still works until `hooks on`, `impeccable update`, or `impeccable doctor --fix` moves the entry to `postToolUse`. Gemini installs session and completion hooks in `.gemini/settings.json`, merged into the settings already there (comments are tolerated; a commented file is backed up to `settings.json.bak` before the rewrite, and a file that is not valid JSON is left alone). It does not install a per-edit detector hook. The `BeforeTool` hook only rewrites shell commands that run `build-phase`, and only on macOS and Linux; on Windows (where Gemini runs hooks through PowerShell) no session id reaches the shell, so a comp build is not tied to the session and the completion reminder stays silent. @@ -104,7 +104,8 @@ Example whole-file exception, for a file that is out of scope entirely: - Never modify `.impeccable/config.json` or `.impeccable/config.local.json` by hand from this command. Always go through `impeccable hooks` so writes stay validated and the file shape stays consistent. One exception: `detector.extensions` has no admin action, so when the user asks to cover a template stack, edit that one field in `.impeccable/config.json` directly and leave the rest of the file untouched. - Do not edit the launcher or the binary behind `impeccable hook` and `impeccable hook-before-edit` from this flow. Those are skill plumbing. -- Cursor can block a proposed write when the detector finds a real issue. Claude Code, Codex, and GitHub Copilot do not block the edit; they emit a post-edit reminder instead. Disabling stops both blocking and reminders. +- When a user asks how far to trust the hook, say it runs the engine unsandboxed with the agent's environment and network access (in the Copilot cloud agent too, once `.github/hooks/impeccable.json` is committed), and that the launcher checks a downloaded engine against `.cursor/skills/impeccable/scripts/engine-checksums.txt` before its first run; **never** call it sandboxed. +- The hook never blocks an edit; it emits a post-edit reminder. (A Cursor project still on the old `preToolUse` gate can block a write until its manifest is migrated.) Disabling stops the reminders. - The hook is bundled with the Impeccable skill. Project installs use `.claude/settings.local.json`, `.codex/hooks.json`, `.cursor/hooks.json`, `.github/hooks/impeccable.json`, and `.gemini/settings.json`; a user-scope Claude install uses `~/.claude/settings.json`. On Codex, the user must approve the hook via `/hooks` the first time. On Cursor, confirm hooks are enabled under Settings -> Hooks. On GitHub Copilot, the CLI loads `.github/hooks/impeccable.json` once it is committed to the repository's default branch, and the cloud agent reads it from the repo directly. ## Failure modes diff --git a/.cursor/skills/impeccable/reference/live.md b/.cursor/skills/impeccable/reference/live.md index 54d8974..0e4b975 100644 --- a/.cursor/skills/impeccable/reference/live.md +++ b/.cursor/skills/impeccable/reference/live.md @@ -158,14 +158,14 @@ Sources in priority order: DESIGN.md's visual system fields; CSS custom properti **Default:** compare each variant against the Phase A lock; palette, type voice, or rhetoric drift means it crossed into departure by accident: rework. Then confirm three different primary axes; three "tighter density" variants is failure. **Departure:** two passes, family before sentence. Family pass (non-negotiable): label each variant with a concrete family of your own choosing; shared or interchangeable labels mean rework. Sentence pass: three one-line descriptions side by side; two that rhyme mean rework. When the primary axis is color or theme, the trio must not share theme + dominant hue: three color worlds, not three shades. -**Action-specific invocations** must vary along the action's dimension: +**Action-specific invocations** must vary along the action's dimension; in default mode every variation stays within the available faces and existing tokens: - `bolder`: amplify a different dimension per variant (scale / saturation / structural change). - `quieter`: pull back a different dimension (color / ornament / spacing). - `distill`: remove a different class of excess (visual noise / redundant content / nested structure). - `polish`: a different refinement axis (rhythm / hierarchy / micro-details). -- `typeset`: different pairing AND different scale ratio each. -- `colorize`: different hue family each; vary chroma and contrast strategy. +- `typeset`: departure varies the pairing AND the scale ratio each; default keeps the faces and varies scale ratio, case, and weight each. +- `colorize`: departure gives each a different hue family and varies chroma and contrast strategy; default gives each a different existing palette role carrying the surface (Restrained / Committed / Full palette / Drenched) and a different contrast strategy. - `layout`: different structural arrangement, not spacing tweaks. - `adapt`: different target context per variant (mobile-first / tablet / desktop / print or low-data). - `animate`: different motion vocabulary (cascade stagger / clip wipe / scale-and-focus / morph / parallax). diff --git a/.cursor/skills/impeccable/reference/new-work.md b/.cursor/skills/impeccable/reference/new-work.md index 85862f9..46910b3 100644 --- a/.cursor/skills/impeccable/reference/new-work.md +++ b/.cursor/skills/impeccable/reference/new-work.md @@ -46,7 +46,7 @@ The script deals three of your structures; the dice pick which three reach the u 2. From that cultural world, list seven concrete visual systems, artifacts, places, or rituals the audience knows by heart, each with one line on why it resonates and can carry the mechanism and one on how it looks (its ground and main colours, its type voices, the one signature that makes it recognisable), ordered by resonance. The audience's world includes its graphic and screen traditions, not only its physical objects: the notation, publications, identity programs, data graphics, and interfaces it reads daily. On an Operate or Read surface, the seven still come from anywhere in that world (its graphic traditions, places, rituals, and artifacts), never from the tools and instruments the audience operates: a terminal, a scope, or a control panel handed to a working screen comes back as a costume of that tool. A nameable abstract system (a school of poster, a documentation standard) is as concrete a candidate as any artifact. On a Persuade or Experience surface, the tools and instruments the audience operates count toward the rut: spend at most one candidate on them. Also ask what this thing would look like as a physical object and what its world looked like before the web. Near-duplicates count once. When more than three of the seven share one material family, the derivation stopped at the subject's most obvious artifact; dig until the list spans at least three families. 3. Turn that material into complete directions: each joins a reusable visual world to a concrete first-surface experience. 4. Run `.cursor/skills/impeccable/scripts/impeccable concept-seed --scope direction --mode ` and follow what it prints. No substitute, no skip: on a new or replacement world, writing artifact code before this script has run and its assignment is acknowledged is a contract violation, whatever the harness, the model, or the time pressure; the roll is what keeps every run from converging on the category default. The script assigns the direction to build and deals catalog challengers. Fuse each challenger before judging it: the challenger supplies the form and its system grammar, the product supplies every fact, clarity wins conflicts. Weigh fused challengers against the assigned direction on exactly two axes, audience identification and product clarity. Losing to strong grounded material is a valid outcome; beating a thin or tool-monoculture list is the point. Close with a verdict per challenger, decided before any borrowing: wins (beats the assigned direction on both axes; becomes the build candidate), competitive (holds one axis; stays a full alternate), or declined (loses both). A declined challenger is not spent: name the one discipline of its system the assigned direction lacks, and raise the assigned direction to match before presenting it. A donation transfers ambition and system discipline (a palette's total commitment, a grid's density courage, a form's structural honesty), never the challenger's clothes. A component treatment, such as a button's shadow or a display face, is clothes, not discipline; a lifted motif is a costume note, not a raise, and one world owns the page. Write each raise into the presented direction as its own line, named for its donor; a raise nobody can read did not happen. -5. Present one direction, fully committed and already raised by the hand it beat, raises visible as named lines: world, first viewport, visitor path, signature interaction, cross-surface reach, honest risk. Route each challenger by verdict: winning and competitive challengers are full alternates with their QUALITY BAR cards and one-line case; declined challengers render demoted, compact and quiet, each carrying its verdict and what the direction kept from it, never full-size, never silently dropped, still adoptable on request. The verdict informs the user's choice, never pre-empts it; the demoted row is the hand's proof of judgment. A hand holds at most three full-card challengers: when the roll deals more, the three strongest join and the rest wait in the re-roll pool, noted in one line; dropping a challenger from the hand itself takes a named product-truth failure, disclosed. Add one card for your own top-ranked grounded candidate when it is not the assigned direction, kicker IMPECCABLE’S PICK, same anatomy as every card, with an honest risk line naming its familiarity when true: the strongest grounded direction is often where most runs in this category land, and the user deciding that trade is the point of showing it. Familiar and effective is a legitimate destination, not a failure of nerve; the pick card and the standing exit serve it at two depths. One pick card, never two, never a ranked list: a lineup of your candidates hands selection back to a taste function and invites the safest card. The pick never takes the lead position; when the dice assign your top candidate there is no pick card, and the assigned card notes it topped your list. Add re-roll with an optional one-line steer, in three registers: plain (a fresh hand, same spread), safer (your remaining conventional grounded candidates plus the canon against named competitors), bolder (foreign forms only, at full commitment). The register is the user's steering on the familiar-to-bold axis, never yours to pre-select; when the answer carries one, re-run the seed with `--register ` and the next `--reroll` round, and follow what it prints. A user saying "bolder" or "safer" while a direction round is open means these registers, never the bolder or harden commands. The two channels share this structure and differ only in richness: cards and boards on the decision page, names and one-liners through the structured tool, whose option list carries the assigned direction, the pick, the winning and competitive challengers, and the standing exit last; declined challengers fold into the assigned option's description as their kept lines, so the raise survives the text channel. +5. Present one direction, fully committed and already raised by the hand it beat, raises visible as named lines: world, first viewport, visitor path, signature interaction, cross-surface reach, honest risk. Route each challenger by verdict: winning and competitive challengers are full alternates with their QUALITY BAR cards and one-line case; declined challengers render demoted, compact and quiet, each carrying its verdict and what the direction kept from it, never full-size, never silently dropped, still adoptable on request. The verdict informs the user's choice, never pre-empts it; the demoted row is the hand's proof of judgment. A hand holds at most three full-card challengers: when the roll deals more, the three strongest join and the rest wait in the re-roll pool, noted in one line; dropping a challenger from the hand itself takes a named product-truth failure, disclosed. The hand's size follows the verdicts, never a number the user named: when the weighing yields fewer full cards than asked, deliver the honest hand, say in one line why it is smaller, and offer a re-roll to deal candidates that could earn full cards. A declined challenger is never promoted to fill a slot; a promoted card looks exactly like a competitive one, so the promotion leaves no trace. The standing exit does not count toward a requested number once the user has seen and rejected it; it stays present as the quiet door. Add one card for your own top-ranked grounded candidate when it is not the assigned direction, kicker IMPECCABLE’S PICK, same anatomy as every card, with an honest risk line naming its familiarity when true: the strongest grounded direction is often where most runs in this category land, and the user deciding that trade is the point of showing it. Familiar and effective is a legitimate destination, not a failure of nerve; the pick card and the standing exit serve it at two depths. One pick card, never two, never a ranked list: a lineup of your candidates hands selection back to a taste function and invites the safest card. The pick never takes the lead position; when the dice assign your top candidate there is no pick card, and the assigned card notes it topped your list. Add re-roll with an optional one-line steer, in three registers: plain (a fresh hand, same spread), safer (your remaining conventional grounded candidates plus the canon against named competitors), bolder (foreign forms only, at full commitment). The register is the user's steering on the familiar-to-bold axis, never yours to pre-select; when the answer carries one, re-run the seed with `--register ` and the next `--reroll` round, and follow what it prints. A user saying "bolder" or "safer" while a direction round is open means these registers, never the bolder or harden commands. The two channels share this structure and differ only in richness: cards and boards on the decision page, names and one-liners through the structured tool, whose option list carries the assigned direction, the pick, the winning and competitive challengers, and the standing exit last; declined challengers fold into the assigned option's description as their kept lines, so the raise survives the text channel. The standing exit: every direction round offers one quiet, permanent alternative, the category standard, played straight. It is the user's door, never yours: never recommend it, never weigh it against the roll, never let it soften the dealt directions; the counterweights bind the unchosen default, not the chosen one. When the user takes it (the canon action, a safer-steer, or plain words asking for the familiar or competitor-like path), convention becomes the commitment: ask once for two or three products this should sit alongside, make their craft level the bar, and execute the canon at full fidelity, without irony or smuggled quirk. Record a standing preference as a brand commitment in PRODUCT.md. Re-roll eliminates every direction already shown, grounded and challenger alike; after two consecutive re-rolls, ask what quality is missing. Re-roll on your own only on named factual grounds, when the assigned direction cannot carry the product's truth or task; taste is never grounds. The user may re-roll freely, and a user- or brief-pinned direction beats the roll, always. Resolve collisions field by field: preserve every user- or brief-pinned constraint. In dimensions the brief leaves open, the assignment still binds through its topology, controls, state vocabulary, and ritual; when only its materials conflict with a pinned visual direction or PRODUCT.md brand commitment, translate that material expression and name the translation in the presented direction. A look mismatch is not grounds to re-roll. Present the decision visually: write an options payload with the assigned direction leading, its raised lines included; the pick card when one exists; the dealt challengers as alternates with their QUALITY BAR cards, verdicts, and kept lines; re-roll with its safer and bolder registers; steer; canon enabled; and `buildPath` carrying the recorded default with `toggle: true` whenever image generation exists (details in the build-path paragraph below). A degraded roll with no challengers still uses the page, as a single text-only card with re-roll. Every option declares its identity: `kind` is `assigned`, `pick`, `challenger`, or `grounded` (another of your own grounded directions, such as each card of a safer hand's lineup, any number of them), and each challenger carries `catalogId`, the SOURCE ID concept-seed printed for its world, never the card's own id; `--start` and `--update` refuse a direction or surface payload without them, and the page reports the choice from them. Give every card the same anatomy: thesis, palette, materials, first viewport, honest risk, and the challengers' case lines (`--schema` prints the exact shape); the page renders identity from these fields, demotes declined challengers to their row on its own, and a challenger's catalog image rides as labeled inspiration, never the promise of the build. Author `canonCard` too: the category standard as one honest card, same anatomy; the page keeps it subordinate, and the counterweights still bind you. Run `.cursor/skills/impeccable/scripts/impeccable serve-question --start --payload ` (`--schema` first for the payload shape). It daemonizes, prints the page URL and a key, and exits; open that URL for the user, in-app browser first, then the system opener, then showing the URL. Collect the choice with `--wait --key `, repeating while it exits 3; the ANSWER prints as JSON. An ANSWER of `{"optionId":"reroll"}` keeps the server alive and the page open on a loading hand: rerun concept-seed with the same `--scope` and `--mode` plus `--from --reroll ` (1 on the first re-roll, counting up), build the next payload, deliver it with `--update --key --payload `, then return to `--wait` on that key. Never `--start` a second server or fall back to chat here: either strands the open tab on a hand that never arrives. Exit 4 means the page closed unanswered: re-present once through the structured question tool, and with no answer there either, proceed unattended with the assigned direction and state the assumptions. A harness that can leave a shell blocked in the background may run the script without `--start` and let it auto-open and block. A harness that cannot hold a blocking `--wait` (it detaches long-running commands without ever returning their output, or reaps a backgrounded child) takes the structured tool without starting the page and discloses the substitution in the first reply, so the tab is never left unanswered. A shell that hands back a still-running command as a session you can poll holds the wait: poll that session until it exits, and rerun `--wait` only after it exits without an answer. Never predict any other fallback: run the script, and only exit code 2 from starting it, or that wait check before starting, routes the decision to the structured tool; those are the fallback, never an error to retry. concept-seed closes every roll with this procedure, condensed, as a PRESENTATION block that names the recorded build path. @@ -86,7 +86,7 @@ After writing, read the brief once more and verify that all six contract blocks Keep the brief small: scope and visitor mode; audience, job, action/task, proof/content, and constraints; chosen direction and memorable moment; unresolved decisions. Do not copy global product truth or DESIGN.md tokens into it. -On a comp-led build, whenever any image generation is available (a harness-native tool or the API fallback `impeccable context` reports), the locked direction is visualized before it is built, never skipped: load [visualize.md](visualize.md) and follow it, three compositional options put before the user for approval, the chosen card's decision comp plus two variations. This step is proven to produce the most compositional and ambitious work. On a code-led build the comp round is skipped by contract, never by drift: the ambition it would have carried lives in the direction contract's FIRST VIEWPORT block and named signature interaction, and the finish reviewer audits those promises in behavior. +On a comp-led build, whenever any image generation is available (a harness-native tool or the API fallback `impeccable context` reports), the locked direction is visualized before it is built, never skipped: load [visualize.md](visualize.md) and follow it, three compositional options put before the user for approval, the chosen card's decision comp plus two variations. This step is proven to produce the most compositional and ambitious work. A comp locked in a surface-scope structure round has already discharged this round (Create a whole surface inside an established world, above). On a code-led build the comp round is skipped by contract, never by drift: the ambition it would have carried lives in the direction contract's FIRST VIEWPORT block and named signature interaction, and the finish reviewer audits those promises in behavior. For `shape`, return the selected direction to [shape.md](shape.md) and stop before persistence or implementation. diff --git a/.cursor/skills/impeccable/reference/optimize.md b/.cursor/skills/impeccable/reference/optimize.md index 5c55a16..3f3fc7c 100644 --- a/.cursor/skills/impeccable/reference/optimize.md +++ b/.cursor/skills/impeccable/reference/optimize.md @@ -38,7 +38,6 @@ Create systematic improvement plan: src="hero.webp" srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px" - loading="lazy" alt="Hero image" /> ``` diff --git a/.cursor/skills/impeccable/reference/visualize.md b/.cursor/skills/impeccable/reference/visualize.md index 48c2681..f628950 100644 --- a/.cursor/skills/impeccable/reference/visualize.md +++ b/.cursor/skills/impeccable/reference/visualize.md @@ -26,7 +26,7 @@ Each comp is a direction test, not a screenshot specification. Core UI text, res Show the three together on the decision page (`impeccable serve-question`, one option per comp with the comp as its hero), or in the harness only when it renders images inline; a text-only surface does not count as display. Ask what should carry forward, what feels false to the world, and whether the selected concept should be approved, combined, revised, or rejected. Then stop and wait. A structured simulated user counts as attended and receives the same question. -Do not begin code until the user approves a direction or explicitly delegates the choice. If they delegate, choose using the task brief, PRODUCT.md, and DESIGN.md, and state the evidence. Approval refines the task concept; it does not modify DESIGN.md. +Do not begin code until the user approves a direction or explicitly delegates the choice. If they delegate, choose using the task brief, PRODUCT.md, and DESIGN.md (the chosen direction on a new world), and state the evidence. Approval refines the task concept; it does not modify DESIGN.md. This approval point has no substitute and no skip condition. When the structured question tool errors, fall back to the decision page; only after both fail may you treat the choice as delegated, and a delegated pick is recorded exactly as an approval is and disclosed in your first reply, not your last. The finish reviewer treats comp-round comps with no recorded approval as a material finding; decision comps under `.impeccable/mocks/decision/` are the direction round's hand, not comp-round output, and imply no approval on their own. diff --git a/.cursor/skills/impeccable/scripts/VERSION b/.cursor/skills/impeccable/scripts/VERSION index e8e277f..f8bc4c6 100644 --- a/.cursor/skills/impeccable/scripts/VERSION +++ b/.cursor/skills/impeccable/scripts/VERSION @@ -1 +1 @@ -0.1.16 +0.1.18 diff --git a/.cursor/skills/impeccable/scripts/command-metadata.json b/.cursor/skills/impeccable/scripts/command-metadata.json index 89891ea..4686bb6 100644 --- a/.cursor/skills/impeccable/scripts/command-metadata.json +++ b/.cursor/skills/impeccable/scripts/command-metadata.json @@ -4,7 +4,7 @@ "argumentHint": "[feature description]" }, "init": { - "description": "Sets up a project for impeccable. Runs a multi-round discovery interview when context is missing and writes PRODUCT.md (strategic: users, brand, principles); offers DESIGN.md (visual: colors, typography, components) when code exists; pre-configures live mode; then recommends the best commands to run next. Every other command reads these files before doing work. Use once per project.", + "description": "Sets up a project for impeccable. Runs a multi-round discovery interview when context is missing and writes PRODUCT.md (strategic: users, brand, principles); pre-configures live mode; then recommends the best commands to run next. Every other command reads these files before doing work. Use once per project.", "argumentHint": "" }, "document": { @@ -88,7 +88,7 @@ "argumentHint": "[target]" }, "shape": { - "description": "Plan UX and UI before code. Runs a required multi-round discovery interview, uses visual probes when available, and produces a user-confirmed design brief for implementation.", + "description": "Plan UX and UI before code. Runs a discovery interview (one round by default), uses visual probes when available, and produces a user-confirmed design brief for implementation.", "argumentHint": "[feature to shape]" }, "typeset": { diff --git a/.cursor/skills/impeccable/scripts/engine-checksums.txt b/.cursor/skills/impeccable/scripts/engine-checksums.txt new file mode 100644 index 0000000..2e94800 --- /dev/null +++ b/.cursor/skills/impeccable/scripts/engine-checksums.txt @@ -0,0 +1,9 @@ +# Engine binary digests for the pinned ENGINE_VERSION: . +# The launchers, the npm shim, `impeccable install` and scripts/fetch-engine.mjs verify +# every engine download against this file. Written by +# `node scripts/check-engine-release.mjs --record` after each engine release. +0.1.18 impeccable-darwin-arm64 543ee2f72036ad185dc9991ac3ba86b74d91f988f3d497776a088b8b65c8a9e1 +0.1.18 impeccable-darwin-x64 1f1eee78c142f7e40e16f481aeeeb1fad1d8515d8a1ef033d7c6d133e52232b3 +0.1.18 impeccable-linux-x64 736ed785e74ae2344d3036127f614ddde5ab520a527d8bc82a891612ef71f648 +0.1.18 impeccable-linux-arm64 317cb18d64b0f7715681dd6e574ad64b2adb5a6caf8e7a1b3b57965f805404be +0.1.18 impeccable-windows-x64.exe 8f61e96b0c97001546a824d79b44f46b423b560f3eb1a0cc44a8695a1b395d9f diff --git a/.cursor/skills/impeccable/scripts/impeccable b/.cursor/skills/impeccable/scripts/impeccable index 224028c..92d8cca 100644 --- a/.cursor/skills/impeccable/scripts/impeccable +++ b/.cursor/skills/impeccable/scripts/impeccable @@ -8,7 +8,10 @@ # named `impeccable`, and exec'ing it would fail every verb with # "Unknown command". Trusted candidates (IMPECCABLE_BIN, the sibling binary, # the version-pinned cache) are exec'd without a probe: hooks run them on -# every edit and must stay fast. +# every edit and must stay fast. The version-pinned cache and the download are +# verified against engine-checksums.txt (next to this script), never against +# anything published beside the binary; a .verified stamp records that +# a cached binary passed, so only the first run hashes it. set -eu # True when the candidate answers the engine handshake (prints @@ -18,14 +21,51 @@ set -eu # then skips its own probes and refuses to download, so probing stays cheap # and can never loop. probe_ok() { - case "$(IMPECCABLE_LAUNCHER_PROBE=1 "$1" engine-probe 2>/dev/null || true)" in + probe_out=$(IMPECCABLE_LAUNCHER_PROBE=1 "$1" engine-probe 2>/dev/null) || return 1 + case "$probe_out" in impeccable-engine*) return 0 ;; esac return 1 } probing=${IMPECCABLE_LAUNCHER_PROBE:-} +# Prints the digest engine-checksums.txt records for engine version $1 and +# asset $2 (lines are " "), nothing when there is none. +# A CR is a separator too (CRLF checkouts), and a last line with no newline +# still counts. +manifest_digest() { + [ -f "$manifest" ] || return 0 + while IFS="$(printf ' \t\r')" read -r m_version m_asset m_sum _ || [ -n "$m_version" ]; do + case "$m_version" in ''|'#'*) continue ;; esac + if [ "$m_version" = "$1" ] && [ "$m_asset" = "$2" ]; then + printf '%s' "$m_sum" + return 0 + fi + done < "$manifest" + return 0 +} +# Sets $expected (and, on Windows on ARM, which runs x64 binaries, +# $expected_x64) from engine-checksums.txt. Only called off the stamped fast +# path: hooks run this launcher on every edit. +read_expected() { + expected=$(manifest_digest "$version" "$asset") + expected_x64="" + if [ "$os" = windows ] && [ "$arch" = arm64 ]; then + expected_x64=$(manifest_digest "$version" impeccable-windows-x64.exe) + fi +} +# Sets $actual to the sha256 of $1, empty when no hash tool works. +hash_file() { + actual="" + if command -v shasum >/dev/null 2>&1; then + if digest=$(shasum -a 256 "$1" 2>/dev/null); then actual=${digest%% *}; fi + elif command -v sha256sum >/dev/null 2>&1; then + if digest=$(sha256sum "$1" 2>/dev/null); then actual=${digest%% *}; fi + fi +} + dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +manifest="$dir/engine-checksums.txt" # What the binary needs to know about its home: the skill directory (for # reference/*.md and command-metadata.json) and how to name itself in the @@ -77,8 +117,19 @@ version="" [ -f "$dir/VERSION" ] && version=$(tr -d '[:space:]' < "$dir/VERSION") cache_root="${IMPECCABLE_HOME:-${HOME:-/nonexistent}/.impeccable}" cached="$cache_root/bin/$version/impeccable$exe" +asset="impeccable-$os-$arch" +[ "$os" = windows ] && asset="$asset.exe" if [ -n "$version" ] && [ -x "$cached" ]; then - exec "$cached" "$@" + if [ -f "$cached.verified" ]; then + exec "$cached" "$@" + fi + read_expected + hash_file "$cached" + if [ -n "$actual" ] && { [ "$actual" = "$expected" ] || [ "$actual" = "$expected_x64" ]; }; then + { echo "$actual" > "$cached.verified"; } 2>/dev/null || : + exec "$cached" "$@" + fi + echo "impeccable: cannot verify the cached engine $cached against $manifest; not using it" >&2 fi if [ -z "$probing" ] && command -v impeccable >/dev/null 2>&1 && probe_ok impeccable; then exec impeccable "$@" @@ -104,12 +155,11 @@ fetch_url() { check_download() { download_file=${1:-$tmp} if [ ! -f "$download_file" ]; then - rm -f "$tmp.sha256" echo "impeccable: download completed but the file was removed before execution: $url; check your antivirus quarantine or logs. Refusing to continue; do not disable protection." >&2 exit 127 fi if [ ! -s "$download_file" ]; then - rm -f "$download_file" "$tmp.sha256" + rm -f "$download_file" echo "impeccable: downloaded file is empty: $url; refusing the unverified download" >&2 exit 127 fi @@ -120,13 +170,17 @@ if [ -n "$probing" ]; then fi if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then base="${IMPECCABLE_DOWNLOAD_BASE:-https://github.com/pbakaus/impeccable/releases/download}" - asset="impeccable-$os-$arch" - [ "$os" = windows ] && asset="$asset.exe" url="$base/engine-v$version/$asset" + read_expected + # Fail closed before any network traffic or cache write. + if [ -z "$expected" ] && [ -z "$expected_x64" ]; then + echo "impeccable: no checksum for engine $version ($asset) in $manifest; refusing the unverified download" >&2 + exit 127 + fi tmp="$cache_root/bin/$version/.impeccable.part.$$" # An interrupted download (Ctrl-C, a hook timeout) would otherwise leave the # PID-named staging file behind for good. The handlers must exit explicitly. - cleanup() { rm -f "$tmp" "$tmp.sha256" 2>/dev/null || :; } + cleanup() { rm -f "$tmp" 2>/dev/null || :; } trap 'cleanup; exit 129' HUP trap 'cleanup; exit 130' INT trap 'cleanup; exit 143' TERM @@ -143,40 +197,22 @@ if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then exit 127 fi fetched=0 - if fetch_url "$url"; then + if [ -n "$expected" ] && fetch_url "$url"; then fetched=1 - elif [ "$os" = windows ] && [ "$arch" = arm64 ]; then + elif [ -n "$expected_x64" ]; then # Windows on ARM runs x64 binaries; fall back when no arm64 asset exists. url="$base/engine-v$version/impeccable-windows-x64.exe" + expected=$expected_x64 fetch_url "$url" && fetched=1 fi if [ "$fetched" = 1 ]; then check_download - # Fail closed: a freshly downloaded binary runs only after verifying - # against its .sha256 sidecar. A sidecar that cannot be fetched, or a - # machine with no sha256 tool, refuses the download instead of exec'ing - # an unverified binary. (A binary already on PATH or in the cache that - # passes engine-probe is unaffected.) - sidecar_ok=0 - if command -v curl >/dev/null 2>&1; then - curl -fsSL --retry 2 -o "$tmp.sha256" "$url.sha256" 2>/dev/null && sidecar_ok=1 - elif command -v wget >/dev/null 2>&1; then - wget -q -O "$tmp.sha256" "$url.sha256" 2>/dev/null && sidecar_ok=1 - fi + # No sha256 tool refuses the download too. + hash_file "$tmp" check_download - expected="" - [ "$sidecar_ok" = 1 ] && expected=$(cut -d' ' -f1 < "$tmp.sha256") - actual="" - if command -v shasum >/dev/null 2>&1; then - if digest=$(shasum -a 256 "$tmp" 2>/dev/null); then actual=${digest%% *}; fi - elif command -v sha256sum >/dev/null 2>&1; then - if digest=$(sha256sum "$tmp" 2>/dev/null); then actual=${digest%% *}; fi - fi - check_download - rm -f "$tmp.sha256" - if [ -z "$expected" ] || [ -z "$actual" ]; then + if [ -z "$actual" ]; then rm -f "$tmp" - echo "impeccable: cannot verify $url against $url.sha256 (sidecar unavailable or hashing failed); refusing the unverified download" >&2 + echo "impeccable: cannot verify $url (no sha256 tool, or hashing failed); refusing the unverified download" >&2 exit 127 fi if [ "$actual" != "$expected" ]; then @@ -199,6 +235,7 @@ if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then exit 127 fi check_download "$cached" + { echo "$actual" > "$cached.verified"; } 2>/dev/null || : exec "$cached" "$@" fi rm -f "$tmp" 2>/dev/null diff --git a/.cursor/skills/impeccable/scripts/impeccable.cmd b/.cursor/skills/impeccable/scripts/impeccable.cmd index 789a96f..5f2039e 100644 --- a/.cursor/skills/impeccable/scripts/impeccable.cmd +++ b/.cursor/skills/impeccable/scripts/impeccable.cmd @@ -13,10 +13,11 @@ rem - The unversioned user binary and the PATH candidate are validated with rem the engine-probe handshake (see :probe) so the retired 3.x npm CLI, rem whose bin is also named impeccable, is never exec'd. IMPECCABLE_BIN, rem the sibling binary, and the version-pinned cache stay trusted. -rem - Downloads are verified against the .sha256 sidecar via certutil and -rem fail closed: a missing sidecar or hash tool refuses the download. On -rem ARM64 the arm64 asset is tried first and the x64 asset is the -rem fallback (Windows on ARM runs x64 binaries). +rem - Downloads and the version-pinned cache are verified via certutil +rem against engine-checksums.txt next to this file, and fail closed; a +rem .verified stamp lets later runs skip hashing the cache. On ARM64 the +rem arm64 asset is tried first and the x64 asset is the fallback (Windows on +rem ARM runs x64 binaries), each only when the manifest has a line for it. if not defined IMPECCABLE_SKILL_DIR set "IMPECCABLE_SKILL_DIR=%~dp0.." if not defined IMPECCABLE_SELF set "IMPECCABLE_SELF=%~f0" set "arch=x64" @@ -47,8 +48,22 @@ set "version=" if exist "%~dp0VERSION" set /p version=<"%~dp0VERSION" if not defined IMPECCABLE_HOME set "IMPECCABLE_HOME=%USERPROFILE%\.impeccable" set "cached=%IMPECCABLE_HOME%\bin\%version%\impeccable.exe" +set "asset=impeccable-windows-%arch%.exe" +set "manifest=%~dp0engine-checksums.txt" if not defined version goto no_cache if not exist "%cached%" goto no_cache +if exist "%cached%.verified" goto cache_trusted +call :read_expected +call :sha256 "%cached%" "%TEMP%\impeccable-hash-%RANDOM%%RANDOM%.txt" +if not defined actual goto cache_unverified +if /I "%actual%"=="%expected%" goto cache_verified +if /I "%actual%"=="%expected_x64%" goto cache_verified +:cache_unverified +echo impeccable: cannot verify the cached engine "%cached%" against "%manifest%"; not using it 1>&2 +goto no_cache +:cache_verified +(>"%cached%.verified" echo %actual%) 2>nul +:cache_trusted set "run=%cached%" goto run :no_cache @@ -67,6 +82,8 @@ rem the version-pinned user cache, verify it, then run it. Never inside rem another launcher's probe: fail fast and quiet instead. if defined IMPECCABLE_LAUNCHER_PROBE exit /b 127 if not defined version goto fail +call :read_expected +if not defined expected if not defined expected_x64 goto no_checksum where curl.exe >nul 2>nul if errorlevel 1 goto curl_missing if not defined IMPECCABLE_DOWNLOAD_BASE set "IMPECCABLE_DOWNLOAD_BASE=https://github.com/pbakaus/impeccable/releases/download" @@ -93,16 +110,17 @@ set "staging=%IMPECCABLE_HOME%\bin\%version%\.impeccable.part.%stamp%-%RANDOM%%R mkdir "%staging%" >nul 2>nul if errorlevel 1 goto claim_staging set "part=%staging%\impeccable.exe" -set "sidecar=%staging%\impeccable.sha256" rem Redirection failures do not reliably update ERRORLEVEL in cmd.exe; rem branch on the command's failure directly. (type nul >"%part%") 2>nul || goto staging_write_failed -set "asset=impeccable-windows-%arch%.exe" set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%" +if not defined expected goto fetch_x64 curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul if not errorlevel 1 goto verify -if not "%arch%"=="arm64" goto download_failed +:fetch_x64 +if not defined expected_x64 goto download_failed set "asset=impeccable-windows-x64.exe" +set "expected=%expected_x64%" set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%" curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul if errorlevel 1 goto download_failed @@ -111,28 +129,13 @@ if errorlevel 1 goto download_failed call :check_download if errorlevel 1 exit /b 127 rem Mirrors the sh launcher and fails closed: a freshly downloaded binary -rem runs only after verifying against its .sha256 sidecar. A sidecar that -rem cannot be fetched, or an empty certutil result, refuses the download -rem instead of running an unverified binary. -curl.exe -fsSL -o "%sidecar%" "%url%.sha256" >nul 2>nul -if errorlevel 1 goto verify_refuse -set "expected=" -set /p expected=<"%sidecar%" -for /f "tokens=1" %%h in ("%expected%") do set "expected=%%h" +rem runs only after its hash matches the digest read from engine-checksums.txt. +rem An empty certutil result refuses the download instead of running an +rem unverified binary. +call :sha256 "%part%" "%staging%\hash.txt" call :check_download if errorlevel 1 exit /b 127 -set "actual=" -rem Reuse the sidecar staging file after reading expected. Check certutil's -rem status before parsing: its error text on stdout is not a digest. -certutil -hashfile "%part%" SHA256 >"%sidecar%" 2>nul -if errorlevel 1 goto verify_refuse -call :check_download -if errorlevel 1 exit /b 127 -for /f "usebackq skip=1 delims=" %%h in ("%sidecar%") do if not defined actual set "actual=%%h" -del "%sidecar%" >nul 2>nul -if not defined expected goto verify_refuse if not defined actual goto verify_refuse -set "actual=%actual: =%" if /I "%actual%"=="%expected%" goto place call :discard_staging echo impeccable: checksum mismatch downloading %url% 1>&2 @@ -142,9 +145,40 @@ exit /b 127 call :check_download if errorlevel 1 exit /b 127 call :discard_staging -echo impeccable: cannot verify %url% against %url%.sha256; refusing the unverified download 1>&2 +echo impeccable: cannot verify %url% (certutil could not hash it); refusing the unverified download 1>&2 exit /b 127 +:read_expected +rem Sets expected (and, on ARM64, expected_x64: Windows on ARM runs x64 +rem binaries) from engine-checksums.txt. Only called off the stamped path: +rem hooks run this launcher on every edit. +call :manifest_digest "%asset%" expected +set "expected_x64=" +if "%arch%"=="arm64" call :manifest_digest impeccable-windows-x64.exe expected_x64 +exit /b 0 + +:manifest_digest +rem Sets the variable named %2 to the digest the first engine-checksums.txt +rem line for this version and asset %1 records, empty when there is none. +set "%~2=" +if not exist "%manifest%" exit /b 0 +for /f "usebackq tokens=1-3" %%a in ("%manifest%") do if "%%a"=="%version%" if /I "%%b"=="%~1" if not defined %~2 set "%~2=%%c" +exit /b 0 + +:sha256 +rem Sets actual to the sha256 of %~1, empty when certutil fails. %~2 is the +rem scratch file for its output. Check certutil's status before parsing: its +rem error text on stdout is not a digest. +set "actual=" +certutil -hashfile "%~1" SHA256 >"%~2" 2>nul +if errorlevel 1 goto sha256_done +for /f "usebackq skip=1 delims=" %%h in ("%~2") do if not defined actual set "actual=%%h" +if not defined actual goto sha256_done +set "actual=%actual: =%" +:sha256_done +del "%~2" >nul 2>nul +exit /b 0 + :check_download set "download_file=%~1" if not defined download_file set "download_file=%part%" @@ -177,6 +211,7 @@ if errorlevel 1 goto place_failed call :discard_staging call :check_download "%cached%" if errorlevel 1 exit /b 127 +(>"%cached%.verified" echo %actual%) 2>nul set "run=%cached%" goto run @@ -208,6 +243,10 @@ if not errorlevel 1 set "probe_ok=1" del "%probe_tmp%" >nul 2>nul exit /b 0 +:no_checksum +echo impeccable: no checksum for engine %version% (%asset%) in "%manifest%"; refusing the unverified download 1>&2 +exit /b 127 + :cache_directory_failed echo impeccable: engine %version% is not installed; cannot create cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2 goto setup_failed diff --git a/.cursor/skills/impeccable/scripts/live-browser-ignores.js b/.cursor/skills/impeccable/scripts/live-browser-ignores.js index 1c8514c..1a2912e 100644 --- a/.cursor/skills/impeccable/scripts/live-browser-ignores.js +++ b/.cursor/skills/impeccable/scripts/live-browser-ignores.js @@ -63,9 +63,13 @@ const c = glob[i]; if (c === '*') { if (glob[i + 1] === '*') { - re += '.*'; i += 2; - if (glob[i] === '/') i += 1; + if (glob[i] === '/') { + re += '(?:.*/)?'; + i += 1; + } else { + re += '.*'; + } } else { re += '[^/]*'; i += 1; diff --git a/.cursor/skills/impeccable/scripts/live-browser-session.js b/.cursor/skills/impeccable/scripts/live-browser-session.js index 388d2c2..6871770 100644 --- a/.cursor/skills/impeccable/scripts/live-browser-session.js +++ b/.cursor/skills/impeccable/scripts/live-browser-session.js @@ -42,7 +42,10 @@ function createLiveBrowserSessionState({ prefix, storage, idFactory }) { if (!prefix) throw new Error('prefix required'); - const store = storage || root.localStorage; + let store = storage; + if (!store) { + try { store = root.localStorage; } catch { store = null; /* storage denied */ } + } const makeId = idFactory || function () { return randomId8(); }; const sessionKey = prefix + '-session'; const handledKey = sessionKey + '-handled'; diff --git a/.cursor/skills/impeccable/scripts/live-browser.js b/.cursor/skills/impeccable/scripts/live-browser.js index 75abdf0..53a2d95 100644 --- a/.cursor/skills/impeccable/scripts/live-browser.js +++ b/.cursor/skills/impeccable/scripts/live-browser.js @@ -13,13 +13,17 @@ 'use strict'; if (typeof window === 'undefined') return; + // Take the helper token out of the global before anything else, including + // on the double-init return below: each served copy re-prepends it. + const TOKEN = window.__IMPECCABLE_TOKEN__; + try { delete window.__IMPECCABLE_TOKEN__; } catch { /* non-configurable */ } + // Guard against double-init. Bun's HTML loader may process the