@atomixstudio/mcp 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +120 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -586,10 +586,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
586
586
|
}]
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
+
const darkModeColors = data.tokens?.colors?.modes;
|
|
589
590
|
let newContent;
|
|
590
591
|
switch (format) {
|
|
591
592
|
case "css":
|
|
592
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
593
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
593
594
|
break;
|
|
594
595
|
case "scss":
|
|
595
596
|
newContent = generateSCSSOutput(data.cssVariables);
|
|
@@ -616,7 +617,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
616
617
|
newContent = generateDartOutput(data.cssVariables);
|
|
617
618
|
break;
|
|
618
619
|
default:
|
|
619
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
620
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
620
621
|
}
|
|
621
622
|
const outputPath = path.resolve(process.cwd(), output);
|
|
622
623
|
const fileExists = fs.existsSync(outputPath);
|
|
@@ -625,8 +626,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
625
626
|
let changes = [];
|
|
626
627
|
if (fileExists && ["css", "scss", "less"].includes(format)) {
|
|
627
628
|
const oldContent = fs.readFileSync(outputPath, "utf-8");
|
|
628
|
-
const diff = diffTokens(oldContent, data.cssVariables, format);
|
|
629
|
-
const
|
|
629
|
+
const diff = diffTokens(oldContent, data.cssVariables, format, darkModeColors?.dark);
|
|
630
|
+
const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;
|
|
631
|
+
const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;
|
|
632
|
+
const totalChanges = lightChanges + darkChanges;
|
|
630
633
|
if (totalChanges === 0) {
|
|
631
634
|
return {
|
|
632
635
|
content: [{
|
|
@@ -639,8 +642,10 @@ Version: ${data.meta.version}`
|
|
|
639
642
|
}]
|
|
640
643
|
};
|
|
641
644
|
}
|
|
642
|
-
changes = diff.modified;
|
|
643
|
-
|
|
645
|
+
changes = [...diff.modified, ...diff.modifiedDark];
|
|
646
|
+
const lightSummary = lightChanges > 0 ? `Light: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed` : "";
|
|
647
|
+
const darkSummary = darkChanges > 0 ? `Dark: ${diff.modifiedDark.length} modified, ${diff.addedDark.length} added, ${diff.removedDark.length} removed` : "";
|
|
648
|
+
diffSummary = [lightSummary, darkSummary].filter(Boolean).join(" | ");
|
|
644
649
|
}
|
|
645
650
|
const outputDir = path.dirname(outputPath);
|
|
646
651
|
if (!fs.existsSync(outputDir)) {
|
|
@@ -965,19 +970,33 @@ function findConfig() {
|
|
|
965
970
|
}
|
|
966
971
|
return null;
|
|
967
972
|
}
|
|
968
|
-
function generateCSSOutput(cssVariables) {
|
|
973
|
+
function generateCSSOutput(cssVariables, darkModeColors) {
|
|
969
974
|
const lines = [
|
|
970
975
|
"/* Atomix Design System Tokens",
|
|
971
976
|
" * Auto-generated - do not edit manually",
|
|
972
977
|
` * Synced: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
973
978
|
" */",
|
|
974
979
|
"",
|
|
980
|
+
"/* Light mode (default) */",
|
|
975
981
|
":root {"
|
|
976
982
|
];
|
|
977
983
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
978
984
|
lines.push(` ${key}: ${value};`);
|
|
979
985
|
}
|
|
980
986
|
lines.push("}");
|
|
987
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
988
|
+
lines.push("");
|
|
989
|
+
lines.push("/* Dark mode */");
|
|
990
|
+
lines.push(".dark,");
|
|
991
|
+
lines.push('[data-theme="dark"] {');
|
|
992
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
993
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
994
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
995
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
996
|
+
lines.push(` ${prefix}color-${key}: ${value};`);
|
|
997
|
+
}
|
|
998
|
+
lines.push("}");
|
|
999
|
+
}
|
|
981
1000
|
lines.push("");
|
|
982
1001
|
return lines.join("\n");
|
|
983
1002
|
}
|
|
@@ -1347,31 +1366,75 @@ function generateDartOutput(cssVariables) {
|
|
|
1347
1366
|
lines.push("");
|
|
1348
1367
|
return lines.join("\n");
|
|
1349
1368
|
}
|
|
1350
|
-
function diffTokens(oldContent, newCssVars, format) {
|
|
1369
|
+
function diffTokens(oldContent, newCssVars, format, newDarkVars) {
|
|
1351
1370
|
const added = [];
|
|
1352
1371
|
const modified = [];
|
|
1353
1372
|
const removed = [];
|
|
1373
|
+
const addedDark = [];
|
|
1374
|
+
const modifiedDark = [];
|
|
1375
|
+
const removedDark = [];
|
|
1354
1376
|
if (format === "css" || format === "scss" || format === "less") {
|
|
1355
|
-
const
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1377
|
+
const rootMatch = oldContent.match(/:root\s*\{([^}]*)\}/);
|
|
1378
|
+
const darkMatch = oldContent.match(/\.dark[^{]*\{([^}]*)\}/);
|
|
1379
|
+
const oldLightVars = {};
|
|
1380
|
+
if (rootMatch) {
|
|
1381
|
+
const rootContent = rootMatch[1];
|
|
1382
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1383
|
+
let match;
|
|
1384
|
+
while ((match = varRegex.exec(rootContent)) !== null) {
|
|
1385
|
+
oldLightVars[match[1]] = match[2].trim();
|
|
1386
|
+
}
|
|
1387
|
+
} else {
|
|
1388
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1389
|
+
let match;
|
|
1390
|
+
while ((match = varRegex.exec(oldContent)) !== null) {
|
|
1391
|
+
if (!(match[1] in oldLightVars)) {
|
|
1392
|
+
oldLightVars[match[1]] = match[2].trim();
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
const oldDarkVars = {};
|
|
1397
|
+
if (darkMatch) {
|
|
1398
|
+
const darkContent = darkMatch[1];
|
|
1399
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1400
|
+
let match;
|
|
1401
|
+
while ((match = varRegex.exec(darkContent)) !== null) {
|
|
1402
|
+
oldDarkVars[match[1]] = match[2].trim();
|
|
1403
|
+
}
|
|
1360
1404
|
}
|
|
1361
1405
|
for (const [key, value] of Object.entries(newCssVars)) {
|
|
1362
|
-
if (!(key in
|
|
1406
|
+
if (!(key in oldLightVars)) {
|
|
1363
1407
|
added.push(key);
|
|
1364
|
-
} else if (
|
|
1365
|
-
modified.push({ key, old:
|
|
1408
|
+
} else if (oldLightVars[key] !== value) {
|
|
1409
|
+
modified.push({ key, old: oldLightVars[key], new: value });
|
|
1366
1410
|
}
|
|
1367
1411
|
}
|
|
1368
|
-
for (const key of Object.keys(
|
|
1412
|
+
for (const key of Object.keys(oldLightVars)) {
|
|
1369
1413
|
if (!(key in newCssVars)) {
|
|
1370
1414
|
removed.push(key);
|
|
1371
1415
|
}
|
|
1372
1416
|
}
|
|
1417
|
+
if (newDarkVars && Object.keys(newDarkVars).length > 0) {
|
|
1418
|
+
const firstKey = Object.keys(newCssVars)[0] || "--atmx-";
|
|
1419
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
1420
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
1421
|
+
for (const [key, value] of Object.entries(newDarkVars)) {
|
|
1422
|
+
const cssVarName = `${prefix}color-${key}`;
|
|
1423
|
+
if (!(cssVarName in oldDarkVars)) {
|
|
1424
|
+
addedDark.push(cssVarName);
|
|
1425
|
+
} else if (oldDarkVars[cssVarName] !== value) {
|
|
1426
|
+
modifiedDark.push({ key: cssVarName, old: oldDarkVars[cssVarName], new: value });
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
for (const key of Object.keys(oldDarkVars)) {
|
|
1430
|
+
const shortKey = key.replace(new RegExp(`^${prefix}color-`), "");
|
|
1431
|
+
if (!(shortKey in newDarkVars)) {
|
|
1432
|
+
removedDark.push(key);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1373
1436
|
}
|
|
1374
|
-
return { added, modified, removed };
|
|
1437
|
+
return { added, modified, removed, addedDark, modifiedDark, removedDark };
|
|
1375
1438
|
}
|
|
1376
1439
|
async function promptConfirm(message) {
|
|
1377
1440
|
const rl = readline.createInterface({
|
|
@@ -1427,10 +1490,11 @@ async function runSync() {
|
|
|
1427
1490
|
}
|
|
1428
1491
|
console.log(` Design System: ${data.meta.name} (v${data.meta.version})`);
|
|
1429
1492
|
console.log("");
|
|
1493
|
+
const darkModeColors = data.tokens?.colors?.modes;
|
|
1430
1494
|
let newContent;
|
|
1431
1495
|
switch (effectiveFormat) {
|
|
1432
1496
|
case "css":
|
|
1433
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
1497
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
1434
1498
|
break;
|
|
1435
1499
|
case "scss":
|
|
1436
1500
|
newContent = generateSCSSOutput(data.cssVariables);
|
|
@@ -1457,7 +1521,7 @@ async function runSync() {
|
|
|
1457
1521
|
newContent = generateDartOutput(data.cssVariables);
|
|
1458
1522
|
break;
|
|
1459
1523
|
default:
|
|
1460
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
1524
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
1461
1525
|
break;
|
|
1462
1526
|
}
|
|
1463
1527
|
const outputPath = path.resolve(process.cwd(), effectiveOutput);
|
|
@@ -1465,8 +1529,10 @@ async function runSync() {
|
|
|
1465
1529
|
const supportsDiff = ["css", "scss", "less"].includes(effectiveFormat);
|
|
1466
1530
|
if (fileExists && supportsDiff) {
|
|
1467
1531
|
const oldContent = fs.readFileSync(outputPath, "utf-8");
|
|
1468
|
-
const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat);
|
|
1469
|
-
const
|
|
1532
|
+
const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat, darkModeColors?.dark);
|
|
1533
|
+
const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;
|
|
1534
|
+
const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;
|
|
1535
|
+
const totalChanges = lightChanges + darkChanges;
|
|
1470
1536
|
if (totalChanges === 0) {
|
|
1471
1537
|
console.log(" \u2713 Already up to date!");
|
|
1472
1538
|
console.log("");
|
|
@@ -1474,21 +1540,41 @@ async function runSync() {
|
|
|
1474
1540
|
}
|
|
1475
1541
|
console.log(` Changes detected in ${path.basename(effectiveOutput)}:`);
|
|
1476
1542
|
console.log("");
|
|
1477
|
-
if (
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1543
|
+
if (lightChanges > 0) {
|
|
1544
|
+
console.log(" Light Mode:");
|
|
1545
|
+
if (diff.modified.length > 0) {
|
|
1546
|
+
for (const { key, old: oldVal, new: newVal } of diff.modified) {
|
|
1547
|
+
console.log(` ${key}`);
|
|
1548
|
+
console.log(` - ${oldVal}`);
|
|
1549
|
+
console.log(` + ${newVal}`);
|
|
1550
|
+
}
|
|
1482
1551
|
}
|
|
1552
|
+
if (diff.added.length > 0) {
|
|
1553
|
+
console.log(` + ${diff.added.length} new token(s)`);
|
|
1554
|
+
}
|
|
1555
|
+
if (diff.removed.length > 0) {
|
|
1556
|
+
console.log(` - ${diff.removed.length} removed token(s)`);
|
|
1557
|
+
}
|
|
1558
|
+
console.log("");
|
|
1483
1559
|
}
|
|
1484
|
-
if (
|
|
1485
|
-
console.log(
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1560
|
+
if (darkChanges > 0) {
|
|
1561
|
+
console.log(" Dark Mode:");
|
|
1562
|
+
if (diff.modifiedDark.length > 0) {
|
|
1563
|
+
for (const { key, old: oldVal, new: newVal } of diff.modifiedDark) {
|
|
1564
|
+
console.log(` ${key}`);
|
|
1565
|
+
console.log(` - ${oldVal}`);
|
|
1566
|
+
console.log(` + ${newVal}`);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
if (diff.addedDark.length > 0) {
|
|
1570
|
+
console.log(` + ${diff.addedDark.length} new token(s)`);
|
|
1571
|
+
}
|
|
1572
|
+
if (diff.removedDark.length > 0) {
|
|
1573
|
+
console.log(` - ${diff.removedDark.length} removed token(s)`);
|
|
1574
|
+
}
|
|
1575
|
+
console.log("");
|
|
1489
1576
|
}
|
|
1490
|
-
console.log(
|
|
1491
|
-
console.log(` Total: ${totalChanges} change(s)`);
|
|
1577
|
+
console.log(` Total: ${totalChanges} change(s) (Light: ${lightChanges}, Dark: ${darkChanges})`);
|
|
1492
1578
|
console.log("");
|
|
1493
1579
|
if (!cliArgs.yes) {
|
|
1494
1580
|
const confirmed = await promptConfirm(" Apply changes?");
|
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}\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\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 }\n }\n\n return { command, dsId, apiKey, apiBase, output, format, exclude, yes };\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 let newContent: string;\n switch (format) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables);\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);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables);\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);\n \n const totalChanges = diff.added.length + diff.modified.length + diff.removed.length;\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;\n diffSummary = `Changes: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed`;\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(cssVariables: Record<string, string>): string {\n const lines = [\n \"/* Atomix Design System Tokens\",\n \" * Auto-generated - do not edit manually\",\n ` * Synced: ${new Date().toISOString()}`,\n \" */\",\n \"\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\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(cssVariables: Record<string, string>): 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 \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n lines.push(\"\");\n lines.push(\"// SCSS Variables (for use in SCSS)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n // Convert --atmx-color-brand-primary to $atmx-color-brand-primary\n const scssVar = \"$\" + key.replace(/^--/, \"\");\n lines.push(`${scssVar}: ${value};`);\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateLessOutput(cssVariables: Record<string, string>): 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 \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n lines.push(\"\");\n lines.push(\"// Less Variables (for use in Less)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n // Convert --atmx-color-brand-primary to @atmx-color-brand-primary\n const lessVar = \"@\" + key.replace(/^--/, \"\");\n lines.push(`${lessVar}: ${value};`);\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(cssVariables: Record<string, string>): 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\",\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 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(cssVariables: Record<string, string>): 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 \" 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 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(cssVariables: Record<string, string>): 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\"\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 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): { added: string[]; modified: Array<{ key: string; old: string; new: string }>; removed: string[] } {\n const added: string[] = [];\n const modified: Array<{ key: string; old: string; new: string }> = [];\n const removed: string[] = [];\n\n // CSS-based formats (css, scss, less) all use CSS variables\n if (format === \"css\" || format === \"scss\" || format === \"less\") {\n // Parse old CSS variables\n const oldVars: Record<string, string> = {};\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(oldContent)) !== null) {\n oldVars[match[1]] = match[2].trim();\n }\n\n // Compare\n for (const [key, value] of Object.entries(newCssVars)) {\n if (!(key in oldVars)) {\n added.push(key);\n } else if (oldVars[key] !== value) {\n modified.push({ key, old: oldVars[key], new: value });\n }\n }\n\n for (const key of Object.keys(oldVars)) {\n if (!(key in newCssVars)) {\n removed.push(key);\n }\n }\n }\n\n return { added, modified, removed };\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 let newContent: string;\n switch (effectiveFormat) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables);\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);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables);\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);\n\n const totalChanges = diff.added.length + diff.modified.length + diff.removed.length;\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 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\n if (diff.added.length > 0) {\n console.log(` + ${diff.added.length} new token(s)`);\n }\n\n if (diff.removed.length > 0) {\n console.log(` - ${diff.removed.length} removed token(s)`);\n }\n\n console.log(\"\");\n console.log(` Total: ${totalChanges} change(s)`);\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 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 --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;AA6nCP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AAxkC1B,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;AAGV,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;AACjD,MAAAC,UAAS,KAAK,IAAI,CAAC;AACnB;AAAA,IACF,WAAW,KAAK,CAAC,MAAM,gBAAgB,KAAK,IAAI,CAAC,GAAG;AAClD,MAAAC,WAAU,KAAK,IAAI,CAAC;AACpB;AAAA,IACF,YAAY,KAAK,CAAC,MAAM,cAAc,KAAK,CAAC,MAAM,SAAS,KAAK,IAAI,CA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAyDb;AACD;AAMA,eAAe,cAAc;AAC3B,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,iCAAiC;AAC/C,YAAQ,MAAM,gDAAgD;AAC9D,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,0CAA0C;AACxD,YAAQ,MAAM,6DAA6D;AAC3E,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAG9B,UAAQ,MAAM,gDAAgD,IAAI,EAAE;AACtE;AAEA,eAAe,OAAO;AACpB,UAAQ,QAAQ,SAAS;AAAA,IACvB,KAAK;AACH,YAAM,QAAQ;AACd;AAAA,IACF,KAAK;AACH,YAAM,QAAQ;AACd;AAAA,IACF,KAAK;AACH,eAAS;AACT;AAAA,IACF,KAAK;AAAA,IACL;AACE,YAAM,YAAY;AAClB;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","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}\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\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 }\n }\n\n return { command, dsId, apiKey, apiBase, output, format, exclude, yes };\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);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables);\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);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables);\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(cssVariables: Record<string, string>): 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 \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n lines.push(\"\");\n lines.push(\"// SCSS Variables (for use in SCSS)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n // Convert --atmx-color-brand-primary to $atmx-color-brand-primary\n const scssVar = \"$\" + key.replace(/^--/, \"\");\n lines.push(`${scssVar}: ${value};`);\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateLessOutput(cssVariables: Record<string, string>): 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 \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n lines.push(\"\");\n lines.push(\"// Less Variables (for use in Less)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n // Convert --atmx-color-brand-primary to @atmx-color-brand-primary\n const lessVar = \"@\" + key.replace(/^--/, \"\");\n lines.push(`${lessVar}: ${value};`);\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(cssVariables: Record<string, string>): 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\",\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 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(cssVariables: Record<string, string>): 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 \" 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 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(cssVariables: Record<string, string>): 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\"\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 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);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables);\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);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables);\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 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 --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;AAwoCP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AAnlC1B,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;AAGV,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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