@atomixstudio/mcp 1.0.3 → 1.0.5
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 +281 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,6 +24,8 @@ function parseArgs() {
|
|
|
24
24
|
let format = null;
|
|
25
25
|
let exclude = [];
|
|
26
26
|
let yes = false;
|
|
27
|
+
let rules = false;
|
|
28
|
+
let rulesDir = null;
|
|
27
29
|
if (args[0] && !args[0].startsWith("-")) {
|
|
28
30
|
const cmd = args[0].toLowerCase();
|
|
29
31
|
if (cmd === "sync") command = "sync";
|
|
@@ -53,9 +55,15 @@ function parseArgs() {
|
|
|
53
55
|
i++;
|
|
54
56
|
} else if (args[i] === "-y" || args[i] === "--yes") {
|
|
55
57
|
yes = true;
|
|
58
|
+
} else if (args[i] === "--rules" || args[i] === "-r") {
|
|
59
|
+
rules = true;
|
|
60
|
+
} else if (args[i] === "--rules-dir" && args[i + 1]) {
|
|
61
|
+
rulesDir = args[i + 1];
|
|
62
|
+
rules = true;
|
|
63
|
+
i++;
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
|
-
return { command, dsId: dsId2, apiKey: apiKey2, apiBase: apiBase2, output, format, exclude, yes };
|
|
66
|
+
return { command, dsId: dsId2, apiKey: apiKey2, apiBase: apiBase2, output, format, exclude, yes, rules, rulesDir };
|
|
59
67
|
}
|
|
60
68
|
var cliArgs = parseArgs();
|
|
61
69
|
var { dsId, apiKey } = cliArgs;
|
|
@@ -586,16 +594,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
586
594
|
}]
|
|
587
595
|
};
|
|
588
596
|
}
|
|
597
|
+
const darkModeColors = data.tokens?.colors?.modes;
|
|
589
598
|
let newContent;
|
|
590
599
|
switch (format) {
|
|
591
600
|
case "css":
|
|
592
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
601
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
593
602
|
break;
|
|
594
603
|
case "scss":
|
|
595
|
-
newContent = generateSCSSOutput(data.cssVariables);
|
|
604
|
+
newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
596
605
|
break;
|
|
597
606
|
case "less":
|
|
598
|
-
newContent = generateLessOutput(data.cssVariables);
|
|
607
|
+
newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);
|
|
599
608
|
break;
|
|
600
609
|
case "json":
|
|
601
610
|
newContent = generateJSONOutput(data.tokens);
|
|
@@ -607,16 +616,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
607
616
|
newContent = generateTSOutput(data.tokens);
|
|
608
617
|
break;
|
|
609
618
|
case "swift":
|
|
610
|
-
newContent = generateSwiftOutput(data.cssVariables);
|
|
619
|
+
newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);
|
|
611
620
|
break;
|
|
612
621
|
case "kotlin":
|
|
613
|
-
newContent = generateKotlinOutput(data.cssVariables);
|
|
622
|
+
newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);
|
|
614
623
|
break;
|
|
615
624
|
case "dart":
|
|
616
|
-
newContent = generateDartOutput(data.cssVariables);
|
|
625
|
+
newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);
|
|
617
626
|
break;
|
|
618
627
|
default:
|
|
619
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
628
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
620
629
|
}
|
|
621
630
|
const outputPath = path.resolve(process.cwd(), output);
|
|
622
631
|
const fileExists = fs.existsSync(outputPath);
|
|
@@ -625,8 +634,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
625
634
|
let changes = [];
|
|
626
635
|
if (fileExists && ["css", "scss", "less"].includes(format)) {
|
|
627
636
|
const oldContent = fs.readFileSync(outputPath, "utf-8");
|
|
628
|
-
const diff = diffTokens(oldContent, data.cssVariables, format);
|
|
629
|
-
const
|
|
637
|
+
const diff = diffTokens(oldContent, data.cssVariables, format, darkModeColors?.dark);
|
|
638
|
+
const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;
|
|
639
|
+
const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;
|
|
640
|
+
const totalChanges = lightChanges + darkChanges;
|
|
630
641
|
if (totalChanges === 0) {
|
|
631
642
|
return {
|
|
632
643
|
content: [{
|
|
@@ -639,8 +650,10 @@ Version: ${data.meta.version}`
|
|
|
639
650
|
}]
|
|
640
651
|
};
|
|
641
652
|
}
|
|
642
|
-
changes = diff.modified;
|
|
643
|
-
|
|
653
|
+
changes = [...diff.modified, ...diff.modifiedDark];
|
|
654
|
+
const lightSummary = lightChanges > 0 ? `Light: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed` : "";
|
|
655
|
+
const darkSummary = darkChanges > 0 ? `Dark: ${diff.modifiedDark.length} modified, ${diff.addedDark.length} added, ${diff.removedDark.length} removed` : "";
|
|
656
|
+
diffSummary = [lightSummary, darkSummary].filter(Boolean).join(" | ");
|
|
644
657
|
}
|
|
645
658
|
const outputDir = path.dirname(outputPath);
|
|
646
659
|
if (!fs.existsSync(outputDir)) {
|
|
@@ -965,19 +978,33 @@ function findConfig() {
|
|
|
965
978
|
}
|
|
966
979
|
return null;
|
|
967
980
|
}
|
|
968
|
-
function generateCSSOutput(cssVariables) {
|
|
981
|
+
function generateCSSOutput(cssVariables, darkModeColors) {
|
|
969
982
|
const lines = [
|
|
970
983
|
"/* Atomix Design System Tokens",
|
|
971
984
|
" * Auto-generated - do not edit manually",
|
|
972
985
|
` * Synced: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
973
986
|
" */",
|
|
974
987
|
"",
|
|
988
|
+
"/* Light mode (default) */",
|
|
975
989
|
":root {"
|
|
976
990
|
];
|
|
977
991
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
978
992
|
lines.push(` ${key}: ${value};`);
|
|
979
993
|
}
|
|
980
994
|
lines.push("}");
|
|
995
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
996
|
+
lines.push("");
|
|
997
|
+
lines.push("/* Dark mode */");
|
|
998
|
+
lines.push(".dark,");
|
|
999
|
+
lines.push('[data-theme="dark"] {');
|
|
1000
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
1001
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
1002
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
1003
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1004
|
+
lines.push(` ${prefix}color-${key}: ${value};`);
|
|
1005
|
+
}
|
|
1006
|
+
lines.push("}");
|
|
1007
|
+
}
|
|
981
1008
|
lines.push("");
|
|
982
1009
|
return lines.join("\n");
|
|
983
1010
|
}
|
|
@@ -1002,47 +1029,97 @@ function generateJSOutput(tokens) {
|
|
|
1002
1029
|
export const tokens = ${JSON.stringify(tokens, null, 2)};
|
|
1003
1030
|
`;
|
|
1004
1031
|
}
|
|
1005
|
-
function generateSCSSOutput(cssVariables) {
|
|
1032
|
+
function generateSCSSOutput(cssVariables, darkModeColors) {
|
|
1006
1033
|
const lines = [
|
|
1007
1034
|
"// Atomix Design System Tokens",
|
|
1008
1035
|
"// Auto-generated - do not edit manually",
|
|
1009
1036
|
`// Synced: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
1010
1037
|
"",
|
|
1011
1038
|
"// CSS Custom Properties (for use in CSS/HTML)",
|
|
1039
|
+
"// Light mode (default)",
|
|
1012
1040
|
":root {"
|
|
1013
1041
|
];
|
|
1014
1042
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
1015
1043
|
lines.push(` ${key}: ${value};`);
|
|
1016
1044
|
}
|
|
1017
1045
|
lines.push("}");
|
|
1046
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1047
|
+
lines.push("");
|
|
1048
|
+
lines.push("// Dark mode");
|
|
1049
|
+
lines.push(".dark,");
|
|
1050
|
+
lines.push('[data-theme="dark"] {');
|
|
1051
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
1052
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
1053
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
1054
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1055
|
+
lines.push(` ${prefix}color-${key}: ${value};`);
|
|
1056
|
+
}
|
|
1057
|
+
lines.push("}");
|
|
1058
|
+
}
|
|
1018
1059
|
lines.push("");
|
|
1019
|
-
lines.push("// SCSS Variables (
|
|
1060
|
+
lines.push("// SCSS Variables (light mode values)");
|
|
1020
1061
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
1021
1062
|
const scssVar = "$" + key.replace(/^--/, "");
|
|
1022
1063
|
lines.push(`${scssVar}: ${value};`);
|
|
1023
1064
|
}
|
|
1065
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1066
|
+
lines.push("");
|
|
1067
|
+
lines.push("// SCSS Variables (dark mode values)");
|
|
1068
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
1069
|
+
const prefixMatch = firstKey.match(/^--([a-z]+)-/);
|
|
1070
|
+
const prefix = prefixMatch ? prefixMatch[1] : "atmx";
|
|
1071
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1072
|
+
const scssVar = `$${prefix}-color-${key}-dark`;
|
|
1073
|
+
lines.push(`${scssVar}: ${value};`);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1024
1076
|
lines.push("");
|
|
1025
1077
|
return lines.join("\n");
|
|
1026
1078
|
}
|
|
1027
|
-
function generateLessOutput(cssVariables) {
|
|
1079
|
+
function generateLessOutput(cssVariables, darkModeColors) {
|
|
1028
1080
|
const lines = [
|
|
1029
1081
|
"// Atomix Design System Tokens",
|
|
1030
1082
|
"// Auto-generated - do not edit manually",
|
|
1031
1083
|
`// Synced: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
1032
1084
|
"",
|
|
1033
1085
|
"// CSS Custom Properties (for use in CSS/HTML)",
|
|
1086
|
+
"// Light mode (default)",
|
|
1034
1087
|
":root {"
|
|
1035
1088
|
];
|
|
1036
1089
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
1037
1090
|
lines.push(` ${key}: ${value};`);
|
|
1038
1091
|
}
|
|
1039
1092
|
lines.push("}");
|
|
1093
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1094
|
+
lines.push("");
|
|
1095
|
+
lines.push("// Dark mode");
|
|
1096
|
+
lines.push(".dark,");
|
|
1097
|
+
lines.push('[data-theme="dark"] {');
|
|
1098
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
1099
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
1100
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
1101
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1102
|
+
lines.push(` ${prefix}color-${key}: ${value};`);
|
|
1103
|
+
}
|
|
1104
|
+
lines.push("}");
|
|
1105
|
+
}
|
|
1040
1106
|
lines.push("");
|
|
1041
|
-
lines.push("// Less Variables (
|
|
1107
|
+
lines.push("// Less Variables (light mode values)");
|
|
1042
1108
|
for (const [key, value] of Object.entries(cssVariables)) {
|
|
1043
1109
|
const lessVar = "@" + key.replace(/^--/, "");
|
|
1044
1110
|
lines.push(`${lessVar}: ${value};`);
|
|
1045
1111
|
}
|
|
1112
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1113
|
+
lines.push("");
|
|
1114
|
+
lines.push("// Less Variables (dark mode values)");
|
|
1115
|
+
const firstKey = Object.keys(cssVariables)[0] || "--atmx-";
|
|
1116
|
+
const prefixMatch = firstKey.match(/^--([a-z]+)-/);
|
|
1117
|
+
const prefix = prefixMatch ? prefixMatch[1] : "atmx";
|
|
1118
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1119
|
+
const lessVar = `@${prefix}-color-${key}-dark`;
|
|
1120
|
+
lines.push(`${lessVar}: ${value};`);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1046
1123
|
lines.push("");
|
|
1047
1124
|
return lines.join("\n");
|
|
1048
1125
|
}
|
|
@@ -1107,7 +1184,7 @@ function hexToDartColor(hex) {
|
|
|
1107
1184
|
}
|
|
1108
1185
|
return `Colors.transparent // Could not parse: ${hex}`;
|
|
1109
1186
|
}
|
|
1110
|
-
function generateSwiftOutput(cssVariables) {
|
|
1187
|
+
function generateSwiftOutput(cssVariables, darkModeColors) {
|
|
1111
1188
|
const lines = [
|
|
1112
1189
|
"// Atomix Design System Tokens",
|
|
1113
1190
|
"// Auto-generated - do not edit manually",
|
|
@@ -1131,7 +1208,7 @@ function generateSwiftOutput(cssVariables) {
|
|
|
1131
1208
|
"// MARK: - Design Tokens",
|
|
1132
1209
|
"enum DesignTokens {",
|
|
1133
1210
|
"",
|
|
1134
|
-
" // MARK: Colors",
|
|
1211
|
+
" // MARK: Colors (Light Mode)",
|
|
1135
1212
|
" enum Colors {"
|
|
1136
1213
|
];
|
|
1137
1214
|
const colors = [];
|
|
@@ -1151,6 +1228,18 @@ function generateSwiftOutput(cssVariables) {
|
|
|
1151
1228
|
}
|
|
1152
1229
|
}
|
|
1153
1230
|
lines.push(" }");
|
|
1231
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1232
|
+
lines.push("");
|
|
1233
|
+
lines.push(" // MARK: Colors (Dark Mode)");
|
|
1234
|
+
lines.push(" enum ColorsDark {");
|
|
1235
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1236
|
+
const name = `color${key.split("-").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")}`;
|
|
1237
|
+
if (isColorValue(value)) {
|
|
1238
|
+
lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
lines.push(" }");
|
|
1242
|
+
}
|
|
1154
1243
|
lines.push("");
|
|
1155
1244
|
lines.push(" // MARK: Spacing");
|
|
1156
1245
|
lines.push(" enum Spacing {");
|
|
@@ -1200,7 +1289,7 @@ function generateSwiftOutput(cssVariables) {
|
|
|
1200
1289
|
lines.push("");
|
|
1201
1290
|
return lines.join("\n");
|
|
1202
1291
|
}
|
|
1203
|
-
function generateKotlinOutput(cssVariables) {
|
|
1292
|
+
function generateKotlinOutput(cssVariables, darkModeColors) {
|
|
1204
1293
|
const lines = [
|
|
1205
1294
|
"// Atomix Design System Tokens",
|
|
1206
1295
|
"// Auto-generated - do not edit manually",
|
|
@@ -1214,6 +1303,7 @@ function generateKotlinOutput(cssVariables) {
|
|
|
1214
1303
|
"",
|
|
1215
1304
|
"object DesignTokens {",
|
|
1216
1305
|
"",
|
|
1306
|
+
" // Light mode colors",
|
|
1217
1307
|
" object Colors {"
|
|
1218
1308
|
];
|
|
1219
1309
|
const colors = [];
|
|
@@ -1233,6 +1323,18 @@ function generateKotlinOutput(cssVariables) {
|
|
|
1233
1323
|
}
|
|
1234
1324
|
}
|
|
1235
1325
|
lines.push(" }");
|
|
1326
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1327
|
+
lines.push("");
|
|
1328
|
+
lines.push(" // Dark mode colors");
|
|
1329
|
+
lines.push(" object ColorsDark {");
|
|
1330
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1331
|
+
const name = `Color${key.split("-").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")}`;
|
|
1332
|
+
if (isColorValue(value)) {
|
|
1333
|
+
lines.push(` val ${name} = ${hexToKotlinColor(value)}`);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
lines.push(" }");
|
|
1337
|
+
}
|
|
1236
1338
|
lines.push("");
|
|
1237
1339
|
lines.push(" object Spacing {");
|
|
1238
1340
|
for (const [key, value] of spacing) {
|
|
@@ -1277,7 +1379,7 @@ function generateKotlinOutput(cssVariables) {
|
|
|
1277
1379
|
lines.push("");
|
|
1278
1380
|
return lines.join("\n");
|
|
1279
1381
|
}
|
|
1280
|
-
function generateDartOutput(cssVariables) {
|
|
1382
|
+
function generateDartOutput(cssVariables, darkModeColors) {
|
|
1281
1383
|
const lines = [
|
|
1282
1384
|
"// Atomix Design System Tokens",
|
|
1283
1385
|
"// Auto-generated - do not edit manually",
|
|
@@ -1288,7 +1390,7 @@ function generateDartOutput(cssVariables) {
|
|
|
1288
1390
|
"class DesignTokens {",
|
|
1289
1391
|
" DesignTokens._();",
|
|
1290
1392
|
"",
|
|
1291
|
-
" // Colors"
|
|
1393
|
+
" // Colors (Light Mode)"
|
|
1292
1394
|
];
|
|
1293
1395
|
const colors = [];
|
|
1294
1396
|
const spacing = [];
|
|
@@ -1306,6 +1408,16 @@ function generateDartOutput(cssVariables) {
|
|
|
1306
1408
|
lines.push(` static const ${name} = ${hexToDartColor(value)};`);
|
|
1307
1409
|
}
|
|
1308
1410
|
}
|
|
1411
|
+
if (darkModeColors && Object.keys(darkModeColors).length > 0) {
|
|
1412
|
+
lines.push("");
|
|
1413
|
+
lines.push(" // Colors (Dark Mode)");
|
|
1414
|
+
for (const [key, value] of Object.entries(darkModeColors)) {
|
|
1415
|
+
const name = `color${key.split("-").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")}Dark`;
|
|
1416
|
+
if (isColorValue(value)) {
|
|
1417
|
+
lines.push(` static const ${name} = ${hexToDartColor(value)};`);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1309
1421
|
lines.push("");
|
|
1310
1422
|
lines.push(" // Spacing");
|
|
1311
1423
|
for (const [key, value] of spacing) {
|
|
@@ -1347,31 +1459,75 @@ function generateDartOutput(cssVariables) {
|
|
|
1347
1459
|
lines.push("");
|
|
1348
1460
|
return lines.join("\n");
|
|
1349
1461
|
}
|
|
1350
|
-
function diffTokens(oldContent, newCssVars, format) {
|
|
1462
|
+
function diffTokens(oldContent, newCssVars, format, newDarkVars) {
|
|
1351
1463
|
const added = [];
|
|
1352
1464
|
const modified = [];
|
|
1353
1465
|
const removed = [];
|
|
1466
|
+
const addedDark = [];
|
|
1467
|
+
const modifiedDark = [];
|
|
1468
|
+
const removedDark = [];
|
|
1354
1469
|
if (format === "css" || format === "scss" || format === "less") {
|
|
1355
|
-
const
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1470
|
+
const rootMatch = oldContent.match(/:root\s*\{([^}]*)\}/);
|
|
1471
|
+
const darkMatch = oldContent.match(/\.dark[^{]*\{([^}]*)\}/);
|
|
1472
|
+
const oldLightVars = {};
|
|
1473
|
+
if (rootMatch) {
|
|
1474
|
+
const rootContent = rootMatch[1];
|
|
1475
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1476
|
+
let match;
|
|
1477
|
+
while ((match = varRegex.exec(rootContent)) !== null) {
|
|
1478
|
+
oldLightVars[match[1]] = match[2].trim();
|
|
1479
|
+
}
|
|
1480
|
+
} else {
|
|
1481
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1482
|
+
let match;
|
|
1483
|
+
while ((match = varRegex.exec(oldContent)) !== null) {
|
|
1484
|
+
if (!(match[1] in oldLightVars)) {
|
|
1485
|
+
oldLightVars[match[1]] = match[2].trim();
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
const oldDarkVars = {};
|
|
1490
|
+
if (darkMatch) {
|
|
1491
|
+
const darkContent = darkMatch[1];
|
|
1492
|
+
const varRegex = /(--[\w-]+):\s*([^;]+);/g;
|
|
1493
|
+
let match;
|
|
1494
|
+
while ((match = varRegex.exec(darkContent)) !== null) {
|
|
1495
|
+
oldDarkVars[match[1]] = match[2].trim();
|
|
1496
|
+
}
|
|
1360
1497
|
}
|
|
1361
1498
|
for (const [key, value] of Object.entries(newCssVars)) {
|
|
1362
|
-
if (!(key in
|
|
1499
|
+
if (!(key in oldLightVars)) {
|
|
1363
1500
|
added.push(key);
|
|
1364
|
-
} else if (
|
|
1365
|
-
modified.push({ key, old:
|
|
1501
|
+
} else if (oldLightVars[key] !== value) {
|
|
1502
|
+
modified.push({ key, old: oldLightVars[key], new: value });
|
|
1366
1503
|
}
|
|
1367
1504
|
}
|
|
1368
|
-
for (const key of Object.keys(
|
|
1505
|
+
for (const key of Object.keys(oldLightVars)) {
|
|
1369
1506
|
if (!(key in newCssVars)) {
|
|
1370
1507
|
removed.push(key);
|
|
1371
1508
|
}
|
|
1372
1509
|
}
|
|
1510
|
+
if (newDarkVars && Object.keys(newDarkVars).length > 0) {
|
|
1511
|
+
const firstKey = Object.keys(newCssVars)[0] || "--atmx-";
|
|
1512
|
+
const prefixMatch = firstKey.match(/^(--[a-z]+-)/);
|
|
1513
|
+
const prefix = prefixMatch ? prefixMatch[1] : "--atmx-";
|
|
1514
|
+
for (const [key, value] of Object.entries(newDarkVars)) {
|
|
1515
|
+
const cssVarName = `${prefix}color-${key}`;
|
|
1516
|
+
if (!(cssVarName in oldDarkVars)) {
|
|
1517
|
+
addedDark.push(cssVarName);
|
|
1518
|
+
} else if (oldDarkVars[cssVarName] !== value) {
|
|
1519
|
+
modifiedDark.push({ key: cssVarName, old: oldDarkVars[cssVarName], new: value });
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
for (const key of Object.keys(oldDarkVars)) {
|
|
1523
|
+
const shortKey = key.replace(new RegExp(`^${prefix}color-`), "");
|
|
1524
|
+
if (!(shortKey in newDarkVars)) {
|
|
1525
|
+
removedDark.push(key);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1373
1529
|
}
|
|
1374
|
-
return { added, modified, removed };
|
|
1530
|
+
return { added, modified, removed, addedDark, modifiedDark, removedDark };
|
|
1375
1531
|
}
|
|
1376
1532
|
async function promptConfirm(message) {
|
|
1377
1533
|
const rl = readline.createInterface({
|
|
@@ -1427,16 +1583,17 @@ async function runSync() {
|
|
|
1427
1583
|
}
|
|
1428
1584
|
console.log(` Design System: ${data.meta.name} (v${data.meta.version})`);
|
|
1429
1585
|
console.log("");
|
|
1586
|
+
const darkModeColors = data.tokens?.colors?.modes;
|
|
1430
1587
|
let newContent;
|
|
1431
1588
|
switch (effectiveFormat) {
|
|
1432
1589
|
case "css":
|
|
1433
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
1590
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
1434
1591
|
break;
|
|
1435
1592
|
case "scss":
|
|
1436
|
-
newContent = generateSCSSOutput(data.cssVariables);
|
|
1593
|
+
newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
1437
1594
|
break;
|
|
1438
1595
|
case "less":
|
|
1439
|
-
newContent = generateLessOutput(data.cssVariables);
|
|
1596
|
+
newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);
|
|
1440
1597
|
break;
|
|
1441
1598
|
case "json":
|
|
1442
1599
|
newContent = generateJSONOutput(data.tokens);
|
|
@@ -1448,16 +1605,16 @@ async function runSync() {
|
|
|
1448
1605
|
newContent = generateTSOutput(data.tokens);
|
|
1449
1606
|
break;
|
|
1450
1607
|
case "swift":
|
|
1451
|
-
newContent = generateSwiftOutput(data.cssVariables);
|
|
1608
|
+
newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);
|
|
1452
1609
|
break;
|
|
1453
1610
|
case "kotlin":
|
|
1454
|
-
newContent = generateKotlinOutput(data.cssVariables);
|
|
1611
|
+
newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);
|
|
1455
1612
|
break;
|
|
1456
1613
|
case "dart":
|
|
1457
|
-
newContent = generateDartOutput(data.cssVariables);
|
|
1614
|
+
newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);
|
|
1458
1615
|
break;
|
|
1459
1616
|
default:
|
|
1460
|
-
newContent = generateCSSOutput(data.cssVariables);
|
|
1617
|
+
newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);
|
|
1461
1618
|
break;
|
|
1462
1619
|
}
|
|
1463
1620
|
const outputPath = path.resolve(process.cwd(), effectiveOutput);
|
|
@@ -1465,8 +1622,10 @@ async function runSync() {
|
|
|
1465
1622
|
const supportsDiff = ["css", "scss", "less"].includes(effectiveFormat);
|
|
1466
1623
|
if (fileExists && supportsDiff) {
|
|
1467
1624
|
const oldContent = fs.readFileSync(outputPath, "utf-8");
|
|
1468
|
-
const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat);
|
|
1469
|
-
const
|
|
1625
|
+
const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat, darkModeColors?.dark);
|
|
1626
|
+
const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;
|
|
1627
|
+
const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;
|
|
1628
|
+
const totalChanges = lightChanges + darkChanges;
|
|
1470
1629
|
if (totalChanges === 0) {
|
|
1471
1630
|
console.log(" \u2713 Already up to date!");
|
|
1472
1631
|
console.log("");
|
|
@@ -1474,21 +1633,41 @@ async function runSync() {
|
|
|
1474
1633
|
}
|
|
1475
1634
|
console.log(` Changes detected in ${path.basename(effectiveOutput)}:`);
|
|
1476
1635
|
console.log("");
|
|
1477
|
-
if (
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1636
|
+
if (lightChanges > 0) {
|
|
1637
|
+
console.log(" Light Mode:");
|
|
1638
|
+
if (diff.modified.length > 0) {
|
|
1639
|
+
for (const { key, old: oldVal, new: newVal } of diff.modified) {
|
|
1640
|
+
console.log(` ${key}`);
|
|
1641
|
+
console.log(` - ${oldVal}`);
|
|
1642
|
+
console.log(` + ${newVal}`);
|
|
1643
|
+
}
|
|
1482
1644
|
}
|
|
1645
|
+
if (diff.added.length > 0) {
|
|
1646
|
+
console.log(` + ${diff.added.length} new token(s)`);
|
|
1647
|
+
}
|
|
1648
|
+
if (diff.removed.length > 0) {
|
|
1649
|
+
console.log(` - ${diff.removed.length} removed token(s)`);
|
|
1650
|
+
}
|
|
1651
|
+
console.log("");
|
|
1483
1652
|
}
|
|
1484
|
-
if (
|
|
1485
|
-
console.log(
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1653
|
+
if (darkChanges > 0) {
|
|
1654
|
+
console.log(" Dark Mode:");
|
|
1655
|
+
if (diff.modifiedDark.length > 0) {
|
|
1656
|
+
for (const { key, old: oldVal, new: newVal } of diff.modifiedDark) {
|
|
1657
|
+
console.log(` ${key}`);
|
|
1658
|
+
console.log(` - ${oldVal}`);
|
|
1659
|
+
console.log(` + ${newVal}`);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
if (diff.addedDark.length > 0) {
|
|
1663
|
+
console.log(` + ${diff.addedDark.length} new token(s)`);
|
|
1664
|
+
}
|
|
1665
|
+
if (diff.removedDark.length > 0) {
|
|
1666
|
+
console.log(` - ${diff.removedDark.length} removed token(s)`);
|
|
1667
|
+
}
|
|
1668
|
+
console.log("");
|
|
1489
1669
|
}
|
|
1490
|
-
console.log(
|
|
1491
|
-
console.log(` Total: ${totalChanges} change(s)`);
|
|
1670
|
+
console.log(` Total: ${totalChanges} change(s) (Light: ${lightChanges}, Dark: ${darkChanges})`);
|
|
1492
1671
|
console.log("");
|
|
1493
1672
|
if (!cliArgs.yes) {
|
|
1494
1673
|
const confirmed = await promptConfirm(" Apply changes?");
|
|
@@ -1516,6 +1695,52 @@ async function runSync() {
|
|
|
1516
1695
|
fs.writeFileSync(outputPath, newContent);
|
|
1517
1696
|
console.log("");
|
|
1518
1697
|
console.log(` \u2713 Updated ${effectiveOutput}`);
|
|
1698
|
+
if (cliArgs.rules) {
|
|
1699
|
+
console.log("");
|
|
1700
|
+
console.log(" Syncing AI rules files...");
|
|
1701
|
+
const rulesDir = cliArgs.rulesDir || process.cwd();
|
|
1702
|
+
const rulesDirResolved = path.resolve(process.cwd(), rulesDir);
|
|
1703
|
+
const toolsToSync = [
|
|
1704
|
+
{ tool: "cursor", filename: ".cursorrules" },
|
|
1705
|
+
{ tool: "windsurf", filename: ".windsurfrules" },
|
|
1706
|
+
{ tool: "cline", filename: ".clinerules" },
|
|
1707
|
+
{ tool: "continue", filename: ".continuerules" },
|
|
1708
|
+
{ tool: "copilot", filename: "copilot-instructions.md", dir: ".github" },
|
|
1709
|
+
{ tool: "generic", filename: "AI_GUIDELINES.md" }
|
|
1710
|
+
];
|
|
1711
|
+
const existingTools = toolsToSync.filter((t) => {
|
|
1712
|
+
const filePath = t.dir ? path.join(rulesDirResolved, t.dir, t.filename) : path.join(rulesDirResolved, t.filename);
|
|
1713
|
+
return fs.existsSync(filePath);
|
|
1714
|
+
});
|
|
1715
|
+
const toolsToWrite = existingTools.length > 0 ? existingTools : [{ tool: "cursor", filename: ".cursorrules" }];
|
|
1716
|
+
for (const { tool, filename, dir } of toolsToWrite) {
|
|
1717
|
+
try {
|
|
1718
|
+
const rulesUrl = `${effectiveApiBase}/api/ds/${effectiveDsId}/rules?format=${tool}`;
|
|
1719
|
+
const headers2 = { "Content-Type": "application/json" };
|
|
1720
|
+
if (effectiveApiKey) headers2["x-api-key"] = effectiveApiKey;
|
|
1721
|
+
const response = await fetch(rulesUrl, { headers: headers2 });
|
|
1722
|
+
if (!response.ok) {
|
|
1723
|
+
console.error(` \u2717 Failed to fetch ${tool} rules: ${response.status}`);
|
|
1724
|
+
continue;
|
|
1725
|
+
}
|
|
1726
|
+
const rulesData = await response.json();
|
|
1727
|
+
if (!rulesData.content) {
|
|
1728
|
+
console.error(` \u2717 No content for ${tool} rules`);
|
|
1729
|
+
continue;
|
|
1730
|
+
}
|
|
1731
|
+
const targetDir = dir ? path.join(rulesDirResolved, dir) : rulesDirResolved;
|
|
1732
|
+
if (!fs.existsSync(targetDir)) {
|
|
1733
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
1734
|
+
}
|
|
1735
|
+
const filePath = path.join(targetDir, filename);
|
|
1736
|
+
fs.writeFileSync(filePath, rulesData.content);
|
|
1737
|
+
const relativePath = dir ? `${dir}/${filename}` : filename;
|
|
1738
|
+
console.log(` \u2713 ${relativePath}`);
|
|
1739
|
+
} catch (error) {
|
|
1740
|
+
console.error(` \u2717 Error syncing ${tool} rules:`, error instanceof Error ? error.message : String(error));
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1519
1744
|
console.log("");
|
|
1520
1745
|
}
|
|
1521
1746
|
async function runInit() {
|
|
@@ -1565,6 +1790,8 @@ function showHelp() {
|
|
|
1565
1790
|
less - CSS vars + Less variables (@var: value)
|
|
1566
1791
|
json - Raw token JSON
|
|
1567
1792
|
ts - TypeScript with types
|
|
1793
|
+
--rules, -r Also sync AI rules files (.cursorrules, etc.)
|
|
1794
|
+
--rules-dir Directory for rules files [project root]
|
|
1568
1795
|
js - JavaScript ES module
|
|
1569
1796
|
NATIVE:
|
|
1570
1797
|
swift - SwiftUI (iOS/macOS)
|
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":";;;AA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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 rules: boolean; // Also sync rules files\n rulesDir: string | null; // Directory for rules files (default: project root)\n}\n\nfunction parseArgs(): CLIArgs {\n const args = process.argv.slice(2);\n let command: CLIArgs[\"command\"] = \"server\";\n let dsId: string | null = null;\n let apiKey: string | null = null;\n let apiBase: string | null = null;\n let output: string | null = null;\n let format: CLIArgs[\"format\"] = null;\n let exclude: string[] = [];\n let yes = false;\n let rules = false;\n let rulesDir: string | null = null;\n\n // Check for subcommand first\n if (args[0] && !args[0].startsWith(\"-\")) {\n const cmd = args[0].toLowerCase();\n if (cmd === \"sync\") command = \"sync\";\n else if (cmd === \"init\") command = \"init\";\n else if (cmd === \"help\" || cmd === \"--help\" || cmd === \"-h\") command = \"help\";\n }\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === \"--ds-id\" && args[i + 1]) {\n dsId = args[i + 1];\n i++;\n } else if (args[i] === \"--api-key\" && args[i + 1]) {\n apiKey = args[i + 1];\n i++;\n } else if (args[i] === \"--api-base\" && args[i + 1]) {\n apiBase = args[i + 1];\n i++;\n } else if ((args[i] === \"--output\" || args[i] === \"-o\") && args[i + 1]) {\n output = args[i + 1];\n i++;\n } else if (args[i] === \"--format\" && args[i + 1]) {\n const f = args[i + 1].toLowerCase() as OutputFormat;\n const validFormats: OutputFormat[] = [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"];\n if (validFormats.includes(f)) format = f;\n i++;\n } else if (args[i] === \"--exclude\" && args[i + 1]) {\n exclude.push(args[i + 1]);\n i++;\n } else if (args[i] === \"-y\" || args[i] === \"--yes\") {\n yes = true;\n } else if (args[i] === \"--rules\" || args[i] === \"-r\") {\n rules = true;\n } else if (args[i] === \"--rules-dir\" && args[i + 1]) {\n rulesDir = args[i + 1];\n rules = true; // Implies --rules\n i++;\n }\n }\n\n return { command, dsId, apiKey, apiBase, output, format, exclude, yes, rules, rulesDir };\n}\n\nconst cliArgs = parseArgs();\nconst { dsId, apiKey } = cliArgs;\n// For MCP server mode, use CLI apiBase or default\nconst apiBase = cliArgs.apiBase || \"https://atomixstudio.eu\";\n\n// ============================================\n// TOKEN FETCHING\n// ============================================\n\nlet cachedData: DesignSystemData | null = null;\n\nasync function fetchDesignSystem(): Promise<DesignSystemData> {\n if (cachedData) return cachedData;\n\n if (!dsId) {\n throw new Error(\"Missing --ds-id argument. Usage: npx @atomixstudio/mcp --ds-id <id> --api-key <key>\");\n }\n\n const url = `${apiBase}/api/ds/${dsId}/tokens?format=export`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n \n if (apiKey) {\n headers[\"x-api-key\"] = apiKey;\n }\n\n const response = await fetch(url, { headers });\n \n if (!response.ok) {\n const text = await response.text();\n throw new Error(`Failed to fetch design system: ${response.status} ${text}`);\n }\n\n const data = await response.json() as DesignSystemData;\n cachedData = data;\n return data;\n}\n\n// ============================================\n// TOKEN UTILITIES\n// ============================================\n\nconst TOKEN_CATEGORIES = [\"colors\", \"typography\", \"spacing\", \"sizing\", \"shadows\", \"radius\", \"borders\", \"motion\", \"zIndex\"] as const;\ntype TokenCategory = typeof TOKEN_CATEGORIES[number];\n\nfunction getTokenByPath(tokens: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = tokens;\n\n for (const part of parts) {\n if (current && typeof current === \"object\" && part in current) {\n current = (current as Record<string, unknown>)[part];\n } else {\n return undefined;\n }\n }\n\n return current;\n}\n\nfunction flattenTokens(obj: unknown, prefix = \"\"): Array<{ path: string; value: unknown }> {\n const results: Array<{ path: string; value: unknown }> = [];\n\n if (obj && typeof obj === \"object\" && !Array.isArray(obj)) {\n for (const [key, value] of Object.entries(obj)) {\n const newPath = prefix ? `${prefix}.${key}` : key;\n \n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n results.push(...flattenTokens(value, newPath));\n } else {\n results.push({ path: newPath, value });\n }\n }\n }\n\n return results;\n}\n\nfunction searchTokens(tokens: Record<string, unknown>, query: string): Array<{ path: string; value: unknown }> {\n const flat = flattenTokens(tokens);\n const lowerQuery = query.toLowerCase();\n \n return flat.filter(({ path, value }) => {\n const pathMatch = path.toLowerCase().includes(lowerQuery);\n const valueMatch = String(value).toLowerCase().includes(lowerQuery);\n return pathMatch || valueMatch;\n });\n}\n\n// ============================================\n// TOKEN COUNTING\n// ============================================\n\nfunction countTokens(tokens: Record<string, unknown>, prefix = \"\"): number {\n let count = 0;\n for (const [key, value] of Object.entries(tokens)) {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n count += countTokens(value as Record<string, unknown>, `${prefix}${key}.`);\n } else if (value !== undefined && value !== null) {\n count++;\n }\n }\n return count;\n}\n\nfunction getTokenStats(data: DesignSystemData): {\n total: number;\n byCategory: Record<string, number>;\n cssVariables: number;\n governanceRules: number;\n} {\n const byCategory: Record<string, number> = {};\n let total = 0;\n\n for (const [category, value] of Object.entries(data.tokens)) {\n if (value && typeof value === \"object\") {\n const count = countTokens(value as Record<string, unknown>);\n byCategory[category] = count;\n total += count;\n }\n }\n\n return {\n total,\n byCategory,\n cssVariables: Object.keys(data.cssVariables).length,\n governanceRules: data.governance.rules.length,\n };\n}\n\n// ============================================\n// MCP SERVER SETUP\n// ============================================\n\nconst server = new Server(\n {\n name: \"atomix-mcp-user\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n tools: {},\n resources: {},\n prompts: {},\n },\n }\n);\n\n// ============================================\n// TOOL DEFINITIONS\n// ============================================\n\nserver.setRequestHandler(ListToolsRequestSchema, async () => {\n return {\n tools: [\n {\n name: \"getToken\",\n description: \"Get a specific design token by its path. Returns the value and CSS variable name.\",\n inputSchema: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"Token path in dot notation (e.g., 'colors.brand.primary', 'spacing.scale.md')\",\n },\n },\n required: [\"path\"],\n },\n },\n {\n name: \"listTokens\",\n description: \"List all tokens in a category (colors, typography, spacing, sizing, shadows, radius, borders, motion, zIndex).\",\n inputSchema: {\n type: \"object\",\n properties: {\n category: {\n type: \"string\",\n enum: TOKEN_CATEGORIES,\n description: \"Token category to list\",\n },\n subcategory: {\n type: \"string\",\n description: \"Optional subcategory (e.g., 'brand' for colors, 'scale' for spacing)\",\n },\n },\n required: [\"category\"],\n },\n },\n {\n name: \"searchTokens\",\n description: \"Search for tokens by name or value.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Search query (matches token paths or values)\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"validateUsage\",\n description: \"Check if a CSS value follows the design system. Detects hardcoded values that should use tokens.\",\n inputSchema: {\n type: \"object\",\n properties: {\n value: {\n type: \"string\",\n description: \"CSS value to validate (e.g., '#ff0000', '16px', 'rgb(0,112,97)')\",\n },\n context: {\n type: \"string\",\n enum: [\"color\", \"spacing\", \"radius\", \"shadow\", \"typography\", \"any\"],\n description: \"Context of the value to help find the right token\",\n },\n },\n required: [\"value\"],\n },\n },\n {\n name: \"getAIToolRules\",\n description: \"Generate design system rules for AI coding tools (Cursor, Copilot, Windsurf, etc.).\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\", \"all\"],\n description: \"AI tool to generate rules for. Use 'all' to get rules for all tools.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"exportMCPConfig\",\n description: \"Generate MCP configuration file for AI tools.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"claude-desktop\", \"windsurf\", \"continue\", \"vscode\", \"all\"],\n description: \"AI tool to generate MCP config for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"getSetupInstructions\",\n description: \"Get detailed setup instructions for a specific AI tool.\",\n inputSchema: {\n type: \"object\",\n properties: {\n tool: {\n type: \"string\",\n enum: [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"claude-desktop\", \"generic\"],\n description: \"AI tool to get setup instructions for.\",\n },\n },\n required: [\"tool\"],\n },\n },\n {\n name: \"syncTokens\",\n description: \"Sync design tokens to a local file. Creates or updates a tokens file with the latest values from your design system. Returns a diff of changes.\",\n inputSchema: {\n type: \"object\",\n properties: {\n output: {\n type: \"string\",\n description: \"Output file path relative to project root (e.g., './src/tokens.css', './DesignTokens.swift')\",\n },\n format: {\n type: \"string\",\n enum: [\"css\", \"scss\", \"less\", \"json\", \"ts\", \"js\", \"swift\", \"kotlin\", \"dart\"],\n description: \"Output format. WEB: css, scss, less, json, ts, js. NATIVE: swift (iOS), kotlin (Android), dart (Flutter). Default: css\",\n },\n },\n required: [\"output\"],\n },\n },\n ],\n };\n});\n\n// ============================================\n// TOOL HANDLERS\n// ============================================\n\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n const data = await fetchDesignSystem();\n\n switch (name) {\n case \"getToken\": {\n const path = args?.path as string;\n const value = getTokenByPath(data.tokens, path);\n \n if (value === undefined) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Token not found: ${path}`,\n suggestion: \"Use listTokens or searchTokens to find available tokens.\",\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n // Find CSS variable for this path\n const cssVarKey = `--atmx-${path.replace(/\\./g, \"-\")}`;\n const cssVar = data.cssVariables[cssVarKey];\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n path,\n value,\n cssVariable: cssVar || `var(${cssVarKey})`,\n usage: `style={{ property: \"var(${cssVarKey})\" }}`,\n }, null, 2),\n }],\n };\n }\n\n case \"listTokens\": {\n const category = args?.category as TokenCategory;\n const subcategory = args?.subcategory as string | undefined;\n \n let tokensToList: unknown = data.tokens[category];\n \n if (subcategory && tokensToList && typeof tokensToList === \"object\") {\n tokensToList = getTokenByPath(tokensToList as Record<string, unknown>, subcategory);\n }\n\n if (!tokensToList) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Category not found: ${category}${subcategory ? `.${subcategory}` : \"\"}`,\n availableCategories: TOKEN_CATEGORIES,\n }, null, 2),\n }],\n };\n }\n\n const flat = flattenTokens(tokensToList);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n category,\n subcategory,\n count: flat.length,\n tokens: flat.slice(0, 50), // Limit to 50 for readability\n truncated: flat.length > 50,\n }, null, 2),\n }],\n };\n }\n\n case \"searchTokens\": {\n const query = args?.query as string;\n const results = searchTokens(data.tokens, query);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n query,\n count: results.length,\n results: results.slice(0, 30),\n truncated: results.length > 30,\n }, null, 2),\n }],\n };\n }\n\n case \"validateUsage\": {\n const value = args?.value as string;\n const context = (args?.context as string) || \"any\";\n \n // Check if value is a hardcoded color\n const isHexColor = /^#[0-9A-Fa-f]{3,8}$/.test(value);\n const isRgbColor = /^rgb\\(|^rgba\\(|^hsl\\(/.test(value);\n const isPixelValue = /^\\d+px$/.test(value);\n \n if (!isHexColor && !isRgbColor && !isPixelValue) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: true,\n message: \"Value appears to be using tokens or is not a design token value.\",\n }, null, 2),\n }],\n };\n }\n\n // Search for matching tokens\n const matches = searchTokens(data.tokens, value);\n \n if (matches.length > 0) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. Use a token instead.\",\n matchingTokens: matches.slice(0, 5),\n suggestion: `Use var(--atmx-${matches[0].path.replace(/\\./g, \"-\")}) instead of ${value}`,\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n value,\n valid: false,\n message: \"Hardcoded value detected. No exact token match found.\",\n suggestion: `Consider adding this value to the design system or use the closest token.`,\n context,\n }, null, 2),\n }],\n };\n }\n\n case \"getAIToolRules\": {\n const tool = args?.tool as string;\n \n // Fetch rules from the API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool === \"all\" ? \"all\" : tool}`;\n console.error(`[getAIToolRules] Fetching: ${rulesUrl}`);\n \n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n \n try {\n const response = await fetch(rulesUrl, { headers });\n console.error(`[getAIToolRules] Response status: ${response.status}`);\n \n if (!response.ok) {\n const errorText = await response.text();\n console.error(`[getAIToolRules] Error response: ${errorText}`);\n throw new Error(`Failed to fetch rules: ${response.status} - ${errorText}`);\n }\n\n const rules = await response.json() as { rules?: string[]; categories?: Record<string, string[]> };\n console.error(`[getAIToolRules] Got ${rules.rules?.length || 0} rules`);\n \n return {\n content: [{\n type: \"text\",\n text: JSON.stringify(rules, null, 2),\n }],\n };\n } catch (fetchError) {\n console.error(`[getAIToolRules] Fetch error:`, fetchError);\n throw fetchError;\n }\n }\n\n case \"exportMCPConfig\": {\n const tool = args?.tool as string;\n \n // Generate MCP config locally\n const serverName = data.meta.name.toLowerCase().replace(/[^a-z0-9]/g, \"-\");\n const npxArgs = [\"@atomixstudio/mcp@latest\"];\n if (dsId) npxArgs.push(\"--ds-id\", dsId);\n if (apiKey) npxArgs.push(\"--api-key\", apiKey);\n\n const config = {\n mcpServers: {\n [serverName]: {\n command: \"npx\",\n args: npxArgs,\n },\n },\n };\n\n const configs: Record<string, { path: string; content: string }> = {\n cursor: { path: \".cursor/mcp.json\", content: JSON.stringify(config, null, 2) },\n \"claude-desktop\": { path: \"claude_desktop_config.json\", content: JSON.stringify(config, null, 2) },\n windsurf: { path: \".windsurf/mcp.json\", content: JSON.stringify(config, null, 2) },\n continue: { path: \".continue/config.json\", content: JSON.stringify({ models: [], mcpServers: [{ name: serverName, command: \"npx\", args: npxArgs }] }, null, 2) },\n vscode: { path: \".vscode/settings.json\", content: JSON.stringify({ \"mcp.servers\": config.mcpServers }, null, 2) },\n };\n\n if (tool === \"all\") {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n message: \"MCP configurations for all tools\",\n configs: Object.entries(configs).map(([t, c]) => ({\n tool: t,\n path: c.path,\n content: JSON.parse(c.content),\n })),\n }, null, 2),\n }],\n };\n }\n\n const selectedConfig = configs[tool as keyof typeof configs];\n if (!selectedConfig) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(configs),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n tool,\n path: selectedConfig.path,\n content: JSON.parse(selectedConfig.content),\n instructions: `Create the file at ${selectedConfig.path} with the content above, then restart your IDE.`,\n }, null, 2),\n }],\n };\n }\n\n case \"getSetupInstructions\": {\n const tool = args?.tool as string;\n \n const instructions: Record<string, string> = {\n cursor: `# Cursor MCP Setup\n\n1. Create \\`.cursor/mcp.json\\` in your project root\n2. Add the MCP configuration (use exportMCPConfig to get it)\n3. Restart Cursor IDE\n4. Verify by asking: \"What design tokens are available?\"`,\n\n copilot: `# GitHub Copilot Setup\n\n1. Create \\`.github/copilot-instructions.md\\` in your project\n2. Use getAIToolRules({ tool: \"copilot\" }) to get the content\n3. Enable custom instructions in VS Code settings:\n \"github.copilot.chat.codeGeneration.useInstructionFiles\": true`,\n\n windsurf: `# Windsurf Setup\n\n1. Create \\`.windsurf/mcp.json\\` in your project root\n2. Create \\`.windsurfrules\\` with rules from getAIToolRules\n3. Restart Windsurf Editor`,\n\n cline: `# Cline Setup\n\n1. Create \\`.clinerules\\` in your project root\n2. Cline auto-detects MCP from .cursor/mcp.json`,\n\n continue: `# Continue Setup\n\n1. Create/edit \\`.continue/config.json\\`\n2. Add mcpServers configuration\n3. Restart VS Code`,\n\n zed: `# Zed Setup\n\n1. Create \\`.zed/assistant/rules.md\\` in your project\n2. Use getAIToolRules({ tool: \"zed\" }) for content`,\n\n \"claude-desktop\": `# Claude Desktop Setup\n\n1. Find your Claude config:\n - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json\n - Windows: %APPDATA%\\\\Claude\\\\claude_desktop_config.json\n2. Add MCP server configuration\n3. Restart Claude Desktop`,\n\n generic: `# Generic AI Tool Setup\n\n1. Create AI_GUIDELINES.md in your project root\n2. Use getAIToolRules({ tool: \"generic\" }) for content\n3. Reference in your prompts or context`,\n };\n\n const instruction = instructions[tool];\n if (!instruction) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${tool}`,\n availableTools: Object.keys(instructions),\n }, null, 2),\n }],\n };\n }\n\n return {\n content: [{\n type: \"text\",\n text: instruction,\n }],\n };\n }\n\n case \"syncTokens\": {\n const output = args?.output as string;\n const format = (args?.format as OutputFormat) || \"css\";\n \n if (!output) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({ error: \"Missing required parameter: output\" }, null, 2),\n }],\n };\n }\n\n // Generate content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (format) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), output);\n const fileExists = fs.existsSync(outputPath);\n const tokenCount = Object.keys(data.cssVariables).length;\n\n let diffSummary = \"\";\n let changes: Array<{ key: string; old: string; new: string }> = [];\n\n if (fileExists && [\"css\", \"scss\", \"less\"].includes(format)) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, format as OutputFormat, darkModeColors?.dark);\n \n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n \n if (totalChanges === 0) {\n return {\n content: [{\n type: \"text\",\n text: `✓ Already up to date!\\n\\nFile: ${output}\\nTokens: ${tokenCount}\\nVersion: ${data.meta.version}`,\n }],\n };\n }\n\n changes = [...diff.modified, ...diff.modifiedDark];\n \n // Build summary\n const lightSummary = lightChanges > 0 ? `Light: ${diff.modified.length} modified, ${diff.added.length} added, ${diff.removed.length} removed` : \"\";\n const darkSummary = darkChanges > 0 ? `Dark: ${diff.modifiedDark.length} modified, ${diff.addedDark.length} added, ${diff.removedDark.length} removed` : \"\";\n diffSummary = [lightSummary, darkSummary].filter(Boolean).join(\" | \");\n }\n\n // Write the file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n // Build response\n let response = `✓ Synced ${tokenCount} tokens to ${output}\\n`;\n response += `Format: ${format}\\n`;\n response += `Design System: ${data.meta.name} (v${data.meta.version})\\n`;\n \n if (diffSummary) {\n response += `\\n${diffSummary}\\n`;\n if (changes.length > 0 && changes.length <= 10) {\n response += \"\\nModified tokens:\\n\";\n for (const { key, old: oldVal, new: newVal } of changes) {\n response += ` ${key}: ${oldVal} → ${newVal}\\n`;\n }\n }\n } else if (!fileExists) {\n response += \"\\n(New file created)\";\n }\n\n return {\n content: [{\n type: \"text\",\n text: response,\n }],\n };\n }\n\n default:\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: `Unknown tool: ${name}`,\n availableTools: [\"getToken\", \"listTokens\", \"searchTokens\", \"validateUsage\", \"getAIToolRules\", \"exportMCPConfig\", \"getSetupInstructions\", \"syncTokens\"],\n }, null, 2),\n }],\n };\n }\n } catch (error) {\n return {\n content: [{\n type: \"text\",\n text: JSON.stringify({\n error: error instanceof Error ? error.message : \"Unknown error\",\n suggestion: \"Make sure --ds-id and --api-key are correct.\",\n }, null, 2),\n }],\n isError: true,\n };\n }\n});\n\n// ============================================\n// RESOURCE HANDLERS\n// ============================================\n\nconst AI_TOOLS = [\"cursor\", \"copilot\", \"windsurf\", \"cline\", \"continue\", \"zed\", \"generic\"] as const;\n\nserver.setRequestHandler(ListResourcesRequestSchema, async () => {\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n \n const resources = [\n {\n uri: \"atomix://welcome\",\n name: `Welcome to ${data.meta.name}`,\n description: `Design system overview with ${stats.total} tokens and ${stats.governanceRules} governance rules`,\n mimeType: \"text/markdown\",\n },\n ...AI_TOOLS.map(tool => ({\n uri: `atomix://rules/${tool}`,\n name: `${tool.charAt(0).toUpperCase() + tool.slice(1)} Rules`,\n description: `Design system rules file for ${tool}`,\n mimeType: \"text/markdown\",\n })),\n ];\n\n return { resources };\n});\n\nserver.setRequestHandler(ReadResourceRequestSchema, async (request) => {\n const { uri } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n // Welcome resource\n if (uri === \"atomix://welcome\") {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: welcome,\n }],\n };\n }\n\n // Rules resources\n const rulesMatch = uri.match(/^atomix:\\/\\/rules\\/(.+)$/);\n if (rulesMatch) {\n const tool = rulesMatch[1];\n if (!AI_TOOLS.includes(tool as typeof AI_TOOLS[number])) {\n throw new Error(`Unknown tool: ${tool}. Available: ${AI_TOOLS.join(\", \")}`);\n }\n\n // Fetch rules from API\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string; tool?: string };\n \n return {\n contents: [{\n uri,\n mimeType: \"text/markdown\",\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n }],\n };\n }\n\n throw new Error(`Unknown resource: ${uri}`);\n});\n\n// ============================================\n// PROMPTS - Auto-suggest welcome on connection\n// ============================================\n\nserver.setRequestHandler(ListPromptsRequestSchema, async () => {\n return {\n prompts: [\n {\n name: \"welcome\",\n description: \"Get started with this design system - shows overview, available tokens, and tools. Run this first!\",\n },\n {\n name: \"design-system-rules\",\n description: \"Get the design system governance rules for your AI coding tool\",\n arguments: [\n {\n name: \"tool\",\n description: \"AI tool to generate rules for (cursor, copilot, windsurf, cline, continue, zed, generic)\",\n required: false,\n },\n ],\n },\n ],\n };\n});\n\nserver.setRequestHandler(GetPromptRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n const data = await fetchDesignSystem();\n const stats = getTokenStats(data);\n\n switch (name) {\n case \"welcome\": {\n const welcome = generateWelcomeMessage(data, stats);\n return {\n description: `Welcome to ${data.meta.name} Design System`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: \"Show me the design system overview and available tools.\",\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: welcome,\n },\n },\n ],\n };\n }\n\n case \"design-system-rules\": {\n const tool = (args?.tool as string) || \"cursor\";\n const rulesUrl = `${apiBase}/api/ds/${dsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (apiKey) headers[\"x-api-key\"] = apiKey;\n\n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n throw new Error(`Failed to fetch rules: ${response.status}`);\n }\n\n const rulesData = await response.json() as { content?: string };\n \n return {\n description: `Design system rules for ${tool}`,\n messages: [\n {\n role: \"user\" as const,\n content: {\n type: \"text\" as const,\n text: `Show me the design system rules for ${tool}.`,\n },\n },\n {\n role: \"assistant\" as const,\n content: {\n type: \"text\" as const,\n text: rulesData.content || JSON.stringify(rulesData, null, 2),\n },\n },\n ],\n };\n }\n\n default:\n throw new Error(`Unknown prompt: ${name}`);\n }\n});\n\nfunction generateWelcomeMessage(data: DesignSystemData, stats: ReturnType<typeof getTokenStats>): string {\n const toolsList = [\n \"getToken - Get a specific token by path\",\n \"listTokens - List all tokens in a category\",\n \"searchTokens - Search tokens by name or value\",\n \"validateUsage - Check if a CSS value follows the design system\",\n \"getAIToolRules - Generate AI coding rules for any tool\",\n \"exportMCPConfig - Generate MCP config for AI tools\",\n \"getSetupInstructions - Get setup guide for specific tools\",\n \"syncTokens - Sync tokens to a local file (css, scss, swift, kotlin, dart, etc.)\",\n ];\n\n const categoryBreakdown = Object.entries(stats.byCategory)\n .map(([cat, count]) => ` - ${cat}: ${count} tokens`)\n .join(\"\\n\");\n\n const asciiArt = `\n\\`\\`\\`\n ↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘ \n ↘↘↘↘↘↘↘↘↘↘↘ \n\\`\\`\\`\n`;\n\n return `${asciiArt}\n# Welcome to ${data.meta.name}\n\nYour design system is connected and ready to use.\n\n## Design System Overview\n\n| Metric | Value |\n|--------|-------|\n| Name | ${data.meta.name} |\n| DS ID | ${dsId} |\n| Total Tokens | ${stats.total} |\n| CSS Variables | ${stats.cssVariables} |\n| Governance Rules | ${stats.governanceRules} |\n| Version | ${data.meta.version || 1} |\n\n### Token Breakdown\n\n${categoryBreakdown}\n\n## Available Tools\n\n${toolsList.map((t, i) => `${i + 1}. **${t.split(\" - \")[0]}** - ${t.split(\" - \")[1]}`).join(\"\\n\")}\n\n## Quick Start\n\n### Get a Token\n\\`\\`\\`\nUse getToken with path \"colors.static.brand.primary\"\n\\`\\`\\`\n\n### List All Spacing Tokens\n\\`\\`\\`\nUse listTokens with category \"spacing\"\n\\`\\`\\`\n\n### Validate a Hardcoded Value\n\\`\\`\\`\nUse validateUsage with value \"#ff0000\" and context \"color\"\n\\`\\`\\`\n\n## Resources Available\n\nThis MCP server exposes rules files as resources that your AI tool can read:\n\n| Resource | Description |\n|----------|-------------|\n| \\`atomix://welcome\\` | This welcome message |\n| \\`atomix://rules/cursor\\` | .cursorrules file content |\n| \\`atomix://rules/copilot\\` | GitHub Copilot instructions |\n| \\`atomix://rules/windsurf\\` | .windsurfrules file content |\n| \\`atomix://rules/cline\\` | .clinerules file content |\n| \\`atomix://rules/continue\\` | Continue rules |\n| \\`atomix://rules/zed\\` | Zed assistant rules |\n| \\`atomix://rules/generic\\` | Generic AI guidelines |\n\n## Checking for Updates\n\nYour design system may be updated over time. To ensure you have the latest tokens:\n\n1. **Check version**: The current version is ${data.meta.version || 1}\n2. **Refresh tokens**: Restart the MCP server to fetch latest tokens\n3. **View changes**: Visit https://atomixstudio.eu/ds/${dsId} to see recent changes\n\n---\n\n*Powered by Atomix Studio - https://atomixstudio.eu*\n`;\n}\n\n// ============================================\n// SYNC COMMAND\n// ============================================\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as readline from \"readline\";\n\ntype OutputFormat = \n | \"css\" | \"scss\" | \"less\" // Web CSS-based\n | \"json\" | \"ts\" | \"js\" // Web JS-based\n | \"swift\" | \"kotlin\" | \"dart\"; // Native mobile\n\ninterface AtomixConfig {\n dsId: string;\n apiKey?: string;\n apiBase?: string;\n output: string;\n format: OutputFormat;\n // For future codebase scanning\n include?: string[]; // Glob patterns to include\n exclude?: string[]; // Glob patterns to exclude\n}\n\n// Default file patterns for codebase scanning\nconst DEFAULT_INCLUDE = [\n \"**/*.tsx\", // React TypeScript components\n \"**/*.jsx\", // React JavaScript components\n \"**/*.ts\", // TypeScript files\n \"**/*.js\", // JavaScript files\n \"**/*.css\", // CSS stylesheets\n \"**/*.scss\", // SASS files\n \"**/*.less\", // Less files\n \"**/*.vue\", // Vue components\n \"**/*.svelte\", // Svelte components\n \"**/*.astro\", // Astro components\n];\n\nconst DEFAULT_EXCLUDE = [\n \"node_modules/**\",\n \"dist/**\",\n \"build/**\",\n \".next/**\",\n \".nuxt/**\",\n \".git/**\",\n \"coverage/**\",\n \"**/*.min.js\",\n \"**/*.min.css\",\n \"**/*.d.ts\", // Type definitions\n \"**/*.test.*\", // Test files\n \"**/*.spec.*\", // Spec files\n];\n\nfunction findConfig(): AtomixConfig | null {\n const configNames = [\".atomixrc\", \".atomixrc.json\", \"atomix.config.json\"];\n const cwd = process.cwd();\n \n for (const name of configNames) {\n const configPath = path.join(cwd, name);\n if (fs.existsSync(configPath)) {\n try {\n const content = fs.readFileSync(configPath, \"utf-8\");\n return JSON.parse(content);\n } catch {\n console.error(`Error parsing ${name}`);\n }\n }\n }\n return null;\n}\n\nfunction generateCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"/* Atomix Design System Tokens\",\n \" * Auto-generated - do not edit manually\",\n ` * Synced: ${new Date().toISOString()}`,\n \" */\",\n \"\",\n \"/* Light mode (default) */\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode overrides if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"/* Dark mode */\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n // Detect prefix from cssVariables keys\n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n // Dark mode colors are stored with keys like \"bg-page\", \"text-primary\"\n // Convert to CSS variable names: --atmx-color-bg-page\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateJSONOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return JSON.stringify(tokens, null, 2);\n}\n\nfunction generateTSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)} as const;\n\nexport type Tokens = typeof tokens;\n`;\n}\n\nfunction generateJSOutput(tokens: ExportedTokens[\"tokens\"]): string {\n return `// Atomix Design System Tokens\n// Auto-generated - do not edit manually\n// Synced: ${new Date().toISOString()}\n\nexport const tokens = ${JSON.stringify(tokens, null, 2)};\n`;\n}\n\nfunction generateSCSSOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// SCSS Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const scssVar = \"$\" + key.replace(/^--/, \"\");\n lines.push(`${scssVar}: ${value};`);\n }\n \n // Add dark mode SCSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// SCSS Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const scssVar = `$${prefix}-color-${key}-dark`;\n lines.push(`${scssVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\nfunction generateLessOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"// CSS Custom Properties (for use in CSS/HTML)\",\n \"// Light mode (default)\",\n \":root {\"\n ];\n \n for (const [key, value] of Object.entries(cssVariables)) {\n lines.push(` ${key}: ${value};`);\n }\n \n lines.push(\"}\");\n \n // Add dark mode CSS variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Dark mode\");\n lines.push(\".dark,\");\n lines.push(\"[data-theme=\\\"dark\\\"] {\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n lines.push(` ${prefix}color-${key}: ${value};`);\n }\n \n lines.push(\"}\");\n }\n \n lines.push(\"\");\n lines.push(\"// Less Variables (light mode values)\");\n \n for (const [key, value] of Object.entries(cssVariables)) {\n const lessVar = \"@\" + key.replace(/^--/, \"\");\n lines.push(`${lessVar}: ${value};`);\n }\n \n // Add dark mode Less variables\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\"// Less Variables (dark mode values)\");\n \n const firstKey = Object.keys(cssVariables)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^--([a-z]+)-/);\n const prefix = prefixMatch ? prefixMatch[1] : \"atmx\";\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const lessVar = `@${prefix}-color-${key}-dark`;\n lines.push(`${lessVar}: ${value};`);\n }\n }\n \n lines.push(\"\");\n \n return lines.join(\"\\n\");\n}\n\n// ============================================\n// NATIVE MOBILE OUTPUT GENERATORS\n// ============================================\n\nfunction toSwiftName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary\n return cssVar\n .replace(/^--atmx-/, \"\")\n .replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n}\n\nfunction toKotlinName(cssVar: string): string {\n // --atmx-color-brand-primary → ColorBrandPrimary\n const camel = toSwiftName(cssVar);\n return camel.charAt(0).toUpperCase() + camel.slice(1);\n}\n\nfunction toDartName(cssVar: string): string {\n // --atmx-color-brand-primary → colorBrandPrimary (same as Swift)\n return toSwiftName(cssVar);\n}\n\nfunction isColorValue(value: string): boolean {\n return /^#[0-9A-Fa-f]{3,8}$/.test(value) || \n /^rgb/.test(value) || \n /^hsl/.test(value);\n}\n\nfunction hexToSwiftColor(hex: string): string {\n // #RRGGBB or #RRGGBBAA\n const clean = hex.replace(\"#\", \"\");\n if (clean.length === 3) {\n // #RGB -> #RRGGBB\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(hex: 0x${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(hex: 0x${clean})`;\n }\n if (clean.length === 8) {\n // #RRGGBBAA\n const rgb = clean.substring(0, 6);\n const alpha = parseInt(clean.substring(6, 8), 16) / 255;\n return `Color(hex: 0x${rgb}).opacity(${alpha.toFixed(2)})`;\n }\n return `Color.clear // Could not parse: ${hex}`;\n}\n\nfunction hexToKotlinColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n // RRGGBBAA -> AARRGGBB for Android\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Color.Transparent // Could not parse: ${hex}`;\n}\n\nfunction hexToDartColor(hex: string): string {\n const clean = hex.replace(\"#\", \"\").toUpperCase();\n if (clean.length === 3) {\n const r = clean[0], g = clean[1], b = clean[2];\n return `Color(0xFF${r}${r}${g}${g}${b}${b})`;\n }\n if (clean.length === 6) {\n return `Color(0xFF${clean})`;\n }\n if (clean.length === 8) {\n const rgb = clean.substring(0, 6);\n const alpha = clean.substring(6, 8);\n return `Color(0x${alpha}${rgb})`;\n }\n return `Colors.transparent // Could not parse: ${hex}`;\n}\n\nfunction generateSwiftOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import SwiftUI\",\n \"\",\n \"// MARK: - Color Extension for Hex\",\n \"extension Color {\",\n \" init(hex: UInt, alpha: Double = 1.0) {\",\n \" self.init(\",\n \" .sRGB,\",\n \" red: Double((hex >> 16) & 0xFF) / 255.0,\",\n \" green: Double((hex >> 8) & 0xFF) / 255.0,\",\n \" blue: Double(hex & 0xFF) / 255.0,\",\n \" opacity: alpha\",\n \" )\",\n \" }\",\n \"}\",\n \"\",\n \"// MARK: - Design Tokens\",\n \"enum DesignTokens {\",\n \"\",\n \" // MARK: Colors (Light Mode)\",\n \" enum Colors {\"\n ];\n\n // Group by category\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // MARK: Colors (Dark Mode)\");\n lines.push(\" enum ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" // MARK: Spacing\");\n lines.push(\" enum Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toSwiftName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Typography\");\n lines.push(\" enum Typography {\");\n\n for (const [key, value] of typography) {\n const name = toSwiftName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n }\n } else if (key.includes(\"weight\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n } else if (key.includes(\"family\")) {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" // MARK: Other\");\n lines.push(\" enum Other {\");\n\n for (const [key, value] of other) {\n const name = toSwiftName(key);\n if (isColorValue(value)) {\n lines.push(` static let ${name} = ${hexToSwiftColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static let ${name}: CGFloat = ${numValue}`);\n } else {\n lines.push(` static let ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateKotlinOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"package com.atomix.design\",\n \"\",\n \"import androidx.compose.ui.graphics.Color\",\n \"import androidx.compose.ui.unit.dp\",\n \"import androidx.compose.ui.unit.sp\",\n \"\",\n \"object DesignTokens {\",\n \"\",\n \" // Light mode colors\",\n \" object Colors {\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n\n lines.push(\" }\");\n \n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Dark mode colors\");\n lines.push(\" object ColorsDark {\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `Color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}`;\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n }\n }\n \n lines.push(\" }\");\n }\n \n lines.push(\"\");\n lines.push(\" object Spacing {\");\n\n for (const [key, value] of spacing) {\n const name = toKotlinName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Typography {\");\n\n for (const [key, value] of typography) {\n const name = toKotlinName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.sp`);\n }\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n\n lines.push(\" }\");\n lines.push(\"\");\n lines.push(\" object Other {\");\n\n for (const [key, value] of other) {\n const name = toKotlinName(key);\n if (isColorValue(value)) {\n lines.push(` val ${name} = ${hexToKotlinColor(value)}`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` val ${name} = ${numValue}.dp`);\n } else {\n lines.push(` const val ${name} = \"${value}\"`);\n }\n }\n }\n\n lines.push(\" }\");\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction generateDartOutput(\n cssVariables: Record<string, string>,\n darkModeColors?: Record<string, string>\n): string {\n const lines = [\n \"// Atomix Design System Tokens\",\n \"// Auto-generated - do not edit manually\",\n `// Synced: ${new Date().toISOString()}`,\n \"\",\n \"import 'package:flutter/material.dart';\",\n \"\",\n \"class DesignTokens {\",\n \" DesignTokens._();\",\n \"\",\n \" // Colors (Light Mode)\"\n ];\n\n const colors: Array<[string, string]> = [];\n const spacing: Array<[string, string]> = [];\n const typography: Array<[string, string]> = [];\n const other: Array<[string, string]> = [];\n\n for (const [key, value] of Object.entries(cssVariables)) {\n if (key.includes(\"-color-\")) colors.push([key, value]);\n else if (key.includes(\"-spacing-\")) spacing.push([key, value]);\n else if (key.includes(\"-typography-\") || key.includes(\"-font-\")) typography.push([key, value]);\n else other.push([key, value]);\n }\n\n for (const [key, value] of colors) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n\n // Add dark mode colors if provided\n if (darkModeColors && Object.keys(darkModeColors).length > 0) {\n lines.push(\"\");\n lines.push(\" // Colors (Dark Mode)\");\n \n for (const [key, value] of Object.entries(darkModeColors)) {\n const name = `color${key.split(\"-\").map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(\"\")}Dark`;\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n }\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Spacing\");\n\n for (const [key, value] of spacing) {\n const name = toDartName(key);\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Typography\");\n\n for (const [key, value] of typography) {\n const name = toDartName(key);\n if (key.includes(\"size\")) {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n }\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n\n lines.push(\"\");\n lines.push(\" // Other\");\n\n for (const [key, value] of other) {\n const name = toDartName(key);\n if (isColorValue(value)) {\n lines.push(` static const ${name} = ${hexToDartColor(value)};`);\n } else {\n const numValue = parseFloat(value);\n if (!isNaN(numValue)) {\n lines.push(` static const double ${name} = ${numValue};`);\n } else {\n lines.push(` static const String ${name} = '${value}';`);\n }\n }\n }\n\n lines.push(\"}\");\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n}\n\nfunction diffTokens(\n oldContent: string,\n newCssVars: Record<string, string>,\n format: OutputFormat,\n newDarkVars?: Record<string, string>\n): { \n added: string[]; \n modified: Array<{ key: string; old: string; new: string }>; \n removed: string[];\n addedDark: string[];\n modifiedDark: Array<{ key: string; old: string; new: string }>;\n removedDark: string[];\n} {\n const added: string[] = [];\n const modified: Array<{ key: string; old: string; new: string }> = [];\n const removed: string[] = [];\n const addedDark: string[] = [];\n const modifiedDark: Array<{ key: string; old: string; new: string }> = [];\n const removedDark: string[] = [];\n\n // CSS-based formats (css, scss, less) all use CSS variables\n if (format === \"css\" || format === \"scss\" || format === \"less\") {\n // Split old content into light mode (:root) and dark mode (.dark) sections\n // Find the :root section\n const rootMatch = oldContent.match(/:root\\s*\\{([^}]*)\\}/);\n const darkMatch = oldContent.match(/\\.dark[^{]*\\{([^}]*)\\}/);\n \n // Parse light mode variables from :root\n const oldLightVars: Record<string, string> = {};\n if (rootMatch) {\n const rootContent = rootMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(rootContent)) !== null) {\n oldLightVars[match[1]] = match[2].trim();\n }\n } else {\n // Fallback: parse everything (old behavior for files without sections)\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(oldContent)) !== null) {\n // Only take the first occurrence to get light mode values\n if (!(match[1] in oldLightVars)) {\n oldLightVars[match[1]] = match[2].trim();\n }\n }\n }\n\n // Parse dark mode variables from .dark\n const oldDarkVars: Record<string, string> = {};\n if (darkMatch) {\n const darkContent = darkMatch[1];\n const varRegex = /(--[\\w-]+):\\s*([^;]+);/g;\n let match;\n while ((match = varRegex.exec(darkContent)) !== null) {\n oldDarkVars[match[1]] = match[2].trim();\n }\n }\n\n // Compare light mode\n for (const [key, value] of Object.entries(newCssVars)) {\n if (!(key in oldLightVars)) {\n added.push(key);\n } else if (oldLightVars[key] !== value) {\n modified.push({ key, old: oldLightVars[key], new: value });\n }\n }\n\n for (const key of Object.keys(oldLightVars)) {\n if (!(key in newCssVars)) {\n removed.push(key);\n }\n }\n\n // Compare dark mode if new dark vars provided\n if (newDarkVars && Object.keys(newDarkVars).length > 0) {\n // Generate the expected CSS variable names for dark mode\n // newDarkVars keys are like \"bg-page\", need to match \"--atmx-color-bg-page\"\n const firstKey = Object.keys(newCssVars)[0] || \"--atmx-\";\n const prefixMatch = firstKey.match(/^(--[a-z]+-)/);\n const prefix = prefixMatch ? prefixMatch[1] : \"--atmx-\";\n\n for (const [key, value] of Object.entries(newDarkVars)) {\n const cssVarName = `${prefix}color-${key}`;\n if (!(cssVarName in oldDarkVars)) {\n addedDark.push(cssVarName);\n } else if (oldDarkVars[cssVarName] !== value) {\n modifiedDark.push({ key: cssVarName, old: oldDarkVars[cssVarName], new: value });\n }\n }\n\n for (const key of Object.keys(oldDarkVars)) {\n // Extract the short key from --atmx-color-bg-page -> bg-page\n const shortKey = key.replace(new RegExp(`^${prefix}color-`), \"\");\n if (!(shortKey in newDarkVars)) {\n removedDark.push(key);\n }\n }\n }\n }\n\n return { added, modified, removed, addedDark, modifiedDark, removedDark };\n}\n\nasync function promptConfirm(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} [Y/n] `, (answer) => {\n rl.close();\n const normalized = answer.toLowerCase().trim();\n resolve(normalized === \"\" || normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\nasync function runSync() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Token Sync\");\n console.log(\"\");\n\n // Load config\n const config = findConfig();\n const effectiveDsId = cliArgs.dsId || config?.dsId;\n const effectiveApiKey = cliArgs.apiKey || config?.apiKey;\n const effectiveApiBase = cliArgs.apiBase || config?.apiBase || \"https://atomixstudio.eu\";\n const effectiveOutput = cliArgs.output || config?.output || \"./tokens.css\";\n const effectiveFormat = cliArgs.format || config?.format || \"css\";\n\n if (!effectiveDsId) {\n console.error(\" Error: Missing design system ID\");\n console.error(\"\");\n console.error(\" Either:\");\n console.error(\" 1. Run: npx atomix sync --ds-id <your-ds-id>\");\n console.error(\" 2. Create .atomixrc with { \\\"dsId\\\": \\\"<your-ds-id>\\\" }\");\n console.error(\" 3. Run: npx atomix init\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(` Fetching tokens from ${effectiveApiBase}...`);\n\n // Fetch latest tokens\n const url = `${effectiveApiBase}/api/ds/${effectiveDsId}/tokens?format=export`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n\n let data: ExportedTokens;\n try {\n const response = await fetch(url, { headers });\n if (!response.ok) {\n const errorText = await response.text();\n console.error(` Error: Failed to fetch tokens (${response.status})`);\n console.error(` ${errorText}`);\n process.exit(1);\n }\n data = await response.json() as ExportedTokens;\n } catch (error) {\n console.error(` Error: Could not connect to ${effectiveApiBase}`);\n console.error(` ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n\n console.log(` Design System: ${data.meta.name} (v${data.meta.version})`);\n console.log(\"\");\n\n // Generate new content based on format\n // Get dark mode colors for CSS output\n const darkModeColors = (data.tokens?.colors as Record<string, unknown>)?.modes as { dark?: Record<string, string> } | undefined;\n \n let newContent: string;\n switch (effectiveFormat) {\n case \"css\":\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"scss\":\n newContent = generateSCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"less\":\n newContent = generateLessOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"json\":\n newContent = generateJSONOutput(data.tokens);\n break;\n case \"js\":\n newContent = generateJSOutput(data.tokens);\n break;\n case \"ts\":\n newContent = generateTSOutput(data.tokens);\n break;\n case \"swift\":\n newContent = generateSwiftOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"kotlin\":\n newContent = generateKotlinOutput(data.cssVariables, darkModeColors?.dark);\n break;\n case \"dart\":\n newContent = generateDartOutput(data.cssVariables, darkModeColors?.dark);\n break;\n default:\n newContent = generateCSSOutput(data.cssVariables, darkModeColors?.dark);\n break;\n }\n\n // Check if file exists and diff\n const outputPath = path.resolve(process.cwd(), effectiveOutput);\n const fileExists = fs.existsSync(outputPath);\n\n // CSS-based formats support diffing\n const supportsDiff = [\"css\", \"scss\", \"less\"].includes(effectiveFormat);\n if (fileExists && supportsDiff) {\n const oldContent = fs.readFileSync(outputPath, \"utf-8\");\n const diff = diffTokens(oldContent, data.cssVariables, effectiveFormat, darkModeColors?.dark);\n\n // Count light mode changes\n const lightChanges = diff.added.length + diff.modified.length + diff.removed.length;\n // Count dark mode changes\n const darkChanges = diff.addedDark.length + diff.modifiedDark.length + diff.removedDark.length;\n const totalChanges = lightChanges + darkChanges;\n\n if (totalChanges === 0) {\n console.log(\" ✓ Already up to date!\");\n console.log(\"\");\n process.exit(0);\n }\n\n console.log(` Changes detected in ${path.basename(effectiveOutput)}:`);\n console.log(\"\");\n\n // Show light mode changes\n if (lightChanges > 0) {\n console.log(\" Light Mode:\");\n if (diff.modified.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modified) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.added.length > 0) {\n console.log(` + ${diff.added.length} new token(s)`);\n }\n if (diff.removed.length > 0) {\n console.log(` - ${diff.removed.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n // Show dark mode changes\n if (darkChanges > 0) {\n console.log(\" Dark Mode:\");\n if (diff.modifiedDark.length > 0) {\n for (const { key, old: oldVal, new: newVal } of diff.modifiedDark) {\n console.log(` ${key}`);\n console.log(` - ${oldVal}`);\n console.log(` + ${newVal}`);\n }\n }\n if (diff.addedDark.length > 0) {\n console.log(` + ${diff.addedDark.length} new token(s)`);\n }\n if (diff.removedDark.length > 0) {\n console.log(` - ${diff.removedDark.length} removed token(s)`);\n }\n console.log(\"\");\n }\n\n console.log(` Total: ${totalChanges} change(s) (Light: ${lightChanges}, Dark: ${darkChanges})`);\n console.log(\"\");\n\n // Confirm\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Apply changes?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n } else if (!fileExists) {\n console.log(` Creating ${effectiveOutput}...`);\n console.log(` ${Object.keys(data.cssVariables).length} tokens`);\n console.log(\"\");\n\n if (!cliArgs.yes) {\n const confirmed = await promptConfirm(\" Create file?\");\n if (!confirmed) {\n console.log(\" Cancelled.\");\n process.exit(0);\n }\n }\n }\n\n // Write file\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n fs.writeFileSync(outputPath, newContent);\n\n console.log(\"\");\n console.log(` ✓ Updated ${effectiveOutput}`);\n\n // Sync rules files if --rules flag is set\n if (cliArgs.rules) {\n console.log(\"\");\n console.log(\" Syncing AI rules files...\");\n \n const rulesDir = cliArgs.rulesDir || process.cwd();\n const rulesDirResolved = path.resolve(process.cwd(), rulesDir);\n \n // Detect which AI tools are likely in use based on existing files\n const toolsToSync: Array<{ tool: string; filename: string; dir?: string }> = [\n { tool: \"cursor\", filename: \".cursorrules\" },\n { tool: \"windsurf\", filename: \".windsurfrules\" },\n { tool: \"cline\", filename: \".clinerules\" },\n { tool: \"continue\", filename: \".continuerules\" },\n { tool: \"copilot\", filename: \"copilot-instructions.md\", dir: \".github\" },\n { tool: \"generic\", filename: \"AI_GUIDELINES.md\" },\n ];\n \n // Check which tools have existing files or should be created\n const existingTools = toolsToSync.filter(t => {\n const filePath = t.dir \n ? path.join(rulesDirResolved, t.dir, t.filename)\n : path.join(rulesDirResolved, t.filename);\n return fs.existsSync(filePath);\n });\n \n // If no existing rules files, create .cursorrules by default\n const toolsToWrite = existingTools.length > 0 \n ? existingTools \n : [{ tool: \"cursor\", filename: \".cursorrules\" }];\n \n for (const { tool, filename, dir } of toolsToWrite) {\n try {\n // Fetch rules from API\n const rulesUrl = `${effectiveApiBase}/api/ds/${effectiveDsId}/rules?format=${tool}`;\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (effectiveApiKey) headers[\"x-api-key\"] = effectiveApiKey;\n \n const response = await fetch(rulesUrl, { headers });\n if (!response.ok) {\n console.error(` ✗ Failed to fetch ${tool} rules: ${response.status}`);\n continue;\n }\n \n const rulesData = await response.json() as { content?: string };\n if (!rulesData.content) {\n console.error(` ✗ No content for ${tool} rules`);\n continue;\n }\n \n // Write the file\n const targetDir = dir ? path.join(rulesDirResolved, dir) : rulesDirResolved;\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n \n const filePath = path.join(targetDir, filename);\n fs.writeFileSync(filePath, rulesData.content);\n \n const relativePath = dir ? `${dir}/${filename}` : filename;\n console.log(` ✓ ${relativePath}`);\n } catch (error) {\n console.error(` ✗ Error syncing ${tool} rules:`, error instanceof Error ? error.message : String(error));\n }\n }\n }\n\n console.log(\"\");\n}\n\nasync function runInit() {\n console.log(\"\");\n console.log(\" ↘↘↘ Atomix Config Setup\");\n console.log(\"\");\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const question = (prompt: string): Promise<string> =>\n new Promise((resolve) => rl.question(prompt, resolve));\n\n const dsId = cliArgs.dsId || await question(\" Design System ID: \");\n const output = await question(\" Output file [./tokens.css]: \") || \"./tokens.css\";\n const format = await question(\" Format (css/json/ts) [css]: \") || \"css\";\n\n rl.close();\n\n const config: AtomixConfig = {\n dsId,\n output,\n format: format as \"css\" | \"json\" | \"ts\",\n };\n\n const configPath = path.join(process.cwd(), \".atomixrc\");\n fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n\n console.log(\"\");\n console.log(` ✓ Created .atomixrc`);\n console.log(\"\");\n console.log(\" Now run: npx atomix sync\");\n console.log(\"\");\n}\n\nfunction showHelp() {\n console.log(`\n ↘↘↘ Atomix CLI\n\n COMMANDS\n sync Sync design tokens to your project\n init Create .atomixrc config file\n help Show this help message\n (none) Start MCP server for AI tools\n\n SYNC OPTIONS\n --ds-id Design system ID (or set in .atomixrc)\n --api-key API key for private design systems\n --output, -o Output file path [./tokens.css]\n --format Output format [css]\n WEB:\n css - CSS custom properties (:root { --var: value })\n scss - CSS vars + SCSS variables ($var: value)\n less - CSS vars + Less variables (@var: value)\n json - Raw token JSON\n ts - TypeScript with types\n --rules, -r Also sync AI rules files (.cursorrules, etc.)\n --rules-dir Directory for rules files [project root]\n js - JavaScript ES module\n NATIVE:\n swift - SwiftUI (iOS/macOS)\n kotlin - Jetpack Compose (Android)\n dart - Flutter\n --exclude Glob pattern to exclude (can use multiple times)\n -y, --yes Auto-confirm changes\n\n MCP SERVER OPTIONS\n --ds-id Design system ID (required)\n --api-key API key for private design systems\n --api-base API base URL [https://atomixstudio.eu]\n\n EXAMPLES\n npx atomix sync\n npx atomix sync --ds-id abc123 -o ./src/tokens.css\n npx atomix sync --format scss -o ./src/styles/_tokens.scss\n npx atomix sync --format ts -o ./src/design-tokens.ts\n npx atomix sync --format swift -o ./Sources/DesignTokens.swift\n npx atomix sync --format kotlin -o ./app/src/.../DesignTokens.kt\n npx atomix sync --format dart -o ./lib/design_tokens.dart\n npx atomix init\n npx atomix --ds-id abc123 (start MCP server)\n\n CONFIG FILE (.atomixrc)\n {\n \"dsId\": \"your-design-system-id\",\n \"output\": \"./src/styles/tokens.css\",\n \"format\": \"css\",\n \"exclude\": [\"legacy/**\", \"vendor/**\"]\n }\n\n DEFAULT SCANNED FILES\n *.tsx, *.jsx, *.ts, *.js, *.css, *.scss, *.less, *.vue, *.svelte\n\n DEFAULT EXCLUDED\n node_modules/**, dist/**, build/**, .next/**, *.min.*, *.d.ts\n`);\n}\n\n// ============================================\n// START SERVER\n// ============================================\n\nasync function startServer() {\n if (!dsId) {\n console.error(\"Error: Missing --ds-id argument\");\n console.error(\"Usage: npx atomix --ds-id <id> --api-key <key>\");\n console.error(\"\");\n console.error(\"For sync command: npx atomix sync --help\");\n console.error(\"Get your DS ID from https://atomixstudio.eu/ds/[your-ds-id]\");\n process.exit(1);\n }\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n \n // Log to stderr so it doesn't interfere with MCP protocol on stdout\n console.error(`Atomix MCP Server started for design system: ${dsId}`);\n}\n\nasync function main() {\n switch (cliArgs.command) {\n case \"sync\":\n await runSync();\n break;\n case \"init\":\n await runInit();\n break;\n case \"help\":\n showHelp();\n break;\n case \"server\":\n default:\n await startServer();\n break;\n }\n}\n\nmain().catch((error) => {\n console.error(\"Failed:\", error);\n process.exit(1);\n});\n\n"],"mappings":";;;AAqBA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAkpCP,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,cAAc;AA3lC1B,SAAS,YAAqB;AAC5B,QAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAI,UAA8B;AAClC,MAAIA,QAAsB;AAC1B,MAAIC,UAAwB;AAC5B,MAAIC,WAAyB;AAC7B,MAAI,SAAwB;AAC5B,MAAI,SAA4B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