@atomixstudio/mcp 1.0.5 → 1.0.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/README.md +115 -23
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,93 @@
|
|
|
1
1
|
# @atomixstudio/mcp
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for Atomix Design System. Query
|
|
3
|
+
MCP (Model Context Protocol) server and CLI for Atomix Design System. Query and sync design tokens directly from AI coding tools like Cursor, Claude Desktop, Windsurf, and more.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Quick Start (CLI)
|
|
6
|
+
|
|
7
|
+
The easiest way to use Atomix is via the CLI:
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
# Sync tokens + AI rules (default behavior)
|
|
11
|
+
npx heyatomix sync
|
|
12
|
+
|
|
13
|
+
# Sync tokens only (skip AI rules)
|
|
14
|
+
npx heyatomix sync --no-rules
|
|
15
|
+
|
|
16
|
+
# Create config file
|
|
17
|
+
npx heyatomix init
|
|
11
18
|
```
|
|
12
19
|
|
|
13
20
|
## Getting Your Credentials
|
|
14
21
|
|
|
15
22
|
1. Go to [Atomix Studio](https://atomixstudio.eu)
|
|
16
|
-
2. Sign in and access your design system
|
|
17
|
-
3. Click **
|
|
23
|
+
2. Sign in and create/access your design system
|
|
24
|
+
3. Click **Publish** to make your DS available via API
|
|
18
25
|
4. Your `ds-id` is in the URL: `atomixstudio.eu/ds/[ds-id]`
|
|
19
26
|
|
|
20
|
-
##
|
|
27
|
+
## CLI Commands
|
|
28
|
+
|
|
29
|
+
### `heyatomix sync`
|
|
30
|
+
|
|
31
|
+
Sync design tokens and AI rules to your project. **Both tokens and AI guidance rules sync by default** since the rules reference tokens.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx heyatomix sync # Sync tokens + AI rules
|
|
35
|
+
npx heyatomix sync --no-rules # Sync tokens only
|
|
36
|
+
npx heyatomix sync -o src/tokens.css # Custom output path
|
|
37
|
+
npx heyatomix sync --format scss # Output as SCSS
|
|
38
|
+
npx heyatomix sync -y # Auto-confirm changes
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `heyatomix init`
|
|
42
|
+
|
|
43
|
+
Create a `.atomixrc` config file:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx heyatomix init
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This creates:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"dsId": "your-design-system-id",
|
|
54
|
+
"output": "./tokens.css",
|
|
55
|
+
"format": "css"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### CLI Options
|
|
60
|
+
|
|
61
|
+
| Option | Description |
|
|
62
|
+
|--------|-------------|
|
|
63
|
+
| `--ds-id` | Design system ID (or set in .atomixrc) |
|
|
64
|
+
| `--api-key` | API key for private design systems |
|
|
65
|
+
| `--output, -o` | Output file path [./tokens.css] |
|
|
66
|
+
| `--format` | Output format (see below) |
|
|
67
|
+
| `--no-rules` | Skip syncing AI rules (tokens + rules sync by default) |
|
|
68
|
+
| `--rules-dir` | Directory for rules files [project root] |
|
|
69
|
+
| `-y, --yes` | Auto-confirm changes |
|
|
70
|
+
|
|
71
|
+
### Output Formats
|
|
72
|
+
|
|
73
|
+
**Web:**
|
|
74
|
+
- `css` — CSS custom properties (`:root { --var: value }`)
|
|
75
|
+
- `scss` — CSS vars + SCSS variables (`$var: value`)
|
|
76
|
+
- `less` — CSS vars + Less variables (`@var: value`)
|
|
77
|
+
- `json` — Raw token JSON
|
|
78
|
+
- `ts` — TypeScript with types
|
|
79
|
+
- `js` — JavaScript module
|
|
80
|
+
|
|
81
|
+
**Native:**
|
|
82
|
+
- `swift` — Swift/SwiftUI for iOS
|
|
83
|
+
- `kotlin` — Kotlin/Compose for Android
|
|
84
|
+
- `dart` — Dart for Flutter
|
|
85
|
+
|
|
86
|
+
All formats include **light and dark mode** values.
|
|
87
|
+
|
|
88
|
+
## MCP Server Setup
|
|
89
|
+
|
|
90
|
+
For AI tools to query your design system directly:
|
|
21
91
|
|
|
22
92
|
### Cursor IDE
|
|
23
93
|
|
|
@@ -28,7 +98,7 @@ Create `.cursor/mcp.json` in your project root:
|
|
|
28
98
|
"mcpServers": {
|
|
29
99
|
"my-design-system": {
|
|
30
100
|
"command": "npx",
|
|
31
|
-
"args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>"
|
|
101
|
+
"args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>"]
|
|
32
102
|
}
|
|
33
103
|
}
|
|
34
104
|
}
|
|
@@ -43,7 +113,7 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
43
113
|
"mcpServers": {
|
|
44
114
|
"my-design-system": {
|
|
45
115
|
"command": "npx",
|
|
46
|
-
"args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>"
|
|
116
|
+
"args": ["@atomixstudio/mcp@latest", "--ds-id", "<your-ds-id>"]
|
|
47
117
|
}
|
|
48
118
|
}
|
|
49
119
|
}
|
|
@@ -53,9 +123,9 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
|
53
123
|
|
|
54
124
|
Create `.windsurf/mcp.json` in your project root (same format as Cursor).
|
|
55
125
|
|
|
56
|
-
##
|
|
126
|
+
## MCP Tools
|
|
57
127
|
|
|
58
|
-
Once connected, AI tools can use these
|
|
128
|
+
Once connected, AI tools can use these:
|
|
59
129
|
|
|
60
130
|
| Tool | Description |
|
|
61
131
|
|------|-------------|
|
|
@@ -63,13 +133,14 @@ Once connected, AI tools can use these MCP tools:
|
|
|
63
133
|
| `listTokens(category)` | List all tokens in a category |
|
|
64
134
|
| `searchTokens(query)` | Search tokens by name or value |
|
|
65
135
|
| `validateUsage(value)` | Check if a hardcoded value should use a token |
|
|
136
|
+
| `syncTokens(options)` | Sync tokens to a local file |
|
|
66
137
|
| `getAIToolRules(tool)` | Generate AI coding rules for your design system |
|
|
67
138
|
| `exportMCPConfig(tool)` | Get MCP configuration for different tools |
|
|
68
139
|
| `getSetupInstructions(tool)` | Get detailed setup guide |
|
|
69
140
|
|
|
70
141
|
## Token Categories
|
|
71
142
|
|
|
72
|
-
- **colors** — Brand, background, text, icon, border, action, feedback
|
|
143
|
+
- **colors** — Brand, background, text, icon, border, action, feedback (light + dark)
|
|
73
144
|
- **typography** — Font families, sizes, weights, line heights
|
|
74
145
|
- **spacing** — Scale tokens (xs, sm, md, lg, xl, etc.)
|
|
75
146
|
- **sizing** — Component heights, icon sizes
|
|
@@ -79,31 +150,52 @@ Once connected, AI tools can use these MCP tools:
|
|
|
79
150
|
- **motion** — Duration and easing tokens
|
|
80
151
|
- **zIndex** — Layer tokens
|
|
81
152
|
|
|
153
|
+
## AI Rules Files
|
|
154
|
+
|
|
155
|
+
By default, `sync` also updates AI rules files based on which AI tools you use:
|
|
156
|
+
|
|
157
|
+
| File | AI Tool |
|
|
158
|
+
|------|---------|
|
|
159
|
+
| `.cursorrules` | Cursor |
|
|
160
|
+
| `.windsurfrules` | Windsurf |
|
|
161
|
+
| `.clinerules` | Cline |
|
|
162
|
+
| `.continuerules` | Continue |
|
|
163
|
+
| `.github/copilot-instructions.md` | GitHub Copilot |
|
|
164
|
+
| `AI_GUIDELINES.md` | Generic |
|
|
165
|
+
|
|
166
|
+
The rules include your design system's governance guidelines and token usage instructions.
|
|
167
|
+
|
|
82
168
|
## Example Usage
|
|
83
169
|
|
|
84
|
-
|
|
170
|
+
**CLI:**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npx heyatomix sync
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Natural language (via MCP):**
|
|
177
|
+
|
|
178
|
+
> "Sync my design tokens to tokens.css"
|
|
85
179
|
|
|
86
|
-
> "What color tokens are available
|
|
180
|
+
> "What color tokens are available?"
|
|
87
181
|
|
|
88
182
|
> "Use the correct spacing token for 16px padding"
|
|
89
183
|
|
|
90
184
|
> "Validate this: style={{ backgroundColor: '#007061' }}"
|
|
91
185
|
|
|
92
|
-
##
|
|
186
|
+
## Package Aliases
|
|
93
187
|
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
188
|
+
| Package | Description |
|
|
189
|
+
|---------|-------------|
|
|
190
|
+
| `heyatomix` | Recommended CLI (e.g., `npx heyatomix sync`) |
|
|
191
|
+
| `@atomixstudio/mcp` | Full MCP server + CLI |
|
|
192
|
+
| `atomix-sync` | Legacy alias (deprecated) |
|
|
99
193
|
|
|
100
194
|
## Links
|
|
101
195
|
|
|
102
196
|
- [Atomix Studio](https://atomixstudio.eu)
|
|
103
|
-
- [Documentation](https://atomixstudio.eu/docs)
|
|
104
197
|
- [MCP Protocol](https://modelcontextprotocol.io)
|
|
105
198
|
|
|
106
199
|
## License
|
|
107
200
|
|
|
108
201
|
MIT
|
|
109
|
-
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ function parseArgs() {
|
|
|
24
24
|
let format = null;
|
|
25
25
|
let exclude = [];
|
|
26
26
|
let yes = false;
|
|
27
|
-
let rules =
|
|
27
|
+
let rules = null;
|
|
28
28
|
let rulesDir = null;
|
|
29
29
|
if (args[0] && !args[0].startsWith("-")) {
|
|
30
30
|
const cmd = args[0].toLowerCase();
|
|
@@ -57,13 +57,16 @@ function parseArgs() {
|
|
|
57
57
|
yes = true;
|
|
58
58
|
} else if (args[i] === "--rules" || args[i] === "-r") {
|
|
59
59
|
rules = true;
|
|
60
|
+
} else if (args[i] === "--no-rules") {
|
|
61
|
+
rules = false;
|
|
60
62
|
} else if (args[i] === "--rules-dir" && args[i + 1]) {
|
|
61
63
|
rulesDir = args[i + 1];
|
|
62
64
|
rules = true;
|
|
63
65
|
i++;
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
const effectiveRules = rules !== null ? rules : command === "sync";
|
|
69
|
+
return { command, dsId: dsId2, apiKey: apiKey2, apiBase: apiBase2, output, format, exclude, yes, rules: effectiveRules, rulesDir };
|
|
67
70
|
}
|
|
68
71
|
var cliArgs = parseArgs();
|
|
69
72
|
var { dsId, apiKey } = cliArgs;
|
|
@@ -1694,10 +1697,10 @@ async function runSync() {
|
|
|
1694
1697
|
}
|
|
1695
1698
|
fs.writeFileSync(outputPath, newContent);
|
|
1696
1699
|
console.log("");
|
|
1697
|
-
console.log(` \u2713
|
|
1700
|
+
console.log(` \u2713 Tokens synced \u2192 ${effectiveOutput}`);
|
|
1698
1701
|
if (cliArgs.rules) {
|
|
1699
1702
|
console.log("");
|
|
1700
|
-
console.log(" Syncing AI rules
|
|
1703
|
+
console.log(" Syncing AI guidance rules...");
|
|
1701
1704
|
const rulesDir = cliArgs.rulesDir || process.cwd();
|
|
1702
1705
|
const rulesDirResolved = path.resolve(process.cwd(), rulesDir);
|
|
1703
1706
|
const toolsToSync = [
|
|
@@ -1790,13 +1793,13 @@ function showHelp() {
|
|
|
1790
1793
|
less - CSS vars + Less variables (@var: value)
|
|
1791
1794
|
json - Raw token JSON
|
|
1792
1795
|
ts - TypeScript with types
|
|
1793
|
-
--rules, -r Also sync AI rules files (.cursorrules, etc.)
|
|
1794
|
-
--rules-dir Directory for rules files [project root]
|
|
1795
1796
|
js - JavaScript ES module
|
|
1796
1797
|
NATIVE:
|
|
1797
1798
|
swift - SwiftUI (iOS/macOS)
|
|
1798
1799
|
kotlin - Jetpack Compose (Android)
|
|
1799
1800
|
dart - Flutter
|
|
1801
|
+
--no-rules Skip syncing AI rules files (tokens + rules sync by default)
|
|
1802
|
+
--rules-dir Directory for rules files [project root]
|
|
1800
1803
|
--exclude Glob pattern to exclude (can use multiple times)
|
|
1801
1804
|
-y, --yes Auto-confirm changes
|
|
1802
1805
|
|
|
@@ -1806,15 +1809,13 @@ function showHelp() {
|
|
|
1806
1809
|
--api-base API base URL [https://atomixstudio.eu]
|
|
1807
1810
|
|
|
1808
1811
|
EXAMPLES
|
|
1809
|
-
npx
|
|
1810
|
-
npx
|
|
1811
|
-
npx
|
|
1812
|
-
npx
|
|
1813
|
-
npx
|
|
1814
|
-
npx
|
|
1815
|
-
npx
|
|
1816
|
-
npx atomix init
|
|
1817
|
-
npx atomix --ds-id abc123 (start MCP server)
|
|
1812
|
+
npx heyatomix sync # Sync tokens + AI rules (default)
|
|
1813
|
+
npx heyatomix sync --no-rules # Sync tokens only
|
|
1814
|
+
npx heyatomix sync -o ./src/tokens.css
|
|
1815
|
+
npx heyatomix sync --format scss -o ./src/styles/_tokens.scss
|
|
1816
|
+
npx heyatomix sync --format swift -o ./Sources/DesignTokens.swift
|
|
1817
|
+
npx heyatomix init
|
|
1818
|
+
npx heyatomix --ds-id abc123 # Start MCP server
|
|
1818
1819
|
|
|
1819
1820
|
CONFIG FILE (.atomixrc)
|
|
1820
1821
|
{
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Atomix MCP Server - User Design System Mode\n * \n * A minimal MCP server that serves design tokens from a user's\n * Atomix Design System via the public API.\n * \n * Usage:\n * npx @atomixstudio/mcp --ds-id <id> --api-key <key>\n * \n * Tools:\n * - getToken: Get a specific token by path\n * - listTokens: List tokens in a category\n * - searchTokens: Search for tokens by name or value\n * - validateUsage: Check if a value follows the design system\n * - getAIToolRules: Generate AI coding rules for this design system\n * - exportMCPConfig: Generate MCP configuration files\n * - getSetupInstructions: Get setup guide for AI tools\n * \n * @see https://atomixstudio.eu\n */\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n ListResourcesRequestSchema,\n ReadResourceRequestSchema,\n ListPromptsRequestSchema,\n GetPromptRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\n// ============================================\n// TYPES\n// ============================================\n\ninterface ExportedTokens {\n tokens: {\n colors: {\n static: { brand: Record<string, string> };\n modes: { light: Record<string, string>; dark: Record<string, string> };\n };\n typography: Record<string, unknown>;\n spacing: { scale: Record<string, string> };\n sizing: { height: Record<string, string>; icon: Record<string, string> };\n shadows: { elevation: Record<string, string> };\n radius: { scale: Record<string, string> };\n borders: { width: Record<string, string> };\n motion: { duration: Record<string, string>; easing: Record<string, string> };\n zIndex: Record<string, number>;\n };\n cssVariables: Record<string, string>;\n governance: {\n rules: string[];\n categories: Record<string, string[]>;\n };\n meta: {\n name: string;\n version: number;\n exportedAt: string;\n };\n}\n\ninterface DesignSystemData {\n tokens: ExportedTokens[\"tokens\"];\n cssVariables: Record<string, string>;\n governance: ExportedTokens[\"governance\"];\n meta: ExportedTokens[\"meta\"];\n}\n\n// ============================================\n// CLI ARGUMENTS\n// ============================================\n\ninterface CLIArgs {\n command: \"server\" | \"sync\" | \"init\" | \"help\";\n dsId: string | null;\n apiKey: string | null;\n apiBase: string | null;\n output: string | null;\n format: OutputFormat | null;\n exclude: string[];\n yes: boolean; // Auto-confirm\n rules: boolean; // Also sync rules files\n rulesDir: string | null; // Directory for rules files (default: project root)\n}\n\nfunction parseArgs(): CLIArgs {\n const args = process.argv.slice(2);\n let command: CLIArgs[\"command\"] = \"server\";\n let dsId: string | null = null;\n let apiKey: string | null = null;\n let apiBase: string | null = null;\n let output: string | null = null;\n let format: CLIArgs[\"format\"] = null;\n let exclude: string[] = [];\n let yes = false;\n let rules = false;\n let rulesDir: string | null = null;\n\n // Check for subcommand first\n if (args[0] && !args[0].startsWith(\"-\")) {\n const cmd = args[0].toLowerCase();\n if (cmd === \"sync\") command = \"sync\";\n else if (cmd === \"init\") command = \"init\";\n else if (cmd === \"help\" || cmd === \"--help\" || cmd === \"-h\") command = \"help\";\n }\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === \"--ds-id\" && args[i + 1]) {\n dsId = args[i + 1];\n i++;\n } else if (args[i] === \"--api-key\" && args[i + 1]) {\n apiKey = args[i + 1];\n i++;\n } else if (args[i] === \"--api-base\" && args[i + 1]) {\n apiBase = args[i + 1];\n i++;\n } else if ((args[i] === \"--output\" || args[i] === \"-o\") && args[i + 1]) {\n output = args[i + 1];\n i++;\n } else if (args[i] === \"--format\" && args[i + 1]) {\n const f = args[i + 1].toLowerCase() as OutputFormat;\n const validFormats: OutputFormat[] = [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"];\n if (validFormats.includes(f)) format = f;\n i++;\n } else if (args[i] === \"--exclude\" && args[i + 1]) {\n exclude.push(args[i + 1]);\n i++;\n } else if (args[i] === \"-y\" || args[i] === \"--yes\") {\n yes = true;\n } else if (args[i] === \"--rules\" || args[i] === \"-r\") {\n rules = true;\n } else if (args[i] === \"--rules-dir\" && args[i + 1]) {\n rulesDir = args[i + 1];\n rules = true; // Implies --rules\n i++;\n }\n }\n\n return { command, dsId, apiKey, apiBase, output, format, exclude, yes, rules, rulesDir };\n}\n\nconst cliArgs = parseArgs();\nconst { dsId, apiKey } = cliArgs;\n// For MCP server mode, use CLI apiBase or default\nconst apiBase = cliArgs.apiBase || \"https://atomixstudio.eu\";\n\n// ============================================\n// TOKEN FETCHING\n// ============================================\n\nlet cachedData: DesignSystemData | null = null;\n\nasync function fetchDesignSystem(): Promise<DesignSystemData> {\n if (cachedData) return cachedData;\n\n if (!dsId) {\n throw new Error(\"Missing --ds-id argument. Usage: npx @atomixstudio/mcp --ds-id <id> --api-key <key>\");\n }\n\n const url = `${apiBase}/api/ds/${dsId}/tokens?format=export`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n \n if (apiKey) {\n headers[\"x-api-key\"] = apiKey;\n }\n\n const response = await fetch(url, { headers });\n \n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Failed to fetch design system: ${response.status} ${text}`);\n }\n\n const data = await response.json() as DesignSystemData;\n cachedData = data;\n return data;\n}\n\n// ============================================\n// TOKEN UTILITIES\n// ============================================\n\nconst TOKEN_CATEGORIES = [\"colors\", \"typography\", \"spacing\", \"sizing\", \"shadows\", \"radius\", \"borders\", \"motion\", \"zIndex\"] as const;\ntype TokenCategory = typeof TOKEN_CATEGORIES[number];\n\nfunction getTokenByPath(tokens: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = tokens;\n\n for (const part of parts) {\n if (current && typeof current === \"object\" && part in current) {\n current = (current as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n\n return current;\n}\n\nfunction flattenTokens(obj: unknown, prefix = \"\"): Array<{ path: string; value: unknown }> {\n const results: Array<{ path: string; value: unknown }> = [];\n\n if (obj && typeof obj === \"object\" && !Array.isArray(obj)) {\n for (const [key, value] of Object.entries(obj)) {\n const newPath = prefix ? `${prefix}.${key}` : key;\n \n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n results.push(...flattenTokens(value, newPath));\n } else {\n results.push({ path: newPath, value });\n }\n }\n }\n\n return results;\n}\n\nfunction searchTokens(tokens: Record<string, unknown>, query: string): Array<{ path: string; value: unknown }> {\n const flat = flattenTokens(tokens);\n const lowerQuery = query.toLowerCase();\n \n return flat.filter(({ path, value }) => {\n const pathMatch = path.toLowerCase().includes(lowerQuery);\n const valueMatch = String(value).toLowerCase().includes(lowerQuery);\n return pathMatch || valueMatch;\n });\n}\n\n// ============================================\n// TOKEN COUNTING\n// ============================================\n\nfunction countTokens(tokens: Record<string, unknown>, prefix = \"\"): number {\n let count = 0;\n for (const [key, value] of Object.entries(tokens)) {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n count += countTokens(value as Record<string, unknown>, `${prefix}${key}.`);\n } else if (value !== undefined && value !== null) {\n count++;\n }\n }\n return count;\n}\n\nfunction getTokenStats(data: DesignSystemData): {\n total: number;\n byCategory: Record<string, number>;\n cssVariables: number;\n governanceRules: number;\n} {\n const byCategory: Record<string, number> = {};\n let total = 0;\n\n for (const [category, value] of Object.entries(data.tokens)) {\n if (value && typeof value === \"object\") {\n const count = countTokens(value as Record<string, unknown>);\n byCategory[category] = count;\n total += count;\n }\n }\n\n return {\n total,\n byCategory,\n cssVariables: Object.keys(data.cssVariables).length,\n governanceRules: data.governance.rules.length,\n };\n}\n\n// ============================================\n// MCP SERVER SETUP\n// ============================================\n\nconst server = new Server(\n {\n name: \"atomix-mcp-user\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n },\n }\n);\n\n// ============================================\n// TOOL DEFINITIONS\n// ============================================\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"getToken\",\n description: \"Get a specific design token by its path. Returns the value and CSS variable name.\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"Token path in dot notation (e.g., 'colors.brand.primary', 'spacing.scale.md')\",\n },\n },\n required: [\"path\"],\n },\n },\n {\n name: \"listTokens\",\n description: \"List all tokens in a category (colors, typography, spacing, sizing, shadows, radius, borders, motion, zIndex).\",\n inputSchema: {\n type: \"object\",\n properties: {\n category: {\n type: \"string\",\n enum: TOKEN_CATEGORIES,\n description: \"Token category to list\",\n },\n subcategory: {\n type: \"string\",\n description: \"Optional subcategory (e.g., 'brand' for colors, 'scale' for spacing)\",\n },\n },\n required: [\"category\"],\n },\n },\n {\n name: \"searchTokens\",\n description: \"Search for tokens by name or value.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Search query (matches token paths or values)\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"validateUsage\",\n description: \"Check if a CSS value follows the design system. Detects hardcoded values that should use tokens.\",\n inputSchema: {\n type: \"object\",\n properties: {\n value: {\n type: \"string\",\n description: \"CSS value to validate (e.g., '#ff0000', '16px', 'rgb(0,112,97)')\",\n },\n context: {\n type: \"string\",\n enum: [\"color\", \"spacing\", \"radius\", \"shadow\", \"typography\", \"any\"],\n description: \"Context of the value to help find the right token\",\n },\n },\n required: [\"value\"],\n },\n },\n {\n name: \"getAIToolRules\",\n description: \"Generate design system rules for AI coding tools (Cursor, Copilot, Windsurf, etc.).\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\", \"all\"],\n description: \"AI tool to generate rules for. Use 'all' to get rules for all tools.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"exportMCPConfig\",\n description: \"Generate MCP configuration file for AI tools.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"claude-desktop\", \"windsurf\", \"continue\", \"vscode\", \"all\"],\n description: \"AI tool to generate MCP config for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"getSetupInstructions\",\n description: \"Get detailed setup instructions for a specific AI tool.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"claude-desktop\", \"generic\"],\n description: \"AI tool to get setup instructions for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"syncTokens\",\n description: \"Sync design tokens to a local file. Creates or updates a tokens file with the latest values from your design system. Returns a diff of changes.\",\n inputSchema: {\n type: \"object\",\n properties: {\n output: {\n type: \"string\",\n description: \"Output file path relative to project root (e.g., './src/tokens.css', './DesignTokens.swift')\",\n },\n format: {\n type: \"string\",\n enum: [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"],\n description: \"Output format. WEB: css, scss, less, json, ts, js. NATIVE: swift (iOS), kotlin (Android), dart (Flutter). Default: css\",\n },\n },\n required: [\"output\"],\n },\n },\n ],\n };\n});\n\n// ============================================\n// TOOL HANDLERS\n// ============================================\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n const data = await fetchDesignSystem();\n\n switch (name) {\n case \"getToken\": {\n const path = args?.path as string;\n const value = getTokenByPath(data.tokens, path);\n \n if (value === undefined) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Token not found: ${path}`,\n suggestion: \"Use listTokens or searchTokens to find available tokens.\",\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n // Find CSS variable for this path\n const cssVarKey = `--atmx-${path.replace(/\\./g, \"-\")}`;\n const cssVar = data.cssVariables[cssVarKey];\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n path,\n value,\n cssVariable: cssVar || `var(${cssVarKey})`,\n usage: `style={{ property: \"var(${cssVarKey})\" }}`,\n }, null, 2),\n }],\n };\n }\n\n case \"listTokens\": {\n const category = args?.category as TokenCategory;\n const subcategory = args?.subcategory as string | undefined;\n \n let tokensToList: unknown = data.tokens[category];\n \n if (subcategory && tokensToList && typeof tokensToList === \"object\") {\n tokensToList = getTokenByPath(tokensToList as Record<string, unknown>, subcategory);\n }\n\n if (!tokensToList) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Category not found: ${category}${subcategory ? `.${subcategory}` : \"\"}`,\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n const flat = flattenTokens(tokensToList);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n category,\n subcategory,\n count: flat.length,\n tokens: flat.slice(0, 50), // Limit to 50 for readability\n truncated: flat.length > 50,\n }, null, 2),\n }],\n };\n }\n\n case \"searchTokens\": {\n const query = args?.query as string;\n const results = searchTokens(data.tokens, query);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n query,\n count: results.length,\n results: results.slice(0, 30),\n truncated: results.length > 30,\n }, null, 2),\n }],\n };\n }\n\n case \"validateUsage\": {\n const value = args?.value as string;\n const context = (args?.context as string) || \"any\";\n \n // Check if value is a hardcoded color\n const isHexColor = /^#[0-9A-Fa-f]{3,8}$/.test(value);\n const isRgbColor = /^rgb\\(|^rgba\\(|^hsl\\(/.test(value);\n const isPixelValue = /^\\d+px$/.test(value);\n \n if (!isHexColor && !isRgbColor && !isPixelValue) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: true,\n message: \"Value appears to be using tokens or is not a design token value.\",\n }, null, 2),\n }],\n };\n }\n\n // Search for matching tokens\n const matches = searchTokens(data.tokens, value);\n \n if (matches.length > 0) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. Use a token instead.\",\n matchingTokens: matches.slice(0, 5),\n suggestion: `Use var(--atmx-${matches[0].path.replace(/\\./g, \"-\")}) instead of ${value}`,\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. No exact token match found.\",\n suggestion: `Consider adding this value to the design system or use the closest token.`,\n context,\n }, null, 2),\n }],\n };\n }\n\n case \"getAIToolRules\": {\n const tool = args?.tool as string;\n \n // Fetch rules from the API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool === \"all\" ? \"all\" : tool}`;\n console.error(`[getAIToolRules] Fetching: ${rulesUrl}`);\n \n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n \n try {\n const response = await fetch(rulesUrl, { headers });\n console.error(`[getAIToolRules] Response status: ${response.status}`);\n \n if (!response.ok) {\n const errorText = await response.text();\n console.error(`[getAIToolRules] Error response: ${errorText}`);\n throw new Error(`Failed to fetch rules: ${response.status} - ${errorText}`);\n }\n\n const rules = await response.json() as { rules?: string[]; categories?: Record<string, string[]> };\n console.error(`[getAIToolRules] Got ${rules.rules?.length || 0} rules`);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(rules, null, 2),\n }],\n };\n } catch (fetchError) {\n console.error(`[getAIToolRules] Fetch error:`, fetchError);\n throw fetchError;\n }\n }\n\n case \"exportMCPConfig\": {\n const tool = args?.tool as string;\n \n // Generate MCP config locally\n const serverName = data.meta.name.toLowerCase().replace(/[^a-z0-9]/g, \"-\");\n const npxArgs = [\"@atomixstudio/mcp@latest\"];\n if (dsId) npxArgs.push(\"--ds-id\", dsId);\n if (apiKey) npxArgs.push(\"--api-key\", apiKey);\n\n const config = {\n mcpServers: {\n [serverName]: {\n command: \"npx\",\n args: npxArgs,\n },\n },\n };\n\n const configs: Record<string, { path: string; content: string }> = {\n cursor: { path: \".cursor/mcp.json\", content: JSON.stringify(config, null, 2) },\n \"claude-desktop\": { path: \"claude_desktop_config.json\", content: JSON.stringify(config, null, 2) },\n windsurf: { path: \".windsurf/mcp.json\", content: JSON.stringify(config, null, 2) },\n continue: { path: \".continue/config.json\", content: JSON.stringify({ models: [], mcpServers: [{ name: serverName, command: \"npx\", args: npxArgs }] }, null, 2) },\n vscode: { path: \".vscode/settings.json\", content: JSON.stringify({ \"mcp.servers\": config.mcpServers }, null, 2) },\n };\n\n if (tool === \"all\") {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n message: \"MCP configurations for all tools\",\n configs: Object.entries(configs).map(([t, c]) => ({\n tool: t,\n path: c.path,\n content: JSON.parse(c.content),\n })),\n }, null, 2),\n }],\n };\n }\n\n const selectedConfig = configs[tool as keyof typeof configs];\n if (!selectedConfig) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(configs),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n tool,\n path: selectedConfig.path,\n content: JSON.parse(selectedConfig.content),\n instructions: `Create the file at ${selectedConfig.path} with the content above, then restart your IDE.`,\n }, null, 2),\n }],\n };\n }\n\n case \"getSetupInstructions\": {\n const tool = args?.tool as string;\n \n const instructions: Record<string, string> = {\n cursor: `# Cursor MCP Setup\n\n1. Create \\`.cursor/mcp.json\\` in your project root\n2. Add the MCP configuration (use exportMCPConfig to get it)\n3. Restart Cursor IDE\n4. Verify by asking: \"What design tokens are available?\"`,\n\n copilot: `# GitHub Copilot Setup\n\n1. Create \\`.github/copilot-instructions.md\\` in your project\n2. Use getAIToolRules({ tool: \"copilot\" }) to get the content\n3. Enable custom instructions in VS Code settings:\n \"github.copilot.chat.codeGeneration.useInstructionFiles\": true`,\n\n windsurf: `# Windsurf Setup\n\n1. Create \\`.windsurf/mcp.json\\` in your project root\n2. Create \\`.windsurfrules\\` with rules from getAIToolRules\n3. Restart Windsurf Editor`,\n\n cline: `# Cline Setup\n\n1. Create \\`.clinerules\\` in your project root\n2. Cline auto-detects MCP from .cursor/mcp.json`,\n\n continue: `# Continue Setup\n\n1. Create/edit \\`.continue/config.json\\`\n2. Add mcpServers configuration\n3. Restart VS Code`,\n\n zed: `# Zed Setup\n\n1. Create \\`.zed/assistant/rules.md\\` in your project\n2. Use getAIToolRules({ tool: \"zed\" }) for content`,\n\n \"claude-desktop\": `# Claude Desktop Setup\n\n1. Find your Claude config:\n - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\n - Windows: %APPDATA%\\\\Claude\\\\claude_desktop_config.json\n2. Add MCP server configuration\n3. Restart Claude Desktop`,\n\n generic: `# Generic AI Tool Setup\n\n1. Create AI_GUIDELINES.md in your project root\n2. Use getAIToolRules({ tool: \"generic\" }) for content\n3. Reference in your prompts or context`,\n };\n\n const instruction = instructions[tool];\n if (!instruction) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(instructions),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: instruction,\n }],\n };\n }\n\n case \"syncTokens\": {\n const output = args?.output as string;\n const format = (args?.format as OutputFormat) || \"css\";\n \n if (!output) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({ error: \"Missing required parameter: output\" }, null, 2),\n }],\n };\n }\n\n // Generate content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (format) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), output);\n const fileExists = fs.existsSync(outputPath);\n const tokenCount = Object.keys(data.cssVariables).length;\n\n let diffSummary = \"\";\n let changes: Array<{ key: string; old: string; new: string }> = [];\n\n if (fileExists && [\"css\", \"scss\", \"less\"].includes(format)) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, format as OutputFormat, darkModeColors?.dark);\n \n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n \n if (totalChanges === 0) {\n return {\n content: [{\n type: \"text\",\n text: `✓ Already up to date!\\n\\nFile: ${output}\\nTokens: ${tokenCount}\\nVersion: ${data.meta.version}`,\n }],\n };\n }\n\n changes = [...diff.modified, ...diff.modifiedDark];\n \n // Build summary\n const lightSummary = lightChanges > 0 ? `Light: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed` : \"\";\n const darkSummary = darkChanges > 0 ? `Dark: ${diff.modifiedDark.length} modified, ${diff.addedDark.length} added, ${diff.removedDark.length} removed` : \"\";\n diffSummary = [lightSummary, darkSummary].filter(Boolean).join(\" | \");\n }\n\n // Write the file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n // Build response\n let response = `✓ Synced ${tokenCount} tokens to ${output}\\n`;\n response += `Format: ${format}\\n`;\n response += `Design System: ${data.meta.name} (v${data.meta.version})\\n`;\n \n if (diffSummary) {\n response += `\\n${diffSummary}\\n`;\n if (changes.length > 0 && changes.length <= 10) {\n response += \"\\nModified tokens:\\n\";\n for (const { key, old: oldVal, new: newVal } of changes) {\n response += ` ${key}: ${oldVal} → ${newVal}\\n`;\n }\n }\n } else if (!fileExists) {\n response += \"\\n(New file created)\";\n }\n\n return {\n content: [{\n type: \"text\",\n text: response,\n }],\n };\n }\n\n default:\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${name}`,\n availableTools: [\"getToken\", \"listTokens\", \"searchTokens\", \"validateUsage\", \"getAIToolRules\", \"exportMCPConfig\", \"getSetupInstructions\", \"syncTokens\"],\n }, null, 2),\n }],\n };\n }\n } catch (error) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: error instanceof Error ? error.message : \"Unknown error\",\n suggestion: \"Make sure --ds-id and --api-key are correct.\",\n }, null, 2),\n }],\n isError: true,\n };\n }\n});\n\n// ============================================\n// RESOURCE HANDLERS\n// ============================================\n\nconst AI_TOOLS = [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\"] as const;\n\nserver.setRequestHandler(ListResourcesRequestSchema, async () => {\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n \n const resources = [\n {\n uri: \"atomix://welcome\",\n name: `Welcome to ${data.meta.name}`,\n description: `Design system overview with ${stats.total} tokens and ${stats.governanceRules} governance rules`,\n mimeType: \"text/markdown\",\n },\n ...AI_TOOLS.map(tool => ({\n uri: `atomix://rules/${tool}`,\n name: `${tool.charAt(0).toUpperCase() + tool.slice(1)} Rules`,\n description: `Design system rules file for ${tool}`,\n mimeType: \"text/markdown\",\n })),\n ];\n\n return { resources };\n});\n\nserver.setRequestHandler(ReadResourceRequestSchema, async (request) => {\n const { uri } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n // Welcome resource\n if (uri === \"atomix://welcome\") {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: welcome,\n }],\n };\n }\n\n // Rules resources\n const rulesMatch = uri.match(/^atomix:\\/\\/rules\\/(.+)$/);\n if (rulesMatch) {\n const tool = rulesMatch[1];\n if (!AI_TOOLS.includes(tool as typeof AI_TOOLS[number])) {\n throw new Error(`Unknown tool: ${tool}. Available: ${AI_TOOLS.join(\", \")}`);\n }\n\n // Fetch rules from API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string; tool?: string };\n \n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n }],\n };\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n});\n\n// ============================================\n// PROMPTS - Auto-suggest welcome on connection\n// ============================================\n\nserver.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: \"welcome\",\n description: \"Get started with this design system - shows overview, available tokens, and tools. Run this first!\",\n },\n {\n name: \"design-system-rules\",\n description: \"Get the design system governance rules for your AI coding tool\",\n arguments: [\n {\n name: \"tool\",\n description: \"AI tool to generate rules for (cursor, copilot, windsurf, cline, continue, zed, generic)\",\n required: false,\n },\n ],\n },\n ],\n };\n});\n\nserver.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n switch (name) {\n case \"welcome\": {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n description: `Welcome to ${data.meta.name} Design System`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: \"Show me the design system overview and available tools.\",\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: welcome,\n },\n },\n ],\n };\n }\n\n case \"design-system-rules\": {\n const tool = (args?.tool as string) || \"cursor\";\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string };\n \n return {\n description: `Design system rules for ${tool}`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: `Show me the design system rules for ${tool}.`,\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n});\n\nfunction generateWelcomeMessage(data: DesignSystemData, stats: ReturnType<typeof getTokenStats>): string {\n const toolsList = [\n \"getToken - Get a specific token by path\",\n \"listTokens - List all tokens in a category\",\n \"searchTokens - Search tokens by name or value\",\n \"validateUsage - Check if a CSS value follows the design system\",\n \"getAIToolRules - Generate AI coding rules for any tool\",\n \"exportMCPConfig - Generate MCP config for AI tools\",\n \"getSetupInstructions - Get setup guide for specific tools\",\n \"syncTokens - Sync tokens to a local file (css, scss, swift, kotlin, dart, etc.)\",\n ];\n\n const categoryBreakdown = Object.entries(stats.byCategory)\n .map(([cat, count]) => ` - ${cat}: ${count} tokens`)\n .join(\"\\n\");\n\n const asciiArt = `\n\\`\\`\\`\n ↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘ \n\\`\\`\\`\n`;\n\n return `${asciiArt}\n# Welcome to ${data.meta.name}\n\nYour design system is connected and ready to use.\n\n## Design System Overview\n\n| Metric | Value |\n|--------|-------|\n| Name | ${data.meta.name} |\n| DS ID | ${dsId} |\n| Total Tokens | ${stats.total} |\n| CSS Variables | ${stats.cssVariables} |\n| Governance Rules | ${stats.governanceRules} |\n| Version | ${data.meta.version || 1} |\n\n### Token Breakdown\n\n${categoryBreakdown}\n\n## Available Tools\n\n${toolsList.map((t, i) => `${i + 1}. **${t.split(\" - \")[0]}** - ${t.split(\" - \")[1]}`).join(\"\\n\")}\n\n## Quick Start\n\n### Get a Token\n\\`\\`\\`\nUse getToken with path \"colors.static.brand.primary\"\n\\`\\`\\`\n\n### List All Spacing Tokens\n\\`\\`\\`\nUse listTokens with category \"spacing\"\n\\`\\`\\`\n\n### Validate a Hardcoded Value\n\\`\\`\\`\nUse validateUsage with value \"#ff0000\" and context \"color\"\n\\`\\`\\`\n\n## Resources Available\n\nThis MCP server exposes rules files as resources that your AI tool can read:\n\n| Resource | Description |\n|----------|-------------|\n| \\`atomix://welcome\\` | This welcome message |\n| \\`atomix://rules/cursor\\` | .cursorrules file content |\n| \\`atomix://rules/copilot\\` | GitHub Copilot instructions |\n| \\`atomix://rules/windsurf\\` | .windsurfrules file content |\n| \\`atomix://rules/cline\\` | .clinerules file content |\n| \\`atomix://rules/continue\\` | Continue rules |\n| \\`atomix://rules/zed\\` | Zed assistant rules |\n| \\`atomix://rules/generic\\` | Generic AI guidelines |\n\n## Checking for Updates\n\nYour design system may be updated over time. To ensure you have the latest tokens:\n\n1. **Check version**: The current version is ${data.meta.version || 1}\n2. **Refresh tokens**: Restart the MCP server to fetch latest tokens\n3. **View changes**: Visit https://atomixstudio.eu/ds/${dsId} to see recent changes\n\n---\n\n*Powered by Atomix Studio - https://atomixstudio.eu*\n`;\n}\n\n// ============================================\n// SYNC COMMAND\n// ============================================\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as readline from \"readline\";\n\ntype OutputFormat = \n | \"css\" | \"scss\" | \"less\" // Web CSS-based\n | \"json\" | \"ts\" | \"js\" // Web JS-based\n | \"swift\" | \"kotlin\" | \"dart\"; // Native mobile\n\ninterface AtomixConfig {\n dsId: string;\n apiKey?: string;\n apiBase?: string;\n output: string;\n format: OutputFormat;\n // For future codebase scanning\n include?: string[]; // Glob patterns to include\n exclude?: string[]; // Glob patterns to exclude\n}\n\n// Default file patterns for codebase scanning\nconst DEFAULT_INCLUDE = [\n \"**/*.tsx\", // React TypeScript components\n \"**/*.jsx\", // React JavaScript components\n \"**/*.ts\", // TypeScript files\n \"**/*.js\", // JavaScript files\n \"**/*.css\", // CSS stylesheets\n \"**/*.scss\", // SASS files\n \"**/*.less\", // Less files\n \"**/*.vue\", // Vue components\n \"**/*.svelte\", // Svelte components\n \"**/*.astro\", // Astro components\n];\n\nconst DEFAULT_EXCLUDE = [\n \"node_modules/**\",\n \"dist/**\",\n \"build/**\",\n \".next/**\",\n \".nuxt/**\",\n \".git/**\",\n \"coverage/**\",\n \"**/*.min.js\",\n \"**/*.min.css\",\n \"**/*.d.ts\", // Type definitions\n \"**/*.test.*\", // Test files\n \"**/*.spec.*\", // Spec files\n];\n\nfunction findConfig(): AtomixConfig | null {\n const configNames = [\".atomixrc\", \".atomixrc.json\", \"atomix.config.json\"];\n const cwd = process.cwd();\n \n for (const name of configNames) {\n const configPath = path.join(cwd, name);\n if (fs.existsSync(configPath)) {\n try {\n const content = fs.readFileSync(configPath, \"utf-8\");\n return JSON.parse(content);\n } catch {\n console.error(`Error parsing ${name}`);\n }\n }\n }\n return null;\n}\n\nfunction generateCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"/* Atomix Design System Tokens\",\n \" * Auto-generated - do not edit manually\",\n ` * Synced: ${new Date().toISOString()}`,\n \" */\",\n \"\",\n \"/* Light mode (default) */\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode overrides if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"/* Dark mode */\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n // Detect prefix from cssVariables keys\n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n // Dark mode colors are stored with keys like \"bg-page\", \"text-primary\"\n // Convert to CSS variable names: --atmx-color-bg-page\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateJSONOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return JSON.stringify(tokens, null, 2);\n}\n\nfunction generateTSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)} as const;\n\nexport type Tokens = typeof tokens;\n`;\n}\n\nfunction generateJSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)};\n`;\n}\n\nfunction generateSCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// SCSS Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const scssVar = \"$\" + key.replace(/^--/, \"\");\n lines.push(`${scssVar}: ${value};`);\n }\n \n // Add dark mode SCSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// SCSS Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const scssVar = `$${prefix}-color-${key}-dark`;\n lines.push(`${scssVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateLessOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// Less Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const lessVar = \"@\" + key.replace(/^--/, \"\");\n lines.push(`${lessVar}: ${value};`);\n }\n \n // Add dark mode Less variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Less Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const lessVar = `@${prefix}-color-${key}-dark`;\n lines.push(`${lessVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\n// ============================================\n// NATIVE MOBILE OUTPUT GENERATORS\n// ============================================\n\nfunction toSwiftName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary\n return cssVar\n .replace(/^--atmx-/, \"\")\n .replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n}\n\nfunction toKotlinName(cssVar: string): string {\n // --atmx-color-brand-primary → ColorBrandPrimary\n const camel = toSwiftName(cssVar);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n}\n\nfunction toDartName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary (same as Swift)\n return toSwiftName(cssVar);\n}\n\nfunction isColorValue(value: string): boolean {\n return /^#[0-9A-Fa-f]{3,8}$/.test(value) || \n /^rgb/.test(value) || \n /^hsl/.test(value);\n}\n\nfunction hexToSwiftColor(hex: string): string {\n // #RRGGBB or #RRGGBBAA\n const clean = hex.replace(\"#\", \"\");\n if (clean.length === 3) {\n // #RGB -> #RRGGBB\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(hex: 0x${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(hex: 0x${clean})`;\n }\n if (clean.length === 8) {\n // #RRGGBBAA\n const rgb = clean.substring(0, 6);\n const alpha = parseInt(clean.substring(6, 8), 16) / 255;\n return `Color(hex: 0x${rgb}).opacity(${alpha.toFixed(2)})`;\n }\n return `Color.clear // Could not parse: ${hex}`;\n}\n\nfunction hexToKotlinColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n // RRGGBBAA -> AARRGGBB for Android\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Color.Transparent // Could not parse: ${hex}`;\n}\n\nfunction hexToDartColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Colors.transparent // Could not parse: ${hex}`;\n}\n\nfunction generateSwiftOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import SwiftUI\",\n \"\",\n \"// MARK: - Color Extension for Hex\",\n \"extension Color {\",\n \" init(hex: UInt, alpha: Double = 1.0) {\",\n \" self.init(\",\n \" .sRGB,\",\n \" red: Double((hex >> 16) & 0xFF) / 255.0,\",\n \" green: Double((hex >> 8) & 0xFF) / 255.0,\",\n \" blue: Double(hex & 0xFF) / 255.0,\",\n \" opacity: alpha\",\n \" )\",\n \" }\",\n \"}\",\n \"\",\n \"// MARK: - Design Tokens\",\n \"enum DesignTokens {\",\n \"\",\n \" // MARK: Colors (Light Mode)\",\n \" enum Colors {\"\n ];\n\n // Group by category\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // MARK: Colors (Dark Mode)\");\n lines.push(\" enum ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" // MARK: Spacing\");\n lines.push(\" enum Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toSwiftName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Typography\");\n lines.push(\" enum Typography {\");\n\n for (const [key, value] of typography) {\n const name = toSwiftName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n } else if (key.includes(\"weight\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n } else if (key.includes(\"family\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Other\");\n lines.push(\" enum Other {\");\n\n for (const [key, value] of other) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n } else {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateKotlinOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"package com.atomix.design\",\n \"\",\n \"import androidx.compose.ui.graphics.Color\",\n \"import androidx.compose.ui.unit.dp\",\n \"import androidx.compose.ui.unit.sp\",\n \"\",\n \"object DesignTokens {\",\n \"\",\n \" // Light mode colors\",\n \" object Colors {\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Dark mode colors\");\n lines.push(\" object ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `Color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" object Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toKotlinName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Typography {\");\n\n for (const [key, value] of typography) {\n const name = toKotlinName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.sp`);\n }\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Other {\");\n\n for (const [key, value] of other) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateDartOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import 'package:flutter/material.dart';\",\n \"\",\n \"class DesignTokens {\",\n \" DesignTokens._();\",\n \"\",\n \" // Colors (Light Mode)\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n\n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Colors (Dark Mode)\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}Dark`;\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Spacing\");\n\n for (const [key, value] of spacing) {\n const name = toDartName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Typography\");\n\n for (const [key, value] of typography) {\n const name = toDartName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Other\");\n\n for (const [key, value] of other) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n }\n\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction diffTokens(\n oldContent: string,\n newCssVars: Record<string, string>,\n format: OutputFormat,\n newDarkVars?: Record<string, string>\n): { \n added: string[]; \n modified: Array<{ key: string; old: string; new: string }>; \n removed: string[];\n addedDark: string[];\n modifiedDark: Array<{ key: string; old: string; new: string }>;\n removedDark: string[];\n} {\n const added: string[] = [];\n const modified: Array<{ key: string; old: string; new: string }> = [];\n const removed: string[] = [];\n const addedDark: string[] = [];\n const modifiedDark: Array<{ key: string; old: string; new: string }> = [];\n const removedDark: string[] = [];\n\n // CSS-based formats (css, scss, less) all use CSS variables\n if (format === \"css\" || format === \"scss\" || format === \"less\") {\n // Split old content into light mode (:root) and dark mode (.dark) sections\n // Find the :root section\n const rootMatch = oldContent.match(/:root\\s*\\{([^}]*)\\}/);\n const darkMatch = oldContent.match(/\\.dark[^{]*\\{([^}]*)\\}/);\n \n // Parse light mode variables from :root\n const oldLightVars: Record<string, string> = {};\n if (rootMatch) {\n const rootContent = rootMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(rootContent)) !== null) {\n oldLightVars[match[1]] = match[2].trim();\n }\n } else {\n // Fallback: parse everything (old behavior for files without sections)\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(oldContent)) !== null) {\n // Only take the first occurrence to get light mode values\n if (!(match[1] in oldLightVars)) {\n oldLightVars[match[1]] = match[2].trim();\n }\n }\n }\n\n // Parse dark mode variables from .dark\n const oldDarkVars: Record<string, string> = {};\n if (darkMatch) {\n const darkContent = darkMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(darkContent)) !== null) {\n oldDarkVars[match[1]] = match[2].trim();\n }\n }\n\n // Compare light mode\n for (const [key, value] of Object.entries(newCssVars)) {\n if (!(key in oldLightVars)) {\n added.push(key);\n } else if (oldLightVars[key] !== value) {\n modified.push({ key, old: oldLightVars[key], new: value });\n }\n }\n\n for (const key of Object.keys(oldLightVars)) {\n if (!(key in newCssVars)) {\n removed.push(key);\n }\n }\n\n // Compare dark mode if new dark vars provided\n if (newDarkVars && Object.keys(newDarkVars).length > 0) {\n // Generate the expected CSS variable names for dark mode\n // newDarkVars keys are like \"bg-page\", need to match \"--atmx-color-bg-page\"\n const firstKey = Object.keys(newCssVars)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n\n for (const [key, value] of Object.entries(newDarkVars)) {\n const cssVarName = `${prefix}color-${key}`;\n if (!(cssVarName in oldDarkVars)) {\n addedDark.push(cssVarName);\n } else if (oldDarkVars[cssVarName] !== value) {\n modifiedDark.push({ key: cssVarName, old: oldDarkVars[cssVarName], new: value });\n }\n }\n\n for (const key of Object.keys(oldDarkVars)) {\n // Extract the short key from --atmx-color-bg-page -> bg-page\n const shortKey = key.replace(new RegExp(`^${prefix}color-`), \"\");\n if (!(shortKey in newDarkVars)) {\n removedDark.push(key);\n }\n }\n }\n }\n\n return { added, modified, removed, addedDark, modifiedDark, removedDark };\n}\n\nasync function promptConfirm(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} [Y/n] `, (answer) => {\n rl.close();\n const normalized = answer.toLowerCase().trim();\n resolve(normalized === \"\" || normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\nasync function runSync() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Token Sync\");\n console.log(\"\");\n\n // Load config\n const config = findConfig();\n const effectiveDsId = cliArgs.dsId || config?.dsId;\n const effectiveApiKey = cliArgs.apiKey || config?.apiKey;\n const effectiveApiBase = cliArgs.apiBase || config?.apiBase || \"https://atomixstudio.eu\";\n const effectiveOutput = cliArgs.output || config?.output || \"./tokens.css\";\n const effectiveFormat = cliArgs.format || config?.format || \"css\";\n\n if (!effectiveDsId) {\n console.error(\" Error: Missing design system ID\");\n console.error(\"\");\n console.error(\" Either:\");\n console.error(\" 1. Run: npx atomix sync --ds-id <your-ds-id>\");\n console.error(\" 2. Create .atomixrc with { \\\"dsId\\\": \\\"<your-ds-id>\\\" }\");\n console.error(\" 3. Run: npx atomix init\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(` Fetching tokens from ${effectiveApiBase}...`);\n\n // Fetch latest tokens\n const url = `${effectiveApiBase}/api/ds/${effectiveDsId}/tokens?format=export`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n\n let data: ExportedTokens;\n try {\n const response = await fetch(url, { headers });\n if (!response.ok) {\n const errorText = await response.text();\n console.error(` Error: Failed to fetch tokens (${response.status})`);\n console.error(` ${errorText}`);\n process.exit(1);\n }\n data = await response.json() as ExportedTokens;\n } catch (error) {\n console.error(` Error: Could not connect to ${effectiveApiBase}`);\n console.error(` ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n\n console.log(` Design System: ${data.meta.name} (v${data.meta.version})`);\n console.log(\"\");\n\n // Generate new content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (effectiveFormat) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), effectiveOutput);\n const fileExists = fs.existsSync(outputPath);\n\n // CSS-based formats support diffing\n const supportsDiff = [\"css\", \"scss\", \"less\"].includes(effectiveFormat);\n if (fileExists && supportsDiff) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat, darkModeColors?.dark);\n\n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n\n if (totalChanges === 0) {\n console.log(\" ✓ Already up to date!\");\n console.log(\"\");\n process.exit(0);\n }\n\n console.log(` Changes detected in ${path.basename(effectiveOutput)}:`);\n console.log(\"\");\n\n // Show light mode changes\n if (lightChanges > 0) {\n console.log(\" Light Mode:\");\n if (diff.modified.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modified) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.added.length > 0) {\n console.log(` + ${diff.added.length} new token(s)`);\n }\n if (diff.removed.length > 0) {\n console.log(` - ${diff.removed.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n // Show dark mode changes\n if (darkChanges > 0) {\n console.log(\" Dark Mode:\");\n if (diff.modifiedDark.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modifiedDark) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.addedDark.length > 0) {\n console.log(` + ${diff.addedDark.length} new token(s)`);\n }\n if (diff.removedDark.length > 0) {\n console.log(` - ${diff.removedDark.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n console.log(` Total: ${totalChanges} change(s) (Light: ${lightChanges}, Dark: ${darkChanges})`);\n console.log(\"\");\n\n // Confirm\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Apply changes?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n } else if (!fileExists) {\n console.log(` Creating ${effectiveOutput}...`);\n console.log(` ${Object.keys(data.cssVariables).length} tokens`);\n console.log(\"\");\n\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Create file?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n }\n\n // Write file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n console.log(\"\");\n console.log(` ✓ Updated ${effectiveOutput}`);\n\n // Sync rules files if --rules flag is set\n if (cliArgs.rules) {\n console.log(\"\");\n console.log(\" Syncing AI rules files...\");\n \n const rulesDir = cliArgs.rulesDir || process.cwd();\n const rulesDirResolved = path.resolve(process.cwd(), rulesDir);\n \n // Detect which AI tools are likely in use based on existing files\n const toolsToSync: Array<{ tool: string; filename: string; dir?: string }> = [\n { tool: \"cursor\", filename: \".cursorrules\" },\n { tool: \"windsurf\", filename: \".windsurfrules\" },\n { tool: \"cline\", filename: \".clinerules\" },\n { tool: \"continue\", filename: \".continuerules\" },\n { tool: \"copilot\", filename: \"copilot-instructions.md\", dir: \".github\" },\n { tool: \"generic\", filename: \"AI_GUIDELINES.md\" },\n ];\n \n // Check which tools have existing files or should be created\n const existingTools = toolsToSync.filter(t => {\n const filePath = t.dir \n ? path.join(rulesDirResolved, t.dir, t.filename)\n : path.join(rulesDirResolved, t.filename);\n return fs.existsSync(filePath);\n });\n \n // If no existing rules files, create .cursorrules by default\n const toolsToWrite = existingTools.length > 0 \n ? existingTools \n : [{ tool: \"cursor\", filename: \".cursorrules\" }];\n \n for (const { tool, filename, dir } of toolsToWrite) {\n try {\n // Fetch rules from API\n const rulesUrl = `${effectiveApiBase}/api/ds/${effectiveDsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n \n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n console.error(` ✗ Failed to fetch ${tool} rules: ${response.status}`);\n continue;\n }\n \n const rulesData = await response.json() as { content?: string };\n if (!rulesData.content) {\n console.error(` ✗ No content for ${tool} rules`);\n continue;\n }\n \n // Write the file\n const targetDir = dir ? path.join(rulesDirResolved, dir) : rulesDirResolved;\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n \n const filePath = path.join(targetDir, filename);\n fs.writeFileSync(filePath, rulesData.content);\n \n const relativePath = dir ? `${dir}/${filename}` : filename;\n console.log(` ✓ ${relativePath}`);\n } catch (error) {\n console.error(` ✗ Error syncing ${tool} rules:`, error instanceof Error ? error.message : String(error));\n }\n }\n }\n\n console.log(\"\");\n}\n\nasync function runInit() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Config Setup\");\n console.log(\"\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const question = (prompt: string): Promise<string> =>\n new Promise((resolve) => rl.question(prompt, resolve));\n\n const dsId = cliArgs.dsId || await question(\" Design System ID: \");\n const output = await question(\" Output file [./tokens.css]: \") || \"./tokens.css\";\n const format = await question(\" Format (css/json/ts) [css]: \") || \"css\";\n\n rl.close();\n\n const config: AtomixConfig = {\n dsId,\n output,\n format: format as \"css\" | \"json\" | \"ts\",\n };\n\n const configPath = path.join(process.cwd(), \".atomixrc\");\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n\n console.log(\"\");\n console.log(` ✓ Created .atomixrc`);\n console.log(\"\");\n console.log(\" Now run: npx atomix sync\");\n console.log(\"\");\n}\n\nfunction showHelp() {\n console.log(`\n ↘↘↘ Atomix CLI\n\n COMMANDS\n sync Sync design tokens to your project\n init Create .atomixrc config file\n help Show this help message\n (none) Start MCP server for AI tools\n\n SYNC OPTIONS\n --ds-id Design system ID (or set in .atomixrc)\n --api-key API key for private design systems\n --output, -o Output file path [./tokens.css]\n --format Output format [css]\n WEB:\n css - CSS custom properties (:root { --var: value })\n scss - CSS vars + SCSS variables ($var: value)\n less - CSS vars + Less variables (@var: value)\n json - Raw token JSON\n ts - TypeScript with types\n --rules, -r Also sync AI rules files (.cursorrules, etc.)\n --rules-dir Directory for rules files [project root]\n js - JavaScript ES module\n NATIVE:\n swift - SwiftUI (iOS/macOS)\n kotlin - Jetpack Compose (Android)\n dart - Flutter\n --exclude Glob pattern to exclude (can use multiple times)\n -y, --yes Auto-confirm changes\n\n MCP SERVER OPTIONS\n --ds-id Design system ID (required)\n --api-key API key for private design systems\n --api-base API base URL [https://atomixstudio.eu]\n\n EXAMPLES\n npx atomix sync\n npx atomix sync --ds-id abc123 -o ./src/tokens.css\n npx atomix sync --format scss -o ./src/styles/_tokens.scss\n npx atomix sync --format ts -o ./src/design-tokens.ts\n npx atomix sync --format swift -o ./Sources/DesignTokens.swift\n npx atomix sync --format kotlin -o ./app/src/.../DesignTokens.kt\n npx atomix sync --format dart -o ./lib/design_tokens.dart\n npx atomix init\n npx atomix --ds-id abc123 (start MCP server)\n\n CONFIG FILE (.atomixrc)\n {\n \"dsId\": \"your-design-system-id\",\n \"output\": \"./src/styles/tokens.css\",\n \"format\": \"css\",\n \"exclude\": [\"legacy/**\", \"vendor/**\"]\n }\n\n DEFAULT SCANNED FILES\n *.tsx, *.jsx, *.ts, *.js, *.css, *.scss, *.less, *.vue, *.svelte\n\n DEFAULT EXCLUDED\n node_modules/**, dist/**, build/**, .next/**, *.min.*, *.d.ts\n`);\n}\n\n// ============================================\n// START SERVER\n// ============================================\n\nasync function startServer() {\n if (!dsId) {\n console.error(\"Error: Missing --ds-id argument\");\n console.error(\"Usage: npx atomix --ds-id <id> --api-key <key>\");\n console.error(\"\");\n console.error(\"For sync command: npx atomix sync --help\");\n console.error(\"Get your DS ID from https://atomixstudio.eu/ds/[your-ds-id]\");\n process.exit(1);\n }\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n \n // Log to stderr so it doesn't interfere with MCP protocol on stdout\n console.error(`Atomix MCP Server started for design system: ${dsId}`);\n}\n\nasync function main() {\n switch (cliArgs.command) {\n case \"sync\":\n await runSync();\n break;\n case \"init\":\n await runInit();\n break;\n case \"help\":\n showHelp();\n break;\n case \"server\":\n default:\n await startServer();\n break;\n }\n}\n\nmain().catch((error) => {\n console.error(\"Failed:\", error);\n process.exit(1);\n});\n\n"],"mappings":";;;AAqBA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkpCP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AA3lC1B,SAAS,YAAqB;AAC5B,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAI,UAA8B;AAClC,MAAIA,QAAsB;AAC1B,MAAIC,UAAwB;AAC5B,MAAIC,WAAyB;AAC7B,MAAI,SAAwB;AAC5B,MAAI,SAA4B;AAChC,MAAI,UAAoB,CAAC;AACzB,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,MAAI,WAA0B;AAG9B,MAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC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AAAA,EACJ;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,WAAW,KAAK;AAC9B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["dsId","apiKey","apiBase","path","resolve","headers","dsId"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Atomix MCP Server - User Design System Mode\n * \n * A minimal MCP server that serves design tokens from a user's\n * Atomix Design System via the public API.\n * \n * Usage:\n * npx @atomixstudio/mcp --ds-id <id> --api-key <key>\n * \n * Tools:\n * - getToken: Get a specific token by path\n * - listTokens: List tokens in a category\n * - searchTokens: Search for tokens by name or value\n * - validateUsage: Check if a value follows the design system\n * - getAIToolRules: Generate AI coding rules for this design system\n * - exportMCPConfig: Generate MCP configuration files\n * - getSetupInstructions: Get setup guide for AI tools\n * \n * @see https://atomixstudio.eu\n */\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n ListResourcesRequestSchema,\n ReadResourceRequestSchema,\n ListPromptsRequestSchema,\n GetPromptRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\n\n// ============================================\n// TYPES\n// ============================================\n\ninterface ExportedTokens {\n tokens: {\n colors: {\n static: { brand: Record<string, string> };\n modes: { light: Record<string, string>; dark: Record<string, string> };\n };\n typography: Record<string, unknown>;\n spacing: { scale: Record<string, string> };\n sizing: { height: Record<string, string>; icon: Record<string, string> };\n shadows: { elevation: Record<string, string> };\n radius: { scale: Record<string, string> };\n borders: { width: Record<string, string> };\n motion: { duration: Record<string, string>; easing: Record<string, string> };\n zIndex: Record<string, number>;\n };\n cssVariables: Record<string, string>;\n governance: {\n rules: string[];\n categories: Record<string, string[]>;\n };\n meta: {\n name: string;\n version: number;\n exportedAt: string;\n };\n}\n\ninterface DesignSystemData {\n tokens: ExportedTokens[\"tokens\"];\n cssVariables: Record<string, string>;\n governance: ExportedTokens[\"governance\"];\n meta: ExportedTokens[\"meta\"];\n}\n\n// ============================================\n// CLI ARGUMENTS\n// ============================================\n\ninterface CLIArgs {\n command: \"server\" | \"sync\" | \"init\" | \"help\";\n dsId: string | null;\n apiKey: string | null;\n apiBase: string | null;\n output: string | null;\n format: OutputFormat | null;\n exclude: string[];\n yes: boolean; // Auto-confirm\n rules: boolean; // Also sync rules files\n rulesDir: string | null; // Directory for rules files (default: project root)\n}\n\nfunction parseArgs(): CLIArgs {\n const args = process.argv.slice(2);\n let command: CLIArgs[\"command\"] = \"server\";\n let dsId: string | null = null;\n let apiKey: string | null = null;\n let apiBase: string | null = null;\n let output: string | null = null;\n let format: CLIArgs[\"format\"] = null;\n let exclude: string[] = [];\n let yes = false;\n let rules: boolean | null = null; // null = use default (true for sync)\n let rulesDir: string | null = null;\n\n // Check for subcommand first\n if (args[0] && !args[0].startsWith(\"-\")) {\n const cmd = args[0].toLowerCase();\n if (cmd === \"sync\") command = \"sync\";\n else if (cmd === \"init\") command = \"init\";\n else if (cmd === \"help\" || cmd === \"--help\" || cmd === \"-h\") command = \"help\";\n }\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === \"--ds-id\" && args[i + 1]) {\n dsId = args[i + 1];\n i++;\n } else if (args[i] === \"--api-key\" && args[i + 1]) {\n apiKey = args[i + 1];\n i++;\n } else if (args[i] === \"--api-base\" && args[i + 1]) {\n apiBase = args[i + 1];\n i++;\n } else if ((args[i] === \"--output\" || args[i] === \"-o\") && args[i + 1]) {\n output = args[i + 1];\n i++;\n } else if (args[i] === \"--format\" && args[i + 1]) {\n const f = args[i + 1].toLowerCase() as OutputFormat;\n const validFormats: OutputFormat[] = [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"];\n if (validFormats.includes(f)) format = f;\n i++;\n } else if (args[i] === \"--exclude\" && args[i + 1]) {\n exclude.push(args[i + 1]);\n i++;\n } else if (args[i] === \"-y\" || args[i] === \"--yes\") {\n yes = true;\n } else if (args[i] === \"--rules\" || args[i] === \"-r\") {\n rules = true;\n } else if (args[i] === \"--no-rules\") {\n rules = false;\n } else if (args[i] === \"--rules-dir\" && args[i + 1]) {\n rulesDir = args[i + 1];\n rules = true; // Implies --rules\n i++;\n }\n }\n\n // Default: rules sync is ON for sync command (since guides reference tokens)\n const effectiveRules = rules !== null ? rules : (command === \"sync\");\n\n return { command, dsId, apiKey, apiBase, output, format, exclude, yes, rules: effectiveRules, rulesDir };\n}\n\nconst cliArgs = parseArgs();\nconst { dsId, apiKey } = cliArgs;\n// For MCP server mode, use CLI apiBase or default\nconst apiBase = cliArgs.apiBase || \"https://atomixstudio.eu\";\n\n// ============================================\n// TOKEN FETCHING\n// ============================================\n\nlet cachedData: DesignSystemData | null = null;\n\nasync function fetchDesignSystem(): Promise<DesignSystemData> {\n if (cachedData) return cachedData;\n\n if (!dsId) {\n throw new Error(\"Missing --ds-id argument. Usage: npx @atomixstudio/mcp --ds-id <id> --api-key <key>\");\n }\n\n const url = `${apiBase}/api/ds/${dsId}/tokens?format=export`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n \n if (apiKey) {\n headers[\"x-api-key\"] = apiKey;\n }\n\n const response = await fetch(url, { headers });\n \n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Failed to fetch design system: ${response.status} ${text}`);\n }\n\n const data = await response.json() as DesignSystemData;\n cachedData = data;\n return data;\n}\n\n// ============================================\n// TOKEN UTILITIES\n// ============================================\n\nconst TOKEN_CATEGORIES = [\"colors\", \"typography\", \"spacing\", \"sizing\", \"shadows\", \"radius\", \"borders\", \"motion\", \"zIndex\"] as const;\ntype TokenCategory = typeof TOKEN_CATEGORIES[number];\n\nfunction getTokenByPath(tokens: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = tokens;\n\n for (const part of parts) {\n if (current && typeof current === \"object\" && part in current) {\n current = (current as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n\n return current;\n}\n\nfunction flattenTokens(obj: unknown, prefix = \"\"): Array<{ path: string; value: unknown }> {\n const results: Array<{ path: string; value: unknown }> = [];\n\n if (obj && typeof obj === \"object\" && !Array.isArray(obj)) {\n for (const [key, value] of Object.entries(obj)) {\n const newPath = prefix ? `${prefix}.${key}` : key;\n \n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n results.push(...flattenTokens(value, newPath));\n } else {\n results.push({ path: newPath, value });\n }\n }\n }\n\n return results;\n}\n\nfunction searchTokens(tokens: Record<string, unknown>, query: string): Array<{ path: string; value: unknown }> {\n const flat = flattenTokens(tokens);\n const lowerQuery = query.toLowerCase();\n \n return flat.filter(({ path, value }) => {\n const pathMatch = path.toLowerCase().includes(lowerQuery);\n const valueMatch = String(value).toLowerCase().includes(lowerQuery);\n return pathMatch || valueMatch;\n });\n}\n\n// ============================================\n// TOKEN COUNTING\n// ============================================\n\nfunction countTokens(tokens: Record<string, unknown>, prefix = \"\"): number {\n let count = 0;\n for (const [key, value] of Object.entries(tokens)) {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n count += countTokens(value as Record<string, unknown>, `${prefix}${key}.`);\n } else if (value !== undefined && value !== null) {\n count++;\n }\n }\n return count;\n}\n\nfunction getTokenStats(data: DesignSystemData): {\n total: number;\n byCategory: Record<string, number>;\n cssVariables: number;\n governanceRules: number;\n} {\n const byCategory: Record<string, number> = {};\n let total = 0;\n\n for (const [category, value] of Object.entries(data.tokens)) {\n if (value && typeof value === \"object\") {\n const count = countTokens(value as Record<string, unknown>);\n byCategory[category] = count;\n total += count;\n }\n }\n\n return {\n total,\n byCategory,\n cssVariables: Object.keys(data.cssVariables).length,\n governanceRules: data.governance.rules.length,\n };\n}\n\n// ============================================\n// MCP SERVER SETUP\n// ============================================\n\nconst server = new Server(\n {\n name: \"atomix-mcp-user\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n },\n }\n);\n\n// ============================================\n// TOOL DEFINITIONS\n// ============================================\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"getToken\",\n description: \"Get a specific design token by its path. Returns the value and CSS variable name.\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"Token path in dot notation (e.g., 'colors.brand.primary', 'spacing.scale.md')\",\n },\n },\n required: [\"path\"],\n },\n },\n {\n name: \"listTokens\",\n description: \"List all tokens in a category (colors, typography, spacing, sizing, shadows, radius, borders, motion, zIndex).\",\n inputSchema: {\n type: \"object\",\n properties: {\n category: {\n type: \"string\",\n enum: TOKEN_CATEGORIES,\n description: \"Token category to list\",\n },\n subcategory: {\n type: \"string\",\n description: \"Optional subcategory (e.g., 'brand' for colors, 'scale' for spacing)\",\n },\n },\n required: [\"category\"],\n },\n },\n {\n name: \"searchTokens\",\n description: \"Search for tokens by name or value.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Search query (matches token paths or values)\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"validateUsage\",\n description: \"Check if a CSS value follows the design system. Detects hardcoded values that should use tokens.\",\n inputSchema: {\n type: \"object\",\n properties: {\n value: {\n type: \"string\",\n description: \"CSS value to validate (e.g., '#ff0000', '16px', 'rgb(0,112,97)')\",\n },\n context: {\n type: \"string\",\n enum: [\"color\", \"spacing\", \"radius\", \"shadow\", \"typography\", \"any\"],\n description: \"Context of the value to help find the right token\",\n },\n },\n required: [\"value\"],\n },\n },\n {\n name: \"getAIToolRules\",\n description: \"Generate design system rules for AI coding tools (Cursor, Copilot, Windsurf, etc.).\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\", \"all\"],\n description: \"AI tool to generate rules for. Use 'all' to get rules for all tools.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"exportMCPConfig\",\n description: \"Generate MCP configuration file for AI tools.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"claude-desktop\", \"windsurf\", \"continue\", \"vscode\", \"all\"],\n description: \"AI tool to generate MCP config for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"getSetupInstructions\",\n description: \"Get detailed setup instructions for a specific AI tool.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"claude-desktop\", \"generic\"],\n description: \"AI tool to get setup instructions for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"syncTokens\",\n description: \"Sync design tokens to a local file. Creates or updates a tokens file with the latest values from your design system. Returns a diff of changes.\",\n inputSchema: {\n type: \"object\",\n properties: {\n output: {\n type: \"string\",\n description: \"Output file path relative to project root (e.g., './src/tokens.css', './DesignTokens.swift')\",\n },\n format: {\n type: \"string\",\n enum: [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"],\n description: \"Output format. WEB: css, scss, less, json, ts, js. NATIVE: swift (iOS), kotlin (Android), dart (Flutter). Default: css\",\n },\n },\n required: [\"output\"],\n },\n },\n ],\n };\n});\n\n// ============================================\n// TOOL HANDLERS\n// ============================================\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n const data = await fetchDesignSystem();\n\n switch (name) {\n case \"getToken\": {\n const path = args?.path as string;\n const value = getTokenByPath(data.tokens, path);\n \n if (value === undefined) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Token not found: ${path}`,\n suggestion: \"Use listTokens or searchTokens to find available tokens.\",\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n // Find CSS variable for this path\n const cssVarKey = `--atmx-${path.replace(/\\./g, \"-\")}`;\n const cssVar = data.cssVariables[cssVarKey];\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n path,\n value,\n cssVariable: cssVar || `var(${cssVarKey})`,\n usage: `style={{ property: \"var(${cssVarKey})\" }}`,\n }, null, 2),\n }],\n };\n }\n\n case \"listTokens\": {\n const category = args?.category as TokenCategory;\n const subcategory = args?.subcategory as string | undefined;\n \n let tokensToList: unknown = data.tokens[category];\n \n if (subcategory && tokensToList && typeof tokensToList === \"object\") {\n tokensToList = getTokenByPath(tokensToList as Record<string, unknown>, subcategory);\n }\n\n if (!tokensToList) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Category not found: ${category}${subcategory ? `.${subcategory}` : \"\"}`,\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n const flat = flattenTokens(tokensToList);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n category,\n subcategory,\n count: flat.length,\n tokens: flat.slice(0, 50), // Limit to 50 for readability\n truncated: flat.length > 50,\n }, null, 2),\n }],\n };\n }\n\n case \"searchTokens\": {\n const query = args?.query as string;\n const results = searchTokens(data.tokens, query);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n query,\n count: results.length,\n results: results.slice(0, 30),\n truncated: results.length > 30,\n }, null, 2),\n }],\n };\n }\n\n case \"validateUsage\": {\n const value = args?.value as string;\n const context = (args?.context as string) || \"any\";\n \n // Check if value is a hardcoded color\n const isHexColor = /^#[0-9A-Fa-f]{3,8}$/.test(value);\n const isRgbColor = /^rgb\\(|^rgba\\(|^hsl\\(/.test(value);\n const isPixelValue = /^\\d+px$/.test(value);\n \n if (!isHexColor && !isRgbColor && !isPixelValue) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: true,\n message: \"Value appears to be using tokens or is not a design token value.\",\n }, null, 2),\n }],\n };\n }\n\n // Search for matching tokens\n const matches = searchTokens(data.tokens, value);\n \n if (matches.length > 0) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. Use a token instead.\",\n matchingTokens: matches.slice(0, 5),\n suggestion: `Use var(--atmx-${matches[0].path.replace(/\\./g, \"-\")}) instead of ${value}`,\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. No exact token match found.\",\n suggestion: `Consider adding this value to the design system or use the closest token.`,\n context,\n }, null, 2),\n }],\n };\n }\n\n case \"getAIToolRules\": {\n const tool = args?.tool as string;\n \n // Fetch rules from the API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool === \"all\" ? \"all\" : tool}`;\n console.error(`[getAIToolRules] Fetching: ${rulesUrl}`);\n \n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n \n try {\n const response = await fetch(rulesUrl, { headers });\n console.error(`[getAIToolRules] Response status: ${response.status}`);\n \n if (!response.ok) {\n const errorText = await response.text();\n console.error(`[getAIToolRules] Error response: ${errorText}`);\n throw new Error(`Failed to fetch rules: ${response.status} - ${errorText}`);\n }\n\n const rules = await response.json() as { rules?: string[]; categories?: Record<string, string[]> };\n console.error(`[getAIToolRules] Got ${rules.rules?.length || 0} rules`);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(rules, null, 2),\n }],\n };\n } catch (fetchError) {\n console.error(`[getAIToolRules] Fetch error:`, fetchError);\n throw fetchError;\n }\n }\n\n case \"exportMCPConfig\": {\n const tool = args?.tool as string;\n \n // Generate MCP config locally\n const serverName = data.meta.name.toLowerCase().replace(/[^a-z0-9]/g, \"-\");\n const npxArgs = [\"@atomixstudio/mcp@latest\"];\n if (dsId) npxArgs.push(\"--ds-id\", dsId);\n if (apiKey) npxArgs.push(\"--api-key\", apiKey);\n\n const config = {\n mcpServers: {\n [serverName]: {\n command: \"npx\",\n args: npxArgs,\n },\n },\n };\n\n const configs: Record<string, { path: string; content: string }> = {\n cursor: { path: \".cursor/mcp.json\", content: JSON.stringify(config, null, 2) },\n \"claude-desktop\": { path: \"claude_desktop_config.json\", content: JSON.stringify(config, null, 2) },\n windsurf: { path: \".windsurf/mcp.json\", content: JSON.stringify(config, null, 2) },\n continue: { path: \".continue/config.json\", content: JSON.stringify({ models: [], mcpServers: [{ name: serverName, command: \"npx\", args: npxArgs }] }, null, 2) },\n vscode: { path: \".vscode/settings.json\", content: JSON.stringify({ \"mcp.servers\": config.mcpServers }, null, 2) },\n };\n\n if (tool === \"all\") {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n message: \"MCP configurations for all tools\",\n configs: Object.entries(configs).map(([t, c]) => ({\n tool: t,\n path: c.path,\n content: JSON.parse(c.content),\n })),\n }, null, 2),\n }],\n };\n }\n\n const selectedConfig = configs[tool as keyof typeof configs];\n if (!selectedConfig) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(configs),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n tool,\n path: selectedConfig.path,\n content: JSON.parse(selectedConfig.content),\n instructions: `Create the file at ${selectedConfig.path} with the content above, then restart your IDE.`,\n }, null, 2),\n }],\n };\n }\n\n case \"getSetupInstructions\": {\n const tool = args?.tool as string;\n \n const instructions: Record<string, string> = {\n cursor: `# Cursor MCP Setup\n\n1. Create \\`.cursor/mcp.json\\` in your project root\n2. Add the MCP configuration (use exportMCPConfig to get it)\n3. Restart Cursor IDE\n4. Verify by asking: \"What design tokens are available?\"`,\n\n copilot: `# GitHub Copilot Setup\n\n1. Create \\`.github/copilot-instructions.md\\` in your project\n2. Use getAIToolRules({ tool: \"copilot\" }) to get the content\n3. Enable custom instructions in VS Code settings:\n \"github.copilot.chat.codeGeneration.useInstructionFiles\": true`,\n\n windsurf: `# Windsurf Setup\n\n1. Create \\`.windsurf/mcp.json\\` in your project root\n2. Create \\`.windsurfrules\\` with rules from getAIToolRules\n3. Restart Windsurf Editor`,\n\n cline: `# Cline Setup\n\n1. Create \\`.clinerules\\` in your project root\n2. Cline auto-detects MCP from .cursor/mcp.json`,\n\n continue: `# Continue Setup\n\n1. Create/edit \\`.continue/config.json\\`\n2. Add mcpServers configuration\n3. Restart VS Code`,\n\n zed: `# Zed Setup\n\n1. Create \\`.zed/assistant/rules.md\\` in your project\n2. Use getAIToolRules({ tool: \"zed\" }) for content`,\n\n \"claude-desktop\": `# Claude Desktop Setup\n\n1. Find your Claude config:\n - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\n - Windows: %APPDATA%\\\\Claude\\\\claude_desktop_config.json\n2. Add MCP server configuration\n3. Restart Claude Desktop`,\n\n generic: `# Generic AI Tool Setup\n\n1. Create AI_GUIDELINES.md in your project root\n2. Use getAIToolRules({ tool: \"generic\" }) for content\n3. Reference in your prompts or context`,\n };\n\n const instruction = instructions[tool];\n if (!instruction) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(instructions),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: instruction,\n }],\n };\n }\n\n case \"syncTokens\": {\n const output = args?.output as string;\n const format = (args?.format as OutputFormat) || \"css\";\n \n if (!output) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({ error: \"Missing required parameter: output\" }, null, 2),\n }],\n };\n }\n\n // Generate content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (format) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), output);\n const fileExists = fs.existsSync(outputPath);\n const tokenCount = Object.keys(data.cssVariables).length;\n\n let diffSummary = \"\";\n let changes: Array<{ key: string; old: string; new: string }> = [];\n\n if (fileExists && [\"css\", \"scss\", \"less\"].includes(format)) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, format as OutputFormat, darkModeColors?.dark);\n \n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n \n if (totalChanges === 0) {\n return {\n content: [{\n type: \"text\",\n text: `✓ Already up to date!\\n\\nFile: ${output}\\nTokens: ${tokenCount}\\nVersion: ${data.meta.version}`,\n }],\n };\n }\n\n changes = [...diff.modified, ...diff.modifiedDark];\n \n // Build summary\n const lightSummary = lightChanges > 0 ? `Light: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed` : \"\";\n const darkSummary = darkChanges > 0 ? `Dark: ${diff.modifiedDark.length} modified, ${diff.addedDark.length} added, ${diff.removedDark.length} removed` : \"\";\n diffSummary = [lightSummary, darkSummary].filter(Boolean).join(\" | \");\n }\n\n // Write the file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n // Build response\n let response = `✓ Synced ${tokenCount} tokens to ${output}\\n`;\n response += `Format: ${format}\\n`;\n response += `Design System: ${data.meta.name} (v${data.meta.version})\\n`;\n \n if (diffSummary) {\n response += `\\n${diffSummary}\\n`;\n if (changes.length > 0 && changes.length <= 10) {\n response += \"\\nModified tokens:\\n\";\n for (const { key, old: oldVal, new: newVal } of changes) {\n response += ` ${key}: ${oldVal} → ${newVal}\\n`;\n }\n }\n } else if (!fileExists) {\n response += \"\\n(New file created)\";\n }\n\n return {\n content: [{\n type: \"text\",\n text: response,\n }],\n };\n }\n\n default:\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${name}`,\n availableTools: [\"getToken\", \"listTokens\", \"searchTokens\", \"validateUsage\", \"getAIToolRules\", \"exportMCPConfig\", \"getSetupInstructions\", \"syncTokens\"],\n }, null, 2),\n }],\n };\n }\n } catch (error) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: error instanceof Error ? error.message : \"Unknown error\",\n suggestion: \"Make sure --ds-id and --api-key are correct.\",\n }, null, 2),\n }],\n isError: true,\n };\n }\n});\n\n// ============================================\n// RESOURCE HANDLERS\n// ============================================\n\nconst AI_TOOLS = [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\"] as const;\n\nserver.setRequestHandler(ListResourcesRequestSchema, async () => {\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n \n const resources = [\n {\n uri: \"atomix://welcome\",\n name: `Welcome to ${data.meta.name}`,\n description: `Design system overview with ${stats.total} tokens and ${stats.governanceRules} governance rules`,\n mimeType: \"text/markdown\",\n },\n ...AI_TOOLS.map(tool => ({\n uri: `atomix://rules/${tool}`,\n name: `${tool.charAt(0).toUpperCase() + tool.slice(1)} Rules`,\n description: `Design system rules file for ${tool}`,\n mimeType: \"text/markdown\",\n })),\n ];\n\n return { resources };\n});\n\nserver.setRequestHandler(ReadResourceRequestSchema, async (request) => {\n const { uri } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n // Welcome resource\n if (uri === \"atomix://welcome\") {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: welcome,\n }],\n };\n }\n\n // Rules resources\n const rulesMatch = uri.match(/^atomix:\\/\\/rules\\/(.+)$/);\n if (rulesMatch) {\n const tool = rulesMatch[1];\n if (!AI_TOOLS.includes(tool as typeof AI_TOOLS[number])) {\n throw new Error(`Unknown tool: ${tool}. Available: ${AI_TOOLS.join(\", \")}`);\n }\n\n // Fetch rules from API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string; tool?: string };\n \n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n }],\n };\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n});\n\n// ============================================\n// PROMPTS - Auto-suggest welcome on connection\n// ============================================\n\nserver.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: \"welcome\",\n description: \"Get started with this design system - shows overview, available tokens, and tools. Run this first!\",\n },\n {\n name: \"design-system-rules\",\n description: \"Get the design system governance rules for your AI coding tool\",\n arguments: [\n {\n name: \"tool\",\n description: \"AI tool to generate rules for (cursor, copilot, windsurf, cline, continue, zed, generic)\",\n required: false,\n },\n ],\n },\n ],\n };\n});\n\nserver.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n switch (name) {\n case \"welcome\": {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n description: `Welcome to ${data.meta.name} Design System`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: \"Show me the design system overview and available tools.\",\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: welcome,\n },\n },\n ],\n };\n }\n\n case \"design-system-rules\": {\n const tool = (args?.tool as string) || \"cursor\";\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string };\n \n return {\n description: `Design system rules for ${tool}`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: `Show me the design system rules for ${tool}.`,\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n});\n\nfunction generateWelcomeMessage(data: DesignSystemData, stats: ReturnType<typeof getTokenStats>): string {\n const toolsList = [\n \"getToken - Get a specific token by path\",\n \"listTokens - List all tokens in a category\",\n \"searchTokens - Search tokens by name or value\",\n \"validateUsage - Check if a CSS value follows the design system\",\n \"getAIToolRules - Generate AI coding rules for any tool\",\n \"exportMCPConfig - Generate MCP config for AI tools\",\n \"getSetupInstructions - Get setup guide for specific tools\",\n \"syncTokens - Sync tokens to a local file (css, scss, swift, kotlin, dart, etc.)\",\n ];\n\n const categoryBreakdown = Object.entries(stats.byCategory)\n .map(([cat, count]) => ` - ${cat}: ${count} tokens`)\n .join(\"\\n\");\n\n const asciiArt = `\n\\`\\`\\`\n ↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘ \n\\`\\`\\`\n`;\n\n return `${asciiArt}\n# Welcome to ${data.meta.name}\n\nYour design system is connected and ready to use.\n\n## Design System Overview\n\n| Metric | Value |\n|--------|-------|\n| Name | ${data.meta.name} |\n| DS ID | ${dsId} |\n| Total Tokens | ${stats.total} |\n| CSS Variables | ${stats.cssVariables} |\n| Governance Rules | ${stats.governanceRules} |\n| Version | ${data.meta.version || 1} |\n\n### Token Breakdown\n\n${categoryBreakdown}\n\n## Available Tools\n\n${toolsList.map((t, i) => `${i + 1}. **${t.split(\" - \")[0]}** - ${t.split(\" - \")[1]}`).join(\"\\n\")}\n\n## Quick Start\n\n### Get a Token\n\\`\\`\\`\nUse getToken with path \"colors.static.brand.primary\"\n\\`\\`\\`\n\n### List All Spacing Tokens\n\\`\\`\\`\nUse listTokens with category \"spacing\"\n\\`\\`\\`\n\n### Validate a Hardcoded Value\n\\`\\`\\`\nUse validateUsage with value \"#ff0000\" and context \"color\"\n\\`\\`\\`\n\n## Resources Available\n\nThis MCP server exposes rules files as resources that your AI tool can read:\n\n| Resource | Description |\n|----------|-------------|\n| \\`atomix://welcome\\` | This welcome message |\n| \\`atomix://rules/cursor\\` | .cursorrules file content |\n| \\`atomix://rules/copilot\\` | GitHub Copilot instructions |\n| \\`atomix://rules/windsurf\\` | .windsurfrules file content |\n| \\`atomix://rules/cline\\` | .clinerules file content |\n| \\`atomix://rules/continue\\` | Continue rules |\n| \\`atomix://rules/zed\\` | Zed assistant rules |\n| \\`atomix://rules/generic\\` | Generic AI guidelines |\n\n## Checking for Updates\n\nYour design system may be updated over time. To ensure you have the latest tokens:\n\n1. **Check version**: The current version is ${data.meta.version || 1}\n2. **Refresh tokens**: Restart the MCP server to fetch latest tokens\n3. **View changes**: Visit https://atomixstudio.eu/ds/${dsId} to see recent changes\n\n---\n\n*Powered by Atomix Studio - https://atomixstudio.eu*\n`;\n}\n\n// ============================================\n// SYNC COMMAND\n// ============================================\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as readline from \"readline\";\n\ntype OutputFormat = \n | \"css\" | \"scss\" | \"less\" // Web CSS-based\n | \"json\" | \"ts\" | \"js\" // Web JS-based\n | \"swift\" | \"kotlin\" | \"dart\"; // Native mobile\n\ninterface AtomixConfig {\n dsId: string;\n apiKey?: string;\n apiBase?: string;\n output: string;\n format: OutputFormat;\n // For future codebase scanning\n include?: string[]; // Glob patterns to include\n exclude?: string[]; // Glob patterns to exclude\n}\n\n// Default file patterns for codebase scanning\nconst DEFAULT_INCLUDE = [\n \"**/*.tsx\", // React TypeScript components\n \"**/*.jsx\", // React JavaScript components\n \"**/*.ts\", // TypeScript files\n \"**/*.js\", // JavaScript files\n \"**/*.css\", // CSS stylesheets\n \"**/*.scss\", // SASS files\n \"**/*.less\", // Less files\n \"**/*.vue\", // Vue components\n \"**/*.svelte\", // Svelte components\n \"**/*.astro\", // Astro components\n];\n\nconst DEFAULT_EXCLUDE = [\n \"node_modules/**\",\n \"dist/**\",\n \"build/**\",\n \".next/**\",\n \".nuxt/**\",\n \".git/**\",\n \"coverage/**\",\n \"**/*.min.js\",\n \"**/*.min.css\",\n \"**/*.d.ts\", // Type definitions\n \"**/*.test.*\", // Test files\n \"**/*.spec.*\", // Spec files\n];\n\nfunction findConfig(): AtomixConfig | null {\n const configNames = [\".atomixrc\", \".atomixrc.json\", \"atomix.config.json\"];\n const cwd = process.cwd();\n \n for (const name of configNames) {\n const configPath = path.join(cwd, name);\n if (fs.existsSync(configPath)) {\n try {\n const content = fs.readFileSync(configPath, \"utf-8\");\n return JSON.parse(content);\n } catch {\n console.error(`Error parsing ${name}`);\n }\n }\n }\n return null;\n}\n\nfunction generateCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"/* Atomix Design System Tokens\",\n \" * Auto-generated - do not edit manually\",\n ` * Synced: ${new Date().toISOString()}`,\n \" */\",\n \"\",\n \"/* Light mode (default) */\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode overrides if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"/* Dark mode */\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n // Detect prefix from cssVariables keys\n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n // Dark mode colors are stored with keys like \"bg-page\", \"text-primary\"\n // Convert to CSS variable names: --atmx-color-bg-page\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateJSONOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return JSON.stringify(tokens, null, 2);\n}\n\nfunction generateTSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)} as const;\n\nexport type Tokens = typeof tokens;\n`;\n}\n\nfunction generateJSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)};\n`;\n}\n\nfunction generateSCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// SCSS Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const scssVar = \"$\" + key.replace(/^--/, \"\");\n lines.push(`${scssVar}: ${value};`);\n }\n \n // Add dark mode SCSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// SCSS Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const scssVar = `$${prefix}-color-${key}-dark`;\n lines.push(`${scssVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateLessOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// Less Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const lessVar = \"@\" + key.replace(/^--/, \"\");\n lines.push(`${lessVar}: ${value};`);\n }\n \n // Add dark mode Less variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Less Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const lessVar = `@${prefix}-color-${key}-dark`;\n lines.push(`${lessVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\n// ============================================\n// NATIVE MOBILE OUTPUT GENERATORS\n// ============================================\n\nfunction toSwiftName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary\n return cssVar\n .replace(/^--atmx-/, \"\")\n .replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n}\n\nfunction toKotlinName(cssVar: string): string {\n // --atmx-color-brand-primary → ColorBrandPrimary\n const camel = toSwiftName(cssVar);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n}\n\nfunction toDartName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary (same as Swift)\n return toSwiftName(cssVar);\n}\n\nfunction isColorValue(value: string): boolean {\n return /^#[0-9A-Fa-f]{3,8}$/.test(value) || \n /^rgb/.test(value) || \n /^hsl/.test(value);\n}\n\nfunction hexToSwiftColor(hex: string): string {\n // #RRGGBB or #RRGGBBAA\n const clean = hex.replace(\"#\", \"\");\n if (clean.length === 3) {\n // #RGB -> #RRGGBB\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(hex: 0x${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(hex: 0x${clean})`;\n }\n if (clean.length === 8) {\n // #RRGGBBAA\n const rgb = clean.substring(0, 6);\n const alpha = parseInt(clean.substring(6, 8), 16) / 255;\n return `Color(hex: 0x${rgb}).opacity(${alpha.toFixed(2)})`;\n }\n return `Color.clear // Could not parse: ${hex}`;\n}\n\nfunction hexToKotlinColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n // RRGGBBAA -> AARRGGBB for Android\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Color.Transparent // Could not parse: ${hex}`;\n}\n\nfunction hexToDartColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Colors.transparent // Could not parse: ${hex}`;\n}\n\nfunction generateSwiftOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import SwiftUI\",\n \"\",\n \"// MARK: - Color Extension for Hex\",\n \"extension Color {\",\n \" init(hex: UInt, alpha: Double = 1.0) {\",\n \" self.init(\",\n \" .sRGB,\",\n \" red: Double((hex >> 16) & 0xFF) / 255.0,\",\n \" green: Double((hex >> 8) & 0xFF) / 255.0,\",\n \" blue: Double(hex & 0xFF) / 255.0,\",\n \" opacity: alpha\",\n \" )\",\n \" }\",\n \"}\",\n \"\",\n \"// MARK: - Design Tokens\",\n \"enum DesignTokens {\",\n \"\",\n \" // MARK: Colors (Light Mode)\",\n \" enum Colors {\"\n ];\n\n // Group by category\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // MARK: Colors (Dark Mode)\");\n lines.push(\" enum ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" // MARK: Spacing\");\n lines.push(\" enum Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toSwiftName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Typography\");\n lines.push(\" enum Typography {\");\n\n for (const [key, value] of typography) {\n const name = toSwiftName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n } else if (key.includes(\"weight\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n } else if (key.includes(\"family\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Other\");\n lines.push(\" enum Other {\");\n\n for (const [key, value] of other) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n } else {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateKotlinOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"package com.atomix.design\",\n \"\",\n \"import androidx.compose.ui.graphics.Color\",\n \"import androidx.compose.ui.unit.dp\",\n \"import androidx.compose.ui.unit.sp\",\n \"\",\n \"object DesignTokens {\",\n \"\",\n \" // Light mode colors\",\n \" object Colors {\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Dark mode colors\");\n lines.push(\" object ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `Color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" object Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toKotlinName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Typography {\");\n\n for (const [key, value] of typography) {\n const name = toKotlinName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.sp`);\n }\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Other {\");\n\n for (const [key, value] of other) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateDartOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import 'package:flutter/material.dart';\",\n \"\",\n \"class DesignTokens {\",\n \" DesignTokens._();\",\n \"\",\n \" // Colors (Light Mode)\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n\n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Colors (Dark Mode)\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}Dark`;\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Spacing\");\n\n for (const [key, value] of spacing) {\n const name = toDartName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Typography\");\n\n for (const [key, value] of typography) {\n const name = toDartName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Other\");\n\n for (const [key, value] of other) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n }\n\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction diffTokens(\n oldContent: string,\n newCssVars: Record<string, string>,\n format: OutputFormat,\n newDarkVars?: Record<string, string>\n): { \n added: string[]; \n modified: Array<{ key: string; old: string; new: string }>; \n removed: string[];\n addedDark: string[];\n modifiedDark: Array<{ key: string; old: string; new: string }>;\n removedDark: string[];\n} {\n const added: string[] = [];\n const modified: Array<{ key: string; old: string; new: string }> = [];\n const removed: string[] = [];\n const addedDark: string[] = [];\n const modifiedDark: Array<{ key: string; old: string; new: string }> = [];\n const removedDark: string[] = [];\n\n // CSS-based formats (css, scss, less) all use CSS variables\n if (format === \"css\" || format === \"scss\" || format === \"less\") {\n // Split old content into light mode (:root) and dark mode (.dark) sections\n // Find the :root section\n const rootMatch = oldContent.match(/:root\\s*\\{([^}]*)\\}/);\n const darkMatch = oldContent.match(/\\.dark[^{]*\\{([^}]*)\\}/);\n \n // Parse light mode variables from :root\n const oldLightVars: Record<string, string> = {};\n if (rootMatch) {\n const rootContent = rootMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(rootContent)) !== null) {\n oldLightVars[match[1]] = match[2].trim();\n }\n } else {\n // Fallback: parse everything (old behavior for files without sections)\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(oldContent)) !== null) {\n // Only take the first occurrence to get light mode values\n if (!(match[1] in oldLightVars)) {\n oldLightVars[match[1]] = match[2].trim();\n }\n }\n }\n\n // Parse dark mode variables from .dark\n const oldDarkVars: Record<string, string> = {};\n if (darkMatch) {\n const darkContent = darkMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(darkContent)) !== null) {\n oldDarkVars[match[1]] = match[2].trim();\n }\n }\n\n // Compare light mode\n for (const [key, value] of Object.entries(newCssVars)) {\n if (!(key in oldLightVars)) {\n added.push(key);\n } else if (oldLightVars[key] !== value) {\n modified.push({ key, old: oldLightVars[key], new: value });\n }\n }\n\n for (const key of Object.keys(oldLightVars)) {\n if (!(key in newCssVars)) {\n removed.push(key);\n }\n }\n\n // Compare dark mode if new dark vars provided\n if (newDarkVars && Object.keys(newDarkVars).length > 0) {\n // Generate the expected CSS variable names for dark mode\n // newDarkVars keys are like \"bg-page\", need to match \"--atmx-color-bg-page\"\n const firstKey = Object.keys(newCssVars)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n\n for (const [key, value] of Object.entries(newDarkVars)) {\n const cssVarName = `${prefix}color-${key}`;\n if (!(cssVarName in oldDarkVars)) {\n addedDark.push(cssVarName);\n } else if (oldDarkVars[cssVarName] !== value) {\n modifiedDark.push({ key: cssVarName, old: oldDarkVars[cssVarName], new: value });\n }\n }\n\n for (const key of Object.keys(oldDarkVars)) {\n // Extract the short key from --atmx-color-bg-page -> bg-page\n const shortKey = key.replace(new RegExp(`^${prefix}color-`), \"\");\n if (!(shortKey in newDarkVars)) {\n removedDark.push(key);\n }\n }\n }\n }\n\n return { added, modified, removed, addedDark, modifiedDark, removedDark };\n}\n\nasync function promptConfirm(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} [Y/n] `, (answer) => {\n rl.close();\n const normalized = answer.toLowerCase().trim();\n resolve(normalized === \"\" || normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\nasync function runSync() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Token Sync\");\n console.log(\"\");\n\n // Load config\n const config = findConfig();\n const effectiveDsId = cliArgs.dsId || config?.dsId;\n const effectiveApiKey = cliArgs.apiKey || config?.apiKey;\n const effectiveApiBase = cliArgs.apiBase || config?.apiBase || \"https://atomixstudio.eu\";\n const effectiveOutput = cliArgs.output || config?.output || \"./tokens.css\";\n const effectiveFormat = cliArgs.format || config?.format || \"css\";\n\n if (!effectiveDsId) {\n console.error(\" Error: Missing design system ID\");\n console.error(\"\");\n console.error(\" Either:\");\n console.error(\" 1. Run: npx atomix sync --ds-id <your-ds-id>\");\n console.error(\" 2. Create .atomixrc with { \\\"dsId\\\": \\\"<your-ds-id>\\\" }\");\n console.error(\" 3. Run: npx atomix init\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(` Fetching tokens from ${effectiveApiBase}...`);\n\n // Fetch latest tokens\n const url = `${effectiveApiBase}/api/ds/${effectiveDsId}/tokens?format=export`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n\n let data: ExportedTokens;\n try {\n const response = await fetch(url, { headers });\n if (!response.ok) {\n const errorText = await response.text();\n console.error(` Error: Failed to fetch tokens (${response.status})`);\n console.error(` ${errorText}`);\n process.exit(1);\n }\n data = await response.json() as ExportedTokens;\n } catch (error) {\n console.error(` Error: Could not connect to ${effectiveApiBase}`);\n console.error(` ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n\n console.log(` Design System: ${data.meta.name} (v${data.meta.version})`);\n console.log(\"\");\n\n // Generate new content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (effectiveFormat) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), effectiveOutput);\n const fileExists = fs.existsSync(outputPath);\n\n // CSS-based formats support diffing\n const supportsDiff = [\"css\", \"scss\", \"less\"].includes(effectiveFormat);\n if (fileExists && supportsDiff) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat, darkModeColors?.dark);\n\n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n\n if (totalChanges === 0) {\n console.log(\" ✓ Already up to date!\");\n console.log(\"\");\n process.exit(0);\n }\n\n console.log(` Changes detected in ${path.basename(effectiveOutput)}:`);\n console.log(\"\");\n\n // Show light mode changes\n if (lightChanges > 0) {\n console.log(\" Light Mode:\");\n if (diff.modified.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modified) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.added.length > 0) {\n console.log(` + ${diff.added.length} new token(s)`);\n }\n if (diff.removed.length > 0) {\n console.log(` - ${diff.removed.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n // Show dark mode changes\n if (darkChanges > 0) {\n console.log(\" Dark Mode:\");\n if (diff.modifiedDark.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modifiedDark) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.addedDark.length > 0) {\n console.log(` + ${diff.addedDark.length} new token(s)`);\n }\n if (diff.removedDark.length > 0) {\n console.log(` - ${diff.removedDark.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n console.log(` Total: ${totalChanges} change(s) (Light: ${lightChanges}, Dark: ${darkChanges})`);\n console.log(\"\");\n\n // Confirm\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Apply changes?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n } else if (!fileExists) {\n console.log(` Creating ${effectiveOutput}...`);\n console.log(` ${Object.keys(data.cssVariables).length} tokens`);\n console.log(\"\");\n\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Create file?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n }\n\n // Write file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n console.log(\"\");\n console.log(` ✓ Tokens synced → ${effectiveOutput}`);\n\n // Sync rules files (ON by default since guides reference tokens)\n if (cliArgs.rules) {\n console.log(\"\");\n console.log(\" Syncing AI guidance rules...\");\n \n const rulesDir = cliArgs.rulesDir || process.cwd();\n const rulesDirResolved = path.resolve(process.cwd(), rulesDir);\n \n // Detect which AI tools are likely in use based on existing files\n const toolsToSync: Array<{ tool: string; filename: string; dir?: string }> = [\n { tool: \"cursor\", filename: \".cursorrules\" },\n { tool: \"windsurf\", filename: \".windsurfrules\" },\n { tool: \"cline\", filename: \".clinerules\" },\n { tool: \"continue\", filename: \".continuerules\" },\n { tool: \"copilot\", filename: \"copilot-instructions.md\", dir: \".github\" },\n { tool: \"generic\", filename: \"AI_GUIDELINES.md\" },\n ];\n \n // Check which tools have existing files or should be created\n const existingTools = toolsToSync.filter(t => {\n const filePath = t.dir \n ? path.join(rulesDirResolved, t.dir, t.filename)\n : path.join(rulesDirResolved, t.filename);\n return fs.existsSync(filePath);\n });\n \n // If no existing rules files, create .cursorrules by default\n const toolsToWrite = existingTools.length > 0 \n ? existingTools \n : [{ tool: \"cursor\", filename: \".cursorrules\" }];\n \n for (const { tool, filename, dir } of toolsToWrite) {\n try {\n // Fetch rules from API\n const rulesUrl = `${effectiveApiBase}/api/ds/${effectiveDsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n \n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n console.error(` ✗ Failed to fetch ${tool} rules: ${response.status}`);\n continue;\n }\n \n const rulesData = await response.json() as { content?: string };\n if (!rulesData.content) {\n console.error(` ✗ No content for ${tool} rules`);\n continue;\n }\n \n // Write the file\n const targetDir = dir ? path.join(rulesDirResolved, dir) : rulesDirResolved;\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n \n const filePath = path.join(targetDir, filename);\n fs.writeFileSync(filePath, rulesData.content);\n \n const relativePath = dir ? `${dir}/${filename}` : filename;\n console.log(` ✓ ${relativePath}`);\n } catch (error) {\n console.error(` ✗ Error syncing ${tool} rules:`, error instanceof Error ? error.message : String(error));\n }\n }\n }\n\n console.log(\"\");\n}\n\nasync function runInit() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Config Setup\");\n console.log(\"\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const question = (prompt: string): Promise<string> =>\n new Promise((resolve) => rl.question(prompt, resolve));\n\n const dsId = cliArgs.dsId || await question(\" Design System ID: \");\n const output = await question(\" Output file [./tokens.css]: \") || \"./tokens.css\";\n const format = await question(\" Format (css/json/ts) [css]: \") || \"css\";\n\n rl.close();\n\n const config: AtomixConfig = {\n dsId,\n output,\n format: format as \"css\" | \"json\" | \"ts\",\n };\n\n const configPath = path.join(process.cwd(), \".atomixrc\");\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n\n console.log(\"\");\n console.log(` ✓ Created .atomixrc`);\n console.log(\"\");\n console.log(\" Now run: npx atomix sync\");\n console.log(\"\");\n}\n\nfunction showHelp() {\n console.log(`\n ↘↘↘ Atomix CLI\n\n COMMANDS\n sync Sync design tokens to your project\n init Create .atomixrc config file\n help Show this help message\n (none) Start MCP server for AI tools\n\n SYNC OPTIONS\n --ds-id Design system ID (or set in .atomixrc)\n --api-key API key for private design systems\n --output, -o Output file path [./tokens.css]\n --format Output format [css]\n WEB:\n css - CSS custom properties (:root { --var: value })\n scss - CSS vars + SCSS variables ($var: value)\n less - CSS vars + Less variables (@var: value)\n json - Raw token JSON\n ts - TypeScript with types\n js - JavaScript ES module\n NATIVE:\n swift - SwiftUI (iOS/macOS)\n kotlin - Jetpack Compose (Android)\n dart - Flutter\n --no-rules Skip syncing AI rules files (tokens + rules sync by default)\n --rules-dir Directory for rules files [project root]\n --exclude Glob pattern to exclude (can use multiple times)\n -y, --yes Auto-confirm changes\n\n MCP SERVER OPTIONS\n --ds-id Design system ID (required)\n --api-key API key for private design systems\n --api-base API base URL [https://atomixstudio.eu]\n\n EXAMPLES\n npx heyatomix sync # Sync tokens + AI rules (default)\n npx heyatomix sync --no-rules # Sync tokens only\n npx heyatomix sync -o ./src/tokens.css\n npx heyatomix sync --format scss -o ./src/styles/_tokens.scss\n npx heyatomix sync --format swift -o ./Sources/DesignTokens.swift\n npx heyatomix init\n npx heyatomix --ds-id abc123 # Start MCP server\n\n CONFIG FILE (.atomixrc)\n {\n \"dsId\": \"your-design-system-id\",\n \"output\": \"./src/styles/tokens.css\",\n \"format\": \"css\",\n \"exclude\": [\"legacy/**\", \"vendor/**\"]\n }\n\n DEFAULT SCANNED FILES\n *.tsx, *.jsx, *.ts, *.js, *.css, *.scss, *.less, *.vue, *.svelte\n\n DEFAULT EXCLUDED\n node_modules/**, dist/**, build/**, .next/**, *.min.*, *.d.ts\n`);\n}\n\n// ============================================\n// START SERVER\n// ============================================\n\nasync function startServer() {\n if (!dsId) {\n console.error(\"Error: Missing --ds-id argument\");\n console.error(\"Usage: npx atomix --ds-id <id> --api-key <key>\");\n console.error(\"\");\n console.error(\"For sync command: npx atomix sync --help\");\n console.error(\"Get your DS ID from https://atomixstudio.eu/ds/[your-ds-id]\");\n process.exit(1);\n }\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n \n // Log to stderr so it doesn't interfere with MCP protocol on stdout\n console.error(`Atomix MCP Server started for design system: ${dsId}`);\n}\n\nasync function main() {\n switch (cliArgs.command) {\n case \"sync\":\n await runSync();\n break;\n case \"init\":\n await runInit();\n break;\n case \"help\":\n showHelp();\n break;\n case \"server\":\n default:\n await startServer();\n break;\n }\n}\n\nmain().catch((error) => {\n console.error(\"Failed:\", error);\n process.exit(1);\n});\n\n"],"mappings":";;;AAqBA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAupCP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AAhmC1B,SAAS,YAAqB;AAC5B,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAI,UAA8B;AAClC,MAAIA,QAAsB;AAC1B,MAAIC,UAAwB;AAC5B,MAAIC,WAAyB;AAC7B,MAAI,SAAwB;AAC5B,MAAI,SAA4B;AAChC,MAAI,UAAoB,CAAC;AACzB,MAAI,MAAM;AACV,MAAI,QAAwB;AAC5B,MAAI,WAA0B;AAG9B,MAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,GAAG;AACvC,UAAM,MAAM,KAAK,CAAC,EAAE,YAAY;AAChC,QAAI,QAAQ,OAAQ,WAAU;AAAA,aACrB,QAAQ,OAAQ,WAAU;AAAA,aAC1B,QAAQ,UAAU,QAAQ,YAAY,QAAQ,KAAM,WAAU;AAAA,EACzE;AAEA,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAI,KAAK,CAAC,MAAM,aAAa,KAAK,IAAI,CAAC,GAAG;AACxC,MAAAF,QAAO,KAAK,IAAI,CAAC;AACjB;AAAA,IACF,WAAW,KAAK,CAAC,MAAM,eAAe,KAAK,IAAI,CAAC,GAAG;A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