@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.
- package/dist/adapters/analysis.adapter.js +42 -0
- package/dist/analyzer/commands/analyze.js +74 -114
- package/dist/auth/device-auth.js +261 -0
- package/dist/auth/secure-auth.js +45 -16
- package/dist/commands/analyze.js +30 -27
- package/dist/commands/auth.js +13 -16
- package/dist/commands/status.js +2 -2
- package/dist/commands/whoami.js +6 -6
- package/dist/components/Dashboard.js +3 -5
- package/dist/components/DeltaApp.js +1 -1
- package/dist/components/UnifiedManager.js +48 -20
- package/dist/core/completion.js +14 -3
- package/dist/core/engine.js +10 -4
- package/dist/core/exit-codes.js +12 -4
- package/dist/core/wizard.js +1 -1
- package/dist/index.js +21 -5
- package/dist/providers/remote-provider.js +2 -2
- package/dist/telemetry/wrapper.js +114 -0
- package/dist/ui.js +9 -2
- package/dist/welcome.js +14 -4
- package/package.json +3 -1
- package/dist/apps/cli/src/analyzer/commands/analyze.js +0 -256
- package/dist/apps/cli/src/analyzer/commands/config.js +0 -83
- package/dist/apps/cli/src/analyzer/commands/report.js +0 -38
- package/dist/apps/cli/src/analyzer/generators/report.generator.js +0 -123
- package/dist/apps/cli/src/analyzer/index.js +0 -44
- package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +0 -92
- package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +0 -42
- package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +0 -40
- package/dist/apps/cli/src/analyzer/validators/observability.validator.js +0 -39
- package/dist/apps/cli/src/analyzer/validators/performance.validator.js +0 -42
- package/dist/apps/cli/src/analyzer/validators/security.validator.js +0 -66
- package/dist/apps/cli/src/analyzer/validators/soc.validator.js +0 -75
- package/dist/apps/cli/src/auth/secure-auth.js +0 -312
- package/dist/apps/cli/src/commands/analyze.js +0 -286
- package/dist/apps/cli/src/commands/auth-new.js +0 -37
- package/dist/apps/cli/src/commands/auth.js +0 -122
- package/dist/apps/cli/src/commands/config.js +0 -49
- package/dist/apps/cli/src/commands/deploy.js +0 -6
- package/dist/apps/cli/src/commands/init.js +0 -47
- package/dist/apps/cli/src/commands/logout.js +0 -23
- package/dist/apps/cli/src/commands/plugins.js +0 -21
- package/dist/apps/cli/src/commands/status.js +0 -80
- package/dist/apps/cli/src/commands/sync.js +0 -6
- package/dist/apps/cli/src/commands/whoami.js +0 -115
- package/dist/apps/cli/src/components/Dashboard.js +0 -168
- package/dist/apps/cli/src/components/DeltaApp.js +0 -56
- package/dist/apps/cli/src/components/UnifiedManager.js +0 -324
- package/dist/apps/cli/src/core/audit.js +0 -184
- package/dist/apps/cli/src/core/completion.js +0 -294
- package/dist/apps/cli/src/core/contracts.js +0 -6
- package/dist/apps/cli/src/core/engine.js +0 -124
- package/dist/apps/cli/src/core/exit-codes.js +0 -71
- package/dist/apps/cli/src/core/hooks.js +0 -181
- package/dist/apps/cli/src/core/index.js +0 -7
- package/dist/apps/cli/src/core/policy.js +0 -115
- package/dist/apps/cli/src/core/profiles.js +0 -161
- package/dist/apps/cli/src/core/wizard.js +0 -203
- package/dist/apps/cli/src/index.js +0 -636
- package/dist/apps/cli/src/interactive/index.js +0 -11
- package/dist/apps/cli/src/plugins/GitStatusPlugin.js +0 -99
- package/dist/apps/cli/src/providers/ai-provider.js +0 -74
- package/dist/apps/cli/src/providers/local-provider.js +0 -302
- package/dist/apps/cli/src/providers/remote-provider.js +0 -100
- package/dist/apps/cli/src/types/api.js +0 -3
- package/dist/apps/cli/src/ui.js +0 -219
- package/dist/apps/cli/src/welcome.js +0 -81
- package/dist/bundle.js +0 -504
- package/dist/packages/domain/src/constitution/contracts/index.js +0 -43
- package/dist/packages/domain/src/constitution/contracts/ts.rules.js +0 -268
- package/dist/packages/domain/src/constitution/index.js +0 -139
- package/dist/packages/domain/src/constitution/maintainability/index.js +0 -43
- package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +0 -344
- package/dist/packages/domain/src/constitution/observability/index.js +0 -43
- package/dist/packages/domain/src/constitution/observability/ts.rules.js +0 -307
- package/dist/packages/domain/src/constitution/performance/index.js +0 -43
- package/dist/packages/domain/src/constitution/performance/ts.rules.js +0 -325
- package/dist/packages/domain/src/constitution/security/index.js +0 -50
- package/dist/packages/domain/src/constitution/security/ts.rules.js +0 -267
- package/dist/packages/domain/src/constitution/soc/index.js +0 -43
- package/dist/packages/domain/src/constitution/soc/ts.rules.js +0 -360
- package/dist/packages/domain/src/contracts/analysis.contract.js +0 -18
- package/dist/packages/domain/src/contracts/index.js +0 -7
- package/dist/packages/domain/src/contracts/projects.contract.js +0 -18
- package/dist/packages/domain/src/control/registry/rules.registry.js +0 -29
- package/dist/packages/domain/src/control/schemas/policies.js +0 -6
- package/dist/packages/domain/src/core/analysis/discovery.js +0 -163
- package/dist/packages/domain/src/core/analysis/engine.contract.js +0 -298
- package/dist/packages/domain/src/core/analysis/engine.js +0 -77
- package/dist/packages/domain/src/core/analysis/index.js +0 -14
- package/dist/packages/domain/src/core/analysis/orchestrator.js +0 -242
- package/dist/packages/domain/src/core/comparison/engine.js +0 -29
- package/dist/packages/domain/src/core/comparison/index.js +0 -5
- package/dist/packages/domain/src/core/documentation/index.js +0 -5
- package/dist/packages/domain/src/core/documentation/pipeline.js +0 -41
- package/dist/packages/domain/src/core/fs/adapter.js +0 -111
- package/dist/packages/domain/src/core/fs/index.js +0 -5
- package/dist/packages/domain/src/core/parser/unified-parser.js +0 -166
- package/dist/packages/domain/src/index.js +0 -33
- package/dist/packages/domain/src/plugin/registry.js +0 -195
- package/dist/packages/domain/src/plugin/types.js +0 -6
- package/dist/packages/domain/src/ports/analysis.engine.js +0 -7
- package/dist/packages/domain/src/ports/audit.logger.js +0 -7
- package/dist/packages/domain/src/ports/project.repository.js +0 -7
- package/dist/packages/domain/src/rules/index.js +0 -134
- package/dist/packages/domain/src/types/analysis.js +0 -6
- package/dist/packages/domain/src/types/errors.js +0 -53
- package/dist/packages/domain/src/types/fs.js +0 -6
- package/dist/packages/domain/src/types/index.js +0 -7
package/dist/core/engine.js
CHANGED
|
@@ -31,7 +31,10 @@ export class DeltaEngine {
|
|
|
31
31
|
const validation = this.policy.validate(request);
|
|
32
32
|
if (!validation.valid) {
|
|
33
33
|
const exitCode = validation.exitCode || ExitCode.VALIDATION_ERROR;
|
|
34
|
-
throw Object.assign(new Error(validation.reason || 'Task validation failed'), {
|
|
34
|
+
throw Object.assign(new Error(validation.reason || 'Task validation failed'), {
|
|
35
|
+
code: exitCode === ExitCode.POLICY_BLOCKED ? 'POLICY_BLOCKED' : 'VALIDATION_ERROR',
|
|
36
|
+
exitCode,
|
|
37
|
+
});
|
|
35
38
|
}
|
|
36
39
|
// Transform request if needed (includes non-TTY detection)
|
|
37
40
|
const transformedRequest = this.policy.transform?.(request) || request;
|
|
@@ -43,7 +46,10 @@ export class DeltaEngine {
|
|
|
43
46
|
// Check provider availability
|
|
44
47
|
const available = await provider.isAvailable();
|
|
45
48
|
if (!available) {
|
|
46
|
-
throw Object.assign(new Error(`Provider '${provider.name}' is not available`), {
|
|
49
|
+
throw Object.assign(new Error(`Provider '${provider.name}' is not available`), {
|
|
50
|
+
code: 'PROVIDER_UNAVAILABLE',
|
|
51
|
+
exitCode: ExitCode.NETWORK_ERROR,
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
54
|
// Execute task
|
|
49
55
|
this.emit({ type: 'task:progress', request: transformedRequest, progress: 0.5 });
|
|
@@ -65,7 +71,7 @@ export class DeltaEngine {
|
|
|
65
71
|
this.emit({
|
|
66
72
|
type: 'task:complete',
|
|
67
73
|
request: transformedRequest,
|
|
68
|
-
response: enrichedResponse
|
|
74
|
+
response: enrichedResponse,
|
|
69
75
|
});
|
|
70
76
|
return enrichedResponse;
|
|
71
77
|
}
|
|
@@ -74,7 +80,7 @@ export class DeltaEngine {
|
|
|
74
80
|
this.emit({
|
|
75
81
|
type: 'task:error',
|
|
76
82
|
request,
|
|
77
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
83
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
78
84
|
});
|
|
79
85
|
return {
|
|
80
86
|
success: false,
|
package/dist/core/exit-codes.js
CHANGED
|
@@ -44,16 +44,24 @@ export function getExitCode(error) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
// Check error messages
|
|
47
|
-
if (errorStr.includes('validation') ||
|
|
47
|
+
if (errorStr.includes('validation') ||
|
|
48
|
+
errorStr.includes('invalid') ||
|
|
49
|
+
errorStr.includes('required')) {
|
|
48
50
|
return ExitCode.VALIDATION_ERROR;
|
|
49
51
|
}
|
|
50
|
-
if (errorStr.includes('auth') ||
|
|
52
|
+
if (errorStr.includes('auth') ||
|
|
53
|
+
errorStr.includes('token') ||
|
|
54
|
+
errorStr.includes('unauthorized')) {
|
|
51
55
|
return ExitCode.AUTH_ERROR;
|
|
52
56
|
}
|
|
53
|
-
if (errorStr.includes('network') ||
|
|
57
|
+
if (errorStr.includes('network') ||
|
|
58
|
+
errorStr.includes('connection') ||
|
|
59
|
+
errorStr.includes('timeout')) {
|
|
54
60
|
return ExitCode.NETWORK_ERROR;
|
|
55
61
|
}
|
|
56
|
-
if (errorStr.includes('policy') ||
|
|
62
|
+
if (errorStr.includes('policy') ||
|
|
63
|
+
errorStr.includes('quota') ||
|
|
64
|
+
errorStr.includes('permission')) {
|
|
57
65
|
return ExitCode.POLICY_BLOCKED;
|
|
58
66
|
}
|
|
59
67
|
return ExitCode.EXECUTION_ERROR;
|
package/dist/core/wizard.js
CHANGED
|
@@ -11,7 +11,7 @@ const initWizardSteps = [
|
|
|
11
11
|
message: 'What is your project name?',
|
|
12
12
|
type: 'text',
|
|
13
13
|
initial: 'my-delta-project',
|
|
14
|
-
validate:
|
|
14
|
+
validate: value => value.length > 0 || 'Project name is required',
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
name: 'template',
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'))
|
|
|
24
24
|
// Check for updates
|
|
25
25
|
const notifier = updateNotifier({
|
|
26
26
|
pkg,
|
|
27
|
-
updateCheckInterval: 1000 * 60 * 60 // 1 hour
|
|
27
|
+
updateCheckInterval: 1000 * 60 * 60, // 1 hour
|
|
28
28
|
});
|
|
29
29
|
// Define gradient themes
|
|
30
30
|
export const gradients = {
|
|
@@ -58,9 +58,13 @@ export function printWelcome() {
|
|
|
58
58
|
printLogo();
|
|
59
59
|
console.log(chalk.dim(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
60
60
|
console.log();
|
|
61
|
-
console.log(chalk.white.bold(' š Delta CLI v2.0') +
|
|
61
|
+
console.log(chalk.white.bold(' š Delta CLI v2.0') +
|
|
62
|
+
chalk.gray(' ā Next-gen code analysis & documentation'));
|
|
62
63
|
console.log();
|
|
63
|
-
console.log(chalk.gray(' Local-first architecture with ') +
|
|
64
|
+
console.log(chalk.gray(' Local-first architecture with ') +
|
|
65
|
+
chalk.cyan('cloud power') +
|
|
66
|
+
chalk.gray(' & ') +
|
|
67
|
+
chalk.magenta('AI intelligence'));
|
|
64
68
|
console.log();
|
|
65
69
|
console.log(chalk.dim(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
66
70
|
console.log();
|
|
@@ -86,8 +90,20 @@ export function printTips() {
|
|
|
86
90
|
console.log(chalk.gray(' ⢠') + chalk.cyan(cmd) + chalk.gray(` ā ${desc}`));
|
|
87
91
|
});
|
|
88
92
|
console.log();
|
|
89
|
-
console.log(chalk.dim(' Try ') +
|
|
90
|
-
|
|
93
|
+
console.log(chalk.dim(' Try ') +
|
|
94
|
+
chalk.cyan('/help') +
|
|
95
|
+
chalk.dim(', ') +
|
|
96
|
+
chalk.cyan('/analyze') +
|
|
97
|
+
chalk.dim(', ') +
|
|
98
|
+
chalk.cyan('/status') +
|
|
99
|
+
chalk.dim(' for quick access'));
|
|
100
|
+
console.log(chalk.dim(' Press ') +
|
|
101
|
+
chalk.bold('Ctrl+T') +
|
|
102
|
+
chalk.dim(' for variants ⢠') +
|
|
103
|
+
chalk.bold('Tab') +
|
|
104
|
+
chalk.dim(' for agents ⢠') +
|
|
105
|
+
chalk.bold('Ctrl+P') +
|
|
106
|
+
chalk.dim(' for commands'));
|
|
91
107
|
console.log();
|
|
92
108
|
}
|
|
93
109
|
// Initialize Core Engine
|
|
@@ -51,7 +51,7 @@ export class RemoteProvider {
|
|
|
51
51
|
const response = await fetch(`${this.config.apiUrl}/api/cli/execute`, {
|
|
52
52
|
method: 'POST',
|
|
53
53
|
headers: {
|
|
54
|
-
|
|
54
|
+
Authorization: `Bearer ${pat}`,
|
|
55
55
|
'Content-Type': 'application/json',
|
|
56
56
|
},
|
|
57
57
|
body: JSON.stringify({
|
|
@@ -64,7 +64,7 @@ export class RemoteProvider {
|
|
|
64
64
|
const error = await response.text();
|
|
65
65
|
throw new Error(`Remote execution failed: ${error}`);
|
|
66
66
|
}
|
|
67
|
-
const data = await response.json();
|
|
67
|
+
const data = (await response.json());
|
|
68
68
|
return {
|
|
69
69
|
success: true,
|
|
70
70
|
exitCode: ExitCode.SUCCESS,
|
|
@@ -0,0 +1,114 @@
|
|
|
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/ui.js
CHANGED
|
@@ -210,9 +210,16 @@ export function printDivider() {
|
|
|
210
210
|
export function printWelcome() {
|
|
211
211
|
console.log();
|
|
212
212
|
console.log(chalk.cyan(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā®'));
|
|
213
|
-
console.log(chalk.cyan(' ā') +
|
|
213
|
+
console.log(chalk.cyan(' ā') +
|
|
214
|
+
' ' +
|
|
215
|
+
chalk.bold(chalk.magenta('š Delta CLI')) +
|
|
216
|
+
chalk.dim(' - Code Analysis & Documentation ') +
|
|
217
|
+
chalk.cyan('ā'));
|
|
214
218
|
console.log(chalk.cyan(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤'));
|
|
215
|
-
console.log(chalk.cyan(' ā') +
|
|
219
|
+
console.log(chalk.cyan(' ā') +
|
|
220
|
+
' ' +
|
|
221
|
+
chalk.gray('Local-first analysis with cloud power ') +
|
|
222
|
+
chalk.cyan('ā'));
|
|
216
223
|
console.log(chalk.cyan(' ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāÆ'));
|
|
217
224
|
console.log();
|
|
218
225
|
}
|
package/dist/welcome.js
CHANGED
|
@@ -13,7 +13,7 @@ const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'))
|
|
|
13
13
|
// Check for updates
|
|
14
14
|
const notifier = updateNotifier({
|
|
15
15
|
pkg,
|
|
16
|
-
updateCheckInterval: 1000 * 60 * 60 // 1 hour
|
|
16
|
+
updateCheckInterval: 1000 * 60 * 60, // 1 hour
|
|
17
17
|
});
|
|
18
18
|
// Define gradient themes
|
|
19
19
|
export const gradients = {
|
|
@@ -47,9 +47,13 @@ export function printWelcome() {
|
|
|
47
47
|
printLogo();
|
|
48
48
|
console.log(chalk.dim(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
49
49
|
console.log();
|
|
50
|
-
console.log(chalk.white.bold(' š Delta CLI v2.0') +
|
|
50
|
+
console.log(chalk.white.bold(' š Delta CLI v2.0') +
|
|
51
|
+
chalk.gray(' ā Next-gen code analysis & documentation'));
|
|
51
52
|
console.log();
|
|
52
|
-
console.log(chalk.gray(' Local-first architecture with ') +
|
|
53
|
+
console.log(chalk.gray(' Local-first architecture with ') +
|
|
54
|
+
chalk.cyan('cloud power') +
|
|
55
|
+
chalk.gray(' & ') +
|
|
56
|
+
chalk.magenta('AI intelligence'));
|
|
53
57
|
console.log();
|
|
54
58
|
console.log(chalk.dim(' āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
55
59
|
console.log();
|
|
@@ -75,7 +79,13 @@ export function printTips() {
|
|
|
75
79
|
console.log(chalk.gray(' ⢠') + chalk.cyan(cmd) + chalk.gray(` ā ${desc}`));
|
|
76
80
|
});
|
|
77
81
|
console.log();
|
|
78
|
-
console.log(chalk.dim(' Press ') +
|
|
82
|
+
console.log(chalk.dim(' Press ') +
|
|
83
|
+
chalk.bold('Ctrl+T') +
|
|
84
|
+
chalk.dim(' for variants ⢠') +
|
|
85
|
+
chalk.bold('Tab') +
|
|
86
|
+
chalk.dim(' for agents ⢠') +
|
|
87
|
+
chalk.bold('Ctrl+P') +
|
|
88
|
+
chalk.dim(' for commands'));
|
|
79
89
|
console.log();
|
|
80
90
|
}
|
|
81
91
|
//# sourceMappingURL=welcome.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vee-stack/delta-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "Delta CLI v2 - Next-gen terminal interface with React Ink",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
"outputPath": "./bin"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@delta/domain": "workspace:*",
|
|
54
|
+
"@delta/application": "workspace:*",
|
|
53
55
|
"ink": "^5.0.0",
|
|
54
56
|
"ink-gradient": "^3.0.0",
|
|
55
57
|
"ink-big-text": "^2.0.0",
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analyze Command
|
|
3
|
-
* @description Main analysis command implementation
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from 'fs/promises';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
import { ProjectScanner } from '../scanners/project.scanner';
|
|
8
|
-
import { SecurityValidator } from '../validators/security.validator';
|
|
9
|
-
import { PerformanceValidator } from '../validators/performance.validator';
|
|
10
|
-
import { SocValidator } from '../validators/soc.validator';
|
|
11
|
-
import { ContractsValidator } from '../validators/contracts.validator';
|
|
12
|
-
import { MaintainabilityValidator } from '../validators/maintainability.validator';
|
|
13
|
-
import { ObservabilityValidator } from '../validators/observability.validator';
|
|
14
|
-
import { ReportGenerator } from '../generators/report.generator';
|
|
15
|
-
export async function analyzeCommand(projectPath, options) {
|
|
16
|
-
console.log(`š Analyzing project: ${projectPath}`);
|
|
17
|
-
console.log(` Language: ${options.language}`);
|
|
18
|
-
console.log(` Depth: ${options.depth}`);
|
|
19
|
-
console.log('');
|
|
20
|
-
try {
|
|
21
|
-
// 1. Validate project path
|
|
22
|
-
const absolutePath = path.resolve(projectPath);
|
|
23
|
-
await fs.access(absolutePath);
|
|
24
|
-
// 2. Scan project structure
|
|
25
|
-
console.log('š Scanning project structure...');
|
|
26
|
-
const projectInfo = await ProjectScanner.scan(absolutePath, options.language);
|
|
27
|
-
// 3. Run validators
|
|
28
|
-
console.log('š Validating Security...');
|
|
29
|
-
const securityResult = await SecurityValidator.validate(projectInfo, options);
|
|
30
|
-
console.log('ā” Validating Performance...');
|
|
31
|
-
const performanceResult = await PerformanceValidator.validate(projectInfo, options);
|
|
32
|
-
console.log('šļø Validating Separation of Concerns...');
|
|
33
|
-
const socResult = await SocValidator.validate(projectInfo, options);
|
|
34
|
-
console.log('š Validating Contracts...');
|
|
35
|
-
const contractsResult = await ContractsValidator.validate(projectInfo, options);
|
|
36
|
-
console.log('š§ Validating Maintainability...');
|
|
37
|
-
const maintainabilityResult = await MaintainabilityValidator.validate(projectInfo, options);
|
|
38
|
-
console.log('šļø Validating Observability...');
|
|
39
|
-
const observabilityResult = await ObservabilityValidator.validate(projectInfo, options);
|
|
40
|
-
// 4. Calculate overall score
|
|
41
|
-
const scores = {
|
|
42
|
-
security: {
|
|
43
|
-
...securityResult,
|
|
44
|
-
weight: 25,
|
|
45
|
-
weightedScore: (securityResult.score / securityResult.maxScore) * 25,
|
|
46
|
-
},
|
|
47
|
-
performance: {
|
|
48
|
-
...performanceResult,
|
|
49
|
-
weight: 20,
|
|
50
|
-
weightedScore: (performanceResult.score / performanceResult.maxScore) * 20,
|
|
51
|
-
},
|
|
52
|
-
soc: { ...socResult, weight: 20, weightedScore: (socResult.score / socResult.maxScore) * 20 },
|
|
53
|
-
contracts: {
|
|
54
|
-
...contractsResult,
|
|
55
|
-
weight: 15,
|
|
56
|
-
weightedScore: (contractsResult.score / contractsResult.maxScore) * 15,
|
|
57
|
-
},
|
|
58
|
-
maintainability: {
|
|
59
|
-
...maintainabilityResult,
|
|
60
|
-
weight: 10,
|
|
61
|
-
weightedScore: (maintainabilityResult.score / maintainabilityResult.maxScore) * 10,
|
|
62
|
-
},
|
|
63
|
-
observability: {
|
|
64
|
-
...observabilityResult,
|
|
65
|
-
weight: 10,
|
|
66
|
-
weightedScore: (observabilityResult.score / observabilityResult.maxScore) * 10,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
const overallScore = Object.values(scores).reduce((sum, s) => sum + s.weightedScore, 0);
|
|
70
|
-
const percentage = Math.round(overallScore);
|
|
71
|
-
const grade = percentage >= 90
|
|
72
|
-
? 'A'
|
|
73
|
-
: percentage >= 80
|
|
74
|
-
? 'B'
|
|
75
|
-
: percentage >= 70
|
|
76
|
-
? 'C'
|
|
77
|
-
: percentage >= 60
|
|
78
|
-
? 'D'
|
|
79
|
-
: 'F';
|
|
80
|
-
// 5. Collect violations
|
|
81
|
-
const violations = [
|
|
82
|
-
...securityResult.violations.map(v => ({ ...v, axis: 'Security' })),
|
|
83
|
-
...performanceResult.violations.map(v => ({ ...v, axis: 'Performance' })),
|
|
84
|
-
...socResult.violations.map(v => ({ ...v, axis: 'SoC' })),
|
|
85
|
-
...contractsResult.violations.map(v => ({ ...v, axis: 'Contracts' })),
|
|
86
|
-
...maintainabilityResult.violations.map(v => ({ ...v, axis: 'Maintainability' })),
|
|
87
|
-
...observabilityResult.violations.map(v => ({ ...v, axis: 'Observability' })),
|
|
88
|
-
];
|
|
89
|
-
// 6. Generate recommendations
|
|
90
|
-
const recommendations = generateRecommendations(violations, scores);
|
|
91
|
-
// 7. Build result
|
|
92
|
-
const result = {
|
|
93
|
-
project: {
|
|
94
|
-
path: absolutePath,
|
|
95
|
-
name: path.basename(absolutePath),
|
|
96
|
-
language: options.language,
|
|
97
|
-
size: projectInfo.size,
|
|
98
|
-
fileCount: projectInfo.fileCount,
|
|
99
|
-
},
|
|
100
|
-
timestamp: new Date().toISOString(),
|
|
101
|
-
constitution: {
|
|
102
|
-
version: '0.5.0',
|
|
103
|
-
axes: ['security', 'performance', 'maintainability'],
|
|
104
|
-
},
|
|
105
|
-
scores,
|
|
106
|
-
overall: {
|
|
107
|
-
score: overallScore,
|
|
108
|
-
percentage,
|
|
109
|
-
grade,
|
|
110
|
-
compliant: violations.filter(v => v.severity === 'critical' || v.severity === 'error').length === 0,
|
|
111
|
-
},
|
|
112
|
-
violations,
|
|
113
|
-
recommendations,
|
|
114
|
-
};
|
|
115
|
-
// 8. Output results
|
|
116
|
-
await outputResults(result, options);
|
|
117
|
-
// 9. Exit with appropriate code
|
|
118
|
-
if (options.strict &&
|
|
119
|
-
violations.some(v => v.severity === 'critical' || v.severity === 'error')) {
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
console.error('ā Analysis failed:', error instanceof Error ? error.message : String(error));
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function outputResults(result, options) {
|
|
129
|
-
switch (options.output) {
|
|
130
|
-
case 'json':
|
|
131
|
-
console.log(JSON.stringify(result, null, 2));
|
|
132
|
-
break;
|
|
133
|
-
case 'html':
|
|
134
|
-
const html = ReportGenerator.generateHTML(result);
|
|
135
|
-
const htmlPath = `${result.project.name}-analysis.html`;
|
|
136
|
-
await fs.writeFile(htmlPath, html);
|
|
137
|
-
console.log(`š HTML report saved to: ${htmlPath}`);
|
|
138
|
-
break;
|
|
139
|
-
case 'markdown':
|
|
140
|
-
const markdown = ReportGenerator.generateMarkdown(result);
|
|
141
|
-
const mdPath = `${result.project.name}-analysis.md`;
|
|
142
|
-
await fs.writeFile(mdPath, markdown);
|
|
143
|
-
console.log(`š Markdown report saved to: ${mdPath}`);
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
// Console output
|
|
147
|
-
printConsoleReport(result);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function printConsoleReport(result) {
|
|
151
|
-
console.log('\n' + '='.repeat(60));
|
|
152
|
-
console.log('š DELTA CONSTITUTION ANALYSIS REPORT');
|
|
153
|
-
console.log('='.repeat(60));
|
|
154
|
-
console.log(`\nProject: ${result.project.name}`);
|
|
155
|
-
console.log(`Path: ${result.project.path}`);
|
|
156
|
-
console.log(`Language: ${result.project.language}`);
|
|
157
|
-
console.log(`Files: ${result.project.fileCount}`);
|
|
158
|
-
console.log(`Constitution: v${result.constitution.version}`);
|
|
159
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
160
|
-
console.log(`\nšÆ OVERALL SCORE: ${result.overall.percentage}% (Grade: ${result.overall.grade})`);
|
|
161
|
-
console.log(`Status: ${result.overall.compliant ? 'ā
Compliant' : 'ā Non-Compliant'}`);
|
|
162
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
163
|
-
console.log('AXIS SCORES:');
|
|
164
|
-
console.log(`${'-'.repeat(60)}`);
|
|
165
|
-
Object.entries(result.scores).forEach(([axis, score]) => {
|
|
166
|
-
const bar = 'ā'.repeat(Math.round(score.percentage / 5)) +
|
|
167
|
-
'ā'.repeat(20 - Math.round(score.percentage / 5));
|
|
168
|
-
console.log(`${axis.padEnd(20)} ${bar} ${score.percentage.toString().padStart(3)}%`);
|
|
169
|
-
});
|
|
170
|
-
if (result.violations.length > 0) {
|
|
171
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
172
|
-
console.log('VIOLATIONS:');
|
|
173
|
-
console.log(`${'-'.repeat(60)}`);
|
|
174
|
-
const critical = result.violations.filter(v => v.severity === 'critical');
|
|
175
|
-
const errors = result.violations.filter(v => v.severity === 'error');
|
|
176
|
-
const warnings = result.violations.filter(v => v.severity === 'warning');
|
|
177
|
-
if (critical.length > 0) {
|
|
178
|
-
console.log('\nš“ Critical:');
|
|
179
|
-
critical.forEach(v => console.log(` - [${v.id}] ${v.message}`));
|
|
180
|
-
}
|
|
181
|
-
if (errors.length > 0) {
|
|
182
|
-
console.log('\nš Errors:');
|
|
183
|
-
errors.forEach(v => console.log(` - [${v.id}] ${v.message}`));
|
|
184
|
-
}
|
|
185
|
-
if (warnings.length > 0) {
|
|
186
|
-
console.log('\nš” Warnings:');
|
|
187
|
-
warnings.slice(0, 5).forEach(v => console.log(` - [${v.id}] ${v.message}`));
|
|
188
|
-
if (warnings.length > 5) {
|
|
189
|
-
console.log(` ... and ${warnings.length - 5} more warnings`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (result.recommendations.length > 0) {
|
|
194
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
195
|
-
console.log('TOP RECOMMENDATIONS:');
|
|
196
|
-
console.log(`${'-'.repeat(60)}`);
|
|
197
|
-
result.recommendations
|
|
198
|
-
.filter(r => r.priority === 'high')
|
|
199
|
-
.slice(0, 5)
|
|
200
|
-
.forEach(r => {
|
|
201
|
-
console.log(`\n[${r.axis}] ${r.description}`);
|
|
202
|
-
console.log(` Action: ${r.action}`);
|
|
203
|
-
console.log(` Effort: ${r.effort}`);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
console.log('\n' + '='.repeat(60) + '\n');
|
|
207
|
-
}
|
|
208
|
-
function generateRecommendations(violations, scores) {
|
|
209
|
-
const recommendations = [];
|
|
210
|
-
// Security recommendations
|
|
211
|
-
if (scores.security.percentage < 80) {
|
|
212
|
-
recommendations.push({
|
|
213
|
-
axis: 'Security',
|
|
214
|
-
priority: 'high',
|
|
215
|
-
description: 'Security score below 80%',
|
|
216
|
-
action: 'Implement Policy Guards, Audit Logging, and Fail-Closed patterns',
|
|
217
|
-
effort: '2-3 days',
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
// Performance recommendations
|
|
221
|
-
if (scores.performance.percentage < 70) {
|
|
222
|
-
recommendations.push({
|
|
223
|
-
axis: 'Performance',
|
|
224
|
-
priority: 'medium',
|
|
225
|
-
description: 'Performance optimizations needed',
|
|
226
|
-
action: 'Add lazy loading, code splitting, and caching layers',
|
|
227
|
-
effort: '1-2 days',
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
// SoC recommendations
|
|
231
|
-
if (scores.soc.percentage < 80) {
|
|
232
|
-
recommendations.push({
|
|
233
|
-
axis: 'SoC',
|
|
234
|
-
priority: 'high',
|
|
235
|
-
description: 'Layer boundaries need improvement',
|
|
236
|
-
action: 'Refactor to follow 7-layer architecture, fix import violations',
|
|
237
|
-
effort: '3-5 days',
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
// Add specific recommendations based on violations
|
|
241
|
-
const failClosedViolations = violations.filter(v => v.message.includes('Fail-Open'));
|
|
242
|
-
if (failClosedViolations.length > 0) {
|
|
243
|
-
recommendations.push({
|
|
244
|
-
axis: 'Security',
|
|
245
|
-
priority: 'high',
|
|
246
|
-
description: `Found ${failClosedViolations.length} Fail-Open patterns`,
|
|
247
|
-
action: 'Replace with Fail-Closed: if (!isAllowed) return deny()',
|
|
248
|
-
effort: '1 day',
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return recommendations.sort((a, b) => {
|
|
252
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
253
|
-
return priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=analyze.js.map
|