impeccable 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/bin/commands/skills.mjs +72 -1
- package/cli/engine/detect-antipatterns-browser.js +89 -56
- package/cli/engine/engines/browser/detect-url.mjs +35 -3
- package/cli/engine/engines/regex/detect-text.mjs +5 -22
- package/cli/engine/engines/static-html/css-cascade.mjs +4 -1
- package/cli/engine/engines/static-html/detect-html.mjs +19 -4
- package/cli/engine/registry/antipatterns.mjs +0 -10
- package/cli/engine/rules/checks.mjs +90 -46
- package/cli/lib/impeccable-config.mjs +3 -0
- package/package.json +2 -1
|
@@ -56,7 +56,7 @@ const PROVIDER_DISPLAY = {
|
|
|
56
56
|
'.grok': { name: 'Grok Build', input: 'grok' },
|
|
57
57
|
'.kiro': { name: 'Kiro', input: 'kiro' },
|
|
58
58
|
'.opencode': { name: 'OpenCode', input: 'opencode' },
|
|
59
|
-
'.pi': { name: '
|
|
59
|
+
'.pi': { name: 'Pi Coding Agent', input: 'pi' },
|
|
60
60
|
'.qoder': { name: 'Qoder', input: 'qoder' },
|
|
61
61
|
'.rovodev': { name: 'Rovo Dev', input: 'rovo-dev' },
|
|
62
62
|
'.trae': { name: 'Trae', input: 'trae' },
|
|
@@ -1189,6 +1189,71 @@ function copyProviderSkills(bundleDir, root, targets, { scope } = {}) {
|
|
|
1189
1189
|
return written;
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
|
+
// Native subagent definitions that ship in the bundle next to a provider's
|
|
1193
|
+
// skills. GitHub Copilot's live at `.github/agents/impeccable-*.agent.md`:
|
|
1194
|
+
// project installs commit them at `<repo>/.github/agents/`, user-level
|
|
1195
|
+
// installs go to `~/.copilot/agents/` (Copilot's user-scope dir, NOT
|
|
1196
|
+
// `~/.github/`). On a name conflict Copilot lets the user-level file shadow
|
|
1197
|
+
// the project one, so both paths overwrite existing impeccable-* copies and a
|
|
1198
|
+
// project install reports any same-named user-level agents that would shadow
|
|
1199
|
+
// it. Cursor's live at `.cursor/agents/impeccable-*.md`, user scope
|
|
1200
|
+
// `~/.cursor/agents/`; project agents take precedence there, so no shadow
|
|
1201
|
+
// warning is needed.
|
|
1202
|
+
const PROVIDER_AGENT_ARTIFACTS = {
|
|
1203
|
+
'.github': {
|
|
1204
|
+
ext: '.agent.md',
|
|
1205
|
+
userDir: home => join(home, '.copilot', 'agents'),
|
|
1206
|
+
userShadowsProject: true,
|
|
1207
|
+
},
|
|
1208
|
+
'.cursor': {
|
|
1209
|
+
ext: '.md',
|
|
1210
|
+
userDir: home => join(home, '.cursor', 'agents'),
|
|
1211
|
+
userShadowsProject: false,
|
|
1212
|
+
},
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
function copyProviderAgents(bundleDir, root, providers, { scope, home = homedir() } = {}) {
|
|
1216
|
+
const targets = Array.isArray(providers) ? providers : [providers];
|
|
1217
|
+
const results = [];
|
|
1218
|
+
for (const provider of targets) {
|
|
1219
|
+
const artifact = PROVIDER_AGENT_ARTIFACTS[provider];
|
|
1220
|
+
if (!artifact) continue;
|
|
1221
|
+
const srcDir = join(bundleDir, provider, 'agents');
|
|
1222
|
+
if (!existsSync(srcDir)) continue;
|
|
1223
|
+
const agentFiles = readdirSync(srcDir).filter(name => name.endsWith(artifact.ext));
|
|
1224
|
+
if (agentFiles.length === 0) continue;
|
|
1225
|
+
|
|
1226
|
+
const destDir = scope === 'user'
|
|
1227
|
+
? artifact.userDir(root)
|
|
1228
|
+
: join(root, provider, 'agents');
|
|
1229
|
+
mkdirSync(destDir, { recursive: true });
|
|
1230
|
+
for (const name of agentFiles) {
|
|
1231
|
+
writeFileSync(join(destDir, name), readFileSync(join(srcDir, name)));
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
// A project install can be shadowed by same-named agents in the user-level
|
|
1235
|
+
// dir; surface them so the freshly installed project agents actually apply.
|
|
1236
|
+
const userDir = artifact.userDir(home);
|
|
1237
|
+
const shadowed = artifact.userShadowsProject && scope !== 'user'
|
|
1238
|
+
? agentFiles.filter(name => existsSync(join(userDir, name)))
|
|
1239
|
+
: [];
|
|
1240
|
+
|
|
1241
|
+
results.push({ provider, written: agentFiles.length, destDir, userDir, shadowed });
|
|
1242
|
+
}
|
|
1243
|
+
return results;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function reportProviderAgents(results) {
|
|
1247
|
+
for (const result of results || []) {
|
|
1248
|
+
if (result.written === 0) continue;
|
|
1249
|
+
console.log(`Installed ${providerDisplayName(result.provider)} agents into: ${formatPathForDisplay(result.destDir)}`);
|
|
1250
|
+
if (result.shadowed.length > 0) {
|
|
1251
|
+
console.warn(`Warning: user-level agents in ${formatPathForDisplay(result.userDir)} shadow the project copies just installed: ${result.shadowed.join(', ')}.`);
|
|
1252
|
+
console.warn('Run `npx impeccable update --user` to refresh them, or remove them so the project agents apply.');
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1192
1257
|
function refreshProviderSkills(bundleDir, root, providers, scope) {
|
|
1193
1258
|
const unique = deduplicateProviders(root, providers, scope);
|
|
1194
1259
|
let updated = 0;
|
|
@@ -1735,6 +1800,7 @@ async function install(flags) {
|
|
|
1735
1800
|
if (!updateCheckSkipped && copyTargets.length > 0 && !isUpToDate(installRoot, copyTargets, bundleDir, scope)) {
|
|
1736
1801
|
migrateUnprefixImpeccable(installRoot, scope);
|
|
1737
1802
|
updated = refreshProviderSkills(bundleDir, installRoot, copyTargets, scope);
|
|
1803
|
+
reportProviderAgents(copyProviderAgents(bundleDir, installRoot, copyTargets, { scope }));
|
|
1738
1804
|
const v = getSkillsVersion(installRoot, scope);
|
|
1739
1805
|
console.log(`Updated ${updated} skill(s)${v ? ` to v${v}` : ''}.`);
|
|
1740
1806
|
}
|
|
@@ -1791,8 +1857,10 @@ async function install(flags) {
|
|
|
1791
1857
|
|
|
1792
1858
|
let written = 0;
|
|
1793
1859
|
let hookTargets = [];
|
|
1860
|
+
let agentResults = [];
|
|
1794
1861
|
try {
|
|
1795
1862
|
written = copyProviderSkills(bundleDir, installRoot, targets, { scope });
|
|
1863
|
+
agentResults = copyProviderAgents(bundleDir, installRoot, targets, { scope });
|
|
1796
1864
|
hookTargets = wantHooks ? copyProviderHooks(bundleDir, hookRoot, targets, { force, skillRoot: installRoot }) : [];
|
|
1797
1865
|
} catch (e) {
|
|
1798
1866
|
rmSync(bundleDir, { recursive: true, force: true });
|
|
@@ -1806,6 +1874,7 @@ async function install(flags) {
|
|
|
1806
1874
|
process.exit(1);
|
|
1807
1875
|
}
|
|
1808
1876
|
console.log(`Installed impeccable into: ${targets.join(', ')} (${scope === 'user' ? 'global' : 'project'})`);
|
|
1877
|
+
reportProviderAgents(agentResults);
|
|
1809
1878
|
if (hookTargets.length > 0) console.log(`Installed hooks into: ${hookTargets.join(', ')}`);
|
|
1810
1879
|
|
|
1811
1880
|
console.log('\nDone! Run /impeccable init in your AI harness to set up design context.\n');
|
|
@@ -2062,6 +2131,7 @@ async function update(flags = []) {
|
|
|
2062
2131
|
if (migrated > 0) console.log('Migrated a prefixed install back to /impeccable (the i- prefix is no longer used).');
|
|
2063
2132
|
|
|
2064
2133
|
const updated = refreshProviderSkills(tmpDir, root, copyProviders, scope);
|
|
2134
|
+
reportProviderAgents(copyProviderAgents(tmpDir, root, copyProviders, { scope }));
|
|
2065
2135
|
const wantHooks = installHooks && await decideHookInstall(root, providers, { yes });
|
|
2066
2136
|
const hookTargets = wantHooks ? copyProviderHooks(tmpDir, root, providers, { force }) : [];
|
|
2067
2137
|
|
|
@@ -2096,6 +2166,7 @@ function copyDirSync(src, dest) {
|
|
|
2096
2166
|
// reimplementation in a helper script (which is how bugs slip through).
|
|
2097
2167
|
export {
|
|
2098
2168
|
collectInstallDetections,
|
|
2169
|
+
copyProviderAgents,
|
|
2099
2170
|
copyProviderHooks,
|
|
2100
2171
|
copyProviderSkills,
|
|
2101
2172
|
decideHookInstall,
|
|
@@ -139,16 +139,6 @@ const ANTIPATTERNS = [
|
|
|
139
139
|
skillSection: 'Typography',
|
|
140
140
|
skillGuideline: 'overused fonts like Inter',
|
|
141
141
|
},
|
|
142
|
-
{
|
|
143
|
-
id: 'single-font',
|
|
144
|
-
category: 'slop',
|
|
145
|
-
scopes: ['type'],
|
|
146
|
-
name: 'Single font without hierarchy',
|
|
147
|
-
description:
|
|
148
|
-
'Only one font family is used for the entire page. A single family can work when weight and size contrast carry the hierarchy; otherwise pair a distinctive display font with a refined body font.',
|
|
149
|
-
skillSection: 'Typography',
|
|
150
|
-
skillGuideline: 'only one font family for the entire page',
|
|
151
|
-
},
|
|
152
142
|
{
|
|
153
143
|
id: 'flat-type-hierarchy',
|
|
154
144
|
category: 'slop',
|
|
@@ -1863,9 +1853,11 @@ function collectMarqueeKeyframes(content) {
|
|
|
1863
1853
|
// bound to a keyframe loop that travels a large horizontal distance.
|
|
1864
1854
|
// Rotation/opacity animations never qualify (no X travel); JS-driven
|
|
1865
1855
|
// carousels with user controls have no infinite CSS X-loop to match.
|
|
1866
|
-
|
|
1856
|
+
// `content` is CSS-bearing text; `markup` (defaulting to the same string
|
|
1857
|
+
// for single-corpus callers) is where the <marquee> tag itself lives.
|
|
1858
|
+
function scanCssTextForMarquee(content, markup = content) {
|
|
1867
1859
|
const findings = [];
|
|
1868
|
-
if (/<marquee\b/i.test(
|
|
1860
|
+
if (/<marquee\b/i.test(markup)) {
|
|
1869
1861
|
findings.push({ id: 'marquee', snippet: '<marquee> element' });
|
|
1870
1862
|
}
|
|
1871
1863
|
const marqueeKeyframes = collectMarqueeKeyframes(content);
|
|
@@ -2044,10 +2036,14 @@ function selectorHitsLandmark(content, selector, ranges) {
|
|
|
2044
2036
|
// element sits inside a header/nav landmark is the hero liveness cliché
|
|
2045
2037
|
// and is promoted to error severity; occurrences elsewhere keep the
|
|
2046
2038
|
// registry default severity.
|
|
2047
|
-
|
|
2039
|
+
//
|
|
2040
|
+
// `content` is CSS-bearing text (rules and keyframes); `markup` — defaulting
|
|
2041
|
+
// to the same string for single-corpus callers like the regex source
|
|
2042
|
+
// engine — is where landmark ranges and Tailwind class attributes live.
|
|
2043
|
+
function scanCssTextForPulsingDot(content, markup = content) {
|
|
2048
2044
|
const customProps = collectCssCustomProps(content);
|
|
2049
2045
|
const keyframes = collectPulseKeyframes(content);
|
|
2050
|
-
const heroRanges = landmarkSourceRanges(
|
|
2046
|
+
const heroRanges = landmarkSourceRanges(markup);
|
|
2051
2047
|
const findings = [];
|
|
2052
2048
|
const seen = new Set();
|
|
2053
2049
|
|
|
@@ -2096,7 +2092,7 @@ function scanCssTextForPulsingDot(content) {
|
|
|
2096
2092
|
|
|
2097
2093
|
if (seen.has(selector)) continue;
|
|
2098
2094
|
seen.add(selector);
|
|
2099
|
-
const inLandmark = selectorHitsLandmark(
|
|
2095
|
+
const inLandmark = selectorHitsLandmark(markup, selector, heroRanges);
|
|
2100
2096
|
findings.push({
|
|
2101
2097
|
id: 'pulsing-dot',
|
|
2102
2098
|
snippet: `${selector} — ${w}x${h}px dot with infinite "${pulseName}" animation${inLandmark ? ' in header/nav' : ''}`,
|
|
@@ -2106,10 +2102,11 @@ function scanCssTextForPulsingDot(content) {
|
|
|
2106
2102
|
}
|
|
2107
2103
|
|
|
2108
2104
|
// Tailwind utilities: animate-ping / animate-pulse on a tiny rounded-full
|
|
2109
|
-
// element declared entirely in the class attribute.
|
|
2105
|
+
// element declared entirely in the class attribute. Scanned in the markup
|
|
2106
|
+
// corpus so the match index lines up with the landmark ranges.
|
|
2110
2107
|
const classRe = /class\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
2111
2108
|
let cm;
|
|
2112
|
-
while ((cm = classRe.exec(
|
|
2109
|
+
while ((cm = classRe.exec(markup)) !== null) {
|
|
2113
2110
|
const cls = cm[1] || cm[2] || '';
|
|
2114
2111
|
const anim = cls.match(/\banimate-(ping|pulse)\b/);
|
|
2115
2112
|
if (!anim) continue;
|
|
@@ -2190,20 +2187,64 @@ function scanHtmlForShapeAssembledIllustration(html) {
|
|
|
2190
2187
|
return findings;
|
|
2191
2188
|
}
|
|
2192
2189
|
|
|
2190
|
+
// Scoped scan corpora for the page-level pattern checks. CSS-property
|
|
2191
|
+
// regexes run over the whole source string fire on documentation ABOUT
|
|
2192
|
+
// css — `<code>background-clip: text</code>` prose, <pre> samples, HTML
|
|
2193
|
+
// comments — so the checks scan only the strings that actually style the
|
|
2194
|
+
// page:
|
|
2195
|
+
// styleText — <style> block contents plus style="…" attribute values.
|
|
2196
|
+
// Attribute values keep their `style="…"` form so block-scoped
|
|
2197
|
+
// scanners (grid background) keep treating each attribute as one
|
|
2198
|
+
// declaration block, exactly as they did against raw source. Engines
|
|
2199
|
+
// that already read more CSS (linked stylesheets) prepend it.
|
|
2200
|
+
// classText — class attribute values, for utility-class scans.
|
|
2201
|
+
// Markup-shaped checks (inline <svg> scenes, <img> tags, <marquee>,
|
|
2202
|
+
// landmark ranges) and rendered-text checks (theater phrases) keep the
|
|
2203
|
+
// full source. This extraction serves callers without a parsed document
|
|
2204
|
+
// (the browser bundle scanning outerHTML); attribute reads are tag-scoped
|
|
2205
|
+
// so escaped code samples (<div style="…">) never contribute. The
|
|
2206
|
+
// static engine passes richer corpora built from its parsed document.
|
|
2207
|
+
// Bare CSS input (no markup at all) is its own style text, which keeps
|
|
2208
|
+
// direct checkHtmlPatterns(css) callers behaving as before.
|
|
2209
|
+
function buildHtmlPatternCorpora(html) {
|
|
2210
|
+
const source = String(html || '');
|
|
2211
|
+
if (!/<[a-zA-Z!/]/.test(source)) {
|
|
2212
|
+
return { styleText: source, classText: source };
|
|
2213
|
+
}
|
|
2214
|
+
const styleParts = [];
|
|
2215
|
+
const classParts = [];
|
|
2216
|
+
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
2217
|
+
let m;
|
|
2218
|
+
while ((m = styleBlockRe.exec(source)) !== null) styleParts.push(m[1]);
|
|
2219
|
+
const tagRe = /<[a-zA-Z][^>]*>/g;
|
|
2220
|
+
while ((m = tagRe.exec(source)) !== null) {
|
|
2221
|
+
const tag = m[0];
|
|
2222
|
+
const sm = tag.match(/\bstyle\s*=\s*("[^"]*"|'[^']*')/i);
|
|
2223
|
+
if (sm) styleParts.push(`style=${sm[1]}`);
|
|
2224
|
+
const cm = tag.match(/\bclass\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
|
|
2225
|
+
if (cm) classParts.push(cm[1] ?? cm[2] ?? '');
|
|
2226
|
+
}
|
|
2227
|
+
return { styleText: styleParts.join('\n'), classText: classParts.join('\n') };
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2193
2230
|
/**
|
|
2194
2231
|
* Regex-on-HTML checks shared between browser and Node page-level detection.
|
|
2195
|
-
* These don't need DOM access, just the raw HTML string.
|
|
2232
|
+
* These don't need DOM access, just the raw HTML string. CSS-property and
|
|
2233
|
+
* utility-class patterns scan the scoped corpora (styleText / classText —
|
|
2234
|
+
* see buildHtmlPatternCorpora) so prose about css never flags; only the
|
|
2235
|
+
* markup-shaped and rendered-text checks read the full source.
|
|
2196
2236
|
*/
|
|
2197
|
-
function checkHtmlPatterns(html) {
|
|
2237
|
+
function checkHtmlPatterns(html, corpora) {
|
|
2238
|
+
const { styleText, classText } = corpora || buildHtmlPatternCorpora(html);
|
|
2198
2239
|
const findings = [];
|
|
2199
2240
|
|
|
2200
2241
|
// --- Color ---
|
|
2201
2242
|
|
|
2202
2243
|
// AI color palette: purple/violet
|
|
2203
2244
|
const purpleHexRe = /#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9|6366f1|764ba2|667eea)\b/gi;
|
|
2204
|
-
if (purpleHexRe.test(
|
|
2245
|
+
if (purpleHexRe.test(styleText)) {
|
|
2205
2246
|
const purpleTextRe = /(?:(?:^|;)\s*color\s*:\s*(?:.*?)(?:#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9))|gradient.*?#(?:7c3aed|8b5cf6|a855f7|764ba2|667eea))/gi;
|
|
2206
|
-
if (purpleTextRe.test(
|
|
2247
|
+
if (purpleTextRe.test(styleText)) {
|
|
2207
2248
|
findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet accent colors detected' });
|
|
2208
2249
|
}
|
|
2209
2250
|
}
|
|
@@ -2211,15 +2252,15 @@ function checkHtmlPatterns(html) {
|
|
|
2211
2252
|
// Gradient text (background-clip: text + gradient)
|
|
2212
2253
|
const gradientRe = /(?:-webkit-)?background-clip\s*:\s*text/gi;
|
|
2213
2254
|
let gm;
|
|
2214
|
-
while ((gm = gradientRe.exec(
|
|
2255
|
+
while ((gm = gradientRe.exec(styleText)) !== null) {
|
|
2215
2256
|
const start = Math.max(0, gm.index - 200);
|
|
2216
|
-
const context =
|
|
2257
|
+
const context = styleText.substring(start, gm.index + gm[0].length + 200);
|
|
2217
2258
|
if (/gradient/i.test(context)) {
|
|
2218
2259
|
findings.push({ id: 'gradient-text', snippet: 'background-clip: text + gradient' });
|
|
2219
2260
|
break;
|
|
2220
2261
|
}
|
|
2221
2262
|
}
|
|
2222
|
-
if (/\bbg-clip-text\b/.test(
|
|
2263
|
+
if (/\bbg-clip-text\b/.test(classText) && /\bbg-gradient-to-/.test(classText)) {
|
|
2223
2264
|
findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
|
|
2224
2265
|
}
|
|
2225
2266
|
|
|
@@ -2228,10 +2269,10 @@ function checkHtmlPatterns(html) {
|
|
|
2228
2269
|
// Side-tab accent stripe drawn as an absolutely-positioned pseudo-element
|
|
2229
2270
|
// (no border property involved, so the element-level border checks and
|
|
2230
2271
|
// the border-left regexes never see it).
|
|
2231
|
-
findings.push(...scanCssTextForPseudoStripe(
|
|
2272
|
+
findings.push(...scanCssTextForPseudoStripe(styleText));
|
|
2232
2273
|
|
|
2233
2274
|
// Side-tab accent stripe drawn as a single-edge inset box-shadow.
|
|
2234
|
-
findings.push(...scanCssTextForInsetStripe(
|
|
2275
|
+
findings.push(...scanCssTextForInsetStripe(styleText));
|
|
2235
2276
|
|
|
2236
2277
|
// --- Layout ---
|
|
2237
2278
|
|
|
@@ -2239,20 +2280,20 @@ function checkHtmlPatterns(html) {
|
|
|
2239
2280
|
const spacingValues = [];
|
|
2240
2281
|
const spacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
|
|
2241
2282
|
let sm;
|
|
2242
|
-
while ((sm = spacingRe.exec(
|
|
2283
|
+
while ((sm = spacingRe.exec(styleText)) !== null) {
|
|
2243
2284
|
const v = parseInt(sm[1], 10);
|
|
2244
2285
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
2245
2286
|
}
|
|
2246
2287
|
const gapRe = /gap\s*:\s*(\d+)px/gi;
|
|
2247
|
-
while ((sm = gapRe.exec(
|
|
2288
|
+
while ((sm = gapRe.exec(styleText)) !== null) {
|
|
2248
2289
|
spacingValues.push(parseInt(sm[1], 10));
|
|
2249
2290
|
}
|
|
2250
2291
|
const twSpaceRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
|
|
2251
|
-
while ((sm = twSpaceRe.exec(
|
|
2292
|
+
while ((sm = twSpaceRe.exec(classText)) !== null) {
|
|
2252
2293
|
spacingValues.push(parseInt(sm[1], 10) * 4);
|
|
2253
2294
|
}
|
|
2254
2295
|
const remSpacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
|
|
2255
|
-
while ((sm = remSpacingRe.exec(
|
|
2296
|
+
while ((sm = remSpacingRe.exec(styleText)) !== null) {
|
|
2256
2297
|
const v = Math.round(parseFloat(sm[1]) * 16);
|
|
2257
2298
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
2258
2299
|
}
|
|
@@ -2276,7 +2317,7 @@ function checkHtmlPatterns(html) {
|
|
|
2276
2317
|
|
|
2277
2318
|
// Bounce/elastic animation names
|
|
2278
2319
|
const bounceRe = /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi;
|
|
2279
|
-
const bounceMatch = bounceRe.exec(
|
|
2320
|
+
const bounceMatch = bounceRe.exec(styleText);
|
|
2280
2321
|
if (bounceMatch) {
|
|
2281
2322
|
const animationToken = bounceMatch[1]
|
|
2282
2323
|
.split(/[,\s]+/)
|
|
@@ -2287,7 +2328,7 @@ function checkHtmlPatterns(html) {
|
|
|
2287
2328
|
// Overshoot cubic-bezier
|
|
2288
2329
|
const bezierRe = /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g;
|
|
2289
2330
|
let bm;
|
|
2290
|
-
while ((bm = bezierRe.exec(
|
|
2331
|
+
while ((bm = bezierRe.exec(styleText)) !== null) {
|
|
2291
2332
|
const y1 = parseFloat(bm[2]), y2 = parseFloat(bm[4]);
|
|
2292
2333
|
if (y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1) {
|
|
2293
2334
|
findings.push({ id: 'bounce-easing', snippet: `cubic-bezier(${bm[1]}, ${bm[2]}, ${bm[3]}, ${bm[4]})` });
|
|
@@ -2298,7 +2339,7 @@ function checkHtmlPatterns(html) {
|
|
|
2298
2339
|
// Layout property transitions
|
|
2299
2340
|
const transRe = /transition(?:-property)?\s*:\s*([^;{}]+)/gi;
|
|
2300
2341
|
let tm;
|
|
2301
|
-
while ((tm = transRe.exec(
|
|
2342
|
+
while ((tm = transRe.exec(styleText)) !== null) {
|
|
2302
2343
|
const val = tm[1].toLowerCase();
|
|
2303
2344
|
if (/\ball\b/.test(val)) continue;
|
|
2304
2345
|
const found = val.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
|
|
@@ -2308,30 +2349,32 @@ function checkHtmlPatterns(html) {
|
|
|
2308
2349
|
}
|
|
2309
2350
|
}
|
|
2310
2351
|
|
|
2311
|
-
// Pulsing status dots (tiny circular elements on infinite pulse animations)
|
|
2312
|
-
|
|
2352
|
+
// Pulsing status dots (tiny circular elements on infinite pulse animations).
|
|
2353
|
+
// The CSS rules come from styleText; the markup carries the landmark
|
|
2354
|
+
// ranges and Tailwind class attributes.
|
|
2355
|
+
findings.push(...scanCssTextForPulsingDot(styleText, html));
|
|
2313
2356
|
|
|
2314
2357
|
// Shape-assembled illustrations (large pictorial SVGs built from primitives)
|
|
2315
2358
|
findings.push(...scanHtmlForShapeAssembledIllustration(html));
|
|
2316
2359
|
|
|
2317
2360
|
// Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
|
|
2318
|
-
findings.push(...scanCssTextForMarquee(html));
|
|
2361
|
+
findings.push(...scanCssTextForMarquee(styleText, html));
|
|
2319
2362
|
|
|
2320
2363
|
// --- Dark glow / chromatic halo shadows ---
|
|
2321
2364
|
|
|
2322
|
-
const glowHits = scanCssTextForGlow(
|
|
2365
|
+
const glowHits = scanCssTextForGlow(styleText);
|
|
2323
2366
|
if (glowHits.length > 0) {
|
|
2324
2367
|
findings.push({ id: 'dark-glow', snippet: glowHits[0].snippet });
|
|
2325
2368
|
}
|
|
2326
2369
|
|
|
2327
2370
|
// Radial-gradient background halo (gradient-drawn sibling of dark-glow)
|
|
2328
|
-
const haloHits = scanCssTextForRadialHalo(
|
|
2371
|
+
const haloHits = scanCssTextForRadialHalo(styleText);
|
|
2329
2372
|
if (haloHits.length > 0) {
|
|
2330
2373
|
findings.push({ id: 'radial-halo', snippet: haloHits[0].snippet });
|
|
2331
2374
|
}
|
|
2332
2375
|
|
|
2333
2376
|
// --- Generated-UI tells: repeating-gradient stripes ---
|
|
2334
|
-
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(
|
|
2377
|
+
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(styleText)) {
|
|
2335
2378
|
findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
|
|
2336
2379
|
}
|
|
2337
2380
|
|
|
@@ -2348,7 +2391,7 @@ function checkHtmlPatterns(html) {
|
|
|
2348
2391
|
// in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
|
|
2349
2392
|
// nested parens, so match the hairline stop directly rather than parsing
|
|
2350
2393
|
// whole gradient layers.
|
|
2351
|
-
const gridHits = scanCssTextForGridBackground(
|
|
2394
|
+
const gridHits = scanCssTextForGridBackground(styleText);
|
|
2352
2395
|
if (gridHits.length > 0) {
|
|
2353
2396
|
findings.push({ id: 'codex-grid-background', snippet: gridHits[0].snippet });
|
|
2354
2397
|
}
|
|
@@ -2370,7 +2413,7 @@ function checkHtmlPatterns(html) {
|
|
|
2370
2413
|
// hover:rotate / hover:translate utility on an <img>. Each distinct
|
|
2371
2414
|
// mechanism is its own finding.
|
|
2372
2415
|
const imgHoverCss = /\bimg\b[^,{}]*:hover\b[^{}]*\{[^}]*\btransform\s*:\s*(?:scale|rotate|translate|matrix|skew)/i;
|
|
2373
|
-
if (imgHoverCss.test(
|
|
2416
|
+
if (imgHoverCss.test(styleText)) {
|
|
2374
2417
|
findings.push({ id: 'image-hover-transform', snippet: 'img:hover { transform } rule' });
|
|
2375
2418
|
}
|
|
2376
2419
|
const imgTagRe = /<img\b[^>]*\bclass\s*=\s*"([^"]*)"/gi;
|
|
@@ -3271,7 +3314,11 @@ function isKickerCandidate(opts) {
|
|
|
3271
3314
|
|| isSmallCaps;
|
|
3272
3315
|
if (!isUppercased) return false;
|
|
3273
3316
|
if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
|
|
3274
|
-
|
|
3317
|
+
// Proportional only, no absolute floor: the wild's most common recipe is
|
|
3318
|
+
// 0.08em at a sub-13px size, which computes to under 1px and sailed past
|
|
3319
|
+
// the old Math.max(1, ...) floor (observed live: a page whose kickers were
|
|
3320
|
+
// literally class="kicker" produced zero findings).
|
|
3321
|
+
const minTrackedSpacing = kickerFontSize * 0.06;
|
|
3275
3322
|
if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
|
|
3276
3323
|
return true;
|
|
3277
3324
|
}
|
|
@@ -4655,12 +4702,6 @@ function checkTypography() {
|
|
|
4655
4702
|
if (isBrandFontOnOwnDomain(font)) continue;
|
|
4656
4703
|
findings.push({ type: 'overused-font', detail: `Primary font: ${font} (${Math.round(share * 100)}% of text)` });
|
|
4657
4704
|
}
|
|
4658
|
-
|
|
4659
|
-
// Single-font check: only one distinct primary font across all text
|
|
4660
|
-
if (fontUsage.size === 1) {
|
|
4661
|
-
const only = [...fontUsage.keys()][0];
|
|
4662
|
-
findings.push({ type: 'single-font', detail: `only font used is ${only}` });
|
|
4663
|
-
}
|
|
4664
4705
|
}
|
|
4665
4706
|
|
|
4666
4707
|
const sizes = new Set();
|
|
@@ -4922,14 +4963,6 @@ function checkPageTypography(doc, win) {
|
|
|
4922
4963
|
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
4923
4964
|
}
|
|
4924
4965
|
|
|
4925
|
-
// Single font
|
|
4926
|
-
if (fonts.size === 1) {
|
|
4927
|
-
const els = doc.querySelectorAll('*');
|
|
4928
|
-
if (els.length >= 20) {
|
|
4929
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
|
|
4933
4966
|
// Flat type hierarchy
|
|
4934
4967
|
const sizes = new Set();
|
|
4935
4968
|
const textEls = doc.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div');
|
|
@@ -7,6 +7,38 @@ import { profileFindingsAsync, profileStep, profileStepAsync } from '../../profi
|
|
|
7
7
|
import { captureVisualContrastCandidate } from '../visual/screenshot-contrast.mjs';
|
|
8
8
|
import { checkContentHiddenAtRest } from '../../rules/checks.mjs';
|
|
9
9
|
|
|
10
|
+
// On Windows, puppeteer's bundled Chrome lives in a user-writable cache
|
|
11
|
+
// directory. Its GPU process can be denied (STATUS_ACCESS_DENIED) by security
|
|
12
|
+
// software or the GPU sandbox because it launches from an untrusted path.
|
|
13
|
+
// Chrome then crash-loops the GPU process, and each relaunch briefly flashes a
|
|
14
|
+
// compositor surface, the black window users report during `detect <url>`
|
|
15
|
+
// (issue #372). The system-installed Chrome runs from a trusted location with a
|
|
16
|
+
// healthy GPU, so channel:'chrome' avoids the crash entirely; both use hardware
|
|
17
|
+
// GPU, so contrast measurement is unaffected. Scope this to Windows only: other
|
|
18
|
+
// platforms do not have the bug, so they keep the pinned bundled build for
|
|
19
|
+
// consistent measurement across machines. Fall back to bundled when the switch
|
|
20
|
+
// fails (Chrome not installed, or channel resolution fails). If the bundled
|
|
21
|
+
// launch then also fails, surface the original system-Chrome error as the
|
|
22
|
+
// cause so the real failure is not lost.
|
|
23
|
+
async function launchBrowser(puppeteer, { headless = true, args = [] } = {}) {
|
|
24
|
+
let channelError;
|
|
25
|
+
if (process.platform === 'win32') {
|
|
26
|
+
try {
|
|
27
|
+
return await puppeteer.default.launch({ channel: 'chrome', headless, args });
|
|
28
|
+
} catch (err) {
|
|
29
|
+
// System Chrome unavailable or unlaunchable; fall through to the bundled
|
|
30
|
+
// browser, but keep the error in case the fallback fails too.
|
|
31
|
+
channelError = err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return await puppeteer.default.launch({ headless, args });
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (channelError && err && err.cause === undefined) err.cause = channelError;
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
10
42
|
// Reveal sweep + invisible-text measurement for the content-hidden-at-rest
|
|
11
43
|
// rule. Scrolls through the document with instant jumps (bypasses CSS
|
|
12
44
|
// scroll-behavior: smooth) so IntersectionObserver / scroll reveal handlers
|
|
@@ -178,7 +210,7 @@ async function detectUrl(url, options = {}) {
|
|
|
178
210
|
phase: 'load',
|
|
179
211
|
ruleId: 'launch-browser',
|
|
180
212
|
target: url,
|
|
181
|
-
}, () => puppeteer
|
|
213
|
+
}, () => launchBrowser(puppeteer, { headless: options?.headless ?? true, args: launchArgs }));
|
|
182
214
|
const page = await profileStepAsync(profile, {
|
|
183
215
|
engine: 'browser',
|
|
184
216
|
phase: 'load',
|
|
@@ -312,7 +344,7 @@ async function createBrowserDetector(options = {}) {
|
|
|
312
344
|
throw new Error('puppeteer is required for URL scanning. Install: npm install puppeteer');
|
|
313
345
|
}
|
|
314
346
|
const launchArgs = options.launchArgs || (process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : []);
|
|
315
|
-
const browser = options.browser || await puppeteer
|
|
347
|
+
const browser = options.browser || await launchBrowser(puppeteer, {
|
|
316
348
|
headless: options.headless ?? true,
|
|
317
349
|
args: launchArgs,
|
|
318
350
|
});
|
|
@@ -337,4 +369,4 @@ async function createBrowserDetector(options = {}) {
|
|
|
337
369
|
};
|
|
338
370
|
}
|
|
339
371
|
|
|
340
|
-
export { runVisualContrastFallback, detectUrl, createBrowserDetector };
|
|
372
|
+
export { runVisualContrastFallback, detectUrl, createBrowserDetector, launchBrowser };
|
|
@@ -12,7 +12,8 @@ import { profileFindings, profileStep } from '../../profile/profiler.mjs';
|
|
|
12
12
|
// Regex fallback (non-HTML files: CSS, JSX, TSX, etc.)
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
|
|
15
|
-
const hasRounded = (line) =>
|
|
15
|
+
const hasRounded = (line) =>
|
|
16
|
+
/\brounded(?:-\w+)?\b/.test(line.replace(/\brounded-none\b/g, ''));
|
|
16
17
|
const hasBorderRadius = (line) => /border-radius/i.test(line);
|
|
17
18
|
const isSafeElement = (line) => /<(?:blockquote|nav[\s>]|pre[\s>]|code[\s>]|a\s|input[\s>]|span[\s>])/i.test(line);
|
|
18
19
|
|
|
@@ -240,24 +241,6 @@ const REGEX_MATCHERS = [
|
|
|
240
241
|
];
|
|
241
242
|
|
|
242
243
|
const REGEX_ANALYZERS = [
|
|
243
|
-
// Single font
|
|
244
|
-
(content, filePath) => {
|
|
245
|
-
const fontFamilyRe = /font-family\s*:\s*([^;}]+)/gi;
|
|
246
|
-
const fonts = new Set();
|
|
247
|
-
let m;
|
|
248
|
-
while ((m = fontFamilyRe.exec(content)) !== null) {
|
|
249
|
-
for (const f of m[1].split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())) {
|
|
250
|
-
if (f && !GENERIC_FONTS.has(f)) fonts.add(f);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
for (const f of extractGoogleFontFamilies(content)) fonts.add(f);
|
|
254
|
-
if (fonts.size !== 1 || content.split('\n').length < 20) return [];
|
|
255
|
-
const name = [...fonts][0];
|
|
256
|
-
const lines = content.split('\n');
|
|
257
|
-
let line = 1;
|
|
258
|
-
for (let i = 0; i < lines.length; i++) { if (lines[i].toLowerCase().includes(name)) { line = i + 1; break; } }
|
|
259
|
-
return [finding('single-font', filePath, `only font used is ${name}`, line)];
|
|
260
|
-
},
|
|
261
244
|
// Flat type hierarchy
|
|
262
245
|
(content, filePath) => {
|
|
263
246
|
const sizes = new Set();
|
|
@@ -625,10 +608,11 @@ const TEXT_CONTENT_ANALYZER_IDS = [
|
|
|
625
608
|
function runTextContentAnalyzers(content, filePath, options = {}) {
|
|
626
609
|
const profile = options?.profile;
|
|
627
610
|
if (!shouldRunPageAnalyzers(content, filePath)) return [];
|
|
628
|
-
// The 3 text-content analyzers are at indices
|
|
611
|
+
// The 3 text-content analyzers are at indices 2-4 in REGEX_ANALYZERS
|
|
612
|
+
// (single-font's removal on 2026-07-29 shifted every index down one).
|
|
629
613
|
const findings = [];
|
|
630
614
|
for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
|
|
631
|
-
const analyzer = REGEX_ANALYZERS[
|
|
615
|
+
const analyzer = REGEX_ANALYZERS[2 + i];
|
|
632
616
|
const ruleId = TEXT_CONTENT_ANALYZER_IDS[i];
|
|
633
617
|
findings.push(...profileFindings(profile, {
|
|
634
618
|
engine: 'regex',
|
|
@@ -749,7 +733,6 @@ function detectText(content, filePath, options = {}) {
|
|
|
749
733
|
// Page-level analyzers only run on full pages
|
|
750
734
|
if (shouldRunPageAnalyzers(content, filePath)) {
|
|
751
735
|
const analyzerIds = [
|
|
752
|
-
'single-font',
|
|
753
736
|
'flat-type-hierarchy',
|
|
754
737
|
'monotonous-spacing',
|
|
755
738
|
'em-dash-overuse',
|
|
@@ -952,7 +952,10 @@ function collectStaticCssText(root, fileDir, profile, filePath, modules) {
|
|
|
952
952
|
const rel = link.attribs?.rel || '';
|
|
953
953
|
const href = link.attribs?.href || '';
|
|
954
954
|
if (!/\bstylesheet\b/i.test(rel) || !href || /^(https?:)?\/\//i.test(href)) continue;
|
|
955
|
-
|
|
955
|
+
// Cache-busting hrefs (styles.css?v=3) resolve to the file, not to a
|
|
956
|
+
// literal path with the query in it; a versioned link otherwise made the
|
|
957
|
+
// whole stylesheet invisible to every element-level check.
|
|
958
|
+
const cssPath = path.resolve(fileDir, href.split(/[?#]/)[0]);
|
|
956
959
|
try {
|
|
957
960
|
const css = profileStep(profile, {
|
|
958
961
|
engine: 'static-html',
|
|
@@ -60,9 +60,6 @@ function checkStaticPageTypography(document, window) {
|
|
|
60
60
|
for (const font of overusedFound) {
|
|
61
61
|
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
62
62
|
}
|
|
63
|
-
if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
|
|
64
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
65
|
-
}
|
|
66
63
|
const sizes = new Set();
|
|
67
64
|
for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
|
|
68
65
|
const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
|
|
@@ -220,7 +217,25 @@ async function detectHtml(filePath, options = {}) {
|
|
|
220
217
|
for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
|
|
221
218
|
findings.push(finding(f.id, filePath, f.snippet));
|
|
222
219
|
}
|
|
223
|
-
|
|
220
|
+
// Scoped corpora for the pattern checks (see buildHtmlPatternCorpora in
|
|
221
|
+
// rules/checks.mjs): CSS-property regexes must not fire on prose ABOUT
|
|
222
|
+
// css — `<code>background-clip: text</code>` in a changelog is
|
|
223
|
+
// documentation, not styling. cssText already carries the <style>
|
|
224
|
+
// blocks and any linked local stylesheets; style/class attributes come
|
|
225
|
+
// from the parsed document, so escaped code samples never contribute.
|
|
226
|
+
const styleAttrParts = [];
|
|
227
|
+
const classAttrParts = [];
|
|
228
|
+
for (const el of document.querySelectorAll('*')) {
|
|
229
|
+
const styleAttr = el.getAttribute('style');
|
|
230
|
+
if (styleAttr) styleAttrParts.push(`style="${styleAttr}"`);
|
|
231
|
+
const classAttr = el.getAttribute('class');
|
|
232
|
+
if (classAttr) classAttrParts.push(classAttr);
|
|
233
|
+
}
|
|
234
|
+
const patternCorpora = {
|
|
235
|
+
styleText: [cssText, ...styleAttrParts].join('\n'),
|
|
236
|
+
classText: classAttrParts.join('\n'),
|
|
237
|
+
};
|
|
238
|
+
for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html, patternCorpora).filter(item =>
|
|
224
239
|
item.id !== 'bounce-easing' && item.id !== 'layout-transition'
|
|
225
240
|
))) {
|
|
226
241
|
const item = finding(f.id, filePath, f.snippet);
|
|
@@ -28,16 +28,6 @@ const ANTIPATTERNS = [
|
|
|
28
28
|
skillSection: 'Typography',
|
|
29
29
|
skillGuideline: 'overused fonts like Inter',
|
|
30
30
|
},
|
|
31
|
-
{
|
|
32
|
-
id: 'single-font',
|
|
33
|
-
category: 'slop',
|
|
34
|
-
scopes: ['type'],
|
|
35
|
-
name: 'Single font without hierarchy',
|
|
36
|
-
description:
|
|
37
|
-
'Only one font family is used for the entire page. A single family can work when weight and size contrast carry the hierarchy; otherwise pair a distinctive display font with a refined body font.',
|
|
38
|
-
skillSection: 'Typography',
|
|
39
|
-
skillGuideline: 'only one font family for the entire page',
|
|
40
|
-
},
|
|
41
31
|
{
|
|
42
32
|
id: 'flat-type-hierarchy',
|
|
43
33
|
category: 'slop',
|
|
@@ -1062,9 +1062,11 @@ function collectMarqueeKeyframes(content) {
|
|
|
1062
1062
|
// bound to a keyframe loop that travels a large horizontal distance.
|
|
1063
1063
|
// Rotation/opacity animations never qualify (no X travel); JS-driven
|
|
1064
1064
|
// carousels with user controls have no infinite CSS X-loop to match.
|
|
1065
|
-
|
|
1065
|
+
// `content` is CSS-bearing text; `markup` (defaulting to the same string
|
|
1066
|
+
// for single-corpus callers) is where the <marquee> tag itself lives.
|
|
1067
|
+
function scanCssTextForMarquee(content, markup = content) {
|
|
1066
1068
|
const findings = [];
|
|
1067
|
-
if (/<marquee\b/i.test(
|
|
1069
|
+
if (/<marquee\b/i.test(markup)) {
|
|
1068
1070
|
findings.push({ id: 'marquee', snippet: '<marquee> element' });
|
|
1069
1071
|
}
|
|
1070
1072
|
const marqueeKeyframes = collectMarqueeKeyframes(content);
|
|
@@ -1243,10 +1245,14 @@ function selectorHitsLandmark(content, selector, ranges) {
|
|
|
1243
1245
|
// element sits inside a header/nav landmark is the hero liveness cliché
|
|
1244
1246
|
// and is promoted to error severity; occurrences elsewhere keep the
|
|
1245
1247
|
// registry default severity.
|
|
1246
|
-
|
|
1248
|
+
//
|
|
1249
|
+
// `content` is CSS-bearing text (rules and keyframes); `markup` — defaulting
|
|
1250
|
+
// to the same string for single-corpus callers like the regex source
|
|
1251
|
+
// engine — is where landmark ranges and Tailwind class attributes live.
|
|
1252
|
+
function scanCssTextForPulsingDot(content, markup = content) {
|
|
1247
1253
|
const customProps = collectCssCustomProps(content);
|
|
1248
1254
|
const keyframes = collectPulseKeyframes(content);
|
|
1249
|
-
const heroRanges = landmarkSourceRanges(
|
|
1255
|
+
const heroRanges = landmarkSourceRanges(markup);
|
|
1250
1256
|
const findings = [];
|
|
1251
1257
|
const seen = new Set();
|
|
1252
1258
|
|
|
@@ -1295,7 +1301,7 @@ function scanCssTextForPulsingDot(content) {
|
|
|
1295
1301
|
|
|
1296
1302
|
if (seen.has(selector)) continue;
|
|
1297
1303
|
seen.add(selector);
|
|
1298
|
-
const inLandmark = selectorHitsLandmark(
|
|
1304
|
+
const inLandmark = selectorHitsLandmark(markup, selector, heroRanges);
|
|
1299
1305
|
findings.push({
|
|
1300
1306
|
id: 'pulsing-dot',
|
|
1301
1307
|
snippet: `${selector} — ${w}x${h}px dot with infinite "${pulseName}" animation${inLandmark ? ' in header/nav' : ''}`,
|
|
@@ -1305,10 +1311,11 @@ function scanCssTextForPulsingDot(content) {
|
|
|
1305
1311
|
}
|
|
1306
1312
|
|
|
1307
1313
|
// Tailwind utilities: animate-ping / animate-pulse on a tiny rounded-full
|
|
1308
|
-
// element declared entirely in the class attribute.
|
|
1314
|
+
// element declared entirely in the class attribute. Scanned in the markup
|
|
1315
|
+
// corpus so the match index lines up with the landmark ranges.
|
|
1309
1316
|
const classRe = /class\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
1310
1317
|
let cm;
|
|
1311
|
-
while ((cm = classRe.exec(
|
|
1318
|
+
while ((cm = classRe.exec(markup)) !== null) {
|
|
1312
1319
|
const cls = cm[1] || cm[2] || '';
|
|
1313
1320
|
const anim = cls.match(/\banimate-(ping|pulse)\b/);
|
|
1314
1321
|
if (!anim) continue;
|
|
@@ -1389,20 +1396,64 @@ function scanHtmlForShapeAssembledIllustration(html) {
|
|
|
1389
1396
|
return findings;
|
|
1390
1397
|
}
|
|
1391
1398
|
|
|
1399
|
+
// Scoped scan corpora for the page-level pattern checks. CSS-property
|
|
1400
|
+
// regexes run over the whole source string fire on documentation ABOUT
|
|
1401
|
+
// css — `<code>background-clip: text</code>` prose, <pre> samples, HTML
|
|
1402
|
+
// comments — so the checks scan only the strings that actually style the
|
|
1403
|
+
// page:
|
|
1404
|
+
// styleText — <style> block contents plus style="…" attribute values.
|
|
1405
|
+
// Attribute values keep their `style="…"` form so block-scoped
|
|
1406
|
+
// scanners (grid background) keep treating each attribute as one
|
|
1407
|
+
// declaration block, exactly as they did against raw source. Engines
|
|
1408
|
+
// that already read more CSS (linked stylesheets) prepend it.
|
|
1409
|
+
// classText — class attribute values, for utility-class scans.
|
|
1410
|
+
// Markup-shaped checks (inline <svg> scenes, <img> tags, <marquee>,
|
|
1411
|
+
// landmark ranges) and rendered-text checks (theater phrases) keep the
|
|
1412
|
+
// full source. This extraction serves callers without a parsed document
|
|
1413
|
+
// (the browser bundle scanning outerHTML); attribute reads are tag-scoped
|
|
1414
|
+
// so escaped code samples (<div style="…">) never contribute. The
|
|
1415
|
+
// static engine passes richer corpora built from its parsed document.
|
|
1416
|
+
// Bare CSS input (no markup at all) is its own style text, which keeps
|
|
1417
|
+
// direct checkHtmlPatterns(css) callers behaving as before.
|
|
1418
|
+
function buildHtmlPatternCorpora(html) {
|
|
1419
|
+
const source = String(html || '');
|
|
1420
|
+
if (!/<[a-zA-Z!/]/.test(source)) {
|
|
1421
|
+
return { styleText: source, classText: source };
|
|
1422
|
+
}
|
|
1423
|
+
const styleParts = [];
|
|
1424
|
+
const classParts = [];
|
|
1425
|
+
const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
1426
|
+
let m;
|
|
1427
|
+
while ((m = styleBlockRe.exec(source)) !== null) styleParts.push(m[1]);
|
|
1428
|
+
const tagRe = /<[a-zA-Z][^>]*>/g;
|
|
1429
|
+
while ((m = tagRe.exec(source)) !== null) {
|
|
1430
|
+
const tag = m[0];
|
|
1431
|
+
const sm = tag.match(/\bstyle\s*=\s*("[^"]*"|'[^']*')/i);
|
|
1432
|
+
if (sm) styleParts.push(`style=${sm[1]}`);
|
|
1433
|
+
const cm = tag.match(/\bclass\s*=\s*(?:"([^"]*)"|'([^']*)')/i);
|
|
1434
|
+
if (cm) classParts.push(cm[1] ?? cm[2] ?? '');
|
|
1435
|
+
}
|
|
1436
|
+
return { styleText: styleParts.join('\n'), classText: classParts.join('\n') };
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1392
1439
|
/**
|
|
1393
1440
|
* Regex-on-HTML checks shared between browser and Node page-level detection.
|
|
1394
|
-
* These don't need DOM access, just the raw HTML string.
|
|
1441
|
+
* These don't need DOM access, just the raw HTML string. CSS-property and
|
|
1442
|
+
* utility-class patterns scan the scoped corpora (styleText / classText —
|
|
1443
|
+
* see buildHtmlPatternCorpora) so prose about css never flags; only the
|
|
1444
|
+
* markup-shaped and rendered-text checks read the full source.
|
|
1395
1445
|
*/
|
|
1396
|
-
function checkHtmlPatterns(html) {
|
|
1446
|
+
function checkHtmlPatterns(html, corpora) {
|
|
1447
|
+
const { styleText, classText } = corpora || buildHtmlPatternCorpora(html);
|
|
1397
1448
|
const findings = [];
|
|
1398
1449
|
|
|
1399
1450
|
// --- Color ---
|
|
1400
1451
|
|
|
1401
1452
|
// AI color palette: purple/violet
|
|
1402
1453
|
const purpleHexRe = /#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9|6366f1|764ba2|667eea)\b/gi;
|
|
1403
|
-
if (purpleHexRe.test(
|
|
1454
|
+
if (purpleHexRe.test(styleText)) {
|
|
1404
1455
|
const purpleTextRe = /(?:(?:^|;)\s*color\s*:\s*(?:.*?)(?:#(?:7c3aed|8b5cf6|a855f7|9333ea|7e22ce|6d28d9))|gradient.*?#(?:7c3aed|8b5cf6|a855f7|764ba2|667eea))/gi;
|
|
1405
|
-
if (purpleTextRe.test(
|
|
1456
|
+
if (purpleTextRe.test(styleText)) {
|
|
1406
1457
|
findings.push({ id: 'ai-color-palette', snippet: 'Purple/violet accent colors detected' });
|
|
1407
1458
|
}
|
|
1408
1459
|
}
|
|
@@ -1410,15 +1461,15 @@ function checkHtmlPatterns(html) {
|
|
|
1410
1461
|
// Gradient text (background-clip: text + gradient)
|
|
1411
1462
|
const gradientRe = /(?:-webkit-)?background-clip\s*:\s*text/gi;
|
|
1412
1463
|
let gm;
|
|
1413
|
-
while ((gm = gradientRe.exec(
|
|
1464
|
+
while ((gm = gradientRe.exec(styleText)) !== null) {
|
|
1414
1465
|
const start = Math.max(0, gm.index - 200);
|
|
1415
|
-
const context =
|
|
1466
|
+
const context = styleText.substring(start, gm.index + gm[0].length + 200);
|
|
1416
1467
|
if (/gradient/i.test(context)) {
|
|
1417
1468
|
findings.push({ id: 'gradient-text', snippet: 'background-clip: text + gradient' });
|
|
1418
1469
|
break;
|
|
1419
1470
|
}
|
|
1420
1471
|
}
|
|
1421
|
-
if (/\bbg-clip-text\b/.test(
|
|
1472
|
+
if (/\bbg-clip-text\b/.test(classText) && /\bbg-gradient-to-/.test(classText)) {
|
|
1422
1473
|
findings.push({ id: 'gradient-text', snippet: 'bg-clip-text + bg-gradient (Tailwind)' });
|
|
1423
1474
|
}
|
|
1424
1475
|
|
|
@@ -1427,10 +1478,10 @@ function checkHtmlPatterns(html) {
|
|
|
1427
1478
|
// Side-tab accent stripe drawn as an absolutely-positioned pseudo-element
|
|
1428
1479
|
// (no border property involved, so the element-level border checks and
|
|
1429
1480
|
// the border-left regexes never see it).
|
|
1430
|
-
findings.push(...scanCssTextForPseudoStripe(
|
|
1481
|
+
findings.push(...scanCssTextForPseudoStripe(styleText));
|
|
1431
1482
|
|
|
1432
1483
|
// Side-tab accent stripe drawn as a single-edge inset box-shadow.
|
|
1433
|
-
findings.push(...scanCssTextForInsetStripe(
|
|
1484
|
+
findings.push(...scanCssTextForInsetStripe(styleText));
|
|
1434
1485
|
|
|
1435
1486
|
// --- Layout ---
|
|
1436
1487
|
|
|
@@ -1438,20 +1489,20 @@ function checkHtmlPatterns(html) {
|
|
|
1438
1489
|
const spacingValues = [];
|
|
1439
1490
|
const spacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
|
|
1440
1491
|
let sm;
|
|
1441
|
-
while ((sm = spacingRe.exec(
|
|
1492
|
+
while ((sm = spacingRe.exec(styleText)) !== null) {
|
|
1442
1493
|
const v = parseInt(sm[1], 10);
|
|
1443
1494
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
1444
1495
|
}
|
|
1445
1496
|
const gapRe = /gap\s*:\s*(\d+)px/gi;
|
|
1446
|
-
while ((sm = gapRe.exec(
|
|
1497
|
+
while ((sm = gapRe.exec(styleText)) !== null) {
|
|
1447
1498
|
spacingValues.push(parseInt(sm[1], 10));
|
|
1448
1499
|
}
|
|
1449
1500
|
const twSpaceRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
|
|
1450
|
-
while ((sm = twSpaceRe.exec(
|
|
1501
|
+
while ((sm = twSpaceRe.exec(classText)) !== null) {
|
|
1451
1502
|
spacingValues.push(parseInt(sm[1], 10) * 4);
|
|
1452
1503
|
}
|
|
1453
1504
|
const remSpacingRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
|
|
1454
|
-
while ((sm = remSpacingRe.exec(
|
|
1505
|
+
while ((sm = remSpacingRe.exec(styleText)) !== null) {
|
|
1455
1506
|
const v = Math.round(parseFloat(sm[1]) * 16);
|
|
1456
1507
|
if (v > 0 && v < 200) spacingValues.push(v);
|
|
1457
1508
|
}
|
|
@@ -1475,7 +1526,7 @@ function checkHtmlPatterns(html) {
|
|
|
1475
1526
|
|
|
1476
1527
|
// Bounce/elastic animation names
|
|
1477
1528
|
const bounceRe = /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi;
|
|
1478
|
-
const bounceMatch = bounceRe.exec(
|
|
1529
|
+
const bounceMatch = bounceRe.exec(styleText);
|
|
1479
1530
|
if (bounceMatch) {
|
|
1480
1531
|
const animationToken = bounceMatch[1]
|
|
1481
1532
|
.split(/[,\s]+/)
|
|
@@ -1486,7 +1537,7 @@ function checkHtmlPatterns(html) {
|
|
|
1486
1537
|
// Overshoot cubic-bezier
|
|
1487
1538
|
const bezierRe = /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g;
|
|
1488
1539
|
let bm;
|
|
1489
|
-
while ((bm = bezierRe.exec(
|
|
1540
|
+
while ((bm = bezierRe.exec(styleText)) !== null) {
|
|
1490
1541
|
const y1 = parseFloat(bm[2]), y2 = parseFloat(bm[4]);
|
|
1491
1542
|
if (y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1) {
|
|
1492
1543
|
findings.push({ id: 'bounce-easing', snippet: `cubic-bezier(${bm[1]}, ${bm[2]}, ${bm[3]}, ${bm[4]})` });
|
|
@@ -1497,7 +1548,7 @@ function checkHtmlPatterns(html) {
|
|
|
1497
1548
|
// Layout property transitions
|
|
1498
1549
|
const transRe = /transition(?:-property)?\s*:\s*([^;{}]+)/gi;
|
|
1499
1550
|
let tm;
|
|
1500
|
-
while ((tm = transRe.exec(
|
|
1551
|
+
while ((tm = transRe.exec(styleText)) !== null) {
|
|
1501
1552
|
const val = tm[1].toLowerCase();
|
|
1502
1553
|
if (/\ball\b/.test(val)) continue;
|
|
1503
1554
|
const found = val.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
|
|
@@ -1507,30 +1558,32 @@ function checkHtmlPatterns(html) {
|
|
|
1507
1558
|
}
|
|
1508
1559
|
}
|
|
1509
1560
|
|
|
1510
|
-
// Pulsing status dots (tiny circular elements on infinite pulse animations)
|
|
1511
|
-
|
|
1561
|
+
// Pulsing status dots (tiny circular elements on infinite pulse animations).
|
|
1562
|
+
// The CSS rules come from styleText; the markup carries the landmark
|
|
1563
|
+
// ranges and Tailwind class attributes.
|
|
1564
|
+
findings.push(...scanCssTextForPulsingDot(styleText, html));
|
|
1512
1565
|
|
|
1513
1566
|
// Shape-assembled illustrations (large pictorial SVGs built from primitives)
|
|
1514
1567
|
findings.push(...scanHtmlForShapeAssembledIllustration(html));
|
|
1515
1568
|
|
|
1516
1569
|
// Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
|
|
1517
|
-
findings.push(...scanCssTextForMarquee(html));
|
|
1570
|
+
findings.push(...scanCssTextForMarquee(styleText, html));
|
|
1518
1571
|
|
|
1519
1572
|
// --- Dark glow / chromatic halo shadows ---
|
|
1520
1573
|
|
|
1521
|
-
const glowHits = scanCssTextForGlow(
|
|
1574
|
+
const glowHits = scanCssTextForGlow(styleText);
|
|
1522
1575
|
if (glowHits.length > 0) {
|
|
1523
1576
|
findings.push({ id: 'dark-glow', snippet: glowHits[0].snippet });
|
|
1524
1577
|
}
|
|
1525
1578
|
|
|
1526
1579
|
// Radial-gradient background halo (gradient-drawn sibling of dark-glow)
|
|
1527
|
-
const haloHits = scanCssTextForRadialHalo(
|
|
1580
|
+
const haloHits = scanCssTextForRadialHalo(styleText);
|
|
1528
1581
|
if (haloHits.length > 0) {
|
|
1529
1582
|
findings.push({ id: 'radial-halo', snippet: haloHits[0].snippet });
|
|
1530
1583
|
}
|
|
1531
1584
|
|
|
1532
1585
|
// --- Generated-UI tells: repeating-gradient stripes ---
|
|
1533
|
-
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(
|
|
1586
|
+
if (/repeating-(?:linear|radial|conic)-gradient\s*\(/i.test(styleText)) {
|
|
1534
1587
|
findings.push({ id: 'repeating-stripes-gradient', snippet: 'repeating-gradient decorative stripes' });
|
|
1535
1588
|
}
|
|
1536
1589
|
|
|
@@ -1547,7 +1600,7 @@ function checkHtmlPatterns(html) {
|
|
|
1547
1600
|
// in for the second axis. Colors like `oklch(96% 0.012 82 / 0.055)` carry
|
|
1548
1601
|
// nested parens, so match the hairline stop directly rather than parsing
|
|
1549
1602
|
// whole gradient layers.
|
|
1550
|
-
const gridHits = scanCssTextForGridBackground(
|
|
1603
|
+
const gridHits = scanCssTextForGridBackground(styleText);
|
|
1551
1604
|
if (gridHits.length > 0) {
|
|
1552
1605
|
findings.push({ id: 'codex-grid-background', snippet: gridHits[0].snippet });
|
|
1553
1606
|
}
|
|
@@ -1569,7 +1622,7 @@ function checkHtmlPatterns(html) {
|
|
|
1569
1622
|
// hover:rotate / hover:translate utility on an <img>. Each distinct
|
|
1570
1623
|
// mechanism is its own finding.
|
|
1571
1624
|
const imgHoverCss = /\bimg\b[^,{}]*:hover\b[^{}]*\{[^}]*\btransform\s*:\s*(?:scale|rotate|translate|matrix|skew)/i;
|
|
1572
|
-
if (imgHoverCss.test(
|
|
1625
|
+
if (imgHoverCss.test(styleText)) {
|
|
1573
1626
|
findings.push({ id: 'image-hover-transform', snippet: 'img:hover { transform } rule' });
|
|
1574
1627
|
}
|
|
1575
1628
|
const imgTagRe = /<img\b[^>]*\bclass\s*=\s*"([^"]*)"/gi;
|
|
@@ -2470,7 +2523,11 @@ function isKickerCandidate(opts) {
|
|
|
2470
2523
|
|| isSmallCaps;
|
|
2471
2524
|
if (!isUppercased) return false;
|
|
2472
2525
|
if (!(kickerFontSize > 0 && kickerFontSize <= 14)) return false;
|
|
2473
|
-
|
|
2526
|
+
// Proportional only, no absolute floor: the wild's most common recipe is
|
|
2527
|
+
// 0.08em at a sub-13px size, which computes to under 1px and sailed past
|
|
2528
|
+
// the old Math.max(1, ...) floor (observed live: a page whose kickers were
|
|
2529
|
+
// literally class="kicker" produced zero findings).
|
|
2530
|
+
const minTrackedSpacing = kickerFontSize * 0.06;
|
|
2474
2531
|
if (!(kickerLetterSpacing >= minTrackedSpacing)) return false;
|
|
2475
2532
|
return true;
|
|
2476
2533
|
}
|
|
@@ -3854,12 +3911,6 @@ function checkTypography() {
|
|
|
3854
3911
|
if (isBrandFontOnOwnDomain(font)) continue;
|
|
3855
3912
|
findings.push({ type: 'overused-font', detail: `Primary font: ${font} (${Math.round(share * 100)}% of text)` });
|
|
3856
3913
|
}
|
|
3857
|
-
|
|
3858
|
-
// Single-font check: only one distinct primary font across all text
|
|
3859
|
-
if (fontUsage.size === 1) {
|
|
3860
|
-
const only = [...fontUsage.keys()][0];
|
|
3861
|
-
findings.push({ type: 'single-font', detail: `only font used is ${only}` });
|
|
3862
|
-
}
|
|
3863
3914
|
}
|
|
3864
3915
|
|
|
3865
3916
|
const sizes = new Set();
|
|
@@ -4121,14 +4172,6 @@ function checkPageTypography(doc, win) {
|
|
|
4121
4172
|
findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
|
|
4122
4173
|
}
|
|
4123
4174
|
|
|
4124
|
-
// Single font
|
|
4125
|
-
if (fonts.size === 1) {
|
|
4126
|
-
const els = doc.querySelectorAll('*');
|
|
4127
|
-
if (els.length >= 20) {
|
|
4128
|
-
findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
|
|
4129
|
-
}
|
|
4130
|
-
}
|
|
4131
|
-
|
|
4132
4175
|
// Flat type hierarchy
|
|
4133
4176
|
const sizes = new Set();
|
|
4134
4177
|
const textEls = doc.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div');
|
|
@@ -5450,6 +5493,7 @@ export {
|
|
|
5450
5493
|
cssLengthToPx,
|
|
5451
5494
|
scanCssTextForPulsingDot,
|
|
5452
5495
|
scanHtmlForShapeAssembledIllustration,
|
|
5496
|
+
buildHtmlPatternCorpora,
|
|
5453
5497
|
checkHtmlPatterns,
|
|
5454
5498
|
readOwnBackgroundColor,
|
|
5455
5499
|
resolveBackground,
|
|
@@ -529,6 +529,9 @@ function extractFindingIgnoreValueRaw(finding, rule = normalizeIgnoreRule(findin
|
|
|
529
529
|
const primary = text.match(/Primary font:\s*([^()\n;]+)/i);
|
|
530
530
|
if (primary) return cleanIgnoreValueDisplay(primary[1]);
|
|
531
531
|
|
|
532
|
+
const googleLabel = text.match(/Google Fonts:\s*([^()\n;]+)/i);
|
|
533
|
+
if (googleLabel) return cleanIgnoreValueDisplay(googleLabel[1]);
|
|
534
|
+
|
|
532
535
|
const family = text.match(/font-family\s*:\s*["']?([^'",;\n]+)/i);
|
|
533
536
|
if (family) return cleanIgnoreValueDisplay(family[1]);
|
|
534
537
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impeccable",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"author": "Paul Bakaus",
|
|
5
5
|
"description": "Design skills, commands, and anti-pattern detection for AI coding agents",
|
|
6
6
|
"keywords": [
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
"ai": "^7.0.14",
|
|
94
94
|
"archiver": "^8.0.0",
|
|
95
95
|
"playwright": "^1.59.1",
|
|
96
|
+
"svelte": "^5",
|
|
96
97
|
"zod": "^4.3.6"
|
|
97
98
|
}
|
|
98
99
|
}
|