test-final-comparison.jsโข5.96 kB
const { spawn } = require('child_process');
const path = require('path');
/**
* Final comparison test showing the difference between minimal and detailed modes
*/
async function testFinalComparison() {
console.log('๐ฏ FINAL COMPARISON: Minimal vs Detailed Modes\n');
const serverPath = path.join(__dirname, '..', 'dist', 'index.js');
console.log('๐งช Testing CL_BUS_ABSTRACT_MAIN_SCREEN class...\n');
// Test minimal mode
console.log('๐ MINIMAL MODE (detailed=false):');
const minimalResult = await callMcpTool(serverPath, {
method: 'tools/call',
params: {
name: 'GetWhereUsed',
arguments: {
object_name: 'CL_BUS_ABSTRACT_MAIN_SCREEN',
object_type: 'class',
detailed: false
}
}
});
if (!minimalResult.error) {
const minimalResponse = JSON.parse(minimalResult.content[0].text);
console.log(` โ
Found: ${minimalResponse.total_found}, Showing: ${minimalResponse.total_references}, Filtered: ${minimalResponse.filtered_out}`);
console.log(` ๐ฏ Key findings:`);
minimalResponse.references.slice(0, 5).forEach((ref, i) => {
console.log(` ${i + 1}. ${ref.name} (${ref.type}) ${ref.isResult ? 'โญ' : ''}`);
});
} else {
console.log(` โ Error:`, minimalResult.error);
}
console.log('');
// Test detailed mode
console.log('๐ DETAILED MODE (detailed=true):');
const detailedResult = await callMcpTool(serverPath, {
method: 'tools/call',
params: {
name: 'GetWhereUsed',
arguments: {
object_name: 'CL_BUS_ABSTRACT_MAIN_SCREEN',
object_type: 'class',
detailed: true
}
}
});
if (!detailedResult.error) {
const detailedResponse = JSON.parse(detailedResult.content[0].text);
console.log(` โ
Found: ${detailedResponse.total_found}, Showing: ${detailedResponse.total_references}, Filtered: ${detailedResponse.filtered_out}`);
console.log(` ๐ All references (first 10):`);
detailedResponse.references.slice(0, 10).forEach((ref, i) => {
const usage = ref.usageInformation || 'no usage info';
console.log(` ${i + 1}. ${ref.name} (${ref.type}) - ${usage} ${ref.isResult ? 'โญ' : ''}`);
});
if (detailedResponse.references.length > 10) {
console.log(` ... and ${detailedResponse.references.length - 10} more`);
}
} else {
console.log(` โ Error:`, detailedResult.error);
}
console.log('\n๐ฏ SUMMARY:');
if (!minimalResult.error && !detailedResult.error) {
const minimalResponse = JSON.parse(minimalResult.content[0].text);
const detailedResponse = JSON.parse(detailedResult.content[0].text);
console.log(` ๐ Minimal mode: Shows ${minimalResponse.total_references}/${minimalResponse.total_found} most relevant results`);
console.log(` ๐ Detailed mode: Shows ${detailedResponse.total_references}/${detailedResponse.total_found} all results`);
console.log(` ๐ฏ Filtering efficiency: ${Math.round((minimalResponse.filtered_out / minimalResponse.total_found) * 100)}% noise reduction`);
console.log('\n ๐ What gets filtered out in minimal mode:');
console.log(' โ Class internal sections (Public/Private/Protected Section)');
console.log(' โ Internal class methods and attributes');
console.log(' โ Package references (organizational structure)');
console.log(' โ Function groups (shows only specific functions)');
console.log(' โ Programs/includes without direct usage');
console.log('\n โ
What stays in minimal mode:');
console.log(' โญ Enhancement implementations (ENHO/XHH)');
console.log(' โญ Main results marked as important');
console.log(' โญ Function modules with direct usage');
}
}
/**
* Call MCP tool via stdio
*/
function callMcpTool(serverPath, request) {
return new Promise((resolve, reject) => {
const child = spawn('node', [serverPath], {
stdio: ['pipe', 'pipe', 'pipe']
});
let stdout = '';
let stderr = '';
child.stdout.on('data', (data) => {
stdout += data.toString();
});
child.stderr.on('data', (data) => {
stderr += data.toString();
});
child.on('close', (code) => {
if (code !== 0) {
reject(new Error(`Process exited with code ${code}. Stderr: ${stderr}`));
return;
}
try {
const lines = stdout.trim().split('\n');
let result = null;
for (const line of lines) {
try {
const parsed = JSON.parse(line);
if (parsed.result) {
result = parsed.result;
break;
}
} catch (e) {
// Skip non-JSON lines
}
}
if (result) {
resolve(result);
} else {
reject(new Error('No valid result found in output'));
}
} catch (error) {
reject(new Error(`Failed to parse output: ${error.message}`));
}
});
const jsonRpcRequest = {
jsonrpc: '2.0',
id: 1,
...request
};
child.stdin.write(JSON.stringify(jsonRpcRequest) + '\n');
child.stdin.end();
});
}
// Run the test
testFinalComparison().catch(console.error);