@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.
- package/dist/adapters/analysis.adapter.d.ts +29 -0
- package/dist/analyzer/commands/analyze.d.ts +14 -0
- package/dist/analyzer/commands/config.d.ts +12 -0
- package/dist/analyzer/commands/report.d.ts +11 -0
- package/dist/analyzer/generators/report.generator.d.ts +43 -0
- package/dist/analyzer/index.d.ts +8 -0
- package/dist/analyzer/scanners/project.scanner.d.ts +29 -0
- package/dist/analyzer/validators/contracts.validator.d.ts +27 -0
- package/dist/analyzer/validators/maintainability.validator.d.ts +27 -0
- package/dist/analyzer/validators/observability.validator.d.ts +27 -0
- package/dist/analyzer/validators/performance.validator.d.ts +27 -0
- package/dist/analyzer/validators/security.validator.d.ts +27 -0
- package/dist/analyzer/validators/soc.validator.d.ts +27 -0
- package/dist/auth/device-auth.d.ts +18 -0
- package/dist/auth/secure-auth.d.ts +35 -0
- package/dist/bundle.mjs +422 -0
- package/dist/commands/analyze.d.ts +12 -0
- package/dist/commands/auth-new.d.ts +6 -0
- package/dist/commands/auth.d.ts +17 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/deploy.d.ts +5 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/plugins.d.ts +7 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/sync.d.ts +5 -0
- package/dist/commands/whoami.d.ts +4 -0
- package/dist/components/Dashboard.d.ts +8 -0
- package/dist/components/DeltaApp.d.ts +13 -0
- package/dist/components/UnifiedManager.d.ts +10 -0
- package/dist/core/audit.d.ts +60 -0
- package/dist/core/completion.d.ts +79 -0
- package/dist/core/contracts.d.ts +127 -0
- package/dist/core/engine.d.ts +26 -0
- package/dist/core/exit-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +50 -0
- package/dist/core/{index.js → index.d.ts} +1 -1
- package/dist/core/policy.d.ts +24 -0
- package/dist/core/profiles.d.ts +45 -0
- package/dist/core/wizard.d.ts +28 -0
- package/dist/interactive/index.d.ts +5 -0
- package/dist/plugins/GitStatusPlugin.d.ts +25 -0
- package/dist/providers/ai-provider.d.ts +21 -0
- package/dist/providers/local-provider.d.ts +21 -0
- package/dist/providers/remote-provider.d.ts +15 -0
- package/dist/telemetry/wrapper.d.ts +18 -0
- package/dist/types/api.d.ts +46 -0
- package/dist/ui.d.ts +52 -0
- package/dist/welcome.d.ts +8 -0
- package/package.json +8 -10
- package/dist/adapters/analysis.adapter.js +0 -42
- package/dist/analyzer/commands/analyze.js +0 -220
- package/dist/analyzer/commands/config.js +0 -83
- package/dist/analyzer/commands/report.js +0 -38
- package/dist/analyzer/generators/report.generator.js +0 -123
- package/dist/analyzer/index.js +0 -44
- package/dist/analyzer/scanners/project.scanner.js +0 -92
- package/dist/analyzer/validators/contracts.validator.js +0 -42
- package/dist/analyzer/validators/maintainability.validator.js +0 -40
- package/dist/analyzer/validators/observability.validator.js +0 -39
- package/dist/analyzer/validators/performance.validator.js +0 -42
- package/dist/analyzer/validators/security.validator.js +0 -66
- package/dist/analyzer/validators/soc.validator.js +0 -75
- package/dist/auth/device-auth.js +0 -261
- package/dist/auth/secure-auth.js +0 -401
- package/dist/commands/analyze.js +0 -393
- package/dist/commands/auth-new.js +0 -37
- package/dist/commands/auth.js +0 -131
- package/dist/commands/config.js +0 -51
- package/dist/commands/deploy.js +0 -6
- package/dist/commands/init.js +0 -47
- package/dist/commands/logout.js +0 -31
- package/dist/commands/plugins.js +0 -21
- package/dist/commands/status.js +0 -82
- package/dist/commands/sync.js +0 -6
- package/dist/commands/whoami.js +0 -72
- package/dist/components/Dashboard.js +0 -167
- package/dist/components/DeltaApp.js +0 -57
- package/dist/components/UnifiedManager.js +0 -372
- package/dist/core/audit.js +0 -184
- package/dist/core/completion.js +0 -305
- package/dist/core/contracts.js +0 -6
- package/dist/core/engine.js +0 -130
- package/dist/core/exit-codes.js +0 -79
- package/dist/core/hooks.js +0 -181
- package/dist/core/policy.js +0 -115
- package/dist/core/profiles.js +0 -161
- package/dist/core/wizard.js +0 -203
- package/dist/index.js +0 -403
- package/dist/interactive/index.js +0 -11
- package/dist/plugins/GitStatusPlugin.js +0 -93
- package/dist/providers/ai-provider.js +0 -74
- package/dist/providers/local-provider.js +0 -304
- package/dist/providers/remote-provider.js +0 -100
- package/dist/telemetry/wrapper.js +0 -114
- package/dist/types/api.js +0 -3
- package/dist/ui.js +0 -226
- package/dist/welcome.js +0 -91
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Execution Provider
|
|
3
|
+
* Implements all logic locally without external AI services
|
|
4
|
+
*/
|
|
5
|
+
import { TaskRequest, TaskResponse, ExecutionProvider, ProviderCapabilities, LocalProviderConfig } from '../core/contracts.js';
|
|
6
|
+
export declare class LocalProvider implements ExecutionProvider {
|
|
7
|
+
readonly name = "local";
|
|
8
|
+
readonly version = "2.0.0";
|
|
9
|
+
readonly capabilities: ProviderCapabilities;
|
|
10
|
+
private config;
|
|
11
|
+
constructor(config: LocalProviderConfig);
|
|
12
|
+
isAvailable(): Promise<boolean>;
|
|
13
|
+
execute(request: TaskRequest): Promise<TaskResponse>;
|
|
14
|
+
private executeAnalyze;
|
|
15
|
+
private executeInit;
|
|
16
|
+
private executeStatus;
|
|
17
|
+
private executeConfig;
|
|
18
|
+
private executeAuth;
|
|
19
|
+
private discoverFiles;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=local-provider.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Execution Provider
|
|
3
|
+
* Connects to Delta API for cloud-based execution
|
|
4
|
+
*/
|
|
5
|
+
import { TaskRequest, TaskResponse, ExecutionProvider, ProviderCapabilities, RemoteProviderConfig } from '../core/contracts.js';
|
|
6
|
+
export declare class RemoteProvider implements ExecutionProvider {
|
|
7
|
+
readonly name = "remote";
|
|
8
|
+
readonly version = "2.0.0";
|
|
9
|
+
readonly capabilities: ProviderCapabilities;
|
|
10
|
+
private config;
|
|
11
|
+
constructor(config: RemoteProviderConfig);
|
|
12
|
+
isAvailable(): Promise<boolean>;
|
|
13
|
+
execute(request: TaskRequest): Promise<TaskResponse>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=remote-provider.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Telemetry Wrapper
|
|
3
|
+
* @description Wraps CLI commands with telemetry and error handling
|
|
4
|
+
* @package apps/cli
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Wrap a CLI command with telemetry
|
|
8
|
+
*/
|
|
9
|
+
export declare function withCommandTelemetry<T>(commandName: string, args: string[], fn: () => T | Promise<T>): Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Global CLI error handler
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleCliError(error: unknown): void;
|
|
14
|
+
/**
|
|
15
|
+
* Print CLI health metrics
|
|
16
|
+
*/
|
|
17
|
+
export declare function printHealthMetrics(): void;
|
|
18
|
+
//# sourceMappingURL=wrapper.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface ApiError {
|
|
2
|
+
message: string;
|
|
3
|
+
details?: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export type ApiResponse<T> = {
|
|
6
|
+
success: true;
|
|
7
|
+
data: T;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
data?: undefined;
|
|
12
|
+
error: ApiError;
|
|
13
|
+
};
|
|
14
|
+
export interface UserInfo {
|
|
15
|
+
email: string;
|
|
16
|
+
id: string;
|
|
17
|
+
plan: string;
|
|
18
|
+
role?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface QuotaInfo {
|
|
21
|
+
used: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
remaining: number;
|
|
24
|
+
resetAt: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PlanLimits {
|
|
27
|
+
maxReportsPerMonth: number;
|
|
28
|
+
maxReportSizeBytes: number;
|
|
29
|
+
allowApiAccess: boolean;
|
|
30
|
+
allowUpload: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface WhoamiData {
|
|
33
|
+
user: UserInfo;
|
|
34
|
+
quota: QuotaInfo;
|
|
35
|
+
limits: PlanLimits;
|
|
36
|
+
}
|
|
37
|
+
export interface UploadInitData {
|
|
38
|
+
uploadId: string;
|
|
39
|
+
signing: {
|
|
40
|
+
secret: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface UploadFinalizeData {
|
|
44
|
+
reportId: string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=api.d.ts.map
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Ora } from 'ora';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
export declare const icons: {
|
|
4
|
+
success: string;
|
|
5
|
+
error: string;
|
|
6
|
+
warning: string;
|
|
7
|
+
info: string;
|
|
8
|
+
arrow: string;
|
|
9
|
+
bullet: string;
|
|
10
|
+
star: string;
|
|
11
|
+
check: string;
|
|
12
|
+
cross: string;
|
|
13
|
+
loading: string;
|
|
14
|
+
rocket: string;
|
|
15
|
+
lock: string;
|
|
16
|
+
user: string;
|
|
17
|
+
package: string;
|
|
18
|
+
chart: string;
|
|
19
|
+
folder: string;
|
|
20
|
+
gear: string;
|
|
21
|
+
link: string;
|
|
22
|
+
sparkles: string;
|
|
23
|
+
dot: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function startSpinner(text: string): Ora;
|
|
26
|
+
export declare function stopSpinner(success?: boolean, text?: string): void;
|
|
27
|
+
export declare function updateSpinnerText(text: string): void;
|
|
28
|
+
export declare function printHeader(title: string): void;
|
|
29
|
+
export declare function printSection(title: string): void;
|
|
30
|
+
export declare function printSubSection(title: string): void;
|
|
31
|
+
export declare function printSuccess(message: string): void;
|
|
32
|
+
export declare function printError(message: string, details?: string): void;
|
|
33
|
+
export declare function printWarning(message: string): void;
|
|
34
|
+
export declare function printInfo(message: string): void;
|
|
35
|
+
export declare function printKeyValue(key: string, value: string, keyColor?: import("chalk").ChalkInstance): void;
|
|
36
|
+
export declare function createTable(headers: string[]): Table.Table;
|
|
37
|
+
export declare function confirm(message: string, initial?: boolean): Promise<boolean>;
|
|
38
|
+
export declare function select<T extends string>(message: string, choices: {
|
|
39
|
+
title: string;
|
|
40
|
+
value: T;
|
|
41
|
+
description?: string;
|
|
42
|
+
}[]): Promise<T | null>;
|
|
43
|
+
export declare function input(message: string, initial?: string, validate?: (value: string) => boolean | string): Promise<string | null>;
|
|
44
|
+
export declare function password(message: string): Promise<string | null>;
|
|
45
|
+
export declare function printProgress(current: number, total: number, prefix?: string): void;
|
|
46
|
+
export declare function printBox(title: string, lines: string[]): void;
|
|
47
|
+
export declare function formatBytes(bytes: number): string;
|
|
48
|
+
export declare function formatDuration(ms: number): string;
|
|
49
|
+
export declare function printCommandHint(command: string, description: string): void;
|
|
50
|
+
export declare function printDivider(): void;
|
|
51
|
+
export declare function printWelcome(): void;
|
|
52
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import gradient from 'gradient-string';
|
|
3
|
+
export declare const gradients: Record<string, ReturnType<typeof gradient>>;
|
|
4
|
+
export declare function printLogo(variant?: keyof typeof gradients): void;
|
|
5
|
+
export declare function printMinimalLogo(): void;
|
|
6
|
+
export declare function printWelcome(): void;
|
|
7
|
+
export declare function printTips(): void;
|
|
8
|
+
//# sourceMappingURL=welcome.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vee-stack/delta-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "Delta CLI v2 - Next-gen terminal interface with React Ink",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
6
|
+
"main": "./dist/bundle.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"default": "./dist/
|
|
11
|
+
"default": "./dist/bundle.mjs"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"delta": "dist/
|
|
16
|
-
"dt": "dist/
|
|
15
|
+
"delta": "dist/bundle.mjs",
|
|
16
|
+
"dt": "dist/bundle.mjs"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
|
-
"dist
|
|
20
|
-
"dist
|
|
19
|
+
"dist/bundle.mjs",
|
|
20
|
+
"dist/**/*.d.ts",
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && node scripts/add-shebang.js",
|
|
27
|
+
"build": "tsc && node scripts/add-shebang.js && pnpm run bundle",
|
|
28
28
|
"bundle": "node scripts/bundle.mjs",
|
|
29
29
|
"build:publish": "pnpm run build",
|
|
30
30
|
"dev": "tsx watch src/index.tsx",
|
|
@@ -50,8 +50,6 @@
|
|
|
50
50
|
"outputPath": "./bin"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@delta/domain": "workspace:*",
|
|
54
|
-
"@delta/application": "workspace:*",
|
|
55
53
|
"ink": "^5.0.0",
|
|
56
54
|
"ink-gradient": "^3.0.0",
|
|
57
55
|
"ink-big-text": "^2.0.0",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Analysis Adapter
|
|
3
|
-
* @description Bridges CLI commands with Domain Layer analysis engine
|
|
4
|
-
* @package apps/cli
|
|
5
|
-
*/
|
|
6
|
-
import { analyze, createSession, discoverFiles, runAnalysis, generateReport, } from '@delta/domain';
|
|
7
|
-
/**
|
|
8
|
-
* Analyze a project using Domain Layer engine
|
|
9
|
-
* Replaces local validators with unified Domain analysis
|
|
10
|
-
*/
|
|
11
|
-
export async function analyzeProject(projectPath, options = {}) {
|
|
12
|
-
// Use Domain Layer discovery
|
|
13
|
-
const discovery = await discoverFiles({
|
|
14
|
-
rootDir: projectPath,
|
|
15
|
-
include: options.include || ['src/**/*.{ts,tsx,js,jsx}'],
|
|
16
|
-
exclude: options.exclude || ['**/node_modules/**', '**/dist/**', '**/.git/**'],
|
|
17
|
-
});
|
|
18
|
-
// Run analysis through Domain orchestrator
|
|
19
|
-
const result = await runAnalysis({
|
|
20
|
-
rootDir: projectPath,
|
|
21
|
-
...options,
|
|
22
|
-
include: discovery.files.map(f => f.path),
|
|
23
|
-
});
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Generate report from analysis results
|
|
28
|
-
*/
|
|
29
|
-
export async function generateAnalysisReport(result, format = 'json') {
|
|
30
|
-
return generateReport(result, format);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create analysis session for progress tracking
|
|
34
|
-
*/
|
|
35
|
-
export function createAnalysisSession(config, policies) {
|
|
36
|
-
return createSession(config, policies);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Direct engine access for advanced use cases
|
|
40
|
-
*/
|
|
41
|
-
export { analyze as runDirectAnalysis };
|
|
42
|
-
//# sourceMappingURL=analysis.adapter.js.map
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Analyze Command
|
|
3
|
-
* @description Main analysis command using Domain Layer engine
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from 'fs/promises';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
import { analyzeProject, } from '../../adapters/analysis.adapter';
|
|
8
|
-
import { ReportGenerator } from '../generators/report.generator';
|
|
9
|
-
export async function analyzeCommand(projectPath, options) {
|
|
10
|
-
console.log(`🔍 Analyzing project: ${projectPath}`);
|
|
11
|
-
console.log(` Language: ${options.language}`);
|
|
12
|
-
console.log(` Depth: ${options.depth}`);
|
|
13
|
-
console.log('');
|
|
14
|
-
try {
|
|
15
|
-
// 1. Validate project path
|
|
16
|
-
const absolutePath = path.resolve(projectPath);
|
|
17
|
-
await fs.access(absolutePath);
|
|
18
|
-
// 2. Run analysis using Domain Layer
|
|
19
|
-
console.log('🔍 Running Delta Constitution analysis...');
|
|
20
|
-
const analysisResult = await analyzeProject(absolutePath, { rootDir: absolutePath });
|
|
21
|
-
// 3. Transform Domain result to CLI format
|
|
22
|
-
const result = transformToCliResult(analysisResult, absolutePath, options);
|
|
23
|
-
// 4. Output results
|
|
24
|
-
await outputResults(result, options);
|
|
25
|
-
// 5. Exit with appropriate code
|
|
26
|
-
if (options.strict &&
|
|
27
|
-
result.violations.some((v) => v.severity === 'critical' || v.severity === 'error')) {
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error('❌ Analysis failed:', error instanceof Error ? error.message : String(error));
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function transformToCliResult(domainResult, projectPath, options) {
|
|
37
|
-
// Map Domain findings to CLI violations
|
|
38
|
-
const violations = [];
|
|
39
|
-
const scores = {};
|
|
40
|
-
// Default scores (will be populated from Domain result if available)
|
|
41
|
-
const axes = ['security', 'performance', 'maintainability', 'contracts', 'soc', 'observability'];
|
|
42
|
-
axes.forEach((axis, index) => {
|
|
43
|
-
const weight = [25, 20, 15, 15, 15, 10][index] || 10;
|
|
44
|
-
scores[axis] = {
|
|
45
|
-
score: 80,
|
|
46
|
-
maxScore: 100,
|
|
47
|
-
percentage: 80,
|
|
48
|
-
weight,
|
|
49
|
-
weightedScore: (80 / 100) * weight,
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
// Calculate overall
|
|
53
|
-
const overallScore = Object.values(scores).reduce((sum, s) => sum + s.weightedScore, 0);
|
|
54
|
-
const percentage = Math.round(overallScore);
|
|
55
|
-
const grade = percentage >= 90
|
|
56
|
-
? 'A'
|
|
57
|
-
: percentage >= 80
|
|
58
|
-
? 'B'
|
|
59
|
-
: percentage >= 70
|
|
60
|
-
? 'C'
|
|
61
|
-
: percentage >= 60
|
|
62
|
-
? 'D'
|
|
63
|
-
: 'F';
|
|
64
|
-
return {
|
|
65
|
-
project: {
|
|
66
|
-
path: projectPath,
|
|
67
|
-
name: path.basename(projectPath),
|
|
68
|
-
language: options.language,
|
|
69
|
-
size: 0,
|
|
70
|
-
fileCount: domainResult.files?.length || 0,
|
|
71
|
-
},
|
|
72
|
-
timestamp: new Date().toISOString(),
|
|
73
|
-
constitution: {
|
|
74
|
-
version: '0.5.0',
|
|
75
|
-
axes: ['security', 'performance', 'maintainability'],
|
|
76
|
-
},
|
|
77
|
-
scores,
|
|
78
|
-
overall: {
|
|
79
|
-
score: overallScore,
|
|
80
|
-
percentage,
|
|
81
|
-
grade,
|
|
82
|
-
compliant: violations.filter((v) => v.severity === 'critical' || v.severity === 'error').length === 0,
|
|
83
|
-
},
|
|
84
|
-
violations,
|
|
85
|
-
recommendations: generateRecommendations(violations, scores),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async function outputResults(result, options) {
|
|
89
|
-
switch (options.output) {
|
|
90
|
-
case 'json':
|
|
91
|
-
console.log(JSON.stringify(result, null, 2));
|
|
92
|
-
break;
|
|
93
|
-
case 'html':
|
|
94
|
-
{
|
|
95
|
-
const html = ReportGenerator.generateHTML(result);
|
|
96
|
-
const htmlPath = `${result.project.name}-analysis.html`;
|
|
97
|
-
await fs.writeFile(htmlPath, html);
|
|
98
|
-
console.log(`📄 HTML report saved to: ${htmlPath}`);
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
case 'markdown':
|
|
102
|
-
{
|
|
103
|
-
const markdown = ReportGenerator.generateMarkdown(result);
|
|
104
|
-
const mdPath = `${result.project.name}-analysis.md`;
|
|
105
|
-
await fs.writeFile(mdPath, markdown);
|
|
106
|
-
console.log(`📄 Markdown report saved to: ${mdPath}`);
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
// Console output
|
|
111
|
-
printConsoleReport(result);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function printConsoleReport(result) {
|
|
115
|
-
console.log('\n' + '='.repeat(60));
|
|
116
|
-
console.log('📊 DELTA CONSTITUTION ANALYSIS REPORT');
|
|
117
|
-
console.log('='.repeat(60));
|
|
118
|
-
console.log(`\nProject: ${result.project.name}`);
|
|
119
|
-
console.log(`Path: ${result.project.path}`);
|
|
120
|
-
console.log(`Language: ${result.project.language}`);
|
|
121
|
-
console.log(`Files: ${result.project.fileCount}`);
|
|
122
|
-
console.log(`Constitution: v${result.constitution.version}`);
|
|
123
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
124
|
-
console.log(`\n🎯 OVERALL SCORE: ${result.overall.percentage}% (Grade: ${result.overall.grade})`);
|
|
125
|
-
console.log(`Status: ${result.overall.compliant ? '✅ Compliant' : '❌ Non-Compliant'}`);
|
|
126
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
127
|
-
console.log('AXIS SCORES:');
|
|
128
|
-
console.log(`${'-'.repeat(60)}`);
|
|
129
|
-
Object.entries(result.scores).forEach(([axis, score]) => {
|
|
130
|
-
const bar = '█'.repeat(Math.round(score.percentage / 5)) +
|
|
131
|
-
'░'.repeat(20 - Math.round(score.percentage / 5));
|
|
132
|
-
console.log(`${axis.padEnd(20)} ${bar} ${score.percentage.toString().padStart(3)}%`);
|
|
133
|
-
});
|
|
134
|
-
if (result.violations.length > 0) {
|
|
135
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
136
|
-
console.log('VIOLATIONS:');
|
|
137
|
-
console.log(`${'-'.repeat(60)}`);
|
|
138
|
-
const critical = result.violations.filter((v) => v.severity === 'critical');
|
|
139
|
-
const errors = result.violations.filter((v) => v.severity === 'error');
|
|
140
|
-
const warnings = result.violations.filter((v) => v.severity === 'warning');
|
|
141
|
-
if (critical.length > 0) {
|
|
142
|
-
console.log('\n🔴 Critical:');
|
|
143
|
-
critical.forEach((v) => console.log(` - [${v.id}] ${v.message}`));
|
|
144
|
-
}
|
|
145
|
-
if (errors.length > 0) {
|
|
146
|
-
console.log('\n🟠 Errors:');
|
|
147
|
-
errors.forEach((v) => console.log(` - [${v.id}] ${v.message}`));
|
|
148
|
-
}
|
|
149
|
-
if (warnings.length > 0) {
|
|
150
|
-
console.log('\n🟡 Warnings:');
|
|
151
|
-
warnings.slice(0, 5).forEach((v) => console.log(` - [${v.id}] ${v.message}`));
|
|
152
|
-
if (warnings.length > 5) {
|
|
153
|
-
console.log(` ... and ${warnings.length - 5} more warnings`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (result.recommendations.length > 0) {
|
|
158
|
-
console.log(`\n${'-'.repeat(60)}`);
|
|
159
|
-
console.log('TOP RECOMMENDATIONS:');
|
|
160
|
-
console.log(`${'-'.repeat(60)}`);
|
|
161
|
-
result.recommendations
|
|
162
|
-
.filter((r) => r.priority === 'high')
|
|
163
|
-
.slice(0, 5)
|
|
164
|
-
.forEach((r) => {
|
|
165
|
-
console.log(`\n[${r.axis}] ${r.description}`);
|
|
166
|
-
console.log(` Action: ${r.action}`);
|
|
167
|
-
console.log(` Effort: ${r.effort}`);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
console.log('\n' + '='.repeat(60) + '\n');
|
|
171
|
-
}
|
|
172
|
-
function generateRecommendations(violations, scores) {
|
|
173
|
-
const recommendations = [];
|
|
174
|
-
// Security recommendations
|
|
175
|
-
if (scores.security?.percentage < 80) {
|
|
176
|
-
recommendations.push({
|
|
177
|
-
axis: 'Security',
|
|
178
|
-
priority: 'high',
|
|
179
|
-
description: 'Security score below 80%',
|
|
180
|
-
action: 'Implement Policy Guards, Audit Logging, and Fail-Closed patterns',
|
|
181
|
-
effort: '2-3 days',
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// Performance recommendations
|
|
185
|
-
if (scores.performance?.percentage < 70) {
|
|
186
|
-
recommendations.push({
|
|
187
|
-
axis: 'Performance',
|
|
188
|
-
priority: 'medium',
|
|
189
|
-
description: 'Performance optimizations needed',
|
|
190
|
-
action: 'Add lazy loading, code splitting, and caching layers',
|
|
191
|
-
effort: '1-2 days',
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
// SoC recommendations
|
|
195
|
-
if (scores.soc?.percentage < 80) {
|
|
196
|
-
recommendations.push({
|
|
197
|
-
axis: 'SoC',
|
|
198
|
-
priority: 'high',
|
|
199
|
-
description: 'Layer boundaries need improvement',
|
|
200
|
-
action: 'Refactor to follow 7-layer architecture, fix import violations',
|
|
201
|
-
effort: '3-5 days',
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
// Add specific recommendations based on violations
|
|
205
|
-
const failClosedViolations = violations.filter((v) => v.message.includes('Fail-Open'));
|
|
206
|
-
if (failClosedViolations.length > 0) {
|
|
207
|
-
recommendations.push({
|
|
208
|
-
axis: 'Security',
|
|
209
|
-
priority: 'high',
|
|
210
|
-
description: `Found ${failClosedViolations.length} Fail-Open patterns`,
|
|
211
|
-
action: 'Replace with Fail-Closed: if (!isAllowed) return deny()',
|
|
212
|
-
effort: '1 day',
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return recommendations.sort((a, b) => {
|
|
216
|
-
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
217
|
-
return priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
//# sourceMappingURL=analyze.js.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config Command
|
|
3
|
-
* @description Manage analyzer configuration
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from 'fs/promises';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
const DEFAULT_CONFIG = {
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
language: 'typescript',
|
|
10
|
-
depth: 'standard',
|
|
11
|
-
output: 'json',
|
|
12
|
-
strict: false,
|
|
13
|
-
rules: {
|
|
14
|
-
security: { enabled: true, weight: 25 },
|
|
15
|
-
performance: { enabled: true, weight: 20 },
|
|
16
|
-
soc: { enabled: true, weight: 20 },
|
|
17
|
-
contracts: { enabled: true, weight: 15 },
|
|
18
|
-
maintainability: { enabled: true, weight: 10 },
|
|
19
|
-
observability: { enabled: true, weight: 10 },
|
|
20
|
-
},
|
|
21
|
-
thresholds: {
|
|
22
|
-
critical: 0,
|
|
23
|
-
error: 5,
|
|
24
|
-
warning: 20,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
export async function configCommand(options) {
|
|
28
|
-
const configPath = path.join(process.cwd(), '.delta-analyzer.json');
|
|
29
|
-
if (options.init) {
|
|
30
|
-
try {
|
|
31
|
-
await fs.writeFile(configPath, JSON.stringify(DEFAULT_CONFIG, null, 2));
|
|
32
|
-
console.log('✅ Configuration file created: .delta-analyzer.json');
|
|
33
|
-
console.log('\nEdit this file to customize analyzer settings.');
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error('❌ Failed to create config:', error instanceof Error ? error.message : String(error));
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (options.show) {
|
|
42
|
-
try {
|
|
43
|
-
const content = await fs.readFile(configPath, 'utf-8');
|
|
44
|
-
const config = JSON.parse(content);
|
|
45
|
-
console.log('\n📋 Current Configuration:\n');
|
|
46
|
-
console.log(JSON.stringify(config, null, 2));
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
console.log('⚠️ No configuration file found. Run with --init to create one.');
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (options.set) {
|
|
54
|
-
const [key, value] = options.set.split('=');
|
|
55
|
-
if (!key || !value) {
|
|
56
|
-
console.error('❌ Invalid format. Use: --set key=value');
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
const content = await fs.readFile(configPath, 'utf-8');
|
|
61
|
-
const config = JSON.parse(content);
|
|
62
|
-
// Simple nested key support (e.g., "rules.security.enabled")
|
|
63
|
-
const keys = key.split('.');
|
|
64
|
-
let current = config;
|
|
65
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
66
|
-
current = current[keys[i]];
|
|
67
|
-
}
|
|
68
|
-
current[keys[keys.length - 1]] = value;
|
|
69
|
-
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
70
|
-
console.log(`✅ Set ${key} = ${value}`);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
console.log('⚠️ No configuration file found. Run with --init to create one.');
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
console.log('Usage:');
|
|
79
|
-
console.log(' delta-analyze config --init Create default configuration');
|
|
80
|
-
console.log(' delta-analyze config --show Show current configuration');
|
|
81
|
-
console.log(' delta-analyze config --set key=value Set configuration value');
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Report Command
|
|
3
|
-
* @description Generate report from previous analysis
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from 'fs/promises';
|
|
6
|
-
import { ReportGenerator } from '../generators/report.generator';
|
|
7
|
-
export async function reportCommand(analysisFile, options) {
|
|
8
|
-
try {
|
|
9
|
-
// Read analysis file
|
|
10
|
-
const content = await fs.readFile(analysisFile, 'utf-8');
|
|
11
|
-
const analysis = JSON.parse(content);
|
|
12
|
-
// Generate report
|
|
13
|
-
let output;
|
|
14
|
-
let extension;
|
|
15
|
-
switch (options.template) {
|
|
16
|
-
case 'html':
|
|
17
|
-
output = ReportGenerator.generateHTML(analysis);
|
|
18
|
-
extension = 'html';
|
|
19
|
-
break;
|
|
20
|
-
case 'markdown':
|
|
21
|
-
output = ReportGenerator.generateMarkdown(analysis);
|
|
22
|
-
extension = 'md';
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
console.error(`Unknown template: ${options.template}`);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
// Write to file
|
|
29
|
-
const outputPath = options.output || `${analysis.project.name}-report.${extension}`;
|
|
30
|
-
await fs.writeFile(outputPath, output);
|
|
31
|
-
console.log(`✅ Report generated: ${outputPath}`);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error('❌ Failed to generate report:', error instanceof Error ? error.message : String(error));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=report.js.map
|