@covibes/zeroshot 1.0.1

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/LICENSE +21 -0
  3. package/README.md +364 -0
  4. package/cli/index.js +3990 -0
  5. package/cluster-templates/base-templates/debug-workflow.json +181 -0
  6. package/cluster-templates/base-templates/full-workflow.json +455 -0
  7. package/cluster-templates/base-templates/single-worker.json +48 -0
  8. package/cluster-templates/base-templates/worker-validator.json +131 -0
  9. package/cluster-templates/conductor-bootstrap.json +122 -0
  10. package/cluster-templates/conductor-junior-bootstrap.json +69 -0
  11. package/docker/zeroshot-cluster/Dockerfile +132 -0
  12. package/lib/completion.js +174 -0
  13. package/lib/id-detector.js +53 -0
  14. package/lib/settings.js +97 -0
  15. package/lib/stream-json-parser.js +236 -0
  16. package/package.json +121 -0
  17. package/src/agent/agent-config.js +121 -0
  18. package/src/agent/agent-context-builder.js +241 -0
  19. package/src/agent/agent-hook-executor.js +329 -0
  20. package/src/agent/agent-lifecycle.js +555 -0
  21. package/src/agent/agent-stuck-detector.js +256 -0
  22. package/src/agent/agent-task-executor.js +1034 -0
  23. package/src/agent/agent-trigger-evaluator.js +67 -0
  24. package/src/agent-wrapper.js +459 -0
  25. package/src/agents/git-pusher-agent.json +20 -0
  26. package/src/attach/attach-client.js +438 -0
  27. package/src/attach/attach-server.js +543 -0
  28. package/src/attach/index.js +35 -0
  29. package/src/attach/protocol.js +220 -0
  30. package/src/attach/ring-buffer.js +121 -0
  31. package/src/attach/socket-discovery.js +242 -0
  32. package/src/claude-task-runner.js +468 -0
  33. package/src/config-router.js +80 -0
  34. package/src/config-validator.js +598 -0
  35. package/src/github.js +103 -0
  36. package/src/isolation-manager.js +1042 -0
  37. package/src/ledger.js +429 -0
  38. package/src/logic-engine.js +223 -0
  39. package/src/message-bus-bridge.js +139 -0
  40. package/src/message-bus.js +202 -0
  41. package/src/name-generator.js +232 -0
  42. package/src/orchestrator.js +1938 -0
  43. package/src/schemas/sub-cluster.js +156 -0
  44. package/src/sub-cluster-wrapper.js +545 -0
  45. package/src/task-runner.js +28 -0
  46. package/src/template-resolver.js +347 -0
  47. package/src/tui/CHANGES.txt +133 -0
  48. package/src/tui/LAYOUT.md +261 -0
  49. package/src/tui/README.txt +192 -0
  50. package/src/tui/TWO-LEVEL-NAVIGATION.md +186 -0
  51. package/src/tui/data-poller.js +325 -0
  52. package/src/tui/demo.js +208 -0
  53. package/src/tui/formatters.js +123 -0
  54. package/src/tui/index.js +193 -0
  55. package/src/tui/keybindings.js +383 -0
  56. package/src/tui/layout.js +317 -0
  57. package/src/tui/renderer.js +194 -0
@@ -0,0 +1,261 @@
1
+ # TUI Dashboard Layout Module
2
+
3
+ Dashboard layout builder for real-time cluster monitoring with blessed-contrib.
4
+
5
+ ## Overview
6
+
7
+ The layout module creates a responsive terminal UI with a 20x12 grid layout containing:
8
+
9
+ - **Clusters Table** (top-left): View all active clusters, status, agent count, and uptime
10
+ - **System Stats** (top-right): CPU, memory, and cluster statistics
11
+ - **Agents Table** (middle): List all agents with role, status, iteration, and resource usage
12
+ - **Live Logs** (lower): Real-time event stream with color-coded severity levels
13
+ - **Help Bar** (bottom): Keyboard shortcut reference
14
+
15
+ ## Grid Layout
16
+
17
+ ```
18
+ ┌─────────────────────────────────────────────┬─────────────────────┐
19
+ │ Clusters Table (6 rows x 8 cols) │ System Stats Box │
20
+ │ │ (6 rows x 4 cols) │
21
+ ├─────────────────────────────────────────────┴─────────────────────┤
22
+ │ Agents Table (6 rows x 12 cols) │
23
+ ├────────────────────────────────────────────────────────────────────┤
24
+ │ Live Logs (6 rows x 12 cols) │
25
+ ├────────────────────────────────────────────────────────────────────┤
26
+ │ Help Bar (2 rows x 12 cols) │
27
+ └────────────────────────────────────────────────────────────────────┘
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### Basic Setup
33
+
34
+ ```javascript
35
+ const blessed = require('blessed');
36
+ const { createLayout } = require('./layout');
37
+
38
+ // Create screen
39
+ const screen = blessed.screen({ mouse: true, title: 'Cluster Dashboard' });
40
+
41
+ // Create layout
42
+ const layout = createLayout(screen);
43
+
44
+ // Render
45
+ screen.render();
46
+
47
+ // Exit handler
48
+ screen.key(['q', 'C-c'], () => process.exit(0));
49
+ ```
50
+
51
+ ### Updating Tables
52
+
53
+ ```javascript
54
+ const { updateClustersTable, updateAgentsTable, updateStatsBox, addLogEntry } = require('./layout');
55
+
56
+ // Update clusters table
57
+ updateClustersTable(layout.clustersTable, [
58
+ {
59
+ id: 'cluster-swift-falcon',
60
+ status: 'running',
61
+ agentCount: 5,
62
+ config: 'default',
63
+ uptime: '2h 30m',
64
+ },
65
+ ]);
66
+
67
+ // Update agents table
68
+ updateAgentsTable(layout.agentTable, [
69
+ {
70
+ clusterId: 'cluster-swift-falcon',
71
+ id: 'worker-1',
72
+ role: 'worker',
73
+ status: 'running',
74
+ iteration: 3,
75
+ cpu: '12.5%',
76
+ memory: '245 MB',
77
+ },
78
+ ]);
79
+
80
+ // Update system stats
81
+ updateStatsBox(layout.statsBox, {
82
+ activeClusters: 2,
83
+ totalAgents: 5,
84
+ usedMemory: '512 MB',
85
+ totalMemory: '8 GB',
86
+ totalCPU: '26.2%',
87
+ });
88
+
89
+ // Add log entry
90
+ addLogEntry(layout.logsBox, 'Cluster started successfully', 'info');
91
+ addLogEntry(layout.logsBox, 'Warning: High CPU usage', 'warn');
92
+ addLogEntry(layout.logsBox, 'Error: Agent crashed', 'error');
93
+ ```
94
+
95
+ ## API Reference
96
+
97
+ ### createLayout(screen)
98
+
99
+ Creates the dashboard layout with all widgets.
100
+
101
+ **Parameters:**
102
+
103
+ - `screen` (blessed.screen): Blessed screen instance
104
+
105
+ **Returns:**
106
+
107
+ ```javascript
108
+ {
109
+ (screen, // Blessed screen
110
+ grid, // blessed-contrib grid
111
+ clustersTable, // Clusters table widget
112
+ agentTable, // Agents table widget
113
+ statsBox, // System stats box widget
114
+ logsBox, // Live logs widget
115
+ helpBar, // Help bar widget
116
+ widgets, // Array of interactive widgets [clustersTable, agentTable, logsBox]
117
+ focus(index), // Function to focus widget by index
118
+ getCurrentFocus()); // Function to get current focus index
119
+ }
120
+ ```
121
+
122
+ ### updateClustersTable(clustersTable, clusters)
123
+
124
+ Updates the clusters table with current data.
125
+
126
+ **Parameters:**
127
+
128
+ - `clustersTable`: Clusters table widget
129
+ - `clusters` (array): Array of cluster objects with properties:
130
+ - `id` (string): Cluster identifier
131
+ - `status` (string): running | stopped | initializing | stopping | failed | killed
132
+ - `agentCount` (number): Number of agents
133
+ - `config` (string): Configuration name
134
+ - `uptime` (string): Formatted uptime (e.g., "2h 30m")
135
+
136
+ ### updateAgentsTable(agentTable, agents)
137
+
138
+ Updates the agents table with current data.
139
+
140
+ **Parameters:**
141
+
142
+ - `agentTable`: Agents table widget
143
+ - `agents` (array): Array of agent objects with properties:
144
+ - `clusterId` (string): Parent cluster ID
145
+ - `id` (string): Agent identifier
146
+ - `role` (string): worker | validator | orchestrator
147
+ - `status` (string): running | idle | failed
148
+ - `iteration` (number): Current iteration count
149
+ - `cpu` (string): CPU percentage (e.g., "12.5%")
150
+ - `memory` (string): Memory usage (e.g., "245 MB")
151
+
152
+ ### updateStatsBox(statsBox, stats)
153
+
154
+ Updates the system stats box.
155
+
156
+ **Parameters:**
157
+
158
+ - `statsBox`: Stats box widget
159
+ - `stats` (object):
160
+ - `activeClusters` (number): Count of active clusters
161
+ - `totalAgents` (number): Total agent count
162
+ - `usedMemory` (string): Formatted memory usage
163
+ - `totalMemory` (string): Formatted total memory
164
+ - `totalCPU` (string): Total CPU percentage
165
+
166
+ ### addLogEntry(logsBox, message, level)
167
+
168
+ Adds a timestamped log entry.
169
+
170
+ **Parameters:**
171
+
172
+ - `logsBox`: Logs box widget
173
+ - `message` (string): Log message
174
+ - `level` (string): info | warn | error | debug (default: info)
175
+
176
+ ### clearLogs(logsBox)
177
+
178
+ Clears all log entries.
179
+
180
+ **Parameters:**
181
+
182
+ - `logsBox`: Logs box widget
183
+
184
+ ## Keyboard Navigation
185
+
186
+ | Key | Action |
187
+ | --------- | -------------------------- |
188
+ | Tab | Next widget |
189
+ | Shift+Tab | Previous widget |
190
+ | ↑/↓ | Navigate in focused widget |
191
+ | Enter | Select/activate |
192
+ | q | Quit |
193
+
194
+ ## Color Scheme
195
+
196
+ - **Borders**: Cyan
197
+ - **Headers**: Cyan (bold)
198
+ - **Text**: White
199
+ - **Selection**: Black text on cyan background
200
+ - **Log levels**:
201
+ - info: White
202
+ - warn: Yellow
203
+ - error: Red
204
+ - debug: Gray
205
+
206
+ ## Demo
207
+
208
+ Run the included demo:
209
+
210
+ ```bash
211
+ node src/tui/demo.js
212
+ ```
213
+
214
+ Keyboard shortcuts in demo:
215
+
216
+ - [r] - Refresh data
217
+ - [c] - Simulate cluster start
218
+ - [k] - Simulate cluster kill
219
+ - [s] - Simulate warning
220
+ - [q] - Quit
221
+
222
+ ## Testing
223
+
224
+ Run tests:
225
+
226
+ ```bash
227
+ npm test -- tests/tui-layout.test.js
228
+ ```
229
+
230
+ Tests verify:
231
+
232
+ - Layout creation and widget initialization
233
+ - Data update functions
234
+ - Focus navigation
235
+ - Log entry handling
236
+ - Edge cases (empty data, missing properties)
237
+
238
+ ## Styling Customization
239
+
240
+ Widgets can be customized by modifying the configuration objects in `createLayout()`:
241
+
242
+ ```javascript
243
+ const clustersTable = grid.set(0, 0, 6, 8, contrib.table, {
244
+ fg: 'white', // Foreground color
245
+ selectedFg: 'black', // Selected foreground
246
+ selectedBg: 'cyan', // Selected background
247
+ border: { type: 'line', fg: 'cyan' },
248
+ style: {
249
+ header: { fg: 'cyan', bold: true },
250
+ cell: { selected: { fg: 'black', bg: 'cyan' } },
251
+ },
252
+ });
253
+ ```
254
+
255
+ ## Related Modules
256
+
257
+ - `formatters.js` - Value formatting utilities (timestamps, bytes, CPU)
258
+ - `renderer.js` - Additional rendering helpers
259
+ - `keybindings.js` - Keyboard event handlers
260
+ - `data-poller.js` - Real-time data collection
261
+ - `index.js` - Main dashboard integration
@@ -0,0 +1,192 @@
1
+ VIBE WATCH - Interactive TUI Dashboard
2
+ =======================================
3
+
4
+ Launch with: vibe watch
5
+
6
+ OVERVIEW
7
+ --------
8
+ The vibe watch command provides a real-time, htop/k9s-style dashboard for monitoring all active vibe clusters.
9
+
10
+ FEATURES
11
+ --------
12
+ ✓ Real-time cluster state monitoring (1s refresh)
13
+ ✓ CPU and memory tracking per agent (via pidusage)
14
+ ✓ Live message streaming from cluster ledgers
15
+ ✓ Interactive keyboard controls (kill, stop, export)
16
+ ✓ Automatic detection of new clusters
17
+ ✓ System-wide statistics (active clusters, agents, avg resources)
18
+
19
+ LAYOUT
20
+ ------
21
+ ┌─────────────────────────────────────────────────────────┐
22
+ │ VIBE CLUSTER WATCH [q] Quit │
23
+ ├─────────────────────────────────────────────────────────┤
24
+ │ ┌─ Clusters ─────────┐ ┌─ System Stats ──────────────┐ │
25
+ │ │ ID State Time │ │ Active: 2 CPU: 12% │ │
26
+ │ │ ● a-38 RUN 5m │ │ Agents: 7 Mem: 245 MB │ │
27
+ │ │ ● s-62 RUN 2m │ └────────────────────────────┘ │
28
+ │ └────────────────────┘ │
29
+ │ ┌─ Agents ───────────────────────────────────────────┐ │
30
+ │ │ Agent Role State Iter CPU% Mem(MB) │ │
31
+ │ │ worker impl exec 3 8.5 67 │ │
32
+ │ │ validator val idle 1 0.1 42 │ │
33
+ │ └────────────────────────────────────────────────────┘ │
34
+ │ ┌─ Live Logs ────────────────────────────────────────┐ │
35
+ │ │ [09:45:23] worker: TASK_STARTED (iteration 3) │ │
36
+ │ │ [09:45:24] worker: Implementing feature X... │ │
37
+ │ └────────────────────────────────────────────────────┘ │
38
+ │ ┌─ Help ─────────────────────────────────────────────┐ │
39
+ │ │ [↑/↓] Nav [K] Kill [s] Stop [e] Export [q] Quit│ │
40
+ │ └────────────────────────────────────────────────────┘ │
41
+ └─────────────────────────────────────────────────────────┘
42
+
43
+ KEYBOARD SHORTCUTS
44
+ ------------------
45
+ Navigation:
46
+ ↑ / k Move selection up
47
+ ↓ / j Move selection down
48
+
49
+ Actions (on selected cluster):
50
+ K Kill cluster (force, with confirmation)
51
+ s Stop cluster (graceful, with confirmation)
52
+ e Export cluster conversation (markdown)
53
+ l Open full logs in new terminal window
54
+
55
+ View Controls:
56
+ r Force refresh all data
57
+ f Toggle filter (running/stopped/all)
58
+ ? / h Show help dialog
59
+
60
+ Exit:
61
+ q / Ctrl-C Quit (with confirmation if clusters active)
62
+
63
+ USAGE
64
+ -----
65
+ # Launch with defaults
66
+ vibe watch
67
+
68
+ # Filter to only running clusters
69
+ vibe watch --filter running
70
+
71
+ # Faster refresh (500ms instead of 1s)
72
+ vibe watch --refresh-rate 500
73
+
74
+ # Show only stopped clusters
75
+ vibe watch --filter stopped
76
+
77
+ ARCHITECTURE
78
+ ------------
79
+ The TUI is composed of 6 modular components:
80
+
81
+ 1. index.js - Main coordinator, initializes screen/layout/poller
82
+ 2. layout.js - Creates blessed-contrib grid with 5 widgets
83
+ 3. renderer.js - Transforms data into widget updates
84
+ 4. data-poller.js - Polls orchestrator at 4 different intervals
85
+ 5. keybindings.js - Keyboard event handlers and confirmations
86
+ 6. formatters.js - Utility functions (time, bytes, CPU, icons)
87
+
88
+ Data Flow:
89
+ Orchestrator → DataPoller → TUI.onUpdate → Renderer → Widgets → Screen
90
+
91
+ Polling Strategy:
92
+ - Cluster states: 1s (main refresh rate)
93
+ - Resource stats: 2s (expensive pidusage calls)
94
+ - New clusters: 2s (rare event)
95
+ - Log messages: 500ms per cluster (real-time feel)
96
+
97
+ DEPENDENCIES
98
+ ------------
99
+ - blessed@0.1.81 Terminal UI framework
100
+ - blessed-contrib@4.11.0 Dashboard widgets (grid, table, log)
101
+ - pidusage@4.0.1 Cross-platform CPU/memory monitoring
102
+
103
+ TESTING
104
+ -------
105
+ # Run integration test
106
+ node tests/tui-integration.test.js
107
+
108
+ # Run layout demo (interactive)
109
+ node src/tui/demo.js
110
+
111
+ # Run unit tests
112
+ npm test
113
+
114
+ TROUBLESHOOTING
115
+ ---------------
116
+ Q: TUI shows "No clusters found"
117
+ A: Start a cluster first: vibe run "test task" or vibe task run "test"
118
+
119
+ Q: CPU/Memory shows 0%
120
+ A: Process may have died. Check cluster state.
121
+
122
+ Q: Logs not streaming
123
+ A: Ledger database may be locked. Wait a few seconds.
124
+
125
+ Q: Terminal garbled on exit
126
+ A: Try running: reset
127
+
128
+ Q: Keyboard shortcuts not working
129
+ A: Make sure terminal supports key events (most modern terminals do)
130
+
131
+ DEMO MODE
132
+ ---------
133
+ To see the TUI with mock data:
134
+ node src/tui/demo.js
135
+
136
+ This starts a live dashboard with simulated clusters that auto-updates.
137
+ Press [r] to refresh, [c] to add cluster, [k] to kill, [q] to quit.
138
+
139
+ FILES
140
+ -----
141
+ src/tui/
142
+ ├── index.js Main TUI class (6.0K)
143
+ ├── layout.js Widget creation (8.1K)
144
+ ├── renderer.js Data → widgets (5.6K)
145
+ ├── data-poller.js Data collection (8.1K)
146
+ ├── keybindings.js User input (8.9K)
147
+ ├── formatters.js Utilities (3.4K)
148
+ ├── demo.js Interactive demo (5.0K)
149
+ └── LAYOUT.md API documentation (7.4K)
150
+
151
+ tests/
152
+ └── tui-integration.test.js Integration test
153
+
154
+ MODIFICATIONS TO EXISTING FILES
155
+ -------------------------------
156
+ src/agent-wrapper.js
157
+ - Added: this.processPid tracking (line 42)
158
+ - Added: PID capture on spawn (line 605-607)
159
+ - Added: PROCESS_SPAWNED lifecycle event
160
+ - Added: TASK_ID_ASSIGNED lifecycle event
161
+ - Added: pid field in getState() (line 1350)
162
+
163
+ cli/index.js
164
+ - Added: vibe watch command with options
165
+
166
+ lib/completion.js
167
+ - Added: Shell completion for watch command
168
+
169
+ package.json
170
+ - Added: blessed, blessed-contrib, pidusage dependencies
171
+
172
+ FUTURE ENHANCEMENTS
173
+ -------------------
174
+ Potential improvements:
175
+ - [ ] Sorting clusters by various fields
176
+ - [ ] Filtering by cluster config name
177
+ - [ ] Graph view for CPU/memory over time
178
+ - [ ] Search/filter logs by keyword
179
+ - [ ] Export selected logs to file
180
+ - [ ] Cluster health indicators
181
+ - [ ] Alert notifications for failures
182
+ - [ ] Docker container stats (for isolation mode)
183
+ - [ ] Network I/O stats
184
+ - [ ] Agent communication graph visualization
185
+
186
+ CREDITS
187
+ -------
188
+ Implementation: 6 parallel agents (Dec 2024)
189
+ Architecture: blessed-contrib grid system
190
+ Inspiration: htop, k9s, lazydocker
191
+
192
+ For issues or feature requests, see vibe/cluster GitHub repo.
@@ -0,0 +1,186 @@
1
+ # Two-Level Navigation - Implementation Summary
2
+
3
+ ## Overview
4
+
5
+ Completely redesigned TUI layout with separate views for overview and detail modes:
6
+
7
+ 1. **Overview mode** (default): ONLY clusters + stats - clean, focused view
8
+ 2. Press Enter → **Detail mode**: ONLY agents + logs for selected cluster
9
+ 3. Press Escape → Return to overview
10
+
11
+ ## User Experience
12
+
13
+ ### Overview Mode (Default)
14
+
15
+ - **ONLY visible:** Large clusters table (16 rows) + system stats sidebar
16
+ - **Hidden:** Agent table and logs (completely invisible)
17
+ - Clean, spacious layout focusing on cluster selection
18
+ - Help text: `[Enter] View [↑/↓] Navigate [k] Kill [s] Stop [l] Logs [r] Refresh [q] Quit`
19
+
20
+ ### Detail Mode (After pressing Enter)
21
+
22
+ - **ONLY visible:** Full-width agents table (9 rows) + full-width logs (9 rows)
23
+ - **Hidden:** Clusters table and stats box (completely invisible)
24
+ - Dedicated space for monitoring single cluster in depth
25
+ - Help text: `[Esc] Back [k] Kill [s] Stop [e] Export [l] Logs [r] Refresh [q] Quit`
26
+
27
+ ### Navigation Flow
28
+
29
+ ```
30
+ Overview (ONLY clusters + stats)
31
+ ↓ Enter
32
+ Detail (ONLY agents + logs)
33
+ ↓ Escape
34
+ Overview (ONLY clusters + stats)
35
+ ```
36
+
37
+ ## Implementation Details
38
+
39
+ ### Layout Design
40
+
41
+ **Overview mode layout** (`src/tui/layout.js`):
42
+
43
+ - Clusters table: rows 0-16 (16 rows), cols 0-8
44
+ - Stats box: rows 0-16 (16 rows), cols 8-12
45
+ - Help bar: rows 18-20
46
+ - Agents/logs: **hidden** (`.hide()` called on initialization)
47
+
48
+ **Detail mode layout** (`src/tui/layout.js`):
49
+
50
+ - Agents table: rows 0-9 (9 rows), cols 0-12 (full width)
51
+ - Logs box: rows 9-18 (9 rows), cols 0-12 (full width)
52
+ - Help bar: rows 18-20
53
+ - Clusters/stats: **hidden** (`.hide()` called on mode switch)
54
+
55
+ ### State Management
56
+
57
+ **New state in TUI class (`src/tui/index.js`):**
58
+
59
+ ```javascript
60
+ this.viewMode = 'overview'; // or 'detail'
61
+ this.detailClusterId = null; // cluster ID when in detail mode
62
+ ```
63
+
64
+ ### Keybindings
65
+
66
+ **Enter key** (`src/tui/keybindings.js` lines 14-37):
67
+
68
+ - Checks if in overview mode with clusters available
69
+ - Sets `viewMode = 'detail'` and `detailClusterId`
70
+ - **Hides** clusters table and stats box (`.hide()`)
71
+ - **Shows** agents table and logs box (`.show()`)
72
+ - Updates help text
73
+ - Clears old messages
74
+
75
+ **Escape key** (`src/tui/keybindings.js` lines 39-59):
76
+
77
+ - Checks if in detail mode
78
+ - Sets `viewMode = 'overview'` and `detailClusterId = null`
79
+ - **Shows** clusters table and stats box (`.show()`)
80
+ - **Hides** agents table and logs box (`.hide()`)
81
+ - Updates help text
82
+ - Clears messages
83
+
84
+ ### Conditional Rendering
85
+
86
+ **Cluster state updates** (`src/tui/index.js` lines 107-119):
87
+
88
+ ```javascript
89
+ if (this.viewMode === 'detail' && this.detailClusterId) {
90
+ // Show agents for detail cluster
91
+ const status = this.orchestrator.getStatus(this.detailClusterId);
92
+ this.renderer.renderAgentTable(status.agents, this.resourceStats);
93
+ } else if (this.viewMode === 'overview') {
94
+ // Don't show agents in overview
95
+ this.renderer.renderAgentTable([], this.resourceStats);
96
+ }
97
+ ```
98
+
99
+ **Resource stats updates** (`src/tui/index.js` lines 130-137):
100
+
101
+ - Same conditional logic as above
102
+ - Only renders agents in detail mode
103
+
104
+ ## Testing
105
+
106
+ ### Automated Tests
107
+
108
+ **Test 1: `tests/tui-integration.test.js`**
109
+
110
+ - Basic TUI startup
111
+ - Data loading
112
+ - Module integration
113
+ - ✅ PASSING
114
+
115
+ **Test 2: `tests/tui-navigation-test.js`**
116
+
117
+ - Initial state verification
118
+ - Enter detail view
119
+ - Verify agents shown
120
+ - Return to overview
121
+ - Conditional rendering logic
122
+ - ✅ PASSING
123
+
124
+ ### Manual Testing
125
+
126
+ **Run the manual test:**
127
+
128
+ ```bash
129
+ chmod +x tests/tui-keybindings-manual-test.js
130
+ node tests/tui-keybindings-manual-test.js
131
+ ```
132
+
133
+ **Instructions:**
134
+
135
+ 1. Press ↑/↓ or j/k to navigate clusters
136
+ 2. Press Enter to drill into detail view → clusters/stats hide, agents/logs appear
137
+ 3. Press Escape to return to overview → clusters/stats reappear, agents/logs hide
138
+ 4. Verify help text updates correctly
139
+
140
+ ## Files Modified
141
+
142
+ | File | Changes |
143
+ | ------------------------ | ------------------------------------------------------- |
144
+ | `src/tui/index.js` | Added viewMode state, conditional rendering |
145
+ | `src/tui/keybindings.js` | Added Enter/Escape handlers, widget visibility toggling |
146
+ | `src/tui/layout.js` | Updated help text to show Enter key |
147
+ | `src/tui/CHANGES.txt` | Documented feature and technical changes |
148
+
149
+ ## Files Created
150
+
151
+ | File | Purpose |
152
+ | -------------------------------------- | --------------------------------------- |
153
+ | `tests/tui-navigation-test.js` | Automated test for two-level navigation |
154
+ | `tests/tui-keybindings-manual-test.js` | Interactive manual test |
155
+ | `src/tui/TWO-LEVEL-NAVIGATION.md` | This document |
156
+
157
+ ## Performance Impact
158
+
159
+ - **Startup:** No impact (viewMode check is O(1))
160
+ - **Rendering:** Slight improvement in overview mode (no agent data fetching)
161
+ - **Memory:** Minimal increase (2 new state variables)
162
+
163
+ ## Known Limitations
164
+
165
+ None. Feature is complete and tested.
166
+
167
+ ## Usage
168
+
169
+ ```bash
170
+ # Start TUI (shows overview by default)
171
+ zeroshot watch
172
+
173
+ # In overview:
174
+ # - Use ↑/↓ or j/k to select cluster
175
+ # - Press Enter to drill into detail view
176
+
177
+ # In detail:
178
+ # - View agents and logs for selected cluster
179
+ # - Press Escape to return to overview
180
+ ```
181
+
182
+ ## Future Enhancements (Optional)
183
+
184
+ - Add breadcrumb showing current cluster in detail mode
185
+ - Add keybinding to jump directly to a cluster by ID
186
+ - Add "pinning" to keep detail view on specific cluster even when new clusters spawn