Skip to content

The design language that makes your AI harness better at design.

JavaScript

Sync generated provider output

github-actions[bot]e4ab5e24bdf5
diff --git a/.agents/skills/impeccable/reference/hooks.md b/.agents/skills/impeccable/reference/hooks.md
index e437ca296..f7ebb8c2e 100644
--- a/.agents/skills/impeccable/reference/hooks.md
+++ b/.agents/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .agents/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .agents/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .agents/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.agents/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.agents/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.agents/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.agents/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.agents/skills/impeccable/scripts/hook-admin.mjs b/.agents/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.agents/skills/impeccable/scripts/hook-admin.mjs
+++ b/.agents/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.agents/skills/impeccable/scripts/hook-lib.mjs b/.agents/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.agents/skills/impeccable/scripts/hook-lib.mjs
+++ b/.agents/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.agents/skills/impeccable/scripts/lib/impeccable-config.mjs b/.agents/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.agents/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.agents/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.claude/skills/impeccable/reference/hooks.md b/.claude/skills/impeccable/reference/hooks.md
index 30f756793..07d191c55 100644
--- a/.claude/skills/impeccable/reference/hooks.md
+++ b/.claude/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.claude/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.claude/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.claude/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.claude/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.claude/skills/impeccable/scripts/hook-admin.mjs b/.claude/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.claude/skills/impeccable/scripts/hook-admin.mjs
+++ b/.claude/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.claude/skills/impeccable/scripts/hook-lib.mjs b/.claude/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.claude/skills/impeccable/scripts/hook-lib.mjs
+++ b/.claude/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.claude/skills/impeccable/scripts/lib/impeccable-config.mjs b/.claude/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.claude/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.claude/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.cursor/skills/impeccable/reference/hooks.md b/.cursor/skills/impeccable/reference/hooks.md
index 829dec839..e37579a54 100644
--- a/.cursor/skills/impeccable/reference/hooks.md
+++ b/.cursor/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .cursor/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .cursor/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .cursor/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.cursor/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.cursor/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.cursor/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.cursor/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.cursor/skills/impeccable/scripts/hook-admin.mjs b/.cursor/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.cursor/skills/impeccable/scripts/hook-admin.mjs
+++ b/.cursor/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.cursor/skills/impeccable/scripts/hook-lib.mjs b/.cursor/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.cursor/skills/impeccable/scripts/hook-lib.mjs
+++ b/.cursor/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.cursor/skills/impeccable/scripts/lib/impeccable-config.mjs b/.cursor/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.cursor/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.cursor/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.gemini/skills/impeccable/reference/hooks.md b/.gemini/skills/impeccable/reference/hooks.md
index e7bb58d14..b6c5def93 100644
--- a/.gemini/skills/impeccable/reference/hooks.md
+++ b/.gemini/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .gemini/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .gemini/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .gemini/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.gemini/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.gemini/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.gemini/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.gemini/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.gemini/skills/impeccable/scripts/hook-admin.mjs b/.gemini/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.gemini/skills/impeccable/scripts/hook-admin.mjs
+++ b/.gemini/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.gemini/skills/impeccable/scripts/hook-lib.mjs b/.gemini/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.gemini/skills/impeccable/scripts/hook-lib.mjs
+++ b/.gemini/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.gemini/skills/impeccable/scripts/lib/impeccable-config.mjs b/.gemini/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.gemini/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.gemini/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.github/skills/impeccable/reference/hooks.md b/.github/skills/impeccable/reference/hooks.md
index 7c7413f96..78d747022 100644
--- a/.github/skills/impeccable/reference/hooks.md
+++ b/.github/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .github/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .github/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .github/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.github/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.github/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.github/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.github/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.github/skills/impeccable/scripts/hook-admin.mjs b/.github/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.github/skills/impeccable/scripts/hook-admin.mjs
+++ b/.github/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.github/skills/impeccable/scripts/hook-lib.mjs b/.github/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.github/skills/impeccable/scripts/hook-lib.mjs
+++ b/.github/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.github/skills/impeccable/scripts/lib/impeccable-config.mjs b/.github/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.github/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.github/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.kiro/skills/impeccable/reference/hooks.md b/.kiro/skills/impeccable/reference/hooks.md
index da1084bb9..c5df16fa9 100644
--- a/.kiro/skills/impeccable/reference/hooks.md
+++ b/.kiro/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .kiro/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .kiro/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .kiro/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.kiro/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.kiro/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.kiro/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.kiro/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.kiro/skills/impeccable/scripts/hook-admin.mjs b/.kiro/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.kiro/skills/impeccable/scripts/hook-admin.mjs
+++ b/.kiro/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.kiro/skills/impeccable/scripts/hook-lib.mjs b/.kiro/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.kiro/skills/impeccable/scripts/hook-lib.mjs
+++ b/.kiro/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.kiro/skills/impeccable/scripts/lib/impeccable-config.mjs b/.kiro/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.kiro/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.kiro/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.opencode/skills/impeccable/reference/hooks.md b/.opencode/skills/impeccable/reference/hooks.md
index 901c3a6cc..dc5b737d7 100644
--- a/.opencode/skills/impeccable/reference/hooks.md
+++ b/.opencode/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .opencode/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .opencode/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .opencode/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.opencode/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.opencode/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.opencode/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.opencode/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.opencode/skills/impeccable/scripts/hook-admin.mjs b/.opencode/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.opencode/skills/impeccable/scripts/hook-admin.mjs
+++ b/.opencode/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.opencode/skills/impeccable/scripts/hook-lib.mjs b/.opencode/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.opencode/skills/impeccable/scripts/hook-lib.mjs
+++ b/.opencode/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.opencode/skills/impeccable/scripts/lib/impeccable-config.mjs b/.opencode/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.opencode/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.opencode/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.pi/skills/impeccable/reference/hooks.md b/.pi/skills/impeccable/reference/hooks.md
index 7f2f6ee4a..b9165d149 100644
--- a/.pi/skills/impeccable/reference/hooks.md
+++ b/.pi/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .pi/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .pi/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .pi/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.pi/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.pi/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.pi/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.pi/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.pi/skills/impeccable/scripts/hook-admin.mjs b/.pi/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.pi/skills/impeccable/scripts/hook-admin.mjs
+++ b/.pi/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.pi/skills/impeccable/scripts/hook-lib.mjs b/.pi/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.pi/skills/impeccable/scripts/hook-lib.mjs
+++ b/.pi/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.pi/skills/impeccable/scripts/lib/impeccable-config.mjs b/.pi/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.pi/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.pi/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.qoder/skills/impeccable/reference/hooks.md b/.qoder/skills/impeccable/reference/hooks.md
index 1b154f701..0dad463ff 100644
--- a/.qoder/skills/impeccable/reference/hooks.md
+++ b/.qoder/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .qoder/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .qoder/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .qoder/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.qoder/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.qoder/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.qoder/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.qoder/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.qoder/skills/impeccable/scripts/hook-admin.mjs b/.qoder/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.qoder/skills/impeccable/scripts/hook-admin.mjs
+++ b/.qoder/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.qoder/skills/impeccable/scripts/hook-lib.mjs b/.qoder/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.qoder/skills/impeccable/scripts/hook-lib.mjs
+++ b/.qoder/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.qoder/skills/impeccable/scripts/lib/impeccable-config.mjs b/.qoder/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.qoder/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.qoder/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.rovodev/skills/impeccable/reference/hooks.md b/.rovodev/skills/impeccable/reference/hooks.md
index 00c0b5088..b4e3cc746 100644
--- a/.rovodev/skills/impeccable/reference/hooks.md
+++ b/.rovodev/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .rovodev/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .rovodev/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .rovodev/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.rovodev/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.rovodev/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.rovodev/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.rovodev/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.rovodev/skills/impeccable/scripts/hook-admin.mjs b/.rovodev/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.rovodev/skills/impeccable/scripts/hook-admin.mjs
+++ b/.rovodev/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.rovodev/skills/impeccable/scripts/hook-lib.mjs b/.rovodev/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.rovodev/skills/impeccable/scripts/hook-lib.mjs
+++ b/.rovodev/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.rovodev/skills/impeccable/scripts/lib/impeccable-config.mjs b/.rovodev/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.rovodev/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.rovodev/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.trae-cn/skills/impeccable/reference/hooks.md b/.trae-cn/skills/impeccable/reference/hooks.md
index e0b51cc33..38df84d7c 100644
--- a/.trae-cn/skills/impeccable/reference/hooks.md
+++ b/.trae-cn/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .trae-cn/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .trae-cn/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .trae-cn/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.trae-cn/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.trae-cn/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.trae-cn/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.trae-cn/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.trae-cn/skills/impeccable/scripts/hook-admin.mjs b/.trae-cn/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.trae-cn/skills/impeccable/scripts/hook-admin.mjs
+++ b/.trae-cn/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.trae-cn/skills/impeccable/scripts/hook-lib.mjs b/.trae-cn/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.trae-cn/skills/impeccable/scripts/hook-lib.mjs
+++ b/.trae-cn/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.trae-cn/skills/impeccable/scripts/lib/impeccable-config.mjs b/.trae-cn/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.trae-cn/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.trae-cn/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/.trae/skills/impeccable/reference/hooks.md b/.trae/skills/impeccable/reference/hooks.md
index 05d4f649e..4c6f185ab 100644
--- a/.trae/skills/impeccable/reference/hooks.md
+++ b/.trae/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .trae/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .trae/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .trae/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/.trae/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/.trae/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/.trae/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/.trae/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/.trae/skills/impeccable/scripts/hook-admin.mjs b/.trae/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/.trae/skills/impeccable/scripts/hook-admin.mjs
+++ b/.trae/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/.trae/skills/impeccable/scripts/hook-lib.mjs b/.trae/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/.trae/skills/impeccable/scripts/hook-lib.mjs
+++ b/.trae/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/.trae/skills/impeccable/scripts/lib/impeccable-config.mjs b/.trae/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/.trae/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/.trae/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.
diff --git a/plugin/skills/impeccable/reference/hooks.md b/plugin/skills/impeccable/reference/hooks.md
index 30f756793..07d191c55 100644
--- a/plugin/skills/impeccable/reference/hooks.md
+++ b/plugin/skills/impeccable/reference/hooks.md
@@ -23,10 +23,11 @@ The first argument is the action. Defaults to `status`.
| `status` | Print current state, shared/local config paths, ignored rules / files / values, env override. |
| `on` | Set `enabled: true` in `.impeccable/config.json`, record local hook consent as accepted, and install/repair provider hook manifests when the skill is installed. |
| `off` | Set `enabled: false` in `.impeccable/config.json`. |
-| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. |
-| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. |
+| `ignore-rule <id>` | Append `<id>` to `detector.ignoreRules`; for `overused-font`, requires `--all-values`. Suppresses the rule across the whole project. |
+| `ignore-file <glob>` | Append `<glob>` to `detector.ignoreFiles`. Suppresses **every** rule for matching files. |
| `ignore-value <id> <value> [--shared] [--reason "..."]` | Append a rule/value suppression to shared `.impeccable/config.json`. |
| `ignore-value <id> <value> --local [--reason "..."]` | Append a private rule/value suppression to `.impeccable/config.local.json`. |
+| `ignore-value <id> "*" --file <glob> [--file <glob>...]` | Turn one rule off in matching files only, leaving it active everywhere else. Repeat `--file`, or use `--file=<glob>` / `--files=<glob>`. A bare `"*"` with no `--file` is refused: use `ignore-rule <id>` if you really mean project-wide. |
| `reset` | Delete the project config, dedup cache, and Cursor pending queue. |
## Flow
@@ -51,7 +52,8 @@ Prefer the narrowest exception:
- If the finding line shows an exact `ignore-value` command, run that command. This writes shared `.impeccable/config.json` by default.
- For value-specific findings such as `overused-font` and `bounce-easing`, use `ignore-value` when the user confirms the specific value. Do not use `ignore-rule overused-font` for a specific font.
-- If the finding has no value-specific command, such as `side-tab`, prefer `ignore-file <path>` for the current file.
+- If the finding has no value-specific command, such as `side-tab`, scope that one rule to the file: `ignore-value <id> "*" --file <path>`. Run `npx impeccable detect <path>` first to see what actually fires there.
+- Reach for `ignore-file <path>` only when the whole file is out of scope for design review: a fixture, a generated artifact, a deliberate slop demo. It silences every rule for that file permanently, including rules that have not been written yet. A real UI surface with one noisy rule wants the file-scoped value ignore above.
- Use `ignore-rule <id>` only when the user asks to suppress that whole rule across the project. For broad overused-font suppression, use `ignore-rule overused-font --all-values` only when the user asks to ignore overused fonts generally.
- Prefer config ignores (the commands above) by default; they keep suppressions in one reviewable place. Reach for an inline comment only when the waiver must travel with a single file that leaves the repo (a generated/exported standalone document, an emailed HTML file). The supported marker is `impeccable-disable <rule>` (whole file) or `impeccable-disable-line` / `impeccable-disable-next-line` (one line), in any comment syntax, with an optional reason after `:` or `--`. The detector honors it by default; `--no-inline-ignores` or `--no-config` bypasses it.
@@ -73,7 +75,14 @@ Example whole-rule font exception:
node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-rule overused-font --all-values --reason "User asked to ignore overused fonts generally"
```
-Example file-scoped exception:
+Example one-rule-in-one-file exception, for a file that is still worth reviewing
+for everything else:
+
+```bash
+node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-value design-system-font-size "*" --file "src/overlay/widget.js" --reason "Injected widget builds its own type scale; DESIGN.md's ramp describes the site"
+```
+
+Example whole-file exception, for a file that is out of scope entirely:
```bash
node .claude/skills/impeccable/scripts/hook-admin.mjs ignore-file "src/legacy/Card.tsx"
diff --git a/plugin/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs b/plugin/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
index 1affdda43..ab2ed562a 100644
--- a/plugin/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
+++ b/plugin/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs
@@ -43,25 +43,96 @@ function firstOverusedGoogleFont(text) {
return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
}
-function isNeutralBorderColor(str) {
- const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
- if (!m) return false;
- const c = m[1].toLowerCase();
- if (['gray', 'grey', 'silver', 'white', 'black', 'transparent', 'currentcolor'].includes(c)) return true;
- if (/^(?:rgba?|hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
- const hex = c.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/);
- if (hex) {
- const [r, g, b] = [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+// CSS named colors whose channels are equal (achromatic). Anything outside
+// this set falls through to the format parsers, and an unrecognized spelling
+// stays non-neutral so a real accent is never skipped.
+const NEUTRAL_COLOR_KEYWORDS = new Set([
+ 'transparent', 'currentcolor',
+ 'black', 'white', 'gray', 'grey', 'silver',
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
+ 'gainsboro', 'whitesmoke',
+]);
+
+function hexChannels(color) {
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
+ return null;
+}
+
+/**
+ * Split one box-shadow layer into top-level tokens.
+ *
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
+ * read their innards as separate lengths.
+ */
+function tokenizeShadowLayer(layer) {
+ const tokens = [];
+ let depth = 0;
+ let current = '';
+ for (const char of String(layer || '')) {
+ if (char === '(') depth++;
+ else if (char === ')') depth--;
+ else if (depth === 0 && /\s/.test(char)) {
+ if (current) tokens.push(current);
+ current = '';
+ continue;
+ }
+ current += char;
}
- const shex = c.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);
- if (shex) {
- const [r, g, b] = [parseInt(shex[1] + shex[1], 16), parseInt(shex[2] + shex[2], 16), parseInt(shex[3] + shex[3], 16)];
- return (Math.max(r, g, b) - Math.min(r, g, b)) < 30;
+ if (current) tokens.push(current);
+ return tokens;
+}
+
+function lastMatch(text, re) {
+ const all = [...String(text || '').matchAll(re)];
+ return all.length ? all[all.length - 1] : null;
+}
+
+function isShadowLength(token) {
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
+}
+
+/**
+ * Neutrality test for colors as written in source CSS.
+ *
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
+ * other spelling as chromatic so an unknown format is never silently skipped.
+ * That default is wrong for authored CSS, where `#000` and `black` are the
+ * normal spellings: calling it directly reports a plain black hairline as a
+ * colored stripe. Handle hex and named neutrals here, then defer.
+ */
+function isNeutralAuthoredColor(rawColor) {
+ const c = String(rawColor || '').trim().toLowerCase();
+ if (!c) return false;
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
+ // parses only the comma form a browser's getComputedStyle emits, so authored
+ // space-separated neutrals fell through it and reported as chromatic — the
+ // exemption this function exists for, missed. Normalize before delegating.
+ if (/^rgba?\(/i.test(c)) {
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
+ if (channels) {
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
+ return (Math.max(...values) - Math.min(...values)) < 30;
+ }
+ return isNeutralColor(c);
}
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
+ const channels = hexChannels(c);
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
return false;
}
+function isNeutralBorderColor(str) {
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
+ if (!m) return false;
+ return isNeutralAuthoredColor(m[1]);
+}
+
const REGEX_MATCHERS = [
// --- Side-tab ---
{ id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
@@ -345,12 +416,120 @@ const REGEX_ANALYZERS = [
];
// ---------------------------------------------------------------------------
-// Style block extraction (Vue/Svelte <style> blocks)
+// Structural CSS checks used by source files whose styles are not parsed by
+// the static HTML engine.
+// ---------------------------------------------------------------------------
+
+const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
+
+function insetStripeColorIsChromatic(rawColor) {
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
+ return !isNeutralAuthoredColor(color);
+}
+
+/**
+ * Blank out comment bodies while preserving every byte offset (and therefore
+ * every line number) so commented-out CSS is not scanned as live rules.
+ */
+function blankCssComments(css) {
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
+}
+
+function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
+ const content = blankCssComments(rawContent);
+ const findings = [];
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
+ let match;
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
+ let scanOffset = 0;
+ let scanLine = 1;
+ const lineAtOffset = (offset) => {
+ while (scanOffset < offset) {
+ if (content[scanOffset] === '\n') scanLine++;
+ scanOffset++;
+ }
+ return scanLine;
+ };
+ while ((match = ruleRe.exec(content)) !== null) {
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
+ // newlines trailing the previous rule. Advance past that run before deriving
+ // the line, or every rule after the first reports the preceding line.
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
+ const selector = match[1].trim().replace(/\s+/g, ' ');
+ if (!selector) continue;
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
+
+ // Read the last of a repeated declaration, not the first: that is what the
+ // cascade paints. Taking the first both flagged stripes that a later
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
+ if (width && Number(width[1]) <= 40) continue;
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
+ // `!important` qualifies the declaration, not the shadow value, so strip it
+ // before the layers are read. Tokenizing split it into its own token, which
+ // made the color count wrong and silently stopped flagging stripes declared
+ // with it — a shape the previous regex handled.
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
+
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
+ const layer = rawLayer.trim();
+ // Parse the layer by its grammar rather than by one spelling of it.
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
+ // all paint the same stripe. Matching a fixed token order missed three
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
+ // whitespace would read its channels as lengths.
+ const tokens = tokenizeShadowLayer(layer);
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
+ const lengths = rest.filter(isShadowLength);
+ const colors = rest.filter((token) => !isShadowLength(token));
+ // Only the two offsets are required; omitted blur/spread default to 0,
+ // which is exactly the stripe shape. More than one non-length token is a
+ // layer shape we do not claim to understand, so leave it alone.
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
+ const values = lengths.map((token) => ({
+ n: Number(token.replace(/px$/i, '')),
+ hasPx: /px$/i.test(token),
+ }));
+ const x = values[0];
+ const y = values[1];
+ const blur = values[2] ? values[2].n : 0;
+ const spread = values[3] ? values[3].n : 0;
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
+ const ax = Math.abs(x.n);
+ const ay = Math.abs(y.n);
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
+ const line = lineOffset + lineAtOffset(selectorStart);
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
+ break;
+ }
+ }
+ return findings;
+}
+
+// ---------------------------------------------------------------------------
+// Style block extraction (Astro/Vue/Svelte <style> blocks)
// ---------------------------------------------------------------------------
function extractStyleBlocks(content, ext) {
ext = ext.toLowerCase();
- if (ext !== '.vue' && ext !== '.svelte') return [];
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
const blocks = [];
const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
let m;
@@ -477,8 +656,9 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'source',
}));
+ if (cssLike.has(ext)) findings.push(...scanInsetStripeCss(content, filePath));
- // Extract and scan <style> blocks from Vue/Svelte SFCs
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
const styleBlocks = profile
? profileStep(profile, {
engine: 'regex',
@@ -493,6 +673,13 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'style-block',
}));
+ // block.startLine is the first line *after* the <style> tag, but block.content
+ // begins at the character right after that tag — so its own line 1 sits on the
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
+ // because it indexes its split lines from zero.
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 2));
}
// Extract and scan CSS-in-JS template literals
@@ -510,6 +697,7 @@ function detectText(content, filePath, options = {}) {
profile,
phase: 'css-in-js',
}));
+ findings.push(...scanInsetStripeCss(block.content, filePath, block.startLine - 1));
}
if (options?.designSystem) {
diff --git a/plugin/skills/impeccable/scripts/hook-admin.mjs b/plugin/skills/impeccable/scripts/hook-admin.mjs
index 8b37b1f3b..12cf004b9 100644
--- a/plugin/skills/impeccable/scripts/hook-admin.mjs
+++ b/plugin/skills/impeccable/scripts/hook-admin.mjs
@@ -13,6 +13,8 @@
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
* node hook-admin.mjs ignore-value <rule> <value> --local
+ * node hook-admin.mjs ignore-value <rule> "*" --file <glob> # rule off in <glob> only
+ * node hook-admin.mjs ignore-value <rule> "*" # refused: scope it or use ignore-rule
* node hook-admin.mjs reset # remove all config + cache
*
* Designed to be invoked by the LLM from the reference/hooks.md flow.
@@ -265,7 +267,10 @@ function mergeIgnoreValueEntries(existing, incoming) {
}
function ignoreValueEntryKey(entry) {
- const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
+ // Sorted: a file scope is a set. Comparing stored order made an on-disk scope
+ // miss the sorted argv form, so a re-add duplicated the entry and a remove
+ // silently failed. Every key that hashes `files` must sort — there are four.
+ const files = Array.isArray(entry.files) && entry.files.length > 0 ? [...entry.files].sort().join('\x1f') : '';
return `${entry.rule}\0${entry.value}\0${files}`;
}
@@ -283,7 +288,14 @@ function statusReport(cwd) {
if (info.exists) return relPath;
return `${relPath} (${absent})`;
};
- const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
+ // Show the file scope. Dropping it rendered a file-scoped entry as
+ // `design-system-font-size=*`, which reads as the project-wide wildcard this
+ // command refuses — the opposite of what is on disk. Matches the
+ // `rule=value [files]` shape `impeccable ignores list` already prints.
+ const ignoreValues = cfg.ignoreValues.map((entry) => {
+ const scope = Array.isArray(entry.files) && entry.files.length ? ` [${entry.files.join(', ')}]` : '';
+ return `${entry.rule}=${entry.value}${scope}`;
+ });
const lines = [
`Impeccable design hook`,
@@ -532,14 +544,29 @@ function addIgnoreFile(cwd, glob) {
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
}
+// An empty glob used to be dropped by filter(Boolean), so `--file=` reported
+// success and wrote an entry with no files: the user asked to scope a rule to one
+// file and silently got the project-wide suppression instead. Refuse it.
+function requireGlob(raw, flag) {
+ const glob = String(raw ?? '').trim();
+ if (!glob) throw new Error(`${flag} requires a non-empty glob`);
+ // A following flag is not a glob. `--file --reason "why"` consumed `--reason`
+ // as the scope and left the reason text to fold into the value, storing
+ // value="* why" files=["--reason"] and reporting success. Same silent-no-op
+ // class as an unknown flag folding into the value; refuse it the same way.
+ if (glob.startsWith('--')) throw new Error(`${flag} requires a glob, got the flag ${glob}`);
+ return glob;
+}
+
function parseIgnoreValueArgs(args) {
const positionals = [];
+ const files = [];
let shared = false;
let local = false;
let reason = '';
for (let i = 0; i < args.length; i++) {
- const arg = args[i];
+ const arg = String(args[i] || '');
if (arg === '--shared') {
shared = true;
} else if (arg === '--local') {
@@ -550,8 +577,20 @@ function parseIgnoreValueArgs(args) {
chunks.push(args[++i]);
}
reason = chunks.join(' ').trim();
- } else if (String(arg).startsWith('--reason=')) {
- reason = String(arg).slice('--reason='.length).trim();
+ } else if (arg.startsWith('--reason=')) {
+ reason = arg.slice('--reason='.length).trim();
+ } else if (arg === '--file' || arg === '--files') {
+ if (i + 1 >= args.length) throw new Error(`${arg} requires a glob`);
+ files.push(requireGlob(args[++i], arg));
+ } else if (arg.startsWith('--file=')) {
+ files.push(requireGlob(arg.slice('--file='.length), '--file'));
+ } else if (arg.startsWith('--files=')) {
+ files.push(requireGlob(arg.slice('--files='.length), '--files'));
+ } else if (arg.startsWith('--')) {
+ // Otherwise a typo folds into the value: `ignore-value overused-font Inter
+ // --shard` stored the value "inter --shard", which matches no finding, and
+ // reported success. Matches `impeccable ignores add-value`.
+ throw new Error(`Unknown ignore-value flag: ${arg}`);
} else {
positionals.push(arg);
}
@@ -561,6 +600,9 @@ function parseIgnoreValueArgs(args) {
return {
rule: String(rule || '').trim().toLowerCase(),
value: normalizeIgnoreValue(valueParts.join(' ')),
+ // Sorted: the dedup key compares the files array, so an unsorted scope made
+ // `--file b.css --file a.css` a different entry from `--file a.css --file b.css`.
+ files: Array.from(new Set(files.filter(Boolean))).sort(),
shared,
local,
reason,
@@ -577,10 +619,24 @@ function addIgnoreValue(cwd, args) {
throw new Error('Pass only one scope flag: --shared or --local');
}
+ // A bare `*` would suppress the rule everywhere, which is ignore-rule's job and
+ // not what a finding in one file justifies. detector.ignoreValues honours a
+ // `files` scope, so require one — matching `impeccable ignores add-value`.
+ if (parsed.value === '*' && parsed.files.length === 0) {
+ // `ignore-rule overused-font` refuses on its own without --all-values, so
+ // naming the bare form here would hand the user a second error.
+ const projectWide = parsed.rule === 'overused-font'
+ ? `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule} --all-values`
+ : `${IMPECCABLE_COMMAND} hooks ignore-rule ${parsed.rule}`;
+ throw new Error(`Wildcard value ignores must be scoped with --file <glob>, e.g. ${IMPECCABLE_COMMAND} hooks ignore-value design-system-font-size "*" --file "src/widget.js". To suppress the rule project-wide use ${projectWide}.`);
+ }
+
const local = parsed.local;
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
- const key = `${parsed.rule}\0${parsed.value}`;
- const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
+ // Key on the file scope too: the same rule/value legitimately appears more than
+ // once with different scopes, and a rule+value-only key overwrote them.
+ const key = ignoreValueEntryKey({ rule: parsed.rule, value: parsed.value, files: parsed.files });
+ const existing = config.ignoreValues.find((entry) => ignoreValueEntryKey(entry) === key);
if (existing) {
if (parsed.reason) existing.reason = parsed.reason;
@@ -588,15 +644,17 @@ function addIgnoreValue(cwd, args) {
const entry = {
rule: parsed.rule,
value: parsed.value,
- createdAt: new Date().toISOString(),
};
+ if (parsed.files.length) entry.files = parsed.files;
+ entry.createdAt = new Date().toISOString();
if (parsed.reason) entry.reason = parsed.reason;
config.ignoreValues.push(entry);
}
const target = writeDetectorConfig(cwd, config, { local });
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
- return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
+ const scopeSuffix = parsed.files.length ? ` scoped to ${parsed.files.join(', ')}` : '';
+ return `Added ${parsed.rule}=${parsed.value}${scopeSuffix} to ${scope} (${path.relative(cwd, target) || target}).`;
}
function reset(cwd) {
diff --git a/plugin/skills/impeccable/scripts/hook-lib.mjs b/plugin/skills/impeccable/scripts/hook-lib.mjs
index 0d9722953..2893fa4f3 100644
--- a/plugin/skills/impeccable/scripts/hook-lib.mjs
+++ b/plugin/skills/impeccable/scripts/hook-lib.mjs
@@ -502,12 +502,15 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -525,7 +528,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
export function readCache(cwd) {
@@ -1465,16 +1470,17 @@ export function appendDesignSystemNote(text, scanOptions) {
// raw envelope. Asking the model to surface the resolution in its
// reply is the cheapest way to make the feedback loop visible.
function directiveFooter(display, opts = {}) {
- const ignoreFileCommand = `${IMPECCABLE_COMMAND} hooks ignore-file ${quoteCommandArg(display)}`;
- const fileIgnoreGuidance = opts.grouped
- ? `run \`${IMPECCABLE_COMMAND} hooks ignore-file <path>\` for the specific file`
- : `run \`${ignoreFileCommand}\``;
+ // Offer the rule-scoped-to-file form first. `ignore-file` silences every rule
+ // for the path forever, which is far more than one noisy rule on a real UI
+ // surface justifies, and it was previously the only option named here.
+ const target = opts.grouped ? '<path>' : quoteCommandArg(display);
+ const fileIgnoreGuidance = `run \`${IMPECCABLE_COMMAND} hooks ignore-value <id> "*" --file ${target}\` to scope just that rule to the file, or \`${IMPECCABLE_COMMAND} hooks ignore-file ${target}\` only when the whole file is out of scope for design review (a fixture, a generated artifact, a deliberate demo)`;
return [
'Handle these before finalizing: fix findings that are real design problems, or explicitly classify contextually intentional findings as false positives. Acknowledge what you changed or why you are leaving a finding unchanged.',
'',
'Use context judgment before editing. A finding is not automatically a defect; literal or domain-appropriate motion, intentional demos or fixtures, documentation of bad design, and user-confirmed choices can be valid as-is.',
'',
- `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For file-specific findings without an ignore-value command, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
+ `Do not change intentional design just to satisfy the hook, and do not silence a real finding with an inline ignore comment to skip fixing it. Suppress a finding only after the user explicitly confirms it is intentional. Prefer a config ignore (one reviewable place, the commands below); reach for an inline \`impeccable-disable <rule>\` comment only when the waiver must travel with a file that leaves the repo, such as an exported or standalone document. Prefer the narrowest persisted exception: run the exact \`${IMPECCABLE_COMMAND} hooks ignore-value ... --shared\` command shown next to a value-specific finding. For \`overused-font\`, use \`ignore-value\` for a specific font and use \`${IMPECCABLE_COMMAND} hooks ignore-rule overused-font --all-values\` only when the user asks to ignore overused fonts generally. For a finding whose line shows no exact ignore-value command, such as \`side-tab\`, ${fileIgnoreGuidance}; use \`${IMPECCABLE_COMMAND} hooks ignore-rule <id>\` only when the user asks to suppress the whole non-value-specific rule. Run ${IMPECCABLE_COMMAND} audit for the full pass.`,
].join('\n');
}
diff --git a/plugin/skills/impeccable/scripts/lib/impeccable-config.mjs b/plugin/skills/impeccable/scripts/lib/impeccable-config.mjs
index 45c65e65a..a62de8e3c 100644
--- a/plugin/skills/impeccable/scripts/lib/impeccable-config.mjs
+++ b/plugin/skills/impeccable/scripts/lib/impeccable-config.mjs
@@ -346,12 +346,16 @@ export function normalizeIgnoreValueEntries(entries) {
...(Array.isArray(entry.files) ? entry.files.filter(v => typeof v === 'string' && v.trim()).map(v => v.trim()) : []),
]);
if (files.length > 0) normalized.files = files;
- if (typeof entry.reason === 'string' && entry.reason.trim()) {
- normalized.reason = entry.reason.trim();
- }
+ // Key order is rule, value, files, createdAt, reason and must stay that way:
+ // normalizing runs on every write, so emitting a different order than the one
+ // already on disk rewrites every untouched entry and churns the diff. Keep in
+ // step with normalizeIgnoreValueEntries in skill/scripts/hook-lib.mjs.
if (typeof entry.createdAt === 'string' && entry.createdAt.trim()) {
normalized.createdAt = entry.createdAt.trim();
}
+ if (typeof entry.reason === 'string' && entry.reason.trim()) {
+ normalized.reason = entry.reason.trim();
+ }
out.push(normalized);
}
return out;
@@ -369,7 +373,9 @@ function mergeIgnoreValues(existing, incoming) {
}
function ignoreValueFilesKey(files) {
- return Array.isArray(files) && files.length > 0 ? files.join('\x1f') : '';
+ // Sort before joining: a scope is a set, so an entry already on disk in another
+ // order must compare equal rather than dedup as two distinct entries.
+ return Array.isArray(files) && files.length > 0 ? [...files].sort().join('\x1f') : '';
}
// Glob -> RegExp. Supports `**`, `*`, `?`, and `{a,b}` alternation.