@aiready/context-analyzer 0.22.1 → 0.22.3
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/.turbo/turbo-build.log +31 -32
- package/.turbo/turbo-test.log +23 -23
- package/dist/chunk-ILMLGJGI.mjs +1295 -0
- package/dist/cli-action-E7UGP4KE.mjs +95 -0
- package/dist/cli.js +72 -83
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +72 -83
- package/dist/index.mjs +2 -2
- package/dist/orchestrator-R6MZT4Z2.mjs +10 -0
- package/package.json +2 -2
- package/src/orchestrator.ts +111 -2
- package/src/mapper.ts +0 -124
package/src/mapper.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ContextAnalysisResult,
|
|
3
|
-
DependencyGraph,
|
|
4
|
-
DependencyNode,
|
|
5
|
-
ModuleCluster,
|
|
6
|
-
} from './types';
|
|
7
|
-
import { calculateEnhancedCohesion } from './metrics';
|
|
8
|
-
import { analyzeIssues } from './issue-analyzer';
|
|
9
|
-
import {
|
|
10
|
-
calculateImportDepth,
|
|
11
|
-
getTransitiveDependencies,
|
|
12
|
-
calculateContextBudget,
|
|
13
|
-
} from './graph-builder';
|
|
14
|
-
import {
|
|
15
|
-
classifyFile,
|
|
16
|
-
adjustCohesionForClassification,
|
|
17
|
-
adjustFragmentationForClassification,
|
|
18
|
-
} from './classifier';
|
|
19
|
-
import { getClassificationRecommendations } from './remediation';
|
|
20
|
-
|
|
21
|
-
export interface MappingOptions {
|
|
22
|
-
maxDepth: number;
|
|
23
|
-
maxContextBudget: number;
|
|
24
|
-
minCohesion: number;
|
|
25
|
-
maxFragmentation: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Maps a single dependency node to a comprehensive ContextAnalysisResult.
|
|
30
|
-
*
|
|
31
|
-
* @param node - The dependency node to map
|
|
32
|
-
* @param graph - The full dependency graph
|
|
33
|
-
* @param clusters - All identified module clusters
|
|
34
|
-
* @param allCircularDeps - All identified circular dependencies
|
|
35
|
-
* @param options - Mapping options for detailed analysis
|
|
36
|
-
*/
|
|
37
|
-
export function mapNodeToResult(
|
|
38
|
-
node: DependencyNode,
|
|
39
|
-
graph: DependencyGraph,
|
|
40
|
-
clusters: ModuleCluster[],
|
|
41
|
-
allCircularDeps: string[][],
|
|
42
|
-
options: MappingOptions
|
|
43
|
-
): ContextAnalysisResult {
|
|
44
|
-
const file = node.file;
|
|
45
|
-
const tokenCost = node.tokenCost;
|
|
46
|
-
const importDepth = calculateImportDepth(file, graph);
|
|
47
|
-
const transitiveDeps = getTransitiveDependencies(file, graph);
|
|
48
|
-
const contextBudget = calculateContextBudget(file, graph);
|
|
49
|
-
const circularDeps = allCircularDeps.filter((cycle) => cycle.includes(file));
|
|
50
|
-
|
|
51
|
-
// Find cluster for this file
|
|
52
|
-
const cluster = clusters.find((c) => c.files.includes(file));
|
|
53
|
-
const rawFragmentationScore = cluster ? cluster.fragmentationScore : 0;
|
|
54
|
-
|
|
55
|
-
// Cohesion
|
|
56
|
-
const rawCohesionScore = calculateEnhancedCohesion(
|
|
57
|
-
node.exports,
|
|
58
|
-
file,
|
|
59
|
-
options as any
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// Initial classification
|
|
63
|
-
const fileClassification = classifyFile(node, rawCohesionScore);
|
|
64
|
-
|
|
65
|
-
// Adjust scores based on classification
|
|
66
|
-
const cohesionScore = adjustCohesionForClassification(
|
|
67
|
-
rawCohesionScore,
|
|
68
|
-
fileClassification
|
|
69
|
-
);
|
|
70
|
-
const fragmentationScore = adjustFragmentationForClassification(
|
|
71
|
-
rawFragmentationScore,
|
|
72
|
-
fileClassification
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const { severity, issues, recommendations, potentialSavings } = analyzeIssues(
|
|
76
|
-
{
|
|
77
|
-
file,
|
|
78
|
-
importDepth,
|
|
79
|
-
contextBudget,
|
|
80
|
-
cohesionScore,
|
|
81
|
-
fragmentationScore,
|
|
82
|
-
maxDepth: options.maxDepth,
|
|
83
|
-
maxContextBudget: options.maxContextBudget,
|
|
84
|
-
minCohesion: options.minCohesion,
|
|
85
|
-
maxFragmentation: options.maxFragmentation,
|
|
86
|
-
circularDeps,
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// Add classification-specific recommendations
|
|
91
|
-
const classRecs = getClassificationRecommendations(
|
|
92
|
-
fileClassification,
|
|
93
|
-
file,
|
|
94
|
-
issues
|
|
95
|
-
);
|
|
96
|
-
const allRecommendations = Array.from(
|
|
97
|
-
new Set([...recommendations, ...classRecs])
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
file,
|
|
102
|
-
tokenCost,
|
|
103
|
-
linesOfCode: node.linesOfCode,
|
|
104
|
-
importDepth,
|
|
105
|
-
dependencyCount: transitiveDeps.length,
|
|
106
|
-
dependencyList: transitiveDeps,
|
|
107
|
-
circularDeps,
|
|
108
|
-
cohesionScore,
|
|
109
|
-
domains: Array.from(
|
|
110
|
-
new Set(
|
|
111
|
-
node.exports.flatMap((e) => e.domains?.map((d) => d.domain) || [])
|
|
112
|
-
)
|
|
113
|
-
),
|
|
114
|
-
exportCount: node.exports.length,
|
|
115
|
-
contextBudget,
|
|
116
|
-
fragmentationScore,
|
|
117
|
-
relatedFiles: cluster ? cluster.files : [],
|
|
118
|
-
fileClassification,
|
|
119
|
-
severity,
|
|
120
|
-
issues,
|
|
121
|
-
recommendations: allRecommendations,
|
|
122
|
-
potentialSavings,
|
|
123
|
-
};
|
|
124
|
-
}
|