@vee-stack/delta-cli 2.0.4 → 2.0.6

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 (135) hide show
  1. package/dist/analyzer/commands/analyze.js +260 -0
  2. package/dist/analyzer/commands/config.js +83 -0
  3. package/dist/analyzer/commands/report.js +38 -0
  4. package/dist/analyzer/generators/report.generator.js +123 -0
  5. package/dist/analyzer/index.js +44 -0
  6. package/dist/analyzer/scanners/project.scanner.js +92 -0
  7. package/dist/analyzer/validators/contracts.validator.js +42 -0
  8. package/dist/analyzer/validators/maintainability.validator.js +40 -0
  9. package/dist/analyzer/validators/observability.validator.js +39 -0
  10. package/dist/analyzer/validators/performance.validator.js +42 -0
  11. package/dist/analyzer/validators/security.validator.js +66 -0
  12. package/dist/analyzer/validators/soc.validator.js +75 -0
  13. package/dist/apps/cli/src/analyzer/commands/analyze.js +256 -0
  14. package/dist/apps/cli/src/analyzer/commands/config.js +83 -0
  15. package/dist/apps/cli/src/analyzer/commands/report.js +38 -0
  16. package/dist/apps/cli/src/analyzer/generators/report.generator.js +123 -0
  17. package/dist/apps/cli/src/analyzer/index.js +44 -0
  18. package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +92 -0
  19. package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +42 -0
  20. package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +40 -0
  21. package/dist/apps/cli/src/analyzer/validators/observability.validator.js +39 -0
  22. package/dist/apps/cli/src/analyzer/validators/performance.validator.js +42 -0
  23. package/dist/apps/cli/src/analyzer/validators/security.validator.js +66 -0
  24. package/dist/apps/cli/src/analyzer/validators/soc.validator.js +75 -0
  25. package/dist/apps/cli/src/auth/secure-auth.js +312 -0
  26. package/dist/apps/cli/src/commands/analyze.js +286 -0
  27. package/dist/apps/cli/src/commands/auth-new.js +37 -0
  28. package/dist/apps/cli/src/commands/auth.js +122 -0
  29. package/dist/apps/cli/src/commands/config.js +49 -0
  30. package/dist/apps/cli/src/commands/deploy.js +6 -0
  31. package/dist/apps/cli/src/commands/init.js +47 -0
  32. package/dist/apps/cli/src/commands/logout.js +23 -0
  33. package/dist/apps/cli/src/commands/plugins.js +21 -0
  34. package/dist/apps/cli/src/commands/status.js +80 -0
  35. package/dist/apps/cli/src/commands/sync.js +6 -0
  36. package/dist/apps/cli/src/commands/whoami.js +115 -0
  37. package/dist/apps/cli/src/components/Dashboard.js +168 -0
  38. package/dist/apps/cli/src/components/DeltaApp.js +56 -0
  39. package/dist/apps/cli/src/components/UnifiedManager.js +324 -0
  40. package/dist/apps/cli/src/core/audit.js +184 -0
  41. package/dist/apps/cli/src/core/completion.js +294 -0
  42. package/dist/apps/cli/src/core/contracts.js +6 -0
  43. package/dist/apps/cli/src/core/engine.js +124 -0
  44. package/dist/apps/cli/src/core/exit-codes.js +71 -0
  45. package/dist/apps/cli/src/core/hooks.js +181 -0
  46. package/dist/apps/cli/src/core/index.js +7 -0
  47. package/dist/apps/cli/src/core/policy.js +115 -0
  48. package/dist/apps/cli/src/core/profiles.js +161 -0
  49. package/dist/apps/cli/src/core/wizard.js +203 -0
  50. package/dist/apps/cli/src/index.js +636 -0
  51. package/dist/apps/cli/src/interactive/index.js +11 -0
  52. package/dist/apps/cli/src/plugins/GitStatusPlugin.js +99 -0
  53. package/dist/apps/cli/src/providers/ai-provider.js +74 -0
  54. package/dist/apps/cli/src/providers/local-provider.js +302 -0
  55. package/dist/apps/cli/src/providers/remote-provider.js +100 -0
  56. package/dist/apps/cli/src/types/api.js +3 -0
  57. package/dist/apps/cli/src/ui.js +219 -0
  58. package/dist/apps/cli/src/welcome.js +81 -0
  59. package/dist/auth/secure-auth.js +418 -0
  60. package/dist/bundle.js +45 -45
  61. package/dist/commands/analyze.js +384 -0
  62. package/dist/commands/auth-new.js +37 -0
  63. package/dist/commands/auth.js +134 -0
  64. package/dist/commands/config.js +51 -0
  65. package/dist/commands/deploy.js +6 -0
  66. package/dist/commands/init.js +47 -0
  67. package/dist/commands/logout.js +31 -0
  68. package/dist/commands/plugins.js +21 -0
  69. package/dist/commands/status.js +82 -0
  70. package/dist/commands/sync.js +6 -0
  71. package/dist/commands/whoami.js +72 -0
  72. package/dist/components/Dashboard.js +169 -0
  73. package/dist/components/DeltaApp.js +57 -0
  74. package/dist/components/UnifiedManager.js +344 -0
  75. package/dist/core/audit.js +184 -0
  76. package/dist/core/completion.js +294 -0
  77. package/dist/core/contracts.js +6 -0
  78. package/dist/core/engine.js +124 -0
  79. package/dist/core/exit-codes.js +71 -0
  80. package/dist/core/hooks.js +181 -0
  81. package/dist/core/index.js +7 -0
  82. package/dist/core/policy.js +115 -0
  83. package/dist/core/profiles.js +161 -0
  84. package/dist/core/wizard.js +203 -0
  85. package/dist/index.js +387 -0
  86. package/dist/interactive/index.js +11 -0
  87. package/dist/packages/domain/src/constitution/contracts/index.js +43 -0
  88. package/dist/packages/domain/src/constitution/contracts/ts.rules.js +268 -0
  89. package/dist/packages/domain/src/constitution/index.js +139 -0
  90. package/dist/packages/domain/src/constitution/maintainability/index.js +43 -0
  91. package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +344 -0
  92. package/dist/packages/domain/src/constitution/observability/index.js +43 -0
  93. package/dist/packages/domain/src/constitution/observability/ts.rules.js +307 -0
  94. package/dist/packages/domain/src/constitution/performance/index.js +43 -0
  95. package/dist/packages/domain/src/constitution/performance/ts.rules.js +325 -0
  96. package/dist/packages/domain/src/constitution/security/index.js +50 -0
  97. package/dist/packages/domain/src/constitution/security/ts.rules.js +267 -0
  98. package/dist/packages/domain/src/constitution/soc/index.js +43 -0
  99. package/dist/packages/domain/src/constitution/soc/ts.rules.js +360 -0
  100. package/dist/packages/domain/src/contracts/analysis.contract.js +18 -0
  101. package/dist/packages/domain/src/contracts/index.js +7 -0
  102. package/dist/packages/domain/src/contracts/projects.contract.js +18 -0
  103. package/dist/packages/domain/src/control/registry/rules.registry.js +29 -0
  104. package/dist/packages/domain/src/control/schemas/policies.js +6 -0
  105. package/dist/packages/domain/src/core/analysis/discovery.js +163 -0
  106. package/dist/packages/domain/src/core/analysis/engine.contract.js +298 -0
  107. package/dist/packages/domain/src/core/analysis/engine.js +77 -0
  108. package/dist/packages/domain/src/core/analysis/index.js +14 -0
  109. package/dist/packages/domain/src/core/analysis/orchestrator.js +242 -0
  110. package/dist/packages/domain/src/core/comparison/engine.js +29 -0
  111. package/dist/packages/domain/src/core/comparison/index.js +5 -0
  112. package/dist/packages/domain/src/core/documentation/index.js +5 -0
  113. package/dist/packages/domain/src/core/documentation/pipeline.js +41 -0
  114. package/dist/packages/domain/src/core/fs/adapter.js +111 -0
  115. package/dist/packages/domain/src/core/fs/index.js +5 -0
  116. package/dist/packages/domain/src/core/parser/unified-parser.js +166 -0
  117. package/dist/packages/domain/src/index.js +33 -0
  118. package/dist/packages/domain/src/plugin/registry.js +195 -0
  119. package/dist/packages/domain/src/plugin/types.js +6 -0
  120. package/dist/packages/domain/src/ports/analysis.engine.js +7 -0
  121. package/dist/packages/domain/src/ports/audit.logger.js +7 -0
  122. package/dist/packages/domain/src/ports/project.repository.js +7 -0
  123. package/dist/packages/domain/src/rules/index.js +134 -0
  124. package/dist/packages/domain/src/types/analysis.js +6 -0
  125. package/dist/packages/domain/src/types/errors.js +53 -0
  126. package/dist/packages/domain/src/types/fs.js +6 -0
  127. package/dist/packages/domain/src/types/index.js +7 -0
  128. package/dist/plugins/GitStatusPlugin.js +93 -0
  129. package/dist/providers/ai-provider.js +74 -0
  130. package/dist/providers/local-provider.js +304 -0
  131. package/dist/providers/remote-provider.js +100 -0
  132. package/dist/types/api.js +3 -0
  133. package/dist/ui.js +219 -0
  134. package/dist/welcome.js +81 -0
  135. package/package.json +18 -18
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Maintainability Validator
3
+ * @description Validates Maintainability rules
4
+ */
5
+ export class MaintainabilityValidator {
6
+ static async validate(project, _options) {
7
+ const violations = [];
8
+ let score = 100;
9
+ // Check for tests
10
+ const testFiles = project.files.filter(f => f.includes('.test.') || f.includes('.spec.'));
11
+ const testRatio = testFiles.length / (project.fileCount || 1);
12
+ if (testRatio < 0.1) {
13
+ violations.push({
14
+ id: 'MAINT-TEST-001',
15
+ severity: 'warning',
16
+ message: `Low test coverage: ${(testRatio * 100).toFixed(1)}% of files are tests`,
17
+ rule: 'Testing Required',
18
+ });
19
+ score -= 20;
20
+ }
21
+ // Check for documentation
22
+ const hasReadme = project.files.some(f => f.toLowerCase() === 'readme.md' || f.toLowerCase().endsWith('/readme.md'));
23
+ if (!hasReadme) {
24
+ violations.push({
25
+ id: 'MAINT-DOC-001',
26
+ severity: 'warning',
27
+ message: 'No README.md found',
28
+ rule: 'Documentation Required',
29
+ });
30
+ score -= 10;
31
+ }
32
+ return {
33
+ score: Math.max(0, score),
34
+ maxScore: 100,
35
+ percentage: Math.max(0, score),
36
+ violations,
37
+ };
38
+ }
39
+ }
40
+ //# sourceMappingURL=maintainability.validator.js.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Observability Validator
3
+ * @description Validates Observability rules
4
+ */
5
+ export class ObservabilityValidator {
6
+ static async validate(project, _options) {
7
+ const violations = [];
8
+ let score = 100;
9
+ // Check for health endpoint
10
+ const hasHealthEndpoint = project.files.some(f => f.includes('health') || f.includes('ready') || f.includes('live'));
11
+ if (!hasHealthEndpoint) {
12
+ violations.push({
13
+ id: 'OBS-HEALTH-001',
14
+ severity: 'warning',
15
+ message: 'No health check endpoint found',
16
+ rule: 'Health Checks Required',
17
+ });
18
+ score -= 20;
19
+ }
20
+ // Check for logging
21
+ const hasLogging = project.files.some(f => f.includes('logger') || f.includes('log'));
22
+ if (!hasLogging) {
23
+ violations.push({
24
+ id: 'OBS-LOG-001',
25
+ severity: 'warning',
26
+ message: 'No logging implementation found',
27
+ rule: 'Structured Logging Required',
28
+ });
29
+ score -= 20;
30
+ }
31
+ return {
32
+ score: Math.max(0, score),
33
+ maxScore: 100,
34
+ percentage: Math.max(0, score),
35
+ violations,
36
+ };
37
+ }
38
+ }
39
+ //# sourceMappingURL=observability.validator.js.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Performance Validator
3
+ * @description Validates performance rules
4
+ */
5
+ export class PerformanceValidator {
6
+ static async validate(project, _options) {
7
+ const violations = [];
8
+ let score = 100;
9
+ // Check for lazy loading patterns
10
+ const hasDynamicImports = project.files.some(f => {
11
+ // Would check file content for dynamic imports
12
+ return f.includes('dynamic') || f.includes('lazy');
13
+ });
14
+ if (!hasDynamicImports && project.fileCount > 50) {
15
+ violations.push({
16
+ id: 'PERF-LAZY-001',
17
+ severity: 'warning',
18
+ message: 'No lazy loading patterns detected in large project',
19
+ rule: 'Lazy Loading Recommended',
20
+ });
21
+ score -= 10;
22
+ }
23
+ // Check for caching implementation
24
+ const hasCaching = project.files.some(f => f.includes('cache') || f.includes('redis') || f.includes('swr'));
25
+ if (!hasCaching) {
26
+ violations.push({
27
+ id: 'PERF-CACHE-001',
28
+ severity: 'warning',
29
+ message: 'No caching implementation found',
30
+ rule: 'Caching Layer Recommended',
31
+ });
32
+ score -= 15;
33
+ }
34
+ return {
35
+ score: Math.max(0, score),
36
+ maxScore: 100,
37
+ percentage: Math.max(0, score),
38
+ violations,
39
+ };
40
+ }
41
+ }
42
+ //# sourceMappingURL=performance.validator.js.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Security Validator
3
+ * @description Validates security rules against project
4
+ */
5
+ export class SecurityValidator {
6
+ static async validate(project, options) {
7
+ const violations = [];
8
+ let score = 100;
9
+ // Check 1: Policy Registry exists
10
+ const hasPolicyRegistry = project.directories.some(d => d.includes('modules') && d.includes('policies'));
11
+ if (!hasPolicyRegistry) {
12
+ violations.push({
13
+ id: 'SEC-POL-002',
14
+ severity: 'error',
15
+ message: 'Missing policies/ directory in modules',
16
+ rule: 'Policy Registry Required',
17
+ });
18
+ score -= 15;
19
+ }
20
+ // Check 2: Audit logging
21
+ const hasAuditFile = project.files.some(f => f.includes('audit') || f.includes('logger'));
22
+ if (!hasAuditFile) {
23
+ violations.push({
24
+ id: 'SEC-AUDIT-001',
25
+ severity: 'warning',
26
+ message: 'No audit logging implementation found',
27
+ rule: 'Audit Logging Required',
28
+ });
29
+ score -= 10;
30
+ }
31
+ // Check 3: Rate limiting
32
+ const hasRateLimit = project.files.some(f => f.includes('rate') || f.includes('limit'));
33
+ if (!hasRateLimit) {
34
+ violations.push({
35
+ id: 'SEC-RATE-001',
36
+ severity: 'warning',
37
+ message: 'No rate limiting implementation found',
38
+ rule: 'Rate Limiting Required',
39
+ });
40
+ score -= 10;
41
+ }
42
+ // Check 4: Security directory
43
+ const hasSecurityDir = project.directories.some(d => d.includes('security'));
44
+ if (!hasSecurityDir) {
45
+ violations.push({
46
+ id: 'SEC-DIR-001',
47
+ severity: 'error',
48
+ message: 'Missing security/ directory',
49
+ rule: 'Security Layer Required',
50
+ });
51
+ score -= 15;
52
+ }
53
+ // Deep scan for Fail-Open patterns (if requested)
54
+ if (options.depth === 'deep') {
55
+ // This would scan file contents for fail-open patterns
56
+ // For now, just check structure
57
+ }
58
+ return {
59
+ score: Math.max(0, score),
60
+ maxScore: 100,
61
+ percentage: Math.max(0, score),
62
+ violations,
63
+ };
64
+ }
65
+ }
66
+ //# sourceMappingURL=security.validator.js.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * SoC Validator
3
+ * @description Validates Separation of Concerns rules
4
+ */
5
+ export class SocValidator {
6
+ static async validate(project, _options) {
7
+ const violations = [];
8
+ let score = 100;
9
+ // Check for proper layer structure
10
+ const hasFeatures = project.directories.some(d => d.includes('features'));
11
+ const hasModules = project.directories.some(d => d.includes('modules'));
12
+ const hasCore = project.directories.some(d => d.includes('core'));
13
+ const hasContracts = project.directories.some(d => d.includes('contracts'));
14
+ if (!hasFeatures) {
15
+ violations.push({
16
+ id: 'SOC-LAYER-001',
17
+ severity: 'error',
18
+ message: 'Missing features/ layer',
19
+ rule: '7-Layer Architecture',
20
+ });
21
+ score -= 20;
22
+ }
23
+ if (!hasModules) {
24
+ violations.push({
25
+ id: 'SOC-LAYER-002',
26
+ severity: 'error',
27
+ message: 'Missing modules/ layer',
28
+ rule: '7-Layer Architecture',
29
+ });
30
+ score -= 20;
31
+ }
32
+ if (!hasCore) {
33
+ violations.push({
34
+ id: 'SOC-LAYER-003',
35
+ severity: 'error',
36
+ message: 'Missing core/ layer',
37
+ rule: '7-Layer Architecture',
38
+ });
39
+ score -= 20;
40
+ }
41
+ if (!hasContracts) {
42
+ violations.push({
43
+ id: 'SOC-LAYER-004',
44
+ severity: 'warning',
45
+ message: 'Missing contracts/ layer',
46
+ rule: '7-Layer Architecture',
47
+ });
48
+ score -= 10;
49
+ }
50
+ // Check feature structure
51
+ if (hasFeatures) {
52
+ const featureDirs = project.directories.filter(d => d.startsWith('features/'));
53
+ for (const featureDir of featureDirs) {
54
+ const hasComponents = project.directories.some(d => d.startsWith(`${featureDir}/components`));
55
+ const hasHooks = project.directories.some(d => d.startsWith(`${featureDir}/hooks`));
56
+ if (!hasComponents || !hasHooks) {
57
+ violations.push({
58
+ id: 'SOC-FEAT-001',
59
+ severity: 'warning',
60
+ message: `Feature ${featureDir} missing components/ or hooks/`,
61
+ rule: 'Feature Structure',
62
+ });
63
+ score -= 5;
64
+ }
65
+ }
66
+ }
67
+ return {
68
+ score: Math.max(0, score),
69
+ maxScore: 100,
70
+ percentage: Math.max(0, score),
71
+ violations,
72
+ };
73
+ }
74
+ }
75
+ //# sourceMappingURL=soc.validator.js.map
@@ -0,0 +1,256 @@
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
@@ -0,0 +1,83 @@
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
@@ -0,0 +1,38 @@
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