forked from anthropics/claude-code
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-clustering.js
More file actions
63 lines (47 loc) · 1.96 KB
/
Copy pathtest-clustering.js
File metadata and controls
63 lines (47 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
import { GraphService } from './src/graph/GraphService.js';
async function testClustering() {
console.log('🔄 Testing clustering manually...');
const rootPath = '/home/riley/Programming/open_spiel/open_spiel';
console.log('🔧 First rebuilding the graph with fixed parser...');
// Run the build script manually to fix corrupted JSON
const { spawn } = await import('child_process');
const buildScript = '/home/riley/Programming/ccg/tools/codegraph.sh';
await new Promise((resolve, reject) => {
const child = spawn('bash', [buildScript], {
cwd: rootPath,
stdio: 'inherit'
});
child.on('close', (code) => {
if (code === 0) resolve();
else reject(new Error(`Build failed with code ${code}`));
});
});
console.log('✅ Graph rebuilt');
const graphService = new GraphService(rootPath);
try {
console.log('1. Initializing GraphService...');
const initialized = await graphService.initialize();
if (!initialized) {
console.log('❌ Failed to initialize GraphService');
return;
}
console.log('✅ GraphService initialized');
// Force super-graph generation
console.log('2. Generating super-graph...');
const combinedData = await graphService.getCombinedGraphData();
console.log(` Combined data: ${combinedData.nodes.length} nodes, ${combinedData.edges.length} edges`);
if (combinedData.nodes.length > 0) {
const superGraph = await graphService.clustering.generateSuperGraph(combinedData);
console.log('✅ Super-graph generated successfully');
console.log(` Clusters: ${Object.keys(superGraph.clusters).length}`);
console.log(` Compression: ${superGraph.metadata.compressionRatio}:1`);
} else {
console.log('❌ No data available for clustering');
}
} catch (error) {
console.error('❌ Error:', error.message);
console.error(error.stack);
}
}
testClustering();