#!/usr/bin/env node
/**
* Test the saptiva_help tool
*/
import { spawn } from 'child_process';
import { config } from 'dotenv';
config();
const server = spawn('node', ['dist/index.js'], {
env: { ...process.env },
stdio: ['pipe', 'pipe', 'pipe']
});
const topics = [
'quick_start',
'chat_example',
'similarity_example',
'all_tools',
'curl_examples'
];
let currentTest = 0;
let buffer = '';
function sendNextTest() {
if (currentTest >= topics.length) {
console.log('\n✅ All help topics tested successfully!');
server.kill();
process.exit(0);
return;
}
const topic = topics[currentTest];
console.log(`\n${'─'.repeat(60)}`);
console.log(`Testing help topic: ${topic}`);
console.log('─'.repeat(60));
buffer = '';
const request = {
jsonrpc: '2.0',
id: currentTest + 1,
method: 'tools/call',
params: {
name: 'saptiva_help',
arguments: { topic }
}
};
server.stdin.write(JSON.stringify(request) + '\n');
}
server.stdout.on('data', (data) => {
buffer += data.toString();
try {
const response = JSON.parse(buffer);
if (response.error) {
console.log('❌ Error:', response.error.message);
} else if (response.result) {
const content = response.result.content?.[0]?.text;
if (response.result.isError) {
console.log('❌ Tool Error:', content?.substring(0, 200));
} else {
console.log('✅ Success!');
// Show first 500 chars of help content
console.log(content?.substring(0, 500) + '...');
}
}
currentTest++;
setTimeout(sendNextTest, 300);
} catch {
// Incomplete JSON
}
});
server.stderr.on('data', (data) => {
const msg = data.toString().trim();
if (msg && !msg.includes('running on stdio') && !msg.includes('injecting')) {
console.error('Server:', msg);
}
});
console.log('='.repeat(60));
console.log('Testing saptiva_help tool');
console.log('='.repeat(60));
setTimeout(sendNextTest, 1000);
setTimeout(() => {
console.log('Timeout');
server.kill();
process.exit(1);
}, 60000);