medesign 1.4.0 → 1.6.1
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/README.md +90 -72
- package/bin/mebolder.js +4 -0
- package/bin/medesign.js +370 -35
- package/bin/melint.js +4 -0
- package/bin/mepolish.js +4 -0
- package/bin/mequiet.js +4 -0
- package/bin/mesearch.js +4 -0
- package/bin/mesnapshot.js +4 -0
- package/examples/cadastral-qaqc-slide.html +577 -0
- package/examples/executive-summary-report.html +597 -0
- package/examples/executive-summary-report.pdf +0 -0
- package/examples/geospatial-banner-1200x630.html +370 -0
- package/examples/geospatial-banner-1200x630.svg +149 -0
- package/examples/linear-issue-board.html +1273 -0
- package/examples/snapshots/cadastral-qaqc-slide-desktop-1440x900.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-mobile-390x844.png +0 -0
- package/examples/snapshots/cadastral-qaqc-slide-tablet-820x1180.png +0 -0
- package/examples/snapshots/executive-summary-report-desktop-1440x900.png +0 -0
- package/examples/snapshots/executive-summary-report-mobile-390x844.png +0 -0
- package/examples/snapshots/executive-summary-report-tablet-820x1180.png +0 -0
- package/examples/snapshots/geospatial-banner-1200x630-og-banner-1200x630.png +0 -0
- package/examples/snapshots/linear-issue-board-desktop-1440x900.png +0 -0
- package/examples/snapshots/linear-issue-board-mobile-390x844.png +0 -0
- package/examples/snapshots/linear-issue-board-tablet-820x1180.png +0 -0
- package/examples/snapshots/spotify-web-player-desktop-1440x900.png +0 -0
- package/examples/snapshots/spotify-web-player-mobile-390x844.png +0 -0
- package/examples/snapshots/spotify-web-player-tablet-820x1180.png +0 -0
- package/examples/spotify-web-player.html +1446 -0
- package/package.json +16 -4
- package/presets/metha/guidelines.md +26 -17
- package/presets/metha/preset.json +16 -16
- package/references/ai-tells.md +9 -2
- package/references/brand-design-tokens.md +27 -28
- package/references/brief-intake.md +90 -0
- package/references/catalog.json +1031 -1023
- package/references/cli-architecture.md +1 -1
- package/references/compositor-smoothness.md +161 -0
- package/references/design-core.md +11 -4
- package/references/executive-reports.md +234 -0
- package/references/image-mockup-direction.md +53 -53
- package/references/image-to-code.md +46 -46
- package/references/modern-craft-invariants.md +55 -9
- package/references/prompt-templates.md +49 -0
- package/references/quality-gate.md +42 -12
- package/references/typography-thai-latin.md +206 -0
- package/references/view-transitions-engine.md +89 -0
- package/references/web-retrofit-protocol.md +103 -0
- package/scripts/export-tokens.js +419 -403
- package/tests/browser-audit.js +463 -442
- package/tests/linter.js +49 -4
- package/tests/snapshot.js +266 -0
package/bin/medesign.js
CHANGED
|
@@ -19,10 +19,28 @@
|
|
|
19
19
|
const fs = require('fs');
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const { spawnSync } = require('child_process');
|
|
22
|
+
const pkg = require('../package.json');
|
|
22
23
|
|
|
23
24
|
const rootDir = path.join(__dirname, '..');
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const rawArgs = process.argv.slice(2);
|
|
26
|
+
const invokedBin = path.basename(process.argv[1] || '', path.extname(process.argv[1] || '')).toLowerCase();
|
|
27
|
+
|
|
28
|
+
let args = rawArgs;
|
|
29
|
+
let command = rawArgs[0] || 'help';
|
|
30
|
+
|
|
31
|
+
const aliasMap = {
|
|
32
|
+
mepolish: 'polish',
|
|
33
|
+
mebolder: 'bolder',
|
|
34
|
+
mequiet: 'quiet',
|
|
35
|
+
melint: 'lint',
|
|
36
|
+
mesearch: 'search',
|
|
37
|
+
mesnapshot: 'snapshot'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (aliasMap[invokedBin] && rawArgs[0] !== aliasMap[invokedBin]) {
|
|
41
|
+
command = aliasMap[invokedBin];
|
|
42
|
+
args = [command, ...rawArgs];
|
|
43
|
+
}
|
|
26
44
|
|
|
27
45
|
const ANSI_RESET = '\x1b[0m';
|
|
28
46
|
const ANSI_BOLD = '\x1b[1m';
|
|
@@ -34,7 +52,7 @@ const ANSI_GRAY = '\x1b[90m';
|
|
|
34
52
|
|
|
35
53
|
function printHelp() {
|
|
36
54
|
console.log(`
|
|
37
|
-
${ANSI_BOLD}ME-DESIGN CLI
|
|
55
|
+
${ANSI_BOLD}ME-DESIGN CLI v${pkg.version}${ANSI_RESET}
|
|
38
56
|
Autonomous Design Engineering Toolkit & Automated Linter for AI Coding Assistants
|
|
39
57
|
|
|
40
58
|
${ANSI_BOLD}USAGE:${ANSI_RESET}
|
|
@@ -59,6 +77,9 @@ ${ANSI_BOLD}COMMANDS:${ANSI_RESET}
|
|
|
59
77
|
(Checks computed contrast, tab focus outline, 44px hit-targets across viewports)
|
|
60
78
|
Options: --json
|
|
61
79
|
|
|
80
|
+
${ANSI_CYAN}snapshot${ANSI_RESET} <file> Capture high-DPI rendered screenshots across responsive viewports
|
|
81
|
+
Options: --out <dir>, --og (1200x630 banner), --viewports <list>
|
|
82
|
+
|
|
62
83
|
${ANSI_CYAN}tokens${ANSI_RESET} [export] Export preset design tokens to Tailwind v4 @theme, W3C DTCG, or CSS
|
|
63
84
|
Options: --preset <apple|tesla|metha|all>
|
|
64
85
|
--format <tailwind|dtcg|css|all>
|
|
@@ -69,7 +90,7 @@ ${ANSI_BOLD}COMMANDS:${ANSI_RESET}
|
|
|
69
90
|
medesign presets get <preset-name>
|
|
70
91
|
|
|
71
92
|
${ANSI_CYAN}test${ANSI_RESET} [options] Run deterministic test suite across fixtures
|
|
72
|
-
Options: --browser (runs both static
|
|
93
|
+
Options: --browser (runs both static pattern and headless browser matrix)
|
|
73
94
|
|
|
74
95
|
${ANSI_CYAN}doctor${ANSI_RESET} Verify local environment, Node.js, and Chrome/CDP availability
|
|
75
96
|
|
|
@@ -80,15 +101,20 @@ ${ANSI_BOLD}COMMANDS:${ANSI_RESET}
|
|
|
80
101
|
switch (command) {
|
|
81
102
|
case 'search': {
|
|
82
103
|
const isJson = args.includes('--json');
|
|
83
|
-
const
|
|
104
|
+
const isHelp = args.includes('--help') || args.includes('-h');
|
|
105
|
+
const query = args.slice(1).filter(a => !a.startsWith('--') && a !== '-h').join(' ').trim();
|
|
84
106
|
|
|
85
|
-
if (!query) {
|
|
107
|
+
if (!query || isHelp) {
|
|
86
108
|
if (isJson) {
|
|
87
|
-
console.log(JSON.stringify({
|
|
109
|
+
console.log(JSON.stringify({ usage: 'medesign search <query> [--json]' }));
|
|
88
110
|
} else {
|
|
89
|
-
console.log(`\n${
|
|
111
|
+
console.log(`\n${ANSI_BOLD}ME-DESIGN Search Engine${ANSI_RESET}`);
|
|
112
|
+
console.log(`${ANSI_GRAY}Instant discovery across 38 Archetypes & system presets${ANSI_RESET}\n`);
|
|
113
|
+
console.log(`${ANSI_BOLD}Usage:${ANSI_RESET} medesign search "<query>" [--json]`);
|
|
114
|
+
console.log(` mesearch "<query>" [--json]\n`);
|
|
115
|
+
console.log(`Example: medesign search "cadastre survey"\n`);
|
|
90
116
|
}
|
|
91
|
-
process.exit(1);
|
|
117
|
+
process.exit(isHelp ? 0 : 1);
|
|
92
118
|
}
|
|
93
119
|
|
|
94
120
|
const catalogPath = path.join(rootDir, 'references', 'catalog.json');
|
|
@@ -239,10 +265,36 @@ ${ANSI_GRAY}──────────────────────
|
|
|
239
265
|
}
|
|
240
266
|
|
|
241
267
|
case 'polish': {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
268
|
+
const isHelp = args.includes('--help') || args.includes('-h');
|
|
269
|
+
const dryRun = args.includes('--dry-run');
|
|
270
|
+
const targetFile = args.slice(1).find(a => !a.startsWith('--'));
|
|
271
|
+
|
|
272
|
+
if (!targetFile || isHelp) {
|
|
273
|
+
console.log(`
|
|
274
|
+
${ANSI_BOLD}ME-DESIGN Self-Healing Polish & Aesthetic Auto-Compiler${ANSI_RESET}
|
|
275
|
+
${ANSI_GRAY}Autonomous aesthetic compilation and self-healing repair engine${ANSI_RESET}
|
|
276
|
+
|
|
277
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
278
|
+
medesign polish <file> [options]
|
|
279
|
+
mepolish <file> [options]
|
|
280
|
+
|
|
281
|
+
${ANSI_BOLD}Options:${ANSI_RESET}
|
|
282
|
+
--dry-run Preview potential repairs without modifying files on disk
|
|
283
|
+
|
|
284
|
+
${ANSI_BOLD}Repairs & Aesthetic Compilations:${ANSI_RESET}
|
|
285
|
+
- Elevates generic typography to curated Archetypes (Geist / Plus Jakarta Sans / JetBrains Mono)
|
|
286
|
+
- Injects GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))
|
|
287
|
+
- Injects dynamic Bento proportions & asymmetric visual hierarchy
|
|
288
|
+
- Decouples 44px hit-targets with transparent touch halos & boundary clearance (MD106)
|
|
289
|
+
- Normalizes color gamut to perceptual OKLCH interpolation (MD102)
|
|
290
|
+
- Replaces hit-target crushing scale with controlled proportional scale (MD003)
|
|
291
|
+
- Injects physical :focus-visible outline & forced-colors high contrast (MD005)
|
|
292
|
+
- Replaces raw 100vh with dynamic 100dvh fallback (MD104)
|
|
293
|
+
- Fixes dead buttons with interactive hover/active states (MD004)
|
|
294
|
+
- Injects prefers-reduced-motion accessibility gate (MD002)
|
|
295
|
+
- Cleans HTML entity and unicode em-dashes to hyphens (MD201)
|
|
296
|
+
`);
|
|
297
|
+
process.exit(isHelp ? 0 : 1);
|
|
246
298
|
}
|
|
247
299
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
248
300
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -261,6 +313,19 @@ ${ANSI_GRAY}──────────────────────
|
|
|
261
313
|
let content = fs.readFileSync(resolvedPath, 'utf8');
|
|
262
314
|
const fixes = [];
|
|
263
315
|
|
|
316
|
+
const getClean = (src) => src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/<!--[\s\S]*?-->/g, '');
|
|
317
|
+
|
|
318
|
+
const isHtml = /<html|<body|<!DOCTYPE|<\/head>/i.test(content);
|
|
319
|
+
if (isHtml && !/<style\b/i.test(content)) {
|
|
320
|
+
if (content.includes('</head>')) {
|
|
321
|
+
content = content.replace('</head>', ' <style>\n </style>\n</head>');
|
|
322
|
+
} else if (content.includes('<body>')) {
|
|
323
|
+
content = content.replace('<body>', '<head>\n <style>\n </style>\n</head>\n<body>');
|
|
324
|
+
} else {
|
|
325
|
+
content = '<style>\n</style>\n' + content;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
264
329
|
// 1. RULE MD104: Dynamic Viewport Units (Convert raw 100vh to 100dvh fallback)
|
|
265
330
|
let count104 = 0;
|
|
266
331
|
content = content.replace(/min-height\s*:\s*100vh\s*;?(?!\s*min-height\s*:\s*100[ds]vh)/gi, () => {
|
|
@@ -295,12 +360,12 @@ ${ANSI_GRAY}──────────────────────
|
|
|
295
360
|
});
|
|
296
361
|
|
|
297
362
|
// Ensure forced-colors high contrast outline media query is injected
|
|
298
|
-
if (!/@media\s*\(forced-colors:\s*active\)/i.test(content)) {
|
|
299
|
-
const forcedColorsRule = `\n @media (forced-colors: active) {\n :focus-visible, button:focus-visible, [class*="btn"]:focus-visible, a:focus-visible {\n outline: 2px solid CanvasText !important;\n outline-offset: 2px !important;\n }\n }\n`;
|
|
363
|
+
if (!/@media\s*\(forced-colors:\s*active\)/i.test(getClean(content))) {
|
|
364
|
+
const forcedColorsRule = `\n @media (forced-colors: active) {\n :focus-visible, button:focus-visible, [class*="btn"]:focus-visible, a:focus-visible, [role="button"]:focus-visible {\n outline: 2px solid CanvasText !important;\n outline-offset: 2px !important;\n }\n }\n`;
|
|
300
365
|
if (content.includes('</style>')) {
|
|
301
366
|
content = content.replace('</style>', `${forcedColorsRule} </style>`);
|
|
302
367
|
md005Applied = true;
|
|
303
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
368
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
304
369
|
content = content.trimEnd() + '\n' + forcedColorsRule;
|
|
305
370
|
md005Applied = true;
|
|
306
371
|
}
|
|
@@ -309,35 +374,72 @@ ${ANSI_GRAY}──────────────────────
|
|
|
309
374
|
fixes.push('Added physical focus outline & forced-colors high contrast (MD005)');
|
|
310
375
|
}
|
|
311
376
|
|
|
312
|
-
// 3. RULE
|
|
313
|
-
|
|
314
|
-
|
|
377
|
+
// 3. RULE MD003: Uncontrolled Button Scale / Hit Target Crush
|
|
378
|
+
let count003 = 0;
|
|
379
|
+
if (/active:scale-9[0-5]/.test(content)) {
|
|
380
|
+
content = content.replace(/active:scale-9[0-5]/g, 'active:scale-98');
|
|
381
|
+
count003++;
|
|
382
|
+
}
|
|
383
|
+
if (/:active\s*\{[^}]*transform:\s*scale\(0\.9[0-5]\)/.test(content)) {
|
|
384
|
+
content = content.replace(/(transform\s*:\s*scale\()0\.9[0-5](\))/gi, '$10.98$2');
|
|
385
|
+
count003++;
|
|
386
|
+
}
|
|
387
|
+
if (count003 > 0) {
|
|
388
|
+
fixes.push('Replaced hit-target crushing active scale with safe proportional scale(0.98) (MD003)');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// 4. RULE MD004: Interactive State Contract & Micro-Interaction Springs
|
|
392
|
+
const cleanForButtons = getClean(content);
|
|
393
|
+
const hasButtons = /<button/i.test(cleanForButtons) || /class="[^"]*btn[^"]*"/i.test(cleanForButtons) || /\.btn\b/i.test(cleanForButtons) || /role="button"/i.test(cleanForButtons);
|
|
394
|
+
const hasInteractive = /:hover/i.test(cleanForButtons) || /:active/i.test(cleanForButtons);
|
|
315
395
|
if (hasButtons && !hasInteractive) {
|
|
316
|
-
const buttonStates = `\n button:hover, [class*="btn"]:hover, .btn:hover {
|
|
396
|
+
const buttonStates = `\n button, [class*="btn"], .btn, [role="button"] {\n min-height: 44px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 160ms cubic-bezier(0.16, 1, 0.3, 1), filter 160ms cubic-bezier(0.16, 1, 0.3, 1);\n }\n button:hover, [class*="btn"]:hover, .btn:hover, [role="button"]:hover {\n filter: brightness(1.1);\n transform: translateY(-1px);\n }\n button:active, [class*="btn"]:active, .btn:active, [role="button"]:active {\n transform: scale(0.98);\n }\n button:focus-visible, [class*="btn"]:focus-visible, .btn:focus-visible, [role="button"]:focus-visible {\n outline: 2px solid Highlight;\n outline-offset: 2px;\n }\n`;
|
|
317
397
|
if (content.includes('</style>')) {
|
|
318
398
|
content = content.replace('</style>', `${buttonStates} </style>`);
|
|
319
399
|
fixes.push('Injected hover and active interactive states for buttons (MD004)');
|
|
320
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
400
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
321
401
|
content = content.trimEnd() + '\n' + buttonStates;
|
|
322
402
|
fixes.push('Injected hover and active interactive states for buttons (MD004)');
|
|
323
403
|
}
|
|
404
|
+
} else if (hasButtons && !content.includes('min-height: 44px')) {
|
|
405
|
+
const hitTargetFix = `\n /* 44px Touch Target Standard (Apple HIG / WCAG) */\n button, [class*="btn"], .btn, [role="button"] { min-height: 44px; }\n`;
|
|
406
|
+
if (content.includes('</style>')) {
|
|
407
|
+
content = content.replace('</style>', `${hitTargetFix} </style>`);
|
|
408
|
+
fixes.push('Enforced 44px minimum touch hit-target standard on buttons');
|
|
409
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
410
|
+
content = content.trimEnd() + '\n' + hitTargetFix;
|
|
411
|
+
fixes.push('Enforced 44px minimum touch hit-target standard on buttons');
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Micro-Interaction Springs (GPU-accelerated 160ms cubic-bezier transitions)
|
|
416
|
+
if (!content.includes('cubic-bezier(0.16, 1, 0.3, 1)')) {
|
|
417
|
+
const springBlock = `\n /* Micro-Interaction Springs (160ms cubic-bezier) */\n button, [class*="btn"], .btn, [role="button"], .card, [class*="card"], .interactive-surface {\n transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 160ms cubic-bezier(0.16, 1, 0.3, 1), filter 160ms cubic-bezier(0.16, 1, 0.3, 1);\n }\n .card:hover, [class*="card"]:hover {\n transform: translateY(-2px);\n box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.3);\n }\n`;
|
|
418
|
+
if (content.includes('</style>')) {
|
|
419
|
+
content = content.replace('</style>', `${springBlock} </style>`);
|
|
420
|
+
fixes.push('Injected GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))');
|
|
421
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
422
|
+
content = content.trimEnd() + '\n' + springBlock;
|
|
423
|
+
fixes.push('Injected GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))');
|
|
424
|
+
}
|
|
324
425
|
}
|
|
325
426
|
|
|
326
|
-
//
|
|
327
|
-
const
|
|
328
|
-
const
|
|
427
|
+
// 5. RULE MD002: Reduced Motion Compliance
|
|
428
|
+
const cleanForMotion = getClean(content);
|
|
429
|
+
const hasAnimations = /animation:|transition:/i.test(cleanForMotion) && !/transition:\s*none/i.test(cleanForMotion);
|
|
430
|
+
const hasReducedMotion = /prefers-reduced-motion/i.test(cleanForMotion);
|
|
329
431
|
if (hasAnimations && !hasReducedMotion) {
|
|
330
432
|
const reducedMotionBlock = `\n @media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n }\n }\n`;
|
|
331
433
|
if (content.includes('</style>')) {
|
|
332
434
|
content = content.replace('</style>', `${reducedMotionBlock} </style>`);
|
|
333
435
|
fixes.push('Added prefers-reduced-motion accessibility gate (MD002)');
|
|
334
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
436
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
335
437
|
content = content.trimEnd() + '\n' + reducedMotionBlock;
|
|
336
438
|
fixes.push('Added prefers-reduced-motion accessibility gate (MD002)');
|
|
337
439
|
}
|
|
338
440
|
}
|
|
339
441
|
|
|
340
|
-
//
|
|
442
|
+
// 6. Anti-AI Tells: Em-Dash / En-Dash & HTML Entities Cleanup (MD201)
|
|
341
443
|
const emDashRegex = /\s*(?:[—–]|—|–|—|–|—|–)\s*/g;
|
|
342
444
|
const emDashMatches = content.match(emDashRegex);
|
|
343
445
|
if (emDashMatches && emDashMatches.length > 0) {
|
|
@@ -346,28 +448,200 @@ ${ANSI_GRAY}──────────────────────
|
|
|
346
448
|
fixes.push(`Cleaned ${count} AI-tell em-dash punctuation & entities`);
|
|
347
449
|
}
|
|
348
450
|
|
|
451
|
+
// 7. Typography Elevation (Generic Fonts -> Curated Archetype Pairings: Geist / Plus Jakarta Sans / JetBrains Mono)
|
|
452
|
+
let countTypo = 0;
|
|
453
|
+
const genericSansRegex = /font-family\s*:\s*(?:['"]?(?:Inter|Arial|Helvetica Neue|Helvetica|Roboto|Open Sans)['"]?|system-ui|-apple-system|BlinkMacSystemFont|['"]?Segoe UI['"]?)(?:\s*,\s*(?:sans-serif|system-ui|-apple-system|BlinkMacSystemFont|['"]?(?:Segoe UI|Roboto|Oxygen|Ubuntu|Cantarell|Open Sans|Helvetica Neue|Helvetica|Arial)['"]?|['"][^'"]+['"]|sans-serif))*\s*;?/gi;
|
|
454
|
+
if (genericSansRegex.test(content)) {
|
|
455
|
+
content = content.replace(genericSansRegex, () => {
|
|
456
|
+
countTypo++;
|
|
457
|
+
return "font-family: 'Geist', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;";
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const varSansRegex = /(--font-sans\s*:\s*)(?:['"]?(?:Inter|Arial|Helvetica Neue|Helvetica|Roboto|Open Sans)['"]?|system-ui|-apple-system|BlinkMacSystemFont|['"]?Segoe UI['"]?)[^;]*;/gi;
|
|
461
|
+
if (varSansRegex.test(content)) {
|
|
462
|
+
content = content.replace(varSansRegex, () => {
|
|
463
|
+
countTypo++;
|
|
464
|
+
return "--font-sans: 'Geist', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;";
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
const genericMonoRegex = /font-family\s*:\s*(?:['"]?(?:Courier New|Courier|Consolas|Menlo|Monaco)['"]?|monospace|ui-monospace|SFMono-Regular)(?:\s*,\s*[^;}]*)*\s*;?/gi;
|
|
468
|
+
if (genericMonoRegex.test(content)) {
|
|
469
|
+
content = content.replace(genericMonoRegex, () => {
|
|
470
|
+
countTypo++;
|
|
471
|
+
return "font-family: 'JetBrains Mono', 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;";
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
const varMonoRegex = /(--font-mono\s*:\s*)(?:['"]?(?:Courier New|Courier|Consolas|Menlo|Monaco)['"]?|monospace|ui-monospace|SFMono-Regular)[^;]*;/gi;
|
|
475
|
+
if (varMonoRegex.test(content)) {
|
|
476
|
+
content = content.replace(varMonoRegex, () => {
|
|
477
|
+
countTypo++;
|
|
478
|
+
return "--font-mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;";
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
if (countTypo > 0) {
|
|
482
|
+
if (content.includes('</head>') && !content.includes('fonts.googleapis.com/css2?family=Geist')) {
|
|
483
|
+
const fontPreconnect = ` <link rel="preconnect" href="https://fonts.googleapis.com">\n <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>\n <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">\n `;
|
|
484
|
+
content = content.replace('</head>', `${fontPreconnect}</head>`);
|
|
485
|
+
} else if ((resolvedPath.endsWith('.css') || !isHtml) && !content.includes('fonts.googleapis.com')) {
|
|
486
|
+
const fontImport = `@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');\n`;
|
|
487
|
+
content = fontImport + content;
|
|
488
|
+
}
|
|
489
|
+
fixes.push('Elevated generic typography to curated Archetype pairings (Geist / Plus Jakarta Sans / JetBrains Mono)');
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// 8. Dynamic Bento Proportions (Asymmetric Visual Hierarchy)
|
|
493
|
+
let countBento = 0;
|
|
494
|
+
const gridContainerRegex = /(<(?:div|section|main|ul)\s+[^>]*\b(?:grid\b|bento-grid\b)[^>]*>[\s\S]*?)(<(?:div|article|section|li)\s+class=")([^"]*\bcard\b[^"]*)(")/i;
|
|
495
|
+
if (gridContainerRegex.test(content) && !/\bcol-span-/i.test(content)) {
|
|
496
|
+
content = content.replace(gridContainerRegex, (match, beforeCard, cardOpen, classNames, cardClose) => {
|
|
497
|
+
if (!classNames.includes('bento-featured') && !classNames.includes('col-span-')) {
|
|
498
|
+
countBento++;
|
|
499
|
+
return `${beforeCard}${cardOpen}${classNames} col-span-2 md:col-span-2 bento-featured${cardClose}`;
|
|
500
|
+
}
|
|
501
|
+
return match;
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const hasBentoCss = /\.bento-featured\b|\.bento-grid\b/.test(getClean(content)) && content.includes('grid-column: span 2');
|
|
506
|
+
if (!hasBentoCss) {
|
|
507
|
+
const bentoCss = `\n /* Dynamic Bento Asymmetric Grid Proportions */\n @media (min-width: 768px) {\n .bento-grid > :first-child, .grid > .bento-featured, [class*="grid"] > .bento-featured { grid-column: span 2; }\n }\n`;
|
|
508
|
+
if (content.includes('</style>')) {
|
|
509
|
+
content = content.replace('</style>', `${bentoCss} </style>`);
|
|
510
|
+
countBento++;
|
|
511
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
512
|
+
content = content.trimEnd() + '\n' + bentoCss;
|
|
513
|
+
countBento++;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (countBento > 0) {
|
|
517
|
+
fixes.push('Injected dynamic Bento grid proportions (asymmetric visual hierarchy & featured spans)');
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 9. RULE MD106: Container Optical Padding & Slider Boundary Clearance
|
|
521
|
+
let count106 = 0;
|
|
522
|
+
const sliderBlockRegex = /((?:[a-zA-Z0-9_\-\.\#\:\*\,\[\]\="'>\s]+)?(?:slider|progress|scrubber|pill-track)\s*\{)([^}]+)(\})/gi;
|
|
523
|
+
content = content.replace(sliderBlockRegex, (match, prefix, body, suffix) => {
|
|
524
|
+
const hasPillRadius = /border-radius\s*:\s*(?:var\(--radius-full\)|9999px|50%|[1-9]\d{1,}px)/i.test(body);
|
|
525
|
+
const hasVisibleBg = /background(?:-color)?\s*:\s*(?!none|transparent\b|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\))/i.test(body);
|
|
526
|
+
const hasMinHeight = /(?:min-)?height\s*:\s*(?:[3-9]\dpx|44px)/i.test(body);
|
|
527
|
+
const hasPadding = /padding(?:-inline|-left|-right)?\s*:\s*(?:[^;}]*?(?:[8-9]px|[1-9]\d+px|var\(--padding))/i.test(body);
|
|
528
|
+
if (hasPillRadius && hasVisibleBg && hasMinHeight && !hasPadding) {
|
|
529
|
+
count106++;
|
|
530
|
+
const updatedBody = body.trimEnd() + ' padding: 0 12px;';
|
|
531
|
+
return prefix + updatedBody + ' ' + suffix;
|
|
532
|
+
}
|
|
533
|
+
return match;
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// Decouple 44px hit-target with transparent touch halo helper
|
|
537
|
+
if (!content.includes('.touch-halo') && !content.includes('.hit-target-decoupled')) {
|
|
538
|
+
const haloCss = `\n /* MD106 Decoupled Touch Halo */\n .touch-halo {\n min-height: 44px;\n min-width: 44px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: transparent !important;\n padding: 0 12px;\n }\n`;
|
|
539
|
+
if (content.includes('</style>')) {
|
|
540
|
+
content = content.replace('</style>', `${haloCss} </style>`);
|
|
541
|
+
count106++;
|
|
542
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
543
|
+
content = content.trimEnd() + '\n' + haloCss;
|
|
544
|
+
count106++;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (count106 > 0) {
|
|
548
|
+
fixes.push('Decoupled 44px touch hit-target with transparent halo and >=12px boundary clearance (MD106)');
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// 10. RULE MD102: Perceptual Color Gamut Normalizer (linear-gradient in oklch)
|
|
552
|
+
let count102 = 0;
|
|
553
|
+
const gradientDirectionRegex = /linear-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)(?:(-?\d+(?:\.\d+)?(?:deg|turn|rad|grad)|to\s+[a-zA-Z\s]+),)?\s*/gi;
|
|
554
|
+
content = content.replace(gradientDirectionRegex, (m, direction) => {
|
|
555
|
+
count102++;
|
|
556
|
+
if (direction) {
|
|
557
|
+
return `linear-gradient(in oklch ${direction.trim()}, `;
|
|
558
|
+
}
|
|
559
|
+
return 'linear-gradient(in oklch, ';
|
|
560
|
+
});
|
|
561
|
+
content = content.replace(/radial-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)/gi, () => {
|
|
562
|
+
count102++;
|
|
563
|
+
return 'radial-gradient(in oklch, ';
|
|
564
|
+
});
|
|
565
|
+
content = content.replace(/conic-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)/gi, () => {
|
|
566
|
+
count102++;
|
|
567
|
+
return 'conic-gradient(in oklch, ';
|
|
568
|
+
});
|
|
569
|
+
if (count102 > 0) {
|
|
570
|
+
fixes.push('Normalized color gamut to perceptual OKLCH interpolation space (MD102)');
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// 11. RULE MD103: Concentric Radius Math Helper
|
|
574
|
+
let count103 = 0;
|
|
575
|
+
const hasOuterRadius = /border-radius:\s*\d+px/i.test(content);
|
|
576
|
+
const hasInnerConcentric = /max\(\s*0px/i.test(content) || /calc\(infinity/i.test(content) || /--corner-r/i.test(content);
|
|
577
|
+
if (hasOuterRadius && !hasInnerConcentric) {
|
|
578
|
+
const concentricRule = `\n /* MD103 Safe Concentric Radius Formula */\n :root { --radius-inner: max(0px, var(--radius-outer, 16px) - 1px - 8px); }\n`;
|
|
579
|
+
if (content.includes('</style>')) {
|
|
580
|
+
content = content.replace('</style>', `${concentricRule} </style>`);
|
|
581
|
+
count103++;
|
|
582
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
583
|
+
content = content.trimEnd() + '\n' + concentricRule;
|
|
584
|
+
count103++;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (count103 > 0) {
|
|
588
|
+
fixes.push('Injected safe concentric radius formula max(0px, r_outer - border_w - pad) (MD103)');
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if (dryRun) {
|
|
592
|
+
console.log(`\n${ANSI_YELLOW}${ANSI_BOLD}[POLISH DRY-RUN PREVIEW]${ANSI_RESET} ${fixes.length} potential repairs identified for ${ANSI_CYAN}${path.basename(resolvedPath)}${ANSI_RESET}`);
|
|
593
|
+
fixes.forEach(f => console.log(` ${ANSI_CYAN}Preview:${ANSI_RESET} ${f}`));
|
|
594
|
+
console.log(`\n${ANSI_GRAY}Dry-run mode: Target file was not modified on disk.${ANSI_RESET}\n`);
|
|
595
|
+
process.exit(0);
|
|
596
|
+
}
|
|
597
|
+
|
|
349
598
|
fs.writeFileSync(resolvedPath, content, 'utf8');
|
|
350
599
|
|
|
351
600
|
let afterQ = beforeQ;
|
|
352
601
|
let isPassed = true;
|
|
602
|
+
let hardFailures = [];
|
|
353
603
|
try {
|
|
354
604
|
const afterRes = spawnSync(process.execPath, [linterScript, resolvedPath, '--json'], { encoding: 'utf8' });
|
|
355
605
|
const parsed = JSON.parse(afterRes.stdout);
|
|
356
606
|
afterQ = parsed.qScore !== undefined ? parsed.qScore : beforeQ;
|
|
357
607
|
isPassed = parsed.passed !== undefined ? parsed.passed : (afterQ >= 75);
|
|
608
|
+
hardFailures = parsed.hardFailures || [];
|
|
358
609
|
} catch (e) {}
|
|
359
610
|
|
|
611
|
+
const statusBadge = isPassed ? `${ANSI_GREEN}PASS${ANSI_RESET}` : `${ANSI_RED}FAIL${ANSI_RESET}`;
|
|
360
612
|
console.log(`\n${ANSI_GREEN}${ANSI_BOLD}[POLISH COMPLETED]${ANSI_RESET} ${fixes.length} issues automatically repaired in ${ANSI_CYAN}${path.basename(resolvedPath)}${ANSI_RESET}`);
|
|
361
613
|
fixes.forEach(f => console.log(` ${ANSI_GREEN}Fixed:${ANSI_RESET} ${f}`));
|
|
362
|
-
console.log(`${ANSI_BOLD}Q-Score:${ANSI_RESET} ${beforeQ.toFixed(1)} -> ${ANSI_GREEN}${ANSI_BOLD}${afterQ.toFixed(1)}${ANSI_RESET} [${
|
|
614
|
+
console.log(`${ANSI_BOLD}Q-Score:${ANSI_RESET} ${beforeQ.toFixed(1)} -> ${ANSI_GREEN}${ANSI_BOLD}${afterQ.toFixed(1)}${ANSI_RESET} [${statusBadge}]\n`);
|
|
615
|
+
|
|
616
|
+
if (!isPassed) {
|
|
617
|
+
console.error(`${ANSI_RED}${ANSI_BOLD}[GATE REJECTED]${ANSI_RESET} File still contains unresolved violations after auto-repair:`);
|
|
618
|
+
if (hardFailures.length > 0) {
|
|
619
|
+
const failureNames = hardFailures.map(f => typeof f === 'string' ? f : `${f.ruleId} (${f.ruleName || 'Violation'})`).join(', ');
|
|
620
|
+
console.error(` ${ANSI_RED}Hard Invariant Failures:${ANSI_RESET} ${failureNames}`);
|
|
621
|
+
}
|
|
622
|
+
process.exit(1);
|
|
623
|
+
}
|
|
624
|
+
|
|
363
625
|
process.exit(0);
|
|
364
626
|
}
|
|
365
627
|
|
|
366
628
|
case 'bolder': {
|
|
367
629
|
const targetFile = args[1];
|
|
368
|
-
if (!targetFile) {
|
|
369
|
-
console.
|
|
370
|
-
|
|
630
|
+
if (!targetFile || targetFile === '--help' || targetFile === '-h') {
|
|
631
|
+
console.log(`
|
|
632
|
+
${ANSI_BOLD}ME-DESIGN Bolder Modifier${ANSI_RESET}
|
|
633
|
+
${ANSI_GRAY}Elevate visual density, typography weights, and color saturation${ANSI_RESET}
|
|
634
|
+
|
|
635
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
636
|
+
medesign bolder <file>
|
|
637
|
+
mebolder <file>
|
|
638
|
+
|
|
639
|
+
${ANSI_BOLD}Modifications:${ANSI_RESET}
|
|
640
|
+
- Elevates font weights: normal/400 -> 600, medium/500 -> 700
|
|
641
|
+
- Deepens subtle translucent borders (border-white/10 -> border-white/20)
|
|
642
|
+
- Boosts OKLCH chroma by ~25%
|
|
643
|
+
`);
|
|
644
|
+
process.exit(targetFile === '--help' || targetFile === '-h' ? 0 : 1);
|
|
371
645
|
}
|
|
372
646
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
373
647
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -461,9 +735,21 @@ ${ANSI_GRAY}──────────────────────
|
|
|
461
735
|
|
|
462
736
|
case 'quiet': {
|
|
463
737
|
const targetFile = args[1];
|
|
464
|
-
if (!targetFile) {
|
|
465
|
-
console.
|
|
466
|
-
|
|
738
|
+
if (!targetFile || targetFile === '--help' || targetFile === '-h') {
|
|
739
|
+
console.log(`
|
|
740
|
+
${ANSI_BOLD}ME-DESIGN Quiet Modifier${ANSI_RESET}
|
|
741
|
+
${ANSI_GRAY}Soften visual density, typography weights, and border contrast${ANSI_RESET}
|
|
742
|
+
|
|
743
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
744
|
+
medesign quiet <file>
|
|
745
|
+
mequiet <file>
|
|
746
|
+
|
|
747
|
+
${ANSI_BOLD}Modifications:${ANSI_RESET}
|
|
748
|
+
- Softens font weights: bold/700 -> 500, semibold/600 -> 500
|
|
749
|
+
- Reduces borders to hairline borders
|
|
750
|
+
- Softens OKLCH chroma by ~30%
|
|
751
|
+
`);
|
|
752
|
+
process.exit(targetFile === '--help' || targetFile === '-h' ? 0 : 1);
|
|
467
753
|
}
|
|
468
754
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
469
755
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -575,6 +861,15 @@ ${ANSI_GRAY}──────────────────────
|
|
|
575
861
|
process.exit(child.status ?? 0);
|
|
576
862
|
}
|
|
577
863
|
|
|
864
|
+
case 'snapshot': {
|
|
865
|
+
const snapshotScript = path.join(rootDir, 'tests', 'snapshot.js');
|
|
866
|
+
const child = spawnSync(process.execPath, [snapshotScript, ...args.slice(1)], {
|
|
867
|
+
stdio: 'inherit',
|
|
868
|
+
cwd: process.cwd()
|
|
869
|
+
});
|
|
870
|
+
process.exit(child.status ?? 0);
|
|
871
|
+
}
|
|
872
|
+
|
|
578
873
|
case 'tokens': {
|
|
579
874
|
const exportScript = path.join(rootDir, 'scripts', 'export-tokens.js');
|
|
580
875
|
const exportArgs = args.slice(1).filter(a => a !== 'export');
|
|
@@ -587,6 +882,17 @@ ${ANSI_GRAY}──────────────────────
|
|
|
587
882
|
|
|
588
883
|
case 'presets': {
|
|
589
884
|
const sub = args[1] || 'list';
|
|
885
|
+
if (sub === '--help' || sub === '-h' || sub === 'help') {
|
|
886
|
+
console.log(`
|
|
887
|
+
${ANSI_BOLD}ME-DESIGN Presets Inspector${ANSI_RESET}
|
|
888
|
+
${ANSI_GRAY}Inspect available design system presets${ANSI_RESET}
|
|
889
|
+
|
|
890
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
891
|
+
medesign presets list
|
|
892
|
+
medesign presets get <preset-name>
|
|
893
|
+
`);
|
|
894
|
+
process.exit(0);
|
|
895
|
+
}
|
|
590
896
|
const presetsDir = path.join(rootDir, 'presets');
|
|
591
897
|
if (sub === 'list') {
|
|
592
898
|
console.log(`\n${ANSI_BOLD}AVAILABLE ME-DESIGN PRESETS:${ANSI_RESET}\n`);
|
|
@@ -619,6 +925,17 @@ ${ANSI_GRAY}──────────────────────
|
|
|
619
925
|
}
|
|
620
926
|
|
|
621
927
|
case 'test': {
|
|
928
|
+
if (args[1] === '--help' || args[1] === '-h') {
|
|
929
|
+
console.log(`
|
|
930
|
+
${ANSI_BOLD}ME-DESIGN Test Runner${ANSI_RESET}
|
|
931
|
+
${ANSI_GRAY}Run deterministic static rule & browser test suites${ANSI_RESET}
|
|
932
|
+
|
|
933
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
934
|
+
medesign test
|
|
935
|
+
medesign test --browser
|
|
936
|
+
`);
|
|
937
|
+
process.exit(0);
|
|
938
|
+
}
|
|
622
939
|
const runnerScript = path.join(rootDir, 'tests', 'runner.js');
|
|
623
940
|
const child = spawnSync(process.execPath, [runnerScript, ...args.slice(1)], {
|
|
624
941
|
stdio: 'inherit',
|
|
@@ -628,6 +945,16 @@ ${ANSI_GRAY}──────────────────────
|
|
|
628
945
|
}
|
|
629
946
|
|
|
630
947
|
case 'doctor': {
|
|
948
|
+
if (args[1] === '--help' || args[1] === '-h') {
|
|
949
|
+
console.log(`
|
|
950
|
+
${ANSI_BOLD}ME-DESIGN Environment Doctor${ANSI_RESET}
|
|
951
|
+
${ANSI_GRAY}Verify local environment, Node.js, and Chrome/CDP availability${ANSI_RESET}
|
|
952
|
+
|
|
953
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
954
|
+
medesign doctor
|
|
955
|
+
`);
|
|
956
|
+
process.exit(0);
|
|
957
|
+
}
|
|
631
958
|
console.log(`\n${ANSI_BOLD}ME-DESIGN System Health & Environment Doctor${ANSI_RESET}`);
|
|
632
959
|
console.log(`${ANSI_GRAY}────────────────────────────────────────${ANSI_RESET}\n`);
|
|
633
960
|
|
|
@@ -678,8 +1005,16 @@ ${ANSI_GRAY}──────────────────────
|
|
|
678
1005
|
console.log(`Test Fixtures: ${ANSI_GREEN}${validCount} valid, ${invalidCount} invalid test fixtures${ANSI_RESET}\n`);
|
|
679
1006
|
|
|
680
1007
|
console.log(`${ANSI_GRAY}────────────────────────────────────────${ANSI_RESET}`);
|
|
681
|
-
|
|
682
|
-
|
|
1008
|
+
if (!nodeOk) {
|
|
1009
|
+
console.log(`${ANSI_RED}${ANSI_BOLD}STATUS: UNSUPPORTED ENVIRONMENT (Node.js >= 18.0.0 required)${ANSI_RESET}\n`);
|
|
1010
|
+
process.exit(1);
|
|
1011
|
+
} else if (foundChrome) {
|
|
1012
|
+
console.log(`${ANSI_GREEN}${ANSI_BOLD}STATUS: ALL SYSTEMS OPERATIONAL (Static & Browser Matrix Ready)${ANSI_RESET}\n`);
|
|
1013
|
+
process.exit(0);
|
|
1014
|
+
} else {
|
|
1015
|
+
console.log(`${ANSI_YELLOW}${ANSI_BOLD}STATUS: CORE OPERATIONAL (Static Engine Ready, Browser Audits Unavailable)${ANSI_RESET}\n`);
|
|
1016
|
+
process.exit(0);
|
|
1017
|
+
}
|
|
683
1018
|
}
|
|
684
1019
|
|
|
685
1020
|
case 'help':
|
package/bin/melint.js
ADDED
package/bin/mepolish.js
ADDED
package/bin/mequiet.js
ADDED
package/bin/mesearch.js
ADDED