@fragments-sdk/context 0.4.3 → 0.4.4
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-2UQY4VNM.js → chunk-AW6Q5736.js} +91 -1
- package/dist/generate/index.d.ts +1 -1
- package/dist/generate/index.js +1 -1
- package/dist/graph/index.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +10 -2
- package/dist/{types-RAbbckR4.d.ts → types-ExvGbLOm.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -81,7 +81,68 @@ function generateMarkdownContext(fragments, include, compact, blocks) {
|
|
|
81
81
|
lines.push("");
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (
|
|
84
|
+
if (fragment.ai?.compositionPattern) {
|
|
85
|
+
const ai = fragment.ai;
|
|
86
|
+
const parts = [`**Composition:** ${ai.compositionPattern}`];
|
|
87
|
+
if (ai.subComponents && ai.subComponents.length > 0) {
|
|
88
|
+
parts.push(`Sub-components: ${ai.subComponents.map((s) => `${fragment.meta.name}.${s}`).join(", ")}`);
|
|
89
|
+
}
|
|
90
|
+
if (ai.requiredChildren && ai.requiredChildren.length > 0) {
|
|
91
|
+
parts.push(`Required: ${ai.requiredChildren.map((c) => `${fragment.meta.name}.${c}`).join(", ")}`);
|
|
92
|
+
}
|
|
93
|
+
lines.push(parts.join(" | "));
|
|
94
|
+
lines.push("");
|
|
95
|
+
if (ai.commonPatterns && ai.commonPatterns.length > 0) {
|
|
96
|
+
lines.push("**Patterns:**");
|
|
97
|
+
for (const pattern of ai.commonPatterns) {
|
|
98
|
+
lines.push(`- \`${pattern}\``);
|
|
99
|
+
}
|
|
100
|
+
lines.push("");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (fragment.contract) {
|
|
104
|
+
const contract = fragment.contract;
|
|
105
|
+
if (contract.propsSummary && contract.propsSummary.length > 0) {
|
|
106
|
+
lines.push(`**Props:** ${contract.propsSummary.join(", ")}`);
|
|
107
|
+
lines.push("");
|
|
108
|
+
} else if (include.props && Object.keys(fragment.props).length > 0) {
|
|
109
|
+
lines.push("**Props:**");
|
|
110
|
+
for (const [name, prop] of Object.entries(fragment.props)) {
|
|
111
|
+
lines.push(`- \`${name}\`: ${formatPropType(prop)}${prop.required ? " (required)" : ""}`);
|
|
112
|
+
}
|
|
113
|
+
lines.push("");
|
|
114
|
+
}
|
|
115
|
+
if (contract.compoundChildren && Object.keys(contract.compoundChildren).length > 0) {
|
|
116
|
+
lines.push("**Sub-components:**");
|
|
117
|
+
for (const [childName, childMeta] of Object.entries(contract.compoundChildren)) {
|
|
118
|
+
const parts = [`\`${fragment.meta.name}.${childName}\``];
|
|
119
|
+
if (childMeta.required) parts.push("(required)");
|
|
120
|
+
if (childMeta.description) parts.push(`\u2014 ${childMeta.description}`);
|
|
121
|
+
lines.push(`- ${parts.join(" ")}`);
|
|
122
|
+
}
|
|
123
|
+
lines.push("");
|
|
124
|
+
}
|
|
125
|
+
if (contract.canonicalUsage && contract.canonicalUsage.length > 0) {
|
|
126
|
+
lines.push("**Usage examples:**");
|
|
127
|
+
for (const usage of contract.canonicalUsage) {
|
|
128
|
+
lines.push("```tsx");
|
|
129
|
+
lines.push(usage);
|
|
130
|
+
lines.push("```");
|
|
131
|
+
}
|
|
132
|
+
lines.push("");
|
|
133
|
+
}
|
|
134
|
+
if (contract.a11yRules && contract.a11yRules.length > 0) {
|
|
135
|
+
lines.push(`**A11y:** ${contract.a11yRules.join(", ")}`);
|
|
136
|
+
lines.push("");
|
|
137
|
+
}
|
|
138
|
+
if (contract.bans && contract.bans.length > 0) {
|
|
139
|
+
lines.push("**Banned patterns:**");
|
|
140
|
+
for (const ban of contract.bans) {
|
|
141
|
+
lines.push(`- \`${ban.pattern}\`: ${ban.message}`);
|
|
142
|
+
}
|
|
143
|
+
lines.push("");
|
|
144
|
+
}
|
|
145
|
+
} else if (include.props && Object.keys(fragment.props).length > 0) {
|
|
85
146
|
lines.push("**Props:**");
|
|
86
147
|
for (const [name, prop] of Object.entries(fragment.props)) {
|
|
87
148
|
lines.push(`- \`${name}\`: ${formatPropType(prop)}${prop.required ? " (required)" : ""}`);
|
|
@@ -159,6 +220,35 @@ function generateJsonContext(fragments, include, compact, blocks) {
|
|
|
159
220
|
if (whenFiltered.length > 0) component.whenToUse = whenFiltered;
|
|
160
221
|
if (whenNotFiltered.length > 0) component.whenNotToUse = whenNotFiltered;
|
|
161
222
|
}
|
|
223
|
+
if (fragment.ai?.compositionPattern) {
|
|
224
|
+
const ai = fragment.ai;
|
|
225
|
+
const comp = { pattern: ai.compositionPattern };
|
|
226
|
+
if (ai.subComponents && ai.subComponents.length > 0) {
|
|
227
|
+
comp.subComponents = ai.subComponents;
|
|
228
|
+
}
|
|
229
|
+
if (ai.requiredChildren && ai.requiredChildren.length > 0) {
|
|
230
|
+
comp.requiredChildren = ai.requiredChildren;
|
|
231
|
+
}
|
|
232
|
+
if (ai.commonPatterns && ai.commonPatterns.length > 0) {
|
|
233
|
+
comp.commonPatterns = ai.commonPatterns;
|
|
234
|
+
}
|
|
235
|
+
component.composition = comp;
|
|
236
|
+
}
|
|
237
|
+
if (fragment.contract?.propsSummary && fragment.contract.propsSummary.length > 0) {
|
|
238
|
+
component.propsSummary = fragment.contract.propsSummary;
|
|
239
|
+
}
|
|
240
|
+
if (fragment.contract?.compoundChildren && Object.keys(fragment.contract.compoundChildren).length > 0) {
|
|
241
|
+
component.compoundChildren = fragment.contract.compoundChildren;
|
|
242
|
+
}
|
|
243
|
+
if (fragment.contract?.canonicalUsage && fragment.contract.canonicalUsage.length > 0) {
|
|
244
|
+
component.canonicalUsage = fragment.contract.canonicalUsage;
|
|
245
|
+
}
|
|
246
|
+
if (fragment.contract?.a11yRules && fragment.contract.a11yRules.length > 0) {
|
|
247
|
+
component.a11yRules = fragment.contract.a11yRules;
|
|
248
|
+
}
|
|
249
|
+
if (fragment.contract?.bans && fragment.contract.bans.length > 0) {
|
|
250
|
+
component.bans = fragment.contract.bans;
|
|
251
|
+
}
|
|
162
252
|
if (include.props && Object.keys(fragment.props).length > 0) {
|
|
163
253
|
component.props = {};
|
|
164
254
|
for (const [name, prop] of Object.entries(fragment.props)) {
|
package/dist/generate/index.d.ts
CHANGED
package/dist/generate/index.js
CHANGED
package/dist/graph/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
export { E as EDGE_TYPE_WEIGHTS, f as GRAPH_EDGE_TYPES, e as SerializedEdge } from '../types-
|
|
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-ExvGbLOm.js';
|
|
2
|
+
export { E as EDGE_TYPE_WEIGHTS, f as GRAPH_EDGE_TYPES, e as SerializedEdge } from '../types-ExvGbLOm.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* ComponentGraphEngine — query engine for the design-system relationship graph.
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { AST_SUPPORTED_LANGUAGES, ChangedFiles, FileEntry, GrammarMapping, INDEX
|
|
|
8
8
|
export { ChunkMapping, CitationDocumentBlock, CitationDocumentOptions, DocumentMapping, RawCitation, ResolvedCitation, buildCitationDocuments, resolveCitation, resolveCitations } from './citations/index.js';
|
|
9
9
|
export { CLI_TOOL_EXTENSIONS, CliToolExtension, MCP_TOOL_DEFINITIONS, McpToolDefinition, McpToolParam, buildMcpTools, buildToolNames } from './mcp-tools/index.js';
|
|
10
10
|
export { CLI_COMMANDS, CLI_COMMAND_CATEGORIES, CliCategoryInfo, CliCommandCategory, CliCommandDef, CliOptionDef } from './cli-commands/index.js';
|
|
11
|
-
import './types-
|
|
11
|
+
import './types-ExvGbLOm.js';
|
package/dist/index.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SerializedComponentGraph } from '../types-
|
|
1
|
+
import { S as SerializedComponentGraph } from '../types-ExvGbLOm.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Compiled fragment types — shared between CLI and MCP packages.
|
|
@@ -73,6 +73,14 @@ interface FragmentContract {
|
|
|
73
73
|
scenarioTags?: string[];
|
|
74
74
|
/** Per-component performance budget override in bytes (gzipped) */
|
|
75
75
|
performanceBudget?: number;
|
|
76
|
+
/** Sub-component slot metadata for compound components */
|
|
77
|
+
compoundChildren?: Record<string, {
|
|
78
|
+
required?: boolean;
|
|
79
|
+
accepts?: string[];
|
|
80
|
+
description?: string;
|
|
81
|
+
}>;
|
|
82
|
+
/** Canonical JSX usage examples showing how to assemble the component */
|
|
83
|
+
canonicalUsage?: string[];
|
|
76
84
|
}
|
|
77
85
|
/**
|
|
78
86
|
* Provenance tracking for generated fragments
|
|
@@ -87,7 +95,7 @@ interface FragmentGenerated {
|
|
|
87
95
|
* AI-specific metadata
|
|
88
96
|
*/
|
|
89
97
|
interface AIMetadata {
|
|
90
|
-
compositionPattern?: "compound" | "simple" | "controlled";
|
|
98
|
+
compositionPattern?: "compound" | "simple" | "controlled" | "wrapper";
|
|
91
99
|
subComponents?: string[];
|
|
92
100
|
requiredChildren?: string[];
|
|
93
101
|
commonPatterns?: string[];
|
|
@@ -12,7 +12,7 @@ interface ComponentNode {
|
|
|
12
12
|
name: string;
|
|
13
13
|
category: string;
|
|
14
14
|
status: string;
|
|
15
|
-
compositionPattern?: 'compound' | 'simple' | 'controlled';
|
|
15
|
+
compositionPattern?: 'compound' | 'simple' | 'controlled' | 'wrapper';
|
|
16
16
|
subComponents?: string[];
|
|
17
17
|
}
|
|
18
18
|
interface GraphEdge {
|
|
@@ -84,7 +84,7 @@ interface CompositionTree {
|
|
|
84
84
|
/** The root component */
|
|
85
85
|
component: string;
|
|
86
86
|
/** Composition pattern */
|
|
87
|
-
compositionPattern?: 'compound' | 'simple' | 'controlled';
|
|
87
|
+
compositionPattern?: 'compound' | 'simple' | 'controlled' | 'wrapper';
|
|
88
88
|
/** Direct sub-components */
|
|
89
89
|
subComponents: string[];
|
|
90
90
|
/** Components that declare this component as their parent */
|