ai-unit-test-generator 2.0.1 โ†’ 2.0.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.
package/CHANGELOG.md CHANGED
@@ -5,19 +5,40 @@ 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.0] - 2025-01-11
8
+ ## [2.0.3] - 2025-01-11
9
9
 
10
- ### ๐ŸŽ‰ Major Release: AI-Enhanced Configuration
10
+ ### ๐Ÿ› Hotfix
11
+ - **Fixed**: `ai-test analyze` and `ai-test generate` - use `cursor-agent --print` instead of `cursor-agent chat`
12
+ - The `--print` flag enables non-interactive mode suitable for scripting
13
+ - Both `lib/workflows/analyze.mjs` and `lib/ai/client.mjs` updated
11
14
 
12
- This is a **major refactor** with breaking changes. The package has been completely restructured to support AI-powered codebase analysis and intelligent scoring configuration.
15
+ ---
16
+
17
+ ## [2.0.2] - 2025-01-11
18
+
19
+ ### ๐Ÿ› Hotfix
20
+ - **Fixed**: `ai-test analyze` command - corrected Cursor Agent invocation to use `chat` command with stdin
21
+ - Previously used invalid `--prompt-file` option, now uses correct stdin-based approach
22
+
23
+ ---
24
+
25
+ ## [2.0.1] - 2025-01-11
13
26
 
14
- ### ๐Ÿ”ฅ Hotfix (same day)
27
+ ### ๐Ÿ”ฅ Hotfix
15
28
  - **Fixed**: AI enhancement logic now correctly applied in `scorer.mjs` scoring loop
16
29
  - **Optimized**: File-level import caching in `scanner.mjs` (30-40% performance improvement)
17
30
  - **Configurable**: Business entity keywords moved to `aiEnhancement.entityKeywords`
18
31
  - **Updated**: README reflects v2.0 architecture
19
32
  - **Added**: `matchPattern` helper function for glob pattern matching in AI suggestions
20
33
 
34
+ ---
35
+
36
+ ## [2.0.0] - 2025-01-11
37
+
38
+ ### ๐ŸŽ‰ Major Release: AI-Enhanced Configuration
39
+
40
+ This is a **major refactor** with breaking changes. The package has been completely restructured to support AI-powered codebase analysis and intelligent scoring configuration.
41
+
21
42
  ### Added
22
43
 
23
44
  #### New Commands
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'] })
@@ -122,34 +122,51 @@ export async function analyze(options) {
122
122
  */
123
123
  async function callCursorAgent(promptPath) {
124
124
  return new Promise((resolve, reject) => {
125
- const responsePath = 'reports/ai_analyze_response.txt'
125
+ const { readFileSync } = require('node:fs')
126
126
 
127
- const child = spawn('cursor-agent', [
128
- '--prompt-file', promptPath,
129
- '--output', responsePath
130
- ], {
131
- stdio: 'inherit',
127
+ // ่ฏปๅ– prompt
128
+ let prompt
129
+ try {
130
+ prompt = readFileSync(promptPath, 'utf-8')
131
+ } catch (err) {
132
+ reject(new Error(`Failed to read prompt file: ${err.message}`))
133
+ return
134
+ }
135
+
136
+ // ่ฐƒ็”จ cursor-agent --print๏ผˆ้€š่ฟ‡ stdin ไผ ้€’ prompt๏ผ‰
137
+ const child = spawn('cursor-agent', ['--print'], {
138
+ stdio: ['pipe', 'pipe', 'inherit'],
132
139
  shell: true,
133
140
  cwd: process.cwd()
134
141
  })
135
142
 
143
+ const chunks = []
144
+ child.stdout.on('data', (d) => chunks.push(Buffer.from(d)))
145
+
146
+ // ๅ†™ๅ…ฅ prompt ๅˆฐ stdin
147
+ child.stdin.write(prompt)
148
+ child.stdin.end()
149
+
150
+ // ่ถ…ๆ—ถๅค„็†๏ผˆ10 ๅˆ†้’Ÿ๏ผ‰
151
+ const timeout = setTimeout(() => {
152
+ child.kill('SIGKILL')
153
+ reject(new Error('cursor-agent timeout after 600s'))
154
+ }, 600000)
155
+
136
156
  child.on('close', (code) => {
157
+ clearTimeout(timeout)
158
+
137
159
  if (code !== 0) {
138
160
  reject(new Error(`cursor-agent exited with code ${code}`))
139
161
  return
140
162
  }
141
163
 
142
- // ่ฏปๅ–ๅ“ๅบ”
143
- try {
144
- const { readFileSync } = require('node:fs')
145
- const response = readFileSync(responsePath, 'utf-8')
146
- resolve(response)
147
- } catch (err) {
148
- reject(new Error(`Failed to read AI response: ${err.message}`))
149
- }
164
+ const response = Buffer.concat(chunks).toString('utf-8')
165
+ resolve(response)
150
166
  })
151
167
 
152
168
  child.on('error', (err) => {
169
+ clearTimeout(timeout)
153
170
  reject(new Error(`Failed to spawn cursor-agent: ${err.message}`))
154
171
  })
155
172
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-unit-test-generator",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "AI-powered unit test generator with smart priority scoring",
5
5
  "keywords": [
6
6
  "unit-test",