@craft-ts/mcp 0.8.6 → 0.8.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-ts/mcp",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "MCP server, Agent Skills, and LLM files for coding agents using @craft-ts/core",
5
5
  "author": "Romain Geffrault",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "test": "vitest run --config vitest.config.mts"
36
36
  },
37
37
  "dependencies": {
38
- "@craft-ts/dev-tools": "^0.8.6",
38
+ "@craft-ts/dev-tools": "^0.8.7",
39
39
  "@modelcontextprotocol/sdk": "1.26.0",
40
40
  "zod": "4.3.6"
41
41
  },
@@ -21,8 +21,8 @@ required and must not be introduced just to solve a Craft problem.
21
21
  - `migrate-to-craft-ts` — run `craft-migrate`, then finish diagnostics
22
22
  - `craft-ts-effect-v4` — use Effect v4 services, Layers, `queryEffect`, and
23
23
  the synchronous-member declaration (`SyncOp` / `computedEffect`)
24
- - `craft-ts-style` — the typed design system: sheets, axes, the visual
25
- matrix, context obligations
24
+ - `craft-ts-style` — the typed design system: sheets, axes, static text
25
+ contrast, the visual matrix, context obligations
26
26
  - `craft-ts-i18n` — typed catalogues, locale parity, semantic tokens
27
27
 
28
28
  For a project created by `craft create`, keep the generated development
@@ -57,7 +57,9 @@ If MCP is not configured, read https://ng-angular-stack.github.io/craft/llms.txt
57
57
  Never assemble a class string at render time — the template sets one constant
58
58
  class and a `data-*` attribute. `@craft-ts/style` is a **build step**: without
59
59
  `craftStyle()` from `@craft-ts/style/vite` in the Vite config, the sheets
60
- typecheck and emit nothing. Load `craft-ts-style` before touching one.
60
+ typecheck and emit nothing. Load `craft-ts-style` before touching one. When
61
+ the project exposes `npm run style:check`, run it after changing colours,
62
+ typography, template classes, themes, hover or another visual axis.
61
63
  - Translations live in a `@craft-ts/i18n` catalogue: `defineCatalog` + `msg` for
62
64
  the reference locale, `defineLocaleLike` for every other one, so a missing key
63
65
  is a compile error. A token may validate or parse its parameter with a
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: craft-ts-style
3
- description: Build and review the typed design system of a CraftTS project with @craft-ts/style — palettes, axes, typed custom properties, sheets, context obligations, the visual matrix, and the style_impact / style_matrix / style_debt MCP tools. Use when adding or changing visual rules, a variant, a theme, dark mode, or a visual test.
3
+ description: Build and review the typed design system of a CraftTS project with @craft-ts/style — palettes, axes, typed custom properties, sheets, static text-contrast checks, context obligations, the visual matrix, and style graph tools. Use when adding or changing visual rules, colours, typography, a variant, hover, a theme, dark mode, or a visual test.
4
4
  ---
5
5
 
6
6
  # CraftTS typed styles
@@ -15,14 +15,17 @@ emitted from.
15
15
  The system is a **build step**, not a runtime library. Before writing a rule,
16
16
  confirm three things exist; without them the sheets typecheck and emit nothing.
17
17
 
18
- 1. `@craft-ts/style` in `dependencies`, `@craft-ts/style-testing` in
19
- `devDependencies`.
18
+ 1. `@craft-ts/style` in `dependencies`. Static contrast additionally needs
19
+ `@craft-ts/dev-tools` in `devDependencies`; `@craft-ts/style-testing` is
20
+ needed only for visual scenarios or attestation.
20
21
  2. `craftStyle()` from `@craft-ts/style/vite` in the Vite `plugins` array, with
21
22
  a `dumpPath`. The dump is what the graph and the MCP tools below read; no
22
23
  `dumpPath`, no answers.
23
24
  3. `import 'virtual:craft-style.css'` once, at the app entry.
24
25
 
25
- A project created by `craft create` already has all three.
26
+ A current project created by `craft create` with typed CSS already has the
27
+ required wiring. An older project must be migrated explicitly; do not assume
28
+ updating the package rewrites its Vite, ESLint or CI configuration.
26
29
 
27
30
  ## Hard rules
28
31
 
@@ -52,7 +55,7 @@ A project created by `craft create` already has all three.
52
55
 
53
56
  | you need | call |
54
57
  | --------------------- | ------------------------------------------- |
55
- | colours | `definePalette({ group: { token: { light, dark } } })` |
58
+ | colours | `definePalette('ui', { group: { token: { light, dark } } })` |
56
59
  | viewport breakpoints | `defineBreakpoints({ md: at.minInlineSize(unit.rem(48)) })` |
57
60
  | a state variant | `defineStateAxis('tone', ['neutral', 'danger'])` |
58
61
  | an axis that may only write one kind | `defineAxis(name, values, onlyVarsOfKind(kind.color))` |
@@ -60,8 +63,8 @@ A project created by `craft create` already has all three.
60
63
  | typed custom properties | `cssVars('prefix', { ink: kind.color(token) })` |
61
64
  | the rules themselves | `craftStyles('name', { root: [...] }, { axes: [...] })` |
62
65
 
63
- `scheme`, `motion`, `forcedColors`, `contrast`, `scrollState` and `descendant`
64
- ship with the package and need no declaration.
66
+ `scheme`, `motion`, `forcedColors`, `contrast`, `interaction`, `scrollState`
67
+ and `descendant` ship with the package and need no declaration.
65
68
 
66
69
  Two details the types cannot enforce and the browser does:
67
70
 
@@ -82,6 +85,56 @@ Level 3 is a **per-route** guarantee. One component in the path handing back a
82
85
  loosely typed subtree stops the requirement travelling, and a partial adoption
83
86
  gives zero of the guarantee, not most of it.
84
87
 
88
+ ## Static text contrast
89
+
90
+ `npm run style:check` is the blocking WCAG 2.2 AA text-contrast proof. It builds
91
+ once so `craftStyle({ dumpPath: '.craft/style-graph.json' })` writes the style
92
+ dump, then runs:
93
+
94
+ ```bash
95
+ craft-graph --style-contrast --style-dump .craft/style-graph.json --project tsconfig.app.json
96
+ ```
97
+
98
+ It reads typed sheets and the TypeScript template graph; it does not need a
99
+ browser, screenshots or Playwright. It checks `4.5:1` for normal text and `3:1`
100
+ for text at least 24px, or at least 18.5px with weight 700 or above.
101
+
102
+ When changing a palette, `color`, `background-color`, font size/weight, a
103
+ template class, theme or visual axis, run `npm run style:check` after the
104
+ focused tests. A failure should be fixed at the named token or state, not hidden
105
+ with a local colour override.
106
+
107
+ Model hover through `when(interaction.hover, [...])`, nest it inside the tone
108
+ or other state it combines with, and add `interaction` to the sheet's `axes`
109
+ budget. A hand-written `:hover` emits CSS but is invisible to the scenario
110
+ contract. Enable `craftRules.configs.typedCss.rules` so raw hover and contrast
111
+ properties in component styles fail lint.
112
+
113
+ Indeterminate rows fail by default. `--allow-indeterminate` is only for the
114
+ first migration inventory; remove it before adding the check to CI. An empty
115
+ report also fails, because zero checked elements is normally broken wiring, not
116
+ a clean application.
117
+
118
+ Do not overstate coverage. Background images, alpha, unknown sizes, dynamic
119
+ classes and incomplete render contexts become indeterminate when they reach the
120
+ graph. External CSS, inline styles outside CraftTS, canvas/SVG text, generated
121
+ content, filters and blend modes may be invisible altogether. The ESLint
122
+ `uncovered` option only suppresses lint for a path; it does not add a gap to the
123
+ contrast report. Font-script and cap-height differences, including CJK, are not
124
+ detected from the CSS size/weight convention.
125
+
126
+ ### Retrofitting an older project
127
+
128
+ 1. Align installed `@craft-ts/*` packages on one current version.
129
+ 2. Name palettes with `definePalette('name', spec)`.
130
+ 3. Add the dump path to `craftStyle()` and keep
131
+ `virtual:craft-style.css` imported once at app entry.
132
+ 4. Enable the `typedCss` ESLint preset and migrate hand-written hover to
133
+ `interaction.hover`.
134
+ 5. Add the build-plus-`craft-graph --style-contrast` command as `style:check`.
135
+ 6. Run once with `--allow-indeterminate`, close visible gaps, remove the flag,
136
+ then add `npm run style:check` to CI.
137
+
85
138
  ## Testing
86
139
 
87
140
  ```ts
@@ -113,4 +166,5 @@ Three MCP tools read the dump, so you do not have to write a script:
113
166
  An empty `style_matrix` is the signature of a missing `dumpPath`.
114
167
 
115
168
  Full guide: `/guide/style/setup`, `/guide/style/define`, `/guide/style/tokens`,
116
- `/guide/style/variants`, `/guide/style/obligations`, `/guide/style/testing`.
169
+ `/guide/style/variants`, `/guide/style/obligations`, `/guide/style/testing`,
170
+ `/guide/style/contrast`.