@aiready/cli 0.14.14 → 0.14.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CONTRIBUTING.md +86 -1
  2. package/LICENSE +21 -0
  3. package/README.md +152 -52
  4. package/dist/cli.js +73 -12
  5. package/dist/cli.mjs +73 -12
  6. package/package.json +44 -14
  7. package/.aiready/aiready-report-20260227-133806.json +0 -7805
  8. package/.aiready/aiready-report-20260227-133938.json +0 -7951
  9. package/.aiready/aiready-report-20260228-003433.json +0 -7939
  10. package/.aiready/aiready-report-20260228-003613.json +0 -771
  11. package/.aiready/aiready-report-20260314-164626.json +0 -59
  12. package/.aiready/aiready-report-20260314-164741.json +0 -59
  13. package/.aiready/aiready-report-20260319-201106.json +0 -5566
  14. package/.aiready/aiready-report-20260319-201511.json +0 -5566
  15. package/.aiready/aiready-report-20260319-202017.json +0 -5708
  16. package/.github/FUNDING.yml +0 -5
  17. package/.turbo/turbo-build.log +0 -29
  18. package/.turbo/turbo-lint.log +0 -0
  19. package/.turbo/turbo-test.log +0 -76
  20. package/aiready-report.json +0 -30703
  21. package/coverage/base.css +0 -224
  22. package/coverage/block-navigation.js +0 -87
  23. package/coverage/clover.xml +0 -865
  24. package/coverage/coverage-final.json +0 -15
  25. package/coverage/favicon.png +0 -0
  26. package/coverage/index.html +0 -146
  27. package/coverage/prettify.css +0 -1
  28. package/coverage/prettify.js +0 -2
  29. package/coverage/sort-arrow-sprite.png +0 -0
  30. package/coverage/sorter.js +0 -210
  31. package/coverage/src/commands/agent-grounding.ts.html +0 -271
  32. package/coverage/src/commands/ai-signal-clarity.ts.html +0 -253
  33. package/coverage/src/commands/change-amplification.ts.html +0 -94
  34. package/coverage/src/commands/consistency.ts.html +0 -781
  35. package/coverage/src/commands/context.ts.html +0 -871
  36. package/coverage/src/commands/deps-health.ts.html +0 -280
  37. package/coverage/src/commands/doc-drift.ts.html +0 -271
  38. package/coverage/src/commands/index.html +0 -281
  39. package/coverage/src/commands/patterns.ts.html +0 -745
  40. package/coverage/src/commands/scan.ts.html +0 -1393
  41. package/coverage/src/commands/testability.ts.html +0 -304
  42. package/coverage/src/commands/upload.ts.html +0 -466
  43. package/coverage/src/commands/visualize.ts.html +0 -1027
  44. package/coverage/src/index.html +0 -116
  45. package/coverage/src/index.ts.html +0 -1372
  46. package/coverage/src/utils/helpers.ts.html +0 -559
  47. package/coverage/src/utils/index.html +0 -116
  48. package/docs/SPOKE_GUIDE.md +0 -184
  49. package/packages/core/src/.aiready/aiready-report-20260314-161145.json +0 -224
  50. package/packages/core/src/.aiready/aiready-report-20260314-161152.json +0 -235
  51. package/packages/pattern-detect/src/.aiready/aiready-report-20260314-161139.json +0 -224
  52. package/src/.aiready/aiready-report-20260312-103623.json +0 -32574
  53. package/src/.aiready/aiready-report-20260312-110843.json +0 -28740
  54. package/src/.aiready/aiready-report-20260312-110955.json +0 -28740
  55. package/src/.aiready/aiready-report-20260314-203209.json +0 -30713
  56. package/src/.aiready/aiready-report-20260314-203736.json +0 -30713
  57. package/src/.aiready/aiready-report-20260314-203857.json +0 -30713
  58. package/src/.aiready/aiready-report-20260314-204047.json +0 -30713
  59. package/src/.aiready/aiready-report-20260318-002110.json +0 -28782
  60. package/src/__tests__/cli.test.ts +0 -85
  61. package/src/__tests__/config-shape.test.ts +0 -105
  62. package/src/__tests__/unified.test.ts +0 -95
  63. package/src/cli.ts +0 -333
  64. package/src/commands/__tests__/agent-grounding.test.ts +0 -24
  65. package/src/commands/__tests__/ai-signal-clarity.test.ts +0 -32
  66. package/src/commands/__tests__/consistency.test.ts +0 -100
  67. package/src/commands/__tests__/deps-health.test.ts +0 -26
  68. package/src/commands/__tests__/doc-drift.test.ts +0 -26
  69. package/src/commands/__tests__/extra-commands.test.ts +0 -168
  70. package/src/commands/__tests__/init.test.ts +0 -51
  71. package/src/commands/__tests__/scan.test.ts +0 -153
  72. package/src/commands/__tests__/testability.test.ts +0 -36
  73. package/src/commands/__tests__/upload.test.ts +0 -50
  74. package/src/commands/__tests__/visualize.test.ts +0 -78
  75. package/src/commands/agent-grounding.ts +0 -62
  76. package/src/commands/ai-signal-clarity.ts +0 -1
  77. package/src/commands/bug.ts +0 -99
  78. package/src/commands/change-amplification.ts +0 -3
  79. package/src/commands/consistency.ts +0 -232
  80. package/src/commands/context.ts +0 -262
  81. package/src/commands/deps-health.ts +0 -1
  82. package/src/commands/doc-drift.ts +0 -1
  83. package/src/commands/index.ts +0 -20
  84. package/src/commands/init.ts +0 -199
  85. package/src/commands/patterns.ts +0 -222
  86. package/src/commands/report-formatter.ts +0 -267
  87. package/src/commands/scan.ts +0 -432
  88. package/src/commands/shared/configured-tool-action.ts +0 -35
  89. package/src/commands/shared/standard-tool-actions.ts +0 -126
  90. package/src/commands/testability.ts +0 -73
  91. package/src/commands/upload.ts +0 -129
  92. package/src/commands/visualize.ts +0 -321
  93. package/src/index.ts +0 -465
  94. package/src/utils/__tests__/helpers.test.ts +0 -35
  95. package/src/utils/helpers.ts +0 -234
  96. package/tsconfig.json +0 -11
  97. package/tsconfig.tsbuildinfo +0 -1
  98. package/vitest.config.ts +0 -13
@@ -1,199 +0,0 @@
1
- import { writeFileSync, existsSync } from 'fs';
2
- import { join } from 'path';
3
- import chalk from 'chalk';
4
- import { ToolName } from '@aiready/core';
5
-
6
- export async function initAction(options: {
7
- force?: boolean;
8
- format?: 'json' | 'js';
9
- full?: boolean;
10
- }) {
11
- const fileExt = options.format === 'js' ? 'js' : 'json';
12
- const fileName = fileExt === 'js' ? 'aiready.config.js' : 'aiready.json';
13
- const filePath = join(process.cwd(), fileName);
14
-
15
- if (existsSync(filePath) && !options.force) {
16
- console.error(
17
- chalk.red(`Error: ${fileName} already exists. Use --force to overwrite.`)
18
- );
19
- process.exit(1);
20
- }
21
-
22
- const baseConfig = {
23
- $schema: 'https://getaiready.dev/schema.json',
24
-
25
- // Target quality score threshold (0-100)
26
- threshold: 75,
27
-
28
- // Global scan settings
29
- scan: {
30
- include: [
31
- 'src/**/*.ts',
32
- 'src/**/*.js',
33
- 'lib/**/*.ts',
34
- 'packages/*/src/**/*.ts',
35
- ],
36
- exclude: [
37
- '**/node_modules/**',
38
- '**/dist/**',
39
- '**/build/**',
40
- '**/*.test.ts',
41
- '**/*.spec.ts',
42
- ],
43
- tools: [
44
- ToolName.PatternDetect,
45
- ToolName.ContextAnalyzer,
46
- ToolName.NamingConsistency,
47
- ToolName.AiSignalClarity,
48
- ToolName.AgentGrounding,
49
- ToolName.TestabilityIndex,
50
- ToolName.DocDrift,
51
- ToolName.DependencyHealth,
52
- ToolName.ChangeAmplification,
53
- ],
54
- },
55
-
56
- // Output preferences
57
- output: {
58
- format: 'console',
59
- showBreakdown: true,
60
- saveTo: 'aiready-report.json',
61
- },
62
-
63
- // Scoring profile and weights
64
- scoring: {
65
- profile: 'balanced',
66
- },
67
-
68
- // Tool-specific configurations
69
- tools: {
70
- [ToolName.PatternDetect]: {
71
- minSimilarity: 0.8,
72
- minLines: 5,
73
- minSharedTokens: 10,
74
- approx: true,
75
- ...(options.full
76
- ? {
77
- batchSize: 300,
78
- maxCandidatesPerBlock: 500,
79
- minClusterFiles: 3,
80
- minClusterTokenCost: 1000,
81
- }
82
- : {}),
83
- },
84
- [ToolName.ContextAnalyzer]: {
85
- maxContextBudget: 128000,
86
- minCohesion: 0.6,
87
- maxDepth: 7,
88
- maxFragmentation: 0.4,
89
- focus: 'all',
90
- includeNodeModules: false,
91
- },
92
- [ToolName.NamingConsistency]: {
93
- checkNaming: true,
94
- checkPatterns: true,
95
- checkArchitecture: true,
96
- shortWords: ['id', 'db', 'ui', 'ai'],
97
- acceptedAbbreviations: [
98
- 'API',
99
- 'JSON',
100
- 'CSV',
101
- 'HTML',
102
- 'CSS',
103
- 'HTTP',
104
- 'URL',
105
- 'SDK',
106
- 'CLI',
107
- 'AI',
108
- 'ML',
109
- 'ID',
110
- 'DB',
111
- 'UI',
112
- 'UX',
113
- 'DOM',
114
- 'UUID',
115
- 'GUID',
116
- 'DEFAULT',
117
- 'MAX',
118
- 'MIN',
119
- 'config',
120
- 'INIT',
121
- 'SKILL',
122
- 'ENV',
123
- 'DEV',
124
- 'PROD',
125
- 'AWS',
126
- 'S3',
127
- 'ARN',
128
- ],
129
- ...(options.full ? { disableChecks: [] } : {}),
130
- },
131
- [ToolName.AiSignalClarity]: {
132
- checkMagicLiterals: true,
133
- checkBooleanTraps: true,
134
- checkAmbiguousNames: true,
135
- checkUndocumentedExports: true,
136
- checkImplicitSideEffects: true,
137
- checkDeepCallbacks: true,
138
- checkOverloadedSymbols: true,
139
- checkLargeFiles: true,
140
- },
141
- [ToolName.AgentGrounding]: {
142
- maxRecommendedDepth: 5,
143
- readmeStaleDays: 30,
144
- additionalVagueNames: ['stuff', 'misc', 'temp', 'test'],
145
- },
146
- [ToolName.TestabilityIndex]: {
147
- minCoverageRatio: 0.7,
148
- testPatterns: ['**/*.test.ts', '**/__tests__/**', '**/*.spec.ts'],
149
- maxDepth: 10,
150
- },
151
- [ToolName.DocDrift]: {
152
- maxCommits: 50,
153
- staleMonths: 3,
154
- },
155
- [ToolName.DependencyHealth]: {
156
- trainingCutoffYear: 2023,
157
- },
158
- [ToolName.ChangeAmplification]: {
159
- // Change amplification primarily relies on global scan settings
160
- },
161
- },
162
-
163
- // Visualizer settings (interactive graph)
164
- visualizer: {
165
- groupingDirs: ['packages', 'src', 'lib'],
166
- graph: {
167
- maxNodes: 5000,
168
- maxEdges: 10000,
169
- },
170
- },
171
- };
172
-
173
- const defaultConfig = baseConfig;
174
-
175
- let content: string;
176
- if (fileExt === 'js') {
177
- content = `/**
178
- * AIReady Configuration
179
- * @type {import('@aiready/core').AIReadyConfig}
180
- */
181
- module.exports = ${JSON.stringify(defaultConfig, null, 2)};\n`;
182
- } else {
183
- content = JSON.stringify(defaultConfig, null, 2);
184
- }
185
-
186
- try {
187
- writeFileSync(filePath, content, 'utf8');
188
- console.log(
189
- chalk.green(`\n✅ Created default configuration: ${chalk.bold(fileName)}`)
190
- );
191
- console.log(
192
- chalk.cyan('You can now fine-tune your settings and run AIReady with:')
193
- );
194
- console.log(chalk.white(` $ aiready scan\n`));
195
- } catch (error) {
196
- console.error(chalk.red(`Failed to write configuration file: ${error}`));
197
- process.exit(1);
198
- }
199
- }
@@ -1,222 +0,0 @@
1
- /**
2
- * Patterns command - Detect duplicate code patterns that confuse AI models
3
- */
4
-
5
- import chalk from 'chalk';
6
- import { resolve as resolvePath } from 'path';
7
- import {
8
- loadMergedConfig,
9
- handleJSONOutput,
10
- handleCLIError,
11
- getElapsedTime,
12
- resolveOutputPath,
13
- formatToolScore,
14
- } from '@aiready/core';
15
- import type { ToolScoringOutput } from '@aiready/core';
16
- import { getReportTimestamp } from '../utils/helpers';
17
-
18
- interface PatternsOptions {
19
- similarity?: string;
20
- minLines?: string;
21
- maxCandidates?: string;
22
- minSharedTokens?: string;
23
- fullScan?: boolean;
24
- include?: string;
25
- exclude?: string;
26
- output?: string;
27
- outputFile?: string;
28
- score?: boolean;
29
- }
30
-
31
- export async function patternsAction(
32
- directory: string,
33
- options: PatternsOptions
34
- ) {
35
- console.log(chalk.blue('🔍 Analyzing patterns...\n'));
36
-
37
- const startTime = Date.now();
38
- const resolvedDir = resolvePath(process.cwd(), directory ?? '.');
39
-
40
- try {
41
- // Determine if smart defaults should be used
42
- const useSmartDefaults = !options.fullScan;
43
-
44
- // Define defaults (only for options not handled by smart defaults)
45
- const defaults = {
46
- useSmartDefaults,
47
- include: undefined,
48
- exclude: undefined,
49
- output: {
50
- format: 'console',
51
- file: undefined,
52
- },
53
- };
54
-
55
- // Set fallback defaults only if smart defaults are disabled
56
- if (!useSmartDefaults) {
57
- (defaults as any).minSimilarity = 0.4;
58
- (defaults as any).minLines = 5;
59
- }
60
-
61
- // Load and merge config with CLI options
62
- const cliOptions: any = {
63
- minSimilarity: options.similarity
64
- ? parseFloat(options.similarity)
65
- : undefined,
66
- minLines: options.minLines ? parseInt(options.minLines) : undefined,
67
- useSmartDefaults,
68
- include: options.include?.split(','),
69
- exclude: options.exclude?.split(','),
70
- };
71
-
72
- // Only include performance tuning options if explicitly specified
73
- if (options.maxCandidates) {
74
- cliOptions.maxCandidatesPerBlock = parseInt(options.maxCandidates);
75
- }
76
- if (options.minSharedTokens) {
77
- cliOptions.minSharedTokens = parseInt(options.minSharedTokens);
78
- }
79
-
80
- const finalOptions = await loadMergedConfig(
81
- resolvedDir,
82
- defaults,
83
- cliOptions
84
- );
85
-
86
- const { analyzePatterns, generateSummary, calculatePatternScore } =
87
- await import('@aiready/pattern-detect');
88
-
89
- const { results, duplicates } = (await analyzePatterns(
90
- finalOptions
91
- )) as any;
92
-
93
- const elapsedTime = getElapsedTime(startTime);
94
- const summary = generateSummary(results);
95
-
96
- // Calculate score if requested
97
- let patternScore: ToolScoringOutput | undefined;
98
- if (options.score) {
99
- patternScore = calculatePatternScore(duplicates, results.length);
100
- }
101
-
102
- const outputFormat =
103
- options.output ?? finalOptions.output?.format ?? 'console';
104
- const userOutputFile = options.outputFile ?? finalOptions.output?.file;
105
-
106
- if (outputFormat === 'json') {
107
- const outputData = {
108
- results,
109
- summary: { ...summary, executionTime: parseFloat(elapsedTime) },
110
- ...(patternScore && { scoring: patternScore }),
111
- };
112
-
113
- const outputPath = resolveOutputPath(
114
- userOutputFile,
115
- `aiready-report-${getReportTimestamp()}.json`,
116
- resolvedDir
117
- );
118
-
119
- handleJSONOutput(
120
- outputData,
121
- outputPath,
122
- `✅ Results saved to ${outputPath}`
123
- );
124
- } else {
125
- // Console output - format to match standalone CLI
126
- const terminalWidth = process.stdout.columns || 80;
127
- const dividerWidth = Math.min(60, terminalWidth - 2);
128
- const divider = '━'.repeat(dividerWidth);
129
-
130
- console.log(chalk.cyan(divider));
131
- console.log(chalk.bold.white(' PATTERN ANALYSIS SUMMARY'));
132
- console.log(chalk.cyan(divider) + '\n');
133
-
134
- console.log(
135
- chalk.white(`📁 Files analyzed: ${chalk.bold(results.length)}`)
136
- );
137
- console.log(
138
- chalk.yellow(
139
- `⚠ Duplicate patterns found: ${chalk.bold(summary.totalPatterns)}`
140
- )
141
- );
142
- console.log(
143
- chalk.red(
144
- `💰 Token cost (wasted): ${chalk.bold(summary.totalTokenCost.toLocaleString())}`
145
- )
146
- );
147
- console.log(
148
- chalk.gray(`⏱ Analysis time: ${chalk.bold(elapsedTime + 's')}`)
149
- );
150
-
151
- // Show breakdown by pattern type
152
- const sortedTypes = Object.entries(summary.patternsByType || {})
153
- .filter(([, count]) => count > 0)
154
- .sort(([, a], [, b]) => (b as number) - (a as number));
155
-
156
- if (sortedTypes.length > 0) {
157
- console.log(chalk.cyan('\n' + divider));
158
- console.log(chalk.bold.white(' PATTERNS BY TYPE'));
159
- console.log(chalk.cyan(divider) + '\n');
160
- sortedTypes.forEach(([type, count]) => {
161
- console.log(` ${chalk.white(type.padEnd(15))} ${chalk.bold(count)}`);
162
- });
163
- }
164
-
165
- // Show top duplicates
166
- if (summary.totalPatterns > 0 && duplicates.length > 0) {
167
- console.log(chalk.cyan('\n' + divider));
168
- console.log(chalk.bold.white(' TOP DUPLICATE PATTERNS'));
169
- console.log(chalk.cyan(divider) + '\n');
170
-
171
- // Sort by similarity and take top 10
172
- const topDuplicates = [...duplicates]
173
- .sort((a, b) => b.similarity - a.similarity)
174
- .slice(0, 10);
175
-
176
- topDuplicates.forEach((dup) => {
177
- const severity =
178
- dup.similarity > 0.95
179
- ? 'CRITICAL'
180
- : dup.similarity > 0.9
181
- ? 'HIGH'
182
- : 'MEDIUM';
183
- const severityIcon =
184
- dup.similarity > 0.95 ? '🔴' : dup.similarity > 0.9 ? '🟡' : '🔵';
185
- const file1Name = dup.file1.split('/').pop() || dup.file1;
186
- const file2Name = dup.file2.split('/').pop() || dup.file2;
187
- console.log(
188
- `${severityIcon} ${severity}: ${chalk.bold(file1Name)} ↔ ${chalk.bold(file2Name)}`
189
- );
190
- console.log(
191
- ` Similarity: ${chalk.bold(Math.round(dup.similarity * 100) + '%')} | Wasted: ${chalk.bold(dup.tokenCost.toLocaleString())} tokens each`
192
- );
193
- console.log(
194
- ` Lines: ${chalk.cyan(dup.line1 + '-' + dup.endLine1)} ↔ ${chalk.cyan(dup.line2 + '-' + dup.endLine2)}\n`
195
- );
196
- });
197
- } else {
198
- console.log(
199
- chalk.green('\n✨ Great! No duplicate patterns detected.\n')
200
- );
201
- }
202
-
203
- // Display score if calculated
204
- if (patternScore) {
205
- console.log(chalk.cyan(divider));
206
- console.log(chalk.bold.white(' AI READINESS SCORE (Patterns)'));
207
- console.log(chalk.cyan(divider) + '\n');
208
- console.log(formatToolScore(patternScore));
209
- console.log();
210
- }
211
- }
212
- } catch (error) {
213
- handleCLIError(error, 'Pattern analysis');
214
- }
215
- }
216
-
217
- export const patternsHelpText = `
218
- EXAMPLES:
219
- $ aiready patterns # Default analysis
220
- $ aiready patterns --similarity 0.6 # Stricter matching
221
- $ aiready patterns --min-lines 10 # Larger patterns only
222
- `;
@@ -1,267 +0,0 @@
1
- import chalk from 'chalk';
2
- import {
3
- Severity,
4
- ScoringResult,
5
- formatScore,
6
- getRating,
7
- getRatingDisplay,
8
- } from '@aiready/core';
9
-
10
- /**
11
- * Generate a visual progress bar for a score.
12
- *
13
- * @param score - The score value (0-100)
14
- * @param width - The width of the progress bar
15
- * @returns A colored progress bar string
16
- */
17
- function generateProgressBar(score: number, width: number = 20): string {
18
- const filled = Math.round((score / 100) * width);
19
- const empty = width - filled;
20
-
21
- let color = chalk.red;
22
- if (score >= 90) color = chalk.green;
23
- else if (score >= 75) color = chalk.cyan;
24
- else if (score >= 60) color = chalk.yellow;
25
-
26
- const bar = '█'.repeat(filled) + '░'.repeat(empty);
27
- return color(bar);
28
- }
29
-
30
- /**
31
- * Count issues by severity level from all tool results.
32
- *
33
- * @param results - The unified results object
34
- * @returns Object with counts for each severity level
35
- */
36
- function countIssuesBySeverity(results: any): {
37
- critical: number;
38
- major: number;
39
- minor: number;
40
- } {
41
- let critical = 0;
42
- let major = 0;
43
- let minor = 0;
44
-
45
- if (results.summary?.toolsRun) {
46
- for (const toolId of results.summary.toolsRun) {
47
- const toolRes = results[toolId];
48
- if (toolRes?.results) {
49
- for (const fileRes of toolRes.results) {
50
- if (fileRes.issues) {
51
- for (const issue of fileRes.issues) {
52
- const sev = issue.severity?.toLowerCase();
53
- if (sev === 'critical') critical++;
54
- else if (sev === 'major') major++;
55
- else minor++;
56
- }
57
- }
58
- }
59
- }
60
- }
61
- }
62
-
63
- return { critical, major, minor };
64
- }
65
-
66
- /**
67
- * Get top files with most issues.
68
- *
69
- * @param results - The unified results object
70
- * @param limit - Maximum number of files to return
71
- * @returns Array of files with issue counts
72
- */
73
- function getTopFilesWithIssues(
74
- results: any,
75
- limit: number = 5
76
- ): Array<{ file: string; count: number }> {
77
- const fileCounts = new Map<string, number>();
78
-
79
- if (results.summary?.toolsRun) {
80
- for (const toolId of results.summary.toolsRun) {
81
- const toolRes = results[toolId];
82
- if (toolRes?.results) {
83
- for (const fileRes of toolRes.results) {
84
- if (fileRes.issues?.length > 0) {
85
- const current = fileCounts.get(fileRes.fileName) || 0;
86
- fileCounts.set(fileRes.fileName, current + fileRes.issues.length);
87
- }
88
- }
89
- }
90
- }
91
- }
92
-
93
- return Array.from(fileCounts.entries())
94
- .map(([file, count]) => ({ file, count }))
95
- .sort((a, b) => b.count - a.count)
96
- .slice(0, limit);
97
- }
98
-
99
- /**
100
- * Handle console output for the scan results.
101
- *
102
- * @param results - The combined results from all tools.
103
- * @param startTime - The timestamp when the scan started.
104
- */
105
- export function printScanSummary(results: any, startTime: number) {
106
- // Count issues by severity
107
- const severity = countIssuesBySeverity(results);
108
- const totalIssues = severity.critical + severity.major + severity.minor;
109
-
110
- // Get top files with issues
111
- const topFiles = getTopFilesWithIssues(results);
112
-
113
- console.log(chalk.cyan('\n=== AIReady Run Summary ==='));
114
- console.log(` Total issues: ${chalk.bold(String(totalIssues))}`);
115
-
116
- // Severity breakdown
117
- if (totalIssues > 0) {
118
- console.log(chalk.dim(' Severity breakdown:'));
119
- if (severity.critical > 0) {
120
- console.log(
121
- ` ${chalk.red('●')} Critical: ${chalk.bold(severity.critical)}`
122
- );
123
- }
124
- if (severity.major > 0) {
125
- console.log(
126
- ` ${chalk.yellow('●')} Major: ${chalk.bold(severity.major)}`
127
- );
128
- }
129
- if (severity.minor > 0) {
130
- console.log(
131
- ` ${chalk.blue('●')} Minor: ${chalk.bold(severity.minor)}`
132
- );
133
- }
134
- }
135
-
136
- // Top files with issues
137
- if (topFiles.length > 0) {
138
- console.log(chalk.dim('\n Top files with issues:'));
139
- topFiles.forEach((item) => {
140
- console.log(
141
- ` ${chalk.yellow('→')} ${item.file}: ${chalk.bold(item.count)} issues`
142
- );
143
- });
144
- }
145
-
146
- console.log(
147
- `\n Execution time: ${chalk.bold(((Date.now() - startTime) / 1000).toFixed(2) + 's')}`
148
- );
149
- }
150
-
151
- /**
152
- * Print business impact analysis based on ROI and budget metrics.
153
- *
154
- * @param roi - Calculated Return on Investment metrics.
155
- * @param unifiedBudget - Consolidated context budget metrics.
156
- */
157
- export function printBusinessImpact(roi: any, unifiedBudget: any) {
158
- console.log(chalk.bold('\n💰 Business Impact Analysis (Monthly)'));
159
- console.log(
160
- ` Potential Savings: ${chalk.green(chalk.bold('$' + roi.monthlySavings.toLocaleString()))}`
161
- );
162
- console.log(
163
- ` Productivity Gain: ${chalk.cyan(chalk.bold(roi.productivityGainHours + 'h'))} (est. dev time)`
164
- );
165
- console.log(
166
- ` Context Efficiency: ${chalk.yellow((unifiedBudget.efficiencyRatio * 100).toFixed(0) + '%')}`
167
- );
168
- console.log(
169
- ` Annual Value: ${chalk.bold('$' + roi.annualValue.toLocaleString())} (ROI Prediction)`
170
- );
171
- }
172
-
173
- /**
174
- * Print detailed scoring breakdown by tool.
175
- *
176
- * @param scoringResult - The overall scoring result.
177
- * @param scoringProfile - The name of the scoring profile used.
178
- */
179
- export function printScoring(
180
- scoringResult: ScoringResult,
181
- scoringProfile: string
182
- ) {
183
- console.log(chalk.bold('\n📊 AI Readiness Overall Score'));
184
- console.log(` ${formatScore(scoringResult)}`);
185
- console.log(chalk.dim(` (Scoring Profile: ${scoringProfile})`));
186
-
187
- if (scoringResult.breakdown) {
188
- console.log(chalk.bold('\nTool breakdown:'));
189
- scoringResult.breakdown.forEach((tool: any) => {
190
- const rating = getRating(tool.score);
191
- const emoji = getRatingDisplay(rating).emoji;
192
- const progressBar = generateProgressBar(tool.score, 15);
193
- console.log(
194
- ` ${progressBar} ${tool.score}/100 (${rating}) ${emoji} ${tool.toolName}`
195
- );
196
- });
197
-
198
- // Top Actionable Recommendations - increased from 3 to 5
199
- const allRecs = scoringResult.breakdown
200
- .flatMap((t: any) =>
201
- (t.recommendations ?? []).map((r: any) => ({ ...r, tool: t.toolName }))
202
- )
203
- .sort((a: any, b: any) => b.estimatedImpact - a.estimatedImpact)
204
- .slice(0, 5); // Increased from 3 to 5
205
-
206
- if (allRecs.length > 0) {
207
- console.log(chalk.bold('\n🎯 Top Actionable Recommendations:'));
208
- allRecs.forEach((rec: any, i: number) => {
209
- const priorityIcon =
210
- rec.priority === 'high'
211
- ? '🔴'
212
- : rec.priority === 'medium'
213
- ? '🟡'
214
- : '🔵';
215
- console.log(` ${i + 1}. ${priorityIcon} ${chalk.bold(rec.action)}`);
216
- console.log(
217
- ` Impact: ${chalk.green(`+${rec.estimatedImpact} points`)} to ${rec.tool}`
218
- );
219
- });
220
- }
221
- }
222
- }
223
-
224
- /**
225
- * Normalize and map tool-specific results to a unified report structure.
226
- *
227
- * @param res - Raw unified results object.
228
- * @param scoring - Optional scoring result to include.
229
- * @returns Enhanced report with totals and scoring.
230
- */
231
- export function mapToUnifiedReport(
232
- res: any,
233
- scoring: ScoringResult | undefined
234
- ) {
235
- const allResults: any[] = [];
236
- const totalFilesSet = new Set<string>();
237
- let criticalCount = 0;
238
- let majorCount = 0;
239
-
240
- res.summary.toolsRun.forEach((toolId: string) => {
241
- const spokeRes = res[toolId];
242
- if (!spokeRes || !spokeRes.results) return;
243
-
244
- spokeRes.results.forEach((r: any) => {
245
- totalFilesSet.add(r.fileName);
246
- allResults.push(r);
247
- r.issues?.forEach((i: any) => {
248
- if (i.severity === Severity.Critical || i.severity === 'critical')
249
- criticalCount++;
250
- if (i.severity === Severity.Major || i.severity === 'major')
251
- majorCount++;
252
- });
253
- });
254
- });
255
-
256
- return {
257
- ...res,
258
- results: allResults,
259
- summary: {
260
- ...res.summary,
261
- totalFiles: totalFilesSet.size,
262
- criticalIssues: criticalCount,
263
- majorIssues: majorCount,
264
- },
265
- scoring,
266
- };
267
- }