@sakaniui/mcp 0.18.2 → 0.18.3

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.
@@ -727,7 +727,7 @@ const tools = {
727
727
  },
728
728
  },
729
729
  get_tokens: {
730
- description: 'Design tokens (CSS custom properties). Pass a group (color, space, radius, shadow, font, motion, glass, surface, liquid, ...) and/or a substring to filter. Only these tokens exist.',
730
+ description: 'Design tokens (CSS custom properties). Pass a group (color, space, radius, shadow, font, motion, glass, surface, liquid, ...) and/or a substring to filter. Only these tokens exist. A token that changes in dark mode (the .dark class) lists { light, dark }, each with its resolved value; the others have one value for both themes.',
731
731
  inputSchema: { type: 'object', properties: { group: { type: 'string' }, query: { type: 'string' } } },
732
732
  run(args) {
733
733
  const g = strArg(args, 'group'); const q = strArg(args, 'query');
@@ -735,11 +735,24 @@ const tools = {
735
735
  const groups = manifest.tokens.groups;
736
736
  if (g.value && !has(groups, g.value)) return fail(`Unknown token group "${g.value}". Groups: ${Object.keys(groups).join(', ')}`);
737
737
  const needle = q.value?.toLowerCase();
738
+ const dark = manifest.tokens.dark ?? {};
739
+ const light = Object.assign({}, ...Object.values(groups));
740
+ // follow var() chains to the real value, in the light or the dark theme, so "var(--color-neutral-500)" also shows #78716A
741
+ const resolve = (name, mode) => {
742
+ let v = mode === 'dark' && name in dark ? dark[name] : light[name];
743
+ for (let i = 0; i < 8 && typeof v === 'string'; i++) {
744
+ const m = v.match(/^var\((--[a-z0-9-]+)\)$/i); if (!m) break;
745
+ v = mode === 'dark' && m[1] in dark ? dark[m[1]] : light[m[1]];
746
+ }
747
+ return v;
748
+ };
749
+ const show = (name, raw, mode) => { const r = resolve(name, mode); return r && r !== raw && !String(r).startsWith('var(') ? `${raw} (${r})` : raw; };
738
750
  const out = {};
739
751
  for (const [name, toks] of Object.entries(groups)) {
740
752
  if (g.value && name !== g.value) continue;
741
- const sel = Object.entries(toks).filter(([k, v]) => !needle || k.includes(needle) || String(v).toLowerCase().includes(needle));
742
- if (sel.length) out[name] = Object.fromEntries(sel);
753
+ const sel = Object.entries(toks).filter(([k, v]) => !needle || k.includes(needle) || String(v).toLowerCase().includes(needle) || String(dark[k] ?? '').toLowerCase().includes(needle));
754
+ // a token that is different in dark (its own .dark value, or a var() of one that is) shows both values; the rest stay a plain string
755
+ if (sel.length) out[name] = Object.fromEntries(sel.map(([k, v]) => [k, k in dark || resolve(k, 'light') !== resolve(k, 'dark') ? { light: show(k, v, 'light'), dark: show(k, dark[k] ?? v, 'dark') } : v]));
743
756
  }
744
757
  return text(Object.keys(out).length ? out : `No tokens match. Groups: ${Object.keys(groups).join(', ')}`);
745
758
  },
package/data/AGENTS.md CHANGED
@@ -102,6 +102,10 @@ colour. Do not guess names (`--fg-muted`, `--bg-canvas`, `--spacing-4` and `--sp
102
102
  - **Radius** — `--radius-{none,2xs,xs,sm,md,lg,xl,2xl,3xl,full}` (`md` = 8px is the default control radius).
103
103
  - **Shadow** — `--shadow-{xs,sm,md,lg,xl,2xl}`. **Font** — `--font-sans`, `--font-mono`.
104
104
  **Motion** — `--transition-{fast,base,hover,slow}`.
105
+ - **Light and dark values:** `get_tokens` lists `{ light, dark }` for every token that is different in dark mode, each with
106
+ its resolved colour. Do not assume a token keeps its light value in dark: `--color-fg-muted` and `--color-fg-subtle` swap
107
+ (muted is the lighter grey in dark, so it stays readable), `--color-border-focus` and `--color-brand-fg` lighten, and the
108
+ chart colours are one set in both. Use the token by name and the theme picks the value.
105
109
  - Full, resolved list for light and dark: https://www.sakaniui.com/docs/tokens
106
110
 
107
111
  ## 3. When nothing fits
package/data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to `@sakaniui/react` are documented here.
4
4
 
5
+ ## 0.18.3
6
+
7
+ ### Fixed
8
+
9
+ - **`get_tokens` (MCP) shows the dark value.** The manifest kept only the first (light) definition of each token, so an agent asking for `--color-fg-muted` saw `neutral-500` and had no way to know that dark mode swaps it with `--color-fg-subtle`. The manifest now carries the `.dark` overrides (`tokens.dark`), and `get_tokens` lists `{ light, dark }` for every token that differs in dark, each resolved to its colour (for example `var(--color-neutral-500) (#78716A)`). 56 tokens show both values; the rest are one string as before. The existing `tokens.groups` of the manifest is unchanged, and the build verifies that every dark token is a listed token. AGENTS.md says not to assume a token keeps its light value in dark.
10
+
5
11
  ## 0.18.2
6
12
 
7
13
  ### Fixed