web-stylebook-mcp 0.1.0 → 0.3.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 (48) hide show
  1. package/README.ko.md +313 -0
  2. package/README.md +260 -48
  3. package/dist/catalog/repository.d.ts +30 -1
  4. package/dist/catalog/repository.js +35 -0
  5. package/dist/catalog/repository.js.map +1 -1
  6. package/dist/catalog/stable-hash.d.ts +2 -0
  7. package/dist/catalog/stable-hash.js +39 -0
  8. package/dist/catalog/stable-hash.js.map +1 -0
  9. package/dist/catalog/validate.js +287 -3
  10. package/dist/catalog/validate.js.map +1 -1
  11. package/dist/design-principles/planner.d.ts +50 -0
  12. package/dist/design-principles/planner.js +165 -0
  13. package/dist/design-principles/planner.js.map +1 -0
  14. package/dist/principles/planner.d.ts +63 -0
  15. package/dist/principles/planner.js +172 -0
  16. package/dist/principles/planner.js.map +1 -0
  17. package/dist/protocol/errors.d.ts +4 -1
  18. package/dist/protocol/errors.js +17 -0
  19. package/dist/protocol/errors.js.map +1 -1
  20. package/dist/protocol/register-prompts.js +48 -5
  21. package/dist/protocol/register-prompts.js.map +1 -1
  22. package/dist/protocol/register-resources.js +60 -1
  23. package/dist/protocol/register-resources.js.map +1 -1
  24. package/dist/protocol/register-tools.js +192 -7
  25. package/dist/protocol/register-tools.js.map +1 -1
  26. package/dist/protocol/result.d.ts +1 -1
  27. package/dist/protocol/result.js +7 -4
  28. package/dist/protocol/result.js.map +1 -1
  29. package/dist/recommendation/scoring.js +14 -3
  30. package/dist/recommendation/scoring.js.map +1 -1
  31. package/dist/server-info.d.ts +4 -3
  32. package/dist/server-info.js +9 -1
  33. package/dist/server-info.js.map +1 -1
  34. package/dist/server.js +2 -2
  35. package/dist/server.js.map +1 -1
  36. package/dist/tokens/compile.js +9 -1
  37. package/dist/tokens/compile.js.map +1 -1
  38. package/dist/tokens/contrast.js +3 -2
  39. package/dist/tokens/contrast.js.map +1 -1
  40. package/dist/types.d.ts +94 -0
  41. package/dist/types.js +28 -0
  42. package/dist/types.js.map +1 -1
  43. package/generated/catalog.v1.json +13829 -9937
  44. package/generated/manifest.v1.json +7 -4
  45. package/package.json +6 -3
  46. package/skill/AGENTS.md +89 -0
  47. package/skill/CLAUDE.md +64 -11
  48. package/skill/web-stylebook-design/SKILL.md +176 -18
package/README.md CHANGED
@@ -1,17 +1,167 @@
1
+ <div align="center">
2
+
1
3
  # web-stylebook-mcp
2
4
 
3
- **Design intelligence for coding agents.**
5
+ **Design intelligence for AI coding agents.** Stop shipping the same hero-plus-three-cards.
6
+ Your agent gets scored design *contracts* — directions, visual-design plans, UX-principle plans, UI-state plans, tokens — then writes the code from evidence.
7
+
8
+ [![npm version](https://img.shields.io/npm/v/web-stylebook-mcp?logo=npm&color=cb3837)](https://www.npmjs.com/package/web-stylebook-mcp)
9
+ [![downloads](https://img.shields.io/npm/dm/web-stylebook-mcp?color=cb3837)](https://www.npmjs.com/package/web-stylebook-mcp)
10
+ [![license](https://img.shields.io/npm/l/web-stylebook-mcp?color=3b82f6)](./LICENSE)
11
+ [![node](https://img.shields.io/node/v/web-stylebook-mcp?logo=nodedotjs&color=339933)](https://nodejs.org)
12
+ [![MCP](https://img.shields.io/badge/MCP-server-6E56CF)](https://modelcontextprotocol.io)
13
+
14
+ **English** · [한국어](./README.ko.md)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ Coding agents default to the same generic UI because they can't *decide* what it should look like — so they fall back to hero + 3 cards + a gradient. `web-stylebook-mcp` is a Model Context Protocol server that hands the agent **design contracts** — scored visual directions, placement-aware visual-design plans, evidence-labeled UX-principle plans, UI-state plans, and design tokens — drawn from the same curated catalog as [webstylebook.com](https://webstylebook.com). It returns **evidence, not code**. Your agent still writes the code — now it knows what to build and what to verify.
4
21
 
5
- Give your coding agent a design vocabulary. Web Stylebook MCP helps AI coding agents
6
- choose a product‑fit visual direction, plan screens, cover real UI states, compose
7
- design tokens, and avoid generic AI‑looking interfaces — without writing the code for them.
22
+ No API key. No model call. No network. No project filesystem access. **Deterministic, read-only, fully local.**
8
23
 
9
- - **No API key. No model call. No network. No project access.** Deterministic, read‑only design knowledge packaged locally.
10
- - Same catalog as [Web Stylebook](https://webstylebook.com).
11
- - English · Korean · Japanese.
24
+ ## Without it / with it
25
+
26
+ | | Without `web-stylebook-mcp` | With `web-stylebook-mcp` |
27
+ |---|---|---|
28
+ | **Direction** | Guesses one look, commits to it | Scored candidates + reason codes + what it *rejected* and why |
29
+ | **Craft** | Principle names dropped into a doc, nothing verified | Placement guidance + an observable check per principle, cautions attached |
30
+ | **UX evidence** | "Hick's Law says…" as a conversation-ender | Evidence-labeled prompts (`strong` / `contextual` / `contested`) you can't restate as law |
31
+ | **UI states** | Happy path only; empty / error / loading bolted on later | Required / recommended / domain states up front, per surface |
32
+ | **Tokens** | Hand-picked hexes, contrast rarely checked | Role-based tokens with WCAG contrast warnings |
33
+ | **Result** | Generic AI UI | A defensible design contract the agent builds from |
34
+
35
+ ## Watch it decide
36
+
37
+ > *"High-density monitoring dashboard for SREs, watched all day on call. Calm, technical. Avoid cyberpunk."*
38
+
39
+ ```jsonc
40
+ // → recommend_design_direction (input)
41
+ {
42
+ "productDescription": "High-density monitoring dashboard for SREs, watched all day on call",
43
+ "productType": "operational-saas",
44
+ "tone": ["calm", "technical"],
45
+ "density": "high",
46
+ "usageFrequency": "daily",
47
+ "avoid": ["cyberpunk"]
48
+ }
49
+ ```
50
+
51
+ ```jsonc
52
+ // ← result
53
+ {
54
+ "confidence": "high",
55
+ "candidates": [ // all tied at 0.91 — ordering is NOT meaningful
56
+ { "styleId": "notion-style", "score": 0.91 },
57
+ { "styleId": "platform-core", "score": 0.91 },
58
+ { "styleId": "quiet-utility", "score": 0.91 },
59
+ { "styleId": "runtime-signal", "score": 0.91 },
60
+ { "styleId": "console-launch", "score": 0.91 }
61
+ ],
62
+ "rejected": [
63
+ { "styleId": "aurora-gradient", "reasonCodes": ["PRODUCT_NOT_IDEAL", "DAILY_USE_OVERSTIMULATION"] },
64
+ { "styleId": "claymorphism", "reasonCodes": ["PRODUCT_NOT_IDEAL"] },
65
+ { "styleId": "cyberpunk-glitch", "reasonCodes": ["EXPLICITLY_AVOIDED", "DAILY_USE_OVERSTIMULATION"] }
66
+ ],
67
+ "pairings": [
68
+ {
69
+ "styleId": "macos-liquid-glass",
70
+ "pairWith": "notion-style",
71
+ "role": ["forms", "navigation", "repetitive surfaces"]
72
+ }
73
+ ],
74
+ "guidance": "Treat candidates as scored evidence; choose using product context. candidates[0] is the strongest match, not a mandate. 5 candidates are tied at the top score — the ordering among them is not meaningful; pick using their \"differentiators\" and your product context."
75
+ }
76
+ ```
77
+
78
+ Notice what it *doesn't* do: it doesn't pretend there's one winner. Five directions tie at 0.91, rejected styles come with reason codes, and pairings are suggestions rather than a mandate. That honesty is the point — the server provides evidence, the agent decides.
79
+
80
+ Then turn the chosen direction into real tokens:
81
+
82
+ ```jsonc
83
+ // → compose_design_tokens(style: "notion-style", format: "css-variables", theme: "light")
84
+ // 0 WCAG contrast warnings
85
+ :root {
86
+ --color-canvas: #ffffff;
87
+ --color-text: #37352f;
88
+ --color-accent: #2383e2;
89
+ --color-border: #d3d3d1;
90
+ /* … role-based color, type, spacing, radius, motion, density */
91
+ }
92
+ ```
93
+
94
+ One request in — and the agent chose a direction, saw what was rejected and why, and got tokens that pass WCAG, without generating a line of code.
95
+
96
+ ## What an agent builds with it
97
+
98
+ A different brief — *"a marketing landing page for **Throughline**, a B2B SaaS that turns scattered customer feedback (support tickets, sales calls, app reviews, Slack) into one prioritized roadmap."* No layout, no hero, no styling was specified. Following the companion skill, the agent composed the opening **from the product's core idea** instead of reaching for a stock hero: the right half is a bespoke diagram of the product's actual mechanic — feedback sources converging into an auto-ranked roadmap — not a decorative card you could paste onto any other site.
99
+
100
+ <div align="center">
101
+ <img src="https://raw.githubusercontent.com/seungdori/web-stylebook-mcp/master/docs/example-throughline-hero.png" alt="A landing-page hero an AI agent composed using web-stylebook-mcp — a bespoke feedback-to-roadmap visualization rather than a generic hero" width="840">
102
+ </div>
103
+
104
+ <div align="center"><sub>Composed by an AI agent following the companion skill — the prompt described the product and stack, nothing about the layout.</sub></div>
105
+
106
+ ## How it works
107
+
108
+ ```mermaid
109
+ flowchart LR
110
+ A[AI coding agent] -->|product, tone,<br/>density, usage| B(web-stylebook-mcp)
111
+ B --> C{Bundled catalog<br/>read-only · offline}
112
+ C --> D[recommend_design_direction]
113
+ C --> E[compare_design_directions]
114
+ C --> F[get_design_principle_plan]
115
+ C --> G[get_ux_principle_plan]
116
+ C --> H[get_ui_state_plan]
117
+ C --> I[compose_design_tokens]
118
+ D & E & F & G & H & I -->|design contracts<br/>scores · reason codes<br/>placement · verify checks · tokens| A
119
+ A -->|writes code<br/>from evidence| Z[Your UI]
120
+ ```
121
+
122
+ The agent describes the product; the server scores its curated catalog and returns structured evidence. No code is generated and nothing leaves your machine.
12
123
 
13
124
  ## Install
14
125
 
126
+ Requires **Node ≥ 20**.
127
+
128
+ <details open>
129
+ <summary><b>Codex CLI · IDE extension</b></summary>
130
+
131
+ Use the Codex CLI:
132
+
133
+ ```bash
134
+ codex mcp add web-stylebook -- npx -y web-stylebook-mcp@latest
135
+ ```
136
+
137
+ Or add it to `~/.codex/config.toml`. You can also use a project-scoped
138
+ `.codex/config.toml` in a trusted repository:
139
+
140
+ ```toml
141
+ [mcp_servers.web-stylebook]
142
+ command = "npx"
143
+ args = ["-y", "web-stylebook-mcp@latest"]
144
+ ```
145
+
146
+ Restart Codex or open a new session after editing config. In the Codex TUI, run `/mcp`
147
+ to confirm the server is active.
148
+
149
+ </details>
150
+
151
+ <details>
152
+ <summary><b>Claude Code</b></summary>
153
+
154
+ ```bash
155
+ claude mcp add web-stylebook -- npx -y web-stylebook-mcp@latest
156
+ ```
157
+
158
+ </details>
159
+
160
+ <details>
161
+ <summary><b>Cursor · Windsurf · generic MCP client</b></summary>
162
+
163
+ Add to your MCP config:
164
+
15
165
  ```json
16
166
  {
17
167
  "mcpServers": {
@@ -23,78 +173,140 @@ design tokens, and avoid generic AI‑looking interfaces — without writing the
23
173
  }
24
174
  ```
25
175
 
26
- Then ask your agent to design something. For the best results, also install the
27
- companion skill / CLAUDE.md fragment (it tells the agent *when* to call these tools).
176
+ </details>
28
177
 
29
- ## Companion skill
178
+ <details>
179
+ <summary><b>Claude Desktop</b></summary>
180
+
181
+ Add the same block to your `claude_desktop_config.json`, then restart:
182
+
183
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
184
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
185
+
186
+ ```json
187
+ {
188
+ "mcpServers": {
189
+ "web-stylebook": {
190
+ "command": "npx",
191
+ "args": ["-y", "web-stylebook-mcp@latest"]
192
+ }
193
+ }
194
+ }
195
+ ```
30
196
 
31
- This package ships the trigger + usage logic in `skill/`:
197
+ </details>
32
198
 
33
- - **Claude Code / skill-aware hosts:** point your skills directory at `skill/web-stylebook-design/`.
34
- - **Other hosts:** copy the block in `skill/CLAUDE.md` into your project's `CLAUDE.md` (or rules file).
199
+ ## Tools
35
200
 
36
- It encodes *when* to call these tools and how to use the results — compose, don't recolor; offer
37
- multiple fully-composed candidates; earn trust, don't fake it; component-owned states; land on
38
- reusable components.
201
+ | Tool | What you get | The honest part |
202
+ |------|--------------|-----------------|
203
+ | **`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 |
204
+ | **`compare_design_directions`** | 2–4 directions compared across product-fit, repeated-use, density, trust, distinctiveness, accessibility-risk, motion, maintenance | No single winner is declared |
205
+ | **`get_design_principle_plan`** | A focused placement, application, and verification plan selected by visual concerns, surface, phase, or principle ids | Craft prompts are testable guidance, not empirical laws or a fixed recipe |
206
+ | **`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 |
207
+ | **`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 |
208
+ | **`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 |
39
209
 
40
- ## Tools (4 compute tools)
210
+ **Catalog:** 48 styles · 22 visual design principles · 23 UX principles · 20 components · 5 surfaces · 57 UI-state recipes · 29 motion profiles · 14 product archetypes.
41
211
 
42
- | Tool | What it does |
43
- |---|---|
44
- | `recommend_design_direction` | Scored style candidates + reason codes + rejected styles with reasons + secondary pairings + confidence. Evidence‑provider: your model makes the final pick. |
45
- | `compare_design_directions` | Compares 2–4 directions across product fit, repeated‑use, density, trust, distinctiveness, accessibility risk, motion and maintenance. No single winner. |
46
- | `get_ui_state_plan` | Required / recommended / domain‑specific UI states for a surface (data‑table, form, checkout, chat, developer‑console) with triggers, must‑show, must‑not, a11y and motion. |
47
- | `compose_design_tokens` | Role‑based design tokens (color, type, spacing, radius, motion, density) in json / css‑variables / tailwind / typescript, light/dark/both, with WCAG contrast warnings. |
212
+ ## Localized output
48
213
 
49
- Prose‑shaped work (search, brief composition, screen planning, and the “when to call” trigger)
50
- is carried by the companion **skill**, not by extra tools.
214
+ Every tool takes an optional `locale`. Reason codes, guidance, and labels come back in the requested language:
215
+
216
+ ```text
217
+ "en" | "ko" | "ja" // English · 한국어 · 日本語
218
+ ```
51
219
 
52
220
  ## Resources
53
221
 
54
- `webstylebook://manifest` · `…/styles` · `…/styles/{id}` · `…/motion` · `…/motion/{id}`
55
- · `…/components` · `…/components/{id}` · `…/states/surfaces` · `…/states/{surface}`
56
- · `…/states/{surface}/{state}` · `…/products` · `…/products/{id}`
57
- · `…/policies/anti-patterns` · `…/policies/verification`
222
+ Browse the catalog directly over MCP resources:
223
+
224
+ ```
225
+ webstylebook://manifest
226
+ webstylebook://styles · /styles/{id}
227
+ webstylebook://motion · /motion/{id}
228
+ webstylebook://components · /components/{id}
229
+ webstylebook://principles · /principles/{id}
230
+ webstylebook://design-principles · /design-principles/{id}
231
+ webstylebook://states/surfaces · /states/{surface} · /states/{surface}/{state}
232
+ webstylebook://products · /products/{id}
233
+ webstylebook://policies/anti-patterns · /policies/verification
234
+ ```
58
235
 
59
236
  ## Prompts
60
237
 
61
- `design-product` · `design-screen` · `complete-ui-states` · `redesign-with-style` · `audit-design-direction`
238
+ Ready-made MCP prompts for common workflows:
239
+
240
+ `design-product` · `design-screen` · `complete-ui-states` · `redesign-with-style` · `audit-design-direction` · `audit-design-principles` · `audit-ux-principles`
62
241
 
63
242
  ## CLI
64
243
 
65
244
  ```bash
66
- web-stylebook-mcp # start MCP server over stdio (default)
245
+ web-stylebook-mcp # run the server over stdio (default)
67
246
  web-stylebook-mcp --version
68
247
  web-stylebook-mcp --catalog-info
69
248
  web-stylebook-mcp --validate-catalog
70
249
  ```
71
250
 
72
- ## Demo
251
+ ## Companion skill
252
+
253
+ A companion skill ships in [`skill/`](./skill) so your agent reaches for these tools at the right moment — and uses the results well (compose, don't recolor; offer multiple candidates; earn trust, don't fake it; land on reusable components):
254
+
255
+ **Codex**
256
+
257
+ - Copy or symlink `skill/web-stylebook-design/` into a Codex skill location such as
258
+ `.agents/skills/web-stylebook-design/` in your repo, or `~/.agents/skills/web-stylebook-design/`
259
+ for your user profile.
260
+ - If you do not want to install the skill, copy `skill/AGENTS.md` into your project's `AGENTS.md`.
73
261
 
74
- > Design a high‑density monitoring dashboard for SREs. Used daily. Keep it calm and technical. Avoid cyberpunk decoration.
262
+ **Claude Code and other agents**
75
263
 
76
- `recommend_design_direction` surfaces calm operational styles like `quiet-utility`,
77
- `platform-core`, and `runtime-signal` among the scored candidates, **rejects** `cyberpunk-glitch`
78
- (`EXPLICITLY_AVOIDED`), suggests a secondary pairing for quieter forms/navigation surfaces, and
79
- records its assumptions and confidence. The agent then reads
80
- the chosen style resources, plans the data‑table states with `get_ui_state_plan`, and emits a
81
- starting token set with `compose_design_tokens`.
264
+ - Point your agent's skills directory at `skill/web-stylebook-design/`, **or**
265
+ - Copy `skill/CLAUDE.md` into your project's `CLAUDE.md` or equivalent rules file.
82
266
 
83
267
  ## Privacy & security
84
268
 
85
- v0.1 reads only the immutable catalog packaged with this module. It does not access your
86
- filesystem, git, environment, shell, browser, network, or any model API. All output is a
87
- deterministic function of the input — the same request always yields the same result.
269
+ | Property | |
270
+ |----------|---|
271
+ | API key | None |
272
+ | Model calls | None |
273
+ | Network access | None — works fully offline |
274
+ | Project filesystem access | None — the server only reads its bundled catalog snapshot |
275
+ | Behavior | Deterministic, read-only |
276
+
277
+ The server reads from a catalog snapshot bundled in the package. Nothing is sent anywhere; the same inputs always yield the same contracts.
278
+
279
+ ## Catalog source sync
280
+
281
+ The canonical catalog is authored in the
282
+ [`web-stylebook`](https://github.com/seungdori/web-stylebook) repository. After generating its
283
+ local MCP handoff snapshot, verify byte-for-byte parity before releasing this package:
284
+
285
+ ```bash
286
+ npm run catalog:check-canonical -- /absolute/path/to/web-stylebook/packages/mcp/generated
287
+ ```
288
+
289
+ Without an argument, the command uses `WEB_STYLEBOOK_CANONICAL_CATALOG_DIR` or the local sibling
290
+ path `../showcase/packages/mcp/generated`. The regular test suite verifies the bundled artifact's
291
+ internal hash, enums, counts, and runtime contract; this command is the explicit cross-repository
292
+ source check.
88
293
 
89
294
  ## Compatibility
90
295
 
91
- - Node ≥ 20.
92
- - Built on `@modelcontextprotocol/sdk` 1.x (stdio transport).
296
+ - **Node:** ≥ 20
297
+ - **Transport:** stdio (Model Context Protocol)
298
+ - **Clients:** Codex CLI / IDE extension, Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible client
93
299
 
94
300
  ## License
95
301
 
96
- MIT — covers both the code and the bundled catalog snapshot. Use this package, including its
97
- catalog data, freely and commercially.
302
+ [MIT](./LICENSE) — covers the code **and** the bundled catalog snapshot (free for commercial use).
98
303
 
99
- > The [Web Stylebook](https://webstylebook.com) website is separately licensed CC BY-NC; this
100
- > package's MIT grant is provided by the same copyright holder for the catalog snapshot shipped here.
304
+ > The [webstylebook.com](https://webstylebook.com) website is licensed CC BY-NC. The same owner grants an MIT license for the catalog snapshot bundled in this package.
305
+ >
306
+ > UX-principle entries are independently written application and verification guidance. They
307
+ > attribute and link to [Laws of UX](https://lawsofux.com) (CC BY-NC-ND 4.0) and supporting
308
+ > references; Laws of UX prose, illustrations, and page layouts are not bundled.
309
+ >
310
+ > Visual-design-principle entries form an independently authored, task-oriented review system for
311
+ > contemporary interfaces. They cover semantic structure, responsive reflow, localization, tokens
312
+ > and themes, multiple input modes, complete state models, recovery, and motion preferences.
@@ -1,4 +1,4 @@
1
- import type { CatalogEnvelope, WebStylebookCatalogV1, CatalogStyle, MotionPattern, ComponentTerm, ProductArchetype, StateSurface, StateRecipe, StyleFamily, Ontology, NotIdealMap, Policies, Lang } from '../types.js';
1
+ import type { CatalogEnvelope, WebStylebookCatalogV1, CatalogStyle, MotionPattern, ComponentTerm, ProductArchetype, StateSurface, StateRecipe, StyleFamily, Ontology, NotIdealMap, Policies, Lang, UxPrinciple, UxPrincipleAttribution, DesignPrinciple } from '../types.js';
2
2
  export interface StyleSummary {
3
3
  id: string;
4
4
  kind: 'style' | 'fusion';
@@ -23,6 +23,27 @@ export interface ComponentSummary {
23
23
  name: string;
24
24
  resourceUri: string;
25
25
  }
26
+ export interface PrincipleSummary {
27
+ id: string;
28
+ category: string;
29
+ name: string;
30
+ summary: string;
31
+ outcomeTags: string[];
32
+ surfaceTags: string[];
33
+ phaseTags: string[];
34
+ confidence: string;
35
+ resourceUri: string;
36
+ }
37
+ export interface DesignPrincipleSummary {
38
+ id: string;
39
+ category: string;
40
+ name: string;
41
+ summary: string;
42
+ concernTags: string[];
43
+ surfaceTags: string[];
44
+ phaseTags: string[];
45
+ resourceUri: string;
46
+ }
26
47
  export interface SurfaceSummary {
27
48
  id: string;
28
49
  name: string;
@@ -42,6 +63,8 @@ export declare class CatalogRepository {
42
63
  private readonly styleById;
43
64
  private readonly motionById;
44
65
  private readonly componentById;
66
+ private readonly principleById;
67
+ private readonly designPrincipleById;
45
68
  private readonly productById;
46
69
  private readonly surfaceById;
47
70
  private readonly recipeById;
@@ -52,14 +75,18 @@ export declare class CatalogRepository {
52
75
  get ontology(): Ontology;
53
76
  get notIdealMap(): NotIdealMap;
54
77
  get policies(): Policies;
78
+ get uxPrincipleAttribution(): UxPrincipleAttribution;
55
79
  get styleFamilies(): StyleFamily[];
56
80
  get catalogVersion(): string;
57
81
  get contentHash(): string;
58
82
  allStyles(): CatalogStyle[];
83
+ allDesignPrinciples(): DesignPrinciple[];
59
84
  getStyle(id: string): CatalogStyle | undefined;
60
85
  getFamily(id: string): StyleFamily | undefined;
61
86
  getMotion(id: string): MotionPattern | undefined;
62
87
  getComponent(id: string): ComponentTerm | undefined;
88
+ getPrinciple(id: string): UxPrinciple | undefined;
89
+ getDesignPrinciple(id: string): DesignPrinciple | undefined;
63
90
  getProduct(id: string): ProductArchetype | undefined;
64
91
  getSurface(id: string): StateSurface | undefined;
65
92
  getRecipe(id: string): StateRecipe | undefined;
@@ -67,6 +94,8 @@ export declare class CatalogRepository {
67
94
  listStyles(locale?: Lang): StyleSummary[];
68
95
  listMotion(locale?: Lang): MotionSummary[];
69
96
  listComponents(locale?: Lang): ComponentSummary[];
97
+ listPrinciples(locale?: Lang): PrincipleSummary[];
98
+ listDesignPrinciples(locale?: Lang): DesignPrincipleSummary[];
70
99
  listSurfaces(locale?: Lang): SurfaceSummary[];
71
100
  listProducts(locale?: Lang): ProductSummary[];
72
101
  }
@@ -16,6 +16,8 @@ export class CatalogRepository {
16
16
  styleById = new Map();
17
17
  motionById = new Map();
18
18
  componentById = new Map();
19
+ principleById = new Map();
20
+ designPrincipleById = new Map();
19
21
  productById = new Map();
20
22
  surfaceById = new Map();
21
23
  recipeById = new Map();
@@ -33,6 +35,10 @@ export class CatalogRepository {
33
35
  this.motionById.set(m.id, m);
34
36
  for (const c of this.data.components)
35
37
  this.componentById.set(c.id, c);
38
+ for (const p of this.data.uxPrinciples)
39
+ this.principleById.set(p.id, p);
40
+ for (const p of this.data.designPrinciples)
41
+ this.designPrincipleById.set(p.id, p);
36
42
  for (const p of this.data.productArchetypes)
37
43
  this.productById.set(p.id, p);
38
44
  for (const f of this.data.styleFamilies)
@@ -64,14 +70,18 @@ export class CatalogRepository {
64
70
  get ontology() { return this.data.ontology; }
65
71
  get notIdealMap() { return this.data.notIdealMap; }
66
72
  get policies() { return this.data.policies; }
73
+ get uxPrincipleAttribution() { return this.data.uxPrincipleAttribution; }
67
74
  get styleFamilies() { return this.data.styleFamilies; }
68
75
  get catalogVersion() { return this.envelope.catalogVersion; }
69
76
  get contentHash() { return this.envelope.contentHash; }
70
77
  allStyles() { return this.data.styles; }
78
+ allDesignPrinciples() { return this.data.designPrinciples; }
71
79
  getStyle(id) { return this.styleById.get(id); }
72
80
  getFamily(id) { return this.familyById.get(id); }
73
81
  getMotion(id) { return this.motionById.get(id); }
74
82
  getComponent(id) { return this.componentById.get(id); }
83
+ getPrinciple(id) { return this.principleById.get(id); }
84
+ getDesignPrinciple(id) { return this.designPrincipleById.get(id); }
75
85
  getProduct(id) { return this.productById.get(id); }
76
86
  getSurface(id) { return this.surfaceById.get(id); }
77
87
  getRecipe(id) { return this.recipeById.get(id); }
@@ -95,6 +105,31 @@ export class CatalogRepository {
95
105
  resourceUri: `webstylebook://components/${c.id}`,
96
106
  }));
97
107
  }
108
+ listPrinciples(locale = 'en') {
109
+ return this.data.uxPrinciples.map((p) => ({
110
+ id: p.id,
111
+ category: p.category,
112
+ name: text(p.name, locale),
113
+ summary: text(p.summary, locale),
114
+ outcomeTags: p.outcomeTags,
115
+ surfaceTags: p.surfaceTags,
116
+ phaseTags: p.phaseTags,
117
+ confidence: p.evidence.confidence,
118
+ resourceUri: `webstylebook://principles/${p.id}`,
119
+ }));
120
+ }
121
+ listDesignPrinciples(locale = 'en') {
122
+ return this.data.designPrinciples.map((p) => ({
123
+ id: p.id,
124
+ category: p.category,
125
+ name: text(p.name, locale),
126
+ summary: text(p.summary, locale),
127
+ concernTags: p.concernTags,
128
+ surfaceTags: p.surfaceTags,
129
+ phaseTags: p.phaseTags,
130
+ resourceUri: `webstylebook://design-principles/${p.id}`,
131
+ }));
132
+ }
98
133
  listSurfaces(locale = 'en') {
99
134
  return this.data.stateSurfaces.map((s) => ({
100
135
  id: s.id, name: text(s.name, locale),
@@ -1 +1 @@
1
- {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/catalog/repository.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,mFAAmF;AACnF,0EAA0E;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAM1C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAmB1C,MAAM,CAAC,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAEnD,SAAS,aAAa;IACpB,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,0CAA0C;IAChG,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,OAAO,iBAAiB;IACnB,QAAQ,CAAkB;IAC1B,IAAI,CAAwB;IAEpB,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC5C,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9C,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;IACjD,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAClD,WAAW,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC9C,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC5C,UAAU,GAAG,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EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC;YACpC,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,CAAC,CAAC,mBAAmB;YAChF,WAAW,EAAE,yBAAyB,CAAC,CAAC,EAAE,EAAE;SAC7C,CAAC,CAAC,CAAC;IACN,CAAC;IACD,YAAY,CAAC,SAAe,IAAI;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7C,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,2BAA2B,CAAC,CAAC,EAAE,EAAE;SACrF,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ /** Content hash over the envelope WITHOUT its own contentHash field. */
2
+ export declare function contentHashOf(envelopeWithoutHash: unknown): string;
@@ -0,0 +1,39 @@
1
+ // Runtime mirror of the build's deterministic serializer (scripts/lib/stable-json.mts),
2
+ // so `--validate-catalog` can recompute the content hash and detect a tampered body —
3
+ // not just a malformed hash string. Must stay byte-identical to the build serializer.
4
+ import { createHash } from 'node:crypto';
5
+ function nfkc(s) {
6
+ return s.normalize('NFKC');
7
+ }
8
+ function codepointCompare(a, b) {
9
+ if (a < b)
10
+ return -1;
11
+ if (a > b)
12
+ return 1;
13
+ return 0;
14
+ }
15
+ function stableNormalize(value) {
16
+ if (Array.isArray(value))
17
+ return value.map(stableNormalize);
18
+ if (value !== null && typeof value === 'object') {
19
+ const input = value;
20
+ const out = {};
21
+ for (const key of Object.keys(input).sort(codepointCompare)) {
22
+ const v = stableNormalize(input[key]);
23
+ if (v !== undefined)
24
+ out[key] = v;
25
+ }
26
+ return out;
27
+ }
28
+ if (typeof value === 'string')
29
+ return nfkc(value);
30
+ return value;
31
+ }
32
+ function stableStringify(value) {
33
+ return JSON.stringify(stableNormalize(value), null, 2) + '\n';
34
+ }
35
+ /** Content hash over the envelope WITHOUT its own contentHash field. */
36
+ export function contentHashOf(envelopeWithoutHash) {
37
+ return `sha256:${createHash('sha256').update(stableStringify(envelopeWithoutHash), 'utf8').digest('hex')}`;
38
+ }
39
+ //# sourceMappingURL=stable-hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stable-hash.js","sourceRoot":"","sources":["../../src/catalog/stable-hash.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,sFAAsF;AACtF,sFAAsF;AAEtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AACD,SAAS,gBAAgB,CAAC,CAAS,EAAE,CAAS;IAC5C,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AACD,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,KAAgC,CAAC;QAC/C,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC5D,MAAM,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,KAAK,S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