@aiready/core 0.9.38 → 0.17.0
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/README.md +3 -0
- package/dist/client.d.mts +14 -6
- package/dist/client.d.ts +14 -6
- package/dist/index.d.mts +221 -281
- package/dist/index.d.ts +221 -281
- package/dist/index.js +464 -542
- package/dist/index.mjs +455 -537
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
|
-
import { ScanOptions, AIReadyConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { AnalysisResult, ScanOptions, AIReadyConfig, ModelContextTier, CostConfig, TokenBudget, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, ComprehensionDifficulty, TechnicalValueChainSummary, TechnicalValueChain, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
|
|
2
|
+
export { 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
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Spoke-to-Hub Contract Definitions
|
|
6
|
+
* This file defines the expected JSON structure for tool outputs to ensure
|
|
7
|
+
* changes in spokes don't break the CLI, Platform, or Visualizer.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The standard output every spoke MUST provide when analyzed.
|
|
12
|
+
* Some fields are optional depending on the tool's focus.
|
|
13
|
+
*/
|
|
14
|
+
interface SpokeOutput {
|
|
15
|
+
results: AnalysisResult[];
|
|
16
|
+
summary: any;
|
|
17
|
+
metadata?: {
|
|
18
|
+
toolName: string;
|
|
19
|
+
version: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Validation utility to ensure a spoke's output matches the expected contract.
|
|
26
|
+
* Used in spoke tests to catch breakages early.
|
|
27
|
+
*/
|
|
28
|
+
declare function validateSpokeOutput(toolName: string, output: any): {
|
|
29
|
+
valid: boolean;
|
|
30
|
+
errors: string[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The unified report format produced by the CLI and consumed by the Platform.
|
|
34
|
+
* This is the master contract for the entire system.
|
|
35
|
+
*/
|
|
36
|
+
interface UnifiedReport {
|
|
37
|
+
summary: {
|
|
38
|
+
totalFiles: number;
|
|
39
|
+
totalIssues: number;
|
|
40
|
+
criticalIssues: number;
|
|
41
|
+
majorIssues: number;
|
|
42
|
+
};
|
|
43
|
+
results: AnalysisResult[];
|
|
44
|
+
scoring?: {
|
|
45
|
+
overall: number;
|
|
46
|
+
rating: string;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
breakdown: Array<{
|
|
49
|
+
toolName: string;
|
|
50
|
+
score: number;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
[toolKey: string]: any;
|
|
55
|
+
}
|
|
3
56
|
|
|
4
57
|
declare const DEFAULT_EXCLUDE: string[];
|
|
5
58
|
declare const VAGUE_FILE_NAMES: Set<string>;
|
|
@@ -120,23 +173,24 @@ declare function handleCLIError(error: unknown, commandName: string): never;
|
|
|
120
173
|
* Calculate elapsed time and format for display
|
|
121
174
|
*/
|
|
122
175
|
declare function getElapsedTime(startTime: number): string;
|
|
123
|
-
|
|
124
176
|
/**
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
177
|
+
* Generate a visual score bar for console output
|
|
178
|
+
*/
|
|
179
|
+
declare function getScoreBar(val: number): string;
|
|
180
|
+
/**
|
|
181
|
+
* Get status icon for safety ratings
|
|
182
|
+
*/
|
|
183
|
+
declare function getSafetyIcon(rating: string): string;
|
|
184
|
+
/**
|
|
185
|
+
* Get chalk color function for a given severity
|
|
186
|
+
* @param severity severity level
|
|
187
|
+
* @param chalk chalk instance
|
|
134
188
|
*/
|
|
189
|
+
declare function getSeverityColor(severity: string, chalk: any): any;
|
|
135
190
|
|
|
136
191
|
/**
|
|
137
192
|
* AI model pricing presets for cost estimation.
|
|
138
193
|
* 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
194
|
*/
|
|
141
195
|
interface ModelPricingPreset {
|
|
142
196
|
name: string;
|
|
@@ -151,96 +205,14 @@ declare const MODEL_PRICING_PRESETS: Record<string, ModelPricingPreset>;
|
|
|
151
205
|
* Get a model pricing preset by ID, with fallback to claude-4.6 (2026 default)
|
|
152
206
|
*/
|
|
153
207
|
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
|
-
}
|
|
208
|
+
|
|
233
209
|
/**
|
|
234
210
|
* 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
211
|
*/
|
|
238
212
|
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
239
213
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
* Calculate estimated monthly cost of AI context waste with confidence intervals.
|
|
214
|
+
* Calculate estimated monthly cost of AI context waste
|
|
215
|
+
* @deprecated Since v0.13
|
|
244
216
|
*/
|
|
245
217
|
declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostConfig>): {
|
|
246
218
|
total: number;
|
|
@@ -248,8 +220,7 @@ declare function calculateMonthlyCost(tokenWaste: number, config?: Partial<CostC
|
|
|
248
220
|
confidence: number;
|
|
249
221
|
};
|
|
250
222
|
/**
|
|
251
|
-
* Calculate token budget and unit economics
|
|
252
|
-
* Technology-agnostic metric that remains valid across model generations.
|
|
223
|
+
* Calculate token budget and unit economics
|
|
253
224
|
*/
|
|
254
225
|
declare function calculateTokenBudget(params: {
|
|
255
226
|
totalContextTokens: number;
|
|
@@ -261,14 +232,23 @@ declare function calculateTokenBudget(params: {
|
|
|
261
232
|
};
|
|
262
233
|
}): TokenBudget;
|
|
263
234
|
/**
|
|
264
|
-
* Estimate dollar cost from a token budget
|
|
265
|
-
* Note: Use this for presentation only. Token budgets are the primary metric.
|
|
235
|
+
* Estimate dollar cost from a token budget
|
|
266
236
|
*/
|
|
267
237
|
declare function estimateCostFromBudget(budget: TokenBudget, model: ModelPricingPreset, config?: Partial<CostConfig>): {
|
|
268
238
|
total: number;
|
|
269
239
|
range: [number, number];
|
|
270
240
|
confidence: number;
|
|
271
241
|
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Severity time estimates (hours to fix)
|
|
245
|
+
*/
|
|
246
|
+
declare const SEVERITY_TIME_ESTIMATES: {
|
|
247
|
+
critical: number;
|
|
248
|
+
major: number;
|
|
249
|
+
minor: number;
|
|
250
|
+
info: number;
|
|
251
|
+
};
|
|
272
252
|
/**
|
|
273
253
|
* Calculate productivity impact from issues
|
|
274
254
|
*/
|
|
@@ -276,85 +256,113 @@ declare function calculateProductivityImpact(issues: {
|
|
|
276
256
|
severity: string;
|
|
277
257
|
}[], hourlyRate?: number): ProductivityImpact;
|
|
278
258
|
/**
|
|
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)
|
|
259
|
+
* Predict AI suggestion acceptance rate
|
|
292
260
|
*/
|
|
293
261
|
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
262
|
+
|
|
294
263
|
/**
|
|
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".
|
|
264
|
+
* Knowledge and Technical Debt Risk Metrics
|
|
303
265
|
*/
|
|
304
|
-
|
|
266
|
+
interface KnowledgeConcentrationRisk {
|
|
267
|
+
score: number;
|
|
268
|
+
rating: 'low' | 'moderate' | 'high' | 'critical';
|
|
269
|
+
analysis: {
|
|
270
|
+
uniqueConceptFiles: number;
|
|
271
|
+
totalFiles: number;
|
|
272
|
+
concentrationRatio: number;
|
|
273
|
+
singleAuthorFiles: number;
|
|
274
|
+
orphanFiles: number;
|
|
275
|
+
};
|
|
276
|
+
recommendations: string[];
|
|
277
|
+
}
|
|
278
|
+
declare function calculateKnowledgeConcentration(params: {
|
|
279
|
+
uniqueConceptFiles: number;
|
|
280
|
+
totalFiles: number;
|
|
281
|
+
singleAuthorFiles: number;
|
|
282
|
+
orphanFiles: number;
|
|
283
|
+
}): KnowledgeConcentrationRisk;
|
|
284
|
+
interface TechnicalDebtInterest {
|
|
285
|
+
monthlyRate: number;
|
|
286
|
+
annualRate: number;
|
|
287
|
+
principal: number;
|
|
288
|
+
projections: {
|
|
289
|
+
months6: number;
|
|
290
|
+
months12: number;
|
|
291
|
+
months24: number;
|
|
292
|
+
};
|
|
293
|
+
monthlyCost: number;
|
|
294
|
+
}
|
|
295
|
+
declare function calculateDebtInterest(principal: number, monthlyGrowthRate: number): TechnicalDebtInterest;
|
|
296
|
+
|
|
305
297
|
/**
|
|
306
|
-
*
|
|
298
|
+
* Calculate Technical Value Chain
|
|
307
299
|
*/
|
|
308
|
-
declare function
|
|
300
|
+
declare function calculateTechnicalValueChain(params: {
|
|
301
|
+
businessLogicDensity: number;
|
|
302
|
+
dataAccessComplexity: number;
|
|
303
|
+
apiSurfaceArea: number;
|
|
304
|
+
}): TechnicalValueChainSummary;
|
|
309
305
|
/**
|
|
310
|
-
*
|
|
306
|
+
* Calculate Comprehension Difficulty Index (CDI)
|
|
311
307
|
*/
|
|
312
|
-
declare function
|
|
308
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, modelTier?: ModelContextTier | string): ComprehensionDifficulty;
|
|
309
|
+
|
|
313
310
|
/**
|
|
314
|
-
*
|
|
311
|
+
* Business Value Metrics Module
|
|
312
|
+
*
|
|
313
|
+
* Provides business-aligned metrics that quantify ROI and survive technology changes.
|
|
315
314
|
*/
|
|
316
|
-
|
|
315
|
+
|
|
317
316
|
/**
|
|
318
|
-
*
|
|
317
|
+
* Historical score entry for trend tracking
|
|
319
318
|
*/
|
|
320
|
-
|
|
319
|
+
interface ScoreHistoryEntry {
|
|
320
|
+
timestamp: string;
|
|
321
|
+
overallScore: number;
|
|
322
|
+
breakdown: Record<string, number>;
|
|
323
|
+
totalIssues: number;
|
|
324
|
+
totalTokens: number;
|
|
325
|
+
}
|
|
321
326
|
/**
|
|
322
|
-
*
|
|
327
|
+
* Trend analysis comparing current vs historical scores
|
|
323
328
|
*/
|
|
324
|
-
|
|
329
|
+
interface ScoreTrend {
|
|
330
|
+
direction: 'improving' | 'stable' | 'degrading';
|
|
331
|
+
change30Days: number;
|
|
332
|
+
change90Days: number;
|
|
333
|
+
velocity: number;
|
|
334
|
+
projectedScore: number;
|
|
335
|
+
}
|
|
325
336
|
/**
|
|
326
|
-
* Calculate
|
|
327
|
-
*
|
|
328
|
-
* This measures how "centralized" knowledge is in the codebase,
|
|
329
|
-
* similar to bus factor but for AI/ML training purposes.
|
|
337
|
+
* Calculate Aggregate Business ROI
|
|
330
338
|
*/
|
|
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;
|
|
339
|
+
declare function calculateBusinessROI(params: {
|
|
340
|
+
tokenWaste: number;
|
|
347
341
|
issues: {
|
|
348
342
|
severity: string;
|
|
349
343
|
}[];
|
|
350
|
-
|
|
351
|
-
|
|
344
|
+
developerCount?: number;
|
|
345
|
+
modelId?: string;
|
|
346
|
+
}): {
|
|
347
|
+
monthlySavings: number;
|
|
348
|
+
productivityGainHours: number;
|
|
349
|
+
annualValue: number;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Format cost for display
|
|
353
|
+
*/
|
|
354
|
+
declare function formatCost(cost: number): string;
|
|
352
355
|
/**
|
|
353
|
-
*
|
|
356
|
+
* Format hours for display
|
|
357
|
+
*/
|
|
358
|
+
declare function formatHours(hours: number): string;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Format acceptance rate for display
|
|
354
362
|
*/
|
|
355
|
-
declare function
|
|
363
|
+
declare function formatAcceptanceRate(rate: number): string;
|
|
356
364
|
/**
|
|
357
|
-
* Generate
|
|
365
|
+
* Generate technical value chain for an issue (v0.12 legacy)
|
|
358
366
|
*/
|
|
359
367
|
declare function generateValueChain(params: {
|
|
360
368
|
issueType: string;
|
|
@@ -491,27 +499,8 @@ declare class PythonParser implements LanguageParser {
|
|
|
491
499
|
}
|
|
492
500
|
|
|
493
501
|
/**
|
|
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
|
|
502
|
+
* Cognitive Load Metrics
|
|
503
|
+
* Measures how much mental effort is required for an AI to understand a file.
|
|
515
504
|
*/
|
|
516
505
|
interface LoadFactor {
|
|
517
506
|
name: string;
|
|
@@ -519,10 +508,6 @@ interface LoadFactor {
|
|
|
519
508
|
weight: number;
|
|
520
509
|
description: string;
|
|
521
510
|
}
|
|
522
|
-
/**
|
|
523
|
-
* Cognitive Load Assessment
|
|
524
|
-
* Replaces "token cost" with a multi-dimensional load analysis
|
|
525
|
-
*/
|
|
526
511
|
interface CognitiveLoad {
|
|
527
512
|
score: number;
|
|
528
513
|
rating: 'trivial' | 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
@@ -534,9 +519,6 @@ interface CognitiveLoad {
|
|
|
534
519
|
conceptCount: number;
|
|
535
520
|
};
|
|
536
521
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Calculate cognitive load from raw file metrics
|
|
539
|
-
*/
|
|
540
522
|
declare function calculateCognitiveLoad(params: {
|
|
541
523
|
linesOfCode: number;
|
|
542
524
|
exportCount: number;
|
|
@@ -544,6 +526,11 @@ declare function calculateCognitiveLoad(params: {
|
|
|
544
526
|
uniqueConcepts: number;
|
|
545
527
|
cyclomaticComplexity?: number;
|
|
546
528
|
}): CognitiveLoad;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Semantic Distance Metrics
|
|
532
|
+
* Measures the conceptual distance between files or domains.
|
|
533
|
+
*/
|
|
547
534
|
interface SemanticDistance {
|
|
548
535
|
between: [string, string];
|
|
549
536
|
distance: number;
|
|
@@ -560,6 +547,11 @@ declare function calculateSemanticDistance(params: {
|
|
|
560
547
|
file2Imports: string[];
|
|
561
548
|
sharedDependencies: string[];
|
|
562
549
|
}): SemanticDistance;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Structural Metrics
|
|
553
|
+
* Measures pattern entropy and concept cohesion.
|
|
554
|
+
*/
|
|
563
555
|
interface PatternEntropy {
|
|
564
556
|
domain: string;
|
|
565
557
|
entropy: number;
|
|
@@ -592,15 +584,10 @@ declare function calculateConceptCohesion(params: {
|
|
|
592
584
|
domains?: string[];
|
|
593
585
|
}>;
|
|
594
586
|
}): ConceptCohesion;
|
|
595
|
-
|
|
596
|
-
cognitiveLoad: CognitiveLoad;
|
|
597
|
-
patternEntropy: PatternEntropy;
|
|
598
|
-
conceptCohesion: ConceptCohesion;
|
|
599
|
-
semanticDistances?: SemanticDistance[];
|
|
600
|
-
}): ToolScoringOutput;
|
|
587
|
+
|
|
601
588
|
/**
|
|
602
|
-
*
|
|
603
|
-
*
|
|
589
|
+
* AI Signal Clarity Metrics
|
|
590
|
+
* Measures code patterns that increase the likelihood of AI generating incorrect code.
|
|
604
591
|
*/
|
|
605
592
|
interface AiSignalClaritySignal {
|
|
606
593
|
name: string;
|
|
@@ -609,162 +596,89 @@ interface AiSignalClaritySignal {
|
|
|
609
596
|
description: string;
|
|
610
597
|
examples?: string[];
|
|
611
598
|
}
|
|
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
599
|
interface AiSignalClarity {
|
|
622
|
-
/** Overall risk score (0-100). Higher = more likely AI will hallucinate. */
|
|
623
600
|
score: number;
|
|
624
601
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
625
602
|
signals: AiSignalClaritySignal[];
|
|
626
|
-
/** Most impactful signal to fix first */
|
|
627
603
|
topRisk: string;
|
|
628
604
|
recommendations: string[];
|
|
629
605
|
}
|
|
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
606
|
declare function calculateAiSignalClarity(params: {
|
|
636
|
-
/** Overloaded function names (same name, different signatures) */
|
|
637
607
|
overloadedSymbols: number;
|
|
638
|
-
/** Magic numbers and string literals without named constants */
|
|
639
608
|
magicLiterals: number;
|
|
640
|
-
/** Boolean trap parameters (function(true, false, null)) */
|
|
641
609
|
booleanTraps: number;
|
|
642
|
-
/** Implicit returns / void-implicit side effect functions */
|
|
643
610
|
implicitSideEffects: number;
|
|
644
|
-
/** Callback nesting depth > 3 (callback hell indicator) */
|
|
645
611
|
deepCallbacks: number;
|
|
646
|
-
/** Non-descriptive names: single letters, x1/x2 patterns, tmp/data/obj */
|
|
647
612
|
ambiguousNames: number;
|
|
648
|
-
/** Exported symbols with no JSDoc/docstring */
|
|
649
613
|
undocumentedExports: number;
|
|
650
|
-
/** Total symbols analyzed (for normalization) */
|
|
651
614
|
totalSymbols: number;
|
|
652
|
-
/** Total exports in codebase */
|
|
653
615
|
totalExports: number;
|
|
654
616
|
}): AiSignalClarity;
|
|
617
|
+
|
|
655
618
|
/**
|
|
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.
|
|
619
|
+
* Agent Grounding Metrics
|
|
620
|
+
* Measures how well an AI agent can navigate a codebase independently.
|
|
666
621
|
*/
|
|
667
622
|
interface AgentGroundingScore {
|
|
668
|
-
/** 0-100 score; higher = better self-navigation */
|
|
669
623
|
score: number;
|
|
670
624
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'disorienting';
|
|
671
625
|
dimensions: {
|
|
672
|
-
/** Can agent find where to put new code? (directory structure clarity) */
|
|
673
626
|
structureClarityScore: number;
|
|
674
|
-
/** Can agent understand what a file does from its name alone? */
|
|
675
627
|
selfDocumentationScore: number;
|
|
676
|
-
/** Are entry points (index, main, README) present and accurate? */
|
|
677
628
|
entryPointScore: number;
|
|
678
|
-
/** Does the public API surface reflect the project's mental model? */
|
|
679
629
|
apiClarityScore: number;
|
|
680
|
-
/** Is the domain language consistent? (Same concept = same word everywhere) */
|
|
681
630
|
domainConsistencyScore: number;
|
|
682
631
|
};
|
|
683
632
|
recommendations: string[];
|
|
684
633
|
}
|
|
685
|
-
/**
|
|
686
|
-
* Calculate how well an AI agent can ground itself in the codebase
|
|
687
|
-
*/
|
|
688
634
|
declare function calculateAgentGrounding(params: {
|
|
689
|
-
/** Number of directories exceeding recommended depth (> 4 levels) */
|
|
690
635
|
deepDirectories: number;
|
|
691
|
-
/** Total directories */
|
|
692
636
|
totalDirectories: number;
|
|
693
|
-
/** Files whose name alone doesn't reveal purpose (e.g., utils.ts, helpers.ts, misc.ts) */
|
|
694
637
|
vagueFileNames: number;
|
|
695
|
-
/** Total files */
|
|
696
638
|
totalFiles: number;
|
|
697
|
-
/** Whether a root README exists */
|
|
698
639
|
hasRootReadme: boolean;
|
|
699
|
-
/** Whether README has been updated in last 90 days (or unknown) */
|
|
700
640
|
readmeIsFresh: boolean;
|
|
701
|
-
/** Number of barrel exports (index.ts/index.js files that re-export) */
|
|
702
641
|
barrelExports: number;
|
|
703
|
-
/** Number of exported functions/classes/types with no type annotations */
|
|
704
642
|
untypedExports: number;
|
|
705
|
-
/** Total exports */
|
|
706
643
|
totalExports: number;
|
|
707
|
-
/** Number of domain terms used inconsistently (same concept, different names) */
|
|
708
644
|
inconsistentDomainTerms: number;
|
|
709
|
-
/** Distinct domain vocabulary size (unique business terms detected) */
|
|
710
645
|
domainVocabularySize: number;
|
|
711
646
|
}): AgentGroundingScore;
|
|
647
|
+
|
|
712
648
|
/**
|
|
713
|
-
* Testability Index
|
|
714
|
-
*
|
|
649
|
+
* Testability Index Metrics
|
|
715
650
|
* 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
651
|
*/
|
|
723
652
|
interface TestabilityIndex {
|
|
724
|
-
/** 0-100 score; higher = AI changes are more verifiable */
|
|
725
653
|
score: number;
|
|
726
654
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'unverifiable';
|
|
727
655
|
dimensions: {
|
|
728
|
-
/** Ratio of test files to source files */
|
|
729
656
|
testCoverageRatio: number;
|
|
730
|
-
/** Pure function prevalence (no side effects = easy to test) */
|
|
731
657
|
purityScore: number;
|
|
732
|
-
/** Dependency injection / inversion of control score */
|
|
733
658
|
dependencyInjectionScore: number;
|
|
734
|
-
/** Interface segregation (small, focused interfaces) */
|
|
735
659
|
interfaceFocusScore: number;
|
|
736
|
-
/** Observable outputs (functions return values vs mutate state) */
|
|
737
660
|
observabilityScore: number;
|
|
738
661
|
};
|
|
739
|
-
/** Estimated AI suggestion safety — without tests, AI changes are high-risk */
|
|
740
662
|
aiChangeSafetyRating: 'safe' | 'moderate-risk' | 'high-risk' | 'blind-risk';
|
|
741
663
|
recommendations: string[];
|
|
742
664
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Calculate testability index from code structure analysis
|
|
745
|
-
*/
|
|
746
665
|
declare function calculateTestabilityIndex(params: {
|
|
747
|
-
/** Number of test files (*.test.*, *.spec.*, __tests__/**) */
|
|
748
666
|
testFiles: number;
|
|
749
|
-
/** Number of source files (excluding tests, configs) */
|
|
750
667
|
sourceFiles: number;
|
|
751
|
-
/** Functions that take only data and return data (no I/O, no mutations) */
|
|
752
668
|
pureFunctions: number;
|
|
753
|
-
/** Total functions analyzed */
|
|
754
669
|
totalFunctions: number;
|
|
755
|
-
/** Classes/functions using constructor injection or factory patterns */
|
|
756
670
|
injectionPatterns: number;
|
|
757
|
-
/** Total classes/services */
|
|
758
671
|
totalClasses: number;
|
|
759
|
-
/** Interfaces/types with > 10 methods (low segregation) */
|
|
760
672
|
bloatedInterfaces: number;
|
|
761
|
-
/** Total interfaces/types */
|
|
762
673
|
totalInterfaces: number;
|
|
763
|
-
/** Functions that directly mutate external state (globals, DOM, DB without abstraction) */
|
|
764
674
|
externalStateMutations: number;
|
|
765
|
-
/** Has a defined testing framework (package.json test script exists) */
|
|
766
675
|
hasTestFramework: boolean;
|
|
767
676
|
}): TestabilityIndex;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Documentation Drift Metrics
|
|
680
|
+
* Measures the risk of documentation becoming out of sync with code.
|
|
681
|
+
*/
|
|
768
682
|
interface DocDriftRisk {
|
|
769
683
|
score: number;
|
|
770
684
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
@@ -781,6 +695,11 @@ declare function calculateDocDrift(params: {
|
|
|
781
695
|
outdatedComments: number;
|
|
782
696
|
undocumentedComplexity: number;
|
|
783
697
|
}): DocDriftRisk;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Dependency Health Metrics
|
|
701
|
+
* Measures the health and recency of project dependencies.
|
|
702
|
+
*/
|
|
784
703
|
interface DependencyHealthScore {
|
|
785
704
|
score: number;
|
|
786
705
|
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'hazardous';
|
|
@@ -798,6 +717,11 @@ declare function calculateDependencyHealth(params: {
|
|
|
798
717
|
deprecatedPackages: number;
|
|
799
718
|
trainingCutoffSkew: number;
|
|
800
719
|
}): DependencyHealthScore;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Change Amplification Metrics
|
|
723
|
+
* Measures how a change in one file ripples through the system.
|
|
724
|
+
*/
|
|
801
725
|
interface ChangeAmplificationScore {
|
|
802
726
|
score: number;
|
|
803
727
|
rating: 'isolated' | 'contained' | 'amplified' | 'explosive';
|
|
@@ -818,9 +742,25 @@ declare function calculateChangeAmplification(params: {
|
|
|
818
742
|
fanIn: number;
|
|
819
743
|
}>;
|
|
820
744
|
}): ChangeAmplificationScore;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Future-Proof AI Metrics Abstraction Layer
|
|
748
|
+
*
|
|
749
|
+
* This module provides technology-agnostic metric primitives that will
|
|
750
|
+
* remain valid across changes in AI models, tokenization, and paradigms.
|
|
751
|
+
*/
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Aggregate Future-Proof Score (Base)
|
|
755
|
+
*/
|
|
756
|
+
declare function calculateFutureProofScore(params: {
|
|
757
|
+
cognitiveLoad: CognitiveLoad;
|
|
758
|
+
patternEntropy: PatternEntropy;
|
|
759
|
+
conceptCohesion: ConceptCohesion;
|
|
760
|
+
semanticDistances?: SemanticDistance[];
|
|
761
|
+
}): ToolScoringOutput;
|
|
821
762
|
/**
|
|
822
|
-
*
|
|
823
|
-
* Replaces calculateFutureProofScore when all dimensions are available.
|
|
763
|
+
* Complete Extended Future-Proof Score
|
|
824
764
|
*/
|
|
825
765
|
declare function calculateExtendedFutureProofScore(params: {
|
|
826
766
|
cognitiveLoad: CognitiveLoad;
|
|
@@ -889,4 +829,4 @@ declare function getRepoMetadata(directory: string): {
|
|
|
889
829
|
author?: string;
|
|
890
830
|
};
|
|
891
831
|
|
|
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
|
|
832
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type AiSignalClarity, type AiSignalClaritySignal, AnalysisResult, 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 SpokeOutput, type TechnicalDebtInterest, TechnicalValueChain, TechnicalValueChainSummary, type TestabilityIndex, TokenBudget, ToolScoringOutput, TypeScriptParser, type UnifiedReport, 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, validateSpokeOutput };
|