@atomixstudio/mcp 0.1.0 → 1.0.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.
@@ -1,1144 +0,0 @@
1
- /**
2
- * AI Rules Generator
3
- *
4
- * Generates project-specific rules and MCP configurations for AI coding tools
5
- * using the Atomix design system.
6
- *
7
- * SUPPORTED MCP CLIENTS (from modelcontextprotocol.io/clients):
8
- *
9
- * IDE/Editors:
10
- * - Cursor (.cursorrules)
11
- * - VS Code + GitHub Copilot (.github/copilot-instructions.md)
12
- * - Windsurf (.windsurfrules)
13
- * - Zed (MCP native)
14
- * - Continue (.continuerules)
15
- * - Cline (.clinerules)
16
- * - CodeGPT (MCP native)
17
- * - Amazon Q IDE (MCP native)
18
- * - Augment Code (MCP native)
19
- * - VT Code (MCP native)
20
- *
21
- * Desktop Apps:
22
- * - Claude Desktop (MCP native)
23
- * - BoltAI (MCP native)
24
- * - Chatbox (MCP native)
25
- * - ChatGPT (MCP native)
26
- *
27
- * CLI/Terminal:
28
- * - Warp (.warp/workflows or MCP)
29
- * - Amazon Q CLI (MCP native)
30
- * - goose (MCP native)
31
- *
32
- * Frameworks/Libraries:
33
- * - Genkit (MCP native)
34
- * - LangChain (MCP native)
35
- * - fast-agent (MCP native)
36
- */
37
-
38
- import { TOKEN_CATEGORIES } from "./tokens.js";
39
- import { COMPONENT_TOKENS } from "./component-tokens.js";
40
-
41
- // ============================================
42
- // SUPPORTED AI TOOLS
43
- // ============================================
44
-
45
- export type AIToolId =
46
- | "cursor"
47
- | "copilot"
48
- | "windsurf"
49
- | "cline"
50
- | "continue"
51
- | "zed"
52
- | "claude-desktop"
53
- | "generic";
54
-
55
- export interface AIToolConfig {
56
- id: AIToolId;
57
- name: string;
58
- rulesFilename: string;
59
- rulesPath: string; // Relative to project root
60
- mcpConfigPath?: string; // Where MCP config lives for this tool
61
- supportsMarkdown: boolean;
62
- supportsMCP: boolean;
63
- description: string;
64
- }
65
-
66
- /**
67
- * Registry of supported AI coding tools and their rules file conventions
68
- */
69
- export const AI_TOOLS: Record<AIToolId, AIToolConfig> = {
70
- cursor: {
71
- id: "cursor",
72
- name: "Cursor",
73
- rulesFilename: ".cursorrules",
74
- rulesPath: ".cursorrules",
75
- mcpConfigPath: ".cursor/mcp.json",
76
- supportsMarkdown: true,
77
- supportsMCP: true,
78
- description: "Cursor IDE - AI-first code editor",
79
- },
80
- copilot: {
81
- id: "copilot",
82
- name: "GitHub Copilot",
83
- rulesFilename: "copilot-instructions.md",
84
- rulesPath: ".github/copilot-instructions.md",
85
- supportsMarkdown: true,
86
- supportsMCP: false, // Uses rules file instead
87
- description: "GitHub Copilot in VS Code, JetBrains, etc.",
88
- },
89
- windsurf: {
90
- id: "windsurf",
91
- name: "Windsurf",
92
- rulesFilename: ".windsurfrules",
93
- rulesPath: ".windsurfrules",
94
- mcpConfigPath: ".windsurf/mcp.json",
95
- supportsMarkdown: true,
96
- supportsMCP: true,
97
- description: "Windsurf Editor by Codeium",
98
- },
99
- cline: {
100
- id: "cline",
101
- name: "Cline",
102
- rulesFilename: ".clinerules",
103
- rulesPath: ".clinerules",
104
- supportsMarkdown: true,
105
- supportsMCP: true,
106
- description: "Cline VS Code extension (formerly Claude Dev)",
107
- },
108
- continue: {
109
- id: "continue",
110
- name: "Continue",
111
- rulesFilename: ".continuerules",
112
- rulesPath: ".continuerules",
113
- mcpConfigPath: ".continue/config.json",
114
- supportsMarkdown: true,
115
- supportsMCP: true,
116
- description: "Continue - open source AI code assistant",
117
- },
118
- zed: {
119
- id: "zed",
120
- name: "Zed",
121
- rulesFilename: ".zed/assistant/rules.md",
122
- rulesPath: ".zed/assistant/rules.md",
123
- supportsMarkdown: true,
124
- supportsMCP: true,
125
- description: "Zed Editor with AI assistant",
126
- },
127
- "claude-desktop": {
128
- id: "claude-desktop",
129
- name: "Claude Desktop",
130
- rulesFilename: "",
131
- rulesPath: "",
132
- mcpConfigPath: "~/Library/Application Support/Claude/claude_desktop_config.json",
133
- supportsMarkdown: false,
134
- supportsMCP: true,
135
- description: "Claude Desktop App by Anthropic",
136
- },
137
- generic: {
138
- id: "generic",
139
- name: "Generic AI",
140
- rulesFilename: "AI_GUIDELINES.md",
141
- rulesPath: "AI_GUIDELINES.md",
142
- supportsMarkdown: true,
143
- supportsMCP: false,
144
- description: "Generic guidelines for any AI tool",
145
- },
146
- };
147
-
148
- // ============================================
149
- // MCP CONFIG GENERATION
150
- // ============================================
151
-
152
- export type MCPConfigToolId = "cursor" | "claude-desktop" | "windsurf" | "continue" | "vscode";
153
-
154
- export interface MCPConfigOptions {
155
- /** Path to the MCP server (default: npx @atomixstudio/mcp) */
156
- serverPath?: string;
157
- /** Use npx to run the server */
158
- useNpx?: boolean;
159
- /** Design system ID for per-user MCP mode */
160
- dsId?: string;
161
- /** API key for authentication (required for per-user mode) */
162
- apiKey?: string;
163
- /** @deprecated Use dsId instead. Tenant ID for backwards compatibility */
164
- tenantId?: string;
165
- /** Project name for identification */
166
- projectName?: string;
167
- }
168
-
169
- export interface MCPConfig {
170
- tool: MCPConfigToolId;
171
- filename: string;
172
- path: string;
173
- content: string;
174
- instructions: string;
175
- }
176
-
177
- /**
178
- * Generate MCP configuration file for a specific AI tool
179
- */
180
- export function generateMCPConfig(
181
- tool: MCPConfigToolId,
182
- options: MCPConfigOptions = {}
183
- ): MCPConfig {
184
- const {
185
- serverPath,
186
- useNpx = true,
187
- dsId,
188
- apiKey,
189
- tenantId, // Legacy support
190
- projectName = "my-project",
191
- } = options;
192
-
193
- const npxCommand = useNpx ? "npx" : "node";
194
- const npxArgs = useNpx
195
- ? ["@atomixstudio/mcp@latest"]
196
- : [serverPath || "./node_modules/@atomixstudio/mcp/dist/index.js"];
197
-
198
- // Use dsId + apiKey (new format) or fall back to tenantId (legacy)
199
- const effectiveDsId = dsId || tenantId;
200
-
201
- if (effectiveDsId && effectiveDsId !== "default") {
202
- npxArgs.push("--ds-id", effectiveDsId);
203
-
204
- // Only add API key if provided
205
- if (apiKey) {
206
- npxArgs.push("--api-key", apiKey);
207
- }
208
- }
209
-
210
- switch (tool) {
211
- case "cursor": {
212
- const config = {
213
- mcpServers: {
214
- atomix: {
215
- command: npxCommand,
216
- args: npxArgs,
217
- },
218
- },
219
- };
220
-
221
- return {
222
- tool: "cursor",
223
- filename: "mcp.json",
224
- path: ".cursor/mcp.json",
225
- content: JSON.stringify(config, null, 2),
226
- instructions: `
227
- ## Cursor MCP Setup
228
-
229
- 1. Create the file \`.cursor/mcp.json\` in your project root
230
- 2. Paste the configuration below
231
- 3. Restart Cursor IDE
232
- 4. The Atomix MCP server will be available in Cursor's AI features
233
-
234
- ### Configuration File
235
- \`\`\`json
236
- ${JSON.stringify(config, null, 2)}
237
- \`\`\`
238
-
239
- ### Verify Setup
240
- After restarting Cursor, you can verify the MCP server is working by:
241
- - Opening the AI chat (Cmd/Ctrl + L)
242
- - Asking: "What design tokens are available?"
243
- - The AI should query the Atomix MCP server and list token categories
244
- `.trim(),
245
- };
246
- }
247
-
248
- case "claude-desktop": {
249
- const config = {
250
- mcpServers: {
251
- atomix: {
252
- command: npxCommand,
253
- args: npxArgs,
254
- },
255
- },
256
- };
257
-
258
- const configPath = process.platform === "darwin"
259
- ? "~/Library/Application Support/Claude/claude_desktop_config.json"
260
- : process.platform === "win32"
261
- ? "%APPDATA%\\Claude\\claude_desktop_config.json"
262
- : "~/.config/Claude/claude_desktop_config.json";
263
-
264
- return {
265
- tool: "claude-desktop",
266
- filename: "claude_desktop_config.json",
267
- path: configPath,
268
- content: JSON.stringify(config, null, 2),
269
- instructions: `
270
- ## Claude Desktop MCP Setup
271
-
272
- 1. Locate your Claude Desktop config file:
273
- - **macOS**: \`${configPath}\`
274
- - **Windows**: \`%APPDATA%\\Claude\\claude_desktop_config.json\`
275
- - **Linux**: \`~/.config/Claude/claude_desktop_config.json\`
276
-
277
- 2. Create or edit the file with the configuration below
278
-
279
- 3. Restart Claude Desktop
280
-
281
- 4. The Atomix MCP server will be available when chatting with Claude
282
-
283
- ### Configuration File
284
- \`\`\`json
285
- ${JSON.stringify(config, null, 2)}
286
- \`\`\`
287
-
288
- ### Verify Setup
289
- After restarting Claude Desktop:
290
- - Start a new conversation
291
- - Ask: "Can you check what Atomix design tokens are available?"
292
- - Claude should use the MCP server to query tokens
293
- `.trim(),
294
- };
295
- }
296
-
297
- case "windsurf": {
298
- const config = {
299
- mcpServers: {
300
- atomix: {
301
- command: npxCommand,
302
- args: npxArgs,
303
- },
304
- },
305
- };
306
-
307
- return {
308
- tool: "windsurf",
309
- filename: "mcp.json",
310
- path: ".windsurf/mcp.json",
311
- content: JSON.stringify(config, null, 2),
312
- instructions: `
313
- ## Windsurf MCP Setup
314
-
315
- 1. Create the file \`.windsurf/mcp.json\` in your project root
316
- 2. Paste the configuration below
317
- 3. Restart Windsurf Editor
318
- 4. The Atomix MCP server will be available in Cascade
319
-
320
- ### Configuration File
321
- \`\`\`json
322
- ${JSON.stringify(config, null, 2)}
323
- \`\`\`
324
- `.trim(),
325
- };
326
- }
327
-
328
- case "continue": {
329
- const config = {
330
- models: [],
331
- mcpServers: [
332
- {
333
- name: "atomix",
334
- command: npxCommand,
335
- args: npxArgs,
336
- },
337
- ],
338
- };
339
-
340
- return {
341
- tool: "continue",
342
- filename: "config.json",
343
- path: ".continue/config.json",
344
- content: JSON.stringify(config, null, 2),
345
- instructions: `
346
- ## Continue MCP Setup
347
-
348
- 1. Create or edit \`.continue/config.json\` in your project root
349
- 2. Add the mcpServers section below
350
- 3. Restart VS Code
351
- 4. The Atomix MCP server will be available in Continue
352
-
353
- ### Configuration File
354
- \`\`\`json
355
- ${JSON.stringify(config, null, 2)}
356
- \`\`\`
357
-
358
- Note: If you already have a config.json, merge the mcpServers array.
359
- `.trim(),
360
- };
361
- }
362
-
363
- case "vscode": {
364
- // VS Code uses settings.json or extension-specific configs
365
- return {
366
- tool: "vscode",
367
- filename: "settings.json",
368
- path: ".vscode/settings.json",
369
- content: JSON.stringify({
370
- "mcp.servers": {
371
- atomix: {
372
- command: npxCommand,
373
- args: npxArgs,
374
- },
375
- },
376
- }, null, 2),
377
- instructions: `
378
- ## VS Code MCP Setup
379
-
380
- For VS Code, MCP support depends on your AI extension:
381
-
382
- ### Option 1: Use GitHub Copilot Instructions
383
- Create \`.github/copilot-instructions.md\` with Atomix rules (use getAIToolRules)
384
-
385
- ### Option 2: Use Continue Extension
386
- See Continue setup instructions above
387
-
388
- ### Option 3: Use Cline Extension
389
- 1. Install Cline extension
390
- 2. Cline will auto-detect MCP servers in .cursor/mcp.json or .vscode/settings.json
391
-
392
- ### Settings.json (for MCP-aware extensions)
393
- \`\`\`json
394
- {
395
- "mcp.servers": {
396
- "atomix": {
397
- "command": "${npxCommand}",
398
- "args": ${JSON.stringify(npxArgs)}
399
- }
400
- }
401
- }
402
- \`\`\`
403
- `.trim(),
404
- };
405
- }
406
-
407
- default:
408
- throw new Error(`Unknown MCP config tool: ${tool}`);
409
- }
410
- }
411
-
412
- /**
413
- * Generate MCP configs for all supported tools
414
- */
415
- export function generateAllMCPConfigs(options: MCPConfigOptions = {}): MCPConfig[] {
416
- const tools: MCPConfigToolId[] = ["cursor", "claude-desktop", "windsurf", "continue", "vscode"];
417
- return tools.map(tool => generateMCPConfig(tool, options));
418
- }
419
-
420
- // ============================================
421
- // SETUP INSTRUCTIONS
422
- // ============================================
423
-
424
- /**
425
- * Get detailed setup instructions for a specific AI tool
426
- */
427
- export function getSetupInstructions(toolId: AIToolId): string {
428
- const tool = AI_TOOLS[toolId];
429
-
430
- if (!tool) {
431
- throw new Error(`Unknown AI tool: ${toolId}. Available: ${Object.keys(AI_TOOLS).join(", ")}`);
432
- }
433
-
434
- const baseInstructions = `
435
- # ${tool.name} Setup for Atomix Design System
436
-
437
- ${tool.description}
438
-
439
- ## Overview
440
-
441
- ${tool.supportsMCP ? `${tool.name} supports MCP (Model Context Protocol), allowing direct integration with the Atomix design token server.` : `${tool.name} uses a rules file to understand the Atomix design system.`}
442
-
443
- `;
444
-
445
- switch (toolId) {
446
- case "cursor":
447
- return baseInstructions + `
448
- ## Quick Setup
449
-
450
- ### Step 1: Add MCP Configuration
451
-
452
- Create \`.cursor/mcp.json\` in your project root:
453
-
454
- \`\`\`json
455
- {
456
- "mcpServers": {
457
- "atomix": {
458
- "command": "npx",
459
- "args": ["@atomixstudio/mcp@latest"]
460
- }
461
- }
462
- }
463
- \`\`\`
464
-
465
- ### Step 2: Add Rules File (Optional but Recommended)
466
-
467
- Create \`.cursorrules\` in your project root with Atomix guidelines.
468
- Use \`getAIToolRules({ tool: "cursor" })\` to generate this file.
469
-
470
- ### Step 3: Restart Cursor
471
-
472
- After adding the MCP config, restart Cursor IDE completely.
473
-
474
- ## Verification
475
-
476
- 1. Open AI chat (Cmd/Ctrl + L)
477
- 2. Ask: "What Atomix design tokens are available?"
478
- 3. Cursor should query the MCP server and respond with token information
479
-
480
- ## Available MCP Tools
481
-
482
- Once configured, you can use these in conversations:
483
- - \`getToken("colors.static.brand.primary")\` - Get a specific token
484
- - \`listTokens("colors")\` - List tokens in a category
485
- - \`getComponentTokens("button")\` - Get component tokens
486
- - \`validateUsage("#ff0000")\` - Check if a value is allowed
487
- - \`searchTokens("brand")\` - Search for tokens
488
- `;
489
-
490
- case "claude-desktop":
491
- return baseInstructions + `
492
- ## Quick Setup
493
-
494
- ### Step 1: Locate Config File
495
-
496
- - **macOS**: \`~/Library/Application Support/Claude/claude_desktop_config.json\`
497
- - **Windows**: \`%APPDATA%\\Claude\\claude_desktop_config.json\`
498
- - **Linux**: \`~/.config/Claude/claude_desktop_config.json\`
499
-
500
- ### Step 2: Add MCP Configuration
501
-
502
- Create or edit the config file:
503
-
504
- \`\`\`json
505
- {
506
- "mcpServers": {
507
- "atomix": {
508
- "command": "npx",
509
- "args": ["@atomixstudio/mcp@latest"]
510
- }
511
- }
512
- }
513
- \`\`\`
514
-
515
- ### Step 3: Restart Claude Desktop
516
-
517
- Completely quit and reopen Claude Desktop.
518
-
519
- ## Verification
520
-
521
- Start a new conversation and ask:
522
- "Can you check what Atomix design tokens are available?"
523
-
524
- Claude should use the MCP server to query and list tokens.
525
- `;
526
-
527
- case "copilot":
528
- return baseInstructions + `
529
- ## Quick Setup
530
-
531
- GitHub Copilot doesn't support MCP directly, but uses instruction files.
532
-
533
- ### Step 1: Create Instructions File
534
-
535
- Create \`.github/copilot-instructions.md\` in your project:
536
-
537
- Use \`getAIToolRules({ tool: "copilot" })\` to generate the content.
538
-
539
- ### Step 2: Enable Custom Instructions
540
-
541
- In VS Code settings, ensure:
542
- \`\`\`json
543
- {
544
- "github.copilot.chat.codeGeneration.useInstructionFiles": true
545
- }
546
- \`\`\`
547
-
548
- ## Verification
549
-
550
- 1. Open Copilot Chat
551
- 2. Ask about design tokens
552
- 3. Copilot should follow the Atomix guidelines from the instructions file
553
- `;
554
-
555
- case "windsurf":
556
- return baseInstructions + `
557
- ## Quick Setup
558
-
559
- ### Step 1: Add MCP Configuration
560
-
561
- Create \`.windsurf/mcp.json\` in your project root:
562
-
563
- \`\`\`json
564
- {
565
- "mcpServers": {
566
- "atomix": {
567
- "command": "npx",
568
- "args": ["@atomixstudio/mcp@latest"]
569
- }
570
- }
571
- }
572
- \`\`\`
573
-
574
- ### Step 2: Add Rules File
575
-
576
- Create \`.windsurfrules\` in your project root.
577
- Use \`getAIToolRules({ tool: "windsurf" })\` to generate this file.
578
-
579
- ### Step 3: Restart Windsurf
580
-
581
- Restart the editor to load the MCP configuration.
582
- `;
583
-
584
- case "cline":
585
- return baseInstructions + `
586
- ## Quick Setup
587
-
588
- ### Step 1: Create Rules File
589
-
590
- Create \`.clinerules\` in your project root.
591
- Use \`getAIToolRules({ tool: "cline" })\` to generate this file.
592
-
593
- ### Step 2: MCP Auto-Detection
594
-
595
- Cline can auto-detect MCP servers from:
596
- - \`.cursor/mcp.json\`
597
- - Project configuration
598
-
599
- If you have Cursor's MCP config, Cline will use it automatically.
600
-
601
- ### Step 3: Manual MCP Setup (if needed)
602
-
603
- In Cline settings, add MCP server configuration:
604
- - Command: \`npx\`
605
- - Args: \`@atomixstudio/mcp@latest\`
606
- `;
607
-
608
- case "continue":
609
- return baseInstructions + `
610
- ## Quick Setup
611
-
612
- ### Step 1: Add MCP Configuration
613
-
614
- Create or edit \`.continue/config.json\`:
615
-
616
- \`\`\`json
617
- {
618
- "mcpServers": [
619
- {
620
- "name": "atomix",
621
- "command": "npx",
622
- "args": ["@atomixstudio/mcp@latest"]
623
- }
624
- ]
625
- }
626
- \`\`\`
627
-
628
- ### Step 2: Add Rules File (Optional)
629
-
630
- Create \`.continuerules\` in your project root.
631
- Use \`getAIToolRules({ tool: "continue" })\` to generate this file.
632
-
633
- ### Step 3: Restart VS Code
634
-
635
- Restart VS Code to load the Continue configuration.
636
- `;
637
-
638
- case "zed":
639
- return baseInstructions + `
640
- ## Quick Setup
641
-
642
- ### Step 1: Add Rules File
643
-
644
- Create \`.zed/assistant/rules.md\` in your project root.
645
- Use \`getAIToolRules({ tool: "zed" })\` to generate this file.
646
-
647
- ### Step 2: MCP Configuration
648
-
649
- Zed's MCP support is configured in Zed settings.
650
- Check Zed documentation for the latest MCP configuration format.
651
- `;
652
-
653
- default:
654
- return baseInstructions + `
655
- ## Generic Setup
656
-
657
- ### Step 1: Create Guidelines File
658
-
659
- Create \`AI_GUIDELINES.md\` in your project root.
660
- Use \`getAIToolRules({ tool: "generic" })\` to generate this file.
661
-
662
- ### Step 2: Reference in Prompts
663
-
664
- When working with AI tools, reference the guidelines file in your prompts
665
- or include it in your context.
666
- `;
667
- }
668
- }
669
-
670
- // ============================================
671
- // RULES GENERATION (kept from original)
672
- // ============================================
673
-
674
- export function generateCursorRules(projectName: string, strict: boolean): string {
675
- const componentList = Object.keys(COMPONENT_TOKENS).join(", ");
676
- const categoryList = TOKEN_CATEGORIES.join(", ");
677
-
678
- const strictRules = strict ? `
679
- ## Hard Rules (Strict Mode)
680
-
681
- 1. **NO arbitrary values** — \`w-[350px]\`, \`bg-[#ff0000]\` are FORBIDDEN
682
- 2. **NO hardcoded colors** — All colors must use CSS variables or token imports
683
- 3. **NO hardcoded spacing** — Use \`spacing.*\` tokens (e.g., \`@spacing.md\`, \`@spacing.lg\`)
684
- 4. **NO hardcoded typography** — Use \`typography.fontSize.*\` and \`typography.fontWeight.*\`
685
- 5. **Token vocabulary only** — If a value isn't in the design system, don't use it
686
-
687
- ### Escape Hatch
688
-
689
- If external constraints require arbitrary values:
690
-
691
- \`\`\`tsx
692
- {/* @design-override: YouTube embed requires 16:9 aspect ratio */}
693
- <div className="aspect-[16/9]">
694
- \`\`\`
695
-
696
- Document the reason. The override comment signals intentional deviation.
697
- ` : `
698
- ## Guidelines (Non-Strict Mode)
699
-
700
- 1. **Prefer tokens** — Use design system tokens when available
701
- 2. **Document overrides** — If using arbitrary values, add a comment explaining why
702
- 3. **Consistency** — Match existing patterns in the codebase
703
- `;
704
-
705
- const tierGuidance = `
706
- ## Token Tier System (Critical)
707
-
708
- Atomix tokens are organized in tiers. Understanding this hierarchy is essential:
709
-
710
- ### Tier 1: Primitives (Read-Only Reference)
711
-
712
- Raw foundational values. **DO NOT use these directly in components.**
713
-
714
- | Type | Example Path | Example Value | Use For |
715
- |------|-------------|---------------|---------|
716
- | Color scales | \`colors.scales.green.500\` | \`#10B981\` | Reference only |
717
- | Spacing scale | \`spacing.md\` | \`1rem\` | Token reference |
718
- | Font sizes | \`typography.fontSize.sm\` | \`0.875rem\` | Reference only |
719
- | Radius scale | \`radius.lg\` | \`12px\` | Token reference |
720
-
721
- These values are **locked** — AI tools should never suggest modifying them.
722
-
723
- ### Tier 2: Semantics (Primary API)
724
-
725
- Purpose-driven tokens that reference primitives. **USE THESE in components.**
726
-
727
- | Type | Example Path | Maps To | Use For |
728
- |------|-------------|---------|---------|
729
- | Mode colors | \`colors.modes.light.bgSurface\` | \`neutral[5]\` | Backgrounds |
730
- | Semantic radius | \`radius.semantic.button\` | \`scale.md\` | Component corners |
731
- | TypeSets | \`typography.typeSets.title-lg\` | Composed style | Text styling |
732
- | Focus rings | \`shadows.focus.ring\` | Composed shadow | A11y focus |
733
-
734
- These are **editable via Atomix Designer** and auto-switch for dark mode.
735
-
736
- ### Tier 3: Component Tokens
737
-
738
- Component-specific token assignments. Managed via Atomix Designer.
739
-
740
- - Button variants: primary, secondary, outline, ghost
741
- - Card variants: default, outlined, elevated
742
- - Sizes: sm, md, lg
743
-
744
- ---
745
-
746
- ### Correct Token Usage
747
-
748
- \`\`\`tsx
749
- // ✅ CORRECT: Use semantic color (Tier 2)
750
- style={{ backgroundColor: "var(--atomix-bg-surface)" }}
751
-
752
- // ❌ WRONG: Using primitive directly (Tier 1)
753
- style={{ backgroundColor: colors.scales.neutral[5] }}
754
-
755
- // ✅ CORRECT: Use typeSet (Tier 2)
756
- style={{ ...typography.typeSets["title-lg"] }}
757
-
758
- // ❌ WRONG: Using primitive font size (Tier 1)
759
- style={{ fontSize: typography.fontSize["2xl"] }}
760
- \`\`\`
761
-
762
- ### When to Reference Primitives
763
-
764
- Primitives are useful for:
765
- 1. **Validation** — Checking if a hardcoded value matches a token
766
- 2. **Documentation** — Explaining what a semantic token resolves to
767
- 3. **A11y calculations** — Contrast ratio checks need actual hex values
768
- 4. **Debug logging** — Showing resolved values in dev tools
769
-
770
- But **NEVER** use primitive paths directly in component styling code.
771
- `;
772
-
773
- return `# ${projectName} — Atomix Design System Rules
774
-
775
- This project uses the **Atomix Design System**. All UI code must follow these guidelines.
776
-
777
- ---
778
- ${strictRules}
779
- ---
780
- ${tierGuidance}
781
- ---
782
-
783
- ## Token Categories
784
-
785
- Available token categories: ${categoryList}
786
-
787
- ### Color Tokens
788
-
789
- Use CSS variables for all colors:
790
-
791
- \`\`\`tsx
792
- // ✅ Correct
793
- style={{ backgroundColor: "var(--atomix-bg-surface)" }}
794
- style={{ color: "var(--atomix-text-primary)" }}
795
-
796
- // ❌ Wrong
797
- style={{ backgroundColor: "#ffffff" }}
798
- style={{ color: "rgb(0, 0, 0)" }}
799
- \`\`\`
800
-
801
- **Semantic color aliases:**
802
- - \`--atomix-brand\` — Primary brand color
803
- - \`--atomix-bg-page\` — Page background
804
- - \`--atomix-bg-surface\` — Card/surface background
805
- - \`--atomix-bg-muted\` — Muted/secondary background
806
- - \`--atomix-text-primary\` — Primary text color
807
- - \`--atomix-text-secondary\` — Secondary text color
808
- - \`--atomix-text-muted\` — Muted/placeholder text
809
- - \`--atomix-icon-brand\` — Brand-colored icons
810
- - \`--atomix-icon-strong\` — High contrast icons
811
- - \`--atomix-icon-subtle\` — Medium contrast icons
812
- - \`--atomix-icon-disabled\` — Disabled state icons
813
- - \`--atomix-border-primary\` — Default border color
814
-
815
- ### Spacing Tokens
816
-
817
- Use spacing tokens for all padding, margin, and gap values:
818
-
819
- \`\`\`tsx
820
- import { spacing } from "@atomix/tokens/primitives";
821
-
822
- // ✅ Correct
823
- style={{ padding: spacing.inset.md }}
824
- style={{ gap: spacing.gap.sm }}
825
-
826
- // ❌ Wrong
827
- style={{ padding: "16px" }}
828
- style={{ gap: "8px" }}
829
- \`\`\`
830
-
831
- **Spacing scale:** xs, sm, md, lg, xl, 2xl, 3xl
832
-
833
- ### Typography Tokens
834
-
835
- Use typography tokens for font properties:
836
-
837
- \`\`\`tsx
838
- import { typography } from "@atomix/tokens/primitives";
839
-
840
- // ✅ Correct
841
- style={{
842
- fontSize: typography.fontSize.sm,
843
- fontWeight: typography.fontWeight.medium,
844
- lineHeight: typography.lineHeight.normal,
845
- }}
846
-
847
- // ❌ Wrong
848
- style={{ fontSize: "14px", fontWeight: 500 }}
849
- \`\`\`
850
-
851
- ### Motion Tokens
852
-
853
- Use motion tokens for animations:
854
-
855
- \`\`\`tsx
856
- import { motion } from "@atomix/tokens/primitives";
857
-
858
- // ✅ Correct
859
- style={{
860
- transitionDuration: motion.duration.fast,
861
- transitionTimingFunction: motion.easing.ease,
862
- }}
863
-
864
- // ❌ Wrong
865
- style={{ transition: "all 150ms ease" }}
866
- \`\`\`
867
-
868
- ---
869
-
870
- ## Component Usage
871
-
872
- Available components: ${componentList}
873
-
874
- ### Using the MCP Server
875
-
876
- This project has an MCP server for querying design tokens. Use these tools:
877
-
878
- - \`getToken("path.to.token")\` — Get a specific token value
879
- - \`listTokens("colors")\` — List all tokens in a category
880
- - \`getComponentTokens("button")\` — Get tokens for a component
881
- - \`validateUsage("value")\` — Check if a value follows the design system
882
- - \`searchTokens("brand")\` — Search for tokens by name or value
883
-
884
- ### Component Patterns
885
-
886
- When implementing components:
887
-
888
- 1. Check the component tokens first: \`getComponentTokens("componentName")\`
889
- 2. Use the documented variants and sizes
890
- 3. Apply tokens through CSS variables or direct imports
891
- 4. Follow the existing component architecture
892
-
893
- ---
894
-
895
- ## Import Patterns
896
-
897
- \`\`\`tsx
898
- // Import primitives for direct use
899
- import { colors, spacing, typography, motion } from "@atomix/tokens/primitives";
900
-
901
- // Or import the combined object
902
- import { primitives } from "@atomix/tokens";
903
-
904
- // Use CSS variables in styles (preferred for colors)
905
- const style = {
906
- backgroundColor: "var(--atomix-bg-surface)",
907
- padding: spacing.inset.md,
908
- borderRadius: "var(--atomix-radius-scale-md)",
909
- };
910
- \`\`\`
911
-
912
- ---
913
-
914
- ## Dark Mode
915
-
916
- Colors automatically switch in dark mode when using CSS variables:
917
-
918
- \`\`\`tsx
919
- // This works in both light and dark mode
920
- style={{
921
- backgroundColor: "var(--atomix-bg-surface)",
922
- color: "var(--atomix-text-primary)",
923
- }}
924
- \`\`\`
925
-
926
- The \`.dark\` class on the root element toggles all color variables.
927
-
928
- ---
929
-
930
- ## When Unsure
931
-
932
- 1. **Search tokens first:** Use \`searchTokens("query")\` to find relevant tokens
933
- 2. **Check component tokens:** Use \`getComponentTokens("component")\` for component-specific values
934
- 3. **Use the nearest token:** If exact match unavailable, use the closest semantic token
935
- 4. **Flag for review:** Add \`{/* TODO: need new token? */}\` comment if a token seems missing
936
-
937
- ---
938
-
939
- ## Reference
940
-
941
- - Token package: \`@atomix/tokens\`
942
- - CSS variables: All prefixed with \`--atomix-\`
943
- - MCP server: \`atomix-mcp\` (run \`npm run start\` in packages/atomix-mcp)
944
- `;
945
- }
946
-
947
- /**
948
- * Generate a minimal rules file focusing on essential rules
949
- */
950
- export function generateMinimalRules(): string {
951
- return `# Atomix Design System
952
-
953
- Use design tokens from \`@atomix/tokens\`:
954
-
955
- ## Token Tiers (Important!)
956
-
957
- - **Primitives** (Tier 1): Raw values — READ-ONLY reference, don't use directly
958
- - **Semantics** (Tier 2): Purpose-driven — USE THESE in components
959
- - **Components** (Tier 3): Component assignments — Managed via Designer
960
-
961
- ## Colors (Semantic - Tier 2)
962
- \`\`\`tsx
963
- // ✅ Use semantic CSS variables
964
- style={{ backgroundColor: "var(--atomix-bg-surface)" }}
965
- style={{ color: "var(--atomix-text-primary)" }}
966
- style={{ borderColor: "var(--atomix-border-primary)" }}
967
- // Icon colors
968
- style={{ color: "var(--atomix-icon-brand)" }} // Brand icons
969
- style={{ color: "var(--atomix-icon-strong)" }} // High contrast icons
970
- style={{ color: "var(--atomix-icon-subtle)" }} // Medium contrast icons
971
- style={{ color: "var(--atomix-icon-disabled)" }} // Disabled icons
972
-
973
- // ❌ Don't use primitive scales directly
974
- style={{ backgroundColor: colors.scales.neutral[5] }}
975
- \`\`\`
976
-
977
- ## Spacing (Use scale keys)
978
- \`\`\`tsx
979
- // In component-defaults.ts, use semantic keys:
980
- padding: { top: "sm", right: "md", bottom: "sm", left: "md" }
981
-
982
- // These resolve to CSS variables automatically
983
- \`\`\`
984
-
985
- ## Typography (Use TypeSets - Tier 2)
986
- \`\`\`tsx
987
- import { typography } from "@atomix/tokens/primitives";
988
-
989
- // ✅ Use composed typeSets
990
- style={{ ...typography.typeSets["title-lg"] }}
991
-
992
- // ❌ Don't use raw fontSize primitives
993
- style={{ fontSize: typography.fontSize["2xl"] }}
994
- \`\`\`
995
-
996
- ## Rules
997
- - NO hardcoded hex colors
998
- - NO hardcoded pixel values
999
- - Use **semantic** tokens (Tier 2), not primitives (Tier 1)
1000
- - Use CSS variables for colors (auto dark mode)
1001
- - Primitives are for reference/validation only
1002
- `;
1003
- }
1004
-
1005
- // ============================================
1006
- // MULTI-TOOL RULES GENERATION
1007
- // ============================================
1008
-
1009
- export interface GeneratedRulesFile {
1010
- tool: AIToolConfig;
1011
- filename: string;
1012
- path: string;
1013
- content: string;
1014
- }
1015
-
1016
- /**
1017
- * Generate rules for a specific AI tool
1018
- */
1019
- export function generateRulesForTool(
1020
- toolId: AIToolId,
1021
- projectName: string,
1022
- strict: boolean
1023
- ): GeneratedRulesFile {
1024
- const tool = AI_TOOLS[toolId];
1025
-
1026
- if (!tool) {
1027
- throw new Error(`Unknown AI tool: ${toolId}. Available: ${Object.keys(AI_TOOLS).join(", ")}`);
1028
- }
1029
-
1030
- // Add tool-specific header
1031
- const header = `<!-- Generated for ${tool.name} by Atomix MCP Server -->
1032
- <!-- Tool: ${tool.description} -->
1033
- <!-- Rules file: ${tool.rulesPath} -->
1034
- <!-- Generated: ${new Date().toISOString()} -->
1035
-
1036
- `;
1037
-
1038
- const content = header + generateCursorRules(projectName, strict);
1039
-
1040
- return {
1041
- tool,
1042
- filename: tool.rulesFilename,
1043
- path: tool.rulesPath,
1044
- content,
1045
- };
1046
- }
1047
-
1048
- /**
1049
- * Generate rules for ALL supported AI tools at once
1050
- */
1051
- export function generateRulesForAllTools(
1052
- projectName: string,
1053
- strict: boolean
1054
- ): GeneratedRulesFile[] {
1055
- return Object.keys(AI_TOOLS)
1056
- .filter(id => AI_TOOLS[id as AIToolId].rulesPath !== "") // Skip tools without rules files
1057
- .map((toolId) =>
1058
- generateRulesForTool(toolId as AIToolId, projectName, strict)
1059
- );
1060
- }
1061
-
1062
- /**
1063
- * Get list of all supported AI tools
1064
- */
1065
- export function getSupportedAITools(): AIToolConfig[] {
1066
- return Object.values(AI_TOOLS);
1067
- }
1068
-
1069
- /**
1070
- * Generate a summary of which files to create for full AI tool support
1071
- */
1072
- export function generateToolSetupGuide(projectName: string): string {
1073
- const tools = getSupportedAITools();
1074
- const mcpTools = tools.filter(t => t.supportsMCP);
1075
- const rulesTools = tools.filter(t => t.rulesPath);
1076
-
1077
- return `# AI Tool Setup Guide for ${projectName}
1078
-
1079
- This project uses the **Atomix Design System** with MCP (Model Context Protocol).
1080
-
1081
- ## Quick Start
1082
-
1083
- Choose your AI tool and follow the setup:
1084
-
1085
- | Tool | MCP Support | Rules File | Setup Command |
1086
- |------|-------------|------------|---------------|
1087
- ${tools.map(t => `| ${t.name} | ${t.supportsMCP ? "Yes" : "No"} | ${t.rulesPath || "N/A"} | \`getSetupInstructions("${t.id}")\` |`).join("\n")}
1088
-
1089
- ## MCP-Enabled Tools (Recommended)
1090
-
1091
- These tools can query Atomix tokens directly:
1092
-
1093
- ${mcpTools.map(t => `- **${t.name}** — ${t.description}`).join("\n")}
1094
-
1095
- ### Generate MCP Config
1096
-
1097
- \`\`\`
1098
- exportMCPConfig({ tool: "cursor" }) // For Cursor
1099
- exportMCPConfig({ tool: "claude-desktop" }) // For Claude Desktop
1100
- exportMCPConfig({ tool: "all" }) // All configs at once
1101
- \`\`\`
1102
-
1103
- ## Rules-Based Tools
1104
-
1105
- These tools use instruction files:
1106
-
1107
- ${rulesTools.filter(t => !t.supportsMCP).map(t => `- **${t.name}** — \`${t.rulesPath}\``).join("\n")}
1108
-
1109
- ### Generate Rules Files
1110
-
1111
- \`\`\`
1112
- getAIToolRules({ tool: "copilot" }) // For GitHub Copilot
1113
- getAIToolRules({ tool: "all" }) // All rules at once
1114
- \`\`\`
1115
-
1116
- ## Available MCP Tools
1117
-
1118
- Once connected, AI tools can use:
1119
-
1120
- | Tool | Description |
1121
- |------|-------------|
1122
- | \`getToken\` | Get a specific token by path |
1123
- | \`listTokens\` | List tokens in a category |
1124
- | \`getComponentTokens\` | Get tokens for a component |
1125
- | \`validateUsage\` | Check if a value follows the design system |
1126
- | \`searchTokens\` | Search tokens by name or value |
1127
- | \`exportMCPConfig\` | Generate MCP configuration files |
1128
- | \`getSetupInstructions\` | Get detailed setup instructions |
1129
-
1130
- ## Token Tier System
1131
-
1132
- | Tier | Mutable | Use For |
1133
- |------|---------|---------|
1134
- | Primitive | No | Reference only (validation, a11y) |
1135
- | Semantic | Yes (Designer) | Primary API for styling |
1136
- | Component | Yes (Designer) | Component-specific tokens |
1137
-
1138
- **Rule**: Always use semantic tokens in code. Never use primitive paths directly.
1139
- `;
1140
- }
1141
-
1142
- // Backward compatibility aliases
1143
- export const generateMinimalCursorRules = generateMinimalRules;
1144
-