Skip to content

Commit aa54a67

Browse files
feat: Add comprehensive TUI monitoring for Ralph swarms
Major features: - Real-time swarm monitoring TUI with blessed interface - Git commit tracking with lines added/deleted per agent - SwarmRegistry for managing active swarms globally - Agent status, iteration counts, and performance metrics - Integration with existing SwarmDashboard and coordination systems - CLI command: stackmemory ralph tui [--swarm-id] TUI Features: - Live agent status table showing role, iteration, current task - Recent commits table with agent attribution and line changes - Performance metrics box with throughput and efficiency - Real-time log output for debugging swarm operations - Auto-detection of active swarms via registry - Keyboard controls: q=quit, r=refresh, s=start, t=stop This provides comprehensive visibility into swarm operations for debugging and optimization.
1 parent b615952 commit aa54a67

7 files changed

Lines changed: 820 additions & 0 deletions

File tree

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"@modelcontextprotocol/sdk": "^0.5.0",
8888
"@stackmemoryai/stackmemory": "^0.3.19",
8989
"@types/bcryptjs": "^2.4.6",
90+
"@types/blessed": "^0.1.27",
9091
"@types/inquirer": "^9.0.9",
9192
"@types/pg": "^8.16.0",
9293
"bcryptjs": "^3.0.3",

scripts/test-swarm-tui.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env npx tsx
2+
3+
/**
4+
* Test script for Swarm TUI monitoring
5+
* Launches the TUI with mock data for testing
6+
*/
7+
8+
import 'dotenv/config';
9+
import { SwarmTUI } from '../src/features/tui/swarm-monitor.js';
10+
import { logger } from '../src/core/monitoring/logger.js';
11+
12+
async function testSwarmTUI() {
13+
try {
14+
console.log('🦾 Starting Swarm TUI Test...');
15+
16+
const tui = new SwarmTUI();
17+
18+
// Initialize without swarm coordinator for testing
19+
await tui.initialize();
20+
21+
// Start the TUI
22+
tui.start();
23+
24+
console.log('TUI should now be running. Press q to quit.');
25+
26+
} catch (error: unknown) {
27+
logger.error('TUI test failed', error as Error);
28+
console.error('❌ TUI test failed:', (error as Error).message);
29+
process.exit(1);
30+
}
31+
}
32+
33+
// Run the test
34+
testSwarmTUI();

src/cli/commands/ralph.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,28 @@ export function createRalphCommand(): Command {
447447
});
448448
});
449449

450+
// TUI command for real-time monitoring
451+
ralph
452+
.command('tui')
453+
.description('Launch TUI monitor for active swarms')
454+
.option('--swarm-id <id>', 'Monitor specific swarm ID')
455+
.action(async (options) => {
456+
try {
457+
const { SwarmTUI } = await import('../../features/tui/swarm-monitor.js');
458+
459+
const tui = new SwarmTUI();
460+
461+
// Initialize with optional swarm ID
462+
await tui.initialize(undefined, options.swarmId);
463+
tui.start();
464+
465+
} catch (error: unknown) {
466+
logger.error('TUI launch failed', error as Error);
467+
console.error('❌ TUI failed:', (error as Error).message);
468+
process.exit(1);
469+
}
470+
});
471+
450472
return ralph;
451473
}
452474

0 commit comments

Comments
 (0)