@agimon-ai/po-style-system-tooling 0.2.14-alpha.2 → 0.2.14-alpha.21
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/LICENSE +149 -21
- package/README.md +1 -2
- package/dist/cli.cjs +9 -41
- package/dist/cli.mjs +10 -42
- package/dist/index.cjs +229 -7
- package/dist/index.d.cts +361 -257
- package/dist/index.d.mts +360 -256
- package/dist/index.mjs +224 -2
- package/dist/{stdio-CT9XjOJQ.cjs → stdio-CSwuqV9E.cjs} +427 -660
- package/dist/{stdio-Dgaj2-_8.mjs → stdio-DBEflKj3.mjs} +415 -658
- package/package.json +22 -14
- package/skills/style-system/SKILL.md +43 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
import { Container, ContainerModule } from "inversify";
|
|
2
2
|
import "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { Browser } from "playwright";
|
|
4
4
|
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
5
|
-
|
|
6
|
-
interface StyleSystemModuleOptions {
|
|
7
|
-
defaultThemePath?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/container/types.d.ts
|
|
12
|
-
export declare const STYLE_SYSTEM_TYPES: {
|
|
13
|
-
readonly ListThemesTool: symbol;
|
|
14
|
-
readonly GetCSSClassesTool: symbol;
|
|
15
|
-
readonly GetComponentVisualTool: symbol;
|
|
16
|
-
readonly ListSharedComponentsTool: symbol;
|
|
17
|
-
readonly ListAppComponentsTool: symbol;
|
|
18
|
-
readonly PolishComponentTool: symbol;
|
|
19
|
-
readonly ThemeServiceFactory: symbol;
|
|
20
|
-
readonly CSSClassesServiceFactory: symbol;
|
|
21
|
-
readonly StoriesIndexService: symbol;
|
|
22
|
-
readonly GetUiComponentService: symbol;
|
|
23
|
-
readonly AppComponentsService: symbol;
|
|
24
|
-
readonly StoriesIndexFactory: symbol;
|
|
25
|
-
readonly RendererFactory: symbol;
|
|
26
|
-
readonly StyleSystemConfigLoader: symbol;
|
|
27
|
-
readonly DefaultThemePath: symbol;
|
|
28
|
-
readonly GetUiComponentServiceConfig: symbol;
|
|
29
|
-
readonly AppComponentsServiceConfig: symbol;
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/container/index.d.ts
|
|
33
|
-
export declare function createContainer(options?: StyleSystemModuleOptions): Container;
|
|
34
|
-
//#endregion
|
|
5
|
+
import { CallToolResult, Server } from "@modelcontextprotocol/server";
|
|
35
6
|
//#region src/config/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Style system configuration types.
|
|
9
|
+
*
|
|
10
|
+
* Two shapes matter here:
|
|
11
|
+
* - `DesignSystemFields` is the RAW shape as written in a `style-system.config.yaml`.
|
|
12
|
+
* Every field is optional, because any single file may only carry a fragment.
|
|
13
|
+
* - `DesignSystemConfig` is the RESOLVED shape handed to consumers after the
|
|
14
|
+
* defaults -> preset chain -> project merge. `type` is guaranteed present.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION = 7680;
|
|
36
17
|
declare const SUPPORTED_COLOR_SCHEMES: readonly ["light", "dark", "automatic"];
|
|
37
18
|
type ColorSchemePreference = (typeof SUPPORTED_COLOR_SCHEMES)[number];
|
|
38
19
|
interface StyleSystemViewport {
|
|
@@ -121,12 +102,14 @@ interface StyleSystemRootConfig {
|
|
|
121
102
|
//#endregion
|
|
122
103
|
//#region src/config/StyleSystemConfigLoader.d.ts
|
|
123
104
|
export declare class StyleSystemConfigLoader {
|
|
105
|
+
readonly workspaceRoot?: string | undefined;
|
|
124
106
|
/**
|
|
125
107
|
* Promises rather than values, so concurrent resolves de-duplicate. Several
|
|
126
108
|
* callers hit config from inside Promise.all/allSettled.
|
|
127
109
|
*/
|
|
128
110
|
private readonly rootPromises;
|
|
129
111
|
private readonly projectCache;
|
|
112
|
+
constructor(workspaceRoot?: string | undefined);
|
|
130
113
|
/** Drop all cached config state. */
|
|
131
114
|
invalidate(): void;
|
|
132
115
|
/** Load and cache the workspace root config. */
|
|
@@ -150,6 +133,7 @@ export declare class StyleSystemConfigLoader {
|
|
|
150
133
|
export declare function resolveStyleSystemThemePath(input: {
|
|
151
134
|
appPath?: string | null;
|
|
152
135
|
themePath: string;
|
|
136
|
+
workspaceRoot?: string;
|
|
153
137
|
}): Promise<string>;
|
|
154
138
|
//#endregion
|
|
155
139
|
//#region src/config/index.d.ts
|
|
@@ -164,192 +148,34 @@ export declare function hasStyleSystemProjectConfig(appPath: string): Promise<bo
|
|
|
164
148
|
/** Workspace-wide tags that identify shared/design system components. */
|
|
165
149
|
export declare function getSharedComponentTags(): Promise<string[]>;
|
|
166
150
|
//#endregion
|
|
167
|
-
//#region src/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/** Arg type definitions */
|
|
189
|
-
argTypes?: Record<string, unknown>;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Component information extracted from story files
|
|
193
|
-
*/
|
|
194
|
-
interface ComponentInfo {
|
|
195
|
-
/** Full title from meta (e.g., "Components/Button") */
|
|
196
|
-
title: string;
|
|
197
|
-
/** Absolute path to story file */
|
|
198
|
-
filePath: string;
|
|
199
|
-
/** SHA256 hash of file content for cache invalidation */
|
|
200
|
-
fileHash: string;
|
|
201
|
-
/** Tags from story meta */
|
|
202
|
-
tags: string[];
|
|
203
|
-
/** Display names of exported stories */
|
|
204
|
-
stories: string[];
|
|
205
|
-
/** Exact named exports available in the story module */
|
|
206
|
-
storyExports: string[];
|
|
207
|
-
/** Full story meta object */
|
|
208
|
-
meta: StoryMeta;
|
|
209
|
-
/** Component description extracted from file header JSDoc or meta.parameters.docs.description */
|
|
210
|
-
description?: string;
|
|
151
|
+
//#region src/utils/screenshot.d.ts
|
|
152
|
+
interface BrowserLease {
|
|
153
|
+
browser: Browser;
|
|
154
|
+
release(): void;
|
|
155
|
+
}
|
|
156
|
+
interface ScreenshotOptions {
|
|
157
|
+
/** A borrowed browser; release runs only after this render's context cleanup settles. */
|
|
158
|
+
sharedBrowser?: () => Promise<Browser | BrowserLease>;
|
|
159
|
+
url: string;
|
|
160
|
+
output: string;
|
|
161
|
+
width?: number;
|
|
162
|
+
height?: number;
|
|
163
|
+
fullPage?: boolean;
|
|
164
|
+
browser?: 'chromium' | 'firefox' | 'webkit';
|
|
165
|
+
waitTime?: number;
|
|
166
|
+
darkMode?: boolean;
|
|
167
|
+
mobile?: boolean;
|
|
168
|
+
generateThumbnail?: boolean;
|
|
169
|
+
thumbnailWidth?: number;
|
|
170
|
+
thumbnailQuality?: number;
|
|
171
|
+
base64?: boolean;
|
|
211
172
|
}
|
|
212
173
|
/**
|
|
213
|
-
*
|
|
174
|
+
* Attempts to launch a browser, trying multiple configurations in order of preference.
|
|
175
|
+
* @returns Launched browser instance
|
|
176
|
+
* @throws Error if no browser can be launched
|
|
214
177
|
*/
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Enable verbose logging
|
|
218
|
-
* @default false
|
|
219
|
-
*/
|
|
220
|
-
verbose?: boolean;
|
|
221
|
-
/** Workspace used to resolve relative search roots. */
|
|
222
|
-
workspaceRoot?: string;
|
|
223
|
-
/** Directories to scan, relative to the workspace or absolute. Defaults to the workspace root. */
|
|
224
|
-
searchRoots?: string[];
|
|
225
|
-
/** Exact story files to add without scanning their surrounding projects. */
|
|
226
|
-
storyFiles?: string[];
|
|
227
|
-
/** Maximum number of story files parsed concurrently. */
|
|
228
|
-
concurrency?: number;
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/services/StoriesIndexService/StoriesIndexService.d.ts
|
|
232
|
-
/**
|
|
233
|
-
* StoriesIndexService handles indexing and querying Storybook story files.
|
|
234
|
-
*
|
|
235
|
-
* Provides methods for scanning story files, extracting metadata using AST parsing,
|
|
236
|
-
* and querying components by tags, title, or name.
|
|
237
|
-
*
|
|
238
|
-
* @example
|
|
239
|
-
* ```typescript
|
|
240
|
-
* const service = new StoriesIndexService();
|
|
241
|
-
* await service.initialize();
|
|
242
|
-
* const components = service.getAllComponents();
|
|
243
|
-
* const button = service.findComponentByName('Button');
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
/**
|
|
247
|
-
* Result of initialization with success/failure statistics.
|
|
248
|
-
*/
|
|
249
|
-
interface InitializationResult {
|
|
250
|
-
/** Total number of story files found */
|
|
251
|
-
totalFiles: number;
|
|
252
|
-
/** Number of successfully indexed files */
|
|
253
|
-
successCount: number;
|
|
254
|
-
/** Number of files that failed to index */
|
|
255
|
-
failureCount: number;
|
|
256
|
-
/** List of files that failed with their error messages */
|
|
257
|
-
failures: Array<{
|
|
258
|
-
filePath: string;
|
|
259
|
-
error: string;
|
|
260
|
-
}>;
|
|
261
|
-
}
|
|
262
|
-
export declare class StoriesIndexService {
|
|
263
|
-
private componentIndex;
|
|
264
|
-
private componentFileIndex;
|
|
265
|
-
private monorepoRoot;
|
|
266
|
-
private initialized;
|
|
267
|
-
/** Last initialization result for error reporting */
|
|
268
|
-
private lastInitResult;
|
|
269
|
-
private readonly config;
|
|
270
|
-
/**
|
|
271
|
-
* Creates a new StoriesIndexService instance
|
|
272
|
-
*/
|
|
273
|
-
constructor(config?: StoriesIndexServiceConfig);
|
|
274
|
-
/**
|
|
275
|
-
* Initialize the index by scanning all .stories files.
|
|
276
|
-
* @returns Initialization result with success/failure statistics
|
|
277
|
-
*/
|
|
278
|
-
initialize(): Promise<InitializationResult>;
|
|
279
|
-
/**
|
|
280
|
-
* Get the last initialization result.
|
|
281
|
-
* @returns Initialization result or null if not initialized
|
|
282
|
-
*/
|
|
283
|
-
getLastInitResult(): InitializationResult | null;
|
|
284
|
-
private findStoryFiles;
|
|
285
|
-
private indexConcurrency;
|
|
286
|
-
private indexStoryFiles;
|
|
287
|
-
/**
|
|
288
|
-
* Index a single story file using storybook/internal/csf-tools.
|
|
289
|
-
*
|
|
290
|
-
* File reads remain cheap enough to hash on every new index. The expensive CSF
|
|
291
|
-
* parse is shared by content hash across service instances and concurrent rules.
|
|
292
|
-
*/
|
|
293
|
-
private indexStoryFile;
|
|
294
|
-
private storeComponent;
|
|
295
|
-
private parseStoryFile;
|
|
296
|
-
/**
|
|
297
|
-
* Extract component description from file header JSDoc or meta.parameters.docs.description.
|
|
298
|
-
*
|
|
299
|
-
* Priority:
|
|
300
|
-
* 1. meta.parameters.docs.description.component (Storybook standard)
|
|
301
|
-
* 2. File header JSDoc comment (first block comment in file)
|
|
302
|
-
*
|
|
303
|
-
* @param content - Raw file content
|
|
304
|
-
* @param meta - Parsed meta object from csf-tools
|
|
305
|
-
* @returns Description string or undefined
|
|
306
|
-
*/
|
|
307
|
-
private extractDescription;
|
|
308
|
-
/**
|
|
309
|
-
* Hash file content for cache invalidation
|
|
310
|
-
*/
|
|
311
|
-
private hashContent;
|
|
312
|
-
/**
|
|
313
|
-
* Get all components filtered by tags
|
|
314
|
-
* @param tags - Optional array of tags to filter by
|
|
315
|
-
* @returns Array of matching components
|
|
316
|
-
*/
|
|
317
|
-
getComponentsByTags(tags?: string[]): ComponentInfo[];
|
|
318
|
-
/**
|
|
319
|
-
* Get component by title
|
|
320
|
-
* @param title - Exact title to match (e.g., "Components/Button")
|
|
321
|
-
* @returns Component info or undefined
|
|
322
|
-
*/
|
|
323
|
-
getComponentByTitle(title: string): ComponentInfo | undefined;
|
|
324
|
-
/**
|
|
325
|
-
* Find component by partial name match
|
|
326
|
-
* @param name - Partial name to search for
|
|
327
|
-
* @returns First matching component or undefined
|
|
328
|
-
*/
|
|
329
|
-
findComponentByName(name: string, preferredAppPath?: string): ComponentInfo | undefined;
|
|
330
|
-
/**
|
|
331
|
-
* Refresh a specific file if it has changed
|
|
332
|
-
* @param filePath - Absolute path to story file
|
|
333
|
-
* @returns True if file was updated, false if unchanged
|
|
334
|
-
*/
|
|
335
|
-
refreshFile(filePath: string): Promise<boolean>;
|
|
336
|
-
/** Get one indexed component by its canonical story file path. */
|
|
337
|
-
getComponentByFilePath(filePath: string): ComponentInfo | undefined;
|
|
338
|
-
/**
|
|
339
|
-
* Get all indexed components
|
|
340
|
-
* @returns Array of all component info objects
|
|
341
|
-
*/
|
|
342
|
-
getAllComponents(): ComponentInfo[];
|
|
343
|
-
/**
|
|
344
|
-
* Clear the index (useful for testing)
|
|
345
|
-
*/
|
|
346
|
-
clear(): void;
|
|
347
|
-
/**
|
|
348
|
-
* Get all unique tags from indexed components
|
|
349
|
-
* @returns Sorted array of unique tag names
|
|
350
|
-
*/
|
|
351
|
-
getAllTags(): string[];
|
|
352
|
-
}
|
|
178
|
+
export declare function launchBrowserWithFallback(): Promise<Browser>;
|
|
353
179
|
//#endregion
|
|
354
180
|
//#region src/services/BundlerService/types.d.ts
|
|
355
181
|
/**
|
|
@@ -554,6 +380,7 @@ export declare abstract class BaseBundlerService {
|
|
|
554
380
|
* ```
|
|
555
381
|
*/
|
|
556
382
|
export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
383
|
+
private readonly workspaceRoot?;
|
|
557
384
|
private static instance;
|
|
558
385
|
private server;
|
|
559
386
|
private monorepoRoot;
|
|
@@ -570,7 +397,7 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
570
397
|
* Use getInstance() for singleton access.
|
|
571
398
|
* @param config - Service configuration options
|
|
572
399
|
*/
|
|
573
|
-
constructor(config?: BundlerServiceConfig);
|
|
400
|
+
constructor(config?: BundlerServiceConfig, workspaceRoot?: string | undefined);
|
|
574
401
|
/**
|
|
575
402
|
* Get the singleton instance of ViteReactBundlerService.
|
|
576
403
|
* Singleton pattern ensures only one dev server runs at a time,
|
|
@@ -731,7 +558,31 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
731
558
|
private buildComponent;
|
|
732
559
|
}
|
|
733
560
|
//#endregion
|
|
561
|
+
//#region src/services/BundlerService/ViteReactNativeBundlerService.d.ts
|
|
562
|
+
export declare class ViteReactNativeBundlerService extends ViteReactBundlerService {
|
|
563
|
+
private static nativeInstance;
|
|
564
|
+
static getInstance(): ViteReactNativeBundlerService;
|
|
565
|
+
getBundlerId(): string;
|
|
566
|
+
protected getAdditionalVitePlugins(appPath?: string): Plugin[];
|
|
567
|
+
protected generateFrameworkSetupImports(options: BuildOptions): string;
|
|
568
|
+
protected generateStoryImport(componentPath: string): string;
|
|
569
|
+
protected wrapFrameworkElement(elementExpression: string): string;
|
|
570
|
+
protected getViteEsbuildConfig(): undefined;
|
|
571
|
+
protected getViteOxcConfig(): false;
|
|
572
|
+
protected getViteDefineConfig(): UserConfig['define'];
|
|
573
|
+
protected generatePreviewStyles(): string;
|
|
574
|
+
protected getViteResolveConfig(appPath: string): {
|
|
575
|
+
alias: AliasOptions;
|
|
576
|
+
extensions?: string[];
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
//#endregion
|
|
734
580
|
//#region src/services/BundlerService/BundlerServiceFactory.d.ts
|
|
581
|
+
/**
|
|
582
|
+
* Factory function type for creating bundler service instances.
|
|
583
|
+
* Users can provide custom implementations by defining their own factory.
|
|
584
|
+
*/
|
|
585
|
+
type BundlerServiceFactory = () => BaseBundlerService;
|
|
735
586
|
/**
|
|
736
587
|
* Default factory that creates a ViteReactBundlerService instance.
|
|
737
588
|
* Uses the singleton pattern to ensure only one dev server runs at a time.
|
|
@@ -746,7 +597,7 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
746
597
|
* await bundler.startDevServer('apps/my-app');
|
|
747
598
|
* ```
|
|
748
599
|
*/
|
|
749
|
-
export declare function createDefaultBundlerService(): BaseBundlerService;
|
|
600
|
+
export declare function createDefaultBundlerService(workspaceRoot?: string): BaseBundlerService;
|
|
750
601
|
/**
|
|
751
602
|
* Get a bundler service by its identifier.
|
|
752
603
|
* Returns the default ViteReactBundlerService if the key is not found.
|
|
@@ -763,7 +614,7 @@ export declare function createDefaultBundlerService(): BaseBundlerService;
|
|
|
763
614
|
* const bundler = getBundlerService('unknown'); // Returns ViteReactBundlerService
|
|
764
615
|
* ```
|
|
765
616
|
*/
|
|
766
|
-
export declare function getBundlerService(key: string): BaseBundlerService;
|
|
617
|
+
export declare function getBundlerService(key: string, workspaceRoot?: string): BaseBundlerService;
|
|
767
618
|
/**
|
|
768
619
|
* Get bundler service based on the workspace style-system.config.yaml.
|
|
769
620
|
*
|
|
@@ -787,7 +638,235 @@ export declare function getBundlerService(key: string): BaseBundlerService;
|
|
|
787
638
|
* await bundler.startDevServer('apps/my-app');
|
|
788
639
|
* ```
|
|
789
640
|
*/
|
|
790
|
-
export declare function getBundlerServiceFromConfig(
|
|
641
|
+
export declare function getBundlerServiceFromConfig(options?: {
|
|
642
|
+
workspaceRoot: string;
|
|
643
|
+
configLoader?: StyleSystemConfigLoader;
|
|
644
|
+
defaultFactory?: BundlerServiceFactory;
|
|
645
|
+
}): Promise<BaseBundlerService>;
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/container/module.d.ts
|
|
648
|
+
interface StyleSystemModuleOptions {
|
|
649
|
+
/** Explicit checkout for a long-lived host; omitted keeps standalone discovery. */
|
|
650
|
+
workspaceRoot?: string;
|
|
651
|
+
defaultThemePath?: string;
|
|
652
|
+
bundlerFactory?: (config: DesignSystemConfig) => BaseBundlerService;
|
|
653
|
+
temporaryDirectory?: string;
|
|
654
|
+
/** A browser a long-lived host keeps warm across renders; one-shot CLI runs leave it unset. */
|
|
655
|
+
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
656
|
+
}
|
|
657
|
+
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/container/types.d.ts
|
|
660
|
+
export declare const STYLE_SYSTEM_TYPES: {
|
|
661
|
+
readonly ListThemesTool: symbol;
|
|
662
|
+
readonly GetCSSClassesTool: symbol;
|
|
663
|
+
readonly GetComponentVisualTool: symbol;
|
|
664
|
+
readonly ListSharedComponentsTool: symbol;
|
|
665
|
+
readonly ListAppComponentsTool: symbol;
|
|
666
|
+
readonly ThemeServiceFactory: symbol;
|
|
667
|
+
readonly CSSClassesServiceFactory: symbol;
|
|
668
|
+
readonly StoriesIndexService: symbol;
|
|
669
|
+
readonly GetUiComponentService: symbol;
|
|
670
|
+
readonly AppComponentsService: symbol;
|
|
671
|
+
readonly StoriesIndexFactory: symbol;
|
|
672
|
+
readonly RendererFactory: symbol;
|
|
673
|
+
readonly StyleSystemConfigLoader: symbol;
|
|
674
|
+
readonly WorkspaceRoot: symbol;
|
|
675
|
+
readonly DefaultThemePath: symbol;
|
|
676
|
+
readonly GetUiComponentServiceConfig: symbol;
|
|
677
|
+
readonly AppComponentsServiceConfig: symbol;
|
|
678
|
+
};
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/container/index.d.ts
|
|
681
|
+
export declare function createContainer(options?: StyleSystemModuleOptions): Container;
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/server/index.d.ts
|
|
684
|
+
export declare function createServer(containerOrThemePath?: Container | string): Server;
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/services/StoriesIndexService/types.d.ts
|
|
687
|
+
/**
|
|
688
|
+
* StoriesIndexService Types
|
|
689
|
+
*
|
|
690
|
+
* Type definitions for the StoriesIndexService service.
|
|
691
|
+
*/
|
|
692
|
+
/**
|
|
693
|
+
* Story meta information from default export
|
|
694
|
+
*/
|
|
695
|
+
interface StoryMeta {
|
|
696
|
+
/** Story title (e.g., "Components/Button") */
|
|
697
|
+
title: string;
|
|
698
|
+
/** Reference to the component */
|
|
699
|
+
component?: unknown;
|
|
700
|
+
/** Story tags for filtering */
|
|
701
|
+
tags?: string[];
|
|
702
|
+
/** Story parameters */
|
|
703
|
+
parameters?: Record<string, unknown>;
|
|
704
|
+
/** Arg type definitions */
|
|
705
|
+
argTypes?: Record<string, unknown>;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Component information extracted from story files
|
|
709
|
+
*/
|
|
710
|
+
interface ComponentInfo {
|
|
711
|
+
/** Full title from meta (e.g., "Components/Button") */
|
|
712
|
+
title: string;
|
|
713
|
+
/** Absolute path to story file */
|
|
714
|
+
filePath: string;
|
|
715
|
+
/** SHA256 hash of file content for cache invalidation */
|
|
716
|
+
fileHash: string;
|
|
717
|
+
/** Tags from story meta */
|
|
718
|
+
tags: string[];
|
|
719
|
+
/** Display names of exported stories */
|
|
720
|
+
stories: string[];
|
|
721
|
+
/** Exact named exports available in the story module */
|
|
722
|
+
storyExports: string[];
|
|
723
|
+
/** Full story meta object */
|
|
724
|
+
meta: StoryMeta;
|
|
725
|
+
/** Component description extracted from file header JSDoc or meta.parameters.docs.description */
|
|
726
|
+
description?: string;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Configuration options for StoriesIndexService
|
|
730
|
+
*/
|
|
731
|
+
interface StoriesIndexServiceConfig {
|
|
732
|
+
/**
|
|
733
|
+
* Enable verbose logging
|
|
734
|
+
* @default false
|
|
735
|
+
*/
|
|
736
|
+
verbose?: boolean;
|
|
737
|
+
/** Workspace used to resolve relative search roots. */
|
|
738
|
+
workspaceRoot?: string;
|
|
739
|
+
/** Directories to scan, relative to the workspace or absolute. Defaults to the workspace root. */
|
|
740
|
+
searchRoots?: string[];
|
|
741
|
+
/** Exact story files to add without scanning their surrounding projects. */
|
|
742
|
+
storyFiles?: string[];
|
|
743
|
+
/** Maximum number of story files parsed concurrently. */
|
|
744
|
+
concurrency?: number;
|
|
745
|
+
}
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/services/StoriesIndexService/StoriesIndexService.d.ts
|
|
748
|
+
/**
|
|
749
|
+
* StoriesIndexService handles indexing and querying Storybook story files.
|
|
750
|
+
*
|
|
751
|
+
* Provides methods for scanning story files, extracting metadata using AST parsing,
|
|
752
|
+
* and querying components by tags, title, or name.
|
|
753
|
+
*
|
|
754
|
+
* @example
|
|
755
|
+
* ```typescript
|
|
756
|
+
* const service = new StoriesIndexService();
|
|
757
|
+
* await service.initialize();
|
|
758
|
+
* const components = service.getAllComponents();
|
|
759
|
+
* const button = service.findComponentByName('Button');
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
/**
|
|
763
|
+
* Result of initialization with success/failure statistics.
|
|
764
|
+
*/
|
|
765
|
+
interface InitializationResult {
|
|
766
|
+
/** Total number of story files found */
|
|
767
|
+
totalFiles: number;
|
|
768
|
+
/** Number of successfully indexed files */
|
|
769
|
+
successCount: number;
|
|
770
|
+
/** Number of files that failed to index */
|
|
771
|
+
failureCount: number;
|
|
772
|
+
/** List of files that failed with their error messages */
|
|
773
|
+
failures: Array<{
|
|
774
|
+
filePath: string;
|
|
775
|
+
error: string;
|
|
776
|
+
}>;
|
|
777
|
+
}
|
|
778
|
+
export declare class StoriesIndexService {
|
|
779
|
+
private componentIndex;
|
|
780
|
+
private componentFileIndex;
|
|
781
|
+
private monorepoRoot;
|
|
782
|
+
private initialized;
|
|
783
|
+
/** Last initialization result for error reporting */
|
|
784
|
+
private lastInitResult;
|
|
785
|
+
private readonly config;
|
|
786
|
+
/**
|
|
787
|
+
* Creates a new StoriesIndexService instance
|
|
788
|
+
*/
|
|
789
|
+
constructor(config?: StoriesIndexServiceConfig);
|
|
790
|
+
/**
|
|
791
|
+
* Initialize the index by scanning all .stories files.
|
|
792
|
+
* @returns Initialization result with success/failure statistics
|
|
793
|
+
*/
|
|
794
|
+
initialize(): Promise<InitializationResult>;
|
|
795
|
+
/**
|
|
796
|
+
* Get the last initialization result.
|
|
797
|
+
* @returns Initialization result or null if not initialized
|
|
798
|
+
*/
|
|
799
|
+
getLastInitResult(): InitializationResult | null;
|
|
800
|
+
private findStoryFiles;
|
|
801
|
+
private indexConcurrency;
|
|
802
|
+
private indexStoryFiles;
|
|
803
|
+
/**
|
|
804
|
+
* Index a single story file using storybook/internal/csf-tools.
|
|
805
|
+
*
|
|
806
|
+
* File reads remain cheap enough to hash on every new index. The expensive CSF
|
|
807
|
+
* parse is shared by content hash across service instances and concurrent rules.
|
|
808
|
+
*/
|
|
809
|
+
private indexStoryFile;
|
|
810
|
+
private assertContainedStory;
|
|
811
|
+
private storeComponent;
|
|
812
|
+
private parseStoryFile;
|
|
813
|
+
/**
|
|
814
|
+
* Extract component description from file header JSDoc or meta.parameters.docs.description.
|
|
815
|
+
*
|
|
816
|
+
* Priority:
|
|
817
|
+
* 1. meta.parameters.docs.description.component (Storybook standard)
|
|
818
|
+
* 2. File header JSDoc comment (first block comment in file)
|
|
819
|
+
*
|
|
820
|
+
* @param content - Raw file content
|
|
821
|
+
* @param meta - Parsed meta object from csf-tools
|
|
822
|
+
* @returns Description string or undefined
|
|
823
|
+
*/
|
|
824
|
+
private extractDescription;
|
|
825
|
+
/**
|
|
826
|
+
* Hash file content for cache invalidation
|
|
827
|
+
*/
|
|
828
|
+
private hashContent;
|
|
829
|
+
/**
|
|
830
|
+
* Get all components filtered by tags
|
|
831
|
+
* @param tags - Optional array of tags to filter by
|
|
832
|
+
* @returns Array of matching components
|
|
833
|
+
*/
|
|
834
|
+
getComponentsByTags(tags?: string[]): ComponentInfo[];
|
|
835
|
+
/**
|
|
836
|
+
* Get component by title
|
|
837
|
+
* @param title - Exact title to match (e.g., "Components/Button")
|
|
838
|
+
* @returns Component info or undefined
|
|
839
|
+
*/
|
|
840
|
+
getComponentByTitle(title: string): ComponentInfo | undefined;
|
|
841
|
+
/**
|
|
842
|
+
* Find component by partial name match
|
|
843
|
+
* @param name - Partial name to search for
|
|
844
|
+
* @returns First matching component or undefined
|
|
845
|
+
*/
|
|
846
|
+
findComponentByName(name: string, preferredAppPath?: string): ComponentInfo | undefined;
|
|
847
|
+
/**
|
|
848
|
+
* Refresh a specific file if it has changed
|
|
849
|
+
* @param filePath - Absolute path to story file
|
|
850
|
+
* @returns True if file was updated, false if unchanged
|
|
851
|
+
*/
|
|
852
|
+
refreshFile(filePath: string): Promise<boolean>;
|
|
853
|
+
/** Get one indexed component by its canonical story file path. */
|
|
854
|
+
getComponentByFilePath(filePath: string): ComponentInfo | undefined;
|
|
855
|
+
/**
|
|
856
|
+
* Get all indexed components
|
|
857
|
+
* @returns Array of all component info objects
|
|
858
|
+
*/
|
|
859
|
+
getAllComponents(): ComponentInfo[];
|
|
860
|
+
/**
|
|
861
|
+
* Clear the index (useful for testing)
|
|
862
|
+
*/
|
|
863
|
+
clear(): void;
|
|
864
|
+
/**
|
|
865
|
+
* Get all unique tags from indexed components
|
|
866
|
+
* @returns Sorted array of unique tag names
|
|
867
|
+
*/
|
|
868
|
+
getAllTags(): string[];
|
|
869
|
+
}
|
|
791
870
|
//#endregion
|
|
792
871
|
//#region src/services/ComponentRendererService/types.d.ts
|
|
793
872
|
/**
|
|
@@ -863,6 +942,9 @@ export declare class ComponentRendererService {
|
|
|
863
942
|
private themeService;
|
|
864
943
|
private appPath;
|
|
865
944
|
private bundlerFactory;
|
|
945
|
+
private log;
|
|
946
|
+
private readonly preserveOutput;
|
|
947
|
+
private readonly sharedBrowser;
|
|
866
948
|
/**
|
|
867
949
|
* Creates a new ComponentRendererService instance
|
|
868
950
|
* @param designSystemConfig - Design system configuration
|
|
@@ -871,6 +953,9 @@ export declare class ComponentRendererService {
|
|
|
871
953
|
*/
|
|
872
954
|
constructor(designSystemConfig: DesignSystemConfig, appPath: string, options?: {
|
|
873
955
|
bundlerFactory?: BundlerFactory;
|
|
956
|
+
workspaceRoot?: string;
|
|
957
|
+
temporaryDirectory?: string;
|
|
958
|
+
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
874
959
|
});
|
|
875
960
|
/**
|
|
876
961
|
* Get the bundler service instance.
|
|
@@ -1016,6 +1101,7 @@ type RendererFactory = (config: DesignSystemConfig, appPath: string) => Componen
|
|
|
1016
1101
|
* ```
|
|
1017
1102
|
*/
|
|
1018
1103
|
export declare class GetUiComponentService {
|
|
1104
|
+
private readonly configLoader?;
|
|
1019
1105
|
private config;
|
|
1020
1106
|
private storiesIndexFactory;
|
|
1021
1107
|
private rendererFactory;
|
|
@@ -1025,7 +1111,7 @@ export declare class GetUiComponentService {
|
|
|
1025
1111
|
* @param storiesIndexFactory - Factory for creating StoriesIndexService (for DI/testing)
|
|
1026
1112
|
* @param rendererFactory - Factory for creating ComponentRendererService (for DI/testing)
|
|
1027
1113
|
*/
|
|
1028
|
-
constructor(config?: GetUiComponentServiceConfig, storiesIndexFactory?: StoriesIndexFactory, rendererFactory?: RendererFactory);
|
|
1114
|
+
constructor(config?: GetUiComponentServiceConfig, storiesIndexFactory?: StoriesIndexFactory, rendererFactory?: RendererFactory, configLoader?: StyleSystemConfigLoader | undefined);
|
|
1029
1115
|
/**
|
|
1030
1116
|
* Get a UI component preview image.
|
|
1031
1117
|
*
|
|
@@ -1223,7 +1309,7 @@ export declare class ThemeService {
|
|
|
1223
1309
|
* Creates a new ThemeService instance
|
|
1224
1310
|
* @param config - Design system configuration
|
|
1225
1311
|
*/
|
|
1226
|
-
constructor(config: DesignSystemConfig);
|
|
1312
|
+
constructor(config: DesignSystemConfig, workspaceRoot?: string);
|
|
1227
1313
|
/**
|
|
1228
1314
|
* Get design system configuration
|
|
1229
1315
|
* @returns Current design system configuration
|
|
@@ -1292,6 +1378,8 @@ export declare class ThemeService {
|
|
|
1292
1378
|
* ```
|
|
1293
1379
|
*/
|
|
1294
1380
|
declare class ThemeServiceFactory {
|
|
1381
|
+
private readonly workspaceRoot?;
|
|
1382
|
+
constructor(workspaceRoot?: string | undefined);
|
|
1295
1383
|
/**
|
|
1296
1384
|
* Create a theme service based on configuration.
|
|
1297
1385
|
*
|
|
@@ -1543,6 +1631,8 @@ export declare class TailwindCSSClassesService extends BaseCSSClassesService {
|
|
|
1543
1631
|
* ```
|
|
1544
1632
|
*/
|
|
1545
1633
|
export declare class CSSClassesServiceFactory {
|
|
1634
|
+
private readonly workspaceRoot?;
|
|
1635
|
+
constructor(workspaceRoot?: string | undefined);
|
|
1546
1636
|
/**
|
|
1547
1637
|
* Create a CSS classes service based on configuration.
|
|
1548
1638
|
*
|
|
@@ -1672,6 +1762,7 @@ interface GetCSSClassesInput {
|
|
|
1672
1762
|
* ```
|
|
1673
1763
|
*/
|
|
1674
1764
|
export declare class GetCSSClassesTool implements Tool<GetCSSClassesInput> {
|
|
1765
|
+
private readonly configLoader?;
|
|
1675
1766
|
static readonly TOOL_NAME = "get_css_classes";
|
|
1676
1767
|
private static readonly CSS_REUSE_INSTRUCTION;
|
|
1677
1768
|
private serviceFactory;
|
|
@@ -1681,7 +1772,7 @@ export declare class GetCSSClassesTool implements Tool<GetCSSClassesInput> {
|
|
|
1681
1772
|
* @param serviceFactory - Injected CSSClassesServiceFactory
|
|
1682
1773
|
* @param defaultThemePath - Default path to theme CSS file (relative to workspace root)
|
|
1683
1774
|
*/
|
|
1684
|
-
constructor(serviceFactory: CSSClassesServiceFactory, defaultThemePath?: string);
|
|
1775
|
+
constructor(serviceFactory: CSSClassesServiceFactory, defaultThemePath?: string, configLoader?: StyleSystemConfigLoader | undefined);
|
|
1685
1776
|
/**
|
|
1686
1777
|
* Returns the tool definition for MCP registration
|
|
1687
1778
|
* @returns Tool definition with name, description, and input schema
|
|
@@ -1778,12 +1869,13 @@ interface AppComponentsServiceResult {
|
|
|
1778
1869
|
* ```
|
|
1779
1870
|
*/
|
|
1780
1871
|
declare class AppComponentsService {
|
|
1872
|
+
private readonly workspaceRoot?;
|
|
1781
1873
|
private config;
|
|
1782
1874
|
/**
|
|
1783
1875
|
* Creates a new AppComponentsService instance.
|
|
1784
1876
|
* @param config - Service configuration options
|
|
1785
1877
|
*/
|
|
1786
|
-
constructor(config?: AppComponentsServiceConfig);
|
|
1878
|
+
constructor(config?: AppComponentsServiceConfig, workspaceRoot?: string | undefined);
|
|
1787
1879
|
/**
|
|
1788
1880
|
* List app-specific and package components for a given application.
|
|
1789
1881
|
* @param input - Object containing appPath and optional cursor for pagination
|
|
@@ -1933,9 +2025,10 @@ interface ListThemesInput {
|
|
|
1933
2025
|
* ```
|
|
1934
2026
|
*/
|
|
1935
2027
|
export declare class ListThemesTool implements Tool<ListThemesInput> {
|
|
2028
|
+
private readonly configLoader?;
|
|
1936
2029
|
static readonly TOOL_NAME = "list_themes";
|
|
1937
2030
|
private serviceFactory;
|
|
1938
|
-
constructor(serviceFactory: ThemeServiceFactory);
|
|
2031
|
+
constructor(serviceFactory: ThemeServiceFactory, configLoader?: StyleSystemConfigLoader | undefined);
|
|
1939
2032
|
getDefinition(): ToolDefinition;
|
|
1940
2033
|
execute(input: ListThemesInput): Promise<CallToolResult>;
|
|
1941
2034
|
}
|
|
@@ -1951,11 +2044,12 @@ interface ListSharedComponentsInput {
|
|
|
1951
2044
|
cursor?: string;
|
|
1952
2045
|
}
|
|
1953
2046
|
export declare class ListSharedComponentsTool implements Tool<ListSharedComponentsInput> {
|
|
2047
|
+
private readonly configLoader?;
|
|
1954
2048
|
static readonly TOOL_NAME = "list_shared_components";
|
|
1955
2049
|
static readonly PAGE_SIZE = 50;
|
|
1956
2050
|
private static readonly COMPONENT_REUSE_INSTRUCTION;
|
|
1957
2051
|
private storiesIndexFactory;
|
|
1958
|
-
constructor(storiesIndexFactory: StoriesIndexFactory);
|
|
2052
|
+
constructor(storiesIndexFactory: StoriesIndexFactory, configLoader?: StyleSystemConfigLoader | undefined);
|
|
1959
2053
|
/**
|
|
1960
2054
|
* Encode pagination state into an opaque cursor string
|
|
1961
2055
|
* @param offset - The current offset in the component list
|
|
@@ -1981,38 +2075,6 @@ export declare class ListSharedComponentsTool implements Tool<ListSharedComponen
|
|
|
1981
2075
|
execute(input: ListSharedComponentsInput): Promise<CallToolResult>;
|
|
1982
2076
|
}
|
|
1983
2077
|
//#endregion
|
|
1984
|
-
//#region src/tools/PolishComponentTool.d.ts
|
|
1985
|
-
interface PolishComponentInput {
|
|
1986
|
-
filePath: string;
|
|
1987
|
-
instructions?: string;
|
|
1988
|
-
}
|
|
1989
|
-
export declare class PolishComponentTool implements Tool<PolishComponentInput> {
|
|
1990
|
-
static readonly TOOL_NAME = "polish_component";
|
|
1991
|
-
private antigravityService;
|
|
1992
|
-
private getUiComponentService;
|
|
1993
|
-
private cssClassesServiceFactory;
|
|
1994
|
-
private storiesIndexFactory;
|
|
1995
|
-
constructor(getUiComponentService: GetUiComponentService, cssClassesServiceFactory: CSSClassesServiceFactory, storiesIndexFactory: StoriesIndexFactory);
|
|
1996
|
-
getDefinition(): ToolDefinition;
|
|
1997
|
-
execute(input: PolishComponentInput): Promise<CallToolResult>;
|
|
1998
|
-
private detectPlatform;
|
|
1999
|
-
private buildSystemPrompt;
|
|
2000
|
-
/**
|
|
2001
|
-
* Read design tokens from config.themePath.
|
|
2002
|
-
* For web: extracts Tailwind CSS classes. For native: reads the TypeScript types file.
|
|
2003
|
-
*/
|
|
2004
|
-
private getDesignTokens;
|
|
2005
|
-
private findStoriesFile;
|
|
2006
|
-
/**
|
|
2007
|
-
* Find the app that owns a file, for style-system context.
|
|
2008
|
-
* Only apps declaring their own style-system.config.yaml are eligible.
|
|
2009
|
-
*/
|
|
2010
|
-
private findAppPath;
|
|
2011
|
-
private getComponentVisual;
|
|
2012
|
-
private getDesignPrinciples;
|
|
2013
|
-
private getSharedComponents;
|
|
2014
|
-
}
|
|
2015
|
-
//#endregion
|
|
2016
2078
|
//#region src/transports/stdio.d.ts
|
|
2017
2079
|
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
2018
2080
|
export declare class StdioTransportHandler {
|
|
@@ -2024,4 +2086,46 @@ export declare class StdioTransportHandler {
|
|
|
2024
2086
|
stop(): Promise<void>;
|
|
2025
2087
|
}
|
|
2026
2088
|
//#endregion
|
|
2027
|
-
|
|
2089
|
+
//#region src/utils/storyBrowser.d.ts
|
|
2090
|
+
/** Server-owned Chrome. Each capture borrows it until its context cleanup settles. */
|
|
2091
|
+
export declare function createStoryBrowser(): {
|
|
2092
|
+
acquire(): Promise<BrowserLease>;
|
|
2093
|
+
dispose(): Promise<void>;
|
|
2094
|
+
};
|
|
2095
|
+
//#endregion
|
|
2096
|
+
//#region src/services/WarmStoryRenderer/WarmStoryRenderer.d.ts
|
|
2097
|
+
/** The style-system tools a warm host exposes, by tool name. */
|
|
2098
|
+
export declare const WARM_RENDERER_TOOLS: {
|
|
2099
|
+
readonly get_component_visual: symbol;
|
|
2100
|
+
readonly get_css_classes: symbol;
|
|
2101
|
+
readonly list_themes: symbol;
|
|
2102
|
+
readonly list_shared_components: symbol;
|
|
2103
|
+
readonly list_app_components: symbol;
|
|
2104
|
+
};
|
|
2105
|
+
type WarmRendererToolName = keyof typeof WARM_RENDERER_TOOLS;
|
|
2106
|
+
interface WarmRendererResult {
|
|
2107
|
+
text: string;
|
|
2108
|
+
images: {
|
|
2109
|
+
data: string;
|
|
2110
|
+
mimeType: string;
|
|
2111
|
+
}[];
|
|
2112
|
+
isError: boolean;
|
|
2113
|
+
}
|
|
2114
|
+
interface WarmStoryRenderer {
|
|
2115
|
+
/** Runs one tool. Calls are serialized: the dev server serves one app at a time. */
|
|
2116
|
+
call(tool: WarmRendererToolName, input: Record<string, unknown>): Promise<WarmRendererResult>;
|
|
2117
|
+
/** Closes owned resources; a borrowed server browser remains running. */
|
|
2118
|
+
restart(): Promise<void>;
|
|
2119
|
+
dispose(): Promise<void>;
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
2123
|
+
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
2124
|
+
*/
|
|
2125
|
+
export declare function createWarmStoryRenderer(options?: {
|
|
2126
|
+
workspaceRoot?: string;
|
|
2127
|
+
temporaryDirectory?: string;
|
|
2128
|
+
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
2129
|
+
}): WarmStoryRenderer;
|
|
2130
|
+
//#endregion
|
|
2131
|
+
export type { CSSClassCategory, CSSClassValue, CSSClassesResult, DesignSystemConfig, OxlintRestrictedClassPattern, OxlintRestrictedClassesConfig, ResolvedDesignSystemConfig, StoryPreviewIdentity, StoryPreviewInput, StoryPreviewResult, StoryPreviewServiceOptions, StyleSystemConfig, StyleSystemModuleOptions, Tool, ToolDefinition, WarmRendererResult, WarmRendererToolName, WarmStoryRenderer };
|