@aiready/context-analyzer 0.22.21 → 0.22.23
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 +14 -14
- package/.turbo/turbo-format-check.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +361 -1
- package/.turbo/turbo-type-check.log +1 -1
- package/dist/chunk-4N6ZDLJF.mjs +1355 -0
- package/dist/cli-action-37GCH3M6.mjs +95 -0
- package/dist/cli.js +101 -26
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +95 -20
- package/dist/index.mjs +2 -2
- package/dist/orchestrator-EVJP3WUV.mjs +10 -0
- package/package.json +2 -2
- package/src/orchestrator.ts +36 -1
- package/src/types.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.23",
|
|
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
|
"chalk": "^5.6.2",
|
|
50
50
|
"commander": "^14.0.3",
|
|
51
51
|
"prompts": "^2.4.2",
|
|
52
|
-
"@aiready/core": "0.24.
|
|
52
|
+
"@aiready/core": "0.24.26"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^24.12.2",
|
package/src/orchestrator.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
adjustFragmentationForClassification,
|
|
24
24
|
} from './classifier';
|
|
25
25
|
import { getClassificationRecommendations } from './remediation';
|
|
26
|
+
import { getSmartDefaults } from './defaults';
|
|
26
27
|
|
|
27
28
|
export interface MappingOptions {
|
|
28
29
|
maxDepth: number;
|
|
@@ -143,6 +144,38 @@ export function calculateCohesion(
|
|
|
143
144
|
return calculateEnhancedCohesion(exports, filePath, options);
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Resolves options, handling "auto" values by using smart defaults.
|
|
149
|
+
*/
|
|
150
|
+
async function resolveOptions(options: ContextAnalyzerOptions): Promise<
|
|
151
|
+
Omit<ContextAnalyzerOptions, 'maxContextBudget'> & {
|
|
152
|
+
maxContextBudget: number;
|
|
153
|
+
}
|
|
154
|
+
> {
|
|
155
|
+
const budget = options.maxContextBudget;
|
|
156
|
+
if (budget === 'auto') {
|
|
157
|
+
const smartDefaults = await getSmartDefaults(
|
|
158
|
+
options.rootDir || '.',
|
|
159
|
+
options as ContextAnalyzerOptions
|
|
160
|
+
);
|
|
161
|
+
return {
|
|
162
|
+
...options,
|
|
163
|
+
maxContextBudget: smartDefaults.maxContextBudget,
|
|
164
|
+
maxDepth: smartDefaults.maxDepth,
|
|
165
|
+
minCohesion: smartDefaults.minCohesion,
|
|
166
|
+
maxFragmentation: smartDefaults.maxFragmentation,
|
|
167
|
+
} as Omit<ContextAnalyzerOptions, 'maxContextBudget'> & {
|
|
168
|
+
maxContextBudget: number;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
...options,
|
|
173
|
+
maxContextBudget: typeof budget === 'number' ? budget : 25000,
|
|
174
|
+
} as Omit<ContextAnalyzerOptions, 'maxContextBudget'> & {
|
|
175
|
+
maxContextBudget: number;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
146
179
|
/**
|
|
147
180
|
* Performs deep context analysis of a project.
|
|
148
181
|
* Scans files, builds a dependency graph, calculates context budgets,
|
|
@@ -154,6 +187,8 @@ export function calculateCohesion(
|
|
|
154
187
|
export async function analyzeContext(
|
|
155
188
|
options: ContextAnalyzerOptions
|
|
156
189
|
): Promise<ContextAnalysisResult[]> {
|
|
190
|
+
const resolvedOptions = await resolveOptions(options);
|
|
191
|
+
|
|
157
192
|
const {
|
|
158
193
|
maxDepth = 5,
|
|
159
194
|
maxContextBudget = 25000,
|
|
@@ -161,7 +196,7 @@ export async function analyzeContext(
|
|
|
161
196
|
maxFragmentation = 0.5,
|
|
162
197
|
includeNodeModules = false,
|
|
163
198
|
...scanOptions
|
|
164
|
-
} =
|
|
199
|
+
} = resolvedOptions;
|
|
165
200
|
|
|
166
201
|
const files = await scanFiles({
|
|
167
202
|
...scanOptions,
|
package/src/types.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type { ExportInfo };
|
|
|
8
8
|
export interface ContextAnalyzerOptions extends ScanOptions {
|
|
9
9
|
/** Maximum acceptable import depth (default: 5) */
|
|
10
10
|
maxDepth?: number;
|
|
11
|
-
/** Maximum acceptable token budget for a single context
|
|
12
|
-
maxContextBudget?: number;
|
|
11
|
+
/** Maximum acceptable token budget for a single context, or "auto" for smart scaling */
|
|
12
|
+
maxContextBudget?: number | 'auto';
|
|
13
13
|
/** Minimum acceptable cohesion score between 0 and 1 (default: 0.6) */
|
|
14
14
|
minCohesion?: number;
|
|
15
15
|
/** Maximum acceptable fragmentation score between 0 and 1 (default: 0.5) */
|