@stackmemoryai/stackmemory 0.3.25 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/ralph.js +12 -0
- package/dist/cli/commands/ralph.js.map +2 -2
- package/dist/features/tui/swarm-monitor.js +488 -0
- package/dist/features/tui/swarm-monitor.js.map +7 -0
- package/dist/integrations/ralph/coordination/enhanced-coordination.js +406 -0
- package/dist/integrations/ralph/coordination/enhanced-coordination.js.map +7 -0
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js +290 -0
- package/dist/integrations/ralph/monitoring/swarm-dashboard.js.map +7 -0
- package/dist/integrations/ralph/monitoring/swarm-registry.js +95 -0
- package/dist/integrations/ralph/monitoring/swarm-registry.js.map +7 -0
- package/dist/integrations/ralph/recovery/crash-recovery.js +458 -0
- package/dist/integrations/ralph/recovery/crash-recovery.js.map +7 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js +4 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +2 -2
- package/package.json +2 -1
- package/scripts/test-swarm-tui.ts +34 -0
|
@@ -284,6 +284,18 @@ ${contextResponse.context}`;
|
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
|
+
ralph.command("tui").description("Launch TUI monitor for active swarms").option("--swarm-id <id>", "Monitor specific swarm ID").action(async (options) => {
|
|
288
|
+
try {
|
|
289
|
+
const { SwarmTUI } = await import("../../features/tui/swarm-monitor.js");
|
|
290
|
+
const tui = new SwarmTUI();
|
|
291
|
+
await tui.initialize(void 0, options.swarmId);
|
|
292
|
+
tui.start();
|
|
293
|
+
} catch (error) {
|
|
294
|
+
logger.error("TUI launch failed", error);
|
|
295
|
+
console.error("\u274C TUI failed:", error.message);
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
287
299
|
return ralph;
|
|
288
300
|
}
|
|
289
301
|
var ralph_default = createRalphCommand;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/ralph.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Ralph Wiggum Loop Commands\n * CLI interface for Ralph-StackMemory integration\n */\n\nimport { Command } from 'commander';\nimport { logger } from '../../core/monitoring/logger.js';\nimport { RalphLoop } from '../../../scripts/ralph-loop-implementation.js';\nimport { stackMemoryContextLoader } from '../../integrations/ralph/context/stackmemory-context-loader.js';\nimport { patternLearner } from '../../integrations/ralph/learning/pattern-learner.js';\nimport { multiLoopOrchestrator } from '../../integrations/ralph/orchestration/multi-loop-orchestrator.js';\nimport { swarmCoordinator } from '../../integrations/ralph/swarm/swarm-coordinator.js';\nimport { ralphDebugger } from '../../integrations/ralph/visualization/ralph-debugger.js';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { trace } from '../../core/trace/index.js';\n\nexport function createRalphCommand(): Command {\n const ralph = new Command('ralph')\n .description('Ralph Wiggum Loop integration with StackMemory');\n\n // Initialize a new Ralph loop\n ralph\n .command('init')\n .description('Initialize a new Ralph Wiggum loop')\n .argument('<task>', 'Task description')\n .option('-c, --criteria <criteria>', 'Completion criteria (comma separated)')\n .option('--max-iterations <n>', 'Maximum iterations', '50')\n .option('--use-context', 'Load relevant context from StackMemory')\n .option('--learn-from-similar', 'Apply patterns from similar completed tasks')\n .action(async (task, options) => {\n return trace.command('ralph-init', { task, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Initializing Ralph Wiggum loop...');\n \n // Use basic Ralph loop for now (StackMemory integration requires DB setup)\n const loop = new RalphLoop({\n baseDir: '.ralph',\n maxIterations: parseInt(options.maxIterations),\n verbose: true\n });\n\n // Parse criteria\n const criteria = options.criteria \n ? options.criteria.split(',').map((c: string) => `- ${c.trim()}`).join('\\n')\n : '- All tests pass\\n- Code works correctly\\n- No lint errors';\n\n // Load StackMemory context if requested\n let enhancedTask = task;\n \n if (options.useContext || options.learnFromSimilar) {\n try {\n await stackMemoryContextLoader.initialize();\n \n const contextResponse = await stackMemoryContextLoader.loadInitialContext({\n task,\n usePatterns: true,\n useSimilarTasks: options.learnFromSimilar,\n maxTokens: 3000\n });\n \n if (contextResponse.context) {\n enhancedTask = `${task}\\n\\n${contextResponse.context}`;\n console.log(`\uD83D\uDCDA Loaded context from ${contextResponse.sources.length} sources`);\n console.log(`\uD83C\uDFAF Context tokens: ${contextResponse.metadata.totalTokens}`);\n }\n } catch (error: unknown) {\n console.log(`\u26A0\uFE0F Context loading failed: ${(error as Error).message}`);\n console.log('Proceeding without context...');\n }\n }\n\n await loop.initialize(enhancedTask, criteria);\n \n console.log('\u2705 Ralph loop initialized!');\n console.log(`\uD83D\uDCCB Task: ${task}`);\n console.log(`\uD83C\uDFAF Max iterations: ${options.maxIterations}`);\n console.log(`\uD83D\uDCC1 Loop directory: .ralph/`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph run # Start the loop');\n console.log(' stackmemory ralph status # Check status');\n\n } catch (error: unknown) {\n logger.error('Failed to initialize Ralph loop', error as Error);\n console.error('\u274C Initialization failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Run the Ralph loop\n ralph\n .command('run')\n .description('Run the Ralph Wiggum loop')\n .option('--verbose', 'Verbose output')\n .option('--pause-on-error', 'Pause on validation errors')\n .action(async (options) => {\n return trace.command('ralph-run', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.error('\u274C No Ralph loop found. Run \"stackmemory ralph init\" first.');\n return;\n }\n\n console.log('\uD83C\uDFAD Starting Ralph Wiggum loop...');\n \n const loop = new RalphLoop({\n baseDir: '.ralph',\n verbose: options.verbose\n });\n\n await loop.run();\n \n } catch (error: unknown) {\n logger.error('Failed to run Ralph loop', error as Error);\n console.error('\u274C Loop execution failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Show loop status\n ralph\n .command('status')\n .description('Show current Ralph loop status')\n .option('--detailed', 'Show detailed iteration history')\n .action(async (options) => {\n return trace.command('ralph-status', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No Ralph loop found in current directory');\n return;\n }\n\n // Get basic status from files\n \n // Read status from files\n const task = readFileSync('.ralph/task.md', 'utf8');\n const iteration = parseInt(readFileSync('.ralph/iteration.txt', 'utf8') || '0');\n const isComplete = existsSync('.ralph/work-complete.txt');\n const feedback = existsSync('.ralph/feedback.txt') ? readFileSync('.ralph/feedback.txt', 'utf8') : '';\n \n console.log('\uD83C\uDFAD Ralph Loop Status:');\n console.log(` Task: ${task.substring(0, 80)}...`);\n console.log(` Iteration: ${iteration}`);\n console.log(` Status: ${isComplete ? '\u2705 COMPLETE' : '\uD83D\uDD04 IN PROGRESS'}`);\n \n if (feedback) {\n console.log(` Last feedback: ${feedback.substring(0, 100)}...`);\n }\n\n if (options.detailed && existsSync('.ralph/progress.jsonl')) {\n console.log('\\n\uD83D\uDCCA Iteration History:');\n const progressLines = readFileSync('.ralph/progress.jsonl', 'utf8')\n .split('\\n')\n .filter(Boolean)\n .map(line => JSON.parse(line));\n \n progressLines.forEach((p: any) => {\n const progress = p as { iteration: number; validation?: { testsPass: boolean }; changes: number; errors: number };\n const status = progress.validation?.testsPass ? '\u2705' : '\u274C';\n console.log(` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`);\n });\n }\n\n // TODO: Show StackMemory integration status when available\n\n } catch (error: unknown) {\n logger.error('Failed to get Ralph status', error as Error);\n console.error('\u274C Status check failed:', (error as Error).message);\n }\n });\n });\n\n // Resume a crashed or paused loop\n ralph\n .command('resume')\n .description('Resume a crashed or paused Ralph loop')\n .option('--from-stackmemory', 'Restore from StackMemory backup')\n .action(async (options) => {\n return trace.command('ralph-resume', options, async () => {\n try {\n console.log('\uD83D\uDD04 Resuming Ralph loop...');\n \n const loop = new RalphLoop({ baseDir: '.ralph', verbose: true });\n \n if (options.fromStackmemory) {\n console.log('\uD83D\uDCDA StackMemory restore feature coming soon...');\n }\n\n await loop.run(); // Resume by continuing the loop\n \n } catch (error: unknown) {\n logger.error('Failed to resume Ralph loop', error as Error);\n console.error('\u274C Resume failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Stop the current loop\n ralph\n .command('stop')\n .description('Stop the current Ralph loop')\n .option('--save-progress', 'Save current progress to StackMemory')\n .action(async (options) => {\n return trace.command('ralph-stop', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No active Ralph loop found');\n return;\n }\n\n console.log('\uD83D\uDED1 Stopping Ralph loop...');\n \n if (options.saveProgress) {\n console.log('\uD83D\uDCBE StackMemory progress save feature coming soon...');\n }\n\n // Create stop signal file\n writeFileSync('.ralph/stop-signal.txt', new Date().toISOString());\n console.log('\u2705 Stop signal sent');\n \n } catch (error: unknown) {\n logger.error('Failed to stop Ralph loop', error as Error);\n console.error('\u274C Stop failed:', (error as Error).message);\n }\n });\n });\n\n // Clean up loop artifacts\n ralph\n .command('clean')\n .description('Clean up Ralph loop artifacts')\n .option('--keep-history', 'Keep iteration history')\n .action(async (options) => {\n return trace.command('ralph-clean', options, async () => {\n try {\n // Clean up Ralph directory\n if (!options.keepHistory && existsSync('.ralph/history')) {\n const { execSync } = await import('child_process');\n execSync('rm -rf .ralph/history');\n }\n \n // Remove working files but keep task definition\n if (existsSync('.ralph/work-complete.txt')) {\n const fs = await import('fs');\n fs.unlinkSync('.ralph/work-complete.txt');\n }\n \n console.log('\uD83E\uDDF9 Ralph loop artifacts cleaned');\n \n } catch (error: unknown) {\n logger.error('Failed to clean Ralph artifacts', error as Error);\n console.error('\u274C Cleanup failed:', (error as Error).message);\n }\n });\n });\n\n // Debug and diagnostics\n ralph\n .command('debug')\n .description('Debug Ralph loop state and diagnostics')\n .option('--reconcile', 'Force state reconciliation')\n .option('--validate-context', 'Validate context budget')\n .action(async (options) => {\n return trace.command('ralph-debug', options, async () => {\n try {\n console.log('\uD83D\uDD0D Ralph Loop Debug Information:');\n \n if (options.reconcile) {\n console.log('\uD83D\uDD27 State reconciliation feature coming soon...');\n }\n\n if (options.validateContext) {\n console.log('\uD83D\uDCCA Context validation feature coming soon...');\n }\n\n // Show file structure\n if (existsSync('.ralph')) {\n console.log('\\n\uD83D\uDCC1 Ralph directory structure:');\n const { execSync } = await import('child_process');\n try {\n const tree = execSync('find .ralph -type f | head -20', { encoding: 'utf8' });\n console.log(tree);\n } catch {\n console.log(' (Unable to show directory tree)');\n }\n }\n \n } catch (error: unknown) {\n logger.error('Ralph debug failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // Swarm coordination commands\n ralph\n .command('swarm')\n .description('Launch a swarm of specialized agents')\n .argument('<project>', 'Project description')\n .option('--agents <agents>', 'Comma-separated list of agent roles (architect,developer,tester,etc)', 'developer,tester')\n .option('--max-agents <n>', 'Maximum number of agents', '5')\n .action(async (project, options) => {\n return trace.command('ralph-swarm', { project, ...options }, async () => {\n try {\n console.log('\uD83E\uDDBE Launching Ralph swarm...');\n \n await swarmCoordinator.initialize();\n \n const agentRoles = options.agents.split(',').map((r: string) => r.trim());\n const agentSpecs = agentRoles.map((role: string) => ({\n role: role as any,\n conflictResolution: 'defer_to_expertise',\n collaborationPreferences: []\n }));\n \n const swarmId = await swarmCoordinator.launchSwarm(project, agentSpecs);\n \n console.log(`\u2705 Swarm launched with ID: ${swarmId}`);\n console.log(`\uD83D\uDC65 ${agentSpecs.length} agents working on: ${project}`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph swarm-status <swarmId> # Check progress');\n console.log(' stackmemory ralph swarm-stop <swarmId> # Stop swarm');\n \n } catch (error: unknown) {\n logger.error('Swarm launch failed', error as Error);\n console.error('\u274C Swarm launch failed:', (error as Error).message);\n }\n });\n });\n\n // Multi-loop orchestration for complex tasks\n ralph\n .command('orchestrate')\n .description('Orchestrate multiple Ralph loops for complex tasks')\n .argument('<description>', 'Complex task description')\n .option('--criteria <criteria>', 'Success criteria (comma separated)')\n .option('--max-loops <n>', 'Maximum parallel loops', '3')\n .option('--sequential', 'Force sequential execution')\n .action(async (description, options) => {\n return trace.command('ralph-orchestrate', { description, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Orchestrating complex task...');\n \n await multiLoopOrchestrator.initialize();\n \n const criteria = options.criteria ? \n options.criteria.split(',').map((c: string) => c.trim()) :\n ['Task completed successfully', 'All components working', 'Tests pass'];\n \n const result = await multiLoopOrchestrator.orchestrateComplexTask(\n description,\n criteria,\n {\n maxLoops: parseInt(options.maxLoops),\n forceSequential: options.sequential\n }\n );\n \n console.log('\u2705 Orchestration completed!');\n console.log(`\uD83D\uDCCA Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`);\n console.log(`\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1000)}s`);\n \n if (result.insights.length > 0) {\n console.log('\\n\uD83D\uDCA1 Insights:');\n result.insights.forEach(insight => console.log(` \u2022 ${insight}`));\n }\n \n } catch (error: unknown) {\n logger.error('Orchestration failed', error as Error);\n console.error('\u274C Orchestration failed:', (error as Error).message);\n }\n });\n });\n\n // Pattern learning command\n ralph\n .command('learn')\n .description('Learn patterns from completed loops')\n .option('--task-type <type>', 'Learn patterns for specific task type')\n .action(async (options) => {\n return trace.command('ralph-learn', options, async () => {\n try {\n console.log('\uD83E\uDDE0 Learning patterns from completed loops...');\n \n await patternLearner.initialize();\n \n const patterns = options.taskType ?\n await patternLearner.learnForTaskType(options.taskType) :\n await patternLearner.learnFromCompletedLoops();\n \n console.log(`\u2705 Learned ${patterns.length} patterns`);\n \n if (patterns.length > 0) {\n console.log('\\n\uD83D\uDCCA Top patterns:');\n patterns.slice(0, 5).forEach(pattern => {\n console.log(` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`);\n });\n }\n \n } catch (error: unknown) {\n logger.error('Pattern learning failed', error as Error);\n console.error('\u274C Pattern learning failed:', (error as Error).message);\n }\n });\n });\n\n // Enhanced debug command with visualization\n ralph\n .command('debug-enhanced')\n .description('Advanced debugging with visualization')\n .option('--loop-id <id>', 'Specific loop to debug')\n .option('--generate-report', 'Generate comprehensive debug report')\n .option('--timeline', 'Generate timeline visualization')\n .action(async (options) => {\n return trace.command('ralph-debug-enhanced', options, async () => {\n try {\n if (!existsSync('.ralph') && !options.loopId) {\n console.log('\u274C No Ralph loop found. Run a loop first or specify --loop-id');\n return;\n }\n \n console.log('\uD83D\uDD0D Starting enhanced debugging...');\n \n await ralphDebugger.initialize();\n \n const loopId = options.loopId || 'current';\n const debugSession = await ralphDebugger.startDebugSession(loopId, '.ralph');\n \n if (options.generateReport) {\n const report = await ralphDebugger.generateDebugReport(loopId);\n console.log(`\uD83D\uDCCB Debug report generated: ${report.exportPath}`);\n }\n \n if (options.timeline) {\n const timelinePath = await ralphDebugger.generateLoopTimeline(loopId);\n console.log(`\uD83D\uDCCA Timeline visualization: ${timelinePath}`);\n }\n \n console.log('\uD83D\uDD0D Debug analysis complete');\n \n } catch (error: unknown) {\n logger.error('Enhanced debugging failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n return ralph;\n}\n\nexport default createRalphCommand;"],
|
|
5
|
-
"mappings": "AAKA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,aAAa;AAEf,SAAS,qBAA8B;AAC5C,QAAM,QAAQ,IAAI,QAAQ,OAAO,EAC9B,YAAY,gDAAgD;AAG/D,QACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,SAAS,UAAU,kBAAkB,EACrC,OAAO,6BAA6B,uCAAuC,EAC3E,OAAO,wBAAwB,sBAAsB,IAAI,EACzD,OAAO,iBAAiB,wCAAwC,EAChE,OAAO,wBAAwB,6CAA6C,EAC5E,OAAO,OAAO,MAAM,YAAY;AAC/B,WA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,KAAK,CAAC,QAAQ,QAAQ;AAC5C,kBAAQ,IAAI,mEAA8D;AAC1E;AAAA,QACF;AAEA,gBAAQ,IAAI,0CAAmC;AAE/C,cAAM,cAAc,WAAW;AAE/B,cAAM,SAAS,QAAQ,UAAU;AACjC,cAAM,eAAe,MAAM,cAAc,kBAAkB,QAAQ,QAAQ;AAE3E,YAAI,QAAQ,gBAAgB;AAC1B,gBAAM,SAAS,MAAM,cAAc,oBAAoB,MAAM;AAC7D,kBAAQ,IAAI,qCAA8B,OAAO,UAAU,EAAE;AAAA,QAC/D;AAEA,YAAI,QAAQ,UAAU;AACpB,gBAAM,eAAe,MAAM,cAAc,qBAAqB,MAAM;AACpE,kBAAQ,IAAI,qCAA8B,YAAY,EAAE;AAAA,QAC1D;AAEA,gBAAQ,IAAI,mCAA4B;AAAA,MAE1C,SAAS,OAAgB;AACvB,eAAO,MAAM,6BAA6B,KAAc;AACxD,gBAAQ,MAAM,wBAAoB,MAAgB,OAAO;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,SAAO;AACT;AAEA,IAAO,gBAAQ;",
|
|
4
|
+
"sourcesContent": ["/**\n * Ralph Wiggum Loop Commands\n * CLI interface for Ralph-StackMemory integration\n */\n\nimport { Command } from 'commander';\nimport { logger } from '../../core/monitoring/logger.js';\nimport { RalphLoop } from '../../../scripts/ralph-loop-implementation.js';\nimport { stackMemoryContextLoader } from '../../integrations/ralph/context/stackmemory-context-loader.js';\nimport { patternLearner } from '../../integrations/ralph/learning/pattern-learner.js';\nimport { multiLoopOrchestrator } from '../../integrations/ralph/orchestration/multi-loop-orchestrator.js';\nimport { swarmCoordinator } from '../../integrations/ralph/swarm/swarm-coordinator.js';\nimport { ralphDebugger } from '../../integrations/ralph/visualization/ralph-debugger.js';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { trace } from '../../core/trace/index.js';\n\nexport function createRalphCommand(): Command {\n const ralph = new Command('ralph')\n .description('Ralph Wiggum Loop integration with StackMemory');\n\n // Initialize a new Ralph loop\n ralph\n .command('init')\n .description('Initialize a new Ralph Wiggum loop')\n .argument('<task>', 'Task description')\n .option('-c, --criteria <criteria>', 'Completion criteria (comma separated)')\n .option('--max-iterations <n>', 'Maximum iterations', '50')\n .option('--use-context', 'Load relevant context from StackMemory')\n .option('--learn-from-similar', 'Apply patterns from similar completed tasks')\n .action(async (task, options) => {\n return trace.command('ralph-init', { task, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Initializing Ralph Wiggum loop...');\n \n // Use basic Ralph loop for now (StackMemory integration requires DB setup)\n const loop = new RalphLoop({\n baseDir: '.ralph',\n maxIterations: parseInt(options.maxIterations),\n verbose: true\n });\n\n // Parse criteria\n const criteria = options.criteria \n ? options.criteria.split(',').map((c: string) => `- ${c.trim()}`).join('\\n')\n : '- All tests pass\\n- Code works correctly\\n- No lint errors';\n\n // Load StackMemory context if requested\n let enhancedTask = task;\n \n if (options.useContext || options.learnFromSimilar) {\n try {\n await stackMemoryContextLoader.initialize();\n \n const contextResponse = await stackMemoryContextLoader.loadInitialContext({\n task,\n usePatterns: true,\n useSimilarTasks: options.learnFromSimilar,\n maxTokens: 3000\n });\n \n if (contextResponse.context) {\n enhancedTask = `${task}\\n\\n${contextResponse.context}`;\n console.log(`\uD83D\uDCDA Loaded context from ${contextResponse.sources.length} sources`);\n console.log(`\uD83C\uDFAF Context tokens: ${contextResponse.metadata.totalTokens}`);\n }\n } catch (error: unknown) {\n console.log(`\u26A0\uFE0F Context loading failed: ${(error as Error).message}`);\n console.log('Proceeding without context...');\n }\n }\n\n await loop.initialize(enhancedTask, criteria);\n \n console.log('\u2705 Ralph loop initialized!');\n console.log(`\uD83D\uDCCB Task: ${task}`);\n console.log(`\uD83C\uDFAF Max iterations: ${options.maxIterations}`);\n console.log(`\uD83D\uDCC1 Loop directory: .ralph/`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph run # Start the loop');\n console.log(' stackmemory ralph status # Check status');\n\n } catch (error: unknown) {\n logger.error('Failed to initialize Ralph loop', error as Error);\n console.error('\u274C Initialization failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Run the Ralph loop\n ralph\n .command('run')\n .description('Run the Ralph Wiggum loop')\n .option('--verbose', 'Verbose output')\n .option('--pause-on-error', 'Pause on validation errors')\n .action(async (options) => {\n return trace.command('ralph-run', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.error('\u274C No Ralph loop found. Run \"stackmemory ralph init\" first.');\n return;\n }\n\n console.log('\uD83C\uDFAD Starting Ralph Wiggum loop...');\n \n const loop = new RalphLoop({\n baseDir: '.ralph',\n verbose: options.verbose\n });\n\n await loop.run();\n \n } catch (error: unknown) {\n logger.error('Failed to run Ralph loop', error as Error);\n console.error('\u274C Loop execution failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Show loop status\n ralph\n .command('status')\n .description('Show current Ralph loop status')\n .option('--detailed', 'Show detailed iteration history')\n .action(async (options) => {\n return trace.command('ralph-status', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No Ralph loop found in current directory');\n return;\n }\n\n // Get basic status from files\n \n // Read status from files\n const task = readFileSync('.ralph/task.md', 'utf8');\n const iteration = parseInt(readFileSync('.ralph/iteration.txt', 'utf8') || '0');\n const isComplete = existsSync('.ralph/work-complete.txt');\n const feedback = existsSync('.ralph/feedback.txt') ? readFileSync('.ralph/feedback.txt', 'utf8') : '';\n \n console.log('\uD83C\uDFAD Ralph Loop Status:');\n console.log(` Task: ${task.substring(0, 80)}...`);\n console.log(` Iteration: ${iteration}`);\n console.log(` Status: ${isComplete ? '\u2705 COMPLETE' : '\uD83D\uDD04 IN PROGRESS'}`);\n \n if (feedback) {\n console.log(` Last feedback: ${feedback.substring(0, 100)}...`);\n }\n\n if (options.detailed && existsSync('.ralph/progress.jsonl')) {\n console.log('\\n\uD83D\uDCCA Iteration History:');\n const progressLines = readFileSync('.ralph/progress.jsonl', 'utf8')\n .split('\\n')\n .filter(Boolean)\n .map(line => JSON.parse(line));\n \n progressLines.forEach((p: any) => {\n const progress = p as { iteration: number; validation?: { testsPass: boolean }; changes: number; errors: number };\n const status = progress.validation?.testsPass ? '\u2705' : '\u274C';\n console.log(` ${progress.iteration}: ${status} ${progress.changes} changes, ${progress.errors} errors`);\n });\n }\n\n // TODO: Show StackMemory integration status when available\n\n } catch (error: unknown) {\n logger.error('Failed to get Ralph status', error as Error);\n console.error('\u274C Status check failed:', (error as Error).message);\n }\n });\n });\n\n // Resume a crashed or paused loop\n ralph\n .command('resume')\n .description('Resume a crashed or paused Ralph loop')\n .option('--from-stackmemory', 'Restore from StackMemory backup')\n .action(async (options) => {\n return trace.command('ralph-resume', options, async () => {\n try {\n console.log('\uD83D\uDD04 Resuming Ralph loop...');\n \n const loop = new RalphLoop({ baseDir: '.ralph', verbose: true });\n \n if (options.fromStackmemory) {\n console.log('\uD83D\uDCDA StackMemory restore feature coming soon...');\n }\n\n await loop.run(); // Resume by continuing the loop\n \n } catch (error: unknown) {\n logger.error('Failed to resume Ralph loop', error as Error);\n console.error('\u274C Resume failed:', (error as Error).message);\n process.exit(1);\n }\n });\n });\n\n // Stop the current loop\n ralph\n .command('stop')\n .description('Stop the current Ralph loop')\n .option('--save-progress', 'Save current progress to StackMemory')\n .action(async (options) => {\n return trace.command('ralph-stop', options, async () => {\n try {\n if (!existsSync('.ralph')) {\n console.log('\u274C No active Ralph loop found');\n return;\n }\n\n console.log('\uD83D\uDED1 Stopping Ralph loop...');\n \n if (options.saveProgress) {\n console.log('\uD83D\uDCBE StackMemory progress save feature coming soon...');\n }\n\n // Create stop signal file\n writeFileSync('.ralph/stop-signal.txt', new Date().toISOString());\n console.log('\u2705 Stop signal sent');\n \n } catch (error: unknown) {\n logger.error('Failed to stop Ralph loop', error as Error);\n console.error('\u274C Stop failed:', (error as Error).message);\n }\n });\n });\n\n // Clean up loop artifacts\n ralph\n .command('clean')\n .description('Clean up Ralph loop artifacts')\n .option('--keep-history', 'Keep iteration history')\n .action(async (options) => {\n return trace.command('ralph-clean', options, async () => {\n try {\n // Clean up Ralph directory\n if (!options.keepHistory && existsSync('.ralph/history')) {\n const { execSync } = await import('child_process');\n execSync('rm -rf .ralph/history');\n }\n \n // Remove working files but keep task definition\n if (existsSync('.ralph/work-complete.txt')) {\n const fs = await import('fs');\n fs.unlinkSync('.ralph/work-complete.txt');\n }\n \n console.log('\uD83E\uDDF9 Ralph loop artifacts cleaned');\n \n } catch (error: unknown) {\n logger.error('Failed to clean Ralph artifacts', error as Error);\n console.error('\u274C Cleanup failed:', (error as Error).message);\n }\n });\n });\n\n // Debug and diagnostics\n ralph\n .command('debug')\n .description('Debug Ralph loop state and diagnostics')\n .option('--reconcile', 'Force state reconciliation')\n .option('--validate-context', 'Validate context budget')\n .action(async (options) => {\n return trace.command('ralph-debug', options, async () => {\n try {\n console.log('\uD83D\uDD0D Ralph Loop Debug Information:');\n \n if (options.reconcile) {\n console.log('\uD83D\uDD27 State reconciliation feature coming soon...');\n }\n\n if (options.validateContext) {\n console.log('\uD83D\uDCCA Context validation feature coming soon...');\n }\n\n // Show file structure\n if (existsSync('.ralph')) {\n console.log('\\n\uD83D\uDCC1 Ralph directory structure:');\n const { execSync } = await import('child_process');\n try {\n const tree = execSync('find .ralph -type f | head -20', { encoding: 'utf8' });\n console.log(tree);\n } catch {\n console.log(' (Unable to show directory tree)');\n }\n }\n \n } catch (error: unknown) {\n logger.error('Ralph debug failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // Swarm coordination commands\n ralph\n .command('swarm')\n .description('Launch a swarm of specialized agents')\n .argument('<project>', 'Project description')\n .option('--agents <agents>', 'Comma-separated list of agent roles (architect,developer,tester,etc)', 'developer,tester')\n .option('--max-agents <n>', 'Maximum number of agents', '5')\n .action(async (project, options) => {\n return trace.command('ralph-swarm', { project, ...options }, async () => {\n try {\n console.log('\uD83E\uDDBE Launching Ralph swarm...');\n \n await swarmCoordinator.initialize();\n \n const agentRoles = options.agents.split(',').map((r: string) => r.trim());\n const agentSpecs = agentRoles.map((role: string) => ({\n role: role as any,\n conflictResolution: 'defer_to_expertise',\n collaborationPreferences: []\n }));\n \n const swarmId = await swarmCoordinator.launchSwarm(project, agentSpecs);\n \n console.log(`\u2705 Swarm launched with ID: ${swarmId}`);\n console.log(`\uD83D\uDC65 ${agentSpecs.length} agents working on: ${project}`);\n console.log('\\nNext steps:');\n console.log(' stackmemory ralph swarm-status <swarmId> # Check progress');\n console.log(' stackmemory ralph swarm-stop <swarmId> # Stop swarm');\n \n } catch (error: unknown) {\n logger.error('Swarm launch failed', error as Error);\n console.error('\u274C Swarm launch failed:', (error as Error).message);\n }\n });\n });\n\n // Multi-loop orchestration for complex tasks\n ralph\n .command('orchestrate')\n .description('Orchestrate multiple Ralph loops for complex tasks')\n .argument('<description>', 'Complex task description')\n .option('--criteria <criteria>', 'Success criteria (comma separated)')\n .option('--max-loops <n>', 'Maximum parallel loops', '3')\n .option('--sequential', 'Force sequential execution')\n .action(async (description, options) => {\n return trace.command('ralph-orchestrate', { description, ...options }, async () => {\n try {\n console.log('\uD83C\uDFAD Orchestrating complex task...');\n \n await multiLoopOrchestrator.initialize();\n \n const criteria = options.criteria ? \n options.criteria.split(',').map((c: string) => c.trim()) :\n ['Task completed successfully', 'All components working', 'Tests pass'];\n \n const result = await multiLoopOrchestrator.orchestrateComplexTask(\n description,\n criteria,\n {\n maxLoops: parseInt(options.maxLoops),\n forceSequential: options.sequential\n }\n );\n \n console.log('\u2705 Orchestration completed!');\n console.log(`\uD83D\uDCCA Results: ${result.completedLoops.length} successful, ${result.failedLoops.length} failed`);\n console.log(`\u23F1\uFE0F Total duration: ${Math.round(result.totalDuration / 1000)}s`);\n \n if (result.insights.length > 0) {\n console.log('\\n\uD83D\uDCA1 Insights:');\n result.insights.forEach(insight => console.log(` \u2022 ${insight}`));\n }\n \n } catch (error: unknown) {\n logger.error('Orchestration failed', error as Error);\n console.error('\u274C Orchestration failed:', (error as Error).message);\n }\n });\n });\n\n // Pattern learning command\n ralph\n .command('learn')\n .description('Learn patterns from completed loops')\n .option('--task-type <type>', 'Learn patterns for specific task type')\n .action(async (options) => {\n return trace.command('ralph-learn', options, async () => {\n try {\n console.log('\uD83E\uDDE0 Learning patterns from completed loops...');\n \n await patternLearner.initialize();\n \n const patterns = options.taskType ?\n await patternLearner.learnForTaskType(options.taskType) :\n await patternLearner.learnFromCompletedLoops();\n \n console.log(`\u2705 Learned ${patterns.length} patterns`);\n \n if (patterns.length > 0) {\n console.log('\\n\uD83D\uDCCA Top patterns:');\n patterns.slice(0, 5).forEach(pattern => {\n console.log(` \u2022 ${pattern.pattern} (${Math.round(pattern.confidence * 100)}% confidence)`);\n });\n }\n \n } catch (error: unknown) {\n logger.error('Pattern learning failed', error as Error);\n console.error('\u274C Pattern learning failed:', (error as Error).message);\n }\n });\n });\n\n // Enhanced debug command with visualization\n ralph\n .command('debug-enhanced')\n .description('Advanced debugging with visualization')\n .option('--loop-id <id>', 'Specific loop to debug')\n .option('--generate-report', 'Generate comprehensive debug report')\n .option('--timeline', 'Generate timeline visualization')\n .action(async (options) => {\n return trace.command('ralph-debug-enhanced', options, async () => {\n try {\n if (!existsSync('.ralph') && !options.loopId) {\n console.log('\u274C No Ralph loop found. Run a loop first or specify --loop-id');\n return;\n }\n \n console.log('\uD83D\uDD0D Starting enhanced debugging...');\n \n await ralphDebugger.initialize();\n \n const loopId = options.loopId || 'current';\n const debugSession = await ralphDebugger.startDebugSession(loopId, '.ralph');\n \n if (options.generateReport) {\n const report = await ralphDebugger.generateDebugReport(loopId);\n console.log(`\uD83D\uDCCB Debug report generated: ${report.exportPath}`);\n }\n \n if (options.timeline) {\n const timelinePath = await ralphDebugger.generateLoopTimeline(loopId);\n console.log(`\uD83D\uDCCA Timeline visualization: ${timelinePath}`);\n }\n \n console.log('\uD83D\uDD0D Debug analysis complete');\n \n } catch (error: unknown) {\n logger.error('Enhanced debugging failed', error as Error);\n console.error('\u274C Debug failed:', (error as Error).message);\n }\n });\n });\n\n // TUI command for real-time monitoring\n ralph\n .command('tui')\n .description('Launch TUI monitor for active swarms')\n .option('--swarm-id <id>', 'Monitor specific swarm ID')\n .action(async (options) => {\n try {\n const { SwarmTUI } = await import('../../features/tui/swarm-monitor.js');\n \n const tui = new SwarmTUI();\n \n // Initialize with optional swarm ID\n await tui.initialize(undefined, options.swarmId);\n tui.start();\n \n } catch (error: unknown) {\n logger.error('TUI launch failed', error as Error);\n console.error('\u274C TUI failed:', (error as Error).message);\n process.exit(1);\n }\n });\n\n return ralph;\n}\n\nexport default createRalphCommand;"],
|
|
5
|
+
"mappings": "AAKA,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,aAAa;AAEf,SAAS,qBAA8B;AAC5C,QAAM,QAAQ,IAAI,QAAQ,OAAO,EAC9B,YAAY,gDAAgD;AAG/D,QACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,SAAS,UAAU,kBAAkB,EACrC,OAAO,6BAA6B,uCAAuC,EAC3E,OAAO,wBAAwB,sBAAsB,IAAI,EACzD,OAAO,iBAAiB,wCAAwC,EAChE,OAAO,wBAAwB,6CAA6C,EAC5E,OAAO,OAAO,MAAM,YAAY;AAC/B,WAAO,MAAM,QAAQ,cAAc,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY;AACnE,UAAI;AACF,gBAAQ,IAAI,6CAAsC;AAGlD,cAAM,OAAO,IAAI,UAAU;AAAA,UACzB,SAAS;AAAA,UACT,eAAe,SAAS,QAAQ,aAAa;AAAA,UAC7C,SAAS;AAAA,QACX,CAAC;AAGD,cAAM,WAAW,QAAQ,WACrB,QAAQ,SAAS,MAAM,GAAG,EAAE,IAAI,CAAC,MAAc,KAAK,EAAE,K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AA8B,OAAO,UAAU,EAAE;AAAA,QAC/D;AAEA,YAAI,QAAQ,UAAU;AACpB,gBAAM,eAAe,MAAM,cAAc,qBAAqB,MAAM;AACpE,kBAAQ,IAAI,qCAA8B,YAAY,EAAE;AAAA,QAC1D;AAEA,gBAAQ,IAAI,mCAA4B;AAAA,MAE1C,SAAS,OAAgB;AACvB,eAAO,MAAM,6BAA6B,KAAc;AACxD,gBAAQ,MAAM,wBAAoB,MAAgB,OAAO;AAAA,MAC3D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAGH,QACG,QAAQ,KAAK,EACb,YAAY,sCAAsC,EAClD,OAAO,mBAAmB,2BAA2B,EACrD,OAAO,OAAO,YAAY;AACzB,QAAI;AACF,YAAM,EAAE,SAAS,IAAI,MAAM,OAAO,qCAAqC;AAEvE,YAAM,MAAM,IAAI,SAAS;AAGzB,YAAM,IAAI,WAAW,QAAW,QAAQ,OAAO;AAC/C,UAAI,MAAM;AAAA,IAEZ,SAAS,OAAgB;AACvB,aAAO,MAAM,qBAAqB,KAAc;AAChD,cAAQ,MAAM,sBAAkB,MAAgB,OAAO;AACvD,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import blessed from "blessed";
|
|
2
|
+
import { logger } from "../../core/monitoring/logger.js";
|
|
3
|
+
import { SwarmDashboard } from "../../integrations/ralph/monitoring/swarm-dashboard.js";
|
|
4
|
+
import { SwarmRegistry } from "../../integrations/ralph/monitoring/swarm-registry.js";
|
|
5
|
+
import { execSync } from "child_process";
|
|
6
|
+
class SwarmTUI {
|
|
7
|
+
screen;
|
|
8
|
+
commitsTable;
|
|
9
|
+
statusBox;
|
|
10
|
+
agentsTable;
|
|
11
|
+
metricsBox;
|
|
12
|
+
logBox;
|
|
13
|
+
swarmCoordinator = null;
|
|
14
|
+
swarmDashboard = null;
|
|
15
|
+
refreshInterval = null;
|
|
16
|
+
commitMetrics = /* @__PURE__ */ new Map();
|
|
17
|
+
constructor() {
|
|
18
|
+
this.screen = blessed.screen({
|
|
19
|
+
smartCSR: true,
|
|
20
|
+
title: "Ralph Swarm Monitor"
|
|
21
|
+
});
|
|
22
|
+
this.createUI();
|
|
23
|
+
this.setupKeyHandlers();
|
|
24
|
+
logger.info("SwarmTUI initialized");
|
|
25
|
+
}
|
|
26
|
+
createUI() {
|
|
27
|
+
const container = blessed.box({
|
|
28
|
+
parent: this.screen,
|
|
29
|
+
top: 0,
|
|
30
|
+
left: 0,
|
|
31
|
+
width: "100%",
|
|
32
|
+
height: "100%",
|
|
33
|
+
style: {
|
|
34
|
+
bg: "black"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
blessed.box({
|
|
38
|
+
parent: container,
|
|
39
|
+
top: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
width: "100%",
|
|
42
|
+
height: 3,
|
|
43
|
+
content: "\u{1F9BE} Ralph Swarm Monitor - Real-time Swarm Operations",
|
|
44
|
+
style: {
|
|
45
|
+
bg: "blue",
|
|
46
|
+
fg: "white",
|
|
47
|
+
bold: true
|
|
48
|
+
},
|
|
49
|
+
border: {
|
|
50
|
+
type: "line"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
this.statusBox = blessed.box({
|
|
54
|
+
parent: container,
|
|
55
|
+
top: 3,
|
|
56
|
+
left: "50%",
|
|
57
|
+
width: "50%",
|
|
58
|
+
height: 8,
|
|
59
|
+
label: " Swarm Status ",
|
|
60
|
+
content: "No active swarm",
|
|
61
|
+
style: {
|
|
62
|
+
bg: "black",
|
|
63
|
+
fg: "white"
|
|
64
|
+
},
|
|
65
|
+
border: {
|
|
66
|
+
type: "line",
|
|
67
|
+
fg: "cyan"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
this.metricsBox = blessed.box({
|
|
71
|
+
parent: container,
|
|
72
|
+
top: 3,
|
|
73
|
+
left: 0,
|
|
74
|
+
width: "50%",
|
|
75
|
+
height: 8,
|
|
76
|
+
label: " Performance Metrics ",
|
|
77
|
+
content: "Waiting for data...",
|
|
78
|
+
style: {
|
|
79
|
+
bg: "black",
|
|
80
|
+
fg: "white"
|
|
81
|
+
},
|
|
82
|
+
border: {
|
|
83
|
+
type: "line",
|
|
84
|
+
fg: "green"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
this.agentsTable = blessed.table({
|
|
88
|
+
parent: container,
|
|
89
|
+
top: 11,
|
|
90
|
+
left: 0,
|
|
91
|
+
width: "50%",
|
|
92
|
+
height: 12,
|
|
93
|
+
label: " Active Agents ",
|
|
94
|
+
style: {
|
|
95
|
+
bg: "black",
|
|
96
|
+
fg: "white",
|
|
97
|
+
header: {
|
|
98
|
+
bg: "blue",
|
|
99
|
+
fg: "white",
|
|
100
|
+
bold: true
|
|
101
|
+
},
|
|
102
|
+
cell: {
|
|
103
|
+
selected: {
|
|
104
|
+
bg: "blue",
|
|
105
|
+
fg: "white"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
border: {
|
|
110
|
+
type: "line",
|
|
111
|
+
fg: "yellow"
|
|
112
|
+
},
|
|
113
|
+
data: [
|
|
114
|
+
["Role", "Status", "Iteration", "Task", "Last Active"]
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
this.commitsTable = blessed.table({
|
|
118
|
+
parent: container,
|
|
119
|
+
top: 11,
|
|
120
|
+
left: "50%",
|
|
121
|
+
width: "50%",
|
|
122
|
+
height: 12,
|
|
123
|
+
label: " Recent Commits ",
|
|
124
|
+
style: {
|
|
125
|
+
bg: "black",
|
|
126
|
+
fg: "white",
|
|
127
|
+
header: {
|
|
128
|
+
bg: "blue",
|
|
129
|
+
fg: "white",
|
|
130
|
+
bold: true
|
|
131
|
+
},
|
|
132
|
+
cell: {
|
|
133
|
+
selected: {
|
|
134
|
+
bg: "blue",
|
|
135
|
+
fg: "white"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
border: {
|
|
140
|
+
type: "line",
|
|
141
|
+
fg: "magenta"
|
|
142
|
+
},
|
|
143
|
+
data: [
|
|
144
|
+
["Agent", "Message", "Lines +/-", "Time"]
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
this.logBox = blessed.log({
|
|
148
|
+
parent: container,
|
|
149
|
+
top: 23,
|
|
150
|
+
left: 0,
|
|
151
|
+
width: "100%",
|
|
152
|
+
height: "100%-23",
|
|
153
|
+
label: " Swarm Logs ",
|
|
154
|
+
style: {
|
|
155
|
+
bg: "black",
|
|
156
|
+
fg: "white"
|
|
157
|
+
},
|
|
158
|
+
border: {
|
|
159
|
+
type: "line",
|
|
160
|
+
fg: "white"
|
|
161
|
+
},
|
|
162
|
+
scrollable: true,
|
|
163
|
+
alwaysScroll: true,
|
|
164
|
+
mouse: true
|
|
165
|
+
});
|
|
166
|
+
blessed.box({
|
|
167
|
+
parent: container,
|
|
168
|
+
bottom: 0,
|
|
169
|
+
left: 0,
|
|
170
|
+
width: "100%",
|
|
171
|
+
height: 1,
|
|
172
|
+
content: "Press q to quit, r to refresh, s to start swarm, t to stop swarm",
|
|
173
|
+
style: {
|
|
174
|
+
bg: "white",
|
|
175
|
+
fg: "black"
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
setupKeyHandlers() {
|
|
180
|
+
this.screen.key(["escape", "q", "C-c"], () => {
|
|
181
|
+
this.cleanup();
|
|
182
|
+
process.exit(0);
|
|
183
|
+
});
|
|
184
|
+
this.screen.key(["r"], () => {
|
|
185
|
+
this.refreshData();
|
|
186
|
+
this.logBox.log("Manual refresh triggered");
|
|
187
|
+
});
|
|
188
|
+
this.screen.key(["s"], () => {
|
|
189
|
+
this.logBox.log("Start swarm command - feature coming soon");
|
|
190
|
+
});
|
|
191
|
+
this.screen.key(["t"], () => {
|
|
192
|
+
this.logBox.log("Stop swarm command - feature coming soon");
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Initialize swarm monitoring
|
|
197
|
+
*/
|
|
198
|
+
async initialize(swarmCoordinator, swarmId) {
|
|
199
|
+
try {
|
|
200
|
+
if (swarmId) {
|
|
201
|
+
const registry = SwarmRegistry.getInstance();
|
|
202
|
+
const swarm = registry.getSwarm(swarmId);
|
|
203
|
+
if (swarm) {
|
|
204
|
+
this.swarmCoordinator = swarm.coordinator;
|
|
205
|
+
this.logBox.log(`Connected to swarm: ${swarmId}`);
|
|
206
|
+
} else {
|
|
207
|
+
this.logBox.log(`Swarm not found: ${swarmId}`);
|
|
208
|
+
}
|
|
209
|
+
} else if (swarmCoordinator) {
|
|
210
|
+
this.swarmCoordinator = swarmCoordinator;
|
|
211
|
+
} else {
|
|
212
|
+
const registry = SwarmRegistry.getInstance();
|
|
213
|
+
const activeSwarms = registry.listActiveSwarms();
|
|
214
|
+
if (activeSwarms.length > 0) {
|
|
215
|
+
this.swarmCoordinator = activeSwarms[0].coordinator;
|
|
216
|
+
this.logBox.log(`Auto-connected to swarm: ${activeSwarms[0].id}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (this.swarmCoordinator) {
|
|
220
|
+
this.swarmDashboard = new SwarmDashboard(this.swarmCoordinator);
|
|
221
|
+
this.swarmDashboard.startMonitoring(2e3);
|
|
222
|
+
this.swarmDashboard.on("metricsUpdated", (metrics) => {
|
|
223
|
+
this.updateUI(metrics);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
this.refreshInterval = setInterval(() => {
|
|
227
|
+
this.refreshData();
|
|
228
|
+
}, 3e3);
|
|
229
|
+
this.logBox.log("SwarmTUI monitoring initialized");
|
|
230
|
+
} catch (error) {
|
|
231
|
+
logger.error("Failed to initialize SwarmTUI", error);
|
|
232
|
+
this.logBox.log(`Error: ${error.message}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Start the TUI display
|
|
237
|
+
*/
|
|
238
|
+
start() {
|
|
239
|
+
this.screen.render();
|
|
240
|
+
this.logBox.log("Ralph Swarm Monitor started");
|
|
241
|
+
this.logBox.log("Monitoring for active swarms...");
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Refresh all data
|
|
245
|
+
*/
|
|
246
|
+
async refreshData() {
|
|
247
|
+
try {
|
|
248
|
+
await this.updateCommitMetrics();
|
|
249
|
+
if (this.swarmCoordinator) {
|
|
250
|
+
const status = this.getSwarmStatus();
|
|
251
|
+
this.updateStatusDisplay(status);
|
|
252
|
+
} else {
|
|
253
|
+
await this.detectActiveSwarms();
|
|
254
|
+
}
|
|
255
|
+
this.screen.render();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
logger.error("Failed to refresh TUI data", error);
|
|
258
|
+
this.logBox.log(`Refresh error: ${error.message}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Update commit metrics for all agents
|
|
263
|
+
*/
|
|
264
|
+
async updateCommitMetrics() {
|
|
265
|
+
try {
|
|
266
|
+
const gitLog = execSync(
|
|
267
|
+
'git log --oneline --since="1 hour ago" --pretty=format:"%H|%an|%s|%ct" --numstat',
|
|
268
|
+
{ encoding: "utf8", cwd: process.cwd() }
|
|
269
|
+
);
|
|
270
|
+
const commits = this.parseGitCommits(gitLog);
|
|
271
|
+
this.updateCommitsTable(commits);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
this.logBox.log("No recent commits found");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Parse git log output into commit data
|
|
278
|
+
*/
|
|
279
|
+
parseGitCommits(gitLog) {
|
|
280
|
+
const commits = [];
|
|
281
|
+
const lines = gitLog.split("\n").filter(Boolean);
|
|
282
|
+
let currentCommit = null;
|
|
283
|
+
for (const line of lines) {
|
|
284
|
+
if (line.includes("|")) {
|
|
285
|
+
const [hash, author, message, timestamp] = line.split("|");
|
|
286
|
+
currentCommit = {
|
|
287
|
+
hash: hash.substring(0, 8),
|
|
288
|
+
agent: this.extractAgentFromAuthor(author),
|
|
289
|
+
message: message.substring(0, 50),
|
|
290
|
+
timestamp: parseInt(timestamp),
|
|
291
|
+
linesAdded: 0,
|
|
292
|
+
linesDeleted: 0
|
|
293
|
+
};
|
|
294
|
+
} else if (currentCommit && line.match(/^\d+\s+\d+/)) {
|
|
295
|
+
const [added, deleted] = line.split(" ")[0].split(" ");
|
|
296
|
+
currentCommit.linesAdded += parseInt(added) || 0;
|
|
297
|
+
currentCommit.linesDeleted += parseInt(deleted) || 0;
|
|
298
|
+
commits.push({ ...currentCommit });
|
|
299
|
+
currentCommit = null;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return commits.slice(0, 10);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Extract agent info from git author
|
|
306
|
+
*/
|
|
307
|
+
extractAgentFromAuthor(author) {
|
|
308
|
+
const agentMatch = author.match(/\[(\w+)\]/);
|
|
309
|
+
if (agentMatch) {
|
|
310
|
+
return agentMatch[1];
|
|
311
|
+
}
|
|
312
|
+
const roles = ["developer", "tester", "optimizer", "documenter", "architect"];
|
|
313
|
+
for (const role of roles) {
|
|
314
|
+
if (author.toLowerCase().includes(role)) {
|
|
315
|
+
return role;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return "user";
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Update commits table display
|
|
322
|
+
*/
|
|
323
|
+
updateCommitsTable(commits) {
|
|
324
|
+
const tableData = [
|
|
325
|
+
["Agent", "Message", "Lines +/-", "Time"]
|
|
326
|
+
];
|
|
327
|
+
for (const commit of commits) {
|
|
328
|
+
const timeAgo = this.formatTimeAgo(commit.timestamp * 1e3);
|
|
329
|
+
const linesChange = `+${commit.linesAdded}/-${commit.linesDeleted}`;
|
|
330
|
+
tableData.push([
|
|
331
|
+
commit.agent,
|
|
332
|
+
commit.message,
|
|
333
|
+
linesChange,
|
|
334
|
+
timeAgo
|
|
335
|
+
]);
|
|
336
|
+
}
|
|
337
|
+
this.commitsTable.setData(tableData);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get current swarm status
|
|
341
|
+
*/
|
|
342
|
+
getSwarmStatus() {
|
|
343
|
+
if (!this.swarmCoordinator) return null;
|
|
344
|
+
const usage = this.swarmCoordinator.getResourceUsage();
|
|
345
|
+
const swarmState = this.swarmCoordinator.swarmState;
|
|
346
|
+
if (!swarmState) return null;
|
|
347
|
+
return {
|
|
348
|
+
swarmId: swarmState.id,
|
|
349
|
+
status: swarmState.status,
|
|
350
|
+
startTime: swarmState.startTime,
|
|
351
|
+
uptime: Date.now() - swarmState.startTime,
|
|
352
|
+
agents: usage.activeAgents ? Array.from(this.swarmCoordinator.activeAgents?.values() || []).map((agent) => ({
|
|
353
|
+
id: agent.id,
|
|
354
|
+
role: agent.role,
|
|
355
|
+
status: agent.status,
|
|
356
|
+
currentTask: agent.currentTask,
|
|
357
|
+
iteration: agent.performance?.tasksCompleted || 0,
|
|
358
|
+
lastActivity: agent.performance?.lastFreshStart || Date.now()
|
|
359
|
+
})) : [],
|
|
360
|
+
performance: {
|
|
361
|
+
throughput: swarmState.performance?.throughput || 0,
|
|
362
|
+
efficiency: swarmState.performance?.efficiency || 0,
|
|
363
|
+
totalTasks: swarmState.totalTaskCount || 0,
|
|
364
|
+
completedTasks: swarmState.completedTaskCount || 0
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Update status display
|
|
370
|
+
*/
|
|
371
|
+
updateStatusDisplay(status) {
|
|
372
|
+
if (!status) {
|
|
373
|
+
this.statusBox.setContent("No active swarm detected");
|
|
374
|
+
this.agentsTable.setData([["Role", "Status", "Iteration", "Task", "Last Active"]]);
|
|
375
|
+
this.metricsBox.setContent("Waiting for swarm data...");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const uptimeStr = this.formatDuration(status.uptime);
|
|
379
|
+
const statusContent = `Swarm: ${status.swarmId.substring(0, 8)}
|
|
380
|
+
Status: ${status.status.toUpperCase()}
|
|
381
|
+
Uptime: ${uptimeStr}
|
|
382
|
+
Agents: ${status.agents.length}`;
|
|
383
|
+
this.statusBox.setContent(statusContent);
|
|
384
|
+
const agentData = [["Role", "Status", "Iteration", "Task", "Last Active"]];
|
|
385
|
+
for (const agent of status.agents) {
|
|
386
|
+
const lastActivity = this.formatTimeAgo(agent.lastActivity);
|
|
387
|
+
const task = agent.currentTask ? agent.currentTask.substring(0, 20) : "idle";
|
|
388
|
+
agentData.push([
|
|
389
|
+
agent.role,
|
|
390
|
+
agent.status,
|
|
391
|
+
agent.iteration.toString(),
|
|
392
|
+
task,
|
|
393
|
+
lastActivity
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
this.agentsTable.setData(agentData);
|
|
397
|
+
const metricsContent = `Throughput: ${status.performance.throughput.toFixed(2)} tasks/min
|
|
398
|
+
Efficiency: ${(status.performance.efficiency * 100).toFixed(1)}%
|
|
399
|
+
Tasks: ${status.performance.completedTasks}/${status.performance.totalTasks}
|
|
400
|
+
Success Rate: ${status.performance.efficiency > 0 ? (status.performance.efficiency * 100).toFixed(1) : "N/A"}%`;
|
|
401
|
+
this.metricsBox.setContent(metricsContent);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Update UI with metrics from dashboard
|
|
405
|
+
*/
|
|
406
|
+
updateUI(metrics) {
|
|
407
|
+
this.logBox.log(`Metrics updated: ${metrics.status} - ${metrics.activeAgents} agents`);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Detect active swarms in the system
|
|
411
|
+
*/
|
|
412
|
+
async detectActiveSwarms() {
|
|
413
|
+
try {
|
|
414
|
+
const registry = SwarmRegistry.getInstance();
|
|
415
|
+
const activeSwarms = registry.listActiveSwarms();
|
|
416
|
+
const stats = registry.getStatistics();
|
|
417
|
+
if (activeSwarms.length > 0) {
|
|
418
|
+
let statusContent = `Available Swarms (${activeSwarms.length}):
|
|
419
|
+
`;
|
|
420
|
+
for (const swarm of activeSwarms.slice(0, 3)) {
|
|
421
|
+
const uptime = this.formatDuration(Date.now() - swarm.startTime);
|
|
422
|
+
statusContent += `\u2022 ${swarm.id.substring(0, 8)}: ${swarm.status} (${uptime})
|
|
423
|
+
`;
|
|
424
|
+
}
|
|
425
|
+
if (activeSwarms.length > 3) {
|
|
426
|
+
statusContent += `... and ${activeSwarms.length - 3} more`;
|
|
427
|
+
}
|
|
428
|
+
this.statusBox.setContent(statusContent);
|
|
429
|
+
this.logBox.log(`Found ${activeSwarms.length} active swarms in registry`);
|
|
430
|
+
} else {
|
|
431
|
+
const ralphProcesses = execSync('ps aux | grep "ralph" | grep -v grep', { encoding: "utf8" });
|
|
432
|
+
if (ralphProcesses.trim()) {
|
|
433
|
+
this.logBox.log("Detected Ralph processes running");
|
|
434
|
+
this.statusBox.setContent("External Ralph processes detected\n(Use swarm coordinator for full monitoring)");
|
|
435
|
+
} else {
|
|
436
|
+
this.statusBox.setContent(`No active swarms detected
|
|
437
|
+
Total swarms: ${stats.totalSwarms}
|
|
438
|
+
Completed: ${stats.completedSwarms}
|
|
439
|
+
|
|
440
|
+
Run: stackmemory ralph swarm <task>`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
} catch {
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Format time ago string
|
|
448
|
+
*/
|
|
449
|
+
formatTimeAgo(timestamp) {
|
|
450
|
+
const diff = Date.now() - timestamp;
|
|
451
|
+
const minutes = Math.floor(diff / 6e4);
|
|
452
|
+
const hours = Math.floor(minutes / 60);
|
|
453
|
+
const days = Math.floor(hours / 24);
|
|
454
|
+
if (days > 0) return `${days}d ago`;
|
|
455
|
+
if (hours > 0) return `${hours}h ago`;
|
|
456
|
+
if (minutes > 0) return `${minutes}m ago`;
|
|
457
|
+
return "just now";
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Format duration string
|
|
461
|
+
*/
|
|
462
|
+
formatDuration(ms) {
|
|
463
|
+
const seconds = Math.floor(ms / 1e3);
|
|
464
|
+
const minutes = Math.floor(seconds / 60);
|
|
465
|
+
const hours = Math.floor(minutes / 60);
|
|
466
|
+
if (hours > 0) return `${hours}h ${minutes % 60}m`;
|
|
467
|
+
if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
|
|
468
|
+
return `${seconds}s`;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Cleanup resources
|
|
472
|
+
*/
|
|
473
|
+
cleanup() {
|
|
474
|
+
if (this.refreshInterval) {
|
|
475
|
+
clearInterval(this.refreshInterval);
|
|
476
|
+
}
|
|
477
|
+
if (this.swarmDashboard) {
|
|
478
|
+
this.swarmDashboard.stopMonitoring();
|
|
479
|
+
}
|
|
480
|
+
logger.info("SwarmTUI cleaned up");
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
var swarm_monitor_default = SwarmTUI;
|
|
484
|
+
export {
|
|
485
|
+
SwarmTUI,
|
|
486
|
+
swarm_monitor_default as default
|
|
487
|
+
};
|
|
488
|
+
//# sourceMappingURL=swarm-monitor.js.map
|