-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest-analysis.js
More file actions
94 lines (81 loc) · 2.45 KB
/
test-analysis.js
File metadata and controls
94 lines (81 loc) · 2.45 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env node
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('Testing Gemini Analysis...\n');
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: __dirname
});
// Wait for server to start
await new Promise(resolve => setTimeout(resolve, 1000));
// Test with a simple performance analysis
const exampleFile = join(__dirname, 'examples', 'performance-issue.ts');
const request = {
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'performance_bottleneck',
arguments: {
code_path: {
entry_point: {
file: exampleFile,
line: 15,
function_name: 'getOrdersWithDetails'
},
suspected_issues: ['N+1 queries', 'memory leak']
},
profile_depth: 3
}
}
};
console.log('Sending performance analysis request...\n');
server.stdin.write(JSON.stringify(request) + '\n');
// Handle response
let responseBuffer = '';
let responseReceived = false;
server.stdout.on('data', (data) => {
responseBuffer += data.toString();
// Try to parse complete JSON responses
const lines = responseBuffer.split('\n');
for (let i = 0; i < lines.length - 1; i++) {
const line = lines[i].trim();
if (line) {
try {
const response = JSON.parse(line);
if (response.id === 1) {
responseReceived = true;
console.log('=== GEMINI ANALYSIS RESULT ===\n');
if (response.result?.content?.[0]?.text) {
const result = JSON.parse(response.result.content[0].text);
console.log('Analysis:', result.analysis);
console.log('\nFiles analyzed:', result.filesAnalyzed);
} else if (response.error) {
console.error('Error:', response.error.message);
}
}
} catch (e) {
// Not complete JSON yet
}
}
}
responseBuffer = lines[lines.length - 1];
});
server.stderr.on('data', (data) => {
const message = data.toString();
if (!message.includes('Deep Code Reasoning MCP server')) {
console.error('Server log:', message);
}
});
// Wait for response or timeout
setTimeout(() => {
if (!responseReceived) {
console.log('\nNo response received within timeout.');
}
console.log('\nShutting down...');
server.kill();
process.exit(0);
}, 15000);