feat(site,skill): lock domain materiality, localize dark-instrument showcases, and curate tier-1 Korean fonts
This commit is contained in:
parent
36835dd8a3
commit
008e29752e
44 changed files with 544 additions and 417 deletions
|
|
@ -7,18 +7,27 @@
|
|||
// 스킬이 약속한 "다른 클라이언트의 것과 혼동될 수 없다"는 페이지 간 비교로만
|
||||
// 검증된다. 이 검사가 그 비교를 한다.
|
||||
//
|
||||
// 지문 축 (각 public/work/<slug>/styles/*.css 정적 분석, var() 재귀 해석):
|
||||
// 지문 축 (각 public/work/<slug>/styles/*.css + index.html 정적 분석, var() 재귀 해석):
|
||||
// 1. 한글 본문 서체 — body/--font-body 스택에서 첫 한글 지원 서체
|
||||
// 2. 한글 표제 서체 — h1/--font-display 스택에서 첫 한글 지원 서체
|
||||
// 3. 배경 — body/--surface 계열 색의 CIELAB 명도·채도·색상
|
||||
// 4. 강조색 hue — --accent 계열(무채색이면 다음 후보)
|
||||
// 5. radius 구간 — --radius 또는 최빈 border-radius
|
||||
// 6. 모노 사용 — 규칙에서 모노 스택을 실제로 쓰는가
|
||||
// 7. 주역 매체(medium) — webgl-3d / canvas-2d / svg-instrument / workbench-app / photo-editorial / typographic
|
||||
// 8. 표제 스케일(scale) — h1/--step-display 최대 크기 구간(compact / editorial / poster)
|
||||
//
|
||||
// 왜 7·8축과 2군 서체 감시를 추가했는가(실측 사고 2026-10-06):
|
||||
// CSS 토큰 6축만 측정하자 지표를 통과하려고 19개 쇼케이스에 유아·예능·전단용 디스플레이 서체
|
||||
// (Bagel Fat One, Gasoek One, Jua, Do Hyeon, Black Han Sans)를 강제 할당하고 정작 히어로 시각물과
|
||||
// 표제 스케일은 평탄화하는 퇴행(Goodhart's Law)이 발생했다. 구조·매체와 스케일 대비를 지문에 포함하고,
|
||||
// 허용 목록(allowedNoveltyDisplay)에 없는 2군 장르 잠금 서체 사용은 즉시 FAIL 처리한다.
|
||||
//
|
||||
// 판정:
|
||||
// - 쌍별 유사도(0~1)가 threshold 이상이면 수렴 쌍. 기본은 WARN.
|
||||
// config.strict 에 든 쇼케이스(재작업 대상)가 낀 쌍은 FAIL.
|
||||
// - 분포 편중: 한 값이 전체의 maxShare 를 넘으면 WARN (distributionMode: "fail" 이면 FAIL).
|
||||
// - 2군 장르 잠금 서체 오용: allowedNoveltyDisplay 에 없는 쇼케이스가 쓰면 FAIL.
|
||||
//
|
||||
// 사용: node tools/similarity.mjs [--config=similarity.config.json] [--json]
|
||||
// 결과: tools/similarity-report.md 에 표를 남긴다.
|
||||
|
|
@ -38,8 +47,18 @@ const defaults = {
|
|||
maxShare: 0.4,
|
||||
distributionMode: "warn",
|
||||
strict: [],
|
||||
allowedNoveltyDisplay: [],
|
||||
ignore: [],
|
||||
weights: { body: 0.25, display: 0.2, background: 0.2, accent: 0.15, radius: 0.1, mono: 0.1 },
|
||||
weights: {
|
||||
body: 0.2,
|
||||
display: 0.16,
|
||||
background: 0.18,
|
||||
accent: 0.12,
|
||||
radius: 0.08,
|
||||
mono: 0.08,
|
||||
medium: 0.1,
|
||||
scale: 0.08,
|
||||
},
|
||||
};
|
||||
const config = fs.existsSync(configPath)
|
||||
? { ...defaults, ...JSON.parse(fs.readFileSync(configPath, "utf8")) }
|
||||
|
|
@ -96,6 +115,16 @@ const KOREAN_FONTS = new Map(
|
|||
],
|
||||
);
|
||||
const MONO_RE = /\b(mono|monospace|consolas|courier|menlo|sfmono|coding)\b/i;
|
||||
// 2군 장르 잠금 디스플레이 서체 — 유아·키즈·아케이드·특가 프로모션 외 신뢰·학술·계측·편집 도메인에 오용하면
|
||||
// 즉시 품격이 붕괴한다(실측 사고 2026-10-06). allowedNoveltyDisplay 에 명시된 경우만 허용한다.
|
||||
const DISALLOWED_NOVELTY_DISPLAY = new Set([
|
||||
"Gasoek One",
|
||||
"Bagel Fat One",
|
||||
"Jua",
|
||||
"Do Hyeon",
|
||||
"Black Han Sans",
|
||||
"Dongle",
|
||||
]);
|
||||
|
||||
/* ── CSS 파싱 ── */
|
||||
function stripComments(css) {
|
||||
|
|
@ -143,6 +172,12 @@ function readShowcase(slug) {
|
|||
return css;
|
||||
}
|
||||
|
||||
function readShowcaseHtml(slug) {
|
||||
const htmlPath = path.join(workRoot, slug, "index.html");
|
||||
if (!fs.existsSync(htmlPath)) return "";
|
||||
return fs.readFileSync(htmlPath, "utf8");
|
||||
}
|
||||
|
||||
/** :root·html 에서 처음 정의된 값을 쓴다. 다크 모드 재정의는 기본 지문이 아니다. */
|
||||
function collectVars(rules) {
|
||||
const vars = new Map();
|
||||
|
|
@ -266,6 +301,39 @@ function radiusBucket(px) {
|
|||
return "pill";
|
||||
}
|
||||
|
||||
function parseMaxSizePx(raw) {
|
||||
if (!raw) return null;
|
||||
const s = String(raw).trim();
|
||||
const clampMatch = s.match(/clamp\s*\(([^)]+)\)/i);
|
||||
if (clampMatch) {
|
||||
const parts = clampMatch[1].split(",").map((p) => p.trim());
|
||||
return toPx(parts[parts.length - 1]);
|
||||
}
|
||||
return toPx(s);
|
||||
}
|
||||
|
||||
function scaleBucket(px) {
|
||||
if (px == null) return "editorial";
|
||||
if (px <= 28) return "compact";
|
||||
if (px <= 52) return "editorial";
|
||||
return "poster";
|
||||
}
|
||||
|
||||
function detectMedium(html = "") {
|
||||
if (!html) return "typographic";
|
||||
if (/\b(webgl2?|gl\.createProgram|THREE\.|three\.module)/i.test(html)) return "webgl-3d";
|
||||
if (/<canvas\b/i.test(html)) return "canvas-2d";
|
||||
if ((html.match(/<svg\b/gi) || []).length >= 2 && /<input\b[^>]*type=["']range["']|role=["']slider["']|data-scenario|data-region/i.test(html)) {
|
||||
return "svg-instrument";
|
||||
}
|
||||
if (/<table\b/i.test(html) && /<dialog\b|role=["']tablist["']|data-tab|type=["']search["']/i.test(html)) {
|
||||
return "workbench-app";
|
||||
}
|
||||
if (/<img\b|<picture\b/i.test(html)) return "photo-editorial";
|
||||
if ((html.match(/<svg\b/gi) || []).length >= 2) return "svg-instrument";
|
||||
return "typographic";
|
||||
}
|
||||
|
||||
/* ── 지문 추출 ── */
|
||||
function firstDecl(rules, selectorRe, prop) {
|
||||
for (const r of rules) {
|
||||
|
|
@ -281,7 +349,7 @@ function firstVar(vars, names) {
|
|||
return null;
|
||||
}
|
||||
|
||||
export function fingerprint(slug, css) {
|
||||
export function fingerprint(slug, css, html = "") {
|
||||
const rules = rulesOf(css);
|
||||
const vars = collectVars(rules);
|
||||
const res = (v) => resolve(v, vars);
|
||||
|
|
@ -355,6 +423,15 @@ export function fingerprint(slug, css) {
|
|||
}
|
||||
}
|
||||
|
||||
const h1SizeRaw = res(
|
||||
firstDecl(rules, /(^|[\s,>])h1(\b|$)/, "font-size") ||
|
||||
firstVar(vars, ["--step-display", "--step-hero", "--step-4", "--step-3", "--text-display"])?.value ||
|
||||
"",
|
||||
);
|
||||
const h1Px = parseMaxSizePx(h1SizeRaw);
|
||||
const scale = scaleBucket(h1Px);
|
||||
const medium = detectMedium(html);
|
||||
|
||||
const bg = bgRgb ? lch(bgRgb) : null;
|
||||
return {
|
||||
slug,
|
||||
|
|
@ -366,6 +443,9 @@ export function fingerprint(slug, css) {
|
|||
radiusPx,
|
||||
radius: radiusBucket(radiusPx),
|
||||
mono,
|
||||
medium,
|
||||
scale,
|
||||
h1Px: h1Px != null ? Math.round(h1Px) : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -394,6 +474,8 @@ export function similarity(a, b, weights = defaults.weights) {
|
|||
else parts.accent = !a.accent && !b.accent ? 1 : 0;
|
||||
parts.radius = a.radius === b.radius ? 1 : 0;
|
||||
parts.mono = a.mono === b.mono ? 1 : 0;
|
||||
parts.medium = a.medium && b.medium ? (a.medium === b.medium ? 1 : 0) : 0;
|
||||
parts.scale = a.scale && b.scale ? (a.scale === b.scale ? 1 : 0) : 0;
|
||||
let score = 0;
|
||||
let total = 0;
|
||||
for (const [k, w] of Object.entries(weights)) {
|
||||
|
|
@ -415,10 +497,12 @@ function main() {
|
|||
for (const slug of slugs) {
|
||||
const css = readShowcase(slug);
|
||||
if (css == null) continue;
|
||||
prints.push(fingerprint(slug, css));
|
||||
const html = readShowcaseHtml(slug);
|
||||
prints.push(fingerprint(slug, css, html));
|
||||
}
|
||||
|
||||
const strict = new Set(config.strict);
|
||||
const allowedNovelty = new Set(config.allowedNoveltyDisplay || []);
|
||||
const pairs = [];
|
||||
for (let i = 0; i < prints.length; i++) {
|
||||
for (let j = i + 1; j < prints.length; j++) {
|
||||
|
|
@ -431,6 +515,16 @@ function main() {
|
|||
const failures = [];
|
||||
const warnings = [];
|
||||
let pass = 0;
|
||||
|
||||
for (const f of prints) {
|
||||
if (DISALLOWED_NOVELTY_DISPLAY.has(f.display) && !allowedNovelty.has(f.slug)) {
|
||||
failures.push(
|
||||
`2군 장르 잠금 서체 오용 — ${f.slug}: '${f.display}' (신뢰·학술·계측·편집 도메인에 유아·예능·전단 서체 사용 금지)`,
|
||||
);
|
||||
} else {
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
for (const p of pairs) {
|
||||
if (p.score < config.threshold) {
|
||||
pass++;
|
||||
|
|
@ -496,11 +590,11 @@ function writeReport(prints, pairs, distribution, warnings, failures) {
|
|||
``,
|
||||
`## 지문`,
|
||||
``,
|
||||
`| 쇼케이스 | 한글 본문 | 한글 표제 | 배경 | 배경 L·C·h | 강조 hue | radius | 모노 |`,
|
||||
`|---|---|---|---|---|---|---|---|`,
|
||||
`| 쇼케이스 | 한글 본문 | 한글 표제 | 배경 | 배경 L·C·h | 강조 hue | radius | 모노 | 주역 매체 | 표제 스케일 |`,
|
||||
`|---|---|---|---|---|---|---|---|---|---|`,
|
||||
...prints.map(
|
||||
(f) =>
|
||||
`| ${f.slug} | ${f.body} | ${f.display} | ${f.bg?.hex ?? "—"} ${f.bgClass} | ${f.bg ? `${f.bg.L}·${f.bg.C}·${f.bg.h}` : "—"} | ${f.accent ? `${f.accent.hex} (${f.accent.h}°)` : "—"} | ${f.radiusPx ?? "—"} (${f.radius}) | ${f.mono ? "사용" : "—"} |`,
|
||||
`| ${f.slug} | ${f.body} | ${f.display} | ${f.bg?.hex ?? "—"} ${f.bgClass} | ${f.bg ? `${f.bg.L}·${f.bg.C}·${f.bg.h}` : "—"} | ${f.accent ? `${f.accent.hex} (${f.accent.h}°)` : "—"} | ${f.radiusPx ?? "—"} (${f.radius}) | ${f.mono ? "사용" : "—"} | ${f.medium} | ${f.scale}${f.h1Px ? ` (${f.h1Px}px)` : ""} |`,
|
||||
),
|
||||
``,
|
||||
`## 분포`,
|
||||
|
|
@ -511,11 +605,11 @@ function writeReport(prints, pairs, distribution, warnings, failures) {
|
|||
``,
|
||||
`## 유사도 상위 15쌍`,
|
||||
``,
|
||||
`| 쌍 | 점수 | 본문 | 표제 | 배경 | 강조 | radius | 모노 |`,
|
||||
`|---|---|---|---|---|---|---|---|`,
|
||||
`| 쌍 | 점수 | 본문 | 표제 | 배경 | 강조 | radius | 모노 | 매체 | 스케일 |`,
|
||||
`|---|---|---|---|---|---|---|---|---|---|`,
|
||||
...pairs.slice(0, 15).map(
|
||||
(p) =>
|
||||
`| ${p.a} ↔ ${p.b} | ${p.score.toFixed(2)} | ${p.parts.body} | ${p.parts.display} | ${p.parts.background.toFixed(2)} | ${p.parts.accent.toFixed(2)} | ${p.parts.radius} | ${p.parts.mono} |`,
|
||||
`| ${p.a} ↔ ${p.b} | ${p.score.toFixed(2)} | ${p.parts.body} | ${p.parts.display} | ${p.parts.background.toFixed(2)} | ${p.parts.accent.toFixed(2)} | ${p.parts.radius} | ${p.parts.mono} | ${p.parts.medium ?? 0} | ${p.parts.scale ?? 0} |`,
|
||||
),
|
||||
``,
|
||||
...(warnings.length ? [`## 경고`, ``, ...warnings.map((w) => `- ${w}`), ``] : []),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue