@lanonasis/cli 3.6.3 → 3.6.5
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/dist/commands/api-keys.d.ts +1 -2
- package/dist/commands/api-keys.js +78 -73
- package/dist/commands/auth.js +167 -160
- package/dist/commands/completion.js +39 -31
- package/dist/commands/config.js +201 -162
- package/dist/commands/enhanced-memory.js +17 -11
- package/dist/commands/guide.js +88 -79
- package/dist/commands/init.js +20 -14
- package/dist/commands/mcp.js +173 -142
- package/dist/commands/memory.js +83 -77
- package/dist/commands/organization.js +21 -15
- package/dist/commands/topics.js +58 -52
- package/dist/core/achievements.js +26 -19
- package/dist/core/architecture.js +59 -42
- package/dist/core/dashboard.js +81 -71
- package/dist/core/error-handler.js +39 -30
- package/dist/core/power-mode.js +53 -46
- package/dist/core/progress.js +44 -35
- package/dist/core/welcome.js +64 -56
- package/dist/enhanced-cli.js +58 -49
- package/dist/index-simple.js +112 -74
- package/dist/index.js +68 -63
- package/dist/mcp/access-control.js +17 -13
- package/dist/mcp/client/enhanced-client.js +23 -16
- package/dist/mcp/enhanced-server.js +14 -10
- package/dist/mcp/logger.js +6 -2
- package/dist/mcp/memory-state.js +17 -13
- package/dist/mcp/schemas/tool-schemas.d.ts +28 -28
- package/dist/mcp/schemas/tool-schemas.js +126 -122
- package/dist/mcp/server/lanonasis-server.js +51 -44
- package/dist/mcp/transports/transport-manager.js +25 -18
- package/dist/mcp/vector-store.js +10 -6
- package/dist/mcp-server.js +21 -17
- package/dist/utils/api.js +30 -21
- package/dist/utils/config.js +61 -15
- package/dist/utils/formatting.js +14 -6
- package/dist/utils/mcp-client.js +132 -77
- package/package.json +17 -92
- package/dist/completions/bash-completion.sh +0 -88
- package/dist/completions/fish-completion.fish +0 -132
- package/dist/completions/zsh-completion.zsh +0 -196
package/dist/core/dashboard.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Main Dashboard Command Center
|
|
3
4
|
* The central hub for all CLI operations after authentication
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AnalyticsView = exports.InteractiveSearch = exports.InteractiveMemoryCreator = exports.DashboardCommandCenter = void 0;
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
13
|
+
const boxen_1 = __importDefault(require("boxen"));
|
|
14
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
15
|
+
class DashboardCommandCenter {
|
|
10
16
|
stateManager;
|
|
11
17
|
stats;
|
|
12
18
|
constructor(stateManager) {
|
|
@@ -34,7 +40,7 @@ export class DashboardCommandCenter {
|
|
|
34
40
|
const header = `Onasis Command Center`;
|
|
35
41
|
const userInfo = `◐ ${email}`;
|
|
36
42
|
const padding = 72 - header.length - userInfo.length - 4;
|
|
37
|
-
return
|
|
43
|
+
return (0, boxen_1.default)(chalk_1.default.bold(header) + ' '.repeat(padding) + chalk_1.default.dim(userInfo), {
|
|
38
44
|
borderStyle: 'round',
|
|
39
45
|
borderColor: 'cyan',
|
|
40
46
|
padding: 0
|
|
@@ -57,19 +63,19 @@ export class DashboardCommandCenter {
|
|
|
57
63
|
}
|
|
58
64
|
renderQuickStats() {
|
|
59
65
|
const stats = [
|
|
60
|
-
`├─ ${
|
|
61
|
-
`├─ ${
|
|
62
|
-
`└─ ${
|
|
66
|
+
`├─ ${chalk_1.default.bold(this.stats.totalMemories)} Memories`,
|
|
67
|
+
`├─ ${chalk_1.default.bold(this.stats.totalTopics)} Topics`,
|
|
68
|
+
`└─ ${chalk_1.default.bold(this.stats.apiKeys)} API Keys`
|
|
63
69
|
];
|
|
64
|
-
return
|
|
70
|
+
return chalk_1.default.blue('📊 Quick Stats\n') + stats.join('\n');
|
|
65
71
|
}
|
|
66
72
|
renderRecentActivity() {
|
|
67
73
|
const activities = this.stats.recentActivity.slice(0, 3).map((activity, index) => {
|
|
68
74
|
const isLast = index === this.stats.recentActivity.slice(0, 3).length - 1;
|
|
69
75
|
const prefix = isLast ? '└─' : '├─';
|
|
70
|
-
return `${prefix} "${activity.target}" ${
|
|
76
|
+
return `${prefix} "${activity.target}" ${chalk_1.default.dim(`(${activity.timestamp})`)}`;
|
|
71
77
|
});
|
|
72
|
-
return
|
|
78
|
+
return chalk_1.default.green('🎯 Recent Activity\n') + activities.join('\n');
|
|
73
79
|
}
|
|
74
80
|
renderMainMenu() {
|
|
75
81
|
const menuItems = [
|
|
@@ -77,28 +83,28 @@ export class DashboardCommandCenter {
|
|
|
77
83
|
['2. 📁 Browse Topics', '5. 🔑 Manage API Keys'],
|
|
78
84
|
['3. 📊 View Analytics', '6. ⚙️ Settings']
|
|
79
85
|
];
|
|
80
|
-
const menuContent =
|
|
86
|
+
const menuContent = chalk_1.default.bold('What would you like to do?\n\n') +
|
|
81
87
|
menuItems.map(row => ` ${row[0]} ${row[1]}`).join('\n') +
|
|
82
88
|
'\n\n' +
|
|
83
|
-
|
|
84
|
-
return
|
|
89
|
+
chalk_1.default.dim('Type a number, command, or describe what you need...');
|
|
90
|
+
return (0, boxen_1.default)(menuContent, {
|
|
85
91
|
padding: 1,
|
|
86
92
|
borderStyle: 'single',
|
|
87
93
|
borderColor: 'gray'
|
|
88
94
|
});
|
|
89
95
|
}
|
|
90
96
|
renderFooter() {
|
|
91
|
-
return
|
|
97
|
+
return chalk_1.default.dim(' [↵] Smart Command [/] Search [Tab] Complete [?] Help');
|
|
92
98
|
}
|
|
93
99
|
async handleUserInput() {
|
|
94
|
-
const { input } = await
|
|
100
|
+
const { input } = await inquirer_1.default.prompt({
|
|
95
101
|
type: 'input',
|
|
96
102
|
name: 'input',
|
|
97
|
-
message:
|
|
103
|
+
message: chalk_1.default.green('>'),
|
|
98
104
|
transformer: (input) => {
|
|
99
105
|
// Real-time input transformation/hints
|
|
100
106
|
if (input.startsWith('/')) {
|
|
101
|
-
return
|
|
107
|
+
return chalk_1.default.cyan(input) + chalk_1.default.dim(' (search mode)');
|
|
102
108
|
}
|
|
103
109
|
return input;
|
|
104
110
|
}
|
|
@@ -171,31 +177,31 @@ export class DashboardCommandCenter {
|
|
|
171
177
|
await search.search(_query);
|
|
172
178
|
}
|
|
173
179
|
async browseTopics() {
|
|
174
|
-
console.log(
|
|
180
|
+
console.log(chalk_1.default.yellow('Browse Topics - Coming soon...'));
|
|
175
181
|
}
|
|
176
182
|
async viewAnalytics() {
|
|
177
183
|
const analytics = new AnalyticsView(this.stateManager);
|
|
178
184
|
await analytics.show();
|
|
179
185
|
}
|
|
180
186
|
async manageApiKeys() {
|
|
181
|
-
console.log(
|
|
187
|
+
console.log(chalk_1.default.yellow('API Key Management - Coming soon...'));
|
|
182
188
|
}
|
|
183
189
|
async openSettings() {
|
|
184
|
-
console.log(
|
|
190
|
+
console.log(chalk_1.default.yellow('Settings - Coming soon...'));
|
|
185
191
|
}
|
|
186
192
|
async showHelp() {
|
|
187
|
-
console.log(
|
|
188
|
-
|
|
193
|
+
console.log((0, boxen_1.default)(chalk_1.default.bold('📚 Help & Commands\n\n') +
|
|
194
|
+
chalk_1.default.cyan('Creating Memories:\n') +
|
|
189
195
|
' create, new, add - Start creating a new memory\n' +
|
|
190
196
|
' "remember that..." - Natural language memory creation\n\n' +
|
|
191
|
-
|
|
197
|
+
chalk_1.default.cyan('Searching:\n') +
|
|
192
198
|
' search, find, / - Search your memories\n' +
|
|
193
199
|
' /keyword - Quick search for keyword\n\n' +
|
|
194
|
-
|
|
200
|
+
chalk_1.default.cyan('Navigation:\n') +
|
|
195
201
|
' 1-6 - Select numbered menu options\n' +
|
|
196
202
|
' back, exit - Return to previous screen\n' +
|
|
197
203
|
' clear - Clear the screen\n\n' +
|
|
198
|
-
|
|
204
|
+
chalk_1.default.dim('Pro tip: Use Tab for auto-completion'), {
|
|
199
205
|
padding: 1,
|
|
200
206
|
borderStyle: 'single',
|
|
201
207
|
borderColor: 'gray'
|
|
@@ -203,7 +209,7 @@ export class DashboardCommandCenter {
|
|
|
203
209
|
}
|
|
204
210
|
async interpretSmartCommand(input) {
|
|
205
211
|
// AI-powered command interpretation
|
|
206
|
-
console.log(
|
|
212
|
+
console.log(chalk_1.default.dim(`Interpreting: "${input}"...`));
|
|
207
213
|
// Simulate smart interpretation
|
|
208
214
|
if (input.toLowerCase().includes('remember')) {
|
|
209
215
|
const content = input.replace(/remember( that)?/i, '').trim();
|
|
@@ -211,7 +217,7 @@ export class DashboardCommandCenter {
|
|
|
211
217
|
await creator.createQuick(content);
|
|
212
218
|
}
|
|
213
219
|
else {
|
|
214
|
-
console.log(
|
|
220
|
+
console.log(chalk_1.default.yellow(`Command not recognized. Type '?' for help.`));
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
loadStats() {
|
|
@@ -228,20 +234,21 @@ export class DashboardCommandCenter {
|
|
|
228
234
|
};
|
|
229
235
|
}
|
|
230
236
|
}
|
|
237
|
+
exports.DashboardCommandCenter = DashboardCommandCenter;
|
|
231
238
|
/**
|
|
232
239
|
* Interactive Memory Creator
|
|
233
240
|
*/
|
|
234
|
-
|
|
241
|
+
class InteractiveMemoryCreator {
|
|
235
242
|
stateManager;
|
|
236
243
|
constructor(stateManager) {
|
|
237
244
|
this.stateManager = stateManager;
|
|
238
245
|
}
|
|
239
246
|
async create() {
|
|
240
247
|
console.clear();
|
|
241
|
-
console.log(
|
|
248
|
+
console.log(chalk_1.default.bold.blue('📝 Creating New Memory\n'));
|
|
242
249
|
console.log("Let's capture your knowledge. I'll guide you through it:\n");
|
|
243
250
|
// Title input with validation
|
|
244
|
-
const { title } = await
|
|
251
|
+
const { title } = await inquirer_1.default.prompt([
|
|
245
252
|
{
|
|
246
253
|
type: 'input',
|
|
247
254
|
name: 'title',
|
|
@@ -257,15 +264,15 @@ export class InteractiveMemoryCreator {
|
|
|
257
264
|
},
|
|
258
265
|
transformer: (input) => {
|
|
259
266
|
if (input.length > 0) {
|
|
260
|
-
return input +
|
|
267
|
+
return input + chalk_1.default.dim(` (${input.length}/100)`);
|
|
261
268
|
}
|
|
262
269
|
return input;
|
|
263
270
|
}
|
|
264
271
|
}
|
|
265
272
|
]);
|
|
266
|
-
console.log(
|
|
273
|
+
console.log(chalk_1.default.green('✓ Great title! Clear and searchable.\n'));
|
|
267
274
|
// Content input
|
|
268
|
-
const { content } = await
|
|
275
|
+
const { content } = await inquirer_1.default.prompt([
|
|
269
276
|
{
|
|
270
277
|
type: 'editor',
|
|
271
278
|
name: 'content',
|
|
@@ -277,8 +284,8 @@ export class InteractiveMemoryCreator {
|
|
|
277
284
|
// Analyze content and suggest metadata
|
|
278
285
|
const suggestions = this.analyzeContent(content);
|
|
279
286
|
if (suggestions.topic) {
|
|
280
|
-
console.log(
|
|
281
|
-
const { topicChoice } = await
|
|
287
|
+
console.log(chalk_1.default.cyan(`📎 I noticed this looks like ${suggestions.contentType}. Would you like to:`));
|
|
288
|
+
const { topicChoice } = await inquirer_1.default.prompt([
|
|
282
289
|
{
|
|
283
290
|
type: 'list',
|
|
284
291
|
name: 'topicChoice',
|
|
@@ -291,7 +298,7 @@ export class InteractiveMemoryCreator {
|
|
|
291
298
|
}
|
|
292
299
|
]);
|
|
293
300
|
if (topicChoice === 'new') {
|
|
294
|
-
const { newTopic } = await
|
|
301
|
+
const { newTopic } = await inquirer_1.default.prompt([
|
|
295
302
|
{
|
|
296
303
|
type: 'input',
|
|
297
304
|
name: 'newTopic',
|
|
@@ -306,8 +313,8 @@ export class InteractiveMemoryCreator {
|
|
|
306
313
|
}
|
|
307
314
|
// Tag selection
|
|
308
315
|
if (suggestions.tags.length > 0) {
|
|
309
|
-
console.log(
|
|
310
|
-
const { selectedTags } = await
|
|
316
|
+
console.log(chalk_1.default.cyan('🏷️ Suggested tags based on content:'));
|
|
317
|
+
const { selectedTags } = await inquirer_1.default.prompt([
|
|
311
318
|
{
|
|
312
319
|
type: 'checkbox',
|
|
313
320
|
name: 'selectedTags',
|
|
@@ -320,7 +327,7 @@ export class InteractiveMemoryCreator {
|
|
|
320
327
|
pageSize: 10
|
|
321
328
|
}
|
|
322
329
|
]);
|
|
323
|
-
const { additionalTags } = await
|
|
330
|
+
const { additionalTags } = await inquirer_1.default.prompt([
|
|
324
331
|
{
|
|
325
332
|
type: 'input',
|
|
326
333
|
name: 'additionalTags',
|
|
@@ -334,7 +341,7 @@ export class InteractiveMemoryCreator {
|
|
|
334
341
|
suggestions.tags = selectedTags;
|
|
335
342
|
}
|
|
336
343
|
// Memory type selection
|
|
337
|
-
const { memoryType } = await
|
|
344
|
+
const { memoryType } = await inquirer_1.default.prompt([
|
|
338
345
|
{
|
|
339
346
|
type: 'list',
|
|
340
347
|
name: 'memoryType',
|
|
@@ -356,7 +363,7 @@ export class InteractiveMemoryCreator {
|
|
|
356
363
|
type: memoryType
|
|
357
364
|
});
|
|
358
365
|
// Confirm save
|
|
359
|
-
const { action } = await
|
|
366
|
+
const { action } = await inquirer_1.default.prompt([
|
|
360
367
|
{
|
|
361
368
|
type: 'list',
|
|
362
369
|
name: 'action',
|
|
@@ -369,8 +376,8 @@ export class InteractiveMemoryCreator {
|
|
|
369
376
|
}
|
|
370
377
|
]);
|
|
371
378
|
if (action === 'save') {
|
|
372
|
-
console.log(
|
|
373
|
-
console.log(
|
|
379
|
+
console.log(chalk_1.default.green('\n✓ Memory saved successfully!'));
|
|
380
|
+
console.log(chalk_1.default.dim('ID: mem_abc123'));
|
|
374
381
|
}
|
|
375
382
|
else if (action === 'edit') {
|
|
376
383
|
// Restart the process
|
|
@@ -378,7 +385,7 @@ export class InteractiveMemoryCreator {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
async createQuick(content) {
|
|
381
|
-
console.log(
|
|
388
|
+
console.log(chalk_1.default.green(`✓ Quick memory created: "${content}"`));
|
|
382
389
|
}
|
|
383
390
|
analyzeContent(content) {
|
|
384
391
|
// Simple content analysis
|
|
@@ -410,11 +417,11 @@ export class InteractiveMemoryCreator {
|
|
|
410
417
|
reference: '📖',
|
|
411
418
|
project: '🎯'
|
|
412
419
|
}[memory.type] || '📝';
|
|
413
|
-
console.log(
|
|
414
|
-
`${
|
|
415
|
-
`${
|
|
416
|
-
`${
|
|
417
|
-
|
|
420
|
+
console.log((0, boxen_1.default)(`${typeIcon} ${chalk_1.default.bold(memory.type.charAt(0).toUpperCase() + memory.type.slice(1))} Memory\n\n` +
|
|
421
|
+
`${chalk_1.default.bold('Title:')} ${memory.title}\n` +
|
|
422
|
+
`${chalk_1.default.bold('Topic:')} ${memory.topic || 'None'}\n` +
|
|
423
|
+
`${chalk_1.default.bold('Tags:')} ${memory.tags.join(', ')}\n\n` +
|
|
424
|
+
chalk_1.default.dim(memory.content.substring(0, 100) + '...'), {
|
|
418
425
|
padding: 1,
|
|
419
426
|
borderStyle: 'single',
|
|
420
427
|
borderColor: 'green',
|
|
@@ -423,18 +430,19 @@ export class InteractiveMemoryCreator {
|
|
|
423
430
|
}));
|
|
424
431
|
}
|
|
425
432
|
}
|
|
433
|
+
exports.InteractiveMemoryCreator = InteractiveMemoryCreator;
|
|
426
434
|
/**
|
|
427
435
|
* Interactive Search Experience
|
|
428
436
|
*/
|
|
429
|
-
|
|
437
|
+
class InteractiveSearch {
|
|
430
438
|
stateManager;
|
|
431
439
|
constructor(stateManager) {
|
|
432
440
|
this.stateManager = stateManager;
|
|
433
441
|
}
|
|
434
442
|
async search(initialQuery = '') {
|
|
435
443
|
console.clear();
|
|
436
|
-
console.log(
|
|
437
|
-
const { query } = await
|
|
444
|
+
console.log(chalk_1.default.bold.blue('🔍 Search Everything\n'));
|
|
445
|
+
const { query } = await inquirer_1.default.prompt([
|
|
438
446
|
{
|
|
439
447
|
type: 'input',
|
|
440
448
|
name: 'query',
|
|
@@ -442,7 +450,7 @@ export class InteractiveSearch {
|
|
|
442
450
|
default: initialQuery,
|
|
443
451
|
transformer: (input) => {
|
|
444
452
|
if (input.length > 0) {
|
|
445
|
-
return
|
|
453
|
+
return chalk_1.default.cyan(input);
|
|
446
454
|
}
|
|
447
455
|
return input;
|
|
448
456
|
}
|
|
@@ -452,12 +460,12 @@ export class InteractiveSearch {
|
|
|
452
460
|
return;
|
|
453
461
|
}
|
|
454
462
|
// Simulate search
|
|
455
|
-
console.log(
|
|
463
|
+
console.log(chalk_1.default.dim(`\nSearching for "${query}"...`));
|
|
456
464
|
await this.simulateDelay(500);
|
|
457
465
|
// Display results
|
|
458
466
|
this.displayResults(query);
|
|
459
467
|
// Result actions
|
|
460
|
-
const { action } = await
|
|
468
|
+
const { action } = await inquirer_1.default.prompt([
|
|
461
469
|
{
|
|
462
470
|
type: 'list',
|
|
463
471
|
name: 'action',
|
|
@@ -480,7 +488,7 @@ export class InteractiveSearch {
|
|
|
480
488
|
await this.search('');
|
|
481
489
|
break;
|
|
482
490
|
case 'view':
|
|
483
|
-
console.log(
|
|
491
|
+
console.log(chalk_1.default.green('Viewing result...'));
|
|
484
492
|
break;
|
|
485
493
|
}
|
|
486
494
|
}
|
|
@@ -490,12 +498,12 @@ export class InteractiveSearch {
|
|
|
490
498
|
{ score: 87, title: 'Payment Error Handling Strategy', age: '1 week ago', type: 'Context', tags: 'error-handling, payments' },
|
|
491
499
|
{ score: 76, title: 'Q3 Payment Provider Comparison', age: '2 weeks ago', type: 'Reference', tags: 'analysis, vendors' }
|
|
492
500
|
];
|
|
493
|
-
console.log(
|
|
501
|
+
console.log((0, boxen_1.default)(chalk_1.default.bold(`Found ${results.length} relevant memories`) + chalk_1.default.dim(' (137ms)\n\n') +
|
|
494
502
|
results.map((r, i) => {
|
|
495
503
|
const marker = i === 0 ? '▶' : ' ';
|
|
496
|
-
return `${marker} ${
|
|
497
|
-
` │ ${
|
|
498
|
-
` │ ${
|
|
504
|
+
return `${marker} ${chalk_1.default.green(r.score + '%')} │ ${chalk_1.default.bold(r.title)}\n` +
|
|
505
|
+
` │ ${chalk_1.default.dim(r.age + ' • ' + r.type + ' • ' + r.tags)}\n` +
|
|
506
|
+
` │ ${chalk_1.default.dim('"...complete integration guide for Stripe payment..."')}`;
|
|
499
507
|
}).join('\n\n'), {
|
|
500
508
|
padding: 1,
|
|
501
509
|
borderStyle: 'single',
|
|
@@ -508,19 +516,20 @@ export class InteractiveSearch {
|
|
|
508
516
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
509
517
|
}
|
|
510
518
|
}
|
|
519
|
+
exports.InteractiveSearch = InteractiveSearch;
|
|
511
520
|
/**
|
|
512
521
|
* Analytics View
|
|
513
522
|
*/
|
|
514
|
-
|
|
523
|
+
class AnalyticsView {
|
|
515
524
|
stateManager;
|
|
516
525
|
constructor(stateManager) {
|
|
517
526
|
this.stateManager = stateManager;
|
|
518
527
|
}
|
|
519
528
|
async show() {
|
|
520
529
|
console.clear();
|
|
521
|
-
console.log(
|
|
530
|
+
console.log(chalk_1.default.bold.blue('📊 Analytics Dashboard\n'));
|
|
522
531
|
// Create analytics table
|
|
523
|
-
const table = new
|
|
532
|
+
const table = new cli_table3_1.default({
|
|
524
533
|
head: ['Metric', 'Value', 'Change'],
|
|
525
534
|
colWidths: [25, 15, 15],
|
|
526
535
|
style: {
|
|
@@ -528,13 +537,13 @@ export class AnalyticsView {
|
|
|
528
537
|
border: ['gray']
|
|
529
538
|
}
|
|
530
539
|
});
|
|
531
|
-
table.push(['Total Memories', '247',
|
|
540
|
+
table.push(['Total Memories', '247', chalk_1.default.green('+12')], ['Topics', '12', chalk_1.default.green('+2')], ['Tags Used', '89', chalk_1.default.green('+8')], ['API Calls (Month)', '1,432', chalk_1.default.yellow('+5%')], ['Search Queries', '342', chalk_1.default.green('+18%')], ['Avg Response Time', '124ms', chalk_1.default.green('-8%')]);
|
|
532
541
|
console.log(table.toString());
|
|
533
542
|
// Memory growth chart
|
|
534
|
-
console.log('\n' +
|
|
543
|
+
console.log('\n' + chalk_1.default.bold('Memory Growth (Last 7 Days)'));
|
|
535
544
|
this.renderChart();
|
|
536
545
|
// Top topics
|
|
537
|
-
console.log('\n' +
|
|
546
|
+
console.log('\n' + chalk_1.default.bold('Top Topics'));
|
|
538
547
|
const topics = [
|
|
539
548
|
{ name: 'Architecture', count: 45 },
|
|
540
549
|
{ name: 'API', count: 38 },
|
|
@@ -544,7 +553,7 @@ export class AnalyticsView {
|
|
|
544
553
|
];
|
|
545
554
|
topics.forEach(topic => {
|
|
546
555
|
const bar = '█'.repeat(Math.floor(topic.count / 2));
|
|
547
|
-
console.log(` ${topic.name.padEnd(15)} ${
|
|
556
|
+
console.log(` ${topic.name.padEnd(15)} ${chalk_1.default.cyan(bar)} ${topic.count}`);
|
|
548
557
|
});
|
|
549
558
|
}
|
|
550
559
|
renderChart() {
|
|
@@ -556,7 +565,7 @@ export class AnalyticsView {
|
|
|
556
565
|
for (const value of data) {
|
|
557
566
|
const barHeight = Math.round((value / max) * height);
|
|
558
567
|
if (barHeight >= row) {
|
|
559
|
-
line +=
|
|
568
|
+
line += chalk_1.default.cyan('█ ');
|
|
560
569
|
}
|
|
561
570
|
else {
|
|
562
571
|
line += ' ';
|
|
@@ -564,6 +573,7 @@ export class AnalyticsView {
|
|
|
564
573
|
}
|
|
565
574
|
console.log(line);
|
|
566
575
|
}
|
|
567
|
-
console.log(' ' +
|
|
576
|
+
console.log(' ' + chalk_1.default.dim('M T W T F S S'));
|
|
568
577
|
}
|
|
569
578
|
}
|
|
579
|
+
exports.AnalyticsView = AnalyticsView;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Enhanced Error Handling and Recovery System
|
|
3
4
|
* Provides intelligent error messages and recovery suggestions
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ValidationError = exports.ErrorBoundary = exports.ErrorHandler = void 0;
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const boxen_1 = __importDefault(require("boxen"));
|
|
13
|
+
class ErrorHandler {
|
|
8
14
|
stateManager;
|
|
9
15
|
errorHistory = [];
|
|
10
16
|
constructor(stateManager) {
|
|
@@ -202,9 +208,9 @@ export class ErrorHandler {
|
|
|
202
208
|
displayError(error) {
|
|
203
209
|
const icon = this.getErrorIcon(error.severity || 'error');
|
|
204
210
|
const color = this.getErrorColor(error.severity || 'error');
|
|
205
|
-
const errorBox =
|
|
211
|
+
const errorBox = (0, boxen_1.default)(`${icon} ${chalk_1.default.bold(error.name || 'Error')}\n\n` +
|
|
206
212
|
`${error.message}\n` +
|
|
207
|
-
(error.suggestion ? `\n${
|
|
213
|
+
(error.suggestion ? `\n${chalk_1.default.yellow('💡 ' + error.suggestion)}` : ''), {
|
|
208
214
|
padding: 1,
|
|
209
215
|
borderStyle: 'round',
|
|
210
216
|
borderColor: color,
|
|
@@ -217,41 +223,41 @@ export class ErrorHandler {
|
|
|
217
223
|
* Offer recovery actions to the user
|
|
218
224
|
*/
|
|
219
225
|
offerRecovery(actions) {
|
|
220
|
-
console.log(
|
|
226
|
+
console.log(chalk_1.default.bold('\n🔧 Possible Solutions:\n'));
|
|
221
227
|
actions.forEach((action, index) => {
|
|
222
|
-
console.log(` ${
|
|
223
|
-
` ${
|
|
224
|
-
(action.description ? ` ${
|
|
228
|
+
console.log(` ${chalk_1.default.cyan(`${index + 1}.`)} ${chalk_1.default.bold(action.label)}\n` +
|
|
229
|
+
` ${chalk_1.default.gray('Command:')} ${chalk_1.default.green(action.command)}\n` +
|
|
230
|
+
(action.description ? ` ${chalk_1.default.dim(action.description)}\n` : ''));
|
|
225
231
|
});
|
|
226
|
-
console.log(
|
|
232
|
+
console.log(chalk_1.default.dim('\nRun any of the above commands to resolve the issue.'));
|
|
227
233
|
}
|
|
228
234
|
/**
|
|
229
235
|
* Log debug information for verbose mode
|
|
230
236
|
*/
|
|
231
237
|
logDebugInfo(error) {
|
|
232
|
-
console.error(
|
|
233
|
-
console.error(
|
|
234
|
-
console.error(
|
|
235
|
-
console.error(
|
|
238
|
+
console.error(chalk_1.default.dim('\n--- Debug Information ---'));
|
|
239
|
+
console.error(chalk_1.default.dim('Timestamp:'), new Date().toISOString());
|
|
240
|
+
console.error(chalk_1.default.dim('Error Type:'), error.name);
|
|
241
|
+
console.error(chalk_1.default.dim('Error Code:'), error.code || 'N/A');
|
|
236
242
|
if (error.stack) {
|
|
237
|
-
console.error(
|
|
238
|
-
console.error(
|
|
243
|
+
console.error(chalk_1.default.dim('Stack Trace:'));
|
|
244
|
+
console.error(chalk_1.default.dim(error.stack));
|
|
239
245
|
}
|
|
240
246
|
if (error.context) {
|
|
241
|
-
console.error(
|
|
242
|
-
console.error(
|
|
247
|
+
console.error(chalk_1.default.dim('Context:'));
|
|
248
|
+
console.error(chalk_1.default.dim(JSON.stringify(error.context, null, 2)));
|
|
243
249
|
}
|
|
244
|
-
console.error(
|
|
250
|
+
console.error(chalk_1.default.dim('--- End Debug Information ---\n'));
|
|
245
251
|
}
|
|
246
252
|
/**
|
|
247
253
|
* Get error icon based on severity
|
|
248
254
|
*/
|
|
249
255
|
getErrorIcon(severity) {
|
|
250
256
|
switch (severity) {
|
|
251
|
-
case 'error': return
|
|
252
|
-
case 'warning': return
|
|
253
|
-
case 'info': return
|
|
254
|
-
default: return
|
|
257
|
+
case 'error': return chalk_1.default.red('✖');
|
|
258
|
+
case 'warning': return chalk_1.default.yellow('⚠');
|
|
259
|
+
case 'info': return chalk_1.default.blue('ℹ');
|
|
260
|
+
default: return chalk_1.default.red('✖');
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
/**
|
|
@@ -283,18 +289,19 @@ export class ErrorHandler {
|
|
|
283
289
|
async retryLastOperation() {
|
|
284
290
|
const lastError = this.errorHistory[this.errorHistory.length - 1];
|
|
285
291
|
if (lastError && lastError.context?.operation) {
|
|
286
|
-
console.log(
|
|
292
|
+
console.log(chalk_1.default.cyan('🔄 Retrying last operation...'));
|
|
287
293
|
// Implementation would retry the stored operation
|
|
288
294
|
}
|
|
289
295
|
else {
|
|
290
|
-
console.log(
|
|
296
|
+
console.log(chalk_1.default.yellow('No operation to retry'));
|
|
291
297
|
}
|
|
292
298
|
}
|
|
293
299
|
}
|
|
300
|
+
exports.ErrorHandler = ErrorHandler;
|
|
294
301
|
/**
|
|
295
302
|
* Global error boundary for the CLI
|
|
296
303
|
*/
|
|
297
|
-
|
|
304
|
+
class ErrorBoundary {
|
|
298
305
|
errorHandler;
|
|
299
306
|
constructor(errorHandler) {
|
|
300
307
|
this.errorHandler = errorHandler;
|
|
@@ -328,13 +335,13 @@ export class ErrorBoundary {
|
|
|
328
335
|
});
|
|
329
336
|
// Handle SIGINT (Ctrl+C)
|
|
330
337
|
process.on('SIGINT', () => {
|
|
331
|
-
console.log(
|
|
338
|
+
console.log(chalk_1.default.yellow('\n\n👋 Gracefully shutting down...'));
|
|
332
339
|
this.cleanup();
|
|
333
340
|
process.exit(0);
|
|
334
341
|
});
|
|
335
342
|
// Handle SIGTERM
|
|
336
343
|
process.on('SIGTERM', () => {
|
|
337
|
-
console.log(
|
|
344
|
+
console.log(chalk_1.default.yellow('\n\n🛑 Received termination signal...'));
|
|
338
345
|
this.cleanup();
|
|
339
346
|
process.exit(0);
|
|
340
347
|
});
|
|
@@ -346,7 +353,7 @@ export class ErrorBoundary {
|
|
|
346
353
|
// Save any pending state
|
|
347
354
|
// Close any open connections
|
|
348
355
|
// Flush any buffers
|
|
349
|
-
console.log(
|
|
356
|
+
console.log(chalk_1.default.dim('Cleanup complete'));
|
|
350
357
|
}
|
|
351
358
|
/**
|
|
352
359
|
* Wrap async functions with error handling
|
|
@@ -363,10 +370,11 @@ export class ErrorBoundary {
|
|
|
363
370
|
});
|
|
364
371
|
}
|
|
365
372
|
}
|
|
373
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
366
374
|
/**
|
|
367
375
|
* Validation error for input validation
|
|
368
376
|
*/
|
|
369
|
-
|
|
377
|
+
class ValidationError extends Error {
|
|
370
378
|
severity = 'warning';
|
|
371
379
|
suggestion;
|
|
372
380
|
constructor(message, field, suggestion) {
|
|
@@ -378,3 +386,4 @@ export class ValidationError extends Error {
|
|
|
378
386
|
this.suggestion = suggestion;
|
|
379
387
|
}
|
|
380
388
|
}
|
|
389
|
+
exports.ValidationError = ValidationError;
|