test-claudio-integration.jsā¢6.89 kB
#!/usr/bin/env node
/**
* Test script for Claudio Integration
*/
import { ClaudioMCPLearningTools } from './integrations/claudio-mcp-tools.js';
async function testClaudioIntegration() {
console.log('š¤ Testing Claudio Integration...\n');
const tools = new ClaudioMCPLearningTools();
try {
// Test initialization
console.log('1. Testing initialization...');
await tools.initialize();
console.log(' ā
Claudio MCP Learning Tools initialized\n');
// Test tool definitions
console.log('2. Testing tool definitions...');
const toolDefinitions = tools.getToolDefinitions();
console.log(` ā
Found ${toolDefinitions.length} MCP tools:`);
toolDefinitions.forEach((tool, index) => {
console.log(` ${index + 1}. ${tool.name} - ${tool.description.substring(0, 50)}...`);
});
console.log();
// Test learn_from_interaction tool
console.log('3. Testing learn_from_interaction...');
const interactionArgs = {
agent_id: 'test-agent',
workflow_id: 'test-workflow-001',
input: 'Create a new React component',
output: 'Created HelloWorld component with TypeScript support',
success: true,
duration: 1500,
metadata: {
tool_used: 'create_component',
language: 'typescript',
framework: 'react'
}
};
const interactionResult = await tools.handleToolCall('learn_from_interaction', interactionArgs);
console.log(` ā
Pattern learned: ${interactionResult.pattern_id?.substring(0, 8)}...`);
console.log(` š§ Learning impact: ${interactionResult.learning_impact || 'positive'}`);
console.log(` š” Recommendations: ${interactionResult.recommendations?.length || 0}\n`);
// Test get_learning_insights tool
console.log('4. Testing get_learning_insights...');
const insightsResult = await tools.handleToolCall('get_learning_insights', {
workflow_id: 'test-workflow-001'
});
console.log(` ā
Insights retrieved: ${insightsResult.success}`);
console.log(` š Total patterns: ${insightsResult.summary?.total_patterns || 0}`);
console.log(` š¤ Claudio interactions: ${insightsResult.summary?.claudio_interactions || 0}`);
console.log(` ā” Workflow efficiency: ${insightsResult.summary?.workflow_efficiency || 0}\n`);
// Test optimize_workflow tool
console.log('5. Testing optimize_workflow...');
const optimizeArgs = {
workflow_id: 'test-workflow-001',
involved_agents: ['test-agent', 'code-generator', 'file-manager'],
current_step: 'component_creation',
performance: {
averageTime: 2000,
successRate: 0.95,
errorRate: 0.05
}
};
const optimizeResult = await tools.handleToolCall('optimize_workflow', optimizeArgs);
console.log(` ā
Optimizations generated: ${optimizeResult.success}`);
console.log(` šÆ Optimization count: ${optimizeResult.optimizations?.length || 0}`);
console.log(` š Confidence: ${optimizeResult.confidence || 'N/A'}`);
if (optimizeResult.implementation_guide) {
console.log(` š Implementation priority: ${optimizeResult.implementation_guide.priority?.length || 0} items`);
}
console.log();
// Test predict_next_action tool
console.log('6. Testing predict_next_action...');
const predictArgs = {
current_agent: 'test-agent',
workflow_state: {
step: 'component_created',
files_modified: ['HelloWorld.tsx', 'index.ts'],
next_possible_actions: ['add_styles', 'add_tests', 'update_exports']
},
user_intent: 'create_complete_component',
available_agents: [
{ id: 'style-generator', capabilities: ['css', 'scss', 'styled-components'] },
{ id: 'test-generator', capabilities: ['jest', 'testing-library', 'cypress'] }
]
};
const predictResult = await tools.handleToolCall('predict_next_action', predictArgs);
console.log(` ā
Predictions generated: ${predictResult.success}`);
console.log(` šÆ Top prediction: ${predictResult.recommended_action?.action || 'N/A'}`);
console.log(` š¤ Suggested agent: ${predictResult.suggested_agent || 'N/A'}`);
console.log(` š Reasoning: ${predictResult.reasoning?.substring(0, 50)}...`);
console.log();
// Test learn_from_workflow_outcome tool
console.log('7. Testing learn_from_workflow_outcome...');
const outcomeArgs = {
workflow_id: 'test-workflow-001',
initial_request: {
type: 'component_creation',
description: 'Create a reusable React component',
priority: 'medium'
},
final_result: {
files_created: ['HelloWorld.tsx', 'HelloWorld.test.tsx', 'HelloWorld.module.css'],
components_exported: 1,
tests_passing: true,
documentation_added: true
},
success: true,
involved_agents: ['test-agent', 'style-generator', 'test-generator'],
total_duration: 4500,
user_satisfaction: 0.92
};
const outcomeResult = await tools.handleToolCall('learn_from_workflow_outcome', outcomeArgs);
console.log(` ā
Workflow outcome learned: ${outcomeResult.success}`);
console.log(` š Learning impact: ${outcomeResult.learning_impact || 'positive'}`);
console.log(` š Pattern ID: ${outcomeResult.pattern_id?.substring(0, 8)}...`);
console.log(` š” Next recommendations: ${outcomeResult.recommendations?.length || 0}\n`);
// Test get_agent_performance_metrics tool
console.log('8. Testing get_agent_performance_metrics...');
const metricsResult = await tools.handleToolCall('get_agent_performance_metrics', {
agent_id: 'test-agent',
time_range: '24h'
});
console.log(` ā
Metrics retrieved: ${metricsResult.success}`);
console.log(` š¤ Agent ID: ${metricsResult.agent_id}`);
console.log(` š Time range: ${metricsResult.time_range}`);
if (metricsResult.summary) {
console.log(` š„ Overall health: ${metricsResult.summary.overall_health}`);
console.log(` š” Key insights: ${metricsResult.summary.key_insights?.length || 0}`);
console.log(` š§ Recommendations: ${metricsResult.summary.recommendations?.length || 0}`);
}
console.log();
// Test cleanup
console.log('9. Testing cleanup...');
await tools.cleanup();
console.log(' ā
Cleanup completed\n');
console.log('ā
All Claudio integration tests passed!\n');
console.log('š¤ Claudio can now use these MCP tools:');
toolDefinitions.forEach(tool => {
console.log(` ⢠${tool.name}`);
});
console.log();
} catch (error) {
console.error('ā Claudio integration test failed:', error.message);
console.error('Stack trace:', error.stack);
process.exit(1);
}
}
// Run the test
await testClaudioIntegration();