@agimon-ai/style-system 0.1.1

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.
@@ -0,0 +1,1959 @@
1
+ import { Container, ContainerModule } from "inversify";
2
+ import "zod";
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
+ import { AliasOptions, Plugin, UserConfig } from "vite";
5
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
6
+ //#region src/container/module.d.ts
7
+ interface StyleSystemModuleOptions {
8
+ defaultThemePath?: string;
9
+ }
10
+ declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
11
+ //#endregion
12
+ //#region src/container/types.d.ts
13
+ declare const STYLE_SYSTEM_TYPES: {
14
+ readonly ListThemesTool: symbol;
15
+ readonly GetCSSClassesTool: symbol;
16
+ readonly GetComponentVisualTool: symbol;
17
+ readonly ListSharedComponentsTool: symbol;
18
+ readonly ListAppComponentsTool: symbol;
19
+ readonly PolishComponentTool: symbol;
20
+ readonly ThemeServiceFactory: symbol;
21
+ readonly CSSClassesServiceFactory: symbol;
22
+ readonly StoriesIndexService: symbol;
23
+ readonly GetUiComponentService: symbol;
24
+ readonly AppComponentsService: symbol;
25
+ readonly StoriesIndexFactory: symbol;
26
+ readonly RendererFactory: symbol;
27
+ readonly StyleSystemConfigLoader: symbol;
28
+ readonly DefaultThemePath: symbol;
29
+ readonly GetUiComponentServiceConfig: symbol;
30
+ readonly AppComponentsServiceConfig: symbol;
31
+ };
32
+ //#endregion
33
+ //#region src/container/index.d.ts
34
+ declare function createContainer(options?: StyleSystemModuleOptions): Container;
35
+ //#endregion
36
+ //#region src/config/types.d.ts
37
+ declare const SUPPORTED_COLOR_SCHEMES: readonly ["light", "dark", "automatic"];
38
+ type ColorSchemePreference = (typeof SUPPORTED_COLOR_SCHEMES)[number];
39
+ interface StyleSystemViewport {
40
+ /** Browser viewport width in pixels */
41
+ width: number;
42
+ /** Browser viewport height in pixels */
43
+ height: number;
44
+ }
45
+ /**
46
+ * Fields that may appear in any layer: root `defaults`, a preset, or a project config.
47
+ */
48
+ interface DesignSystemFields {
49
+ /** Type of design system (tailwind or shadcn) */
50
+ type?: 'tailwind' | 'shadcn';
51
+ /** Bundler service identifier (e.g., 'vite-react', 'vite-react-native') */
52
+ bundler?: string;
53
+ /** Brand theme key for native rendering (e.g., 'gruu', 'boomlink', 'receiptnote') */
54
+ brand?: string;
55
+ /** Path to native app Unistyles runtime configuration */
56
+ unistylesConfig?: string;
57
+ /** Supported color scheme. Fixed light/dark apps override render requests. */
58
+ colorScheme?: ColorSchemePreference;
59
+ /** Default browser viewport for component screenshots. */
60
+ viewport?: StyleSystemViewport;
61
+ /** Path to tailwind config file */
62
+ tailwindConfig?: string;
63
+ /** Legacy path to a theme provider component with a default export */
64
+ themeProvider?: string;
65
+ /** Path to root component for wrapping rendered components */
66
+ rootComponent?: string;
67
+ /** CSS file paths to include */
68
+ cssFiles?: string[];
69
+ /** Component library path (for shadcn) */
70
+ componentLibrary?: string;
71
+ /** Path to theme CSS file for Tailwind class extraction */
72
+ themePath?: string;
73
+ /**
74
+ * Tags that identify shared/design system components.
75
+ * Workspace-wide tags live at the root config; see `getSharedComponentTags`.
76
+ */
77
+ sharedComponentTags?: string[];
78
+ }
79
+ /**
80
+ * Resolved design system configuration.
81
+ *
82
+ * Same shape as `DesignSystemFields` except `type` is required, which is enforced
83
+ * once by `finalizeDesignSystemConfig` rather than by any file schema.
84
+ */
85
+ interface DesignSystemConfig extends DesignSystemFields {
86
+ type: 'tailwind' | 'shadcn';
87
+ }
88
+ /** Resolution result carrying the provenance callers need. */
89
+ interface ResolvedDesignSystemConfig {
90
+ /** Merged and validated configuration. */
91
+ config: DesignSystemConfig;
92
+ /** True when the project declares its own `style-system.config.yaml`. */
93
+ hasProjectConfig: boolean;
94
+ /** Absolute path to the project config, when one exists. */
95
+ projectConfigPath?: string;
96
+ /** Preset names applied, root-most first. */
97
+ appliedPresets: string[];
98
+ }
99
+ /** Configuration for getCssClasses tool custom service override */
100
+ interface GetCssClassesConfig {
101
+ /** Path to custom service module (relative to workspace root) */
102
+ customService?: string;
103
+ }
104
+ /** Configuration for bundler service override */
105
+ interface BundlerConfig {
106
+ /** Path to custom bundler service module (relative to workspace root) */
107
+ customService?: string;
108
+ }
109
+ /** A named preset: design system fields plus an optional parent chain. */
110
+ interface PresetConfig extends DesignSystemFields {
111
+ extends?: string | string[];
112
+ }
113
+ /** Workspace root `style-system.config.yaml`, after parsing. */
114
+ interface StyleSystemRootConfig {
115
+ root: true;
116
+ sharedComponentTags?: string[];
117
+ getCssClasses?: GetCssClassesConfig;
118
+ bundler?: BundlerConfig;
119
+ defaults?: DesignSystemFields;
120
+ presets?: Record<string, PresetConfig>;
121
+ }
122
+ //#endregion
123
+ //#region src/config/StyleSystemConfigLoader.d.ts
124
+ declare class StyleSystemConfigLoader {
125
+ /**
126
+ * Promises rather than values, so concurrent resolves de-duplicate. Several
127
+ * callers hit config from inside Promise.all/allSettled.
128
+ */
129
+ private rootPromise;
130
+ private readonly projectCache;
131
+ /** Drop all cached config state. */
132
+ invalidate(): void;
133
+ /** Load and cache the workspace root config. */
134
+ loadRoot(): Promise<StyleSystemRootConfig>;
135
+ /** Resolve the merged configuration for a project. */
136
+ resolveProject(appPath: string): Promise<ResolvedDesignSystemConfig>;
137
+ private readRoot;
138
+ private readProject;
139
+ private finalize;
140
+ }
141
+ //#endregion
142
+ //#region src/config/themePath.d.ts
143
+ /**
144
+ * Resolve a configured `themePath` to an absolute filesystem path.
145
+ *
146
+ * Canonical config uses workspace-root relative paths (for example
147
+ * packages/frontend/web-theme/dist/agiflow-theme.css). The app-relative candidate
148
+ * is kept as a compatibility fallback, mainly for user supplied `--theme-path`
149
+ * values, and warns when it is the one that resolves.
150
+ */
151
+ declare function resolveStyleSystemThemePath(input: {
152
+ appPath?: string | null;
153
+ themePath: string;
154
+ }): Promise<string>;
155
+ //#endregion
156
+ //#region src/config/index.d.ts
157
+ /** Drop all cached config state. Test and long-lived-process seam. */
158
+ declare function resetStyleSystemConfigCache(): void;
159
+ /** Resolve a project's design system configuration. */
160
+ declare function getAppDesignSystemConfig(appPath: string): Promise<DesignSystemConfig>;
161
+ /** Resolve a project's configuration together with its provenance. */
162
+ declare function resolveAppDesignSystemConfig(appPath: string): Promise<ResolvedDesignSystemConfig>;
163
+ /** True when the project declares its own style-system.config.yaml. */
164
+ declare function hasStyleSystemProjectConfig(appPath: string): Promise<boolean>;
165
+ /** Workspace-wide tags that identify shared/design system components. */
166
+ declare function getSharedComponentTags(): Promise<string[]>;
167
+ //#endregion
168
+ //#region src/server/index.d.ts
169
+ declare function createServer(containerOrThemePath?: Container | string): Server;
170
+ //#endregion
171
+ //#region src/services/StoriesIndexService/types.d.ts
172
+ /**
173
+ * StoriesIndexService Types
174
+ *
175
+ * Type definitions for the StoriesIndexService service.
176
+ */
177
+ /**
178
+ * Story meta information from default export
179
+ */
180
+ interface StoryMeta {
181
+ /** Story title (e.g., "Components/Button") */
182
+ title: string;
183
+ /** Reference to the component */
184
+ component?: unknown;
185
+ /** Story tags for filtering */
186
+ tags?: string[];
187
+ /** Story parameters */
188
+ parameters?: Record<string, unknown>;
189
+ /** Arg type definitions */
190
+ argTypes?: Record<string, unknown>;
191
+ }
192
+ /**
193
+ * Component information extracted from story files
194
+ */
195
+ interface ComponentInfo {
196
+ /** Full title from meta (e.g., "Components/Button") */
197
+ title: string;
198
+ /** Absolute path to story file */
199
+ filePath: string;
200
+ /** SHA256 hash of file content for cache invalidation */
201
+ fileHash: string;
202
+ /** Tags from story meta */
203
+ tags: string[];
204
+ /** Names of exported stories */
205
+ stories: string[];
206
+ /** Full story meta object */
207
+ meta: StoryMeta;
208
+ /** Component description extracted from file header JSDoc or meta.parameters.docs.description */
209
+ description?: string;
210
+ }
211
+ /**
212
+ * Configuration options for StoriesIndexService
213
+ */
214
+ interface StoriesIndexServiceConfig {
215
+ /**
216
+ * Enable verbose logging
217
+ * @default false
218
+ */
219
+ verbose?: boolean;
220
+ /** Workspace used to resolve relative search roots. */
221
+ workspaceRoot?: string;
222
+ /** Directories to scan, relative to the workspace or absolute. Defaults to the workspace root. */
223
+ searchRoots?: string[];
224
+ /** Exact story files to add without scanning their surrounding projects. */
225
+ storyFiles?: string[];
226
+ /** Maximum number of story files parsed concurrently. */
227
+ concurrency?: number;
228
+ }
229
+ //#endregion
230
+ //#region src/services/StoriesIndexService/StoriesIndexService.d.ts
231
+ /**
232
+ * StoriesIndexService handles indexing and querying Storybook story files.
233
+ *
234
+ * Provides methods for scanning story files, extracting metadata using AST parsing,
235
+ * and querying components by tags, title, or name.
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const service = new StoriesIndexService();
240
+ * await service.initialize();
241
+ * const components = service.getAllComponents();
242
+ * const button = service.findComponentByName('Button');
243
+ * ```
244
+ */
245
+ /**
246
+ * Result of initialization with success/failure statistics.
247
+ */
248
+ interface InitializationResult {
249
+ /** Total number of story files found */
250
+ totalFiles: number;
251
+ /** Number of successfully indexed files */
252
+ successCount: number;
253
+ /** Number of files that failed to index */
254
+ failureCount: number;
255
+ /** List of files that failed with their error messages */
256
+ failures: Array<{
257
+ filePath: string;
258
+ error: string;
259
+ }>;
260
+ }
261
+ declare class StoriesIndexService {
262
+ private componentIndex;
263
+ private monorepoRoot;
264
+ private initialized;
265
+ /** Last initialization result for error reporting */
266
+ private lastInitResult;
267
+ private readonly config;
268
+ /**
269
+ * Creates a new StoriesIndexService instance
270
+ */
271
+ constructor(config?: StoriesIndexServiceConfig);
272
+ /**
273
+ * Initialize the index by scanning all .stories files.
274
+ * @returns Initialization result with success/failure statistics
275
+ */
276
+ initialize(): Promise<InitializationResult>;
277
+ /**
278
+ * Get the last initialization result.
279
+ * @returns Initialization result or null if not initialized
280
+ */
281
+ getLastInitResult(): InitializationResult | null;
282
+ private findStoryFiles;
283
+ private indexConcurrency;
284
+ private indexStoryFiles;
285
+ /**
286
+ * Index a single story file using storybook/internal/csf-tools.
287
+ *
288
+ * File reads remain cheap enough to hash on every new index. The expensive CSF
289
+ * parse is shared by content hash across service instances and concurrent rules.
290
+ */
291
+ private indexStoryFile;
292
+ private parseStoryFile;
293
+ /**
294
+ * Extract component description from file header JSDoc or meta.parameters.docs.description.
295
+ *
296
+ * Priority:
297
+ * 1. meta.parameters.docs.description.component (Storybook standard)
298
+ * 2. File header JSDoc comment (first block comment in file)
299
+ *
300
+ * @param content - Raw file content
301
+ * @param meta - Parsed meta object from csf-tools
302
+ * @returns Description string or undefined
303
+ */
304
+ private extractDescription;
305
+ /**
306
+ * Hash file content for cache invalidation
307
+ */
308
+ private hashContent;
309
+ /**
310
+ * Get all components filtered by tags
311
+ * @param tags - Optional array of tags to filter by
312
+ * @returns Array of matching components
313
+ */
314
+ getComponentsByTags(tags?: string[]): ComponentInfo[];
315
+ /**
316
+ * Get component by title
317
+ * @param title - Exact title to match (e.g., "Components/Button")
318
+ * @returns Component info or undefined
319
+ */
320
+ getComponentByTitle(title: string): ComponentInfo | undefined;
321
+ /**
322
+ * Find component by partial name match
323
+ * @param name - Partial name to search for
324
+ * @returns First matching component or undefined
325
+ */
326
+ findComponentByName(name: string, preferredAppPath?: string): ComponentInfo | undefined;
327
+ /**
328
+ * Refresh a specific file if it has changed
329
+ * @param filePath - Absolute path to story file
330
+ * @returns True if file was updated, false if unchanged
331
+ */
332
+ refreshFile(filePath: string): Promise<boolean>;
333
+ /**
334
+ * Get all indexed components
335
+ * @returns Array of all component info objects
336
+ */
337
+ getAllComponents(): ComponentInfo[];
338
+ /**
339
+ * Clear the index (useful for testing)
340
+ */
341
+ clear(): void;
342
+ /**
343
+ * Get all unique tags from indexed components
344
+ * @returns Sorted array of unique tag names
345
+ */
346
+ getAllTags(): string[];
347
+ }
348
+ //#endregion
349
+ //#region src/services/BundlerService/types.d.ts
350
+ /**
351
+ * BundlerService Types
352
+ *
353
+ * Type definitions for the BundlerService abstraction.
354
+ * Supports multiple bundler implementations (Vite, Webpack, etc.)
355
+ * and multiple frameworks (React, Vue, etc.).
356
+ */
357
+ /**
358
+ * Options for rendering a component through the bundler.
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * const options: RenderOptions = {
363
+ * componentPath: '/path/to/Button.stories.tsx',
364
+ * storyName: 'Primary',
365
+ * appPath: 'apps/my-app',
366
+ * darkMode: true,
367
+ * };
368
+ * ```
369
+ */
370
+ interface RenderOptions$1 {
371
+ /** Absolute path to the component story file */
372
+ componentPath: string;
373
+ /** Name of the story to render */
374
+ storyName: string;
375
+ /** Optional args to pass to the story */
376
+ args?: Record<string, unknown>;
377
+ /** Path to theme provider */
378
+ themePath?: string;
379
+ /** Whether to use dark mode */
380
+ darkMode?: boolean;
381
+ /** Path to the app directory */
382
+ appPath: string;
383
+ /** CSS files to import */
384
+ cssFiles?: string[];
385
+ /** Path to root component wrapper */
386
+ rootComponent?: string;
387
+ /** Path to native app Unistyles runtime configuration */
388
+ unistylesConfig?: string;
389
+ }
390
+ /**
391
+ * Internal options for building a component to static HTML.
392
+ */
393
+ interface BuildOptions {
394
+ /** Absolute path to the component story file */
395
+ componentPath: string;
396
+ /** Name of the story to render */
397
+ storyName: string;
398
+ /** Args to pass to the story */
399
+ args: Record<string, unknown>;
400
+ /** Resolved absolute path to the app directory */
401
+ appPath: string;
402
+ /** Whether to use dark mode */
403
+ darkMode: boolean;
404
+ /** CSS files to import */
405
+ cssFiles: string[];
406
+ /** Path to root component wrapper */
407
+ rootComponent?: string;
408
+ /** Path to native app Unistyles runtime configuration */
409
+ unistylesConfig?: string;
410
+ /** Temporary directory for build artifacts */
411
+ tmpDir: string;
412
+ }
413
+ /**
414
+ * Result from starting a dev server.
415
+ */
416
+ interface DevServerResult {
417
+ /** URL where the dev server is accessible */
418
+ url: string;
419
+ /** Port the server is listening on */
420
+ port: number;
421
+ }
422
+ /**
423
+ * Result from serving a component through dev server.
424
+ */
425
+ interface ServeComponentResult {
426
+ /** URL to access the rendered component */
427
+ url: string;
428
+ /** Path to the generated HTML file (optional if served from memory) */
429
+ htmlFilePath?: string;
430
+ /** The generated HTML content (optional if served from memory) */
431
+ htmlContent?: string;
432
+ }
433
+ /**
434
+ * Result from pre-rendering a component to static HTML.
435
+ */
436
+ interface PrerenderResult {
437
+ /** Path to the generated static HTML file */
438
+ htmlFilePath: string;
439
+ }
440
+ /**
441
+ * Configuration for BundlerService implementations.
442
+ */
443
+ interface BundlerServiceConfig {
444
+ /** Enable verbose logging @default false */
445
+ verbose?: boolean;
446
+ }
447
+ //#endregion
448
+ //#region src/services/BundlerService/BaseBundlerService.d.ts
449
+ /**
450
+ * Abstract base class for bundler service implementations.
451
+ *
452
+ * Subclasses must implement the abstract methods to provide
453
+ * bundler-specific (Vite, Webpack, etc.) and framework-specific
454
+ * (React, Vue, etc.) component rendering logic.
455
+ *
456
+ * @example
457
+ * ```typescript
458
+ * class MyCustomBundlerService extends BaseBundlerService {
459
+ * async startDevServer(appPath: string): Promise<DevServerResult> {
460
+ * // Custom dev server logic
461
+ * }
462
+ * // ... implement other abstract methods
463
+ * }
464
+ * ```
465
+ */
466
+ declare abstract class BaseBundlerService {
467
+ protected config: BundlerServiceConfig;
468
+ /**
469
+ * Creates a new bundler service instance.
470
+ * @param config - Service configuration options
471
+ */
472
+ constructor(config?: BundlerServiceConfig);
473
+ /**
474
+ * Get the bundler identifier for this service.
475
+ * @returns Bundler identifier string (e.g., 'vite', 'webpack')
476
+ */
477
+ abstract getBundlerId(): string;
478
+ /**
479
+ * Get the framework identifier for this service.
480
+ * @returns Framework identifier string (e.g., 'react', 'vue')
481
+ */
482
+ abstract getFrameworkId(): string;
483
+ /**
484
+ * Start a dev server for hot reload and caching.
485
+ *
486
+ * @param appPath - Absolute or relative path to the app directory
487
+ * @returns Promise resolving to server URL and port
488
+ * @throws Error if server fails to start
489
+ */
490
+ abstract startDevServer(appPath: string): Promise<DevServerResult>;
491
+ /**
492
+ * Serve a component dynamically through the dev server.
493
+ *
494
+ * @param options - Component rendering options
495
+ * @returns Promise resolving to the component URL and HTML file path
496
+ * @throws Error if dev server is not running or rendering fails
497
+ */
498
+ abstract serveComponent(options: RenderOptions$1): Promise<ServeComponentResult>;
499
+ /**
500
+ * Pre-render a component to a static HTML file.
501
+ *
502
+ * @param options - Component rendering options
503
+ * @returns Promise resolving to the HTML file path
504
+ * @throws Error if build fails
505
+ */
506
+ abstract prerenderComponent(options: RenderOptions$1): Promise<PrerenderResult>;
507
+ /**
508
+ * Check if the dev server is running.
509
+ * @returns True if server is running
510
+ */
511
+ abstract isServerRunning(): boolean;
512
+ /**
513
+ * Get the current server URL.
514
+ * @returns Server URL or null if not running
515
+ */
516
+ abstract getServerUrl(): string | null;
517
+ /**
518
+ * Get the current server port.
519
+ * @returns Server port or null if not running
520
+ */
521
+ abstract getServerPort(): number | null;
522
+ /**
523
+ * Get the current app path being served.
524
+ * @returns App path or null if not running
525
+ */
526
+ abstract getCurrentAppPath(): string | null;
527
+ /**
528
+ * Clean up server resources and reset state.
529
+ */
530
+ abstract cleanup(): Promise<void>;
531
+ }
532
+ //#endregion
533
+ //#region src/services/BundlerService/ViteReactBundlerService.d.ts
534
+ /**
535
+ * ViteReactBundlerService provides Vite + React bundling for component rendering.
536
+ *
537
+ * This is the default implementation of BaseBundlerService that uses Vite
538
+ * as the bundler and React as the framework for rendering components.
539
+ *
540
+ * @example
541
+ * ```typescript
542
+ * const service = ViteReactBundlerService.getInstance();
543
+ * await service.startDevServer('apps/my-app');
544
+ * const { url } = await service.serveComponent({
545
+ * componentPath: '/path/to/Button.stories.tsx',
546
+ * storyName: 'Primary',
547
+ * appPath: 'apps/my-app'
548
+ * });
549
+ * ```
550
+ */
551
+ declare class ViteReactBundlerService extends BaseBundlerService {
552
+ private static instance;
553
+ private server;
554
+ private monorepoRoot;
555
+ private serverUrl;
556
+ private serverPort;
557
+ private currentAppPath;
558
+ private storyConfigs;
559
+ /** Timestamps for when each story config was created, used for cleanup */
560
+ private storyConfigTimestamps;
561
+ /** Promise that resolves when server startup completes, prevents race conditions */
562
+ private serverStartPromise;
563
+ /**
564
+ * Creates a new ViteReactBundlerService instance.
565
+ * Use getInstance() for singleton access.
566
+ * @param config - Service configuration options
567
+ */
568
+ constructor(config?: BundlerServiceConfig);
569
+ /**
570
+ * Get the singleton instance of ViteReactBundlerService.
571
+ * Singleton pattern ensures only one dev server runs at a time,
572
+ * preventing port conflicts and resource duplication.
573
+ * @returns The singleton ViteReactBundlerService instance
574
+ */
575
+ static getInstance(): ViteReactBundlerService;
576
+ /**
577
+ * Reset the singleton instance.
578
+ * This is primarily used in testing to ensure a fresh instance.
579
+ * @example
580
+ * ```typescript
581
+ * afterEach(() => {
582
+ * ViteReactBundlerService.resetInstance();
583
+ * });
584
+ * ```
585
+ */
586
+ static resetInstance(): void;
587
+ /**
588
+ * Get the bundler identifier.
589
+ * @returns The bundler ID string ('vite')
590
+ */
591
+ getBundlerId(): string;
592
+ /**
593
+ * Get the framework identifier.
594
+ * @returns The framework ID string ('react')
595
+ */
596
+ getFrameworkId(): string;
597
+ /**
598
+ * Get the current server URL.
599
+ * @returns Server URL or null if not running
600
+ */
601
+ getServerUrl(): string | null;
602
+ /**
603
+ * Get the current server port.
604
+ * @returns Server port or null if not running
605
+ */
606
+ getServerPort(): number | null;
607
+ /**
608
+ * Check if the dev server is running.
609
+ * @returns True if server is running
610
+ */
611
+ isServerRunning(): boolean;
612
+ /**
613
+ * Get the current app path being served.
614
+ * @returns App path or null if not running
615
+ */
616
+ getCurrentAppPath(): string | null;
617
+ /**
618
+ * Start a Vite dev server for hot reload and caching.
619
+ * Handles concurrent calls by returning the same promise if server is already starting.
620
+ * @param appPath - Absolute or relative path to the app directory
621
+ * @returns Promise resolving to server URL and port
622
+ * @throws Error if server fails to start
623
+ */
624
+ startDevServer(appPath: string): Promise<DevServerResult>;
625
+ /**
626
+ * Internal method that performs the actual server startup.
627
+ * @param resolvedAppPath - Resolved absolute path to the app directory
628
+ * @returns Promise resolving to server URL and port
629
+ */
630
+ private doStartDevServer;
631
+ /**
632
+ * Serve a component dynamically through the dev server.
633
+ * @param options - Component rendering options
634
+ * @returns Promise resolving to the component URL and HTML file path
635
+ * @throws Error if dev server is not running or file operations fail
636
+ */
637
+ serveComponent(options: RenderOptions$1): Promise<ServeComponentResult>;
638
+ /**
639
+ * Pre-render a component to a static HTML file.
640
+ * @param options - Component rendering options
641
+ * @returns Promise resolving to the HTML file path
642
+ * @throws Error if build fails
643
+ */
644
+ prerenderComponent(options: RenderOptions$1): Promise<PrerenderResult>;
645
+ /**
646
+ * Get Vite resolve configuration for the given app path.
647
+ * Subclasses can override to add platform-specific aliases (e.g., react-native-web).
648
+ */
649
+ protected getViteResolveConfig(appPath: string): {
650
+ alias: AliasOptions;
651
+ extensions?: string[];
652
+ };
653
+ /**
654
+ * Get Vite define replacements.
655
+ * Subclasses can override to provide platform globals.
656
+ */
657
+ protected getViteDefineConfig(): UserConfig['define'];
658
+ /**
659
+ * Generate preview HTML styles.
660
+ * Subclasses can override for platform-specific layout constraints.
661
+ */
662
+ protected generatePreviewStyles(): string;
663
+ /**
664
+ * Get Vite esbuild configuration.
665
+ * Subclasses can override to handle platform-specific JSX needs.
666
+ */
667
+ protected getViteEsbuildConfig(): UserConfig['esbuild'];
668
+ /**
669
+ * Get Vite Oxc configuration.
670
+ * Subclasses can override to disable Oxc for platform-specific parsing needs.
671
+ */
672
+ protected getViteOxcConfig(): UserConfig['oxc'];
673
+ /**
674
+ * Get additional Vite plugins.
675
+ * Subclasses can override to add platform-specific plugins (e.g., @vitejs/plugin-react).
676
+ */
677
+ protected getAdditionalVitePlugins(_appPath?: string): Plugin[];
678
+ /**
679
+ * Clean up server resources and reset state.
680
+ * Closes the Vite dev server if running.
681
+ *
682
+ * Note: Errors during server close are intentionally logged but not re-thrown.
683
+ * This ensures cleanup always completes and state is reset, even if the server
684
+ * is in an unexpected state. Callers should not depend on cleanup failure detection.
685
+ */
686
+ cleanup(): Promise<void>;
687
+ /**
688
+ * Clean up stale story configs to prevent memory leaks.
689
+ * Removes configs that are older than STORY_CONFIG_MAX_AGE_MS or
690
+ * when the number of configs exceeds STORY_CONFIG_MAX_COUNT.
691
+ */
692
+ private cleanupStaleStoryConfigs;
693
+ /**
694
+ * Generate a wrapper CSS file with @source directive for Tailwind v4.
695
+ * This tells Tailwind where to scan for class names when building from .tmp directory.
696
+ * @param appPath - Absolute path to the app directory
697
+ * @param cssFiles - Array of CSS file paths to import
698
+ * @returns Generated CSS content with @source directive
699
+ */
700
+ private generateWrapperCss;
701
+ /**
702
+ * Infer an app stylesheet when project.json does not define style-system.cssFiles.
703
+ * Many Vite apps keep their Tailwind/theme entrypoint in src/assets/main.css.
704
+ */
705
+ private getDefaultCssFiles;
706
+ /**
707
+ * Generate the React entry file content for rendering a story.
708
+ * @param options - Build options including component path and story name
709
+ * @returns Generated TypeScript/JSX entry file content
710
+ */
711
+ private generateEntryFile;
712
+ /**
713
+ * Generate framework-specific setup imports that must run before story imports.
714
+ * Native rendering overrides this to load app-specific runtime setup.
715
+ */
716
+ protected generateFrameworkSetupImports(_options: BuildOptions): string;
717
+ protected generateStoryImport(componentPath: string): string;
718
+ protected wrapFrameworkElement(elementExpression: string, _options: BuildOptions): string;
719
+ /**
720
+ * Generate the HTML template for component preview.
721
+ * @param entryFileName - Name of the entry file to include
722
+ * @param darkMode - Whether to add dark mode class to HTML
723
+ * @returns Generated HTML template string
724
+ */
725
+ private generateHtmlTemplate;
726
+ private buildComponent;
727
+ }
728
+ //#endregion
729
+ //#region src/services/BundlerService/BundlerServiceFactory.d.ts
730
+ /**
731
+ * Default factory that creates a ViteReactBundlerService instance.
732
+ * Uses the singleton pattern to ensure only one dev server runs at a time.
733
+ *
734
+ * @returns The singleton ViteReactBundlerService instance
735
+ *
736
+ * @example
737
+ * ```typescript
738
+ * import { createDefaultBundlerService } from './BundlerServiceFactory';
739
+ *
740
+ * const bundler = createDefaultBundlerService();
741
+ * await bundler.startDevServer('apps/my-app');
742
+ * ```
743
+ */
744
+ declare function createDefaultBundlerService(): BaseBundlerService;
745
+ /**
746
+ * Get bundler service based on the workspace style-system.config.yaml.
747
+ *
748
+ * If a custom service is configured under bundler.customService,
749
+ * it will be dynamically loaded. Otherwise, returns the default ViteReactBundlerService.
750
+ *
751
+ * The custom service module must:
752
+ * - Export a class that extends BaseBundlerService as default export, OR
753
+ * - Export an instance of BaseBundlerService as default export, OR
754
+ * - Export a getInstance() function that returns a BaseBundlerService
755
+ *
756
+ * @returns Promise resolving to a bundler service instance
757
+ *
758
+ * @example
759
+ * ```typescript
760
+ * // In style-system.config.yaml at the workspace root:
761
+ * // bundler:
762
+ * // customService: packages/my-app/src/bundler/CustomBundlerService.ts
763
+ *
764
+ * const bundler = await getBundlerServiceFromConfig();
765
+ * await bundler.startDevServer('apps/my-app');
766
+ * ```
767
+ */
768
+ declare function getBundlerServiceFromConfig(): Promise<BaseBundlerService>;
769
+ //#endregion
770
+ //#region src/services/ComponentRendererService/types.d.ts
771
+ /**
772
+ * Factory function type for creating bundler service instances.
773
+ * Allows users to provide custom bundler implementations.
774
+ */
775
+ type BundlerFactory = () => BaseBundlerService;
776
+ /**
777
+ * Options for rendering a component
778
+ */
779
+ interface RenderOptions {
780
+ /** The story variant name to render (e.g., 'Primary', 'Secondary') */
781
+ storyName?: string;
782
+ /** Component props/arguments to pass to the story */
783
+ args?: Record<string, unknown>;
784
+ /** Whether to render in dark mode theme */
785
+ darkMode?: boolean;
786
+ /** Viewport width in pixels */
787
+ width?: number;
788
+ /** Viewport height in pixels */
789
+ height?: number;
790
+ }
791
+ /**
792
+ * Result of component rendering
793
+ */
794
+ interface RenderResult {
795
+ /** Path to the rendered image file */
796
+ imagePath: string;
797
+ /** Generated HTML content */
798
+ html: string;
799
+ /** Component metadata */
800
+ componentInfo: ComponentInfo;
801
+ /** Width of the generated screenshot in pixels */
802
+ width: number;
803
+ /** Height of the generated screenshot in pixels */
804
+ height: number;
805
+ }
806
+ //#endregion
807
+ //#region src/services/ComponentRendererService/ComponentRendererService.d.ts
808
+ /**
809
+ * ComponentRendererService handles rendering React components to images.
810
+ *
811
+ * Uses BundlerService for building/serving components and ThemeService
812
+ * for theme configuration. Supports both dev server (fast) and static
813
+ * build (fallback) rendering modes.
814
+ *
815
+ * The bundler service can be customized by providing a bundlerFactory
816
+ * to support different bundlers (Vite, Webpack) and frameworks (React, Vue).
817
+ *
818
+ * @example
819
+ * ```typescript
820
+ * // Using default bundler (Vite + React)
821
+ * const service = new ComponentRendererService(designConfig, 'apps/my-app');
822
+ *
823
+ * // Using custom bundler
824
+ * const service = new ComponentRendererService(
825
+ * designConfig,
826
+ * 'apps/my-app',
827
+ * { bundlerFactory: () => new MyCustomBundlerService() }
828
+ * );
829
+ *
830
+ * const result = await service.renderComponent(componentInfo, {
831
+ * storyName: 'Primary',
832
+ * darkMode: true,
833
+ * width: DEFAULT_RENDER_WIDTH,
834
+ * height: DEFAULT_RENDER_HEIGHT
835
+ * });
836
+ * result.imagePath;
837
+ * ```
838
+ */
839
+ declare class ComponentRendererService {
840
+ private tmpDir;
841
+ private themeService;
842
+ private appPath;
843
+ private bundlerFactory;
844
+ /**
845
+ * Creates a new ComponentRendererService instance
846
+ * @param designSystemConfig - Design system configuration
847
+ * @param appPath - Path to the app directory (relative or absolute)
848
+ * @param options - Optional configuration including custom bundler factory
849
+ */
850
+ constructor(designSystemConfig: DesignSystemConfig, appPath: string, options?: {
851
+ bundlerFactory?: BundlerFactory;
852
+ });
853
+ /**
854
+ * Get the bundler service instance.
855
+ * Uses the factory to create/retrieve the bundler.
856
+ * @returns The bundler service instance
857
+ */
858
+ private getBundlerService;
859
+ /**
860
+ * Render a component to an image
861
+ * @param componentInfo - Component metadata from StoriesIndexService
862
+ * @param options - Render options (story name, args, dimensions, etc.)
863
+ * @returns Rendered image path, HTML content, and component info
864
+ * @throws Error if rendering fails
865
+ */
866
+ renderComponent(componentInfo: ComponentInfo, options?: RenderOptions): Promise<RenderResult>;
867
+ /**
868
+ * Default maximum number of screenshot files to keep in temp directory.
869
+ * Prevents disk space issues on long-running servers.
870
+ */
871
+ private static readonly DEFAULT_MAX_TEMP_FILES;
872
+ /**
873
+ * Number of recent files to keep when cleaning up on dispose.
874
+ */
875
+ private static readonly DISPOSE_KEEP_COUNT;
876
+ /**
877
+ * Clean up old rendered files.
878
+ * Removes files older than the specified duration and enforces a max file count.
879
+ * @param olderThanMs - Remove files older than this duration (default: 1 hour)
880
+ * @param keepCount - Maximum number of recent files to keep (default: 100)
881
+ */
882
+ cleanup(olderThanMs?: number, keepCount?: number): Promise<void>;
883
+ /**
884
+ * Cleanup bundler server resources and old temp files.
885
+ * Called on service shutdown.
886
+ * Keeps the most recent files for caching purposes.
887
+ */
888
+ dispose(): Promise<void>;
889
+ }
890
+ //#endregion
891
+ //#region src/services/GetUiComponentService/types.d.ts
892
+ /**
893
+ * GetUiComponentService Types
894
+ *
895
+ * Type definitions for the GetUiComponentService service.
896
+ */
897
+ /**
898
+ * Configuration options for GetUiComponentService.
899
+ *
900
+ * All options are optional. When not provided, values from
901
+ * DEFAULT_GET_UI_COMPONENT_CONFIG are used as fallbacks.
902
+ */
903
+ interface GetUiComponentServiceConfig {
904
+ /** Default story name to render if not specified @default 'Playground' */
905
+ defaultStoryName?: string;
906
+ /** Default dark mode setting for automatic-theme apps @default false */
907
+ defaultDarkMode?: boolean;
908
+ /** Default viewport width @default 1280 */
909
+ defaultWidth?: number;
910
+ /** Default viewport height @default 800 */
911
+ defaultHeight?: number;
912
+ }
913
+ /**
914
+ * Input parameters for getting a UI component preview.
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * const input: GetUiComponentInput = {
919
+ * componentName: 'Button',
920
+ * appPath: './apps/my-app',
921
+ * storyName: 'Primary',
922
+ * darkMode: true,
923
+ * };
924
+ * ```
925
+ */
926
+ interface GetUiComponentInput {
927
+ /** The name of the component to capture (e.g., "Button", "Card") */
928
+ componentName: string;
929
+ /** App path (relative or absolute) to load design system configuration from */
930
+ appPath: string;
931
+ /** The story name to render (e.g., "Playground", "Default") */
932
+ storyName?: string;
933
+ /** Whether to render the component in dark mode */
934
+ darkMode?: boolean;
935
+ /** Browser viewport width in pixels */
936
+ width?: number;
937
+ /** Browser viewport height in pixels */
938
+ height?: number;
939
+ /** CSS selector to target specific element for screenshot */
940
+ selector?: string;
941
+ }
942
+ /**
943
+ * Result returned by GetUiComponentService.getComponent().
944
+ */
945
+ interface GetUiComponentResult {
946
+ /** Path to the rendered image file */
947
+ imagePath: string;
948
+ /** Image format */
949
+ format: string;
950
+ /** Dimension info */
951
+ dimensions: string;
952
+ /** Path to the story file */
953
+ storyFilePath: string;
954
+ /** Content of the story file */
955
+ storyFileContent: string;
956
+ /** Component title from stories index */
957
+ componentTitle: string;
958
+ /** Available stories for this component */
959
+ availableStories: string[];
960
+ /** The story that was actually rendered */
961
+ renderedStory: string;
962
+ /** Resolved light or dark color scheme used for the screenshot */
963
+ colorScheme: 'light' | 'dark';
964
+ /** Browser viewport used for the screenshot */
965
+ viewport: {
966
+ width: number;
967
+ height: number;
968
+ };
969
+ }
970
+ //#endregion
971
+ //#region src/services/GetUiComponentService/GetUiComponentService.d.ts
972
+ /**
973
+ * Factory function type for creating StoriesIndexService instances.
974
+ */
975
+ type StoriesIndexFactory = () => StoriesIndexService;
976
+ /**
977
+ * Factory function type for creating ComponentRendererService instances.
978
+ */
979
+ type RendererFactory = (config: DesignSystemConfig, appPath: string) => ComponentRendererService;
980
+ /**
981
+ * GetUiComponentService handles rendering UI component previews.
982
+ *
983
+ * Locates components in the stories index, renders them with app-specific
984
+ * design system configuration, and returns screenshot results.
985
+ *
986
+ * @example
987
+ * ```typescript
988
+ * const service = new GetUiComponentService();
989
+ * const result = await service.getComponent({
990
+ * componentName: 'Button',
991
+ * appPath: 'apps/my-app',
992
+ * });
993
+ * result.imagePath;
994
+ * ```
995
+ */
996
+ declare class GetUiComponentService {
997
+ private config;
998
+ private storiesIndexFactory;
999
+ private rendererFactory;
1000
+ /**
1001
+ * Creates a new GetUiComponentService instance.
1002
+ * @param config - Service configuration options
1003
+ * @param storiesIndexFactory - Factory for creating StoriesIndexService (for DI/testing)
1004
+ * @param rendererFactory - Factory for creating ComponentRendererService (for DI/testing)
1005
+ */
1006
+ constructor(config?: GetUiComponentServiceConfig, storiesIndexFactory?: StoriesIndexFactory, rendererFactory?: RendererFactory);
1007
+ /**
1008
+ * Get a UI component preview image.
1009
+ *
1010
+ * @param input - Component input parameters
1011
+ * @returns Result with image path and component metadata
1012
+ * @throws Error if input validation fails, component not found, or rendering fails
1013
+ */
1014
+ getComponent(input: GetUiComponentInput): Promise<GetUiComponentResult>;
1015
+ private validateViewportDimension;
1016
+ /**
1017
+ * Resolve and validate the story name.
1018
+ *
1019
+ * A mismatch throws rather than falling back to another story: the caller would
1020
+ * otherwise receive a real screenshot of a story it did not ask for, with nothing
1021
+ * downstream able to tell.
1022
+ *
1023
+ * @param requestedStory - The requested story name
1024
+ * @param availableStories - List of available stories for the component
1025
+ * @param componentTitle - Story title of the component being resolved
1026
+ * @returns The requested story name
1027
+ * @throws When the requested story is not one of the component's indexed stories
1028
+ */
1029
+ private resolveStoryName;
1030
+ /**
1031
+ * Read the story file content.
1032
+ *
1033
+ * @param filePath - Path to the story file
1034
+ * @returns File content or error message
1035
+ */
1036
+ private readStoryFile;
1037
+ }
1038
+ //#endregion
1039
+ //#region src/services/ThemeService/types.d.ts
1040
+ /**
1041
+ * ThemeService Types
1042
+ *
1043
+ * Type definitions for the ThemeService service.
1044
+ */
1045
+ /**
1046
+ * Configuration for theme service
1047
+ */
1048
+ interface ThemeServiceConfig {
1049
+ /** Path to theme CSS file (from style-system.config.yaml themePath) */
1050
+ themePath?: string;
1051
+ /** CSS files to scan for themes (from style-system.config.yaml cssFiles) */
1052
+ cssFiles?: string[];
1053
+ /** Custom service path for user-provided theme service implementation */
1054
+ customServicePath?: string;
1055
+ }
1056
+ /**
1057
+ * Theme metadata returned by listAvailableThemes
1058
+ */
1059
+ interface ThemeInfo {
1060
+ /** Theme name (derived from CSS class selector or filename) */
1061
+ name: string;
1062
+ /** Original filename with extension */
1063
+ fileName: string;
1064
+ /** Absolute path to theme file */
1065
+ path: string;
1066
+ /** Color variables defined in theme (from CSS parsing) */
1067
+ colorVariables?: Record<string, string>;
1068
+ /** Legacy: color data from JSON config (deprecated, use colorVariables) */
1069
+ colors?: Record<string, unknown>;
1070
+ /** Number of color shades (e.g., 50-950) */
1071
+ shadeCount?: number;
1072
+ }
1073
+ /**
1074
+ * Result of listing available themes
1075
+ */
1076
+ interface AvailableThemesResult {
1077
+ /** Array of available themes */
1078
+ themes: ThemeInfo[];
1079
+ /** Currently active theme name if detected */
1080
+ activeTheme?: string;
1081
+ /** Legacy: active brand name (deprecated, use activeTheme) */
1082
+ activeBrand?: string;
1083
+ /** Source of themes (css-file, json-config, custom) */
1084
+ source?: 'css-file' | 'json-config' | 'custom';
1085
+ }
1086
+ //#endregion
1087
+ //#region src/services/ThemeService/BaseThemeService.d.ts
1088
+ /**
1089
+ * Abstract base class for theme listing services.
1090
+ *
1091
+ * Subclasses must implement the `listThemes` method to provide
1092
+ * source-specific theme extraction logic (CSS files, JSON configs, etc.).
1093
+ *
1094
+ * @example
1095
+ * ```typescript
1096
+ * class MyCustomThemeService extends BaseThemeService {
1097
+ * async listThemes(): Promise<AvailableThemesResult> {
1098
+ * // Custom theme extraction logic
1099
+ * }
1100
+ * }
1101
+ * ```
1102
+ */
1103
+ declare abstract class BaseThemeService {
1104
+ protected config: ThemeServiceConfig;
1105
+ /**
1106
+ * Creates a new theme service instance
1107
+ * @param config - Theme service configuration
1108
+ */
1109
+ constructor(config: ThemeServiceConfig);
1110
+ /**
1111
+ * List available themes from the configured source.
1112
+ *
1113
+ * Subclasses must implement this method to provide source-specific
1114
+ * theme extraction logic (e.g., CSS class selectors, JSON files).
1115
+ *
1116
+ * @returns Promise resolving to available themes result
1117
+ * @throws Error if themes cannot be loaded
1118
+ */
1119
+ abstract listThemes(): Promise<AvailableThemesResult>;
1120
+ /**
1121
+ * Get the source identifier for this service
1122
+ * @returns Source identifier string (e.g., 'css-file', 'json-config', 'custom')
1123
+ */
1124
+ abstract getSourceId(): 'css-file' | 'json-config' | 'custom';
1125
+ /**
1126
+ * Validate that a file path exists and is readable.
1127
+ * Can be overridden by subclasses for custom validation.
1128
+ *
1129
+ * @param filePath - Path to validate
1130
+ * @throws Error if path is invalid or unreadable
1131
+ */
1132
+ protected validatePath(filePath: string): Promise<void>;
1133
+ }
1134
+ //#endregion
1135
+ //#region src/services/ThemeService/ThemeService.d.ts
1136
+ /**
1137
+ * ThemeService handles theme configuration and CSS generation.
1138
+ *
1139
+ * Provides methods for accessing theme CSS, generating theme wrappers,
1140
+ * and listing available theme configurations.
1141
+ *
1142
+ * @example
1143
+ * ```typescript
1144
+ * const service = new ThemeService(designConfig);
1145
+ * const cssFiles = await service.getThemeCSS();
1146
+ * const themes = await service.listAvailableThemes();
1147
+ * ```
1148
+ */
1149
+ declare class ThemeService {
1150
+ private monorepoRoot;
1151
+ private config;
1152
+ /**
1153
+ * Creates a new ThemeService instance
1154
+ * @param config - Design system configuration
1155
+ */
1156
+ constructor(config: DesignSystemConfig);
1157
+ /**
1158
+ * Get design system configuration
1159
+ * @returns Current design system configuration
1160
+ */
1161
+ getConfig(): DesignSystemConfig;
1162
+ /**
1163
+ * Get theme CSS imports from config or common locations
1164
+ * @returns Array of absolute paths to CSS files
1165
+ */
1166
+ getThemeCSS(): Promise<string[]>;
1167
+ /**
1168
+ * Generate theme provider wrapper code
1169
+ * Imports the configured provider's default export and exposes a named wrapper
1170
+ * @param componentCode - Component code to wrap
1171
+ * @param darkMode - Whether to use dark mode theme
1172
+ * @returns Generated wrapper code string
1173
+ */
1174
+ generateThemeWrapper(componentCode: string, darkMode?: boolean): string;
1175
+ /**
1176
+ * Get inline theme styles for SSR
1177
+ * @param darkMode - Whether to use dark mode styles
1178
+ * @returns Combined CSS content as string
1179
+ */
1180
+ getInlineStyles(darkMode?: boolean): Promise<string>;
1181
+ /**
1182
+ * Get Tailwind CSS classes for theming
1183
+ * @param darkMode - Whether to use dark mode classes
1184
+ * @returns Array of Tailwind class names
1185
+ */
1186
+ getTailwindClasses(darkMode?: boolean): string[];
1187
+ /**
1188
+ * Validate that the theme provider path exists
1189
+ * @returns True if theme provider is valid
1190
+ */
1191
+ validateThemeProvider(): Promise<boolean>;
1192
+ /**
1193
+ * List all available theme configurations
1194
+ * @returns Object containing themes array and active brand
1195
+ * @throws Error if themes directory cannot be read
1196
+ */
1197
+ listAvailableThemes(): Promise<AvailableThemesResult>;
1198
+ }
1199
+ //#endregion
1200
+ //#region src/services/ThemeService/ThemeServiceFactory.d.ts
1201
+ /**
1202
+ * Factory for creating theme service instances.
1203
+ *
1204
+ * Supports the built-in CSSThemeService and custom service implementations
1205
+ * loaded dynamically from user-specified paths.
1206
+ *
1207
+ * @example
1208
+ * ```typescript
1209
+ * const factory = new ThemeServiceFactory();
1210
+ *
1211
+ * // Create default CSS-based service
1212
+ * const service = await factory.createService({
1213
+ * themePath: 'apps/my-app/src/styles/colors.css'
1214
+ * });
1215
+ *
1216
+ * // Create with custom service override
1217
+ * const customService = await factory.createService({
1218
+ * customServicePath: './my-custom-theme-service.ts'
1219
+ * });
1220
+ *
1221
+ * const themes = await service.listThemes();
1222
+ * ```
1223
+ */
1224
+ declare class ThemeServiceFactory {
1225
+ /**
1226
+ * Create a theme service based on configuration.
1227
+ *
1228
+ * Resolution order:
1229
+ * 1. If customServicePath is provided, load custom service dynamically
1230
+ * 2. Otherwise, create the default CSSThemeService
1231
+ *
1232
+ * @param config - Theme service configuration
1233
+ * @returns Promise resolving to a theme service instance
1234
+ * @throws Error if custom service cannot be loaded or is invalid
1235
+ */
1236
+ createService(config?: Partial<ThemeServiceConfig>): Promise<BaseThemeService>;
1237
+ /**
1238
+ * Load a custom theme service from user-specified path.
1239
+ *
1240
+ * The custom service must export a class that extends BaseThemeService.
1241
+ *
1242
+ * @param config - Configuration with customServicePath set
1243
+ * @returns Promise resolving to custom service instance
1244
+ * @throws Error if service cannot be loaded or is invalid
1245
+ */
1246
+ private loadCustomService;
1247
+ }
1248
+ //#endregion
1249
+ //#region src/services/CssClasses/types.d.ts
1250
+ /**
1251
+ * CSSClasses Service Types
1252
+ *
1253
+ * Shared type definitions for CSS class extraction services.
1254
+ * Configuration is read from the workspace style-system.config.yaml.
1255
+ */
1256
+ /**
1257
+ * Represents a single CSS class with its name and value
1258
+ */
1259
+ interface CSSClassValue {
1260
+ class: string;
1261
+ value: string;
1262
+ }
1263
+ /**
1264
+ * Categories of CSS classes that can be extracted
1265
+ */
1266
+ type CSSClassCategory = 'colors' | 'typography' | 'spacing' | 'effects' | 'all';
1267
+ /**
1268
+ * Result of CSS class extraction organized by category
1269
+ */
1270
+ interface CSSClassesResult {
1271
+ category: string;
1272
+ classes: {
1273
+ colors?: CSSClassValue[];
1274
+ typography?: CSSClassValue[];
1275
+ spacing?: CSSClassValue[];
1276
+ effects?: CSSClassValue[];
1277
+ sidebar?: CSSClassValue[];
1278
+ icons?: CSSClassValue[];
1279
+ grid?: CSSClassValue[];
1280
+ animations?: CSSClassValue[];
1281
+ };
1282
+ totalClasses?: number;
1283
+ }
1284
+ /**
1285
+ * CSS classes service configuration
1286
+ *
1287
+ * Example style-system.config.yaml:
1288
+ * ```yaml
1289
+ * style-system:
1290
+ * getCssClasses:
1291
+ * customService: ./my-custom-css-service.ts
1292
+ * ```
1293
+ */
1294
+ interface StyleSystemConfig {
1295
+ /** CSS framework type (tailwind, vanilla, etc.) */
1296
+ cssFramework: string;
1297
+ /**
1298
+ * Custom service class path for CSS extraction override.
1299
+ * Path is relative to workspace root.
1300
+ * The module must export a class that extends BaseCSSClassesService.
1301
+ */
1302
+ customServicePath?: string;
1303
+ }
1304
+ /**
1305
+ * Default configuration values
1306
+ */
1307
+ declare const DEFAULT_STYLE_SYSTEM_CONFIG: StyleSystemConfig;
1308
+ //#endregion
1309
+ //#region src/services/CssClasses/BaseCSSClassesService.d.ts
1310
+ /**
1311
+ * Abstract base class for CSS class extraction services.
1312
+ *
1313
+ * Subclasses must implement the `extractClasses` method to provide
1314
+ * framework-specific CSS class extraction logic.
1315
+ *
1316
+ * @example
1317
+ * ```typescript
1318
+ * class MyCustomCSSService extends BaseCSSClassesService {
1319
+ * async extractClasses(category: CSSClassCategory, themePath: string): Promise<CSSClassesResult> {
1320
+ * // Custom extraction logic
1321
+ * }
1322
+ * }
1323
+ * ```
1324
+ */
1325
+ declare abstract class BaseCSSClassesService {
1326
+ protected config: StyleSystemConfig;
1327
+ /**
1328
+ * Creates a new CSS classes service instance
1329
+ * @param config - Style system configuration from style-system.config.yaml
1330
+ */
1331
+ constructor(config: StyleSystemConfig);
1332
+ /**
1333
+ * Extract CSS classes from a theme file.
1334
+ *
1335
+ * Subclasses must implement this method to provide framework-specific
1336
+ * extraction logic (e.g., Tailwind, vanilla CSS, CSS-in-JS).
1337
+ *
1338
+ * @param category - Category filter for CSS classes ('colors', 'typography', 'spacing', 'effects', 'all')
1339
+ * @param themePath - Absolute path to the theme CSS file
1340
+ * @returns Promise resolving to extracted CSS classes organized by category
1341
+ * @throws Error if theme file cannot be read or parsed
1342
+ */
1343
+ abstract extractClasses(category: string, themePath: string): Promise<CSSClassesResult>;
1344
+ /**
1345
+ * Get the CSS framework identifier for this service
1346
+ * @returns Framework identifier string (e.g., 'tailwind', 'vanilla')
1347
+ */
1348
+ abstract getFrameworkId(): string;
1349
+ /**
1350
+ * Validate that the theme path exists and is readable.
1351
+ * Can be overridden by subclasses for custom validation.
1352
+ *
1353
+ * @param themePath - Path to validate
1354
+ * @throws Error if path is invalid or unreadable
1355
+ */
1356
+ protected validateThemePath(themePath: string): Promise<void>;
1357
+ }
1358
+ //#endregion
1359
+ //#region src/services/CssClasses/TailwindCSSClassesService.d.ts
1360
+ /**
1361
+ * Tailwind CSS class extraction service.
1362
+ *
1363
+ * Extracts CSS classes from Tailwind theme files by parsing CSS variables
1364
+ * using postcss AST and generating corresponding utility class names.
1365
+ *
1366
+ * @example
1367
+ * ```typescript
1368
+ * const service = new TailwindCSSClassesService(config);
1369
+ * const result = await service.extractClasses('colors', '/path/to/theme.css');
1370
+ * console.log(result.classes.colors); // Array of color utility classes
1371
+ * ```
1372
+ */
1373
+ declare class TailwindCSSClassesService extends BaseCSSClassesService {
1374
+ /**
1375
+ * Get the CSS framework identifier
1376
+ * @returns Framework identifier string 'tailwind'
1377
+ */
1378
+ getFrameworkId(): string;
1379
+ /**
1380
+ * Extract Tailwind CSS classes from a theme file.
1381
+ *
1382
+ * Uses postcss to parse the CSS AST and safely extract variable declarations,
1383
+ * then generates corresponding Tailwind utility classes (e.g., bg-*, text-*, border-*).
1384
+ *
1385
+ * Note: If an unrecognized category is passed, the method returns a result with
1386
+ * empty classes object. Use valid categories: 'colors', 'typography', 'spacing', 'effects', 'all'.
1387
+ *
1388
+ * @param category - Category filter ('colors', 'typography', 'spacing', 'effects', 'all')
1389
+ * @param themePath - Absolute path to the theme CSS file
1390
+ * @returns Promise resolving to extracted CSS classes organized by category
1391
+ * @throws Error if theme file cannot be read or parsed
1392
+ */
1393
+ extractClasses(category: string, themePath: string): Promise<CSSClassesResult>;
1394
+ /**
1395
+ * Extract CSS variables with their values from theme content using postcss AST.
1396
+ *
1397
+ * Walks the CSS AST to find all custom property declarations (--*),
1398
+ * handling multi-line values, comments, and any CSS formatting.
1399
+ *
1400
+ * @param themeContent - Raw CSS content from theme file
1401
+ * @returns Promise resolving to Map of variable names (without --) to their values
1402
+ *
1403
+ * @example
1404
+ * ```typescript
1405
+ * // Handles standard declarations
1406
+ * // --color-primary: #3b82f6;
1407
+ *
1408
+ * // Handles multi-line declarations
1409
+ * // --shadow-lg:
1410
+ * // 0 10px 15px -3px rgba(0, 0, 0, 0.1),
1411
+ * // 0 4px 6px -4px rgba(0, 0, 0, 0.1);
1412
+ *
1413
+ * // Handles compressed CSS
1414
+ * // --color-primary:#3b82f6;--color-secondary:#10b981;
1415
+ * ```
1416
+ */
1417
+ private extractVariablesWithPostCSS;
1418
+ /**
1419
+ * Generate utility classes with actual values from CSS variables.
1420
+ *
1421
+ * Maps CSS variable naming conventions to Tailwind utility classes:
1422
+ * - color-* → bg-*, text-*, border-*, ring-*
1423
+ * - sidebar* → bg-*, text-*, border-*
1424
+ * - text-* → text-* (typography)
1425
+ * - font-* → font-* (typography)
1426
+ * - space-* → p-*, m-*, gap-*
1427
+ * - shadow-* → shadow-*
1428
+ *
1429
+ * Note: If the variables Map is empty, returns a result with empty arrays
1430
+ * for all requested categories.
1431
+ *
1432
+ * @param variables - Map of CSS variable names to values
1433
+ * @param category - Category filter for which classes to generate
1434
+ * @returns CSSClassesResult with organized classes by category
1435
+ *
1436
+ * @example
1437
+ * ```typescript
1438
+ * const variables = new Map([
1439
+ * ['color-primary', '#3b82f6'],
1440
+ * ['shadow-md', '0 4px 6px rgba(0,0,0,0.1)']
1441
+ * ]);
1442
+ * const result = generateClassesFromVariables(variables, 'colors');
1443
+ * // Returns:
1444
+ * // {
1445
+ * // category: 'colors',
1446
+ * // classes: {
1447
+ * // colors: [
1448
+ * // { class: 'bg-primary', value: '#3b82f6' },
1449
+ * // { class: 'text-primary', value: '#3b82f6' },
1450
+ * // { class: 'border-primary', value: '#3b82f6' },
1451
+ * // { class: 'ring-primary', value: '#3b82f6' }
1452
+ * // ]
1453
+ * // },
1454
+ * // totalClasses: 4
1455
+ * // }
1456
+ * ```
1457
+ */
1458
+ private generateClassesFromVariables;
1459
+ }
1460
+ //#endregion
1461
+ //#region src/services/CssClasses/CSSClassesServiceFactory.d.ts
1462
+ /**
1463
+ * Factory for creating CSS classes service instances.
1464
+ *
1465
+ * Supports built-in frameworks (tailwind) and custom service implementations
1466
+ * loaded dynamically from user-specified paths.
1467
+ *
1468
+ * @example
1469
+ * ```typescript
1470
+ * const factory = new CSSClassesServiceFactory();
1471
+ * const service = await factory.createService({ cssFramework: 'tailwind' });
1472
+ * const classes = await service.extractClasses('colors', '/path/to/theme.css');
1473
+ * ```
1474
+ */
1475
+ declare class CSSClassesServiceFactory {
1476
+ /**
1477
+ * Create a CSS classes service based on configuration.
1478
+ *
1479
+ * @param config - Style system configuration (defaults to tailwind)
1480
+ * @returns Promise resolving to a CSS classes service instance
1481
+ * @throws Error if framework is unknown or custom service cannot be loaded
1482
+ */
1483
+ createService(config?: Partial<StyleSystemConfig>): Promise<BaseCSSClassesService>;
1484
+ /**
1485
+ * Create a built-in CSS classes service based on framework identifier.
1486
+ *
1487
+ * @param config - Resolved style system configuration
1488
+ * @returns CSS classes service instance
1489
+ * @throws Error if framework is not supported
1490
+ */
1491
+ private createBuiltInService;
1492
+ /**
1493
+ * Load a custom CSS classes service from user-specified path.
1494
+ *
1495
+ * The custom service must export a class that extends BaseCSSClassesService.
1496
+ *
1497
+ * @param config - Configuration with customServicePath set
1498
+ * @returns Promise resolving to custom service instance
1499
+ * @throws Error if service cannot be loaded or is invalid
1500
+ */
1501
+ private loadCustomService;
1502
+ }
1503
+ //#endregion
1504
+ //#region src/utils/OxlintPatternGenerator.d.ts
1505
+ /**
1506
+ * A single pattern entry within the oxlint no-restricted-classes rule
1507
+ */
1508
+ interface OxlintRestrictedClassPattern {
1509
+ pattern: string;
1510
+ message: string;
1511
+ }
1512
+ /**
1513
+ * The full patterns config for the oxlint no-restricted-classes rule
1514
+ */
1515
+ interface OxlintRestrictedClassesConfig {
1516
+ patterns: OxlintRestrictedClassPattern[];
1517
+ }
1518
+ /**
1519
+ * Extract unique custom color token base names from a CSSClassesResult.
1520
+ *
1521
+ * Strips known utility prefixes (bg-, text-, border-, ring-, etc.) from
1522
+ * the color class names to derive the semantic token name (e.g., `primary`,
1523
+ * `muted-foreground`, `accent`).
1524
+ *
1525
+ * @param cssResult - The extracted CSS classes result from TailwindCSSClassesService
1526
+ * @returns Alphabetically sorted array of unique custom token base names
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * const result = await service.extractClasses('colors', themePath);
1531
+ * const tokens = extractCustomTokenNames(result);
1532
+ * // ['accent', 'background', 'destructive', 'muted', 'primary', ...]
1533
+ * ```
1534
+ */
1535
+ declare function extractCustomTokenNames(cssResult: CSSClassesResult): string[];
1536
+ /**
1537
+ * Generate an oxlint `tailwindcss/no-restricted-classes` config from
1538
+ * extracted CSS design tokens.
1539
+ *
1540
+ * Produces a regex pattern matching default Tailwind color utilities
1541
+ * (e.g., `bg-red-500`, `dark:text-zinc-100`) and a human-readable
1542
+ * message listing available custom theme tokens.
1543
+ *
1544
+ * @param cssResult - The extracted CSS classes result from TailwindCSSClassesService
1545
+ * @returns Config object suitable for the oxlint rule's `patterns` array
1546
+ *
1547
+ * @example
1548
+ * ```typescript
1549
+ * const result = await service.extractClasses('colors', themePath);
1550
+ * const config = generateRestrictedClassesConfig(result);
1551
+ * // {
1552
+ * // patterns: [{
1553
+ * // pattern: "([a-zA-Z0-9:/_-]*:)?(text|bg|...)-(slate|gray|...)-(50|100|...)(/[0-9]{1,3})?$",
1554
+ * // message: "Default Tailwind color is disabled. Use custom theme colors instead (e.g., primary, accent, muted)."
1555
+ * // }]
1556
+ * // }
1557
+ * ```
1558
+ */
1559
+ declare function generateRestrictedClassesConfig(cssResult: CSSClassesResult): OxlintRestrictedClassesConfig;
1560
+ //#endregion
1561
+ //#region src/types/index.d.ts
1562
+ /**
1563
+ * Tool definition for MCP
1564
+ */
1565
+ interface ToolDefinition {
1566
+ name: string;
1567
+ description: string;
1568
+ inputSchema: {
1569
+ type: string;
1570
+ properties: Record<string, any>;
1571
+ required?: string[];
1572
+ additionalProperties?: boolean;
1573
+ };
1574
+ _meta?: Record<string, unknown>;
1575
+ }
1576
+ /**
1577
+ * Base tool interface following MCP SDK patterns
1578
+ */
1579
+ interface Tool<TInput = any> {
1580
+ getDefinition(): ToolDefinition;
1581
+ execute(input: TInput): Promise<CallToolResult>;
1582
+ }
1583
+ //#endregion
1584
+ //#region src/tools/GetCSSClassesTool.d.ts
1585
+ /**
1586
+ * Input parameters for GetCSSClassesTool
1587
+ */
1588
+ interface GetCSSClassesInput {
1589
+ category?: string;
1590
+ appPath?: string;
1591
+ }
1592
+ /**
1593
+ * MCP Tool for extracting CSS classes from theme files.
1594
+ *
1595
+ * Uses the CSSClassesServiceFactory to create the appropriate service
1596
+ * based on configuration, supporting Tailwind and custom CSS frameworks.
1597
+ *
1598
+ * @example
1599
+ * ```typescript
1600
+ * const tool = new GetCSSClassesTool();
1601
+ * const result = await tool.execute({ category: 'colors' });
1602
+ * ```
1603
+ */
1604
+ declare class GetCSSClassesTool implements Tool<GetCSSClassesInput> {
1605
+ static readonly TOOL_NAME = "get_css_classes";
1606
+ private static readonly CSS_REUSE_INSTRUCTION;
1607
+ private serviceFactory;
1608
+ private defaultThemePath?;
1609
+ /**
1610
+ * Creates a new GetCSSClassesTool instance
1611
+ * @param serviceFactory - Injected CSSClassesServiceFactory
1612
+ * @param defaultThemePath - Default path to theme CSS file (relative to workspace root)
1613
+ */
1614
+ constructor(serviceFactory: CSSClassesServiceFactory, defaultThemePath?: string);
1615
+ /**
1616
+ * Returns the tool definition for MCP registration
1617
+ * @returns Tool definition with name, description, and input schema
1618
+ */
1619
+ getDefinition(): ToolDefinition;
1620
+ /**
1621
+ * Executes the CSS class extraction
1622
+ * @param input - Tool input parameters
1623
+ * @returns CallToolResult with extracted CSS classes or error
1624
+ */
1625
+ execute(input: GetCSSClassesInput): Promise<CallToolResult>;
1626
+ /**
1627
+ * Resolves the theme file path based on app configuration or defaults.
1628
+ *
1629
+ * Resolution strategy:
1630
+ * 1. If appPath provided, read themePath from the resolved style-system config
1631
+ * 2. themePath is resolved relative to the workspace root, with app-relative fallback
1632
+ * 3. Fall back to default theme path if not configured
1633
+ *
1634
+ * @param appPath - Optional app path to read config from
1635
+ * @returns Absolute path to the theme file
1636
+ */
1637
+ private resolveThemePath;
1638
+ }
1639
+ //#endregion
1640
+ //#region src/services/AppComponentsService/types.d.ts
1641
+ /**
1642
+ * AppComponentsService Types
1643
+ *
1644
+ * Type definitions for the AppComponentsService service.
1645
+ */
1646
+ /**
1647
+ * Configuration options for AppComponentsService.
1648
+ */
1649
+ interface AppComponentsServiceConfig {
1650
+ /** Page size for pagination @default 50 */
1651
+ pageSize?: number;
1652
+ }
1653
+ /**
1654
+ * Input parameters for listing app components.
1655
+ */
1656
+ interface ListAppComponentsInput$1 {
1657
+ /** App path (relative or absolute) to list components for */
1658
+ appPath: string;
1659
+ /** Optional pagination cursor from previous response */
1660
+ cursor?: string;
1661
+ }
1662
+ /**
1663
+ * Pagination metadata in the result.
1664
+ */
1665
+ interface PaginationInfo {
1666
+ offset: number;
1667
+ pageSize: number;
1668
+ totalComponents: number;
1669
+ hasMore: boolean;
1670
+ }
1671
+ /**
1672
+ * Brief component information for list results.
1673
+ */
1674
+ interface ComponentBrief {
1675
+ /** Component name (e.g., "Button") */
1676
+ name: string;
1677
+ /** Component description from story file JSDoc or parameters.docs.description */
1678
+ description?: string;
1679
+ }
1680
+ /**
1681
+ * Result returned by AppComponentsService.listComponents().
1682
+ */
1683
+ interface AppComponentsServiceResult {
1684
+ /** Name of the app */
1685
+ app: string;
1686
+ /** Components defined within the app directory */
1687
+ appComponents: ComponentBrief[];
1688
+ /** Components from workspace dependencies, keyed by package name */
1689
+ packageComponents: Record<string, ComponentBrief[]>;
1690
+ /** Pagination metadata */
1691
+ pagination: PaginationInfo;
1692
+ /** Cursor for fetching next page, if more results exist */
1693
+ nextCursor?: string;
1694
+ }
1695
+ //#endregion
1696
+ //#region src/services/AppComponentsService/AppComponentsService.d.ts
1697
+ /**
1698
+ * AppComponentsService handles listing app-specific and package components.
1699
+ *
1700
+ * Detects components by file path (within app directory) and resolves
1701
+ * workspace dependencies to find package components.
1702
+ *
1703
+ * @example
1704
+ * ```typescript
1705
+ * const service = new AppComponentsService();
1706
+ * const result = await service.listComponents({ appPath: 'apps/my-app' });
1707
+ * // Returns: { app: 'my-app', appComponents: ['Button'], packageComponents: {...}, pagination: {...} }
1708
+ * ```
1709
+ */
1710
+ declare class AppComponentsService {
1711
+ private config;
1712
+ /**
1713
+ * Creates a new AppComponentsService instance.
1714
+ * @param config - Service configuration options
1715
+ */
1716
+ constructor(config?: AppComponentsServiceConfig);
1717
+ /**
1718
+ * List app-specific and package components for a given application.
1719
+ * @param input - Object containing appPath and optional cursor for pagination
1720
+ * @returns Promise resolving to paginated component list
1721
+ * @throws Error if input validation fails, app path does not exist, or stories index fails to initialize
1722
+ */
1723
+ listComponents(input: ListAppComponentsInput$1): Promise<AppComponentsServiceResult>;
1724
+ /**
1725
+ * Get app name from project.json.
1726
+ * @param resolvedAppPath - Absolute path to the app directory
1727
+ * @returns App name from project.json or directory basename as fallback
1728
+ */
1729
+ private getAppName;
1730
+ /**
1731
+ * Get workspace dependencies from package.json.
1732
+ * @param resolvedAppPath - Absolute path to the app directory
1733
+ * @returns Array of workspace dependency package names
1734
+ */
1735
+ private getWorkspaceDependencies;
1736
+ /**
1737
+ * Find all package.json files in the monorepo and build a map of package name → directory path.
1738
+ * @param monorepoRoot - The root directory of the monorepo
1739
+ * @returns Promise resolving to a Map where keys are package names and values are directory paths
1740
+ * @throws Error if scanning for package.json files fails
1741
+ */
1742
+ private buildPackageMap;
1743
+ /**
1744
+ * Categorize components into app-specific and package components.
1745
+ * App components are detected by file path (within app directory).
1746
+ * Package components are matched to workspace dependencies.
1747
+ *
1748
+ * @param allComponents - All components from stories index
1749
+ * @param resolvedAppPath - Absolute path to the app directory
1750
+ * @param workspaceDependencies - List of workspace dependency package names
1751
+ * @param packageMap - Map of package name to directory path
1752
+ * @returns Categorized components with totals
1753
+ */
1754
+ private categorizeComponents;
1755
+ /**
1756
+ * Apply pagination to component lists.
1757
+ *
1758
+ * Pagination strategy:
1759
+ * 1. First, fill page with app components starting from offset
1760
+ * 2. Then, fill remaining page space with package components in order
1761
+ * 3. Track total returned for cursor calculation
1762
+ *
1763
+ * @param appComponentsArray - Sorted array of app component briefs
1764
+ * @param packageComponents - Record of package name to component briefs
1765
+ * @param offset - Current pagination offset (0-indexed)
1766
+ * @returns Paginated components and total returned count
1767
+ */
1768
+ private paginateComponents;
1769
+ /**
1770
+ * Encode pagination state into a base64 cursor string.
1771
+ * @param offset - The current offset position in the component list
1772
+ * @returns Base64-encoded cursor string for the next page
1773
+ */
1774
+ private encodeCursor;
1775
+ /**
1776
+ * Decode cursor string into pagination state.
1777
+ * @param cursor - Base64-encoded cursor string from previous response
1778
+ * @returns Object with offset position; defaults to 0 if cursor is invalid
1779
+ */
1780
+ private decodeCursor;
1781
+ }
1782
+ //#endregion
1783
+ //#region src/tools/GetComponentVisualTool.d.ts
1784
+ declare class GetComponentVisualTool implements Tool<GetUiComponentInput> {
1785
+ static readonly TOOL_NAME = "get_component_visual";
1786
+ private service;
1787
+ /**
1788
+ * Creates a new GetComponentVisualTool instance.
1789
+ * @param service - Injected GetUiComponentService instance
1790
+ */
1791
+ constructor(service: GetUiComponentService);
1792
+ /**
1793
+ * Returns the tool definition including name, description, and input schema.
1794
+ * @returns Tool definition with JSON Schema for input validation
1795
+ */
1796
+ getDefinition(): ToolDefinition;
1797
+ /**
1798
+ * Executes the tool to get a UI component preview.
1799
+ * @param input - The input parameters for getting the component
1800
+ * @returns Promise resolving to CallToolResult with component info or error
1801
+ */
1802
+ execute(input: GetUiComponentInput): Promise<CallToolResult>;
1803
+ }
1804
+ //#endregion
1805
+ //#region src/tools/ListAppComponentsTool.d.ts
1806
+ /**
1807
+ * Input parameters for ListAppComponentsTool.
1808
+ */
1809
+ interface ListAppComponentsInput {
1810
+ appPath: string;
1811
+ cursor?: string;
1812
+ }
1813
+ /**
1814
+ * Tool to list app-specific components and package components used by an app.
1815
+ *
1816
+ * Detects app components by file path (within app directory) and resolves
1817
+ * workspace dependencies to find package components from Storybook stories.
1818
+ *
1819
+ * @example
1820
+ * ```typescript
1821
+ * const tool = new ListAppComponentsTool();
1822
+ * const result = await tool.execute({ appPath: 'apps/my-app' });
1823
+ * // Returns: { app: 'my-app', appComponents: ['Button'], packageComponents: {...}, pagination: {...} }
1824
+ * ```
1825
+ */
1826
+ declare class ListAppComponentsTool implements Tool<ListAppComponentsInput> {
1827
+ static readonly TOOL_NAME = "list_app_components";
1828
+ private static readonly COMPONENT_REUSE_INSTRUCTION;
1829
+ private service;
1830
+ constructor(service: AppComponentsService);
1831
+ /**
1832
+ * Gets the tool definition including name, description, and input schema.
1833
+ * @returns Tool definition for MCP registration
1834
+ */
1835
+ getDefinition(): ToolDefinition;
1836
+ /**
1837
+ * Lists app-specific and package components for a given application.
1838
+ * @param input - Object containing appPath and optional cursor for pagination
1839
+ * @returns CallToolResult with component list or error
1840
+ */
1841
+ execute(input: ListAppComponentsInput): Promise<CallToolResult>;
1842
+ }
1843
+ //#endregion
1844
+ //#region src/tools/ListThemesTool.d.ts
1845
+ /**
1846
+ * Input parameters for ListThemesTool
1847
+ */
1848
+ interface ListThemesInput {
1849
+ appPath?: string;
1850
+ }
1851
+ /**
1852
+ * Tool to list all available theme configurations.
1853
+ *
1854
+ * Reads themes from CSS files configured in the app's project.json
1855
+ * style-system config. Themes are extracted by parsing CSS class selectors
1856
+ * that contain color variable definitions.
1857
+ *
1858
+ * @example
1859
+ * ```typescript
1860
+ * const tool = new ListThemesTool();
1861
+ * const result = await tool.execute({ appPath: 'apps/my-app' });
1862
+ * // Returns: { themes: [{ name: 'slate', ... }, { name: 'blue', ... }], source: 'css-file' }
1863
+ * ```
1864
+ */
1865
+ declare class ListThemesTool implements Tool<ListThemesInput> {
1866
+ static readonly TOOL_NAME = "list_themes";
1867
+ private serviceFactory;
1868
+ constructor(serviceFactory: ThemeServiceFactory);
1869
+ getDefinition(): ToolDefinition;
1870
+ execute(input: ListThemesInput): Promise<CallToolResult>;
1871
+ }
1872
+ //#endregion
1873
+ //#region src/tools/ListSharedComponentsTool.d.ts
1874
+ /**
1875
+ * Input parameters for ListSharedComponentsTool
1876
+ */
1877
+ interface ListSharedComponentsInput {
1878
+ /** Optional tags to filter components by. If not provided, uses sharedComponentTags from the workspace style-system.config.yaml */
1879
+ tags?: string[];
1880
+ /** Optional pagination cursor to fetch the next page of results */
1881
+ cursor?: string;
1882
+ }
1883
+ declare class ListSharedComponentsTool implements Tool<ListSharedComponentsInput> {
1884
+ static readonly TOOL_NAME = "list_shared_components";
1885
+ static readonly PAGE_SIZE = 50;
1886
+ private static readonly COMPONENT_REUSE_INSTRUCTION;
1887
+ private storiesIndexFactory;
1888
+ constructor(storiesIndexFactory: StoriesIndexFactory);
1889
+ /**
1890
+ * Encode pagination state into an opaque cursor string
1891
+ * @param offset - The current offset in the component list
1892
+ * @returns Base64 encoded cursor string
1893
+ */
1894
+ private encodeCursor;
1895
+ /**
1896
+ * Decode cursor string into pagination state
1897
+ * @param cursor - Base64 encoded cursor string
1898
+ * @returns Object containing the offset
1899
+ */
1900
+ private decodeCursor;
1901
+ /**
1902
+ * Gets the tool definition including name, description, and input schema.
1903
+ * @returns Tool definition for MCP registration
1904
+ */
1905
+ getDefinition(): ToolDefinition;
1906
+ /**
1907
+ * Lists shared UI components from the design system.
1908
+ * @param input - Object containing optional tags filter and cursor for pagination
1909
+ * @returns CallToolResult with component list or error
1910
+ */
1911
+ execute(input: ListSharedComponentsInput): Promise<CallToolResult>;
1912
+ }
1913
+ //#endregion
1914
+ //#region src/tools/PolishComponentTool.d.ts
1915
+ interface PolishComponentInput {
1916
+ filePath: string;
1917
+ instructions?: string;
1918
+ }
1919
+ declare class PolishComponentTool implements Tool<PolishComponentInput> {
1920
+ static readonly TOOL_NAME = "polish_component";
1921
+ private antigravityService;
1922
+ private getUiComponentService;
1923
+ private cssClassesServiceFactory;
1924
+ private storiesIndexFactory;
1925
+ constructor(getUiComponentService: GetUiComponentService, cssClassesServiceFactory: CSSClassesServiceFactory, storiesIndexFactory: StoriesIndexFactory);
1926
+ getDefinition(): ToolDefinition;
1927
+ execute(input: PolishComponentInput): Promise<CallToolResult>;
1928
+ private detectPlatform;
1929
+ private buildSystemPrompt;
1930
+ /**
1931
+ * Read design tokens from config.themePath.
1932
+ * For web: extracts Tailwind CSS classes. For native: reads the TypeScript types file.
1933
+ */
1934
+ private getDesignTokens;
1935
+ private findStoriesFile;
1936
+ /**
1937
+ * Find the app that owns a file, for style-system context.
1938
+ * Only apps declaring their own style-system.config.yaml are eligible.
1939
+ */
1940
+ private findAppPath;
1941
+ private getComponentVisual;
1942
+ private getDesignPrinciples;
1943
+ private getSharedComponents;
1944
+ }
1945
+ //#endregion
1946
+ //#region src/transports/stdio.d.ts
1947
+ /**
1948
+ * Stdio transport handler for MCP server
1949
+ * Used for command-line and direct integrations
1950
+ */
1951
+ declare class StdioTransportHandler {
1952
+ private server;
1953
+ private transport;
1954
+ constructor(server: Server);
1955
+ start(): Promise<void>;
1956
+ stop(): Promise<void>;
1957
+ }
1958
+ //#endregion
1959
+ export { BaseBundlerService, BaseCSSClassesService, type CSSClassCategory, type CSSClassValue, type CSSClassesResult, CSSClassesServiceFactory, ComponentRendererService, DEFAULT_STYLE_SYSTEM_CONFIG, type DesignSystemConfig, GetCSSClassesTool, GetComponentVisualTool, GetUiComponentService, ListAppComponentsTool, ListSharedComponentsTool, ListThemesTool, type OxlintRestrictedClassPattern, type OxlintRestrictedClassesConfig, PolishComponentTool, type ResolvedDesignSystemConfig, STYLE_SYSTEM_TYPES, StdioTransportHandler, StoriesIndexService, type StyleSystemConfig, StyleSystemConfigLoader, type StyleSystemModuleOptions, TailwindCSSClassesService, ThemeService, type Tool, type ToolDefinition, ViteReactBundlerService, createContainer, createDefaultBundlerService, createServer, createStyleSystemModule, extractCustomTokenNames, generateRestrictedClassesConfig, getAppDesignSystemConfig, getBundlerServiceFromConfig, getSharedComponentTags, hasStyleSystemProjectConfig, resetStyleSystemConfigCache, resolveAppDesignSystemConfig, resolveStyleSystemThemePath };