@aiready/context-analyzer 0.3.3 → 0.3.4
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 +7 -7
- package/dist/cli.js +15 -30
- package/dist/cli.mjs +16 -31
- package/package.json +2 -2
- package/src/cli.ts +16 -35
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/context-analyzer@0.3.
|
|
3
|
+
> @aiready/context-analyzer@0.3.4 build /Users/pengcao/projects/aiready/packages/context-analyzer
|
|
4
4
|
> tsup src/index.ts src/cli.ts --format cjs,esm --dts
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2020
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/cli.mjs [22m[
|
|
13
|
-
[32mESM[39m [1mdist/chunk-T6ZCOPPI.mjs [22m[32m17.25 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m13.36 KB[39m
|
|
14
13
|
[32mESM[39m [1mdist/index.mjs [22m[32m124.00 B[39m
|
|
15
|
-
[32mESM[39m
|
|
16
|
-
[
|
|
14
|
+
[32mESM[39m [1mdist/chunk-T6ZCOPPI.mjs [22m[32m17.25 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 60ms
|
|
17
16
|
[32mCJS[39m [1mdist/index.js [22m[32m18.33 KB[39m
|
|
18
|
-
[32mCJS[39m
|
|
17
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m32.57 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 61ms
|
|
19
19
|
DTS Build start
|
|
20
|
-
DTS ⚡️ Build success in
|
|
20
|
+
DTS ⚡️ Build success in 654ms
|
|
21
21
|
DTS dist/cli.d.ts 20.00 B
|
|
22
22
|
DTS dist/index.d.ts 2.14 KB
|
|
23
23
|
DTS dist/cli.d.mts 20.00 B
|
package/dist/cli.js
CHANGED
|
@@ -583,7 +583,6 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
583
583
|
console.log(import_chalk.default.blue("\u{1F50D} Analyzing context window costs...\n"));
|
|
584
584
|
const startTime = Date.now();
|
|
585
585
|
try {
|
|
586
|
-
const config = (0, import_core3.loadConfig)(directory);
|
|
587
586
|
const defaults = {
|
|
588
587
|
maxDepth: 5,
|
|
589
588
|
maxContextBudget: 1e4,
|
|
@@ -595,21 +594,19 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
595
594
|
exclude: void 0,
|
|
596
595
|
maxResults: 10
|
|
597
596
|
};
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
maxResults: options.maxResults ? parseInt(options.maxResults) : mergedConfig.maxResults
|
|
610
|
-
};
|
|
597
|
+
const finalOptions = (0, import_core3.loadMergedConfig)(directory, defaults, {
|
|
598
|
+
maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
|
|
599
|
+
maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
|
|
600
|
+
minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : void 0,
|
|
601
|
+
maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : void 0,
|
|
602
|
+
focus: options.focus || void 0,
|
|
603
|
+
includeNodeModules: options.includeNodeModules,
|
|
604
|
+
include: options.include?.split(","),
|
|
605
|
+
exclude: options.exclude?.split(","),
|
|
606
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0
|
|
607
|
+
});
|
|
611
608
|
const results = await analyzeContext(finalOptions);
|
|
612
|
-
const elapsedTime = (
|
|
609
|
+
const elapsedTime = (0, import_core3.getElapsedTime)(startTime);
|
|
613
610
|
const summary = generateSummary(results);
|
|
614
611
|
if (options.output === "json") {
|
|
615
612
|
const jsonOutput = {
|
|
@@ -618,18 +615,8 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
618
615
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
619
616
|
analysisTime: elapsedTime
|
|
620
617
|
};
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
options.outputFile,
|
|
624
|
-
JSON.stringify(jsonOutput, null, 2)
|
|
625
|
-
);
|
|
626
|
-
console.log(
|
|
627
|
-
import_chalk.default.green(`
|
|
628
|
-
\u2713 JSON report saved to ${options.outputFile}`)
|
|
629
|
-
);
|
|
630
|
-
} else {
|
|
631
|
-
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
632
|
-
}
|
|
618
|
+
(0, import_core3.handleJSONOutput)(jsonOutput, options.outputFile, `
|
|
619
|
+
\u2713 JSON report saved to ${options.outputFile}`);
|
|
633
620
|
return;
|
|
634
621
|
}
|
|
635
622
|
if (options.output === "html") {
|
|
@@ -642,9 +629,7 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
642
629
|
}
|
|
643
630
|
displayConsoleReport(summary, results, elapsedTime, finalOptions.maxResults);
|
|
644
631
|
} catch (error) {
|
|
645
|
-
|
|
646
|
-
console.error(import_chalk.default.red(error instanceof Error ? error.message : String(error)));
|
|
647
|
-
process.exit(1);
|
|
632
|
+
(0, import_core3.handleCLIError)(error, "Analysis");
|
|
648
633
|
}
|
|
649
634
|
});
|
|
650
635
|
program.parse();
|
package/dist/cli.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { Command } from "commander";
|
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import { writeFileSync } from "fs";
|
|
11
11
|
import { join } from "path";
|
|
12
|
-
import {
|
|
12
|
+
import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime } from "@aiready/core";
|
|
13
13
|
var program = new Command();
|
|
14
14
|
program.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").addHelpText("after", "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings").argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth").option(
|
|
15
15
|
"--max-context <number>",
|
|
@@ -28,7 +28,6 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
28
28
|
console.log(chalk.blue("\u{1F50D} Analyzing context window costs...\n"));
|
|
29
29
|
const startTime = Date.now();
|
|
30
30
|
try {
|
|
31
|
-
const config = loadConfig(directory);
|
|
32
31
|
const defaults = {
|
|
33
32
|
maxDepth: 5,
|
|
34
33
|
maxContextBudget: 1e4,
|
|
@@ -40,21 +39,19 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
40
39
|
exclude: void 0,
|
|
41
40
|
maxResults: 10
|
|
42
41
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
maxResults: options.maxResults ? parseInt(options.maxResults) : mergedConfig.maxResults
|
|
55
|
-
};
|
|
42
|
+
const finalOptions = loadMergedConfig(directory, defaults, {
|
|
43
|
+
maxDepth: options.maxDepth ? parseInt(options.maxDepth) : void 0,
|
|
44
|
+
maxContextBudget: options.maxContext ? parseInt(options.maxContext) : void 0,
|
|
45
|
+
minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : void 0,
|
|
46
|
+
maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : void 0,
|
|
47
|
+
focus: options.focus || void 0,
|
|
48
|
+
includeNodeModules: options.includeNodeModules,
|
|
49
|
+
include: options.include?.split(","),
|
|
50
|
+
exclude: options.exclude?.split(","),
|
|
51
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : void 0
|
|
52
|
+
});
|
|
56
53
|
const results = await analyzeContext(finalOptions);
|
|
57
|
-
const elapsedTime = (
|
|
54
|
+
const elapsedTime = getElapsedTime(startTime);
|
|
58
55
|
const summary = generateSummary(results);
|
|
59
56
|
if (options.output === "json") {
|
|
60
57
|
const jsonOutput = {
|
|
@@ -63,18 +60,8 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
63
60
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
64
61
|
analysisTime: elapsedTime
|
|
65
62
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
options.outputFile,
|
|
69
|
-
JSON.stringify(jsonOutput, null, 2)
|
|
70
|
-
);
|
|
71
|
-
console.log(
|
|
72
|
-
chalk.green(`
|
|
73
|
-
\u2713 JSON report saved to ${options.outputFile}`)
|
|
74
|
-
);
|
|
75
|
-
} else {
|
|
76
|
-
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
77
|
-
}
|
|
63
|
+
handleJSONOutput(jsonOutput, options.outputFile, `
|
|
64
|
+
\u2713 JSON report saved to ${options.outputFile}`);
|
|
78
65
|
return;
|
|
79
66
|
}
|
|
80
67
|
if (options.output === "html") {
|
|
@@ -87,9 +74,7 @@ program.name("aiready-context").description("Analyze AI context window cost and
|
|
|
87
74
|
}
|
|
88
75
|
displayConsoleReport(summary, results, elapsedTime, finalOptions.maxResults);
|
|
89
76
|
} catch (error) {
|
|
90
|
-
|
|
91
|
-
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
|
92
|
-
process.exit(1);
|
|
77
|
+
handleCLIError(error, "Analysis");
|
|
93
78
|
}
|
|
94
79
|
});
|
|
95
80
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
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.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^22.10.2",
|
package/src/cli.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { analyzeContext, generateSummary } from './index';
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { writeFileSync } from 'fs';
|
|
7
7
|
import { join } from 'path';
|
|
8
|
-
import {
|
|
8
|
+
import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime } from '@aiready/core';
|
|
9
9
|
|
|
10
10
|
const program = new Command();
|
|
11
11
|
|
|
@@ -45,9 +45,6 @@ program
|
|
|
45
45
|
const startTime = Date.now();
|
|
46
46
|
|
|
47
47
|
try {
|
|
48
|
-
// Load config file if it exists
|
|
49
|
-
const config = loadConfig(directory);
|
|
50
|
-
|
|
51
48
|
// Define defaults
|
|
52
49
|
const defaults = {
|
|
53
50
|
maxDepth: 5,
|
|
@@ -61,26 +58,22 @@ program
|
|
|
61
58
|
maxResults: 10,
|
|
62
59
|
};
|
|
63
60
|
|
|
64
|
-
//
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
include: options.include?.split(',') || mergedConfig.include,
|
|
77
|
-
exclude: options.exclude?.split(',') || mergedConfig.exclude,
|
|
78
|
-
maxResults: options.maxResults ? parseInt(options.maxResults) : mergedConfig.maxResults,
|
|
79
|
-
};
|
|
61
|
+
// Load and merge config with CLI options
|
|
62
|
+
const finalOptions = loadMergedConfig(directory, defaults, {
|
|
63
|
+
maxDepth: options.maxDepth ? parseInt(options.maxDepth) : undefined,
|
|
64
|
+
maxContextBudget: options.maxContext ? parseInt(options.maxContext) : undefined,
|
|
65
|
+
minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : undefined,
|
|
66
|
+
maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : undefined,
|
|
67
|
+
focus: (options.focus as 'fragmentation' | 'cohesion' | 'depth' | 'all') || undefined,
|
|
68
|
+
includeNodeModules: options.includeNodeModules,
|
|
69
|
+
include: options.include?.split(','),
|
|
70
|
+
exclude: options.exclude?.split(','),
|
|
71
|
+
maxResults: options.maxResults ? parseInt(options.maxResults) : undefined,
|
|
72
|
+
}) as any;
|
|
80
73
|
|
|
81
74
|
const results = await analyzeContext(finalOptions);
|
|
82
75
|
|
|
83
|
-
const elapsedTime = (
|
|
76
|
+
const elapsedTime = getElapsedTime(startTime);
|
|
84
77
|
const summary = generateSummary(results);
|
|
85
78
|
|
|
86
79
|
if (options.output === 'json') {
|
|
@@ -91,17 +84,7 @@ program
|
|
|
91
84
|
analysisTime: elapsedTime,
|
|
92
85
|
};
|
|
93
86
|
|
|
94
|
-
|
|
95
|
-
writeFileSync(
|
|
96
|
-
options.outputFile,
|
|
97
|
-
JSON.stringify(jsonOutput, null, 2)
|
|
98
|
-
);
|
|
99
|
-
console.log(
|
|
100
|
-
chalk.green(`\n✓ JSON report saved to ${options.outputFile}`)
|
|
101
|
-
);
|
|
102
|
-
} else {
|
|
103
|
-
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
104
|
-
}
|
|
87
|
+
handleJSONOutput(jsonOutput, options.outputFile, `\n✓ JSON report saved to ${options.outputFile}`);
|
|
105
88
|
return;
|
|
106
89
|
}
|
|
107
90
|
|
|
@@ -117,9 +100,7 @@ program
|
|
|
117
100
|
// Console output
|
|
118
101
|
displayConsoleReport(summary, results, elapsedTime, finalOptions.maxResults);
|
|
119
102
|
} catch (error) {
|
|
120
|
-
|
|
121
|
-
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
|
122
|
-
process.exit(1);
|
|
103
|
+
handleCLIError(error, 'Analysis');
|
|
123
104
|
}
|
|
124
105
|
});
|
|
125
106
|
|