@aiready/core 0.9.23 → 0.9.26
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 +318 -3
- package/dist/index.d.ts +318 -3
- package/dist/index.js +730 -0
- package/dist/index.mjs +698 -1
- package/package.json +4 -3
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,180 @@ 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
|
+
* NEW in v0.11: Extended with temporal tracking, knowledge concentration, and
|
|
122
|
+
* technical debt interest calculations.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Historical score entry for trend tracking
|
|
127
|
+
*/
|
|
128
|
+
interface ScoreHistoryEntry {
|
|
129
|
+
timestamp: string;
|
|
130
|
+
overallScore: number;
|
|
131
|
+
breakdown: Record<string, number>;
|
|
132
|
+
totalIssues: number;
|
|
133
|
+
totalTokens: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Trend analysis comparing current vs historical scores
|
|
137
|
+
*/
|
|
138
|
+
interface ScoreTrend {
|
|
139
|
+
direction: 'improving' | 'stable' | 'degrading';
|
|
140
|
+
change30Days: number;
|
|
141
|
+
change90Days: number;
|
|
142
|
+
velocity: number;
|
|
143
|
+
projectedScore: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Remediation velocity tracking
|
|
147
|
+
*/
|
|
148
|
+
interface RemediationVelocity {
|
|
149
|
+
issuesFixedThisWeek: number;
|
|
150
|
+
avgIssuesPerWeek: number;
|
|
151
|
+
trend: 'accelerating' | 'stable' | 'decelerating';
|
|
152
|
+
estimatedCompletionWeeks: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Knowledge concentration risk - measures "bus factor" for AI training
|
|
156
|
+
*/
|
|
157
|
+
interface KnowledgeConcentrationRisk {
|
|
158
|
+
/** Overall risk score 0-100: higher = more risk */
|
|
159
|
+
score: number;
|
|
160
|
+
rating: 'low' | 'moderate' | 'high' | 'critical';
|
|
161
|
+
/** Analysis details */
|
|
162
|
+
analysis: {
|
|
163
|
+
/** Files with unique concepts (only source) */
|
|
164
|
+
uniqueConceptFiles: number;
|
|
165
|
+
totalFiles: number;
|
|
166
|
+
concentrationRatio: number;
|
|
167
|
+
/** Key person dependencies (files only one person understands) */
|
|
168
|
+
singleAuthorFiles: number;
|
|
169
|
+
/** Orphan files (no dependencies) */
|
|
170
|
+
orphanFiles: number;
|
|
171
|
+
};
|
|
172
|
+
/** Recommendations for reducing risk */
|
|
173
|
+
recommendations: string[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Technical debt interest rate - cost of inaction over time
|
|
177
|
+
*/
|
|
178
|
+
interface TechnicalDebtInterest {
|
|
179
|
+
/** Monthly interest rate (% of principal adding up) */
|
|
180
|
+
monthlyRate: number;
|
|
181
|
+
/** Annual effective rate */
|
|
182
|
+
annualRate: number;
|
|
183
|
+
/** Principal (current technical debt cost) */
|
|
184
|
+
principal: number;
|
|
185
|
+
/** Projected debt in 6/12/24 months */
|
|
186
|
+
projections: {
|
|
187
|
+
months6: number;
|
|
188
|
+
months12: number;
|
|
189
|
+
months24: number;
|
|
190
|
+
};
|
|
191
|
+
/** Monthly cost of delay */
|
|
192
|
+
monthlyCost: number;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Detailed debt breakdown by category
|
|
196
|
+
*/
|
|
197
|
+
interface DebtBreakdown {
|
|
198
|
+
category: string;
|
|
199
|
+
currentCost: number;
|
|
200
|
+
monthlyGrowthRate: number;
|
|
201
|
+
priority: 'high' | 'medium' | 'low';
|
|
202
|
+
fixCost: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Default cost configuration
|
|
206
|
+
* Based on GPT-4 pricing and typical team usage
|
|
207
|
+
*/
|
|
208
|
+
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
209
|
+
/**
|
|
210
|
+
* Calculate estimated monthly cost of AI context waste
|
|
211
|
+
*
|
|
212
|
+
* Formula: (tokenWaste / 1000) × pricePer1K × queriesPerDev × devCount × days
|
|
213
|
+
*/
|
|
214
|
+
declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): number;
|
|
215
|
+
/**
|
|
216
|
+
* Calculate productivity impact from issues
|
|
217
|
+
*/
|
|
218
|
+
declare function calculateProductivityImpact(issues: {
|
|
219
|
+
severity: string;
|
|
220
|
+
}[], hourlyRate?: number): ProductivityImpact;
|
|
221
|
+
/**
|
|
222
|
+
* Predict AI suggestion acceptance rate based on code quality
|
|
223
|
+
*
|
|
224
|
+
* Research shows:
|
|
225
|
+
* - High consistency correlates with 30%+ higher acceptance
|
|
226
|
+
* - Low context budget improves understanding by ~40%
|
|
227
|
+
* - Good naming patterns reduce clarification needs by 50%
|
|
228
|
+
*/
|
|
229
|
+
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
230
|
+
/**
|
|
231
|
+
* Calculate Comprehension Difficulty Index
|
|
232
|
+
*
|
|
233
|
+
* A future-proof abstraction that normalizes multiple factors
|
|
234
|
+
* into a single difficulty score. Lower = easier for AI.
|
|
235
|
+
*/
|
|
236
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, consistencyScore: number, totalFiles: number): ComprehensionDifficulty;
|
|
237
|
+
/**
|
|
238
|
+
* Format cost for display
|
|
239
|
+
*/
|
|
240
|
+
declare function formatCost(cost: number): string;
|
|
241
|
+
/**
|
|
242
|
+
* Format hours for display
|
|
243
|
+
*/
|
|
244
|
+
declare function formatHours(hours: number): string;
|
|
245
|
+
/**
|
|
246
|
+
* Format acceptance rate for display
|
|
247
|
+
*/
|
|
248
|
+
declare function formatAcceptanceRate(rate: number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Calculate score trend from historical data
|
|
251
|
+
*/
|
|
252
|
+
declare function calculateScoreTrend(history: ScoreHistoryEntry[]): ScoreTrend;
|
|
253
|
+
/**
|
|
254
|
+
* Calculate remediation velocity
|
|
255
|
+
*/
|
|
256
|
+
declare function calculateRemediationVelocity(history: ScoreHistoryEntry[], currentIssues: number): RemediationVelocity;
|
|
257
|
+
/**
|
|
258
|
+
* Calculate knowledge concentration risk
|
|
259
|
+
*
|
|
260
|
+
* This measures how "centralized" knowledge is in the codebase,
|
|
261
|
+
* similar to bus factor but for AI/ML training purposes.
|
|
262
|
+
*/
|
|
263
|
+
declare function calculateKnowledgeConcentration(files: {
|
|
264
|
+
path: string;
|
|
265
|
+
exports: number;
|
|
266
|
+
imports: number;
|
|
267
|
+
}[], authorData?: Map<string, string[]>): KnowledgeConcentrationRisk;
|
|
268
|
+
/**
|
|
269
|
+
* Calculate technical debt interest rate
|
|
270
|
+
*
|
|
271
|
+
* The key insight: technical debt compounds over time.
|
|
272
|
+
* Each month, issues grow by a certain rate due to:
|
|
273
|
+
* - New code inheriting patterns
|
|
274
|
+
* - Context budget growing
|
|
275
|
+
* - Duplication spreading
|
|
276
|
+
*/
|
|
277
|
+
declare function calculateTechnicalDebtInterest(params: {
|
|
278
|
+
currentMonthlyCost: number;
|
|
279
|
+
issues: {
|
|
280
|
+
severity: string;
|
|
281
|
+
}[];
|
|
282
|
+
monthsOpen: number;
|
|
283
|
+
}): TechnicalDebtInterest;
|
|
284
|
+
/**
|
|
285
|
+
* Get debt breakdown by category
|
|
286
|
+
*/
|
|
287
|
+
declare function getDebtBreakdown(patternCost: number, contextCost: number, consistencyCost: number): DebtBreakdown[];
|
|
288
|
+
|
|
115
289
|
/**
|
|
116
290
|
* Parser Factory - Manages language-specific parsers
|
|
117
291
|
*
|
|
@@ -240,4 +414,145 @@ declare class PythonParser implements LanguageParser {
|
|
|
240
414
|
private extractExportsRegex;
|
|
241
415
|
}
|
|
242
416
|
|
|
243
|
-
|
|
417
|
+
/**
|
|
418
|
+
* Future-Proof AI Metrics Abstraction Layer
|
|
419
|
+
*
|
|
420
|
+
* This module provides technology-agnostic metric primitives that will
|
|
421
|
+
* remain valid across changes in AI models, tokenization, and paradigms.
|
|
422
|
+
*
|
|
423
|
+
* The key insight: rather than measuring "tokens" or "import depth",
|
|
424
|
+
* we measure cognitive concepts that translate to any AI architecture:
|
|
425
|
+
* - Cognitive Load: How much mental effort for AI to understand
|
|
426
|
+
* - Semantic Distance: How far apart related concepts are
|
|
427
|
+
* - Concept Cohesion: How well grouped related ideas are
|
|
428
|
+
* - Pattern Entropy: How ordered vs chaotic the structure is
|
|
429
|
+
*/
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Factors that contribute to cognitive load for AI understanding
|
|
433
|
+
* These are normalized 0-100 factors that can be combined
|
|
434
|
+
*/
|
|
435
|
+
interface LoadFactor {
|
|
436
|
+
name: string;
|
|
437
|
+
score: number;
|
|
438
|
+
weight: number;
|
|
439
|
+
description: string;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Cognitive Load Assessment
|
|
443
|
+
* Replaces "token cost" with a multi-dimensional load analysis
|
|
444
|
+
*/
|
|
445
|
+
interface CognitiveLoad {
|
|
446
|
+
score: number;
|
|
447
|
+
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
448
|
+
factors: LoadFactor[];
|
|
449
|
+
rawValues: {
|
|
450
|
+
size: number;
|
|
451
|
+
complexity: number;
|
|
452
|
+
dependencyCount: number;
|
|
453
|
+
conceptCount: number;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Calculate cognitive load from raw file metrics
|
|
458
|
+
*/
|
|
459
|
+
declare function calculateCognitiveLoad(params: {
|
|
460
|
+
linesOfCode: number;
|
|
461
|
+
exportCount: number;
|
|
462
|
+
importCount: number;
|
|
463
|
+
uniqueConcepts: number;
|
|
464
|
+
cyclomaticComplexity?: number;
|
|
465
|
+
}): CognitiveLoad;
|
|
466
|
+
interface SemanticDistance {
|
|
467
|
+
between: [string, string];
|
|
468
|
+
distance: number;
|
|
469
|
+
relationship: 'same-file' | 'same-domain' | 'cross-domain' | 'unrelated';
|
|
470
|
+
path: string[];
|
|
471
|
+
reason: string;
|
|
472
|
+
}
|
|
473
|
+
declare function calculateSemanticDistance(params: {
|
|
474
|
+
file1: string;
|
|
475
|
+
file2: string;
|
|
476
|
+
file1Domain: string;
|
|
477
|
+
file2Domain: string;
|
|
478
|
+
file1Imports: string[];
|
|
479
|
+
file2Imports: string[];
|
|
480
|
+
sharedDependencies: string[];
|
|
481
|
+
}): SemanticDistance;
|
|
482
|
+
interface PatternEntropy {
|
|
483
|
+
domain: string;
|
|
484
|
+
entropy: number;
|
|
485
|
+
rating: 'crystalline' | 'well-structured' | 'moderate' | 'fragmented' | 'chaotic';
|
|
486
|
+
distribution: {
|
|
487
|
+
locationCount: number;
|
|
488
|
+
dominantLocation: string;
|
|
489
|
+
giniCoefficient: number;
|
|
490
|
+
};
|
|
491
|
+
recommendations: string[];
|
|
492
|
+
}
|
|
493
|
+
interface FileWithDomain {
|
|
494
|
+
path: string;
|
|
495
|
+
domain: string;
|
|
496
|
+
}
|
|
497
|
+
declare function calculatePatternEntropy(files: FileWithDomain[]): PatternEntropy;
|
|
498
|
+
interface ConceptCohesion {
|
|
499
|
+
score: number;
|
|
500
|
+
rating: 'excellent' | 'good' | 'moderate' | 'poor';
|
|
501
|
+
analysis: {
|
|
502
|
+
uniqueDomains: number;
|
|
503
|
+
domainConcentration: number;
|
|
504
|
+
exportPurposeClarity: number;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
declare function calculateConceptCohesion(params: {
|
|
508
|
+
exports: Array<{
|
|
509
|
+
name: string;
|
|
510
|
+
inferredDomain?: string;
|
|
511
|
+
domains?: string[];
|
|
512
|
+
}>;
|
|
513
|
+
}): ConceptCohesion;
|
|
514
|
+
declare function calculateFutureProofScore(params: {
|
|
515
|
+
cognitiveLoad: CognitiveLoad;
|
|
516
|
+
patternEntropy: PatternEntropy;
|
|
517
|
+
conceptCohesion: ConceptCohesion;
|
|
518
|
+
semanticDistances?: SemanticDistance[];
|
|
519
|
+
}): ToolScoringOutput;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Temporal Tracking Utilities
|
|
523
|
+
*
|
|
524
|
+
* Manages score history storage and retrieval for trend analysis.
|
|
525
|
+
* Stores data in .aiready/history/ directory.
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* Load score history from disk
|
|
529
|
+
*/
|
|
530
|
+
declare function loadScoreHistory(rootDir: string): any[];
|
|
531
|
+
/**
|
|
532
|
+
* Save score entry to history
|
|
533
|
+
*/
|
|
534
|
+
declare function saveScoreEntry(rootDir: string, entry: {
|
|
535
|
+
overallScore: number;
|
|
536
|
+
breakdown: Record<string, number>;
|
|
537
|
+
totalIssues: number;
|
|
538
|
+
totalTokens: number;
|
|
539
|
+
}): void;
|
|
540
|
+
/**
|
|
541
|
+
* Get summary of recent history
|
|
542
|
+
*/
|
|
543
|
+
declare function getHistorySummary(rootDir: string): {
|
|
544
|
+
totalScans: number;
|
|
545
|
+
firstScan: string | null;
|
|
546
|
+
lastScan: string | null;
|
|
547
|
+
avgScore: number;
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* Export history for external analysis
|
|
551
|
+
*/
|
|
552
|
+
declare function exportHistory(rootDir: string, format?: 'json' | 'csv'): string;
|
|
553
|
+
/**
|
|
554
|
+
* Clear history (for testing or reset)
|
|
555
|
+
*/
|
|
556
|
+
declare function clearHistory(rootDir: string): void;
|
|
557
|
+
|
|
558
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type CLIOptions, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DebtBreakdown, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, ToolScoringOutput, TypeScriptParser, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, clearHistory, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getDebtBreakdown, getElapsedTime, getFileExtension, getHistorySummary, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanFiles };
|