/** * πŸ€– Generate Self-Evolving Modules Handler * ========================================== * Command interface for Cipher's autonomous evolution system */ import * as vscode from 'vscode'; import { selfGenerationSystem } from '../../brain/SelfGenerationSystem'; export async function generateSelfEvolvingModulesHandler(): Promise { try { // Show evolution options to user const evolutionType = await vscode.window.showQuickPick([ { label: 'πŸ€– Full Evolution', description: 'Complete autonomous evolution cycle', detail: 'Self-heal, expand, rewire, compile, and learn', type: 'full' }, { label: 'πŸ”§ Self-Healing Only', description: 'Create missing handlers', detail: 'Scan for missing handlers and create them', type: 'healing' }, { label: 'πŸš€ Self-Expansion Only', description: 'Generate new intelligent handlers', detail: 'Create new handlers based on brain analysis', type: 'expansion' }, { label: 'βš™οΈ Configure Evolution', description: 'Set evolution preferences', detail: 'Configure auto-compile, auto-register, etc.', type: 'configure' }, { label: 'πŸ“Š Evolution Status', description: 'View current evolution status', detail: 'Check brain connectivity and configuration', type: 'status' } ], { placeHolder: 'Choose evolution mode', title: 'πŸ€– Cipher Autonomous Evolution' }); if (!evolutionType) { vscode.window.showInformationMessage('Evolution canceled.'); return; } switch (evolutionType.type) { case 'full': await runFullEvolution(); break; case 'healing': await runSelfHealing(); break; case 'expansion': await runSelfExpansion(); break; case 'configure': await configureEvolution(); break; case 'status': await showEvolutionStatus(); break; } } catch (error) { vscode.window.showErrorMessage(`Evolution failed: ${error}`); console.error('Evolution error:', error); } } // ============================================================================= // πŸš€ EVOLUTION MODES // ============================================================================= async function runFullEvolution(): Promise { const confirm = await vscode.window.showWarningMessage( 'πŸ€– Full Evolution will:\n\n' + 'β€’ Create missing handlers\n' + 'β€’ Generate new intelligent handlers\n' + 'β€’ Update extension.ts and package.json\n' + 'β€’ Compile TypeScript\n' + 'β€’ Learn from results\n\n' + 'This may modify multiple files. Continue?', 'Yes, Evolve!', 'Cancel' ); if (confirm !== 'Yes, Evolve!') { vscode.window.showInformationMessage('Evolution canceled.'); return; } vscode.window.showInformationMessage('πŸ€– Starting full evolution...'); const result = await selfGenerationSystem.runFullEvolution(); if (result.created.length > 0 || result.modified.length > 0) { vscode.window.showInformationMessage( `βœ… Evolution complete! Created ${result.created.length} handlers, modified ${result.modified.length} files.` ); } } async function runSelfHealing(): Promise { vscode.window.showInformationMessage('πŸ”§ Starting self-healing...'); const result = await selfGenerationSystem.runSelfHealing(); if (result.created.length > 0) { vscode.window.showInformationMessage( `πŸ”§ Self-healing complete! Created ${result.created.length} missing handlers.` ); } else { vscode.window.showInformationMessage('🎯 All handlers present! No healing needed.'); } } async function runSelfExpansion(): Promise { vscode.window.showInformationMessage('πŸš€ Starting self-expansion...'); const result = await selfGenerationSystem.runSelfExpansion(); if (result.created.length > 0) { vscode.window.showInformationMessage( `πŸš€ Self-expansion complete! Created ${result.created.length} intelligent handlers.` ); } else { vscode.window.showInformationMessage('🎯 No expansion opportunities detected.'); } } // ============================================================================= // βš™οΈ CONFIGURATION // ============================================================================= async function configureEvolution(): Promise { const currentStatus = selfGenerationSystem.getStatus(); const config = currentStatus.config; const options = [ { label: `${config.autoHeal ? 'βœ…' : '❌'} Auto-Healing`, description: 'Automatically create missing handlers', key: 'autoHeal' }, { label: `${config.autoExpand ? 'βœ…' : '❌'} Auto-Expansion`, description: 'Generate new intelligent handlers', key: 'autoExpand' }, { label: `${config.autoRegister ? 'βœ…' : '❌'} Auto-Registration`, description: 'Automatically register commands', key: 'autoRegister' }, { label: `${config.autoCompile ? 'βœ…' : '❌'} Auto-Compilation`, description: 'Automatically compile TypeScript', key: 'autoCompile' }, { label: `${config.autoReload ? 'βœ…' : '❌'} Auto-Reload`, description: 'Automatically reload VS Code', key: 'autoReload' }, { label: `${config.brainLearning ? 'βœ…' : '❌'} Brain Learning`, description: 'Enable brain learning from evolution', key: 'brainLearning' } ]; const selection = await vscode.window.showQuickPick(options, { placeHolder: 'Select option to toggle', title: 'βš™οΈ Evolution Configuration' }); if (selection) { const newValue = !config[selection.key as keyof typeof config]; await selfGenerationSystem.configure({ [selection.key]: newValue }); vscode.window.showInformationMessage( `βœ… ${selection.key} ${newValue ? 'enabled' : 'disabled'}` ); // Show updated configuration await configureEvolution(); } } // ============================================================================= // πŸ“Š STATUS DISPLAY // ============================================================================= async function showEvolutionStatus(): Promise { const status = selfGenerationSystem.getStatus(); const statusMessage = `πŸ€– Cipher Evolution Status πŸ”§ Configuration: β€’ Auto-Healing: ${status.config.autoHeal ? 'βœ… Enabled' : '❌ Disabled'} β€’ Auto-Expansion: ${status.config.autoExpansion ? 'βœ… Enabled' : '❌ Disabled'} β€’ Auto-Registration: ${status.config.autoRegister ? 'βœ… Enabled' : '❌ Disabled'} β€’ Auto-Compilation: ${status.config.autoCompile ? 'βœ… Enabled' : '❌ Disabled'} β€’ Auto-Reload: ${status.config.autoReload ? 'βœ… Enabled' : '❌ Disabled'} β€’ Brain Learning: ${status.config.brainLearning ? 'βœ… Enabled' : '❌ Disabled'} 🧠 Brain Status: β€’ Connected: ${status.brainConnected ? 'βœ… Yes' : '❌ No'} β€’ Running: ${status.isRunning ? 'πŸ”„ Yes' : '⏸️ No'} πŸ“‚ Workspace: β€’ Path: ${status.workspacePath || 'Not found'}`; const actions = ['Configure', 'Run Evolution', 'OK']; const action = await vscode.window.showInformationMessage(statusMessage, ...actions); if (action === 'Configure') { await configureEvolution(); } else if (action === 'Run Evolution') { await runFullEvolution(); } } export default generateSelfEvolvingModulesHandler;