@fragments-sdk/context 0.6.0 → 0.7.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/{chunk-62K7BSAT.js → chunk-PIWQB6CK.js} +77 -25
- package/dist/{chunk-XVZH4IVV.js → chunk-RQ46R2HQ.js} +2 -0
- package/dist/cli-commands/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/mcp-tools/index.d.ts +6 -5
- package/dist/mcp-tools/index.js +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -50,6 +50,11 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
50
50
|
type: "string",
|
|
51
51
|
enum: ["compact", "standard", "full"],
|
|
52
52
|
description: 'Response detail level: "compact" (names only), "standard" (default), "full" (everything including code)'
|
|
53
|
+
},
|
|
54
|
+
depth: {
|
|
55
|
+
type: "string",
|
|
56
|
+
enum: ["quick", "full"],
|
|
57
|
+
description: 'Search depth for useCase mode. "quick" (default): component suggestions only. "full": also returns matching blocks with code, relevant CSS tokens, and import statements \u2014 everything needed to implement in one call.'
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
},
|
|
@@ -135,26 +140,6 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
},
|
|
138
|
-
{
|
|
139
|
-
key: "implement",
|
|
140
|
-
description: "One-shot implementation helper. Describe what you want to build and get everything needed in a single call: best-matching component(s) with full props and code examples, relevant composition blocks, and applicable CSS tokens. Saves multiple round-trips.",
|
|
141
|
-
params: {
|
|
142
|
-
useCase: {
|
|
143
|
-
type: "string",
|
|
144
|
-
description: 'What you want to implement (e.g., "login form", "data table with sorting", "streaming chat messages")'
|
|
145
|
-
},
|
|
146
|
-
limit: {
|
|
147
|
-
type: "number",
|
|
148
|
-
description: "Maximum number of components to return (default: 5)"
|
|
149
|
-
},
|
|
150
|
-
verbosity: {
|
|
151
|
-
type: "string",
|
|
152
|
-
enum: ["compact", "standard", "full"],
|
|
153
|
-
description: 'Response detail level: "compact" (names only), "standard" (default), "full" (all props + examples + full block code)'
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
required: ["useCase"]
|
|
157
|
-
},
|
|
158
143
|
{
|
|
159
144
|
key: "render",
|
|
160
145
|
description: "Render a component and return a screenshot. Optionally compare against a Figma design ('figmaUrl'). Requires a running Fragments dev server (viewer URL). Use this to verify your implementation looks correct.",
|
|
@@ -243,11 +228,11 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
243
228
|
description: "Max traversal depth for impact mode (default: 3)"
|
|
244
229
|
}
|
|
245
230
|
},
|
|
246
|
-
required: [
|
|
231
|
+
required: []
|
|
247
232
|
},
|
|
248
233
|
{
|
|
249
234
|
key: "perf",
|
|
250
|
-
description: "Query component performance data (bundle sizes, complexity tiers, budget status). Returns measured bundle sizes
|
|
235
|
+
description: "Query component performance data (bundle sizes, complexity tiers, budget status). Returns measured bundle sizes when the active source provides performance data. Run `fragments perf` first to generate measurements for local fragments.json sources.",
|
|
251
236
|
params: {
|
|
252
237
|
component: {
|
|
253
238
|
type: "string",
|
|
@@ -323,6 +308,73 @@ var MCP_TOOL_DEFINITIONS = [
|
|
|
323
308
|
}
|
|
324
309
|
},
|
|
325
310
|
required: ["spec"]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: "validate_and_fix",
|
|
314
|
+
description: "Validate a UI spec against governance policies and deterministically repair deprecated component usage when a safe canonical replacement exists. Returns the verdict, any applied replacements, and the fixed spec when successful.",
|
|
315
|
+
params: {
|
|
316
|
+
spec: {
|
|
317
|
+
type: "object",
|
|
318
|
+
description: "The UI spec to validate and repair. Format: { nodes: [{ id, type, props, children }], root?, metadata? }"
|
|
319
|
+
},
|
|
320
|
+
policy: {
|
|
321
|
+
type: "object",
|
|
322
|
+
description: "Optional policy overrides to merge with the base policy. Same shape as govern.config.ts rules."
|
|
323
|
+
},
|
|
324
|
+
applyFixes: {
|
|
325
|
+
type: "boolean",
|
|
326
|
+
description: "If true (default), applies deterministic repairs before re-validating the spec."
|
|
327
|
+
},
|
|
328
|
+
format: {
|
|
329
|
+
type: "string",
|
|
330
|
+
description: 'Output format: "json" (default) or "summary" (compact text)',
|
|
331
|
+
enum: ["json", "summary"]
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
required: ["spec"]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: "findings_list",
|
|
338
|
+
description: "List governance findings for a project from Fragments Cloud. Returns violations detected by CI checks or repo scans. Requires a Cloud API key (FRAGMENTS_API_KEY). Filter by status, severity, category, ruleId, or file path.",
|
|
339
|
+
params: {
|
|
340
|
+
status: {
|
|
341
|
+
type: "string",
|
|
342
|
+
enum: ["open", "resolved", "ignored"],
|
|
343
|
+
description: 'Filter by finding status (default: "open")'
|
|
344
|
+
},
|
|
345
|
+
severity: {
|
|
346
|
+
type: "string",
|
|
347
|
+
enum: ["error", "warning", "info"],
|
|
348
|
+
description: "Filter by severity level"
|
|
349
|
+
},
|
|
350
|
+
category: {
|
|
351
|
+
type: "string",
|
|
352
|
+
description: 'Filter by violation category (e.g., "tokens/hardcoded-color")'
|
|
353
|
+
},
|
|
354
|
+
ruleId: {
|
|
355
|
+
type: "string",
|
|
356
|
+
description: "Filter by governance rule ID"
|
|
357
|
+
},
|
|
358
|
+
filePath: {
|
|
359
|
+
type: "string",
|
|
360
|
+
description: "Filter findings whose file path starts with this prefix"
|
|
361
|
+
},
|
|
362
|
+
limit: {
|
|
363
|
+
type: "number",
|
|
364
|
+
description: "Maximum number of findings to return (default: 50, max: 200)"
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
key: "findings_for_file",
|
|
370
|
+
description: "Get all open governance findings for a specific file from Fragments Cloud. Returns findings sorted by line number. Requires a Cloud API key (FRAGMENTS_API_KEY).",
|
|
371
|
+
params: {
|
|
372
|
+
filePath: {
|
|
373
|
+
type: "string",
|
|
374
|
+
description: "Exact file path to retrieve findings for"
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
required: ["filePath"]
|
|
326
378
|
}
|
|
327
379
|
];
|
|
328
380
|
var CLI_TOOL_EXTENSIONS = [
|
|
@@ -343,14 +395,14 @@ var CLI_TOOL_EXTENSIONS = [
|
|
|
343
395
|
},
|
|
344
396
|
{
|
|
345
397
|
key: "fix",
|
|
346
|
-
description: "Generate patches to fix token compliance issues in a component. Returns unified diff patches that replace hardcoded CSS values with design token references. Use this after
|
|
398
|
+
description: "Generate patches to fix token compliance issues in a component. Returns unified diff patches that replace hardcoded CSS values with design token references. Use this after the render tool identifies issues to automatically fix them.",
|
|
347
399
|
params: {}
|
|
348
400
|
}
|
|
349
401
|
];
|
|
350
402
|
function buildToolNames(prefix) {
|
|
351
403
|
const map = {};
|
|
352
404
|
for (const def of MCP_TOOL_DEFINITIONS) {
|
|
353
|
-
map[def.key] = `${prefix}_${def.key}
|
|
405
|
+
map[def.key] = prefix ? `${prefix}_${def.key}` : def.key;
|
|
354
406
|
}
|
|
355
407
|
return map;
|
|
356
408
|
}
|
|
@@ -382,7 +434,7 @@ function buildMcpTools(prefix, extensions) {
|
|
|
382
434
|
properties[name] = prop;
|
|
383
435
|
}
|
|
384
436
|
return {
|
|
385
|
-
name: `${prefix}_${def.key}
|
|
437
|
+
name: prefix ? `${prefix}_${def.key}` : def.key,
|
|
386
438
|
description: ext?.description ?? def.description,
|
|
387
439
|
inputSchema: {
|
|
388
440
|
type: "object",
|
|
@@ -84,6 +84,8 @@ var CLI_COMMANDS = [
|
|
|
84
84
|
{ flags: "--registry", description: "Also generate .fragments/registry.json and context.md" },
|
|
85
85
|
{ flags: "--registry-only", description: "Only generate .fragments/ directory (skip fragments.json)" },
|
|
86
86
|
{ flags: "--from-source", description: "Build from source code (zero-config, no fragment files needed)" },
|
|
87
|
+
{ flags: "--if-needed", description: "Skip rebuilding when fragments.json is already fresh" },
|
|
88
|
+
{ flags: "--check", description: "Check whether fragments.json is fresh and exit non-zero if it is stale" },
|
|
87
89
|
{ flags: "--skip-usage", description: "Skip usage analysis when building from source" },
|
|
88
90
|
{ flags: "--skip-storybook", description: "Skip Storybook parsing when building from source" },
|
|
89
91
|
{ flags: "-v, --verbose", description: "Verbose output" }
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
MCP_TOOL_DEFINITIONS,
|
|
4
4
|
buildMcpTools,
|
|
5
5
|
buildToolNames
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PIWQB6CK.js";
|
|
7
7
|
import {
|
|
8
8
|
CLI_COMMANDS,
|
|
9
9
|
CLI_COMMAND_CATEGORIES
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RQ46R2HQ.js";
|
|
11
11
|
import {
|
|
12
12
|
chunkByAST,
|
|
13
13
|
chunkByLines,
|
|
@@ -15,7 +15,7 @@ interface McpToolParam {
|
|
|
15
15
|
properties?: Record<string, McpToolParam>;
|
|
16
16
|
}
|
|
17
17
|
interface McpToolDefinition {
|
|
18
|
-
/** Short key used
|
|
18
|
+
/** Short key used as the canonical tool name, e.g. "discover" */
|
|
19
19
|
key: string;
|
|
20
20
|
description: string;
|
|
21
21
|
params: Record<string, McpToolParam>;
|
|
@@ -41,13 +41,14 @@ interface McpSdkTool {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Build a TOOL_NAMES map: `{ discover: "
|
|
44
|
+
* Build a TOOL_NAMES map: `{ discover: "discover", ... }` by default.
|
|
45
|
+
* Pass a prefix only for embedding scenarios that intentionally namespace tools.
|
|
45
46
|
*/
|
|
46
|
-
declare function buildToolNames(prefix
|
|
47
|
+
declare function buildToolNames(prefix?: string): Record<string, string>;
|
|
47
48
|
/**
|
|
48
49
|
* Build MCP SDK `Tool[]` from shared definitions, optionally merging CLI
|
|
49
|
-
* extensions.
|
|
50
|
+
* extensions. Tool names are bare by default.
|
|
50
51
|
*/
|
|
51
|
-
declare function buildMcpTools(prefix
|
|
52
|
+
declare function buildMcpTools(prefix?: string, extensions?: CliToolExtension[]): McpSdkTool[];
|
|
52
53
|
|
|
53
54
|
export { CLI_TOOL_EXTENSIONS, type CliToolExtension, MCP_TOOL_DEFINITIONS, type McpToolDefinition, type McpToolParam, buildMcpTools, buildToolNames };
|
package/dist/mcp-tools/index.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -219,6 +219,10 @@ interface PerformanceSummary {
|
|
|
219
219
|
interface CompiledFragmentsFile {
|
|
220
220
|
version: string;
|
|
221
221
|
generatedAt: string;
|
|
222
|
+
/** CLI version that produced this file, used for freshness checks */
|
|
223
|
+
generatorVersion?: string;
|
|
224
|
+
/** Relative source/config inputs used to build this file, used for freshness checks */
|
|
225
|
+
buildInputs?: string[];
|
|
222
226
|
packageName?: string;
|
|
223
227
|
fragments: Record<string, CompiledFragment>;
|
|
224
228
|
blocks?: Record<string, CompiledBlock>;
|