@aiready/context-analyzer 0.3.6 → 0.3.8
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 +10 -10
- package/dist/chunk-5N5DCJOV.mjs +583 -0
- package/dist/chunk-TPF75CNP.mjs +581 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +48 -2
- package/dist/index.mjs +5 -3
- package/package.json +2 -2
- package/src/index.ts +63 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "AI context window cost analysis - detect fragmented code, deep import chains, and expensive context budgets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"commander": "^12.1.0",
|
|
51
51
|
"chalk": "^5.3.0",
|
|
52
|
-
"@aiready/core": "0.3.
|
|
52
|
+
"@aiready/core": "0.3.7"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^22.10.2",
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,67 @@ import type {
|
|
|
19
19
|
|
|
20
20
|
export type { ContextAnalyzerOptions, ContextAnalysisResult, ContextSummary, ModuleCluster };
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Generate smart defaults for context analysis based on repository size
|
|
24
|
+
*/
|
|
25
|
+
async function getSmartDefaults(
|
|
26
|
+
directory: string,
|
|
27
|
+
userOptions: Partial<ContextAnalyzerOptions>
|
|
28
|
+
): Promise<ContextAnalyzerOptions> {
|
|
29
|
+
// Estimate repository size by scanning files
|
|
30
|
+
const files = await scanFiles({
|
|
31
|
+
rootDir: directory,
|
|
32
|
+
include: userOptions.include,
|
|
33
|
+
exclude: userOptions.exclude,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const estimatedBlocks = files.length;
|
|
37
|
+
|
|
38
|
+
// Smart defaults based on repository size
|
|
39
|
+
let maxDepth: number;
|
|
40
|
+
let maxContextBudget: number;
|
|
41
|
+
let minCohesion: number;
|
|
42
|
+
let maxFragmentation: number;
|
|
43
|
+
|
|
44
|
+
if (estimatedBlocks < 100) {
|
|
45
|
+
// Small project
|
|
46
|
+
maxDepth = 3;
|
|
47
|
+
maxContextBudget = 5000;
|
|
48
|
+
minCohesion = 0.7;
|
|
49
|
+
maxFragmentation = 0.3;
|
|
50
|
+
} else if (estimatedBlocks < 500) {
|
|
51
|
+
// Medium project
|
|
52
|
+
maxDepth = 4;
|
|
53
|
+
maxContextBudget = 8000;
|
|
54
|
+
minCohesion = 0.65;
|
|
55
|
+
maxFragmentation = 0.4;
|
|
56
|
+
} else if (estimatedBlocks < 2000) {
|
|
57
|
+
// Large project
|
|
58
|
+
maxDepth = 5;
|
|
59
|
+
maxContextBudget = 12000;
|
|
60
|
+
minCohesion = 0.6;
|
|
61
|
+
maxFragmentation = 0.5;
|
|
62
|
+
} else {
|
|
63
|
+
// Enterprise project
|
|
64
|
+
maxDepth = 6;
|
|
65
|
+
maxContextBudget = 20000;
|
|
66
|
+
minCohesion = 0.55;
|
|
67
|
+
maxFragmentation = 0.6;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
maxDepth,
|
|
72
|
+
maxContextBudget,
|
|
73
|
+
minCohesion,
|
|
74
|
+
maxFragmentation,
|
|
75
|
+
focus: 'all',
|
|
76
|
+
includeNodeModules: false,
|
|
77
|
+
rootDir: userOptions.rootDir || directory,
|
|
78
|
+
include: userOptions.include,
|
|
79
|
+
exclude: userOptions.exclude,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
22
83
|
/**
|
|
23
84
|
* Analyze AI context window cost for a codebase
|
|
24
85
|
*/
|
|
@@ -394,3 +455,5 @@ function analyzeIssues(params: {
|
|
|
394
455
|
|
|
395
456
|
return { severity, issues, recommendations, potentialSavings: Math.floor(potentialSavings) };
|
|
396
457
|
}
|
|
458
|
+
|
|
459
|
+
export { getSmartDefaults };
|