code-mesh-tui 0.1.0

Interactive Terminal User Interface for the Code-Mesh distributed swarm intelligence system
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# Code-Mesh TUI ๐Ÿ–ฅ๏ธโœจ

[![Crates.io](https://img.shields.io/crates/v/code-mesh-tui.svg)](https://crates.io/crates/code-mesh-tui)
[![Documentation](https://docs.rs/code-mesh-tui/badge.svg)](https://docs.rs/code-mesh-tui)
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/ruvnet/code-mesh)
[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org)

**Interactive Terminal User Interface for the Code-Mesh distributed swarm intelligence system.**

Code-Mesh TUI provides a beautiful, feature-rich terminal interface to visualize, monitor, and control your Code-Mesh swarms in real-time. Experience the power of distributed computing through an intuitive, responsive interface.

## ๐ŸŒŸ Features

### ๐ŸŽจ **Beautiful Interface**
- **Modern Design**: Clean, intuitive interface with customizable themes
- **Real-time Updates**: Live monitoring with smooth animations
- **Responsive Layout**: Adapts to any terminal size
- **Syntax Highlighting**: Code display with language-aware highlighting

### ๐Ÿ“Š **Visual Monitoring**
- **Swarm Topology Visualization**: Interactive network graphs of agent relationships
- **Performance Dashboards**: Real-time metrics with charts and graphs
- **Agent Status Display**: Live status updates for all active agents
- **Task Progress Tracking**: Visual progress bars and completion indicators

### ๐ŸŽฎ **Interactive Controls**
- **Command Palette**: Quick access to all functions with fuzzy search
- **Keyboard Shortcuts**: Efficient navigation and control
- **Mouse Support**: Click and scroll support where available
- **Multi-panel Layout**: Split views for monitoring multiple aspects simultaneously

### ๐Ÿง  **Neural Intelligence Visualization**
- **Neural Network Display**: Visual representation of agent neural networks
- **Learning Progress**: Real-time learning metrics and pattern recognition
- **Cognitive Pattern Visualization**: See how different thinking patterns work
- **Cross-Agent Communication**: Visualize message passing between agents

## ๐Ÿš€ Installation

### From Crates.io

```bash
cargo install code-mesh-tui
```

### From Source

```bash
git clone https://github.com/ruvnet/code-mesh
cd code-mesh
cargo install --path crates/code-mesh-tui
```

### As a Library

Add this to your `Cargo.toml`:

```toml
[dependencies]
code-mesh-tui = "0.1"
```

## ๐Ÿš€ Quick Start

### Launch the TUI

```bash
# Start with default settings
code-mesh-tui

# Start with specific configuration
code-mesh-tui --config ~/.config/code-mesh/tui-config.toml

# Connect to remote Code-Mesh instance
code-mesh-tui --connect ws://localhost:8080

# Start in specific mode
code-mesh-tui --mode monitor
```

### Basic Navigation

```
Tab / Shift+Tab    - Navigate between panels
Ctrl+P             - Open command palette
Ctrl+Q             - Quit application
?                  - Show help
Space              - Toggle pause/resume
F5                 - Refresh data
```

## ๐ŸŽจ Interface Overview

### Main Dashboard

```
โ”Œโ”€ Code-Mesh TUI v0.1.0 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โšก Swarm: mesh-001 โ”‚ ๐Ÿง  Agents: 5/8 โ”‚ ๐Ÿ“Š CPU: 45% โ”‚ ๐Ÿ’พ RAM: 2.1GB โ”‚ โ†— Net โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                             โ”‚
โ”‚  โ”Œโ”€ Swarm Topology โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€ Performance Metrics โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚  โ”‚                              โ”‚ โ”‚  CPU Usage        โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 89%      โ”‚โ”‚
โ”‚  โ”‚    [R1]โ”€โ”€โ”€โ”€[C1]              โ”‚ โ”‚  Memory Usage     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 67%      โ”‚โ”‚
โ”‚  โ”‚     โ”‚       โ”‚                โ”‚ โ”‚  Neural Ops/sec   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 85%      โ”‚โ”‚
โ”‚  โ”‚    [A1]โ”€โ”€โ”€โ”€[O1]              โ”‚ โ”‚  Network I/O      โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 59%      โ”‚โ”‚
โ”‚  โ”‚     โ”‚       โ”‚                โ”‚ โ”‚                                       โ”‚โ”‚
โ”‚  โ”‚    [A2]โ”€โ”€โ”€โ”€[C2]              โ”‚ โ”‚  โ”Œโ”€ Recent Tasks โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚โ”‚
โ”‚  โ”‚                              โ”‚ โ”‚  โ”‚ โœ“ Code analysis    (2.3s)        โ”‚โ”‚โ”‚
โ”‚  โ”‚  Legend:                     โ”‚ โ”‚  โ”‚ โณ Optimization    (45% done)    โ”‚โ”‚โ”‚
โ”‚  โ”‚  [R] Researcher [C] Coder    โ”‚ โ”‚  โ”‚ โธ Documentation   (paused)       โ”‚โ”‚โ”‚
โ”‚  โ”‚  [A] Analyst    [O] Optimizerโ”‚ โ”‚  โ”‚ โŒ› Testing         (queued)       โ”‚โ”‚โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚โ”‚
โ”‚                                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ”‚                                                                             โ”‚
โ”‚  โ”Œโ”€ Agent Details โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”‚
โ”‚  โ”‚ Agent ID: researcher-001                    Status: โšก Active             โ”‚โ”‚
โ”‚  โ”‚ Type: Researcher                           Uptime: 2h 15m 33s           โ”‚โ”‚
โ”‚  โ”‚ Cognitive Pattern: Adaptive                Tasks: 12 completed          โ”‚โ”‚
โ”‚  โ”‚ Neural Network: nn-1752..                  Success Rate: 98.3%          โ”‚โ”‚
โ”‚  โ”‚                                                                         โ”‚โ”‚
โ”‚  โ”‚ Current Task: "Analyze codebase structure and dependencies"             โ”‚โ”‚
โ”‚  โ”‚ Progress: โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 78%                                      โ”‚โ”‚
โ”‚  โ”‚ ETA: 45 seconds                                                         โ”‚โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

### Available Views

#### 1. **Dashboard View** (Default)
- Overview of entire swarm
- Key performance metrics
- Active task monitoring
- Agent status summary

#### 2. **Swarm View**
- Detailed swarm topology visualization
- Agent relationships and communication flows
- Network health and connectivity status
- Real-time topology optimization

#### 3. **Agent View**
- Individual agent details
- Neural network visualization
- Performance metrics per agent
- Task history and success rates

#### 4. **Task View**
- Task queue and execution status
- Detailed progress tracking
- Task results and outputs
- Performance analytics

#### 5. **Neural View**
- Neural network architecture display
- Learning progress visualization
- Pattern recognition results
- Cross-agent knowledge sharing

#### 6. **Performance View**
- Comprehensive system metrics
- Resource utilization graphs
- Performance trends and analytics
- Bottleneck identification

## โŒจ๏ธ Keyboard Shortcuts

### Global Shortcuts

| Key | Action |
|-----|--------|
| `Ctrl+Q` | Quit application |
| `Ctrl+P` | Open command palette |
| `Tab` / `Shift+Tab` | Navigate panels |
| `?` | Show help |
| `F5` | Refresh data |
| `Space` | Pause/Resume updates |
| `Ctrl+R` | Reset view |

### View-Specific Shortcuts

#### Dashboard View
| Key | Action |
|-----|--------|
| `1-6` | Switch to specific view |
| `Enter` | View details of selected item |
| `D` | Toggle detailed mode |

#### Swarm View
| Key | Action |
|-----|--------|
| `+/-` | Zoom in/out |
| `Arrow Keys` | Pan around topology |
| `S` | Save topology layout |
| `R` | Reset layout |

#### Agent View
| Key | Action |
|-----|--------|
| `Up/Down` | Select agent |
| `Enter` | View agent details |
| `K` | Kill selected agent |
| `M` | Send message to agent |

#### Task View
| Key | Action |
|-----|--------|
| `Up/Down` | Select task |
| `Enter` | View task details |
| `C` | Cancel selected task |
| `N` | Create new task |

## ๐ŸŽจ Themes and Customization

### Built-in Themes

```bash
# Dark theme (default)
code-mesh-tui --theme dark

# Light theme
code-mesh-tui --theme light

# High contrast
code-mesh-tui --theme high-contrast

# Cyberpunk theme
code-mesh-tui --theme cyberpunk

# Minimalist theme
code-mesh-tui --theme minimal
```

### Custom Theme Configuration

Create `~/.config/code-mesh/tui-theme.toml`:

```toml
[colors]
background = "#1e1e1e"
foreground = "#d4d4d4"
primary = "#007acc"
secondary = "#ff6b6b"
success = "#4ade80"
warning = "#facc15"
error = "#ef4444"
accent = "#a855f7"

[borders]
style = "rounded"  # rounded, sharp, double, thick
color = "primary"

[graphs]
line_color = "primary"
fill_color = "secondary"
grid_color = "foreground"
```

### Layout Customization

```toml
[layout]
show_borders = true
panel_spacing = 1
header_height = 3
footer_height = 2

[panels]
swarm_topology = { x = 0, y = 0, width = 50, height = 60 }
performance_metrics = { x = 50, y = 0, width = 50, height = 30 }
task_list = { x = 50, y = 30, width = 50, height = 30 }
agent_details = { x = 0, y = 60, width = 100, height = 40 }
```

## ๐Ÿ”ง Configuration

### Configuration File (`~/.config/code-mesh/tui-config.toml`)

```toml
[display]
theme = "dark"
refresh_rate = 1000  # milliseconds
enable_mouse = true
enable_unicode = true

[performance]
max_fps = 60
buffer_size = 1000
enable_vsync = true

[networking]
connection_timeout = 5000
retry_attempts = 3
keepalive_interval = 30

[features]
enable_neural_viz = true
enable_audio_alerts = false
enable_notifications = true
show_debug_info = false

[keybindings]
quit = "Ctrl+Q"
help = "?"
refresh = "F5"
command_palette = "Ctrl+P"
```

## ๐Ÿš€ Advanced Usage

### Embedding in Applications

```rust
use code_mesh_tui::{TuiApp, TuiConfig};
use code_mesh_core::CodeMesh;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize Code-Mesh core
    let mesh = CodeMesh::new().await?;
    
    // Configure TUI
    let config = TuiConfig::default()
        .with_theme("cyberpunk")
        .with_refresh_rate(500)
        .with_mouse_support(true);
    
    // Create and run TUI
    let mut tui = TuiApp::new(mesh, config).await?;
    tui.run().await?;
    
    Ok(())
}
```

### Custom Views

```rust
use code_mesh_tui::{View, ViewContext, RenderResult};

struct CustomMetricsView {
    data: Vec<Metric>,
}

impl View for CustomMetricsView {
    fn render(&mut self, ctx: &ViewContext) -> RenderResult {
        // Custom rendering logic
        Ok(())
    }
    
    fn handle_input(&mut self, input: InputEvent) -> bool {
        // Custom input handling
        false
    }
}

// Register custom view
tui.register_view("custom_metrics", Box::new(CustomMetricsView::new()));
```

### Remote Monitoring

```bash
# Start Code-Mesh server with TUI endpoint
code-mesh serve --tui-port 8080

# Connect TUI to remote instance
code-mesh-tui --connect ws://remote-server:8080

# SSH tunnel for secure connection
ssh -L 8080:localhost:8080 remote-server
code-mesh-tui --connect ws://localhost:8080
```

## ๐ŸŽฏ Performance Optimization

### For Large Swarms (10+ agents)

```toml
[performance]
# Reduce refresh rate for better performance
refresh_rate = 2000
max_fps = 30

# Limit data retention
buffer_size = 500
max_history = 100

# Disable expensive features
enable_neural_viz = false
show_topology_animation = false
```

### For Resource-Constrained Systems

```toml
[display]
# Use minimal theme
theme = "minimal"
enable_unicode = false

[features]
# Disable non-essential features
enable_audio_alerts = false
enable_notifications = false
show_debug_info = false
```

## ๐Ÿ› Troubleshooting

### Common Issues

**Issue**: TUI doesn't display correctly
**Solution**: Ensure terminal supports 256 colors and Unicode

**Issue**: High CPU usage
**Solution**: Increase refresh_rate in config (e.g., 2000ms)

**Issue**: Connection timeouts
**Solution**: Check network connectivity and increase connection_timeout

**Issue**: Garbled display
**Solution**: Try `--theme minimal` or disable Unicode

### Debug Mode

```bash
# Enable debug logging
export CODE_MESH_TUI_LOG=debug

# Run with debug output
code-mesh-tui --debug 2>debug.log

# Capture screen output
code-mesh-tui --capture-output tui-output.txt
```

## ๐Ÿ“š Documentation

- [TUI User Guide]https://github.com/ruvnet/code-mesh/docs/tui-guide.md
- [Theme Development]https://github.com/ruvnet/code-mesh/docs/tui-themes.md
- [Custom Views]https://github.com/ruvnet/code-mesh/docs/tui-views.md
- [API Reference]https://docs.rs/code-mesh-tui

## ๐Ÿค Contributing

We welcome contributions! Please see our [Contributing Guide](https://github.com/ruvnet/code-mesh/CONTRIBUTING.md) for details.

## ๐Ÿ“œ License

This project is licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License ([LICENSE-MIT]LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

## ๐Ÿ‘จโ€๐Ÿ’ป Creator

**Created by [ruv](https://github.com/ruvnet)** - Innovator in AI-driven development tools and distributed systems.

**Repository**: [github.com/ruvnet/code-mesh](https://github.com/ruvnet/code-mesh)

---

<div align="center">

**Code-Mesh TUI - Visualize Your Swarm Intelligence** ๐Ÿ–ฅ๏ธโœจ

*Beautiful, interactive terminal interface for distributed computing*

</div>