@fragments-sdk/context 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{chunk-ZMBYQK43.js → chunk-F3ZH5BUA.js} +0 -1
- package/dist/chunk-HAJWPNLU.js +310 -0
- package/dist/chunk-U4V5NX67.js +447 -0
- package/dist/cli-commands/index.d.ts +31 -0
- package/dist/cli-commands/index.js +8 -0
- package/dist/generate/index.d.ts +1 -0
- package/dist/graph/index.d.ts +66 -0
- package/dist/graph/index.js +388 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +17 -1
- package/dist/mcp-tools/index.d.ts +53 -0
- package/dist/mcp-tools/index.js +12 -0
- package/dist/search/index.js +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types-DOhSojcf.d.ts +119 -0
- package/package.json +26 -10
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
// src/cli-commands/index.ts
|
|
2
|
+
var CLI_COMMAND_CATEGORIES = {
|
|
3
|
+
setup: {
|
|
4
|
+
label: "Setup",
|
|
5
|
+
description: "Initialize and scaffold your design system project."
|
|
6
|
+
},
|
|
7
|
+
build: {
|
|
8
|
+
label: "Build & Compile",
|
|
9
|
+
description: "Compile fragment files into machine-readable output."
|
|
10
|
+
},
|
|
11
|
+
dev: {
|
|
12
|
+
label: "Development",
|
|
13
|
+
description: "Development server and live preview tools."
|
|
14
|
+
},
|
|
15
|
+
quality: {
|
|
16
|
+
label: "Quality & Compliance",
|
|
17
|
+
description: "Validate, audit, and verify design system compliance."
|
|
18
|
+
},
|
|
19
|
+
visual: {
|
|
20
|
+
label: "Visual Testing",
|
|
21
|
+
description: "Screenshot capture, diff, and visual regression testing."
|
|
22
|
+
},
|
|
23
|
+
ai: {
|
|
24
|
+
label: "AI & Context",
|
|
25
|
+
description: "Generate AI-ready context and enhance documentation."
|
|
26
|
+
},
|
|
27
|
+
integration: {
|
|
28
|
+
label: "Integrations",
|
|
29
|
+
description: "Link Figma designs, Storybook stories, and external tools."
|
|
30
|
+
},
|
|
31
|
+
utility: {
|
|
32
|
+
label: "Utilities",
|
|
33
|
+
description: "Miscellaneous helpers and viewers."
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var CLI_COMMANDS = [
|
|
37
|
+
// ── Setup ──
|
|
38
|
+
{
|
|
39
|
+
name: "init",
|
|
40
|
+
description: "Initialize fragments in a project (interactive by default)",
|
|
41
|
+
category: "setup",
|
|
42
|
+
usage: "fragments init [--yes] [--force]",
|
|
43
|
+
options: [
|
|
44
|
+
{ flags: "--force", description: "Overwrite existing config" },
|
|
45
|
+
{ flags: "-y, --yes", description: "Non-interactive mode \u2014 auto-detect and use defaults" }
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "add",
|
|
50
|
+
description: "Scaffold a new component with fragment file",
|
|
51
|
+
category: "setup",
|
|
52
|
+
usage: "fragments add [name] [options]",
|
|
53
|
+
argument: "[name]",
|
|
54
|
+
argumentDescription: 'Component name (e.g., "Button", "TextField")',
|
|
55
|
+
options: [
|
|
56
|
+
{ flags: "-c, --category <category>", description: "Component category" },
|
|
57
|
+
{ flags: "-d, --dir <directory>", description: "Output directory" },
|
|
58
|
+
{ flags: "-t, --template <template>", description: "Template to use (action, form-input, layout, display)" },
|
|
59
|
+
{ flags: "--no-component", description: "Only generate fragment file, skip component stub" }
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
// ── Build ──
|
|
63
|
+
{
|
|
64
|
+
name: "build",
|
|
65
|
+
description: "Build compiled fragments.json and .fragments/ directory",
|
|
66
|
+
category: "build",
|
|
67
|
+
usage: "fragments build [options]",
|
|
68
|
+
options: [
|
|
69
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
70
|
+
{ flags: "-o, --output <path>", description: "Output file path" },
|
|
71
|
+
{ flags: "--registry", description: "Also generate .fragments/registry.json and context.md" },
|
|
72
|
+
{ flags: "--registry-only", description: "Only generate .fragments/ directory (skip fragments.json)" },
|
|
73
|
+
{ flags: "--from-source", description: "Build from source code (zero-config, no fragment files needed)" },
|
|
74
|
+
{ flags: "--skip-usage", description: "Skip usage analysis when building from source" },
|
|
75
|
+
{ flags: "--skip-storybook", description: "Skip Storybook parsing when building from source" },
|
|
76
|
+
{ flags: "-v, --verbose", description: "Verbose output" }
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "scan",
|
|
81
|
+
description: "Zero-config fragments.json generation from source code",
|
|
82
|
+
category: "build",
|
|
83
|
+
usage: "fragments scan [options]",
|
|
84
|
+
options: [
|
|
85
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
86
|
+
{ flags: "-o, --output <path>", description: "Output file path", default: "fragments.json" },
|
|
87
|
+
{ flags: "--patterns <patterns...>", description: "Component file patterns to scan" },
|
|
88
|
+
{ flags: "--barrel <files...>", description: "Barrel export files to parse" },
|
|
89
|
+
{ flags: "--usage-dir <dir>", description: "Directory to scan for usage patterns" },
|
|
90
|
+
{ flags: "--skip-usage", description: "Skip usage pattern analysis" },
|
|
91
|
+
{ flags: "--skip-storybook", description: "Skip Storybook story parsing" },
|
|
92
|
+
{ flags: "-v, --verbose", description: "Verbose output" }
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "generate",
|
|
97
|
+
description: "Generate fragment files from component source code",
|
|
98
|
+
category: "build",
|
|
99
|
+
usage: "fragments generate [component] [options]",
|
|
100
|
+
argument: "[component]",
|
|
101
|
+
argumentDescription: "Specific component name to generate (optional)",
|
|
102
|
+
options: [
|
|
103
|
+
{ flags: "--force", description: "Overwrite existing fragment files" },
|
|
104
|
+
{ flags: "--pattern <glob>", description: "Pattern for component files", default: "src/components/**/*.tsx" }
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "validate",
|
|
109
|
+
description: "Validate fragment files",
|
|
110
|
+
category: "build",
|
|
111
|
+
usage: "fragments validate [options]",
|
|
112
|
+
options: [
|
|
113
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
114
|
+
{ flags: "--schema", description: "Validate fragment schema only" },
|
|
115
|
+
{ flags: "--coverage", description: "Validate coverage only" }
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
// ── Dev ──
|
|
119
|
+
{
|
|
120
|
+
name: "dev",
|
|
121
|
+
description: "Start the development server with live component rendering",
|
|
122
|
+
category: "dev",
|
|
123
|
+
usage: "fragments dev [options]",
|
|
124
|
+
options: [
|
|
125
|
+
{ flags: "-p, --port <port>", description: "Port to run on", default: "6006" },
|
|
126
|
+
{ flags: "--no-open", description: "Do not open browser" },
|
|
127
|
+
{ flags: "--skip-setup", description: "Skip auto-setup (Storybook import, build, Figma link)" },
|
|
128
|
+
{ flags: "--skip-storybook", description: "Skip auto-importing from Storybook" },
|
|
129
|
+
{ flags: "--skip-figma", description: "Skip Figma link check" },
|
|
130
|
+
{ flags: "--skip-build", description: "Skip auto-building fragments.json" }
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "list",
|
|
135
|
+
description: "List all discovered fragment files",
|
|
136
|
+
category: "dev",
|
|
137
|
+
usage: "fragments list [options]",
|
|
138
|
+
options: [
|
|
139
|
+
{ flags: "-c, --config <path>", description: "Path to config file" }
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "tokens",
|
|
144
|
+
description: "Discover and list design tokens from CSS/SCSS files",
|
|
145
|
+
category: "dev",
|
|
146
|
+
usage: "fragments tokens [options]",
|
|
147
|
+
options: [
|
|
148
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
149
|
+
{ flags: "--json", description: "Output as JSON" },
|
|
150
|
+
{ flags: "--categories", description: "Group tokens by category" },
|
|
151
|
+
{ flags: "--theme <theme>", description: "Filter by theme name" },
|
|
152
|
+
{ flags: "--category <category>", description: "Filter by category (color, spacing, typography, etc.)" },
|
|
153
|
+
{ flags: "--verbose", description: "Show all tokens (no truncation)" }
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
// ── Quality ──
|
|
157
|
+
{
|
|
158
|
+
name: "verify",
|
|
159
|
+
description: "Verify component compliance for CI pipelines",
|
|
160
|
+
category: "quality",
|
|
161
|
+
usage: "fragments verify [component] [options]",
|
|
162
|
+
argument: "[component]",
|
|
163
|
+
argumentDescription: "Component name to verify (optional, verifies all if omitted)",
|
|
164
|
+
options: [
|
|
165
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
166
|
+
{ flags: "--ci", description: "CI mode \u2014 output JSON and exit non-zero on failure" },
|
|
167
|
+
{ flags: "--min-compliance <percent>", description: "Minimum compliance percentage", default: "80" },
|
|
168
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "audit",
|
|
173
|
+
description: "Scan all fragments and show compliance metrics across the design system",
|
|
174
|
+
category: "quality",
|
|
175
|
+
usage: "fragments audit [options]",
|
|
176
|
+
options: [
|
|
177
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
178
|
+
{ flags: "--json", description: "Output machine-readable JSON format" },
|
|
179
|
+
{ flags: "--sort <field>", description: "Sort by field: compliance, name, hardcoded", default: "compliance" },
|
|
180
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "a11y",
|
|
185
|
+
description: "Run accessibility checks on all component variants",
|
|
186
|
+
category: "quality",
|
|
187
|
+
usage: "fragments a11y [options]",
|
|
188
|
+
options: [
|
|
189
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
190
|
+
{ flags: "--json", description: "Output results as JSON" },
|
|
191
|
+
{ flags: "--ci", description: "CI mode (exit code 1 if any critical/serious violations)" },
|
|
192
|
+
{ flags: "--component <name>", description: "Check specific component only" },
|
|
193
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: "test",
|
|
198
|
+
description: "Run interaction tests for fragments with play functions",
|
|
199
|
+
category: "quality",
|
|
200
|
+
usage: "fragments test [options]",
|
|
201
|
+
options: [
|
|
202
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
203
|
+
{ flags: "--component <name>", description: "Filter by component name" },
|
|
204
|
+
{ flags: "--tags <tags>", description: "Filter by tags (comma-separated)" },
|
|
205
|
+
{ flags: "--grep <pattern>", description: "Filter by variant name pattern" },
|
|
206
|
+
{ flags: "--exclude <pattern>", description: "Exclude tests matching pattern" },
|
|
207
|
+
{ flags: "--parallel <count>", description: "Number of parallel browser contexts", default: "4" },
|
|
208
|
+
{ flags: "--timeout <ms>", description: "Timeout per test in milliseconds", default: "30000" },
|
|
209
|
+
{ flags: "--retries <count>", description: "Number of retries for failed tests", default: "0" },
|
|
210
|
+
{ flags: "--bail", description: "Stop on first failure" },
|
|
211
|
+
{ flags: "--browser <name>", description: "Browser to use (chromium, firefox, webkit)", default: "chromium" },
|
|
212
|
+
{ flags: "--headed", description: "Run in headed mode (show browser)" },
|
|
213
|
+
{ flags: "--a11y", description: "Run accessibility checks with axe-core" },
|
|
214
|
+
{ flags: "--visual", description: "Capture screenshots for visual regression" },
|
|
215
|
+
{ flags: "--update-snapshots", description: "Update visual snapshots" },
|
|
216
|
+
{ flags: "--watch", description: "Watch mode \u2014 re-run on file changes" },
|
|
217
|
+
{ flags: "--reporters <names>", description: "Reporters to use (console, junit, json)", default: "console" },
|
|
218
|
+
{ flags: "-o, --output <dir>", description: "Output directory for results", default: "./test-results" },
|
|
219
|
+
{ flags: "--server-url <url>", description: "URL of running dev server (skips starting server)" },
|
|
220
|
+
{ flags: "-p, --port <port>", description: "Port for dev server", default: "6006" },
|
|
221
|
+
{ flags: "--ci", description: "CI mode \u2014 non-interactive, exit with code 1 on failure" },
|
|
222
|
+
{ flags: "--list", description: "List available tests without running them" }
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
// ── Visual ──
|
|
226
|
+
{
|
|
227
|
+
name: "screenshot",
|
|
228
|
+
description: "Capture screenshots of component variants",
|
|
229
|
+
category: "visual",
|
|
230
|
+
usage: "fragments screenshot [options]",
|
|
231
|
+
options: [
|
|
232
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
233
|
+
{ flags: "--component <name>", description: "Capture specific component only" },
|
|
234
|
+
{ flags: "--variant <name>", description: "Capture specific variant only" },
|
|
235
|
+
{ flags: "--theme <theme>", description: "Theme to capture (light/dark)", default: "light" },
|
|
236
|
+
{ flags: "--update", description: "Update existing baselines" },
|
|
237
|
+
{ flags: "--width <pixels>", description: "Viewport width" },
|
|
238
|
+
{ flags: "--height <pixels>", description: "Viewport height" },
|
|
239
|
+
{ flags: "--ci", description: "CI mode \u2014 no interactive prompts" }
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "diff",
|
|
244
|
+
description: "Compare current renders against baselines",
|
|
245
|
+
category: "visual",
|
|
246
|
+
usage: "fragments diff [component] [options]",
|
|
247
|
+
argument: "[component]",
|
|
248
|
+
argumentDescription: "Component name to diff (optional)",
|
|
249
|
+
options: [
|
|
250
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
251
|
+
{ flags: "--variant <name>", description: "Compare specific variant only" },
|
|
252
|
+
{ flags: "--theme <theme>", description: "Theme to compare (light/dark)", default: "light" },
|
|
253
|
+
{ flags: "--threshold <percent>", description: "Diff threshold percentage" },
|
|
254
|
+
{ flags: "--ci", description: "CI mode \u2014 exit 1 on differences" },
|
|
255
|
+
{ flags: "--open", description: "Open diff images" }
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "compare",
|
|
260
|
+
description: "Compare component renders against Figma designs",
|
|
261
|
+
category: "visual",
|
|
262
|
+
usage: "fragments compare [component] [options]",
|
|
263
|
+
argument: "[component]",
|
|
264
|
+
argumentDescription: "Component name to compare",
|
|
265
|
+
options: [
|
|
266
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
267
|
+
{ flags: "--variant <name>", description: "Compare specific variant" },
|
|
268
|
+
{ flags: "--figma <url>", description: "Figma frame URL (uses fragment figma link if not provided)" },
|
|
269
|
+
{ flags: "--threshold <percent>", description: "Diff threshold percentage", default: "1.0" },
|
|
270
|
+
{ flags: "--all", description: "Compare all components with Figma links" },
|
|
271
|
+
{ flags: "--output <dir>", description: "Save diff images to directory" },
|
|
272
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
273
|
+
]
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "baseline",
|
|
277
|
+
description: "Manage visual regression baselines",
|
|
278
|
+
category: "visual",
|
|
279
|
+
usage: "fragments baseline <action> [component] [options]",
|
|
280
|
+
argument: "<action>",
|
|
281
|
+
argumentDescription: "Action to perform: update, list, delete",
|
|
282
|
+
options: [
|
|
283
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
284
|
+
{ flags: "--variant <name>", description: "Specific variant to update" },
|
|
285
|
+
{ flags: "--all", description: "Update/delete all baselines" },
|
|
286
|
+
{ flags: "--theme <theme>", description: "Theme for baseline (light/dark)", default: "light" },
|
|
287
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: "metrics",
|
|
292
|
+
description: "View compliance trends over time",
|
|
293
|
+
category: "visual",
|
|
294
|
+
usage: "fragments metrics [component] [options]",
|
|
295
|
+
argument: "[component]",
|
|
296
|
+
argumentDescription: "Component name (optional, shows system-wide if omitted)",
|
|
297
|
+
options: [
|
|
298
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
299
|
+
{ flags: "--days <number>", description: "Number of days to look back", default: "30" },
|
|
300
|
+
{ flags: "--json", description: "Output JSON format" }
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
// ── Graph ──
|
|
304
|
+
{
|
|
305
|
+
name: "graph",
|
|
306
|
+
description: "Query the component relationship graph for dependencies, impact analysis, and composition trees",
|
|
307
|
+
category: "ai",
|
|
308
|
+
usage: "fragments graph [component] [options]",
|
|
309
|
+
argument: "[component]",
|
|
310
|
+
argumentDescription: "Component name (optional, shows health dashboard if omitted)",
|
|
311
|
+
options: [
|
|
312
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
313
|
+
{ flags: "-m, --mode <mode>", description: "Query mode: health, dependencies, dependents, impact, path, composition, alternatives, islands" },
|
|
314
|
+
{ flags: "-t, --target <component>", description: "Target component for path mode" },
|
|
315
|
+
{ flags: "--edge-types <types>", description: "Comma-separated edge types to filter by" },
|
|
316
|
+
{ flags: "--depth <number>", description: "Max traversal depth for impact mode", default: "3" },
|
|
317
|
+
{ flags: "--format <format>", description: "Output format: table, json, dot", default: "table" }
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
// ── AI ──
|
|
321
|
+
{
|
|
322
|
+
name: "context",
|
|
323
|
+
description: "Generate AI-ready context for your design system",
|
|
324
|
+
category: "ai",
|
|
325
|
+
usage: "fragments context [options]",
|
|
326
|
+
options: [
|
|
327
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
328
|
+
{ flags: "-i, --input <path>", description: "Path to fragments.json (builds if not provided)" },
|
|
329
|
+
{ flags: "-f, --format <format>", description: "Output format (markdown/json)", default: "markdown" },
|
|
330
|
+
{ flags: "--compact", description: "Minimal output for token efficiency" },
|
|
331
|
+
{ flags: "--code", description: "Include code examples" },
|
|
332
|
+
{ flags: "--relations", description: "Include component relationships" },
|
|
333
|
+
{ flags: "--tokens", description: "Only output token estimate" }
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "ai",
|
|
338
|
+
description: "Generate context optimized for AI assistants (Claude Desktop)",
|
|
339
|
+
category: "ai",
|
|
340
|
+
usage: "fragments ai [options]",
|
|
341
|
+
options: [
|
|
342
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
343
|
+
{ flags: "--live", description: "Connect to running dev server for live data" },
|
|
344
|
+
{ flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
|
|
345
|
+
]
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "enhance",
|
|
349
|
+
description: "AI-powered documentation generation from codebase analysis",
|
|
350
|
+
category: "ai",
|
|
351
|
+
usage: "fragments enhance [options]",
|
|
352
|
+
options: [
|
|
353
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
354
|
+
{ flags: "--component <name>", description: 'Enhance specific component (or "all")' },
|
|
355
|
+
{ flags: "--yes", description: "Skip confirmation prompts" },
|
|
356
|
+
{ flags: "--dry-run", description: "Only analyze, do not modify files" },
|
|
357
|
+
{ flags: "--format <format>", description: "Output format: interactive, json, quiet, context", default: "interactive" },
|
|
358
|
+
{ flags: "--provider <provider>", description: "AI provider: anthropic, openai (auto-detected from API key)" },
|
|
359
|
+
{ flags: "--api-key <key>", description: "API key (or use ANTHROPIC_API_KEY/OPENAI_API_KEY env)" },
|
|
360
|
+
{ flags: "--model <model>", description: "AI model to use" },
|
|
361
|
+
{ flags: "--root <dir>", description: "Root directory to scan", default: "cwd" },
|
|
362
|
+
{ flags: "--context-only", description: "Output context for IDE AI without calling API" }
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
// ── Integration ──
|
|
366
|
+
{
|
|
367
|
+
name: "link figma",
|
|
368
|
+
description: "Interactive wizard to link Figma components to code",
|
|
369
|
+
category: "integration",
|
|
370
|
+
usage: "fragments link figma [figma-url] [options]",
|
|
371
|
+
argument: "[figma-url]",
|
|
372
|
+
argumentDescription: "Figma file URL to link components from",
|
|
373
|
+
options: [
|
|
374
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
375
|
+
{ flags: "--auto", description: "Auto-link matching components without prompts" },
|
|
376
|
+
{ flags: "--dry-run", description: "Show matches without updating files" },
|
|
377
|
+
{ flags: "--no-variants", description: "Skip linking individual variants to their Figma frames" }
|
|
378
|
+
]
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "link storybook",
|
|
382
|
+
description: "Bootstrap fragments from existing Storybook stories",
|
|
383
|
+
category: "integration",
|
|
384
|
+
usage: "fragments link storybook [options]",
|
|
385
|
+
options: [
|
|
386
|
+
{ flags: "-c, --config <path>", description: "Path to .storybook/main.* config" },
|
|
387
|
+
{ flags: "-o, --out <dir>", description: "Output directory for fragment files" },
|
|
388
|
+
{ flags: "--yes", description: "Skip confirmation prompts" },
|
|
389
|
+
{ flags: "--dry-run", description: "Preview what would be generated without writing files" },
|
|
390
|
+
{ flags: "--include <glob>", description: "Only process stories matching glob" },
|
|
391
|
+
{ flags: "--exclude <glob>", description: "Skip stories matching glob" }
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "storygen",
|
|
396
|
+
description: "Generate Storybook stories from fragment definitions",
|
|
397
|
+
category: "integration",
|
|
398
|
+
usage: "fragments storygen [options]",
|
|
399
|
+
options: [
|
|
400
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
401
|
+
{ flags: "-o, --output <dir>", description: "Output directory", default: ".storybook/generated" },
|
|
402
|
+
{ flags: "--watch", description: "Watch for segment changes and regenerate" },
|
|
403
|
+
{ flags: "--format <format>", description: "Story format (csf3)", default: "csf3" }
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
// ── Utility ──
|
|
407
|
+
{
|
|
408
|
+
name: "view",
|
|
409
|
+
description: "Generate a static HTML viewer for fragments.json",
|
|
410
|
+
category: "utility",
|
|
411
|
+
usage: "fragments view [options]",
|
|
412
|
+
options: [
|
|
413
|
+
{ flags: "-i, --input <path>", description: "Path to fragments.json", default: "fragments.json" },
|
|
414
|
+
{ flags: "-o, --output <path>", description: "Output HTML file path", default: "fragments-viewer.html" },
|
|
415
|
+
{ flags: "--open", description: "Open in browser after generation" }
|
|
416
|
+
]
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "analyze",
|
|
420
|
+
description: "Analyze design system and generate report",
|
|
421
|
+
category: "utility",
|
|
422
|
+
usage: "fragments analyze [options]",
|
|
423
|
+
options: [
|
|
424
|
+
{ flags: "-c, --config <path>", description: "Path to config file" },
|
|
425
|
+
{ flags: "-f, --format <format>", description: "Output format (html/json/console)", default: "html" },
|
|
426
|
+
{ flags: "-o, --output <path>", description: "Output file path" },
|
|
427
|
+
{ flags: "--open", description: "Open report in browser after generation" },
|
|
428
|
+
{ flags: "--ci", description: "CI mode \u2014 exit with code based on score" },
|
|
429
|
+
{ flags: "--min-score <score>", description: "Minimum score to pass in CI mode" }
|
|
430
|
+
]
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
name: "reset",
|
|
434
|
+
description: "Reset to initial state (delete all generated files)",
|
|
435
|
+
category: "utility",
|
|
436
|
+
usage: "fragments reset [options]",
|
|
437
|
+
options: [
|
|
438
|
+
{ flags: "-y, --yes", description: "Skip confirmation prompt" },
|
|
439
|
+
{ flags: "--dry-run", description: "Show what would be deleted without deleting" }
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
];
|
|
443
|
+
|
|
444
|
+
export {
|
|
445
|
+
CLI_COMMAND_CATEGORIES,
|
|
446
|
+
CLI_COMMANDS
|
|
447
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command metadata — single source of truth for bin.ts and docs.
|
|
3
|
+
*
|
|
4
|
+
* This file defines all CLI commands declaratively. bin.ts consumes the
|
|
5
|
+
* descriptions, and the docs site imports the full metadata to render the
|
|
6
|
+
* CLI reference page.
|
|
7
|
+
*/
|
|
8
|
+
interface CliOptionDef {
|
|
9
|
+
flags: string;
|
|
10
|
+
description: string;
|
|
11
|
+
default?: string;
|
|
12
|
+
}
|
|
13
|
+
interface CliCommandDef {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
category: CliCommandCategory;
|
|
17
|
+
usage: string;
|
|
18
|
+
options: CliOptionDef[];
|
|
19
|
+
/** Optional positional argument (e.g., "[component]") */
|
|
20
|
+
argument?: string;
|
|
21
|
+
argumentDescription?: string;
|
|
22
|
+
}
|
|
23
|
+
type CliCommandCategory = 'setup' | 'build' | 'dev' | 'quality' | 'visual' | 'ai' | 'integration' | 'utility';
|
|
24
|
+
interface CliCategoryInfo {
|
|
25
|
+
label: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}
|
|
28
|
+
declare const CLI_COMMAND_CATEGORIES: Record<CliCommandCategory, CliCategoryInfo>;
|
|
29
|
+
declare const CLI_COMMANDS: CliCommandDef[];
|
|
30
|
+
|
|
31
|
+
export { CLI_COMMANDS, CLI_COMMAND_CATEGORIES, type CliCategoryInfo, type CliCommandCategory, type CliCommandDef, type CliOptionDef };
|
package/dist/generate/index.d.ts
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { C as ComponentGraph, G as GraphEdgeType, a as GraphEdge, I as ImpactResult, P as PathResult, N as NeighborResult, b as CompositionTree, c as GraphHealth, d as ComponentNode, S as SerializedComponentGraph } from '../types-DOhSojcf.js';
|
|
2
|
+
export { E as EDGE_TYPE_WEIGHTS, f as GRAPH_EDGE_TYPES, e as SerializedEdge } from '../types-DOhSojcf.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ComponentGraphEngine — query engine for the design-system relationship graph.
|
|
6
|
+
*
|
|
7
|
+
* Provides BFS-based traversal, impact analysis, composition trees,
|
|
8
|
+
* alternative discovery, and health metrics. Operates on an in-memory
|
|
9
|
+
* adjacency list built from GraphEdge[].
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare class ComponentGraphEngine {
|
|
13
|
+
private nodes;
|
|
14
|
+
private outgoing;
|
|
15
|
+
private incoming;
|
|
16
|
+
private edges;
|
|
17
|
+
private blockIndex;
|
|
18
|
+
private health;
|
|
19
|
+
constructor(graph: ComponentGraph, blocks?: Record<string, {
|
|
20
|
+
components: string[];
|
|
21
|
+
}>);
|
|
22
|
+
/** Get outgoing edges from a component, optionally filtered by edge type */
|
|
23
|
+
dependencies(component: string, edgeTypes?: GraphEdgeType[]): GraphEdge[];
|
|
24
|
+
/** Get incoming edges to a component, optionally filtered by edge type */
|
|
25
|
+
dependents(component: string, edgeTypes?: GraphEdgeType[]): GraphEdge[];
|
|
26
|
+
/** BFS transitive closure — what's affected if this component changes */
|
|
27
|
+
impact(component: string, maxDepth?: number): ImpactResult;
|
|
28
|
+
/** BFS shortest path between two components (undirected) */
|
|
29
|
+
path(from: string, to: string): PathResult;
|
|
30
|
+
/** Connected components via BFS on undirected projection */
|
|
31
|
+
islands(): string[][];
|
|
32
|
+
/** All components reachable within N hops (undirected) */
|
|
33
|
+
neighbors(component: string, maxHops?: number): NeighborResult;
|
|
34
|
+
/** Get the composition tree for a compound component */
|
|
35
|
+
composition(component: string): CompositionTree;
|
|
36
|
+
/** Get alternative components */
|
|
37
|
+
alternatives(component: string): Array<{
|
|
38
|
+
component: string;
|
|
39
|
+
note?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/** Get blocks that use a component */
|
|
42
|
+
blocksUsing(component: string): string[];
|
|
43
|
+
/** Extract an induced subgraph for a set of components */
|
|
44
|
+
subgraph(components: string[]): ComponentGraph;
|
|
45
|
+
/** Return precomputed health metrics */
|
|
46
|
+
getHealth(): GraphHealth;
|
|
47
|
+
/** Get a single node by name */
|
|
48
|
+
getNode(name: string): ComponentNode | undefined;
|
|
49
|
+
/** Check if a component exists in the graph */
|
|
50
|
+
hasNode(name: string): boolean;
|
|
51
|
+
}
|
|
52
|
+
declare function computeHealthFromData(nodes: ComponentNode[], edges: GraphEdge[], blockIndex?: Map<string, string[]>): GraphHealth;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Graph serialization — compact JSON format for fragments.json embedding.
|
|
56
|
+
*
|
|
57
|
+
* Edges use short keys (s, t, ty, w, no, p) to reduce JSON size.
|
|
58
|
+
* Round-trips through serialize → deserialize preserve all data.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/** Serialize a ComponentGraph to compact JSON format */
|
|
62
|
+
declare function serializeGraph(graph: ComponentGraph): SerializedComponentGraph;
|
|
63
|
+
/** Deserialize a compact JSON graph back to full ComponentGraph */
|
|
64
|
+
declare function deserializeGraph(serialized: SerializedComponentGraph): ComponentGraph;
|
|
65
|
+
|
|
66
|
+
export { ComponentGraph, ComponentGraphEngine, ComponentNode, CompositionTree, GraphEdge, GraphEdgeType, GraphHealth, ImpactResult, NeighborResult, PathResult, SerializedComponentGraph, computeHealthFromData, deserializeGraph, serializeGraph };
|