@fragments-sdk/context 0.3.5 → 0.4.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.
@@ -193,6 +193,19 @@ var CLI_COMMANDS = [
193
193
  { flags: "-p, --port <port>", description: "Dev server port", default: "6006" }
194
194
  ]
195
195
  },
196
+ {
197
+ name: "perf",
198
+ description: "Profile component bundle sizes and performance budgets",
199
+ category: "quality",
200
+ usage: "fragments perf [options]",
201
+ options: [
202
+ { flags: "-c, --config <path>", description: "Path to config file" },
203
+ { flags: "--json", description: "Output results as JSON" },
204
+ { flags: "--component <name>", description: "Measure specific component only" },
205
+ { flags: "--no-write", description: "Do not write results to fragments.json" },
206
+ { flags: "--concurrency <n>", description: "Max concurrent measurements", default: "4" }
207
+ ]
208
+ },
196
209
  {
197
210
  name: "test",
198
211
  description: "Run interaction tests for fragments with play functions",
@@ -245,6 +245,26 @@ var MCP_TOOL_DEFINITIONS = [
245
245
  },
246
246
  required: ["mode"]
247
247
  },
248
+ {
249
+ key: "perf",
250
+ description: "Query component performance data (bundle sizes, complexity tiers, budget status). Returns measured bundle sizes from fragments.json. Run `fragments perf` first to generate measurements.",
251
+ params: {
252
+ component: {
253
+ type: "string",
254
+ description: "Component name to query (optional, returns all if omitted)"
255
+ },
256
+ sort: {
257
+ type: "string",
258
+ enum: ["size", "name", "budget"],
259
+ description: "Sort order: size (largest first), name (alphabetical), budget (most over-budget first). Default: size"
260
+ },
261
+ filter: {
262
+ type: "string",
263
+ enum: ["lightweight", "moderate", "heavy", "over-budget"],
264
+ description: "Filter by complexity tier or over-budget status"
265
+ }
266
+ }
267
+ },
248
268
  {
249
269
  key: "a11y",
250
270
  description: "Run an accessibility audit on a component. Returns axe-core violations, a WCAG compliance score, and optional fix suggestions. Requires a running Fragments dev server.",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CLI_COMMANDS,
3
3
  CLI_COMMAND_CATEGORIES
4
- } from "../chunk-IQMVRBVF.js";
4
+ } from "../chunk-5CV3LGEU.js";
5
5
  export {
6
6
  CLI_COMMANDS,
7
7
  CLI_COMMAND_CATEGORIES
package/dist/index.js CHANGED
@@ -3,11 +3,11 @@ import {
3
3
  MCP_TOOL_DEFINITIONS,
4
4
  buildMcpTools,
5
5
  buildToolNames
6
- } from "./chunk-NECSN43I.js";
6
+ } from "./chunk-FGBRIJOT.js";
7
7
  import {
8
8
  CLI_COMMANDS,
9
9
  CLI_COMMAND_CATEGORIES
10
- } from "./chunk-IQMVRBVF.js";
10
+ } from "./chunk-5CV3LGEU.js";
11
11
  import {
12
12
  chunkByAST,
13
13
  chunkByLines,
@@ -3,7 +3,7 @@ import {
3
3
  MCP_TOOL_DEFINITIONS,
4
4
  buildMcpTools,
5
5
  buildToolNames
6
- } from "../chunk-NECSN43I.js";
6
+ } from "../chunk-FGBRIJOT.js";
7
7
  export {
8
8
  CLI_TOOL_EXTENSIONS,
9
9
  MCP_TOOL_DEFINITIONS,
@@ -71,6 +71,8 @@ interface FragmentContract {
71
71
  message: string;
72
72
  }>;
73
73
  scenarioTags?: string[];
74
+ /** Per-component performance budget override in bytes (gzipped) */
75
+ performanceBudget?: number;
74
76
  }
75
77
  /**
76
78
  * Provenance tracking for generated fragments
@@ -90,6 +92,36 @@ interface AIMetadata {
90
92
  requiredChildren?: string[];
91
93
  commonPatterns?: string[];
92
94
  }
95
+ /**
96
+ * Performance data for a component (from bundle size measurement)
97
+ */
98
+ /**
99
+ * A single import contributing to bundle size
100
+ */
101
+ interface ImportEntry {
102
+ /** Resolved file path (relative to project root) */
103
+ path: string;
104
+ /** Bytes contributed to the bundle */
105
+ bytes: number;
106
+ /** Percentage of total bundle size */
107
+ percent: number;
108
+ }
109
+ interface PerformanceData {
110
+ /** Gzipped bundle size in bytes */
111
+ bundleSize: number;
112
+ /** Raw (minified, not gzipped) bundle size in bytes */
113
+ rawSize: number;
114
+ /** Complexity classification */
115
+ complexity: 'lightweight' | 'moderate' | 'heavy';
116
+ /** Percentage of budget used (0-100+) */
117
+ budgetPercent: number;
118
+ /** Whether the component exceeds its budget */
119
+ overBudget: boolean;
120
+ /** ISO timestamp when measured */
121
+ measuredAt: string;
122
+ /** Top imports by size (largest first) */
123
+ imports?: ImportEntry[];
124
+ }
93
125
  /**
94
126
  * Compiled fragment data (JSON-serializable for AI consumption)
95
127
  */
@@ -108,6 +140,8 @@ interface CompiledFragment {
108
140
  }>;
109
141
  contract?: FragmentContract;
110
142
  ai?: AIMetadata;
143
+ /** Component performance data from bundle size measurement */
144
+ performance?: PerformanceData;
111
145
  _generated?: FragmentGenerated;
112
146
  }
113
147
  /**
@@ -138,6 +172,21 @@ interface CompiledTokenData {
138
172
  total: number;
139
173
  categories: Record<string, CompiledTokenEntry[]>;
140
174
  }
175
+ /**
176
+ * Performance summary across all components
177
+ */
178
+ interface PerformanceSummary {
179
+ /** Preset name used */
180
+ preset: string;
181
+ /** Budget applied in bytes */
182
+ budget: number;
183
+ /** Total components measured */
184
+ total: number;
185
+ /** Number of components over budget */
186
+ overBudget: number;
187
+ /** Distribution by tier */
188
+ tiers: Record<string, number>;
189
+ }
141
190
  /**
142
191
  * The compiled fragments.json structure
143
192
  */
@@ -150,6 +199,8 @@ interface CompiledFragmentsFile {
150
199
  tokens?: CompiledTokenData;
151
200
  /** Component relationship graph for AI structural queries */
152
201
  graph?: SerializedComponentGraph;
202
+ /** Performance measurement summary */
203
+ performanceSummary?: PerformanceSummary;
153
204
  /** @deprecated Use blocks instead */
154
205
  recipes?: Record<string, CompiledBlock>;
155
206
  }
@@ -177,4 +228,4 @@ interface VerifyResult {
177
228
  };
178
229
  }
179
230
 
180
- export type { AIMetadata, CompiledBlock, CompiledFragment, CompiledFragmentsFile, CompiledTokenData, CompiledTokenEntry, ComponentRelation, FragmentContract, FragmentGenerated, FragmentMeta, FragmentUsage, PropDefinition, Theme, VerifyResult };
231
+ export type { AIMetadata, CompiledBlock, CompiledFragment, CompiledFragmentsFile, CompiledTokenData, CompiledTokenEntry, ComponentRelation, FragmentContract, FragmentGenerated, FragmentMeta, FragmentUsage, ImportEntry, PerformanceData, PerformanceSummary, PropDefinition, Theme, VerifyResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fragments-sdk/context",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "license": "FSL-1.1-MIT",
5
5
  "description": "Code intelligence and RAG primitives for design system and codebase indexing",
6
6
  "author": "Conan McNicholl",