@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,184 +0,0 @@
1
- /**
2
- * Audit Logger for Delta CLI
3
- * Tracks all commands, results, and performance metrics
4
- * Enterprise-grade logging for compliance and debugging
5
- */
6
- import { promises as fs } from 'fs';
7
- import { homedir } from 'os';
8
- import { join } from 'path';
9
- const DEFAULT_CONFIG = {
10
- enabled: true,
11
- logLevel: 'standard',
12
- retentionDays: 30,
13
- maxEntries: 10000,
14
- includeMetadata: true,
15
- };
16
- const AUDIT_DIR = join(homedir(), '.delta', 'audit');
17
- const AUDIT_FILE = join(AUDIT_DIR, 'commands.jsonl');
18
- const CONFIG_FILE = join(AUDIT_DIR, 'config.json');
19
- export class AuditLogger {
20
- config;
21
- initialized = false;
22
- constructor() {
23
- this.config = DEFAULT_CONFIG;
24
- }
25
- async initialize() {
26
- if (this.initialized)
27
- return;
28
- try {
29
- await fs.mkdir(AUDIT_DIR, { recursive: true });
30
- // Load config if exists
31
- try {
32
- const configData = await fs.readFile(CONFIG_FILE, 'utf-8');
33
- this.config = { ...DEFAULT_CONFIG, ...JSON.parse(configData) };
34
- }
35
- catch {
36
- // Use defaults
37
- }
38
- this.initialized = true;
39
- }
40
- catch (error) {
41
- console.error('Failed to initialize audit logger:', error);
42
- }
43
- }
44
- async logCommand(command, args, options, response, startTime) {
45
- if (!this.config.enabled)
46
- return;
47
- await this.initialize();
48
- const entry = {
49
- id: this.generateId(),
50
- timestamp: new Date().toISOString(),
51
- command,
52
- args,
53
- options: this.sanitizeOptions(options),
54
- exitCode: response.exitCode || (response.success ? 0 : 1),
55
- success: response.success,
56
- duration: Date.now() - startTime,
57
- provider: response.meta?.provider || 'unknown',
58
- error: response.error,
59
- };
60
- if (this.config.includeMetadata) {
61
- entry.metadata = {
62
- nodeVersion: process.version,
63
- platform: process.platform,
64
- cwd: process.cwd(),
65
- ci: process.env.CI === 'true',
66
- };
67
- }
68
- // Write to log file
69
- await this.appendEntry(entry);
70
- // Send to remote if configured
71
- if (this.config.remoteEndpoint) {
72
- await this.sendRemote(entry).catch(() => { });
73
- }
74
- }
75
- async getRecentEntries(limit = 50) {
76
- await this.initialize();
77
- try {
78
- const data = await fs.readFile(AUDIT_FILE, 'utf-8');
79
- const lines = data.trim().split('\n').filter(Boolean);
80
- return lines
81
- .slice(-limit)
82
- .map(line => JSON.parse(line))
83
- .reverse();
84
- }
85
- catch {
86
- return [];
87
- }
88
- }
89
- async getStats() {
90
- const entries = await this.getRecentEntries(1000);
91
- if (entries.length === 0) {
92
- return {
93
- totalCommands: 0,
94
- successRate: 0,
95
- avgDuration: 0,
96
- mostUsed: [],
97
- lastUsed: 'Never',
98
- };
99
- }
100
- const commands = entries.map(e => e.command);
101
- const successCount = entries.filter(e => e.success).length;
102
- const totalDuration = entries.reduce((sum, e) => sum + e.duration, 0);
103
- // Count command frequency
104
- const frequency = {};
105
- commands.forEach(cmd => {
106
- frequency[cmd] = (frequency[cmd] || 0) + 1;
107
- });
108
- const mostUsed = Object.entries(frequency)
109
- .sort((a, b) => b[1] - a[1])
110
- .slice(0, 5)
111
- .map(([cmd]) => cmd);
112
- return {
113
- totalCommands: entries.length,
114
- successRate: Math.round((successCount / entries.length) * 100),
115
- avgDuration: Math.round(totalDuration / entries.length),
116
- mostUsed,
117
- lastUsed: entries[0]?.timestamp || 'Never',
118
- };
119
- }
120
- async appendEntry(entry) {
121
- const line = JSON.stringify(entry) + '\n';
122
- await fs.appendFile(AUDIT_FILE, line, 'utf-8');
123
- }
124
- async sendRemote(entry) {
125
- if (!this.config.remoteEndpoint)
126
- return;
127
- try {
128
- await fetch(this.config.remoteEndpoint, {
129
- method: 'POST',
130
- headers: { 'Content-Type': 'application/json' },
131
- body: JSON.stringify(entry),
132
- });
133
- }
134
- catch {
135
- // Silently fail - don't block CLI execution
136
- }
137
- }
138
- sanitizeOptions(options) {
139
- const sensitiveKeys = ['token', 'password', 'secret', 'key', 'auth'];
140
- const sanitized = {};
141
- for (const [key, value] of Object.entries(options)) {
142
- if (sensitiveKeys.some(sk => key.toLowerCase().includes(sk))) {
143
- sanitized[key] = '[REDACTED]';
144
- }
145
- else {
146
- sanitized[key] = value;
147
- }
148
- }
149
- return sanitized;
150
- }
151
- generateId() {
152
- return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
153
- }
154
- // Cleanup old entries
155
- async cleanup() {
156
- if (!this.config.enabled)
157
- return;
158
- try {
159
- const entries = await this.getRecentEntries(this.config.maxEntries);
160
- const cutoff = new Date();
161
- cutoff.setDate(cutoff.getDate() - this.config.retentionDays);
162
- const validEntries = entries.filter(e => new Date(e.timestamp) > cutoff);
163
- // Rewrite file with only valid entries
164
- const data = validEntries.map(e => JSON.stringify(e)).join('\n') + '\n';
165
- await fs.writeFile(AUDIT_FILE, data, 'utf-8');
166
- }
167
- catch {
168
- // Ignore cleanup errors
169
- }
170
- }
171
- }
172
- // Singleton instance
173
- let auditLogger = null;
174
- export function getAuditLogger() {
175
- if (!auditLogger) {
176
- auditLogger = new AuditLogger();
177
- }
178
- return auditLogger;
179
- }
180
- // Export for testing
181
- export function resetAuditLogger() {
182
- auditLogger = null;
183
- }
184
- //# sourceMappingURL=audit.js.map
@@ -1,294 +0,0 @@
1
- /**
2
- * Tab Autocomplete System for Delta CLI
3
- * Provides shell completion for commands, flags, and options
4
- */
5
- // Completion items database
6
- export const completionDatabase = {
7
- commands: [
8
- { name: 'help', alias: ['/?', '/h'], desc: 'Show help' },
9
- { name: 'analyze', alias: ['/a', '/analyze'], desc: 'Code analysis' },
10
- { name: 'init', alias: ['/i', '/init'], desc: 'Initialize project' },
11
- { name: 'status', alias: ['/st', '/status'], desc: 'Check status' },
12
- { name: 'login', alias: ['/login'], desc: 'Authenticate' },
13
- { name: 'logout', alias: ['/logout'], desc: 'Sign out' },
14
- { name: 'whoami', alias: ['/me', '/whoami'], desc: 'User info' },
15
- { name: 'config', alias: ['/config'], desc: 'Configuration' },
16
- { name: 'dashboard', alias: ['/ui', '/dashboard'], desc: 'Interactive UI' },
17
- { name: 'sync', alias: ['/sync'], desc: 'Cloud sync' },
18
- { name: 'deploy', alias: ['/deploy'], desc: 'Deploy project' },
19
- { name: 'plugins', alias: ['/plugins'], desc: 'Manage plugins' },
20
- ],
21
- globalFlags: [
22
- { name: '--json', desc: 'Output as JSON' },
23
- { name: '--provider', values: ['local', 'remote', 'ai'], desc: 'Execution provider' },
24
- { name: '--theme', values: ['delta', 'cyber', 'sunset', 'neon', 'ocean', 'fire'], desc: 'Color theme' },
25
- { name: '--verbose', desc: 'Verbose logging' },
26
- { name: '--no-color', desc: 'Disable colors' },
27
- { name: '--interactive', alias: '-i', desc: 'Interactive mode' },
28
- { name: '--version', alias: '-v', desc: 'Show version' },
29
- { name: '--help', alias: '-h', desc: 'Show help' },
30
- ],
31
- commandFlags: {
32
- analyze: [
33
- { name: '--format', values: ['json', 'html', 'markdown', 'sarif'], desc: 'Output format' },
34
- { name: '--output', values: ['./delta-reports'], desc: 'Output directory' },
35
- { name: '--include', desc: 'Include patterns' },
36
- { name: '--exclude', desc: 'Exclude patterns' },
37
- { name: '--max-size', desc: 'Max file size' },
38
- { name: '--upload', desc: 'Upload to cloud' },
39
- { name: '--share', desc: 'Generate shareable link' },
40
- { name: '--project-name', desc: 'Project name' },
41
- { name: '--ai-insights', desc: 'AI insights' },
42
- { name: '--security-scan', desc: 'Security scan' },
43
- { name: '--performance', desc: 'Performance analysis' },
44
- ],
45
- init: [
46
- { name: '--template', values: ['default', 'nextjs', 'react', 'node', 'python'], desc: 'Project template' },
47
- { name: '--force', alias: '-f', desc: 'Overwrite existing' },
48
- { name: '--git', desc: 'Initialize git' },
49
- ],
50
- status: [
51
- { name: '--diagnostics', desc: 'Full diagnostics' },
52
- { name: '--fix', desc: 'Auto-fix issues' },
53
- ],
54
- login: [
55
- { name: '--method', values: ['oauth', 'pat', 'github', 'google'], desc: 'Auth method' },
56
- { name: '--token', desc: 'PAT token' },
57
- ],
58
- config: [
59
- { name: '--get', desc: 'Get config value' },
60
- { name: '--set', desc: 'Set config value' },
61
- { name: '--list', alias: '-l', desc: 'List all config' },
62
- { name: '--reset', desc: 'Reset to default' },
63
- ],
64
- },
65
- };
66
- // Generate shell completion script
67
- export function generateCompletionScript(shell) {
68
- const cliName = 'delta';
69
- switch (shell) {
70
- case 'bash':
71
- return generateBashCompletion(cliName);
72
- case 'zsh':
73
- return generateZshCompletion(cliName);
74
- case 'fish':
75
- return generateFishCompletion(cliName);
76
- case 'powershell':
77
- return generatePowershellCompletion(cliName);
78
- default:
79
- throw new Error(`Unsupported shell: ${shell}`);
80
- }
81
- }
82
- function generateBashCompletion(cliName) {
83
- const commands = completionDatabase.commands.map(c => c.name).join(' ');
84
- const slashCommands = completionDatabase.commands.flatMap(c => c.alias).filter(a => a.startsWith('/')).join(' ');
85
- return `#!/bin/bash
86
- # Delta CLI Bash Completion
87
- # Source this file: source <(delta completion bash)
88
-
89
- _${cliName}_completions() {
90
- local cur prev opts
91
- COMPREPLY=()
92
- cur="\${COMP_WORDS[COMP_CWORD]}"
93
- prev="\${COMP_WORDS[COMP_CWORD-1]}"
94
-
95
- # Commands list
96
- local commands="${commands} ${slashCommands}"
97
- local global_flags="--json --provider --theme --verbose --no-color --interactive --version --help -i -v -h"
98
-
99
- # Complete commands
100
- if [[ \${COMP_CWORD} -eq 1 ]]; then
101
- COMPREPLY=( $(compgen -W "\${commands} \${global_flags}" -- \${cur}) )
102
- return 0
103
- fi
104
-
105
- # Complete flags based on command
106
- case "\${COMP_WORDS[1]}" in
107
- analyze|/a|/analyze)
108
- opts="--format --output --include --exclude --max-size --upload --share --project-name --ai-insights --security-scan --performance --json --provider"
109
- ;;
110
- init|/i|/init)
111
- opts="--template --force --git --json --provider -f"
112
- ;;
113
- status|/st|/status)
114
- opts="--diagnostics --fix --json"
115
- ;;
116
- login|/login)
117
- opts="--method --token --json"
118
- ;;
119
- config|/config)
120
- opts="--get --set --list --reset -l --json"
121
- ;;
122
- *)
123
- opts="\${global_flags}"
124
- ;;
125
- esac
126
-
127
- # Complete flag values
128
- case "\${prev}" in
129
- --provider)
130
- COMPREPLY=( $(compgen -W "local remote ai" -- \${cur}) )
131
- return 0
132
- ;;
133
- --theme)
134
- COMPREPLY=( $(compgen -W "delta cyber sunset neon ocean fire" -- \${cur}) )
135
- return 0
136
- ;;
137
- --format)
138
- COMPREPLY=( $(compgen -W "json html markdown sarif" -- \${cur}) )
139
- return 0
140
- ;;
141
- --template)
142
- COMPREPLY=( $(compgen -W "default nextjs react node python" -- \${cur}) )
143
- return 0
144
- ;;
145
- --method)
146
- COMPREPLY=( $(compgen -W "oauth pat github google" -- \${cur}) )
147
- return 0
148
- ;;
149
- esac
150
-
151
- COMPREPLY=( $(compgen -W "\${opts}" -- \${cur}) )
152
- return 0
153
- }
154
-
155
- complete -F _${cliName}_completions ${cliName}
156
- `;
157
- }
158
- function generateZshCompletion(cliName) {
159
- return `#compdef ${cliName}
160
- # Delta CLI Zsh Completion
161
-
162
- _${cliName}() {
163
- local curcontext="$curcontext" state line
164
- typeset -A opt_args
165
-
166
- _arguments -C \\
167
- '(-h --help)'{-h,--help}'[Show help]' \\
168
- '(-v --version)'{-v,--version}'[Show version]' \\
169
- '(-i --interactive)'{-i,--interactive}'[Interactive mode]' \\
170
- '--json[Output as JSON]' \\
171
- '--provider[Execution provider]:provider:(local remote ai)' \\
172
- '--theme[Color theme]:theme:(delta cyber sunset neon ocean fire)' \\
173
- '--verbose[Verbose logging]' \\
174
- '--no-color[Disable colors]' \\
175
- '1: :->command' \\
176
- '*:: :->args'
177
-
178
- case "$state" in
179
- command)
180
- _values 'commands' \\
181
- 'help[Show help]' \\
182
- 'analyze[Code analysis]' \\
183
- 'init[Initialize project]' \\
184
- 'status[Check status]' \\
185
- 'login[Authenticate]' \\
186
- 'logout[Sign out]' \\
187
- 'whoami[User info]' \\
188
- 'config[Configuration]' \\
189
- 'dashboard[Interactive UI]' \\
190
- 'sync[Cloud sync]' \\
191
- 'deploy[Deploy project]' \\
192
- 'plugins[Manage plugins]'
193
- ;;
194
- args)
195
- case "$line[1]" in
196
- analyze)
197
- _arguments \\
198
- '--format[Output format]:format:(json html markdown sarif)' \\
199
- '--output[Output directory]' \\
200
- '--include[Include patterns]' \\
201
- '--exclude[Exclude patterns]' \\
202
- '--upload[Upload to cloud]' \\
203
- '--share[Generate shareable link]' \\
204
- '--project-name[Project name]'
205
- ;;
206
- init)
207
- _arguments \\
208
- '--template[Project template]:template:(default nextjs react node python)' \\
209
- '(-f --force)'{-f,--force}'[Overwrite existing]' \\
210
- '--git[Initialize git]'
211
- ;;
212
- status)
213
- _arguments \\
214
- '--diagnostics[Full diagnostics]' \\
215
- '--fix[Auto-fix issues]'
216
- ;;
217
- esac
218
- ;;
219
- esac
220
- }
221
-
222
- _${cliName} "$@"
223
- `;
224
- }
225
- function generateFishCompletion(cliName) {
226
- return `# Delta CLI Fish Completion
227
-
228
- # Commands
229
- complete -c ${cliName} -f
230
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'help' -d 'Show help'
231
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'analyze' -d 'Code analysis'
232
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'init' -d 'Initialize project'
233
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'status' -d 'Check status'
234
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'login' -d 'Authenticate'
235
- complete -c ${cliName} -n '__fish_use_subcommand' -a 'logout' -d 'Sign out'
236
-
237
- # Global flags
238
- complete -c ${cliName} -l json -d 'Output as JSON'
239
- complete -c ${cliName} -l provider -d 'Execution provider' -xa 'local remote ai'
240
- complete -c ${cliName} -l theme -d 'Color theme' -xa 'delta cyber sunset neon ocean fire'
241
- complete -c ${cliName} -l verbose -d 'Verbose logging'
242
- complete -c ${cliName} -l no-color -d 'Disable colors'
243
- complete -c ${cliName} -s i -l interactive -d 'Interactive mode'
244
- complete -c ${cliName} -s v -l version -d 'Show version'
245
- complete -c ${cliName} -s h -l help -d 'Show help'
246
- `;
247
- }
248
- function generatePowershellCompletion(cliName) {
249
- return `# Delta CLI PowerShell Completion
250
- # Add to $PROFILE: . delta completion powershell | Out-String | Invoke-Expression
251
-
252
- Register-ArgumentCompleter -Native -CommandName ${cliName} -ScriptBlock {
253
- param($wordToComplete, $commandAst, $cursorPosition)
254
-
255
- $commands = @('help', 'analyze', 'init', 'status', 'login', 'logout', 'whoami', 'config', 'dashboard', 'sync', 'deploy', 'plugins')
256
- $slashCommands = @('/help', '/h', '/analyze', '/a', '/init', '/i', '/status', '/st', '/login', '/logout', '/me', '/whoami', '/config', '/ui', '/sync', '/deploy', '/plugins')
257
-
258
- $command = $commandAst.CommandElements[1].Value
259
-
260
- if ($commandAst.CommandElements.Count -eq 1 -or
261
- ($commandAst.CommandElements.Count -eq 2 -and $wordToComplete -ne '')) {
262
- $commands + $slashCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
263
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
264
- }
265
- return
266
- }
267
-
268
- switch ($command) {
269
- { $_ -in 'analyze', '/a', '/analyze' } {
270
- $flags = @('--format', '--output', '--include', '--exclude', '--upload', '--share', '--json', '--provider')
271
- $flags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
272
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterName', $_)
273
- }
274
- }
275
- { $_ -in 'init', '/i', '/init' } {
276
- $flags = @('--template', '--force', '--git', '--json')
277
- $flags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
278
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterName', $_)
279
- }
280
- }
281
- }
282
- }
283
- `;
284
- }
285
- // Install completion for current shell
286
- export async function installCompletion(shell) {
287
- const detectedShell = shell || process.env.SHELL?.split('/').pop() || 'bash';
288
- console.log(`Installing completion for ${detectedShell}...\n`);
289
- const script = generateCompletionScript(detectedShell);
290
- console.log('Add this to your shell config:\n');
291
- console.log(script);
292
- console.log('\nOr run: eval "$(delta completion ' + detectedShell + ')"');
293
- }
294
- //# sourceMappingURL=completion.js.map
@@ -1,6 +0,0 @@
1
- /**
2
- * Core Contracts - Interface definitions for Delta CLI
3
- * AI-Ready Architecture: Separate CLI from Business Logic
4
- */
5
- export {};
6
- //# sourceMappingURL=contracts.js.map
@@ -1,124 +0,0 @@
1
- /**
2
- * Delta Engine - Core Execution Engine
3
- * Mediator between CLI and Execution Providers
4
- */
5
- import { ExitCode, getExitCode } from './exit-codes.js';
6
- export class DeltaEngine {
7
- providers = new Map();
8
- config;
9
- policy;
10
- listeners = [];
11
- version = '2.0.0';
12
- constructor(config, policy) {
13
- this.config = config;
14
- this.policy = policy;
15
- }
16
- // Register an execution provider
17
- registerProvider(provider) {
18
- this.providers.set(provider.name, provider);
19
- }
20
- // Get registered provider
21
- getProvider(name) {
22
- return this.providers.get(name);
23
- }
24
- // Execute a task through the engine
25
- async execute(request) {
26
- const startTime = Date.now();
27
- // Emit start event
28
- this.emit({ type: 'task:start', request });
29
- try {
30
- // Validate request with policy (includes capability check)
31
- const validation = this.policy.validate(request);
32
- if (!validation.valid) {
33
- const exitCode = validation.exitCode || ExitCode.VALIDATION_ERROR;
34
- throw Object.assign(new Error(validation.reason || 'Task validation failed'), { code: exitCode === ExitCode.POLICY_BLOCKED ? 'POLICY_BLOCKED' : 'VALIDATION_ERROR', exitCode });
35
- }
36
- // Transform request if needed (includes non-TTY detection)
37
- const transformedRequest = this.policy.transform?.(request) || request;
38
- // Select appropriate provider using policy
39
- const provider = this.policy.selectProvider(transformedRequest, this.providers);
40
- if (!provider) {
41
- throw Object.assign(new Error(`No provider available for task type '${transformedRequest.type}'`), { code: 'NO_PROVIDER', exitCode: ExitCode.POLICY_BLOCKED });
42
- }
43
- // Check provider availability
44
- const available = await provider.isAvailable();
45
- if (!available) {
46
- throw Object.assign(new Error(`Provider '${provider.name}' is not available`), { code: 'PROVIDER_UNAVAILABLE', exitCode: ExitCode.NETWORK_ERROR });
47
- }
48
- // Execute task
49
- this.emit({ type: 'task:progress', request: transformedRequest, progress: 0.5 });
50
- const response = await provider.execute(transformedRequest);
51
- // Enrich response with engine metadata
52
- const enrichedResponse = {
53
- ...response,
54
- meta: {
55
- ...response.meta,
56
- command: request.command,
57
- duration: Date.now() - startTime,
58
- timestamp: new Date().toISOString(),
59
- version: this.version,
60
- coldStart: Date.now() - startTime - response.meta.duration,
61
- provider: provider.name,
62
- },
63
- };
64
- // Emit completion
65
- this.emit({
66
- type: 'task:complete',
67
- request: transformedRequest,
68
- response: enrichedResponse
69
- });
70
- return enrichedResponse;
71
- }
72
- catch (error) {
73
- // Emit error
74
- this.emit({
75
- type: 'task:error',
76
- request,
77
- error: error instanceof Error ? error : new Error(String(error))
78
- });
79
- return {
80
- success: false,
81
- exitCode: getExitCode(error),
82
- meta: {
83
- command: request.command,
84
- duration: Date.now() - startTime,
85
- timestamp: new Date().toISOString(),
86
- version: this.version,
87
- provider: 'engine',
88
- },
89
- error: {
90
- code: error instanceof Error && 'code' in error
91
- ? error.code
92
- : 'EXECUTION_ERROR',
93
- message: error instanceof Error ? error.message : String(error),
94
- },
95
- };
96
- }
97
- }
98
- // Subscribe to engine events
99
- on(_event, listener) {
100
- this.listeners.push(listener);
101
- }
102
- // Emit event to all listeners
103
- emit(event) {
104
- this.listeners.forEach(listener => listener(event));
105
- }
106
- // Get engine status
107
- getStatus() {
108
- return {
109
- version: this.version,
110
- providers: Array.from(this.providers.keys()),
111
- defaultProvider: this.config.defaultProvider,
112
- };
113
- }
114
- }
115
- // Singleton instance
116
- let engineInstance = null;
117
- export function createEngine(config, policy) {
118
- engineInstance = new DeltaEngine(config, policy);
119
- return engineInstance;
120
- }
121
- export function getEngine() {
122
- return engineInstance;
123
- }
124
- //# sourceMappingURL=engine.js.map
@@ -1,71 +0,0 @@
1
- /**
2
- * Exit Code Contract - Enterprise-grade error classification
3
- * Critical for CI/CD integration and automation
4
- */
5
- export var ExitCode;
6
- (function (ExitCode) {
7
- ExitCode[ExitCode["SUCCESS"] = 0] = "SUCCESS";
8
- ExitCode[ExitCode["VALIDATION_ERROR"] = 1] = "VALIDATION_ERROR";
9
- ExitCode[ExitCode["NETWORK_ERROR"] = 2] = "NETWORK_ERROR";
10
- ExitCode[ExitCode["AUTH_ERROR"] = 3] = "AUTH_ERROR";
11
- ExitCode[ExitCode["POLICY_BLOCKED"] = 4] = "POLICY_BLOCKED";
12
- ExitCode[ExitCode["EXECUTION_ERROR"] = 5] = "EXECUTION_ERROR";
13
- ExitCode[ExitCode["UNKNOWN_ERROR"] = 6] = "UNKNOWN_ERROR";
14
- })(ExitCode || (ExitCode = {}));
15
- // Error to Exit Code mapping
16
- export function getExitCode(error) {
17
- const errorStr = typeof error === 'string'
18
- ? error
19
- : error instanceof Error
20
- ? error.message
21
- : error.message || String(error);
22
- const errorCode = typeof error === 'object' && 'code' in error ? error.code : undefined;
23
- // Check error codes first
24
- if (errorCode) {
25
- switch (errorCode) {
26
- case 'VALIDATION_ERROR':
27
- case 'INVALID_INPUT':
28
- case 'MISSING_ARGUMENT':
29
- return ExitCode.VALIDATION_ERROR;
30
- case 'AUTH_ERROR':
31
- case 'UNAUTHORIZED':
32
- case 'TOKEN_EXPIRED':
33
- return ExitCode.AUTH_ERROR;
34
- case 'NETWORK_ERROR':
35
- case 'CONNECTION_FAILED':
36
- case 'TIMEOUT':
37
- return ExitCode.NETWORK_ERROR;
38
- case 'POLICY_BLOCKED':
39
- case 'QUOTA_EXCEEDED':
40
- case 'PERMISSION_DENIED':
41
- return ExitCode.POLICY_BLOCKED;
42
- case 'EXECUTION_ERROR':
43
- return ExitCode.EXECUTION_ERROR;
44
- }
45
- }
46
- // Check error messages
47
- if (errorStr.includes('validation') || errorStr.includes('invalid') || errorStr.includes('required')) {
48
- return ExitCode.VALIDATION_ERROR;
49
- }
50
- if (errorStr.includes('auth') || errorStr.includes('token') || errorStr.includes('unauthorized')) {
51
- return ExitCode.AUTH_ERROR;
52
- }
53
- if (errorStr.includes('network') || errorStr.includes('connection') || errorStr.includes('timeout')) {
54
- return ExitCode.NETWORK_ERROR;
55
- }
56
- if (errorStr.includes('policy') || errorStr.includes('quota') || errorStr.includes('permission')) {
57
- return ExitCode.POLICY_BLOCKED;
58
- }
59
- return ExitCode.EXECUTION_ERROR;
60
- }
61
- // Human-readable exit code descriptions
62
- export const ExitCodeDescription = {
63
- [ExitCode.SUCCESS]: 'Success',
64
- [ExitCode.VALIDATION_ERROR]: 'Validation error - check your input',
65
- [ExitCode.NETWORK_ERROR]: 'Network error - check your connection',
66
- [ExitCode.AUTH_ERROR]: 'Authentication error - please login',
67
- [ExitCode.POLICY_BLOCKED]: 'Policy blocked - insufficient permissions or quota',
68
- [ExitCode.EXECUTION_ERROR]: 'Execution error - task failed during execution',
69
- [ExitCode.UNKNOWN_ERROR]: 'Unknown error - please report this issue',
70
- };
71
- //# sourceMappingURL=exit-codes.js.map