test-goose-setup.js•3.45 kB
#!/usr/bin/env node
import { spawn, exec } from 'child_process';
import { promisify } from 'util';
const execAsync = promisify(exec);
class GooseSetupTester {
async testGooseInstallation() {
console.log('🔍 Checking Goose CLI installation...');
try {
const { stdout } = await execAsync('goose --version');
console.log('✅ Goose CLI found:', stdout.trim());
return true;
} catch (error) {
console.log('❌ Goose CLI not found or not in PATH');
console.log(' Please install Goose CLI: https://github.com/block/goose');
return false;
}
}
async testAlphaFeatures() {
console.log('\n🧪 Testing alpha features environment...');
const alphaEnabled = process.env.ALPHA_FEATURES === 'true';
if (alphaEnabled) {
console.log('✅ ALPHA_FEATURES is enabled');
} else {
console.log('⚠️ ALPHA_FEATURES not set to "true"');
console.log(' Run: export ALPHA_FEATURES=true');
}
return alphaEnabled;
}
async testGooseSubagents() {
console.log('\n🤖 Testing Goose subagents capability...');
return new Promise((resolve) => {
// Set environment for subagents
const env = { ...process.env, ALPHA_FEATURES: 'true' };
const gooseProcess = spawn('goose', ['session', 'start'], {
stdio: ['pipe', 'pipe', 'pipe'],
env
});
let output = '';
let hasError = false;
gooseProcess.stdout.on('data', (data) => {
output += data.toString();
});
gooseProcess.stderr.on('data', (data) => {
const errorText = data.toString();
if (errorText.includes('subagent') || errorText.includes('alpha')) {
console.log('📝 Goose output:', errorText.trim());
}
});
// Send a simple test prompt
setTimeout(() => {
gooseProcess.stdin.write('Test subagent capabilities - just respond with "Hello from Goose"\n');
setTimeout(() => {
gooseProcess.kill();
if (output.length > 0) {
console.log('✅ Goose responded successfully');
console.log('📄 Sample output:', output.substring(0, 200) + '...');
} else {
console.log('⚠️ Goose started but no output captured');
}
resolve(!hasError);
}, 5000);
}, 2000);
gooseProcess.on('error', (error) => {
console.log('❌ Error starting Goose:', error.message);
hasError = true;
resolve(false);
});
});
}
async runSetupTests() {
console.log('🚀 Testing Goose CLI setup for MCP subagents...\n');
const gooseInstalled = await this.testGooseInstallation();
const alphaEnabled = await this.testAlphaFeatures();
if (gooseInstalled) {
await this.testGooseSubagents();
}
console.log('\n📊 Setup Test Summary:');
console.log('- Goose CLI:', gooseInstalled ? '✅ Installed' : '❌ Missing');
console.log('- Alpha Features:', alphaEnabled ? '✅ Enabled' : '⚠️ Disabled');
if (gooseInstalled && alphaEnabled) {
console.log('\n🎉 Setup looks good! MCP server should work properly.');
} else {
console.log('\n⚠️ Setup issues detected. Please resolve before using MCP server.');
}
}
}
// Run setup tests
const tester = new GooseSetupTester();
tester.runSetupTests().catch(console.error);