@aiready/core 0.9.26 → 0.9.28
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/chunk-JJ5JL5FX.mjs +408 -0
- package/dist/client.d.mts +70 -2
- package/dist/client.d.ts +70 -2
- package/dist/client.js +58 -2
- package/dist/client.mjs +11 -1
- package/dist/index.d.mts +260 -9
- package/dist/index.d.ts +260 -9
- package/dist/index.js +631 -20
- package/dist/index.mjs +576 -19
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -20,17 +20,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/client.ts
|
|
21
21
|
var client_exports = {};
|
|
22
22
|
__export(client_exports, {
|
|
23
|
+
CONTEXT_TIER_THRESHOLDS: () => CONTEXT_TIER_THRESHOLDS,
|
|
23
24
|
DEFAULT_TOOL_WEIGHTS: () => DEFAULT_TOOL_WEIGHTS,
|
|
24
25
|
LANGUAGE_EXTENSIONS: () => LANGUAGE_EXTENSIONS,
|
|
25
26
|
Language: () => Language,
|
|
26
27
|
ParseError: () => ParseError,
|
|
28
|
+
SIZE_ADJUSTED_THRESHOLDS: () => SIZE_ADJUSTED_THRESHOLDS,
|
|
27
29
|
TOOL_NAME_MAP: () => TOOL_NAME_MAP,
|
|
28
30
|
calculateOverallScore: () => calculateOverallScore,
|
|
29
31
|
formatScore: () => formatScore,
|
|
30
32
|
formatToolScore: () => formatToolScore,
|
|
31
33
|
generateHTML: () => generateHTML,
|
|
34
|
+
getProjectSizeTier: () => getProjectSizeTier,
|
|
32
35
|
getRating: () => getRating,
|
|
33
36
|
getRatingDisplay: () => getRatingDisplay,
|
|
37
|
+
getRatingWithContext: () => getRatingWithContext,
|
|
38
|
+
getRecommendedThreshold: () => getRecommendedThreshold,
|
|
34
39
|
getToolWeight: () => getToolWeight,
|
|
35
40
|
normalizeToolName: () => normalizeToolName,
|
|
36
41
|
parseWeightString: () => parseWeightString
|
|
@@ -73,16 +78,57 @@ var DEFAULT_TOOL_WEIGHTS = {
|
|
|
73
78
|
"pattern-detect": 40,
|
|
74
79
|
"context-analyzer": 35,
|
|
75
80
|
"consistency": 25,
|
|
76
|
-
"
|
|
77
|
-
"
|
|
81
|
+
"hallucination-risk": 20,
|
|
82
|
+
"agent-grounding": 18,
|
|
83
|
+
"testability": 18,
|
|
84
|
+
"doc-drift": 15,
|
|
85
|
+
"deps": 12
|
|
78
86
|
};
|
|
79
87
|
var TOOL_NAME_MAP = {
|
|
80
88
|
"patterns": "pattern-detect",
|
|
81
89
|
"context": "context-analyzer",
|
|
82
90
|
"consistency": "consistency",
|
|
91
|
+
"hallucination": "hallucination-risk",
|
|
92
|
+
"hallucination-risk": "hallucination-risk",
|
|
93
|
+
"grounding": "agent-grounding",
|
|
94
|
+
"agent-grounding": "agent-grounding",
|
|
95
|
+
"testability": "testability",
|
|
96
|
+
"tests": "testability",
|
|
83
97
|
"doc-drift": "doc-drift",
|
|
98
|
+
"docs": "doc-drift",
|
|
84
99
|
"deps": "deps"
|
|
85
100
|
};
|
|
101
|
+
var CONTEXT_TIER_THRESHOLDS = {
|
|
102
|
+
compact: { idealTokens: 3e3, criticalTokens: 1e4, idealDepth: 4 },
|
|
103
|
+
standard: { idealTokens: 5e3, criticalTokens: 15e3, idealDepth: 5 },
|
|
104
|
+
extended: { idealTokens: 15e3, criticalTokens: 5e4, idealDepth: 7 },
|
|
105
|
+
frontier: { idealTokens: 5e4, criticalTokens: 15e4, idealDepth: 10 }
|
|
106
|
+
};
|
|
107
|
+
var SIZE_ADJUSTED_THRESHOLDS = {
|
|
108
|
+
"xs": 80,
|
|
109
|
+
// < 50 files
|
|
110
|
+
"small": 75,
|
|
111
|
+
// 50-200 files
|
|
112
|
+
"medium": 70,
|
|
113
|
+
// 200-500 files
|
|
114
|
+
"large": 65,
|
|
115
|
+
// 500-2000 files
|
|
116
|
+
"enterprise": 58
|
|
117
|
+
// 2000+ files
|
|
118
|
+
};
|
|
119
|
+
function getProjectSizeTier(fileCount) {
|
|
120
|
+
if (fileCount < 50) return "xs";
|
|
121
|
+
if (fileCount < 200) return "small";
|
|
122
|
+
if (fileCount < 500) return "medium";
|
|
123
|
+
if (fileCount < 2e3) return "large";
|
|
124
|
+
return "enterprise";
|
|
125
|
+
}
|
|
126
|
+
function getRecommendedThreshold(fileCount, modelTier = "standard") {
|
|
127
|
+
const sizeTier = getProjectSizeTier(fileCount);
|
|
128
|
+
const base = SIZE_ADJUSTED_THRESHOLDS[sizeTier];
|
|
129
|
+
const modelBonus = modelTier === "frontier" ? -3 : modelTier === "extended" ? -2 : 0;
|
|
130
|
+
return base + modelBonus;
|
|
131
|
+
}
|
|
86
132
|
function normalizeToolName(shortName) {
|
|
87
133
|
return TOOL_NAME_MAP[shortName] || shortName;
|
|
88
134
|
}
|
|
@@ -165,6 +211,11 @@ function getRating(score) {
|
|
|
165
211
|
if (score >= 40) return "Needs Work";
|
|
166
212
|
return "Critical";
|
|
167
213
|
}
|
|
214
|
+
function getRatingWithContext(score, fileCount, modelTier = "standard") {
|
|
215
|
+
const threshold = getRecommendedThreshold(fileCount, modelTier);
|
|
216
|
+
const normalized = score - threshold + 70;
|
|
217
|
+
return getRating(normalized);
|
|
218
|
+
}
|
|
168
219
|
function getRatingDisplay(rating) {
|
|
169
220
|
switch (rating) {
|
|
170
221
|
case "Excellent":
|
|
@@ -379,17 +430,22 @@ function generateHTML(graph) {
|
|
|
379
430
|
}
|
|
380
431
|
// Annotate the CommonJS export names for ESM import in node:
|
|
381
432
|
0 && (module.exports = {
|
|
433
|
+
CONTEXT_TIER_THRESHOLDS,
|
|
382
434
|
DEFAULT_TOOL_WEIGHTS,
|
|
383
435
|
LANGUAGE_EXTENSIONS,
|
|
384
436
|
Language,
|
|
385
437
|
ParseError,
|
|
438
|
+
SIZE_ADJUSTED_THRESHOLDS,
|
|
386
439
|
TOOL_NAME_MAP,
|
|
387
440
|
calculateOverallScore,
|
|
388
441
|
formatScore,
|
|
389
442
|
formatToolScore,
|
|
390
443
|
generateHTML,
|
|
444
|
+
getProjectSizeTier,
|
|
391
445
|
getRating,
|
|
392
446
|
getRatingDisplay,
|
|
447
|
+
getRatingWithContext,
|
|
448
|
+
getRecommendedThreshold,
|
|
393
449
|
getToolWeight,
|
|
394
450
|
normalizeToolName,
|
|
395
451
|
parseWeightString
|
package/dist/client.mjs
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CONTEXT_TIER_THRESHOLDS,
|
|
2
3
|
DEFAULT_TOOL_WEIGHTS,
|
|
3
4
|
LANGUAGE_EXTENSIONS,
|
|
4
5
|
Language,
|
|
5
6
|
ParseError,
|
|
7
|
+
SIZE_ADJUSTED_THRESHOLDS,
|
|
6
8
|
TOOL_NAME_MAP,
|
|
7
9
|
calculateOverallScore,
|
|
8
10
|
formatScore,
|
|
9
11
|
formatToolScore,
|
|
10
12
|
generateHTML,
|
|
13
|
+
getProjectSizeTier,
|
|
11
14
|
getRating,
|
|
12
15
|
getRatingDisplay,
|
|
16
|
+
getRatingWithContext,
|
|
17
|
+
getRecommendedThreshold,
|
|
13
18
|
getToolWeight,
|
|
14
19
|
normalizeToolName,
|
|
15
20
|
parseWeightString
|
|
16
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JJ5JL5FX.mjs";
|
|
17
22
|
export {
|
|
23
|
+
CONTEXT_TIER_THRESHOLDS,
|
|
18
24
|
DEFAULT_TOOL_WEIGHTS,
|
|
19
25
|
LANGUAGE_EXTENSIONS,
|
|
20
26
|
Language,
|
|
21
27
|
ParseError,
|
|
28
|
+
SIZE_ADJUSTED_THRESHOLDS,
|
|
22
29
|
TOOL_NAME_MAP,
|
|
23
30
|
calculateOverallScore,
|
|
24
31
|
formatScore,
|
|
25
32
|
formatToolScore,
|
|
26
33
|
generateHTML,
|
|
34
|
+
getProjectSizeTier,
|
|
27
35
|
getRating,
|
|
28
36
|
getRatingDisplay,
|
|
37
|
+
getRatingWithContext,
|
|
38
|
+
getRecommendedThreshold,
|
|
29
39
|
getToolWeight,
|
|
30
40
|
normalizeToolName,
|
|
31
41
|
parseWeightString
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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';
|
|
1
|
+
import { ScanOptions, AIReadyConfig, CostConfig, ModelContextTier, ComprehensionDifficulty, ProductivityImpact, ToolScoringOutput, AcceptancePrediction, LanguageParser, Language, ParseResult, NamingConvention } from './client.mjs';
|
|
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[];
|
|
5
5
|
/**
|
|
@@ -120,8 +120,28 @@ declare function getElapsedTime(startTime: number): string;
|
|
|
120
120
|
*
|
|
121
121
|
* NEW in v0.11: Extended with temporal tracking, knowledge concentration, and
|
|
122
122
|
* technical debt interest calculations.
|
|
123
|
+
* NEW in v0.12: Multi-model pricing presets, model-aware CDI calibration,
|
|
124
|
+
* and improved acceptance rate prediction with data-grounded baselines.
|
|
123
125
|
*/
|
|
124
126
|
|
|
127
|
+
/**
|
|
128
|
+
* AI model pricing presets for cost estimation.
|
|
129
|
+
* Prices are input token costs per 1K tokens (USD), as of Q1 2026.
|
|
130
|
+
* Update these as model pricing evolves — the calculation logic is unchanged.
|
|
131
|
+
*/
|
|
132
|
+
interface ModelPricingPreset {
|
|
133
|
+
name: string;
|
|
134
|
+
pricePer1KInputTokens: number;
|
|
135
|
+
pricePer1KOutputTokens: number;
|
|
136
|
+
contextTier: ModelContextTier;
|
|
137
|
+
/** Approximate daily queries per active dev for this model class */
|
|
138
|
+
typicalQueriesPerDevPerDay: number;
|
|
139
|
+
}
|
|
140
|
+
declare const MODEL_PRICING_PRESETS: Record<string, ModelPricingPreset>;
|
|
141
|
+
/**
|
|
142
|
+
* Get a model pricing preset by ID, with fallback to gpt-4o
|
|
143
|
+
*/
|
|
144
|
+
declare function getModelPreset(modelId: string): ModelPricingPreset;
|
|
125
145
|
/**
|
|
126
146
|
* Historical score entry for trend tracking
|
|
127
147
|
*/
|
|
@@ -203,7 +223,8 @@ interface DebtBreakdown {
|
|
|
203
223
|
}
|
|
204
224
|
/**
|
|
205
225
|
* Default cost configuration
|
|
206
|
-
*
|
|
226
|
+
* Points to GPT-4o as the default model (most common in 2026).
|
|
227
|
+
* Use MODEL_PRICING_PRESETS for model-specific accuracy.
|
|
207
228
|
*/
|
|
208
229
|
declare const DEFAULT_COST_CONFIG: CostConfig;
|
|
209
230
|
/**
|
|
@@ -221,10 +242,16 @@ declare function calculateProductivityImpact(issues: {
|
|
|
221
242
|
/**
|
|
222
243
|
* Predict AI suggestion acceptance rate based on code quality
|
|
223
244
|
*
|
|
224
|
-
*
|
|
225
|
-
* -
|
|
226
|
-
* -
|
|
227
|
-
* -
|
|
245
|
+
* Calibration notes (v0.12):
|
|
246
|
+
* - GitHub Copilot reports ~30% industry average acceptance rate (2023 blog)
|
|
247
|
+
* - Internal teams with high-consistency codebases report 40-55%
|
|
248
|
+
* - Teams with semantic duplication report 20-25% (AI suggests wrong variant)
|
|
249
|
+
* - Context efficiency is the strongest single predictor
|
|
250
|
+
*
|
|
251
|
+
* Confidence levels:
|
|
252
|
+
* - 3 tools: 0.75 (triangulated estimate)
|
|
253
|
+
* - 2 tools: 0.55 (partial estimate)
|
|
254
|
+
* - 1 tool: 0.35 (weak estimate — don't over-rely)
|
|
228
255
|
*/
|
|
229
256
|
declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutput>): AcceptancePrediction;
|
|
230
257
|
/**
|
|
@@ -232,8 +259,12 @@ declare function predictAcceptanceRate(toolOutputs: Map<string, ToolScoringOutpu
|
|
|
232
259
|
*
|
|
233
260
|
* A future-proof abstraction that normalizes multiple factors
|
|
234
261
|
* into a single difficulty score. Lower = easier for AI.
|
|
262
|
+
*
|
|
263
|
+
* v0.12+: Now model-aware. Pass the `modelTier` of your AI toolchain
|
|
264
|
+
* to recalibrate token budget thresholds correctly. With frontier models
|
|
265
|
+
* (200k+ context), a 20k-token file is no longer "critical".
|
|
235
266
|
*/
|
|
236
|
-
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, consistencyScore: number, totalFiles: number): ComprehensionDifficulty;
|
|
267
|
+
declare function calculateComprehensionDifficulty(contextBudget: number, importDepth: number, fragmentation: number, consistencyScore: number, totalFiles: number, modelTier?: ModelContextTier): ComprehensionDifficulty;
|
|
237
268
|
/**
|
|
238
269
|
* Format cost for display
|
|
239
270
|
*/
|
|
@@ -426,6 +457,11 @@ declare class PythonParser implements LanguageParser {
|
|
|
426
457
|
* - Semantic Distance: How far apart related concepts are
|
|
427
458
|
* - Concept Cohesion: How well grouped related ideas are
|
|
428
459
|
* - Pattern Entropy: How ordered vs chaotic the structure is
|
|
460
|
+
* - Hallucination Risk: How likely AI is to generate incorrect code
|
|
461
|
+
* - Agent Grounding Score: How well an agent can navigate unaided
|
|
462
|
+
* - Testability Index: How verifiable AI-generated changes are
|
|
463
|
+
*
|
|
464
|
+
* v0.12+: Added hallucination risk, agent grounding, and testability dimensions.
|
|
429
465
|
*/
|
|
430
466
|
|
|
431
467
|
/**
|
|
@@ -517,6 +553,221 @@ declare function calculateFutureProofScore(params: {
|
|
|
517
553
|
conceptCohesion: ConceptCohesion;
|
|
518
554
|
semanticDistances?: SemanticDistance[];
|
|
519
555
|
}): ToolScoringOutput;
|
|
556
|
+
/**
|
|
557
|
+
* Signals that increase the likelihood of AI generating incorrect code.
|
|
558
|
+
* Technology-agnostic: these patterns confuse both current and future AI.
|
|
559
|
+
*/
|
|
560
|
+
interface HallucinationRiskSignal {
|
|
561
|
+
name: string;
|
|
562
|
+
count: number;
|
|
563
|
+
riskContribution: number;
|
|
564
|
+
description: string;
|
|
565
|
+
examples?: string[];
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Hallucination Risk Score (0-100, higher = more risk)
|
|
569
|
+
*
|
|
570
|
+
* Measures code patterns that empirically cause AI models to:
|
|
571
|
+
* - Confidently generate incorrect function signatures
|
|
572
|
+
* - Create plausible-but-wrong implementations
|
|
573
|
+
* - Miss implicit contracts / side effects
|
|
574
|
+
* - Misunderstand overloaded symbols
|
|
575
|
+
*/
|
|
576
|
+
interface HallucinationRisk {
|
|
577
|
+
/** Overall risk score (0-100). Higher = more likely AI will hallucinate. */
|
|
578
|
+
score: number;
|
|
579
|
+
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
580
|
+
signals: HallucinationRiskSignal[];
|
|
581
|
+
/** Most impactful signal to fix first */
|
|
582
|
+
topRisk: string;
|
|
583
|
+
recommendations: string[];
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Calculate hallucination risk from code analysis results
|
|
587
|
+
*
|
|
588
|
+
* Input data can come from any parser; all inputs are normalized 0-N counts.
|
|
589
|
+
*/
|
|
590
|
+
declare function calculateHallucinationRisk(params: {
|
|
591
|
+
/** Overloaded function names (same name, different signatures) */
|
|
592
|
+
overloadedSymbols: number;
|
|
593
|
+
/** Magic numbers and string literals without named constants */
|
|
594
|
+
magicLiterals: number;
|
|
595
|
+
/** Boolean trap parameters (function(true, false, null)) */
|
|
596
|
+
booleanTraps: number;
|
|
597
|
+
/** Implicit returns / void-implicit side effect functions */
|
|
598
|
+
implicitSideEffects: number;
|
|
599
|
+
/** Callback nesting depth > 3 (callback hell indicator) */
|
|
600
|
+
deepCallbacks: number;
|
|
601
|
+
/** Non-descriptive names: single letters, x1/x2 patterns, tmp/data/obj */
|
|
602
|
+
ambiguousNames: number;
|
|
603
|
+
/** Exported symbols with no JSDoc/docstring */
|
|
604
|
+
undocumentedExports: number;
|
|
605
|
+
/** Total symbols analyzed (for normalization) */
|
|
606
|
+
totalSymbols: number;
|
|
607
|
+
/** Total exports in codebase */
|
|
608
|
+
totalExports: number;
|
|
609
|
+
}): HallucinationRisk;
|
|
610
|
+
/**
|
|
611
|
+
* Agent Grounding Score
|
|
612
|
+
*
|
|
613
|
+
* Measures how well an AI agent can navigate a codebase *independently*,
|
|
614
|
+
* without human assistance or extensive prompting.
|
|
615
|
+
*
|
|
616
|
+
* High grounding = agent can find files, understand project structure,
|
|
617
|
+
* locate relevant code, and correctly infer ownership without being told.
|
|
618
|
+
*
|
|
619
|
+
* This is technology-agnostic: any agentic system (current or future)
|
|
620
|
+
* needs these structural guarantees to work effectively.
|
|
621
|
+
*/
|
|
622
|
+
interface AgentGroundingScore {
|
|
623
|
+
/** 0-100 score; higher = better self-navigation */
|
|
624
|
+
score: number;
|
|
625
|
+
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'disorienting';
|
|
626
|
+
dimensions: {
|
|
627
|
+
/** Can agent find where to put new code? (directory structure clarity) */
|
|
628
|
+
structureClarityScore: number;
|
|
629
|
+
/** Can agent understand what a file does from its name alone? */
|
|
630
|
+
selfDocumentationScore: number;
|
|
631
|
+
/** Are entry points (index, main, README) present and accurate? */
|
|
632
|
+
entryPointScore: number;
|
|
633
|
+
/** Does the public API surface reflect the project's mental model? */
|
|
634
|
+
apiClarityScore: number;
|
|
635
|
+
/** Is the domain language consistent? (Same concept = same word everywhere) */
|
|
636
|
+
domainConsistencyScore: number;
|
|
637
|
+
};
|
|
638
|
+
recommendations: string[];
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Calculate how well an AI agent can ground itself in the codebase
|
|
642
|
+
*/
|
|
643
|
+
declare function calculateAgentGrounding(params: {
|
|
644
|
+
/** Number of directories exceeding recommended depth (> 4 levels) */
|
|
645
|
+
deepDirectories: number;
|
|
646
|
+
/** Total directories */
|
|
647
|
+
totalDirectories: number;
|
|
648
|
+
/** Files whose name alone doesn't reveal purpose (e.g., utils.ts, helpers.ts, misc.ts) */
|
|
649
|
+
vagueFileNames: number;
|
|
650
|
+
/** Total files */
|
|
651
|
+
totalFiles: number;
|
|
652
|
+
/** Whether a root README exists */
|
|
653
|
+
hasRootReadme: boolean;
|
|
654
|
+
/** Whether README has been updated in last 90 days (or unknown) */
|
|
655
|
+
readmeIsFresh: boolean;
|
|
656
|
+
/** Number of barrel exports (index.ts/index.js files that re-export) */
|
|
657
|
+
barrelExports: number;
|
|
658
|
+
/** Number of exported functions/classes/types with no type annotations */
|
|
659
|
+
untypedExports: number;
|
|
660
|
+
/** Total exports */
|
|
661
|
+
totalExports: number;
|
|
662
|
+
/** Number of domain terms used inconsistently (same concept, different names) */
|
|
663
|
+
inconsistentDomainTerms: number;
|
|
664
|
+
/** Distinct domain vocabulary size (unique business terms detected) */
|
|
665
|
+
domainVocabularySize: number;
|
|
666
|
+
}): AgentGroundingScore;
|
|
667
|
+
/**
|
|
668
|
+
* Testability Index
|
|
669
|
+
*
|
|
670
|
+
* Measures how verifiable AI-generated changes are.
|
|
671
|
+
* AI assistants are only as useful as your ability to validate their output.
|
|
672
|
+
*
|
|
673
|
+
* Core insight: A codebase where generated code CAN'T be verified
|
|
674
|
+
* is one where AI assistance actively introduces hidden risk.
|
|
675
|
+
*
|
|
676
|
+
* Technology-agnostic: test frameworks change; testability principles don't.
|
|
677
|
+
*/
|
|
678
|
+
interface TestabilityIndex {
|
|
679
|
+
/** 0-100 score; higher = AI changes are more verifiable */
|
|
680
|
+
score: number;
|
|
681
|
+
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'unverifiable';
|
|
682
|
+
dimensions: {
|
|
683
|
+
/** Ratio of test files to source files */
|
|
684
|
+
testCoverageRatio: number;
|
|
685
|
+
/** Pure function prevalence (no side effects = easy to test) */
|
|
686
|
+
purityScore: number;
|
|
687
|
+
/** Dependency injection / inversion of control score */
|
|
688
|
+
dependencyInjectionScore: number;
|
|
689
|
+
/** Interface segregation (small, focused interfaces) */
|
|
690
|
+
interfaceFocusScore: number;
|
|
691
|
+
/** Observable outputs (functions return values vs mutate state) */
|
|
692
|
+
observabilityScore: number;
|
|
693
|
+
};
|
|
694
|
+
/** Estimated AI suggestion safety — without tests, AI changes are high-risk */
|
|
695
|
+
aiChangeSafetyRating: 'safe' | 'moderate-risk' | 'high-risk' | 'blind-risk';
|
|
696
|
+
recommendations: string[];
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Calculate testability index from code structure analysis
|
|
700
|
+
*/
|
|
701
|
+
declare function calculateTestabilityIndex(params: {
|
|
702
|
+
/** Number of test files (*.test.*, *.spec.*, __tests__/**) */
|
|
703
|
+
testFiles: number;
|
|
704
|
+
/** Number of source files (excluding tests, configs) */
|
|
705
|
+
sourceFiles: number;
|
|
706
|
+
/** Functions that take only data and return data (no I/O, no mutations) */
|
|
707
|
+
pureFunctions: number;
|
|
708
|
+
/** Total functions analyzed */
|
|
709
|
+
totalFunctions: number;
|
|
710
|
+
/** Classes/functions using constructor injection or factory patterns */
|
|
711
|
+
injectionPatterns: number;
|
|
712
|
+
/** Total classes/services */
|
|
713
|
+
totalClasses: number;
|
|
714
|
+
/** Interfaces/types with > 10 methods (low segregation) */
|
|
715
|
+
bloatedInterfaces: number;
|
|
716
|
+
/** Total interfaces/types */
|
|
717
|
+
totalInterfaces: number;
|
|
718
|
+
/** Functions that directly mutate external state (globals, DOM, DB without abstraction) */
|
|
719
|
+
externalStateMutations: number;
|
|
720
|
+
/** Has a defined testing framework (package.json test script exists) */
|
|
721
|
+
hasTestFramework: boolean;
|
|
722
|
+
}): TestabilityIndex;
|
|
723
|
+
interface DocDriftRisk {
|
|
724
|
+
score: number;
|
|
725
|
+
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
726
|
+
dimensions: {
|
|
727
|
+
uncommentedExports: number;
|
|
728
|
+
outdatedComments: number;
|
|
729
|
+
undocumentedComplexity: number;
|
|
730
|
+
};
|
|
731
|
+
recommendations: string[];
|
|
732
|
+
}
|
|
733
|
+
declare function calculateDocDrift(params: {
|
|
734
|
+
uncommentedExports: number;
|
|
735
|
+
totalExports: number;
|
|
736
|
+
outdatedComments: number;
|
|
737
|
+
undocumentedComplexity: number;
|
|
738
|
+
}): DocDriftRisk;
|
|
739
|
+
interface DependencyHealthScore {
|
|
740
|
+
score: number;
|
|
741
|
+
rating: 'excellent' | 'good' | 'moderate' | 'poor' | 'hazardous';
|
|
742
|
+
dimensions: {
|
|
743
|
+
outdatedPackages: number;
|
|
744
|
+
deprecatedPackages: number;
|
|
745
|
+
trainingCutoffSkew: number;
|
|
746
|
+
};
|
|
747
|
+
aiKnowledgeConfidence: 'high' | 'moderate' | 'low' | 'blind';
|
|
748
|
+
recommendations: string[];
|
|
749
|
+
}
|
|
750
|
+
declare function calculateDependencyHealth(params: {
|
|
751
|
+
totalPackages: number;
|
|
752
|
+
outdatedPackages: number;
|
|
753
|
+
deprecatedPackages: number;
|
|
754
|
+
trainingCutoffSkew: number;
|
|
755
|
+
}): DependencyHealthScore;
|
|
756
|
+
/**
|
|
757
|
+
* Calculate the complete extended future-proof score including all dimensions.
|
|
758
|
+
* Replaces calculateFutureProofScore when all dimensions are available.
|
|
759
|
+
*/
|
|
760
|
+
declare function calculateExtendedFutureProofScore(params: {
|
|
761
|
+
cognitiveLoad: CognitiveLoad;
|
|
762
|
+
patternEntropy: PatternEntropy;
|
|
763
|
+
conceptCohesion: ConceptCohesion;
|
|
764
|
+
hallucinationRisk: HallucinationRisk;
|
|
765
|
+
agentGrounding: AgentGroundingScore;
|
|
766
|
+
testability: TestabilityIndex;
|
|
767
|
+
docDrift?: DocDriftRisk;
|
|
768
|
+
dependencyHealth?: DependencyHealthScore;
|
|
769
|
+
semanticDistances?: SemanticDistance[];
|
|
770
|
+
}): ToolScoringOutput;
|
|
520
771
|
|
|
521
772
|
/**
|
|
522
773
|
* Temporal Tracking Utilities
|
|
@@ -555,4 +806,4 @@ declare function exportHistory(rootDir: string, format?: 'json' | 'csv'): string
|
|
|
555
806
|
*/
|
|
556
807
|
declare function clearHistory(rootDir: string): void;
|
|
557
808
|
|
|
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 };
|
|
809
|
+
export { AIReadyConfig, type ASTNode, AcceptancePrediction, type AgentGroundingScore, type CLIOptions, type CognitiveLoad, ComprehensionDifficulty, type ConceptCohesion, CostConfig, DEFAULT_COST_CONFIG, DEFAULT_EXCLUDE, type DebtBreakdown, type DependencyHealthScore, type DocDriftRisk, type ExportWithImports, type FileImport, type FileWithDomain, type HallucinationRisk, type HallucinationRiskSignal, type KnowledgeConcentrationRisk, Language, LanguageParser, type LoadFactor, MODEL_PRICING_PRESETS, ModelContextTier, type ModelPricingPreset, NamingConvention, ParseResult, ParserFactory, type PatternEntropy, ProductivityImpact, PythonParser, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, type TestabilityIndex, ToolScoringOutput, TypeScriptParser, calculateAgentGrounding, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, calculateHallucinationRisk, calculateImportSimilarity, calculateKnowledgeConcentration, calculateMonthlyCost, calculatePatternEntropy, calculateProductivityImpact, calculateRemediationVelocity, calculateScoreTrend, calculateSemanticDistance, calculateTechnicalDebtInterest, calculateTestabilityIndex, clearHistory, estimateTokens, exportHistory, extractFunctions, extractImports, formatAcceptanceRate, formatCost, formatHours, getDebtBreakdown, getElapsedTime, getFileExtension, getHistorySummary, getModelPreset, getParser, getSupportedLanguages, handleCLIError, handleJSONOutput, isFileSupported, isSourceFile, loadConfig, loadMergedConfig, loadScoreHistory, mergeConfigWithDefaults, parseCode, parseFileExports, predictAcceptanceRate, readFileContent, resolveOutputPath, saveScoreEntry, scanFiles };
|