@monoes/monomindcli 2.15.6 → 2.15.7

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 (180) hide show
  1. package/dist/src/orgrt/completion-gate.d.ts +15 -0
  2. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  3. package/dist/src/orgrt/completion-gate.js +59 -3
  4. package/dist/src/orgrt/completion-gate.js.map +1 -1
  5. package/dist/src/orgrt/daemon.d.ts +4 -0
  6. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  7. package/dist/src/orgrt/daemon.js +1 -0
  8. package/dist/src/orgrt/daemon.js.map +1 -1
  9. package/dist/src/orgrt/decisions.d.ts +17 -0
  10. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  11. package/dist/src/orgrt/decisions.js +104 -4
  12. package/dist/src/orgrt/decisions.js.map +1 -1
  13. package/dist/src/orgrt/review-packet.d.ts +1 -1
  14. package/dist/src/orgrt/review-packet.d.ts.map +1 -1
  15. package/dist/src/orgrt/review-packet.js +2 -2
  16. package/dist/src/orgrt/review-packet.js.map +1 -1
  17. package/dist/src/orgrt/session.d.ts +3 -0
  18. package/dist/src/orgrt/session.d.ts.map +1 -1
  19. package/dist/src/orgrt/session.js +6 -1
  20. package/dist/src/orgrt/session.js.map +1 -1
  21. package/dist/src/orgrt/task-dag.d.ts +3 -0
  22. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  23. package/dist/src/orgrt/task-dag.js +6 -0
  24. package/dist/src/orgrt/task-dag.js.map +1 -1
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +4 -4
  27. package/.claude/skills/monodesign/SKILL.md +0 -257
  28. package/.claude/skills/monodesign/adapt.md +0 -53
  29. package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +0 -100
  30. package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +0 -103
  31. package/.claude/skills/monodesign/animate.md +0 -65
  32. package/.claude/skills/monodesign/audit.md +0 -89
  33. package/.claude/skills/monodesign/bolder.md +0 -50
  34. package/.claude/skills/monodesign/clarify.md +0 -64
  35. package/.claude/skills/monodesign/colorize.md +0 -68
  36. package/.claude/skills/monodesign/craft.md +0 -51
  37. package/.claude/skills/monodesign/critique.md +0 -66
  38. package/.claude/skills/monodesign/delight.md +0 -47
  39. package/.claude/skills/monodesign/distill.md +0 -56
  40. package/.claude/skills/monodesign/document.md +0 -83
  41. package/.claude/skills/monodesign/extract.md +0 -74
  42. package/.claude/skills/monodesign/harden.md +0 -65
  43. package/.claude/skills/monodesign/init.md +0 -30
  44. package/.claude/skills/monodesign/layout.md +0 -36
  45. package/.claude/skills/monodesign/live.md +0 -34
  46. package/.claude/skills/monodesign/onboard.md +0 -50
  47. package/.claude/skills/monodesign/optimize.md +0 -64
  48. package/.claude/skills/monodesign/overdrive.md +0 -56
  49. package/.claude/skills/monodesign/polish.md +0 -68
  50. package/.claude/skills/monodesign/quieter.md +0 -57
  51. package/.claude/skills/monodesign/reference/adapt.md +0 -312
  52. package/.claude/skills/monodesign/reference/adapt.native.md +0 -58
  53. package/.claude/skills/monodesign/reference/android.md +0 -40
  54. package/.claude/skills/monodesign/reference/animate.md +0 -203
  55. package/.claude/skills/monodesign/reference/antipatterns-catalog.md +0 -410
  56. package/.claude/skills/monodesign/reference/audit.md +0 -135
  57. package/.claude/skills/monodesign/reference/audit.native.md +0 -139
  58. package/.claude/skills/monodesign/reference/bolder.md +0 -120
  59. package/.claude/skills/monodesign/reference/brand-workflow.md +0 -180
  60. package/.claude/skills/monodesign/reference/brand.md +0 -108
  61. package/.claude/skills/monodesign/reference/clarify.md +0 -288
  62. package/.claude/skills/monodesign/reference/codex.md +0 -105
  63. package/.claude/skills/monodesign/reference/cognitive-load.md +0 -106
  64. package/.claude/skills/monodesign/reference/color-and-contrast.md +0 -105
  65. package/.claude/skills/monodesign/reference/colorize.md +0 -257
  66. package/.claude/skills/monodesign/reference/component-specs.md +0 -260
  67. package/.claude/skills/monodesign/reference/component-states.md +0 -274
  68. package/.claude/skills/monodesign/reference/component-system.md +0 -358
  69. package/.claude/skills/monodesign/reference/copy-formulas.md +0 -160
  70. package/.claude/skills/monodesign/reference/craft.md +0 -123
  71. package/.claude/skills/monodesign/reference/critique.md +0 -780
  72. package/.claude/skills/monodesign/reference/delight.md +0 -302
  73. package/.claude/skills/monodesign/reference/design-principles.md +0 -246
  74. package/.claude/skills/monodesign/reference/distill.md +0 -111
  75. package/.claude/skills/monodesign/reference/document.md +0 -429
  76. package/.claude/skills/monodesign/reference/extract.md +0 -69
  77. package/.claude/skills/monodesign/reference/harden.md +0 -347
  78. package/.claude/skills/monodesign/reference/heuristics-scoring.md +0 -234
  79. package/.claude/skills/monodesign/reference/hooks.md +0 -92
  80. package/.claude/skills/monodesign/reference/image-prompts.md +0 -130
  81. package/.claude/skills/monodesign/reference/init.md +0 -221
  82. package/.claude/skills/monodesign/reference/interaction-design.md +0 -189
  83. package/.claude/skills/monodesign/reference/ios.md +0 -45
  84. package/.claude/skills/monodesign/reference/layout.md +0 -185
  85. package/.claude/skills/monodesign/reference/live.md +0 -710
  86. package/.claude/skills/monodesign/reference/motion-design.md +0 -109
  87. package/.claude/skills/monodesign/reference/onboard.md +0 -234
  88. package/.claude/skills/monodesign/reference/optimize.md +0 -258
  89. package/.claude/skills/monodesign/reference/overdrive.md +0 -130
  90. package/.claude/skills/monodesign/reference/personas.md +0 -179
  91. package/.claude/skills/monodesign/reference/polish.md +0 -241
  92. package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +0 -108
  93. package/.claude/skills/monodesign/reference/product.md +0 -60
  94. package/.claude/skills/monodesign/reference/quieter.md +0 -99
  95. package/.claude/skills/monodesign/reference/responsive-design.md +0 -114
  96. package/.claude/skills/monodesign/reference/shape.md +0 -165
  97. package/.claude/skills/monodesign/reference/spatial-design.md +0 -100
  98. package/.claude/skills/monodesign/reference/teach.md +0 -10
  99. package/.claude/skills/monodesign/reference/token-architecture.md +0 -222
  100. package/.claude/skills/monodesign/reference/typeset.md +0 -301
  101. package/.claude/skills/monodesign/reference/typography.md +0 -159
  102. package/.claude/skills/monodesign/reference/ux-research.md +0 -143
  103. package/.claude/skills/monodesign/reference/ux-rules.md +0 -211
  104. package/.claude/skills/monodesign/reference/ux-writing.md +0 -107
  105. package/.claude/skills/monodesign/scripts/command-metadata.json +0 -94
  106. package/.claude/skills/monodesign/scripts/context-signals.mjs +0 -260
  107. package/.claude/skills/monodesign/scripts/context.mjs +0 -1065
  108. package/.claude/skills/monodesign/scripts/critique-storage.mjs +0 -416
  109. package/.claude/skills/monodesign/scripts/detect-csp.mjs +0 -193
  110. package/.claude/skills/monodesign/scripts/detect.mjs +0 -33
  111. package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +0 -1960
  112. package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +0 -321
  113. package/.claude/skills/monodesign/scripts/detector/design-system.mjs +0 -814
  114. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +0 -5628
  115. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +0 -50
  116. package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +0 -259
  117. package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +0 -339
  118. package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +0 -636
  119. package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +0 -1016
  120. package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +0 -253
  121. package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -198
  122. package/.claude/skills/monodesign/scripts/detector/findings.mjs +0 -12
  123. package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +0 -181
  124. package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +0 -373
  125. package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +0 -426
  126. package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +0 -198
  127. package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +0 -166
  128. package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +0 -563
  129. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +0 -3024
  130. package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +0 -124
  131. package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +0 -101
  132. package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +0 -30
  133. package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +0 -148
  134. package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +0 -7
  135. package/.claude/skills/monodesign/scripts/hook-admin.mjs +0 -694
  136. package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +0 -516
  137. package/.claude/skills/monodesign/scripts/hook-lib.mjs +0 -1785
  138. package/.claude/skills/monodesign/scripts/hook.mjs +0 -61
  139. package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +0 -809
  140. package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +0 -69
  141. package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +0 -640
  142. package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +0 -129
  143. package/.claude/skills/monodesign/scripts/lib/provider.mjs +0 -4
  144. package/.claude/skills/monodesign/scripts/lib/target-args.mjs +0 -42
  145. package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +0 -50
  146. package/.claude/skills/monodesign/scripts/live/completion.mjs +0 -19
  147. package/.claude/skills/monodesign/scripts/live/event-validation.mjs +0 -137
  148. package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +0 -458
  149. package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +0 -939
  150. package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +0 -357
  151. package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +0 -152
  152. package/.claude/skills/monodesign/scripts/live/session-store.mjs +0 -293
  153. package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +0 -826
  154. package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +0 -279
  155. package/.claude/skills/monodesign/scripts/live/ui-core.mjs +0 -180
  156. package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +0 -36
  157. package/.claude/skills/monodesign/scripts/live-accept.mjs +0 -812
  158. package/.claude/skills/monodesign/scripts/live-browser-dom.js +0 -147
  159. package/.claude/skills/monodesign/scripts/live-browser-session.js +0 -124
  160. package/.claude/skills/monodesign/scripts/live-browser.js +0 -11213
  161. package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +0 -1241
  162. package/.claude/skills/monodesign/scripts/live-complete.mjs +0 -75
  163. package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +0 -683
  164. package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +0 -51
  165. package/.claude/skills/monodesign/scripts/live-inject.mjs +0 -596
  166. package/.claude/skills/monodesign/scripts/live-insert.mjs +0 -272
  167. package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +0 -363
  168. package/.claude/skills/monodesign/scripts/live-poll.mjs +0 -384
  169. package/.claude/skills/monodesign/scripts/live-resume.mjs +0 -94
  170. package/.claude/skills/monodesign/scripts/live-server.mjs +0 -1210
  171. package/.claude/skills/monodesign/scripts/live-status.mjs +0 -61
  172. package/.claude/skills/monodesign/scripts/live-target.mjs +0 -30
  173. package/.claude/skills/monodesign/scripts/live-wrap.mjs +0 -884
  174. package/.claude/skills/monodesign/scripts/live.mjs +0 -297
  175. package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +0 -14
  176. package/.claude/skills/monodesign/scripts/palette.mjs +0 -635
  177. package/.claude/skills/monodesign/scripts/pin.mjs +0 -221
  178. package/.claude/skills/monodesign/shape.md +0 -71
  179. package/.claude/skills/monodesign/teach.md +0 -18
  180. package/.claude/skills/monodesign/typeset.md +0 -59
@@ -1,253 +0,0 @@
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
- checkElementImageDimensions,
32
- checkElementSmallTouchTarget,
33
- checkFocusVisible,
34
- checkHoverOnlyAffordance,
35
- checkDarkSchemeContrast,
36
- resolveBackground,
37
- resolveBorderRadiusPx,
38
- } from '../../rules/checks.mjs';
39
- import { filterByProviders } from '../../registry/antipatterns.mjs';
40
- import { detectText, runTextContentAnalyzers } from '../regex/detect-text.mjs';
41
- import {
42
- StaticDocument,
43
- buildStaticStyleMap,
44
- buildStaticWindow,
45
- collectStaticCssText,
46
- } from './css-cascade.mjs';
47
-
48
- function checkStaticPageTypography(document, window) {
49
- const findings = [];
50
- const fonts = new Set();
51
- const overusedFound = new Set();
52
- for (const el of document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, td, th, dd, blockquote, figcaption, a, button, label, span, div')) {
53
- const hasText = el.childNodes.some(n => n.nodeType === 3 && n.textContent.trim().length > 0);
54
- if (!hasText) continue;
55
- const ff = window.getComputedStyle(el).fontFamily || '';
56
- const stack = ff.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
57
- const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
58
- if (!primary) continue;
59
- fonts.add(primary);
60
- if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
61
- }
62
- for (const font of overusedFound) {
63
- findings.push({ id: 'overused-font', snippet: `Primary font: ${font}` });
64
- }
65
- if (fonts.size === 1 && document.querySelectorAll('*').length >= 20) {
66
- findings.push({ id: 'single-font', snippet: `only font used is ${[...fonts][0]}` });
67
- }
68
- const sizes = new Set();
69
- for (const el of document.querySelectorAll('h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, label, button, div')) {
70
- const fontSize = parseFloat(window.getComputedStyle(el).fontSize);
71
- if (fontSize >= 8 && fontSize < 200) sizes.add(Math.round(fontSize * 10) / 10);
72
- }
73
- if (sizes.size >= 3) {
74
- const sorted = [...sizes].sort((a, b) => a - b);
75
- const ratio = sorted[sorted.length - 1] / sorted[0];
76
- if (ratio < 2.0) {
77
- findings.push({ id: 'flat-type-hierarchy', snippet: `Sizes: ${sorted.map(s => `${s}px`).join(', ')} (ratio ${ratio.toFixed(1)}:1)` });
78
- }
79
- }
80
- return findings;
81
- }
82
-
83
- function checkElementBrokenImage(el) {
84
- const src = el.getAttribute?.('src') ?? el.attribs?.src;
85
- // Missing src attribute entirely
86
- if (src === undefined || src === null) {
87
- return [{ id: 'broken-image', snippet: '<img> with no src attribute' }];
88
- }
89
- const trimmed = String(src).trim();
90
- // Empty or placeholder-only src values
91
- if (trimmed === '' || trimmed === '#') {
92
- return [{ id: 'broken-image', snippet: `<img src="${src}">` }];
93
- }
94
- return [];
95
- }
96
-
97
- const STATIC_ELEMENT_RULES = [
98
- { id: 'border-rules', selector: '*', run: (el, tag, style, window, _customPropMap) => checkElementBorders(tag, style, null, resolveBorderRadiusPx(el, style, parseFloat(style.width) || 0, window)) },
99
- { id: 'color-rules', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementColors(el, style, tag, window, customPropMap, false) },
100
- { id: 'dark-glow', selector: '*', run: (el, tag, style, window, customPropMap) => checkElementGlow(tag, style, resolveBackground(el.parentElement || el, window, customPropMap)) },
101
- { id: 'motion-rules', selector: '*', run: (_el, tag, style) => checkElementMotion(tag, style) },
102
- { id: 'icon-tile-stack', selector: 'h1,h2,h3,h4,h5,h6', run: (el, tag, _style, window) => checkElementIconTile(el, tag, window) },
103
- { id: 'italic-serif-display', selector: 'h1,h2', run: (el, tag, style) => checkElementItalicSerif(el, style, tag) },
104
- { id: 'hero-eyebrow-chip', selector: 'h1', run: (el, tag, style, window, customPropMap) => checkElementHeroEyebrow(el, style, tag, window, customPropMap) },
105
- { id: 'broken-image', selector: 'img', run: (el) => checkElementBrokenImage(el) },
106
- { id: 'quality-rules', selector: '*', run: (el, tag, style, window) => checkElementQuality(el, style, tag, window) },
107
- { id: 'oversized-h1', selector: 'h1', run: (el, tag, style, window) => checkElementOversizedH1(el, style, tag, window) },
108
- { id: 'clipped-overflow-container', selector: '*', run: (el, tag, style, window) => checkElementClippedOverflow(el, style, tag, window) },
109
- { id: 'gpt-thin-border-wide-shadow', selector: '*', run: (el, _tag, style) => checkElementGptBorderShadow(el, style) },
110
- { id: 'image-missing-dimensions', selector: 'img', run: (el, _tag, style) => checkElementImageDimensions(el, style) },
111
- { id: 'small-touch-target', selector: 'a,button,input,select,summary,[role=button],[role=link],[role=menuitem],[role=tab],[role=switch]', run: (el, tag, style) => checkElementSmallTouchTarget(el, style, tag) },
112
- ];
113
-
114
- async function detectHtml(filePath, options = {}) {
115
- const profile = options?.profile;
116
- const html = profileStep(profile, {
117
- engine: 'static-html',
118
- phase: 'setup',
119
- ruleId: 'read-html',
120
- target: filePath,
121
- }, () => fs.readFileSync(filePath, 'utf-8'));
122
-
123
- let modules;
124
- try {
125
- modules = await profileStepAsync(profile, {
126
- engine: 'static-html',
127
- phase: 'setup',
128
- ruleId: 'import-static-parser',
129
- target: filePath,
130
- }, async () => {
131
- const [htmlparser2, cssSelect, csstree, domutils] = await Promise.all([
132
- import('htmlparser2'),
133
- import('css-select'),
134
- import('css-tree'),
135
- import('domutils'),
136
- ]);
137
- return {
138
- parseDocument: htmlparser2.parseDocument,
139
- selectAll: cssSelect.selectAll,
140
- selectOne: cssSelect.selectOne,
141
- is: cssSelect.is,
142
- csstree,
143
- domutils,
144
- };
145
- });
146
- } catch {
147
- return detectText(html, filePath, options);
148
- }
149
-
150
- const resolvedPath = path.resolve(filePath);
151
- const fileDir = path.dirname(resolvedPath);
152
- const root = profileStep(profile, {
153
- engine: 'static-html',
154
- phase: 'parse-html',
155
- ruleId: 'parse-document',
156
- target: filePath,
157
- }, () => modules.parseDocument(html, { lowerCaseAttributeNames: false, lowerCaseTags: true }));
158
-
159
- const cssText = collectStaticCssText(root, fileDir, profile, filePath, modules);
160
- const document = new StaticDocument(root, modules);
161
- buildStaticStyleMap(root, document, cssText, modules, profile, filePath);
162
- const window = buildStaticWindow(document);
163
-
164
- const customPropMap = null;
165
-
166
- const findings = [];
167
- const runElementCheck = (ruleId, callback) => profile
168
- ? profileFindings(profile, { engine: 'static-html', phase: 'element', ruleId, target: filePath }, callback)
169
- : callback();
170
-
171
- const visitedByRule = new Map();
172
- for (const rule of STATIC_ELEMENT_RULES) {
173
- const elements = document.querySelectorAll(rule.selector);
174
- visitedByRule.set(rule.id, elements.length);
175
- for (const el of elements) {
176
- const tag = el.tagName.toLowerCase();
177
- const style = window.getComputedStyle(el);
178
- for (const f of runElementCheck(rule.id, () => rule.run(el, tag, style, window, customPropMap))) {
179
- findings.push(finding(f.id, filePath, f.snippet));
180
- }
181
- }
182
- }
183
-
184
- if (options?.designSystem) {
185
- const sourceDesignFindings = profileFindings(profile, {
186
- engine: 'static-html',
187
- phase: 'source',
188
- ruleId: 'design-system',
189
- target: filePath,
190
- }, () => checkSourceDesignSystem(html, filePath, { designSystem: options.designSystem }));
191
- const staticDesignFindings = profileFindings(profile, {
192
- engine: 'static-html',
193
- phase: 'page',
194
- ruleId: 'design-system',
195
- target: filePath,
196
- }, () => collectStaticDesignSystemFindings(document, window, filePath, options.designSystem));
197
- findings.push(...mergeDesignSystemFindings(staticDesignFindings, sourceDesignFindings));
198
- }
199
-
200
- if (isFullPage(html)) {
201
- const runPageCheck = (ruleId, callback) => profile
202
- ? profileFindings(profile, { engine: 'static-html', phase: 'page', ruleId, target: filePath }, callback)
203
- : callback();
204
- for (const f of runPageCheck('typography-rules', () => checkStaticPageTypography(document, window))) {
205
- findings.push(finding(f.id, filePath, f.snippet));
206
- }
207
- for (const f of runPageCheck('repeated-section-kickers', () => checkRepeatedSectionKickersFromDoc(document, window))) {
208
- findings.push(finding(f.id, filePath, f.snippet));
209
- }
210
- for (const f of runPageCheck('layout-rules', () => checkPageLayout(document, window))) {
211
- findings.push(finding(f.id, filePath, f.snippet));
212
- }
213
- for (const f of runPageCheck('cream-palette', () => checkCreamPalette(document, window))) {
214
- findings.push(finding(f.id, filePath, f.snippet));
215
- }
216
- for (const f of runPageCheck('skipped-heading', () => checkPageQualityFromDoc(document))) {
217
- findings.push(finding(f.id, filePath, f.snippet));
218
- }
219
- // Stylesheet-level accessibility rules operate on the concatenated CSS
220
- // text (<style> blocks + linked sheets) — :hover / :focus-visible /
221
- // prefers-color-scheme conditions can't be read off a resting element.
222
- for (const f of runPageCheck('missing-focus-visible', () => checkFocusVisible(cssText))) {
223
- findings.push(finding(f.id, filePath, f.snippet));
224
- }
225
- for (const f of runPageCheck('hover-only-affordance', () => checkHoverOnlyAffordance(cssText))) {
226
- findings.push(finding(f.id, filePath, f.snippet));
227
- }
228
- for (const f of runPageCheck('dark-scheme-contrast-blindspot', () => checkDarkSchemeContrast(cssText))) {
229
- findings.push(finding(f.id, filePath, f.snippet));
230
- }
231
- for (const f of runPageCheck('html-patterns', () => checkHtmlPatterns(html).filter(item =>
232
- item.id !== 'bounce-easing' && item.id !== 'layout-transition'
233
- ))) {
234
- findings.push(finding(f.id, filePath, f.snippet));
235
- }
236
- // Text-content analyzers (em-dash overuse, marketing buzzwords,
237
- // numbered section markers, aphoristic cadence) live in the regex
238
- // engine. Call them from here so .html files get the same coverage
239
- // as .css/.tsx files. These are scoped to text content only and
240
- // don't overlap with static-html's element/page rules.
241
- for (const f of runPageCheck('text-content', () => runTextContentAnalyzers(html, filePath, options))) {
242
- findings.push(finding(f.antipattern, filePath, f.snippet));
243
- }
244
- }
245
-
246
- const byProvider = filterByProviders(findings, options.providers);
247
- // Static-HTML findings carry no line number, so only whole-file
248
- // `monodesign-disable` directives apply here — exactly the standalone-document
249
- // waiver this primitive targets. Bypassed by `--no-config` / `--no-inline-ignores`.
250
- return options?.inlineIgnores === false ? byProvider : applyInlineIgnores(byProvider, html);
251
- }
252
-
253
- export { checkStaticPageTypography, STATIC_ELEMENT_RULES, detectHtml };
@@ -1,198 +0,0 @@
1
- //
2
- // Visual-contrast pixel fallback. `page` is the driver page abstraction from
3
- // ../browser/drivers.mjs (a raw puppeteer Page also satisfies it): it only
4
- // needs `evaluate(fn, arg)` roundtrips and `screenshot({ encoding: 'base64',
5
- // clip, captureBeyondViewport })` returning a base64 PNG string. The logic is
6
- // driver-agnostic: hide the glyphs via CSS, screenshot the clip twice, and
7
- // diff the pixels in-page on a canvas. Both the monobrowse (CDP
8
- // Page.captureScreenshot + Runtime.evaluate) and puppeteer drivers support
9
- // this fully.
10
- function sanitizeScreenshotClip(clip, viewport) {
11
- if (!clip) return null;
12
- const x = Math.max(0, Math.floor(clip.x || 0));
13
- const y = Math.max(0, Math.floor(clip.y || 0));
14
- const width = Math.min(
15
- Math.max(1, Math.ceil(clip.width || 0)),
16
- Math.max(1, viewport?.width || 1600),
17
- );
18
- const height = Math.min(
19
- Math.max(1, Math.ceil(clip.height || 0)),
20
- 320,
21
- );
22
- if (width < 1 || height < 1) return null;
23
- return { x, y, width, height };
24
- }
25
-
26
- async function compareScreenshotContrast(page, beforeBase64, afterBase64, candidate) {
27
- return page.evaluate(async ({ beforeBase64, afterBase64, candidate }) => {
28
- const loadImage = (base64) => new Promise((resolve, reject) => {
29
- const img = new Image();
30
- img.onload = () => resolve(img);
31
- img.onerror = () => reject(new Error('Could not decode contrast screenshot'));
32
- img.src = `data:image/png;base64,${base64}`;
33
- });
34
- const [before, after] = await Promise.all([loadImage(beforeBase64), loadImage(afterBase64)]);
35
- const width = Math.min(before.width, after.width);
36
- const height = Math.min(before.height, after.height);
37
- if (width < 1 || height < 1) return null;
38
-
39
- const canvas = document.createElement('canvas');
40
- canvas.width = width;
41
- canvas.height = height;
42
- const ctx = canvas.getContext('2d', { willReadFrequently: true });
43
- if (!ctx) return null;
44
-
45
- ctx.drawImage(before, 0, 0, width, height);
46
- const beforePixels = ctx.getImageData(0, 0, width, height).data;
47
- ctx.clearRect(0, 0, width, height);
48
- ctx.drawImage(after, 0, 0, width, height);
49
- const afterPixels = ctx.getImageData(0, 0, width, height).data;
50
-
51
- const luminance = ({ r, g, b }) => {
52
- const convert = c => {
53
- const v = c / 255;
54
- return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
55
- };
56
- return 0.2126 * convert(r) + 0.7152 * convert(g) + 0.0722 * convert(b);
57
- };
58
- const ratio = (a, b) => {
59
- const l1 = luminance(a);
60
- const l2 = luminance(b);
61
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
62
- };
63
-
64
- const cssTextColor = candidate.textColor && !candidate.preferRenderedForeground
65
- ? {
66
- r: candidate.textColor.r,
67
- g: candidate.textColor.g,
68
- b: candidate.textColor.b,
69
- }
70
- : null;
71
- const ratios = [];
72
- let glyphPixels = 0;
73
- let strongestDelta = 0;
74
- for (let i = 0; i < beforePixels.length; i += 4) {
75
- const delta = Math.abs(beforePixels[i] - afterPixels[i])
76
- + Math.abs(beforePixels[i + 1] - afterPixels[i + 1])
77
- + Math.abs(beforePixels[i + 2] - afterPixels[i + 2])
78
- + Math.abs(beforePixels[i + 3] - afterPixels[i + 3]);
79
- strongestDelta = Math.max(strongestDelta, delta);
80
- if (delta < 10) continue;
81
- glyphPixels++;
82
- const fg = cssTextColor || {
83
- r: beforePixels[i],
84
- g: beforePixels[i + 1],
85
- b: beforePixels[i + 2],
86
- };
87
- const bg = {
88
- r: afterPixels[i],
89
- g: afterPixels[i + 1],
90
- b: afterPixels[i + 2],
91
- };
92
- ratios.push(ratio(fg, bg));
93
- }
94
-
95
- if (ratios.length < 8) {
96
- return {
97
- glyphPixels,
98
- strongestDelta,
99
- worstRatio: null,
100
- p10Ratio: null,
101
- medianRatio: null,
102
- };
103
- }
104
-
105
- ratios.sort((a, b) => a - b);
106
- const pick = pct => ratios[Math.min(ratios.length - 1, Math.max(0, Math.floor((pct / 100) * ratios.length)))];
107
- return {
108
- glyphPixels,
109
- strongestDelta,
110
- worstRatio: ratios[0],
111
- p10Ratio: pick(10),
112
- medianRatio: pick(50),
113
- };
114
- }, { beforeBase64, afterBase64, candidate });
115
- }
116
-
117
- async function captureVisualContrastCandidate(page, candidate, viewport) {
118
- const clip = sanitizeScreenshotClip(candidate.clip, viewport);
119
- if (!clip) return null;
120
-
121
- const beforeBase64 = await page.screenshot({
122
- encoding: 'base64',
123
- clip,
124
- captureBeyondViewport: true,
125
- });
126
- const token = `monodesign-contrast-${Date.now()}-${Math.random().toString(36).slice(2)}`;
127
- const applied = await page.evaluate(({ selector, token, backgroundClipText }) => {
128
- let el;
129
- try {
130
- el = document.querySelector(selector);
131
- } catch {
132
- return false;
133
- }
134
- if (!el) return false;
135
- let style = document.getElementById('monodesign-visual-contrast-hide-style');
136
- if (!style) {
137
- style = document.createElement('style');
138
- style.id = 'monodesign-visual-contrast-hide-style';
139
- style.textContent = [
140
- '[data-monodesign-visual-contrast-target] {',
141
- ' color: transparent !important;',
142
- ' -webkit-text-fill-color: transparent !important;',
143
- ' text-shadow: none !important;',
144
- '}',
145
- '[data-monodesign-visual-contrast-target][data-monodesign-bgclip-text="true"] {',
146
- ' background-image: none !important;',
147
- '}',
148
- ].join('\n');
149
- document.head.appendChild(style);
150
- }
151
- el.setAttribute('data-monodesign-visual-contrast-target', token);
152
- if (backgroundClipText) el.setAttribute('data-monodesign-bgclip-text', 'true');
153
- return true;
154
- }, {
155
- selector: candidate.selector,
156
- token,
157
- backgroundClipText: candidate.backgroundClipText,
158
- });
159
- if (!applied) return null;
160
-
161
- let afterBase64;
162
- try {
163
- afterBase64 = await page.screenshot({
164
- encoding: 'base64',
165
- clip,
166
- captureBeyondViewport: true,
167
- });
168
- } finally {
169
- await page.evaluate(({ selector }) => {
170
- try {
171
- const el = document.querySelector(selector);
172
- if (el) {
173
- el.removeAttribute('data-monodesign-visual-contrast-target');
174
- el.removeAttribute('data-monodesign-bgclip-text');
175
- }
176
- } catch {
177
- // Ignore invalid or stale selectors during cleanup.
178
- }
179
- }, { selector: candidate.selector }).catch(() => {});
180
- }
181
-
182
- const metrics = await compareScreenshotContrast(page, beforeBase64, afterBase64, candidate);
183
- if (!metrics || !Number.isFinite(metrics.p10Ratio) || metrics.glyphPixels < 8) return null;
184
- const measuredRatio = metrics.p10Ratio;
185
- if (measuredRatio >= candidate.threshold) return null;
186
- const textLabel = candidate.text ? ` "${candidate.text}"` : '';
187
- const reasonLabel = (candidate.reasons || []).slice(0, 3).join(', ') || 'visual background';
188
- return {
189
- id: 'low-contrast',
190
- snippet: `pixel contrast ${measuredRatio.toFixed(1)}:1 median ${metrics.medianRatio.toFixed(1)}:1 (need ${candidate.threshold}:1) on ${reasonLabel}${textLabel}`,
191
- };
192
- }
193
-
194
- export {
195
- sanitizeScreenshotClip,
196
- compareScreenshotContrast,
197
- captureVisualContrastCandidate,
198
- };
@@ -1,12 +0,0 @@
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 };
@@ -1,181 +0,0 @@
1
- /**
2
- * CSS region extraction and declaration scanning for the auto-fix engine.
3
- *
4
- * Fixers never parse a full DOM — they operate on the raw source text of the
5
- * "CSS-shaped" regions of a file:
6
- * - whole file for .css/.scss/.sass/.less
7
- * - <style> blocks and style="" attributes for HTML-family files
8
- * - styled-components / emotion template literals for JS/TS files
9
- *
10
- * All offsets returned here are absolute within the original file content, so
11
- * edits computed against a region can be applied directly to the file.
12
- */
13
-
14
- const CSS_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
15
- const HTML_FAMILY_EXTENSIONS = new Set(['.html', '.htm', '.vue', '.svelte', '.astro']);
16
- const JS_EXTENSIONS = new Set(['.js', '.ts', '.jsx', '.tsx', '.mjs', '.cjs']);
17
-
18
- /**
19
- * A region of file content that can be scanned as CSS declarations.
20
- * kind:
21
- * 'css' — full stylesheet syntax (selectors + blocks)
22
- * 'style-attr' — a bare declaration list from a style="" attribute;
23
- * selectorHint carries the owning tag name
24
- */
25
- function extractCssRegions(content, ext) {
26
- ext = (ext || '').toLowerCase();
27
- if (CSS_EXTENSIONS.has(ext)) {
28
- return [{ start: 0, end: content.length, text: content, kind: 'css', selectorHint: null }];
29
- }
30
-
31
- const regions = [];
32
- if (HTML_FAMILY_EXTENSIONS.has(ext)) {
33
- const styleBlockRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
34
- let m;
35
- while ((m = styleBlockRe.exec(content)) !== null) {
36
- const start = m.index + m[0].indexOf(m[1]);
37
- regions.push({ start, end: start + m[1].length, text: m[1], kind: 'css', selectorHint: null });
38
- }
39
- const styleAttrRe = /<([a-zA-Z][\w-]*)\b[^>]*?\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi;
40
- while ((m = styleAttrRe.exec(content)) !== null) {
41
- const value = m[3] !== undefined ? m[3] : m[4];
42
- if (!value) continue;
43
- const start = m.index + m[0].length - value.length - 1; // inside the closing quote
44
- regions.push({
45
- start,
46
- end: start + value.length,
47
- text: value,
48
- kind: 'style-attr',
49
- selectorHint: m[1].toLowerCase(),
50
- });
51
- }
52
- return regions;
53
- }
54
-
55
- if (JS_EXTENSIONS.has(ext)) {
56
- const cssInJsRe = /(?:styled(?:\.\w+|\([^)]+\))|css)\s*`([\s\S]*?)`/g;
57
- let m;
58
- while ((m = cssInJsRe.exec(content)) !== null) {
59
- const start = m.index + m[0].indexOf('`') + 1;
60
- regions.push({ start, end: start + m[1].length, text: m[1], kind: 'css', selectorHint: null });
61
- }
62
- return regions;
63
- }
64
-
65
- return regions;
66
- }
67
-
68
- /**
69
- * Find every `prop: value` declaration in a CSS-shaped text. Returns local
70
- * offsets (relative to the given text):
71
- * { declStart, valueStart, valueEnd, value, terminator }
72
- * `value` is the raw trimmed value text (may include !important).
73
- * `terminator` is the index just past the trailing `;` when present,
74
- * otherwise valueEnd.
75
- */
76
- function findDeclarations(text, prop) {
77
- const re = new RegExp(`(^|[{;])(\\s*)(${prop})\\s*:\\s*([^;{}]*)`, 'gi');
78
- const results = [];
79
- let m;
80
- while ((m = re.exec(text)) !== null) {
81
- const declStart = m.index + m[1].length + m[2].length;
82
- const rawValue = m[4];
83
- const trimmed = rawValue.replace(/\s+$/, '');
84
- const valueStart = m.index + m[0].length - rawValue.length;
85
- const valueEnd = valueStart + trimmed.length;
86
- const terminator = text[m.index + m[0].length] === ';'
87
- ? m.index + m[0].length + 1
88
- : valueEnd;
89
- results.push({ declStart, valueStart, valueEnd, value: trimmed.trim(), terminator });
90
- }
91
- return results;
92
- }
93
-
94
- /**
95
- * The enclosing `{ ... }` block for a declaration at `index`, with its
96
- * selector text. For bare declaration lists (style attributes) there is no
97
- * block — the whole text is the body and selector is null.
98
- */
99
- function declBlockInfo(text, index) {
100
- let i = index - 1;
101
- let depth = 0;
102
- while (i >= 0) {
103
- const ch = text[i];
104
- if (ch === '}') depth++;
105
- else if (ch === '{') {
106
- if (depth === 0) break;
107
- depth--;
108
- }
109
- i--;
110
- }
111
- if (i < 0) {
112
- return { bodyStart: 0, bodyEnd: text.length, body: text, selector: null };
113
- }
114
- const braceIdx = i;
115
- let s = braceIdx - 1;
116
- while (s >= 0 && !'};{'.includes(text[s])) s--;
117
- const selector = text.slice(s + 1, braceIdx).trim();
118
- let j = braceIdx + 1;
119
- let d = 0;
120
- while (j < text.length) {
121
- const ch = text[j];
122
- if (ch === '{') d++;
123
- else if (ch === '}') {
124
- if (d === 0) break;
125
- d--;
126
- }
127
- j++;
128
- }
129
- return { bodyStart: braceIdx + 1, bodyEnd: j, body: text.slice(braceIdx + 1, j), selector };
130
- }
131
-
132
- /** Parse a single CSS length/number value, tolerating !important. */
133
- function parseCssValue(raw) {
134
- const important = /!\s*important/i.test(raw);
135
- const cleaned = raw.replace(/!\s*important/i, '').trim();
136
- const m = cleaned.match(/^(-?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i);
137
- if (!m) return null;
138
- return { num: parseFloat(m[1]), unit: (m[2] || '').toLowerCase(), important };
139
- }
140
-
141
- /** Resolve a block's font-size to px when statically computable, else null. */
142
- function blockFontSizePx(body) {
143
- const decls = findDeclarations(body, 'font-size');
144
- if (decls.length === 0) return null;
145
- const parsed = parseCssValue(decls[decls.length - 1].value);
146
- if (!parsed) return null;
147
- if (parsed.unit === 'px') return parsed.num;
148
- if (parsed.unit === 'rem') return parsed.num * 16;
149
- return null;
150
- }
151
-
152
- /** Split a CSS value list on top-level commas (paren-aware, for cubic-bezier). */
153
- function splitTopLevel(value) {
154
- const parts = [];
155
- let depth = 0;
156
- let current = '';
157
- for (const ch of value) {
158
- if (ch === '(') depth++;
159
- else if (ch === ')') depth--;
160
- if (ch === ',' && depth === 0) {
161
- parts.push(current.trim());
162
- current = '';
163
- } else {
164
- current += ch;
165
- }
166
- }
167
- if (current.trim()) parts.push(current.trim());
168
- return parts;
169
- }
170
-
171
- export {
172
- CSS_EXTENSIONS,
173
- HTML_FAMILY_EXTENSIONS,
174
- JS_EXTENSIONS,
175
- extractCssRegions,
176
- findDeclarations,
177
- declBlockInfo,
178
- parseCssValue,
179
- blockFontSizePx,
180
- splitTopLevel,
181
- };