@nhonh/qabot 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nhonh/qabot",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "AI-powered universal QA automation tool. Import any project, AI analyzes and runs tests across all layers.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -64,8 +64,45 @@ export class AIEngine {
64
64
  }
65
65
 
66
66
  async generateTestCode(testCases, context) {
67
- const prompt = buildGenerationPrompt(testCases, context);
68
- return this.complete(prompt);
67
+ const maxBatchSize = 8;
68
+
69
+ if (testCases.length <= maxBatchSize) {
70
+ const prompt = buildGenerationPrompt(testCases, context);
71
+ const savedMaxTokens = this.maxTokens;
72
+ this.maxTokens = Math.max(this.maxTokens, 8192);
73
+ try {
74
+ return await this.complete(prompt);
75
+ } finally {
76
+ this.maxTokens = savedMaxTokens;
77
+ }
78
+ }
79
+
80
+ const batches = [];
81
+ for (let i = 0; i < testCases.length; i += maxBatchSize) {
82
+ batches.push(testCases.slice(i, i + maxBatchSize));
83
+ }
84
+
85
+ const savedMaxTokens = this.maxTokens;
86
+ this.maxTokens = Math.max(this.maxTokens, 8192);
87
+
88
+ let fullCode = "";
89
+ try {
90
+ for (let i = 0; i < batches.length; i++) {
91
+ const isFirst = i === 0;
92
+ const batchContext = { ...context };
93
+ if (!isFirst) {
94
+ batchContext.existingTestCode = "";
95
+ batchContext.sourceCode = "";
96
+ }
97
+ const prompt = buildGenerationPrompt(batches[i], batchContext);
98
+ const code = await this.complete(prompt);
99
+ fullCode += (isFirst ? "" : "\n\n") + code;
100
+ }
101
+ } finally {
102
+ this.maxTokens = savedMaxTokens;
103
+ }
104
+
105
+ return fullCode;
69
106
  }
70
107
 
71
108
  async generateRecommendations(results) {
@@ -222,7 +222,22 @@ function cleanGeneratedCode(code) {
222
222
  if (cleaned.endsWith("```")) {
223
223
  cleaned = cleaned.slice(0, cleaned.lastIndexOf("```"));
224
224
  }
225
- return cleaned.trim() + "\n";
225
+ cleaned = cleaned.trim();
226
+
227
+ const openBraces = (cleaned.match(/\{/g) || []).length;
228
+ const closeBraces = (cleaned.match(/\}/g) || []).length;
229
+ const openParens = (cleaned.match(/\(/g) || []).length;
230
+ const closeParens = (cleaned.match(/\)/g) || []).length;
231
+
232
+ let suffix = "";
233
+ for (let i = 0; i < openParens - closeParens; i++) suffix += ")";
234
+ for (let i = 0; i < openBraces - closeBraces; i++) suffix += "\n}";
235
+
236
+ if (suffix) {
237
+ cleaned += suffix + ";\n";
238
+ }
239
+
240
+ return cleaned + "\n";
226
241
  }
227
242
 
228
243
  function toPascalCase(str) {
@@ -1,4 +1,4 @@
1
- export const VERSION = "0.4.0";
1
+ export const VERSION = "0.4.1";
2
2
  export const TOOL_NAME = "qabot";
3
3
 
4
4
  export const PROJECT_TYPES = [