@aiready/context-analyzer 0.1.1 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/context-analyzer@0.1.1 build /Users/pengcao/projects/aiready/packages/context-analyzer
3
+ > @aiready/context-analyzer@0.1.3 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
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,15 +9,15 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/cli.js 31.86 KB
12
+ CJS dist/cli.js 32.65 KB
13
13
  CJS dist/index.js 18.33 KB
14
- CJS ⚡️ Build success in 54ms
14
+ CJS ⚡️ Build success in 57ms
15
+ ESM dist/cli.mjs 13.39 KB
15
16
  ESM dist/index.mjs 124.00 B
16
- ESM dist/cli.mjs 12.61 KB
17
17
  ESM dist/chunk-T6ZCOPPI.mjs 17.25 KB
18
- ESM ⚡️ Build success in 55ms
18
+ ESM ⚡️ Build success in 57ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 570ms
20
+ DTS ⚡️ Build success in 605ms
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/README.md CHANGED
@@ -85,6 +85,27 @@ aiready-context ./src --output html --output-file report.html
85
85
  aiready-context ./src --exclude "**/test/**,**/*.test.ts"
86
86
  ```
87
87
 
88
+ ### Configuration
89
+
90
+ Create an `aiready.json` or `aiready.config.json` file in your project root:
91
+
92
+ ```json
93
+ {
94
+ "scan": {
95
+ "include": ["**/*.{ts,tsx,js,jsx}"],
96
+ "exclude": ["**/test/**", "**/*.test.*"]
97
+ },
98
+ "tools": {
99
+ "context-analyzer": {
100
+ "maxDepth": 4,
101
+ "maxContextBudget": 8000,
102
+ "minCohesion": 0.7,
103
+ "includeNodeModules": false
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
88
109
  ### Sample Output
89
110
 
90
111
  ```bash
@@ -236,6 +257,32 @@ for (const result of results) {
236
257
  --output-file <path> # Output file path (for json/html)
237
258
  ```
238
259
 
260
+ ### Default Exclusions
261
+
262
+ By default, these patterns are excluded (unless `--include-node-modules` is used):
263
+ ```bash
264
+ # Dependencies (excluded by default, override with --include-node-modules)
265
+ **/node_modules/**
266
+
267
+ # Build outputs
268
+ **/dist/**, **/build/**, **/out/**, **/output/**, **/target/**, **/bin/**, **/obj/**
269
+
270
+ # Framework-specific build dirs
271
+ **/.next/**, **/.nuxt/**, **/.vuepress/**, **/.cache/**, **/.turbo/**
272
+
273
+ # Test and coverage
274
+ **/coverage/**, **/.nyc_output/**, **/.jest/**
275
+
276
+ # Version control and IDE
277
+ **/.git/**, **/.svn/**, **/.hg/**, **/.vscode/**, **/.idea/**, **/*.swp, **/*.swo
278
+
279
+ # Build artifacts and minified files
280
+ **/*.min.js, **/*.min.css, **/*.bundle.js, **/*.tsbuildinfo
281
+
282
+ # Logs and temporary files
283
+ **/logs/**, **/*.log, **/.DS_Store
284
+ ```
285
+
239
286
  ### API Options
240
287
 
241
288
  ```typescript
package/dist/cli.js CHANGED
@@ -564,6 +564,7 @@ function analyzeIssues(params) {
564
564
  var import_chalk = __toESM(require("chalk"));
565
565
  var import_fs = require("fs");
566
566
  var import_path = require("path");
567
+ var import_core3 = require("@aiready/core");
567
568
  var program = new import_commander.Command();
568
569
  program.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth", "5").option(
569
570
  "--max-context <number>",
@@ -585,17 +586,30 @@ program.name("aiready-context").description("Analyze AI context window cost and
585
586
  console.log(import_chalk.default.blue("\u{1F50D} Analyzing context window costs...\n"));
586
587
  const startTime = Date.now();
587
588
  try {
588
- const results = await analyzeContext({
589
+ const config = (0, import_core3.loadConfig)(directory);
590
+ const defaults = {
591
+ maxDepth: 5,
592
+ maxContextBudget: 1e4,
593
+ minCohesion: 0.6,
594
+ maxFragmentation: 0.5,
595
+ focus: "all",
596
+ includeNodeModules: false,
597
+ include: void 0,
598
+ exclude: void 0
599
+ };
600
+ const mergedConfig = (0, import_core3.mergeConfigWithDefaults)(config, defaults);
601
+ const finalOptions = {
589
602
  rootDir: directory,
590
- maxDepth: parseInt(options.maxDepth),
591
- maxContextBudget: parseInt(options.maxContext),
592
- minCohesion: parseFloat(options.minCohesion),
593
- maxFragmentation: parseFloat(options.maxFragmentation),
594
- focus: options.focus,
595
- includeNodeModules: options.includeNodeModules,
596
- include: options.include?.split(","),
597
- exclude: options.exclude?.split(",")
598
- });
603
+ maxDepth: options.maxDepth ? parseInt(options.maxDepth) : mergedConfig.maxDepth,
604
+ maxContextBudget: options.maxContext ? parseInt(options.maxContext) : mergedConfig.maxContextBudget,
605
+ minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : mergedConfig.minCohesion,
606
+ maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : mergedConfig.maxFragmentation,
607
+ focus: options.focus || mergedConfig.focus,
608
+ includeNodeModules: options.includeNodeModules !== void 0 ? options.includeNodeModules : mergedConfig.includeNodeModules,
609
+ include: options.include?.split(",") || mergedConfig.include,
610
+ exclude: options.exclude?.split(",") || mergedConfig.exclude
611
+ };
612
+ const results = await analyzeContext(finalOptions);
599
613
  const elapsedTime = ((Date.now() - startTime) / 1e3).toFixed(2);
600
614
  const summary = generateSummary(results);
601
615
  if (options.output === "json") {
package/dist/cli.mjs CHANGED
@@ -9,6 +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 { loadConfig, mergeConfigWithDefaults } from "@aiready/core";
12
13
  var program = new Command();
13
14
  program.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth", "5").option(
14
15
  "--max-context <number>",
@@ -30,17 +31,30 @@ program.name("aiready-context").description("Analyze AI context window cost and
30
31
  console.log(chalk.blue("\u{1F50D} Analyzing context window costs...\n"));
31
32
  const startTime = Date.now();
32
33
  try {
33
- const results = await analyzeContext({
34
+ const config = loadConfig(directory);
35
+ const defaults = {
36
+ maxDepth: 5,
37
+ maxContextBudget: 1e4,
38
+ minCohesion: 0.6,
39
+ maxFragmentation: 0.5,
40
+ focus: "all",
41
+ includeNodeModules: false,
42
+ include: void 0,
43
+ exclude: void 0
44
+ };
45
+ const mergedConfig = mergeConfigWithDefaults(config, defaults);
46
+ const finalOptions = {
34
47
  rootDir: directory,
35
- maxDepth: parseInt(options.maxDepth),
36
- maxContextBudget: parseInt(options.maxContext),
37
- minCohesion: parseFloat(options.minCohesion),
38
- maxFragmentation: parseFloat(options.maxFragmentation),
39
- focus: options.focus,
40
- includeNodeModules: options.includeNodeModules,
41
- include: options.include?.split(","),
42
- exclude: options.exclude?.split(",")
43
- });
48
+ maxDepth: options.maxDepth ? parseInt(options.maxDepth) : mergedConfig.maxDepth,
49
+ maxContextBudget: options.maxContext ? parseInt(options.maxContext) : mergedConfig.maxContextBudget,
50
+ minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : mergedConfig.minCohesion,
51
+ maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : mergedConfig.maxFragmentation,
52
+ focus: options.focus || mergedConfig.focus,
53
+ includeNodeModules: options.includeNodeModules !== void 0 ? options.includeNodeModules : mergedConfig.includeNodeModules,
54
+ include: options.include?.split(",") || mergedConfig.include,
55
+ exclude: options.exclude?.split(",") || mergedConfig.exclude
56
+ };
57
+ const results = await analyzeContext(finalOptions);
44
58
  const elapsedTime = ((Date.now() - startTime) / 1e3).toFixed(2);
45
59
  const summary = generateSummary(results);
46
60
  if (options.output === "json") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/context-analyzer",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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.2.1"
52
+ "@aiready/core": "0.2.3"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^22.10.2",
package/src/cli.ts CHANGED
@@ -5,6 +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 { loadConfig, mergeConfigWithDefaults } from '@aiready/core';
8
9
 
9
10
  const program = new Command();
10
11
 
@@ -45,17 +46,38 @@ program
45
46
  const startTime = Date.now();
46
47
 
47
48
  try {
48
- const results = await analyzeContext({
49
+ // Load config file if it exists
50
+ const config = loadConfig(directory);
51
+
52
+ // Define defaults
53
+ const defaults = {
54
+ maxDepth: 5,
55
+ maxContextBudget: 10000,
56
+ minCohesion: 0.6,
57
+ maxFragmentation: 0.5,
58
+ focus: 'all',
59
+ includeNodeModules: false,
60
+ include: undefined,
61
+ exclude: undefined,
62
+ };
63
+
64
+ // Merge config with defaults
65
+ const mergedConfig = mergeConfigWithDefaults(config, defaults);
66
+
67
+ // Override with CLI options (CLI takes precedence)
68
+ const finalOptions = {
49
69
  rootDir: directory,
50
- maxDepth: parseInt(options.maxDepth),
51
- maxContextBudget: parseInt(options.maxContext),
52
- minCohesion: parseFloat(options.minCohesion),
53
- maxFragmentation: parseFloat(options.maxFragmentation),
54
- focus: options.focus as any,
55
- includeNodeModules: options.includeNodeModules,
56
- include: options.include?.split(','),
57
- exclude: options.exclude?.split(','),
58
- });
70
+ maxDepth: options.maxDepth ? parseInt(options.maxDepth) : mergedConfig.maxDepth,
71
+ maxContextBudget: options.maxContext ? parseInt(options.maxContext) : mergedConfig.maxContextBudget,
72
+ minCohesion: options.minCohesion ? parseFloat(options.minCohesion) : mergedConfig.minCohesion,
73
+ maxFragmentation: options.maxFragmentation ? parseFloat(options.maxFragmentation) : mergedConfig.maxFragmentation,
74
+ focus: (options.focus || mergedConfig.focus) as any,
75
+ includeNodeModules: options.includeNodeModules !== undefined ? options.includeNodeModules : mergedConfig.includeNodeModules,
76
+ include: options.include?.split(',') || mergedConfig.include,
77
+ exclude: options.exclude?.split(',') || mergedConfig.exclude,
78
+ };
79
+
80
+ const results = await analyzeContext(finalOptions);
59
81
 
60
82
  const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);
61
83
  const summary = generateSummary(results);