UNPKG

mirror-magi-meta-agent

Version:

AI-powered development planning and execution system with Supabase integration

122 lines (102 loc) • 3.83 kB
#!/usr/bin/env node const fs = require('fs').promises; const path = require('path'); async function setupMetaAgent() { console.log('šŸš€ Setting up Mirror Magi Meta-Agent for your project...\n'); const baseDir = path.join(__dirname, '..'); const configDir = path.join(baseDir, 'config'); const stateDir = path.join(baseDir, 'state'); try { // Check if configuration files already exist const configExists = await fileExists(path.join(configDir, 'project-config.json')); const personaExists = await fileExists(path.join(configDir, 'agent-persona.md')); if (configExists && personaExists) { console.log('āœ… Configuration files already exist.'); console.log(' If you want to reset them, delete the existing files and run setup again.\n'); return; } // Copy template files if (!configExists) { await copyFile( path.join(configDir, 'project-config.template.json'), path.join(configDir, 'project-config.json') ); console.log('āœ… Created config/project-config.json from template'); } if (!personaExists) { await copyFile( path.join(configDir, 'agent-persona.template.md'), path.join(configDir, 'agent-persona.md') ); console.log('āœ… Created config/agent-persona.md from template'); } // Create basic project state if it doesn't exist const stateFile = path.join(stateDir, 'project-state.json'); const stateExists = await fileExists(stateFile); if (!stateExists) { const defaultState = { "current_session": { "session_id": `session_${Date.now()}`, "start_time": new Date().toISOString(), "current_feature": null, "active": true }, "recent_activities": [], "code_metrics": { "test_coverage": 0, "compilation_errors": 0, "build_status": "unknown" }, "dependencies": { "last_updated": new Date().toISOString(), "status": "needs_check" } }; await fs.writeFile(stateFile, JSON.stringify(defaultState, null, 2)); console.log('āœ… Created state/project-state.json with default values'); } console.log('\nšŸŽ‰ Setup complete! Next steps:'); console.log('\n1. Edit config/project-config.json:'); console.log(' - Update project name and description'); console.log(' - Configure your tech stack'); console.log(' - Set up your directory structure'); console.log(' - Define your coding standards'); console.log('\n2. Edit config/agent-persona.md:'); console.log(' - Replace placeholder content with your project details'); console.log(' - Add domain-specific knowledge'); console.log(' - Define your coding patterns'); console.log('\n3. Test the configuration:'); console.log(' npm test'); console.log('\n4. Customize command templates:'); console.log(' - Edit config/command-templates.json'); console.log(' - Adapt templates for your project patterns'); console.log('\nšŸ“š For more detailed configuration help, see the README.md\n'); } catch (error) { console.error('āŒ Setup failed:', error.message); process.exit(1); } } async function fileExists(filePath) { try { await fs.access(filePath); return true; } catch { return false; } } async function copyFile(source, destination) { try { const content = await fs.readFile(source, 'utf8'); await fs.writeFile(destination, content); } catch (error) { if (error.code === 'ENOENT') { throw new Error(`Template file not found: ${source}`); } throw error; } } // Run setup if called directly if (require.main === module) { setupMetaAgent().catch(console.error); } module.exports = { setupMetaAgent };