@aiready/context-analyzer 0.4.2 → 0.4.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.4.2 build /Users/pengcao/projects/aiready/packages/context-analyzer
3
+ > @aiready/context-analyzer@0.4.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
- ESM dist/cli.mjs 15.74 KB
13
- ESM dist/index.mjs 164.00 B
14
12
  ESM dist/chunk-HDFXSEFW.mjs 19.11 KB
15
- ESM ⚡️ Build success in 33ms
16
- CJS dist/cli.js 35.91 KB
13
+ ESM dist/index.mjs 164.00 B
14
+ ESM dist/cli.mjs 16.16 KB
15
+ ESM ⚡️ Build success in 16ms
16
+ CJS dist/cli.js 36.36 KB
17
17
  CJS dist/index.js 20.26 KB
18
- CJS ⚡️ Build success in 33ms
18
+ CJS ⚡️ Build success in 16ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 646ms
20
+ DTS ⚡️ Build success in 540ms
21
21
  DTS dist/cli.d.ts 20.00 B
22
22
  DTS dist/index.d.ts 2.37 KB
23
23
  DTS dist/cli.d.mts 20.00 B
package/README.md CHANGED
@@ -75,8 +75,14 @@ aiready-context ./src --focus depth
75
75
  # Set thresholds
76
76
  aiready-context ./src --max-depth 5 --max-context 10000 --min-cohesion 0.6
77
77
 
78
- # Export to JSON
79
- aiready-context ./src --output json --output-file report.json
78
+ # Export to JSON (saved to .aiready/ by default)
79
+ aiready-context ./src --output json
80
+
81
+ # Or specify custom path
82
+ aiready-context ./src --output json --output-file custom-report.json
83
+ ```
84
+
85
+ > **📁 Output Files:** By default, all output files are saved to the `.aiready/` directory in your project root. You can override this with `--output-file`.
80
86
 
81
87
  # Generate HTML report
82
88
  aiready-context ./src --output html --output-file report.html
package/dist/cli.js CHANGED
@@ -641,13 +641,26 @@ program.name("aiready-context").description("Analyze AI context window cost and
641
641
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
642
642
  analysisTime: elapsedTime
643
643
  };
644
- (0, import_core3.handleJSONOutput)(jsonOutput, options.outputFile, `
645
- \u2713 JSON report saved to ${options.outputFile}`);
644
+ const outputPath = (0, import_core3.resolveOutputPath)(
645
+ options.outputFile,
646
+ `context-report-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.json`,
647
+ directory
648
+ );
649
+ (0, import_core3.handleJSONOutput)(jsonOutput, outputPath, `
650
+ \u2713 JSON report saved to ${outputPath}`);
646
651
  return;
647
652
  }
648
653
  if (options.output === "html") {
649
654
  const html = generateHTMLReport(summary, results);
650
- const outputPath = options.outputFile || (0, import_path.join)(process.cwd(), "context-report.html");
655
+ const outputPath = (0, import_core3.resolveOutputPath)(
656
+ options.outputFile,
657
+ `context-report-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.html`,
658
+ directory
659
+ );
660
+ const dir = (0, import_path.dirname)(outputPath);
661
+ if (!(0, import_fs.existsSync)(dir)) {
662
+ (0, import_fs.mkdirSync)(dir, { recursive: true });
663
+ }
651
664
  (0, import_fs.writeFileSync)(outputPath, html);
652
665
  console.log(import_chalk.default.green(`
653
666
  \u2713 HTML report saved to ${outputPath}`));
package/dist/cli.mjs CHANGED
@@ -7,9 +7,9 @@ import {
7
7
  // src/cli.ts
8
8
  import { Command } from "commander";
9
9
  import chalk from "chalk";
10
- import { writeFileSync, existsSync, readFileSync } from "fs";
11
- import { join } from "path";
12
- import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime } from "@aiready/core";
10
+ import { writeFileSync, existsSync, readFileSync, mkdirSync } from "fs";
11
+ import { join, dirname } from "path";
12
+ import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime, resolveOutputPath } from "@aiready/core";
13
13
  import prompts from "prompts";
14
14
  var program = new Command();
15
15
  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(
@@ -64,13 +64,26 @@ program.name("aiready-context").description("Analyze AI context window cost and
64
64
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
65
65
  analysisTime: elapsedTime
66
66
  };
67
- handleJSONOutput(jsonOutput, options.outputFile, `
68
- \u2713 JSON report saved to ${options.outputFile}`);
67
+ const outputPath = resolveOutputPath(
68
+ options.outputFile,
69
+ `context-report-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.json`,
70
+ directory
71
+ );
72
+ handleJSONOutput(jsonOutput, outputPath, `
73
+ \u2713 JSON report saved to ${outputPath}`);
69
74
  return;
70
75
  }
71
76
  if (options.output === "html") {
72
77
  const html = generateHTMLReport(summary, results);
73
- const outputPath = options.outputFile || join(process.cwd(), "context-report.html");
78
+ const outputPath = resolveOutputPath(
79
+ options.outputFile,
80
+ `context-report-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.html`,
81
+ directory
82
+ );
83
+ const dir = dirname(outputPath);
84
+ if (!existsSync(dir)) {
85
+ mkdirSync(dir, { recursive: true });
86
+ }
74
87
  writeFileSync(outputPath, html);
75
88
  console.log(chalk.green(`
76
89
  \u2713 HTML report saved to ${outputPath}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/context-analyzer",
3
- "version": "0.4.2",
3
+ "version": "0.4.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",
@@ -50,7 +50,7 @@
50
50
  "commander": "^12.1.0",
51
51
  "chalk": "^5.3.0",
52
52
  "prompts": "^2.4.2",
53
- "@aiready/core": "0.5.1"
53
+ "@aiready/core": "0.5.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "^22.10.2",
package/src/cli.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  import { Command } from 'commander';
4
4
  import { analyzeContext, generateSummary } from './index';
5
5
  import chalk from 'chalk';
6
- import { writeFileSync, existsSync, readFileSync } from 'fs';
7
- import { join } from 'path';
8
- import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime } from '@aiready/core';
6
+ import { writeFileSync, existsSync, readFileSync, mkdirSync } from 'fs';
7
+ import { join, dirname } from 'path';
8
+ import { loadMergedConfig, handleJSONOutput, handleCLIError, getElapsedTime, resolveOutputPath } from '@aiready/core';
9
9
  import prompts from 'prompts';
10
10
 
11
11
  const program = new Command();
@@ -91,14 +91,29 @@ program
91
91
  analysisTime: elapsedTime,
92
92
  };
93
93
 
94
- handleJSONOutput(jsonOutput, options.outputFile, `\n✓ JSON report saved to ${options.outputFile}`);
94
+ const outputPath = resolveOutputPath(
95
+ options.outputFile,
96
+ `context-report-${new Date().toISOString().split('T')[0]}.json`,
97
+ directory
98
+ );
99
+
100
+ handleJSONOutput(jsonOutput, outputPath, `\n✓ JSON report saved to ${outputPath}`);
95
101
  return;
96
102
  }
97
103
 
98
104
  if (options.output === 'html') {
99
105
  const html = generateHTMLReport(summary, results);
100
- const outputPath =
101
- options.outputFile || join(process.cwd(), 'context-report.html');
106
+ const outputPath = resolveOutputPath(
107
+ options.outputFile,
108
+ `context-report-${new Date().toISOString().split('T')[0]}.html`,
109
+ directory
110
+ );
111
+
112
+ const dir = dirname(outputPath);
113
+ if (!existsSync(dir)) {
114
+ mkdirSync(dir, { recursive: true });
115
+ }
116
+
102
117
  writeFileSync(outputPath, html);
103
118
  console.log(chalk.green(`\n✓ HTML report saved to ${outputPath}`));
104
119
  return;