@buoy-design/core 0.1.1 → 0.1.2
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/analysis/audit.d.ts +47 -0
- package/dist/analysis/audit.d.ts.map +1 -0
- package/dist/analysis/audit.js +168 -0
- package/dist/analysis/audit.js.map +1 -0
- package/dist/analysis/index.d.ts +1 -0
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +2 -0
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/semantic-diff.d.ts.map +1 -1
- package/dist/analysis/semantic-diff.js +2 -1
- package/dist/analysis/semantic-diff.js.map +1 -1
- package/dist/analysis/token-suggestions.d.ts +8 -1
- package/dist/analysis/token-suggestions.d.ts.map +1 -1
- package/dist/analysis/token-suggestions.js +116 -10
- package/dist/analysis/token-suggestions.js.map +1 -1
- package/dist/extraction/css-parser.d.ts +51 -0
- package/dist/extraction/css-parser.d.ts.map +1 -0
- package/dist/extraction/css-parser.js +303 -0
- package/dist/extraction/css-parser.js.map +1 -0
- package/dist/extraction/index.d.ts +2 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +2 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/graph/builder.d.ts +118 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/builder.js +328 -0
- package/dist/graph/builder.js.map +1 -0
- package/dist/graph/collectors/git.d.ts +90 -0
- package/dist/graph/collectors/git.d.ts.map +1 -0
- package/dist/graph/collectors/git.js +253 -0
- package/dist/graph/collectors/git.js.map +1 -0
- package/dist/graph/collectors/imports.d.ts +55 -0
- package/dist/graph/collectors/imports.d.ts.map +1 -0
- package/dist/graph/collectors/imports.js +230 -0
- package/dist/graph/collectors/imports.js.map +1 -0
- package/dist/graph/collectors/index.d.ts +9 -0
- package/dist/graph/collectors/index.d.ts.map +1 -0
- package/dist/graph/collectors/index.js +12 -0
- package/dist/graph/collectors/index.js.map +1 -0
- package/dist/graph/collectors/usages.d.ts +68 -0
- package/dist/graph/collectors/usages.d.ts.map +1 -0
- package/dist/graph/collectors/usages.js +244 -0
- package/dist/graph/collectors/usages.js.map +1 -0
- package/dist/graph/index.d.ts +11 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +29 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +81 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +379 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/types.d.ts +135 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +8 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/models/drift.d.ts +6 -0
- package/dist/models/drift.d.ts.map +1 -1
- package/dist/models/drift.js +17 -0
- package/dist/models/drift.js.map +1 -1
- package/dist/models/index.d.ts +3 -3
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/token.d.ts +57 -0
- package/dist/models/token.d.ts.map +1 -1
- package/dist/models/token.js +9 -0
- package/dist/models/token.js.map +1 -1
- package/dist/tokenization/generator.d.ts +49 -0
- package/dist/tokenization/generator.d.ts.map +1 -0
- package/dist/tokenization/generator.js +886 -0
- package/dist/tokenization/generator.js.map +1 -0
- package/dist/tokenization/index.d.ts +2 -0
- package/dist/tokenization/index.d.ts.map +1 -0
- package/dist/tokenization/index.js +2 -0
- package/dist/tokenization/index.js.map +1 -0
- package/dist/tokens/comparison.d.ts +30 -0
- package/dist/tokens/comparison.d.ts.map +1 -0
- package/dist/tokens/comparison.js +142 -0
- package/dist/tokens/comparison.js.map +1 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +5 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/parser.d.ts +11 -0
- package/dist/tokens/parser.d.ts.map +1 -0
- package/dist/tokens/parser.js +268 -0
- package/dist/tokens/parser.js.map +1 -0
- package/package.json +12 -8
- package/LICENSE +0 -21
- package/dist/analysis/semantic-diff.test.d.ts +0 -2
- package/dist/analysis/semantic-diff.test.d.ts.map +0 -1
- package/dist/analysis/semantic-diff.test.js +0 -188
- package/dist/analysis/semantic-diff.test.js.map +0 -1
- package/dist/models/component.test.d.ts +0 -2
- package/dist/models/component.test.d.ts.map +0 -1
- package/dist/models/component.test.js +0 -55
- package/dist/models/component.test.js.map +0 -1
- package/dist/models/drift.test.d.ts +0 -2
- package/dist/models/drift.test.d.ts.map +0 -1
- package/dist/models/drift.test.js +0 -38
- package/dist/models/drift.test.js.map +0 -1
- package/dist/models/token.test.d.ts +0 -2
- package/dist/models/token.test.d.ts.map +0 -1
- package/dist/models/token.test.js +0 -168
- package/dist/models/token.test.js.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs the design system knowledge graph from SQLite data.
|
|
5
|
+
* Uses graphology for in-memory graph operations.
|
|
6
|
+
*/
|
|
7
|
+
import type { AbstractGraph } from 'graphology-types';
|
|
8
|
+
import type { NodeType, EdgeType, NodeAttributes, EdgeAttributes, GraphBuildOptions, GraphStats } from './types.js';
|
|
9
|
+
export type DesignSystemGraph = AbstractGraph<NodeAttributes, EdgeAttributes>;
|
|
10
|
+
/**
|
|
11
|
+
* Create an empty directed multigraph for the design system
|
|
12
|
+
*/
|
|
13
|
+
export declare function createGraph(): DesignSystemGraph;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a unique node ID
|
|
16
|
+
*/
|
|
17
|
+
export declare function nodeId(type: NodeType, id: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate a unique edge ID
|
|
20
|
+
*/
|
|
21
|
+
export declare function edgeId(type: EdgeType, sourceId: string, targetId: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Add a node to the graph if it doesn't exist
|
|
24
|
+
*/
|
|
25
|
+
export declare function addNode(graph: DesignSystemGraph, type: NodeType, id: string, attributes: Omit<NodeAttributes, 'type'>): string;
|
|
26
|
+
/**
|
|
27
|
+
* Update node attributes
|
|
28
|
+
*/
|
|
29
|
+
export declare function updateNode(graph: DesignSystemGraph, nid: string, attributes: Partial<NodeAttributes>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get all nodes of a specific type
|
|
32
|
+
*/
|
|
33
|
+
export declare function getNodesByType(graph: DesignSystemGraph, type: NodeType): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Add an edge to the graph
|
|
36
|
+
*/
|
|
37
|
+
export declare function addEdge(graph: DesignSystemGraph, type: EdgeType, sourceId: string, targetId: string, attributes?: Omit<EdgeAttributes, 'type'>): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get all edges of a specific type
|
|
40
|
+
*/
|
|
41
|
+
export declare function getEdgesByType(graph: DesignSystemGraph, type: EdgeType): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get all outgoing edges of a specific type from a node
|
|
44
|
+
*/
|
|
45
|
+
export declare function getOutEdgesByType(graph: DesignSystemGraph, nid: string, type: EdgeType): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Get all incoming edges of a specific type to a node
|
|
48
|
+
*/
|
|
49
|
+
export declare function getInEdgesByType(graph: DesignSystemGraph, nid: string, type: EdgeType): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Get statistics about the graph
|
|
52
|
+
*/
|
|
53
|
+
export declare function getGraphStats(graph: DesignSystemGraph): GraphStats;
|
|
54
|
+
/**
|
|
55
|
+
* Export graph to JSON format
|
|
56
|
+
*/
|
|
57
|
+
export declare function exportToJSON(graph: DesignSystemGraph): object;
|
|
58
|
+
/**
|
|
59
|
+
* Import graph from JSON format
|
|
60
|
+
*/
|
|
61
|
+
export declare function importFromJSON(data: ReturnType<DesignSystemGraph['export']>): DesignSystemGraph;
|
|
62
|
+
/**
|
|
63
|
+
* Export graph to DOT format for visualization
|
|
64
|
+
*/
|
|
65
|
+
export declare function exportToDOT(graph: DesignSystemGraph): string;
|
|
66
|
+
/**
|
|
67
|
+
* Export graph to Cytoscape format for web visualization
|
|
68
|
+
*/
|
|
69
|
+
export declare function exportToCytoscape(graph: DesignSystemGraph): object;
|
|
70
|
+
/**
|
|
71
|
+
* Builder class for constructing the graph incrementally
|
|
72
|
+
*/
|
|
73
|
+
export declare class GraphBuilder {
|
|
74
|
+
private graph;
|
|
75
|
+
readonly projectId: string;
|
|
76
|
+
constructor(options: GraphBuildOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Add a token node
|
|
79
|
+
*/
|
|
80
|
+
addToken(id: string, name: string, category: string, value: string, source: string, isW3C?: boolean): string;
|
|
81
|
+
/**
|
|
82
|
+
* Add a component node
|
|
83
|
+
*/
|
|
84
|
+
addComponent(id: string, name: string, filePath: string, framework: string, props?: string[], variants?: string[]): string;
|
|
85
|
+
/**
|
|
86
|
+
* Add a file node
|
|
87
|
+
*/
|
|
88
|
+
addFile(id: string, path: string, lineCount?: number): string;
|
|
89
|
+
/**
|
|
90
|
+
* Add a commit node
|
|
91
|
+
*/
|
|
92
|
+
addCommit(sha: string, message: string, author: string, authorEmail: string | undefined, timestamp: Date): string;
|
|
93
|
+
/**
|
|
94
|
+
* Add a developer node
|
|
95
|
+
*/
|
|
96
|
+
addDeveloper(id: string, name: string, email: string, githubLogin?: string, commitCount?: number): string;
|
|
97
|
+
/**
|
|
98
|
+
* Add a PR node
|
|
99
|
+
*/
|
|
100
|
+
addPR(id: string, number: number, title: string, state: 'open' | 'closed' | 'merged', authorLogin?: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Add a drift signal node
|
|
103
|
+
*/
|
|
104
|
+
addDriftSignal(id: string, driftType: string, severity: string, message: string, resolved?: boolean): string;
|
|
105
|
+
/**
|
|
106
|
+
* Add an edge between nodes
|
|
107
|
+
*/
|
|
108
|
+
addEdge(type: EdgeType, sourceId: string, targetId: string, attributes?: Omit<EdgeAttributes, 'type'>): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Get the built graph
|
|
111
|
+
*/
|
|
112
|
+
build(): DesignSystemGraph;
|
|
113
|
+
/**
|
|
114
|
+
* Get graph statistics
|
|
115
|
+
*/
|
|
116
|
+
getStats(): GraphStats;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/graph/builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAW9E;;GAEG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAM/C;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjF;AAMD;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,QAAQ,EACd,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GACvC,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,iBAAiB,EACxB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,OAAO,CAAC,cAAc,CAAC,GACl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,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GACxC,MAAM,GAAG,IAAI;IAIhB;;OAEG;IACH,KAAK,IAAI,iBAAiB;IAI1B;;OAEG;IACH,QAAQ,IAAI,UAAU;CAGvB"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs the design system knowledge graph from SQLite data.
|
|
5
|
+
* Uses graphology for in-memory graph operations.
|
|
6
|
+
*/
|
|
7
|
+
import GraphConstructor from 'graphology';
|
|
8
|
+
// Cast constructor for use
|
|
9
|
+
const Graph = GraphConstructor;
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Graph Creation
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Create an empty directed multigraph for the design system
|
|
15
|
+
*/
|
|
16
|
+
export function createGraph() {
|
|
17
|
+
return new Graph({
|
|
18
|
+
multi: true,
|
|
19
|
+
type: 'directed',
|
|
20
|
+
allowSelfLoops: false,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate a unique node ID
|
|
25
|
+
*/
|
|
26
|
+
export function nodeId(type, id) {
|
|
27
|
+
return `${type.toLowerCase()}:${id}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate a unique edge ID
|
|
31
|
+
*/
|
|
32
|
+
export function edgeId(type, sourceId, targetId) {
|
|
33
|
+
return `${type.toLowerCase()}:${sourceId}:${targetId}`;
|
|
34
|
+
}
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Node Operations
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Add a node to the graph if it doesn't exist
|
|
40
|
+
*/
|
|
41
|
+
export function addNode(graph, type, id, attributes) {
|
|
42
|
+
const nid = nodeId(type, id);
|
|
43
|
+
if (!graph.hasNode(nid)) {
|
|
44
|
+
graph.addNode(nid, {
|
|
45
|
+
...attributes,
|
|
46
|
+
type,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return nid;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Update node attributes
|
|
53
|
+
*/
|
|
54
|
+
export function updateNode(graph, nid, attributes) {
|
|
55
|
+
if (graph.hasNode(nid)) {
|
|
56
|
+
graph.mergeNodeAttributes(nid, attributes);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get all nodes of a specific type
|
|
61
|
+
*/
|
|
62
|
+
export function getNodesByType(graph, type) {
|
|
63
|
+
return graph.filterNodes((_node, attrs) => attrs.type === type);
|
|
64
|
+
}
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Edge Operations
|
|
67
|
+
// ============================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Add an edge to the graph
|
|
70
|
+
*/
|
|
71
|
+
export function addEdge(graph, type, sourceId, targetId, attributes) {
|
|
72
|
+
// Ensure both nodes exist
|
|
73
|
+
if (!graph.hasNode(sourceId) || !graph.hasNode(targetId)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const eid = edgeId(type, sourceId, targetId);
|
|
77
|
+
// Check if edge already exists
|
|
78
|
+
if (!graph.hasEdge(eid)) {
|
|
79
|
+
graph.addEdgeWithKey(eid, sourceId, targetId, {
|
|
80
|
+
...attributes,
|
|
81
|
+
type,
|
|
82
|
+
createdAt: attributes?.createdAt ?? new Date(),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return eid;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all edges of a specific type
|
|
89
|
+
*/
|
|
90
|
+
export function getEdgesByType(graph, type) {
|
|
91
|
+
return graph.filterEdges((_edge, attrs) => attrs.type === type);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all outgoing edges of a specific type from a node
|
|
95
|
+
*/
|
|
96
|
+
export function getOutEdgesByType(graph, nid, type) {
|
|
97
|
+
if (!graph.hasNode(nid))
|
|
98
|
+
return [];
|
|
99
|
+
return graph.filterOutEdges(nid, (_edge, attrs) => attrs.type === type);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get all incoming edges of a specific type to a node
|
|
103
|
+
*/
|
|
104
|
+
export function getInEdgesByType(graph, nid, type) {
|
|
105
|
+
if (!graph.hasNode(nid))
|
|
106
|
+
return [];
|
|
107
|
+
return graph.filterInEdges(nid, (_edge, attrs) => attrs.type === type);
|
|
108
|
+
}
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// Graph Stats
|
|
111
|
+
// ============================================================================
|
|
112
|
+
/**
|
|
113
|
+
* Get statistics about the graph
|
|
114
|
+
*/
|
|
115
|
+
export function getGraphStats(graph) {
|
|
116
|
+
const nodesByType = {};
|
|
117
|
+
const edgesByType = {};
|
|
118
|
+
graph.forEachNode((_node, attrs) => {
|
|
119
|
+
const nodeType = attrs.type;
|
|
120
|
+
nodesByType[nodeType] = (nodesByType[nodeType] ?? 0) + 1;
|
|
121
|
+
});
|
|
122
|
+
graph.forEachEdge((_edge, attrs) => {
|
|
123
|
+
const edgeType = attrs.type;
|
|
124
|
+
edgesByType[edgeType] = (edgesByType[edgeType] ?? 0) + 1;
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
nodeCount: graph.order,
|
|
128
|
+
edgeCount: graph.size,
|
|
129
|
+
nodesByType: nodesByType,
|
|
130
|
+
edgesByType: edgesByType,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// Serialization
|
|
135
|
+
// ============================================================================
|
|
136
|
+
/**
|
|
137
|
+
* Export graph to JSON format
|
|
138
|
+
*/
|
|
139
|
+
export function exportToJSON(graph) {
|
|
140
|
+
return graph.export();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Import graph from JSON format
|
|
144
|
+
*/
|
|
145
|
+
export function importFromJSON(data) {
|
|
146
|
+
const graph = createGraph();
|
|
147
|
+
graph.import(data);
|
|
148
|
+
return graph;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Export graph to DOT format for visualization
|
|
152
|
+
*/
|
|
153
|
+
export function exportToDOT(graph) {
|
|
154
|
+
const lines = ['digraph DesignSystem {'];
|
|
155
|
+
lines.push(' rankdir=LR;');
|
|
156
|
+
lines.push(' node [shape=box];');
|
|
157
|
+
lines.push('');
|
|
158
|
+
// Define node styles by type
|
|
159
|
+
const nodeStyles = {
|
|
160
|
+
Token: 'style=filled,fillcolor="#e3f2fd"',
|
|
161
|
+
Component: 'style=filled,fillcolor="#e8f5e9"',
|
|
162
|
+
File: 'style=filled,fillcolor="#fff3e0"',
|
|
163
|
+
Commit: 'style=filled,fillcolor="#fce4ec"',
|
|
164
|
+
Developer: 'style=filled,fillcolor="#f3e5f5"',
|
|
165
|
+
DriftSignal: 'style=filled,fillcolor="#ffebee"',
|
|
166
|
+
};
|
|
167
|
+
// Add nodes
|
|
168
|
+
graph.forEachNode((node, attrs) => {
|
|
169
|
+
const nodeAttrs = attrs;
|
|
170
|
+
const style = nodeStyles[nodeAttrs.type] ?? '';
|
|
171
|
+
const label = nodeAttrs.name.replace(/"/g, '\\"');
|
|
172
|
+
lines.push(` "${node}" [label="${label}" ${style}];`);
|
|
173
|
+
});
|
|
174
|
+
lines.push('');
|
|
175
|
+
// Add edges
|
|
176
|
+
graph.forEachEdge((_edge, attrs, source, target) => {
|
|
177
|
+
const edgeAttrs = attrs;
|
|
178
|
+
const label = edgeAttrs.type;
|
|
179
|
+
lines.push(` "${source}" -> "${target}" [label="${label}"];`);
|
|
180
|
+
});
|
|
181
|
+
lines.push('}');
|
|
182
|
+
return lines.join('\n');
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Export graph to Cytoscape format for web visualization
|
|
186
|
+
*/
|
|
187
|
+
export function exportToCytoscape(graph) {
|
|
188
|
+
const elements = [];
|
|
189
|
+
graph.forEachNode((node, attrs) => {
|
|
190
|
+
elements.push({
|
|
191
|
+
group: 'nodes',
|
|
192
|
+
data: {
|
|
193
|
+
id: node,
|
|
194
|
+
...attrs,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
graph.forEachEdge((_edge, attrs, source, target) => {
|
|
199
|
+
elements.push({
|
|
200
|
+
group: 'edges',
|
|
201
|
+
data: {
|
|
202
|
+
id: _edge,
|
|
203
|
+
source,
|
|
204
|
+
target,
|
|
205
|
+
...attrs,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
return { elements };
|
|
210
|
+
}
|
|
211
|
+
// ============================================================================
|
|
212
|
+
// Graph Builder Class
|
|
213
|
+
// ============================================================================
|
|
214
|
+
/**
|
|
215
|
+
* Builder class for constructing the graph incrementally
|
|
216
|
+
*/
|
|
217
|
+
export class GraphBuilder {
|
|
218
|
+
graph;
|
|
219
|
+
projectId;
|
|
220
|
+
constructor(options) {
|
|
221
|
+
this.graph = createGraph();
|
|
222
|
+
this.projectId = options.projectId;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Add a token node
|
|
226
|
+
*/
|
|
227
|
+
addToken(id, name, category, value, source, isW3C = false) {
|
|
228
|
+
return addNode(this.graph, 'Token', id, {
|
|
229
|
+
name,
|
|
230
|
+
category,
|
|
231
|
+
value,
|
|
232
|
+
source,
|
|
233
|
+
isW3C,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Add a component node
|
|
238
|
+
*/
|
|
239
|
+
addComponent(id, name, filePath, framework, props, variants) {
|
|
240
|
+
return addNode(this.graph, 'Component', id, {
|
|
241
|
+
name,
|
|
242
|
+
filePath,
|
|
243
|
+
framework,
|
|
244
|
+
props,
|
|
245
|
+
variants,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Add a file node
|
|
250
|
+
*/
|
|
251
|
+
addFile(id, path, lineCount) {
|
|
252
|
+
const extension = path.split('.').pop() ?? '';
|
|
253
|
+
const name = path.split('/').pop() ?? path;
|
|
254
|
+
return addNode(this.graph, 'File', id, {
|
|
255
|
+
name,
|
|
256
|
+
path,
|
|
257
|
+
extension,
|
|
258
|
+
lineCount,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Add a commit node
|
|
263
|
+
*/
|
|
264
|
+
addCommit(sha, message, author, authorEmail, timestamp) {
|
|
265
|
+
return addNode(this.graph, 'Commit', sha, {
|
|
266
|
+
name: (message.split('\n')[0] ?? '').slice(0, 50),
|
|
267
|
+
sha,
|
|
268
|
+
message,
|
|
269
|
+
author,
|
|
270
|
+
authorEmail,
|
|
271
|
+
timestamp,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Add a developer node
|
|
276
|
+
*/
|
|
277
|
+
addDeveloper(id, name, email, githubLogin, commitCount = 0) {
|
|
278
|
+
return addNode(this.graph, 'Developer', id, {
|
|
279
|
+
name,
|
|
280
|
+
email,
|
|
281
|
+
githubLogin,
|
|
282
|
+
commitCount,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Add a PR node
|
|
287
|
+
*/
|
|
288
|
+
addPR(id, number, title, state, authorLogin) {
|
|
289
|
+
return addNode(this.graph, 'PR', id, {
|
|
290
|
+
name: `#${number}: ${title.slice(0, 50)}`,
|
|
291
|
+
number,
|
|
292
|
+
title,
|
|
293
|
+
state,
|
|
294
|
+
authorLogin,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Add a drift signal node
|
|
299
|
+
*/
|
|
300
|
+
addDriftSignal(id, driftType, severity, message, resolved = false) {
|
|
301
|
+
return addNode(this.graph, 'DriftSignal', id, {
|
|
302
|
+
name: message.slice(0, 50),
|
|
303
|
+
driftType,
|
|
304
|
+
severity,
|
|
305
|
+
message,
|
|
306
|
+
resolved,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Add an edge between nodes
|
|
311
|
+
*/
|
|
312
|
+
addEdge(type, sourceId, targetId, attributes) {
|
|
313
|
+
return addEdge(this.graph, type, sourceId, targetId, attributes);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get the built graph
|
|
317
|
+
*/
|
|
318
|
+
build() {
|
|
319
|
+
return this.graph;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get graph statistics
|
|
323
|
+
*/
|
|
324
|
+
getStats() {
|
|
325
|
+
return getGraphStats(this.graph);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/graph/builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,gBAAgB,MAAM,YAAY,CAAC;AAc1C,2BAA2B;AAC3B,MAAM,KAAK,GAAG,gBAEU,CAAC;AAEzB,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,IAAI,KAAK,CAAiC;QAC/C,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,UAAU;QAChB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAc,EAAE,EAAU;IAC/C,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAc,EAAE,QAAgB,EAAE,QAAgB;IACvE,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;AACzD,CAAC;AAED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MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE;YACzC,MAAM;YACN,KAAK;YACL,KAAK;YACL,WAAW;SACoB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,cAAc,CACZ,EAAU,EACV,SAAiB,EACjB,QAAgB,EAChB,OAAe,EACf,QAAQ,GAAG,KAAK;QAEhB,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE;YAC5C,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YAC1B,SAAS;YACT,QAAQ;YACR,OAAO;YACP,QAAQ;SACuB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,OAAO,CACL,IAAc,EACd,QAAgB,EAChB,QAAgB,EAChB,UAAyC;QAEzC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git History Collector
|
|
3
|
+
*
|
|
4
|
+
* Extracts commit history, authors, and file changes from git.
|
|
5
|
+
* Populates commits and developers tables.
|
|
6
|
+
*/
|
|
7
|
+
export interface CollectedCommit {
|
|
8
|
+
sha: string;
|
|
9
|
+
message: string;
|
|
10
|
+
author: string;
|
|
11
|
+
authorEmail: string;
|
|
12
|
+
timestamp: Date;
|
|
13
|
+
parentSha: string | null;
|
|
14
|
+
filesChanged: FileChange[];
|
|
15
|
+
}
|
|
16
|
+
export interface FileChange {
|
|
17
|
+
path: string;
|
|
18
|
+
status: 'added' | 'modified' | 'deleted' | 'renamed';
|
|
19
|
+
additions?: number;
|
|
20
|
+
deletions?: number;
|
|
21
|
+
oldPath?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CollectedDeveloper {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
email: string;
|
|
27
|
+
commitCount: number;
|
|
28
|
+
firstSeenAt: Date;
|
|
29
|
+
lastSeenAt: Date;
|
|
30
|
+
}
|
|
31
|
+
export interface GitCollectorOptions {
|
|
32
|
+
/** Only collect commits after this date */
|
|
33
|
+
since?: Date;
|
|
34
|
+
/** Only collect commits before this date */
|
|
35
|
+
until?: Date;
|
|
36
|
+
/** Only collect commits touching these file patterns */
|
|
37
|
+
paths?: string[];
|
|
38
|
+
/** Maximum number of commits to collect */
|
|
39
|
+
maxCount?: number;
|
|
40
|
+
/** Include file change stats (slower but more data) */
|
|
41
|
+
includeStats?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface GitCollectorResult {
|
|
44
|
+
commits: CollectedCommit[];
|
|
45
|
+
developers: CollectedDeveloper[];
|
|
46
|
+
stats: {
|
|
47
|
+
totalCommits: number;
|
|
48
|
+
totalDevelopers: number;
|
|
49
|
+
dateRange: {
|
|
50
|
+
start: Date;
|
|
51
|
+
end: Date;
|
|
52
|
+
} | null;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Collect git history from a repository
|
|
57
|
+
*/
|
|
58
|
+
export declare function collectGitHistory(projectRoot: string, options?: GitCollectorOptions): Promise<GitCollectorResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Collect commits that touched design-related files
|
|
61
|
+
*/
|
|
62
|
+
export declare function collectDesignSystemHistory(projectRoot: string, options?: Omit<GitCollectorOptions, 'paths'>): Promise<GitCollectorResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Get file history (who changed this file)
|
|
65
|
+
*/
|
|
66
|
+
export declare function getFileHistory(projectRoot: string, filePath: string, options?: {
|
|
67
|
+
maxCount?: number;
|
|
68
|
+
}): Promise<CollectedCommit[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get blame information for a file
|
|
71
|
+
*/
|
|
72
|
+
export declare function getFileBlame(projectRoot: string, filePath: string): Promise<Map<number, {
|
|
73
|
+
author: string;
|
|
74
|
+
email: string;
|
|
75
|
+
sha: string;
|
|
76
|
+
date: Date;
|
|
77
|
+
}>>;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a path is inside a git repository
|
|
80
|
+
*/
|
|
81
|
+
export declare function isGitRepository(path: string): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the current branch name
|
|
84
|
+
*/
|
|
85
|
+
export declare function getCurrentBranch(projectRoot: string): Promise<string | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Get the remote URL
|
|
88
|
+
*/
|
|
89
|
+
export declare function getRemoteUrl(projectRoot: string): Promise<string | null>;
|
|
90
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/graph/collectors/git.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,E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