@fragments-sdk/cli 0.2.2
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 +21 -0
- package/README.md +106 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +4783 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-4FDQSGKX.js +786 -0
- package/dist/chunk-4FDQSGKX.js.map +1 -0
- package/dist/chunk-7H2MMGYG.js +369 -0
- package/dist/chunk-7H2MMGYG.js.map +1 -0
- package/dist/chunk-BSCG3IP7.js +619 -0
- package/dist/chunk-BSCG3IP7.js.map +1 -0
- package/dist/chunk-LY2CFFPY.js +898 -0
- package/dist/chunk-LY2CFFPY.js.map +1 -0
- package/dist/chunk-MUZ6CM66.js +6636 -0
- package/dist/chunk-MUZ6CM66.js.map +1 -0
- package/dist/chunk-OAENNG3G.js +1489 -0
- package/dist/chunk-OAENNG3G.js.map +1 -0
- package/dist/chunk-XHNKNI6J.js +235 -0
- package/dist/chunk-XHNKNI6J.js.map +1 -0
- package/dist/core-DWKLGY4N.js +68 -0
- package/dist/core-DWKLGY4N.js.map +1 -0
- package/dist/generate-4LQNJ7SX.js +249 -0
- package/dist/generate-4LQNJ7SX.js.map +1 -0
- package/dist/index.d.ts +775 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/init-EMVI47QG.js +416 -0
- package/dist/init-EMVI47QG.js.map +1 -0
- package/dist/mcp-bin.d.ts +1 -0
- package/dist/mcp-bin.js +1117 -0
- package/dist/mcp-bin.js.map +1 -0
- package/dist/scan-4YPRF7FV.js +12 -0
- package/dist/scan-4YPRF7FV.js.map +1 -0
- package/dist/service-QSZMZJBJ.js +208 -0
- package/dist/service-QSZMZJBJ.js.map +1 -0
- package/dist/static-viewer-MIPGZ4Z7.js +12 -0
- package/dist/static-viewer-MIPGZ4Z7.js.map +1 -0
- package/dist/test-SQ5ZHXWU.js +1067 -0
- package/dist/test-SQ5ZHXWU.js.map +1 -0
- package/dist/tokens-HSGMYK64.js +173 -0
- package/dist/tokens-HSGMYK64.js.map +1 -0
- package/dist/viewer-YRF4SQE4.js +11101 -0
- package/dist/viewer-YRF4SQE4.js.map +1 -0
- package/package.json +107 -0
- package/src/ai.ts +266 -0
- package/src/analyze.ts +265 -0
- package/src/bin.ts +916 -0
- package/src/build.ts +248 -0
- package/src/commands/a11y.ts +302 -0
- package/src/commands/add.ts +313 -0
- package/src/commands/audit.ts +195 -0
- package/src/commands/baseline.ts +221 -0
- package/src/commands/build.ts +144 -0
- package/src/commands/compare.ts +337 -0
- package/src/commands/context.ts +107 -0
- package/src/commands/dev.ts +107 -0
- package/src/commands/enhance.ts +858 -0
- package/src/commands/generate.ts +391 -0
- package/src/commands/init.ts +531 -0
- package/src/commands/link/figma.ts +645 -0
- package/src/commands/link/index.ts +10 -0
- package/src/commands/link/storybook.ts +267 -0
- package/src/commands/list.ts +49 -0
- package/src/commands/metrics.ts +114 -0
- package/src/commands/reset.ts +242 -0
- package/src/commands/scan.ts +537 -0
- package/src/commands/storygen.ts +207 -0
- package/src/commands/tokens.ts +251 -0
- package/src/commands/validate.ts +93 -0
- package/src/commands/verify.ts +215 -0
- package/src/core/composition.test.ts +262 -0
- package/src/core/composition.ts +255 -0
- package/src/core/config.ts +84 -0
- package/src/core/constants.ts +111 -0
- package/src/core/context.ts +380 -0
- package/src/core/defineSegment.ts +137 -0
- package/src/core/discovery.ts +337 -0
- package/src/core/figma.ts +263 -0
- package/src/core/fragment-types.ts +214 -0
- package/src/core/generators/context.ts +389 -0
- package/src/core/generators/index.ts +23 -0
- package/src/core/generators/registry.ts +364 -0
- package/src/core/generators/typescript-extractor.ts +374 -0
- package/src/core/importAnalyzer.ts +217 -0
- package/src/core/index.ts +149 -0
- package/src/core/loader.ts +155 -0
- package/src/core/node.ts +63 -0
- package/src/core/parser.ts +551 -0
- package/src/core/previewLoader.ts +172 -0
- package/src/core/schema/fragment.schema.json +189 -0
- package/src/core/schema/registry.schema.json +137 -0
- package/src/core/schema.ts +182 -0
- package/src/core/storyAdapter.test.ts +571 -0
- package/src/core/storyAdapter.ts +761 -0
- package/src/core/token-types.ts +287 -0
- package/src/core/types.ts +754 -0
- package/src/diff.ts +323 -0
- package/src/index.ts +43 -0
- package/src/mcp/__tests__/projectFields.test.ts +130 -0
- package/src/mcp/bin.ts +36 -0
- package/src/mcp/index.ts +8 -0
- package/src/mcp/server.ts +1310 -0
- package/src/mcp/utils.ts +54 -0
- package/src/mcp-bin.ts +36 -0
- package/src/migrate/__tests__/argTypes/argTypes.test.ts +189 -0
- package/src/migrate/__tests__/args/args.test.ts +452 -0
- package/src/migrate/__tests__/meta/meta.test.ts +198 -0
- package/src/migrate/__tests__/stories/stories.test.ts +278 -0
- package/src/migrate/__tests__/utils/utils.test.ts +371 -0
- package/src/migrate/__tests__/values/values.test.ts +303 -0
- package/src/migrate/bin.ts +108 -0
- package/src/migrate/converter.ts +658 -0
- package/src/migrate/detect.ts +196 -0
- package/src/migrate/index.ts +45 -0
- package/src/migrate/migrate.ts +163 -0
- package/src/migrate/parser.ts +1136 -0
- package/src/migrate/report.ts +624 -0
- package/src/migrate/types.ts +169 -0
- package/src/screenshot.ts +249 -0
- package/src/service/__tests__/ast-utils.test.ts +426 -0
- package/src/service/__tests__/enhance-scanner.test.ts +200 -0
- package/src/service/__tests__/figma/figma.test.ts +652 -0
- package/src/service/__tests__/metrics-store.test.ts +409 -0
- package/src/service/__tests__/patch-generator.test.ts +186 -0
- package/src/service/__tests__/props-extractor.test.ts +365 -0
- package/src/service/__tests__/token-registry.test.ts +267 -0
- package/src/service/analytics.ts +659 -0
- package/src/service/ast-utils.ts +444 -0
- package/src/service/browser-pool.ts +339 -0
- package/src/service/capture.ts +267 -0
- package/src/service/diff.ts +279 -0
- package/src/service/enhance/aggregator.ts +489 -0
- package/src/service/enhance/cache.ts +275 -0
- package/src/service/enhance/codebase-scanner.ts +357 -0
- package/src/service/enhance/context-generator.ts +529 -0
- package/src/service/enhance/doc-extractor.ts +523 -0
- package/src/service/enhance/index.ts +131 -0
- package/src/service/enhance/props-extractor.ts +665 -0
- package/src/service/enhance/scanner.ts +445 -0
- package/src/service/enhance/storybook-parser.ts +552 -0
- package/src/service/enhance/types.ts +346 -0
- package/src/service/enhance/variant-renderer.ts +479 -0
- package/src/service/figma.ts +1008 -0
- package/src/service/index.ts +249 -0
- package/src/service/metrics-store.ts +333 -0
- package/src/service/patch-generator.ts +349 -0
- package/src/service/report.ts +854 -0
- package/src/service/storage.ts +401 -0
- package/src/service/token-fixes.ts +281 -0
- package/src/service/token-parser.ts +504 -0
- package/src/service/token-registry.ts +721 -0
- package/src/service/utils.ts +172 -0
- package/src/setup.ts +241 -0
- package/src/shared/command-wrapper.ts +81 -0
- package/src/shared/dev-server-client.ts +199 -0
- package/src/shared/index.ts +8 -0
- package/src/shared/segment-loader.ts +59 -0
- package/src/shared/types.ts +147 -0
- package/src/static-viewer.ts +715 -0
- package/src/test/discovery.ts +172 -0
- package/src/test/index.ts +281 -0
- package/src/test/reporters/console.ts +194 -0
- package/src/test/reporters/json.ts +190 -0
- package/src/test/reporters/junit.ts +186 -0
- package/src/test/runner.ts +598 -0
- package/src/test/types.ts +245 -0
- package/src/test/watch.ts +200 -0
- package/src/validators.ts +152 -0
- package/src/viewer/__tests__/jsx-parser.test.ts +502 -0
- package/src/viewer/__tests__/render-utils.test.ts +232 -0
- package/src/viewer/__tests__/style-utils.test.ts +404 -0
- package/src/viewer/bin.ts +86 -0
- package/src/viewer/cli/health.ts +256 -0
- package/src/viewer/cli/index.ts +33 -0
- package/src/viewer/cli/scan.ts +124 -0
- package/src/viewer/cli/utils.ts +174 -0
- package/src/viewer/components/AccessibilityPanel.tsx +1404 -0
- package/src/viewer/components/ActionCapture.tsx +172 -0
- package/src/viewer/components/ActionsPanel.tsx +371 -0
- package/src/viewer/components/App.tsx +638 -0
- package/src/viewer/components/BottomPanel.tsx +224 -0
- package/src/viewer/components/CodePanel.tsx +589 -0
- package/src/viewer/components/CommandPalette.tsx +336 -0
- package/src/viewer/components/ComponentGraph.tsx +394 -0
- package/src/viewer/components/ComponentHeader.tsx +85 -0
- package/src/viewer/components/ContractPanel.tsx +234 -0
- package/src/viewer/components/ErrorBoundary.tsx +85 -0
- package/src/viewer/components/FigmaEmbed.tsx +231 -0
- package/src/viewer/components/FragmentEditor.tsx +485 -0
- package/src/viewer/components/HealthDashboard.tsx +452 -0
- package/src/viewer/components/HmrStatusIndicator.tsx +71 -0
- package/src/viewer/components/Icons.tsx +417 -0
- package/src/viewer/components/InteractionsPanel.tsx +720 -0
- package/src/viewer/components/IsolatedPreviewFrame.tsx +321 -0
- package/src/viewer/components/IsolatedRender.tsx +111 -0
- package/src/viewer/components/KeyboardShortcutsHelp.tsx +89 -0
- package/src/viewer/components/LandingPage.tsx +441 -0
- package/src/viewer/components/Layout.tsx +22 -0
- package/src/viewer/components/LeftSidebar.tsx +391 -0
- package/src/viewer/components/MultiViewportPreview.tsx +429 -0
- package/src/viewer/components/PreviewArea.tsx +404 -0
- package/src/viewer/components/PreviewFrameHost.tsx +310 -0
- package/src/viewer/components/PreviewPane.tsx +150 -0
- package/src/viewer/components/PreviewToolbar.tsx +176 -0
- package/src/viewer/components/PropsEditor.tsx +512 -0
- package/src/viewer/components/PropsTable.tsx +98 -0
- package/src/viewer/components/RelationsSection.tsx +57 -0
- package/src/viewer/components/ResizablePanel.tsx +328 -0
- package/src/viewer/components/RightSidebar.tsx +118 -0
- package/src/viewer/components/ScreenshotButton.tsx +90 -0
- package/src/viewer/components/Sidebar.tsx +169 -0
- package/src/viewer/components/SkeletonLoader.tsx +156 -0
- package/src/viewer/components/StoryRenderer.tsx +128 -0
- package/src/viewer/components/ThemeProvider.tsx +96 -0
- package/src/viewer/components/Toast.tsx +67 -0
- package/src/viewer/components/TokenStylePanel.tsx +708 -0
- package/src/viewer/components/UsageSection.tsx +95 -0
- package/src/viewer/components/VariantMatrix.tsx +350 -0
- package/src/viewer/components/VariantRenderer.tsx +131 -0
- package/src/viewer/components/VariantTabs.tsx +84 -0
- package/src/viewer/components/ViewportSelector.tsx +165 -0
- package/src/viewer/components/_future/CreatePage.tsx +836 -0
- package/src/viewer/composition-renderer.ts +381 -0
- package/src/viewer/constants/index.ts +1 -0
- package/src/viewer/constants/ui.ts +185 -0
- package/src/viewer/entry.tsx +299 -0
- package/src/viewer/hooks/index.ts +2 -0
- package/src/viewer/hooks/useA11yCache.ts +383 -0
- package/src/viewer/hooks/useA11yService.ts +498 -0
- package/src/viewer/hooks/useActions.ts +138 -0
- package/src/viewer/hooks/useAppState.ts +124 -0
- package/src/viewer/hooks/useFigmaIntegration.ts +132 -0
- package/src/viewer/hooks/useHmrStatus.ts +109 -0
- package/src/viewer/hooks/useKeyboardShortcuts.ts +222 -0
- package/src/viewer/hooks/usePreviewBridge.ts +347 -0
- package/src/viewer/hooks/useScrollSpy.ts +78 -0
- package/src/viewer/hooks/useUrlState.ts +330 -0
- package/src/viewer/hooks/useViewSettings.ts +125 -0
- package/src/viewer/index.html +28 -0
- package/src/viewer/index.ts +14 -0
- package/src/viewer/intelligence/healthReport.ts +505 -0
- package/src/viewer/intelligence/styleDrift.ts +340 -0
- package/src/viewer/intelligence/usageScanner.ts +309 -0
- package/src/viewer/jsx-parser.ts +485 -0
- package/src/viewer/postcss.config.js +6 -0
- package/src/viewer/preview-frame-entry.tsx +25 -0
- package/src/viewer/preview-frame.html +109 -0
- package/src/viewer/render-template.html +68 -0
- package/src/viewer/render-utils.ts +170 -0
- package/src/viewer/server.ts +276 -0
- package/src/viewer/style-utils.ts +414 -0
- package/src/viewer/styles/globals.css +355 -0
- package/src/viewer/tailwind.config.js +37 -0
- package/src/viewer/types/a11y.ts +197 -0
- package/src/viewer/utils/a11y-fixes.ts +471 -0
- package/src/viewer/utils/actionExport.ts +372 -0
- package/src/viewer/utils/colorSchemes.ts +201 -0
- package/src/viewer/utils/detectRelationships.ts +256 -0
- package/src/viewer/vite-plugin.ts +2143 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,775 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata about the component
|
|
3
|
+
*/
|
|
4
|
+
interface SegmentMeta {
|
|
5
|
+
/** Component display name */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Brief description of the component's purpose */
|
|
8
|
+
description: string;
|
|
9
|
+
/** Category for organizing components (e.g., "actions", "forms", "layout") */
|
|
10
|
+
category: string;
|
|
11
|
+
/** Optional tags for additional categorization */
|
|
12
|
+
tags?: string[];
|
|
13
|
+
/** Component status */
|
|
14
|
+
status?: "stable" | "beta" | "deprecated" | "experimental";
|
|
15
|
+
/** Version when component was introduced */
|
|
16
|
+
since?: string;
|
|
17
|
+
/** Figma frame URL for design verification */
|
|
18
|
+
figma?: string;
|
|
19
|
+
/** Figma property mappings (how Figma props map to code props) */
|
|
20
|
+
figmaProps?: Record<string, FigmaPropMapping>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Figma property mapping types - describes how a Figma property maps to code
|
|
24
|
+
*/
|
|
25
|
+
type FigmaPropMapping = FigmaStringMapping | FigmaBooleanMapping | FigmaEnumMapping | FigmaInstanceMapping | FigmaChildrenMapping | FigmaTextContentMapping;
|
|
26
|
+
/** Maps a Figma text property to a string prop */
|
|
27
|
+
interface FigmaStringMapping {
|
|
28
|
+
__type: 'figma-string';
|
|
29
|
+
figmaProperty: string;
|
|
30
|
+
}
|
|
31
|
+
/** Maps a Figma boolean property to a boolean prop (with optional value mapping) */
|
|
32
|
+
interface FigmaBooleanMapping {
|
|
33
|
+
__type: 'figma-boolean';
|
|
34
|
+
figmaProperty: string;
|
|
35
|
+
valueMapping?: {
|
|
36
|
+
true: unknown;
|
|
37
|
+
false: unknown;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Maps a Figma variant property to an enum prop */
|
|
41
|
+
interface FigmaEnumMapping {
|
|
42
|
+
__type: 'figma-enum';
|
|
43
|
+
figmaProperty: string;
|
|
44
|
+
valueMapping: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/** References a nested Figma component instance */
|
|
47
|
+
interface FigmaInstanceMapping {
|
|
48
|
+
__type: 'figma-instance';
|
|
49
|
+
figmaProperty: string;
|
|
50
|
+
}
|
|
51
|
+
/** Renders children from Figma layer names */
|
|
52
|
+
interface FigmaChildrenMapping {
|
|
53
|
+
__type: 'figma-children';
|
|
54
|
+
layers: string[];
|
|
55
|
+
}
|
|
56
|
+
/** Extracts text content from a Figma text layer */
|
|
57
|
+
interface FigmaTextContentMapping {
|
|
58
|
+
__type: 'figma-text-content';
|
|
59
|
+
layer: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Usage guidelines for AI agents and developers
|
|
63
|
+
*/
|
|
64
|
+
interface SegmentUsage {
|
|
65
|
+
/** When to use this component */
|
|
66
|
+
when: string[];
|
|
67
|
+
/** When NOT to use this component (with alternatives) */
|
|
68
|
+
whenNot: string[];
|
|
69
|
+
/** Additional usage guidelines and best practices */
|
|
70
|
+
guidelines?: string[];
|
|
71
|
+
/** Accessibility considerations */
|
|
72
|
+
accessibility?: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Prop type definitions
|
|
76
|
+
*/
|
|
77
|
+
type PropType = {
|
|
78
|
+
type: "string";
|
|
79
|
+
pattern?: string;
|
|
80
|
+
} | {
|
|
81
|
+
type: "number";
|
|
82
|
+
min?: number;
|
|
83
|
+
max?: number;
|
|
84
|
+
} | {
|
|
85
|
+
type: "boolean";
|
|
86
|
+
} | {
|
|
87
|
+
type: "enum";
|
|
88
|
+
values: readonly string[];
|
|
89
|
+
} | {
|
|
90
|
+
type: "function";
|
|
91
|
+
signature?: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: "node";
|
|
94
|
+
} | {
|
|
95
|
+
type: "element";
|
|
96
|
+
} | {
|
|
97
|
+
type: "object";
|
|
98
|
+
shape?: Record<string, PropDefinition>;
|
|
99
|
+
} | {
|
|
100
|
+
type: "array";
|
|
101
|
+
items?: PropType;
|
|
102
|
+
} | {
|
|
103
|
+
type: "union";
|
|
104
|
+
types: PropType[];
|
|
105
|
+
} | {
|
|
106
|
+
type: "custom";
|
|
107
|
+
typescript: string;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Storybook control types for UI rendering
|
|
111
|
+
*/
|
|
112
|
+
type ControlType = "text" | "number" | "range" | "boolean" | "select" | "multi-select" | "radio" | "inline-radio" | "check" | "inline-check" | "object" | "file" | "color" | "date";
|
|
113
|
+
/**
|
|
114
|
+
* Definition for a single prop
|
|
115
|
+
*/
|
|
116
|
+
interface PropDefinition {
|
|
117
|
+
/** The prop type */
|
|
118
|
+
type: PropType["type"];
|
|
119
|
+
/** For enum types, the allowed values */
|
|
120
|
+
values?: readonly string[];
|
|
121
|
+
/** Default value if not provided */
|
|
122
|
+
default?: unknown;
|
|
123
|
+
/** Description of what this prop does */
|
|
124
|
+
description: string;
|
|
125
|
+
/** Whether this prop is required */
|
|
126
|
+
required?: boolean;
|
|
127
|
+
/** Usage constraints for AI agents */
|
|
128
|
+
constraints?: string[];
|
|
129
|
+
/** Additional type details for complex types */
|
|
130
|
+
typeDetails?: Omit<PropType, "type">;
|
|
131
|
+
/** Original Storybook control type for UI rendering (e.g., "color", "date", "range") */
|
|
132
|
+
controlType?: ControlType;
|
|
133
|
+
/** Control options (e.g., min/max for range, presetColors for color) */
|
|
134
|
+
controlOptions?: {
|
|
135
|
+
min?: number;
|
|
136
|
+
max?: number;
|
|
137
|
+
step?: number;
|
|
138
|
+
presetColors?: string[];
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Relationship types between components
|
|
143
|
+
*/
|
|
144
|
+
type RelationshipType = "alternative" | "sibling" | "parent" | "child" | "composition";
|
|
145
|
+
/**
|
|
146
|
+
* Relationship to another component
|
|
147
|
+
*/
|
|
148
|
+
interface ComponentRelation {
|
|
149
|
+
/** Name of the related component */
|
|
150
|
+
component: string;
|
|
151
|
+
/** Type of relationship */
|
|
152
|
+
relationship: RelationshipType;
|
|
153
|
+
/** Explanation of the relationship */
|
|
154
|
+
note: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Agent-optimized contract metadata
|
|
158
|
+
* Provides compact, structured data for AI code generation
|
|
159
|
+
*/
|
|
160
|
+
interface SegmentContract {
|
|
161
|
+
/** Short prop descriptions for agents (e.g., "variant: primary|secondary (required)") */
|
|
162
|
+
propsSummary?: string[];
|
|
163
|
+
/** Accessibility rule IDs for lookup in glossary (e.g., "A11Y_BTN_LABEL") */
|
|
164
|
+
a11yRules?: string[];
|
|
165
|
+
/** Banned patterns in codebase - triggers warnings during code review */
|
|
166
|
+
bans?: Array<{
|
|
167
|
+
/** Pattern to match (regex string or literal) */
|
|
168
|
+
pattern: string;
|
|
169
|
+
/** Message explaining why this pattern is banned and what to use instead */
|
|
170
|
+
message: string;
|
|
171
|
+
}>;
|
|
172
|
+
/** Scenario tags for use-case matching (e.g., "form.submit", "navigation.primary") */
|
|
173
|
+
scenarioTags?: string[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Provenance tracking for generated segments
|
|
177
|
+
* Helps distinguish human-authored from machine-generated content
|
|
178
|
+
*/
|
|
179
|
+
interface SegmentGenerated {
|
|
180
|
+
/** Source of this segment definition */
|
|
181
|
+
source: "storybook" | "manual" | "ai";
|
|
182
|
+
/** Original source file (e.g., "Button.stories.tsx") */
|
|
183
|
+
sourceFile?: string;
|
|
184
|
+
/** Confidence score from 0-1 (how reliable the extraction was) */
|
|
185
|
+
confidence?: number;
|
|
186
|
+
/** ISO timestamp when this was generated */
|
|
187
|
+
timestamp?: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Registry generation options
|
|
191
|
+
*/
|
|
192
|
+
interface RegistryOptions {
|
|
193
|
+
/** Only include components that have a corresponding .stories.tsx file */
|
|
194
|
+
requireStory?: boolean;
|
|
195
|
+
/** Only include components that are exported (public API) */
|
|
196
|
+
publicOnly?: boolean;
|
|
197
|
+
/** Maximum depth for category inference from directory structure (default: 1) */
|
|
198
|
+
categoryDepth?: number;
|
|
199
|
+
/** Include props in registry (default: false - AI can read TypeScript directly) */
|
|
200
|
+
includeProps?: boolean;
|
|
201
|
+
/** Include full fragment data in registry (default: false - reference fragmentPath instead) */
|
|
202
|
+
embedFragments?: boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Design token configuration
|
|
206
|
+
*/
|
|
207
|
+
interface TokenConfig {
|
|
208
|
+
/**
|
|
209
|
+
* Glob patterns for files to scan for tokens
|
|
210
|
+
* e.g., ["src/styles/theme.scss", "src/styles/variables.css"]
|
|
211
|
+
*/
|
|
212
|
+
include: string[];
|
|
213
|
+
/**
|
|
214
|
+
* Glob patterns to exclude
|
|
215
|
+
* @example ["node_modules"]
|
|
216
|
+
*/
|
|
217
|
+
exclude?: string[];
|
|
218
|
+
/**
|
|
219
|
+
* Map CSS selectors to theme names
|
|
220
|
+
* @example { ":root": "default", "[data-theme='dark']": "dark" }
|
|
221
|
+
*/
|
|
222
|
+
themeSelectors?: Record<string, string>;
|
|
223
|
+
/** Enable token comparison in style diffs (default: true) */
|
|
224
|
+
enabled?: boolean;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* CI configuration for automated compliance checks
|
|
228
|
+
*/
|
|
229
|
+
interface CIConfig {
|
|
230
|
+
/** Minimum compliance percentage to pass (default: 80) */
|
|
231
|
+
minCompliance?: number;
|
|
232
|
+
/** Whether to fail on any visual regression */
|
|
233
|
+
failOnDiff?: boolean;
|
|
234
|
+
/** Whether to output JSON format */
|
|
235
|
+
jsonOutput?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Config file structure
|
|
239
|
+
*/
|
|
240
|
+
interface FragmentsConfig {
|
|
241
|
+
/** Glob patterns for finding segment/fragment files */
|
|
242
|
+
include: string[];
|
|
243
|
+
/** Glob patterns to exclude */
|
|
244
|
+
exclude?: string[];
|
|
245
|
+
/** Glob patterns for finding component files (for coverage validation) */
|
|
246
|
+
components?: string[];
|
|
247
|
+
/** Output path for compiled output */
|
|
248
|
+
outFile?: string;
|
|
249
|
+
/** Framework adapter to use */
|
|
250
|
+
framework?: "react" | "vue" | "svelte";
|
|
251
|
+
/** Figma file URL for the design system (used by `fragments link`) */
|
|
252
|
+
figmaFile?: string;
|
|
253
|
+
/** Figma access token (alternative to FIGMA_ACCESS_TOKEN env var) */
|
|
254
|
+
figmaToken?: string;
|
|
255
|
+
/** Screenshot configuration */
|
|
256
|
+
screenshots?: ScreenshotConfig;
|
|
257
|
+
/** Service configuration */
|
|
258
|
+
service?: ServiceConfig;
|
|
259
|
+
/** Registry generation options */
|
|
260
|
+
registry?: RegistryOptions;
|
|
261
|
+
/** Design token discovery and mapping configuration */
|
|
262
|
+
tokens?: TokenConfig;
|
|
263
|
+
/** CI pipeline configuration */
|
|
264
|
+
ci?: CIConfig;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @deprecated Use FragmentsConfig instead
|
|
268
|
+
*/
|
|
269
|
+
type SegmentsConfig = FragmentsConfig;
|
|
270
|
+
/**
|
|
271
|
+
* Screenshot capture configuration
|
|
272
|
+
*/
|
|
273
|
+
interface ScreenshotConfig {
|
|
274
|
+
/** Default viewport for captures */
|
|
275
|
+
viewport?: Viewport;
|
|
276
|
+
/** Diff threshold percentage (0-100) */
|
|
277
|
+
threshold?: number;
|
|
278
|
+
/** Additional delay after render before capture (ms) */
|
|
279
|
+
delay?: number;
|
|
280
|
+
/** Output directory for baselines (relative to project root) */
|
|
281
|
+
outputDir?: string;
|
|
282
|
+
/** Themes to capture */
|
|
283
|
+
themes?: Theme[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Service configuration
|
|
287
|
+
*/
|
|
288
|
+
interface ServiceConfig {
|
|
289
|
+
/** Browser pool size */
|
|
290
|
+
poolSize?: number;
|
|
291
|
+
/** Idle timeout before shutdown (ms) */
|
|
292
|
+
idleTimeout?: number;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Viewport dimensions
|
|
296
|
+
*/
|
|
297
|
+
interface Viewport {
|
|
298
|
+
width: number;
|
|
299
|
+
height: number;
|
|
300
|
+
deviceScaleFactor?: number;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Theme identifier
|
|
304
|
+
*/
|
|
305
|
+
type Theme = "light" | "dark";
|
|
306
|
+
/**
|
|
307
|
+
* Result of comparing two screenshots
|
|
308
|
+
*/
|
|
309
|
+
interface DiffResult {
|
|
310
|
+
/** Whether images are considered matching (below threshold) */
|
|
311
|
+
matches: boolean;
|
|
312
|
+
/** Percentage of pixels that differ (0-100) */
|
|
313
|
+
diffPercentage: number;
|
|
314
|
+
/** Number of differing pixels */
|
|
315
|
+
diffPixelCount: number;
|
|
316
|
+
/** Total pixels compared */
|
|
317
|
+
totalPixels: number;
|
|
318
|
+
/** PNG image highlighting differences */
|
|
319
|
+
diffImage?: Buffer;
|
|
320
|
+
/** Bounding boxes of changed regions */
|
|
321
|
+
changedRegions: BoundingBox[];
|
|
322
|
+
/** Time taken to compute diff (ms) */
|
|
323
|
+
diffTimeMs: number;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Bounding box for changed region
|
|
327
|
+
*/
|
|
328
|
+
interface BoundingBox {
|
|
329
|
+
x: number;
|
|
330
|
+
y: number;
|
|
331
|
+
width: number;
|
|
332
|
+
height: number;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Compiled segment data (JSON-serializable for AI consumption)
|
|
336
|
+
*/
|
|
337
|
+
interface CompiledSegment {
|
|
338
|
+
/** File path relative to project root */
|
|
339
|
+
filePath: string;
|
|
340
|
+
/** Component metadata */
|
|
341
|
+
meta: SegmentMeta;
|
|
342
|
+
/** Usage guidelines */
|
|
343
|
+
usage: SegmentUsage;
|
|
344
|
+
/** Props documentation (without render functions) */
|
|
345
|
+
props: Record<string, PropDefinition>;
|
|
346
|
+
/** Component relationships */
|
|
347
|
+
relations?: ComponentRelation[];
|
|
348
|
+
/** Variant names and descriptions (without render functions) */
|
|
349
|
+
variants: Array<{
|
|
350
|
+
name: string;
|
|
351
|
+
description: string;
|
|
352
|
+
code?: string;
|
|
353
|
+
figma?: string;
|
|
354
|
+
/** Args/props used to render this variant (for code generation) */
|
|
355
|
+
args?: Record<string, unknown>;
|
|
356
|
+
}>;
|
|
357
|
+
/** Agent-optimized contract metadata */
|
|
358
|
+
contract?: SegmentContract;
|
|
359
|
+
/** Provenance tracking (for generated segments) */
|
|
360
|
+
_generated?: SegmentGenerated;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Compiled recipe data (JSON-serializable for AI consumption)
|
|
364
|
+
*/
|
|
365
|
+
interface CompiledRecipe {
|
|
366
|
+
filePath: string;
|
|
367
|
+
name: string;
|
|
368
|
+
description: string;
|
|
369
|
+
category: string;
|
|
370
|
+
components: string[];
|
|
371
|
+
code: string;
|
|
372
|
+
tags?: string[];
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The compiled segments.json structure
|
|
376
|
+
*/
|
|
377
|
+
interface CompiledSegmentsFile {
|
|
378
|
+
/** Version of the schema */
|
|
379
|
+
version: string;
|
|
380
|
+
/** When this file was generated */
|
|
381
|
+
generatedAt: string;
|
|
382
|
+
/** All compiled segments indexed by component name */
|
|
383
|
+
segments: Record<string, CompiledSegment>;
|
|
384
|
+
/** All compiled recipes indexed by recipe name */
|
|
385
|
+
recipes?: Record<string, CompiledRecipe>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Find the config file in the current directory or parent directories.
|
|
390
|
+
* Checks for both the current config file name and the legacy name.
|
|
391
|
+
*/
|
|
392
|
+
declare function findConfigFile(startDir?: string): string | null;
|
|
393
|
+
/**
|
|
394
|
+
* Load and validate the config file
|
|
395
|
+
*/
|
|
396
|
+
declare function loadConfig(configPath?: string): Promise<{
|
|
397
|
+
config: SegmentsConfig;
|
|
398
|
+
configDir: string;
|
|
399
|
+
}>;
|
|
400
|
+
|
|
401
|
+
interface DiscoveredFile {
|
|
402
|
+
/** Absolute path to the file */
|
|
403
|
+
absolutePath: string;
|
|
404
|
+
/** Path relative to config directory */
|
|
405
|
+
relativePath: string;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Discover segment files matching the config patterns
|
|
409
|
+
*/
|
|
410
|
+
declare function discoverSegmentFiles(config: SegmentsConfig, configDir: string): Promise<DiscoveredFile[]>;
|
|
411
|
+
/**
|
|
412
|
+
* Discover component files for coverage validation
|
|
413
|
+
*/
|
|
414
|
+
declare function discoverComponentFiles(config: SegmentsConfig, configDir: string): Promise<DiscoveredFile[]>;
|
|
415
|
+
/**
|
|
416
|
+
* Extract component name from file path
|
|
417
|
+
*/
|
|
418
|
+
declare function extractComponentName(filePath: string): string;
|
|
419
|
+
|
|
420
|
+
interface ValidationResult {
|
|
421
|
+
valid: boolean;
|
|
422
|
+
errors: ValidationError[];
|
|
423
|
+
warnings: ValidationWarning[];
|
|
424
|
+
}
|
|
425
|
+
interface ValidationError {
|
|
426
|
+
file: string;
|
|
427
|
+
message: string;
|
|
428
|
+
details?: string;
|
|
429
|
+
}
|
|
430
|
+
interface ValidationWarning {
|
|
431
|
+
file: string;
|
|
432
|
+
message: string;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Validate segment file schema
|
|
436
|
+
*/
|
|
437
|
+
declare function validateSchema(config: SegmentsConfig, configDir: string): Promise<ValidationResult>;
|
|
438
|
+
/**
|
|
439
|
+
* Validate coverage - ensure all components have segments
|
|
440
|
+
*/
|
|
441
|
+
declare function validateCoverage(config: SegmentsConfig, configDir: string): Promise<ValidationResult>;
|
|
442
|
+
/**
|
|
443
|
+
* Run all validations
|
|
444
|
+
*/
|
|
445
|
+
declare function validateAll(config: SegmentsConfig, configDir: string): Promise<ValidationResult>;
|
|
446
|
+
|
|
447
|
+
interface BuildResult {
|
|
448
|
+
success: boolean;
|
|
449
|
+
outputPath: string;
|
|
450
|
+
segmentCount: number;
|
|
451
|
+
errors: Array<{
|
|
452
|
+
file: string;
|
|
453
|
+
error: string;
|
|
454
|
+
}>;
|
|
455
|
+
warnings: Array<{
|
|
456
|
+
file: string;
|
|
457
|
+
warning: string;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Build compiled fragments.json file for AI consumption.
|
|
462
|
+
*
|
|
463
|
+
* Uses AST parsing to extract metadata WITHOUT executing fragment files.
|
|
464
|
+
* This means the build works without any project dependencies installed.
|
|
465
|
+
*/
|
|
466
|
+
declare function buildSegments(config: SegmentsConfig, configDir: string): Promise<BuildResult>;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Options for the screenshot command
|
|
470
|
+
*/
|
|
471
|
+
interface ScreenshotCommandOptions {
|
|
472
|
+
/** Specific component to capture */
|
|
473
|
+
component?: string;
|
|
474
|
+
/** Specific variant to capture */
|
|
475
|
+
variant?: string;
|
|
476
|
+
/** Theme to capture */
|
|
477
|
+
theme?: Theme;
|
|
478
|
+
/** Update existing baselines */
|
|
479
|
+
update?: boolean;
|
|
480
|
+
/** CI mode - no interactive prompts */
|
|
481
|
+
ci?: boolean;
|
|
482
|
+
/** Viewport width */
|
|
483
|
+
width?: number;
|
|
484
|
+
/** Viewport height */
|
|
485
|
+
height?: number;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Result of the screenshot command
|
|
489
|
+
*/
|
|
490
|
+
interface ScreenshotResult {
|
|
491
|
+
success: boolean;
|
|
492
|
+
captured: number;
|
|
493
|
+
skipped: number;
|
|
494
|
+
errors: Array<{
|
|
495
|
+
component: string;
|
|
496
|
+
variant: string;
|
|
497
|
+
error: string;
|
|
498
|
+
}>;
|
|
499
|
+
totalTimeMs: number;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Execute the screenshot command
|
|
503
|
+
*/
|
|
504
|
+
declare function runScreenshotCommand(config: SegmentsConfig, configDir: string, options?: ScreenshotCommandOptions): Promise<ScreenshotResult>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Analytics engine for design system insights.
|
|
508
|
+
*
|
|
509
|
+
* Analyzes compiled segments to provide:
|
|
510
|
+
* - Component inventory stats
|
|
511
|
+
* - Documentation coverage
|
|
512
|
+
* - Usage pattern insights
|
|
513
|
+
* - Quality scores
|
|
514
|
+
*/
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Overall design system analytics
|
|
518
|
+
*/
|
|
519
|
+
interface DesignSystemAnalytics {
|
|
520
|
+
/** When the analysis was performed */
|
|
521
|
+
analyzedAt: Date;
|
|
522
|
+
/** Summary metrics */
|
|
523
|
+
summary: {
|
|
524
|
+
totalComponents: number;
|
|
525
|
+
totalVariants: number;
|
|
526
|
+
totalProps: number;
|
|
527
|
+
categories: string[];
|
|
528
|
+
overallScore: number;
|
|
529
|
+
};
|
|
530
|
+
/** Component inventory */
|
|
531
|
+
inventory: ComponentInventory;
|
|
532
|
+
/** Documentation coverage */
|
|
533
|
+
coverage: CoverageAnalytics;
|
|
534
|
+
/** Quality insights */
|
|
535
|
+
quality: QualityAnalytics;
|
|
536
|
+
/** Distribution charts data */
|
|
537
|
+
distribution: DistributionAnalytics;
|
|
538
|
+
/** Recommendations for improvement */
|
|
539
|
+
recommendations: Recommendation[];
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Component inventory breakdown
|
|
543
|
+
*/
|
|
544
|
+
interface ComponentInventory {
|
|
545
|
+
/** Components by category */
|
|
546
|
+
byCategory: Record<string, ComponentSummary[]>;
|
|
547
|
+
/** Components by status */
|
|
548
|
+
byStatus: Record<string, ComponentSummary[]>;
|
|
549
|
+
/** Components sorted by variant count (most to least) */
|
|
550
|
+
byVariantCount: ComponentSummary[];
|
|
551
|
+
/** Components sorted by prop count */
|
|
552
|
+
byPropCount: ComponentSummary[];
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Summary info for a single component
|
|
556
|
+
*/
|
|
557
|
+
interface ComponentSummary {
|
|
558
|
+
name: string;
|
|
559
|
+
category: string;
|
|
560
|
+
status: string;
|
|
561
|
+
variantCount: number;
|
|
562
|
+
propCount: number;
|
|
563
|
+
hasUsageWhen: boolean;
|
|
564
|
+
hasUsageWhenNot: boolean;
|
|
565
|
+
hasGuidelines: boolean;
|
|
566
|
+
hasRelations: boolean;
|
|
567
|
+
documentationScore: number;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Documentation coverage analytics
|
|
571
|
+
*/
|
|
572
|
+
interface CoverageAnalytics {
|
|
573
|
+
/** Overall coverage percentage */
|
|
574
|
+
overall: number;
|
|
575
|
+
/** Coverage by field */
|
|
576
|
+
fields: {
|
|
577
|
+
description: {
|
|
578
|
+
covered: number;
|
|
579
|
+
total: number;
|
|
580
|
+
percentage: number;
|
|
581
|
+
};
|
|
582
|
+
usageWhen: {
|
|
583
|
+
covered: number;
|
|
584
|
+
total: number;
|
|
585
|
+
percentage: number;
|
|
586
|
+
};
|
|
587
|
+
usageWhenNot: {
|
|
588
|
+
covered: number;
|
|
589
|
+
total: number;
|
|
590
|
+
percentage: number;
|
|
591
|
+
};
|
|
592
|
+
guidelines: {
|
|
593
|
+
covered: number;
|
|
594
|
+
total: number;
|
|
595
|
+
percentage: number;
|
|
596
|
+
};
|
|
597
|
+
accessibility: {
|
|
598
|
+
covered: number;
|
|
599
|
+
total: number;
|
|
600
|
+
percentage: number;
|
|
601
|
+
};
|
|
602
|
+
relations: {
|
|
603
|
+
covered: number;
|
|
604
|
+
total: number;
|
|
605
|
+
percentage: number;
|
|
606
|
+
};
|
|
607
|
+
propDescriptions: {
|
|
608
|
+
covered: number;
|
|
609
|
+
total: number;
|
|
610
|
+
percentage: number;
|
|
611
|
+
};
|
|
612
|
+
propConstraints: {
|
|
613
|
+
covered: number;
|
|
614
|
+
total: number;
|
|
615
|
+
percentage: number;
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
/** Components with incomplete documentation */
|
|
619
|
+
incomplete: Array<{
|
|
620
|
+
component: string;
|
|
621
|
+
missing: string[];
|
|
622
|
+
}>;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Quality insights
|
|
626
|
+
*/
|
|
627
|
+
interface QualityAnalytics {
|
|
628
|
+
/** Components with no whenNot guidance (anti-patterns) */
|
|
629
|
+
missingWhenNot: string[];
|
|
630
|
+
/** Components with no relations defined */
|
|
631
|
+
isolated: string[];
|
|
632
|
+
/** Deprecated components still in use */
|
|
633
|
+
deprecated: string[];
|
|
634
|
+
/** Components with very few variants (might need more examples) */
|
|
635
|
+
fewVariants: string[];
|
|
636
|
+
/** Props without descriptions */
|
|
637
|
+
undocumentedProps: Array<{
|
|
638
|
+
component: string;
|
|
639
|
+
prop: string;
|
|
640
|
+
}>;
|
|
641
|
+
/** Props without constraints (might need validation rules) */
|
|
642
|
+
unconstrainedProps: Array<{
|
|
643
|
+
component: string;
|
|
644
|
+
prop: string;
|
|
645
|
+
}>;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Distribution data for charts
|
|
649
|
+
*/
|
|
650
|
+
interface DistributionAnalytics {
|
|
651
|
+
/** Variants per component distribution */
|
|
652
|
+
variantsPerComponent: Array<{
|
|
653
|
+
name: string;
|
|
654
|
+
count: number;
|
|
655
|
+
}>;
|
|
656
|
+
/** Props per component distribution */
|
|
657
|
+
propsPerComponent: Array<{
|
|
658
|
+
name: string;
|
|
659
|
+
count: number;
|
|
660
|
+
}>;
|
|
661
|
+
/** Components per category */
|
|
662
|
+
componentsPerCategory: Array<{
|
|
663
|
+
category: string;
|
|
664
|
+
count: number;
|
|
665
|
+
}>;
|
|
666
|
+
/** Status distribution */
|
|
667
|
+
statusDistribution: Array<{
|
|
668
|
+
status: string;
|
|
669
|
+
count: number;
|
|
670
|
+
}>;
|
|
671
|
+
/** Tag frequency */
|
|
672
|
+
tagFrequency: Array<{
|
|
673
|
+
tag: string;
|
|
674
|
+
count: number;
|
|
675
|
+
}>;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Actionable recommendation
|
|
679
|
+
*/
|
|
680
|
+
interface Recommendation {
|
|
681
|
+
priority: "high" | "medium" | "low";
|
|
682
|
+
category: "documentation" | "coverage" | "quality" | "organization";
|
|
683
|
+
title: string;
|
|
684
|
+
description: string;
|
|
685
|
+
components?: string[];
|
|
686
|
+
impact: string;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Options for the diff command
|
|
691
|
+
*/
|
|
692
|
+
interface DiffCommandOptions {
|
|
693
|
+
/** Specific component to diff */
|
|
694
|
+
component?: string;
|
|
695
|
+
/** Specific variant to diff */
|
|
696
|
+
variant?: string;
|
|
697
|
+
/** Theme to compare */
|
|
698
|
+
theme?: Theme;
|
|
699
|
+
/** CI mode - exit 1 on differences */
|
|
700
|
+
ci?: boolean;
|
|
701
|
+
/** Diff threshold percentage */
|
|
702
|
+
threshold?: number;
|
|
703
|
+
/** Open diff images */
|
|
704
|
+
open?: boolean;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Single diff result with metadata
|
|
708
|
+
*/
|
|
709
|
+
interface VariantDiffResult {
|
|
710
|
+
component: string;
|
|
711
|
+
variant: string;
|
|
712
|
+
theme: Theme;
|
|
713
|
+
result: DiffResult;
|
|
714
|
+
diffImagePath?: string;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Result of the diff command
|
|
718
|
+
*/
|
|
719
|
+
interface DiffCommandResult {
|
|
720
|
+
success: boolean;
|
|
721
|
+
total: number;
|
|
722
|
+
passed: number;
|
|
723
|
+
failed: number;
|
|
724
|
+
missing: number;
|
|
725
|
+
results: VariantDiffResult[];
|
|
726
|
+
totalTimeMs: number;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Execute the diff command
|
|
730
|
+
*/
|
|
731
|
+
declare function runDiffCommand(config: SegmentsConfig, configDir: string, options?: DiffCommandOptions): Promise<DiffCommandResult>;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* CLI command: segments analyze
|
|
735
|
+
*
|
|
736
|
+
* Analyzes the design system and generates an HTML report with:
|
|
737
|
+
* - Component inventory
|
|
738
|
+
* - Documentation coverage
|
|
739
|
+
* - Quality insights
|
|
740
|
+
* - Actionable recommendations
|
|
741
|
+
*/
|
|
742
|
+
|
|
743
|
+
interface AnalyzeOptions {
|
|
744
|
+
/** Output format */
|
|
745
|
+
format?: "html" | "json" | "console";
|
|
746
|
+
/** Output file path (default: segments-report.html) */
|
|
747
|
+
output?: string;
|
|
748
|
+
/** Open report in browser after generation */
|
|
749
|
+
open?: boolean;
|
|
750
|
+
/** CI mode - exit with appropriate code */
|
|
751
|
+
ci?: boolean;
|
|
752
|
+
/** Minimum score to pass in CI mode */
|
|
753
|
+
minScore?: number;
|
|
754
|
+
}
|
|
755
|
+
interface AnalyzeResult {
|
|
756
|
+
success: boolean;
|
|
757
|
+
analytics: DesignSystemAnalytics;
|
|
758
|
+
outputPath?: string;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Run the analyze command
|
|
762
|
+
*/
|
|
763
|
+
declare function runAnalyzeCommand(config: SegmentsConfig, configDir: string, options?: AnalyzeOptions): Promise<AnalyzeResult>;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Generate a static HTML viewer for the segments.json file.
|
|
767
|
+
* This viewer shows component documentation without needing to render actual components.
|
|
768
|
+
*/
|
|
769
|
+
declare function generateStaticViewer(data: CompiledSegmentsFile): string;
|
|
770
|
+
/**
|
|
771
|
+
* Load segments.json and generate static viewer
|
|
772
|
+
*/
|
|
773
|
+
declare function generateViewerFromJson(jsonPath: string): Promise<string>;
|
|
774
|
+
|
|
775
|
+
export { type AnalyzeOptions, type AnalyzeResult, type BuildResult, type DiffCommandOptions, type DiffCommandResult, type DiscoveredFile, type ScreenshotCommandOptions, type ScreenshotResult, type ValidationError, type ValidationResult, type ValidationWarning, type VariantDiffResult, buildSegments, discoverComponentFiles, discoverSegmentFiles, extractComponentName, findConfigFile, generateStaticViewer, generateViewerFromJson, loadConfig, runAnalyzeCommand, runDiffCommand, runScreenshotCommand, validateAll, validateCoverage, validateSchema };
|