ai-unit-test-generator 2.0.2 → 2.0.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/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.4] - 2025-01-11
9
+
10
+ ### 🐛 Hotfix
11
+ - **Fixed**: ESM import error in `lib/workflows/analyze.mjs` - replaced `require` with proper `import`
12
+ - Added `readFileSync` to imports at module top
13
+ - Resolves `ReferenceError: require is not defined` in ESM context
14
+
15
+ ---
16
+
17
+ ## [2.0.3] - 2025-01-11
18
+
19
+ ### 🐛 Hotfix
20
+ - **Fixed**: `ai-test analyze` and `ai-test generate` - use `cursor-agent --print` instead of `cursor-agent chat`
21
+ - The `--print` flag enables non-interactive mode suitable for scripting
22
+ - Both `lib/workflows/analyze.mjs` and `lib/ai/client.mjs` updated
23
+
24
+ ---
25
+
8
26
  ## [2.0.2] - 2025-01-11
9
27
 
10
28
  ### 🐛 Hotfix
package/lib/ai/client.mjs CHANGED
@@ -30,7 +30,7 @@ export async function runOnce({ prompt, promptFile, out = 'reports/ai_response.t
30
30
  }
31
31
 
32
32
  return new Promise((resolve, reject) => {
33
- const args = ['chat']
33
+ const args = ['--print']
34
34
  if (model) args.push('-m', model)
35
35
 
36
36
  const child = spawn('cursor-agent', args, { stdio: ['pipe', 'pipe', 'inherit'] })
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { spawn } from 'node:child_process'
6
- import { writeFileSync } from 'node:fs'
6
+ import { writeFileSync, readFileSync } from 'node:fs'
7
7
  import { detectConfig } from '../utils/config-manager.mjs'
8
8
  import { sampleCodeFiles, analyzeProjectStructure } from '../ai/sampler.mjs'
9
9
  import { buildProjectContext } from '../ai/context-builder.mjs'
@@ -122,8 +122,6 @@ export async function analyze(options) {
122
122
  */
123
123
  async function callCursorAgent(promptPath) {
124
124
  return new Promise((resolve, reject) => {
125
- const { readFileSync } = require('node:fs')
126
-
127
125
  // 读取 prompt
128
126
  let prompt
129
127
  try {
@@ -133,8 +131,8 @@ async function callCursorAgent(promptPath) {
133
131
  return
134
132
  }
135
133
 
136
- // 调用 cursor-agent chat(通过 stdin 传递 prompt)
137
- const child = spawn('cursor-agent', ['chat'], {
134
+ // 调用 cursor-agent --print(通过 stdin 传递 prompt)
135
+ const child = spawn('cursor-agent', ['--print'], {
138
136
  stdio: ['pipe', 'pipe', 'inherit'],
139
137
  shell: true,
140
138
  cwd: process.cwd()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-unit-test-generator",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "AI-powered unit test generator with smart priority scoring",
5
5
  "keywords": [
6
6
  "unit-test",