@fragments-sdk/cli 0.11.1 → 0.13.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/dist/ai-client-I6MDWNYA.js +21 -0
- package/dist/bin.js +419 -410
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-HRFUSSZI.js → chunk-3SOAPJDX.js} +2 -2
- package/dist/{chunk-D5PYOXEI.js → chunk-4K7EAQ5L.js} +148 -13
- package/dist/{chunk-D5PYOXEI.js.map → chunk-4K7EAQ5L.js.map} +1 -1
- package/dist/chunk-DXX6HADE.js +443 -0
- package/dist/chunk-DXX6HADE.js.map +1 -0
- package/dist/chunk-EYXVAMEX.js +626 -0
- package/dist/chunk-EYXVAMEX.js.map +1 -0
- package/dist/{chunk-ZM4ZQZWZ.js → chunk-FO6EBJWP.js} +39 -37
- package/dist/chunk-FO6EBJWP.js.map +1 -0
- package/dist/{chunk-OQO55NKV.js → chunk-QM7SVOGF.js} +120 -12
- package/dist/chunk-QM7SVOGF.js.map +1 -0
- package/dist/{chunk-5G3VZH43.js → chunk-RF3C6LGA.js} +281 -351
- package/dist/chunk-RF3C6LGA.js.map +1 -0
- package/dist/{chunk-WXSR2II7.js → chunk-SM674YAS.js} +58 -6
- package/dist/chunk-SM674YAS.js.map +1 -0
- package/dist/chunk-SXTKFDCR.js +104 -0
- package/dist/chunk-SXTKFDCR.js.map +1 -0
- package/dist/{chunk-PW7QTQA6.js → chunk-UV5JQV3R.js} +2 -2
- package/dist/core/index.js +13 -1
- package/dist/{discovery-NEOY4MPN.js → discovery-VSGC76JN.js} +3 -3
- package/dist/{generate-FBHSXR3D.js → generate-QZXOXYFW.js} +4 -4
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/init-XK6PRUE5.js +636 -0
- package/dist/init-XK6PRUE5.js.map +1 -0
- package/dist/mcp-bin.js +2 -2
- package/dist/{scan-CJF2DOQW.js → scan-CHQHXWVD.js} +6 -6
- package/dist/scan-generate-U3RFVDTX.js +1115 -0
- package/dist/scan-generate-U3RFVDTX.js.map +1 -0
- package/dist/{service-TQYWY65E.js → service-MMEKG4MZ.js} +3 -3
- package/dist/{snapshot-SV2JOFZH.js → snapshot-53TUR3HW.js} +2 -2
- package/dist/{static-viewer-NUBFPKWH.js → static-viewer-KKCR4KXR.js} +3 -3
- package/dist/static-viewer-KKCR4KXR.js.map +1 -0
- package/dist/{test-Z5LVO724.js → test-5UCKXYSC.js} +4 -4
- package/dist/{tokens-CE46OTMD.js → tokens-L46MK5AW.js} +5 -5
- package/dist/{viewer-DLLJIMCK.js → viewer-M2EQQSGE.js} +14 -14
- package/dist/viewer-M2EQQSGE.js.map +1 -0
- package/package.json +11 -9
- package/src/ai-client.ts +156 -0
- package/src/bin.ts +99 -2
- package/src/build.ts +95 -33
- package/src/commands/__tests__/drift-sync.test.ts +252 -0
- package/src/commands/__tests__/scan-generate.test.ts +497 -45
- package/src/commands/enhance.ts +11 -35
- package/src/commands/govern.ts +122 -0
- package/src/commands/init.ts +288 -260
- package/src/commands/scan-generate.ts +740 -139
- package/src/commands/scan.ts +37 -32
- package/src/commands/setup.ts +143 -52
- package/src/commands/sync.ts +357 -0
- package/src/commands/validate.ts +43 -1
- package/src/core/component-extractor.test.ts +282 -0
- package/src/core/component-extractor.ts +1030 -0
- package/src/core/discovery.ts +93 -7
- package/src/service/enhance/props-extractor.ts +235 -13
- package/src/validators.ts +236 -0
- package/src/viewer/vite-plugin.ts +1 -1
- package/dist/chunk-5G3VZH43.js.map +0 -1
- package/dist/chunk-OQO55NKV.js.map +0 -1
- package/dist/chunk-WXSR2II7.js.map +0 -1
- package/dist/chunk-ZM4ZQZWZ.js.map +0 -1
- package/dist/init-UFGK5TCN.js +0 -867
- package/dist/init-UFGK5TCN.js.map +0 -1
- package/dist/scan-generate-SJAN5MVI.js +0 -691
- package/dist/scan-generate-SJAN5MVI.js.map +0 -1
- package/dist/viewer-DLLJIMCK.js.map +0 -1
- package/src/ai.ts +0 -266
- package/src/commands/init-framework.ts +0 -414
- package/src/mcp/bin.ts +0 -36
- package/src/migrate/bin.ts +0 -114
- package/src/theme/index.ts +0 -77
- package/src/viewer/bin.ts +0 -86
- package/src/viewer/cli/health.ts +0 -256
- package/src/viewer/cli/index.ts +0 -33
- package/src/viewer/cli/scan.ts +0 -124
- package/src/viewer/cli/utils.ts +0 -174
- /package/dist/{discovery-NEOY4MPN.js.map → ai-client-I6MDWNYA.js.map} +0 -0
- /package/dist/{chunk-HRFUSSZI.js.map → chunk-3SOAPJDX.js.map} +0 -0
- /package/dist/{chunk-PW7QTQA6.js.map → chunk-UV5JQV3R.js.map} +0 -0
- /package/dist/{scan-CJF2DOQW.js.map → discovery-VSGC76JN.js.map} +0 -0
- /package/dist/{generate-FBHSXR3D.js.map → generate-QZXOXYFW.js.map} +0 -0
- /package/dist/{service-TQYWY65E.js.map → scan-CHQHXWVD.js.map} +0 -0
- /package/dist/{static-viewer-NUBFPKWH.js.map → service-MMEKG4MZ.js.map} +0 -0
- /package/dist/{snapshot-SV2JOFZH.js.map → snapshot-53TUR3HW.js.map} +0 -0
- /package/dist/{test-Z5LVO724.js.map → test-5UCKXYSC.js.map} +0 -0
- /package/dist/{tokens-CE46OTMD.js.map → tokens-L46MK5AW.js.map} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fragments govern — AI UI governance checks
|
|
3
|
+
*
|
|
4
|
+
* Subcommands:
|
|
5
|
+
* check — Validate a UISpec against governance policies
|
|
6
|
+
* init — Generate a govern.config.ts template
|
|
7
|
+
* report — Summarize audit log
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import pc from 'picocolors';
|
|
11
|
+
import { BRAND } from '../core/index.js';
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Options
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
export interface GovernCheckOptions {
|
|
18
|
+
/** Path to UISpec JSON file, or '-' for stdin */
|
|
19
|
+
input?: string;
|
|
20
|
+
/** Path to govern.config.ts */
|
|
21
|
+
config?: string;
|
|
22
|
+
/** Output format */
|
|
23
|
+
format?: 'json' | 'summary' | 'sarif';
|
|
24
|
+
/** Suppress non-error output */
|
|
25
|
+
quiet?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface GovernInitOptions {
|
|
29
|
+
/** Output path (defaults to ./govern.config.ts) */
|
|
30
|
+
output?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// check
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
export async function governCheck(options: GovernCheckOptions = {}): Promise<{ exitCode: number }> {
|
|
38
|
+
console.log(pc.cyan(`\n${BRAND.name} Governance Check\n`));
|
|
39
|
+
|
|
40
|
+
const { cliCheck, formatVerdict } = await import('@fragments-sdk/govern');
|
|
41
|
+
|
|
42
|
+
const result = await cliCheck(options);
|
|
43
|
+
const output = formatVerdict(result.verdict, options.format ?? 'summary');
|
|
44
|
+
|
|
45
|
+
if (!options.quiet) {
|
|
46
|
+
console.log(output);
|
|
47
|
+
console.log();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (result.verdict.passed) {
|
|
51
|
+
console.log(pc.green(`✓ Governance check passed (score: ${result.verdict.score}/100)\n`));
|
|
52
|
+
} else {
|
|
53
|
+
console.log(pc.red(`✗ Governance check failed (score: ${result.verdict.score}/100)\n`));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { exitCode: result.exitCode };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// init
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
export async function governInit(options: GovernInitOptions = {}): Promise<void> {
|
|
64
|
+
const { writeFile } = await import('node:fs/promises');
|
|
65
|
+
const { resolve } = await import('node:path');
|
|
66
|
+
const { generateConfigTemplate } = await import('@fragments-sdk/govern');
|
|
67
|
+
|
|
68
|
+
const outputPath = resolve(options.output ?? 'govern.config.ts');
|
|
69
|
+
const template = generateConfigTemplate();
|
|
70
|
+
|
|
71
|
+
await writeFile(outputPath, template, 'utf-8');
|
|
72
|
+
console.log(pc.green(`✓ Created ${outputPath}\n`));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// report
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
export async function governReport(): Promise<void> {
|
|
80
|
+
const { readFile } = await import('node:fs/promises');
|
|
81
|
+
|
|
82
|
+
console.log(pc.cyan(`\n${BRAND.name} Governance Report\n`));
|
|
83
|
+
|
|
84
|
+
let raw: string;
|
|
85
|
+
try {
|
|
86
|
+
raw = await readFile('.govern-audit.jsonl', 'utf-8');
|
|
87
|
+
} catch {
|
|
88
|
+
console.log(pc.yellow('No audit log found (.govern-audit.jsonl)\n'));
|
|
89
|
+
console.log(pc.dim('Run `fragments govern check` to generate audit data.\n'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const lines = raw.trim().split('\n').filter(Boolean);
|
|
94
|
+
if (lines.length === 0) {
|
|
95
|
+
console.log(pc.yellow('Audit log is empty.\n'));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let totalScore = 0;
|
|
100
|
+
let passCount = 0;
|
|
101
|
+
let totalViolations = 0;
|
|
102
|
+
|
|
103
|
+
for (const line of lines) {
|
|
104
|
+
try {
|
|
105
|
+
const entry = JSON.parse(line);
|
|
106
|
+
totalScore += entry.score ?? 0;
|
|
107
|
+
if (entry.passed) passCount++;
|
|
108
|
+
totalViolations += entry.violationCount ?? 0;
|
|
109
|
+
} catch {
|
|
110
|
+
// Skip malformed lines
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const avgScore = Math.round(totalScore / lines.length);
|
|
115
|
+
const passRate = Math.round((passCount / lines.length) * 100);
|
|
116
|
+
|
|
117
|
+
console.log(` Checks: ${lines.length}`);
|
|
118
|
+
console.log(` Pass rate: ${passRate}%`);
|
|
119
|
+
console.log(` Avg score: ${avgScore}/100`);
|
|
120
|
+
console.log(` Violations: ${totalViolations} total`);
|
|
121
|
+
console.log();
|
|
122
|
+
}
|