designpaca/build/ci/lint-skill.mjs
Yun Chan 6805fb2be7 feat(skill): absorb external design skills, restore interview gate, add review route
- Restore the step-0 interview as a mechanical gate the skill explicitly
  depends on; add harness.md (per-harness question tools, limits,
  fallbacks) and brief-interview.md (slots, question cards, rounds).
- Add 10 reference docs absorbed from external design skills
  (accessibility, interaction-feel, elevation, color, icons, product-copy,
  component-systems, critique, change-review, print-email) and extend
  existing references.
- Add a review-only route and two hard-gate clauses (truncated content
  reachability, three-flashes limit).
- design-gate: split tap targets into WCAG 2.5.8 and 44px contract layers,
  run axe-core when available, and fix false positives found on a real
  site (decorative alt="", stacked wordmark line count, url-only pages).
- lint-skill: fail if the interview gate section or its links disappear.
- Ship agents/openai.yaml and THIRD_PARTY_NOTICES.md.
2026-09-24 13:26:03 +09:00

92 lines
3.6 KiB
JavaScript

// 스킬 문서의 최소 규약을 검사한다. CI 와 `pnpm test` 가 함께 쓴다.
// - SKILL.md 존재와 프론트매터 필수 필드
// - description 길이(트리거 정확도에 직접 영향)
// - references 링크가 실제 파일을 가리키는지
import fs from "node:fs/promises";
import path from "node:path";
const root = path.resolve(process.argv[2] ?? ".");
const errors = [];
const warnings = [];
const skillPath = path.join(root, "SKILL.md");
let md;
try {
md = await fs.readFile(skillPath, "utf8");
} catch {
console.error(`SKILL.md 를 찾을 수 없다: ${skillPath}`);
process.exit(1);
}
const fmMatch = /^---\r?\n([\s\S]*?)\r?\n---/.exec(md);
if (!fmMatch) {
errors.push("프론트매터(---)가 없다");
} else {
const fm = Object.fromEntries(
fmMatch[1]
.split(/\r?\n/)
.map((l) => /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(l))
.filter(Boolean)
.map((m) => [m[1], m[2].replace(/^["']|["']$/g, "")]),
);
if (fm.name !== "designpaca") errors.push(`name 이 designpaca 가 아니다: ${fm.name}`);
if (!fm.description) errors.push("description 이 없다");
else {
const len = fm.description.length;
if (len < 80) warnings.push(`description 이 짧다(${len}자) — 트리거 정확도가 떨어진다`);
if (len > 700) warnings.push(`description 이 길다(${len}자) — 요약해라`);
}
}
// 0단계 인터뷰 게이트가 조용히 약해지지 않았는지 확인한다. v0.11.0(45ba92e)에서 "거의 항상 묻는다"가
// "결과를 크게 바꿀 때만 묻는다"로 바뀌었는데 커밋·체인지로그 어디에도 적히지 않아 아무도 알아채지 못했다.
if (!/^## 인터뷰 게이트/m.test(md) || !md.includes("명시적으로 의존한다")) {
errors.push("인터뷰 게이트 절(## 인터뷰 게이트, '명시적으로 의존한다')이 없다");
}
for (const rel of ["references/harness.md", "references/brief-interview.md"]) {
if (!md.includes(rel)) errors.push(`인터뷰 게이트가 가리켜야 할 문서 링크가 없다: ${rel}`);
}
if (/때만\s*(?:아래 항목을\s*)?묻는다/.test(md)) {
errors.push("본문에 '~때만 묻는다' 조건이 있다 — 질문 여부를 모델의 자기평가에 맡기는 완화 문구다");
}
// 본문이 참조하는 파일이 실제로 있는지 확인한다 (references/xxx.md 형태)
const refs = [...md.matchAll(/references\/[A-Za-z0-9._/-]+\.md/g)].map((m) => m[0]);
for (const rel of new Set(refs)) {
try {
await fs.access(path.join(root, rel));
} catch {
errors.push(`본문이 가리키는 참조 문서가 없다: ${rel}`);
}
}
// 참조 문서가 본문 어디에서도 언급되지 않으면 죽은 문서다
async function walk(dir, base = dir) {
const out = [];
let entries = [];
try {
entries = await fs.readdir(dir, { withFileTypes: true });
} catch {
return out;
}
for (const e of entries) {
const full = path.join(dir, e.name);
if (e.isDirectory()) out.push(...(await walk(full, base)));
else out.push(path.relative(base, full).split(path.sep).join("/"));
}
return out;
}
const refDir = path.join(root, "references");
for (const f of await walk(refDir, root)) {
if (!f.endsWith(".md")) continue;
const rel = f.split(path.sep).join("/");
if (!md.includes(rel)) warnings.push(`본문에서 참조되지 않는 문서: ${rel}`);
}
for (const w of warnings) console.warn(` 경고: ${w}`);
if (errors.length > 0) {
for (const e of errors) console.error(` 오류: ${e}`);
console.error(`\n스킬 검사 실패 — 오류 ${errors.length}건`);
process.exit(1);
}
console.log(`스킬 검사 통과 (경고 ${warnings.length}건)`);