chore: 将 Impeccable 更新到 4.8.0

This commit is contained in:
2026-10-29 17:42:50 +08:00
parent a53ada10de
commit 9f44082c8a
22 changed files with 313 additions and 113 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
{ {
"version": 1, "version": 1,
"hooks": { "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 "timeout": 5
} }
] ]
+2 -2
View File
@@ -1,7 +1,7 @@
--- ---
name: impeccable 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." 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 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. 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. 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 ## How to design
@@ -42,5 +42,5 @@ Would a fluent Android user trust this app, or trip on off-spec components? The
## Verifying the build ## 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 > <path>` (pick a device with `adb -s <serial>` 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. - **Screenshots come from the emulator or a connected device, never a browser.** Build and install, then capture with `adb exec-out screencap -p > <path>` (pick a device with `adb -s <serial>` 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 <serial>` 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 <serial>` goes on these commands too.
- **Emulators give breadth; gestures, refresh rates, and performance need hardware.** Say which one produced the evidence. - **Emulators give breadth; gestures, refresh rates, and performance need hardware.** Say which one produced the evidence.
+2 -2
View File
@@ -11,7 +11,7 @@ Run comprehensive checks across 5 dimensions. Score each dimension 0-4 using the
### 1. Accessibility (A11y) ### 1. Accessibility (A11y)
**Check for**: **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 - **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 - **Missing ARIA**: Interactive elements without proper roles, labels, or states
- **Keyboard navigation**: Missing focus indicators, illogical tab order, keyboard traps - **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**: **Check for**:
- **Fixed widths**: Hard-coded widths that break on mobile - **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 - **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 - **Horizontal scroll**: Content overflow on narrow viewports
- **Text scaling**: Layouts that break when text size increases - **Text scaling**: Layouts that break when text size increases
@@ -1,6 +1,6 @@
# Craft floor # 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 ## Verify
@@ -41,7 +41,7 @@ Expect to say no to good ideas to make room for great execution.
Systematically remove complexity across these dimensions: Systematically remove complexity across these dimensions:
### Information Architecture ### 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) - **Progressive disclosure**: Hide complexity behind clear entry points (accordions, modals, step-through flows)
- **Combine related actions**: Merge similar buttons, consolidate forms, group related content - **Combine related actions**: Merge similar buttons, consolidate forms, group related content
- **Clear hierarchy**: ONE primary action, few secondary actions, everything else tertiary or hidden - **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 - **Clear next action**: ONE obvious next action, not five competing ones
### Content Simplification ### 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" - **Active voice**: "Save changes" not "Changes will be saved"
- **Remove jargon**: Plain language always wins - **Remove jargon**: Plain language always wins
- **Scannable structure**: Short paragraphs, bullet points, clear headings - **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 - **Remove redundant copy**: No headers restating intros, no repeated explanations, say it once
### Code Simplification ### Code Simplification
@@ -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: 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. - **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. - **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.
@@ -17,10 +17,10 @@ colors:
typography: typography:
display: display:
fontFamily: "Cormorant Garamond, Georgia, serif" fontFamily: "Cormorant Garamond, Georgia, serif"
fontSize: "clamp(2.5rem, 7vw, 4.5rem)" fontSize: "4.5rem"
fontWeight: 300 fontWeight: 300
lineHeight: 1 lineHeight: 1
letterSpacing: "normal" letterSpacing: "0em"
body: body:
# ... # ...
rounded: rounded:
@@ -325,7 +325,7 @@ If the project has **no component library yet** (bare landing page, new project)
#### Tonal ramps #### 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 #### Narrative mapping
@@ -109,6 +109,25 @@ border-inline-end: 1px solid; /* Not border-right */
[dir="rtl"] .arrow { transform: scaleX(-1); } [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**: **Character set support**:
- Use UTF-8 encoding everywhere - Use UTF-8 encoding everywhere
- Test with Chinese/Japanese/Korean (CJK) characters - Test with Chinese/Japanese/Korean (CJK) characters
+5 -4
View File
@@ -2,9 +2,9 @@
Manage the **design detector hook** for the current project. 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. 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. 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. 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. - 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. - 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. - 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 ## Failure modes
+3 -3
View File
@@ -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. **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). - `bolder`: amplify a different dimension per variant (scale / saturation / structural change).
- `quieter`: pull back a different dimension (color / ornament / spacing). - `quieter`: pull back a different dimension (color / ornament / spacing).
- `distill`: remove a different class of excess (visual noise / redundant content / nested structure). - `distill`: remove a different class of excess (visual noise / redundant content / nested structure).
- `polish`: a different refinement axis (rhythm / hierarchy / micro-details). - `polish`: a different refinement axis (rhythm / hierarchy / micro-details).
- `typeset`: different pairing AND different scale ratio each. - `typeset`: departure varies the pairing AND the scale ratio each; default keeps the faces and varies scale ratio, case, and weight each.
- `colorize`: different hue family each; vary chroma and contrast strategy. - `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. - `layout`: different structural arrangement, not spacing tweaks.
- `adapt`: different target context per variant (mobile-first / tablet / desktop / print or low-data). - `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). - `animate`: different motion vocabulary (cascade stagger / clip wipe / scale-and-focus / morph / parallax).
File diff suppressed because one or more lines are too long
@@ -38,7 +38,6 @@ Create systematic improvement plan:
src="hero.webp" src="hero.webp"
srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w" srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1200.webp 1200w"
sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"
loading="lazy"
alt="Hero image" alt="Hero image"
/> />
``` ```
@@ -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. 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. 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.
+1 -1
View File
@@ -1 +1 @@
0.1.16 0.1.18
@@ -4,7 +4,7 @@
"argumentHint": "[feature description]" "argumentHint": "[feature description]"
}, },
"init": { "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": "" "argumentHint": ""
}, },
"document": { "document": {
@@ -88,7 +88,7 @@
"argumentHint": "[target]" "argumentHint": "[target]"
}, },
"shape": { "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]" "argumentHint": "[feature to shape]"
}, },
"typeset": { "typeset": {
@@ -0,0 +1,9 @@
# Engine binary digests for the pinned ENGINE_VERSION: <engine-version> <asset> <sha256>.
# 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
+69 -32
View File
@@ -8,7 +8,10 @@
# named `impeccable`, and exec'ing it would fail every verb with # named `impeccable`, and exec'ing it would fail every verb with
# "Unknown command". Trusted candidates (IMPECCABLE_BIN, the sibling binary, # "Unknown command". Trusted candidates (IMPECCABLE_BIN, the sibling binary,
# the version-pinned cache) are exec'd without a probe: hooks run them on # 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 <binary>.verified stamp records that
# a cached binary passed, so only the first run hashes it.
set -eu set -eu
# True when the candidate answers the engine handshake (prints # 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 # then skips its own probes and refuses to download, so probing stays cheap
# and can never loop. # and can never loop.
probe_ok() { 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 ;; impeccable-engine*) return 0 ;;
esac esac
return 1 return 1
} }
probing=${IMPECCABLE_LAUNCHER_PROBE:-} probing=${IMPECCABLE_LAUNCHER_PROBE:-}
# Prints the digest engine-checksums.txt records for engine version $1 and
# asset $2 (lines are "<version> <asset> <sha256>"), 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) dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
manifest="$dir/engine-checksums.txt"
# What the binary needs to know about its home: the skill directory (for # 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 # 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") [ -f "$dir/VERSION" ] && version=$(tr -d '[:space:]' < "$dir/VERSION")
cache_root="${IMPECCABLE_HOME:-${HOME:-/nonexistent}/.impeccable}" cache_root="${IMPECCABLE_HOME:-${HOME:-/nonexistent}/.impeccable}"
cached="$cache_root/bin/$version/impeccable$exe" cached="$cache_root/bin/$version/impeccable$exe"
asset="impeccable-$os-$arch"
[ "$os" = windows ] && asset="$asset.exe"
if [ -n "$version" ] && [ -x "$cached" ]; then if [ -n "$version" ] && [ -x "$cached" ]; then
if [ -f "$cached.verified" ]; then
exec "$cached" "$@" 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 fi
if [ -z "$probing" ] && command -v impeccable >/dev/null 2>&1 && probe_ok impeccable; then if [ -z "$probing" ] && command -v impeccable >/dev/null 2>&1 && probe_ok impeccable; then
exec impeccable "$@" exec impeccable "$@"
@@ -104,12 +155,11 @@ fetch_url() {
check_download() { check_download() {
download_file=${1:-$tmp} download_file=${1:-$tmp}
if [ ! -f "$download_file" ]; then 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 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 exit 127
fi fi
if [ ! -s "$download_file" ]; then 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 echo "impeccable: downloaded file is empty: $url; refusing the unverified download" >&2
exit 127 exit 127
fi fi
@@ -120,13 +170,17 @@ if [ -n "$probing" ]; then
fi fi
if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then
base="${IMPECCABLE_DOWNLOAD_BASE:-https://github.com/pbakaus/impeccable/releases/download}" 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" 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.$$" tmp="$cache_root/bin/$version/.impeccable.part.$$"
# An interrupted download (Ctrl-C, a hook timeout) would otherwise leave the # An interrupted download (Ctrl-C, a hook timeout) would otherwise leave the
# PID-named staging file behind for good. The handlers must exit explicitly. # 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 129' HUP
trap 'cleanup; exit 130' INT trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM trap 'cleanup; exit 143' TERM
@@ -143,40 +197,22 @@ if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then
exit 127 exit 127
fi fi
fetched=0 fetched=0
if fetch_url "$url"; then if [ -n "$expected" ] && fetch_url "$url"; then
fetched=1 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. # Windows on ARM runs x64 binaries; fall back when no arm64 asset exists.
url="$base/engine-v$version/impeccable-windows-x64.exe" url="$base/engine-v$version/impeccable-windows-x64.exe"
expected=$expected_x64
fetch_url "$url" && fetched=1 fetch_url "$url" && fetched=1
fi fi
if [ "$fetched" = 1 ]; then if [ "$fetched" = 1 ]; then
check_download check_download
# Fail closed: a freshly downloaded binary runs only after verifying # No sha256 tool refuses the download too.
# against its .sha256 sidecar. A sidecar that cannot be fetched, or a hash_file "$tmp"
# 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
check_download check_download
expected="" if [ -z "$actual" ]; then
[ "$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
rm -f "$tmp" 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 exit 127
fi fi
if [ "$actual" != "$expected" ]; then if [ "$actual" != "$expected" ]; then
@@ -199,6 +235,7 @@ if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then
exit 127 exit 127
fi fi
check_download "$cached" check_download "$cached"
{ echo "$actual" > "$cached.verified"; } 2>/dev/null || :
exec "$cached" "$@" exec "$cached" "$@"
fi fi
rm -f "$tmp" 2>/dev/null rm -f "$tmp" 2>/dev/null
@@ -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 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 whose bin is also named impeccable, is never exec'd. IMPECCABLE_BIN,
rem the sibling binary, and the version-pinned cache stay trusted. rem the sibling binary, and the version-pinned cache stay trusted.
rem - Downloads are verified against the .sha256 sidecar via certutil and rem - Downloads and the version-pinned cache are verified via certutil
rem fail closed: a missing sidecar or hash tool refuses the download. On rem against engine-checksums.txt next to this file, and fail closed; a
rem ARM64 the arm64 asset is tried first and the x64 asset is the rem .verified stamp lets later runs skip hashing the cache. On ARM64 the
rem fallback (Windows on ARM runs x64 binaries). 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_SKILL_DIR set "IMPECCABLE_SKILL_DIR=%~dp0.."
if not defined IMPECCABLE_SELF set "IMPECCABLE_SELF=%~f0" if not defined IMPECCABLE_SELF set "IMPECCABLE_SELF=%~f0"
set "arch=x64" set "arch=x64"
@@ -47,8 +48,22 @@ set "version="
if exist "%~dp0VERSION" set /p version=<"%~dp0VERSION" if exist "%~dp0VERSION" set /p version=<"%~dp0VERSION"
if not defined IMPECCABLE_HOME set "IMPECCABLE_HOME=%USERPROFILE%\.impeccable" if not defined IMPECCABLE_HOME set "IMPECCABLE_HOME=%USERPROFILE%\.impeccable"
set "cached=%IMPECCABLE_HOME%\bin\%version%\impeccable.exe" 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 defined version goto no_cache
if not exist "%cached%" 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%" set "run=%cached%"
goto run goto run
:no_cache :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. rem another launcher's probe: fail fast and quiet instead.
if defined IMPECCABLE_LAUNCHER_PROBE exit /b 127 if defined IMPECCABLE_LAUNCHER_PROBE exit /b 127
if not defined version goto fail 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 where curl.exe >nul 2>nul
if errorlevel 1 goto curl_missing if errorlevel 1 goto curl_missing
if not defined IMPECCABLE_DOWNLOAD_BASE set "IMPECCABLE_DOWNLOAD_BASE=https://github.com/pbakaus/impeccable/releases/download" 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 mkdir "%staging%" >nul 2>nul
if errorlevel 1 goto claim_staging if errorlevel 1 goto claim_staging
set "part=%staging%\impeccable.exe" set "part=%staging%\impeccable.exe"
set "sidecar=%staging%\impeccable.sha256"
rem Redirection failures do not reliably update ERRORLEVEL in cmd.exe; rem Redirection failures do not reliably update ERRORLEVEL in cmd.exe;
rem branch on the command's failure directly. rem branch on the command's failure directly.
(type nul >"%part%") 2>nul || goto staging_write_failed (type nul >"%part%") 2>nul || goto staging_write_failed
set "asset=impeccable-windows-%arch%.exe"
set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%" 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 curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul
if not errorlevel 1 goto verify 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 "asset=impeccable-windows-x64.exe"
set "expected=%expected_x64%"
set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%" set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul curl.exe -fsSL -o "%part%" "%url%" >nul 2>nul
if errorlevel 1 goto download_failed if errorlevel 1 goto download_failed
@@ -111,28 +129,13 @@ if errorlevel 1 goto download_failed
call :check_download call :check_download
if errorlevel 1 exit /b 127 if errorlevel 1 exit /b 127
rem Mirrors the sh launcher and fails closed: a freshly downloaded binary 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 runs only after its hash matches the digest read from engine-checksums.txt.
rem cannot be fetched, or an empty certutil result, refuses the download rem An empty certutil result refuses the download instead of running an
rem instead of running an unverified binary. rem unverified binary.
curl.exe -fsSL -o "%sidecar%" "%url%.sha256" >nul 2>nul call :sha256 "%part%" "%staging%\hash.txt"
if errorlevel 1 goto verify_refuse
set "expected="
set /p expected=<"%sidecar%"
for /f "tokens=1" %%h in ("%expected%") do set "expected=%%h"
call :check_download call :check_download
if errorlevel 1 exit /b 127 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 if not defined actual goto verify_refuse
set "actual=%actual: =%"
if /I "%actual%"=="%expected%" goto place if /I "%actual%"=="%expected%" goto place
call :discard_staging call :discard_staging
echo impeccable: checksum mismatch downloading %url% 1>&2 echo impeccable: checksum mismatch downloading %url% 1>&2
@@ -142,9 +145,40 @@ exit /b 127
call :check_download call :check_download
if errorlevel 1 exit /b 127 if errorlevel 1 exit /b 127
call :discard_staging 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 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 :check_download
set "download_file=%~1" set "download_file=%~1"
if not defined download_file set "download_file=%part%" if not defined download_file set "download_file=%part%"
@@ -177,6 +211,7 @@ if errorlevel 1 goto place_failed
call :discard_staging call :discard_staging
call :check_download "%cached%" call :check_download "%cached%"
if errorlevel 1 exit /b 127 if errorlevel 1 exit /b 127
(>"%cached%.verified" echo %actual%) 2>nul
set "run=%cached%" set "run=%cached%"
goto run goto run
@@ -208,6 +243,10 @@ if not errorlevel 1 set "probe_ok=1"
del "%probe_tmp%" >nul 2>nul del "%probe_tmp%" >nul 2>nul
exit /b 0 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 :cache_directory_failed
echo impeccable: engine %version% is not installed; cannot create cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2 echo impeccable: engine %version% is not installed; cannot create cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2
goto setup_failed goto setup_failed
@@ -63,9 +63,13 @@
const c = glob[i]; const c = glob[i];
if (c === '*') { if (c === '*') {
if (glob[i + 1] === '*') { if (glob[i + 1] === '*') {
re += '.*';
i += 2; i += 2;
if (glob[i] === '/') i += 1; if (glob[i] === '/') {
re += '(?:.*/)?';
i += 1;
} else {
re += '.*';
}
} else { } else {
re += '[^/]*'; re += '[^/]*';
i += 1; i += 1;
@@ -42,7 +42,10 @@
function createLiveBrowserSessionState({ prefix, storage, idFactory }) { function createLiveBrowserSessionState({ prefix, storage, idFactory }) {
if (!prefix) throw new Error('prefix required'); 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 makeId = idFactory || function () { return randomId8(); };
const sessionKey = prefix + '-session'; const sessionKey = prefix + '-session';
const handledKey = sessionKey + '-handled'; const handledKey = sessionKey + '-handled';
+109 -21
View File
@@ -13,13 +13,17 @@
'use strict'; 'use strict';
if (typeof window === 'undefined') return; 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 <script> tag // Guard against double-init. Bun's HTML loader may process the <script> tag
// and create a bundled copy alongside the external load, or HMR may re-execute. // and create a bundled copy alongside the external load, or HMR may re-execute.
// Check BEFORE reading token/port to catch all cases. // Check BEFORE reading port to catch all cases.
if (window.__IMPECCABLE_LIVE_INIT__) return; if (window.__IMPECCABLE_LIVE_INIT__) return;
window.__IMPECCABLE_LIVE_INIT__ = true; window.__IMPECCABLE_LIVE_INIT__ = true;
const TOKEN = window.__IMPECCABLE_TOKEN__;
const PORT = window.__IMPECCABLE_PORT__; const PORT = window.__IMPECCABLE_PORT__;
const APP_ROOT = window.__IMPECCABLE_APP_ROOT__ || null; const APP_ROOT = window.__IMPECCABLE_APP_ROOT__ || null;
if (!TOKEN || !PORT) { if (!TOKEN || !PORT) {
@@ -63,11 +67,13 @@
const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000; const MANUAL_APPLY_STATE_TTL_MS = 15 * 60 * 1000;
// No idFactory: the session helper's default works on plain-HTTP origins, // No idFactory: the session helper's default works on plain-HTTP origins,
// where the secure-context-only randomUUID does not exist (issue #1055). // where the secure-context-only randomUUID does not exist (issue #1055).
let liveStorage = null;
try { liveStorage = window.localStorage; } catch { /* storage denied */ }
let sessionState = null; let sessionState = null;
try { try {
sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({ sessionState = window.__IMPECCABLE_LIVE_SESSION__?.createLiveBrowserSessionState({
prefix: PREFIX, prefix: PREFIX,
storage: localStorage, storage: liveStorage,
}); });
} catch (err) { } catch (err) {
console.error('[impeccable] Live mode could not create its session state.', err); console.error('[impeccable] Live mode could not create its session state.', err);
@@ -2512,7 +2518,7 @@
row.appendChild(buildConfigureTrailingCluster([action, count], voiceBtn, go)); row.appendChild(buildConfigureTrailingCluster([action, count], voiceBtn, go));
syncConfigureInputChrome(); syncConfigureInputChrome();
if (!controlsLocked) setTimeout(() => input.focus(), 60); if (!controlsLocked && !touchPrimary()) setTimeout(() => input.focus(), 60);
return row; return row;
} }
@@ -2616,7 +2622,7 @@
row.appendChild(buildConfigureTrailingCluster([count], voiceBtn, create)); row.appendChild(buildConfigureTrailingCluster([count], voiceBtn, create));
syncInsertCreateButton(create, input); syncInsertCreateButton(create, input);
syncConfigureInputChrome(); syncConfigureInputChrome();
if (!controlsLocked) setTimeout(() => input.focus(), 60); if (!controlsLocked && !touchPrimary()) setTimeout(() => input.focus(), 60);
return row; return row;
} }
@@ -3124,6 +3130,11 @@
let paramsPanelBody = null; // grid holding the knob cells let paramsPanelBody = null; // grid holding the knob cells
let paramsCurrentValues = {}; // {paramId: value} - mirror of the visible variant's live values let paramsCurrentValues = {}; // {paramId: value} - mirror of the visible variant's live values
let tuneOpen = false; // whether the Tune popover is open right now let tuneOpen = false; // whether the Tune popover is open right now
// Tune values a saved session carried across a reload: {sessionId, variant,
// values}. Cycling refreshes of that session and variant restore them (a
// resume refreshes more than once); a refresh for any other variant, or a
// knob edit, drops them.
let restoredParamValues = null;
// Theme-aware Tune popover. Appears as a drawer that slides out from the // Theme-aware Tune popover. Appears as a drawer that slides out from the
// contextual bar's bar-facing edge (below if the bar sits below the // contextual bar's bar-facing edge (below if the bar sits below the
@@ -3260,6 +3271,54 @@
} }
} }
function rememberSavedParamValues(saved) {
const values = saved.paramValues;
if (!values || typeof values !== 'object' || Array.isArray(values)) return;
if (Object.keys(values).length === 0) return;
const variant = Number(saved.visible != null ? saved.visible : saved.visibleVariant) || 0;
restoredParamValues = { sessionId: saved.id || null, variant, values: { ...values } };
}
function restoredParamValuesForVisibleVariant() {
const restored = restoredParamValues;
if (!restored) return null;
if (restored.sessionId === currentSessionId && restored.variant === visibleVariant) return restored.values;
restoredParamValues = null;
return null;
}
// The local save is what a reload resumes from, so an edit is saved there
// as well as checkpointed to the server.
function noteParamEdited() {
restoredParamValues = null;
saveSession();
queueCheckpoint('param_changed');
}
// A saved value comes from storage the page does not own, and the variant
// may have been regenerated since, so it must still fit the param it names.
function isValidSavedParamValue(p, value) {
if (p.kind === 'range') {
if (typeof value !== 'number' || !Number.isFinite(value)) return false;
const min = p.min != null ? Number(p.min) : 0;
const max = p.max != null ? Number(p.max) : 1;
return value >= min && value <= max;
}
if (p.kind === 'toggle') return typeof value === 'boolean';
if (p.kind === 'steps') {
return (p.options || []).some(o => (o && typeof o === 'object' ? o.value : o) === value);
}
return false;
}
function applySavedParamValues(variantEl, params, saved) {
for (const p of params) {
if (!Object.hasOwn(saved, p.id) || !isValidSavedParamValue(p, saved[p.id])) continue;
paramsCurrentValues[p.id] = saved[p.id];
applyParamValue(variantEl, p, saved[p.id]);
}
}
function formatRangeValue(input) { function formatRangeValue(input) {
const max = parseFloat(input.max), min = parseFloat(input.min); const max = parseFloat(input.max), min = parseFloat(input.min);
const v = parseFloat(input.value); const v = parseFloat(input.value);
@@ -3271,6 +3330,14 @@
const P = paramsPanelPalette || barPaletteForTheme(detectPageTheme()); const P = paramsPanelPalette || barPaletteForTheme(detectPageTheme());
paramsPanelBody.innerHTML = ''; paramsPanelBody.innerHTML = '';
for (const p of params) { for (const p of params) {
// A knob the panel shows must be in the live values and on the variant,
// or accept drops it and the preview ignores it. Seed only missing keys
// so a reopen keeps edits.
if (!Object.hasOwn(paramsCurrentValues, p.id)) {
paramsCurrentValues[p.id] = p.default;
applyParamValue(variantEl, p, p.default);
}
const value = paramsCurrentValues[p.id];
const row = el('div', { display: 'flex', flexDirection: 'column', gap: '6px' }); const row = el('div', { display: 'flex', flexDirection: 'column', gap: '6px' });
const labelRow = el('div', { const labelRow = el('div', {
display: 'flex', justifyContent: 'space-between', display: 'flex', justifyContent: 'space-between',
@@ -3295,7 +3362,7 @@
input.min = String(p.min != null ? p.min : 0); input.min = String(p.min != null ? p.min : 0);
input.max = String(p.max != null ? p.max : 1); input.max = String(p.max != null ? p.max : 1);
input.step = String(p.step != null ? p.step : 0.05); input.step = String(p.step != null ? p.step : 0.05);
input.value = String(p.default); input.value = String(value);
Object.assign(input.style, { Object.assign(input.style, {
width: '100%', accentColor: C.brand, cursor: 'pointer', width: '100%', accentColor: C.brand, cursor: 'pointer',
}); });
@@ -3306,11 +3373,11 @@
paramsCurrentValues[p.id] = v; paramsCurrentValues[p.id] = v;
readout.textContent = formatRangeValue(input); readout.textContent = formatRangeValue(input);
applyParamValue(variantEl, p, v); applyParamValue(variantEl, p, v);
queueCheckpoint('param_changed'); noteParamEdited();
}); });
row.appendChild(input); row.appendChild(input);
} else if (p.kind === 'toggle') { } else if (p.kind === 'toggle') {
const initial = !!p.default; const initial = !!value;
readout.textContent = initial ? 'On' : 'Off'; readout.textContent = initial ? 'On' : 'Off';
const track = el('button', { const track = el('button', {
position: 'relative', width: '36px', height: '20px', position: 'relative', width: '36px', height: '20px',
@@ -3337,15 +3404,15 @@
knob.style.left = next ? '18px' : '2px'; knob.style.left = next ? '18px' : '2px';
readout.textContent = next ? 'On' : 'Off'; readout.textContent = next ? 'On' : 'Off';
applyParamValue(variantEl, p, next); applyParamValue(variantEl, p, next);
queueCheckpoint('param_changed'); noteParamEdited();
}); });
row.appendChild(track); row.appendChild(track);
} else if (p.kind === 'steps') { } else if (p.kind === 'steps') {
const opts = (p.options || []).map(o => const opts = (p.options || []).map(o =>
typeof o === 'string' ? { value: o, label: o } : o typeof o === 'string' ? { value: o, label: o } : o
); );
const activeOpt = opts.find(o => o.value === p.default) || opts[0]; const activeOpt = opts.find(o => o.value === value) || opts[0];
readout.textContent = activeOpt ? activeOpt.label : String(p.default); readout.textContent = activeOpt ? activeOpt.label : String(value);
const segRow = el('div', { const segRow = el('div', {
display: 'grid', display: 'grid',
gridTemplateColumns: 'repeat(' + opts.length + ', 1fr)', gridTemplateColumns: 'repeat(' + opts.length + ', 1fr)',
@@ -3354,7 +3421,7 @@
}); });
const segBtns = []; const segBtns = [];
opts.forEach(o => { opts.forEach(o => {
const active = o.value === p.default; const active = o.value === value;
const b = el('button', { const b = el('button', {
padding: '5px 4px', border: 'none', borderRadius: '3px', padding: '5px 4px', border: 'none', borderRadius: '3px',
background: active ? C.brand : 'transparent', background: active ? C.brand : 'transparent',
@@ -3374,7 +3441,7 @@
btn.style.color = on ? C.ink : P.text; btn.style.color = on ? C.ink : P.text;
}); });
applyParamValue(variantEl, p, o.value); applyParamValue(variantEl, p, o.value);
queueCheckpoint('param_changed'); noteParamEdited();
}); });
segRow.appendChild(b); segRow.appendChild(b);
segBtns.push({ btn: b, val: o.value }); segBtns.push({ btn: b, val: o.value });
@@ -4923,6 +4990,9 @@
} }
const variantEl = getVisibleVariantEl(); const variantEl = getVisibleVariantEl();
const params = parseVariantParams(variantEl); const params = parseVariantParams(variantEl);
// Values saved before a reload come back for the variant they were saved
// on; a switch to any other variant starts from its defaults.
const restored = restoredParamValuesForVisibleVariant();
if (!variantEl || params.length === 0) { if (!variantEl || params.length === 0) {
paramsCurrentValues = {}; paramsCurrentValues = {};
tuneOpen = false; tuneOpen = false;
@@ -4931,6 +5001,7 @@
return; return;
} }
applyParamDefaults(variantEl, params); applyParamDefaults(variantEl, params);
if (restored) applySavedParamValues(variantEl, params, restored);
buildParamsPanel(variantEl, params); buildParamsPanel(variantEl, params);
if (tuneOpen) { if (tuneOpen) {
// If already visible (variant cycled while open), refresh in place // If already visible (variant cycled while open), refresh in place
@@ -4988,8 +5059,8 @@
const variantEl = getVisibleVariantEl(); const variantEl = getVisibleVariantEl();
const params = parseVariantParams(variantEl); const params = parseVariantParams(variantEl);
if (!variantEl || params.length === 0) return; if (!variantEl || params.length === 0) return;
// Build fresh to ensure the current variant's controls are shown. // Rebuild the controls from the current values. Defaults are applied
applyParamDefaults(variantEl, params); // when the variant is initialized, not when its Tune panel is reopened.
buildParamsPanel(variantEl, params); buildParamsPanel(variantEl, params);
tuneOpen = true; tuneOpen = true;
showParamsPanel(); showParamsPanel();
@@ -9517,6 +9588,7 @@ void main() {
if (saved.previewMode) currentPreviewMode = saved.previewMode; if (saved.previewMode) currentPreviewMode = saved.previewMode;
if (saved.paramValues && typeof saved.paramValues === 'object') { if (saved.paramValues && typeof saved.paramValues === 'object') {
paramsCurrentValues = { ...saved.paramValues }; paramsCurrentValues = { ...saved.paramValues };
rememberSavedParamValues(saved);
} }
if (saved.parameterState) parameterGenerationState = saved.parameterState; if (saved.parameterState) parameterGenerationState = saved.parameterState;
sessionOrigin = saved.origin === 'agent' ? 'agent' : null; sessionOrigin = saved.origin === 'agent' ? 'agent' : null;
@@ -10148,10 +10220,9 @@ void main() {
hideShaderOverlay(); hideShaderOverlay();
if (isInsert) finalizeInsertSession(); if (isInsert) finalizeInsertSession();
disableInlineEdit(); disableInlineEdit();
// Build the params panel for the restored visible variant. Previously // Build the params panel for the restored visible variant, with any
// this was missed on page-reload resume: showVariantInDOM above fires // Tune values saved before the reload (showVariantInDOM above may
// refreshParamsPanel, but state was still IDLE at that moment so it // already have refreshed; a repeat for the same variant keeps them).
// hid. Now that state is CYCLING, re-fire.
refreshParamsPanel(); refreshParamsPanel();
} }
saveSession(); saveSession();
@@ -10592,6 +10663,11 @@ void main() {
return true; return true;
} }
// Programmatic focus raises the soft keyboard on touch devices (#1067).
function touchPrimary() {
return !!window.matchMedia?.('(pointer: coarse)').matches;
}
function shouldSteerAutoFocus() { function shouldSteerAutoFocus() {
return shouldFocusSteerChat() return shouldFocusSteerChat()
&& !steerFocusSuspended && !steerFocusSuspended
@@ -10800,6 +10876,7 @@ void main() {
function syncPageChatFocus(reason) { function syncPageChatFocus(reason) {
steerFocusLog('syncPageChatFocus', { reason }); steerFocusLog('syncPageChatFocus', { reason });
if (touchPrimary()) return;
if (state === 'CONFIGURING') focusConfigureInput(reason); if (state === 'CONFIGURING') focusConfigureInput(reason);
else if (shouldSteerAutoFocus()) focusSteerChat(reason); else if (shouldSteerAutoFocus()) focusSteerChat(reason);
} }
@@ -10987,7 +11064,8 @@ void main() {
file: opts?.file || '', file: opts?.file || '',
}); });
} }
if (keepExpanded) focusPageChatInput('steer-error-restore'); if (keepExpanded && touchPrimary()) preparePageChatInputForTyping();
else if (keepExpanded) focusPageChatInput('steer-error-restore');
else syncPageChatFocus('steer-unlock'); else syncPageChatFocus('steer-unlock');
} }
@@ -13454,7 +13532,9 @@ void main() {
// Code spans // Code spans
s = s.replace(/`([^`]+)`/g, (_, code) => `<code>${code}</code>`); s = s.replace(/`([^`]+)`/g, (_, code) => `<code>${code}</code>`);
// Links [text](url) // Links [text](url)
s = s.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, t, u) => `<a href="${u}" target="_blank" rel="noopener noreferrer">${t}</a>`); s = s.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, t, u) => (
isSafeHref(u) ? `<a href="${u}" target="_blank" rel="noopener noreferrer">${t}</a>` : t
));
// Bold // Bold
s = s.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>'); s = s.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
// Italic (only single *…*, skip if inside bold already handled) // Italic (only single *…*, skip if inside bold already handled)
@@ -13462,6 +13542,14 @@ void main() {
return s; return s;
} }
function isSafeHref(url) {
// Browsers drop ASCII whitespace and C0 controls inside a scheme, so
// "java\tscript:" still runs; strip them before reading the scheme.
const probe = String(url).replace(/[\u0000-\u0020\u007f]/g, '');
const scheme = probe.match(/^([a-z][a-z0-9+.-]*):/i);
return !scheme || ['http', 'https', 'mailto'].includes(scheme[1].toLowerCase());
}
function highlightBold(text) { function highlightBold(text) {
return inlineMd(text); return inlineMd(text);
} }