@lanonasis/cli 3.6.5 → 3.6.7

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