@aiready/visualizer 0.1.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/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # @aiready/visualizer
2
+
3
+ Interactive graph visualization for analysis results produced by `aiready-cli`.
4
+
5
+ ## Overview
6
+
7
+ This package provides tools to transform AIReady analysis results into interactive force-directed graph visualizations. It consists of:
8
+
9
+ - **Graph Builder**: Transforms analysis data into graph structures
10
+ - **CLI Tool**: Generates standalone HTML visualizations
11
+ - **Type Definitions**: Comprehensive TypeScript types for graph data
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @aiready/visualizer
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### As a Library
22
+
23
+ ```typescript
24
+ import { buildGraph, createSampleGraph } from '@aiready/visualizer';
25
+
26
+ // Build graph from analysis results
27
+ const graph = buildGraph(analysisResults);
28
+
29
+ // Or create a sample graph for testing
30
+ const sampleGraph = createSampleGraph();
31
+
32
+ console.log(`Graph has ${graph.nodes.length} nodes and ${graph.edges.length} edges`);
33
+ ```
34
+
35
+ ### As a CLI Tool
36
+
37
+ ```bash
38
+ # Generate a sample visualization
39
+ aiready-visualize sample -o visualization.html
40
+
41
+ # Generate from analysis results (Phase 4B)
42
+ aiready-visualize generate results.json -o visualization.html
43
+ ```
44
+
45
+ ## Data Structure
46
+
47
+ The visualizer uses a comprehensive graph data structure:
48
+
49
+ ```typescript
50
+ interface GraphData {
51
+ nodes: FileNode[]; // Files in the codebase
52
+ edges: DependencyEdge[]; // Import/dependency relationships
53
+ clusters: Cluster[]; // Domain/module groupings
54
+ issues: IssueOverlay[]; // Detected issues
55
+ metadata: GraphMetadata; // Aggregate information
56
+ }
57
+ ```
58
+
59
+ ### Node Properties
60
+
61
+ - **Metrics**: Lines of code, token cost, complexity
62
+ - **Issues**: Duplicates, inconsistencies count
63
+ - **Categorization**: Domain, module type
64
+ - **Visual**: Color, size, group
65
+
66
+ ### Edge Properties
67
+
68
+ - **Type**: import, require, dynamic
69
+ - **Weight**: Dependency strength
70
+ - **Visual**: Color, width, label
71
+
72
+ ## Development Status
73
+
74
+ **Phase 4A (Current)**: CLI package foundation
75
+ - ✅ Type definitions
76
+ - ✅ Graph builder with sample data
77
+ - ✅ Basic CLI structure
78
+ - ⏳ HTML generation (Phase 4B)
79
+
80
+ **Phase 4B (Next)**: Interactive frontend
81
+ - Vite + React setup
82
+ - ForceDirectedGraph integration
83
+ - Controls and filters
84
+ - Standalone HTML output
85
+
86
+ ## Architecture
87
+
88
+ This package follows the hub-and-spoke pattern:
89
+
90
+ - **Hub**: `@aiready/core` (HUB) and the public CLI `aiready-cli`
91
+ - **Spoke**: Independent repo at `aiready-visualizer`
92
+ - **Integration**: With `@aiready/components` for UI
93
+
94
+ ## Contributing
95
+
96
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
97
+
98
+ ## License
99
+
100
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+
4
+ // src/graph/builder.ts
5
+ function createSampleGraph() {
6
+ const nodes = [
7
+ {
8
+ id: "file1",
9
+ path: "src/components/Button.tsx",
10
+ label: "Button",
11
+ linesOfCode: 120,
12
+ tokenCost: 450,
13
+ domain: "components",
14
+ moduleType: "component",
15
+ color: "#3b82f6",
16
+ size: 15
17
+ },
18
+ {
19
+ id: "file2",
20
+ path: "src/utils/helpers.ts",
21
+ label: "helpers",
22
+ linesOfCode: 80,
23
+ tokenCost: 300,
24
+ domain: "utils",
25
+ moduleType: "util",
26
+ color: "#10b981",
27
+ size: 12
28
+ },
29
+ {
30
+ id: "file3",
31
+ path: "src/services/api.ts",
32
+ label: "api",
33
+ linesOfCode: 200,
34
+ tokenCost: 750,
35
+ domain: "services",
36
+ moduleType: "service",
37
+ color: "#f59e0b",
38
+ size: 18
39
+ }
40
+ ];
41
+ const edges = [
42
+ {
43
+ source: "file1",
44
+ target: "file2",
45
+ type: "import",
46
+ weight: 1
47
+ },
48
+ {
49
+ source: "file2",
50
+ target: "file3",
51
+ type: "import",
52
+ weight: 1
53
+ }
54
+ ];
55
+ const clusters = [
56
+ {
57
+ id: "cluster1",
58
+ name: "Components",
59
+ nodeIds: ["file1"],
60
+ color: "#3b82f6"
61
+ },
62
+ {
63
+ id: "cluster2",
64
+ name: "Utils",
65
+ nodeIds: ["file2"],
66
+ color: "#10b981"
67
+ },
68
+ {
69
+ id: "cluster3",
70
+ name: "Services",
71
+ nodeIds: ["file3"],
72
+ color: "#f59e0b"
73
+ }
74
+ ];
75
+ const issues = [
76
+ {
77
+ id: "issue1",
78
+ type: "high-cost",
79
+ severity: "minor",
80
+ nodeIds: ["file3"],
81
+ message: "High token cost detected",
82
+ details: "This file has a token cost of 750, consider refactoring"
83
+ }
84
+ ];
85
+ return {
86
+ nodes,
87
+ edges,
88
+ clusters,
89
+ issues,
90
+ metadata: {
91
+ projectName: "Sample Project",
92
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
93
+ totalFiles: nodes.length,
94
+ totalDependencies: edges.length,
95
+ analysisTypes: ["sample"],
96
+ totalLinesOfCode: 400,
97
+ totalTokenCost: 1500,
98
+ criticalIssues: 0,
99
+ majorIssues: 0,
100
+ minorIssues: 1,
101
+ infoIssues: 0
102
+ }
103
+ };
104
+ }
105
+
106
+ // src/cli/index.ts
107
+ var program = new Command();
108
+ program.name("aiready-visualize").description("Generate interactive visualizations from AIReady analysis results").version("0.1.0");
109
+ program.command("sample").description("Generate a sample visualization for testing").option("-o, --output <file>", "Output HTML file", "visualization.html").action((options) => {
110
+ console.log("Generating sample visualization...");
111
+ const graph = createSampleGraph();
112
+ console.log(`Graph data:`, JSON.stringify(graph, null, 2));
113
+ console.log(`
114
+ Sample graph created with ${graph.nodes.length} nodes and ${graph.edges.length} edges`);
115
+ console.log(`Output would be saved to: ${options.output}`);
116
+ console.log("\n\u26A0\uFE0F Full HTML generation will be implemented in Phase 4B");
117
+ });
118
+ program.command("generate").description("Generate visualization from analysis results").argument("<input>", "Input JSON file with analysis results").option("-o, --output <file>", "Output HTML file", "visualization.html").action((input, options) => {
119
+ console.log(`Input: ${input}`);
120
+ console.log(`Output: ${options.output}`);
121
+ console.log("\n\u26A0\uFE0F This command will be implemented in Phase 4B");
122
+ });
123
+ program.parse();
124
+ //# sourceMappingURL=cli.js.map
125
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graph/builder.ts","../src/cli/index.ts"],"names":[],"mappings":";;;;AA+CO,SAAS,iBAAA,GAA+B;AAC7C,EAAA,MAAM,KAAA,GAAoB;AAAA,IACxB;AAAA,MACE,EAAA,EAAI,OAAA;AAAA,MACJ,IAAA,EAAM,2BAAA;AAAA,MACN,KAAA,EAAO,QAAA;AAAA,MACP,WAAA,EAAa,GAAA;AAAA,MACb,SAAA,EAAW,GAAA;AAAA,MACX,MAAA,EAAQ,YAAA;AAAA,MACR,UAAA,EAAY,WAAA;AAAA,MACZ,KAAA,EAAO,SAAA;AAAA,MACP,IAAA,EAAM;AAAA,KACR;AAAA,IACA;AAAA,MACE,EAAA,EAAI,OAAA;AAAA,MACJ,IAAA,EAAM,sBAAA;AAAA,MACN,KAAA,EAAO,SAAA;AAAA,MACP,WAAA,EAAa,EAAA;AAAA,MACb,SAAA,EAAW,GAAA;AAAA,MACX,MAAA,EAAQ,OAAA;AAAA,MACR,UAAA,EAAY,MAAA;AAAA,MACZ,KAAA,EAAO,SAAA;AAAA,MACP,IAAA,EAAM;AAAA,KACR;AAAA,IACA;AAAA,MACE,EAAA,EAAI,OAAA;AAAA,MACJ,IAAA,EAAM,qBAAA;AAAA,MACN,KAAA,EAAO,KAAA;AAAA,MACP,WAAA,EAAa,GAAA;AAAA,MACb,SAAA,EAAW,GAAA;AAAA,MACX,MAAA,EAAQ,UAAA;AAAA,MACR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G,QAAQ,UAAU,CAAA,CAClB,YAAY,8CAA8C,CAAA,CAC1D,SAAS,SAAA,EAAW,uCAAuC,CAAA,CAC3D,MAAA,CAAO,uBAAuB,kBAAA,EAAoB,oBAAoB,EACtE,MAAA,CAAO,CAAC,OAAO,OAAA,KAAY;AAC1B,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,OAAA,EAAU,KAAK,CAAA,CAAE,CAAA;AAC7B,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,QAAA,EAAW,OAAA,CAAQ,MAAM,CAAA,CAAE,CAAA;AACvC,EAAA,OAAA,CAAQ,IAAI,8DAAoD,CAAA;AAClE,CAAC,CAAA;AAEH,OAAA,CAAQ,KAAA,EAAM","file":"cli.js","sourcesContent":["/**\n * Graph builder - transforms AIReady analysis results into graph data\n */\n\nimport type {\n GraphData,\n FileNode,\n DependencyEdge,\n Cluster,\n IssueOverlay,\n IssueSeverity,\n} from '../types';\n\n/**\n * Build graph data from AIReady analysis results\n * This is a placeholder that will be expanded to handle real analysis data\n */\nexport function buildGraph(analysisResults: any): GraphData {\n const nodes: FileNode[] = [];\n const edges: DependencyEdge[] = [];\n const clusters: Cluster[] = [];\n const issues: IssueOverlay[] = [];\n\n // TODO: Parse analysis results and build graph\n // For now, return empty graph structure\n \n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: [],\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 0,\n infoIssues: 0,\n },\n };\n}\n\n/**\n * Create a sample graph for testing\n */\nexport function createSampleGraph(): GraphData {\n const nodes: FileNode[] = [\n {\n id: 'file1',\n path: 'src/components/Button.tsx',\n label: 'Button',\n linesOfCode: 120,\n tokenCost: 450,\n domain: 'components',\n moduleType: 'component',\n color: '#3b82f6',\n size: 15,\n },\n {\n id: 'file2',\n path: 'src/utils/helpers.ts',\n label: 'helpers',\n linesOfCode: 80,\n tokenCost: 300,\n domain: 'utils',\n moduleType: 'util',\n color: '#10b981',\n size: 12,\n },\n {\n id: 'file3',\n path: 'src/services/api.ts',\n label: 'api',\n linesOfCode: 200,\n tokenCost: 750,\n domain: 'services',\n moduleType: 'service',\n color: '#f59e0b',\n size: 18,\n },\n ];\n\n const edges: DependencyEdge[] = [\n {\n source: 'file1',\n target: 'file2',\n type: 'import',\n weight: 1,\n },\n {\n source: 'file2',\n target: 'file3',\n type: 'import',\n weight: 1,\n },\n ];\n\n const clusters: Cluster[] = [\n {\n id: 'cluster1',\n name: 'Components',\n nodeIds: ['file1'],\n color: '#3b82f6',\n },\n {\n id: 'cluster2',\n name: 'Utils',\n nodeIds: ['file2'],\n color: '#10b981',\n },\n {\n id: 'cluster3',\n name: 'Services',\n nodeIds: ['file3'],\n color: '#f59e0b',\n },\n ];\n\n const issues: IssueOverlay[] = [\n {\n id: 'issue1',\n type: 'high-cost',\n severity: 'minor',\n nodeIds: ['file3'],\n message: 'High token cost detected',\n details: 'This file has a token cost of 750, consider refactoring',\n },\n ];\n\n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n projectName: 'Sample Project',\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: ['sample'],\n totalLinesOfCode: 400,\n totalTokenCost: 1500,\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 1,\n infoIssues: 0,\n },\n };\n}","#!/usr/bin/env node\n\n/**\n * CLI for AIReady Visualizer\n * Placeholder for now - will be expanded to generate HTML visualizations\n */\n\nimport { Command } from 'commander';\nimport { createSampleGraph } from '../graph/builder';\n\nconst program = new Command();\n\nprogram\n .name('aiready-visualize')\n .description('Generate interactive visualizations from AIReady analysis results')\n .version('0.1.0');\n\nprogram\n .command('sample')\n .description('Generate a sample visualization for testing')\n .option('-o, --output <file>', 'Output HTML file', 'visualization.html')\n .action((options) => {\n console.log('Generating sample visualization...');\n const graph = createSampleGraph();\n console.log(`Graph data:`, JSON.stringify(graph, null, 2));\n console.log(`\\nSample graph created with ${graph.nodes.length} nodes and ${graph.edges.length} edges`);\n console.log(`Output would be saved to: ${options.output}`);\n console.log('\\n⚠️ Full HTML generation will be implemented in Phase 4B');\n });\n\nprogram\n .command('generate')\n .description('Generate visualization from analysis results')\n .argument('<input>', 'Input JSON file with analysis results')\n .option('-o, --output <file>', 'Output HTML file', 'visualization.html')\n .action((input, options) => {\n console.log(`Input: ${input}`);\n console.log(`Output: ${options.output}`);\n console.log('\\n⚠️ This command will be implemented in Phase 4B');\n });\n\nprogram.parse();"]}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Core types for graph visualization
3
+ */
4
+ /**
5
+ * Severity levels for issues
6
+ */
7
+ type IssueSeverity = 'critical' | 'major' | 'minor' | 'info';
8
+ /**
9
+ * Base graph node (compatible with d3-force SimulationNodeDatum)
10
+ */
11
+ interface BaseGraphNode {
12
+ id: string;
13
+ x?: number;
14
+ y?: number;
15
+ vx?: number;
16
+ vy?: number;
17
+ fx?: number | null;
18
+ fy?: number | null;
19
+ }
20
+ /**
21
+ * Base graph link (compatible with d3-force SimulationLinkDatum)
22
+ */
23
+ interface BaseGraphLink {
24
+ source: string | BaseGraphNode;
25
+ target: string | BaseGraphNode;
26
+ index?: number;
27
+ }
28
+ /**
29
+ * File node in the dependency graph
30
+ */
31
+ interface FileNode extends BaseGraphNode {
32
+ id: string;
33
+ path: string;
34
+ label: string;
35
+ linesOfCode?: number;
36
+ tokenCost?: number;
37
+ complexity?: number;
38
+ duplicates?: number;
39
+ inconsistencies?: number;
40
+ domain?: string;
41
+ moduleType?: 'component' | 'util' | 'service' | 'config' | 'test' | 'other';
42
+ color?: string;
43
+ size?: number;
44
+ group?: string;
45
+ }
46
+ /**
47
+ * Dependency edge between files
48
+ */
49
+ interface DependencyEdge extends BaseGraphLink {
50
+ source: string | FileNode;
51
+ target: string | FileNode;
52
+ type?: 'import' | 'require' | 'dynamic';
53
+ weight?: number;
54
+ color?: string;
55
+ width?: number;
56
+ label?: string;
57
+ }
58
+ /**
59
+ * Domain or module cluster
60
+ */
61
+ interface Cluster {
62
+ id: string;
63
+ name: string;
64
+ nodeIds: string[];
65
+ color?: string;
66
+ description?: string;
67
+ }
68
+ /**
69
+ * Issue overlay on the graph
70
+ */
71
+ interface IssueOverlay {
72
+ id: string;
73
+ type: 'duplicate' | 'circular-dependency' | 'inconsistency' | 'high-cost' | 'complexity';
74
+ severity: IssueSeverity;
75
+ nodeIds: string[];
76
+ edgeIds?: string[];
77
+ message: string;
78
+ details?: string;
79
+ }
80
+ /**
81
+ * Complete graph data structure
82
+ */
83
+ interface GraphData {
84
+ nodes: FileNode[];
85
+ edges: DependencyEdge[];
86
+ clusters: Cluster[];
87
+ issues: IssueOverlay[];
88
+ metadata: GraphMetadata;
89
+ }
90
+ /**
91
+ * Metadata about the graph
92
+ */
93
+ interface GraphMetadata {
94
+ projectName?: string;
95
+ timestamp: string;
96
+ totalFiles: number;
97
+ totalDependencies: number;
98
+ analysisTypes: string[];
99
+ totalLinesOfCode?: number;
100
+ totalTokenCost?: number;
101
+ averageComplexity?: number;
102
+ criticalIssues: number;
103
+ majorIssues: number;
104
+ minorIssues: number;
105
+ infoIssues: number;
106
+ }
107
+ /**
108
+ * Filter options for the visualization
109
+ */
110
+ interface FilterOptions {
111
+ severities?: IssueSeverity[];
112
+ issueTypes?: IssueOverlay['type'][];
113
+ domains?: string[];
114
+ moduleTypes?: FileNode['moduleType'][];
115
+ minTokenCost?: number;
116
+ maxTokenCost?: number;
117
+ showOnlyIssues?: boolean;
118
+ }
119
+ /**
120
+ * Layout configuration
121
+ */
122
+ interface LayoutConfig {
123
+ type: 'force' | 'hierarchical' | 'circular' | 'radial';
124
+ chargeStrength?: number;
125
+ linkDistance?: number;
126
+ collisionRadius?: number;
127
+ }
128
+ /**
129
+ * Visualization configuration
130
+ */
131
+ interface VisualizationConfig {
132
+ layout: LayoutConfig;
133
+ filters: FilterOptions;
134
+ colorBy: 'severity' | 'domain' | 'moduleType' | 'tokenCost';
135
+ sizeBy: 'tokenCost' | 'loc' | 'complexity' | 'duplicates';
136
+ showLabels: boolean;
137
+ showClusters: boolean;
138
+ }
139
+
140
+ /**
141
+ * Graph builder - transforms AIReady analysis results into graph data
142
+ */
143
+
144
+ /**
145
+ * Build graph data from AIReady analysis results
146
+ * This is a placeholder that will be expanded to handle real analysis data
147
+ */
148
+ declare function buildGraph(analysisResults: any): GraphData;
149
+ /**
150
+ * Create a sample graph for testing
151
+ */
152
+ declare function createSampleGraph(): GraphData;
153
+
154
+ export { type BaseGraphLink, type BaseGraphNode, type Cluster, type DependencyEdge, type FileNode, type FilterOptions, type GraphData, type GraphMetadata, type IssueOverlay, type IssueSeverity, type LayoutConfig, type VisualizationConfig, buildGraph, createSampleGraph };
@@ -0,0 +1,127 @@
1
+ // src/graph/builder.ts
2
+ function buildGraph(analysisResults) {
3
+ const nodes = [];
4
+ const edges = [];
5
+ const clusters = [];
6
+ const issues = [];
7
+ return {
8
+ nodes,
9
+ edges,
10
+ clusters,
11
+ issues,
12
+ metadata: {
13
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
14
+ totalFiles: nodes.length,
15
+ totalDependencies: edges.length,
16
+ analysisTypes: [],
17
+ criticalIssues: 0,
18
+ majorIssues: 0,
19
+ minorIssues: 0,
20
+ infoIssues: 0
21
+ }
22
+ };
23
+ }
24
+ function createSampleGraph() {
25
+ const nodes = [
26
+ {
27
+ id: "file1",
28
+ path: "src/components/Button.tsx",
29
+ label: "Button",
30
+ linesOfCode: 120,
31
+ tokenCost: 450,
32
+ domain: "components",
33
+ moduleType: "component",
34
+ color: "#3b82f6",
35
+ size: 15
36
+ },
37
+ {
38
+ id: "file2",
39
+ path: "src/utils/helpers.ts",
40
+ label: "helpers",
41
+ linesOfCode: 80,
42
+ tokenCost: 300,
43
+ domain: "utils",
44
+ moduleType: "util",
45
+ color: "#10b981",
46
+ size: 12
47
+ },
48
+ {
49
+ id: "file3",
50
+ path: "src/services/api.ts",
51
+ label: "api",
52
+ linesOfCode: 200,
53
+ tokenCost: 750,
54
+ domain: "services",
55
+ moduleType: "service",
56
+ color: "#f59e0b",
57
+ size: 18
58
+ }
59
+ ];
60
+ const edges = [
61
+ {
62
+ source: "file1",
63
+ target: "file2",
64
+ type: "import",
65
+ weight: 1
66
+ },
67
+ {
68
+ source: "file2",
69
+ target: "file3",
70
+ type: "import",
71
+ weight: 1
72
+ }
73
+ ];
74
+ const clusters = [
75
+ {
76
+ id: "cluster1",
77
+ name: "Components",
78
+ nodeIds: ["file1"],
79
+ color: "#3b82f6"
80
+ },
81
+ {
82
+ id: "cluster2",
83
+ name: "Utils",
84
+ nodeIds: ["file2"],
85
+ color: "#10b981"
86
+ },
87
+ {
88
+ id: "cluster3",
89
+ name: "Services",
90
+ nodeIds: ["file3"],
91
+ color: "#f59e0b"
92
+ }
93
+ ];
94
+ const issues = [
95
+ {
96
+ id: "issue1",
97
+ type: "high-cost",
98
+ severity: "minor",
99
+ nodeIds: ["file3"],
100
+ message: "High token cost detected",
101
+ details: "This file has a token cost of 750, consider refactoring"
102
+ }
103
+ ];
104
+ return {
105
+ nodes,
106
+ edges,
107
+ clusters,
108
+ issues,
109
+ metadata: {
110
+ projectName: "Sample Project",
111
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
112
+ totalFiles: nodes.length,
113
+ totalDependencies: edges.length,
114
+ analysisTypes: ["sample"],
115
+ totalLinesOfCode: 400,
116
+ totalTokenCost: 1500,
117
+ criticalIssues: 0,
118
+ majorIssues: 0,
119
+ minorIssues: 1,
120
+ infoIssues: 0
121
+ }
122
+ };
123
+ }
124
+
125
+ export { buildGraph, createSampleGraph };
126
+ //# sourceMappingURL=index.js.map
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/graph/builder.ts"],"names":[],"mappings":";AAiBO,SAAS,WAAW,eAAA,EAAiC;AAC1D,EAAA,MAAM,QAAoB,EAAC;AAC3B,EAAA,MAAM,QAA0B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AAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU;AAAA,MACR,WAAA,EAAa,gBAAA;AAAA,MACb,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,MAClC,YAAY,KAAA,CAAM,MAAA;AAAA,MAClB,mBAAmB,KAAA,CAAM,MAAA;AAAA,MACzB,aAAA,EAAe,CAAC,QAAQ,CAAA;AAAA,MACxB,gBAAA,EAAkB,GAAA;AAAA,MAClB,cAAA,EAAgB,IAAA;AAAA,MAChB,cAAA,EAAgB,CAAA;AAAA,MAChB,WAAA,EAAa,CAAA;AAAA,MACb,WAAA,EAAa,CAAA;AAAA,MACb,UAAA,EAAY;AAAA;AACd,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Graph builder - transforms AIReady analysis results into graph data\n */\n\nimport type {\n GraphData,\n FileNode,\n DependencyEdge,\n Cluster,\n IssueOverlay,\n IssueSeverity,\n} from '../types';\n\n/**\n * Build graph data from AIReady analysis results\n * This is a placeholder that will be expanded to handle real analysis data\n */\nexport function buildGraph(analysisResults: any): GraphData {\n const nodes: FileNode[] = [];\n const edges: DependencyEdge[] = [];\n const clusters: Cluster[] = [];\n const issues: IssueOverlay[] = [];\n\n // TODO: Parse analysis results and build graph\n // For now, return empty graph structure\n \n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: [],\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 0,\n infoIssues: 0,\n },\n };\n}\n\n/**\n * Create a sample graph for testing\n */\nexport function createSampleGraph(): GraphData {\n const nodes: FileNode[] = [\n {\n id: 'file1',\n path: 'src/components/Button.tsx',\n label: 'Button',\n linesOfCode: 120,\n tokenCost: 450,\n domain: 'components',\n moduleType: 'component',\n color: '#3b82f6',\n size: 15,\n },\n {\n id: 'file2',\n path: 'src/utils/helpers.ts',\n label: 'helpers',\n linesOfCode: 80,\n tokenCost: 300,\n domain: 'utils',\n moduleType: 'util',\n color: '#10b981',\n size: 12,\n },\n {\n id: 'file3',\n path: 'src/services/api.ts',\n label: 'api',\n linesOfCode: 200,\n tokenCost: 750,\n domain: 'services',\n moduleType: 'service',\n color: '#f59e0b',\n size: 18,\n },\n ];\n\n const edges: DependencyEdge[] = [\n {\n source: 'file1',\n target: 'file2',\n type: 'import',\n weight: 1,\n },\n {\n source: 'file2',\n target: 'file3',\n type: 'import',\n weight: 1,\n },\n ];\n\n const clusters: Cluster[] = [\n {\n id: 'cluster1',\n name: 'Components',\n nodeIds: ['file1'],\n color: '#3b82f6',\n },\n {\n id: 'cluster2',\n name: 'Utils',\n nodeIds: ['file2'],\n color: '#10b981',\n },\n {\n id: 'cluster3',\n name: 'Services',\n nodeIds: ['file3'],\n color: '#f59e0b',\n },\n ];\n\n const issues: IssueOverlay[] = [\n {\n id: 'issue1',\n type: 'high-cost',\n severity: 'minor',\n nodeIds: ['file3'],\n message: 'High token cost detected',\n details: 'This file has a token cost of 750, consider refactoring',\n },\n ];\n\n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n projectName: 'Sample Project',\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: ['sample'],\n totalLinesOfCode: 400,\n totalTokenCost: 1500,\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 1,\n infoIssues: 0,\n },\n };\n}"]}
@@ -0,0 +1 @@
1
+ export { BaseGraphLink, BaseGraphNode, Cluster, DependencyEdge, FileNode, FilterOptions, GraphData, GraphMetadata, IssueOverlay, IssueSeverity, LayoutConfig, VisualizationConfig, buildGraph, createSampleGraph } from './graph/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,127 @@
1
+ // src/graph/builder.ts
2
+ function buildGraph(analysisResults) {
3
+ const nodes = [];
4
+ const edges = [];
5
+ const clusters = [];
6
+ const issues = [];
7
+ return {
8
+ nodes,
9
+ edges,
10
+ clusters,
11
+ issues,
12
+ metadata: {
13
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
14
+ totalFiles: nodes.length,
15
+ totalDependencies: edges.length,
16
+ analysisTypes: [],
17
+ criticalIssues: 0,
18
+ majorIssues: 0,
19
+ minorIssues: 0,
20
+ infoIssues: 0
21
+ }
22
+ };
23
+ }
24
+ function createSampleGraph() {
25
+ const nodes = [
26
+ {
27
+ id: "file1",
28
+ path: "src/components/Button.tsx",
29
+ label: "Button",
30
+ linesOfCode: 120,
31
+ tokenCost: 450,
32
+ domain: "components",
33
+ moduleType: "component",
34
+ color: "#3b82f6",
35
+ size: 15
36
+ },
37
+ {
38
+ id: "file2",
39
+ path: "src/utils/helpers.ts",
40
+ label: "helpers",
41
+ linesOfCode: 80,
42
+ tokenCost: 300,
43
+ domain: "utils",
44
+ moduleType: "util",
45
+ color: "#10b981",
46
+ size: 12
47
+ },
48
+ {
49
+ id: "file3",
50
+ path: "src/services/api.ts",
51
+ label: "api",
52
+ linesOfCode: 200,
53
+ tokenCost: 750,
54
+ domain: "services",
55
+ moduleType: "service",
56
+ color: "#f59e0b",
57
+ size: 18
58
+ }
59
+ ];
60
+ const edges = [
61
+ {
62
+ source: "file1",
63
+ target: "file2",
64
+ type: "import",
65
+ weight: 1
66
+ },
67
+ {
68
+ source: "file2",
69
+ target: "file3",
70
+ type: "import",
71
+ weight: 1
72
+ }
73
+ ];
74
+ const clusters = [
75
+ {
76
+ id: "cluster1",
77
+ name: "Components",
78
+ nodeIds: ["file1"],
79
+ color: "#3b82f6"
80
+ },
81
+ {
82
+ id: "cluster2",
83
+ name: "Utils",
84
+ nodeIds: ["file2"],
85
+ color: "#10b981"
86
+ },
87
+ {
88
+ id: "cluster3",
89
+ name: "Services",
90
+ nodeIds: ["file3"],
91
+ color: "#f59e0b"
92
+ }
93
+ ];
94
+ const issues = [
95
+ {
96
+ id: "issue1",
97
+ type: "high-cost",
98
+ severity: "minor",
99
+ nodeIds: ["file3"],
100
+ message: "High token cost detected",
101
+ details: "This file has a token cost of 750, consider refactoring"
102
+ }
103
+ ];
104
+ return {
105
+ nodes,
106
+ edges,
107
+ clusters,
108
+ issues,
109
+ metadata: {
110
+ projectName: "Sample Project",
111
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
112
+ totalFiles: nodes.length,
113
+ totalDependencies: edges.length,
114
+ analysisTypes: ["sample"],
115
+ totalLinesOfCode: 400,
116
+ totalTokenCost: 1500,
117
+ criticalIssues: 0,
118
+ majorIssues: 0,
119
+ minorIssues: 1,
120
+ infoIssues: 0
121
+ }
122
+ };
123
+ }
124
+
125
+ export { buildGraph, createSampleGraph };
126
+ //# sourceMappingURL=index.js.map
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graph/builder.ts"],"names":[],"mappings":";AAiBO,SAAS,WAAW,eAAA,EAAiC;AAC1D,EAAA,MAAM,QAAoB,EAAC;AAC3B,EAAA,MAAM,QAA0B,EAAC;AACjC,EAAA,MAAM,WAAsB,EAAC;AAC7B,EAAA,MAAM,SAAyB,EAAC;AAKhC,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU;AAAA,MACR,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,MAClC,YAAY,KAAA,CAAM,MAAA;AAAA,MAClB,mBAAmB,KAAA,CAAM,MAAA;AAAA,MACzB,eAAe,EAAC;AAAA,MAChB,cAAA,EAAgB,CAAA;AAAA,MAChB,WAAA,EAAa,CAAA;AAAA,MACb,WAAA,EAAa,CAAA;AAAA,MACb,UAAA,EAAY;AAAA;AACd,GACF;AACF;AAKO,SAAS,iBAAA,GAA+B;AAC7C,EAAA,MAAM,KAAA,GAAoB;AAAA,IACxB;AAAA,MACE,EAAA,EAAI,OAAA;AAAA,MACJ,IAAA,EAAM,2BAAA;AAAA,MACN,KAAA,EAAO,QA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KACT;AAAA,IACA;AAAA,MACE,EAAA,EAAI,UAAA;AAAA,MACJ,IAAA,EAAM,OAAA;AAAA,MACN,OAAA,EAAS,CAAC,OAAO,CAAA;AAAA,MACjB,KAAA,EAAO;AAAA,KACT;AAAA,IACA;AAAA,MACE,EAAA,EAAI,UAAA;AAAA,MACJ,IAAA,EAAM,UAAA;AAAA,MACN,OAAA,EAAS,CAAC,OAAO,CAAA;AAAA,MACjB,KAAA,EAAO;AAAA;AACT,GACF;AAEA,EAAA,MAAM,MAAA,GAAyB;AAAA,IAC7B;AAAA,MACE,EAAA,EAAI,QAAA;AAAA,MACJ,IAAA,EAAM,WAAA;AAAA,MACN,QAAA,EAAU,OAAA;AAAA,MACV,OAAA,EAAS,CAAC,OAAO,CAAA;AAAA,MACjB,OAAA,EAAS,0BAAA;AAAA,MACT,OAAA,EAAS;AAAA;AACX,GACF;AAEA,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,EAAU;AAAA,MACR,WAAA,EAAa,gBAAA;AAAA,MACb,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAAA,MAClC,YAAY,KAAA,CAAM,MAAA;AAAA,MAClB,mBAAmB,KAAA,CAAM,MAAA;AAAA,MACzB,aAAA,EAAe,CAAC,QAAQ,CAAA;AAAA,MACxB,gBAAA,EAAkB,GAAA;AAAA,MAClB,cAAA,EAAgB,IAAA;AAAA,MAChB,cAAA,EAAgB,CAAA;AAAA,MAChB,WAAA,EAAa,CAAA;AAAA,MACb,WAAA,EAAa,CAAA;AAAA,MACb,UAAA,EAAY;AAAA;AACd,GACF;AACF","file":"index.js","sourcesContent":["/**\n * Graph builder - transforms AIReady analysis results into graph data\n */\n\nimport type {\n GraphData,\n FileNode,\n DependencyEdge,\n Cluster,\n IssueOverlay,\n IssueSeverity,\n} from '../types';\n\n/**\n * Build graph data from AIReady analysis results\n * This is a placeholder that will be expanded to handle real analysis data\n */\nexport function buildGraph(analysisResults: any): GraphData {\n const nodes: FileNode[] = [];\n const edges: DependencyEdge[] = [];\n const clusters: Cluster[] = [];\n const issues: IssueOverlay[] = [];\n\n // TODO: Parse analysis results and build graph\n // For now, return empty graph structure\n \n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: [],\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 0,\n infoIssues: 0,\n },\n };\n}\n\n/**\n * Create a sample graph for testing\n */\nexport function createSampleGraph(): GraphData {\n const nodes: FileNode[] = [\n {\n id: 'file1',\n path: 'src/components/Button.tsx',\n label: 'Button',\n linesOfCode: 120,\n tokenCost: 450,\n domain: 'components',\n moduleType: 'component',\n color: '#3b82f6',\n size: 15,\n },\n {\n id: 'file2',\n path: 'src/utils/helpers.ts',\n label: 'helpers',\n linesOfCode: 80,\n tokenCost: 300,\n domain: 'utils',\n moduleType: 'util',\n color: '#10b981',\n size: 12,\n },\n {\n id: 'file3',\n path: 'src/services/api.ts',\n label: 'api',\n linesOfCode: 200,\n tokenCost: 750,\n domain: 'services',\n moduleType: 'service',\n color: '#f59e0b',\n size: 18,\n },\n ];\n\n const edges: DependencyEdge[] = [\n {\n source: 'file1',\n target: 'file2',\n type: 'import',\n weight: 1,\n },\n {\n source: 'file2',\n target: 'file3',\n type: 'import',\n weight: 1,\n },\n ];\n\n const clusters: Cluster[] = [\n {\n id: 'cluster1',\n name: 'Components',\n nodeIds: ['file1'],\n color: '#3b82f6',\n },\n {\n id: 'cluster2',\n name: 'Utils',\n nodeIds: ['file2'],\n color: '#10b981',\n },\n {\n id: 'cluster3',\n name: 'Services',\n nodeIds: ['file3'],\n color: '#f59e0b',\n },\n ];\n\n const issues: IssueOverlay[] = [\n {\n id: 'issue1',\n type: 'high-cost',\n severity: 'minor',\n nodeIds: ['file3'],\n message: 'High token cost detected',\n details: 'This file has a token cost of 750, consider refactoring',\n },\n ];\n\n return {\n nodes,\n edges,\n clusters,\n issues,\n metadata: {\n projectName: 'Sample Project',\n timestamp: new Date().toISOString(),\n totalFiles: nodes.length,\n totalDependencies: edges.length,\n analysisTypes: ['sample'],\n totalLinesOfCode: 400,\n totalTokenCost: 1500,\n criticalIssues: 0,\n majorIssues: 0,\n minorIssues: 1,\n infoIssues: 0,\n },\n };\n}"]}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@aiready/visualizer",
3
+ "version": "0.1.0",
4
+ "description": "Interactive graph visualization for AIReady analysis results",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "aiready-visualize": "./dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "./graph": {
17
+ "import": "./dist/graph/index.js",
18
+ "types": "./dist/graph/index.d.ts"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "web/dist"
24
+ ],
25
+ "keywords": [
26
+ "aiready",
27
+ "visualization",
28
+ "graph",
29
+ "d3",
30
+ "dependency-graph"
31
+ ],
32
+ "author": "Peng Cao <caopengau@gmail.com>",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/caopengau/aiready-visualizer.git"
37
+ },
38
+ "dependencies": {
39
+ "commander": "^13.0.0",
40
+ "@aiready/core": "0.9.1"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.10.5",
44
+ "tsup": "^8.3.5",
45
+ "typescript": "^5.7.2",
46
+ "vitest": "^2.1.8"
47
+ },
48
+ "scripts": {
49
+ "dev": "tsup --watch",
50
+ "dev:web": "cd web && vite",
51
+ "build": "tsup && cd web && vite build",
52
+ "build:cli": "tsup",
53
+ "build:web": "cd web && vite build",
54
+ "typecheck": "tsc --noEmit && cd web && tsc --noEmit",
55
+ "test": "vitest"
56
+ }
57
+ }