@fragments-sdk/cli 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +8 -8
- package/dist/{chunk-7H2MMGYG.js → chunk-3OTEW66K.js} +2 -2
- package/dist/{chunk-4FDQSGKX.js → chunk-D6VXWI45.js} +15 -4
- package/dist/chunk-D6VXWI45.js.map +1 -0
- package/dist/{chunk-OAENNG3G.js → chunk-PMGI7ATF.js} +27 -1
- package/dist/chunk-PMGI7ATF.js.map +1 -0
- package/dist/{generate-4LQNJ7SX.js → generate-3LBZANQ3.js} +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/dist/{init-EMVI47QG.js → init-NKIUCYTG.js} +2 -2
- package/dist/mcp-bin.js +5 -0
- package/dist/mcp-bin.js.map +1 -1
- package/dist/{scan-4YPRF7FV.js → scan-3ZAOVO4U.js} +3 -3
- package/dist/{test-SQ5ZHXWU.js → test-ZCTR4LBB.js} +2 -2
- package/dist/{tokens-HSGMYK64.js → tokens-5JQ5IOR2.js} +2 -2
- package/dist/{viewer-UYSS7DVA.js → viewer-D7QC4GM2.js} +17 -5
- package/dist/viewer-D7QC4GM2.js.map +1 -0
- package/package.json +1 -1
- package/src/build.ts +14 -0
- package/src/core/discovery.ts +40 -0
- package/src/core/node.ts +1 -0
- package/src/core/types.ts +3 -0
- package/src/mcp/server.ts +11 -1
- package/src/viewer/__tests__/viewer-integration.test.ts +81 -2
- package/src/viewer/server.ts +20 -5
- package/dist/chunk-4FDQSGKX.js.map +0 -1
- package/dist/chunk-OAENNG3G.js.map +0 -1
- package/dist/viewer-UYSS7DVA.js.map +0 -1
- /package/dist/{chunk-7H2MMGYG.js.map → chunk-3OTEW66K.js.map} +0 -0
- /package/dist/{generate-4LQNJ7SX.js.map → generate-3LBZANQ3.js.map} +0 -0
- /package/dist/{init-EMVI47QG.js.map → init-NKIUCYTG.js.map} +0 -0
- /package/dist/{scan-4YPRF7FV.js.map → scan-3ZAOVO4U.js.map} +0 -0
- /package/dist/{test-SQ5ZHXWU.js.map → test-ZCTR4LBB.js.map} +0 -0
- /package/dist/{tokens-HSGMYK64.js.map → tokens-5JQ5IOR2.js.map} +0 -0
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { resolve, join } from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
3
4
|
import type {
|
|
4
5
|
SegmentsConfig,
|
|
5
6
|
CompiledSegmentsFile,
|
|
@@ -150,9 +151,22 @@ export async function buildSegments(
|
|
|
150
151
|
// Recipe discovery failure is non-fatal
|
|
151
152
|
}
|
|
152
153
|
|
|
154
|
+
// Read package name for import statements
|
|
155
|
+
let packageName: string | undefined;
|
|
156
|
+
const pkgJsonPath = resolve(configDir, "package.json");
|
|
157
|
+
if (existsSync(pkgJsonPath)) {
|
|
158
|
+
try {
|
|
159
|
+
const pkg = JSON.parse(await readFile(pkgJsonPath, "utf-8"));
|
|
160
|
+
if (pkg.name) packageName = pkg.name;
|
|
161
|
+
} catch {
|
|
162
|
+
// Non-fatal
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
153
166
|
const output: CompiledSegmentsFile = {
|
|
154
167
|
version: "1.0.0",
|
|
155
168
|
generatedAt: new Date().toISOString(),
|
|
169
|
+
...(packageName && { packageName }),
|
|
156
170
|
segments,
|
|
157
171
|
...(Object.keys(recipes).length > 0 && { recipes }),
|
|
158
172
|
};
|
package/src/core/discovery.ts
CHANGED
|
@@ -296,6 +296,46 @@ export async function discoverComponentsFromBarrel(
|
|
|
296
296
|
return components;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Discover fragment files from installed packages that declare a "fragments" field
|
|
301
|
+
* in their package.json. This allows consumer projects to see components from
|
|
302
|
+
* installed packages (e.g. @fragments-sdk/ui) in the dev viewer.
|
|
303
|
+
*/
|
|
304
|
+
export async function discoverInstalledFragments(
|
|
305
|
+
projectRoot: string
|
|
306
|
+
): Promise<DiscoveredFile[]> {
|
|
307
|
+
const pkgJsonPath = resolve(projectRoot, 'package.json');
|
|
308
|
+
if (!existsSync(pkgJsonPath)) return [];
|
|
309
|
+
|
|
310
|
+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
|
|
311
|
+
const allDeps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
|
|
312
|
+
const results: DiscoveredFile[] = [];
|
|
313
|
+
|
|
314
|
+
for (const depName of Object.keys(allDeps)) {
|
|
315
|
+
const depDir = resolve(projectRoot, 'node_modules', depName);
|
|
316
|
+
const depPkgPath = resolve(depDir, 'package.json');
|
|
317
|
+
if (!existsSync(depPkgPath)) continue;
|
|
318
|
+
|
|
319
|
+
const depPkg = JSON.parse(await readFile(depPkgPath, 'utf-8'));
|
|
320
|
+
if (!depPkg.fragments) continue;
|
|
321
|
+
|
|
322
|
+
// Package declares fragments — scan for source fragment files
|
|
323
|
+
const files = await fg(
|
|
324
|
+
[`src/**/*${BRAND.fileExtension}`, 'src/**/*.stories.tsx'],
|
|
325
|
+
{ cwd: depDir, ignore: ['**/node_modules/**'], absolute: false }
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
for (const rel of files) {
|
|
329
|
+
results.push({
|
|
330
|
+
relativePath: `${depName}/${rel}`,
|
|
331
|
+
absolutePath: resolve(depDir, rel),
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return results;
|
|
337
|
+
}
|
|
338
|
+
|
|
299
339
|
/**
|
|
300
340
|
* Discover all components using multiple strategies
|
|
301
341
|
*/
|
package/src/core/node.ts
CHANGED
package/src/core/types.ts
CHANGED
|
@@ -746,6 +746,9 @@ export interface CompiledSegmentsFile {
|
|
|
746
746
|
/** When this file was generated */
|
|
747
747
|
generatedAt: string;
|
|
748
748
|
|
|
749
|
+
/** Package name for import statements (read from package.json at build time) */
|
|
750
|
+
packageName?: string;
|
|
751
|
+
|
|
749
752
|
/** All compiled segments indexed by component name */
|
|
750
753
|
segments: Record<string, CompiledSegment>;
|
|
751
754
|
|
package/src/mcp/server.ts
CHANGED
|
@@ -366,13 +366,23 @@ export function createMcpServer(config: McpServerConfig): Server {
|
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/**
|
|
369
|
-
* Get the package name
|
|
369
|
+
* Get the package name for import statements.
|
|
370
|
+
* Prefers packageName from fragments.json (set at build time),
|
|
371
|
+
* falls back to the project's package.json name.
|
|
370
372
|
*/
|
|
371
373
|
async function getPackageName(): Promise<string> {
|
|
372
374
|
if (packageName) {
|
|
373
375
|
return packageName;
|
|
374
376
|
}
|
|
375
377
|
|
|
378
|
+
// Prefer packageName from compiled fragments.json
|
|
379
|
+
const data = await loadSegments();
|
|
380
|
+
if (data.packageName) {
|
|
381
|
+
packageName = data.packageName;
|
|
382
|
+
return packageName;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Fallback to project package.json
|
|
376
386
|
const packageJsonPath = join(config.projectRoot, 'package.json');
|
|
377
387
|
if (existsSync(packageJsonPath)) {
|
|
378
388
|
try {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
2
|
import { resolve, dirname } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
|
-
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { readFile, mkdtemp, writeFile, mkdir, rm } from "node:fs/promises";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { discoverInstalledFragments } from "../../core/discovery.js";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Integration tests for the consolidated viewer.
|
|
@@ -141,6 +143,83 @@ describe("viewer HTML templates", () => {
|
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
145
|
|
|
146
|
+
describe("discoverInstalledFragments", () => {
|
|
147
|
+
let tmpDir: string;
|
|
148
|
+
|
|
149
|
+
beforeAll(async () => {
|
|
150
|
+
tmpDir = await mkdtemp(resolve(tmpdir(), "fragments-test-"));
|
|
151
|
+
|
|
152
|
+
// Create a fake project with a dependency that has fragments
|
|
153
|
+
await writeFile(
|
|
154
|
+
resolve(tmpDir, "package.json"),
|
|
155
|
+
JSON.stringify({
|
|
156
|
+
dependencies: { "@acme/ui": "1.0.0", "some-lib": "2.0.0" },
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// @acme/ui declares fragments
|
|
161
|
+
const acmeDir = resolve(tmpDir, "node_modules/@acme/ui");
|
|
162
|
+
await mkdir(resolve(acmeDir, "src/components"), { recursive: true });
|
|
163
|
+
await writeFile(
|
|
164
|
+
resolve(acmeDir, "package.json"),
|
|
165
|
+
JSON.stringify({ name: "@acme/ui", fragments: { src: "src" } })
|
|
166
|
+
);
|
|
167
|
+
await writeFile(
|
|
168
|
+
resolve(acmeDir, "src/components/Button.fragment.tsx"),
|
|
169
|
+
"export default {};"
|
|
170
|
+
);
|
|
171
|
+
await writeFile(
|
|
172
|
+
resolve(acmeDir, "src/components/Card.fragment.tsx"),
|
|
173
|
+
"export default {};"
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// some-lib does NOT declare fragments
|
|
177
|
+
const someLibDir = resolve(tmpDir, "node_modules/some-lib");
|
|
178
|
+
await mkdir(resolve(someLibDir, "src"), { recursive: true });
|
|
179
|
+
await writeFile(
|
|
180
|
+
resolve(someLibDir, "package.json"),
|
|
181
|
+
JSON.stringify({ name: "some-lib" })
|
|
182
|
+
);
|
|
183
|
+
await writeFile(
|
|
184
|
+
resolve(someLibDir, "src/Foo.fragment.tsx"),
|
|
185
|
+
"export default {};"
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
afterAll(async () => {
|
|
190
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("finds fragment files from packages with a fragments field", async () => {
|
|
194
|
+
const results = await discoverInstalledFragments(tmpDir);
|
|
195
|
+
const paths = results.map((r) => r.relativePath).sort();
|
|
196
|
+
expect(paths).toEqual([
|
|
197
|
+
"@acme/ui/src/components/Button.fragment.tsx",
|
|
198
|
+
"@acme/ui/src/components/Card.fragment.tsx",
|
|
199
|
+
]);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("ignores packages without a fragments field", async () => {
|
|
203
|
+
const results = await discoverInstalledFragments(tmpDir);
|
|
204
|
+
const hasLib = results.some((r) => r.relativePath.includes("some-lib"));
|
|
205
|
+
expect(hasLib).toBe(false);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("returns absolutePath that exists on disk", async () => {
|
|
209
|
+
const results = await discoverInstalledFragments(tmpDir);
|
|
210
|
+
for (const r of results) {
|
|
211
|
+
expect(existsSync(r.absolutePath)).toBe(true);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("returns empty array when no package.json exists", async () => {
|
|
216
|
+
const emptyDir = await mkdtemp(resolve(tmpdir(), "fragments-empty-"));
|
|
217
|
+
const results = await discoverInstalledFragments(emptyDir);
|
|
218
|
+
expect(results).toEqual([]);
|
|
219
|
+
await rm(emptyDir, { recursive: true, force: true });
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
144
223
|
describe("no stale @fragments/* package references", () => {
|
|
145
224
|
it("server.ts does not reference old resolveFragmentsPackage for core", async () => {
|
|
146
225
|
const serverPath = resolve(viewerDir, "server.ts");
|
package/src/viewer/server.ts
CHANGED
|
@@ -23,7 +23,7 @@ import autoprefixer from "autoprefixer";
|
|
|
23
23
|
import { resolve, dirname, join } from "node:path";
|
|
24
24
|
import { existsSync, realpathSync } from "node:fs";
|
|
25
25
|
import { fileURLToPath } from "node:url";
|
|
26
|
-
import { loadConfig, discoverSegmentFiles } from "../core/node.js";
|
|
26
|
+
import { loadConfig, discoverSegmentFiles, discoverInstalledFragments } from "../core/node.js";
|
|
27
27
|
import { segmentsPlugin } from "./vite-plugin.js";
|
|
28
28
|
|
|
29
29
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -69,9 +69,11 @@ export async function createDevServer(
|
|
|
69
69
|
// Load segments config
|
|
70
70
|
const { config, configDir } = await loadConfig(configPath);
|
|
71
71
|
|
|
72
|
-
// Discover segment files
|
|
72
|
+
// Discover segment files (local + installed packages)
|
|
73
73
|
const segmentFiles = await discoverSegmentFiles(config, configDir);
|
|
74
|
-
|
|
74
|
+
const installedFiles = await discoverInstalledFragments(projectRoot);
|
|
75
|
+
const allSegmentFiles = [...segmentFiles, ...installedFiles];
|
|
76
|
+
console.log(`📦 Found ${segmentFiles.length} local + ${installedFiles.length} installed fragment file(s)`);
|
|
75
77
|
|
|
76
78
|
// Try to load project's Vite config
|
|
77
79
|
let projectViteConfig: InlineConfig = {};
|
|
@@ -99,6 +101,19 @@ export async function createDevServer(
|
|
|
99
101
|
const nodeModulesPath = findNodeModules(projectRoot);
|
|
100
102
|
console.log(`📁 Using node_modules: ${nodeModulesPath}`);
|
|
101
103
|
|
|
104
|
+
// Collect installed package roots so Vite can serve files from node_modules
|
|
105
|
+
const installedPkgRoots = [...new Set(
|
|
106
|
+
installedFiles.map(f => {
|
|
107
|
+
const idx = f.absolutePath.indexOf('/node_modules/');
|
|
108
|
+
if (idx === -1) return dirname(f.absolutePath);
|
|
109
|
+
const afterNm = f.absolutePath.slice(idx + '/node_modules/'.length);
|
|
110
|
+
const pkgName = afterNm.startsWith('@')
|
|
111
|
+
? afterNm.split('/').slice(0, 2).join('/')
|
|
112
|
+
: afterNm.split('/')[0];
|
|
113
|
+
return resolve(projectRoot, 'node_modules', pkgName);
|
|
114
|
+
})
|
|
115
|
+
)];
|
|
116
|
+
|
|
102
117
|
// Our Segments-specific configuration
|
|
103
118
|
const segmentsConfig: InlineConfig = {
|
|
104
119
|
configFile: false, // Don't load config again
|
|
@@ -110,7 +125,7 @@ export async function createDevServer(
|
|
|
110
125
|
open: open ? "/fragments/" : false,
|
|
111
126
|
fs: {
|
|
112
127
|
// Allow serving files from viewer package, project, and node_modules root
|
|
113
|
-
allow: [viewerRoot, projectRoot, configDir, dirname(nodeModulesPath)],
|
|
128
|
+
allow: [viewerRoot, projectRoot, configDir, dirname(nodeModulesPath), ...installedPkgRoots],
|
|
114
129
|
},
|
|
115
130
|
},
|
|
116
131
|
|
|
@@ -120,7 +135,7 @@ export async function createDevServer(
|
|
|
120
135
|
|
|
121
136
|
// Segments plugins (array including SVGR)
|
|
122
137
|
...segmentsPlugin({
|
|
123
|
-
segmentFiles,
|
|
138
|
+
segmentFiles: allSegmentFiles,
|
|
124
139
|
config,
|
|
125
140
|
projectRoot,
|
|
126
141
|
}),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/validators.ts","../src/build.ts","../src/screenshot.ts","../src/diff.ts","../src/analyze.ts"],"sourcesContent":["import { segmentDefinitionSchema, BRAND, type SegmentsConfig } from './core/index.js';\nimport {\n discoverSegmentFiles,\n discoverComponentFiles,\n extractComponentName,\n loadSegmentFile,\n type DiscoveredFile,\n} from './core/node.js';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[];\n warnings: ValidationWarning[];\n}\n\nexport interface ValidationError {\n file: string;\n message: string;\n details?: string;\n}\n\nexport interface ValidationWarning {\n file: string;\n message: string;\n}\n\n/**\n * Validate segment file schema\n */\nexport async function validateSchema(\n config: SegmentsConfig,\n configDir: string\n): Promise<ValidationResult> {\n const files = await discoverSegmentFiles(config, configDir);\n const errors: ValidationError[] = [];\n const warnings: ValidationWarning[] = [];\n\n for (const file of files) {\n try {\n const segment = await loadSegmentFile(file.absolutePath);\n\n if (!segment) {\n errors.push({\n file: file.relativePath,\n message: 'No default export found',\n details: `Segment files must have a default export from defineSegment()`,\n });\n continue;\n }\n\n const result = segmentDefinitionSchema.safeParse(segment);\n\n if (!result.success) {\n const details = result.error.errors\n .map((e) => `${e.path.join('.')}: ${e.message}`)\n .join('; ');\n\n errors.push({\n file: file.relativePath,\n message: 'Invalid segment schema',\n details,\n });\n }\n } catch (error) {\n errors.push({\n file: file.relativePath,\n message: 'Failed to load segment file',\n details: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n\n/**\n * Validate coverage - ensure all components have segments\n */\nexport async function validateCoverage(\n config: SegmentsConfig,\n configDir: string\n): Promise<ValidationResult> {\n const segmentFiles = await discoverSegmentFiles(config, configDir);\n const componentFiles = await discoverComponentFiles(config, configDir);\n const errors: ValidationError[] = [];\n const warnings: ValidationWarning[] = [];\n\n // Build set of documented component names\n const documentedComponents = new Set<string>();\n\n for (const file of segmentFiles) {\n try {\n const segment = await loadSegmentFile(file.absolutePath);\n\n if (segment?.meta?.name) {\n documentedComponents.add(segment.meta.name);\n }\n } catch {\n // Skip files that fail to load - schema validation will catch these\n }\n }\n\n // Check each component file\n for (const file of componentFiles) {\n const componentName = extractComponentName(file.relativePath);\n\n // Check if there's a corresponding segment file\n const segmentPath = file.relativePath.replace(\n /\\.(tsx?|jsx?)$/,\n BRAND.fileExtension\n );\n const hasSegmentFile = segmentFiles.some(\n (s) => s.relativePath === segmentPath\n );\n\n if (!hasSegmentFile && !documentedComponents.has(componentName)) {\n warnings.push({\n file: file.relativePath,\n message: `Component \"${componentName}\" has no segment documentation`,\n });\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n\n/**\n * Run all validations\n */\nexport async function validateAll(\n config: SegmentsConfig,\n configDir: string\n): Promise<ValidationResult> {\n const [schemaResult, coverageResult] = await Promise.all([\n validateSchema(config, configDir),\n validateCoverage(config, configDir),\n ]);\n\n return {\n valid: schemaResult.valid && coverageResult.valid,\n errors: [...schemaResult.errors, ...coverageResult.errors],\n warnings: [...schemaResult.warnings, ...coverageResult.warnings],\n };\n}\n","import { readFile, writeFile, mkdir } from \"node:fs/promises\";\nimport { resolve, join } from \"node:path\";\nimport type {\n SegmentsConfig,\n CompiledSegmentsFile,\n CompiledSegment,\n CompiledRecipe,\n} from \"./core/index.js\";\nimport { BRAND, compileRecipe } from \"./core/index.js\";\nimport type { RecipeDefinition } from \"./core/index.js\";\nimport {\n discoverSegmentFiles,\n discoverRecipeFiles,\n parseSegmentFile,\n loadSegmentFile,\n generateRegistry,\n generateContextMd,\n} from \"./core/node.js\";\n\nexport interface BuildResult {\n success: boolean;\n outputPath: string;\n segmentCount: number;\n errors: Array<{ file: string; error: string }>;\n warnings: Array<{ file: string; warning: string }>;\n}\n\n/**\n * Build compiled fragments.json file for AI consumption.\n *\n * Uses AST parsing to extract metadata WITHOUT executing fragment files.\n * This means the build works without any project dependencies installed.\n */\nexport async function buildSegments(\n config: SegmentsConfig,\n configDir: string\n): Promise<BuildResult> {\n const files = await discoverSegmentFiles(config, configDir);\n const errors: Array<{ file: string; error: string }> = [];\n const warnings: Array<{ file: string; warning: string }> = [];\n const segments: CompiledSegmentsFile[\"segments\"] = {};\n\n for (const file of files) {\n try {\n // Read file content as text\n const content = await readFile(file.absolutePath, \"utf-8\");\n\n // Parse using AST (no execution)\n const parsed = parseSegmentFile(content, file.relativePath);\n\n // Collect warnings\n for (const warning of parsed.warnings) {\n warnings.push({ file: file.relativePath, warning });\n }\n\n // Check for required fields\n if (!parsed.meta.name) {\n errors.push({\n file: file.relativePath,\n error: \"Missing meta.name in fragment definition\",\n });\n continue;\n }\n\n // Build compiled fragment from parsed metadata\n const compiled: CompiledSegment = {\n filePath: file.relativePath,\n meta: {\n name: parsed.meta.name,\n description: parsed.meta.description ?? \"\",\n category: parsed.meta.category ?? \"Uncategorized\",\n status: parsed.meta.status,\n tags: parsed.meta.tags,\n since: parsed.meta.since,\n figma: parsed.meta.figma,\n },\n usage: {\n when: parsed.usage.when ?? [],\n whenNot: parsed.usage.whenNot ?? [],\n guidelines: parsed.usage.guidelines,\n accessibility: parsed.usage.accessibility,\n },\n props: Object.fromEntries(\n Object.entries(parsed.props).map(([name, prop]) => [\n name,\n {\n type: prop.type ?? \"custom\",\n description: prop.description ?? \"\",\n default: prop.default,\n required: prop.required,\n values: prop.values,\n constraints: prop.constraints,\n },\n ])\n ),\n relations: parsed.relations.map((rel) => ({\n component: rel.component,\n relationship: rel.relationship as\n | \"alternative\"\n | \"sibling\"\n | \"parent\"\n | \"child\"\n | \"composition\",\n note: rel.note,\n })),\n variants: parsed.variants.map((v) => ({\n name: v.name,\n description: v.description,\n ...(v.code && { code: v.code }),\n ...(v.figma && { figma: v.figma }),\n ...(v.args && { args: v.args }),\n })),\n };\n\n segments[parsed.meta.name] = compiled;\n } catch (error) {\n errors.push({\n file: file.relativePath,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n // Discover and compile recipe files\n const recipes: Record<string, CompiledRecipe> = {};\n try {\n const recipeFiles = await discoverRecipeFiles(configDir, config.exclude);\n for (const file of recipeFiles) {\n try {\n // loadSegmentFile uses esbuild to bundle+evaluate, returns default export\n // CJS/ESM interop may double-wrap the default export\n let raw = await loadSegmentFile(file.absolutePath) as unknown as Record<string, unknown> | null;\n // Unwrap double-default from CJS interop\n if (raw && 'default' in raw && typeof raw.default === 'object') {\n raw = raw.default as Record<string, unknown>;\n }\n const def = raw;\n if (def && typeof def === 'object' && 'name' in def && 'code' in def && 'components' in def) {\n const compiled = compileRecipe(def as unknown as RecipeDefinition, file.relativePath);\n recipes[compiled.name] = compiled;\n }\n } catch (error) {\n warnings.push({\n file: file.relativePath,\n warning: `Failed to load recipe: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n } catch {\n // Recipe discovery failure is non-fatal\n }\n\n const output: CompiledSegmentsFile = {\n version: \"1.0.0\",\n generatedAt: new Date().toISOString(),\n segments,\n ...(Object.keys(recipes).length > 0 && { recipes }),\n };\n\n const outputPath = resolve(configDir, config.outFile ?? BRAND.outFile);\n await writeFile(outputPath, JSON.stringify(output));\n\n return {\n success: errors.length === 0,\n outputPath,\n segmentCount: Object.keys(segments).length,\n errors,\n warnings,\n };\n}\n\n/**\n * Result of building the .fragments directory\n */\nexport interface FragmentsBuildResult {\n success: boolean;\n indexPath: string;\n registryPath: string;\n contextPath: string;\n componentCount: number;\n errors: Array<{ file: string; error: string }>;\n warnings: Array<{ file: string; warning: string }>;\n}\n\n/**\n * Build the .fragments/ directory with index.json, registry.json, and context.md\n *\n * This generates:\n * - .fragments/index.json - Minimal name → path mapping (tiny, for quick lookups)\n * - .fragments/registry.json - Component index with paths and enrichment references\n * - .fragments/context.md - AI-ready consolidated context file\n */\nexport async function buildFragmentsDir(\n config: SegmentsConfig,\n configDir: string\n): Promise<FragmentsBuildResult> {\n const fragmentsDir = join(configDir, BRAND.dataDir);\n const componentsDir = join(fragmentsDir, BRAND.componentsDir);\n\n // Create directories\n await mkdir(fragmentsDir, { recursive: true });\n await mkdir(componentsDir, { recursive: true });\n\n // Generate registry with config options\n const registryResult = await generateRegistry({\n projectRoot: configDir,\n componentPatterns: config.components || [\"src/**/*.tsx\", \"src/**/*.ts\"],\n storyPatterns: config.include || [\"src/**/*.stories.tsx\"],\n fragmentsDir,\n registryOptions: config.registry || {},\n });\n\n const errors = [...registryResult.errors];\n const warnings = [...registryResult.warnings];\n\n // Write index.json (minimal name → path)\n const indexPath = join(fragmentsDir, \"index.json\");\n await writeFile(indexPath, JSON.stringify(registryResult.index, null, 2));\n\n // Write registry.json (full metadata)\n const registryPath = join(fragmentsDir, BRAND.registryFile);\n await writeFile(registryPath, JSON.stringify(registryResult.registry, null, 2));\n\n // Generate context.md - focus on semantic knowledge, skip props (AI can read source)\n const contextResult = generateContextMd(registryResult.registry, {\n format: \"markdown\",\n compact: false,\n include: {\n props: false, // AI can read TypeScript directly\n relations: true,\n code: false,\n },\n });\n\n // Write context.md\n const contextPath = join(fragmentsDir, BRAND.contextFile);\n await writeFile(contextPath, contextResult.content);\n\n return {\n success: errors.length === 0,\n indexPath,\n registryPath,\n contextPath,\n componentCount: registryResult.registry.componentCount,\n errors,\n warnings,\n };\n}\n","import pc from 'picocolors';\nimport {\n BRAND,\n DEFAULTS,\n type SegmentsConfig,\n type SegmentDefinition,\n type Theme,\n} from './core/index.js';\nimport { discoverSegmentFiles, loadSegmentFile } from './core/node.js';\nimport {\n BrowserPool,\n CaptureEngine,\n StorageManager,\n formatMs,\n type CaptureOptions,\n} from './service/index.js';\n\n/**\n * Options for the screenshot command\n */\nexport interface ScreenshotCommandOptions {\n /** Specific component to capture */\n component?: string;\n\n /** Specific variant to capture */\n variant?: string;\n\n /** Theme to capture */\n theme?: Theme;\n\n /** Update existing baselines */\n update?: boolean;\n\n /** CI mode - no interactive prompts */\n ci?: boolean;\n\n /** Viewport width */\n width?: number;\n\n /** Viewport height */\n height?: number;\n}\n\n/**\n * Result of the screenshot command\n */\nexport interface ScreenshotResult {\n success: boolean;\n captured: number;\n skipped: number;\n errors: Array<{ component: string; variant: string; error: string }>;\n totalTimeMs: number;\n}\n\n/**\n * Execute the screenshot command\n */\nexport async function runScreenshotCommand(\n config: SegmentsConfig,\n configDir: string,\n options: ScreenshotCommandOptions = {}\n): Promise<ScreenshotResult> {\n const startTime = Date.now();\n const errors: ScreenshotResult['errors'] = [];\n\n // Initialize storage\n const storage = new StorageManager({\n projectRoot: configDir,\n viewport: options.width && options.height\n ? { width: options.width, height: options.height }\n : config.screenshots?.viewport,\n });\n await storage.initialize();\n\n // Discover segments\n const segmentFiles = await discoverSegmentFiles(config, configDir);\n\n if (segmentFiles.length === 0) {\n console.log(pc.yellow('No segment files found.'));\n return {\n success: true,\n captured: 0,\n skipped: 0,\n errors: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Load all segments\n const segments: Array<{ path: string; segment: SegmentDefinition }> = [];\n\n for (const file of segmentFiles) {\n try {\n const segment = await loadSegmentFile(file.absolutePath);\n if (segment) {\n segments.push({ path: file.relativePath, segment });\n }\n } catch (error) {\n errors.push({\n component: file.relativePath,\n variant: '',\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n // Filter by component if specified\n const filteredSegments = options.component\n ? segments.filter((s) => s.segment.meta.name === options.component)\n : segments;\n\n if (options.component && filteredSegments.length === 0) {\n console.log(pc.yellow(`Component \"${options.component}\" not found.`));\n return {\n success: false,\n captured: 0,\n skipped: 0,\n errors: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Build list of variants to capture\n const variantsToCapture: Array<{\n component: string;\n variant: string;\n render: () => unknown;\n }> = [];\n\n for (const { segment } of filteredSegments) {\n const variants = options.variant\n ? segment.variants.filter((v) => v.name === options.variant)\n : segment.variants;\n\n for (const variant of variants) {\n variantsToCapture.push({\n component: segment.meta.name,\n variant: variant.name,\n render: variant.render,\n });\n }\n }\n\n if (variantsToCapture.length === 0) {\n console.log(pc.yellow('No variants to capture.'));\n return {\n success: true,\n captured: 0,\n skipped: 0,\n errors: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Determine theme\n const theme: Theme = options.theme ?? DEFAULTS.theme;\n const viewport = {\n width: options.width ?? config.screenshots?.viewport?.width ?? DEFAULTS.viewport.width,\n height: options.height ?? config.screenshots?.viewport?.height ?? DEFAULTS.viewport.height,\n };\n\n console.log(pc.cyan(`\\n${BRAND.name} Screenshot\\n`));\n console.log(pc.dim(`Capturing variants (theme: ${theme}, viewport: ${viewport.width}x${viewport.height}):\\n`));\n\n // Initialize browser pool\n const pool = new BrowserPool({\n viewport,\n });\n\n // Create capture engine - use the viewer URL\n const viewerPort = DEFAULTS.port;\n const baseUrl = `http://localhost:${viewerPort}`;\n const captureEngine = new CaptureEngine(pool, baseUrl);\n\n let captured = 0;\n let skipped = 0;\n\n const captureOptions: CaptureOptions = {\n theme,\n viewport,\n delay: config.screenshots?.delay ?? DEFAULTS.captureDelayMs,\n };\n\n try {\n // Warm up the pool\n console.log(pc.dim('Starting browser...'));\n await pool.warmup();\n console.log(pc.dim('Browser ready.\\n'));\n\n // Capture each variant\n for (const { component, variant } of variantsToCapture) {\n const hasExisting = storage.hasBaseline(component, variant, theme);\n\n // Skip if exists and not updating\n if (hasExisting && !options.update) {\n console.log(` ${pc.dim('○')} ${component}/${variant} ${pc.dim('(skipped)')}`);\n skipped++;\n continue;\n }\n\n try {\n const screenshot = await captureEngine.captureVariant(\n component,\n variant,\n captureOptions\n );\n\n await storage.saveBaseline(screenshot);\n\n const totalTime = screenshot.metadata.renderTimeMs + screenshot.metadata.captureTimeMs;\n console.log(\n ` ${pc.green('✓')} ${component}/${variant} ${pc.dim(formatMs(totalTime))}`\n );\n captured++;\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n console.log(` ${pc.red('✗')} ${component}/${variant} ${pc.dim(errorMsg)}`);\n errors.push({ component, variant, error: errorMsg });\n }\n }\n } finally {\n // Shutdown browser pool\n await pool.shutdown();\n }\n\n const totalTimeMs = Date.now() - startTime;\n\n // Print summary\n console.log();\n if (errors.length === 0) {\n console.log(pc.green(`✓ Captured ${captured} screenshot(s) in ${formatMs(totalTimeMs)}`));\n } else {\n console.log(pc.yellow(`⚠ Captured ${captured} screenshot(s) with ${errors.length} error(s)`));\n }\n\n if (skipped > 0) {\n console.log(pc.dim(` ${skipped} skipped (use --update to recapture)`));\n }\n\n console.log(pc.dim(` Stored in ${storage.screenshotsDirPath}\\n`));\n\n return {\n success: errors.length === 0,\n captured,\n skipped,\n errors,\n totalTimeMs,\n };\n}\n","import pc from 'picocolors';\nimport {\n BRAND,\n DEFAULTS,\n type SegmentsConfig,\n type SegmentDefinition,\n type Theme,\n} from './core/index.js';\nimport { discoverSegmentFiles, loadSegmentFile } from './core/node.js';\nimport {\n BrowserPool,\n CaptureEngine,\n StorageManager,\n DiffEngine,\n formatMs,\n type CaptureOptions,\n type DiffResult,\n} from './service/index.js';\n\n/**\n * Options for the diff command\n */\nexport interface DiffCommandOptions {\n /** Specific component to diff */\n component?: string;\n\n /** Specific variant to diff */\n variant?: string;\n\n /** Theme to compare */\n theme?: Theme;\n\n /** CI mode - exit 1 on differences */\n ci?: boolean;\n\n /** Diff threshold percentage */\n threshold?: number;\n\n /** Open diff images */\n open?: boolean;\n}\n\n/**\n * Single diff result with metadata\n */\nexport interface VariantDiffResult {\n component: string;\n variant: string;\n theme: Theme;\n result: DiffResult;\n diffImagePath?: string;\n}\n\n/**\n * Result of the diff command\n */\nexport interface DiffCommandResult {\n success: boolean;\n total: number;\n passed: number;\n failed: number;\n missing: number;\n results: VariantDiffResult[];\n totalTimeMs: number;\n}\n\n/**\n * Execute the diff command\n */\nexport async function runDiffCommand(\n config: SegmentsConfig,\n configDir: string,\n options: DiffCommandOptions = {}\n): Promise<DiffCommandResult> {\n const startTime = Date.now();\n const results: VariantDiffResult[] = [];\n\n // Initialize storage\n const storage = new StorageManager({\n projectRoot: configDir,\n viewport: config.screenshots?.viewport,\n });\n await storage.initialize();\n\n // Initialize diff engine\n const threshold = options.threshold ?? config.screenshots?.threshold ?? DEFAULTS.diffThreshold;\n const diffEngine = new DiffEngine(threshold);\n\n // Discover segments\n const segmentFiles = await discoverSegmentFiles(config, configDir);\n\n if (segmentFiles.length === 0) {\n console.log(pc.yellow('No segment files found.'));\n return {\n success: true,\n total: 0,\n passed: 0,\n failed: 0,\n missing: 0,\n results: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Load all segments\n const segments: Array<{ path: string; segment: SegmentDefinition }> = [];\n\n for (const file of segmentFiles) {\n try {\n const segment = await loadSegmentFile(file.absolutePath);\n if (segment) {\n segments.push({ path: file.relativePath, segment });\n }\n } catch {\n // Skip failed loads\n }\n }\n\n // Filter by component if specified\n const filteredSegments = options.component\n ? segments.filter((s) => s.segment.meta.name === options.component)\n : segments;\n\n if (options.component && filteredSegments.length === 0) {\n console.log(pc.yellow(`Component \"${options.component}\" not found.`));\n return {\n success: false,\n total: 0,\n passed: 0,\n failed: 0,\n missing: 0,\n results: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Build list of variants to diff\n const variantsToDiff: Array<{\n component: string;\n variant: string;\n }> = [];\n\n for (const { segment } of filteredSegments) {\n const variants = options.variant\n ? segment.variants.filter((v) => v.name === options.variant)\n : segment.variants;\n\n for (const variant of variants) {\n variantsToDiff.push({\n component: segment.meta.name,\n variant: variant.name,\n });\n }\n }\n\n if (variantsToDiff.length === 0) {\n console.log(pc.yellow('No variants to compare.'));\n return {\n success: true,\n total: 0,\n passed: 0,\n failed: 0,\n missing: 0,\n results: [],\n totalTimeMs: Date.now() - startTime,\n };\n }\n\n // Determine theme\n const theme: Theme = options.theme ?? DEFAULTS.theme;\n const viewport = config.screenshots?.viewport ?? DEFAULTS.viewport;\n\n console.log(pc.cyan(`\\n${BRAND.name} Diff\\n`));\n console.log(pc.dim(`Comparing against baselines (theme: ${theme}, threshold: ${threshold}%):\\n`));\n\n // Initialize browser pool\n const pool = new BrowserPool({\n viewport,\n });\n\n // Create capture engine\n const viewerPort = DEFAULTS.port;\n const baseUrl = `http://localhost:${viewerPort}`;\n const captureEngine = new CaptureEngine(pool, baseUrl);\n\n let passed = 0;\n let failed = 0;\n let missing = 0;\n\n const captureOptions: CaptureOptions = {\n theme,\n viewport,\n delay: config.screenshots?.delay ?? DEFAULTS.captureDelayMs,\n };\n\n try {\n // Warm up the pool\n await pool.warmup();\n\n // Compare each variant\n for (const { component, variant } of variantsToDiff) {\n // Load baseline\n const baseline = await storage.loadBaseline(component, variant, theme);\n\n if (!baseline) {\n console.log(\n ` ${pc.yellow('?')} ${component}/${variant} ${pc.dim('(no baseline)')}`\n );\n missing++;\n continue;\n }\n\n try {\n // Capture current\n const current = await captureEngine.captureVariant(\n component,\n variant,\n captureOptions\n );\n\n // Quick hash check\n if (diffEngine.areIdentical(current, baseline)) {\n console.log(` ${pc.green('✓')} ${component}/${variant} ${pc.dim('0.0%')}`);\n results.push({\n component,\n variant,\n theme,\n result: {\n matches: true,\n diffPercentage: 0,\n diffPixelCount: 0,\n totalPixels: current.viewport.width * current.viewport.height,\n changedRegions: [],\n diffTimeMs: 0,\n },\n });\n passed++;\n continue;\n }\n\n // Full diff\n const diffResult = diffEngine.compare(current, baseline, { threshold });\n\n if (diffResult.matches) {\n console.log(\n ` ${pc.green('✓')} ${component}/${variant} ${pc.dim(`${diffResult.diffPercentage}%`)}`\n );\n passed++;\n } else {\n // Save diff image\n let diffImagePath: string | undefined;\n if (diffResult.diffImage) {\n diffImagePath = await storage.saveDiff(\n component,\n variant,\n theme,\n diffResult.diffImage\n );\n }\n\n console.log(\n ` ${pc.red('✗')} ${component}/${variant} ${pc.yellow(`${diffResult.diffPercentage}%`)}` +\n (diffImagePath ? pc.dim(` → ${diffImagePath}`) : '')\n );\n failed++;\n\n results.push({\n component,\n variant,\n theme,\n result: diffResult,\n diffImagePath,\n });\n continue;\n }\n\n results.push({\n component,\n variant,\n theme,\n result: diffResult,\n });\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n console.log(` ${pc.red('!')} ${component}/${variant} ${pc.dim(errorMsg)}`);\n failed++;\n }\n }\n } finally {\n // Shutdown browser pool\n await pool.shutdown();\n }\n\n const totalTimeMs = Date.now() - startTime;\n const total = passed + failed + missing;\n\n // Print summary\n console.log();\n if (failed === 0 && missing === 0) {\n console.log(pc.green(`✓ All ${passed} variant(s) match baselines`));\n } else if (failed > 0) {\n console.log(pc.red(`✗ ${failed} variant(s) differ from baselines`));\n }\n\n if (missing > 0) {\n console.log(pc.yellow(` ${missing} variant(s) have no baseline (run \\`${BRAND.cliCommand} screenshot\\`)`));\n }\n\n console.log(pc.dim(` Completed in ${formatMs(totalTimeMs)}\\n`));\n\n // In CI mode, exit with error if any failed\n const success = failed === 0;\n\n return {\n success,\n total,\n passed,\n failed,\n missing,\n results,\n totalTimeMs,\n };\n}\n","/**\n * CLI command: segments analyze\n *\n * Analyzes the design system and generates an HTML report with:\n * - Component inventory\n * - Documentation coverage\n * - Quality insights\n * - Actionable recommendations\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile, writeFile, mkdir } from \"node:fs/promises\";\nimport { join, dirname } from \"node:path\";\nimport pc from \"picocolors\";\nimport type { SegmentsConfig, CompiledSegmentsFile } from \"./core/index.js\";\nimport { BRAND, DEFAULTS } from \"./core/index.js\";\nimport {\n analyzeDesignSystem,\n generateHtmlReport,\n getGrade,\n getScoreColor,\n type DesignSystemAnalytics,\n} from \"./service/index.js\";\n\nexport interface AnalyzeOptions {\n /** Output format */\n format?: \"html\" | \"json\" | \"console\";\n /** Output file path (default: segments-report.html) */\n output?: string;\n /** Open report in browser after generation */\n open?: boolean;\n /** CI mode - exit with appropriate code */\n ci?: boolean;\n /** Minimum score to pass in CI mode */\n minScore?: number;\n}\n\nexport interface AnalyzeResult {\n success: boolean;\n analytics: DesignSystemAnalytics;\n outputPath?: string;\n}\n\n/**\n * Run the analyze command\n */\nexport async function runAnalyzeCommand(\n config: SegmentsConfig,\n configDir: string,\n options: AnalyzeOptions = {}\n): Promise<AnalyzeResult> {\n const format = options.format ?? \"html\";\n const minScore = options.minScore ?? 0;\n\n console.log(pc.cyan(`\\n${BRAND.name} Analyzer\\n`));\n\n // Load compiled segments\n const segmentsPath = join(configDir, config.outFile ?? \"segments.json\");\n\n if (!existsSync(segmentsPath)) {\n console.log(pc.red(`✗ No segments.json found. Run \\`${BRAND.cliCommand} build\\` first.\\n`));\n return {\n success: false,\n analytics: createEmptyAnalytics(),\n };\n }\n\n console.log(pc.dim(\"Analyzing design system...\\n\"));\n\n const content = await readFile(segmentsPath, \"utf-8\");\n const data: CompiledSegmentsFile = JSON.parse(content);\n\n // Run analysis\n const analytics = analyzeDesignSystem(data);\n\n // Print summary to console\n printConsoleSummary(analytics);\n\n // Generate output based on format\n let outputPath: string | undefined;\n\n if (format === \"html\" || format === \"json\") {\n outputPath = options.output ?? getDefaultOutputPath(format, configDir);\n\n // Ensure output directory exists\n await mkdir(dirname(outputPath), { recursive: true });\n\n if (format === \"html\") {\n const html = generateHtmlReport(analytics);\n await writeFile(outputPath, html);\n console.log(pc.green(`✓ Report generated: ${outputPath}\\n`));\n } else {\n await writeFile(outputPath, JSON.stringify(analytics, null, 2));\n console.log(pc.green(`✓ JSON report generated: ${outputPath}\\n`));\n }\n\n // Open in browser if requested\n if (options.open && format === \"html\") {\n await openInBrowser(outputPath);\n }\n }\n\n // CI mode - check score\n const passedCi = analytics.summary.overallScore >= minScore;\n\n if (options.ci) {\n if (passedCi) {\n console.log(\n pc.green(`✓ Score ${analytics.summary.overallScore} meets minimum threshold ${minScore}\\n`)\n );\n } else {\n console.log(\n pc.red(\n `✗ Score ${analytics.summary.overallScore} below minimum threshold ${minScore}\\n`\n )\n );\n }\n }\n\n return {\n success: !options.ci || passedCi,\n analytics,\n outputPath,\n };\n}\n\n/**\n * Print a summary to the console\n */\nfunction printConsoleSummary(analytics: DesignSystemAnalytics): void {\n const { summary, coverage, recommendations } = analytics;\n const grade = getGrade(summary.overallScore);\n\n // Score header\n console.log(\n pc.bold(\n `Overall Score: ${colorizeScore(summary.overallScore)} (${grade})\\n`\n )\n );\n\n // Summary stats\n console.log(pc.dim(\"Summary\"));\n console.log(` Components: ${pc.white(summary.totalComponents.toString())}`);\n console.log(` Variants: ${pc.white(summary.totalVariants.toString())}`);\n console.log(` Props: ${pc.white(summary.totalProps.toString())}`);\n console.log(` Categories: ${pc.white(summary.categories.join(\", \"))}`);\n console.log();\n\n // Coverage\n console.log(pc.dim(\"Coverage\"));\n console.log(` Description: ${formatCoverage(coverage.fields.description)}`);\n console.log(` Usage when: ${formatCoverage(coverage.fields.usageWhen)}`);\n console.log(` Usage whenNot:${formatCoverage(coverage.fields.usageWhenNot)}`);\n console.log(` Guidelines: ${formatCoverage(coverage.fields.guidelines)}`);\n console.log(` Relations: ${formatCoverage(coverage.fields.relations)}`);\n console.log();\n\n // Top recommendations\n if (recommendations.length > 0) {\n console.log(pc.dim(\"Top Recommendations\"));\n for (const rec of recommendations.slice(0, 3)) {\n const priority = rec.priority === \"high\"\n ? pc.red(`[${rec.priority}]`)\n : rec.priority === \"medium\"\n ? pc.yellow(`[${rec.priority}]`)\n : pc.dim(`[${rec.priority}]`);\n console.log(` ${priority} ${rec.title}`);\n }\n console.log();\n }\n}\n\n/**\n * Format coverage percentage with color\n */\nfunction formatCoverage(field: { percentage: number; covered: number; total: number }): string {\n const pct = colorizeScore(field.percentage);\n return `${pct} (${field.covered}/${field.total})`;\n}\n\n/**\n * Colorize a score\n */\nfunction colorizeScore(score: number): string {\n if (score >= 80) return pc.green(`${score}%`);\n if (score >= 60) return pc.yellow(`${score}%`);\n return pc.red(`${score}%`);\n}\n\n/**\n * Get default output path\n */\nfunction getDefaultOutputPath(format: \"html\" | \"json\", configDir: string): string {\n const filename = format === \"html\" ? \"segments-report.html\" : \"segments-report.json\";\n return join(configDir, filename);\n}\n\n/**\n * Open file in default browser\n */\nasync function openInBrowser(path: string): Promise<void> {\n const { platform } = await import(\"node:os\");\n const { exec } = await import(\"node:child_process\");\n\n const os = platform();\n const cmd = os === \"darwin\"\n ? `open \"${path}\"`\n : os === \"win32\"\n ? `start \"\" \"${path}\"`\n : `xdg-open \"${path}\"`;\n\n exec(cmd);\n}\n\n/**\n * Create empty analytics for error cases\n */\nfunction createEmptyAnalytics(): DesignSystemAnalytics {\n return {\n analyzedAt: new Date(),\n summary: {\n totalComponents: 0,\n totalVariants: 0,\n totalProps: 0,\n categories: [],\n overallScore: 0,\n },\n inventory: {\n byCategory: {},\n byStatus: {},\n byVariantCount: [],\n byPropCount: [],\n },\n coverage: {\n overall: 0,\n fields: {\n description: { covered: 0, total: 0, percentage: 0 },\n usageWhen: { covered: 0, total: 0, percentage: 0 },\n usageWhenNot: { covered: 0, total: 0, percentage: 0 },\n guidelines: { covered: 0, total: 0, percentage: 0 },\n accessibility: { covered: 0, total: 0, percentage: 0 },\n relations: { covered: 0, total: 0, percentage: 0 },\n propDescriptions: { covered: 0, total: 0, percentage: 0 },\n propConstraints: { covered: 0, total: 0, percentage: 0 },\n },\n incomplete: [],\n },\n quality: {\n missingWhenNot: [],\n isolated: [],\n deprecated: [],\n fewVariants: [],\n undocumentedProps: [],\n unconstrainedProps: [],\n },\n distribution: {\n variantsPerComponent: [],\n propsPerComponent: [],\n componentsPerCategory: [],\n statusDistribution: [],\n tagFrequency: [],\n },\n recommendations: [],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,eACpB,QACA,WAC2B;AAC3B,QAAM,QAAQ,MAAM,qBAAqB,QAAQ,SAAS;AAC1D,QAAM,SAA4B,CAAC;AACnC,QAAM,WAAgC,CAAC;AAEvC,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,YAAM,UAAU,MAAM,gBAAgB,KAAK,YAAY;AAEvD,UAAI,CAAC,SAAS;AACZ,eAAO,KAAK;AAAA,UACV,MAAM,KAAK;AAAA,UACX,SAAS;AAAA,UACT,SAAS;AAAA,QACX,CAAC;AACD;AAAA,MACF;AAEA,YAAM,SAAS,wBAAwB,UAAU,OAAO;AAExD,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,UAAU,OAAO,MAAM,OAC1B,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,KAAK,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAC9C,KAAK,IAAI;AAEZ,eAAO,KAAK;AAAA,UACV,MAAM,KAAK;AAAA,UACX,SAAS;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,SAAS,OAAO;AACd,aAAO,KAAK;AAAA,QACV,MAAM,KAAK;AAAA,QACX,SAAS;AAAA,QACT,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,OAAO,WAAW;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;AAKA,eAAsB,iBACpB,QACA,WAC2B;AAC3B,QAAM,eAAe,MAAM,qBAAqB,QAAQ,SAAS;AACjE,QAAM,i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