medesign 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mebolder.js +4 -0
- package/bin/medesign.js +331 -30
- 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 +81 -69
- 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 +263 -0
package/bin/mebolder.js
ADDED
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>
|
|
@@ -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');
|
|
@@ -240,9 +266,29 @@ ${ANSI_GRAY}──────────────────────
|
|
|
240
266
|
|
|
241
267
|
case 'polish': {
|
|
242
268
|
const targetFile = args[1];
|
|
243
|
-
if (!targetFile) {
|
|
244
|
-
console.
|
|
245
|
-
|
|
269
|
+
if (!targetFile || targetFile === '--help' || targetFile === '-h') {
|
|
270
|
+
console.log(`
|
|
271
|
+
${ANSI_BOLD}ME-DESIGN Self-Healing Polish & Aesthetic Auto-Compiler${ANSI_RESET}
|
|
272
|
+
${ANSI_GRAY}Autonomous aesthetic compilation and self-healing repair engine${ANSI_RESET}
|
|
273
|
+
|
|
274
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
275
|
+
medesign polish <file>
|
|
276
|
+
mepolish <file>
|
|
277
|
+
|
|
278
|
+
${ANSI_BOLD}Repairs & Aesthetic Compilations:${ANSI_RESET}
|
|
279
|
+
- Elevates generic typography to curated Archetypes (Geist / Plus Jakarta Sans / JetBrains Mono)
|
|
280
|
+
- Injects GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))
|
|
281
|
+
- Injects dynamic Bento proportions & asymmetric visual hierarchy
|
|
282
|
+
- Decouples 44px hit-targets with transparent touch halos & boundary clearance (MD106)
|
|
283
|
+
- Normalizes color gamut to perceptual OKLCH interpolation (MD102)
|
|
284
|
+
- Replaces hit-target crushing scale with controlled proportional scale (MD003)
|
|
285
|
+
- Injects physical :focus-visible outline & forced-colors high contrast (MD005)
|
|
286
|
+
- Replaces raw 100vh with dynamic 100dvh fallback (MD104)
|
|
287
|
+
- Fixes dead buttons with interactive hover/active states (MD004)
|
|
288
|
+
- Injects prefers-reduced-motion accessibility gate (MD002)
|
|
289
|
+
- Cleans HTML entity and unicode em-dashes to hyphens (MD201)
|
|
290
|
+
`);
|
|
291
|
+
process.exit(targetFile === '--help' || targetFile === '-h' ? 0 : 1);
|
|
246
292
|
}
|
|
247
293
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
248
294
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -261,6 +307,19 @@ ${ANSI_GRAY}──────────────────────
|
|
|
261
307
|
let content = fs.readFileSync(resolvedPath, 'utf8');
|
|
262
308
|
const fixes = [];
|
|
263
309
|
|
|
310
|
+
const getClean = (src) => src.replace(/\/\*[\s\S]*?\*\//g, '').replace(/<!--[\s\S]*?-->/g, '');
|
|
311
|
+
|
|
312
|
+
const isHtml = /<html|<body|<!DOCTYPE|<\/head>/i.test(content);
|
|
313
|
+
if (isHtml && !/<style\b/i.test(content)) {
|
|
314
|
+
if (content.includes('</head>')) {
|
|
315
|
+
content = content.replace('</head>', ' <style>\n </style>\n</head>');
|
|
316
|
+
} else if (content.includes('<body>')) {
|
|
317
|
+
content = content.replace('<body>', '<head>\n <style>\n </style>\n</head>\n<body>');
|
|
318
|
+
} else {
|
|
319
|
+
content = '<style>\n</style>\n' + content;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
264
323
|
// 1. RULE MD104: Dynamic Viewport Units (Convert raw 100vh to 100dvh fallback)
|
|
265
324
|
let count104 = 0;
|
|
266
325
|
content = content.replace(/min-height\s*:\s*100vh\s*;?(?!\s*min-height\s*:\s*100[ds]vh)/gi, () => {
|
|
@@ -295,12 +354,12 @@ ${ANSI_GRAY}──────────────────────
|
|
|
295
354
|
});
|
|
296
355
|
|
|
297
356
|
// 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`;
|
|
357
|
+
if (!/@media\s*\(forced-colors:\s*active\)/i.test(getClean(content))) {
|
|
358
|
+
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
359
|
if (content.includes('</style>')) {
|
|
301
360
|
content = content.replace('</style>', `${forcedColorsRule} </style>`);
|
|
302
361
|
md005Applied = true;
|
|
303
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
362
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
304
363
|
content = content.trimEnd() + '\n' + forcedColorsRule;
|
|
305
364
|
md005Applied = true;
|
|
306
365
|
}
|
|
@@ -309,35 +368,72 @@ ${ANSI_GRAY}──────────────────────
|
|
|
309
368
|
fixes.push('Added physical focus outline & forced-colors high contrast (MD005)');
|
|
310
369
|
}
|
|
311
370
|
|
|
312
|
-
// 3. RULE
|
|
313
|
-
|
|
314
|
-
|
|
371
|
+
// 3. RULE MD003: Uncontrolled Button Scale / Hit Target Crush
|
|
372
|
+
let count003 = 0;
|
|
373
|
+
if (/active:scale-9[0-5]/.test(content)) {
|
|
374
|
+
content = content.replace(/active:scale-9[0-5]/g, 'active:scale-98');
|
|
375
|
+
count003++;
|
|
376
|
+
}
|
|
377
|
+
if (/:active\s*\{[^}]*transform:\s*scale\(0\.9[0-5]\)/.test(content)) {
|
|
378
|
+
content = content.replace(/(transform\s*:\s*scale\()0\.9[0-5](\))/gi, '$10.98$2');
|
|
379
|
+
count003++;
|
|
380
|
+
}
|
|
381
|
+
if (count003 > 0) {
|
|
382
|
+
fixes.push('Replaced hit-target crushing active scale with safe proportional scale(0.98) (MD003)');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// 4. RULE MD004: Interactive State Contract & Micro-Interaction Springs
|
|
386
|
+
const cleanForButtons = getClean(content);
|
|
387
|
+
const hasButtons = /<button/i.test(cleanForButtons) || /class="[^"]*btn[^"]*"/i.test(cleanForButtons) || /\.btn\b/i.test(cleanForButtons) || /role="button"/i.test(cleanForButtons);
|
|
388
|
+
const hasInteractive = /:hover/i.test(cleanForButtons) || /:active/i.test(cleanForButtons);
|
|
315
389
|
if (hasButtons && !hasInteractive) {
|
|
316
|
-
const buttonStates = `\n button:hover, [class*="btn"]:hover, .btn:hover {
|
|
390
|
+
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
391
|
if (content.includes('</style>')) {
|
|
318
392
|
content = content.replace('</style>', `${buttonStates} </style>`);
|
|
319
393
|
fixes.push('Injected hover and active interactive states for buttons (MD004)');
|
|
320
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
394
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
321
395
|
content = content.trimEnd() + '\n' + buttonStates;
|
|
322
396
|
fixes.push('Injected hover and active interactive states for buttons (MD004)');
|
|
323
397
|
}
|
|
398
|
+
} else if (hasButtons && !content.includes('min-height: 44px')) {
|
|
399
|
+
const hitTargetFix = `\n /* 44px Touch Target Standard (Apple HIG / WCAG) */\n button, [class*="btn"], .btn, [role="button"] { min-height: 44px; }\n`;
|
|
400
|
+
if (content.includes('</style>')) {
|
|
401
|
+
content = content.replace('</style>', `${hitTargetFix} </style>`);
|
|
402
|
+
fixes.push('Enforced 44px minimum touch hit-target standard on buttons');
|
|
403
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
404
|
+
content = content.trimEnd() + '\n' + hitTargetFix;
|
|
405
|
+
fixes.push('Enforced 44px minimum touch hit-target standard on buttons');
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Micro-Interaction Springs (GPU-accelerated 160ms cubic-bezier transitions)
|
|
410
|
+
if (!content.includes('cubic-bezier(0.16, 1, 0.3, 1)')) {
|
|
411
|
+
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`;
|
|
412
|
+
if (content.includes('</style>')) {
|
|
413
|
+
content = content.replace('</style>', `${springBlock} </style>`);
|
|
414
|
+
fixes.push('Injected GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))');
|
|
415
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
416
|
+
content = content.trimEnd() + '\n' + springBlock;
|
|
417
|
+
fixes.push('Injected GPU-accelerated spring micro-interactions (160ms cubic-bezier(0.16, 1, 0.3, 1))');
|
|
418
|
+
}
|
|
324
419
|
}
|
|
325
420
|
|
|
326
|
-
//
|
|
327
|
-
const
|
|
328
|
-
const
|
|
421
|
+
// 5. RULE MD002: Reduced Motion Compliance
|
|
422
|
+
const cleanForMotion = getClean(content);
|
|
423
|
+
const hasAnimations = /animation:|transition:/i.test(cleanForMotion) && !/transition:\s*none/i.test(cleanForMotion);
|
|
424
|
+
const hasReducedMotion = /prefers-reduced-motion/i.test(cleanForMotion);
|
|
329
425
|
if (hasAnimations && !hasReducedMotion) {
|
|
330
426
|
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
427
|
if (content.includes('</style>')) {
|
|
332
428
|
content = content.replace('</style>', `${reducedMotionBlock} </style>`);
|
|
333
429
|
fixes.push('Added prefers-reduced-motion accessibility gate (MD002)');
|
|
334
|
-
} else if (resolvedPath.endsWith('.css') ||
|
|
430
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
335
431
|
content = content.trimEnd() + '\n' + reducedMotionBlock;
|
|
336
432
|
fixes.push('Added prefers-reduced-motion accessibility gate (MD002)');
|
|
337
433
|
}
|
|
338
434
|
}
|
|
339
435
|
|
|
340
|
-
//
|
|
436
|
+
// 6. Anti-AI Tells: Em-Dash / En-Dash & HTML Entities Cleanup (MD201)
|
|
341
437
|
const emDashRegex = /\s*(?:[—–]|—|–|—|–|—|–)\s*/g;
|
|
342
438
|
const emDashMatches = content.match(emDashRegex);
|
|
343
439
|
if (emDashMatches && emDashMatches.length > 0) {
|
|
@@ -346,6 +442,146 @@ ${ANSI_GRAY}──────────────────────
|
|
|
346
442
|
fixes.push(`Cleaned ${count} AI-tell em-dash punctuation & entities`);
|
|
347
443
|
}
|
|
348
444
|
|
|
445
|
+
// 7. Typography Elevation (Generic Fonts -> Curated Archetype Pairings: Geist / Plus Jakarta Sans / JetBrains Mono)
|
|
446
|
+
let countTypo = 0;
|
|
447
|
+
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;
|
|
448
|
+
if (genericSansRegex.test(content)) {
|
|
449
|
+
content = content.replace(genericSansRegex, () => {
|
|
450
|
+
countTypo++;
|
|
451
|
+
return "font-family: 'Geist', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;";
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
const varSansRegex = /(--font-sans\s*:\s*)(?:['"]?(?:Inter|Arial|Helvetica Neue|Helvetica|Roboto|Open Sans)['"]?|system-ui|-apple-system|BlinkMacSystemFont|['"]?Segoe UI['"]?)[^;]*;/gi;
|
|
455
|
+
if (varSansRegex.test(content)) {
|
|
456
|
+
content = content.replace(varSansRegex, () => {
|
|
457
|
+
countTypo++;
|
|
458
|
+
return "--font-sans: 'Geist', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;";
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
const genericMonoRegex = /font-family\s*:\s*(?:['"]?(?:Courier New|Courier|Consolas|Menlo|Monaco)['"]?|monospace|ui-monospace|SFMono-Regular)(?:\s*,\s*[^;}]*)*\s*;?/gi;
|
|
462
|
+
if (genericMonoRegex.test(content)) {
|
|
463
|
+
content = content.replace(genericMonoRegex, () => {
|
|
464
|
+
countTypo++;
|
|
465
|
+
return "font-family: 'JetBrains Mono', 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;";
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
const varMonoRegex = /(--font-mono\s*:\s*)(?:['"]?(?:Courier New|Courier|Consolas|Menlo|Monaco)['"]?|monospace|ui-monospace|SFMono-Regular)[^;]*;/gi;
|
|
469
|
+
if (varMonoRegex.test(content)) {
|
|
470
|
+
content = content.replace(varMonoRegex, () => {
|
|
471
|
+
countTypo++;
|
|
472
|
+
return "--font-mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;";
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (countTypo > 0) {
|
|
476
|
+
if (content.includes('</head>') && !content.includes('fonts.googleapis.com/css2?family=Geist')) {
|
|
477
|
+
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 `;
|
|
478
|
+
content = content.replace('</head>', `${fontPreconnect}</head>`);
|
|
479
|
+
} else if ((resolvedPath.endsWith('.css') || !isHtml) && !content.includes('fonts.googleapis.com')) {
|
|
480
|
+
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`;
|
|
481
|
+
content = fontImport + content;
|
|
482
|
+
}
|
|
483
|
+
fixes.push('Elevated generic typography to curated Archetype pairings (Geist / Plus Jakarta Sans / JetBrains Mono)');
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// 8. Dynamic Bento Proportions (Asymmetric Visual Hierarchy)
|
|
487
|
+
let countBento = 0;
|
|
488
|
+
const gridContainerRegex = /(<(?:div|section|main|ul)\s+[^>]*\b(?:grid\b|bento-grid\b)[^>]*>[\s\S]*?)(<(?:div|article|section|li)\s+class=")([^"]*\bcard\b[^"]*)(")/i;
|
|
489
|
+
if (gridContainerRegex.test(content) && !/\bcol-span-/i.test(content)) {
|
|
490
|
+
content = content.replace(gridContainerRegex, (match, beforeCard, cardOpen, classNames, cardClose) => {
|
|
491
|
+
if (!classNames.includes('bento-featured') && !classNames.includes('col-span-')) {
|
|
492
|
+
countBento++;
|
|
493
|
+
return `${beforeCard}${cardOpen}${classNames} col-span-2 md:col-span-2 bento-featured${cardClose}`;
|
|
494
|
+
}
|
|
495
|
+
return match;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const hasBentoCss = /\.bento-featured\b|\.bento-grid\b/.test(getClean(content)) && content.includes('grid-column: span 2');
|
|
500
|
+
if (!hasBentoCss) {
|
|
501
|
+
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`;
|
|
502
|
+
if (content.includes('</style>')) {
|
|
503
|
+
content = content.replace('</style>', `${bentoCss} </style>`);
|
|
504
|
+
countBento++;
|
|
505
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
506
|
+
content = content.trimEnd() + '\n' + bentoCss;
|
|
507
|
+
countBento++;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (countBento > 0) {
|
|
511
|
+
fixes.push('Injected dynamic Bento grid proportions (asymmetric visual hierarchy & featured spans)');
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// 9. RULE MD106: Container Optical Padding & Slider Boundary Clearance
|
|
515
|
+
let count106 = 0;
|
|
516
|
+
const sliderBlockRegex = /((?:[a-zA-Z0-9_\-\.\#\:\*\,\[\]\="'>\s]+)?(?:slider|progress|scrubber|pill-track)\s*\{)([^}]+)(\})/gi;
|
|
517
|
+
content = content.replace(sliderBlockRegex, (match, prefix, body, suffix) => {
|
|
518
|
+
const hasPillRadius = /border-radius\s*:\s*(?:var\(--radius-full\)|9999px|50%|[1-9]\d{1,}px)/i.test(body);
|
|
519
|
+
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);
|
|
520
|
+
const hasMinHeight = /(?:min-)?height\s*:\s*(?:[3-9]\dpx|44px)/i.test(body);
|
|
521
|
+
const hasPadding = /padding(?:-inline|-left|-right)?\s*:\s*(?:[^;}]*?(?:[8-9]px|[1-9]\d+px|var\(--padding))/i.test(body);
|
|
522
|
+
if (hasPillRadius && hasVisibleBg && hasMinHeight && !hasPadding) {
|
|
523
|
+
count106++;
|
|
524
|
+
const updatedBody = body.trimEnd() + ' padding: 0 12px;';
|
|
525
|
+
return prefix + updatedBody + ' ' + suffix;
|
|
526
|
+
}
|
|
527
|
+
return match;
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// Decouple 44px hit-target with transparent touch halo helper
|
|
531
|
+
if (!content.includes('.touch-halo') && !content.includes('.hit-target-decoupled')) {
|
|
532
|
+
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`;
|
|
533
|
+
if (content.includes('</style>')) {
|
|
534
|
+
content = content.replace('</style>', `${haloCss} </style>`);
|
|
535
|
+
count106++;
|
|
536
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
537
|
+
content = content.trimEnd() + '\n' + haloCss;
|
|
538
|
+
count106++;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (count106 > 0) {
|
|
542
|
+
fixes.push('Decoupled 44px touch hit-target with transparent halo and >=12px boundary clearance (MD106)');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// 10. RULE MD102: Perceptual Color Gamut Normalizer (linear-gradient in oklch)
|
|
546
|
+
let count102 = 0;
|
|
547
|
+
const gradientDirectionRegex = /linear-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)(?:(-?\d+(?:\.\d+)?(?:deg|turn|rad|grad)|to\s+[a-zA-Z\s]+),)?\s*/gi;
|
|
548
|
+
content = content.replace(gradientDirectionRegex, (m, direction) => {
|
|
549
|
+
count102++;
|
|
550
|
+
if (direction) {
|
|
551
|
+
return `linear-gradient(in oklch ${direction.trim()}, `;
|
|
552
|
+
}
|
|
553
|
+
return 'linear-gradient(in oklch, ';
|
|
554
|
+
});
|
|
555
|
+
content = content.replace(/radial-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)/gi, () => {
|
|
556
|
+
count102++;
|
|
557
|
+
return 'radial-gradient(in oklch, ';
|
|
558
|
+
});
|
|
559
|
+
content = content.replace(/conic-gradient\(\s*(?!in\s+(?:oklch|oklab)\b)/gi, () => {
|
|
560
|
+
count102++;
|
|
561
|
+
return 'conic-gradient(in oklch, ';
|
|
562
|
+
});
|
|
563
|
+
if (count102 > 0) {
|
|
564
|
+
fixes.push('Normalized color gamut to perceptual OKLCH interpolation space (MD102)');
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// 11. RULE MD103: Concentric Radius Math Helper
|
|
568
|
+
let count103 = 0;
|
|
569
|
+
const hasOuterRadius = /border-radius:\s*\d+px/i.test(content);
|
|
570
|
+
const hasInnerConcentric = /max\(\s*0px/i.test(content) || /calc\(infinity/i.test(content) || /--corner-r/i.test(content);
|
|
571
|
+
if (hasOuterRadius && !hasInnerConcentric) {
|
|
572
|
+
const concentricRule = `\n /* MD103 Safe Concentric Radius Formula */\n :root { --radius-inner: max(0px, var(--radius-outer, 16px) - 1px - 8px); }\n`;
|
|
573
|
+
if (content.includes('</style>')) {
|
|
574
|
+
content = content.replace('</style>', `${concentricRule} </style>`);
|
|
575
|
+
count103++;
|
|
576
|
+
} else if (resolvedPath.endsWith('.css') || !isHtml) {
|
|
577
|
+
content = content.trimEnd() + '\n' + concentricRule;
|
|
578
|
+
count103++;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (count103 > 0) {
|
|
582
|
+
fixes.push('Injected safe concentric radius formula max(0px, r_outer - border_w - pad) (MD103)');
|
|
583
|
+
}
|
|
584
|
+
|
|
349
585
|
fs.writeFileSync(resolvedPath, content, 'utf8');
|
|
350
586
|
|
|
351
587
|
let afterQ = beforeQ;
|
|
@@ -365,9 +601,21 @@ ${ANSI_GRAY}──────────────────────
|
|
|
365
601
|
|
|
366
602
|
case 'bolder': {
|
|
367
603
|
const targetFile = args[1];
|
|
368
|
-
if (!targetFile) {
|
|
369
|
-
console.
|
|
370
|
-
|
|
604
|
+
if (!targetFile || targetFile === '--help' || targetFile === '-h') {
|
|
605
|
+
console.log(`
|
|
606
|
+
${ANSI_BOLD}ME-DESIGN Bolder Modifier${ANSI_RESET}
|
|
607
|
+
${ANSI_GRAY}Elevate visual density, typography weights, and color saturation${ANSI_RESET}
|
|
608
|
+
|
|
609
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
610
|
+
medesign bolder <file>
|
|
611
|
+
mebolder <file>
|
|
612
|
+
|
|
613
|
+
${ANSI_BOLD}Modifications:${ANSI_RESET}
|
|
614
|
+
- Elevates font weights: normal/400 -> 600, medium/500 -> 700
|
|
615
|
+
- Deepens subtle translucent borders (border-white/10 -> border-white/20)
|
|
616
|
+
- Boosts OKLCH chroma by ~25%
|
|
617
|
+
`);
|
|
618
|
+
process.exit(targetFile === '--help' || targetFile === '-h' ? 0 : 1);
|
|
371
619
|
}
|
|
372
620
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
373
621
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -461,9 +709,21 @@ ${ANSI_GRAY}──────────────────────
|
|
|
461
709
|
|
|
462
710
|
case 'quiet': {
|
|
463
711
|
const targetFile = args[1];
|
|
464
|
-
if (!targetFile) {
|
|
465
|
-
console.
|
|
466
|
-
|
|
712
|
+
if (!targetFile || targetFile === '--help' || targetFile === '-h') {
|
|
713
|
+
console.log(`
|
|
714
|
+
${ANSI_BOLD}ME-DESIGN Quiet Modifier${ANSI_RESET}
|
|
715
|
+
${ANSI_GRAY}Soften visual density, typography weights, and border contrast${ANSI_RESET}
|
|
716
|
+
|
|
717
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
718
|
+
medesign quiet <file>
|
|
719
|
+
mequiet <file>
|
|
720
|
+
|
|
721
|
+
${ANSI_BOLD}Modifications:${ANSI_RESET}
|
|
722
|
+
- Softens font weights: bold/700 -> 500, semibold/600 -> 500
|
|
723
|
+
- Reduces borders to hairline borders
|
|
724
|
+
- Softens OKLCH chroma by ~30%
|
|
725
|
+
`);
|
|
726
|
+
process.exit(targetFile === '--help' || targetFile === '-h' ? 0 : 1);
|
|
467
727
|
}
|
|
468
728
|
const resolvedPath = path.resolve(process.cwd(), targetFile);
|
|
469
729
|
if (!fs.existsSync(resolvedPath)) {
|
|
@@ -575,6 +835,15 @@ ${ANSI_GRAY}──────────────────────
|
|
|
575
835
|
process.exit(child.status ?? 0);
|
|
576
836
|
}
|
|
577
837
|
|
|
838
|
+
case 'snapshot': {
|
|
839
|
+
const snapshotScript = path.join(rootDir, 'tests', 'snapshot.js');
|
|
840
|
+
const child = spawnSync(process.execPath, [snapshotScript, ...args.slice(1)], {
|
|
841
|
+
stdio: 'inherit',
|
|
842
|
+
cwd: process.cwd()
|
|
843
|
+
});
|
|
844
|
+
process.exit(child.status ?? 0);
|
|
845
|
+
}
|
|
846
|
+
|
|
578
847
|
case 'tokens': {
|
|
579
848
|
const exportScript = path.join(rootDir, 'scripts', 'export-tokens.js');
|
|
580
849
|
const exportArgs = args.slice(1).filter(a => a !== 'export');
|
|
@@ -587,6 +856,17 @@ ${ANSI_GRAY}──────────────────────
|
|
|
587
856
|
|
|
588
857
|
case 'presets': {
|
|
589
858
|
const sub = args[1] || 'list';
|
|
859
|
+
if (sub === '--help' || sub === '-h' || sub === 'help') {
|
|
860
|
+
console.log(`
|
|
861
|
+
${ANSI_BOLD}ME-DESIGN Presets Inspector${ANSI_RESET}
|
|
862
|
+
${ANSI_GRAY}Inspect available design system presets${ANSI_RESET}
|
|
863
|
+
|
|
864
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
865
|
+
medesign presets list
|
|
866
|
+
medesign presets get <preset-name>
|
|
867
|
+
`);
|
|
868
|
+
process.exit(0);
|
|
869
|
+
}
|
|
590
870
|
const presetsDir = path.join(rootDir, 'presets');
|
|
591
871
|
if (sub === 'list') {
|
|
592
872
|
console.log(`\n${ANSI_BOLD}AVAILABLE ME-DESIGN PRESETS:${ANSI_RESET}\n`);
|
|
@@ -619,6 +899,17 @@ ${ANSI_GRAY}──────────────────────
|
|
|
619
899
|
}
|
|
620
900
|
|
|
621
901
|
case 'test': {
|
|
902
|
+
if (args[1] === '--help' || args[1] === '-h') {
|
|
903
|
+
console.log(`
|
|
904
|
+
${ANSI_BOLD}ME-DESIGN Test Runner${ANSI_RESET}
|
|
905
|
+
${ANSI_GRAY}Run deterministic AST & semantic rule test suites${ANSI_RESET}
|
|
906
|
+
|
|
907
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
908
|
+
medesign test
|
|
909
|
+
medesign test --browser
|
|
910
|
+
`);
|
|
911
|
+
process.exit(0);
|
|
912
|
+
}
|
|
622
913
|
const runnerScript = path.join(rootDir, 'tests', 'runner.js');
|
|
623
914
|
const child = spawnSync(process.execPath, [runnerScript, ...args.slice(1)], {
|
|
624
915
|
stdio: 'inherit',
|
|
@@ -628,6 +919,16 @@ ${ANSI_GRAY}──────────────────────
|
|
|
628
919
|
}
|
|
629
920
|
|
|
630
921
|
case 'doctor': {
|
|
922
|
+
if (args[1] === '--help' || args[1] === '-h') {
|
|
923
|
+
console.log(`
|
|
924
|
+
${ANSI_BOLD}ME-DESIGN Environment Doctor${ANSI_RESET}
|
|
925
|
+
${ANSI_GRAY}Verify local environment, Node.js, and Chrome/CDP availability${ANSI_RESET}
|
|
926
|
+
|
|
927
|
+
${ANSI_BOLD}Usage:${ANSI_RESET}
|
|
928
|
+
medesign doctor
|
|
929
|
+
`);
|
|
930
|
+
process.exit(0);
|
|
931
|
+
}
|
|
631
932
|
console.log(`\n${ANSI_BOLD}ME-DESIGN System Health & Environment Doctor${ANSI_RESET}`);
|
|
632
933
|
console.log(`${ANSI_GRAY}────────────────────────────────────────${ANSI_RESET}\n`);
|
|
633
934
|
|
package/bin/melint.js
ADDED
package/bin/mepolish.js
ADDED
package/bin/mequiet.js
ADDED
package/bin/mesearch.js
ADDED