@csszyx/mcp-server 0.10.8 → 0.10.10

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/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
6
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
7
  import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema } from '@modelcontextprotocol/sdk/types.js';
8
8
  import fs from 'node:fs';
9
- import { SPECIAL_VARIANTS, KNOWN_VARIANTS, PROPERTY_MAP, transform, SUGGESTION_MAP, BOOLEAN_SHORTHANDS, REMOVED_BOOLEAN_SUGAR } from '@csszyx/compiler';
9
+ import { sortStrings, SPECIAL_VARIANTS, KNOWN_VARIANTS, PROPERTY_MAP, transform, SUGGESTION_MAP, BOOLEAN_SHORTHANDS, REMOVED_BOOLEAN_SUGAR } from '@csszyx/compiler';
10
10
  import { z } from 'zod';
11
11
  import { migrateSource, classNameToSzObject } from '@csszyx/cli';
12
12
  import { parseThemeBlocks, hasTokens } from '@csszyx/unplugin';
@@ -277,8 +277,8 @@ function readResource(uri) {
277
277
  mimeType: "application/json",
278
278
  text: JSON.stringify(
279
279
  {
280
- standard: [...KNOWN_VARIANTS].sort(),
281
- parametric: [...SPECIAL_VARIANTS].sort()
280
+ standard: sortStrings(KNOWN_VARIANTS),
281
+ parametric: sortStrings(SPECIAL_VARIANTS)
282
282
  },
283
283
  null,
284
284
  2
@@ -824,7 +824,36 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
824
824
  throw new Error(`Prompt error: ${message}`);
825
825
  }
826
826
  });
827
+ function handleCliFlags(argv) {
828
+ if (argv.includes("--version") || argv.includes("-v")) {
829
+ console.log(VERSION);
830
+ return true;
831
+ }
832
+ if (argv.includes("--help") || argv.includes("-h")) {
833
+ console.log(
834
+ [
835
+ `csszyx MCP Server v${VERSION}`,
836
+ "",
837
+ "Usage: csszyx-mcp start the MCP server on stdio (JSON-RPC)",
838
+ " csszyx-mcp --version print the version and exit",
839
+ " csszyx-mcp --help print this help and exit",
840
+ "",
841
+ `Exposes ${TOOLS.length} tools, ${listResources().length} resources, ${listPrompts().length} prompts.`,
842
+ "",
843
+ "Health probe (no extra deps) \u2014 a clean initialize over stdio:",
844
+ ` echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}' | csszyx-mcp`,
845
+ "A JSON-RPC result on stdout means the server/package is healthy; then",
846
+ "the problem is the host MCP attachment, not csszyx."
847
+ ].join("\n")
848
+ );
849
+ return true;
850
+ }
851
+ return false;
852
+ }
827
853
  async function main() {
854
+ if (handleCliFlags(process.argv.slice(2))) {
855
+ return;
856
+ }
828
857
  const transport = new StdioServerTransport();
829
858
  await server.connect(transport);
830
859
  console.error(`csszyx MCP Server v${VERSION} running on stdio`);
package/llms-full.txt CHANGED
@@ -643,6 +643,77 @@ Strategy for static analysis vs runtime generation.
643
643
  - ✅ `sz({ color: isErr ? 'red-500' : 'green-500' })` (Zero Runtime)
644
644
  - ⚠️ `sz({ color:`red-${shade}`})` (Runtime injection overhead)
645
645
 
646
+ ## TypeScript: `sz` on custom components
647
+
648
+ The JSX augmentation (`@csszyx/types/jsx`) adds `sz` to **host elements only**
649
+ (`<div>`, `<span>`, … via React `HTMLAttributes` / `SVGAttributes`). A custom
650
+ component has its own props type, so `sz` is **not auto-typed** there.
651
+
652
+ Two independent layers:
653
+
654
+ - **Compile** — the transform lowers `sz` → `className` on ANY element, custom
655
+ included: `<Card sz={{ p: 4 }} />` → `<Card className="p-4" />`. So it works at
656
+ runtime as long as the component forwards `className` down to a host element.
657
+ - **Type** — only auto-typed when the component's props derive from host attributes.
658
+
659
+ | Component props type | `sz` typed? |
660
+ | :--------------------------------------------------------- | :------------------ |
661
+ | `{ title: string }` (fresh type) | ❌ TS error |
662
+ | `ComponentProps<'div'>` / `extends HTMLAttributes<T>` | ✅ inherited |
663
+ | `{ title: string } & Pick<ComponentProps<'div'>, 'sz'>` | ✅ just `sz` |
664
+
665
+ Add `sz` to a fresh props type by picking it (no import needed) or declaring it:
666
+
667
+ ```tsx
668
+ import type { ComponentProps } from 'react';
669
+ type Props = { title: string } & Pick<ComponentProps<'div'>, 'sz'>;
670
+ // equivalent: import type { SzPropValue } from '@csszyx/types'; then `sz?: SzPropValue`
671
+ ```
672
+
673
+ The augmentation must be in scope (a `/// <reference types="@csszyx/types/jsx" />`
674
+ or the project's `csszyx-env.d.ts`), otherwise `sz` is not a key of
675
+ `ComponentProps<'div'>` and `Pick` fails.
676
+
677
+ ## Styling parts of a compound component
678
+
679
+ No special API. `sz` compiles to `className` on ANY element — host tags, custom
680
+ components, and dotted names (`Card.Header`) — and each is safelisted + mangled like
681
+ a normal `sz`. So style a compound component's parts by giving each part its own `sz`:
682
+
683
+ ```tsx
684
+ <Card sz={{ p: 4 }}>
685
+ <Card.Header sz={{ bg: 'gray-100', fontWeight: 'bold' }}>Title</Card.Header>
686
+ <Card.Body sz={{ text: 'sm' }}>Body</Card.Body>
687
+ </Card>
688
+ // → each part compiled to className at build time; all classes safelisted.
689
+ ```
690
+
691
+ Build it as a plain React compound component; each part forwards `sz` (already
692
+ rewritten to `className` by the transform) onto a host element. Type each part with
693
+ `ComponentProps<'div'>` (or the relevant tag) to get `sz` + `className` for free.
694
+ Merge a part's own defaults with the consumer's override via `szcn` (mangle-aware,
695
+ last-wins) or `clsx`.
696
+
697
+ ## `szs` — slot map for a component's internal parts
698
+
699
+ For parts a component renders ITSELF (no consumer content), `szs` maps slot names
700
+ to sz values. The transform compiles each VALUE to its class string (key kept),
701
+ safelisting + mangling like `sz`; the component forwards `props.szs?.<slot>` into
702
+ the matching child's `className`.
703
+
704
+ ```tsx
705
+ type CardProps = { szs?: Szs<'header' | 'icon'> }; // Szs from @csszyx/types
706
+ <Card szs={{ header: { bg: 'gray-100' }, icon: { color: 'red-500' } }} />
707
+ // → <Card szs={{ header: "bg-gray-100", icon: "text-red-500" }} />
708
+ // component: <header className={props.szs?.header} />
709
+ ```
710
+
711
+ Rules: custom components only (host element → dev warn, unchanged). Slot values
712
+ must be STATIC — a pure object literal (nested variants OK) or a raw class string;
713
+ identifiers/conditionals/spreads leave the attribute unchanged with a dev warning.
714
+ Keys are identifiers. `sz` styles the element itself; `szs` styles its internal
715
+ parts — a component can take both.
716
+
646
717
 
647
718
  # Backgrounds
648
719
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csszyx/mcp-server",
3
- "version": "0.10.8",
3
+ "version": "0.10.10",
4
4
  "description": "Model Context Protocol (MCP) server for csszyx — enables AI agents to understand and generate sz props",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,15 +30,15 @@
30
30
  "dependencies": {
31
31
  "@modelcontextprotocol/sdk": "^1.29.0",
32
32
  "zod": "^3.23.8",
33
- "@csszyx/compiler": "0.10.8",
34
- "@csszyx/cli": "0.10.8",
35
- "@csszyx/unplugin": "0.10.8"
33
+ "@csszyx/compiler": "0.10.10",
34
+ "@csszyx/cli": "0.10.10",
35
+ "@csszyx/unplugin": "0.10.10"
36
36
  },
37
37
  "devDependencies": {
38
38
  "typescript": "^6.0.3",
39
39
  "@types/node": "^20.0.0",
40
40
  "tsx": "^4.0.0",
41
- "vitest": "^4.1.6",
41
+ "vitest": "^4.1.9",
42
42
  "unbuild": "^3.6.1"
43
43
  },
44
44
  "keywords": [