@aiready/core 0.9.38 → 0.9.39
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 +14 -6
- package/dist/client.d.ts +14 -6
- package/dist/index.d.mts +167 -280
- package/dist/index.d.ts +167 -280
- package/dist/index.js +412 -540
- package/dist/index.mjs +405 -536
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScanOptions, AIReadyConfig,
|
|
1
|
+
import { ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
|
|
2
2
|
export { AnalysisResult, BusinessReport, CONTEXT_TIER_THRESHOLDS, CommonASTNode, DEFAULT_TOOL_WEIGHTS, ExportInfo, GraphData, GraphEdge, GraphIssueSeverity, GraphMetadata, GraphNode, ImportInfo, Issue, IssueType, LANGUAGE_EXTENSIONS, LanguageConfig, Location, Metrics, ParseError, ParseStatistics, Report, SIZE_ADJUSTED_THRESHOLDS, ScoringConfig, ScoringResult, SourceLocation, SourceRange, TOOL_NAME_MAP, calculateOverallScore, formatScore, formatToolScore, generateHTML, getProjectSizeTier, getRating, getRatingDisplay, getRatingWithContext, getRecommendedThreshold, getToolWeight, normalizeToolName, parseWeightString } from './client.mjs';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_EXCLUDE: string[];
|
|
@@ -120,23 +120,24 @@ declare function handleCLIError(error: unknown, commandName: string): never;
|
|
|
120
120
|
* Calculate elapsed time and format for display
|
|
121
121
|
*/
|
|
122
122
|
declare function getElapsedTime(startTime: number): string;
|
|
123
|
-
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
* NEW in v0.11: Extended with temporal tracking, knowledge concentration, and
|
|
131
|
-
* technical debt interest calculations.
|
|
132
|
-
* NEW in v0.12: Multi-model pricing presets, model-aware CDI calibration,
|
|
133
|
-
* and improved acceptance rate prediction with data-grounded baselines.
|
|
124
|
+
* Generate a visual score bar for console output
|
|
125
|
+
*/
|
|
126
|
+
declare function getScoreBar(val: number): string;
|
|
127
|
+
/**
|
|
128
|
+
* Get status icon for safety ratings
|
|
134
129
|
*/
|
|
130
|
+
declare function getSafetyIcon(rating: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Get chalk color function for a given severity
|
|
133
|
+
* @param severity severity level
|
|
134
|
+
* @param chalk chalk instance
|
|
135
|
+
*/
|
|
136
|
+
declare function getSeverityColor(severity: string, chalk: any): any;
|
|
135
137
|
|
|
136
138
|
/**
|
|
137
139
|
* AI model pricing presets for cost estimation.
|
|
138
140
|
* Prices are input token costs per 1K tokens (USD), as of Q1 2026.
|
|
139
|
-
* Update these as model pricing evolves — the calculation logic is unchanged.
|
|
140
141
|
*/
|
|
141
142
|
interface ModelPricingPreset {
|
|
142
143
|
name: string;
|
|
@@ -151,96 +152,14 @@ declare const MODEL_PRICING_PRESETS: Record<string, ModelPricingPreset>;
|
|
|
151
152
|
* Get a model pricing preset by ID, with fallback to claude-4.6 (2026 default)
|
|
152
153
|
*/
|
|
153
154
|
declare function getModelPreset(modelId: string): ModelPricingPreset;
|
|
154
|
-
|
|
155
|
-
* Historical score entry for trend tracking
|
|
156
|
-
*/
|
|
157
|
-
interface ScoreHistoryEntry {
|
|
158
|
-
timestamp: string;
|
|
159
|
-
overallScore: number;
|
|
160
|
-
breakdown: Record<string, number>;
|
|
161
|
-
totalIssues: number;
|
|
162
|
-
totalTokens: number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Trend analysis comparing current vs historical scores
|
|
166
|
-
*/
|
|
167
|
-
interface ScoreTrend {
|
|
168
|
-
direction: 'improving' | 'stable' | 'degrading';
|
|
169
|
-
change30Days: number;
|
|
170
|
-
change90Days: number;
|
|
171
|
-
velocity: number;
|
|
172
|
-
projectedScore: number;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Remediation velocity tracking
|
|
176
|
-
*/
|
|
177
|
-
interface RemediationVelocity {
|
|
178
|
-
issuesFixedThisWeek: number;
|
|
179
|
-
avgIssuesPerWeek: number;
|
|
180
|
-
trend: 'accelerating' | 'stable' | 'decelerating';
|
|
181
|
-
estimatedCompletionWeeks: number;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Knowledge concentration risk - measures "bus factor" for AI training
|
|
185
|
-
*/
|
|
186
|
-
interface KnowledgeConcentrationRisk {
|
|
187
|
-
/** Overall risk score 0-100: higher = more risk */
|
|
188
|
-
score: number;
|
|
189
|
-
rating: 'low' | 'moderate' | 'high' | 'critical';
|
|
190
|
-
/** Analysis details */
|
|
191
|
-
analysis: {
|
|
192
|
-
/** Files with unique concepts (only source) */
|
|
193
|
-
uniqueConceptFiles: number;
|
|
194
|
-
totalFiles: number;
|
|
195
|
-
concentrationRatio: number;
|
|
196
|
-
/** Key person dependencies (files only one person understands) */
|
|
197
|
-
singleAuthorFiles: number;
|
|
198
|
-
/** Orphan files (no dependencies) */
|
|
199
|
-
orphanFiles: number;
|
|
200
|
-
};
|
|
201
|
-
/** Recommendations for reducing risk */
|
|
202
|
-
recommendations: string[];
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Technical debt interest rate - cost of inaction over time
|
|
206
|
-
*/
|
|
207
|
-
interface TechnicalDebtInterest {
|
|
208
|
-
/** Monthly interest rate (% of principal adding up) */
|
|
209
|
-
monthlyRate: number;
|
|
210
|
-
/** Annual effective rate */
|
|
211
|
-
annualRate: number;
|
|
212
|
-
/** Principal (current technical debt cost) */
|
|
213
|
-
principal: number;
|
|
214
|
-
/** Projected debt in 6/12/24 months */
|
|
215
|
-
projections: {
|
|
216
|
-
months6: number;
|
|
217
|
-
months12: number;
|
|
218
|
-
months24: number;
|
|
219
|
-
};
|
|
220
|
-
/** Monthly cost of delay */
|
|
221
|
-
monthlyCost: number;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Detailed debt breakdown by category
|
|
225
|
-
*/
|
|
226
|
-
interface DebtBreakdown {
|
|
227
|
-
category: string;
|
|
228
|
-
currentCost: number;
|
|
229
|
-
monthlyGrowthRate: number;
|
|
230
|
-
priority: 'high' | 'medium' | 'low';
|
|
231
|
-
fixCost: number;
|
|
232
|
-
}
|
|
155
|
+
|
|
233
156
|
/**
|
|
234
157
|
* Default cost configuration
|
|
235
|
-
* Points to GPT-4o as the default model (most common in 2026).
|
|
236
|
-
* Use MODEL_PRICING_PRESETS for model-specific accuracy.
|
|
237
158
|
*/
|
|
238
159
|
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
239
160
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* Calculate estimated monthly cost of AI context waste with confidence intervals.
|
|
161
|
+
* Calculate estimated monthly cost of AI context waste
|
|
162
|
+
* @deprecated Since v0.13
|
|
244
163
|
*/
|
|
245
164
|
declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): {
|
|
246
165
|
total: number;
|
|
@@ -248,8 +167,7 @@ declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostC
|
|
|
248
167
|
confidence: number;
|
|
249
168
|
};
|
|
250
169
|
/**
|
|
251
|
-
* Calculate token budget and unit economics
|
|
252
|
-
* Technology-agnostic metric that remains valid across model generations.
|
|
170
|
+
* Calculate token budget and unit economics
|
|
253
171
|
*/
|
|
254
172
|
declare function calculateTokenBudget(params: {
|
|
255
173
|
totalContextTokens: number;
|
|
@@ -261,14 +179,23 @@ declare function calculateTokenBudget(params: {
|
|
|
261
179
|
};
|
|
262
180
|
}): TokenBudget;
|
|
263
181
|
/**
|
|
264
|
-
* Estimate dollar cost from a token budget
|
|
265
|
-
* Note: Use this for presentation only. Token budgets are the primary metric.
|
|
182
|
+
* Estimate dollar cost from a token budget
|
|
266
183
|
*/
|
|
267
184
|
declare function estimateCostFromBudget(budget: TokenBudget, model: ModelPricingPreset, config?: Partial<CostConfig>): {
|
|
268
185
|
total: number;
|
|
269
186
|
range: [number, number];
|
|
270
187
|
confidence: number;
|
|
271
188
|
};
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Severity time estimates (hours to fix)
|
|
192
|
+
*/
|
|
193
|
+
declare const SEVERITY_TIME_ESTIMATES: {
|
|
194
|
+
critical: number;
|
|
195
|
+
major: number;
|
|
196
|
+
minor: number;
|
|
197
|
+
info: number;
|
|
198
|
+
};
|
|
272
199
|
/**
|
|
273
200
|
* Calculate productivity impact from issues
|
|
274
201
|
*/
|
|
@@ -276,85 +203,113 @@ declare function calculateProductivityImpact(issues: {
|
|
|
276
203
|
severity: string;
|
|
277
204
|
}[], hourlyRate?: number): ProductivityImpact;
|
|
278
205
|
/**
|
|
279
|
-
* Predict AI suggestion acceptance rate
|
|
280
|
-
*
|
|
281
|
-
* Calibration notes (v0.12):
|
|
282
|
-
* - GitHub Copilot reports ~30% industry average acceptance rate (2023 blog)
|
|
283
|
-
* - Research (Ziegler et al., 2022) indicates acceptance rate is a proxy for productivity
|
|
284
|
-
* - Internal teams with high-consistency codebases report 40-55%
|
|
285
|
-
* - Teams with semantic duplication report 20-25% (AI suggests wrong variant)
|
|
286
|
-
* - Context efficiency is the strongest single predictor (empirical correlation: r=0.68)
|
|
287
|
-
*
|
|
288
|
-
* Confidence levels:
|
|
289
|
-
* - 3 tools: 0.75 (triangulated estimate)
|
|
290
|
-
* - 2 tools: 0.55 (partial estimate)
|
|
291
|
-
* - 1 tool: 0.35 (weak estimate — don't over-rely)
|
|
206
|
+
* Predict AI suggestion acceptance rate
|
|
292
207
|
*/
|
|
293
208
|
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
209
|
+
|
|
294
210
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* A future-proof abstraction that normalizes multiple factors
|
|
298
|
-
* into a single difficulty score. Lower = easier for AI.
|
|
299
|
-
*
|
|
300
|
-
* v0.12+: Now model-aware. Pass the `modelTier` of your AI toolchain
|
|
301
|
-
* to recalibrate token budget thresholds correctly. With frontier models
|
|
302
|
-
* (200k+ context), a 20k-token file is no longer "critical".
|
|
211
|
+
* Knowledge and Technical Debt Risk Metrics
|
|
303
212
|
*/
|
|
304
|
-
|
|
213
|
+
interface KnowledgeConcentrationRisk {
|
|
214
|
+
score: number;
|
|
215
|
+
rating: 'low' | 'moderate' | 'high' | 'critical';
|
|
216
|
+
analysis: {
|
|
217
|
+
uniqueConceptFiles: number;
|
|
218
|
+
totalFiles: number;
|
|
219
|
+
concentrationRatio: number;
|
|
220
|
+
singleAuthorFiles: number;
|
|
221
|
+
orphanFiles: number;
|
|
222
|
+
};
|
|
223
|
+
recommendations: string[];
|
|
224
|
+
}
|
|
225
|
+
declare function calculateKnowledgeConcentration(params: {
|
|
226
|
+
uniqueConceptFiles: number;
|
|
227
|
+
totalFiles: number;
|
|
228
|
+
singleAuthorFiles: number;
|
|
229
|
+
orphanFiles: number;
|
|
230
|
+
}): KnowledgeConcentrationRisk;
|
|
231
|
+
interface TechnicalDebtInterest {
|
|
232
|
+
monthlyRate: number;
|
|
233
|
+
annualRate: number;
|
|
234
|
+
principal: number;
|
|
235
|
+
projections: {
|
|
236
|
+
months6: number;
|
|
237
|
+
months12: number;
|
|
238
|
+
months24: number;
|
|
239
|
+
};
|
|
240
|
+
monthlyCost: number;
|
|
241
|
+
}
|
|
242
|
+
declare function calculateDebtInterest(principal: number, monthlyGrowthRate: number): TechnicalDebtInterest;
|
|
243
|
+
|
|
305
244
|
/**
|
|
306
|
-
*
|
|
245
|
+
* Calculate Technical Value Chain
|
|
307
246
|
*/
|
|
308
|
-
declare function
|
|
247
|
+
declare function calculateTechnicalValueChain(params: {
|
|
248
|
+
businessLogicDensity: number;
|
|
249
|
+
dataAccessComplexity: number;
|
|
250
|
+
apiSurfaceArea: number;
|
|
251
|
+
}): TechnicalValueChainSummary;
|
|
309
252
|
/**
|
|
310
|
-
*
|
|
253
|
+
* Calculate Comprehension Difficulty Index (CDI)
|
|
311
254
|
*/
|
|
312
|
-
declare function
|
|
255
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, modelTier?: ModelContextTier | string): ComprehensionDifficulty;
|
|
256
|
+
|
|
313
257
|
/**
|
|
314
|
-
*
|
|
258
|
+
* Business Value Metrics Module
|
|
259
|
+
*
|
|
260
|
+
* Provides business-aligned metrics that quantify ROI and survive technology changes.
|
|
315
261
|
*/
|
|
316
|
-
|
|
262
|
+
|
|
317
263
|
/**
|
|
318
|
-
*
|
|
264
|
+
* Historical score entry for trend tracking
|
|
319
265
|
*/
|
|
320
|
-
|
|
266
|
+
interface ScoreHistoryEntry {
|
|
267
|
+
timestamp: string;
|
|
268
|
+
overallScore: number;
|
|
269
|
+
breakdown: Record<string, number>;
|
|
270
|
+
totalIssues: number;
|
|
271
|
+
totalTokens: number;
|
|
272
|
+
}
|
|
321
273
|
/**
|
|
322
|
-
*
|
|
274
|
+
* Trend analysis comparing current vs historical scores
|
|
323
275
|
*/
|
|
324
|
-
|
|
276
|
+
interface ScoreTrend {
|
|
277
|
+
direction: 'improving' | 'stable' | 'degrading';
|
|
278
|
+
change30Days: number;
|
|
279
|
+
change90Days: number;
|
|
280
|
+
velocity: number;
|
|
281
|
+
projectedScore: number;
|
|
282
|
+
}
|
|
325
283
|
/**
|
|
326
|
-
* Calculate
|
|
327
|
-
*
|
|
328
|
-
* This measures how "centralized" knowledge is in the codebase,
|
|
329
|
-
* similar to bus factor but for AI/ML training purposes.
|
|
284
|
+
* Calculate Aggregate Business ROI
|
|
330
285
|
*/
|
|
331
|
-
declare function
|
|
332
|
-
|
|
333
|
-
exports: number;
|
|
334
|
-
imports: number;
|
|
335
|
-
}[], authorData?: Map<string, string[]>): KnowledgeConcentrationRisk;
|
|
336
|
-
/**
|
|
337
|
-
* Calculate technical debt interest rate
|
|
338
|
-
*
|
|
339
|
-
* The key insight: technical debt compounds over time.
|
|
340
|
-
* Each month, issues grow by a certain rate due to:
|
|
341
|
-
* - New code inheriting patterns
|
|
342
|
-
* - Context budget growing
|
|
343
|
-
* - Duplication spreading
|
|
344
|
-
*/
|
|
345
|
-
declare function calculateTechnicalDebtInterest(params: {
|
|
346
|
-
currentMonthlyCost: number;
|
|
286
|
+
declare function calculateBusinessROI(params: {
|
|
287
|
+
tokenWaste: number;
|
|
347
288
|
issues: {
|
|
348
289
|
severity: string;
|
|
349
290
|
}[];
|
|
350
|
-
|
|
351
|
-
|
|
291
|
+
developerCount?: number;
|
|
292
|
+
modelId?: string;
|
|
293
|
+
}): {
|
|
294
|
+
monthlySavings: number;
|
|
295
|
+
productivityGainHours: number;
|
|
296
|
+
annualValue: number;
|
|
297
|
+
};
|
|
352
298
|
/**
|
|
353
|
-
*
|
|
299
|
+
* Format cost for display
|
|
354
300
|
*/
|
|
355
|
-
declare function
|
|
301
|
+
declare function formatCost(cost: number): string;
|
|
356
302
|
/**
|
|
357
|
-
*
|
|
303
|
+
* Format hours for display
|
|
304
|
+
*/
|
|
305
|
+
declare function formatHours(hours: number): string;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Format acceptance rate for display
|
|
309
|
+
*/
|
|
310
|
+
declare function formatAcceptanceRate(rate: number): string;
|
|
311
|
+
/**
|
|
312
|
+
* Generate technical value chain for an issue (v0.12 legacy)
|
|
358
313
|
*/
|
|
359
314
|
declare function generateValueChain(params: {
|
|
360
315
|
issueType: string;
|
|
@@ -491,27 +446,8 @@ declare class PythonParser implements LanguageParser {
|
|
|
491
446
|
}
|
|
492
447
|
|
|
493
448
|
/**
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
* This module provides technology-agnostic metric primitives that will
|
|
497
|
-
* remain valid across changes in AI models, tokenization, and paradigms.
|
|
498
|
-
*
|
|
499
|
-
* The key insight: rather than measuring "tokens" or "import depth",
|
|
500
|
-
* we measure cognitive concepts that translate to any AI architecture:
|
|
501
|
-
* - Cognitive Load: How much mental effort for AI to understand
|
|
502
|
-
* - Semantic Distance: How far apart related concepts are
|
|
503
|
-
* - Concept Cohesion: How well grouped related ideas are
|
|
504
|
-
* - Pattern Entropy: How ordered vs chaotic the structure is
|
|
505
|
-
* - AI Signal Clarity: How likely AI is to generate incorrect code
|
|
506
|
-
* - Agent Grounding Score: How well an agent can navigate unaided
|
|
507
|
-
* - Testability Index: How verifiable AI-generated changes are
|
|
508
|
-
*
|
|
509
|
-
* v0.12+: Added AI signal clarity, agent grounding, and testability dimensions.
|
|
510
|
-
*/
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Factors that contribute to cognitive load for AI understanding
|
|
514
|
-
* These are normalized 0-100 factors that can be combined
|
|
449
|
+
* Cognitive Load Metrics
|
|
450
|
+
* Measures how much mental effort is required for an AI to understand a file.
|
|
515
451
|
*/
|
|
516
452
|
interface LoadFactor {
|
|
517
453
|
name: string;
|
|
@@ -519,10 +455,6 @@ interface LoadFactor {
|
|
|
519
455
|
weight: number;
|
|
520
456
|
description: string;
|
|
521
457
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Cognitive Load Assessment
|
|
524
|
-
* Replaces "token cost" with a multi-dimensional load analysis
|
|
525
|
-
*/
|
|
526
458
|
interface CognitiveLoad {
|
|
527
459
|
score: number;
|
|
528
460
|
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
@@ -534,9 +466,6 @@ interface CognitiveLoad {
|
|
|
534
466
|
conceptCount: number;
|
|
535
467
|
};
|
|
536
468
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Calculate cognitive load from raw file metrics
|
|
539
|
-
*/
|
|
540
469
|
declare function calculateCognitiveLoad(params: {
|
|
541
470
|
linesOfCode: number;
|
|
542
471
|
exportCount: number;
|
|
@@ -544,6 +473,11 @@ declare function calculateCognitiveLoad(params: {
|
|
|
544
473
|
uniqueConcepts: number;
|
|
545
474
|
cyclomaticComplexity?: number;
|
|
546
475
|
}): CognitiveLoad;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Semantic Distance Metrics
|
|
479
|
+
* Measures the conceptual distance between files or domains.
|
|
480
|
+
*/
|
|
547
481
|
interface SemanticDistance {
|
|
548
482
|
between: [string, string];
|
|
549
483
|
distance: number;
|
|
@@ -560,6 +494,11 @@ declare function calculateSemanticDistance(params: {
|
|
|
560
494
|
file2Imports: string[];
|
|
561
495
|
sharedDependencies: string[];
|
|
562
496
|
}): SemanticDistance;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Structural Metrics
|
|
500
|
+
* Measures pattern entropy and concept cohesion.
|
|
501
|
+
*/
|
|
563
502
|
interface PatternEntropy {
|
|
564
503
|
domain: string;
|
|
565
504
|
entropy: number;
|
|
@@ -592,15 +531,10 @@ declare function calculateConceptCohesion(params: {
|
|
|
592
531
|
domains?: string[];
|
|
593
532
|
}>;
|
|
594
533
|
}): ConceptCohesion;
|
|
595
|
-
|
|
596
|
-
cognitiveLoad: CognitiveLoad;
|
|
597
|
-
patternEntropy: PatternEntropy;
|
|
598
|
-
conceptCohesion: ConceptCohesion;
|
|
599
|
-
semanticDistances?: SemanticDistance[];
|
|
600
|
-
}): ToolScoringOutput;
|
|
534
|
+
|
|
601
535
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
536
|
+
* AI Signal Clarity Metrics
|
|
537
|
+
* Measures code patterns that increase the likelihood of AI generating incorrect code.
|
|
604
538
|
*/
|
|
605
539
|
interface AiSignalClaritySignal {
|
|
606
540
|
name: string;
|
|
@@ -609,162 +543,89 @@ interface AiSignalClaritySignal {
|
|
|
609
543
|
description: string;
|
|
610
544
|
examples?: string[];
|
|
611
545
|
}
|
|
612
|
-
/**
|
|
613
|
-
* AI Signal Clarity Score (0-100, higher = more risk)
|
|
614
|
-
*
|
|
615
|
-
* Measures code patterns that empirically cause AI models to:
|
|
616
|
-
* - Confidently generate incorrect function signatures
|
|
617
|
-
* - Create plausible-but-wrong implementations
|
|
618
|
-
* - Miss implicit contracts / side effects
|
|
619
|
-
* - Misunderstand overloaded symbols
|
|
620
|
-
*/
|
|
621
546
|
interface AiSignalClarity {
|
|
622
|
-
/** Overall risk score (0-100). Higher = more likely AI will hallucinate. */
|
|
623
547
|
score: number;
|
|
624
548
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
625
549
|
signals: AiSignalClaritySignal[];
|
|
626
|
-
/** Most impactful signal to fix first */
|
|
627
550
|
topRisk: string;
|
|
628
551
|
recommendations: string[];
|
|
629
552
|
}
|
|
630
|
-
/**
|
|
631
|
-
* Calculate AI signal clarity from code analysis results
|
|
632
|
-
*
|
|
633
|
-
* Input data can come from any parser; all inputs are normalized 0-N counts.
|
|
634
|
-
*/
|
|
635
553
|
declare function calculateAiSignalClarity(params: {
|
|
636
|
-
/** Overloaded function names (same name, different signatures) */
|
|
637
554
|
overloadedSymbols: number;
|
|
638
|
-
/** Magic numbers and string literals without named constants */
|
|
639
555
|
magicLiterals: number;
|
|
640
|
-
/** Boolean trap parameters (function(true, false, null)) */
|
|
641
556
|
booleanTraps: number;
|
|
642
|
-
/** Implicit returns / void-implicit side effect functions */
|
|
643
557
|
implicitSideEffects: number;
|
|
644
|
-
/** Callback nesting depth > 3 (callback hell indicator) */
|
|
645
558
|
deepCallbacks: number;
|
|
646
|
-
/** Non-descriptive names: single letters, x1/x2 patterns, tmp/data/obj */
|
|
647
559
|
ambiguousNames: number;
|
|
648
|
-
/** Exported symbols with no JSDoc/docstring */
|
|
649
560
|
undocumentedExports: number;
|
|
650
|
-
/** Total symbols analyzed (for normalization) */
|
|
651
561
|
totalSymbols: number;
|
|
652
|
-
/** Total exports in codebase */
|
|
653
562
|
totalExports: number;
|
|
654
563
|
}): AiSignalClarity;
|
|
564
|
+
|
|
655
565
|
/**
|
|
656
|
-
* Agent Grounding
|
|
657
|
-
*
|
|
658
|
-
* Measures how well an AI agent can navigate a codebase *independently*,
|
|
659
|
-
* without human assistance or extensive prompting.
|
|
660
|
-
*
|
|
661
|
-
* High grounding = agent can find files, understand project structure,
|
|
662
|
-
* locate relevant code, and correctly infer ownership without being told.
|
|
663
|
-
*
|
|
664
|
-
* This is technology-agnostic: any agentic system (current or future)
|
|
665
|
-
* needs these structural guarantees to work effectively.
|
|
566
|
+
* Agent Grounding Metrics
|
|
567
|
+
* Measures how well an AI agent can navigate a codebase independently.
|
|
666
568
|
*/
|
|
667
569
|
interface AgentGroundingScore {
|
|
668
|
-
/** 0-100 score; higher = better self-navigation */
|
|
669
570
|
score: number;
|
|
670
571
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'disorienting';
|
|
671
572
|
dimensions: {
|
|
672
|
-
/** Can agent find where to put new code? (directory structure clarity) */
|
|
673
573
|
structureClarityScore: number;
|
|
674
|
-
/** Can agent understand what a file does from its name alone? */
|
|
675
574
|
selfDocumentationScore: number;
|
|
676
|
-
/** Are entry points (index, main, README) present and accurate? */
|
|
677
575
|
entryPointScore: number;
|
|
678
|
-
/** Does the public API surface reflect the project's mental model? */
|
|
679
576
|
apiClarityScore: number;
|
|
680
|
-
/** Is the domain language consistent? (Same concept = same word everywhere) */
|
|
681
577
|
domainConsistencyScore: number;
|
|
682
578
|
};
|
|
683
579
|
recommendations: string[];
|
|
684
580
|
}
|
|
685
|
-
/**
|
|
686
|
-
* Calculate how well an AI agent can ground itself in the codebase
|
|
687
|
-
*/
|
|
688
581
|
declare function calculateAgentGrounding(params: {
|
|
689
|
-
/** Number of directories exceeding recommended depth (> 4 levels) */
|
|
690
582
|
deepDirectories: number;
|
|
691
|
-
/** Total directories */
|
|
692
583
|
totalDirectories: number;
|
|
693
|
-
/** Files whose name alone doesn't reveal purpose (e.g., utils.ts, helpers.ts, misc.ts) */
|
|
694
584
|
vagueFileNames: number;
|
|
695
|
-
/** Total files */
|
|
696
585
|
totalFiles: number;
|
|
697
|
-
/** Whether a root README exists */
|
|
698
586
|
hasRootReadme: boolean;
|
|
699
|
-
/** Whether README has been updated in last 90 days (or unknown) */
|
|
700
587
|
readmeIsFresh: boolean;
|
|
701
|
-
/** Number of barrel exports (index.ts/index.js files that re-export) */
|
|
702
588
|
barrelExports: number;
|
|
703
|
-
/** Number of exported functions/classes/types with no type annotations */
|
|
704
589
|
untypedExports: number;
|
|
705
|
-
/** Total exports */
|
|
706
590
|
totalExports: number;
|
|
707
|
-
/** Number of domain terms used inconsistently (same concept, different names) */
|
|
708
591
|
inconsistentDomainTerms: number;
|
|
709
|
-
/** Distinct domain vocabulary size (unique business terms detected) */
|
|
710
592
|
domainVocabularySize: number;
|
|
711
593
|
}): AgentGroundingScore;
|
|
594
|
+
|
|
712
595
|
/**
|
|
713
|
-
* Testability Index
|
|
714
|
-
*
|
|
596
|
+
* Testability Index Metrics
|
|
715
597
|
* Measures how verifiable AI-generated changes are.
|
|
716
|
-
* AI assistants are only as useful as your ability to validate their output.
|
|
717
|
-
*
|
|
718
|
-
* Core insight: A codebase where generated code CAN'T be verified
|
|
719
|
-
* is one where AI assistance actively introduces hidden risk.
|
|
720
|
-
*
|
|
721
|
-
* Technology-agnostic: test frameworks change; testability principles don't.
|
|
722
598
|
*/
|
|
723
599
|
interface TestabilityIndex {
|
|
724
|
-
/** 0-100 score; higher = AI changes are more verifiable */
|
|
725
600
|
score: number;
|
|
726
601
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'unverifiable';
|
|
727
602
|
dimensions: {
|
|
728
|
-
/** Ratio of test files to source files */
|
|
729
603
|
testCoverageRatio: number;
|
|
730
|
-
/** Pure function prevalence (no side effects = easy to test) */
|
|
731
604
|
purityScore: number;
|
|
732
|
-
/** Dependency injection / inversion of control score */
|
|
733
605
|
dependencyInjectionScore: number;
|
|
734
|
-
/** Interface segregation (small, focused interfaces) */
|
|
735
606
|
interfaceFocusScore: number;
|
|
736
|
-
/** Observable outputs (functions return values vs mutate state) */
|
|
737
607
|
observabilityScore: number;
|
|
738
608
|
};
|
|
739
|
-
/** Estimated AI suggestion safety — without tests, AI changes are high-risk */
|
|
740
609
|
aiChangeSafetyRating: 'safe' | 'moderate-risk' | 'high-risk' | 'blind-risk';
|
|
741
610
|
recommendations: string[];
|
|
742
611
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Calculate testability index from code structure analysis
|
|
745
|
-
*/
|
|
746
612
|
declare function calculateTestabilityIndex(params: {
|
|
747
|
-
/** Number of test files (*.test.*, *.spec.*, __tests__/**) */
|
|
748
613
|
testFiles: number;
|
|
749
|
-
/** Number of source files (excluding tests, configs) */
|
|
750
614
|
sourceFiles: number;
|
|
751
|
-
/** Functions that take only data and return data (no I/O, no mutations) */
|
|
752
615
|
pureFunctions: number;
|
|
753
|
-
/** Total functions analyzed */
|
|
754
616
|
totalFunctions: number;
|
|
755
|
-
/** Classes/functions using constructor injection or factory patterns */
|
|
756
617
|
injectionPatterns: number;
|
|
757
|
-
/** Total classes/services */
|
|
758
618
|
totalClasses: number;
|
|
759
|
-
/** Interfaces/types with > 10 methods (low segregation) */
|
|
760
619
|
bloatedInterfaces: number;
|
|
761
|
-
/** Total interfaces/types */
|
|
762
620
|
totalInterfaces: number;
|
|
763
|
-
/** Functions that directly mutate external state (globals, DOM, DB without abstraction) */
|
|
764
621
|
externalStateMutations: number;
|
|
765
|
-
/** Has a defined testing framework (package.json test script exists) */
|
|
766
622
|
hasTestFramework: boolean;
|
|
767
623
|
}): TestabilityIndex;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Documentation Drift Metrics
|
|
627
|
+
* Measures the risk of documentation becoming out of sync with code.
|
|
628
|
+
*/
|
|
768
629
|
interface DocDriftRisk {
|
|
769
630
|
score: number;
|
|
770
631
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
@@ -781,6 +642,11 @@ declare function calculateDocDrift(params: {
|
|
|
781
642
|
outdatedComments: number;
|
|
782
643
|
undocumentedComplexity: number;
|
|
783
644
|
}): DocDriftRisk;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Dependency Health Metrics
|
|
648
|
+
* Measures the health and recency of project dependencies.
|
|
649
|
+
*/
|
|
784
650
|
interface DependencyHealthScore {
|
|
785
651
|
score: number;
|
|
786
652
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'hazardous';
|
|
@@ -798,6 +664,11 @@ declare function calculateDependencyHealth(params: {
|
|
|
798
664
|
deprecatedPackages: number;
|
|
799
665
|
trainingCutoffSkew: number;
|
|
800
666
|
}): DependencyHealthScore;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Change Amplification Metrics
|
|
670
|
+
* Measures how a change in one file ripples through the system.
|
|
671
|
+
*/
|
|
801
672
|
interface ChangeAmplificationScore {
|
|
802
673
|
score: number;
|
|
803
674
|
rating: 'isolated' | 'contained' | 'amplified' | 'explosive';
|
|
@@ -818,9 +689,25 @@ declare function calculateChangeAmplification(params: {
|
|
|
818
689
|
fanIn: number;
|
|
819
690
|
}>;
|
|
820
691
|
}): ChangeAmplificationScore;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Future-Proof AI Metrics Abstraction Layer
|
|
695
|
+
*
|
|
696
|
+
* This module provides technology-agnostic metric primitives that will
|
|
697
|
+
* remain valid across changes in AI models, tokenization, and paradigms.
|
|
698
|
+
*/
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Aggregate Future-Proof Score (Base)
|
|
702
|
+
*/
|
|
703
|
+
declare function calculateFutureProofScore(params: {
|
|
704
|
+
cognitiveLoad: CognitiveLoad;
|
|
705
|
+
patternEntropy: PatternEntropy;
|
|
706
|
+
conceptCohesion: ConceptCohesion;
|
|
707
|
+
semanticDistances?: SemanticDistance[];
|
|
708
|
+
}): ToolScoringOutput;
|
|
821
709
|
/**
|
|
822
|
-
*
|
|
823
|
-
* Replaces calculateFutureProofScore when all dimensions are available.
|
|
710
|
+
* Complete Extended Future-Proof Score
|
|
824
711
|
*/
|
|
825
712
|
declare function calculateExtendedFutureProofScore(params: {
|
|
826
713
|
cognitiveLoad: CognitiveLoad;
|
|
@@ -889,4 +776,4 @@ declare function getRepoMetadata(directory: string): {
|
|
|
889
776
|
author?: string;
|
|
890
777
|
};
|
|
891
778
|
|
|
892
|
-
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type
|
|
779
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, type CLIOptions, type ChangeAmplificationScore, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, SEVERITY_TIME_ESTIMATES, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, VAGUE_FILE_NAMES, calculateAgentGrounding, calculateAiSignalClarity, calculateBusinessROI, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDebtInterest, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateSemanticDistance, calculateTechnicalValueChain, calculateTestabilityIndex, calculateTokenBudget, clearHistory, estimateCostFromBudget, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, generateValueChain, getElapsedTime, getFileCommitTimestamps, getFileExtension, getHistorySummary, getLineRangeLastModifiedCached, getModelPreset, getParser, getRepoMetadata, getSafetyIcon, getScoreBar, getSeverityColor, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanEntries, scanFiles };
|