// Doctrine palette audit (S6). // 1. Every hex color inside the INDUSTRIAL BLUEPRINT CANVAS CSS section // must be one of the doctrinal tokens. // 2. Blueprint TSX files must not introduce hardcoded hex/rgb literals — // they should reference --bp-* tokens via var(...). import { readFileSync } from "node:fs"; const DOCTRINE = new Set([ "#f5f7fb", "#e8edf5", "#d5dde9", "#1a2740", "#243453", "#4a5b80", "#7a8aa8", "#c46a14", "#3d6a2c", "#a6342a", "#1d6f82", ]); function fail(msg) { console.log("✗", msg); process.exitCode = 1; } function pass(msg) { console.log("✓", msg); } const css = readFileSync("src/index.css", "utf8"); const idx = css.indexOf("INDUSTRIAL BLUEPRINT CANVAS"); if (idx < 0) { fail("blueprint CSS block not found"); process.exit(1); } const cssBlock = css.slice(idx); const cssHexes = cssBlock.match(/#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}/g) || []; const cssOffending = cssHexes.filter((h) => !DOCTRINE.has(h.toLowerCase())); if (cssOffending.length === 0) { pass(`CSS palette: ${cssHexes.length} hex tokens, all doctrinal`); } else { fail(`CSS non-doctrinal hex tokens: ${cssOffending.join(", ")}`); } const cssRgba = cssBlock.match(/rgba?\([^)]*\)/g) || []; if (cssRgba.length === 0) { pass("CSS has no raw rgba() literals (alpha goes through color-mix tokens)"); } else { fail(`CSS raw rgba() literals: ${cssRgba.join(", ")}`); } const tsxFiles = [ "src/components/ProcessGraph.tsx", "src/components/BlueprintFrame.tsx", ]; let tsxOffending = 0; for (const f of tsxFiles) { const src = readFileSync(f, "utf8"); const hex = (src.match(/#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}/g) || []).filter( (h) => !DOCTRINE.has(h.toLowerCase()), ); const rgba = src.match(/rgba?\(\s*\d+/g) || []; if (hex.length || rgba.length) { fail(`${f}: hardcoded color literals: hex=${hex.join(",") || "none"} rgba=${rgba.join(",") || "none"}`); tsxOffending += hex.length + rgba.length; } } if (tsxOffending === 0) pass(`TSX palette: ${tsxFiles.length} blueprint TSX files clean (no hardcoded color literals)`); if (process.exitCode === 1) console.log("\nPalette audit FAILED"); else console.log("\nPalette audit PASSED");