@hahlex/millar-mcp 0.0.0-stage → 0.1.0-draft.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/LICENSE +21 -0
- package/dist/docs/CHANGELOG.md +21 -0
- package/dist/docs/GLOSSARY.md +77 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +39566 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1115 -0
- package/dist/server.js.map +1 -0
- package/dist/skills/millar-animation/SKILL.md +66 -0
- package/dist/skills/millar-animation/references/animation-research-patterns.md +28 -0
- package/dist/skills/millar-animation/references/motion-choreography.md +80 -0
- package/dist/skills/millar-build-web/SKILL.md +59 -0
- package/dist/skills/millar-build-web/references/seo-cwv-and-copy.md +24 -0
- package/dist/skills/millar-build-web/references/web-architecture-checklist.md +47 -0
- package/dist/skills/millar-create-image/SKILL.md +62 -0
- package/dist/skills/millar-create-image/references/human-editorial-photography.md +74 -0
- package/dist/skills/millar-create-image/references/hybrid-plate-compositing.md +43 -0
- package/dist/skills/millar-create-image/references/image-art-direction.md +74 -0
- package/dist/skills/millar-create-image/references/multi-page-asset-map.md +27 -0
- package/dist/skills/millar-create-image/references/natural-editorial-illustration.md +57 -0
- package/dist/skills/millar-create-image/references/procedural-gallery-craft.md +84 -0
- package/dist/skills/millar-create-image/scripts/embed-provenance.mjs +185 -0
- package/dist/skills/millar-deep-research/SKILL.md +62 -0
- package/dist/skills/millar-deep-research/references/visual-extraction-protocol.md +36 -0
- package/dist/skills/millar-deep-research/references/world-class-benchmarks.md +30 -0
- package/dist/skills/millar-design/SKILL.md +83 -0
- package/dist/skills/millar-design/references/aesthetic-movements.md +49 -0
- package/dist/skills/millar-design/references/cross-page-sync-audit.md +25 -0
- package/dist/skills/millar-design/references/style-dna-contract.md +89 -0
- package/dist/skills/millar-verify-web/SKILL.md +76 -0
- package/dist/skills/millar-verify-web/references/five-layer-qa-gate.md +104 -0
- package/dist/skills/millar-verify-web/references/two-axis-review-rubric.md +23 -0
- package/dist/skills/millar-verify-web/scripts/millar-audit.mjs +617 -0
- package/dist/skills/millar-web-workflow/SKILL.md +60 -0
- package/dist/skills/millar-web-workflow/references/creative-divergence-protocol.md +52 -0
- package/dist/skills/millar-web-workflow/references/track-routing-and-gates.md +32 -0
- package/dist/skills-loader.d.ts +47 -0
- package/dist/skills-loader.d.ts.map +1 -0
- package/dist/skills-loader.js +204 -0
- package/dist/skills-loader.js.map +1 -0
- package/dist/sources/packages/marketing/src/assets/BrandAndGeometricAssets.tsx +373 -0
- package/dist/sources/packages/marketing/src/assets/SchematicAndProductAssets.tsx +497 -0
- package/dist/sources/packages/marketing/src/sections/MarketingSections.tsx +946 -0
- package/dist/sources/packages/marketing/src/templates/PageTemplates.tsx +304 -0
- package/dist/sources/packages/ui/src/components/Button.tsx +162 -0
- package/dist/sources/packages/ui/src/components/FormControls.tsx +476 -0
- package/dist/sources/packages/ui/src/components/Layout.tsx +176 -0
- package/dist/sources/packages/ui/src/components/OverlaysAndFeedback.tsx +291 -0
- package/dist/sources/packages/ui/src/components/SurfacesAndData.tsx +564 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +37380 -0
- package/dist/stdio.js.map +1 -0
- package/package.json +48 -3
- package/README.md +0 -3
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* millar-audit.mjs (v0.3.0): Standalone Zero-MCP Mechanical Web & Design Auditor
|
|
4
|
+
*
|
|
5
|
+
* Bundled inside skills/millar-verify-web/scripts/ so users installing Millar Skills
|
|
6
|
+
* via `npx millar install` retain deterministic mechanical verification even WITHOUT Millar MCP:
|
|
7
|
+
* - WCAG 2.1 text contrast (>= 4.5:1) across light, dark, and stage CSS tokens + telemetry count
|
|
8
|
+
* - WCAG SC 1.4.11 UI control border contrast (>= 3.0:1)
|
|
9
|
+
* - AI-slop Craft Floor checks (gradient text, eyebrow kickers, 1-sided rounded-box bars, hard shadows)
|
|
10
|
+
* - Inline <style> & stylesheet prefers-reduced-motion check + [hidden] CSS override guard
|
|
11
|
+
* - Accessibility & CWV checks (img alt/width/height, undersized text, static opacity:0 traps)
|
|
12
|
+
* - Product-register CSS gradient ban (--register=product) & U+2014 em-dash check (--strict-em-dash)
|
|
13
|
+
* - Sparse inline <svg> clip-art detector
|
|
14
|
+
* - Optional live-browser check (--url=http://...) across 1440/768/375 viewports
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* node millar-audit.mjs <target-path> [--register=shared|marketing|product] [--strict-em-dash] [--include-internal] [--json] [--url=http://...]
|
|
18
|
+
*
|
|
19
|
+
* Zero external npm dependencies required (Node.js >= 18).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
import { createRequire } from "node:module";
|
|
25
|
+
|
|
26
|
+
const BASE_IGNORE_DIRS = new Set([
|
|
27
|
+
".git",
|
|
28
|
+
"node_modules",
|
|
29
|
+
".next",
|
|
30
|
+
"dist",
|
|
31
|
+
"out",
|
|
32
|
+
"build",
|
|
33
|
+
"coverage",
|
|
34
|
+
".turbo",
|
|
35
|
+
"playwright-report",
|
|
36
|
+
"test-results",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const CODE_EXTS = new Set([".html", ".htm", ".css", ".scss", ".tsx", ".jsx", ".ts", ".js", ".vue", ".svelte", ".astro"]);
|
|
40
|
+
const COPY_EXTS = new Set([".html", ".htm", ".tsx", ".jsx", ".md", ".mdx", ".vue", ".svelte", ".astro"]);
|
|
41
|
+
const EM_DASH = "\u2014";
|
|
42
|
+
|
|
43
|
+
/** @typedef {{ severity: "error" | "warn"; rule: string; file: string; line?: number; message: string }} Finding */
|
|
44
|
+
|
|
45
|
+
function parseArgs(argv) {
|
|
46
|
+
const opts = {
|
|
47
|
+
target: ".",
|
|
48
|
+
register: "shared",
|
|
49
|
+
strictEmDash: false,
|
|
50
|
+
includeInternal: false,
|
|
51
|
+
json: false,
|
|
52
|
+
url: null,
|
|
53
|
+
};
|
|
54
|
+
for (const arg of argv) {
|
|
55
|
+
if (arg.startsWith("--register=")) opts.register = arg.slice("--register=".length);
|
|
56
|
+
else if (arg === "--strict-em-dash") opts.strictEmDash = true;
|
|
57
|
+
else if (arg === "--include-internal") opts.includeInternal = true;
|
|
58
|
+
else if (arg === "--json") opts.json = true;
|
|
59
|
+
else if (arg.startsWith("--url=")) opts.url = arg.slice("--url=".length);
|
|
60
|
+
else if (!arg.startsWith("--")) opts.target = arg;
|
|
61
|
+
}
|
|
62
|
+
return opts;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function collectFiles(targetPath, includeInternal) {
|
|
66
|
+
const abs = path.resolve(process.cwd(), targetPath);
|
|
67
|
+
if (!fs.existsSync(abs)) {
|
|
68
|
+
throw new Error(`Target path does not exist: ${abs}`);
|
|
69
|
+
}
|
|
70
|
+
const stat = fs.statSync(abs);
|
|
71
|
+
if (stat.isFile()) return [abs];
|
|
72
|
+
|
|
73
|
+
/** @type {string[]} */
|
|
74
|
+
const files = [];
|
|
75
|
+
function walk(dir) {
|
|
76
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
77
|
+
if (BASE_IGNORE_DIRS.has(entry.name)) continue;
|
|
78
|
+
if (!includeInternal && entry.name === ".millar") continue;
|
|
79
|
+
const full = path.join(dir, entry.name);
|
|
80
|
+
if (entry.isDirectory()) walk(full);
|
|
81
|
+
else files.push(full);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
walk(abs);
|
|
85
|
+
return files;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function parseHexColor(hex) {
|
|
89
|
+
const clean = hex.trim().replace(/^#/, "");
|
|
90
|
+
if (clean.length === 3) {
|
|
91
|
+
return clean.split("").map((c) => parseInt(c + c, 16));
|
|
92
|
+
}
|
|
93
|
+
if (clean.length === 6) {
|
|
94
|
+
return [parseInt(clean.slice(0, 2), 16), parseInt(clean.slice(2, 4), 16), parseInt(clean.slice(4, 6), 16)];
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function relativeLuminance(rgb) {
|
|
100
|
+
const [r, g, b] = rgb.map((v) => {
|
|
101
|
+
const s = v / 255;
|
|
102
|
+
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
103
|
+
});
|
|
104
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function contrastRatio(hexA, hexB) {
|
|
108
|
+
const a = parseHexColor(hexA);
|
|
109
|
+
const b = parseHexColor(hexB);
|
|
110
|
+
if (!a || !b) return null;
|
|
111
|
+
const la = relativeLuminance(a);
|
|
112
|
+
const lb = relativeLuminance(b);
|
|
113
|
+
const lighter = Math.max(la, lb);
|
|
114
|
+
const darker = Math.min(la, lb);
|
|
115
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Audit CSS custom property text (WCAG AA 4.5:1) and UI border (SC 1.4.11 3.0:1) pairs.
|
|
120
|
+
* Returns number of pairs checked so callers never get a silent zero-pair pass.
|
|
121
|
+
* @param {string} rel
|
|
122
|
+
* @param {string} content
|
|
123
|
+
* @param {Finding[]} findings
|
|
124
|
+
* @returns {number}
|
|
125
|
+
*/
|
|
126
|
+
function auditCssContrast(rel, content, findings) {
|
|
127
|
+
let checked = 0;
|
|
128
|
+
const blocks = [...content.matchAll(/(?::root|html|\[data-theme=["']?(?:light|dark)["']?\]|\.dark|\.light)\s*\{([\s\S]*?)\}/g)];
|
|
129
|
+
|
|
130
|
+
const textPairs = [
|
|
131
|
+
["--bg-app", "--fg-default", 4.5],
|
|
132
|
+
["--bg-surface", "--fg-default", 4.5],
|
|
133
|
+
["--bg-app", "--fg-muted", 4.5],
|
|
134
|
+
["--bg-surface", "--fg-muted", 4.5],
|
|
135
|
+
["--bg-primary", "--fg-primary", 4.5],
|
|
136
|
+
["--bg-canvas", "--ink-primary", 4.5],
|
|
137
|
+
["--bg-canvas", "--ink-muted", 4.5],
|
|
138
|
+
["--bg-stage", "--fg-on-stage", 4.5],
|
|
139
|
+
["--bg-stage", "--fg-stage-muted", 4.5],
|
|
140
|
+
["--bg-stage-dark", "--fg-on-stage-dark", 4.5],
|
|
141
|
+
["--bg-dark", "--fg-on-dark", 4.5],
|
|
142
|
+
["--accent-primary", "--fg-on-accent", 4.5],
|
|
143
|
+
["--accent", "--fg-on-accent", 4.5],
|
|
144
|
+
["--hx-cream-50", "--hx-ink-900", 4.5],
|
|
145
|
+
["--hx-cream-50", "--hx-ink-700", 4.5],
|
|
146
|
+
["--hx-espresso-800", "--hx-paper", 4.5],
|
|
147
|
+
["--hx-espresso-800", "--hx-paper-muted", 4.5],
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
const uiBorderPairs = [
|
|
151
|
+
["--bg-surface", "--border-control", 3.0],
|
|
152
|
+
["--bg-app", "--border-control", 3.0],
|
|
153
|
+
["--bg-surface", "--border-input", 3.0],
|
|
154
|
+
["--bg-surface", "--border-strong", 3.0],
|
|
155
|
+
["--bg-app", "--border-strong", 3.0],
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
for (const block of blocks) {
|
|
159
|
+
const body = block[1] ?? "";
|
|
160
|
+
const vars = new Map();
|
|
161
|
+
for (const m of body.matchAll(/(--[a-zA-Z0-9_-]+)\s*:\s*(#[0-9a-fA-F]{3,6})\b/g)) {
|
|
162
|
+
vars.set(m[1], m[2]);
|
|
163
|
+
}
|
|
164
|
+
if (vars.size === 0) continue;
|
|
165
|
+
|
|
166
|
+
for (const [bgKey, fgKey, minRatio] of textPairs) {
|
|
167
|
+
const bg = vars.get(bgKey);
|
|
168
|
+
const fg = vars.get(fgKey);
|
|
169
|
+
if (!bg || !fg) continue;
|
|
170
|
+
const ratio = contrastRatio(bg, fg);
|
|
171
|
+
if (ratio === null) continue;
|
|
172
|
+
checked += 1;
|
|
173
|
+
if (ratio < minRatio) {
|
|
174
|
+
findings.push({
|
|
175
|
+
severity: "error",
|
|
176
|
+
rule: "wcag/contrast-pair",
|
|
177
|
+
file: rel,
|
|
178
|
+
message: `Text token pair ${fgKey} (${fg}) on ${bgKey} (${bg}) has contrast ${ratio.toFixed(2)}:1 (requires >= ${minRatio}:1 WCAG AA).`,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const [bgKey, borderKey, minRatio] of uiBorderPairs) {
|
|
184
|
+
const bg = vars.get(bgKey);
|
|
185
|
+
const border = vars.get(borderKey);
|
|
186
|
+
if (!bg || !border) continue;
|
|
187
|
+
const ratio = contrastRatio(bg, border);
|
|
188
|
+
if (ratio === null) continue;
|
|
189
|
+
checked += 1;
|
|
190
|
+
if (ratio < minRatio) {
|
|
191
|
+
findings.push({
|
|
192
|
+
severity: "warn",
|
|
193
|
+
rule: "wcag/ui-border-contrast",
|
|
194
|
+
file: rel,
|
|
195
|
+
message: `UI control border ${borderKey} (${border}) on ${bgKey} (${bg}) has contrast ${ratio.toFixed(2)}:1 (WCAG SC 1.4.11 requires >= ${minRatio}:1 for interactive control boundaries).`,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return checked;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Audit inline editorial SVGs for flat low-primitive clip-art tells.
|
|
205
|
+
* @param {string} rel
|
|
206
|
+
* @param {string} content
|
|
207
|
+
* @param {Finding[]} findings
|
|
208
|
+
*/
|
|
209
|
+
function auditInlineSvgs(rel, content, findings) {
|
|
210
|
+
const svgs = [...content.matchAll(/<svg\b([^>]*)>([\s\S]*?)<\/svg>/gi)];
|
|
211
|
+
for (const match of svgs) {
|
|
212
|
+
const attrs = match[1] ?? "";
|
|
213
|
+
const inner = match[2] ?? "";
|
|
214
|
+
const widthMatch = attrs.match(/\bwidth\s*=\s*["']?(\d+)/i);
|
|
215
|
+
const viewBoxMatch = attrs.match(/viewBox\s*=\s*["']?\s*[\d.-]+\s+[\d.-]+\s+([\d.]+)\s+([\d.]+)/i);
|
|
216
|
+
const width = widthMatch ? Number(widthMatch[1]) : viewBoxMatch ? Number(viewBoxMatch[1]) : 0;
|
|
217
|
+
if (width < 180) continue;
|
|
218
|
+
|
|
219
|
+
const primitiveCount = (inner.match(/<(?:path|circle|ellipse|rect|polygon|polyline|line)\b/gi) ?? []).length;
|
|
220
|
+
const hasDepthDefs = /<(?:defs|filter|linearGradient|radialGradient|pattern|feTurbulence)\b/i.test(inner);
|
|
221
|
+
if (primitiveCount > 0 && primitiveCount < 15 && !hasDepthDefs) {
|
|
222
|
+
findings.push({
|
|
223
|
+
severity: "warn",
|
|
224
|
+
rule: "craft/sparse-svg-clipart",
|
|
225
|
+
file: rel,
|
|
226
|
+
message: `Large inline <svg> (${width}px) has only ${primitiveCount} primitives and zero <defs>/lighting/grain filters. Check against flat clip-art ban (procedural-gallery-craft.md).`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Scan a single file deterministically.
|
|
234
|
+
* @param {string} absFile
|
|
235
|
+
* @param {ReturnType<typeof parseArgs>} opts
|
|
236
|
+
* @param {Finding[]} findings
|
|
237
|
+
* @returns {{ contrastPairsChecked: number }}
|
|
238
|
+
*/
|
|
239
|
+
function auditFile(absFile, opts, findings) {
|
|
240
|
+
const ext = path.extname(absFile).toLowerCase();
|
|
241
|
+
if (!CODE_EXTS.has(ext) && !COPY_EXTS.has(ext)) return { contrastPairsChecked: 0 };
|
|
242
|
+
|
|
243
|
+
const rel = path.relative(process.cwd(), absFile).replaceAll("\\", "/");
|
|
244
|
+
const content = fs.readFileSync(absFile, "utf8");
|
|
245
|
+
const lines = content.split(/\r?\n/);
|
|
246
|
+
let contrastPairsChecked = 0;
|
|
247
|
+
|
|
248
|
+
const isCode = CODE_EXTS.has(ext);
|
|
249
|
+
const isMarkup = [".html", ".htm", ".tsx", ".jsx", ".vue", ".svelte", ".astro"].includes(ext);
|
|
250
|
+
const isStyle = [".css", ".scss", ".html", ".htm", ".tsx", ".jsx"].includes(ext);
|
|
251
|
+
|
|
252
|
+
// 1. Em-dash check
|
|
253
|
+
if (COPY_EXTS.has(ext) || isCode) {
|
|
254
|
+
lines.forEach((line, idx) => {
|
|
255
|
+
if (!line.includes(EM_DASH) || line.includes("em-dash-fixture-ok")) return;
|
|
256
|
+
findings.push({
|
|
257
|
+
severity: opts.strictEmDash ? "error" : "warn",
|
|
258
|
+
rule: "copy/em-dash",
|
|
259
|
+
file: rel,
|
|
260
|
+
line: idx + 1,
|
|
261
|
+
message: "Contains U+2014 em-dash character (replace with colon, comma, parentheses, or hyphen).",
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (!isCode) return { contrastPairsChecked };
|
|
267
|
+
|
|
268
|
+
// 2. Style & Craft-Floor checks (external CSS AND inline <style> inside HTML!)
|
|
269
|
+
if (isStyle) {
|
|
270
|
+
contrastPairsChecked += auditCssContrast(rel, content, findings);
|
|
271
|
+
|
|
272
|
+
lines.forEach((line, idx) => {
|
|
273
|
+
const lineNo = idx + 1;
|
|
274
|
+
|
|
275
|
+
if (/(?:background-clip\s*:\s*text|bg-clip-text)/i.test(line)) {
|
|
276
|
+
findings.push({
|
|
277
|
+
severity: "error",
|
|
278
|
+
rule: "craft/no-gradient-text",
|
|
279
|
+
file: rel,
|
|
280
|
+
line: lineNo,
|
|
281
|
+
message: "Gradient text detected (craft floor ban: use weight, scale, or contrast instead).",
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (opts.register === "product" && /(?:linear-gradient|radial-gradient|conic-gradient)\s*\(/i.test(line) && !line.includes("approved-visual-asset")) {
|
|
286
|
+
findings.push({
|
|
287
|
+
severity: "error",
|
|
288
|
+
rule: "product/no-css-gradients",
|
|
289
|
+
file: rel,
|
|
290
|
+
line: lineNo,
|
|
291
|
+
message: "CSS gradient detected in Product UI register (forbidden on operational chrome).",
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (/box-shadow\s*:[^;]*\b[3-8]px\s+[3-8]px\s+0(?:px)?\b/i.test(line) && !line.includes("neobrutalist-ok")) {
|
|
296
|
+
findings.push({
|
|
297
|
+
severity: "warn",
|
|
298
|
+
rule: "craft/hard-offset-shadow",
|
|
299
|
+
file: rel,
|
|
300
|
+
line: lineNo,
|
|
301
|
+
message: "Zero-blur hard offset box-shadow detected (only valid in an intentional neobrutalist system).",
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (/border-left\s*:\s*[3-6]px\s+solid\b/i.test(line)) {
|
|
306
|
+
findings.push({
|
|
307
|
+
severity: "warn",
|
|
308
|
+
rule: "craft/one-sided-border-strip",
|
|
309
|
+
file: rel,
|
|
310
|
+
line: lineNo,
|
|
311
|
+
message: "Thick 1-sided border-left strip detected (avoid on rounded cards; prefer full hairline border, surface tint, or leading icon).",
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (/font-size\s*:\s*(?:[6-9]|10)px\b/i.test(line)) {
|
|
316
|
+
findings.push({
|
|
317
|
+
severity: "warn",
|
|
318
|
+
rule: "a11y/undersized-text",
|
|
319
|
+
file: rel,
|
|
320
|
+
line: lineNo,
|
|
321
|
+
message: "Text size <= 10px detected (fails readability floor; keep UI micro labels >= 11-12px and body >= 14-16px).",
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const isStylesheetOrEmbedded = ext === ".css" || ext === ".scss" || ((ext === ".html" || ext === ".htm") && /<style\b/i.test(content));
|
|
327
|
+
const hasMotion = /@keyframes\b|animation\s*:|transition\s*:/i.test(content);
|
|
328
|
+
const hasReducedMotion = /prefers-reduced-motion\s*:\s*reduce/i.test(content);
|
|
329
|
+
if (isStylesheetOrEmbedded && hasMotion && !hasReducedMotion) {
|
|
330
|
+
findings.push({
|
|
331
|
+
severity: "warn",
|
|
332
|
+
rule: "motion/missing-reduced-motion",
|
|
333
|
+
file: rel,
|
|
334
|
+
message: "Styles define animations/transitions without a @media (prefers-reduced-motion: reduce) fallback.",
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 3. Markup accessibility, Craft Floor, [hidden] guard, CLS & clip-art checks
|
|
340
|
+
if (isMarkup) {
|
|
341
|
+
auditInlineSvgs(rel, content, findings);
|
|
342
|
+
|
|
343
|
+
// Eyebrow kicker above heading tell
|
|
344
|
+
if (/<(?:div|p|span)\b[^>]*class=["'][^"']*\b(?:eyebrow|hero-eyebrow|section-kicker|kicker|heading-kicker)\b[^"']*["'][^>]*>[\s\S]{0,120}<\/(?:div|p|span)>\s*<h[12]\b/i.test(content)) {
|
|
345
|
+
findings.push({
|
|
346
|
+
severity: "warn",
|
|
347
|
+
rule: "craft/eyebrow-kicker",
|
|
348
|
+
file: rel,
|
|
349
|
+
message: "Eyebrow/kicker label detected immediately above <h1>/<h2> (Craft Floor rule: delete decorative eyebrow labels and let the heading carry its own weight).",
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// [hidden] attribute overridden by display:flex/grid without reset
|
|
354
|
+
if ((ext === ".html" || ext === ".htm") && /\bhidden(?:\s|>|=)/i.test(content) && /display\s*:\s*(?:flex|inline-flex|grid)\b/i.test(content) && !/\[hidden\]\s*\{[^}]*display\s*:\s*none\s*!important/i.test(content)) {
|
|
355
|
+
findings.push({
|
|
356
|
+
severity: "warn",
|
|
357
|
+
rule: "css/hidden-override-guard",
|
|
358
|
+
file: rel,
|
|
359
|
+
message: "HTML uses `hidden` attribute alongside display:flex/grid without `[hidden] { display: none !important; }` reset (risks broken mutually exclusive UI states).",
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
for (const imgMatch of content.matchAll(/<img\b([^>]*)>/gi)) {
|
|
364
|
+
const attrs = imgMatch[1] ?? "";
|
|
365
|
+
if (!/\balt\s*=/i.test(attrs)) {
|
|
366
|
+
findings.push({
|
|
367
|
+
severity: "error",
|
|
368
|
+
rule: "a11y/img-missing-alt",
|
|
369
|
+
file: rel,
|
|
370
|
+
message: "<img> element missing alt attribute.",
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
if (!/\bwidth\s*=/i.test(attrs) && !/\baspect-ratio\b/i.test(attrs)) {
|
|
374
|
+
findings.push({
|
|
375
|
+
severity: "warn",
|
|
376
|
+
rule: "cwv/img-missing-dimensions",
|
|
377
|
+
file: rel,
|
|
378
|
+
message: "<img> missing explicit width/height (risks Cumulative Layout Shift).",
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (/(?:opacity:\s*0\b|opacity-0\b)/.test(content) && /(?:IntersectionObserver|data-reveal|scroll)/i.test(content) && !/prefers-reduced-motion/i.test(content)) {
|
|
384
|
+
findings.push({
|
|
385
|
+
severity: "warn",
|
|
386
|
+
rule: "motion/potential-scroll-trap",
|
|
387
|
+
file: rel,
|
|
388
|
+
message: "Potential opacity: 0 scroll-reveal trap detected without explicit prefers-reduced-motion visible fallback.",
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return { contrastPairsChecked };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Resolve playwright / @playwright/test from MILLAR_PLAYWRIGHT_PATH, cwd, or script ancestor workspaces.
|
|
398
|
+
*/
|
|
399
|
+
async function resolvePlaywright() {
|
|
400
|
+
const roots = [
|
|
401
|
+
process.env.MILLAR_PLAYWRIGHT_PATH,
|
|
402
|
+
path.join(process.cwd(), "package.json"),
|
|
403
|
+
path.resolve(import.meta.dirname, "../../../package.json"),
|
|
404
|
+
path.resolve(import.meta.dirname, "../../../../package.json"),
|
|
405
|
+
].filter(Boolean);
|
|
406
|
+
|
|
407
|
+
for (const base of roots) {
|
|
408
|
+
try {
|
|
409
|
+
const req = createRequire(base);
|
|
410
|
+
for (const modName of ["playwright", "@playwright/test"]) {
|
|
411
|
+
try {
|
|
412
|
+
const mod = req(modName);
|
|
413
|
+
if (mod?.chromium) return mod;
|
|
414
|
+
} catch {
|
|
415
|
+
// continue
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
} catch {
|
|
419
|
+
// continue
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
for (const modName of ["playwright", "@playwright/test"]) {
|
|
423
|
+
try {
|
|
424
|
+
const mod = await import(modName);
|
|
425
|
+
if (mod?.chromium) return mod;
|
|
426
|
+
} catch {
|
|
427
|
+
// continue
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Optional live-browser check when --url is supplied and Playwright is resolvable.
|
|
435
|
+
* @param {string} url
|
|
436
|
+
* @param {Finding[]} findings
|
|
437
|
+
*/
|
|
438
|
+
async function auditLiveUrl(url, findings) {
|
|
439
|
+
const playwright = await resolvePlaywright();
|
|
440
|
+
if (!playwright?.chromium) {
|
|
441
|
+
findings.push({
|
|
442
|
+
severity: "warn",
|
|
443
|
+
rule: "browser/playwright-unavailable",
|
|
444
|
+
file: url,
|
|
445
|
+
message: "Skipped live URL check because neither 'playwright' nor '@playwright/test' could be resolved (set MILLAR_PLAYWRIGHT_PATH or install @playwright/test).",
|
|
446
|
+
});
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
let browser = null;
|
|
451
|
+
for (const launchOpts of [{}, { channel: "chrome" }, { channel: "msedge" }]) {
|
|
452
|
+
try {
|
|
453
|
+
browser = await playwright.chromium.launch(launchOpts);
|
|
454
|
+
break;
|
|
455
|
+
} catch {
|
|
456
|
+
browser = null;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (!browser) {
|
|
460
|
+
findings.push({
|
|
461
|
+
severity: "warn",
|
|
462
|
+
rule: "browser/launch-unavailable",
|
|
463
|
+
file: url,
|
|
464
|
+
message: "Skipped live URL check because no Chromium/Chrome/Edge binary could be launched.",
|
|
465
|
+
});
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
const context = await browser.newContext();
|
|
471
|
+
const page = await context.newPage();
|
|
472
|
+
const consoleErrors = [];
|
|
473
|
+
const httpErrors = [];
|
|
474
|
+
page.on("pageerror", (err) => consoleErrors.push(err.message));
|
|
475
|
+
page.on("console", (msg) => {
|
|
476
|
+
if (msg.type() === "error") consoleErrors.push(msg.text());
|
|
477
|
+
});
|
|
478
|
+
page.on("response", (res) => {
|
|
479
|
+
if (res.status() >= 400) httpErrors.push(`${res.status()} ${res.url()}`);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
for (const vp of [
|
|
483
|
+
{ name: "desktop", width: 1440, height: 900 },
|
|
484
|
+
{ name: "tablet", width: 768, height: 1024 },
|
|
485
|
+
{ name: "mobile", width: 375, height: 812 },
|
|
486
|
+
]) {
|
|
487
|
+
await page.setViewportSize({ width: vp.width, height: vp.height });
|
|
488
|
+
await page.goto(url, { waitUntil: "networkidle", timeout: 25000 });
|
|
489
|
+
|
|
490
|
+
const metrics = await page.evaluate(() => {
|
|
491
|
+
const overflow = document.documentElement.scrollWidth > window.innerWidth + 1;
|
|
492
|
+
const mains = document.querySelectorAll("main");
|
|
493
|
+
const footers = document.querySelectorAll("footer");
|
|
494
|
+
const footerInsideMain = Boolean(mains[0] && footers[0] && mains[0].contains(footers[0]));
|
|
495
|
+
/** @type {Record<string, number>} */
|
|
496
|
+
const vtCounts = {};
|
|
497
|
+
for (const el of document.querySelectorAll("*")) {
|
|
498
|
+
const style = window.getComputedStyle(el);
|
|
499
|
+
if (style.display === "none" || style.visibility === "hidden") continue;
|
|
500
|
+
const vtn = style.viewTransitionName;
|
|
501
|
+
if (vtn && vtn !== "none") {
|
|
502
|
+
vtCounts[vtn] = (vtCounts[vtn] || 0) + 1;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const duplicateViewTransitionNames = Object.entries(vtCounts)
|
|
506
|
+
.filter(([, count]) => count > 1)
|
|
507
|
+
.map(([name, count]) => `${name} (${count}x)`);
|
|
508
|
+
return {
|
|
509
|
+
overflow,
|
|
510
|
+
mainCount: mains.length,
|
|
511
|
+
footerCount: footers.length,
|
|
512
|
+
footerInsideMain,
|
|
513
|
+
duplicateViewTransitionNames,
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
if (metrics.overflow) {
|
|
518
|
+
findings.push({
|
|
519
|
+
severity: "error",
|
|
520
|
+
rule: "responsive/horizontal-overflow",
|
|
521
|
+
file: url,
|
|
522
|
+
message: `Horizontal overflow detected at ${vp.name} (${vp.width}px).`,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
if (vp.name === "desktop") {
|
|
526
|
+
if (metrics.mainCount !== 1) {
|
|
527
|
+
findings.push({
|
|
528
|
+
severity: "error",
|
|
529
|
+
rule: "a11y/landmark-main",
|
|
530
|
+
file: url,
|
|
531
|
+
message: `Expected exactly 1 <main> landmark, found ${metrics.mainCount}.`,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
if (metrics.footerInsideMain) {
|
|
535
|
+
findings.push({
|
|
536
|
+
severity: "error",
|
|
537
|
+
rule: "a11y/footer-outside-main",
|
|
538
|
+
file: url,
|
|
539
|
+
message: "Top-level <footer> must sit outside <main>.",
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
if (metrics.duplicateViewTransitionNames.length > 0) {
|
|
543
|
+
findings.push({
|
|
544
|
+
severity: "error",
|
|
545
|
+
rule: "motion/duplicate-view-transition-name",
|
|
546
|
+
file: url,
|
|
547
|
+
message: `Duplicate visible view-transition-name values silently abort MPA/SPA transitions: ${metrics.duplicateViewTransitionNames.join(", ")}.`,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
for (const err of consoleErrors) {
|
|
554
|
+
findings.push({ severity: "error", rule: "browser/console-error", file: url, message: err });
|
|
555
|
+
}
|
|
556
|
+
for (const err of httpErrors) {
|
|
557
|
+
findings.push({ severity: "error", rule: "browser/http-error", file: url, message: err });
|
|
558
|
+
}
|
|
559
|
+
} finally {
|
|
560
|
+
await browser.close();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
async function main() {
|
|
565
|
+
const opts = parseArgs(process.argv.slice(2));
|
|
566
|
+
const files = collectFiles(opts.target, opts.includeInternal);
|
|
567
|
+
/** @type {Finding[]} */
|
|
568
|
+
const findings = [];
|
|
569
|
+
let totalContrastPairsChecked = 0;
|
|
570
|
+
|
|
571
|
+
for (const file of files) {
|
|
572
|
+
const res = auditFile(file, opts, findings);
|
|
573
|
+
totalContrastPairsChecked += res.contrastPairsChecked;
|
|
574
|
+
}
|
|
575
|
+
if (opts.url) {
|
|
576
|
+
await auditLiveUrl(opts.url, findings);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const errors = findings.filter((f) => f.severity === "error");
|
|
580
|
+
const warnings = findings.filter((f) => f.severity === "warn");
|
|
581
|
+
|
|
582
|
+
if (opts.json) {
|
|
583
|
+
console.log(
|
|
584
|
+
JSON.stringify(
|
|
585
|
+
{
|
|
586
|
+
tool: "millar-audit",
|
|
587
|
+
version: "0.3.0",
|
|
588
|
+
register: opts.register,
|
|
589
|
+
scannedFiles: files.length,
|
|
590
|
+
contrastPairsChecked: totalContrastPairsChecked,
|
|
591
|
+
passed: errors.length === 0,
|
|
592
|
+
errorCount: errors.length,
|
|
593
|
+
warningCount: warnings.length,
|
|
594
|
+
findings,
|
|
595
|
+
},
|
|
596
|
+
null,
|
|
597
|
+
2,
|
|
598
|
+
),
|
|
599
|
+
);
|
|
600
|
+
} else {
|
|
601
|
+
const status = errors.length === 0 ? "PASS" : "FAIL";
|
|
602
|
+
console.log(
|
|
603
|
+
`${status}: millar-audit v0.3 scanned ${files.length} file(s) [register=${opts.register}, contrastPairs=${totalContrastPairsChecked}] -> ${errors.length} error(s), ${warnings.length} warning(s).`,
|
|
604
|
+
);
|
|
605
|
+
for (const f of findings) {
|
|
606
|
+
const loc = f.line ? `${f.file}:${f.line}` : f.file;
|
|
607
|
+
console.log(` [${f.severity.toUpperCase()}] ${f.rule} (${loc}): ${f.message}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
process.exit(errors.length === 0 ? 0 : 1);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
main().catch((err) => {
|
|
615
|
+
console.error(`millar-audit fatal error: ${err instanceof Error ? err.message : String(err)}`);
|
|
616
|
+
process.exit(2);
|
|
617
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: millar-web-workflow
|
|
3
|
+
description: "Master end-to-end web engineering conductor and creative workflow router (v0.3.0) uniting the 7 Millar skills with Matt Pocock engineering discipline, Agency Agents studio roles, Anthropic canvas-design craft, and Impeccable anti-slop rigor. Always researches any named brand first (zero hardcoded palettes), authors all prompts in English, routes Track S/M/L cleanly, and gates completion on Zero-MCP mechanical auditing plus fresh-context independent review."
|
|
4
|
+
version: 0.3.0-draft.1
|
|
5
|
+
license: MIT
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Millar Web Workflow v0.3: End-to-End 5-Role Creative & Engineering Conductor
|
|
9
|
+
|
|
10
|
+
Orchestrate every web build as one continuous, gated pipeline from user intent and **Brand-First Research** through **Dual-Soul Creative Art Direction** (`canvas-design` engraving discipline + `Impeccable` craft-floor & storytelling rigor), clean Server-First frontend engineering, and zero-mercy independent verification. Choose the lightest track that fits the job so small edits stay surgical while multi-page sites achieve unforgettable `>= 9.0/10` craft with zero bureaucratic bloat.
|
|
11
|
+
|
|
12
|
+
## Non-Negotiable Ground Rules
|
|
13
|
+
|
|
14
|
+
1. **Brand-First Research (Zero Hardcoding):** If the user mentions ANY brand, research its real identity first (local `DESIGN.md`/`PRODUCT.md`, live connected MCP tools such as Millar MCP for Hahlex, or web research via `millar-deep-research`). NEVER hardcode one brand's colors or rules into another project.
|
|
15
|
+
2. **100% English Prompts & Technical Specs:** Author all image-generation prompts, art-direction prefixes, `.millar/*.md` design contracts, and reviewer briefs in crisp English. Render visible website and artwork copy in the user's requested locale (e.g., Vietnamese with full UTF-8 diacritics).
|
|
16
|
+
3. **Studio Role Accountability:** Never run on generic autopilot. Every phase activates explicit studio ownership:
|
|
17
|
+
- *Phases 1-2:* Visual Storyteller + Brand Guardian + UX Architect (`millar-deep-research` -> `millar-design`).
|
|
18
|
+
- *Phase 3:* Master Illustrator + Motion Choreographer (`millar-create-image` + `millar-animation`).
|
|
19
|
+
- *Phase 4:* Frontend Developer + Software Architect + Minimal Change Engineer (`millar-build-web`).
|
|
20
|
+
- *Phase 5:* Mechanical Auditor (`scripts/millar-audit.mjs`) + **Fresh-Context Independent Finish Reviewer** (`millar-verify-web`).
|
|
21
|
+
|
|
22
|
+
## Step 1: Classify the Track (S / M / L) Before Touching Code
|
|
23
|
+
|
|
24
|
+
Read [references/track-routing-and-gates.md](references/track-routing-and-gates.md) when boundaries are non-obvious, then declare one track upfront:
|
|
25
|
+
|
|
26
|
+
| Track | Scope | Required Pipeline |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| **Track S (Surgical Fix / Single Component)** | Bug fix, single control update, isolated refactor | `diagnosing-bugs` (if bug) -> `millar-build-web` (minimal-change mode) -> `millar-verify-web` (Layer 1 + `millar-audit.mjs` + Layer 2 + Layer 5 diff review) |
|
|
29
|
+
| **Track M (Secondary Pages Synced to Existing Site / Hero Assets)** | Adding `/features`, `/pricing`, `/about`, `/docs`, `/app` to a styled hero, named brand, or user-supplied imagery/animations | `millar-deep-research` (Brand Research + Visual/Motion DNA) -> `millar-design` (`.millar/style-dna.md`) -> `millar-create-image` + `millar-animation` -> `millar-build-web` -> `millar-verify-web` (All 5 Layers + Independent Finish Review) |
|
|
30
|
+
| **Track L (Full Website / Multi-Page App / Redesign)** | Greenfield website, landing + app suite, or visual overhaul | `grilling` (only if critical product tradeoffs are ambiguous) -> `millar-deep-research` -> Creative Divergence -> `millar-design` -> `millar-create-image` + `millar-animation` -> `millar-build-web` (vertical slices) -> `millar-verify-web` (All 5 Layers + Independent Finish Review) |
|
|
31
|
+
|
|
32
|
+
**Completion criterion:** Track (`S`, `M`, or `L`), named brand research path, affected routes, and Visitor Modes (`Persuade` / `Experience` / `Operate` / `Read`) declared before editing.
|
|
33
|
+
|
|
34
|
+
## Step 2: Run Brand Research & Creative Divergence (Track M & L Only)
|
|
35
|
+
|
|
36
|
+
Before locking `.millar/style-dna.md`, read [references/creative-divergence-protocol.md](references/creative-divergence-protocol.md) and establish:
|
|
37
|
+
1. **Researched Brand Truth (If Named):** Verified palette, light/dark polarity cadence, accent ceiling, typography, and cultural context from real sources (local files, live MCP, or web research).
|
|
38
|
+
2. **The Rut (Explicitly Banned):** Name the predictable category template AND all 4 generic AI defaults (including unbriefed warm-cream + serif + terracotta, dark neon SaaS, and overused training-data display fonts) and exclude them.
|
|
39
|
+
3. **Cultural & Material Anchor:** Ground open visual axes in 3+ concrete material/graphic families from the audience's real world, picking light vs. dark polarity from their physical use scene.
|
|
40
|
+
4. **One Authored Signature Moment:** Define one unforgettable interactive or visual centerpiece per `Persuade`/`Experience` page (and compounding micro-craft on `Operate`/`Read` screens).
|
|
41
|
+
|
|
42
|
+
**Completion criterion:** Creative direction and researched brand truth locked inside `.millar/style-dna.md` with zero category-default clichés.
|
|
43
|
+
|
|
44
|
+
## Step 3: Coordinate Specialist Context Pointers (Zero Duplication)
|
|
45
|
+
|
|
46
|
+
- **Ambiguous architecture or product tradeoffs:** invoke `grilling` before coding.
|
|
47
|
+
- **Module boundaries, seams, and testability:** apply `codebase-design` (deep modules) and `tdd` (vertical slices) inside `millar-build-web`.
|
|
48
|
+
- **Hard bugs or regressions:** invoke `diagnosing-bugs` before patching.
|
|
49
|
+
- **Backend APIs, schemas, auth, or deployment:** invoke the matching specialist (`agency-backend-architect`, `agency-database-optimizer`, `agency-identity-access-engineer`, `agency-devops-automator`).
|
|
50
|
+
- **Hahlex ecosystem projects:** query live canonical tokens, UI primitives, sections, and compliance checks from Millar MCP (`get_design_guidelines`, `get_design_tokens`, `get_component`, `get_visual_assets`, `validate_design`).
|
|
51
|
+
|
|
52
|
+
## Step 4: Execute Gated Handoffs (No Premature Self-Grading)
|
|
53
|
+
|
|
54
|
+
Pass explicit disk artifacts between phases so decisions never drift:
|
|
55
|
+
1. **Research -> Design:** `.millar/research-dossier.md` feeds `.millar/style-dna.md`.
|
|
56
|
+
2. **Design -> Visuals & Motion:** `.millar/style-dna.md` locks the 80% English Master Style Prefix (plus provenance sidecars) for `millar-create-image` and the 4-line Motion Thesis for `millar-animation`.
|
|
57
|
+
3. **Design + Visuals -> Code:** `millar-build-web` ships vertical slices with real interactive states, Server-First boundaries, browser surface theming, and Core Web Vitals hygiene.
|
|
58
|
+
4. **Code -> Ship Gate:** `millar-verify-web` runs standalone `scripts/millar-audit.mjs` (works with zero MCP!) + Millar MCP `validate_design` (when active) + Playwright E2E/WCAG + **Fresh-Context Independent Finish Reviewer** (`ship` | `fix` | `rebuild` | `recapture`).
|
|
59
|
+
|
|
60
|
+
**Completion criterion:** Every gate required by the active Track passed with observed evidence and independent finish-reviewer sign-off.
|