@vee-stack/delta-cli 2.0.7 → 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,636 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import gradient from 'gradient-string';
4
- import figlet from 'figlet';
5
- import updateNotifier from 'update-notifier';
6
- import chalk from 'chalk';
7
- import { readFileSync } from 'fs';
8
- import { fileURLToPath } from 'url';
9
- import { dirname, join } from 'path';
10
- import { runInteractiveMode } from './interactive/index.js';
11
- // Core Engine Imports
12
- import { createEngine } from './core/engine.js';
13
- import { DefaultExecutionPolicy } from './core/policy.js';
14
- import { LocalProvider } from './providers/local-provider.js';
15
- import { RemoteProvider } from './providers/remote-provider.js';
16
- import { AIProviderPlaceholder } from './providers/ai-provider.js';
17
- import { installCompletion, generateCompletionScript } from './core/completion.js';
18
- import { runInitWizard, executeWizardActions } from './core/wizard.js';
19
- import { getAuditLogger } from './core/audit.js';
20
- import { getProfileManager } from './core/profiles.js';
21
- import { getHookManager, hookTemplates } from './core/hooks.js';
22
- import { loadConfig } from './commands/auth.js';
23
- const __filename = fileURLToPath(import.meta.url);
24
- const __dirname = dirname(__filename);
25
- // Read package.json for version info
26
- const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
27
- // Check for updates
28
- const notifier = updateNotifier({
29
- pkg,
30
- updateCheckInterval: 1000 * 60 * 60 // 1 hour
31
- });
32
- // Define gradient themes
33
- export const gradients = {
34
- delta: gradient(['#00d4ff', '#7b2cbf', '#ff006e']),
35
- cyber: gradient(['#00f5ff', '#0080ff', '#8000ff']),
36
- sunset: gradient(['#ff4e50', '#fca311', '#e85d04']),
37
- neon: gradient(['#39ff14', '#00ffff', '#ff00ff']),
38
- ocean: gradient(['#0066ff', '#00ccff', '#66ffff']),
39
- fire: gradient(['#ff4e00', '#ff9500', '#ffcc00']),
40
- };
41
- // Print animated logo
42
- export function printLogo(variant = 'delta') {
43
- const text = figlet.textSync('DELTA', {
44
- font: 'Big Money-nw',
45
- horizontalLayout: 'default',
46
- verticalLayout: 'default',
47
- });
48
- console.log('\n' + gradients[variant](text) + '\n');
49
- }
50
- // Print minimal logo
51
- export function printMinimalLogo() {
52
- const text = figlet.textSync('Ī”', {
53
- font: 'ANSI Shadow',
54
- horizontalLayout: 'default',
55
- });
56
- console.log(gradients.delta(text));
57
- }
58
- // Print welcome screen
59
- export function printWelcome() {
60
- console.clear();
61
- printLogo();
62
- console.log(chalk.dim(' ═══════════════════════════════════════════════════════════════'));
63
- console.log();
64
- console.log(chalk.white.bold(' šŸš€ Delta CLI v2.0') + chalk.gray(' — Next-gen code analysis & documentation'));
65
- console.log();
66
- console.log(chalk.gray(' Local-first architecture with ') + chalk.cyan('cloud power') + chalk.gray(' & ') + chalk.magenta('AI intelligence'));
67
- console.log();
68
- console.log(chalk.dim(' ═══════════════════════════════════════════════════════════════'));
69
- console.log();
70
- // Update notification
71
- if (notifier.update) {
72
- console.log(chalk.yellow.bold(' ⚔ Update Available!'));
73
- console.log(chalk.gray(` ${notifier.update.current} → ${notifier.update.latest}`));
74
- console.log(chalk.cyan(` Run: npm install -g ${pkg.name}`));
75
- console.log();
76
- }
77
- }
78
- // Print tips
79
- export function printTips() {
80
- const tips = [
81
- { cmd: 'delta /help', desc: 'Quick help with slash commands' },
82
- { cmd: 'delta /analyze', desc: 'Run analysis with / command' },
83
- { cmd: 'delta /status', desc: 'Check project status' },
84
- { cmd: 'delta --interactive', desc: 'Open interactive dashboard' },
85
- ];
86
- console.log(chalk.bold.cyan(' Quick Start (Slash Commands Available):'));
87
- console.log();
88
- tips.forEach(({ cmd, desc }) => {
89
- console.log(chalk.gray(' • ') + chalk.cyan(cmd) + chalk.gray(` — ${desc}`));
90
- });
91
- console.log();
92
- console.log(chalk.dim(' Try ') + chalk.cyan('/help') + chalk.dim(', ') + chalk.cyan('/analyze') + chalk.dim(', ') + chalk.cyan('/status') + chalk.dim(' for quick access'));
93
- console.log(chalk.dim(' Press ') + chalk.bold('Ctrl+T') + chalk.dim(' for variants • ') + chalk.bold('Tab') + chalk.dim(' for agents • ') + chalk.bold('Ctrl+P') + chalk.dim(' for commands'));
94
- console.log();
95
- }
96
- // Initialize Core Engine
97
- let engine = null;
98
- async function initializeEngine() {
99
- if (engine)
100
- return engine;
101
- const auth = await loadConfig();
102
- const config = {
103
- defaultProvider: 'local',
104
- providers: {
105
- local: {
106
- enabled: true,
107
- maxFileSize: 10 * 1024 * 1024, // 10MB
108
- excludePatterns: ['node_modules', 'dist', '.git', 'coverage'],
109
- },
110
- remote: {
111
- enabled: !!auth.pat,
112
- apiUrl: auth.apiUrl || 'https://api.delta.dev',
113
- timeout: 30000,
114
- retryAttempts: 3,
115
- },
116
- ai: {
117
- enabled: false, // Reserved for future
118
- provider: 'openai',
119
- },
120
- },
121
- features: {
122
- cache: true,
123
- offlineMode: !auth.pat,
124
- autoUpdate: true,
125
- },
126
- };
127
- const policy = new DefaultExecutionPolicy(config);
128
- engine = createEngine(config, policy);
129
- // Register providers
130
- engine.registerProvider(new LocalProvider(config.providers.local));
131
- if (config.providers.remote.enabled) {
132
- engine.registerProvider(new RemoteProvider(config.providers.remote));
133
- }
134
- engine.registerProvider(new AIProviderPlaceholder(config.providers.ai));
135
- return engine;
136
- }
137
- // JSON Output Helper
138
- function outputJSON(response) {
139
- console.log(JSON.stringify(response, null, 2));
140
- }
141
- // Non-TTY Detection
142
- function isNonTTY() {
143
- return !process.stdout.isTTY || process.env.CI === 'true' || process.env.NO_COLOR === 'true';
144
- }
145
- // CLI Program Setup
146
- const program = new Command();
147
- program
148
- .name('delta')
149
- .description('Delta Platform - Next-gen code analysis and documentation')
150
- .version(pkg.version, '-v, --version', 'Display version number')
151
- .usage('<command> [options]')
152
- .helpOption('-h, --help', 'Display help for command')
153
- .addHelpCommand('help [command]', 'Display help for command');
154
- // Global options
155
- program
156
- .option('-i, --interactive', 'Run in interactive mode', false)
157
- .option('--no-color', 'Disable colored output', false)
158
- .option('--theme <name>', 'Set color theme (delta, cyber, sunset, neon, ocean, fire)', 'delta')
159
- .option('--verbose', 'Enable verbose logging', false);
160
- // Auth commands
161
- program
162
- .command('login')
163
- .description('šŸ” Authenticate with Delta cloud (OAuth2 + secure keychain storage)')
164
- .option('--method <type>', 'Auth method: oauth, pat, github, google', 'oauth')
165
- .option('--token <token>', 'Personal Access Token (for CI/CD)')
166
- .action(async (options) => {
167
- printWelcome();
168
- const { loginCommand } = await import('./commands/auth.js');
169
- await loginCommand(options);
170
- });
171
- program
172
- .command('logout')
173
- .description('šŸ”“ Remove stored authentication and clear credentials')
174
- .action(async () => {
175
- const { logoutCommand } = await import('./commands/logout.js');
176
- await logoutCommand();
177
- });
178
- program
179
- .command('whoami')
180
- .alias('me')
181
- .description('šŸ‘¤ Show current user, plan, quota, and session info')
182
- .option('--format <type>', 'Output format: table, json, compact', 'table')
183
- .action(async (options) => {
184
- const { whoamiCommand } = await import('./commands/whoami.js');
185
- await whoamiCommand(options);
186
- });
187
- // Main commands
188
- program
189
- .command('manager')
190
- .alias('mgr')
191
- .description('šŸŽ›ļø Launch Unified Manager TUI - Run CLI + Web from single terminal')
192
- .action(async () => {
193
- printWelcome();
194
- console.log(chalk.cyan('\nšŸš€ Starting Unified Manager...\n'));
195
- console.log(chalk.gray('Press ? for help, q to quit\n'));
196
- await runInteractiveMode({ mode: 'manager' });
197
- });
198
- program
199
- .command('analyze [path]')
200
- .alias('a')
201
- .description('šŸ” Run comprehensive code analysis with AI insights')
202
- .option('-f, --format <type>', 'Output format: json, html, markdown, sarif', 'json')
203
- .option('-o, --output <dir>', 'Output directory', './delta-reports')
204
- .option('-i, --include <patterns...>', 'Include file patterns')
205
- .option('-e, --exclude <patterns...>', 'Exclude file patterns')
206
- .option('--max-size <bytes>', 'Max file size in bytes', '10485760')
207
- .option('--upload', 'Upload report to Delta cloud', false)
208
- .option('--share', 'Generate shareable link after upload', false)
209
- .option('--project-name <name>', 'Project name for the report')
210
- .option('--ai-insights', 'Enable AI-powered code insights', true)
211
- .option('--security-scan', 'Enable security vulnerability scan', true)
212
- .option('--performance', 'Enable performance analysis', true)
213
- .option('--json', 'Output results as JSON', false)
214
- .option('--provider <name>', 'Execution provider: local, remote, ai', 'local')
215
- .action(async (path, options) => {
216
- const engine = await initializeEngine();
217
- const targetPath = path || '.';
218
- const response = await engine.execute({
219
- type: 'analyze',
220
- command: 'analyze',
221
- payload: {
222
- targetPath,
223
- options: {
224
- format: options.format,
225
- output: options.output,
226
- maxSize: parseInt(options.maxSize, 10),
227
- projectName: options.projectName,
228
- },
229
- },
230
- options: {
231
- json: options.json || isNonTTY(),
232
- provider: options.provider,
233
- },
234
- });
235
- if (options.json || isNonTTY()) {
236
- outputJSON(response);
237
- }
238
- else {
239
- // Human-readable output
240
- if (response.success) {
241
- console.log('\nāœ… Analysis complete');
242
- console.log(` Files analyzed: ${response.data?.filesAnalyzed}`);
243
- console.log(` Findings: ${response.data?.findings}`);
244
- console.log(` Report: ${response.data?.reportFile}`);
245
- }
246
- else {
247
- console.error('\nāŒ Analysis failed:', response.error?.message);
248
- process.exit(1);
249
- }
250
- }
251
- });
252
- program
253
- .command('init [path]')
254
- .description('šŸš€ Initialize a new Delta project with wizard')
255
- .option('-t, --template <name>', 'Project template: default, nextjs, react, node, python', 'default')
256
- .option('-f, --force', 'Overwrite existing config', false)
257
- .option('--git', 'Initialize git repository', false)
258
- .option('--json', 'Output results as JSON', false)
259
- .option('--provider <name>', 'Execution provider: local, remote', 'local')
260
- .option('-w, --wizard', 'Run interactive wizard', false)
261
- .action(async (path, options) => {
262
- // Run wizard if requested or no path provided
263
- if (options.wizard || !path) {
264
- const wizardResult = await runInitWizard();
265
- await executeWizardActions(wizardResult);
266
- // Then run engine init with wizard results
267
- const engine = await initializeEngine();
268
- const response = await engine.execute({
269
- type: 'init',
270
- command: 'init',
271
- payload: {
272
- projectPath: wizardResult.projectPath,
273
- template: wizardResult.template,
274
- force: options.force,
275
- git: wizardResult.initializeGit,
276
- },
277
- options: {
278
- json: options.json || isNonTTY(),
279
- provider: options.provider,
280
- },
281
- });
282
- if (options.json || isNonTTY()) {
283
- outputJSON(response);
284
- }
285
- return;
286
- }
287
- // Standard init flow
288
- const engine = await initializeEngine();
289
- const projectPath = path || '.';
290
- const response = await engine.execute({
291
- type: 'init',
292
- command: 'init',
293
- payload: {
294
- projectPath,
295
- template: options.template,
296
- force: options.force,
297
- git: options.git,
298
- },
299
- options: {
300
- json: options.json || isNonTTY(),
301
- provider: options.provider,
302
- },
303
- });
304
- if (options.json || isNonTTY()) {
305
- outputJSON(response);
306
- }
307
- else {
308
- printWelcome();
309
- if (response.success) {
310
- console.log('\nšŸ“ Project initialized');
311
- console.log(` Path: ${response.data?.projectPath}`);
312
- console.log(` Config: ${response.data?.configPath}`);
313
- console.log(` Template: ${response.data?.template}`);
314
- }
315
- else {
316
- console.error('\nāŒ Init failed:', response.error?.message);
317
- process.exit(1);
318
- }
319
- }
320
- });
321
- program
322
- .command('config')
323
- .description('āš™ļø Manage CLI configuration with schema validation')
324
- .option('-g, --get <key>', 'Get config value')
325
- .option('-s, --set <key=value>', 'Set config value')
326
- .option('-l, --list', 'List all config')
327
- .option('--reset', 'Reset to default configuration')
328
- .action(async (options) => {
329
- const { configCommand } = await import('./commands/config.js');
330
- await configCommand(options);
331
- });
332
- program
333
- .command('status [path]')
334
- .alias('st')
335
- .description('šŸ“ˆ Check project health, connection status, and diagnostics')
336
- .option('--diagnostics', 'Run full diagnostics', false)
337
- .option('--fix', 'Auto-fix issues where possible', false)
338
- .option('--json', 'Output results as JSON', false)
339
- .action(async (path, options) => {
340
- const engine = await initializeEngine();
341
- const projectPath = path || '.';
342
- const response = await engine.execute({
343
- type: 'status',
344
- command: 'status',
345
- payload: {
346
- projectPath,
347
- diagnostics: options.diagnostics,
348
- fix: options.fix,
349
- },
350
- options: {
351
- json: options.json || isNonTTY(),
352
- },
353
- });
354
- if (options.json || isNonTTY()) {
355
- outputJSON(response);
356
- }
357
- else {
358
- if (response.success) {
359
- const data = response.data;
360
- console.log('\nšŸ“Š Project Status');
361
- console.log(` Path: ${data?.project?.path || 'N/A'}`);
362
- console.log(` Config: ${data?.project?.hasConfig ? 'āœ…' : 'āŒ'}`);
363
- console.log(` Auth: ${data?.auth?.authenticated ? 'āœ…' : 'āŒ'}`);
364
- }
365
- else {
366
- console.error('\nāŒ Status check failed:', response.error?.message);
367
- }
368
- }
369
- });
370
- program
371
- .command('completion [shell]')
372
- .description('šŸ”§ Generate shell completion script (bash, zsh, fish, powershell)')
373
- .option('--install', 'Install completion for current shell', false)
374
- .action(async (shell, options) => {
375
- const targetShell = shell || 'bash';
376
- if (options.install) {
377
- await installCompletion(targetShell);
378
- }
379
- else {
380
- console.log(generateCompletionScript(targetShell));
381
- }
382
- });
383
- // New advanced commands
384
- program
385
- .command('sync')
386
- .description('ā˜ļø Sync local analysis with Delta cloud in real-time')
387
- .option('--watch', 'Watch for changes and auto-sync', false)
388
- .option('--force', 'Force sync and overwrite remote', false)
389
- .action(async (options) => {
390
- const { syncCommand } = await import('./commands/sync.js');
391
- await syncCommand(options);
392
- });
393
- program
394
- .command('deploy')
395
- .description('šŸš€ Deploy documentation site to Delta hosting')
396
- .option('--build', 'Build before deploy', true)
397
- .option('--domain <name>', 'Custom domain')
398
- .action(async (options) => {
399
- const { deployCommand } = await import('./commands/deploy.js');
400
- await deployCommand(options);
401
- });
402
- program
403
- .command('plugins')
404
- .description('šŸ”Œ Manage Delta CLI plugins and extensions')
405
- .option('--list', 'List installed plugins')
406
- .option('--install <name>', 'Install a plugin')
407
- .option('--uninstall <name>', 'Uninstall a plugin')
408
- .option('--search <query>', 'Search for plugins')
409
- .action(async (options) => {
410
- const { pluginsCommand } = await import('./commands/plugins.js');
411
- await pluginsCommand(options);
412
- });
413
- program
414
- .command('profile [action]')
415
- .description('šŸŽ­ Manage environment profiles (dev/staging/prod)')
416
- .option('--list', 'List all profiles', false)
417
- .option('--use <name>', 'Switch to profile', '')
418
- .option('--create <name>', 'Create new profile', '')
419
- .option('--delete <name>', 'Delete profile', '')
420
- .option('--provider <name>', 'Provider for new profile', 'local')
421
- .option('--api-url <url>', 'API URL for remote profile', '')
422
- .option('--json', 'Output as JSON', false)
423
- .action(async (action, options) => {
424
- const profiles = getProfileManager();
425
- await profiles.load();
426
- // Apply profile to environment
427
- profiles.applyToEnvironment();
428
- if (options.list || action === 'list') {
429
- const list = profiles.listProfiles();
430
- if (options.json) {
431
- console.log(JSON.stringify(list, null, 2));
432
- }
433
- else {
434
- console.log(chalk.bold.cyan('\nšŸŽ­ Profiles\n'));
435
- list.forEach(p => {
436
- const active = p.active ? chalk.green('ā—') : chalk.gray('ā—‹');
437
- const name = p.active ? chalk.bold(p.name) : p.name;
438
- console.log(` ${active} ${name} ${chalk.gray(`(${p.provider})`)}`);
439
- });
440
- console.log(chalk.gray('\nActive profile affects provider selection and API endpoints'));
441
- }
442
- return;
443
- }
444
- if (options.use) {
445
- await profiles.setActiveProfile(options.use);
446
- console.log(chalk.green(`āœ… Switched to profile: ${options.use}`));
447
- return;
448
- }
449
- if (options.create) {
450
- await profiles.createProfile(options.create, {
451
- provider: options.provider,
452
- apiUrl: options.apiUrl || undefined,
453
- });
454
- console.log(chalk.green(`āœ… Created profile: ${options.create}`));
455
- return;
456
- }
457
- if (options.delete) {
458
- await profiles.deleteProfile(options.delete);
459
- console.log(chalk.green(`āœ… Deleted profile: ${options.delete}`));
460
- return;
461
- }
462
- // Show current profile
463
- const current = profiles.getActiveProfile();
464
- if (options.json) {
465
- console.log(JSON.stringify(current, null, 2));
466
- }
467
- else {
468
- console.log(chalk.bold.cyan('\nšŸŽ­ Active Profile\n'));
469
- console.log(` Name: ${chalk.bold(current.name)}`);
470
- console.log(` Provider: ${current.provider}`);
471
- console.log(` Timeout: ${current.timeout}ms`);
472
- console.log(` Retries: ${current.retries}`);
473
- if (current.apiUrl)
474
- console.log(` API URL: ${current.apiUrl}`);
475
- console.log(` Features: ${Object.entries(current.features)
476
- .filter(([, v]) => v)
477
- .map(([k]) => k)
478
- .join(', ') || 'none'}`);
479
- }
480
- });
481
- program
482
- .command('audit')
483
- .description('šŸ“‹ View audit log of recent commands')
484
- .option('--recent <n>', 'Show last N entries', '50')
485
- .option('--stats', 'Show usage statistics', false)
486
- .option('--json', 'Output as JSON', false)
487
- .action(async (options) => {
488
- const audit = getAuditLogger();
489
- if (options.stats) {
490
- const stats = await audit.getStats();
491
- if (options.json) {
492
- console.log(JSON.stringify(stats, null, 2));
493
- }
494
- else {
495
- console.log(chalk.bold.cyan('\nšŸ“Š Audit Statistics\n'));
496
- console.log(` Total Commands: ${stats.totalCommands}`);
497
- console.log(` Success Rate: ${stats.successRate}%`);
498
- console.log(` Avg Duration: ${stats.avgDuration}ms`);
499
- console.log(` Most Used: ${stats.mostUsed.join(', ') || 'N/A'}`);
500
- console.log(` Last Used: ${stats.lastUsed}`);
501
- }
502
- return;
503
- }
504
- const entries = await audit.getRecentEntries(parseInt(options.recent, 10));
505
- if (options.json) {
506
- console.log(JSON.stringify(entries, null, 2));
507
- }
508
- else {
509
- console.log(chalk.bold.cyan(`\nšŸ“‹ Recent Commands (last ${entries.length})\n`));
510
- entries.forEach(entry => {
511
- const status = entry.success ? chalk.green('āœ“') : chalk.red('āœ—');
512
- const cmd = chalk.cyan(entry.command);
513
- const time = chalk.gray(new Date(entry.timestamp).toLocaleTimeString());
514
- const duration = chalk.gray(`${entry.duration}ms`);
515
- console.log(` ${status} ${cmd} ${time} ${duration}`);
516
- });
517
- }
518
- });
519
- program
520
- .command('hooks')
521
- .description('šŸ”” Manage webhooks and notifications (Slack, Teams)')
522
- .option('--list', 'List all hooks', false)
523
- .option('--add-slack <url>', 'Add Slack webhook')
524
- .option('--add-teams <url>', 'Add Teams webhook')
525
- .option('--remove <id>', 'Remove hook by ID')
526
- .option('--toggle <id>', 'Toggle hook on/off')
527
- .option('--json', 'Output as JSON', false)
528
- .action(async (options) => {
529
- const hooks = getHookManager();
530
- await hooks.load();
531
- if (options.list) {
532
- const list = await hooks.listHooks();
533
- if (options.json) {
534
- console.log(JSON.stringify(list, null, 2));
535
- }
536
- else {
537
- console.log(chalk.bold.cyan('\nšŸ”” Hooks\n'));
538
- if (list.length === 0) {
539
- console.log(chalk.gray(' No hooks configured'));
540
- }
541
- else {
542
- list.forEach(h => {
543
- const status = h.enabled ? chalk.green('ā—') : chalk.red('ā—');
544
- console.log(` ${status} ${h.name} ${chalk.gray(`(${h.type})`)}`);
545
- console.log(` ${chalk.gray(h.url)}`);
546
- });
547
- }
548
- }
549
- return;
550
- }
551
- if (options.addSlack) {
552
- const hook = await hooks.addHook(hookTemplates.slack(options.addSlack));
553
- console.log(chalk.green(`āœ… Added Slack hook: ${hook.id}`));
554
- return;
555
- }
556
- if (options.addTeams) {
557
- const hook = await hooks.addHook(hookTemplates.teams(options.addTeams));
558
- console.log(chalk.green(`āœ… Added Teams hook: ${hook.id}`));
559
- return;
560
- }
561
- if (options.remove) {
562
- await hooks.removeHook(options.remove);
563
- console.log(chalk.green(`āœ… Removed hook: ${options.remove}`));
564
- return;
565
- }
566
- if (options.toggle) {
567
- await hooks.toggleHook(options.toggle);
568
- console.log(chalk.green(`āœ… Toggled hook: ${options.toggle}`));
569
- return;
570
- }
571
- // Show help if no action
572
- console.log(chalk.bold.cyan('\nšŸ”” Hooks Management\n'));
573
- console.log(chalk.gray(' --list List all hooks'));
574
- console.log(chalk.gray(' --add-slack <url> Add Slack webhook'));
575
- console.log(chalk.gray(' --add-teams <url> Add Teams webhook'));
576
- console.log(chalk.gray(' --remove <id> Remove hook'));
577
- console.log(chalk.gray(' --toggle <id> Toggle hook on/off'));
578
- });
579
- // Parse arguments
580
- const args = process.argv.slice(2);
581
- // Handle slash commands (e.g., /help, /analyze)
582
- const slashCommandMap = {
583
- '/help': 'help',
584
- '/h': 'help',
585
- '/analyze': 'analyze',
586
- '/a': 'analyze',
587
- '/status': 'status',
588
- '/st': 'status',
589
- '/init': 'init',
590
- '/i': 'init',
591
- '/login': 'login',
592
- '/logout': 'logout',
593
- '/whoami': 'whoami',
594
- '/me': 'whoami',
595
- '/config': 'config',
596
- '/dashboard': 'dashboard',
597
- '/ui': 'dashboard',
598
- '/sync': 'sync',
599
- '/deploy': 'deploy',
600
- '/plugins': 'plugins',
601
- '/version': '--version',
602
- '/v': '--version',
603
- };
604
- // Convert slash commands to regular commands
605
- if (args.length > 0 && args[0].startsWith('/')) {
606
- const slashCmd = args[0].toLowerCase();
607
- const mappedCmd = slashCommandMap[slashCmd];
608
- if (mappedCmd) {
609
- if (mappedCmd.startsWith('--')) {
610
- // It's a flag like --version
611
- args[0] = mappedCmd;
612
- }
613
- else {
614
- // It's a command
615
- args[0] = mappedCmd;
616
- }
617
- }
618
- else {
619
- // Unknown slash command
620
- console.error(chalk.red(`āŒ Unknown command: ${slashCmd}`));
621
- console.log(chalk.gray('Run /help to see available commands'));
622
- process.exit(1);
623
- }
624
- }
625
- const parsed = program.parse(['node', 'delta', ...args]);
626
- // If no command provided and not in interactive mode, show welcome
627
- if (process.argv.length <= 2 && !parsed.opts().interactive) {
628
- printWelcome();
629
- printTips();
630
- }
631
- // Run interactive mode if requested
632
- if (parsed.opts().interactive) {
633
- printWelcome();
634
- runInteractiveMode({});
635
- }
636
- //# sourceMappingURL=index.js.map
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from 'ink';
3
- import { DeltaApp } from '../components/DeltaApp.js';
4
- import { UnifiedManager } from '../components/UnifiedManager.js';
5
- export async function runInteractiveMode(options) {
6
- // Render the React Ink app
7
- const Component = options.mode === 'manager' ? UnifiedManager : DeltaApp;
8
- const { waitUntilExit } = render(_jsx(Component, {}));
9
- await waitUntilExit();
10
- }
11
- //# sourceMappingURL=index.js.map