@vee-stack/delta-cli 2.0.4 → 2.0.5
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.
- package/dist/analyzer/commands/analyze.js +260 -0
- package/dist/analyzer/commands/config.js +83 -0
- package/dist/analyzer/commands/report.js +38 -0
- package/dist/analyzer/generators/report.generator.js +123 -0
- package/dist/analyzer/index.js +44 -0
- package/dist/analyzer/scanners/project.scanner.js +92 -0
- package/dist/analyzer/validators/contracts.validator.js +42 -0
- package/dist/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/analyzer/validators/observability.validator.js +39 -0
- package/dist/analyzer/validators/performance.validator.js +42 -0
- package/dist/analyzer/validators/security.validator.js +66 -0
- package/dist/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/analyzer/commands/analyze.js +256 -0
- package/dist/apps/cli/src/analyzer/commands/config.js +83 -0
- package/dist/apps/cli/src/analyzer/commands/report.js +38 -0
- package/dist/apps/cli/src/analyzer/generators/report.generator.js +123 -0
- package/dist/apps/cli/src/analyzer/index.js +44 -0
- package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +92 -0
- package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/apps/cli/src/analyzer/validators/observability.validator.js +39 -0
- package/dist/apps/cli/src/analyzer/validators/performance.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/security.validator.js +66 -0
- package/dist/apps/cli/src/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/auth/secure-auth.js +312 -0
- package/dist/apps/cli/src/commands/analyze.js +286 -0
- package/dist/apps/cli/src/commands/auth-new.js +37 -0
- package/dist/apps/cli/src/commands/auth.js +122 -0
- package/dist/apps/cli/src/commands/config.js +49 -0
- package/dist/apps/cli/src/commands/deploy.js +6 -0
- package/dist/apps/cli/src/commands/init.js +47 -0
- package/dist/apps/cli/src/commands/logout.js +23 -0
- package/dist/apps/cli/src/commands/plugins.js +21 -0
- package/dist/apps/cli/src/commands/status.js +80 -0
- package/dist/apps/cli/src/commands/sync.js +6 -0
- package/dist/apps/cli/src/commands/whoami.js +115 -0
- package/dist/apps/cli/src/components/Dashboard.js +168 -0
- package/dist/apps/cli/src/components/DeltaApp.js +56 -0
- package/dist/apps/cli/src/components/UnifiedManager.js +324 -0
- package/dist/apps/cli/src/core/audit.js +184 -0
- package/dist/apps/cli/src/core/completion.js +294 -0
- package/dist/apps/cli/src/core/contracts.js +6 -0
- package/dist/apps/cli/src/core/engine.js +124 -0
- package/dist/apps/cli/src/core/exit-codes.js +71 -0
- package/dist/apps/cli/src/core/hooks.js +181 -0
- package/dist/apps/cli/src/core/index.js +7 -0
- package/dist/apps/cli/src/core/policy.js +115 -0
- package/dist/apps/cli/src/core/profiles.js +161 -0
- package/dist/apps/cli/src/core/wizard.js +203 -0
- package/dist/apps/cli/src/index.js +636 -0
- package/dist/apps/cli/src/interactive/index.js +11 -0
- package/dist/apps/cli/src/plugins/GitStatusPlugin.js +99 -0
- package/dist/apps/cli/src/providers/ai-provider.js +74 -0
- package/dist/apps/cli/src/providers/local-provider.js +302 -0
- package/dist/apps/cli/src/providers/remote-provider.js +100 -0
- package/dist/apps/cli/src/types/api.js +3 -0
- package/dist/apps/cli/src/ui.js +219 -0
- package/dist/apps/cli/src/welcome.js +81 -0
- package/dist/auth/secure-auth.js +418 -0
- package/dist/bundle.js +45 -45
- package/dist/commands/analyze.js +363 -0
- package/dist/commands/auth-new.js +37 -0
- package/dist/commands/auth.js +133 -0
- package/dist/commands/config.js +50 -0
- package/dist/commands/deploy.js +6 -0
- package/dist/commands/init.js +47 -0
- package/dist/commands/logout.js +30 -0
- package/dist/commands/plugins.js +21 -0
- package/dist/commands/status.js +82 -0
- package/dist/commands/sync.js +6 -0
- package/dist/commands/whoami.js +71 -0
- package/dist/components/Dashboard.js +169 -0
- package/dist/components/DeltaApp.js +57 -0
- package/dist/components/UnifiedManager.js +344 -0
- package/dist/core/audit.js +184 -0
- package/dist/core/completion.js +294 -0
- package/dist/core/contracts.js +6 -0
- package/dist/core/engine.js +124 -0
- package/dist/core/exit-codes.js +71 -0
- package/dist/core/hooks.js +181 -0
- package/dist/core/index.js +7 -0
- package/dist/core/policy.js +115 -0
- package/dist/core/profiles.js +161 -0
- package/dist/core/wizard.js +203 -0
- package/dist/index.js +387 -0
- package/dist/interactive/index.js +11 -0
- package/dist/packages/domain/src/constitution/contracts/index.js +43 -0
- package/dist/packages/domain/src/constitution/contracts/ts.rules.js +268 -0
- package/dist/packages/domain/src/constitution/index.js +139 -0
- package/dist/packages/domain/src/constitution/maintainability/index.js +43 -0
- package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +344 -0
- package/dist/packages/domain/src/constitution/observability/index.js +43 -0
- package/dist/packages/domain/src/constitution/observability/ts.rules.js +307 -0
- package/dist/packages/domain/src/constitution/performance/index.js +43 -0
- package/dist/packages/domain/src/constitution/performance/ts.rules.js +325 -0
- package/dist/packages/domain/src/constitution/security/index.js +50 -0
- package/dist/packages/domain/src/constitution/security/ts.rules.js +267 -0
- package/dist/packages/domain/src/constitution/soc/index.js +43 -0
- package/dist/packages/domain/src/constitution/soc/ts.rules.js +360 -0
- package/dist/packages/domain/src/contracts/analysis.contract.js +18 -0
- package/dist/packages/domain/src/contracts/index.js +7 -0
- package/dist/packages/domain/src/contracts/projects.contract.js +18 -0
- package/dist/packages/domain/src/control/registry/rules.registry.js +29 -0
- package/dist/packages/domain/src/control/schemas/policies.js +6 -0
- package/dist/packages/domain/src/core/analysis/discovery.js +163 -0
- package/dist/packages/domain/src/core/analysis/engine.contract.js +298 -0
- package/dist/packages/domain/src/core/analysis/engine.js +77 -0
- package/dist/packages/domain/src/core/analysis/index.js +14 -0
- package/dist/packages/domain/src/core/analysis/orchestrator.js +242 -0
- package/dist/packages/domain/src/core/comparison/engine.js +29 -0
- package/dist/packages/domain/src/core/comparison/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/pipeline.js +41 -0
- package/dist/packages/domain/src/core/fs/adapter.js +111 -0
- package/dist/packages/domain/src/core/fs/index.js +5 -0
- package/dist/packages/domain/src/core/parser/unified-parser.js +166 -0
- package/dist/packages/domain/src/index.js +33 -0
- package/dist/packages/domain/src/plugin/registry.js +195 -0
- package/dist/packages/domain/src/plugin/types.js +6 -0
- package/dist/packages/domain/src/ports/analysis.engine.js +7 -0
- package/dist/packages/domain/src/ports/audit.logger.js +7 -0
- package/dist/packages/domain/src/ports/project.repository.js +7 -0
- package/dist/packages/domain/src/rules/index.js +134 -0
- package/dist/packages/domain/src/types/analysis.js +6 -0
- package/dist/packages/domain/src/types/errors.js +53 -0
- package/dist/packages/domain/src/types/fs.js +6 -0
- package/dist/packages/domain/src/types/index.js +7 -0
- package/dist/plugins/GitStatusPlugin.js +93 -0
- package/dist/providers/ai-provider.js +74 -0
- package/dist/providers/local-provider.js +304 -0
- package/dist/providers/remote-provider.js +100 -0
- package/dist/types/api.js +3 -0
- package/dist/ui.js +219 -0
- package/dist/welcome.js +81 -0
- package/package.json +18 -18
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitStatusPlugin - MVP Plugin Example
|
|
3
|
+
* Displays git repository status in the sidebar
|
|
4
|
+
* Demonstrates Plugin System capabilities
|
|
5
|
+
*/
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
export class GitStatusPlugin {
|
|
8
|
+
id = 'git-status';
|
|
9
|
+
name = 'Git Status';
|
|
10
|
+
version = '1.0.0';
|
|
11
|
+
description = 'Displays git repository status in the dashboard';
|
|
12
|
+
context;
|
|
13
|
+
branch = 'unknown';
|
|
14
|
+
status = 'clean';
|
|
15
|
+
aheadBehind = '';
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
}
|
|
19
|
+
onActivate() {
|
|
20
|
+
this.updateGitStatus();
|
|
21
|
+
// Auto-update every 10 seconds
|
|
22
|
+
setInterval(() => this.updateGitStatus(), 10000);
|
|
23
|
+
this.context.addLog('GitStatus', 'Git Status Plugin activated', 'info');
|
|
24
|
+
}
|
|
25
|
+
onDeactivate() {
|
|
26
|
+
this.context.addLog('GitStatus', 'Git Status Plugin deactivated', 'info');
|
|
27
|
+
}
|
|
28
|
+
registerCommands() {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
id: 'refresh',
|
|
32
|
+
label: 'Refresh Git Status',
|
|
33
|
+
shortcut: 'g',
|
|
34
|
+
icon: '🔄',
|
|
35
|
+
execute: () => {
|
|
36
|
+
this.updateGitStatus();
|
|
37
|
+
this.context.addLog('GitStatus', 'Git status refreshed manually', 'success');
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
registerDashboardWidgets() {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
id: 'git-info',
|
|
46
|
+
title: 'Git Status',
|
|
47
|
+
position: 'sidebar',
|
|
48
|
+
priority: 10,
|
|
49
|
+
render: () => this.renderWidget(),
|
|
50
|
+
updateInterval: 10000,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
updateGitStatus() {
|
|
55
|
+
try {
|
|
56
|
+
// Check if we're in a git repo
|
|
57
|
+
execSync('git rev-parse --git-dir', { stdio: 'pipe' });
|
|
58
|
+
// Get current branch
|
|
59
|
+
this.branch = execSync('git branch --show-current', { encoding: 'utf-8' }).trim();
|
|
60
|
+
// Check for uncommitted changes
|
|
61
|
+
const status = execSync('git status --porcelain', { encoding: 'utf-8' });
|
|
62
|
+
this.status = status.trim() ? 'dirty' : 'clean';
|
|
63
|
+
// Get ahead/behind info
|
|
64
|
+
try {
|
|
65
|
+
const aheadBehind = execSync('git rev-list --left-right --count HEAD...@{u} 2>/dev/null || echo "0\t0"', { encoding: 'utf-8' }).trim();
|
|
66
|
+
const [ahead, behind] = aheadBehind.split('\t');
|
|
67
|
+
if (ahead !== '0' || behind !== '0') {
|
|
68
|
+
this.aheadBehind = `${ahead}↑ ${behind}↓`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.aheadBehind = '';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
this.aheadBehind = '';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
this.branch = 'not a repo';
|
|
80
|
+
this.status = 'clean';
|
|
81
|
+
this.aheadBehind = '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
renderWidget() {
|
|
85
|
+
const { Text, Box } = require('ink');
|
|
86
|
+
const statusIcon = this.status === 'clean' ? '✓' : '⚡';
|
|
87
|
+
const statusColor = this.status === 'clean' ? 'green' : 'yellow';
|
|
88
|
+
return (Box({
|
|
89
|
+
flexDirection: 'column',
|
|
90
|
+
borderStyle: 'round',
|
|
91
|
+
borderColor: 'gray',
|
|
92
|
+
paddingX: 1,
|
|
93
|
+
width: 28,
|
|
94
|
+
marginBottom: 1,
|
|
95
|
+
}, Text({ bold: true, color: 'cyan' }, '🌿 Git Status'), Text({ color: 'white' }, `Branch: ${this.branch}`), Text({ color: statusColor }, `${statusIcon} ${this.status === 'clean' ? 'Clean' : 'Modified'}`), this.aheadBehind ? Text({ color: 'yellow' }, this.aheadBehind) : null));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export default GitStatusPlugin;
|
|
99
|
+
//# sourceMappingURL=GitStatusPlugin.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Provider (Placeholder)
|
|
3
|
+
* Reserved for future AI integration without breaking existing architecture
|
|
4
|
+
*/
|
|
5
|
+
import { ExitCode } from '../core/exit-codes.js';
|
|
6
|
+
export class AIProviderPlaceholder {
|
|
7
|
+
name = 'ai';
|
|
8
|
+
version = '2.0.0-placeholder';
|
|
9
|
+
capabilities = {
|
|
10
|
+
commands: ['analyze'],
|
|
11
|
+
features: {
|
|
12
|
+
json: true,
|
|
13
|
+
streaming: true,
|
|
14
|
+
caching: false,
|
|
15
|
+
ai: true,
|
|
16
|
+
},
|
|
17
|
+
constraints: {
|
|
18
|
+
maxFileSize: 100 * 1024 * 1024, // 100MB
|
|
19
|
+
requiresAuth: true,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
config;
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this.config = config;
|
|
25
|
+
}
|
|
26
|
+
async isAvailable() {
|
|
27
|
+
// AI provider is not available in current version
|
|
28
|
+
// This will return true when AI is implemented
|
|
29
|
+
return this.config.enabled && !!this.config.apiKey;
|
|
30
|
+
}
|
|
31
|
+
async execute(request) {
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
// Placeholder: Return error indicating AI is not implemented
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
exitCode: ExitCode.POLICY_BLOCKED,
|
|
37
|
+
meta: {
|
|
38
|
+
command: request.command,
|
|
39
|
+
duration: Date.now() - startTime,
|
|
40
|
+
timestamp: new Date().toISOString(),
|
|
41
|
+
version: this.version,
|
|
42
|
+
provider: this.name,
|
|
43
|
+
},
|
|
44
|
+
error: {
|
|
45
|
+
code: 'AI_NOT_IMPLEMENTED',
|
|
46
|
+
message: 'AI features are reserved for future releases. Use --provider=local for now.',
|
|
47
|
+
details: {
|
|
48
|
+
note: 'AI integration will be available in v2.1.0 without requiring any CLI changes',
|
|
49
|
+
alternative: 'Use --provider=local for local execution or --provider=remote for cloud execution',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// AI-specific methods (to be implemented)
|
|
55
|
+
async generate(input, _context) {
|
|
56
|
+
if (!this.config.enabled) {
|
|
57
|
+
throw new Error('AI provider is not enabled');
|
|
58
|
+
}
|
|
59
|
+
// Placeholder implementation
|
|
60
|
+
return `AI generation not implemented. Input received: ${input.substring(0, 50)}...`;
|
|
61
|
+
}
|
|
62
|
+
async analyzeCode(_code, _language) {
|
|
63
|
+
if (!this.config.enabled) {
|
|
64
|
+
throw new Error('AI provider is not enabled');
|
|
65
|
+
}
|
|
66
|
+
// Placeholder implementation
|
|
67
|
+
return {
|
|
68
|
+
insights: ['AI code analysis not yet implemented'],
|
|
69
|
+
suggestions: ['Use --provider=local for current analysis capabilities'],
|
|
70
|
+
score: 0,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ai-provider.js.map
|
|
@@ -0,0 +1,302 @@
|
|
|
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
|
+
export class LocalProvider {
|
|
10
|
+
name = 'local';
|
|
11
|
+
version = '2.0.0';
|
|
12
|
+
capabilities = {
|
|
13
|
+
commands: ['analyze', 'init', 'status', 'config', 'auth'],
|
|
14
|
+
features: {
|
|
15
|
+
json: true,
|
|
16
|
+
streaming: false,
|
|
17
|
+
caching: true,
|
|
18
|
+
ai: false,
|
|
19
|
+
},
|
|
20
|
+
constraints: {
|
|
21
|
+
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
22
|
+
maxFiles: 1000,
|
|
23
|
+
requiresAuth: false,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
config;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
async isAvailable() {
|
|
31
|
+
// Local provider is always available
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
async execute(request) {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
switch (request.type) {
|
|
38
|
+
case 'analyze':
|
|
39
|
+
return await this.executeAnalyze(request);
|
|
40
|
+
case 'init':
|
|
41
|
+
return await this.executeInit(request);
|
|
42
|
+
case 'status':
|
|
43
|
+
return await this.executeStatus(request);
|
|
44
|
+
case 'config':
|
|
45
|
+
return await this.executeConfig(request);
|
|
46
|
+
case 'auth':
|
|
47
|
+
return await this.executeAuth(request);
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Task type '${request.type}' not supported by local provider`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
exitCode: ExitCode.EXECUTION_ERROR,
|
|
56
|
+
meta: {
|
|
57
|
+
command: request.command,
|
|
58
|
+
duration: Date.now() - startTime,
|
|
59
|
+
timestamp: new Date().toISOString(),
|
|
60
|
+
version: this.version,
|
|
61
|
+
provider: this.name,
|
|
62
|
+
},
|
|
63
|
+
error: {
|
|
64
|
+
code: 'LOCAL_EXECUTION_ERROR',
|
|
65
|
+
message: error instanceof Error ? error.message : String(error),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Analyze task execution
|
|
71
|
+
async executeAnalyze(request) {
|
|
72
|
+
const { targetPath, options } = request.payload;
|
|
73
|
+
// Discover files
|
|
74
|
+
const files = await this.discoverFiles(targetPath, {
|
|
75
|
+
include: ['**/*.{ts,tsx,js,jsx}'],
|
|
76
|
+
exclude: this.config.excludePatterns,
|
|
77
|
+
maxSize: options.maxSize,
|
|
78
|
+
});
|
|
79
|
+
// Analyze files
|
|
80
|
+
const findings = [];
|
|
81
|
+
let totalLines = 0;
|
|
82
|
+
let totalFunctions = 0;
|
|
83
|
+
let totalClasses = 0;
|
|
84
|
+
for (const file of files) {
|
|
85
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
86
|
+
const lines = content.split('\n');
|
|
87
|
+
totalLines += lines.length;
|
|
88
|
+
// Simple heuristics
|
|
89
|
+
if (content.includes('function '))
|
|
90
|
+
totalFunctions++;
|
|
91
|
+
if (content.includes('class '))
|
|
92
|
+
totalClasses++;
|
|
93
|
+
// Find issues
|
|
94
|
+
if (content.includes('eval(')) {
|
|
95
|
+
findings.push({
|
|
96
|
+
file: path.relative(targetPath, file),
|
|
97
|
+
type: 'security',
|
|
98
|
+
severity: 'high',
|
|
99
|
+
message: 'Use of eval() detected',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (content.includes('console.log')) {
|
|
103
|
+
findings.push({
|
|
104
|
+
file: path.relative(targetPath, file),
|
|
105
|
+
type: 'maintainability',
|
|
106
|
+
severity: 'low',
|
|
107
|
+
message: 'Console.log statement found',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Generate report
|
|
112
|
+
const report = {
|
|
113
|
+
schema_version: '1.0',
|
|
114
|
+
engine_version: this.version,
|
|
115
|
+
created_at: new Date().toISOString(),
|
|
116
|
+
project: {
|
|
117
|
+
name: options.projectName || path.basename(targetPath),
|
|
118
|
+
path: targetPath,
|
|
119
|
+
},
|
|
120
|
+
summary: {
|
|
121
|
+
total: findings.length,
|
|
122
|
+
high: findings.filter(f => f.severity === 'high').length,
|
|
123
|
+
medium: findings.filter(f => f.severity === 'medium').length,
|
|
124
|
+
low: findings.filter(f => f.severity === 'low').length,
|
|
125
|
+
},
|
|
126
|
+
metrics: {
|
|
127
|
+
totalFiles: files.length,
|
|
128
|
+
totalLines,
|
|
129
|
+
totalFunctions,
|
|
130
|
+
totalClasses,
|
|
131
|
+
},
|
|
132
|
+
findings,
|
|
133
|
+
};
|
|
134
|
+
// Save report
|
|
135
|
+
const outputDir = path.resolve(options.output);
|
|
136
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
137
|
+
const reportFile = path.join(outputDir, `report-${Date.now()}.json`);
|
|
138
|
+
await fs.writeFile(reportFile, JSON.stringify(report, null, 2));
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
exitCode: ExitCode.SUCCESS,
|
|
142
|
+
meta: {
|
|
143
|
+
command: request.command,
|
|
144
|
+
duration: 0,
|
|
145
|
+
timestamp: new Date().toISOString(),
|
|
146
|
+
version: this.version,
|
|
147
|
+
provider: this.name,
|
|
148
|
+
},
|
|
149
|
+
data: {
|
|
150
|
+
report,
|
|
151
|
+
reportFile,
|
|
152
|
+
filesAnalyzed: files.length,
|
|
153
|
+
findings: findings.length,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// Init task execution
|
|
158
|
+
async executeInit(request) {
|
|
159
|
+
const { projectPath, template } = request.payload;
|
|
160
|
+
await fs.mkdir(projectPath, { recursive: true });
|
|
161
|
+
const config = {
|
|
162
|
+
name: path.basename(projectPath),
|
|
163
|
+
version: '1.0.0',
|
|
164
|
+
template,
|
|
165
|
+
type: 'default',
|
|
166
|
+
created_at: new Date().toISOString(),
|
|
167
|
+
};
|
|
168
|
+
const configPath = path.join(projectPath, 'delta.config.json');
|
|
169
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
170
|
+
return {
|
|
171
|
+
success: true,
|
|
172
|
+
exitCode: ExitCode.SUCCESS,
|
|
173
|
+
meta: {
|
|
174
|
+
command: request.command,
|
|
175
|
+
duration: 0,
|
|
176
|
+
timestamp: new Date().toISOString(),
|
|
177
|
+
version: this.version,
|
|
178
|
+
provider: this.name,
|
|
179
|
+
},
|
|
180
|
+
data: {
|
|
181
|
+
projectPath,
|
|
182
|
+
configPath,
|
|
183
|
+
template,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// Status task execution
|
|
188
|
+
async executeStatus(request) {
|
|
189
|
+
const { projectPath } = request.payload;
|
|
190
|
+
// Check config
|
|
191
|
+
const configPath = path.join(projectPath, 'delta.config.json');
|
|
192
|
+
let hasConfig = false;
|
|
193
|
+
try {
|
|
194
|
+
await fs.access(configPath);
|
|
195
|
+
hasConfig = true;
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
hasConfig = false;
|
|
199
|
+
}
|
|
200
|
+
// Check auth
|
|
201
|
+
const auth = await loadConfig();
|
|
202
|
+
return {
|
|
203
|
+
success: true,
|
|
204
|
+
exitCode: ExitCode.SUCCESS,
|
|
205
|
+
meta: {
|
|
206
|
+
command: request.command,
|
|
207
|
+
duration: 0,
|
|
208
|
+
timestamp: new Date().toISOString(),
|
|
209
|
+
version: this.version,
|
|
210
|
+
provider: this.name,
|
|
211
|
+
},
|
|
212
|
+
data: {
|
|
213
|
+
project: {
|
|
214
|
+
path: projectPath,
|
|
215
|
+
hasConfig,
|
|
216
|
+
configPath: hasConfig ? configPath : null,
|
|
217
|
+
},
|
|
218
|
+
auth: {
|
|
219
|
+
authenticated: !!auth.pat,
|
|
220
|
+
apiUrl: auth.apiUrl || 'default',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// Config task execution
|
|
226
|
+
async executeConfig(request) {
|
|
227
|
+
// Simple config management
|
|
228
|
+
return {
|
|
229
|
+
success: true,
|
|
230
|
+
exitCode: ExitCode.SUCCESS,
|
|
231
|
+
meta: {
|
|
232
|
+
command: request.command,
|
|
233
|
+
duration: 0,
|
|
234
|
+
timestamp: new Date().toISOString(),
|
|
235
|
+
version: this.version,
|
|
236
|
+
provider: this.name,
|
|
237
|
+
},
|
|
238
|
+
data: {
|
|
239
|
+
action: request.payload.action,
|
|
240
|
+
config: {},
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Auth task execution
|
|
245
|
+
async executeAuth(request) {
|
|
246
|
+
const { action } = request.payload;
|
|
247
|
+
return {
|
|
248
|
+
success: true,
|
|
249
|
+
exitCode: ExitCode.SUCCESS,
|
|
250
|
+
meta: {
|
|
251
|
+
command: request.command,
|
|
252
|
+
duration: 0,
|
|
253
|
+
timestamp: new Date().toISOString(),
|
|
254
|
+
version: this.version,
|
|
255
|
+
provider: this.name,
|
|
256
|
+
},
|
|
257
|
+
data: {
|
|
258
|
+
action,
|
|
259
|
+
authenticated: action === 'login',
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
// File discovery helper
|
|
264
|
+
async discoverFiles(rootPath, options) {
|
|
265
|
+
const files = [];
|
|
266
|
+
async function walk(dir) {
|
|
267
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
268
|
+
for (const entry of entries) {
|
|
269
|
+
const fullPath = path.join(dir, entry.name);
|
|
270
|
+
if (entry.isDirectory()) {
|
|
271
|
+
if (options.exclude.some(e => entry.name.includes(e)))
|
|
272
|
+
continue;
|
|
273
|
+
await walk(fullPath);
|
|
274
|
+
}
|
|
275
|
+
else if (entry.isFile()) {
|
|
276
|
+
// Simple pattern matching
|
|
277
|
+
const shouldInclude = options.include.some(pattern => {
|
|
278
|
+
if (pattern.includes('**')) {
|
|
279
|
+
const ext = pattern.replace('**/*', '');
|
|
280
|
+
return entry.name.endsWith(ext);
|
|
281
|
+
}
|
|
282
|
+
return entry.name.includes(pattern.replace('*', ''));
|
|
283
|
+
});
|
|
284
|
+
if (shouldInclude) {
|
|
285
|
+
try {
|
|
286
|
+
const stats = await fs.stat(fullPath);
|
|
287
|
+
if (stats.size <= options.maxSize) {
|
|
288
|
+
files.push(fullPath);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
// Skip files we can't stat
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
await walk(rootPath);
|
|
299
|
+
return files;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=local-provider.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { loadConfig } from '../commands/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 auth = await loadConfig();
|
|
47
|
+
if (!auth.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 ${auth.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
|