self-evolve-framework 1.1.0 → 1.2.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.
Files changed (220) hide show
  1. package/package.json +1 -1
  2. package/template/skills/impeccable/SKILL.md +174 -47
  3. package/template/skills/impeccable/agents/impeccable_asset_producer.toml +92 -0
  4. package/template/skills/impeccable/agents/impeccable_manual_edit_applier.toml +95 -0
  5. package/template/skills/impeccable/agents/openai.yaml +4 -0
  6. package/template/skills/impeccable/reference/adapt.md +311 -0
  7. package/template/skills/impeccable/reference/animate.md +201 -0
  8. package/template/skills/impeccable/reference/audit.md +133 -0
  9. package/template/skills/impeccable/reference/bolder.md +113 -0
  10. package/template/skills/impeccable/reference/brand.md +108 -0
  11. package/template/skills/impeccable/reference/clarify.md +288 -0
  12. package/template/skills/impeccable/reference/codex.md +105 -0
  13. package/template/skills/impeccable/reference/colorize.md +257 -0
  14. package/template/skills/impeccable/reference/craft.md +123 -0
  15. package/template/skills/impeccable/reference/critique.md +790 -0
  16. package/template/skills/impeccable/reference/delight.md +302 -0
  17. package/template/skills/impeccable/reference/distill.md +111 -0
  18. package/template/skills/impeccable/reference/document.md +429 -0
  19. package/template/skills/impeccable/reference/extract.md +69 -0
  20. package/template/skills/impeccable/reference/harden.md +347 -0
  21. package/template/skills/impeccable/reference/hooks.md +90 -0
  22. package/template/skills/impeccable/reference/init.md +172 -0
  23. package/template/skills/impeccable/reference/interaction-design.md +189 -0
  24. package/template/skills/impeccable/reference/layout.md +161 -0
  25. package/template/skills/impeccable/reference/live.md +720 -0
  26. package/template/skills/impeccable/reference/onboard.md +234 -0
  27. package/template/skills/impeccable/reference/optimize.md +258 -0
  28. package/template/skills/impeccable/reference/overdrive.md +130 -0
  29. package/template/skills/impeccable/reference/polish.md +241 -0
  30. package/template/skills/impeccable/reference/product.md +60 -0
  31. package/template/skills/impeccable/reference/quieter.md +99 -0
  32. package/template/skills/impeccable/reference/shape.md +165 -0
  33. package/template/skills/impeccable/reference/typeset.md +279 -0
  34. package/template/skills/impeccable/scripts/command-metadata.json +94 -0
  35. package/template/skills/impeccable/scripts/context-signals.mjs +225 -0
  36. package/template/skills/impeccable/scripts/context.mjs +961 -0
  37. package/template/skills/impeccable/scripts/critique-storage.mjs +242 -0
  38. package/template/skills/impeccable/scripts/detect-csp.mjs +198 -0
  39. package/template/skills/impeccable/scripts/detect.mjs +21 -0
  40. package/template/skills/impeccable/scripts/detector/browser/injected/index.mjs +1937 -0
  41. package/template/skills/impeccable/scripts/detector/cli/main.mjs +290 -0
  42. package/template/skills/impeccable/scripts/detector/design-system.mjs +750 -0
  43. package/template/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +5138 -0
  44. package/template/skills/impeccable/scripts/detector/detect-antipatterns.mjs +50 -0
  45. package/template/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +277 -0
  46. package/template/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +568 -0
  47. package/template/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1015 -0
  48. package/template/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +234 -0
  49. package/template/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  50. package/template/skills/impeccable/scripts/detector/findings.mjs +12 -0
  51. package/template/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
  52. package/template/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
  53. package/template/skills/impeccable/scripts/detector/registry/antipatterns.mjs +448 -0
  54. package/template/skills/impeccable/scripts/detector/rules/checks.mjs +2671 -0
  55. package/template/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
  56. package/template/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
  57. package/template/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
  58. package/template/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
  59. package/template/skills/impeccable/scripts/hook-admin.mjs +661 -0
  60. package/template/skills/impeccable/scripts/hook-before-edit.mjs +476 -0
  61. package/template/skills/impeccable/scripts/hook-lib.mjs +1632 -0
  62. package/template/skills/impeccable/scripts/hook.mjs +61 -0
  63. package/template/skills/impeccable/scripts/lib/design-parser.mjs +842 -0
  64. package/template/skills/impeccable/scripts/lib/impeccable-config.mjs +638 -0
  65. package/template/skills/impeccable/scripts/lib/impeccable-paths.mjs +128 -0
  66. package/template/skills/impeccable/scripts/lib/is-generated.mjs +69 -0
  67. package/template/skills/impeccable/scripts/lib/target-args.mjs +42 -0
  68. package/template/skills/impeccable/scripts/live/browser-script-parts.mjs +49 -0
  69. package/template/skills/impeccable/scripts/live/completion.mjs +19 -0
  70. package/template/skills/impeccable/scripts/live/event-validation.mjs +137 -0
  71. package/template/skills/impeccable/scripts/live/insert-ui.mjs +458 -0
  72. package/template/skills/impeccable/scripts/live/manual-apply.mjs +939 -0
  73. package/template/skills/impeccable/scripts/live/manual-edit-routes.mjs +357 -0
  74. package/template/skills/impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
  75. package/template/skills/impeccable/scripts/live/session-store.mjs +289 -0
  76. package/template/skills/impeccable/scripts/live/svelte-component.mjs +826 -0
  77. package/template/skills/impeccable/scripts/live/sveltekit-adapter.mjs +274 -0
  78. package/template/skills/impeccable/scripts/live/ui-core.mjs +180 -0
  79. package/template/skills/impeccable/scripts/live/vocabulary.mjs +36 -0
  80. package/template/skills/impeccable/scripts/live-accept.mjs +812 -0
  81. package/template/skills/impeccable/scripts/live-browser-dom.js +146 -0
  82. package/template/skills/impeccable/scripts/live-browser-session.js +123 -0
  83. package/template/skills/impeccable/scripts/live-browser.js +11173 -0
  84. package/template/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
  85. package/template/skills/impeccable/scripts/live-complete.mjs +75 -0
  86. package/template/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
  87. package/template/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  88. package/template/skills/impeccable/scripts/live-inject.mjs +583 -0
  89. package/template/skills/impeccable/scripts/live-insert.mjs +272 -0
  90. package/template/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
  91. package/template/skills/impeccable/scripts/live-poll.mjs +384 -0
  92. package/template/skills/impeccable/scripts/live-resume.mjs +94 -0
  93. package/template/skills/impeccable/scripts/live-server.mjs +1135 -0
  94. package/template/skills/impeccable/scripts/live-status.mjs +61 -0
  95. package/template/skills/impeccable/scripts/live-target.mjs +30 -0
  96. package/template/skills/impeccable/scripts/live-wrap.mjs +894 -0
  97. package/template/skills/impeccable/scripts/live.mjs +297 -0
  98. package/template/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  99. package/template/skills/impeccable/scripts/palette.mjs +633 -0
  100. package/template/skills/impeccable/scripts/pin.mjs +214 -0
  101. package/template/rules/CodeGraph.mdc +0 -23
  102. package/template/rules/Svelte_5.mdc +0 -167
  103. package/template/rules/Svelte_Flow.mdc +0 -176
  104. package/template/rules/Tailwind_CSS_v4.mdc +0 -187
  105. package/template/rules/Tauri.mdc +0 -145
  106. package/template/rules/app-error-pattern.mdc +0 -65
  107. package/template/rules/invoke-safe-pattern.mdc +0 -53
  108. package/template/rules/js.mdc +0 -10
  109. package/template/rules/powershell.mdc +0 -9
  110. package/template/rules//346/227/245/345/277/227.mdc +0 -15
  111. package/template/rules//350/257/267/346/261/202.mdc +0 -49
  112. package/template/skills/caveman/SKILL.md +0 -49
  113. package/template/skills/check/SKILL.md +0 -393
  114. package/template/skills/check/agents/reviewer-architecture.md +0 -39
  115. package/template/skills/check/agents/reviewer-security.md +0 -39
  116. package/template/skills/check/references/persona-catalog.md +0 -56
  117. package/template/skills/check/references/project-context.md +0 -120
  118. package/template/skills/check/references/public-reply.md +0 -14
  119. package/template/skills/check/scripts/audit_signals.py +0 -666
  120. package/template/skills/check/scripts/run-tests.sh +0 -19
  121. package/template/skills/design/SKILL.md +0 -173
  122. package/template/skills/design/references/design-aesthetic-quality.md +0 -67
  123. package/template/skills/design/references/design-data-viz.md +0 -34
  124. package/template/skills/design/references/design-reference.md +0 -295
  125. package/template/skills/design/references/design-tokens.md +0 -45
  126. package/template/skills/design/references/design-traps.md +0 -43
  127. package/template/skills/design-an-interface/SKILL.md +0 -94
  128. package/template/skills/diagnose/SKILL.md +0 -117
  129. package/template/skills/diagnose/scripts/hitl-loop.template.sh +0 -41
  130. package/template/skills/edit-article/SKILL.md +0 -14
  131. package/template/skills/git-guardrails-claude-code/SKILL.md +0 -95
  132. package/template/skills/git-guardrails-claude-code/scripts/block-dangerous-git.sh +0 -25
  133. package/template/skills/grill-me/SKILL.md +0 -10
  134. package/template/skills/grill-with-docs/ADR-FORMAT.md +0 -47
  135. package/template/skills/grill-with-docs/CONTEXT-FORMAT.md +0 -60
  136. package/template/skills/grill-with-docs/SKILL.md +0 -88
  137. package/template/skills/handoff/SKILL.md +0 -15
  138. package/template/skills/health/SKILL.md +0 -260
  139. package/template/skills/health/agents/inspector-context.md +0 -119
  140. package/template/skills/health/agents/inspector-control.md +0 -84
  141. package/template/skills/health/agents/inspector-maintainability.md +0 -55
  142. package/template/skills/health/scripts/check-agent-context.sh +0 -5
  143. package/template/skills/health/scripts/check-doc-refs.sh +0 -8
  144. package/template/skills/health/scripts/check-maintainability.sh +0 -8
  145. package/template/skills/health/scripts/check-verifier-output.sh +0 -5
  146. package/template/skills/health/scripts/check_agent_context.py +0 -444
  147. package/template/skills/health/scripts/check_doc_refs.py +0 -110
  148. package/template/skills/health/scripts/check_maintainability.py +0 -635
  149. package/template/skills/health/scripts/check_verifier_output.py +0 -116
  150. package/template/skills/health/scripts/collect-data.sh +0 -751
  151. package/template/skills/hunt/SKILL.md +0 -232
  152. package/template/skills/hunt/references/failure-patterns.md +0 -138
  153. package/template/skills/hunt/references/ime-unicode.md +0 -58
  154. package/template/skills/hunt/references/logging-techniques.md +0 -72
  155. package/template/skills/hunt/references/rendering-debug.md +0 -34
  156. package/template/skills/improve-codebase-architecture/DEEPENING.md +0 -37
  157. package/template/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  158. package/template/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +0 -44
  159. package/template/skills/improve-codebase-architecture/LANGUAGE.md +0 -53
  160. package/template/skills/improve-codebase-architecture/SKILL.md +0 -81
  161. package/template/skills/learn/SKILL.md +0 -140
  162. package/template/skills/migrate-to-shoehorn/SKILL.md +0 -118
  163. package/template/skills/obsidian-vault/SKILL.md +0 -59
  164. package/template/skills/prototype/LOGIC.md +0 -79
  165. package/template/skills/prototype/SKILL.md +0 -30
  166. package/template/skills/prototype/UI.md +0 -112
  167. package/template/skills/qa/SKILL.md +0 -130
  168. package/template/skills/read/SKILL.md +0 -141
  169. package/template/skills/read/references/read-methods.md +0 -129
  170. package/template/skills/read/scripts/fetch.sh +0 -106
  171. package/template/skills/read/scripts/fetch_feishu.py +0 -251
  172. package/template/skills/read/scripts/fetch_local.py +0 -218
  173. package/template/skills/read/scripts/fetch_weixin.py +0 -107
  174. package/template/skills/request-refactor-plan/SKILL.md +0 -68
  175. package/template/skills/review/SKILL.md +0 -78
  176. package/template/skills/rust-auto-fix/SKILL.md +0 -94
  177. package/template/skills/scaffold-exercises/SKILL.md +0 -106
  178. package/template/skills/sdd-dev/SKILL.md +0 -114
  179. package/template/skills/setup-matt-pocock-skills/SKILL.md +0 -121
  180. package/template/skills/setup-matt-pocock-skills/domain.md +0 -51
  181. package/template/skills/setup-matt-pocock-skills/issue-tracker-github.md +0 -22
  182. package/template/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +0 -23
  183. package/template/skills/setup-matt-pocock-skills/issue-tracker-local.md +0 -19
  184. package/template/skills/setup-matt-pocock-skills/triage-labels.md +0 -15
  185. package/template/skills/setup-pre-commit/SKILL.md +0 -91
  186. package/template/skills/svelte-warnings-fix/SKILL.md +0 -94
  187. package/template/skills/tauri-nsis-installer-icon/SKILL.md +0 -92
  188. package/template/skills/tauri-nsis-installer-icon/references/tauri-nsis-schema.md +0 -71
  189. package/template/skills/tb/SKILL.md +0 -62
  190. package/template/skills/tdd/SKILL.md +0 -109
  191. package/template/skills/tdd/deep-modules.md +0 -33
  192. package/template/skills/tdd/interface-design.md +0 -31
  193. package/template/skills/tdd/mocking.md +0 -59
  194. package/template/skills/tdd/refactoring.md +0 -10
  195. package/template/skills/tdd/tests.md +0 -61
  196. package/template/skills/teach/GLOSSARY-FORMAT.md +0 -35
  197. package/template/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  198. package/template/skills/teach/MISSION-FORMAT.md +0 -31
  199. package/template/skills/teach/RESOURCES-FORMAT.md +0 -32
  200. package/template/skills/teach/SKILL.md +0 -91
  201. package/template/skills/think/SKILL.md +0 -184
  202. package/template/skills/to-issues/SKILL.md +0 -83
  203. package/template/skills/to-prd/SKILL.md +0 -74
  204. package/template/skills/triage/AGENT-BRIEF.md +0 -168
  205. package/template/skills/triage/OUT-OF-SCOPE.md +0 -101
  206. package/template/skills/triage/SKILL.md +0 -103
  207. package/template/skills/ubiquitous-language/SKILL.md +0 -93
  208. package/template/skills/ver/SKILL.md +0 -62
  209. package/template/skills/write/SKILL.md +0 -209
  210. package/template/skills/write/references/write-en.md +0 -199
  211. package/template/skills/write/references/write-product-localization.md +0 -43
  212. package/template/skills/write/references/write-zh-bilingual.md +0 -59
  213. package/template/skills/write/references/write-zh-prose.md +0 -50
  214. package/template/skills/write/references/write-zh-release-notes.md +0 -40
  215. package/template/skills/write/references/write-zh.md +0 -721
  216. package/template/skills/write-a-skill/SKILL.md +0 -117
  217. package/template/skills/writing-beats/SKILL.md +0 -52
  218. package/template/skills/writing-fragments/SKILL.md +0 -75
  219. package/template/skills/writing-shape/SKILL.md +0 -64
  220. package/template/skills/zoom-out/SKILL.md +0 -7
@@ -0,0 +1,234 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ import { GENERIC_FONTS, OVERUSED_FONTS } from '../../shared/constants.mjs';
5
+ import {
6
+ checkSourceDesignSystem,
7
+ collectStaticDesignSystemFindings,
8
+ mergeDesignSystemFindings,
9
+ } from '../../design-system.mjs';
10
+ import { isFullPage } from '../../shared/page.mjs';
11
+ import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
12
+ import { finding } from '../../findings.mjs';
13
+ import { profileFindings, profileStep, profileStepAsync } from '../../profile/profiler.mjs';
14
+ import {
15
+ checkElementBorders,
16
+ checkElementClippedOverflow,
17
+ checkElementColors,
18
+ checkElementGlow,
19
+ checkElementGptBorderShadow,
20
+ checkElementHeroEyebrow,
21
+ checkElementIconTile,
22
+ checkElementItalicSerif,
23
+ checkElementMotion,
24
+ checkElementOversizedH1,
25
+ checkElementQuality,
26
+ checkCreamPalette,
27
+ checkHtmlPatterns,
28
+ checkPageLayout,
29
+ checkPageQualityFromDoc,
30
+ checkRepeatedSectionKickersFromDoc,
31
+ resolveBackground,
32
+ resolveBorderRadiusPx,
33
+ } from '../../rules/checks.mjs';
34
+ import { filterByProviders } from '../../registry/antipatterns.mjs';
35
+ import { detectText, runTextContentAnalyzers } from '../regex/detect-text.mjs';
36
+ import {
37
+ StaticDocument,
38
+ buildStaticStyleMap,
39
+ buildStaticWindow,
40
+ collectStaticCssText,
41
+ } from './css-cascade.mjs';
42
+
43
+ function checkStaticPageTypography(document, window) {
44
+ const findings = [];
45
+ const fonts = new Set();
46
+ const overusedFound = new Set();
47
+ for (const el of document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, td, th, dd, blockquote, figcaption, a, button, label, span, div')) {
48
+ const hasText = el.childNodes.some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
49
+ if (!hasText) continue;
50
+ const ff = window.getComputedStyle(el).fontFamily || '';
51
+ const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
52
+ const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
53
+ if (!primary) continue;
54
+ fonts.add(primary);
55
+ if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
56
+ }
57
+ for (const font of overusedFound) {
58
+ findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
59
+ }
60
+ if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
61
+ findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
62
+ }
63
+ const sizes = new Set();
64
+ for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
65
+ const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
66
+ if (fontSize >= 8 && fontSize < 200) sizes.add(Math.round(fontSize * 10) / 10);
67
+ }
68
+ if (sizes.size >= 3) {
69
+ const sorted = [...sizes].sort((a, b) => a - b);
70
+ const ratio = sorted[sorted.length - 1] / sorted[0];
71
+ if (ratio < 2.0) {
72
+ findings.push({ id: 'flat-type-hierarchy', snippet: `Sizes: ${sorted.map(s => s + 'px').join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
73
+ }
74
+ }
75
+ return findings;
76
+ }
77
+
78
+ function checkElementBrokenImage(el) {
79
+ const src = (el.getAttribute && el.getAttribute('src')) ?? el.attribs?.src;
80
+ // Missing src attribute entirely
81
+ if (src === undefined || src === null) {
82
+ return [{ id: 'broken-image', snippet: '<img> with no src attribute' }];
83
+ }
84
+ const trimmed = String(src).trim();
85
+ // Empty or placeholder-only src values
86
+ if (trimmed === '' || trimmed === '#') {
87
+ return [{ id: 'broken-image', snippet: `<img src="${src}">` }];
88
+ }
89
+ return [];
90
+ }
91
+
92
+ const STATIC_ELEMENT_RULES = [
93
+ { id: 'border-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementBorders(tag, style, null, resolveBorderRadiusPx(el, style, parseFloat(style.width) || 0, window)) },
94
+ { id: 'color-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementColors(el, style, tag, window, customPropMap, false) },
95
+ { id: 'dark-glow', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementGlow(tag, style, resolveBackground(el.parentElement || el, window, customPropMap)) },
96
+ { id: 'motion-rules', selector: '*', run: (el, tag, style) => checkElementMotion(tag, style) },
97
+ { id: 'icon-tile-stack', selector: 'h1,h2,h3,h4,h5,h6', run: (el, tag, _style, window) => checkElementIconTile(el, tag, window) },
98
+ { id: 'italic-serif-display', selector: 'h1,h2', run: (el, tag, style) => checkElementItalicSerif(el, style, tag) },
99
+ { id: 'hero-eyebrow-chip', selector: 'h1', run: (el, tag, style, window, customPropMap) => checkElementHeroEyebrow(el, style, tag, window, customPropMap) },
100
+ { id: 'broken-image', selector: 'img', run: (el) => checkElementBrokenImage(el) },
101
+ { id: 'quality-rules', selector: '*', run: (el, tag, style, window) => checkElementQuality(el, style, tag, window) },
102
+ { id: 'oversized-h1', selector: 'h1', run: (el, tag, style, window) => checkElementOversizedH1(el, style, tag, window) },
103
+ { id: 'clipped-overflow-container', selector: '*', run: (el, tag, style, window) => checkElementClippedOverflow(el, style, tag, window) },
104
+ { id: 'gpt-thin-border-wide-shadow', selector: '*', run: (el, tag, style) => checkElementGptBorderShadow(el, style) },
105
+ ];
106
+
107
+ async function detectHtml(filePath, options = {}) {
108
+ const profile = options?.profile;
109
+ const html = profileStep(profile, {
110
+ engine: 'static-html',
111
+ phase: 'setup',
112
+ ruleId: 'read-html',
113
+ target: filePath,
114
+ }, () => fs.readFileSync(filePath, 'utf-8'));
115
+
116
+ let modules;
117
+ try {
118
+ modules = await profileStepAsync(profile, {
119
+ engine: 'static-html',
120
+ phase: 'setup',
121
+ ruleId: 'import-static-parser',
122
+ target: filePath,
123
+ }, async () => {
124
+ const [htmlparser2, cssSelect, csstree, domutils] = await Promise.all([
125
+ import('htmlparser2'),
126
+ import('css-select'),
127
+ import('css-tree'),
128
+ import('domutils'),
129
+ ]);
130
+ return {
131
+ parseDocument: htmlparser2.parseDocument,
132
+ selectAll: cssSelect.selectAll,
133
+ selectOne: cssSelect.selectOne,
134
+ is: cssSelect.is,
135
+ csstree,
136
+ domutils,
137
+ };
138
+ });
139
+ } catch {
140
+ return detectText(html, filePath, options);
141
+ }
142
+
143
+ const resolvedPath = path.resolve(filePath);
144
+ const fileDir = path.dirname(resolvedPath);
145
+ const root = profileStep(profile, {
146
+ engine: 'static-html',
147
+ phase: 'parse-html',
148
+ ruleId: 'parse-document',
149
+ target: filePath,
150
+ }, () => modules.parseDocument(html, { lowerCaseAttributeNames: false, lowerCaseTags: true }));
151
+
152
+ const cssText = collectStaticCssText(root, fileDir, profile, filePath, modules);
153
+ const document = new StaticDocument(root, modules);
154
+ buildStaticStyleMap(root, document, cssText, modules, profile, filePath);
155
+ const window = buildStaticWindow(document);
156
+
157
+ const customPropMap = null;
158
+
159
+ const findings = [];
160
+ const runElementCheck = (ruleId, callback) => profile
161
+ ? profileFindings(profile, { engine: 'static-html', phase: 'element', ruleId, target: filePath }, callback)
162
+ : callback();
163
+
164
+ const visitedByRule = new Map();
165
+ for (const rule of STATIC_ELEMENT_RULES) {
166
+ const elements = document.querySelectorAll(rule.selector);
167
+ visitedByRule.set(rule.id, elements.length);
168
+ for (const el of elements) {
169
+ const tag = el.tagName.toLowerCase();
170
+ const style = window.getComputedStyle(el);
171
+ for (const f of runElementCheck(rule.id, () => rule.run(el, tag, style, window, customPropMap))) {
172
+ findings.push(finding(f.id, filePath, f.snippet));
173
+ }
174
+ }
175
+ }
176
+
177
+ if (options?.designSystem) {
178
+ const sourceDesignFindings = profileFindings(profile, {
179
+ engine: 'static-html',
180
+ phase: 'source',
181
+ ruleId: 'design-system',
182
+ target: filePath,
183
+ }, () => checkSourceDesignSystem(html, filePath, { designSystem: options.designSystem }));
184
+ const staticDesignFindings = profileFindings(profile, {
185
+ engine: 'static-html',
186
+ phase: 'page',
187
+ ruleId: 'design-system',
188
+ target: filePath,
189
+ }, () => collectStaticDesignSystemFindings(document, window, filePath, options.designSystem));
190
+ findings.push(...mergeDesignSystemFindings(staticDesignFindings, sourceDesignFindings));
191
+ }
192
+
193
+ if (isFullPage(html)) {
194
+ const runPageCheck = (ruleId, callback) => profile
195
+ ? profileFindings(profile, { engine: 'static-html', phase: 'page', ruleId, target: filePath }, callback)
196
+ : callback();
197
+ for (const f of runPageCheck('typography-rules', () => checkStaticPageTypography(document, window))) {
198
+ findings.push(finding(f.id, filePath, f.snippet));
199
+ }
200
+ for (const f of runPageCheck('repeated-section-kickers', () => checkRepeatedSectionKickersFromDoc(document, window))) {
201
+ findings.push(finding(f.id, filePath, f.snippet));
202
+ }
203
+ for (const f of runPageCheck('layout-rules', () => checkPageLayout(document, window))) {
204
+ findings.push(finding(f.id, filePath, f.snippet));
205
+ }
206
+ for (const f of runPageCheck('cream-palette', () => checkCreamPalette(document, window))) {
207
+ findings.push(finding(f.id, filePath, f.snippet));
208
+ }
209
+ for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
210
+ findings.push(finding(f.id, filePath, f.snippet));
211
+ }
212
+ for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html).filter(item =>
213
+ item.id !== 'bounce-easing' && item.id !== 'layout-transition'
214
+ ))) {
215
+ findings.push(finding(f.id, filePath, f.snippet));
216
+ }
217
+ // Text-content analyzers (em-dash overuse, marketing buzzwords,
218
+ // numbered section markers, aphoristic cadence) live in the regex
219
+ // engine. Call them from here so .html files get the same coverage
220
+ // as .css/.tsx files. These are scoped to text content only and
221
+ // don't overlap with static-html's element/page rules.
222
+ for (const f of runPageCheck('text-content', () => runTextContentAnalyzers(html, filePath, options))) {
223
+ findings.push(finding(f.antipattern, filePath, f.snippet));
224
+ }
225
+ }
226
+
227
+ const byProvider = filterByProviders(findings, options.providers);
228
+ // Static-HTML findings carry no line number, so only whole-file
229
+ // `impeccable-disable` directives apply here — exactly the standalone-document
230
+ // waiver this primitive targets. Bypassed by `--no-config` / `--no-inline-ignores`.
231
+ return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, html);
232
+ }
233
+
234
+ export { checkStaticPageTypography, STATIC_ELEMENT_RULES, detectHtml };
@@ -0,0 +1,189 @@
1
+ function sanitizeScreenshotClip(clip, viewport) {
2
+ if (!clip) return null;
3
+ const x = Math.max(0, Math.floor(clip.x || 0));
4
+ const y = Math.max(0, Math.floor(clip.y || 0));
5
+ const width = Math.min(
6
+ Math.max(1, Math.ceil(clip.width || 0)),
7
+ Math.max(1, viewport?.width || 1600),
8
+ );
9
+ const height = Math.min(
10
+ Math.max(1, Math.ceil(clip.height || 0)),
11
+ 320,
12
+ );
13
+ if (width < 1 || height < 1) return null;
14
+ return { x, y, width, height };
15
+ }
16
+
17
+ async function compareScreenshotContrast(page, beforeBase64, afterBase64, candidate) {
18
+ return page.evaluate(async ({ beforeBase64, afterBase64, candidate }) => {
19
+ const loadImage = (base64) => new Promise((resolve, reject) => {
20
+ const img = new Image();
21
+ img.onload = () => resolve(img);
22
+ img.onerror = () => reject(new Error('Could not decode contrast screenshot'));
23
+ img.src = `data:image/png;base64,${base64}`;
24
+ });
25
+ const [before, after] = await Promise.all([loadImage(beforeBase64), loadImage(afterBase64)]);
26
+ const width = Math.min(before.width, after.width);
27
+ const height = Math.min(before.height, after.height);
28
+ if (width < 1 || height < 1) return null;
29
+
30
+ const canvas = document.createElement('canvas');
31
+ canvas.width = width;
32
+ canvas.height = height;
33
+ const ctx = canvas.getContext('2d', { willReadFrequently: true });
34
+ if (!ctx) return null;
35
+
36
+ ctx.drawImage(before, 0, 0, width, height);
37
+ const beforePixels = ctx.getImageData(0, 0, width, height).data;
38
+ ctx.clearRect(0, 0, width, height);
39
+ ctx.drawImage(after, 0, 0, width, height);
40
+ const afterPixels = ctx.getImageData(0, 0, width, height).data;
41
+
42
+ const luminance = ({ r, g, b }) => {
43
+ const convert = c => {
44
+ const v = c / 255;
45
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
46
+ };
47
+ return 0.2126 * convert(r) + 0.7152 * convert(g) + 0.0722 * convert(b);
48
+ };
49
+ const ratio = (a, b) => {
50
+ const l1 = luminance(a);
51
+ const l2 = luminance(b);
52
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
53
+ };
54
+
55
+ const cssTextColor = candidate.textColor && !candidate.preferRenderedForeground
56
+ ? {
57
+ r: candidate.textColor.r,
58
+ g: candidate.textColor.g,
59
+ b: candidate.textColor.b,
60
+ }
61
+ : null;
62
+ const ratios = [];
63
+ let glyphPixels = 0;
64
+ let strongestDelta = 0;
65
+ for (let i = 0; i < beforePixels.length; i += 4) {
66
+ const delta = Math.abs(beforePixels[i] - afterPixels[i])
67
+ + Math.abs(beforePixels[i + 1] - afterPixels[i + 1])
68
+ + Math.abs(beforePixels[i + 2] - afterPixels[i + 2])
69
+ + Math.abs(beforePixels[i + 3] - afterPixels[i + 3]);
70
+ strongestDelta = Math.max(strongestDelta, delta);
71
+ if (delta < 10) continue;
72
+ glyphPixels++;
73
+ const fg = cssTextColor || {
74
+ r: beforePixels[i],
75
+ g: beforePixels[i + 1],
76
+ b: beforePixels[i + 2],
77
+ };
78
+ const bg = {
79
+ r: afterPixels[i],
80
+ g: afterPixels[i + 1],
81
+ b: afterPixels[i + 2],
82
+ };
83
+ ratios.push(ratio(fg, bg));
84
+ }
85
+
86
+ if (ratios.length < 8) {
87
+ return {
88
+ glyphPixels,
89
+ strongestDelta,
90
+ worstRatio: null,
91
+ p10Ratio: null,
92
+ medianRatio: null,
93
+ };
94
+ }
95
+
96
+ ratios.sort((a, b) => a - b);
97
+ const pick = pct => ratios[Math.min(ratios.length - 1, Math.max(0, Math.floor((pct / 100) * ratios.length)))];
98
+ return {
99
+ glyphPixels,
100
+ strongestDelta,
101
+ worstRatio: ratios[0],
102
+ p10Ratio: pick(10),
103
+ medianRatio: pick(50),
104
+ };
105
+ }, { beforeBase64, afterBase64, candidate });
106
+ }
107
+
108
+ async function captureVisualContrastCandidate(page, candidate, viewport) {
109
+ const clip = sanitizeScreenshotClip(candidate.clip, viewport);
110
+ if (!clip) return null;
111
+
112
+ const beforeBase64 = await page.screenshot({
113
+ encoding: 'base64',
114
+ clip,
115
+ captureBeyondViewport: true,
116
+ });
117
+ const token = `impeccable-contrast-${Date.now()}-${Math.random().toString(36).slice(2)}`;
118
+ const applied = await page.evaluate(({ selector, token, backgroundClipText }) => {
119
+ let el;
120
+ try {
121
+ el = document.querySelector(selector);
122
+ } catch {
123
+ return false;
124
+ }
125
+ if (!el) return false;
126
+ let style = document.getElementById('impeccable-visual-contrast-hide-style');
127
+ if (!style) {
128
+ style = document.createElement('style');
129
+ style.id = 'impeccable-visual-contrast-hide-style';
130
+ style.textContent = [
131
+ '[data-impeccable-visual-contrast-target] {',
132
+ ' color: transparent !important;',
133
+ ' -webkit-text-fill-color: transparent !important;',
134
+ ' text-shadow: none !important;',
135
+ '}',
136
+ '[data-impeccable-visual-contrast-target][data-impeccable-bgclip-text="true"] {',
137
+ ' background-image: none !important;',
138
+ '}',
139
+ ].join('\n');
140
+ document.head.appendChild(style);
141
+ }
142
+ el.setAttribute('data-impeccable-visual-contrast-target', token);
143
+ if (backgroundClipText) el.setAttribute('data-impeccable-bgclip-text', 'true');
144
+ return true;
145
+ }, {
146
+ selector: candidate.selector,
147
+ token,
148
+ backgroundClipText: candidate.backgroundClipText,
149
+ });
150
+ if (!applied) return null;
151
+
152
+ let afterBase64;
153
+ try {
154
+ afterBase64 = await page.screenshot({
155
+ encoding: 'base64',
156
+ clip,
157
+ captureBeyondViewport: true,
158
+ });
159
+ } finally {
160
+ await page.evaluate(({ selector }) => {
161
+ try {
162
+ const el = document.querySelector(selector);
163
+ if (el) {
164
+ el.removeAttribute('data-impeccable-visual-contrast-target');
165
+ el.removeAttribute('data-impeccable-bgclip-text');
166
+ }
167
+ } catch {
168
+ // Ignore invalid or stale selectors during cleanup.
169
+ }
170
+ }, { selector: candidate.selector }).catch(() => {});
171
+ }
172
+
173
+ const metrics = await compareScreenshotContrast(page, beforeBase64, afterBase64, candidate);
174
+ if (!metrics || !Number.isFinite(metrics.p10Ratio) || metrics.glyphPixels < 8) return null;
175
+ const measuredRatio = metrics.p10Ratio;
176
+ if (measuredRatio >= candidate.threshold) return null;
177
+ const textLabel = candidate.text ? ` "${candidate.text}"` : '';
178
+ const reasonLabel = (candidate.reasons || []).slice(0, 3).join(', ') || 'visual background';
179
+ return {
180
+ id: 'low-contrast',
181
+ snippet: `pixel contrast ${measuredRatio.toFixed(1)}:1 median ${metrics.medianRatio.toFixed(1)}:1 (need ${candidate.threshold}:1) on ${reasonLabel}${textLabel}`,
182
+ };
183
+ }
184
+
185
+ export {
186
+ sanitizeScreenshotClip,
187
+ compareScreenshotContrast,
188
+ captureVisualContrastCandidate,
189
+ };
@@ -0,0 +1,12 @@
1
+ import { getAntipattern } from './registry/antipatterns.mjs';
2
+
3
+ function getAP(id) {
4
+ return getAntipattern(id);
5
+ }
6
+
7
+ function finding(id, filePath, snippet, line = 0) {
8
+ const ap = getAP(id);
9
+ return { antipattern: id, name: ap.name, description: ap.description, severity: ap.severity || 'warning', file: filePath, line, snippet };
10
+ }
11
+
12
+ export { getAP, finding };
@@ -0,0 +1,198 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ // ---------------------------------------------------------------------------
5
+ // File walker
6
+ // ---------------------------------------------------------------------------
7
+
8
+ const SKIP_DIRS = new Set([
9
+ 'node_modules', '.git', 'dist', 'build', '.next', '.nuxt', '.output',
10
+ '.svelte-kit', '__pycache__', '.turbo', '.vercel',
11
+ ]);
12
+
13
+ const SCANNABLE_EXTENSIONS = new Set([
14
+ '.html', '.htm', '.css', '.scss', '.sass', '.less',
15
+ '.jsx', '.tsx', '.js', '.ts',
16
+ '.vue', '.svelte', '.astro',
17
+ ]);
18
+
19
+ const HTML_EXTENSIONS = new Set(['.html', '.htm']);
20
+
21
+ function walkDir(dir) {
22
+ const files = [];
23
+ let entries;
24
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return files; }
25
+ for (const entry of entries) {
26
+ if (SKIP_DIRS.has(entry.name)) continue;
27
+ const full = path.join(dir, entry.name);
28
+ if (entry.isDirectory()) files.push(...walkDir(full));
29
+ else if (SCANNABLE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) files.push(full);
30
+ }
31
+ return files;
32
+ }
33
+
34
+
35
+ // ---------------------------------------------------------------------------
36
+ // Import graph (multi-file awareness)
37
+ // ---------------------------------------------------------------------------
38
+
39
+ function resolveImport(specifier, fromDir, fileSet) {
40
+ if (!/^[./]/.test(specifier)) return null; // skip bare specifiers
41
+ const base = path.resolve(fromDir, specifier);
42
+ if (fileSet.has(base)) return base;
43
+ for (const ext of SCANNABLE_EXTENSIONS) {
44
+ const withExt = base + ext;
45
+ if (fileSet.has(withExt)) return withExt;
46
+ }
47
+ // index file convention
48
+ for (const ext of SCANNABLE_EXTENSIONS) {
49
+ const indexFile = path.join(base, 'index' + ext);
50
+ if (fileSet.has(indexFile)) return indexFile;
51
+ }
52
+ return null;
53
+ }
54
+
55
+ function buildImportGraph(files) {
56
+ const fileSet = new Set(files);
57
+ const graph = new Map();
58
+
59
+ for (const file of files) {
60
+ const content = fs.readFileSync(file, 'utf-8');
61
+ const dir = path.dirname(file);
62
+ const imports = new Set();
63
+
64
+ // ES imports: import ... from '...' and import '...'
65
+ const esRe = /import\s+(?:[\s\S]*?from\s+)?['"]([^'"]+)['"]/g;
66
+ let m;
67
+ while ((m = esRe.exec(content)) !== null) {
68
+ const resolved = resolveImport(m[1], dir, fileSet);
69
+ if (resolved) imports.add(resolved);
70
+ }
71
+
72
+ // CSS @import
73
+ const cssRe = /@import\s+(?:url\(\s*)?['"]?([^'");\s]+)['"]?\s*\)?/g;
74
+ while ((m = cssRe.exec(content)) !== null) {
75
+ const resolved = resolveImport(m[1], dir, fileSet);
76
+ if (resolved) imports.add(resolved);
77
+ }
78
+
79
+ // SCSS @use / @forward
80
+ const scssRe = /@(?:use|forward)\s+['"]([^'"]+)['"]/g;
81
+ while ((m = scssRe.exec(content)) !== null) {
82
+ const resolved = resolveImport(m[1], dir, fileSet);
83
+ if (resolved) imports.add(resolved);
84
+ }
85
+
86
+ graph.set(file, imports);
87
+ }
88
+ return graph;
89
+ }
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // Framework dev server detection
93
+ // ---------------------------------------------------------------------------
94
+
95
+ const FRAMEWORK_CONFIGS = [
96
+ { name: 'Next.js', files: ['next.config.js', 'next.config.mjs', 'next.config.ts'], defaultPort: 3000,
97
+ portRe: /port\s*[:=]\s*(\d+)/,
98
+ fingerprint: { header: 'x-powered-by', value: /next/i } },
99
+ { name: 'SvelteKit', files: ['svelte.config.js', 'svelte.config.ts'], defaultPort: 5173,
100
+ portRe: /port\s*[:=]\s*(\d+)/,
101
+ fingerprint: { header: 'x-sveltekit-page', value: null } },
102
+ { name: 'Nuxt', files: ['nuxt.config.js', 'nuxt.config.ts'], defaultPort: 3000,
103
+ portRe: /port\s*[:=]\s*(\d+)/,
104
+ fingerprint: { header: 'x-powered-by', value: /nuxt/i } },
105
+ { name: 'Vite', files: ['vite.config.js', 'vite.config.ts', 'vite.config.mjs'], defaultPort: 5173,
106
+ portRe: /port\s*[:=]\s*(\d+)/,
107
+ fingerprint: { body: /@vite\/client/ } },
108
+ { name: 'Astro', files: ['astro.config.js', 'astro.config.ts', 'astro.config.mjs'], defaultPort: 4321,
109
+ portRe: /port\s*[:=]\s*(\d+)/,
110
+ fingerprint: { body: /astro/i } },
111
+ { name: 'Angular', files: ['angular.json'], defaultPort: 4200,
112
+ portRe: /"port"\s*:\s*(\d+)/,
113
+ fingerprint: { body: /ng-version/i } },
114
+ { name: 'Remix', files: ['remix.config.js', 'remix.config.ts'], defaultPort: 3000,
115
+ portRe: /port\s*[:=]\s*(\d+)/,
116
+ fingerprint: { header: 'x-powered-by', value: /remix/i } },
117
+ ];
118
+
119
+ function detectFrameworkConfig(dir) {
120
+ let entries;
121
+ try { entries = fs.readdirSync(dir); } catch { return null; }
122
+ const entrySet = new Set(entries);
123
+
124
+ for (const cfg of FRAMEWORK_CONFIGS) {
125
+ const match = cfg.files.find(f => entrySet.has(f));
126
+ if (!match) continue;
127
+
128
+ const configPath = path.join(dir, match);
129
+ let port = cfg.defaultPort;
130
+ try {
131
+ const content = fs.readFileSync(configPath, 'utf-8');
132
+ const portMatch = content.match(cfg.portRe);
133
+ if (portMatch) port = parseInt(portMatch[1], 10);
134
+ } catch { /* use default */ }
135
+
136
+ return { name: cfg.name, port, configPath, fingerprint: cfg.fingerprint };
137
+ }
138
+ return null;
139
+ }
140
+
141
+ /**
142
+ * Check if a port is listening and optionally verify it matches the expected framework.
143
+ * Returns { listening: true, matched: true/false } or { listening: false }.
144
+ */
145
+ async function isPortListening(port, fingerprint = null) {
146
+ if (!fingerprint) {
147
+ // Simple TCP probe fallback
148
+ const net = await import('node:net');
149
+ return new Promise((resolve) => {
150
+ const sock = net.default.createConnection({ port, host: '127.0.0.1' });
151
+ sock.setTimeout(500);
152
+ sock.on('connect', () => { sock.destroy(); resolve({ listening: true, matched: true }); });
153
+ sock.on('error', () => resolve({ listening: false }));
154
+ sock.on('timeout', () => { sock.destroy(); resolve({ listening: false }); });
155
+ });
156
+ }
157
+
158
+ // HTTP probe with fingerprint matching
159
+ try {
160
+ const controller = new AbortController();
161
+ const timeout = setTimeout(() => controller.abort(), 2000);
162
+ const res = await fetch(`http://localhost:${port}/`, { signal: controller.signal, redirect: 'follow' });
163
+ clearTimeout(timeout);
164
+
165
+ // Check header fingerprint
166
+ if (fingerprint.header) {
167
+ const val = res.headers.get(fingerprint.header);
168
+ if (val && (!fingerprint.value || fingerprint.value.test(val))) {
169
+ return { listening: true, matched: true };
170
+ }
171
+ }
172
+
173
+ // Check body fingerprint
174
+ if (fingerprint.body) {
175
+ const body = await res.text();
176
+ if (fingerprint.body.test(body)) {
177
+ return { listening: true, matched: true };
178
+ }
179
+ }
180
+
181
+ // Port is listening but doesn't match the expected framework
182
+ return { listening: true, matched: false };
183
+ } catch {
184
+ return { listening: false };
185
+ }
186
+ }
187
+
188
+ export {
189
+ SKIP_DIRS,
190
+ SCANNABLE_EXTENSIONS,
191
+ HTML_EXTENSIONS,
192
+ walkDir,
193
+ resolveImport,
194
+ buildImportGraph,
195
+ FRAMEWORK_CONFIGS,
196
+ detectFrameworkConfig,
197
+ isPortListening,
198
+ };