@aiready/core 0.9.23 → 0.9.25
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/client.d.mts +91 -1
- package/dist/client.d.ts +91 -1
- package/dist/index.d.mts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/index.js +204 -0
- package/dist/index.mjs +187 -1
- package/package.json +2 -1
package/dist/client.d.mts
CHANGED
|
@@ -23,6 +23,96 @@ interface Metrics {
|
|
|
23
23
|
complexityScore?: number;
|
|
24
24
|
consistencyScore?: number;
|
|
25
25
|
docFreshnessScore?: number;
|
|
26
|
+
estimatedMonthlyCost?: number;
|
|
27
|
+
estimatedDeveloperHours?: number;
|
|
28
|
+
comprehensionDifficultyIndex?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Cost estimation configuration
|
|
32
|
+
*/
|
|
33
|
+
interface CostConfig {
|
|
34
|
+
/** Price per 1K tokens (default: $0.01 for GPT-4) */
|
|
35
|
+
pricePer1KTokens: number;
|
|
36
|
+
/** Average AI queries per developer per day */
|
|
37
|
+
queriesPerDevPerDay: number;
|
|
38
|
+
/** Number of developers on the team */
|
|
39
|
+
developerCount: number;
|
|
40
|
+
/** Days per month (default: 30) */
|
|
41
|
+
daysPerMonth: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Productivity impact estimates
|
|
45
|
+
*/
|
|
46
|
+
interface ProductivityImpact {
|
|
47
|
+
/** Estimated hours to fix all issues */
|
|
48
|
+
totalHours: number;
|
|
49
|
+
/** Average hourly rate for developers */
|
|
50
|
+
hourlyRate: number;
|
|
51
|
+
/** Estimated total fix cost */
|
|
52
|
+
totalCost: number;
|
|
53
|
+
/** Breakdown by severity */
|
|
54
|
+
bySeverity: {
|
|
55
|
+
critical: {
|
|
56
|
+
hours: number;
|
|
57
|
+
cost: number;
|
|
58
|
+
};
|
|
59
|
+
major: {
|
|
60
|
+
hours: number;
|
|
61
|
+
cost: number;
|
|
62
|
+
};
|
|
63
|
+
minor: {
|
|
64
|
+
hours: number;
|
|
65
|
+
cost: number;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* AI acceptance rate prediction
|
|
71
|
+
* Based on research correlating code quality to AI suggestion acceptance
|
|
72
|
+
*/
|
|
73
|
+
interface AcceptancePrediction {
|
|
74
|
+
/** Predicted acceptance rate (0-1) */
|
|
75
|
+
rate: number;
|
|
76
|
+
/** Confidence level (0-1) */
|
|
77
|
+
confidence: number;
|
|
78
|
+
/** Factors affecting acceptance */
|
|
79
|
+
factors: {
|
|
80
|
+
name: string;
|
|
81
|
+
impact: number;
|
|
82
|
+
}[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Comprehension difficulty score (future-proof abstraction)
|
|
86
|
+
* Normalized 0-100 scale: lower = easier for AI to understand
|
|
87
|
+
*/
|
|
88
|
+
interface ComprehensionDifficulty {
|
|
89
|
+
/** Overall difficulty score (0-100) */
|
|
90
|
+
score: number;
|
|
91
|
+
/** Factors contributing to difficulty */
|
|
92
|
+
factors: {
|
|
93
|
+
name: string;
|
|
94
|
+
contribution: number;
|
|
95
|
+
description: string;
|
|
96
|
+
}[];
|
|
97
|
+
/** Interpretation */
|
|
98
|
+
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Extended report with business metrics
|
|
102
|
+
*/
|
|
103
|
+
interface BusinessReport extends Report {
|
|
104
|
+
businessMetrics: {
|
|
105
|
+
/** Estimated monthly cost impact of AI context waste */
|
|
106
|
+
estimatedMonthlyCost: number;
|
|
107
|
+
/** Estimated developer hours to address issues */
|
|
108
|
+
estimatedDeveloperHours: number;
|
|
109
|
+
/** Predicted AI suggestion acceptance rate */
|
|
110
|
+
aiAcceptanceRate: number;
|
|
111
|
+
/** Comprehension difficulty assessment */
|
|
112
|
+
comprehensionDifficulty: ComprehensionDifficulty;
|
|
113
|
+
/** Timestamp for trend tracking */
|
|
114
|
+
period?: string;
|
|
115
|
+
};
|
|
26
116
|
}
|
|
27
117
|
interface ScanOptions {
|
|
28
118
|
rootDir: string;
|
|
@@ -454,4 +544,4 @@ declare function formatToolScore(output: ToolScoringOutput): string;
|
|
|
454
544
|
*/
|
|
455
545
|
declare function generateHTML(graph: GraphData): string;
|
|
456
546
|
|
|
457
|
-
export { type AIReadyConfig, type AnalysisResult, type CommonASTNode, DEFAULT_TOOL_WEIGHTS, type ExportInfo, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, type IssueType, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, type Metrics, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type Report, type ScanOptions, type ScoringConfig, type ScoringResult, type SourceLocation, type SourceRange, TOOL_NAME_MAP, type ToolScoringOutput, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString };
|
|
547
|
+
export { type AIReadyConfig, type AcceptancePrediction, type AnalysisResult, type BusinessReport, type CommonASTNode, type ComprehensionDifficulty, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, type IssueType, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, type Metrics, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type ProductivityImpact, type Report, type ScanOptions, type ScoringConfig, type ScoringResult, type SourceLocation, type SourceRange, TOOL_NAME_MAP, type ToolScoringOutput, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString };
|
package/dist/client.d.ts
CHANGED
|
@@ -23,6 +23,96 @@ interface Metrics {
|
|
|
23
23
|
complexityScore?: number;
|
|
24
24
|
consistencyScore?: number;
|
|
25
25
|
docFreshnessScore?: number;
|
|
26
|
+
estimatedMonthlyCost?: number;
|
|
27
|
+
estimatedDeveloperHours?: number;
|
|
28
|
+
comprehensionDifficultyIndex?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Cost estimation configuration
|
|
32
|
+
*/
|
|
33
|
+
interface CostConfig {
|
|
34
|
+
/** Price per 1K tokens (default: $0.01 for GPT-4) */
|
|
35
|
+
pricePer1KTokens: number;
|
|
36
|
+
/** Average AI queries per developer per day */
|
|
37
|
+
queriesPerDevPerDay: number;
|
|
38
|
+
/** Number of developers on the team */
|
|
39
|
+
developerCount: number;
|
|
40
|
+
/** Days per month (default: 30) */
|
|
41
|
+
daysPerMonth: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Productivity impact estimates
|
|
45
|
+
*/
|
|
46
|
+
interface ProductivityImpact {
|
|
47
|
+
/** Estimated hours to fix all issues */
|
|
48
|
+
totalHours: number;
|
|
49
|
+
/** Average hourly rate for developers */
|
|
50
|
+
hourlyRate: number;
|
|
51
|
+
/** Estimated total fix cost */
|
|
52
|
+
totalCost: number;
|
|
53
|
+
/** Breakdown by severity */
|
|
54
|
+
bySeverity: {
|
|
55
|
+
critical: {
|
|
56
|
+
hours: number;
|
|
57
|
+
cost: number;
|
|
58
|
+
};
|
|
59
|
+
major: {
|
|
60
|
+
hours: number;
|
|
61
|
+
cost: number;
|
|
62
|
+
};
|
|
63
|
+
minor: {
|
|
64
|
+
hours: number;
|
|
65
|
+
cost: number;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* AI acceptance rate prediction
|
|
71
|
+
* Based on research correlating code quality to AI suggestion acceptance
|
|
72
|
+
*/
|
|
73
|
+
interface AcceptancePrediction {
|
|
74
|
+
/** Predicted acceptance rate (0-1) */
|
|
75
|
+
rate: number;
|
|
76
|
+
/** Confidence level (0-1) */
|
|
77
|
+
confidence: number;
|
|
78
|
+
/** Factors affecting acceptance */
|
|
79
|
+
factors: {
|
|
80
|
+
name: string;
|
|
81
|
+
impact: number;
|
|
82
|
+
}[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Comprehension difficulty score (future-proof abstraction)
|
|
86
|
+
* Normalized 0-100 scale: lower = easier for AI to understand
|
|
87
|
+
*/
|
|
88
|
+
interface ComprehensionDifficulty {
|
|
89
|
+
/** Overall difficulty score (0-100) */
|
|
90
|
+
score: number;
|
|
91
|
+
/** Factors contributing to difficulty */
|
|
92
|
+
factors: {
|
|
93
|
+
name: string;
|
|
94
|
+
contribution: number;
|
|
95
|
+
description: string;
|
|
96
|
+
}[];
|
|
97
|
+
/** Interpretation */
|
|
98
|
+
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Extended report with business metrics
|
|
102
|
+
*/
|
|
103
|
+
interface BusinessReport extends Report {
|
|
104
|
+
businessMetrics: {
|
|
105
|
+
/** Estimated monthly cost impact of AI context waste */
|
|
106
|
+
estimatedMonthlyCost: number;
|
|
107
|
+
/** Estimated developer hours to address issues */
|
|
108
|
+
estimatedDeveloperHours: number;
|
|
109
|
+
/** Predicted AI suggestion acceptance rate */
|
|
110
|
+
aiAcceptanceRate: number;
|
|
111
|
+
/** Comprehension difficulty assessment */
|
|
112
|
+
comprehensionDifficulty: ComprehensionDifficulty;
|
|
113
|
+
/** Timestamp for trend tracking */
|
|
114
|
+
period?: string;
|
|
115
|
+
};
|
|
26
116
|
}
|
|
27
117
|
interface ScanOptions {
|
|
28
118
|
rootDir: string;
|
|
@@ -454,4 +544,4 @@ declare function formatToolScore(output: ToolScoringOutput): string;
|
|
|
454
544
|
*/
|
|
455
545
|
declare function generateHTML(graph: GraphData): string;
|
|
456
546
|
|
|
457
|
-
export { type AIReadyConfig, type AnalysisResult, type CommonASTNode, DEFAULT_TOOL_WEIGHTS, type ExportInfo, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, type IssueType, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, type Metrics, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type Report, type ScanOptions, type ScoringConfig, type ScoringResult, type SourceLocation, type SourceRange, TOOL_NAME_MAP, type ToolScoringOutput, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString };
|
|
547
|
+
export { type AIReadyConfig, type AcceptancePrediction, type AnalysisResult, type BusinessReport, type CommonASTNode, type ComprehensionDifficulty, type CostConfig, DEFAULT_TOOL_WEIGHTS, type ExportInfo, type GraphData, type GraphEdge, type GraphIssueSeverity, type GraphMetadata, type GraphNode, type ImportInfo, type Issue, type IssueType, LANGUAGE_EXTENSIONS, Language, type LanguageConfig, type LanguageParser, type Location, type Metrics, type NamingConvention, ParseError, type ParseResult, type ParseStatistics, type ProductivityImpact, type Report, type ScanOptions, type ScoringConfig, type ScoringResult, type SourceLocation, type SourceRange, TOOL_NAME_MAP, type ToolScoringOutput, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScanOptions, AIReadyConfig, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
|
|
2
|
-
export { AnalysisResult, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP,
|
|
1
|
+
import { ScanOptions, AIReadyConfig, CostConfig, ComprehensionDifficulty, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
|
|
2
|
+
export { AnalysisResult, BusinessReport, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString } from './client.mjs';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_EXCLUDE: string[];
|
|
5
5
|
/**
|
|
@@ -112,6 +112,59 @@ declare function handleCLIError(error: unknown, commandName: string): never;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function getElapsedTime(startTime: number): string;
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Business Value Metrics Module
|
|
117
|
+
*
|
|
118
|
+
* Provides business-aligned metrics that quantify ROI and survive technology changes.
|
|
119
|
+
* These metrics connect technical measurements to developer productivity and cost impact.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Default cost configuration
|
|
124
|
+
* Based on GPT-4 pricing and typical team usage
|
|
125
|
+
*/
|
|
126
|
+
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Calculate estimated monthly cost of AI context waste
|
|
129
|
+
*
|
|
130
|
+
* Formula: (tokenWaste / 1000) × pricePer1K × queriesPerDev × devCount × days
|
|
131
|
+
*/
|
|
132
|
+
declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): number;
|
|
133
|
+
/**
|
|
134
|
+
* Calculate productivity impact from issues
|
|
135
|
+
*/
|
|
136
|
+
declare function calculateProductivityImpact(issues: {
|
|
137
|
+
severity: string;
|
|
138
|
+
}[], hourlyRate?: number): ProductivityImpact;
|
|
139
|
+
/**
|
|
140
|
+
* Predict AI suggestion acceptance rate based on code quality
|
|
141
|
+
*
|
|
142
|
+
* Research shows:
|
|
143
|
+
* - High consistency correlates with 30%+ higher acceptance
|
|
144
|
+
* - Low context budget improves understanding by ~40%
|
|
145
|
+
* - Good naming patterns reduce clarification needs by 50%
|
|
146
|
+
*/
|
|
147
|
+
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
148
|
+
/**
|
|
149
|
+
* Calculate Comprehension Difficulty Index
|
|
150
|
+
*
|
|
151
|
+
* A future-proof abstraction that normalizes multiple factors
|
|
152
|
+
* into a single difficulty score. Lower = easier for AI.
|
|
153
|
+
*/
|
|
154
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, consistencyScore: number, totalFiles: number): ComprehensionDifficulty;
|
|
155
|
+
/**
|
|
156
|
+
* Format cost for display
|
|
157
|
+
*/
|
|
158
|
+
declare function formatCost(cost: number): string;
|
|
159
|
+
/**
|
|
160
|
+
* Format hours for display
|
|
161
|
+
*/
|
|
162
|
+
declare function formatHours(hours: number): string;
|
|
163
|
+
/**
|
|
164
|
+
* Format acceptance rate for display
|
|
165
|
+
*/
|
|
166
|
+
declare function formatAcceptanceRate(rate: number): string;
|
|
167
|
+
|
|
115
168
|
/**
|
|
116
169
|
* Parser Factory - Manages language-specific parsers
|
|
117
170
|
*
|
|
@@ -240,4 +293,4 @@ declare class PythonParser implements LanguageParser {
|
|
|
240
293
|
private extractExportsRegex;
|
|
241
294
|
}
|
|
242
295
|
|
|
243
|
-
export { AIReadyConfig, type ASTNode, type CLIOptions, DEFAULT_EXCLUDE, type ExportWithImports, type FileImport, Language, LanguageParser, NamingConvention, ParseResult, ParserFactory, PythonParser, ScanOptions, TypeScriptParser, calculateImportSimilarity, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, parseFileExports, readFileContent, resolveOutputPath, scanFiles };
|
|
296
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type CLIOptions, ComprehensionDifficulty, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type ExportWithImports, type FileImport, Language, LanguageParser, NamingConvention, ParseResult, ParserFactory, ProductivityImpact, PythonParser, ScanOptions, ToolScoringOutput, TypeScriptParser, calculateComprehensionDifficulty, calculateImportSimilarity, calculateMonthlyCost, calculateProductivityImpact, estimateTokens, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getElapsedTime, getFileExtension, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, scanFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScanOptions, AIReadyConfig, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
|
|
2
|
-
export { AnalysisResult, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP,
|
|
1
|
+
import { ScanOptions, AIReadyConfig, CostConfig, ComprehensionDifficulty, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.js';
|
|
2
|
+
export { AnalysisResult, BusinessReport, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP, calculateOverallScore, formatScore, formatToolScore, generateHTML, getRating, getRatingDisplay, getToolWeight, normalizeToolName, parseWeightString } from './client.js';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_EXCLUDE: string[];
|
|
5
5
|
/**
|
|
@@ -112,6 +112,59 @@ declare function handleCLIError(error: unknown, commandName: string): never;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function getElapsedTime(startTime: number): string;
|
|
114
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Business Value Metrics Module
|
|
117
|
+
*
|
|
118
|
+
* Provides business-aligned metrics that quantify ROI and survive technology changes.
|
|
119
|
+
* These metrics connect technical measurements to developer productivity and cost impact.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Default cost configuration
|
|
124
|
+
* Based on GPT-4 pricing and typical team usage
|
|
125
|
+
*/
|
|
126
|
+
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Calculate estimated monthly cost of AI context waste
|
|
129
|
+
*
|
|
130
|
+
* Formula: (tokenWaste / 1000) × pricePer1K × queriesPerDev × devCount × days
|
|
131
|
+
*/
|
|
132
|
+
declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): number;
|
|
133
|
+
/**
|
|
134
|
+
* Calculate productivity impact from issues
|
|
135
|
+
*/
|
|
136
|
+
declare function calculateProductivityImpact(issues: {
|
|
137
|
+
severity: string;
|
|
138
|
+
}[], hourlyRate?: number): ProductivityImpact;
|
|
139
|
+
/**
|
|
140
|
+
* Predict AI suggestion acceptance rate based on code quality
|
|
141
|
+
*
|
|
142
|
+
* Research shows:
|
|
143
|
+
* - High consistency correlates with 30%+ higher acceptance
|
|
144
|
+
* - Low context budget improves understanding by ~40%
|
|
145
|
+
* - Good naming patterns reduce clarification needs by 50%
|
|
146
|
+
*/
|
|
147
|
+
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
148
|
+
/**
|
|
149
|
+
* Calculate Comprehension Difficulty Index
|
|
150
|
+
*
|
|
151
|
+
* A future-proof abstraction that normalizes multiple factors
|
|
152
|
+
* into a single difficulty score. Lower = easier for AI.
|
|
153
|
+
*/
|
|
154
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, consistencyScore: number, totalFiles: number): ComprehensionDifficulty;
|
|
155
|
+
/**
|
|
156
|
+
* Format cost for display
|
|
157
|
+
*/
|
|
158
|
+
declare function formatCost(cost: number): string;
|
|
159
|
+
/**
|
|
160
|
+
* Format hours for display
|
|
161
|
+
*/
|
|
162
|
+
declare function formatHours(hours: number): string;
|
|
163
|
+
/**
|
|
164
|
+
* Format acceptance rate for display
|
|
165
|
+
*/
|
|
166
|
+
declare function formatAcceptanceRate(rate: number): string;
|
|
167
|
+
|
|
115
168
|
/**
|
|
116
169
|
* Parser Factory - Manages language-specific parsers
|
|
117
170
|
*
|
|
@@ -240,4 +293,4 @@ declare class PythonParser implements LanguageParser {
|
|
|
240
293
|
private extractExportsRegex;
|
|
241
294
|
}
|
|
242
295
|
|
|
243
|
-
export { AIReadyConfig, type ASTNode, type CLIOptions, DEFAULT_EXCLUDE, type ExportWithImports, type FileImport, Language, LanguageParser, NamingConvention, ParseResult, ParserFactory, PythonParser, ScanOptions, TypeScriptParser, calculateImportSimilarity, estimateTokens, extractFunctions, extractImports, getElapsedTime, getFileExtension, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, parseFileExports, readFileContent, resolveOutputPath, scanFiles };
|
|
296
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type CLIOptions, ComprehensionDifficulty, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type ExportWithImports, type FileImport, Language, LanguageParser, NamingConvention, ParseResult, ParserFactory, ProductivityImpact, PythonParser, ScanOptions, ToolScoringOutput, TypeScriptParser, calculateComprehensionDifficulty, calculateImportSimilarity, calculateMonthlyCost, calculateProductivityImpact, estimateTokens, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getElapsedTime, getFileExtension, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, scanFiles };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,11 +17,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
33
|
+
DEFAULT_COST_CONFIG: () => DEFAULT_COST_CONFIG,
|
|
23
34
|
DEFAULT_EXCLUDE: () => DEFAULT_EXCLUDE,
|
|
24
35
|
DEFAULT_TOOL_WEIGHTS: () => DEFAULT_TOOL_WEIGHTS,
|
|
25
36
|
LANGUAGE_EXTENSIONS: () => LANGUAGE_EXTENSIONS,
|
|
@@ -29,11 +40,17 @@ __export(index_exports, {
|
|
|
29
40
|
PythonParser: () => PythonParser,
|
|
30
41
|
TOOL_NAME_MAP: () => TOOL_NAME_MAP,
|
|
31
42
|
TypeScriptParser: () => TypeScriptParser,
|
|
43
|
+
calculateComprehensionDifficulty: () => calculateComprehensionDifficulty,
|
|
32
44
|
calculateImportSimilarity: () => calculateImportSimilarity,
|
|
45
|
+
calculateMonthlyCost: () => calculateMonthlyCost,
|
|
33
46
|
calculateOverallScore: () => calculateOverallScore,
|
|
47
|
+
calculateProductivityImpact: () => calculateProductivityImpact,
|
|
34
48
|
estimateTokens: () => estimateTokens,
|
|
35
49
|
extractFunctions: () => extractFunctions,
|
|
36
50
|
extractImports: () => extractImports,
|
|
51
|
+
formatAcceptanceRate: () => formatAcceptanceRate,
|
|
52
|
+
formatCost: () => formatCost,
|
|
53
|
+
formatHours: () => formatHours,
|
|
37
54
|
formatScore: () => formatScore,
|
|
38
55
|
formatToolScore: () => formatToolScore,
|
|
39
56
|
generateHTML: () => generateHTML,
|
|
@@ -55,6 +72,7 @@ __export(index_exports, {
|
|
|
55
72
|
parseCode: () => parseCode,
|
|
56
73
|
parseFileExports: () => parseFileExports,
|
|
57
74
|
parseWeightString: () => parseWeightString,
|
|
75
|
+
predictAcceptanceRate: () => predictAcceptanceRate,
|
|
58
76
|
readFileContent: () => readFileContent,
|
|
59
77
|
resolveOutputPath: () => resolveOutputPath,
|
|
60
78
|
scanFiles: () => scanFiles
|
|
@@ -97,6 +115,7 @@ var import_glob = require("glob");
|
|
|
97
115
|
var import_promises = require("fs/promises");
|
|
98
116
|
var import_fs = require("fs");
|
|
99
117
|
var import_path = require("path");
|
|
118
|
+
var import_ignore = __toESM(require("ignore"));
|
|
100
119
|
var DEFAULT_EXCLUDE = [
|
|
101
120
|
// Dependencies
|
|
102
121
|
"**/node_modules/**",
|
|
@@ -165,6 +184,22 @@ async function scanFiles(options) {
|
|
|
165
184
|
ignore: finalExclude,
|
|
166
185
|
absolute: true
|
|
167
186
|
});
|
|
187
|
+
const gitignorePath = (0, import_path.join)(rootDir || ".", ".gitignore");
|
|
188
|
+
if ((0, import_fs.existsSync)(gitignorePath)) {
|
|
189
|
+
try {
|
|
190
|
+
const gitTxt = await (0, import_promises.readFile)(gitignorePath, "utf-8");
|
|
191
|
+
const ig = (0, import_ignore.default)();
|
|
192
|
+
ig.add(gitTxt);
|
|
193
|
+
const filtered = files.filter((f) => {
|
|
194
|
+
let rel = (0, import_path.relative)(rootDir || ".", f).replace(/\\/g, "/");
|
|
195
|
+
if (rel === "") rel = f;
|
|
196
|
+
return !ig.ignores(rel);
|
|
197
|
+
});
|
|
198
|
+
return filtered;
|
|
199
|
+
} catch (e) {
|
|
200
|
+
return files;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
168
203
|
return files;
|
|
169
204
|
}
|
|
170
205
|
async function readFileContent(filePath) {
|
|
@@ -783,6 +818,167 @@ function formatToolScore(output) {
|
|
|
783
818
|
return result;
|
|
784
819
|
}
|
|
785
820
|
|
|
821
|
+
// src/business-metrics.ts
|
|
822
|
+
var DEFAULT_COST_CONFIG = {
|
|
823
|
+
pricePer1KTokens: 0.01,
|
|
824
|
+
// $0.01 per 1K tokens (GPT-4)
|
|
825
|
+
queriesPerDevPerDay: 50,
|
|
826
|
+
// Average AI queries per developer
|
|
827
|
+
developerCount: 5,
|
|
828
|
+
// Default team size
|
|
829
|
+
daysPerMonth: 30
|
|
830
|
+
};
|
|
831
|
+
var SEVERITY_TIME_ESTIMATES = {
|
|
832
|
+
critical: 4,
|
|
833
|
+
// Complex architectural issues
|
|
834
|
+
major: 2,
|
|
835
|
+
// Significant refactoring needed
|
|
836
|
+
minor: 0.5,
|
|
837
|
+
// Simple naming/style fixes
|
|
838
|
+
info: 0.25
|
|
839
|
+
// Documentation improvements
|
|
840
|
+
};
|
|
841
|
+
var DEFAULT_HOURLY_RATE = 75;
|
|
842
|
+
function calculateMonthlyCost(tokenWaste, config = {}) {
|
|
843
|
+
const cfg = { ...DEFAULT_COST_CONFIG, ...config };
|
|
844
|
+
const tokensPerDay = tokenWaste * cfg.queriesPerDevPerDay;
|
|
845
|
+
const tokensPerMonth = tokensPerDay * cfg.daysPerMonth;
|
|
846
|
+
const cost = tokensPerMonth / 1e3 * cfg.pricePer1KTokens;
|
|
847
|
+
return Math.round(cost * 100) / 100;
|
|
848
|
+
}
|
|
849
|
+
function calculateProductivityImpact(issues, hourlyRate = DEFAULT_HOURLY_RATE) {
|
|
850
|
+
const counts = {
|
|
851
|
+
critical: issues.filter((i) => i.severity === "critical").length,
|
|
852
|
+
major: issues.filter((i) => i.severity === "major").length,
|
|
853
|
+
minor: issues.filter((i) => i.severity === "minor").length,
|
|
854
|
+
info: issues.filter((i) => i.severity === "info").length
|
|
855
|
+
};
|
|
856
|
+
const hours = {
|
|
857
|
+
critical: counts.critical * SEVERITY_TIME_ESTIMATES.critical,
|
|
858
|
+
major: counts.major * SEVERITY_TIME_ESTIMATES.major,
|
|
859
|
+
minor: counts.minor * SEVERITY_TIME_ESTIMATES.minor,
|
|
860
|
+
info: counts.info * SEVERITY_TIME_ESTIMATES.info
|
|
861
|
+
};
|
|
862
|
+
const totalHours = hours.critical + hours.major + hours.minor + hours.info;
|
|
863
|
+
const totalCost = totalHours * hourlyRate;
|
|
864
|
+
return {
|
|
865
|
+
totalHours: Math.round(totalHours * 10) / 10,
|
|
866
|
+
hourlyRate,
|
|
867
|
+
totalCost: Math.round(totalCost),
|
|
868
|
+
bySeverity: {
|
|
869
|
+
critical: { hours: Math.round(hours.critical * 10) / 10, cost: Math.round(hours.critical * hourlyRate) },
|
|
870
|
+
major: { hours: Math.round(hours.major * 10) / 10, cost: Math.round(hours.major * hourlyRate) },
|
|
871
|
+
minor: { hours: Math.round(hours.minor * 10) / 10, cost: Math.round(hours.minor * hourlyRate) }
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
function predictAcceptanceRate(toolOutputs) {
|
|
876
|
+
const factors = [];
|
|
877
|
+
const patterns = toolOutputs.get("pattern-detect");
|
|
878
|
+
if (patterns) {
|
|
879
|
+
const patternImpact = (patterns.score - 50) * 0.3;
|
|
880
|
+
factors.push({
|
|
881
|
+
name: "Semantic Duplication",
|
|
882
|
+
impact: Math.round(patternImpact)
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
const context = toolOutputs.get("context-analyzer");
|
|
886
|
+
if (context) {
|
|
887
|
+
const contextImpact = (context.score - 50) * 0.4;
|
|
888
|
+
factors.push({
|
|
889
|
+
name: "Context Efficiency",
|
|
890
|
+
impact: Math.round(contextImpact)
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
const consistency = toolOutputs.get("consistency");
|
|
894
|
+
if (consistency) {
|
|
895
|
+
const consistencyImpact = (consistency.score - 50) * 0.3;
|
|
896
|
+
factors.push({
|
|
897
|
+
name: "Code Consistency",
|
|
898
|
+
impact: Math.round(consistencyImpact)
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
const baseRate = 0.65;
|
|
902
|
+
const totalImpact = factors.reduce((sum, f) => sum + f.impact / 100, 0);
|
|
903
|
+
const rate = Math.max(0.1, Math.min(0.95, baseRate + totalImpact));
|
|
904
|
+
const confidence = toolOutputs.size >= 3 ? 0.8 : toolOutputs.size >= 2 ? 0.6 : 0.4;
|
|
905
|
+
return {
|
|
906
|
+
rate: Math.round(rate * 100) / 100,
|
|
907
|
+
confidence,
|
|
908
|
+
factors
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function calculateComprehensionDifficulty(contextBudget, importDepth, fragmentation, consistencyScore, totalFiles) {
|
|
912
|
+
const budgetFactor = Math.min(100, Math.max(0, (contextBudget - 5e3) / 250));
|
|
913
|
+
const depthFactor = Math.min(100, Math.max(0, (importDepth - 5) * 10));
|
|
914
|
+
const fragmentationFactor = Math.min(100, Math.max(0, (fragmentation - 0.3) * 250));
|
|
915
|
+
const consistencyFactor = Math.min(100, Math.max(0, 100 - consistencyScore));
|
|
916
|
+
const fileFactor = Math.min(100, Math.max(0, (totalFiles - 50) / 5));
|
|
917
|
+
const score = Math.round(
|
|
918
|
+
budgetFactor * 0.35 + depthFactor * 0.2 + fragmentationFactor * 0.2 + consistencyFactor * 0.15 + fileFactor * 0.1
|
|
919
|
+
);
|
|
920
|
+
let rating;
|
|
921
|
+
if (score < 20) rating = "trivial";
|
|
922
|
+
else if (score < 40) rating = "easy";
|
|
923
|
+
else if (score < 60) rating = "moderate";
|
|
924
|
+
else if (score < 80) rating = "difficult";
|
|
925
|
+
else rating = "expert";
|
|
926
|
+
return {
|
|
927
|
+
score,
|
|
928
|
+
rating,
|
|
929
|
+
factors: [
|
|
930
|
+
{
|
|
931
|
+
name: "Context Budget",
|
|
932
|
+
contribution: Math.round(budgetFactor * 0.35),
|
|
933
|
+
description: `${Math.round(contextBudget)} tokens required`
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
name: "Import Depth",
|
|
937
|
+
contribution: Math.round(depthFactor * 0.2),
|
|
938
|
+
description: `${importDepth.toFixed(1)} average levels`
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
name: "Code Fragmentation",
|
|
942
|
+
contribution: Math.round(fragmentationFactor * 0.2),
|
|
943
|
+
description: `${(fragmentation * 100).toFixed(0)}% fragmentation`
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
name: "Consistency",
|
|
947
|
+
contribution: Math.round(consistencyFactor * 0.15),
|
|
948
|
+
description: `${consistencyScore}/100 consistency score`
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
name: "Project Scale",
|
|
952
|
+
contribution: Math.round(fileFactor * 0.1),
|
|
953
|
+
description: `${totalFiles} files analyzed`
|
|
954
|
+
}
|
|
955
|
+
]
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function formatCost(cost) {
|
|
959
|
+
if (cost < 1) {
|
|
960
|
+
return `$${cost.toFixed(2)}`;
|
|
961
|
+
} else if (cost < 1e3) {
|
|
962
|
+
return `$${cost.toFixed(0)}`;
|
|
963
|
+
} else {
|
|
964
|
+
return `$${(cost / 1e3).toFixed(1)}k`;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
function formatHours(hours) {
|
|
968
|
+
if (hours < 1) {
|
|
969
|
+
return `${Math.round(hours * 60)}min`;
|
|
970
|
+
} else if (hours < 8) {
|
|
971
|
+
return `${hours.toFixed(1)}h`;
|
|
972
|
+
} else if (hours < 40) {
|
|
973
|
+
return `${Math.round(hours)}h`;
|
|
974
|
+
} else {
|
|
975
|
+
return `${(hours / 40).toFixed(1)} weeks`;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
function formatAcceptanceRate(rate) {
|
|
979
|
+
return `${Math.round(rate * 100)}%`;
|
|
980
|
+
}
|
|
981
|
+
|
|
786
982
|
// src/parsers/typescript-parser.ts
|
|
787
983
|
var import_typescript_estree2 = require("@typescript-eslint/typescript-estree");
|
|
788
984
|
var TypeScriptParser = class {
|
|
@@ -1264,6 +1460,7 @@ function getSupportedLanguages() {
|
|
|
1264
1460
|
}
|
|
1265
1461
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1266
1462
|
0 && (module.exports = {
|
|
1463
|
+
DEFAULT_COST_CONFIG,
|
|
1267
1464
|
DEFAULT_EXCLUDE,
|
|
1268
1465
|
DEFAULT_TOOL_WEIGHTS,
|
|
1269
1466
|
LANGUAGE_EXTENSIONS,
|
|
@@ -1273,11 +1470,17 @@ function getSupportedLanguages() {
|
|
|
1273
1470
|
PythonParser,
|
|
1274
1471
|
TOOL_NAME_MAP,
|
|
1275
1472
|
TypeScriptParser,
|
|
1473
|
+
calculateComprehensionDifficulty,
|
|
1276
1474
|
calculateImportSimilarity,
|
|
1475
|
+
calculateMonthlyCost,
|
|
1277
1476
|
calculateOverallScore,
|
|
1477
|
+
calculateProductivityImpact,
|
|
1278
1478
|
estimateTokens,
|
|
1279
1479
|
extractFunctions,
|
|
1280
1480
|
extractImports,
|
|
1481
|
+
formatAcceptanceRate,
|
|
1482
|
+
formatCost,
|
|
1483
|
+
formatHours,
|
|
1281
1484
|
formatScore,
|
|
1282
1485
|
formatToolScore,
|
|
1283
1486
|
generateHTML,
|
|
@@ -1299,6 +1502,7 @@ function getSupportedLanguages() {
|
|
|
1299
1502
|
parseCode,
|
|
1300
1503
|
parseFileExports,
|
|
1301
1504
|
parseWeightString,
|
|
1505
|
+
predictAcceptanceRate,
|
|
1302
1506
|
readFileContent,
|
|
1303
1507
|
resolveOutputPath,
|
|
1304
1508
|
scanFiles
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
import { glob } from "glob";
|
|
20
20
|
import { readFile } from "fs/promises";
|
|
21
21
|
import { existsSync } from "fs";
|
|
22
|
-
import { join } from "path";
|
|
22
|
+
import { join, relative } from "path";
|
|
23
|
+
import ignorePkg from "ignore";
|
|
23
24
|
var DEFAULT_EXCLUDE = [
|
|
24
25
|
// Dependencies
|
|
25
26
|
"**/node_modules/**",
|
|
@@ -88,6 +89,22 @@ async function scanFiles(options) {
|
|
|
88
89
|
ignore: finalExclude,
|
|
89
90
|
absolute: true
|
|
90
91
|
});
|
|
92
|
+
const gitignorePath = join(rootDir || ".", ".gitignore");
|
|
93
|
+
if (existsSync(gitignorePath)) {
|
|
94
|
+
try {
|
|
95
|
+
const gitTxt = await readFile(gitignorePath, "utf-8");
|
|
96
|
+
const ig = ignorePkg();
|
|
97
|
+
ig.add(gitTxt);
|
|
98
|
+
const filtered = files.filter((f) => {
|
|
99
|
+
let rel = relative(rootDir || ".", f).replace(/\\/g, "/");
|
|
100
|
+
if (rel === "") rel = f;
|
|
101
|
+
return !ig.ignores(rel);
|
|
102
|
+
});
|
|
103
|
+
return filtered;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
return files;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
91
108
|
return files;
|
|
92
109
|
}
|
|
93
110
|
async function readFileContent(filePath) {
|
|
@@ -396,6 +413,167 @@ function getElapsedTime(startTime) {
|
|
|
396
413
|
return ((Date.now() - startTime) / 1e3).toFixed(2);
|
|
397
414
|
}
|
|
398
415
|
|
|
416
|
+
// src/business-metrics.ts
|
|
417
|
+
var DEFAULT_COST_CONFIG = {
|
|
418
|
+
pricePer1KTokens: 0.01,
|
|
419
|
+
// $0.01 per 1K tokens (GPT-4)
|
|
420
|
+
queriesPerDevPerDay: 50,
|
|
421
|
+
// Average AI queries per developer
|
|
422
|
+
developerCount: 5,
|
|
423
|
+
// Default team size
|
|
424
|
+
daysPerMonth: 30
|
|
425
|
+
};
|
|
426
|
+
var SEVERITY_TIME_ESTIMATES = {
|
|
427
|
+
critical: 4,
|
|
428
|
+
// Complex architectural issues
|
|
429
|
+
major: 2,
|
|
430
|
+
// Significant refactoring needed
|
|
431
|
+
minor: 0.5,
|
|
432
|
+
// Simple naming/style fixes
|
|
433
|
+
info: 0.25
|
|
434
|
+
// Documentation improvements
|
|
435
|
+
};
|
|
436
|
+
var DEFAULT_HOURLY_RATE = 75;
|
|
437
|
+
function calculateMonthlyCost(tokenWaste, config = {}) {
|
|
438
|
+
const cfg = { ...DEFAULT_COST_CONFIG, ...config };
|
|
439
|
+
const tokensPerDay = tokenWaste * cfg.queriesPerDevPerDay;
|
|
440
|
+
const tokensPerMonth = tokensPerDay * cfg.daysPerMonth;
|
|
441
|
+
const cost = tokensPerMonth / 1e3 * cfg.pricePer1KTokens;
|
|
442
|
+
return Math.round(cost * 100) / 100;
|
|
443
|
+
}
|
|
444
|
+
function calculateProductivityImpact(issues, hourlyRate = DEFAULT_HOURLY_RATE) {
|
|
445
|
+
const counts = {
|
|
446
|
+
critical: issues.filter((i) => i.severity === "critical").length,
|
|
447
|
+
major: issues.filter((i) => i.severity === "major").length,
|
|
448
|
+
minor: issues.filter((i) => i.severity === "minor").length,
|
|
449
|
+
info: issues.filter((i) => i.severity === "info").length
|
|
450
|
+
};
|
|
451
|
+
const hours = {
|
|
452
|
+
critical: counts.critical * SEVERITY_TIME_ESTIMATES.critical,
|
|
453
|
+
major: counts.major * SEVERITY_TIME_ESTIMATES.major,
|
|
454
|
+
minor: counts.minor * SEVERITY_TIME_ESTIMATES.minor,
|
|
455
|
+
info: counts.info * SEVERITY_TIME_ESTIMATES.info
|
|
456
|
+
};
|
|
457
|
+
const totalHours = hours.critical + hours.major + hours.minor + hours.info;
|
|
458
|
+
const totalCost = totalHours * hourlyRate;
|
|
459
|
+
return {
|
|
460
|
+
totalHours: Math.round(totalHours * 10) / 10,
|
|
461
|
+
hourlyRate,
|
|
462
|
+
totalCost: Math.round(totalCost),
|
|
463
|
+
bySeverity: {
|
|
464
|
+
critical: { hours: Math.round(hours.critical * 10) / 10, cost: Math.round(hours.critical * hourlyRate) },
|
|
465
|
+
major: { hours: Math.round(hours.major * 10) / 10, cost: Math.round(hours.major * hourlyRate) },
|
|
466
|
+
minor: { hours: Math.round(hours.minor * 10) / 10, cost: Math.round(hours.minor * hourlyRate) }
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function predictAcceptanceRate(toolOutputs) {
|
|
471
|
+
const factors = [];
|
|
472
|
+
const patterns = toolOutputs.get("pattern-detect");
|
|
473
|
+
if (patterns) {
|
|
474
|
+
const patternImpact = (patterns.score - 50) * 0.3;
|
|
475
|
+
factors.push({
|
|
476
|
+
name: "Semantic Duplication",
|
|
477
|
+
impact: Math.round(patternImpact)
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
const context = toolOutputs.get("context-analyzer");
|
|
481
|
+
if (context) {
|
|
482
|
+
const contextImpact = (context.score - 50) * 0.4;
|
|
483
|
+
factors.push({
|
|
484
|
+
name: "Context Efficiency",
|
|
485
|
+
impact: Math.round(contextImpact)
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
const consistency = toolOutputs.get("consistency");
|
|
489
|
+
if (consistency) {
|
|
490
|
+
const consistencyImpact = (consistency.score - 50) * 0.3;
|
|
491
|
+
factors.push({
|
|
492
|
+
name: "Code Consistency",
|
|
493
|
+
impact: Math.round(consistencyImpact)
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
const baseRate = 0.65;
|
|
497
|
+
const totalImpact = factors.reduce((sum, f) => sum + f.impact / 100, 0);
|
|
498
|
+
const rate = Math.max(0.1, Math.min(0.95, baseRate + totalImpact));
|
|
499
|
+
const confidence = toolOutputs.size >= 3 ? 0.8 : toolOutputs.size >= 2 ? 0.6 : 0.4;
|
|
500
|
+
return {
|
|
501
|
+
rate: Math.round(rate * 100) / 100,
|
|
502
|
+
confidence,
|
|
503
|
+
factors
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function calculateComprehensionDifficulty(contextBudget, importDepth, fragmentation, consistencyScore, totalFiles) {
|
|
507
|
+
const budgetFactor = Math.min(100, Math.max(0, (contextBudget - 5e3) / 250));
|
|
508
|
+
const depthFactor = Math.min(100, Math.max(0, (importDepth - 5) * 10));
|
|
509
|
+
const fragmentationFactor = Math.min(100, Math.max(0, (fragmentation - 0.3) * 250));
|
|
510
|
+
const consistencyFactor = Math.min(100, Math.max(0, 100 - consistencyScore));
|
|
511
|
+
const fileFactor = Math.min(100, Math.max(0, (totalFiles - 50) / 5));
|
|
512
|
+
const score = Math.round(
|
|
513
|
+
budgetFactor * 0.35 + depthFactor * 0.2 + fragmentationFactor * 0.2 + consistencyFactor * 0.15 + fileFactor * 0.1
|
|
514
|
+
);
|
|
515
|
+
let rating;
|
|
516
|
+
if (score < 20) rating = "trivial";
|
|
517
|
+
else if (score < 40) rating = "easy";
|
|
518
|
+
else if (score < 60) rating = "moderate";
|
|
519
|
+
else if (score < 80) rating = "difficult";
|
|
520
|
+
else rating = "expert";
|
|
521
|
+
return {
|
|
522
|
+
score,
|
|
523
|
+
rating,
|
|
524
|
+
factors: [
|
|
525
|
+
{
|
|
526
|
+
name: "Context Budget",
|
|
527
|
+
contribution: Math.round(budgetFactor * 0.35),
|
|
528
|
+
description: `${Math.round(contextBudget)} tokens required`
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: "Import Depth",
|
|
532
|
+
contribution: Math.round(depthFactor * 0.2),
|
|
533
|
+
description: `${importDepth.toFixed(1)} average levels`
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
name: "Code Fragmentation",
|
|
537
|
+
contribution: Math.round(fragmentationFactor * 0.2),
|
|
538
|
+
description: `${(fragmentation * 100).toFixed(0)}% fragmentation`
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
name: "Consistency",
|
|
542
|
+
contribution: Math.round(consistencyFactor * 0.15),
|
|
543
|
+
description: `${consistencyScore}/100 consistency score`
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "Project Scale",
|
|
547
|
+
contribution: Math.round(fileFactor * 0.1),
|
|
548
|
+
description: `${totalFiles} files analyzed`
|
|
549
|
+
}
|
|
550
|
+
]
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function formatCost(cost) {
|
|
554
|
+
if (cost < 1) {
|
|
555
|
+
return `$${cost.toFixed(2)}`;
|
|
556
|
+
} else if (cost < 1e3) {
|
|
557
|
+
return `$${cost.toFixed(0)}`;
|
|
558
|
+
} else {
|
|
559
|
+
return `$${(cost / 1e3).toFixed(1)}k`;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function formatHours(hours) {
|
|
563
|
+
if (hours < 1) {
|
|
564
|
+
return `${Math.round(hours * 60)}min`;
|
|
565
|
+
} else if (hours < 8) {
|
|
566
|
+
return `${hours.toFixed(1)}h`;
|
|
567
|
+
} else if (hours < 40) {
|
|
568
|
+
return `${Math.round(hours)}h`;
|
|
569
|
+
} else {
|
|
570
|
+
return `${(hours / 40).toFixed(1)} weeks`;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function formatAcceptanceRate(rate) {
|
|
574
|
+
return `${Math.round(rate * 100)}%`;
|
|
575
|
+
}
|
|
576
|
+
|
|
399
577
|
// src/parsers/typescript-parser.ts
|
|
400
578
|
import { parse as parse2 } from "@typescript-eslint/typescript-estree";
|
|
401
579
|
var TypeScriptParser = class {
|
|
@@ -876,6 +1054,7 @@ function getSupportedLanguages() {
|
|
|
876
1054
|
return ParserFactory.getInstance().getSupportedLanguages();
|
|
877
1055
|
}
|
|
878
1056
|
export {
|
|
1057
|
+
DEFAULT_COST_CONFIG,
|
|
879
1058
|
DEFAULT_EXCLUDE,
|
|
880
1059
|
DEFAULT_TOOL_WEIGHTS,
|
|
881
1060
|
LANGUAGE_EXTENSIONS,
|
|
@@ -885,11 +1064,17 @@ export {
|
|
|
885
1064
|
PythonParser,
|
|
886
1065
|
TOOL_NAME_MAP,
|
|
887
1066
|
TypeScriptParser,
|
|
1067
|
+
calculateComprehensionDifficulty,
|
|
888
1068
|
calculateImportSimilarity,
|
|
1069
|
+
calculateMonthlyCost,
|
|
889
1070
|
calculateOverallScore,
|
|
1071
|
+
calculateProductivityImpact,
|
|
890
1072
|
estimateTokens,
|
|
891
1073
|
extractFunctions,
|
|
892
1074
|
extractImports,
|
|
1075
|
+
formatAcceptanceRate,
|
|
1076
|
+
formatCost,
|
|
1077
|
+
formatHours,
|
|
893
1078
|
formatScore,
|
|
894
1079
|
formatToolScore,
|
|
895
1080
|
generateHTML,
|
|
@@ -911,6 +1096,7 @@ export {
|
|
|
911
1096
|
parseCode,
|
|
912
1097
|
parseFileExports,
|
|
913
1098
|
parseWeightString,
|
|
1099
|
+
predictAcceptanceRate,
|
|
914
1100
|
readFileContent,
|
|
915
1101
|
resolveOutputPath,
|
|
916
1102
|
scanFiles
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.25",
|
|
4
4
|
"description": "Shared utilities for AIReady analysis tools",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@typescript-eslint/typescript-estree": "^8.53.0",
|
|
48
48
|
"chalk": "^5.4.1",
|
|
49
49
|
"glob": "^13.0.0",
|
|
50
|
+
"ignore": "^7.0.0",
|
|
50
51
|
"typescript": "^5.9.3"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|