web-stylebook-mcp 0.8.0 → 0.10.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.
Files changed (72) hide show
  1. package/README.ko.md +74 -4
  2. package/README.md +72 -4
  3. package/dist/audit/evaluator.d.ts +125 -0
  4. package/dist/audit/evaluator.js +308 -0
  5. package/dist/audit/evaluator.js.map +1 -0
  6. package/dist/audit/planner.d.ts +6 -0
  7. package/dist/audit/planner.js +17 -6
  8. package/dist/audit/planner.js.map +1 -1
  9. package/dist/catalog/repository.d.ts +39 -1
  10. package/dist/catalog/repository.js +67 -0
  11. package/dist/catalog/repository.js.map +1 -1
  12. package/dist/catalog/stable-hash.d.ts +2 -0
  13. package/dist/catalog/stable-hash.js +5 -1
  14. package/dist/catalog/stable-hash.js.map +1 -1
  15. package/dist/catalog/validate.js +102 -1
  16. package/dist/catalog/validate.js.map +1 -1
  17. package/dist/catalog/visual.d.ts +38 -0
  18. package/dist/catalog/visual.js +75 -0
  19. package/dist/catalog/visual.js.map +1 -0
  20. package/dist/cli.js +1 -0
  21. package/dist/cli.js.map +1 -1
  22. package/dist/protocol/errors.d.ts +1 -1
  23. package/dist/protocol/errors.js +1 -0
  24. package/dist/protocol/errors.js.map +1 -1
  25. package/dist/protocol/register-prompts.js +14 -8
  26. package/dist/protocol/register-prompts.js.map +1 -1
  27. package/dist/protocol/register-resources.js +86 -4
  28. package/dist/protocol/register-resources.js.map +1 -1
  29. package/dist/protocol/register-tools.js +271 -16
  30. package/dist/protocol/register-tools.js.map +1 -1
  31. package/dist/references/search.d.ts +59 -0
  32. package/dist/references/search.js +137 -0
  33. package/dist/references/search.js.map +1 -0
  34. package/dist/server-info.d.ts +2 -2
  35. package/dist/server-info.js +5 -2
  36. package/dist/server-info.js.map +1 -1
  37. package/dist/tokens/compile.d.ts +28 -0
  38. package/dist/tokens/compile.js +24 -4
  39. package/dist/tokens/compile.js.map +1 -1
  40. package/dist/tokens/visual.d.ts +7 -0
  41. package/dist/tokens/visual.js +104 -0
  42. package/dist/tokens/visual.js.map +1 -0
  43. package/dist/types.d.ts +89 -0
  44. package/dist/types.js +4 -4
  45. package/dist/types.js.map +1 -1
  46. package/dist/visual-canonical/contrast.d.ts +12 -0
  47. package/dist/visual-canonical/contrast.js +48 -0
  48. package/dist/visual-canonical/contrast.js.map +1 -0
  49. package/dist/visual-canonical/export.d.ts +79 -0
  50. package/dist/visual-canonical/export.js +115 -0
  51. package/dist/visual-canonical/export.js.map +1 -0
  52. package/dist/visual-canonical/hash.d.ts +4 -0
  53. package/dist/visual-canonical/hash.js +17 -0
  54. package/dist/visual-canonical/hash.js.map +1 -0
  55. package/dist/visual-canonical/resolve.d.ts +3 -0
  56. package/dist/visual-canonical/resolve.js +140 -0
  57. package/dist/visual-canonical/resolve.js.map +1 -0
  58. package/dist/visual-canonical/schema.d.ts +1982 -0
  59. package/dist/visual-canonical/schema.js +71 -0
  60. package/dist/visual-canonical/schema.js.map +1 -0
  61. package/dist/visual-canonical/types.d.ts +135 -0
  62. package/dist/visual-canonical/types.js +3 -0
  63. package/dist/visual-canonical/types.js.map +1 -0
  64. package/generated/catalog.v1.json +77419 -135
  65. package/generated/manifest.v1.json +4 -2
  66. package/generated/visual-contract-LICENSE +25 -0
  67. package/generated/visual-contract-source.v1.json +16 -0
  68. package/generated/visual-contracts.v1.json +23799 -0
  69. package/package.json +6 -2
  70. package/skill/AGENTS.md +8 -0
  71. package/skill/CLAUDE.md +8 -0
  72. package/skill/web-stylebook-design/SKILL.md +11 -0
package/README.ko.md CHANGED
@@ -119,11 +119,16 @@ flowchart LR
119
119
  C --> H[get_ui_state_plan]
120
120
  C --> I[compose_design_tokens]
121
121
  C --> J[get_design_audit_plan]
122
- D & E & F & G & H & I & J -->|디자인 계약<br/>점수 · 사유 코드<br/>배치 · 증거 · 토큰| A
122
+ C --> K[search_design_references]
123
+ C --> L[get_design_reference]
124
+ C --> M[validate_design_audit_result]
125
+ D & E & F & G & H & I & J & K & L -->|디자인 계약<br/>관찰 · 점수 · 사유<br/>배치 · 증거 · 토큰| A
126
+ A -->|대상 행렬 · 증거 참조<br/>검사/대상별 판정| M
127
+ M -->|범위 · 정규화 판정<br/>plan/evidence/result hash| A
123
128
  A -->|근거로<br/>코드 작성| Z[당신의 UI]
124
129
  ```
125
130
 
126
- 에이전트가 제품을 설명하면, 서버가 큐레이션 카탈로그를 점수화해 구조화된 근거를 돌려줍니다. 코드는 생성하지 않고, 어떤 것도 기기를 벗어나지 않습니다.
131
+ 에이전트가 제품을 설명하면, 서버가 큐레이션 카탈로그를 점수화해 구조화된 근거를 돌려줍니다. 검사 후 validator는 참조된 artifact를 직접 열거나 시각 품질을 판단하지 않고 결과 계약만 검증합니다. 코드는 생성하지 않고, 어떤 것도 기기를 벗어나지 않습니다.
127
132
 
128
133
  ## 설치
129
134
 
@@ -206,13 +211,43 @@ MCP 설정에 추가:
206
211
  |------|--------------|-----------------|
207
212
  | **`recommend_design_direction`** | 사유 코드가 붙은 점수화 스타일 후보, *이유*가 붙은 **탈락** 스타일, 보조 페어링, 신뢰도 | 최종 선택은 모델이 — 이건 근거 제공자입니다 |
208
213
  | **`compare_design_directions`** | 2~4개 방향을 제품 적합성·반복 사용·밀도·신뢰·차별성·접근성 리스크·모션·유지보수로 비교 | 정답 하나를 선언하지 않습니다 |
214
+ | **`search_design_references`** | 실제 디자인 레퍼런스를 텍스트·카테고리·태그로 제한 검색하고 간결한 다국어 관찰 결과 제공 | 스크린샷이나 브랜드 자산 복제가 아니라 출처가 붙은 연구 요약을 반환합니다 |
215
+ | **`get_design_reference`** | 팔레트·레이아웃·인터랙션·모션 관찰, 정규화 토큰, 원본 리비전, 출처와 권리 고지를 포함한 레퍼런스 1건 | 원 사이트 카피·서체·스크린샷·시각 정체성의 권리는 각 권리자에게 있습니다 |
209
216
  | **`get_design_principle_plan`** | 시각적 관심사·화면·설계 단계·원칙 ID로 고른 배치/적용/검증 계획 — 가능한 경우 출처 링크 포함 | 제작 원칙은 경험 법칙이나 고정 레시피가 아니라 검증 가능한 점검 질문입니다 |
210
217
  | **`get_ux_principle_plan`** | 결과 목표·화면·설계 단계·원칙 ID로 고른 적용/검증 계획 — 질문·주의점·근거 신뢰도·참고 링크 포함 | 원칙은 보편 법칙이나 사용자 조사의 대체물이 아니라 맥락별 점검 질문입니다 |
211
218
  | **`get_ui_state_plan`** | 표면(데이터 테이블·폼·체크아웃·채팅·개발자 콘솔)의 필수/권장/도메인 UI 상태 — 트리거·표시 필수·금지·접근성·모션 | 에이전트가 잊는 상태까지: 빈·에러·로딩·엣지 |
212
- | **`compose_design_tokens`** | 역할 기반 토큰(색·타이포·간격·radius·모션·밀도)을 `json` / `css-variables` / `tailwind` / `typescript`, light / dark / both | WCAG 대비 경고를 숨기지 않고 내보냅니다 |
219
+ | **`compose_design_tokens`** | 역할 기반 토큰을 `json` / `css-variables` / `tailwind` / `typescript`로 출력하며, 공통 시각 명세를 선택하면 스타일 원본과 편집값을 보존 | 명세에 작성된 색상 모드를 사용하며, 명시적으로 수락한 대비 수정만 적용합니다 |
213
220
  | **`get_design_audit_plan`** | 안정적인 검사 ID·심각도·적용 조건·필요 증거·수정 방향·사용자용 콘텐츠 검사·선택 원칙 검사·UI 상태 범위를 담은 다국어 감사 계획 | 프로젝트를 실제로 봤다고 가장하지 않으며, 증거가 없으면 `PASS`가 아니라 `NOT_VERIFIED`입니다 |
221
+ | **`validate_design_audit_result`** | plan query·대상 행렬·지속 가능한 증거 참조·검사/대상별 판정을 검증하고 정규화 판정과 안정 hash를 반환 | 범위와 증거 정합성을 검증할 뿐 시각 품질을 판정하지 않으며, `valid: true`는 전체 디자인 통과가 아닙니다 |
214
222
 
215
- **카탈로그:** 스타일 48 · 인터페이스 디자인 원칙 25 · UX 원칙 23 · 구조화 감사 검사 51 · 컴포넌트 20 · 표면 5 · UI 상태 레시피 57 · 모션 프로파일 29 · 제품 아키타입 14.
223
+ **카탈로그:** 실제 디자인 레퍼런스 520 · 스타일 48 · 인터페이스 디자인 원칙 25 · UX 원칙 23 · 구조화 감사 검사 51 · 컴포넌트 20 · 표면 5 · UI 상태 레시피 57 · 모션 프로파일 29 · 제품 아키타입 14.
224
+
225
+ 레퍼런스 라이브러리는 [OpenDesign](https://opendesign.cc)의 완성도 높은 항목을 선별·수정한 데이터이며, 구조화 스펙은 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)으로 제공됩니다. Web Stylebook은 원본 스크린샷과 브랜드 자산을 포함하지 않습니다. 원 사이트·브랜드·카피·서체·시각 정체성의 권리는 각 권리자에게 있으므로 사용 전 상세 항목의 출처와 권리 고지를 확인하세요.
226
+
227
+ ## 웹사이트의 시각 명세 그대로 전달하기
228
+
229
+ 선택한 스타일이나 웹 편집기에서 수정한 값을 토큰으로 옮길 때 공통 명세를 선택합니다.
230
+
231
+ ```json
232
+ {
233
+ "primaryStyleId": "brutalist-grid",
234
+ "format": "css-variables",
235
+ "contract": { "schema": "webstylebook.visual.v1" },
236
+ "locale": "ko",
237
+ "overrides": {
238
+ "colors": { "text": "#111111" },
239
+ "typography": { "body": { "lineHeight": 1.75 } }
240
+ }
241
+ }
242
+ ```
243
+
244
+ `webstylebook://manifest`에서 `visualContract.contractSchema`와 번들 명세의 `visualContract.contentHash`를 읽습니다. `webstylebook://styles/brutalist-grid`에서는 선택한 스타일의 기본 명세와 `visualContract.revision`을 읽습니다. 이 값을 각각 `contract.schema`, `contract.contentHash`, `contract.revision`으로 보내면 원본을 고정할 수 있으며, 일치하지 않으면 `INVALID_INPUT`을 반환합니다. `colorMode`를 생략하면 스타일의 원래 모드를 사용합니다. `light`, `dark`, `both`는 필요한 모드가 원본에 작성되어 있을 때만 가능합니다.
245
+
246
+ `overrides`는 역할별 색상, 타이포그래피, 간격, 밀도, 폰트 정보를 받습니다. 다른 스타일에서 가져온 요소도 이 명시적 값으로 전달합니다. 기존 `secondaryStyleId`는 강조색만 겹치는 옵션이므로 공통 명세와 함께 사용하면 거절합니다. 알 수 없는 필드, `density` 또는 `accentOverride`와 충돌하는 편집값도 거절합니다. `overrides`나 `acceptedRepairs`를 보낼 때는 `contract`가 필요합니다.
247
+
248
+ 응답에는 선택한 `visualContract`, 원본 식별 정보인 `contract`, 대비 수정안인 `repairProposals`가 들어 있습니다. 수정안의 객체를 그대로 `acceptedRepairs`에 담아 다시 보내야 적용되며, 현재 값과 맞지 않는 이전 수정안은 거절합니다. CSS를 전달할 때도 `visualContract`를 함께 보존하세요. 여기에는 컴포넌트별 색상 조합, 폰트 로딩·라이선스 정보, 사용 규칙, 출처, 적용한 수정이 남습니다. 테마 출력은 `roleStyles`와 전체 명세인 `metadata`도 포함합니다. 실제 폰트 로딩과 화면 표현은 적용하는 앱에서 확인해야 합니다.
249
+
250
+ 수정안을 수락할 때는 `light` 또는 `dark`를 각각 요청합니다. `both`는 모드별 제안만 반환하며, 수락한 수정안을 두 모드에 일괄 적용하지 않습니다.
216
251
 
217
252
  ## 다국어 출력
218
253
 
@@ -235,9 +270,12 @@ webstylebook://principles · /principles/{id}
235
270
  webstylebook://design-principles · /design-principles/{id}
236
271
  webstylebook://states/surfaces · /states/{surface} · /states/{surface}/{state}
237
272
  webstylebook://products · /products/{id}
273
+ webstylebook://references · /references/{id}
238
274
  webstylebook://policies/anti-patterns · /policies/verification · /policies/audit-checks
239
275
  ```
240
276
 
277
+ 스타일 상세에는 `locale`, `mode`, 기대하는 `revision`을 쿼리로 지정할 수 있습니다. 예: `webstylebook://styles/brutalist-grid?locale=ko&mode=light`. 선택한 언어와 모드 1개의 명세를 반환하며, 지원하지 않는 값·중복 인자·알 수 없는 쿼리 이름은 명확한 오류로 반환합니다.
278
+
241
279
  ## 프롬프트
242
280
 
243
281
  자주 쓰는 워크플로우용 MCP 프롬프트:
@@ -253,6 +291,36 @@ webstylebook://policies/anti-patterns · /policies/verification · /policies/aud
253
291
  시각적 강조가 정보 가치·과업 관련성·근거 수준에 맞는지도 검사합니다. 카드·통계·Sitemap
254
292
  링크는 유형 자체를 금지하지 않고 실제 사용자 과업에 도움이 되는지로 판단합니다.
255
293
 
294
+ ## 감사 결과 계약
295
+
296
+ `get_design_audit_plan`은 이제 catalog version/hash와 결정론적 `planHash`를 담은 `identity`를
297
+ 반환합니다. 실제 구현을 검사한 뒤 같은 plan query와 함께 다음을 제출합니다.
298
+
299
+ - 검사한 route 또는 screen·state·viewport·theme·locale·role별 target;
300
+ - 지속 가능한 artifact reference, content hash 또는 정확한 route/selector/file/region이 있는 evidence;
301
+ - interaction evidence의 before/input/after/recovery phase;
302
+ - 모든 계획된 check/target 쌍에 대한 결과 1건.
303
+
304
+ `validate_design_audit_result`는 plan을 다시 생성해 오래된 plan hash, 누락·중복 결과,
305
+ 끊어진 evidence reference, 다른 target의 evidence, 잘못된 region, 부당한
306
+ `NOT_APPLICABLE`, 필수 증거가 없거나 실패 증거와 모순되는 `PASS`를 거부합니다. 누락된
307
+ 결과는 숨기지 않고 `NOT_VERIFIED`로 구체화합니다. 재검증 가능한 비교를 위해 plan,
308
+ evidence bundle, 정규화된 result의 content-addressed hash도 반환합니다. 이 툴은 artifact를
309
+ 직접 열지 않으며 계약 유효성을 디자인 품질 점수로 바꾸지 않습니다.
310
+
311
+ 저장소에는 재현 가능한 계약 품질 벤치마크가 포함됩니다.
312
+
313
+ ```bash
314
+ npm run eval:audit-contract
315
+ ```
316
+
317
+ 사람이 라벨링한 정상·adversarial 사례 14건에서 기존 pass-through 판정은 4/14(28.57%)와
318
+ 잘못된 `PASS` 9건을 기록했습니다. 새 validator는 14/14, 잘못된 `PASS` 0건이며 계약의
319
+ 유효/무효도 14건 모두 올바르게 분류했습니다. 증거 누락·서술뿐인 증거·알 수 없는 증거·
320
+ 다른 target의 증거·판정 불가·interaction phase 누락·blocker/major/minor 실패·정직한
321
+ `NOT_VERIFIED`·유효/무효 `NOT_APPLICABLE`을 포함합니다. 이는 결과 계약의 정확도 개선을
322
+ 증명하며, 주관적 시각 판단 자체가 100% 정확하다고 주장하는 수치는 아닙니다.
323
+
256
324
  ## CLI
257
325
 
258
326
  ```bash
@@ -310,6 +378,8 @@ enum, 개수, 런타임 계약을 검증하고, 이 명령은 두 저장소 사
310
378
  - **전송:** stdio (Model Context Protocol)
311
379
  - **클라이언트:** Codex CLI / IDE 확장 · Claude Code · Claude Desktop · Cursor · Windsurf, 그리고 모든 MCP 호환 클라이언트
312
380
 
381
+ `contract`를 생략한 호출은 기존 토큰 형식과 계열 기본값을 유지합니다. 기존 경로에서도 명시한 밀도가 계열 기본값보다 우선하며, CSS·테마 출력에 줄간격 토큰이 포함됩니다. 공통 명세는 기존 도구에 추가한 옵션이므로 새 도구가 필요하지 않습니다.
382
+
313
383
  ## 라이선스
314
384
 
315
385
  [MIT](./LICENSE) — 코드 **및** 번들된 카탈로그 스냅샷에 적용 (상업적 사용 자유).
package/README.md CHANGED
@@ -117,11 +117,16 @@ flowchart LR
117
117
  C --> H[get_ui_state_plan]
118
118
  C --> I[compose_design_tokens]
119
119
  C --> J[get_design_audit_plan]
120
- D & E & F & G & H & I & J -->|design contracts<br/>scores · reason codes<br/>placement · evidence · tokens| A
120
+ C --> K[search_design_references]
121
+ C --> L[get_design_reference]
122
+ C --> M[validate_design_audit_result]
123
+ D & E & F & G & H & I & J & K & L -->|design contracts<br/>observations · scores · reasons<br/>placement · evidence · tokens| A
124
+ A -->|target matrix · evidence refs<br/>one verdict per check/target| M
125
+ M -->|coverage · normalized verdicts<br/>plan/evidence/result hashes| A
121
126
  A -->|writes code<br/>from evidence| Z[Your UI]
122
127
  ```
123
128
 
124
- The agent describes the product; the server scores its curated catalog and returns structured evidence. No code is generated and nothing leaves your machine.
129
+ The agent describes the product; the server scores its curated catalog and returns structured evidence. After inspection, the validator checks the result contract without opening the referenced artifacts or judging visual quality. No code is generated and nothing leaves your machine.
125
130
 
126
131
  ## Install
127
132
 
@@ -204,13 +209,41 @@ Add the same block to your `claude_desktop_config.json`, then restart:
204
209
  |------|--------------|-----------------|
205
210
  | **`recommend_design_direction`** | Scored style candidates with reason codes, **rejected** styles with *why*, secondary pairings, confidence | The model makes the final pick — this is the evidence provider |
206
211
  | **`compare_design_directions`** | 2–4 directions compared across product-fit, repeated-use, density, trust, distinctiveness, accessibility-risk, motion, maintenance | No single winner is declared |
212
+ | **`search_design_references`** | Bounded search across real-world references by text, category, and tags, with concise localized observations | Returns attributed research summaries, not copied screenshots or brand assets |
213
+ | **`get_design_reference`** | One complete localized reference with palette/layout/interaction/motion observations, normalized tokens, source revision, attribution, and rights notice | Original-site copy, typefaces, screenshots, and visual identity remain with their owners |
207
214
  | **`get_design_principle_plan`** | A focused placement, application, and verification plan selected by visual concerns, surface, phase, or principle ids — with source references where available | Craft prompts are testable guidance, not empirical laws or a fixed recipe |
208
215
  | **`get_ux_principle_plan`** | A focused apply-and-verify plan selected by outcomes, surface, phase, or principle ids — with questions, cautions, confidence, and references | Principles are contextual prompts, not universal laws or a substitute for research |
209
216
  | **`get_ui_state_plan`** | Required / recommended / domain UI states for a surface (data-table, form, checkout, chat, developer-console) — triggers, must-show, must-not, a11y, motion | Covers the states agents forget: empty, error, loading, edge |
210
- | **`compose_design_tokens`** | Role-based tokens (color, type, spacing, radius, motion, density) as `json` / `css-variables` / `tailwind` / `typescript`, light / dark / both | Emits WCAG contrast warnings instead of hiding them |
217
+ | **`compose_design_tokens`** | Role-based tokens as `json` / `css-variables` / `tailwind` / `typescript`; opt into the shared visual contract to preserve authored style values and editor changes | Contract mode uses authored color modes and applies only explicitly accepted contrast repairs |
211
218
  | **`get_design_audit_plan`** | Localized, surface-aware checks with stable ids, severity, applicability, required evidence, remediation, user-facing content checks, selected principle checks, and UI-state coverage | The tool plans the audit but never pretends it inspected your project; missing evidence is `NOT_VERIFIED`, not `PASS` |
219
+ | **`validate_design_audit_result`** | Contract validation for the plan query, target matrix, durable evidence references, and one verdict per check/target, with normalized verdicts and stable hashes | It verifies coverage and evidence consistency, not visual quality; `valid: true` is never an overall design pass |
212
220
 
213
- **Catalog:** 48 styles · 25 interface design principles · 23 UX principles · 51 structured audit checks · 20 components · 5 surfaces · 57 UI-state recipes · 29 motion profiles · 14 product archetypes.
221
+ **Catalog:** 520 real-world design references · 48 styles · 25 interface design principles · 23 UX principles · 51 structured audit checks · 20 components · 5 surfaces · 57 UI-state recipes · 29 motion profiles · 14 product archetypes.
222
+
223
+ The reference library is an adapted, high-completeness subset of [OpenDesign](https://opendesign.cc), whose structured specifications are licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Web Stylebook excludes upstream screenshots and brand assets. Original sites, brands, copy, typefaces, and visual identities remain the property of their respective owners; inspect each detail's attribution and rights notice before use.
224
+
225
+ ## Preserve the website's visual specification
226
+
227
+ Opt into the shared contract when the selected style or web-editor adjustments must survive token generation:
228
+
229
+ ```json
230
+ {
231
+ "primaryStyleId": "brutalist-grid",
232
+ "format": "css-variables",
233
+ "contract": { "schema": "webstylebook.visual.v1" },
234
+ "locale": "ko",
235
+ "overrides": {
236
+ "colors": { "text": "#111111" },
237
+ "typography": { "body": { "lineHeight": 1.75 } }
238
+ }
239
+ }
240
+ ```
241
+
242
+ Read `webstylebook://manifest` for `visualContract.contractSchema` and the bundled library's `visualContract.contentHash`. Read `webstylebook://styles/brutalist-grid` for the selected native contract and its `visualContract.revision`. Pass those values as `contract.schema`, `contract.contentHash`, and `contract.revision` to pin the source; a mismatch returns `INVALID_INPUT`. Omitting `colorMode` uses the style's authored native mode. Requesting `light`, `dark`, or `both` succeeds only when the required modes are authored.
243
+
244
+ `overrides` accepts semantic colors, typography roles, spacing, density, and font metadata. Use these explicit values for selections taken from another style; `secondaryStyleId` remains the legacy accent overlay and is rejected in contract mode. Unknown fields and conflicting `density` / `accentOverride` aliases are rejected. Supply `contract` whenever using `overrides` or `acceptedRepairs`.
245
+
246
+ The result includes the selected `visualContract`, source identity in `contract`, and `repairProposals`. Repairs stay unapplied until their exact proposal objects are sent back in `acceptedRepairs`; stale proposals are rejected. Apply accepted repairs with a single `light` or `dark` request; `both` requests return separate mode proposals. Keep `visualContract` alongside exported CSS: it carries component color pairs, font loading and license metadata, usage rules, provenance, and accepted repairs. Theme output also includes `roleStyles` and a complete `metadata` companion. Font loading and rendered appearance still require checks in the consuming app.
214
247
 
215
248
  ## Localized output
216
249
 
@@ -233,9 +266,12 @@ webstylebook://principles · /principles/{id}
233
266
  webstylebook://design-principles · /design-principles/{id}
234
267
  webstylebook://states/surfaces · /states/{surface} · /states/{surface}/{state}
235
268
  webstylebook://products · /products/{id}
269
+ webstylebook://references · /references/{id}
236
270
  webstylebook://policies/anti-patterns · /policies/verification · /policies/audit-checks
237
271
  ```
238
272
 
273
+ Style detail accepts optional `locale`, `mode`, and expected `revision` query parameters, for example `webstylebook://styles/brutalist-grid?locale=ko&mode=light`. It returns one resolved locale and mode; unsupported values, duplicate parameters, and unknown query names return an explicit error.
274
+
239
275
  ## Prompts
240
276
 
241
277
  Ready-made MCP prompts for common workflows:
@@ -253,6 +289,36 @@ context-specific information, and whether its visual emphasis matches informatio
253
289
  relevance, and support. Cards, statistics, and Sitemap links are still judged by their actual
254
290
  user-task value rather than banned as types.
255
291
 
292
+ ## Audit result contract
293
+
294
+ `get_design_audit_plan` now returns an `identity` with the catalog version/hash and a deterministic
295
+ `planHash`. After inspecting the actual implementation, submit the same plan query plus:
296
+
297
+ - one target per inspected route or screen, state, viewport, theme, locale, and role;
298
+ - evidence with a durable artifact reference, content hash, or exact route/selector/file/region;
299
+ - a before/input/after/recovery phase for interaction evidence; and
300
+ - one result for every planned check/target pair.
301
+
302
+ `validate_design_audit_result` regenerates the plan and rejects stale plan hashes, missing or duplicate
303
+ result slots, broken evidence references, cross-target evidence, invalid regions, unsupported
304
+ `NOT_APPLICABLE`, and `PASS` that lacks required evidence or contradicts failed evidence. Missing result
305
+ slots are materialized as `NOT_VERIFIED`, never hidden. The result carries content-addressed plan,
306
+ evidence-bundle, and normalized-result hashes for comparable rechecks. The tool never opens the
307
+ artifact references and never turns contract validity into a design-quality score.
308
+
309
+ The repository includes a reproducible contract-quality benchmark:
310
+
311
+ ```bash
312
+ npm run eval:audit-contract
313
+ ```
314
+
315
+ Across 14 human-labeled normal and adversarial cases, legacy pass-through verdicts score 4/14
316
+ (28.57%) with 9 false `PASS` results. The validator scores 14/14 with 0 false `PASS` results and
317
+ classifies every contract-valid/invalid case correctly. The corpus covers missing, narrative-only,
318
+ unknown, cross-target, indeterminate, phase-less, blocker/major/minor failure, honest
319
+ `NOT_VERIFIED`, and valid/invalid `NOT_APPLICABLE` cases. This demonstrates result-contract
320
+ correctness; it does not claim that subjective visual judgment itself is 100% accurate.
321
+
256
322
  ## CLI
257
323
 
258
324
  ```bash
@@ -311,6 +377,8 @@ source check.
311
377
  - **Transport:** stdio (Model Context Protocol)
312
378
  - **Clients:** Codex CLI / IDE extension, Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible client
313
379
 
380
+ Calls without `contract` keep the existing token format and family defaults. Explicit legacy density now takes precedence over a family's defaults, and CSS / theme output retains line-height tokens. The shared contract is additive; no new tool is required.
381
+
314
382
  ## License
315
383
 
316
384
  [MIT](./LICENSE) — covers the code **and** the bundled catalog snapshot (free for commercial use).
@@ -0,0 +1,125 @@
1
+ import type { CatalogRepository } from '../catalog/repository.js';
2
+ import type { AuditEvidenceType, AuditSeverity, Lang, UxSurface } from '../types.js';
3
+ import { type AuditVerdict, type DesignAuditPlanInput } from './planner.js';
4
+ export declare const AUDIT_EVIDENCE_PHASES: readonly ["static", "before", "input", "after", "recovery"];
5
+ export type AuditEvidencePhase = (typeof AUDIT_EVIDENCE_PHASES)[number];
6
+ export declare const AUDIT_EVIDENCE_OUTCOMES: readonly ["passed", "failed", "cant-tell", "inapplicable", "error"];
7
+ export type AuditEvidenceOutcome = (typeof AUDIT_EVIDENCE_OUTCOMES)[number];
8
+ export declare const AUDIT_TARGET_THEMES: readonly ["light", "dark", "high-contrast", "system", "other"];
9
+ export type AuditTargetTheme = (typeof AUDIT_TARGET_THEMES)[number];
10
+ export interface AuditTarget {
11
+ id: string;
12
+ surface: UxSurface;
13
+ route?: string;
14
+ screen?: string;
15
+ stateId?: string;
16
+ viewport?: {
17
+ width: number;
18
+ height: number;
19
+ label?: string;
20
+ };
21
+ theme?: AuditTargetTheme;
22
+ locale?: Lang;
23
+ userRole?: string;
24
+ buildId?: string;
25
+ }
26
+ export interface AuditEvidenceLocation {
27
+ route?: string;
28
+ selector?: string;
29
+ file?: string;
30
+ line?: number;
31
+ region?: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ unit: 'px' | 'normalized';
37
+ };
38
+ }
39
+ export interface AuditEvidence {
40
+ id: string;
41
+ targetId: string;
42
+ type: AuditEvidenceType;
43
+ phase?: AuditEvidencePhase;
44
+ summary: string;
45
+ outcome?: AuditEvidenceOutcome;
46
+ actual?: unknown;
47
+ expected?: unknown;
48
+ artifactRef?: string;
49
+ contentHash?: string;
50
+ capturedAt?: string;
51
+ location?: AuditEvidenceLocation;
52
+ producer?: {
53
+ name: string;
54
+ version?: string;
55
+ configHash?: string;
56
+ };
57
+ }
58
+ export interface SubmittedAuditCheckResult {
59
+ checkId: string;
60
+ targetId: string;
61
+ verdict: AuditVerdict;
62
+ evidenceRefs?: string[];
63
+ rationale: string;
64
+ remediation?: string;
65
+ actual?: unknown;
66
+ normalizedActual?: unknown;
67
+ expected?: unknown;
68
+ }
69
+ export interface ValidateDesignAuditResultInput {
70
+ plan: DesignAuditPlanInput;
71
+ expectedPlanHash?: string;
72
+ targets: AuditTarget[];
73
+ evidence: AuditEvidence[];
74
+ results: SubmittedAuditCheckResult[];
75
+ }
76
+ export type AuditContractIssueSeverity = 'error' | 'warning';
77
+ export interface AuditContractIssue {
78
+ code: string;
79
+ severity: AuditContractIssueSeverity;
80
+ message: string;
81
+ checkId?: string;
82
+ targetId?: string;
83
+ evidenceId?: string;
84
+ }
85
+ export interface ValidatedAuditCheckResult {
86
+ checkId: string;
87
+ targetId: string;
88
+ submittedVerdict: AuditVerdict | null;
89
+ verdict: AuditVerdict;
90
+ severity: AuditSeverity;
91
+ requiredEvidenceTypes: AuditEvidenceType[];
92
+ observedEvidenceTypes: AuditEvidenceType[];
93
+ evidenceRefs: string[];
94
+ rationale: string;
95
+ remediation?: string;
96
+ actual?: unknown;
97
+ normalizedActual?: unknown;
98
+ expected?: unknown;
99
+ synthesized: boolean;
100
+ }
101
+ export interface ValidatedDesignAuditResult {
102
+ identity: {
103
+ schema: 'webstylebook.audit-result.v1';
104
+ catalogVersion: string;
105
+ catalogContentHash: string;
106
+ planHash: string;
107
+ evidenceBundleHash: string;
108
+ resultHash: string;
109
+ };
110
+ valid: boolean;
111
+ coverage: {
112
+ state: 'full' | 'partial' | 'nothing';
113
+ targets: number;
114
+ plannedChecks: number;
115
+ expectedSlots: number;
116
+ reportedSlots: number;
117
+ verifiedSlots: number;
118
+ missingSlots: number;
119
+ };
120
+ verdictCounts: Record<AuditVerdict, number>;
121
+ issues: AuditContractIssue[];
122
+ results: ValidatedAuditCheckResult[];
123
+ guidance: string[];
124
+ }
125
+ export declare function validateDesignAuditResult(input: ValidateDesignAuditResultInput, repo: CatalogRepository): ValidatedDesignAuditResult;