@vee-stack/delta-cli 2.0.8 → 2.0.9

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 (109) hide show
  1. package/dist/adapters/analysis.adapter.js +42 -0
  2. package/dist/analyzer/commands/analyze.js +74 -114
  3. package/dist/auth/device-auth.js +261 -0
  4. package/dist/auth/secure-auth.js +45 -16
  5. package/dist/commands/analyze.js +30 -27
  6. package/dist/commands/auth.js +13 -16
  7. package/dist/commands/status.js +2 -2
  8. package/dist/commands/whoami.js +6 -6
  9. package/dist/components/Dashboard.js +3 -5
  10. package/dist/components/DeltaApp.js +1 -1
  11. package/dist/components/UnifiedManager.js +48 -20
  12. package/dist/core/completion.js +14 -3
  13. package/dist/core/engine.js +10 -4
  14. package/dist/core/exit-codes.js +12 -4
  15. package/dist/core/wizard.js +1 -1
  16. package/dist/index.js +21 -5
  17. package/dist/providers/remote-provider.js +2 -2
  18. package/dist/telemetry/wrapper.js +114 -0
  19. package/dist/ui.js +9 -2
  20. package/dist/welcome.js +14 -4
  21. package/package.json +3 -1
  22. package/dist/apps/cli/src/analyzer/commands/analyze.js +0 -256
  23. package/dist/apps/cli/src/analyzer/commands/config.js +0 -83
  24. package/dist/apps/cli/src/analyzer/commands/report.js +0 -38
  25. package/dist/apps/cli/src/analyzer/generators/report.generator.js +0 -123
  26. package/dist/apps/cli/src/analyzer/index.js +0 -44
  27. package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +0 -92
  28. package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +0 -42
  29. package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +0 -40
  30. package/dist/apps/cli/src/analyzer/validators/observability.validator.js +0 -39
  31. package/dist/apps/cli/src/analyzer/validators/performance.validator.js +0 -42
  32. package/dist/apps/cli/src/analyzer/validators/security.validator.js +0 -66
  33. package/dist/apps/cli/src/analyzer/validators/soc.validator.js +0 -75
  34. package/dist/apps/cli/src/auth/secure-auth.js +0 -312
  35. package/dist/apps/cli/src/commands/analyze.js +0 -286
  36. package/dist/apps/cli/src/commands/auth-new.js +0 -37
  37. package/dist/apps/cli/src/commands/auth.js +0 -122
  38. package/dist/apps/cli/src/commands/config.js +0 -49
  39. package/dist/apps/cli/src/commands/deploy.js +0 -6
  40. package/dist/apps/cli/src/commands/init.js +0 -47
  41. package/dist/apps/cli/src/commands/logout.js +0 -23
  42. package/dist/apps/cli/src/commands/plugins.js +0 -21
  43. package/dist/apps/cli/src/commands/status.js +0 -80
  44. package/dist/apps/cli/src/commands/sync.js +0 -6
  45. package/dist/apps/cli/src/commands/whoami.js +0 -115
  46. package/dist/apps/cli/src/components/Dashboard.js +0 -168
  47. package/dist/apps/cli/src/components/DeltaApp.js +0 -56
  48. package/dist/apps/cli/src/components/UnifiedManager.js +0 -324
  49. package/dist/apps/cli/src/core/audit.js +0 -184
  50. package/dist/apps/cli/src/core/completion.js +0 -294
  51. package/dist/apps/cli/src/core/contracts.js +0 -6
  52. package/dist/apps/cli/src/core/engine.js +0 -124
  53. package/dist/apps/cli/src/core/exit-codes.js +0 -71
  54. package/dist/apps/cli/src/core/hooks.js +0 -181
  55. package/dist/apps/cli/src/core/index.js +0 -7
  56. package/dist/apps/cli/src/core/policy.js +0 -115
  57. package/dist/apps/cli/src/core/profiles.js +0 -161
  58. package/dist/apps/cli/src/core/wizard.js +0 -203
  59. package/dist/apps/cli/src/index.js +0 -636
  60. package/dist/apps/cli/src/interactive/index.js +0 -11
  61. package/dist/apps/cli/src/plugins/GitStatusPlugin.js +0 -99
  62. package/dist/apps/cli/src/providers/ai-provider.js +0 -74
  63. package/dist/apps/cli/src/providers/local-provider.js +0 -302
  64. package/dist/apps/cli/src/providers/remote-provider.js +0 -100
  65. package/dist/apps/cli/src/types/api.js +0 -3
  66. package/dist/apps/cli/src/ui.js +0 -219
  67. package/dist/apps/cli/src/welcome.js +0 -81
  68. package/dist/bundle.js +0 -504
  69. package/dist/packages/domain/src/constitution/contracts/index.js +0 -43
  70. package/dist/packages/domain/src/constitution/contracts/ts.rules.js +0 -268
  71. package/dist/packages/domain/src/constitution/index.js +0 -139
  72. package/dist/packages/domain/src/constitution/maintainability/index.js +0 -43
  73. package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +0 -344
  74. package/dist/packages/domain/src/constitution/observability/index.js +0 -43
  75. package/dist/packages/domain/src/constitution/observability/ts.rules.js +0 -307
  76. package/dist/packages/domain/src/constitution/performance/index.js +0 -43
  77. package/dist/packages/domain/src/constitution/performance/ts.rules.js +0 -325
  78. package/dist/packages/domain/src/constitution/security/index.js +0 -50
  79. package/dist/packages/domain/src/constitution/security/ts.rules.js +0 -267
  80. package/dist/packages/domain/src/constitution/soc/index.js +0 -43
  81. package/dist/packages/domain/src/constitution/soc/ts.rules.js +0 -360
  82. package/dist/packages/domain/src/contracts/analysis.contract.js +0 -18
  83. package/dist/packages/domain/src/contracts/index.js +0 -7
  84. package/dist/packages/domain/src/contracts/projects.contract.js +0 -18
  85. package/dist/packages/domain/src/control/registry/rules.registry.js +0 -29
  86. package/dist/packages/domain/src/control/schemas/policies.js +0 -6
  87. package/dist/packages/domain/src/core/analysis/discovery.js +0 -163
  88. package/dist/packages/domain/src/core/analysis/engine.contract.js +0 -298
  89. package/dist/packages/domain/src/core/analysis/engine.js +0 -77
  90. package/dist/packages/domain/src/core/analysis/index.js +0 -14
  91. package/dist/packages/domain/src/core/analysis/orchestrator.js +0 -242
  92. package/dist/packages/domain/src/core/comparison/engine.js +0 -29
  93. package/dist/packages/domain/src/core/comparison/index.js +0 -5
  94. package/dist/packages/domain/src/core/documentation/index.js +0 -5
  95. package/dist/packages/domain/src/core/documentation/pipeline.js +0 -41
  96. package/dist/packages/domain/src/core/fs/adapter.js +0 -111
  97. package/dist/packages/domain/src/core/fs/index.js +0 -5
  98. package/dist/packages/domain/src/core/parser/unified-parser.js +0 -166
  99. package/dist/packages/domain/src/index.js +0 -33
  100. package/dist/packages/domain/src/plugin/registry.js +0 -195
  101. package/dist/packages/domain/src/plugin/types.js +0 -6
  102. package/dist/packages/domain/src/ports/analysis.engine.js +0 -7
  103. package/dist/packages/domain/src/ports/audit.logger.js +0 -7
  104. package/dist/packages/domain/src/ports/project.repository.js +0 -7
  105. package/dist/packages/domain/src/rules/index.js +0 -134
  106. package/dist/packages/domain/src/types/analysis.js +0 -6
  107. package/dist/packages/domain/src/types/errors.js +0 -53
  108. package/dist/packages/domain/src/types/fs.js +0 -6
  109. package/dist/packages/domain/src/types/index.js +0 -7
@@ -1,37 +0,0 @@
1
- import chalk from 'chalk';
2
- import { startOAuthFlow, authenticateWithPAT, SecureTokenStore } from '../auth/secure-auth.js';
3
- import { printSuccess, printInfo } from '../ui.js';
4
- import prompts from 'prompts';
5
- export async function loginCommand(options) {
6
- // Check if already authenticated
7
- if (await SecureTokenStore.hasTokens()) {
8
- const overwrite = await prompts({
9
- type: 'confirm',
10
- name: 'value',
11
- message: chalk.yellow('Already authenticated. Overwrite existing credentials?'),
12
- initial: false,
13
- });
14
- if (!overwrite.value) {
15
- printInfo('Login cancelled');
16
- return;
17
- }
18
- }
19
- if (options.token) {
20
- // PAT authentication
21
- await authenticateWithPAT(options.token);
22
- }
23
- else {
24
- // OAuth2 flow
25
- const method = options.method || 'oauth';
26
- const success = await startOAuthFlow(method);
27
- if (success) {
28
- printSuccess('You are now logged in!');
29
- printInfo('Run "delta whoami" to see your account info');
30
- }
31
- }
32
- }
33
- export async function logoutCommand() {
34
- const { logout } = await import('../auth/secure-auth.js');
35
- await logout();
36
- }
37
- //# sourceMappingURL=auth-new.js.map
@@ -1,122 +0,0 @@
1
- /**
2
- * Enhanced Auth Commands - Professional CLI with interactive prompts
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import * as os from 'os';
7
- import { icons, startSpinner, stopSpinner, printHeader, printSection, printSuccess, printError, printInfo, printKeyValue, printCommandHint, createTable, password, printWelcome, } from '../ui.js';
8
- const CONFIG_DIR = path.join(os.homedir(), '.delta');
9
- const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
10
- async function loadConfig() {
11
- try {
12
- const data = await fs.readFile(CONFIG_FILE, 'utf-8');
13
- return JSON.parse(data);
14
- }
15
- catch {
16
- return {};
17
- }
18
- }
19
- async function saveConfig(config) {
20
- await fs.mkdir(CONFIG_DIR, { recursive: true });
21
- await fs.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2));
22
- }
23
- export const authCommands = {
24
- async login(options) {
25
- printWelcome();
26
- printHeader('Authentication');
27
- let token = options.token || process.env.DELTA_PAT;
28
- // Interactive prompt if no token provided
29
- if (!token) {
30
- printInfo('No token provided. Please enter your PAT (Personal Access Token).');
31
- printCommandHint('delta login --token <your-token>', 'to skip this prompt');
32
- console.log();
33
- const tokenInput = await password('Enter PAT (starts with delta_pat_):');
34
- if (!tokenInput) {
35
- printError('Authentication cancelled');
36
- process.exit(1);
37
- }
38
- token = tokenInput;
39
- }
40
- // Validate token format
41
- if (!token.startsWith('delta_pat_')) {
42
- printError('Invalid PAT token format', 'Token should start with "delta_pat_"');
43
- console.log();
44
- printInfo('You can get your PAT from:');
45
- printCommandHint('https://app.delta.dev/settings/tokens', '');
46
- process.exit(1);
47
- }
48
- // Load existing config to get custom apiUrl if set
49
- const existingConfig = await loadConfig();
50
- const apiUrl = process.env.DELTA_API_URL || existingConfig.apiUrl || 'https://api.delta.dev';
51
- printSection('Connecting to Platform');
52
- printKeyValue('API Endpoint', apiUrl);
53
- console.log();
54
- startSpinner('Verifying credentials...');
55
- try {
56
- const controller = new AbortController();
57
- const timeout = setTimeout(() => controller.abort(), 10000);
58
- const response = await fetch(`${apiUrl}/api/me/entitlements`, {
59
- headers: {
60
- 'Authorization': `Bearer ${token}`,
61
- 'Content-Type': 'application/json',
62
- },
63
- signal: controller.signal,
64
- });
65
- clearTimeout(timeout);
66
- if (!response.ok) {
67
- const errorText = await response.text().catch(() => response.statusText);
68
- throw new Error(`HTTP ${response.status}: ${errorText}`);
69
- }
70
- const data = await response.json();
71
- if (!data.success) {
72
- throw new Error(data.error?.message || 'Authentication failed');
73
- }
74
- // Save config
75
- await saveConfig({
76
- pat: token,
77
- apiUrl,
78
- lastUsedAt: new Date().toISOString(),
79
- });
80
- stopSpinner(true, 'Authentication successful!');
81
- console.log();
82
- const user = data.data.user;
83
- const quota = data.data.quota;
84
- printHeader('Account Overview');
85
- // User info table
86
- const userTable = createTable(['Property', 'Value']);
87
- userTable.push([icons.user + ' Email', user.email], [icons.package + ' Plan', user.plan], [icons.chart + ' Quota Used', `${quota.used}/${quota.limit} reports`], [icons.lock + ' Config', CONFIG_FILE]);
88
- console.log(userTable.toString());
89
- console.log();
90
- printSuccess(`Welcome back, ${user.email.split('@')[0]}! 🎉`);
91
- console.log();
92
- printCommandHint('delta whoami', 'to see full account details');
93
- printCommandHint('delta analyze', 'to start analyzing code');
94
- }
95
- catch (error) {
96
- stopSpinner(false, 'Authentication failed');
97
- console.log();
98
- if (error instanceof Error && error.name === 'AbortError') {
99
- printError('Request timeout (10s)', 'Check if the server is running and accessible');
100
- }
101
- else {
102
- const message = error instanceof Error ? error.message : String(error);
103
- if (message.includes('401')) {
104
- printError('Invalid or expired token', 'Generate a new token from the web app');
105
- }
106
- else if (message.includes('ENOTFOUND') || message.includes('ECONNREFUSED')) {
107
- printError('Cannot connect to server', 'Check your internet connection and API URL');
108
- }
109
- else {
110
- printError(message);
111
- }
112
- }
113
- console.log();
114
- printInfo('Need help? Visit: https://docs.delta.dev/cli/authentication');
115
- process.exit(1);
116
- }
117
- },
118
- };
119
- // Export individual commands for direct import
120
- export const loginCommand = authCommands.login;
121
- export { loadConfig, saveConfig, CONFIG_FILE };
122
- //# sourceMappingURL=auth.js.map
@@ -1,49 +0,0 @@
1
- /**
2
- * Config Command - Manage CLI configuration
3
- */
4
- import { loadConfig, saveConfig, CONFIG_FILE } from './auth.js';
5
- export async function configCommand(options) {
6
- const config = await loadConfig();
7
- if (options.get) {
8
- const value = config[options.get];
9
- if (value !== undefined) {
10
- console.log(`${options.get}: ${value}`);
11
- }
12
- else {
13
- console.log(`${options.get}: (not set)`);
14
- }
15
- return;
16
- }
17
- if (options.set) {
18
- const [key, value] = options.set.split('=');
19
- if (!key || value === undefined) {
20
- console.error('❌ Error: Invalid format. Use: key=value');
21
- process.exit(1);
22
- }
23
- const newConfig = {
24
- ...config,
25
- pat: config.pat || '',
26
- apiUrl: config.apiUrl || 'https://api.delta.dev',
27
- [key]: value,
28
- };
29
- await saveConfig(newConfig);
30
- console.log(`✅ Set ${key} = ${value}`);
31
- return;
32
- }
33
- if (options.list || (!options.get && !options.set)) {
34
- console.log('🔧 Delta CLI Configuration');
35
- console.log(` Config file: ${CONFIG_FILE}`);
36
- console.log();
37
- if (config.pat) {
38
- console.log(' PAT: ✅ Set (hidden)');
39
- }
40
- else {
41
- console.log(' PAT: ❌ Not set');
42
- }
43
- console.log(` API URL: ${config.apiUrl || 'https://api.delta.dev (default)'}`);
44
- if (config.lastUsedAt) {
45
- console.log(` Last used: ${new Date(config.lastUsedAt).toLocaleString()}`);
46
- }
47
- }
48
- }
49
- //# sourceMappingURL=config.js.map
@@ -1,6 +0,0 @@
1
- import { printSuccess, printInfo } from '../ui.js';
2
- export async function deployCommand(_options) {
3
- printInfo('Deploying documentation site...');
4
- printSuccess('Deploy completed successfully');
5
- }
6
- //# sourceMappingURL=deploy.js.map
@@ -1,47 +0,0 @@
1
- /**
2
- * Init Command - Initialize a new Delta project
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- export async function initCommand(projectPath, options) {
7
- const targetPath = path.resolve(projectPath);
8
- const configPath = path.join(targetPath, 'delta.config.json');
9
- try {
10
- // Check if directory exists
11
- await fs.access(targetPath);
12
- }
13
- catch {
14
- console.log(`📁 Creating directory: ${targetPath}`);
15
- await fs.mkdir(targetPath, { recursive: true });
16
- }
17
- // Check if config already exists
18
- try {
19
- await fs.access(configPath);
20
- if (!options.force) {
21
- console.log('⚠️ Delta config already exists');
22
- console.log(' Use --force to overwrite');
23
- return;
24
- }
25
- }
26
- catch {
27
- // Config doesn't exist, continue
28
- }
29
- // Create default config
30
- const config = {
31
- name: path.basename(targetPath),
32
- version: '1.0.0',
33
- template: options.template || 'default',
34
- createdAt: new Date().toISOString(),
35
- settings: {
36
- include: ['src/**/*'],
37
- exclude: ['node_modules', 'dist', '.git'],
38
- maxFileSize: 10485760,
39
- },
40
- };
41
- await fs.writeFile(configPath, JSON.stringify(config, null, 2));
42
- console.log('✅ Project initialized');
43
- console.log(` Path: ${targetPath}`);
44
- console.log(` Config: ${configPath}`);
45
- console.log(` Template: ${config.template}`);
46
- }
47
- //# sourceMappingURL=init.js.map
@@ -1,23 +0,0 @@
1
- /**
2
- * Logout Command - Remove stored authentication
3
- */
4
- import * as fs from 'fs/promises';
5
- import { CONFIG_FILE, loadConfig } from './auth.js';
6
- export async function logoutCommand() {
7
- try {
8
- const config = await loadConfig();
9
- if (!config.pat) {
10
- console.log('ℹ️ Not currently authenticated');
11
- return;
12
- }
13
- // Remove the config file
14
- await fs.unlink(CONFIG_FILE);
15
- console.log('✅ Successfully logged out');
16
- console.log(' Authentication data removed');
17
- }
18
- catch (error) {
19
- console.error('❌ Error during logout:', error instanceof Error ? error.message : String(error));
20
- process.exit(1);
21
- }
22
- }
23
- //# sourceMappingURL=logout.js.map
@@ -1,21 +0,0 @@
1
- import { printSuccess, printInfo } from '../ui.js';
2
- export async function pluginsCommand(options) {
3
- if (options.list) {
4
- printInfo('Installed plugins:');
5
- }
6
- else if (options.install) {
7
- printInfo(`Installing plugin: ${options.install}`);
8
- printSuccess('Plugin installed successfully');
9
- }
10
- else if (options.uninstall) {
11
- printInfo(`Uninstalling plugin: ${options.uninstall}`);
12
- printSuccess('Plugin uninstalled successfully');
13
- }
14
- else if (options.search) {
15
- printInfo(`Searching for plugins: ${options.search}`);
16
- }
17
- else {
18
- printInfo('Use --list, --install, --uninstall, or --search');
19
- }
20
- }
21
- //# sourceMappingURL=plugins.js.map
@@ -1,80 +0,0 @@
1
- /**
2
- * Enhanced Status Command - Professional project and connection status
3
- */
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import { loadConfig } from './auth.js';
7
- import { icons, startSpinner, stopSpinner, printWelcome, printHeader, printSection, printSuccess, printError, printWarning, printInfo, printKeyValue, printCommandHint, createTable, printDivider, confirm, } from '../ui.js';
8
- export async function statusCommand(projectPath, _options) {
9
- const targetPath = path.resolve(projectPath);
10
- printWelcome();
11
- printHeader('Project Status Check');
12
- printKeyValue('Path', targetPath);
13
- console.log();
14
- // Check for delta config
15
- printSection('Project Configuration');
16
- const configPath = path.join(targetPath, 'delta.config.json');
17
- try {
18
- await fs.access(configPath);
19
- const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
20
- printSuccess('Configuration found');
21
- const configTable = createTable(['Property', 'Value']);
22
- configTable.push([icons.folder + ' Name', config.name || 'Unnamed'], [icons.folder + ' Type', config.type || 'default'], [icons.gear + ' Version', config.version || 'N/A'], [icons.info + ' Config File', configPath]);
23
- console.log(configTable.toString());
24
- }
25
- catch {
26
- printWarning('No Delta project found');
27
- printInfo('Initialize a new project:');
28
- printCommandHint(`delta init ${projectPath}`, 'to create a new project');
29
- const shouldInit = await confirm('Would you like to initialize now?', true);
30
- if (shouldInit) {
31
- console.log();
32
- printInfo('Run: delta init ' + projectPath);
33
- }
34
- }
35
- console.log();
36
- printDivider();
37
- // Check auth status
38
- printSection('Authentication');
39
- const auth = await loadConfig();
40
- if (auth.pat) {
41
- printSuccess('Authenticated');
42
- printKeyValue('API URL', auth.apiUrl || 'default');
43
- // Test connection
44
- const apiUrl = auth.apiUrl || process.env.DELTA_API_URL || 'https://api.delta.dev';
45
- startSpinner('Testing connection...');
46
- try {
47
- const response = await fetch(`${apiUrl}/api/me/entitlements`, {
48
- headers: { 'Authorization': `Bearer ${auth.pat}` },
49
- });
50
- if (response.ok) {
51
- stopSpinner(true, 'Connection active');
52
- const data = await response.json();
53
- if (data.success) {
54
- printKeyValue('User', data.data.user.email);
55
- printKeyValue('Plan', data.data.user.plan);
56
- }
57
- }
58
- else {
59
- stopSpinner(false, 'Authentication expired');
60
- printError('Your session has expired');
61
- printCommandHint('delta login --token <new-pat>', 'to re-authenticate');
62
- }
63
- }
64
- catch {
65
- stopSpinner(false, 'API unreachable');
66
- printError('Cannot connect to Delta API');
67
- printInfo('Check your internet connection or API URL configuration');
68
- }
69
- }
70
- else {
71
- printError('Not authenticated');
72
- printInfo('Please login to access cloud features:');
73
- printCommandHint('delta login --token <pat>', 'to authenticate');
74
- }
75
- console.log();
76
- printDivider();
77
- printCommandHint('delta analyze', 'to analyze your project');
78
- printCommandHint('delta whoami', 'to see account details');
79
- }
80
- //# sourceMappingURL=status.js.map
@@ -1,6 +0,0 @@
1
- import { printSuccess, printInfo } from '../ui.js';
2
- export async function syncCommand(_options) {
3
- printInfo('Syncing with Delta cloud...');
4
- printSuccess('Sync completed successfully');
5
- }
6
- //# sourceMappingURL=sync.js.map
@@ -1,115 +0,0 @@
1
- /**
2
- * Enhanced Whoami Command - Professional user info display
3
- */
4
- import { loadConfig } from './auth.js';
5
- import { icons, startSpinner, stopSpinner, printHeader, printSection, printSuccess, printError, printWarning, printInfo, printCommandHint, createTable, formatBytes, printDivider, } from '../ui.js';
6
- export async function whoamiCommand(_options) {
7
- try {
8
- const config = await loadConfig();
9
- if (!config.pat) {
10
- printHeader('Authentication Status');
11
- printError('Not authenticated');
12
- console.log();
13
- printInfo('Please login first:');
14
- printCommandHint('delta login', 'to authenticate with your PAT');
15
- process.exit(1);
16
- }
17
- printHeader('Loading Account Information');
18
- startSpinner('Fetching user data...');
19
- const apiUrl = config.apiUrl || process.env.DELTA_API_URL || 'https://api.delta.dev';
20
- const response = await fetch(`${apiUrl}/api/me/entitlements`, {
21
- headers: {
22
- 'Authorization': `Bearer ${config.pat}`,
23
- 'Content-Type': 'application/json',
24
- },
25
- });
26
- if (!response.ok) {
27
- stopSpinner(false);
28
- if (response.status === 401) {
29
- printError('Authentication expired or invalid');
30
- console.log();
31
- printInfo('Please login again:');
32
- printCommandHint('delta login --token <new-pat>', 'to re-authenticate');
33
- process.exit(1);
34
- }
35
- throw new Error(`API error: ${response.status} ${response.statusText}`);
36
- }
37
- const data = await response.json();
38
- if (!data.success) {
39
- throw new Error(data.error?.message || 'Failed to fetch user info');
40
- }
41
- stopSpinner(true);
42
- console.log();
43
- const user = data.data.user;
44
- const quota = data.data.quota;
45
- const limits = data.data.limits;
46
- // User Info Section
47
- printHeader('User Profile');
48
- const userTable = createTable(['Property', 'Value']);
49
- userTable.push([icons.user + ' Email', user.email], [icons.user + ' User ID', user.id], [icons.package + ' Plan', formatPlan(user.plan)], [icons.star + ' Role', user.role || user.plan]);
50
- console.log(userTable.toString());
51
- printDivider();
52
- // Plan Limits Section
53
- printSection('Plan Features');
54
- const limitsTable = createTable(['Feature', 'Value']);
55
- limitsTable.push([icons.chart + ' Max Reports/Month', limits.maxReportsPerMonth.toString()], [icons.package + ' Max Report Size', formatBytes(limits.maxReportSizeBytes)], [icons.lock + ' API Access', limits.allowApiAccess ? '✅ Yes' : '❌ No'], [icons.folder + ' Upload Allowed', limits.allowUpload ? '✅ Yes' : '❌ No']);
56
- console.log(limitsTable.toString());
57
- printDivider();
58
- // Quota Section with visual bar
59
- printSection('Usage This Month');
60
- const usagePercent = (quota.used / quota.limit) * 100;
61
- const bar = renderUsageBar(quota.used, quota.limit);
62
- const quotaTable = createTable(['Metric', 'Value']);
63
- quotaTable.push([icons.chart + ' Reports Used', `${quota.used} of ${quota.limit}`], [icons.chart + ' Remaining', quota.remaining.toString()], [icons.chart + ' Usage', bar], [icons.info + ' Resets On', new Date(quota.resetAt).toLocaleDateString('en-US', {
64
- weekday: 'long',
65
- year: 'numeric',
66
- month: 'long',
67
- day: 'numeric'
68
- })]);
69
- console.log(quotaTable.toString());
70
- console.log();
71
- if (usagePercent >= 90) {
72
- printWarning(`You're using ${usagePercent.toFixed(0)}% of your monthly quota!`);
73
- printCommandHint('delta upgrade', 'to increase your limits (coming soon)');
74
- }
75
- else if (usagePercent >= 75) {
76
- printInfo(`Usage: ${usagePercent.toFixed(0)}% of monthly quota`);
77
- }
78
- else {
79
- printSuccess(`Usage: ${usagePercent.toFixed(0)}% of monthly quota`);
80
- }
81
- console.log();
82
- printCommandHint('delta analyze', 'to run a code analysis');
83
- printCommandHint('delta status', 'to check project status');
84
- }
85
- catch (error) {
86
- stopSpinner(false);
87
- console.log();
88
- printError(error instanceof Error ? error.message : String(error));
89
- process.exit(1);
90
- }
91
- }
92
- function formatPlan(plan) {
93
- const planColors = {
94
- 'individual_free': '🔷 Free',
95
- 'individual_pro': '💎 Pro',
96
- 'individual_team': '👥 Team',
97
- 'enterprise': '🏢 Enterprise',
98
- };
99
- return planColors[plan] || plan;
100
- }
101
- function renderUsageBar(used, limit) {
102
- const percentage = Math.min((used / limit) * 100, 100);
103
- const filledBlocks = Math.round((percentage / 100) * 20);
104
- const emptyBlocks = 20 - filledBlocks;
105
- let color;
106
- if (percentage >= 90)
107
- color = (s) => `\x1b[31m${s}\x1b[0m`; // red
108
- else if (percentage >= 75)
109
- color = (s) => `\x1b[33m${s}\x1b[0m`; // yellow
110
- else
111
- color = (s) => `\x1b[32m${s}\x1b[0m`; // green
112
- const bar = color('█'.repeat(filledBlocks)) + '░'.repeat(emptyBlocks);
113
- return `${bar} ${percentage.toFixed(1)}%`;
114
- }
115
- //# sourceMappingURL=whoami.js.map