@benzsiangco/jarvis 1.0.0 ā 1.1.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/README.md +5 -0
- package/bin/{jarvis.js ā jarvis} +1 -1
- package/dist/cli.js +476 -350
- package/dist/electron/main.js +160 -0
- package/dist/electron/preload.js +19 -0
- package/package.json +21 -8
- package/skills.md +147 -0
- package/src/agents/index.ts +248 -0
- package/src/brain/loader.ts +136 -0
- package/src/cli.ts +411 -0
- package/src/config/index.ts +363 -0
- package/src/core/executor.ts +222 -0
- package/src/core/plugins.ts +148 -0
- package/src/core/types.ts +217 -0
- package/src/electron/main.ts +192 -0
- package/src/electron/preload.ts +25 -0
- package/src/electron/types.d.ts +20 -0
- package/src/index.ts +12 -0
- package/src/providers/antigravity-loader.ts +233 -0
- package/src/providers/antigravity.ts +585 -0
- package/src/providers/index.ts +523 -0
- package/src/sessions/index.ts +194 -0
- package/src/tools/index.ts +436 -0
- package/src/tui/index.tsx +784 -0
- package/src/utils/auth-prompt.ts +394 -0
- package/src/utils/index.ts +180 -0
- package/src/utils/native-picker.ts +71 -0
- package/src/utils/skills.ts +99 -0
- package/src/utils/table-integration-examples.ts +617 -0
- package/src/utils/table-utils.ts +401 -0
- package/src/web/build-ui.ts +27 -0
- package/src/web/server.ts +674 -0
- package/src/web/ui/dist/.gitkeep +0 -0
- package/src/web/ui/dist/main.css +1 -0
- package/src/web/ui/dist/main.js +320 -0
- package/src/web/ui/dist/main.js.map +20 -0
- package/src/web/ui/index.html +46 -0
- package/src/web/ui/src/App.tsx +143 -0
- package/src/web/ui/src/Modules/Safety/GuardianModal.tsx +83 -0
- package/src/web/ui/src/components/Layout/ContextPanel.tsx +243 -0
- package/src/web/ui/src/components/Layout/Header.tsx +91 -0
- package/src/web/ui/src/components/Layout/ModelSelector.tsx +235 -0
- package/src/web/ui/src/components/Layout/SessionStats.tsx +369 -0
- package/src/web/ui/src/components/Layout/Sidebar.tsx +895 -0
- package/src/web/ui/src/components/Modules/Chat/ChatStage.tsx +620 -0
- package/src/web/ui/src/components/Modules/Chat/MessageItem.tsx +446 -0
- package/src/web/ui/src/components/Modules/Editor/CommandInspector.tsx +71 -0
- package/src/web/ui/src/components/Modules/Editor/DiffViewer.tsx +83 -0
- package/src/web/ui/src/components/Modules/Terminal/TabbedTerminal.tsx +202 -0
- package/src/web/ui/src/components/Settings/SettingsModal.tsx +935 -0
- package/src/web/ui/src/config/models.ts +70 -0
- package/src/web/ui/src/main.tsx +13 -0
- package/src/web/ui/src/store/agentStore.ts +41 -0
- package/src/web/ui/src/store/uiStore.ts +64 -0
- package/src/web/ui/src/types/index.ts +54 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jarvis Table Integration Examples
|
|
3
|
+
* Practical examples for using tables in the Jarvis project
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { TerminalTable, createTable, createStatusTable, formatters } from './table-utils';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
// ============================================
|
|
10
|
+
// 1. Session History Table
|
|
11
|
+
// ============================================
|
|
12
|
+
|
|
13
|
+
export interface Session {
|
|
14
|
+
id: string;
|
|
15
|
+
timestamp: Date;
|
|
16
|
+
command: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
tokens: number;
|
|
19
|
+
cost: number;
|
|
20
|
+
duration: number;
|
|
21
|
+
success: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function displaySessionHistory(sessions: Session[]) {
|
|
25
|
+
console.log(chalk.bold.blue('\nš Session History\n'));
|
|
26
|
+
|
|
27
|
+
const table = new TerminalTable([
|
|
28
|
+
{ key: 'id', header: 'ID', width: 8 },
|
|
29
|
+
{ key: 'time', header: 'Time', width: 10 },
|
|
30
|
+
{ key: 'command', header: 'Command', width: 30 },
|
|
31
|
+
{ key: 'provider', header: 'Provider', width: 12, align: 'center' },
|
|
32
|
+
{ key: 'tokens', header: 'Tokens', width: 10, align: 'right' },
|
|
33
|
+
{ key: 'cost', header: 'Cost', width: 10, align: 'right' },
|
|
34
|
+
{ key: 'duration', header: 'Duration', width: 10, align: 'right' },
|
|
35
|
+
{
|
|
36
|
+
key: 'status',
|
|
37
|
+
header: 'Status',
|
|
38
|
+
width: 8,
|
|
39
|
+
align: 'center',
|
|
40
|
+
color: (value) => value === 'ā' ? chalk.green(value) : chalk.red(value),
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
table.addRows(sessions.map(s => ({
|
|
45
|
+
id: s.id.slice(0, 6),
|
|
46
|
+
time: s.timestamp.toLocaleTimeString(),
|
|
47
|
+
command: formatters.truncate(s.command, 28),
|
|
48
|
+
provider: s.provider,
|
|
49
|
+
tokens: formatters.number(s.tokens),
|
|
50
|
+
cost: formatters.currency(s.cost),
|
|
51
|
+
duration: formatters.duration(s.duration),
|
|
52
|
+
status: s.success ? 'ā' : 'ā',
|
|
53
|
+
})));
|
|
54
|
+
|
|
55
|
+
table.print();
|
|
56
|
+
|
|
57
|
+
// Summary
|
|
58
|
+
const totalTokens = sessions.reduce((sum, s) => sum + s.tokens, 0);
|
|
59
|
+
const totalCost = sessions.reduce((sum, s) => sum + s.cost, 0);
|
|
60
|
+
const successRate = (sessions.filter(s => s.success).length / sessions.length) * 100;
|
|
61
|
+
|
|
62
|
+
console.log(chalk.dim('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
63
|
+
console.log(chalk.bold('Summary:'));
|
|
64
|
+
console.log(` Total Sessions: ${chalk.cyan(sessions.length)}`);
|
|
65
|
+
console.log(` Total Tokens: ${chalk.cyan(formatters.number(totalTokens))}`);
|
|
66
|
+
console.log(` Total Cost: ${chalk.cyan(formatters.currency(totalCost))}`);
|
|
67
|
+
console.log(` Success Rate: ${chalk.cyan(formatters.percent(successRate))}`);
|
|
68
|
+
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ============================================
|
|
72
|
+
// 2. Model Comparison Table
|
|
73
|
+
// ============================================
|
|
74
|
+
|
|
75
|
+
export interface ModelInfo {
|
|
76
|
+
name: string;
|
|
77
|
+
provider: string;
|
|
78
|
+
contextWindow: number;
|
|
79
|
+
inputCost: number;
|
|
80
|
+
outputCost: number;
|
|
81
|
+
speed: 'slow' | 'medium' | 'fast' | 'very-fast';
|
|
82
|
+
quality: number; // 1-5
|
|
83
|
+
recommended: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function displayModelComparison(models: ModelInfo[]) {
|
|
87
|
+
console.log(chalk.bold.blue('\nš¤ Available Models\n'));
|
|
88
|
+
|
|
89
|
+
const speedEmojis = {
|
|
90
|
+
'slow': 'š',
|
|
91
|
+
'medium': 'š¶',
|
|
92
|
+
'fast': 'š',
|
|
93
|
+
'very-fast': 'ā”',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const table = new TerminalTable([
|
|
97
|
+
{
|
|
98
|
+
key: 'name',
|
|
99
|
+
header: 'Model',
|
|
100
|
+
color: (value, row) => row.recommended ? chalk.bold.green(value + ' ā') : value,
|
|
101
|
+
},
|
|
102
|
+
{ key: 'provider', header: 'Provider', align: 'center' },
|
|
103
|
+
{ key: 'context', header: 'Context', align: 'right' },
|
|
104
|
+
{ key: 'inputCost', header: 'Input Cost', align: 'right' },
|
|
105
|
+
{ key: 'outputCost', header: 'Output Cost', align: 'right' },
|
|
106
|
+
{ key: 'speed', header: 'Speed', align: 'center' },
|
|
107
|
+
{ key: 'quality', header: 'Quality', align: 'center' },
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
table.addRows(models.map(m => ({
|
|
111
|
+
name: m.name,
|
|
112
|
+
provider: m.provider,
|
|
113
|
+
context: m.contextWindow >= 1000000
|
|
114
|
+
? `${m.contextWindow / 1000000}M`
|
|
115
|
+
: `${m.contextWindow / 1000}K`,
|
|
116
|
+
inputCost: `$${m.inputCost.toFixed(2)}/M`,
|
|
117
|
+
outputCost: `$${m.outputCost.toFixed(2)}/M`,
|
|
118
|
+
speed: speedEmojis[m.speed] + ' ' + m.speed,
|
|
119
|
+
quality: 'ā'.repeat(m.quality),
|
|
120
|
+
recommended: m.recommended,
|
|
121
|
+
})));
|
|
122
|
+
|
|
123
|
+
table.print();
|
|
124
|
+
|
|
125
|
+
console.log(chalk.dim('\nā¹ļø Costs are per million tokens. ā indicates recommended model.\n'));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ============================================
|
|
129
|
+
// 3. File Browser Table
|
|
130
|
+
// ============================================
|
|
131
|
+
|
|
132
|
+
export interface FileInfo {
|
|
133
|
+
name: string;
|
|
134
|
+
type: 'file' | 'directory';
|
|
135
|
+
size: number;
|
|
136
|
+
modified: Date;
|
|
137
|
+
permissions: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function displayFileBrowser(files: FileInfo[], currentPath: string) {
|
|
141
|
+
console.log(chalk.bold.blue(`\nš ${currentPath}\n`));
|
|
142
|
+
|
|
143
|
+
const table = new TerminalTable([
|
|
144
|
+
{
|
|
145
|
+
key: 'icon',
|
|
146
|
+
header: '',
|
|
147
|
+
width: 4,
|
|
148
|
+
},
|
|
149
|
+
{ key: 'name', header: 'Name', width: 40 },
|
|
150
|
+
{ key: 'size', header: 'Size', width: 12, align: 'right' },
|
|
151
|
+
{ key: 'modified', header: 'Modified', width: 20 },
|
|
152
|
+
{ key: 'permissions', header: 'Permissions', width: 12, align: 'center' },
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
table.addRows(files.map(f => ({
|
|
156
|
+
icon: f.type === 'directory' ? 'š' : 'š',
|
|
157
|
+
name: f.type === 'directory' ? chalk.bold.cyan(f.name) : f.name,
|
|
158
|
+
size: f.type === 'directory' ? '-' : formatters.bytes(f.size),
|
|
159
|
+
modified: formatters.datetime(f.modified),
|
|
160
|
+
permissions: f.permissions,
|
|
161
|
+
})));
|
|
162
|
+
|
|
163
|
+
table.print();
|
|
164
|
+
|
|
165
|
+
console.log(chalk.dim(`\nTotal: ${files.length} items\n`));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ============================================
|
|
169
|
+
// 4. Task Queue Table
|
|
170
|
+
// ============================================
|
|
171
|
+
|
|
172
|
+
export interface Task {
|
|
173
|
+
id: string;
|
|
174
|
+
name: string;
|
|
175
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
176
|
+
progress: number; // 0-100
|
|
177
|
+
priority: 'low' | 'medium' | 'high';
|
|
178
|
+
assignedTo?: string;
|
|
179
|
+
estimatedTime?: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function displayTaskQueue(tasks: Task[]) {
|
|
183
|
+
console.log(chalk.bold.blue('\nš Task Queue\n'));
|
|
184
|
+
|
|
185
|
+
const statusColors = {
|
|
186
|
+
pending: (text: string) => chalk.gray(text),
|
|
187
|
+
running: (text: string) => chalk.blue(text),
|
|
188
|
+
completed: (text: string) => chalk.green(text),
|
|
189
|
+
failed: (text: string) => chalk.red(text),
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const priorityColors = {
|
|
193
|
+
low: (text: string) => chalk.gray(text),
|
|
194
|
+
medium: (text: string) => chalk.yellow(text),
|
|
195
|
+
high: (text: string) => chalk.red.bold(text),
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const table = new TerminalTable([
|
|
199
|
+
{ key: 'id', header: 'ID', width: 10 },
|
|
200
|
+
{ key: 'name', header: 'Task', width: 30 },
|
|
201
|
+
{
|
|
202
|
+
key: 'status',
|
|
203
|
+
header: 'Status',
|
|
204
|
+
width: 12,
|
|
205
|
+
align: 'center',
|
|
206
|
+
},
|
|
207
|
+
{ key: 'progress', header: 'Progress', width: 20 },
|
|
208
|
+
{ key: 'priority', header: 'Priority', width: 10, align: 'center' },
|
|
209
|
+
{ key: 'assignedTo', header: 'Assigned To', width: 15 },
|
|
210
|
+
{ key: 'eta', header: 'ETA', width: 10, align: 'right' },
|
|
211
|
+
]);
|
|
212
|
+
|
|
213
|
+
table.addRows(tasks.map(t => {
|
|
214
|
+
const progressBar = createProgressBar(t.progress);
|
|
215
|
+
const statusText = statusColors[t.status](t.status.toUpperCase());
|
|
216
|
+
const priorityText = priorityColors[t.priority](t.priority.toUpperCase());
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
id: t.id,
|
|
220
|
+
name: formatters.truncate(t.name, 28),
|
|
221
|
+
status: statusText,
|
|
222
|
+
progress: progressBar,
|
|
223
|
+
priority: priorityText,
|
|
224
|
+
assignedTo: t.assignedTo || '-',
|
|
225
|
+
eta: t.estimatedTime ? formatters.duration(t.estimatedTime) : '-',
|
|
226
|
+
};
|
|
227
|
+
}));
|
|
228
|
+
|
|
229
|
+
table.print();
|
|
230
|
+
|
|
231
|
+
// Statistics
|
|
232
|
+
const stats = {
|
|
233
|
+
pending: tasks.filter(t => t.status === 'pending').length,
|
|
234
|
+
running: tasks.filter(t => t.status === 'running').length,
|
|
235
|
+
completed: tasks.filter(t => t.status === 'completed').length,
|
|
236
|
+
failed: tasks.filter(t => t.status === 'failed').length,
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
console.log(chalk.dim('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
240
|
+
console.log(chalk.bold('Status Summary:'));
|
|
241
|
+
console.log(` ${chalk.gray('Pending')}: ${stats.pending}`);
|
|
242
|
+
console.log(` ${chalk.blue('Running')}: ${stats.running}`);
|
|
243
|
+
console.log(` ${chalk.green('Completed')}: ${stats.completed}`);
|
|
244
|
+
console.log(` ${chalk.red('Failed')}: ${stats.failed}`);
|
|
245
|
+
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function createProgressBar(percent: number, width: number = 15): string {
|
|
249
|
+
const filled = Math.round((percent / 100) * width);
|
|
250
|
+
const empty = width - filled;
|
|
251
|
+
const bar = 'ā'.repeat(filled) + 'ā'.repeat(empty);
|
|
252
|
+
|
|
253
|
+
if (percent === 100) {
|
|
254
|
+
return chalk.green(bar + ' ' + percent + '%');
|
|
255
|
+
} else if (percent > 50) {
|
|
256
|
+
return chalk.blue(bar + ' ' + percent + '%');
|
|
257
|
+
} else if (percent > 0) {
|
|
258
|
+
return chalk.yellow(bar + ' ' + percent + '%');
|
|
259
|
+
} else {
|
|
260
|
+
return chalk.gray(bar + ' ' + percent + '%');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ============================================
|
|
265
|
+
// 5. Performance Metrics Dashboard
|
|
266
|
+
// ============================================
|
|
267
|
+
|
|
268
|
+
export interface PerformanceMetrics {
|
|
269
|
+
responseTime: number;
|
|
270
|
+
tokensPerSecond: number;
|
|
271
|
+
memoryUsage: number;
|
|
272
|
+
cpuUsage: number;
|
|
273
|
+
requestsPerMinute: number;
|
|
274
|
+
errorRate: number;
|
|
275
|
+
uptime: number;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function displayPerformanceDashboard(metrics: PerformanceMetrics) {
|
|
279
|
+
console.log(chalk.bold.blue('\nā” Performance Dashboard\n'));
|
|
280
|
+
|
|
281
|
+
const getStatus = (value: number, threshold: number, inverted = false) => {
|
|
282
|
+
const exceeded = inverted ? value < threshold : value > threshold;
|
|
283
|
+
return exceeded ? chalk.red('ā Warning') : chalk.green('ā Good');
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
const table = new TerminalTable([
|
|
287
|
+
{ key: 'metric', header: 'Metric', width: 25 },
|
|
288
|
+
{ key: 'value', header: 'Value', width: 20, align: 'right' },
|
|
289
|
+
{ key: 'status', header: 'Status', width: 15, align: 'center' },
|
|
290
|
+
]);
|
|
291
|
+
|
|
292
|
+
table.addRows([
|
|
293
|
+
{
|
|
294
|
+
metric: 'Response Time',
|
|
295
|
+
value: formatters.duration(metrics.responseTime),
|
|
296
|
+
status: getStatus(metrics.responseTime, 1000),
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
metric: 'Tokens/Second',
|
|
300
|
+
value: formatters.number(metrics.tokensPerSecond),
|
|
301
|
+
status: getStatus(metrics.tokensPerSecond, 10, true),
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
metric: 'Memory Usage',
|
|
305
|
+
value: formatters.bytes(metrics.memoryUsage),
|
|
306
|
+
status: getStatus(metrics.memoryUsage, 1024 * 1024 * 512),
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
metric: 'CPU Usage',
|
|
310
|
+
value: formatters.percent(metrics.cpuUsage),
|
|
311
|
+
status: getStatus(metrics.cpuUsage, 80),
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
metric: 'Requests/Minute',
|
|
315
|
+
value: formatters.number(metrics.requestsPerMinute),
|
|
316
|
+
status: chalk.blue('ā¹ Info'),
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
metric: 'Error Rate',
|
|
320
|
+
value: formatters.percent(metrics.errorRate, 2),
|
|
321
|
+
status: getStatus(metrics.errorRate, 1),
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
metric: 'Uptime',
|
|
325
|
+
value: formatters.duration(metrics.uptime),
|
|
326
|
+
status: chalk.green('ā Online'),
|
|
327
|
+
},
|
|
328
|
+
]);
|
|
329
|
+
|
|
330
|
+
table.print();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ============================================
|
|
334
|
+
// 6. Plugin/Extension Table
|
|
335
|
+
// ============================================
|
|
336
|
+
|
|
337
|
+
export interface Plugin {
|
|
338
|
+
name: string;
|
|
339
|
+
version: string;
|
|
340
|
+
enabled: boolean;
|
|
341
|
+
author: string;
|
|
342
|
+
description: string;
|
|
343
|
+
size: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function displayPluginList(plugins: Plugin[]) {
|
|
347
|
+
console.log(chalk.bold.blue('\nš Installed Plugins\n'));
|
|
348
|
+
|
|
349
|
+
const table = new TerminalTable([
|
|
350
|
+
{ key: 'status', header: '', width: 4 },
|
|
351
|
+
{ key: 'name', header: 'Plugin Name', width: 25 },
|
|
352
|
+
{ key: 'version', header: 'Version', width: 10, align: 'center' },
|
|
353
|
+
{ key: 'author', header: 'Author', width: 20 },
|
|
354
|
+
{ key: 'size', header: 'Size', width: 10, align: 'right' },
|
|
355
|
+
{ key: 'description', header: 'Description', width: 35 },
|
|
356
|
+
]);
|
|
357
|
+
|
|
358
|
+
table.addRows(plugins.map(p => ({
|
|
359
|
+
status: p.enabled ? chalk.green('ā') : chalk.gray('ā'),
|
|
360
|
+
name: p.enabled ? chalk.bold(p.name) : chalk.dim(p.name),
|
|
361
|
+
version: p.version,
|
|
362
|
+
author: p.author,
|
|
363
|
+
size: formatters.bytes(p.size),
|
|
364
|
+
description: formatters.truncate(p.description, 33),
|
|
365
|
+
})));
|
|
366
|
+
|
|
367
|
+
table.print();
|
|
368
|
+
|
|
369
|
+
const enabledCount = plugins.filter(p => p.enabled).length;
|
|
370
|
+
console.log(chalk.dim(`\n${enabledCount}/${plugins.length} plugins enabled\n`));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// ============================================
|
|
374
|
+
// 7. Git Status Table
|
|
375
|
+
// ============================================
|
|
376
|
+
|
|
377
|
+
export interface GitFile {
|
|
378
|
+
path: string;
|
|
379
|
+
status: 'modified' | 'added' | 'deleted' | 'renamed' | 'untracked';
|
|
380
|
+
additions: number;
|
|
381
|
+
deletions: number;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export function displayGitStatus(files: GitFile[], branch: string) {
|
|
385
|
+
console.log(chalk.bold.blue(`\nšæ Git Status (${branch})\n`));
|
|
386
|
+
|
|
387
|
+
const statusIcons = {
|
|
388
|
+
modified: chalk.yellow('M'),
|
|
389
|
+
added: chalk.green('A'),
|
|
390
|
+
deleted: chalk.red('D'),
|
|
391
|
+
renamed: chalk.blue('R'),
|
|
392
|
+
untracked: chalk.gray('?'),
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
const table = new TerminalTable([
|
|
396
|
+
{ key: 'status', header: '', width: 4, align: 'center' },
|
|
397
|
+
{ key: 'path', header: 'File', width: 50 },
|
|
398
|
+
{ key: 'changes', header: 'Changes', width: 20, align: 'right' },
|
|
399
|
+
]);
|
|
400
|
+
|
|
401
|
+
table.addRows(files.map(f => ({
|
|
402
|
+
status: statusIcons[f.status],
|
|
403
|
+
path: f.path,
|
|
404
|
+
changes: f.status === 'untracked'
|
|
405
|
+
? chalk.gray('new file')
|
|
406
|
+
: `${chalk.green('+' + f.additions)} ${chalk.red('-' + f.deletions)}`,
|
|
407
|
+
})));
|
|
408
|
+
|
|
409
|
+
table.print();
|
|
410
|
+
|
|
411
|
+
const totalAdd = files.reduce((sum, f) => sum + f.additions, 0);
|
|
412
|
+
const totalDel = files.reduce((sum, f) => sum + f.deletions, 0);
|
|
413
|
+
|
|
414
|
+
console.log(chalk.dim('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
415
|
+
console.log(`Total: ${chalk.green('+' + totalAdd)} ${chalk.red('-' + totalDel)} across ${files.length} files`);
|
|
416
|
+
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ============================================
|
|
420
|
+
// 8. Environment Variables Table
|
|
421
|
+
// ============================================
|
|
422
|
+
|
|
423
|
+
export function displayEnvironmentVariables(env: Record<string, string>) {
|
|
424
|
+
console.log(chalk.bold.blue('\nš Environment Variables\n'));
|
|
425
|
+
|
|
426
|
+
const table = new TerminalTable([
|
|
427
|
+
{ key: 'name', header: 'Variable', width: 30 },
|
|
428
|
+
{ key: 'value', header: 'Value', width: 50 },
|
|
429
|
+
{ key: 'source', header: 'Source', width: 15, align: 'center' },
|
|
430
|
+
]);
|
|
431
|
+
|
|
432
|
+
const entries = Object.entries(env).map(([name, value]) => {
|
|
433
|
+
// Mask sensitive values
|
|
434
|
+
const isSensitive = name.toLowerCase().includes('key') ||
|
|
435
|
+
name.toLowerCase().includes('secret') ||
|
|
436
|
+
name.toLowerCase().includes('password') ||
|
|
437
|
+
name.toLowerCase().includes('token');
|
|
438
|
+
|
|
439
|
+
const displayValue = isSensitive
|
|
440
|
+
? chalk.gray('ā¢ā¢ā¢ā¢ā¢ā¢ā¢ā¢' + value.slice(-4))
|
|
441
|
+
: formatters.truncate(value, 48);
|
|
442
|
+
|
|
443
|
+
const source = process.env[name] ? 'system' : 'custom';
|
|
444
|
+
|
|
445
|
+
return {
|
|
446
|
+
name: isSensitive ? chalk.yellow(name) : name,
|
|
447
|
+
value: displayValue,
|
|
448
|
+
source,
|
|
449
|
+
};
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
table.addRows(entries);
|
|
453
|
+
table.print();
|
|
454
|
+
|
|
455
|
+
console.log(chalk.dim(`\nTotal: ${entries.length} variables\n`));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ============================================
|
|
459
|
+
// Demo: Run All Examples
|
|
460
|
+
// ============================================
|
|
461
|
+
|
|
462
|
+
export function runAllExamples() {
|
|
463
|
+
// 1. Session History
|
|
464
|
+
const sessions: Session[] = [
|
|
465
|
+
{
|
|
466
|
+
id: 'sess-001',
|
|
467
|
+
timestamp: new Date(Date.now() - 3600000),
|
|
468
|
+
command: 'Create a new React component',
|
|
469
|
+
provider: 'OpenAI',
|
|
470
|
+
tokens: 1523,
|
|
471
|
+
cost: 0.0456,
|
|
472
|
+
duration: 3200,
|
|
473
|
+
success: true,
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
id: 'sess-002',
|
|
477
|
+
timestamp: new Date(Date.now() - 1800000),
|
|
478
|
+
command: 'Debug the authentication issue',
|
|
479
|
+
provider: 'Anthropic',
|
|
480
|
+
tokens: 2341,
|
|
481
|
+
cost: 0.0702,
|
|
482
|
+
duration: 5100,
|
|
483
|
+
success: true,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: 'sess-003',
|
|
487
|
+
timestamp: new Date(Date.now() - 900000),
|
|
488
|
+
command: 'Refactor the database queries',
|
|
489
|
+
provider: 'Google',
|
|
490
|
+
tokens: 1876,
|
|
491
|
+
cost: 0.0375,
|
|
492
|
+
duration: 4500,
|
|
493
|
+
success: false,
|
|
494
|
+
},
|
|
495
|
+
];
|
|
496
|
+
displaySessionHistory(sessions);
|
|
497
|
+
|
|
498
|
+
// 2. Model Comparison
|
|
499
|
+
const models: ModelInfo[] = [
|
|
500
|
+
{
|
|
501
|
+
name: 'GPT-4 Turbo',
|
|
502
|
+
provider: 'OpenAI',
|
|
503
|
+
contextWindow: 128000,
|
|
504
|
+
inputCost: 10.00,
|
|
505
|
+
outputCost: 30.00,
|
|
506
|
+
speed: 'fast',
|
|
507
|
+
quality: 5,
|
|
508
|
+
recommended: true,
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: 'Claude 3 Opus',
|
|
512
|
+
provider: 'Anthropic',
|
|
513
|
+
contextWindow: 200000,
|
|
514
|
+
inputCost: 15.00,
|
|
515
|
+
outputCost: 75.00,
|
|
516
|
+
speed: 'medium',
|
|
517
|
+
quality: 5,
|
|
518
|
+
recommended: false,
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: 'Gemini 1.5 Pro',
|
|
522
|
+
provider: 'Google',
|
|
523
|
+
contextWindow: 1000000,
|
|
524
|
+
inputCost: 3.50,
|
|
525
|
+
outputCost: 10.50,
|
|
526
|
+
speed: 'very-fast',
|
|
527
|
+
quality: 4,
|
|
528
|
+
recommended: false,
|
|
529
|
+
},
|
|
530
|
+
];
|
|
531
|
+
displayModelComparison(models);
|
|
532
|
+
|
|
533
|
+
// 3. Task Queue
|
|
534
|
+
const tasks: Task[] = [
|
|
535
|
+
{
|
|
536
|
+
id: 'TASK-001',
|
|
537
|
+
name: 'Implement user authentication',
|
|
538
|
+
status: 'completed',
|
|
539
|
+
progress: 100,
|
|
540
|
+
priority: 'high',
|
|
541
|
+
assignedTo: 'Alice',
|
|
542
|
+
estimatedTime: 0,
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
id: 'TASK-002',
|
|
546
|
+
name: 'Design homepage mockup',
|
|
547
|
+
status: 'running',
|
|
548
|
+
progress: 65,
|
|
549
|
+
priority: 'medium',
|
|
550
|
+
assignedTo: 'Bob',
|
|
551
|
+
estimatedTime: 7200000,
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
id: 'TASK-003',
|
|
555
|
+
name: 'Write API documentation',
|
|
556
|
+
status: 'pending',
|
|
557
|
+
progress: 0,
|
|
558
|
+
priority: 'low',
|
|
559
|
+
assignedTo: 'Carol',
|
|
560
|
+
estimatedTime: 14400000,
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
id: 'TASK-004',
|
|
564
|
+
name: 'Fix critical bug in payment flow',
|
|
565
|
+
status: 'failed',
|
|
566
|
+
progress: 45,
|
|
567
|
+
priority: 'high',
|
|
568
|
+
assignedTo: 'Dave',
|
|
569
|
+
},
|
|
570
|
+
];
|
|
571
|
+
displayTaskQueue(tasks);
|
|
572
|
+
|
|
573
|
+
// 4. Performance Dashboard
|
|
574
|
+
const metrics: PerformanceMetrics = {
|
|
575
|
+
responseTime: 245,
|
|
576
|
+
tokensPerSecond: 45,
|
|
577
|
+
memoryUsage: 256 * 1024 * 1024,
|
|
578
|
+
cpuUsage: 34.5,
|
|
579
|
+
requestsPerMinute: 120,
|
|
580
|
+
errorRate: 0.05,
|
|
581
|
+
uptime: 86400000 * 7,
|
|
582
|
+
};
|
|
583
|
+
displayPerformanceDashboard(metrics);
|
|
584
|
+
|
|
585
|
+
// 5. File Browser
|
|
586
|
+
const files: FileInfo[] = [
|
|
587
|
+
{
|
|
588
|
+
name: 'src',
|
|
589
|
+
type: 'directory',
|
|
590
|
+
size: 0,
|
|
591
|
+
modified: new Date(),
|
|
592
|
+
permissions: 'rwxr-xr-x',
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: 'package.json',
|
|
596
|
+
type: 'file',
|
|
597
|
+
size: 2048,
|
|
598
|
+
modified: new Date(Date.now() - 86400000),
|
|
599
|
+
permissions: 'rw-r--r--',
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
name: 'README.md',
|
|
603
|
+
type: 'file',
|
|
604
|
+
size: 4096,
|
|
605
|
+
modified: new Date(Date.now() - 172800000),
|
|
606
|
+
permissions: 'rw-r--r--',
|
|
607
|
+
},
|
|
608
|
+
];
|
|
609
|
+
displayFileBrowser(files, '/home/user/project');
|
|
610
|
+
|
|
611
|
+
console.log(chalk.bold.green('\n⨠All examples completed!\n'));
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// Run examples if executed directly
|
|
615
|
+
if (import.meta.main) {
|
|
616
|
+
runAllExamples();
|
|
617
|
+
}
|