@aiready/core 0.9.30 → 0.9.32
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 +25 -110
- package/dist/chunk-CWRCDSKZ.mjs +408 -0
- package/dist/chunk-KI7XORTN.mjs +408 -0
- package/dist/client.d.mts +13 -12
- package/dist/client.d.ts +13 -12
- package/dist/client.js +11 -11
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +31 -11
- package/dist/index.d.ts +31 -11
- package/dist/index.js +70 -27
- package/dist/index.mjs +58 -16
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -457,11 +457,11 @@ declare class PythonParser implements LanguageParser {
|
|
|
457
457
|
* - Semantic Distance: How far apart related concepts are
|
|
458
458
|
* - Concept Cohesion: How well grouped related ideas are
|
|
459
459
|
* - Pattern Entropy: How ordered vs chaotic the structure is
|
|
460
|
-
* -
|
|
460
|
+
* - AI Signal Clarity: How likely AI is to generate incorrect code
|
|
461
461
|
* - Agent Grounding Score: How well an agent can navigate unaided
|
|
462
462
|
* - Testability Index: How verifiable AI-generated changes are
|
|
463
463
|
*
|
|
464
|
-
* v0.12+: Added
|
|
464
|
+
* v0.12+: Added AI signal clarity, agent grounding, and testability dimensions.
|
|
465
465
|
*/
|
|
466
466
|
|
|
467
467
|
/**
|
|
@@ -557,7 +557,7 @@ declare function calculateFutureProofScore(params: {
|
|
|
557
557
|
* Signals that increase the likelihood of AI generating incorrect code.
|
|
558
558
|
* Technology-agnostic: these patterns confuse both current and future AI.
|
|
559
559
|
*/
|
|
560
|
-
interface
|
|
560
|
+
interface AiSignalClaritySignal {
|
|
561
561
|
name: string;
|
|
562
562
|
count: number;
|
|
563
563
|
riskContribution: number;
|
|
@@ -565,7 +565,7 @@ interface HallucinationRiskSignal {
|
|
|
565
565
|
examples?: string[];
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
|
-
*
|
|
568
|
+
* AI Signal Clarity Score (0-100, higher = more risk)
|
|
569
569
|
*
|
|
570
570
|
* Measures code patterns that empirically cause AI models to:
|
|
571
571
|
* - Confidently generate incorrect function signatures
|
|
@@ -573,21 +573,21 @@ interface HallucinationRiskSignal {
|
|
|
573
573
|
* - Miss implicit contracts / side effects
|
|
574
574
|
* - Misunderstand overloaded symbols
|
|
575
575
|
*/
|
|
576
|
-
interface
|
|
576
|
+
interface AiSignalClarity {
|
|
577
577
|
/** Overall risk score (0-100). Higher = more likely AI will hallucinate. */
|
|
578
578
|
score: number;
|
|
579
579
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
580
|
-
signals:
|
|
580
|
+
signals: AiSignalClaritySignal[];
|
|
581
581
|
/** Most impactful signal to fix first */
|
|
582
582
|
topRisk: string;
|
|
583
583
|
recommendations: string[];
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
|
-
* Calculate
|
|
586
|
+
* Calculate AI signal clarity from code analysis results
|
|
587
587
|
*
|
|
588
588
|
* Input data can come from any parser; all inputs are normalized 0-N counts.
|
|
589
589
|
*/
|
|
590
|
-
declare function
|
|
590
|
+
declare function calculateAiSignalClarity(params: {
|
|
591
591
|
/** Overloaded function names (same name, different signatures) */
|
|
592
592
|
overloadedSymbols: number;
|
|
593
593
|
/** Magic numbers and string literals without named constants */
|
|
@@ -606,7 +606,7 @@ declare function calculateHallucinationRisk(params: {
|
|
|
606
606
|
totalSymbols: number;
|
|
607
607
|
/** Total exports in codebase */
|
|
608
608
|
totalExports: number;
|
|
609
|
-
}):
|
|
609
|
+
}): AiSignalClarity;
|
|
610
610
|
/**
|
|
611
611
|
* Agent Grounding Score
|
|
612
612
|
*
|
|
@@ -753,6 +753,26 @@ declare function calculateDependencyHealth(params: {
|
|
|
753
753
|
deprecatedPackages: number;
|
|
754
754
|
trainingCutoffSkew: number;
|
|
755
755
|
}): DependencyHealthScore;
|
|
756
|
+
interface ChangeAmplificationScore {
|
|
757
|
+
score: number;
|
|
758
|
+
rating: 'isolated' | 'contained' | 'amplified' | 'explosive';
|
|
759
|
+
avgAmplification: number;
|
|
760
|
+
maxAmplification: number;
|
|
761
|
+
hotspots: Array<{
|
|
762
|
+
file: string;
|
|
763
|
+
fanOut: number;
|
|
764
|
+
fanIn: number;
|
|
765
|
+
amplificationFactor: number;
|
|
766
|
+
}>;
|
|
767
|
+
recommendations: string[];
|
|
768
|
+
}
|
|
769
|
+
declare function calculateChangeAmplification(params: {
|
|
770
|
+
files: Array<{
|
|
771
|
+
file: string;
|
|
772
|
+
fanOut: number;
|
|
773
|
+
fanIn: number;
|
|
774
|
+
}>;
|
|
775
|
+
}): ChangeAmplificationScore;
|
|
756
776
|
/**
|
|
757
777
|
* Calculate the complete extended future-proof score including all dimensions.
|
|
758
778
|
* Replaces calculateFutureProofScore when all dimensions are available.
|
|
@@ -761,7 +781,7 @@ declare function calculateExtendedFutureProofScore(params: {
|
|
|
761
781
|
cognitiveLoad: CognitiveLoad;
|
|
762
782
|
patternEntropy: PatternEntropy;
|
|
763
783
|
conceptCohesion: ConceptCohesion;
|
|
764
|
-
|
|
784
|
+
aiSignalClarity: AiSignalClarity;
|
|
765
785
|
agentGrounding: AgentGroundingScore;
|
|
766
786
|
testability: TestabilityIndex;
|
|
767
787
|
docDrift?: DocDriftRisk;
|
|
@@ -806,4 +826,4 @@ declare function exportHistory(rootDir: string, format?: 'json' | 'csv'): string
|
|
|
806
826
|
*/
|
|
807
827
|
declare function clearHistory(rootDir: string): void;
|
|
808
828
|
|
|
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
|
|
829
|
+
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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, type TestabilityIndex, ToolScoringOutput, TypeScriptParser, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -457,11 +457,11 @@ declare class PythonParser implements LanguageParser {
|
|
|
457
457
|
* - Semantic Distance: How far apart related concepts are
|
|
458
458
|
* - Concept Cohesion: How well grouped related ideas are
|
|
459
459
|
* - Pattern Entropy: How ordered vs chaotic the structure is
|
|
460
|
-
* -
|
|
460
|
+
* - AI Signal Clarity: How likely AI is to generate incorrect code
|
|
461
461
|
* - Agent Grounding Score: How well an agent can navigate unaided
|
|
462
462
|
* - Testability Index: How verifiable AI-generated changes are
|
|
463
463
|
*
|
|
464
|
-
* v0.12+: Added
|
|
464
|
+
* v0.12+: Added AI signal clarity, agent grounding, and testability dimensions.
|
|
465
465
|
*/
|
|
466
466
|
|
|
467
467
|
/**
|
|
@@ -557,7 +557,7 @@ declare function calculateFutureProofScore(params: {
|
|
|
557
557
|
* Signals that increase the likelihood of AI generating incorrect code.
|
|
558
558
|
* Technology-agnostic: these patterns confuse both current and future AI.
|
|
559
559
|
*/
|
|
560
|
-
interface
|
|
560
|
+
interface AiSignalClaritySignal {
|
|
561
561
|
name: string;
|
|
562
562
|
count: number;
|
|
563
563
|
riskContribution: number;
|
|
@@ -565,7 +565,7 @@ interface HallucinationRiskSignal {
|
|
|
565
565
|
examples?: string[];
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
|
-
*
|
|
568
|
+
* AI Signal Clarity Score (0-100, higher = more risk)
|
|
569
569
|
*
|
|
570
570
|
* Measures code patterns that empirically cause AI models to:
|
|
571
571
|
* - Confidently generate incorrect function signatures
|
|
@@ -573,21 +573,21 @@ interface HallucinationRiskSignal {
|
|
|
573
573
|
* - Miss implicit contracts / side effects
|
|
574
574
|
* - Misunderstand overloaded symbols
|
|
575
575
|
*/
|
|
576
|
-
interface
|
|
576
|
+
interface AiSignalClarity {
|
|
577
577
|
/** Overall risk score (0-100). Higher = more likely AI will hallucinate. */
|
|
578
578
|
score: number;
|
|
579
579
|
rating: 'minimal' | 'low' | 'moderate' | 'high' | 'severe';
|
|
580
|
-
signals:
|
|
580
|
+
signals: AiSignalClaritySignal[];
|
|
581
581
|
/** Most impactful signal to fix first */
|
|
582
582
|
topRisk: string;
|
|
583
583
|
recommendations: string[];
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
|
-
* Calculate
|
|
586
|
+
* Calculate AI signal clarity from code analysis results
|
|
587
587
|
*
|
|
588
588
|
* Input data can come from any parser; all inputs are normalized 0-N counts.
|
|
589
589
|
*/
|
|
590
|
-
declare function
|
|
590
|
+
declare function calculateAiSignalClarity(params: {
|
|
591
591
|
/** Overloaded function names (same name, different signatures) */
|
|
592
592
|
overloadedSymbols: number;
|
|
593
593
|
/** Magic numbers and string literals without named constants */
|
|
@@ -606,7 +606,7 @@ declare function calculateHallucinationRisk(params: {
|
|
|
606
606
|
totalSymbols: number;
|
|
607
607
|
/** Total exports in codebase */
|
|
608
608
|
totalExports: number;
|
|
609
|
-
}):
|
|
609
|
+
}): AiSignalClarity;
|
|
610
610
|
/**
|
|
611
611
|
* Agent Grounding Score
|
|
612
612
|
*
|
|
@@ -753,6 +753,26 @@ declare function calculateDependencyHealth(params: {
|
|
|
753
753
|
deprecatedPackages: number;
|
|
754
754
|
trainingCutoffSkew: number;
|
|
755
755
|
}): DependencyHealthScore;
|
|
756
|
+
interface ChangeAmplificationScore {
|
|
757
|
+
score: number;
|
|
758
|
+
rating: 'isolated' | 'contained' | 'amplified' | 'explosive';
|
|
759
|
+
avgAmplification: number;
|
|
760
|
+
maxAmplification: number;
|
|
761
|
+
hotspots: Array<{
|
|
762
|
+
file: string;
|
|
763
|
+
fanOut: number;
|
|
764
|
+
fanIn: number;
|
|
765
|
+
amplificationFactor: number;
|
|
766
|
+
}>;
|
|
767
|
+
recommendations: string[];
|
|
768
|
+
}
|
|
769
|
+
declare function calculateChangeAmplification(params: {
|
|
770
|
+
files: Array<{
|
|
771
|
+
file: string;
|
|
772
|
+
fanOut: number;
|
|
773
|
+
fanIn: number;
|
|
774
|
+
}>;
|
|
775
|
+
}): ChangeAmplificationScore;
|
|
756
776
|
/**
|
|
757
777
|
* Calculate the complete extended future-proof score including all dimensions.
|
|
758
778
|
* Replaces calculateFutureProofScore when all dimensions are available.
|
|
@@ -761,7 +781,7 @@ declare function calculateExtendedFutureProofScore(params: {
|
|
|
761
781
|
cognitiveLoad: CognitiveLoad;
|
|
762
782
|
patternEntropy: PatternEntropy;
|
|
763
783
|
conceptCohesion: ConceptCohesion;
|
|
764
|
-
|
|
784
|
+
aiSignalClarity: AiSignalClarity;
|
|
765
785
|
agentGrounding: AgentGroundingScore;
|
|
766
786
|
testability: TestabilityIndex;
|
|
767
787
|
docDrift?: DocDriftRisk;
|
|
@@ -806,4 +826,4 @@ declare function exportHistory(rootDir: string, format?: 'json' | 'csv'): string
|
|
|
806
826
|
*/
|
|
807
827
|
declare function clearHistory(rootDir: string): void;
|
|
808
828
|
|
|
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
|
|
829
|
+
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 DebtBreakdown, 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, type RemediationVelocity, ScanOptions, type ScoreHistoryEntry, type ScoreTrend, type SemanticDistance, type TechnicalDebtInterest, type TestabilityIndex, ToolScoringOutput, TypeScriptParser, calculateAgentGrounding, calculateAiSignalClarity, calculateChangeAmplification, calculateCognitiveLoad, calculateComprehensionDifficulty, calculateConceptCohesion, calculateDependencyHealth, calculateDocDrift, calculateExtendedFutureProofScore, calculateFutureProofScore, 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 };
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,8 @@ __export(index_exports, {
|
|
|
44
44
|
TOOL_NAME_MAP: () => TOOL_NAME_MAP,
|
|
45
45
|
TypeScriptParser: () => TypeScriptParser,
|
|
46
46
|
calculateAgentGrounding: () => calculateAgentGrounding,
|
|
47
|
+
calculateAiSignalClarity: () => calculateAiSignalClarity,
|
|
48
|
+
calculateChangeAmplification: () => calculateChangeAmplification,
|
|
47
49
|
calculateCognitiveLoad: () => calculateCognitiveLoad,
|
|
48
50
|
calculateComprehensionDifficulty: () => calculateComprehensionDifficulty,
|
|
49
51
|
calculateConceptCohesion: () => calculateConceptCohesion,
|
|
@@ -51,7 +53,6 @@ __export(index_exports, {
|
|
|
51
53
|
calculateDocDrift: () => calculateDocDrift,
|
|
52
54
|
calculateExtendedFutureProofScore: () => calculateExtendedFutureProofScore,
|
|
53
55
|
calculateFutureProofScore: () => calculateFutureProofScore,
|
|
54
|
-
calculateHallucinationRisk: () => calculateHallucinationRisk,
|
|
55
56
|
calculateImportSimilarity: () => calculateImportSimilarity,
|
|
56
57
|
calculateKnowledgeConcentration: () => calculateKnowledgeConcentration,
|
|
57
58
|
calculateMonthlyCost: () => calculateMonthlyCost,
|
|
@@ -704,21 +705,21 @@ function generateHTML(graph) {
|
|
|
704
705
|
|
|
705
706
|
// src/scoring.ts
|
|
706
707
|
var DEFAULT_TOOL_WEIGHTS = {
|
|
707
|
-
"pattern-detect":
|
|
708
|
-
"context-analyzer":
|
|
709
|
-
"consistency":
|
|
710
|
-
"
|
|
711
|
-
"agent-grounding":
|
|
712
|
-
"testability":
|
|
713
|
-
"doc-drift":
|
|
714
|
-
"deps":
|
|
708
|
+
"pattern-detect": 22,
|
|
709
|
+
"context-analyzer": 19,
|
|
710
|
+
"consistency": 14,
|
|
711
|
+
"ai-signal-clarity": 11,
|
|
712
|
+
"agent-grounding": 10,
|
|
713
|
+
"testability": 10,
|
|
714
|
+
"doc-drift": 8,
|
|
715
|
+
"deps": 6
|
|
715
716
|
};
|
|
716
717
|
var TOOL_NAME_MAP = {
|
|
717
718
|
"patterns": "pattern-detect",
|
|
718
719
|
"context": "context-analyzer",
|
|
719
720
|
"consistency": "consistency",
|
|
720
|
-
"
|
|
721
|
-
"
|
|
721
|
+
"AI signal clarity": "ai-signal-clarity",
|
|
722
|
+
"ai-signal-clarity": "ai-signal-clarity",
|
|
722
723
|
"grounding": "agent-grounding",
|
|
723
724
|
"agent-grounding": "agent-grounding",
|
|
724
725
|
"testability": "testability",
|
|
@@ -768,7 +769,7 @@ function getToolWeight(toolName, toolConfig, cliOverride) {
|
|
|
768
769
|
if (toolConfig?.scoreWeight !== void 0) {
|
|
769
770
|
return toolConfig.scoreWeight;
|
|
770
771
|
}
|
|
771
|
-
return DEFAULT_TOOL_WEIGHTS[toolName] ||
|
|
772
|
+
return DEFAULT_TOOL_WEIGHTS[toolName] || 5;
|
|
772
773
|
}
|
|
773
774
|
function parseWeightString(weightStr) {
|
|
774
775
|
const weights = /* @__PURE__ */ new Map();
|
|
@@ -1049,11 +1050,11 @@ function predictAcceptanceRate(toolOutputs) {
|
|
|
1049
1050
|
impact: Math.round(consistencyImpact * 100)
|
|
1050
1051
|
});
|
|
1051
1052
|
}
|
|
1052
|
-
const
|
|
1053
|
-
if (
|
|
1054
|
-
const hrImpact = (50 -
|
|
1053
|
+
const aiSignalClarity = toolOutputs.get("ai-signal-clarity");
|
|
1054
|
+
if (aiSignalClarity) {
|
|
1055
|
+
const hrImpact = (50 - aiSignalClarity.score) * 2e-3;
|
|
1055
1056
|
factors.push({
|
|
1056
|
-
name: "
|
|
1057
|
+
name: "AI Signal Clarity",
|
|
1057
1058
|
impact: Math.round(hrImpact * 100)
|
|
1058
1059
|
});
|
|
1059
1060
|
}
|
|
@@ -2050,7 +2051,7 @@ function calculateFutureProofScore(params) {
|
|
|
2050
2051
|
recommendations
|
|
2051
2052
|
};
|
|
2052
2053
|
}
|
|
2053
|
-
function
|
|
2054
|
+
function calculateAiSignalClarity(params) {
|
|
2054
2055
|
const {
|
|
2055
2056
|
overloadedSymbols,
|
|
2056
2057
|
magicLiterals,
|
|
@@ -2144,7 +2145,7 @@ function calculateHallucinationRisk(params) {
|
|
|
2144
2145
|
else if (score < 75) rating = "high";
|
|
2145
2146
|
else rating = "severe";
|
|
2146
2147
|
const topSignal = signals.reduce((a, b) => a.riskContribution > b.riskContribution ? a : b);
|
|
2147
|
-
const topRisk = topSignal.riskContribution > 0 ? topSignal.description : "No significant
|
|
2148
|
+
const topRisk = topSignal.riskContribution > 0 ? topSignal.description : "No significant AI signal claritys detected";
|
|
2148
2149
|
const recommendations = [];
|
|
2149
2150
|
if (overloadSignal.riskContribution > 5) {
|
|
2150
2151
|
recommendations.push(`Rename ${overloadedSymbols} overloaded symbols to unique, intent-revealing names`);
|
|
@@ -2384,17 +2385,58 @@ function calculateDependencyHealth(params) {
|
|
|
2384
2385
|
recommendations
|
|
2385
2386
|
};
|
|
2386
2387
|
}
|
|
2388
|
+
function calculateChangeAmplification(params) {
|
|
2389
|
+
const { files } = params;
|
|
2390
|
+
if (files.length === 0) {
|
|
2391
|
+
return {
|
|
2392
|
+
score: 100,
|
|
2393
|
+
rating: "isolated",
|
|
2394
|
+
avgAmplification: 1,
|
|
2395
|
+
maxAmplification: 1,
|
|
2396
|
+
hotspots: [],
|
|
2397
|
+
recommendations: []
|
|
2398
|
+
};
|
|
2399
|
+
}
|
|
2400
|
+
const hotspots = files.map((f) => {
|
|
2401
|
+
const amplificationFactor = f.fanOut + f.fanIn * 0.5;
|
|
2402
|
+
return { ...f, amplificationFactor };
|
|
2403
|
+
}).sort((a, b) => b.amplificationFactor - a.amplificationFactor);
|
|
2404
|
+
const maxAmplification = hotspots[0].amplificationFactor;
|
|
2405
|
+
const avgAmplification = hotspots.reduce((sum, h) => sum + h.amplificationFactor, 0) / hotspots.length;
|
|
2406
|
+
let score = 100 - avgAmplification * 5;
|
|
2407
|
+
if (maxAmplification > 20) score -= maxAmplification - 20;
|
|
2408
|
+
score = Math.max(0, Math.min(100, score));
|
|
2409
|
+
let rating = "isolated";
|
|
2410
|
+
if (score < 40) rating = "explosive";
|
|
2411
|
+
else if (score < 70) rating = "amplified";
|
|
2412
|
+
else if (score < 90) rating = "contained";
|
|
2413
|
+
const recommendations = [];
|
|
2414
|
+
if (score < 70 && hotspots.length > 0) {
|
|
2415
|
+
recommendations.push(`Refactor top hotspot '${hotspots[0].file}' to reduce coupling (fan-out: ${hotspots[0].fanOut}, fan-in: ${hotspots[0].fanIn}).`);
|
|
2416
|
+
}
|
|
2417
|
+
if (maxAmplification > 30) {
|
|
2418
|
+
recommendations.push(`Break down key bottlenecks with amplification factor > 30.`);
|
|
2419
|
+
}
|
|
2420
|
+
return {
|
|
2421
|
+
score: Math.round(score),
|
|
2422
|
+
rating,
|
|
2423
|
+
avgAmplification,
|
|
2424
|
+
maxAmplification,
|
|
2425
|
+
hotspots: hotspots.slice(0, 10),
|
|
2426
|
+
recommendations
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2387
2429
|
function calculateExtendedFutureProofScore(params) {
|
|
2388
2430
|
const loadScore = 100 - params.cognitiveLoad.score;
|
|
2389
2431
|
const entropyScore = 100 - params.patternEntropy.entropy * 100;
|
|
2390
2432
|
const cohesionScore = params.conceptCohesion.score * 100;
|
|
2391
|
-
const
|
|
2433
|
+
const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
|
|
2392
2434
|
const groundingScore = params.agentGrounding.score;
|
|
2393
2435
|
const testabilityScore = params.testability.score;
|
|
2394
2436
|
const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
|
|
2395
2437
|
const depsHealthScore = params.dependencyHealth ? params.dependencyHealth.score : 100;
|
|
2396
2438
|
let totalWeight = 0.8;
|
|
2397
|
-
let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 +
|
|
2439
|
+
let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
|
|
2398
2440
|
if (params.docDrift) {
|
|
2399
2441
|
overall += docDriftScore * 0.1;
|
|
2400
2442
|
totalWeight += 0.1;
|
|
@@ -2421,9 +2463,9 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
2421
2463
|
description: params.conceptCohesion.rating
|
|
2422
2464
|
},
|
|
2423
2465
|
{
|
|
2424
|
-
name: "
|
|
2425
|
-
impact: Math.round(
|
|
2426
|
-
description: `${params.
|
|
2466
|
+
name: "AI Signal Clarity",
|
|
2467
|
+
impact: Math.round(aiSignalClarityScore - 50),
|
|
2468
|
+
description: `${params.aiSignalClarity.rating} risk (${params.aiSignalClarity.score}/100 raw)`
|
|
2427
2469
|
},
|
|
2428
2470
|
{
|
|
2429
2471
|
name: "Agent Grounding",
|
|
@@ -2440,7 +2482,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
2440
2482
|
factors.push({
|
|
2441
2483
|
name: "Documentation Drift",
|
|
2442
2484
|
impact: Math.round(docDriftScore - 50),
|
|
2443
|
-
description: `${params.docDrift.rating} risk of
|
|
2485
|
+
description: `${params.docDrift.rating} risk of AI signal clarity from drift`
|
|
2444
2486
|
});
|
|
2445
2487
|
}
|
|
2446
2488
|
if (params.dependencyHealth) {
|
|
@@ -2451,7 +2493,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
2451
2493
|
});
|
|
2452
2494
|
}
|
|
2453
2495
|
const recommendations = [];
|
|
2454
|
-
for (const rec of params.
|
|
2496
|
+
for (const rec of params.aiSignalClarity.recommendations) {
|
|
2455
2497
|
recommendations.push({ action: rec, estimatedImpact: 8, priority: "high" });
|
|
2456
2498
|
}
|
|
2457
2499
|
for (const rec of params.agentGrounding.recommendations) {
|
|
@@ -2482,7 +2524,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
2482
2524
|
cognitiveLoadScore: params.cognitiveLoad.score,
|
|
2483
2525
|
entropyScore: params.patternEntropy.entropy,
|
|
2484
2526
|
cohesionScore: params.conceptCohesion.score,
|
|
2485
|
-
|
|
2527
|
+
aiSignalClarityScore: params.aiSignalClarity.score,
|
|
2486
2528
|
agentGroundingScore: params.agentGrounding.score,
|
|
2487
2529
|
testabilityScore: params.testability.score,
|
|
2488
2530
|
docDriftScore: params.docDrift?.score,
|
|
@@ -2583,6 +2625,8 @@ function clearHistory(rootDir) {
|
|
|
2583
2625
|
TOOL_NAME_MAP,
|
|
2584
2626
|
TypeScriptParser,
|
|
2585
2627
|
calculateAgentGrounding,
|
|
2628
|
+
calculateAiSignalClarity,
|
|
2629
|
+
calculateChangeAmplification,
|
|
2586
2630
|
calculateCognitiveLoad,
|
|
2587
2631
|
calculateComprehensionDifficulty,
|
|
2588
2632
|
calculateConceptCohesion,
|
|
@@ -2590,7 +2634,6 @@ function clearHistory(rootDir) {
|
|
|
2590
2634
|
calculateDocDrift,
|
|
2591
2635
|
calculateExtendedFutureProofScore,
|
|
2592
2636
|
calculateFutureProofScore,
|
|
2593
|
-
calculateHallucinationRisk,
|
|
2594
2637
|
calculateImportSimilarity,
|
|
2595
2638
|
calculateKnowledgeConcentration,
|
|
2596
2639
|
calculateMonthlyCost,
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
getToolWeight,
|
|
19
19
|
normalizeToolName,
|
|
20
20
|
parseWeightString
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-CWRCDSKZ.mjs";
|
|
22
22
|
|
|
23
23
|
// src/utils/file-scanner.ts
|
|
24
24
|
import { glob } from "glob";
|
|
@@ -575,11 +575,11 @@ function predictAcceptanceRate(toolOutputs) {
|
|
|
575
575
|
impact: Math.round(consistencyImpact * 100)
|
|
576
576
|
});
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
580
|
-
const hrImpact = (50 -
|
|
578
|
+
const aiSignalClarity = toolOutputs.get("ai-signal-clarity");
|
|
579
|
+
if (aiSignalClarity) {
|
|
580
|
+
const hrImpact = (50 - aiSignalClarity.score) * 2e-3;
|
|
581
581
|
factors.push({
|
|
582
|
-
name: "
|
|
582
|
+
name: "AI Signal Clarity",
|
|
583
583
|
impact: Math.round(hrImpact * 100)
|
|
584
584
|
});
|
|
585
585
|
}
|
|
@@ -1576,7 +1576,7 @@ function calculateFutureProofScore(params) {
|
|
|
1576
1576
|
recommendations
|
|
1577
1577
|
};
|
|
1578
1578
|
}
|
|
1579
|
-
function
|
|
1579
|
+
function calculateAiSignalClarity(params) {
|
|
1580
1580
|
const {
|
|
1581
1581
|
overloadedSymbols,
|
|
1582
1582
|
magicLiterals,
|
|
@@ -1670,7 +1670,7 @@ function calculateHallucinationRisk(params) {
|
|
|
1670
1670
|
else if (score < 75) rating = "high";
|
|
1671
1671
|
else rating = "severe";
|
|
1672
1672
|
const topSignal = signals.reduce((a, b) => a.riskContribution > b.riskContribution ? a : b);
|
|
1673
|
-
const topRisk = topSignal.riskContribution > 0 ? topSignal.description : "No significant
|
|
1673
|
+
const topRisk = topSignal.riskContribution > 0 ? topSignal.description : "No significant AI signal claritys detected";
|
|
1674
1674
|
const recommendations = [];
|
|
1675
1675
|
if (overloadSignal.riskContribution > 5) {
|
|
1676
1676
|
recommendations.push(`Rename ${overloadedSymbols} overloaded symbols to unique, intent-revealing names`);
|
|
@@ -1910,17 +1910,58 @@ function calculateDependencyHealth(params) {
|
|
|
1910
1910
|
recommendations
|
|
1911
1911
|
};
|
|
1912
1912
|
}
|
|
1913
|
+
function calculateChangeAmplification(params) {
|
|
1914
|
+
const { files } = params;
|
|
1915
|
+
if (files.length === 0) {
|
|
1916
|
+
return {
|
|
1917
|
+
score: 100,
|
|
1918
|
+
rating: "isolated",
|
|
1919
|
+
avgAmplification: 1,
|
|
1920
|
+
maxAmplification: 1,
|
|
1921
|
+
hotspots: [],
|
|
1922
|
+
recommendations: []
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
const hotspots = files.map((f) => {
|
|
1926
|
+
const amplificationFactor = f.fanOut + f.fanIn * 0.5;
|
|
1927
|
+
return { ...f, amplificationFactor };
|
|
1928
|
+
}).sort((a, b) => b.amplificationFactor - a.amplificationFactor);
|
|
1929
|
+
const maxAmplification = hotspots[0].amplificationFactor;
|
|
1930
|
+
const avgAmplification = hotspots.reduce((sum, h) => sum + h.amplificationFactor, 0) / hotspots.length;
|
|
1931
|
+
let score = 100 - avgAmplification * 5;
|
|
1932
|
+
if (maxAmplification > 20) score -= maxAmplification - 20;
|
|
1933
|
+
score = Math.max(0, Math.min(100, score));
|
|
1934
|
+
let rating = "isolated";
|
|
1935
|
+
if (score < 40) rating = "explosive";
|
|
1936
|
+
else if (score < 70) rating = "amplified";
|
|
1937
|
+
else if (score < 90) rating = "contained";
|
|
1938
|
+
const recommendations = [];
|
|
1939
|
+
if (score < 70 && hotspots.length > 0) {
|
|
1940
|
+
recommendations.push(`Refactor top hotspot '${hotspots[0].file}' to reduce coupling (fan-out: ${hotspots[0].fanOut}, fan-in: ${hotspots[0].fanIn}).`);
|
|
1941
|
+
}
|
|
1942
|
+
if (maxAmplification > 30) {
|
|
1943
|
+
recommendations.push(`Break down key bottlenecks with amplification factor > 30.`);
|
|
1944
|
+
}
|
|
1945
|
+
return {
|
|
1946
|
+
score: Math.round(score),
|
|
1947
|
+
rating,
|
|
1948
|
+
avgAmplification,
|
|
1949
|
+
maxAmplification,
|
|
1950
|
+
hotspots: hotspots.slice(0, 10),
|
|
1951
|
+
recommendations
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1913
1954
|
function calculateExtendedFutureProofScore(params) {
|
|
1914
1955
|
const loadScore = 100 - params.cognitiveLoad.score;
|
|
1915
1956
|
const entropyScore = 100 - params.patternEntropy.entropy * 100;
|
|
1916
1957
|
const cohesionScore = params.conceptCohesion.score * 100;
|
|
1917
|
-
const
|
|
1958
|
+
const aiSignalClarityScore = 100 - params.aiSignalClarity.score;
|
|
1918
1959
|
const groundingScore = params.agentGrounding.score;
|
|
1919
1960
|
const testabilityScore = params.testability.score;
|
|
1920
1961
|
const docDriftScore = params.docDrift ? 100 - params.docDrift.score : 100;
|
|
1921
1962
|
const depsHealthScore = params.dependencyHealth ? params.dependencyHealth.score : 100;
|
|
1922
1963
|
let totalWeight = 0.8;
|
|
1923
|
-
let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 +
|
|
1964
|
+
let overall = loadScore * 0.15 + entropyScore * 0.1 + cohesionScore * 0.1 + aiSignalClarityScore * 0.15 + groundingScore * 0.15 + testabilityScore * 0.15;
|
|
1924
1965
|
if (params.docDrift) {
|
|
1925
1966
|
overall += docDriftScore * 0.1;
|
|
1926
1967
|
totalWeight += 0.1;
|
|
@@ -1947,9 +1988,9 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
1947
1988
|
description: params.conceptCohesion.rating
|
|
1948
1989
|
},
|
|
1949
1990
|
{
|
|
1950
|
-
name: "
|
|
1951
|
-
impact: Math.round(
|
|
1952
|
-
description: `${params.
|
|
1991
|
+
name: "AI Signal Clarity",
|
|
1992
|
+
impact: Math.round(aiSignalClarityScore - 50),
|
|
1993
|
+
description: `${params.aiSignalClarity.rating} risk (${params.aiSignalClarity.score}/100 raw)`
|
|
1953
1994
|
},
|
|
1954
1995
|
{
|
|
1955
1996
|
name: "Agent Grounding",
|
|
@@ -1966,7 +2007,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
1966
2007
|
factors.push({
|
|
1967
2008
|
name: "Documentation Drift",
|
|
1968
2009
|
impact: Math.round(docDriftScore - 50),
|
|
1969
|
-
description: `${params.docDrift.rating} risk of
|
|
2010
|
+
description: `${params.docDrift.rating} risk of AI signal clarity from drift`
|
|
1970
2011
|
});
|
|
1971
2012
|
}
|
|
1972
2013
|
if (params.dependencyHealth) {
|
|
@@ -1977,7 +2018,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
1977
2018
|
});
|
|
1978
2019
|
}
|
|
1979
2020
|
const recommendations = [];
|
|
1980
|
-
for (const rec of params.
|
|
2021
|
+
for (const rec of params.aiSignalClarity.recommendations) {
|
|
1981
2022
|
recommendations.push({ action: rec, estimatedImpact: 8, priority: "high" });
|
|
1982
2023
|
}
|
|
1983
2024
|
for (const rec of params.agentGrounding.recommendations) {
|
|
@@ -2008,7 +2049,7 @@ function calculateExtendedFutureProofScore(params) {
|
|
|
2008
2049
|
cognitiveLoadScore: params.cognitiveLoad.score,
|
|
2009
2050
|
entropyScore: params.patternEntropy.entropy,
|
|
2010
2051
|
cohesionScore: params.conceptCohesion.score,
|
|
2011
|
-
|
|
2052
|
+
aiSignalClarityScore: params.aiSignalClarity.score,
|
|
2012
2053
|
agentGroundingScore: params.agentGrounding.score,
|
|
2013
2054
|
testabilityScore: params.testability.score,
|
|
2014
2055
|
docDriftScore: params.docDrift?.score,
|
|
@@ -2108,6 +2149,8 @@ export {
|
|
|
2108
2149
|
TOOL_NAME_MAP,
|
|
2109
2150
|
TypeScriptParser,
|
|
2110
2151
|
calculateAgentGrounding,
|
|
2152
|
+
calculateAiSignalClarity,
|
|
2153
|
+
calculateChangeAmplification,
|
|
2111
2154
|
calculateCognitiveLoad,
|
|
2112
2155
|
calculateComprehensionDifficulty,
|
|
2113
2156
|
calculateConceptCohesion,
|
|
@@ -2115,7 +2158,6 @@ export {
|
|
|
2115
2158
|
calculateDocDrift,
|
|
2116
2159
|
calculateExtendedFutureProofScore,
|
|
2117
2160
|
calculateFutureProofScore,
|
|
2118
|
-
calculateHallucinationRisk,
|
|
2119
2161
|
calculateImportSimilarity,
|
|
2120
2162
|
calculateKnowledgeConcentration,
|
|
2121
2163
|
calculateMonthlyCost,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.32",
|
|
4
4
|
"description": "Shared utilities for AIReady analysis tools",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.9.3"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
|
-
"build": "tsup src/index.ts src/client.ts --format cjs,esm",
|
|
54
|
+
"build": "tsup src/index.ts src/client.ts --format cjs,esm --dts",
|
|
55
55
|
"dev": "tsup src/index.ts src/client.ts --format cjs,esm --watch",
|
|
56
56
|
"lint": "eslint src",
|
|
57
57
|
"clean": "rm -rf dist",
|