@vee-stack/delta-cli 2.0.9 → 2.0.11

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 (98) hide show
  1. package/dist/adapters/analysis.adapter.d.ts +29 -0
  2. package/dist/analyzer/commands/analyze.d.ts +14 -0
  3. package/dist/analyzer/commands/config.d.ts +12 -0
  4. package/dist/analyzer/commands/report.d.ts +11 -0
  5. package/dist/analyzer/generators/report.generator.d.ts +43 -0
  6. package/dist/analyzer/index.d.ts +8 -0
  7. package/dist/analyzer/scanners/project.scanner.d.ts +29 -0
  8. package/dist/analyzer/validators/contracts.validator.d.ts +27 -0
  9. package/dist/analyzer/validators/maintainability.validator.d.ts +27 -0
  10. package/dist/analyzer/validators/observability.validator.d.ts +27 -0
  11. package/dist/analyzer/validators/performance.validator.d.ts +27 -0
  12. package/dist/analyzer/validators/security.validator.d.ts +27 -0
  13. package/dist/analyzer/validators/soc.validator.d.ts +27 -0
  14. package/dist/auth/device-auth.d.ts +18 -0
  15. package/dist/auth/secure-auth.d.ts +35 -0
  16. package/dist/bundle.mjs +422 -0
  17. package/dist/commands/analyze.d.ts +12 -0
  18. package/dist/commands/auth-new.d.ts +6 -0
  19. package/dist/commands/auth.d.ts +17 -0
  20. package/dist/commands/config.d.ts +8 -0
  21. package/dist/commands/deploy.d.ts +5 -0
  22. package/dist/commands/init.d.ts +7 -0
  23. package/dist/commands/logout.d.ts +2 -0
  24. package/dist/commands/plugins.d.ts +7 -0
  25. package/dist/commands/status.d.ts +5 -0
  26. package/dist/commands/sync.d.ts +5 -0
  27. package/dist/commands/whoami.d.ts +4 -0
  28. package/dist/components/Dashboard.d.ts +8 -0
  29. package/dist/components/DeltaApp.d.ts +13 -0
  30. package/dist/components/UnifiedManager.d.ts +10 -0
  31. package/dist/core/audit.d.ts +60 -0
  32. package/dist/core/completion.d.ts +79 -0
  33. package/dist/core/contracts.d.ts +127 -0
  34. package/dist/core/engine.d.ts +26 -0
  35. package/dist/core/exit-codes.d.ts +19 -0
  36. package/dist/core/hooks.d.ts +50 -0
  37. package/dist/core/{index.js → index.d.ts} +1 -1
  38. package/dist/core/policy.d.ts +24 -0
  39. package/dist/core/profiles.d.ts +45 -0
  40. package/dist/core/wizard.d.ts +28 -0
  41. package/dist/interactive/index.d.ts +5 -0
  42. package/dist/plugins/GitStatusPlugin.d.ts +25 -0
  43. package/dist/providers/ai-provider.d.ts +21 -0
  44. package/dist/providers/local-provider.d.ts +21 -0
  45. package/dist/providers/remote-provider.d.ts +15 -0
  46. package/dist/telemetry/wrapper.d.ts +18 -0
  47. package/dist/types/api.d.ts +46 -0
  48. package/dist/ui.d.ts +52 -0
  49. package/dist/welcome.d.ts +8 -0
  50. package/package.json +8 -10
  51. package/dist/adapters/analysis.adapter.js +0 -42
  52. package/dist/analyzer/commands/analyze.js +0 -220
  53. package/dist/analyzer/commands/config.js +0 -83
  54. package/dist/analyzer/commands/report.js +0 -38
  55. package/dist/analyzer/generators/report.generator.js +0 -123
  56. package/dist/analyzer/index.js +0 -44
  57. package/dist/analyzer/scanners/project.scanner.js +0 -92
  58. package/dist/analyzer/validators/contracts.validator.js +0 -42
  59. package/dist/analyzer/validators/maintainability.validator.js +0 -40
  60. package/dist/analyzer/validators/observability.validator.js +0 -39
  61. package/dist/analyzer/validators/performance.validator.js +0 -42
  62. package/dist/analyzer/validators/security.validator.js +0 -66
  63. package/dist/analyzer/validators/soc.validator.js +0 -75
  64. package/dist/auth/device-auth.js +0 -261
  65. package/dist/auth/secure-auth.js +0 -401
  66. package/dist/commands/analyze.js +0 -393
  67. package/dist/commands/auth-new.js +0 -37
  68. package/dist/commands/auth.js +0 -131
  69. package/dist/commands/config.js +0 -51
  70. package/dist/commands/deploy.js +0 -6
  71. package/dist/commands/init.js +0 -47
  72. package/dist/commands/logout.js +0 -31
  73. package/dist/commands/plugins.js +0 -21
  74. package/dist/commands/status.js +0 -82
  75. package/dist/commands/sync.js +0 -6
  76. package/dist/commands/whoami.js +0 -72
  77. package/dist/components/Dashboard.js +0 -167
  78. package/dist/components/DeltaApp.js +0 -57
  79. package/dist/components/UnifiedManager.js +0 -372
  80. package/dist/core/audit.js +0 -184
  81. package/dist/core/completion.js +0 -305
  82. package/dist/core/contracts.js +0 -6
  83. package/dist/core/engine.js +0 -130
  84. package/dist/core/exit-codes.js +0 -79
  85. package/dist/core/hooks.js +0 -181
  86. package/dist/core/policy.js +0 -115
  87. package/dist/core/profiles.js +0 -161
  88. package/dist/core/wizard.js +0 -203
  89. package/dist/index.js +0 -403
  90. package/dist/interactive/index.js +0 -11
  91. package/dist/plugins/GitStatusPlugin.js +0 -93
  92. package/dist/providers/ai-provider.js +0 -74
  93. package/dist/providers/local-provider.js +0 -304
  94. package/dist/providers/remote-provider.js +0 -100
  95. package/dist/telemetry/wrapper.js +0 -114
  96. package/dist/types/api.js +0 -3
  97. package/dist/ui.js +0 -226
  98. package/dist/welcome.js +0 -91
@@ -1,304 +0,0 @@
1
- /**
2
- * Local Execution Provider
3
- * Implements all logic locally without external AI services
4
- */
5
- import { ExitCode } from '../core/exit-codes.js';
6
- import * as fs from 'fs/promises';
7
- import * as path from 'path';
8
- import { loadConfig } from '../commands/auth.js';
9
- import { SecureTokenStore } from '../auth/secure-auth.js';
10
- export class LocalProvider {
11
- name = 'local';
12
- version = '2.0.0';
13
- capabilities = {
14
- commands: ['analyze', 'init', 'status', 'config', 'auth'],
15
- features: {
16
- json: true,
17
- streaming: false,
18
- caching: true,
19
- ai: false,
20
- },
21
- constraints: {
22
- maxFileSize: 10 * 1024 * 1024, // 10MB
23
- maxFiles: 1000,
24
- requiresAuth: false,
25
- },
26
- };
27
- config;
28
- constructor(config) {
29
- this.config = config;
30
- }
31
- async isAvailable() {
32
- // Local provider is always available
33
- return true;
34
- }
35
- async execute(request) {
36
- const startTime = Date.now();
37
- try {
38
- switch (request.type) {
39
- case 'analyze':
40
- return await this.executeAnalyze(request);
41
- case 'init':
42
- return await this.executeInit(request);
43
- case 'status':
44
- return await this.executeStatus(request);
45
- case 'config':
46
- return await this.executeConfig(request);
47
- case 'auth':
48
- return await this.executeAuth(request);
49
- default:
50
- throw new Error(`Task type '${request.type}' not supported by local provider`);
51
- }
52
- }
53
- catch (error) {
54
- return {
55
- success: false,
56
- exitCode: ExitCode.EXECUTION_ERROR,
57
- meta: {
58
- command: request.command,
59
- duration: Date.now() - startTime,
60
- timestamp: new Date().toISOString(),
61
- version: this.version,
62
- provider: this.name,
63
- },
64
- error: {
65
- code: 'LOCAL_EXECUTION_ERROR',
66
- message: error instanceof Error ? error.message : String(error),
67
- },
68
- };
69
- }
70
- }
71
- // Analyze task execution
72
- async executeAnalyze(request) {
73
- const { targetPath, options } = request.payload;
74
- // Discover files
75
- const files = await this.discoverFiles(targetPath, {
76
- include: ['**/*.{ts,tsx,js,jsx}'],
77
- exclude: this.config.excludePatterns,
78
- maxSize: options.maxSize,
79
- });
80
- // Analyze files
81
- const findings = [];
82
- let totalLines = 0;
83
- let totalFunctions = 0;
84
- let totalClasses = 0;
85
- for (const file of files) {
86
- const content = await fs.readFile(file, 'utf-8');
87
- const lines = content.split('\n');
88
- totalLines += lines.length;
89
- // Simple heuristics
90
- if (content.includes('function '))
91
- totalFunctions++;
92
- if (content.includes('class '))
93
- totalClasses++;
94
- // Find issues
95
- if (content.includes('eval(')) {
96
- findings.push({
97
- file: path.relative(targetPath, file),
98
- type: 'security',
99
- severity: 'high',
100
- message: 'Use of eval() detected',
101
- });
102
- }
103
- if (content.includes('console.log')) {
104
- findings.push({
105
- file: path.relative(targetPath, file),
106
- type: 'maintainability',
107
- severity: 'low',
108
- message: 'Console.log statement found',
109
- });
110
- }
111
- }
112
- // Generate report
113
- const report = {
114
- schema_version: '1.0',
115
- engine_version: this.version,
116
- created_at: new Date().toISOString(),
117
- project: {
118
- name: options.projectName || path.basename(targetPath),
119
- path: targetPath,
120
- },
121
- summary: {
122
- total: findings.length,
123
- high: findings.filter(f => f.severity === 'high').length,
124
- medium: findings.filter(f => f.severity === 'medium').length,
125
- low: findings.filter(f => f.severity === 'low').length,
126
- },
127
- metrics: {
128
- totalFiles: files.length,
129
- totalLines,
130
- totalFunctions,
131
- totalClasses,
132
- },
133
- findings,
134
- };
135
- // Save report
136
- const outputDir = path.resolve(options.output);
137
- await fs.mkdir(outputDir, { recursive: true });
138
- const reportFile = path.join(outputDir, `report-${Date.now()}.json`);
139
- await fs.writeFile(reportFile, JSON.stringify(report, null, 2));
140
- return {
141
- success: true,
142
- exitCode: ExitCode.SUCCESS,
143
- meta: {
144
- command: request.command,
145
- duration: 0,
146
- timestamp: new Date().toISOString(),
147
- version: this.version,
148
- provider: this.name,
149
- },
150
- data: {
151
- report,
152
- reportFile,
153
- filesAnalyzed: files.length,
154
- findings: findings.length,
155
- },
156
- };
157
- }
158
- // Init task execution
159
- async executeInit(request) {
160
- const { projectPath, template } = request.payload;
161
- await fs.mkdir(projectPath, { recursive: true });
162
- const config = {
163
- name: path.basename(projectPath),
164
- version: '1.0.0',
165
- template,
166
- type: 'default',
167
- created_at: new Date().toISOString(),
168
- };
169
- const configPath = path.join(projectPath, 'delta.config.json');
170
- await fs.writeFile(configPath, JSON.stringify(config, null, 2));
171
- return {
172
- success: true,
173
- exitCode: ExitCode.SUCCESS,
174
- meta: {
175
- command: request.command,
176
- duration: 0,
177
- timestamp: new Date().toISOString(),
178
- version: this.version,
179
- provider: this.name,
180
- },
181
- data: {
182
- projectPath,
183
- configPath,
184
- template,
185
- },
186
- };
187
- }
188
- // Status task execution
189
- async executeStatus(request) {
190
- const { projectPath } = request.payload;
191
- // Check config
192
- const configPath = path.join(projectPath, 'delta.config.json');
193
- let hasConfig = false;
194
- try {
195
- await fs.access(configPath);
196
- hasConfig = true;
197
- }
198
- catch {
199
- hasConfig = false;
200
- }
201
- // Check auth
202
- const auth = await loadConfig();
203
- const hasPat = await SecureTokenStore.hasTokens();
204
- return {
205
- success: true,
206
- exitCode: ExitCode.SUCCESS,
207
- meta: {
208
- command: request.command,
209
- duration: 0,
210
- timestamp: new Date().toISOString(),
211
- version: this.version,
212
- provider: this.name,
213
- },
214
- data: {
215
- project: {
216
- path: projectPath,
217
- hasConfig,
218
- configPath: hasConfig ? configPath : null,
219
- },
220
- auth: {
221
- authenticated: hasPat,
222
- apiUrl: auth.apiUrl || 'default',
223
- },
224
- },
225
- };
226
- }
227
- // Config task execution
228
- async executeConfig(request) {
229
- // Simple config management
230
- return {
231
- success: true,
232
- exitCode: ExitCode.SUCCESS,
233
- meta: {
234
- command: request.command,
235
- duration: 0,
236
- timestamp: new Date().toISOString(),
237
- version: this.version,
238
- provider: this.name,
239
- },
240
- data: {
241
- action: request.payload.action,
242
- config: {},
243
- },
244
- };
245
- }
246
- // Auth task execution
247
- async executeAuth(request) {
248
- const { action } = request.payload;
249
- return {
250
- success: true,
251
- exitCode: ExitCode.SUCCESS,
252
- meta: {
253
- command: request.command,
254
- duration: 0,
255
- timestamp: new Date().toISOString(),
256
- version: this.version,
257
- provider: this.name,
258
- },
259
- data: {
260
- action,
261
- authenticated: action === 'login',
262
- },
263
- };
264
- }
265
- // File discovery helper
266
- async discoverFiles(rootPath, options) {
267
- const files = [];
268
- async function walk(dir) {
269
- const entries = await fs.readdir(dir, { withFileTypes: true });
270
- for (const entry of entries) {
271
- const fullPath = path.join(dir, entry.name);
272
- if (entry.isDirectory()) {
273
- if (options.exclude.some(e => entry.name.includes(e)))
274
- continue;
275
- await walk(fullPath);
276
- }
277
- else if (entry.isFile()) {
278
- // Simple pattern matching
279
- const shouldInclude = options.include.some(pattern => {
280
- if (pattern.includes('**')) {
281
- const ext = pattern.replace('**/*', '');
282
- return entry.name.endsWith(ext);
283
- }
284
- return entry.name.includes(pattern.replace('*', ''));
285
- });
286
- if (shouldInclude) {
287
- try {
288
- const stats = await fs.stat(fullPath);
289
- if (stats.size <= options.maxSize) {
290
- files.push(fullPath);
291
- }
292
- }
293
- catch {
294
- // Skip files we can't stat
295
- }
296
- }
297
- }
298
- }
299
- }
300
- await walk(rootPath);
301
- return files;
302
- }
303
- }
304
- //# sourceMappingURL=local-provider.js.map
@@ -1,100 +0,0 @@
1
- /**
2
- * Remote Execution Provider
3
- * Connects to Delta API for cloud-based execution
4
- */
5
- import { ExitCode } from '../core/exit-codes.js';
6
- import { SecureTokenStore } from '../auth/secure-auth.js';
7
- export class RemoteProvider {
8
- name = 'remote';
9
- version = '2.0.0';
10
- capabilities = {
11
- commands: ['analyze', 'status', 'sync', 'deploy'],
12
- features: {
13
- json: true,
14
- streaming: true,
15
- caching: true,
16
- ai: false,
17
- },
18
- constraints: {
19
- maxFileSize: 50 * 1024 * 1024, // 50MB
20
- maxFiles: 10000,
21
- requiresAuth: true,
22
- },
23
- };
24
- config;
25
- constructor(config) {
26
- this.config = config;
27
- }
28
- async isAvailable() {
29
- try {
30
- const controller = new AbortController();
31
- const timeout = setTimeout(() => controller.abort(), 5000);
32
- const response = await fetch(`${this.config.apiUrl}/health`, {
33
- method: 'GET',
34
- signal: controller.signal,
35
- });
36
- clearTimeout(timeout);
37
- return response.ok;
38
- }
39
- catch {
40
- return false;
41
- }
42
- }
43
- async execute(request) {
44
- const startTime = Date.now();
45
- try {
46
- const pat = await SecureTokenStore.getAccessToken();
47
- if (!pat) {
48
- throw new Error('Authentication required for remote execution');
49
- }
50
- // Call remote API
51
- const response = await fetch(`${this.config.apiUrl}/api/cli/execute`, {
52
- method: 'POST',
53
- headers: {
54
- Authorization: `Bearer ${pat}`,
55
- 'Content-Type': 'application/json',
56
- },
57
- body: JSON.stringify({
58
- type: request.type,
59
- command: request.command,
60
- payload: request.payload,
61
- }),
62
- });
63
- if (!response.ok) {
64
- const error = await response.text();
65
- throw new Error(`Remote execution failed: ${error}`);
66
- }
67
- const data = (await response.json());
68
- return {
69
- success: true,
70
- exitCode: ExitCode.SUCCESS,
71
- meta: {
72
- command: request.command,
73
- duration: Date.now() - startTime,
74
- timestamp: new Date().toISOString(),
75
- version: this.version,
76
- provider: this.name,
77
- },
78
- data: data,
79
- };
80
- }
81
- catch (error) {
82
- return {
83
- success: false,
84
- exitCode: ExitCode.NETWORK_ERROR,
85
- meta: {
86
- command: request.command,
87
- duration: Date.now() - startTime,
88
- timestamp: new Date().toISOString(),
89
- version: this.version,
90
- provider: this.name,
91
- },
92
- error: {
93
- code: 'REMOTE_EXECUTION_ERROR',
94
- message: error instanceof Error ? error.message : String(error),
95
- },
96
- };
97
- }
98
- }
99
- }
100
- //# sourceMappingURL=remote-provider.js.map
@@ -1,114 +0,0 @@
1
- /**
2
- * CLI Telemetry Wrapper
3
- * @description Wraps CLI commands with telemetry and error handling
4
- * @package apps/cli
5
- */
6
- import { telemetry, generateCorrelationId, withTelemetry, logCommandMetrics, } from '@delta/infrastructure';
7
- import { recordCommand, metrics, isDeltaError, getClientErrorMessage } from '@delta/shared';
8
- /**
9
- * Wrap a CLI command with telemetry
10
- */
11
- export async function withCommandTelemetry(commandName, args, fn) {
12
- const correlationId = generateCorrelationId();
13
- const startTime = Date.now();
14
- const context = {
15
- correlationId,
16
- requestId: correlationId,
17
- path: `cli:${commandName}`,
18
- startTime,
19
- };
20
- return withTelemetry(context, async () => {
21
- telemetry.info(`Command started: ${commandName}`, {
22
- command: commandName,
23
- args: args.join(' '),
24
- });
25
- try {
26
- const result = await fn();
27
- const duration = Date.now() - startTime;
28
- // Log to telemetry
29
- logCommandMetrics({
30
- command: commandName,
31
- duration,
32
- success: true,
33
- });
34
- // Record to metrics store
35
- recordCommand(commandName, duration, true);
36
- telemetry.info(`Command completed: ${commandName}`, {
37
- command: commandName,
38
- duration,
39
- success: true,
40
- });
41
- return result;
42
- }
43
- catch (error) {
44
- const duration = Date.now() - startTime;
45
- const errorMessage = getClientErrorMessage(error);
46
- // Log to telemetry
47
- logCommandMetrics({
48
- command: commandName,
49
- duration,
50
- success: false,
51
- error: errorMessage,
52
- });
53
- // Record to metrics store
54
- recordCommand(commandName, duration, false, errorMessage);
55
- // Log error details
56
- if (isDeltaError(error)) {
57
- telemetry.error(`Command failed: ${commandName}`, error, {
58
- command: commandName,
59
- code: error.code,
60
- duration,
61
- });
62
- }
63
- else {
64
- telemetry.error(`Command failed: ${commandName}`, error instanceof Error ? error : undefined, {
65
- command: commandName,
66
- duration,
67
- });
68
- }
69
- throw error;
70
- }
71
- });
72
- }
73
- /**
74
- * Global CLI error handler
75
- */
76
- export function handleCliError(error) {
77
- if (isDeltaError(error)) {
78
- // Structured error - show clean message
79
- console.error(`Error [${error.code}]: ${error.message}`);
80
- // Show stack in debug mode
81
- if (process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development') {
82
- console.error('\nDebug info:');
83
- console.error(error.toJSON());
84
- }
85
- }
86
- else if (error instanceof Error) {
87
- // Regular error
88
- console.error(`Error: ${error.message}`);
89
- if (process.env.DEBUG === 'true') {
90
- console.error(error.stack);
91
- }
92
- }
93
- else {
94
- console.error('An unexpected error occurred');
95
- }
96
- }
97
- /**
98
- * Print CLI health metrics
99
- */
100
- export function printHealthMetrics() {
101
- const health = metrics.getHealth();
102
- const commandMetrics = metrics.getCommandMetrics(300000); // 5 min
103
- console.log('\nšŸ“Š CLI Health Metrics');
104
- console.log(`Status: ${health.status}`);
105
- console.log(`Command Success Rate: ${(health.commandSuccessRate * 100).toFixed(1)}%`);
106
- console.log(`Recent Commands: ${commandMetrics.total}`);
107
- if (Object.keys(commandMetrics.failuresByCommand).length > 0) {
108
- console.log('\nāŒ Failures by Command:');
109
- Object.entries(commandMetrics.failuresByCommand).forEach(([cmd, count]) => {
110
- console.log(` ${cmd}: ${count}`);
111
- });
112
- }
113
- }
114
- //# sourceMappingURL=wrapper.js.map
package/dist/types/api.js DELETED
@@ -1,3 +0,0 @@
1
- // API Response types for Delta CLI
2
- export {};
3
- //# sourceMappingURL=api.js.map