mirror-magi-meta-agent
Version:
AI-powered development planning and execution system with Supabase integration
101 lines (83 loc) ⢠4.19 kB
JavaScript
const fs = require('fs').promises;
const path = require('path');
const GenericTemplateEngine = require('../core/template-engine');
const TaskClassifier = require('../core/task-classifier');
async function testMetaAgent() {
console.log('š Mirror Magi Meta-Agent Test\n');
// Load configurations
const configPath = path.join(__dirname, '../config/project-config.json');
const statePath = path.join(__dirname, '../state/project-state.json');
try {
const config = JSON.parse(await fs.readFile(configPath, 'utf8'));
const projectState = JSON.parse(await fs.readFile(statePath, 'utf8'));
// Initialize components
const classifier = new TaskClassifier();
const templateEngine = new GenericTemplateEngine(config, projectState);
// Test tasks - generic examples that work for any project
const testTasks = [
"Create a new React component for displaying user profiles with edit functionality",
"Fix bug where form validation fails on mobile devices",
"Add comprehensive unit tests for the authentication module",
"Integrate third-party API for data synchronization",
"Create database migration for new user preferences feature",
"Refactor the main service layer to improve performance",
"Add loading states and error handling to the dashboard"
];
console.log('š Testing Task Classification and Command Generation:\n');
for (const taskDescription of testTasks) {
console.log(`\n${'='.repeat(80)}`);
console.log(`š Task: "${taskDescription}"`);
console.log(`${'='.repeat(80)}\n`);
// Classify the task
const classification = classifier.classifyTask(taskDescription);
console.log('šÆ CLASSIFICATION:');
console.log(` Type: ${classification.primaryType}`);
console.log(` Complexity: ${classification.complexity}/5`);
console.log(` Domains: ${classification.domains.join(', ')}`);
console.log(` Risk Level: ${classification.riskLevel}`);
console.log(` Estimated Time: ${classification.estimatedTime} minutes`);
if (classification.recommendations.length > 0) {
console.log('\nš” RECOMMENDATIONS:');
classification.recommendations.forEach(rec => {
console.log(` - ${rec}`);
});
}
// Generate command
const taskSpec = {
description: taskDescription,
type: classification.primaryType,
complexity: classification.complexity,
domains: classification.domains
};
const commandData = await templateEngine.generateCommand(taskSpec);
console.log('\nš GENERATED COMMAND PREVIEW:');
console.log(' Command Length:', commandData.command.length, 'characters');
console.log(' Validation Steps:', commandData.validationSteps.length);
console.log(' Success Criteria:', commandData.successCriteria.length);
console.log(' Estimated Time:', commandData.estimatedTime, 'minutes');
if (commandData.riskFactors.length > 0) {
console.log('\nā ļø RISK FACTORS:');
commandData.riskFactors.forEach(risk => {
console.log(` - ${risk}`);
});
}
}
console.log(`\n${'='.repeat(80)}`);
console.log('ā
Meta-Agent Test Complete!');
console.log('š” To customize for your project:');
console.log(' 1. Edit config/project-config.json with your tech stack');
console.log(' 2. Update config/agent-persona.md with your domain knowledge');
console.log(' 3. Modify config/command-templates.json for your patterns');
console.log(`${'='.repeat(80)}\n`);
} catch (error) {
console.error('ā Error running meta-agent test:', error.message);
console.log('\nš” This might be because the configuration files need to be set up.');
console.log('Please run: npm run setup');
console.log('Or manually copy the template files:');
console.log(' cp config/project-config.template.json config/project-config.json');
console.log(' cp config/agent-persona.template.md config/agent-persona.md\n');
}
}
// Run the test
testMetaAgent().catch(console.error);