@agiflowai/style-system 0.0.12 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +96 -35
- package/dist/{cli.js → cli.mjs} +87 -24
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -3
- package/dist/{index.d.ts → index.d.mts} +1 -3
- package/dist/index.mjs +2 -0
- package/dist/{stdio-Db2a8Jns.js → stdio-CbJA-IPN.mjs} +343 -56
- package/dist/{stdio-BgY0loAk.cjs → stdio-DWCPGPyw.cjs} +569 -281
- package/package.json +32 -31
- package/dist/index.js +0 -3
- /package/dist/{cli.d.ts → cli.d.mts} +0 -0
|
@@ -14,9 +14,14 @@ import os from "node:os";
|
|
|
14
14
|
import { chromium, firefox, webkit } from "playwright";
|
|
15
15
|
import sharp from "sharp";
|
|
16
16
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
|
-
|
|
18
17
|
//#region src/config.ts
|
|
19
18
|
/**
|
|
19
|
+
* App-specific design system configuration
|
|
20
|
+
*
|
|
21
|
+
* This configuration is read from each app's project.json file
|
|
22
|
+
* under the "style-system" key.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
20
25
|
* Default tags for identifying shared/design system components
|
|
21
26
|
*/
|
|
22
27
|
const DEFAULT_SHARED_COMPONENT_TAGS = ["style-system"];
|
|
@@ -170,10 +175,28 @@ async function getBundlerConfig() {
|
|
|
170
175
|
if (error instanceof Error && "code" in error && error.code !== "ENOENT") log.warn(`[Config] Failed to parse toolkit.yaml: ${error.message}`);
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
|
-
|
|
174
178
|
//#endregion
|
|
175
179
|
//#region src/services/CssClasses/BaseCSSClassesService.ts
|
|
176
180
|
/**
|
|
181
|
+
* BaseCSSClassesService
|
|
182
|
+
*
|
|
183
|
+
* DESIGN PATTERNS:
|
|
184
|
+
* - Abstract base class for CSS class extraction services
|
|
185
|
+
* - Template method pattern for extensible extraction logic
|
|
186
|
+
* - Strategy pattern allowing different CSS framework implementations
|
|
187
|
+
*
|
|
188
|
+
* CODING STANDARDS:
|
|
189
|
+
* - Abstract classes define interface contracts for subclasses
|
|
190
|
+
* - Protected methods allow subclass customization
|
|
191
|
+
* - Use async/await for all I/O operations
|
|
192
|
+
* - Throw descriptive errors with context
|
|
193
|
+
*
|
|
194
|
+
* AVOID:
|
|
195
|
+
* - Direct instantiation of abstract class
|
|
196
|
+
* - Framework-specific logic in base class
|
|
197
|
+
* - Synchronous file operations
|
|
198
|
+
*/
|
|
199
|
+
/**
|
|
177
200
|
* Abstract base class for CSS class extraction services.
|
|
178
201
|
*
|
|
179
202
|
* Subclasses must implement the `extractClasses` method to provide
|
|
@@ -212,10 +235,27 @@ var BaseCSSClassesService = class {
|
|
|
212
235
|
}
|
|
213
236
|
}
|
|
214
237
|
};
|
|
215
|
-
|
|
216
238
|
//#endregion
|
|
217
239
|
//#region src/services/CssClasses/TailwindCSSClassesService.ts
|
|
218
240
|
/**
|
|
241
|
+
* TailwindCSSClassesService
|
|
242
|
+
*
|
|
243
|
+
* DESIGN PATTERNS:
|
|
244
|
+
* - Extends BaseCSSClassesService for Tailwind-specific extraction
|
|
245
|
+
* - Uses postcss AST parser for robust CSS variable extraction
|
|
246
|
+
* - Parses CSS variables from theme files to generate utility classes
|
|
247
|
+
*
|
|
248
|
+
* CODING STANDARDS:
|
|
249
|
+
* - Implement abstract methods from base class
|
|
250
|
+
* - Use async/await for file operations
|
|
251
|
+
* - Throw descriptive errors with context
|
|
252
|
+
*
|
|
253
|
+
* AVOID:
|
|
254
|
+
* - Hardcoding theme paths
|
|
255
|
+
* - Synchronous file operations
|
|
256
|
+
* - Fragile regex-based CSS parsing
|
|
257
|
+
*/
|
|
258
|
+
/**
|
|
219
259
|
* Tailwind CSS class extraction service.
|
|
220
260
|
*
|
|
221
261
|
* Extracts CSS classes from Tailwind theme files by parsing CSS variables
|
|
@@ -430,16 +470,30 @@ var TailwindCSSClassesService = class extends BaseCSSClassesService {
|
|
|
430
470
|
return result;
|
|
431
471
|
}
|
|
432
472
|
};
|
|
433
|
-
|
|
434
473
|
//#endregion
|
|
435
474
|
//#region src/services/CssClasses/types.ts
|
|
436
475
|
/**
|
|
437
476
|
* Default configuration values
|
|
438
477
|
*/
|
|
439
478
|
const DEFAULT_STYLE_SYSTEM_CONFIG = { cssFramework: "tailwind" };
|
|
440
|
-
|
|
441
479
|
//#endregion
|
|
442
480
|
//#region src/services/CssClasses/CSSClassesServiceFactory.ts
|
|
481
|
+
/**
|
|
482
|
+
* CSSClassesServiceFactory
|
|
483
|
+
*
|
|
484
|
+
* DESIGN PATTERNS:
|
|
485
|
+
* - Factory pattern for creating CSS classes service instances
|
|
486
|
+
* - Supports built-in frameworks and custom service loading
|
|
487
|
+
*
|
|
488
|
+
* CODING STANDARDS:
|
|
489
|
+
* - Use async factory method for dynamic service loading
|
|
490
|
+
* - Return typed results
|
|
491
|
+
* - Throw descriptive errors with context
|
|
492
|
+
*
|
|
493
|
+
* AVOID:
|
|
494
|
+
* - Synchronous file operations
|
|
495
|
+
* - Hardcoded framework paths
|
|
496
|
+
*/
|
|
443
497
|
/** Valid file extensions for custom service modules */
|
|
444
498
|
const VALID_SERVICE_EXTENSIONS$1 = [
|
|
445
499
|
".ts",
|
|
@@ -522,10 +576,29 @@ var CSSClassesServiceFactory = class {
|
|
|
522
576
|
}
|
|
523
577
|
}
|
|
524
578
|
};
|
|
525
|
-
|
|
526
579
|
//#endregion
|
|
527
580
|
//#region src/tools/GetCSSClassesTool.ts
|
|
528
581
|
/**
|
|
582
|
+
* GetCSSClassesTool
|
|
583
|
+
*
|
|
584
|
+
* DESIGN PATTERNS:
|
|
585
|
+
* - Tool pattern with getDefinition() and execute() methods
|
|
586
|
+
* - Service delegation for business logic via factory pattern
|
|
587
|
+
* - JSON Schema validation for inputs
|
|
588
|
+
*
|
|
589
|
+
* CODING STANDARDS:
|
|
590
|
+
* - Implement Tool interface from ../types
|
|
591
|
+
* - Use TOOL_NAME constant with snake_case (e.g., 'get_css_classes')
|
|
592
|
+
* - Return CallToolResult with content array
|
|
593
|
+
* - Handle errors with isError flag
|
|
594
|
+
* - Delegate complex logic to services
|
|
595
|
+
*
|
|
596
|
+
* AVOID:
|
|
597
|
+
* - Complex business logic in execute method
|
|
598
|
+
* - Unhandled promise rejections
|
|
599
|
+
* - Missing input validation
|
|
600
|
+
*/
|
|
601
|
+
/**
|
|
529
602
|
* Valid CSS class category values
|
|
530
603
|
*/
|
|
531
604
|
const VALID_CATEGORIES = [
|
|
@@ -565,7 +638,7 @@ var GetCSSClassesTool = class GetCSSClassesTool {
|
|
|
565
638
|
* Creates a new GetCSSClassesTool instance
|
|
566
639
|
* @param defaultThemePath - Default path to theme CSS file (relative to workspace root)
|
|
567
640
|
*/
|
|
568
|
-
constructor(defaultThemePath
|
|
641
|
+
constructor(defaultThemePath) {
|
|
569
642
|
this.serviceFactory = new CSSClassesServiceFactory();
|
|
570
643
|
this.defaultThemePath = defaultThemePath;
|
|
571
644
|
}
|
|
@@ -649,12 +722,30 @@ var GetCSSClassesTool = class GetCSSClassesTool {
|
|
|
649
722
|
return path.resolve(resolvedAppPath, config.themePath);
|
|
650
723
|
}
|
|
651
724
|
}
|
|
652
|
-
return path.resolve(workspaceRoot, this.defaultThemePath);
|
|
725
|
+
if (this.defaultThemePath) return path.resolve(workspaceRoot, this.defaultThemePath);
|
|
726
|
+
throw new Error("No theme CSS path configured. Pass --theme-path, or provide style-system.themePath in the target app project.json.");
|
|
653
727
|
}
|
|
654
728
|
};
|
|
655
|
-
|
|
656
729
|
//#endregion
|
|
657
730
|
//#region src/services/StoriesIndexService/StoriesIndexService.ts
|
|
731
|
+
/**
|
|
732
|
+
* StoriesIndexService
|
|
733
|
+
*
|
|
734
|
+
* DESIGN PATTERNS:
|
|
735
|
+
* - Service pattern for business logic encapsulation
|
|
736
|
+
* - Single responsibility principle
|
|
737
|
+
* - Caching with file content hashing
|
|
738
|
+
*
|
|
739
|
+
* CODING STANDARDS:
|
|
740
|
+
* - Use async/await for asynchronous operations
|
|
741
|
+
* - Throw descriptive errors for error cases
|
|
742
|
+
* - Keep methods focused and well-named
|
|
743
|
+
* - Document complex logic with comments
|
|
744
|
+
*
|
|
745
|
+
* AVOID:
|
|
746
|
+
* - Mixing concerns (keep focused on single domain)
|
|
747
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
748
|
+
*/
|
|
658
749
|
var StoriesIndexService = class {
|
|
659
750
|
componentIndex = /* @__PURE__ */ new Map();
|
|
660
751
|
monorepoRoot;
|
|
@@ -844,17 +935,32 @@ var StoriesIndexService = class {
|
|
|
844
935
|
return Array.from(tagSet).sort();
|
|
845
936
|
}
|
|
846
937
|
};
|
|
847
|
-
|
|
848
938
|
//#endregion
|
|
849
939
|
//#region src/services/AppComponentsService/types.ts
|
|
850
940
|
/**
|
|
851
941
|
* Default configuration values.
|
|
852
942
|
*/
|
|
853
943
|
const DEFAULT_APP_COMPONENTS_CONFIG = { pageSize: 50 };
|
|
854
|
-
|
|
855
944
|
//#endregion
|
|
856
945
|
//#region src/services/AppComponentsService/AppComponentsService.ts
|
|
857
946
|
/**
|
|
947
|
+
* AppComponentsService
|
|
948
|
+
*
|
|
949
|
+
* DESIGN PATTERNS:
|
|
950
|
+
* - Service pattern for business logic encapsulation
|
|
951
|
+
* - Single responsibility principle
|
|
952
|
+
*
|
|
953
|
+
* CODING STANDARDS:
|
|
954
|
+
* - Use async/await for asynchronous operations
|
|
955
|
+
* - Throw descriptive errors for error cases
|
|
956
|
+
* - Keep methods focused and well-named
|
|
957
|
+
* - Document complex logic with comments
|
|
958
|
+
*
|
|
959
|
+
* AVOID:
|
|
960
|
+
* - Mixing concerns (keep focused on single domain)
|
|
961
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
962
|
+
*/
|
|
963
|
+
/**
|
|
858
964
|
* AppComponentsService handles listing app-specific and package components.
|
|
859
965
|
*
|
|
860
966
|
* Detects components by file path (within app directory) and resolves
|
|
@@ -1096,7 +1202,6 @@ var AppComponentsService = class {
|
|
|
1096
1202
|
}
|
|
1097
1203
|
}
|
|
1098
1204
|
};
|
|
1099
|
-
|
|
1100
1205
|
//#endregion
|
|
1101
1206
|
//#region src/services/BundlerService/BaseBundlerService.ts
|
|
1102
1207
|
/**
|
|
@@ -1126,10 +1231,27 @@ var BaseBundlerService = class {
|
|
|
1126
1231
|
this.config = config;
|
|
1127
1232
|
}
|
|
1128
1233
|
};
|
|
1129
|
-
|
|
1130
1234
|
//#endregion
|
|
1131
1235
|
//#region src/services/BundlerService/ViteReactBundlerService.ts
|
|
1132
1236
|
/**
|
|
1237
|
+
* ViteReactBundlerService
|
|
1238
|
+
*
|
|
1239
|
+
* DESIGN PATTERNS:
|
|
1240
|
+
* - Concrete implementation of BaseBundlerService
|
|
1241
|
+
* - Singleton pattern for dev server management
|
|
1242
|
+
* - Programmatic Vite build for React component SSR
|
|
1243
|
+
*
|
|
1244
|
+
* CODING STANDARDS:
|
|
1245
|
+
* - Use async/await for asynchronous operations
|
|
1246
|
+
* - Throw descriptive errors for error cases
|
|
1247
|
+
* - Keep methods focused and well-named
|
|
1248
|
+
* - Document complex logic with comments
|
|
1249
|
+
*
|
|
1250
|
+
* AVOID:
|
|
1251
|
+
* - Mixing concerns (keep focused on Vite + React)
|
|
1252
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
1253
|
+
*/
|
|
1254
|
+
/**
|
|
1133
1255
|
* Maximum age for story configs in milliseconds (5 minutes).
|
|
1134
1256
|
* Configs older than this are cleaned up to prevent memory leaks.
|
|
1135
1257
|
*/
|
|
@@ -1372,8 +1494,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
1372
1494
|
const tmpDir = path.join(resolvedAppPath, ".tmp");
|
|
1373
1495
|
try {
|
|
1374
1496
|
await promises.mkdir(tmpDir, { recursive: true });
|
|
1375
|
-
const { createServer
|
|
1376
|
-
this.server = await createServer
|
|
1497
|
+
const { createServer } = await import("vite");
|
|
1498
|
+
this.server = await createServer({
|
|
1377
1499
|
root: tmpDir,
|
|
1378
1500
|
base: "/",
|
|
1379
1501
|
configFile: false,
|
|
@@ -1389,14 +1511,14 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
1389
1511
|
}
|
|
1390
1512
|
});
|
|
1391
1513
|
this.server.middlewares.use(async (req, res, next) => {
|
|
1392
|
-
const url
|
|
1393
|
-
const match = url
|
|
1514
|
+
const url = req.url || "/";
|
|
1515
|
+
const match = url.match(/^\/preview\/([^/?]+)/);
|
|
1394
1516
|
if (match) {
|
|
1395
1517
|
const storyId = match[1];
|
|
1396
1518
|
const config = this.storyConfigs.get(storyId);
|
|
1397
1519
|
if (config) try {
|
|
1398
1520
|
const htmlTemplate = this.generateHtmlTemplate(`@virtual:story-entry?id=${storyId}`, config.darkMode);
|
|
1399
|
-
const transformedHtml = await this.server?.transformIndexHtml(url
|
|
1521
|
+
const transformedHtml = await this.server?.transformIndexHtml(url, htmlTemplate);
|
|
1400
1522
|
res.statusCode = 200;
|
|
1401
1523
|
res.setHeader("Content-Type", "text/html");
|
|
1402
1524
|
res.end(transformedHtml);
|
|
@@ -1700,9 +1822,26 @@ root.render(wrappedElement);
|
|
|
1700
1822
|
}
|
|
1701
1823
|
}
|
|
1702
1824
|
};
|
|
1703
|
-
|
|
1704
1825
|
//#endregion
|
|
1705
1826
|
//#region src/services/BundlerService/BundlerServiceFactory.ts
|
|
1827
|
+
/**
|
|
1828
|
+
* BundlerServiceFactory
|
|
1829
|
+
*
|
|
1830
|
+
* DESIGN PATTERNS:
|
|
1831
|
+
* - Factory pattern for creating bundler service instances
|
|
1832
|
+
* - Registry pattern for bundler implementations
|
|
1833
|
+
* - Follows StoriesIndexService factory approach
|
|
1834
|
+
*
|
|
1835
|
+
* CODING STANDARDS:
|
|
1836
|
+
* - Use type-safe factory functions
|
|
1837
|
+
* - Provide sensible defaults (ViteReactBundlerService)
|
|
1838
|
+
* - Allow user-provided implementations
|
|
1839
|
+
* - Document public APIs with JSDoc
|
|
1840
|
+
*
|
|
1841
|
+
* AVOID:
|
|
1842
|
+
* - Hard-coding bundler implementations
|
|
1843
|
+
* - Breaking changes to factory interface
|
|
1844
|
+
*/
|
|
1706
1845
|
/** Valid file extensions for custom service modules */
|
|
1707
1846
|
const VALID_SERVICE_EXTENSIONS = [
|
|
1708
1847
|
".ts",
|
|
@@ -1727,22 +1866,7 @@ const VALID_SERVICE_EXTENSIONS = [
|
|
|
1727
1866
|
function createDefaultBundlerService() {
|
|
1728
1867
|
return ViteReactBundlerService.getInstance();
|
|
1729
1868
|
}
|
|
1730
|
-
|
|
1731
|
-
* Registry of available bundler service factories.
|
|
1732
|
-
* Allows registration of custom bundler implementations by key.
|
|
1733
|
-
*
|
|
1734
|
-
* @example
|
|
1735
|
-
* ```typescript
|
|
1736
|
-
* // Register a custom bundler
|
|
1737
|
-
* bundlerRegistry.set('webpack-react', () => new WebpackReactBundlerService());
|
|
1738
|
-
*
|
|
1739
|
-
* // Get a bundler by key
|
|
1740
|
-
* const factory = bundlerRegistry.get('webpack-react');
|
|
1741
|
-
* const bundler = factory?.() ?? createDefaultBundlerService();
|
|
1742
|
-
* ```
|
|
1743
|
-
*/
|
|
1744
|
-
const bundlerRegistry = /* @__PURE__ */ new Map();
|
|
1745
|
-
bundlerRegistry.set("vite-react", createDefaultBundlerService);
|
|
1869
|
+
(/* @__PURE__ */ new Map()).set("vite-react", createDefaultBundlerService);
|
|
1746
1870
|
/** Cached bundler service instance loaded from config */
|
|
1747
1871
|
let cachedBundlerService = null;
|
|
1748
1872
|
/**
|
|
@@ -1822,9 +1946,25 @@ async function getBundlerServiceFromConfig() {
|
|
|
1822
1946
|
return cachedBundlerService;
|
|
1823
1947
|
}
|
|
1824
1948
|
}
|
|
1825
|
-
|
|
1826
1949
|
//#endregion
|
|
1827
1950
|
//#region src/utils/screenshot.ts
|
|
1951
|
+
/**
|
|
1952
|
+
* Screenshot utility using Playwright
|
|
1953
|
+
*
|
|
1954
|
+
* DESIGN PATTERNS:
|
|
1955
|
+
* - Utility function for browser automation
|
|
1956
|
+
* - Factory pattern for browser selection
|
|
1957
|
+
* - Options pattern for configuration
|
|
1958
|
+
*
|
|
1959
|
+
* CODING STANDARDS:
|
|
1960
|
+
* - Use async/await for browser operations
|
|
1961
|
+
* - Clean up resources (close browser) in finally block
|
|
1962
|
+
* - Support multiple browsers (chromium, firefox, webkit)
|
|
1963
|
+
*
|
|
1964
|
+
* AVOID:
|
|
1965
|
+
* - Leaving browser instances open
|
|
1966
|
+
* - Hardcoding viewport sizes
|
|
1967
|
+
*/
|
|
1828
1968
|
const browsers = {
|
|
1829
1969
|
chromium,
|
|
1830
1970
|
firefox,
|
|
@@ -1908,10 +2048,28 @@ async function takeScreenshot(options) {
|
|
|
1908
2048
|
if (browser) await browser.close();
|
|
1909
2049
|
}
|
|
1910
2050
|
}
|
|
1911
|
-
|
|
1912
2051
|
//#endregion
|
|
1913
2052
|
//#region src/services/ThemeService/BaseThemeService.ts
|
|
1914
2053
|
/**
|
|
2054
|
+
* BaseThemeService
|
|
2055
|
+
*
|
|
2056
|
+
* DESIGN PATTERNS:
|
|
2057
|
+
* - Abstract base class for theme listing services
|
|
2058
|
+
* - Template method pattern for extensible theme extraction
|
|
2059
|
+
* - Strategy pattern allowing different theme source implementations
|
|
2060
|
+
*
|
|
2061
|
+
* CODING STANDARDS:
|
|
2062
|
+
* - Abstract classes define interface contracts for subclasses
|
|
2063
|
+
* - Protected methods allow subclass customization
|
|
2064
|
+
* - Use async/await for all I/O operations
|
|
2065
|
+
* - Throw descriptive errors with context
|
|
2066
|
+
*
|
|
2067
|
+
* AVOID:
|
|
2068
|
+
* - Direct instantiation of abstract class
|
|
2069
|
+
* - Source-specific logic in base class
|
|
2070
|
+
* - Synchronous file operations
|
|
2071
|
+
*/
|
|
2072
|
+
/**
|
|
1915
2073
|
* Abstract base class for theme listing services.
|
|
1916
2074
|
*
|
|
1917
2075
|
* Subclasses must implement the `listThemes` method to provide
|
|
@@ -1950,10 +2108,27 @@ var BaseThemeService = class {
|
|
|
1950
2108
|
}
|
|
1951
2109
|
}
|
|
1952
2110
|
};
|
|
1953
|
-
|
|
1954
2111
|
//#endregion
|
|
1955
2112
|
//#region src/services/ThemeService/CSSThemeService.ts
|
|
1956
2113
|
/**
|
|
2114
|
+
* CSSThemeService
|
|
2115
|
+
*
|
|
2116
|
+
* DESIGN PATTERNS:
|
|
2117
|
+
* - Extends BaseThemeService for CSS-based theme extraction
|
|
2118
|
+
* - Uses postcss AST parser for robust CSS parsing
|
|
2119
|
+
* - Extracts theme names from CSS class selectors
|
|
2120
|
+
*
|
|
2121
|
+
* CODING STANDARDS:
|
|
2122
|
+
* - Implement abstract methods from base class
|
|
2123
|
+
* - Use async/await for file operations
|
|
2124
|
+
* - Throw descriptive errors with context
|
|
2125
|
+
*
|
|
2126
|
+
* AVOID:
|
|
2127
|
+
* - Hardcoding theme paths
|
|
2128
|
+
* - Synchronous file operations
|
|
2129
|
+
* - Fragile regex-based CSS parsing
|
|
2130
|
+
*/
|
|
2131
|
+
/**
|
|
1957
2132
|
* CSS-based theme service implementation.
|
|
1958
2133
|
*
|
|
1959
2134
|
* Extracts themes from CSS files by parsing class selectors that contain
|
|
@@ -2080,10 +2255,26 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
2080
2255
|
});
|
|
2081
2256
|
}
|
|
2082
2257
|
};
|
|
2083
|
-
|
|
2084
2258
|
//#endregion
|
|
2085
2259
|
//#region src/services/ThemeService/ThemeService.ts
|
|
2086
2260
|
/**
|
|
2261
|
+
* ThemeService
|
|
2262
|
+
*
|
|
2263
|
+
* DESIGN PATTERNS:
|
|
2264
|
+
* - Service pattern for business logic encapsulation
|
|
2265
|
+
* - App-specific theme configuration from project.json
|
|
2266
|
+
*
|
|
2267
|
+
* CODING STANDARDS:
|
|
2268
|
+
* - Use async/await for asynchronous operations
|
|
2269
|
+
* - Throw descriptive errors for error cases
|
|
2270
|
+
* - Keep methods focused and well-named
|
|
2271
|
+
* - Document complex logic with comments
|
|
2272
|
+
*
|
|
2273
|
+
* AVOID:
|
|
2274
|
+
* - Mixing concerns (keep focused on single domain)
|
|
2275
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
2276
|
+
*/
|
|
2277
|
+
/**
|
|
2087
2278
|
* ThemeService handles theme configuration and CSS generation.
|
|
2088
2279
|
*
|
|
2089
2280
|
* Provides methods for accessing theme CSS, generating theme wrappers,
|
|
@@ -2242,7 +2433,6 @@ export default WrappedComponent;
|
|
|
2242
2433
|
}
|
|
2243
2434
|
}
|
|
2244
2435
|
};
|
|
2245
|
-
|
|
2246
2436
|
//#endregion
|
|
2247
2437
|
//#region src/services/ThemeService/types.ts
|
|
2248
2438
|
/**
|
|
@@ -2253,10 +2443,25 @@ const DEFAULT_THEME_SERVICE_CONFIG = {
|
|
|
2253
2443
|
cssFiles: [],
|
|
2254
2444
|
customServicePath: void 0
|
|
2255
2445
|
};
|
|
2256
|
-
|
|
2257
2446
|
//#endregion
|
|
2258
2447
|
//#region src/services/ThemeService/ThemeServiceFactory.ts
|
|
2259
2448
|
/**
|
|
2449
|
+
* ThemeServiceFactory
|
|
2450
|
+
*
|
|
2451
|
+
* DESIGN PATTERNS:
|
|
2452
|
+
* - Factory pattern for creating theme service instances
|
|
2453
|
+
* - Supports built-in CSS theme extraction and custom service loading
|
|
2454
|
+
*
|
|
2455
|
+
* CODING STANDARDS:
|
|
2456
|
+
* - Use async factory method for dynamic service loading
|
|
2457
|
+
* - Return typed results
|
|
2458
|
+
* - Throw descriptive errors with context
|
|
2459
|
+
*
|
|
2460
|
+
* AVOID:
|
|
2461
|
+
* - Synchronous file operations
|
|
2462
|
+
* - Hardcoded service paths
|
|
2463
|
+
*/
|
|
2464
|
+
/**
|
|
2260
2465
|
* Factory for creating theme service instances.
|
|
2261
2466
|
*
|
|
2262
2467
|
* Supports the built-in CSSThemeService and custom service implementations
|
|
@@ -2324,10 +2529,28 @@ var ThemeServiceFactory = class {
|
|
|
2324
2529
|
}
|
|
2325
2530
|
}
|
|
2326
2531
|
};
|
|
2327
|
-
|
|
2328
2532
|
//#endregion
|
|
2329
2533
|
//#region src/services/ComponentRendererService/ComponentRendererService.ts
|
|
2330
2534
|
/**
|
|
2535
|
+
* ComponentRendererService
|
|
2536
|
+
*
|
|
2537
|
+
* DESIGN PATTERNS:
|
|
2538
|
+
* - Service pattern for business logic encapsulation
|
|
2539
|
+
* - Service composition (uses BundlerService and ThemeService)
|
|
2540
|
+
* - Dependency injection for bundler service (allows custom implementations)
|
|
2541
|
+
* - HTML template generation with theme provider wrapping
|
|
2542
|
+
*
|
|
2543
|
+
* CODING STANDARDS:
|
|
2544
|
+
* - Use async/await for asynchronous operations
|
|
2545
|
+
* - Throw descriptive errors for error cases
|
|
2546
|
+
* - Keep methods focused and well-named
|
|
2547
|
+
* - Document complex logic with comments
|
|
2548
|
+
*
|
|
2549
|
+
* AVOID:
|
|
2550
|
+
* - Mixing concerns (keep focused on single domain)
|
|
2551
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
2552
|
+
*/
|
|
2553
|
+
/**
|
|
2331
2554
|
* ComponentRendererService handles rendering React components to images.
|
|
2332
2555
|
*
|
|
2333
2556
|
* Uses BundlerService for building/serving components and ThemeService
|
|
@@ -2545,7 +2768,6 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
2545
2768
|
}
|
|
2546
2769
|
}
|
|
2547
2770
|
};
|
|
2548
|
-
|
|
2549
2771
|
//#endregion
|
|
2550
2772
|
//#region src/services/GetUiComponentService/types.ts
|
|
2551
2773
|
/**
|
|
@@ -2557,10 +2779,26 @@ const DEFAULT_GET_UI_COMPONENT_CONFIG = {
|
|
|
2557
2779
|
defaultWidth: 1280,
|
|
2558
2780
|
defaultHeight: 800
|
|
2559
2781
|
};
|
|
2560
|
-
|
|
2561
2782
|
//#endregion
|
|
2562
2783
|
//#region src/services/GetUiComponentService/GetUiComponentService.ts
|
|
2563
2784
|
/**
|
|
2785
|
+
* GetUiComponentService
|
|
2786
|
+
*
|
|
2787
|
+
* DESIGN PATTERNS:
|
|
2788
|
+
* - Service pattern for business logic encapsulation
|
|
2789
|
+
* - Single responsibility principle
|
|
2790
|
+
*
|
|
2791
|
+
* CODING STANDARDS:
|
|
2792
|
+
* - Use async/await for asynchronous operations
|
|
2793
|
+
* - Throw descriptive errors for error cases
|
|
2794
|
+
* - Keep methods focused and well-named
|
|
2795
|
+
* - Document complex logic with comments
|
|
2796
|
+
*
|
|
2797
|
+
* AVOID:
|
|
2798
|
+
* - Mixing concerns (keep focused on single domain)
|
|
2799
|
+
* - Direct tool implementation (services should be tool-agnostic)
|
|
2800
|
+
*/
|
|
2801
|
+
/**
|
|
2564
2802
|
* GetUiComponentService handles rendering UI component previews.
|
|
2565
2803
|
*
|
|
2566
2804
|
* Locates components in the stories index, renders them with app-specific
|
|
@@ -2682,7 +2920,6 @@ var GetUiComponentService = class {
|
|
|
2682
2920
|
}
|
|
2683
2921
|
}
|
|
2684
2922
|
};
|
|
2685
|
-
|
|
2686
2923
|
//#endregion
|
|
2687
2924
|
//#region src/tools/GetComponentVisualTool.ts
|
|
2688
2925
|
/**
|
|
@@ -2784,7 +3021,6 @@ var GetComponentVisualTool = class GetComponentVisualTool {
|
|
|
2784
3021
|
}
|
|
2785
3022
|
}
|
|
2786
3023
|
};
|
|
2787
|
-
|
|
2788
3024
|
//#endregion
|
|
2789
3025
|
//#region src/tools/ListAppComponentsTool.ts
|
|
2790
3026
|
/**
|
|
@@ -2859,7 +3095,6 @@ var ListAppComponentsTool = class ListAppComponentsTool {
|
|
|
2859
3095
|
}
|
|
2860
3096
|
}
|
|
2861
3097
|
};
|
|
2862
|
-
|
|
2863
3098
|
//#endregion
|
|
2864
3099
|
//#region src/tools/ListThemesTool.ts
|
|
2865
3100
|
/**
|
|
@@ -2924,9 +3159,28 @@ var ListThemesTool = class ListThemesTool {
|
|
|
2924
3159
|
}
|
|
2925
3160
|
}
|
|
2926
3161
|
};
|
|
2927
|
-
|
|
2928
3162
|
//#endregion
|
|
2929
3163
|
//#region src/tools/ListSharedComponentsTool.ts
|
|
3164
|
+
/**
|
|
3165
|
+
* ListSharedComponentsTool
|
|
3166
|
+
*
|
|
3167
|
+
* DESIGN PATTERNS:
|
|
3168
|
+
* - Tool pattern with getDefinition() and execute() methods
|
|
3169
|
+
* - Service delegation for business logic
|
|
3170
|
+
* - JSON Schema validation for inputs
|
|
3171
|
+
*
|
|
3172
|
+
* CODING STANDARDS:
|
|
3173
|
+
* - Implement Tool interface from ../types
|
|
3174
|
+
* - Use TOOL_NAME constant with snake_case (e.g., 'list_shared_components')
|
|
3175
|
+
* - Return CallToolResult with content array
|
|
3176
|
+
* - Handle errors with isError flag
|
|
3177
|
+
* - Delegate complex logic to services
|
|
3178
|
+
*
|
|
3179
|
+
* AVOID:
|
|
3180
|
+
* - Complex business logic in execute method
|
|
3181
|
+
* - Unhandled promise rejections
|
|
3182
|
+
* - Missing input validation
|
|
3183
|
+
*/
|
|
2930
3184
|
var ListSharedComponentsTool = class ListSharedComponentsTool {
|
|
2931
3185
|
static TOOL_NAME = "list_shared_components";
|
|
2932
3186
|
static PAGE_SIZE = 50;
|
|
@@ -3022,9 +3276,28 @@ var ListSharedComponentsTool = class ListSharedComponentsTool {
|
|
|
3022
3276
|
}
|
|
3023
3277
|
}
|
|
3024
3278
|
};
|
|
3025
|
-
|
|
3279
|
+
//#endregion
|
|
3280
|
+
//#region package.json
|
|
3281
|
+
var version = "0.0.13";
|
|
3282
|
+
//#endregion
|
|
3283
|
+
//#region src/metadata.ts
|
|
3284
|
+
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
3285
|
+
const STYLE_SYSTEM_SERVER_NAME = "style-system";
|
|
3286
|
+
const STYLE_SYSTEM_VERSION = version;
|
|
3026
3287
|
//#endregion
|
|
3027
3288
|
//#region src/server/index.ts
|
|
3289
|
+
/**
|
|
3290
|
+
* MCP Server Setup
|
|
3291
|
+
*
|
|
3292
|
+
* DESIGN PATTERNS:
|
|
3293
|
+
* - Factory pattern for server creation
|
|
3294
|
+
* - Tool registration pattern
|
|
3295
|
+
*
|
|
3296
|
+
* CODING STANDARDS:
|
|
3297
|
+
* - Register all tools, resources, and prompts here
|
|
3298
|
+
* - Keep server setup modular and extensible
|
|
3299
|
+
* - Import tools from ../tools/ and register them in the handlers
|
|
3300
|
+
*/
|
|
3028
3301
|
const TOOL_CAPABILITIES_META_KEY = "agiflowai/capabilities";
|
|
3029
3302
|
function withCapabilities(definition, capabilities) {
|
|
3030
3303
|
return {
|
|
@@ -3035,10 +3308,10 @@ function withCapabilities(definition, capabilities) {
|
|
|
3035
3308
|
}
|
|
3036
3309
|
};
|
|
3037
3310
|
}
|
|
3038
|
-
function createServer(themePath
|
|
3311
|
+
function createServer(themePath) {
|
|
3039
3312
|
const server = new Server({
|
|
3040
|
-
name:
|
|
3041
|
-
version:
|
|
3313
|
+
name: STYLE_SYSTEM_SERVER_NAME,
|
|
3314
|
+
version: STYLE_SYSTEM_VERSION
|
|
3042
3315
|
}, {
|
|
3043
3316
|
capabilities: { tools: {} },
|
|
3044
3317
|
instructions: "Use this MCP when you work on the frontend or design. You can use this to list supported themes, get the correct tailwind classes supported by the repo, list design system components, and get visual + detailed implementation of components."
|
|
@@ -3095,10 +3368,25 @@ function createServer(themePath = "packages/frontend/web-theme/src/agimon-theme.
|
|
|
3095
3368
|
});
|
|
3096
3369
|
return server;
|
|
3097
3370
|
}
|
|
3098
|
-
|
|
3099
3371
|
//#endregion
|
|
3100
3372
|
//#region src/transports/stdio.ts
|
|
3101
3373
|
/**
|
|
3374
|
+
* STDIO Transport
|
|
3375
|
+
*
|
|
3376
|
+
* DESIGN PATTERNS:
|
|
3377
|
+
* - Transport handler pattern implementing TransportHandler interface
|
|
3378
|
+
* - Standard I/O based communication for CLI usage
|
|
3379
|
+
*
|
|
3380
|
+
* CODING STANDARDS:
|
|
3381
|
+
* - Initialize server and transport properly
|
|
3382
|
+
* - Handle cleanup on shutdown with stop() method
|
|
3383
|
+
* - Use async/await for all operations
|
|
3384
|
+
*
|
|
3385
|
+
* AVOID:
|
|
3386
|
+
* - Forgetting to close transport on shutdown
|
|
3387
|
+
* - Missing error handling for connection failures
|
|
3388
|
+
*/
|
|
3389
|
+
/**
|
|
3102
3390
|
* Stdio transport handler for MCP server
|
|
3103
3391
|
* Used for command-line and direct integrations
|
|
3104
3392
|
*/
|
|
@@ -3111,7 +3399,7 @@ var StdioTransportHandler = class {
|
|
|
3111
3399
|
async start() {
|
|
3112
3400
|
this.transport = new StdioServerTransport();
|
|
3113
3401
|
await this.server.connect(this.transport);
|
|
3114
|
-
log.info(
|
|
3402
|
+
log.info(`${STYLE_SYSTEM_SERVER_NAME} MCP server started on stdio`);
|
|
3115
3403
|
}
|
|
3116
3404
|
async stop() {
|
|
3117
3405
|
if (this.transport) {
|
|
@@ -3120,6 +3408,5 @@ var StdioTransportHandler = class {
|
|
|
3120
3408
|
}
|
|
3121
3409
|
}
|
|
3122
3410
|
};
|
|
3123
|
-
|
|
3124
3411
|
//#endregion
|
|
3125
|
-
export {
|
|
3412
|
+
export { CSSClassesServiceFactory as _, ListSharedComponentsTool as a, BaseCSSClassesService as b, GetComponentVisualTool as c, createDefaultBundlerService as d, getBundlerServiceFromConfig as f, GetCSSClassesTool as g, StoriesIndexService as h, STYLE_SYSTEM_VERSION as i, ComponentRendererService as l, BaseBundlerService as m, createServer as n, ListThemesTool as o, ViteReactBundlerService as p, STYLE_SYSTEM_CLI_NAME as r, ListAppComponentsTool as s, StdioTransportHandler as t, ThemeService as u, DEFAULT_STYLE_SYSTEM_CONFIG as v, TailwindCSSClassesService as y };
|