@fragments-sdk/context 0.2.0 → 0.3.1

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.
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Component Graph data model — types for the design-system-semantic relationship graph.
3
+ *
4
+ * These types describe nodes (components), edges (relationships), and health
5
+ * metrics that together give AI agents structural understanding of a design system.
6
+ */
7
+ type GraphEdgeType = 'imports' | 'hook-depends' | 'renders' | 'composes' | 'parent-of' | 'alternative-to' | 'sibling-of';
8
+ declare const GRAPH_EDGE_TYPES: readonly GraphEdgeType[];
9
+ /** Default weight for each edge type */
10
+ declare const EDGE_TYPE_WEIGHTS: Record<GraphEdgeType, number>;
11
+ interface ComponentNode {
12
+ name: string;
13
+ category: string;
14
+ status: string;
15
+ compositionPattern?: 'compound' | 'simple' | 'controlled';
16
+ subComponents?: string[];
17
+ }
18
+ interface GraphEdge {
19
+ source: string;
20
+ target: string;
21
+ type: GraphEdgeType;
22
+ weight: number;
23
+ note?: string;
24
+ /** Where this edge was detected from */
25
+ provenance: string;
26
+ }
27
+ interface GraphHealth {
28
+ /** Components with zero edges */
29
+ orphans: string[];
30
+ /** Top components by total degree (in + out) */
31
+ hubs: Array<{
32
+ name: string;
33
+ degree: number;
34
+ }>;
35
+ /** Percentage of components appearing in at least one block */
36
+ compositionCoverage: number;
37
+ /** Disconnected groups (BFS on undirected projection) */
38
+ connectedComponents: string[][];
39
+ /** Average degree across all nodes */
40
+ averageDegree: number;
41
+ /** Total node and edge counts */
42
+ nodeCount: number;
43
+ edgeCount: number;
44
+ }
45
+ interface ComponentGraph {
46
+ nodes: ComponentNode[];
47
+ edges: GraphEdge[];
48
+ health: GraphHealth;
49
+ }
50
+ interface ImpactResult {
51
+ /** The component that was changed */
52
+ component: string;
53
+ /** Components affected at each depth level */
54
+ affected: Array<{
55
+ component: string;
56
+ depth: number;
57
+ path: string[];
58
+ edgeType: GraphEdgeType;
59
+ }>;
60
+ /** Blocks that use the changed component or any affected component */
61
+ affectedBlocks: string[];
62
+ /** Total count of affected components */
63
+ totalAffected: number;
64
+ }
65
+ interface PathResult {
66
+ /** Whether a path exists */
67
+ found: boolean;
68
+ /** Nodes along the shortest path (including source and target) */
69
+ path: string[];
70
+ /** Edges along the shortest path */
71
+ edges: GraphEdge[];
72
+ }
73
+ interface NeighborResult {
74
+ /** The center component */
75
+ component: string;
76
+ /** All components reachable within maxHops */
77
+ neighbors: Array<{
78
+ component: string;
79
+ hops: number;
80
+ edgeType: GraphEdgeType;
81
+ }>;
82
+ }
83
+ interface CompositionTree {
84
+ /** The root component */
85
+ component: string;
86
+ /** Composition pattern */
87
+ compositionPattern?: 'compound' | 'simple' | 'controlled';
88
+ /** Direct sub-components */
89
+ subComponents: string[];
90
+ /** Sub-components that must be present */
91
+ requiredChildren: string[];
92
+ /** Parent component (if this is a sub-component) */
93
+ parent?: string;
94
+ /** Sibling components at the same level */
95
+ siblings: string[];
96
+ /** Blocks that use this component */
97
+ blocks: string[];
98
+ }
99
+ interface SerializedEdge {
100
+ /** source */
101
+ s: string;
102
+ /** target */
103
+ t: string;
104
+ /** type */
105
+ ty: GraphEdgeType;
106
+ /** weight */
107
+ w: number;
108
+ /** note (optional) */
109
+ no?: string;
110
+ /** provenance */
111
+ p: string;
112
+ }
113
+ interface SerializedComponentGraph {
114
+ nodes: ComponentNode[];
115
+ edges: SerializedEdge[];
116
+ health: GraphHealth;
117
+ }
118
+
119
+ export { type ComponentGraph as C, EDGE_TYPE_WEIGHTS as E, type GraphEdgeType as G, type ImpactResult as I, type NeighborResult as N, type PathResult as P, type SerializedComponentGraph as S, type GraphEdge as a, type CompositionTree as b, type GraphHealth as c, type ComponentNode as d, type SerializedEdge as e, GRAPH_EDGE_TYPES as f };
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@fragments-sdk/context",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Code intelligence and RAG primitives for design system and codebase indexing",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/ConanMcN/fragments"
8
+ },
5
9
  "type": "module",
6
10
  "main": "./dist/index.js",
7
11
  "module": "./dist/index.js",
@@ -38,6 +42,18 @@
38
42
  "./citations": {
39
43
  "types": "./dist/citations/index.d.ts",
40
44
  "import": "./dist/citations/index.js"
45
+ },
46
+ "./mcp-tools": {
47
+ "types": "./dist/mcp-tools/index.d.ts",
48
+ "import": "./dist/mcp-tools/index.js"
49
+ },
50
+ "./cli-commands": {
51
+ "types": "./dist/cli-commands/index.d.ts",
52
+ "import": "./dist/cli-commands/index.js"
53
+ },
54
+ "./graph": {
55
+ "types": "./dist/graph/index.d.ts",
56
+ "import": "./dist/graph/index.js"
41
57
  }
42
58
  },
43
59
  "publishConfig": {