-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtui-dashboard.ts
More file actions
302 lines (258 loc) · 7.97 KB
/
Copy pathtui-dashboard.ts
File metadata and controls
302 lines (258 loc) · 7.97 KB
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
import * as blessed from 'blessed';
import { ChangeProposal, AgentRecommendation } from './types';
export class TUIDashboard {
private screen: blessed.Widgets.Screen;
private proposal: ChangeProposal | null = null;
constructor() {
this.screen = blessed.screen({
smartCSR: true,
title: '🎭 Conductor CLI - Agent Orchestra Dashboard'
});
// Enable mouse support
this.screen.key(['escape', 'q', 'C-c'], () => {
process.exit(0);
});
}
async showProposalDashboard(proposal: ChangeProposal): Promise<string> {
this.proposal = proposal;
this.createLayout();
this.renderContent();
return new Promise((resolve) => {
this.createActionButtons(resolve);
this.screen.render();
});
}
private createLayout(): void {
// Clear screen
this.screen.children.forEach(child => child.destroy());
// Header
const header = blessed.box({
top: 0,
left: 0,
width: '100%',
height: 4,
border: { type: 'line' },
style: {
border: { fg: 'cyan' },
bg: 'black'
},
tags: true,
content: this.getHeaderContent()
});
// Agent Status Grid
const agentGrid = blessed.box({
top: 4,
left: 0,
width: '70%',
height: '60%',
border: { type: 'line' },
label: ' 🤖 Agent Orchestra ',
style: {
border: { fg: 'blue' },
bg: 'black'
},
tags: true,
scrollable: true,
content: this.getAgentGridContent()
});
// Consensus Panel
const consensusPanel = blessed.box({
top: 4,
left: '70%',
width: '30%',
height: '60%',
border: { type: 'line' },
label: ' 📊 Team Consensus ',
style: {
border: { fg: 'green' },
bg: 'black'
},
tags: true,
content: this.getConsensusContent()
});
// Detailed Recommendations
const detailPanel = blessed.box({
top: '64%',
left: 0,
width: '100%',
height: '28%',
border: { type: 'line' },
label: ' 🔍 Detailed Recommendations ',
style: {
border: { fg: 'yellow' },
bg: 'black'
},
tags: true,
scrollable: true,
scrollbar: {
style: { bg: 'yellow' }
},
content: this.getDetailedRecommendations()
});
// Action Bar
const actionBar = blessed.box({
top: '92%',
left: 0,
width: '100%',
height: '8%',
border: { type: 'line' },
style: {
border: { fg: 'magenta' },
bg: 'black'
},
tags: true
});
this.screen.append(header);
this.screen.append(agentGrid);
this.screen.append(consensusPanel);
this.screen.append(detailPanel);
this.screen.append(actionBar);
}
private getHeaderContent(): string {
if (!this.proposal) return '';
const priority = this.getPriorityDisplay(this.proposal.priority);
const type = this.proposal.type.toUpperCase();
return `{center}{bold}{cyan-fg}🎭 CONDUCTOR CLI - AGENT ORCHESTRA{/cyan-fg}{/bold}{/center}
{center}📋 {yellow-fg}${this.proposal.title}{/yellow-fg} | 🎯 {cyan-fg}${type}{/cyan-fg} | ${priority}{/center}`;
}
private getAgentGridContent(): string {
if (!this.proposal) return '';
const agents = this.proposal.agentRecommendations;
let content = '';
// Create grid layout
const columns = 2;
for (let i = 0; i < agents.length; i += columns) {
const row = agents.slice(i, i + columns);
// Agent names
const names = row.map(agent => {
const name = agent.agent.substring(0, 18).padEnd(20);
return `{cyan-fg}${name}{/cyan-fg}`;
}).join(' ');
content += names + '\\n';
// Status
const statuses = row.map(agent => {
const priority = this.getPriorityDisplay(agent.priority);
return `${priority}`.padEnd(20);
}).join(' ');
content += statuses + '\\n';
// Task preview
const tasks = row.map(agent => {
const task = agent.recommendation.substring(0, 18) + '...';
return `{gray-fg}${task.padEnd(20)}{/gray-fg}`;
}).join(' ');
content += tasks + '\\n\\n';
}
return content;
}
private getConsensusContent(): string {
if (!this.proposal) return '';
const agents = this.proposal.agentRecommendations;
const priorities = agents.map(a => a.priority);
const uniquePriorities = [...new Set(priorities)];
const alignment = uniquePriorities.length === 1 ? 'High' :
uniquePriorities.length === 2 ? 'Medium' : 'Low';
const risks = [...new Set(agents.flatMap(a => a.risks || []))];
const impacts = [...new Set(agents.flatMap(a => a.impacts || []))];
return `
{bold}🎯 Priority Alignment{/bold}
{green-fg}${alignment}{/green-fg} (${priorities[0]})
{bold}⚠️ Risk Factors{/bold}
{yellow-fg}${risks.length} identified{/yellow-fg}
{bold}📈 Impact Areas{/bold}
${impacts.slice(0, 3).map(i => `• ${i}`).join('\\n')}
${impacts.length > 3 ? `... +${impacts.length - 3} more` : ''}
{bold}🤖 Active Agents{/bold}
{cyan-fg}${agents.length} specialists{/cyan-fg}
`;
}
private getDetailedRecommendations(): string {
if (!this.proposal) return '';
let content = '';
this.proposal.agentRecommendations.forEach((rec, index) => {
content += `{bold}{cyan-fg}${rec.agent}{/cyan-fg}{/bold} - {gray-fg}${rec.role}{/gray-fg}\\n`;
content += `💡 ${rec.recommendation}\\n`;
content += `🧠 {dim}${rec.reasoning}{/dim}\\n`;
if (rec.risks && rec.risks.length > 0) {
content += `⚠️ {yellow-fg}${rec.risks[0]}{/yellow-fg}`;
if (rec.risks.length > 1) {
content += ` {gray-fg}(+${rec.risks.length - 1} more){/gray-fg}`;
}
content += '\\n';
}
if (this.proposal && index < this.proposal.agentRecommendations.length - 1) {
content += '\\n{gray-fg}────────────────────────────────────────{/gray-fg}\\n\\n';
}
});
return content;
}
private createActionButtons(resolve: (action: string) => void): void {
const actions = [
{ key: 'a', label: '✅ Approve All', value: 'approve-all' },
{ key: 'm', label: '🔧 Modify', value: 'modify' },
{ key: 'i', label: '🔍 Individual', value: 'individual' },
{ key: 'r', label: '❌ Reject', value: 'reject' },
{ key: 's', label: '⏸️ Save Later', value: 'save' }
];
actions.forEach((action, index) => {
const button = blessed.button({
parent: this.screen.children[this.screen.children.length - 1],
mouse: true,
keys: true,
shrink: true,
left: 2 + (index * 16),
top: 1,
width: 14,
height: 3,
content: action.label,
style: {
bg: 'blue',
fg: 'white',
hover: {
bg: 'cyan',
fg: 'black'
},
focus: {
border: { fg: 'yellow' }
}
},
border: { type: 'line' }
});
button.on('press', () => {
resolve(action.value);
});
// Keyboard shortcuts
this.screen.key([action.key], () => {
resolve(action.value);
});
});
// Instructions
const instructions = blessed.text({
parent: this.screen.children[this.screen.children.length - 1],
right: 2,
top: 1,
content: 'Press keys (a,m,i,r,s) or click buttons | ESC/q to quit',
style: {
fg: 'gray'
}
});
}
private getPriorityDisplay(priority: string): string {
const displays = {
'critical': '🔴 CRITICAL',
'high': '🟠 HIGH',
'medium': '🟡 MEDIUM',
'low': '🟢 LOW'
};
return displays[priority as keyof typeof displays] || '⚪ UNKNOWN';
}
private renderContent(): void {
this.screen.render();
}
destroy(): void {
this.screen.destroy();
}
}
// Usage example and export
export function createTUIDashboard(): TUIDashboard {
return new TUIDashboard();
}