@empiricalrun/test-gen 0.41.4 → 0.41.6
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 +12 -0
- package/dist/agent/codegen/repo-edit.d.ts.map +1 -1
- package/dist/agent/codegen/repo-edit.js +2 -4
- package/dist/agent/codegen/utils.d.ts +30 -0
- package/dist/agent/codegen/utils.d.ts.map +1 -1
- package/dist/agent/codegen/utils.js +85 -18
- package/dist/reporter/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.41.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cee101c: fix: search and replace code for repo edit agent
|
|
8
|
+
|
|
9
|
+
## 0.41.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- da4d7f1: fix: added strict check for project repo name
|
|
14
|
+
|
|
3
15
|
## 0.41.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAexE,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE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CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CA6GD;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B,EAAE,CAAC;CACL,CAAC,CAiED"}
|
|
@@ -132,9 +132,8 @@ async function repoEditAgent({ trace, task, }) {
|
|
|
132
132
|
repoFiles,
|
|
133
133
|
});
|
|
134
134
|
const updates = repoAgentOutput.fileChanges;
|
|
135
|
-
const fileUpdateResponses = await (0, utils_1.
|
|
135
|
+
const fileUpdateResponses = await (0, utils_1.applyFileChangesForRepoEdit)({
|
|
136
136
|
trace,
|
|
137
|
-
testCase: {},
|
|
138
137
|
fileChanges: updates.filter((f) => f.filePath && fs_extra_1.default.existsSync(f.filePath)),
|
|
139
138
|
});
|
|
140
139
|
const errorResponses = fileUpdateResponses.filter((f) => f?.error);
|
|
@@ -148,9 +147,8 @@ async function repoEditAgent({ trace, task, }) {
|
|
|
148
147
|
errorMessage: e?.errorMessage,
|
|
149
148
|
})),
|
|
150
149
|
});
|
|
151
|
-
await (0, utils_1.
|
|
150
|
+
await (0, utils_1.applyFileChangesForRepoEdit)({
|
|
152
151
|
trace,
|
|
153
|
-
testCase: {},
|
|
154
152
|
fileChanges: updatedFileChanges,
|
|
155
153
|
});
|
|
156
154
|
}
|
|
@@ -88,4 +88,34 @@ export declare function getTaskForCreateTest({ testCase, file, }: {
|
|
|
88
88
|
testCase: TestCase;
|
|
89
89
|
file: string;
|
|
90
90
|
}): string;
|
|
91
|
+
export declare function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }: {
|
|
92
|
+
trace?: TraceClient;
|
|
93
|
+
fileChanges: {
|
|
94
|
+
filePath: string | undefined;
|
|
95
|
+
oldCode: string | undefined;
|
|
96
|
+
newCode: string | undefined;
|
|
97
|
+
reason: string | undefined;
|
|
98
|
+
}[];
|
|
99
|
+
logger?: CustomLogger;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
error: boolean;
|
|
102
|
+
errorMessage: string;
|
|
103
|
+
filePath: string;
|
|
104
|
+
}[]>;
|
|
105
|
+
export declare function searchAndReplaceCode({ logger, fileChange, }: {
|
|
106
|
+
fileChange: {
|
|
107
|
+
filePath: string | undefined;
|
|
108
|
+
oldCode: string | undefined;
|
|
109
|
+
newCode: string | undefined;
|
|
110
|
+
reason: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
logger?: CustomLogger;
|
|
113
|
+
}): Promise<{
|
|
114
|
+
result: {
|
|
115
|
+
error: boolean;
|
|
116
|
+
errorMessage: string;
|
|
117
|
+
filePath: string;
|
|
118
|
+
};
|
|
119
|
+
updatedContent: string;
|
|
120
|
+
}>;
|
|
91
121
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMhD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG7D;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IACjD,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO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EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CA6BD"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = exports.applyFileChanges = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
|
|
6
|
+
exports.searchAndReplaceCode = exports.applyFileChangesForRepoEdit = exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = exports.applyFileChanges = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
|
|
7
7
|
const llm_1 = require("@empiricalrun/llm");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const ts_morph_1 = require("ts-morph");
|
|
@@ -162,30 +162,27 @@ async function applyFileChanges({ trace, testCase, fileChanges, logger, }) {
|
|
|
162
162
|
contents = originalSource.getFullText();
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
165
|
+
const { result, updatedContent } = await searchAndReplaceCode({
|
|
166
|
+
logger,
|
|
167
|
+
fileChange,
|
|
168
|
+
});
|
|
169
|
+
if (result.error) {
|
|
172
170
|
logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
|
|
173
|
-
results.push(
|
|
174
|
-
filePath: fileChange.filePath,
|
|
175
|
-
error: true,
|
|
176
|
-
errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
|
|
177
|
-
});
|
|
171
|
+
results.push(result);
|
|
178
172
|
continue;
|
|
179
173
|
}
|
|
174
|
+
else {
|
|
175
|
+
contents = updatedContent;
|
|
176
|
+
}
|
|
180
177
|
}
|
|
181
178
|
await fs_extra_1.default.writeFile(fileChange.filePath, contents, "utf-8");
|
|
182
179
|
readWriteFileSpan?.end({ output: { contents } });
|
|
180
|
+
results.push({
|
|
181
|
+
filePath: fileChange.filePath,
|
|
182
|
+
error: false,
|
|
183
|
+
errorMessage: "",
|
|
184
|
+
});
|
|
183
185
|
}
|
|
184
|
-
results.push({
|
|
185
|
-
filePath: fileChange.filePath,
|
|
186
|
-
error: false,
|
|
187
|
-
errorMessage: "",
|
|
188
|
-
});
|
|
189
186
|
}
|
|
190
187
|
catch (e) {
|
|
191
188
|
trace?.event({
|
|
@@ -242,3 +239,73 @@ ${testCase.steps.join("\n")}
|
|
|
242
239
|
`;
|
|
243
240
|
}
|
|
244
241
|
exports.getTaskForCreateTest = getTaskForCreateTest;
|
|
242
|
+
async function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }) {
|
|
243
|
+
const repoEditFileChangesSpan = trace?.span({
|
|
244
|
+
name: "repo-edit-file-changes",
|
|
245
|
+
});
|
|
246
|
+
const results = [];
|
|
247
|
+
for (const fileChange of fileChanges) {
|
|
248
|
+
if (!fileChange.filePath) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const readWriteFileSpan = repoEditFileChangesSpan?.span({
|
|
253
|
+
name: "write-to-file",
|
|
254
|
+
input: {
|
|
255
|
+
fileChange,
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
const { result, updatedContent } = await searchAndReplaceCode({
|
|
259
|
+
logger,
|
|
260
|
+
fileChange,
|
|
261
|
+
});
|
|
262
|
+
if (result.error) {
|
|
263
|
+
logger?.error(`Unable to find the code to update in ${result.filePath}`);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
|
|
267
|
+
readWriteFileSpan?.end({ output: { updatedContent } });
|
|
268
|
+
}
|
|
269
|
+
results.push(result);
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
trace?.event({
|
|
273
|
+
name: "repo-edit-file-changes-error",
|
|
274
|
+
output: {
|
|
275
|
+
filePath: fileChange.filePath,
|
|
276
|
+
error: e,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return results;
|
|
283
|
+
}
|
|
284
|
+
exports.applyFileChangesForRepoEdit = applyFileChangesForRepoEdit;
|
|
285
|
+
async function searchAndReplaceCode({ logger, fileChange, }) {
|
|
286
|
+
let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
|
|
287
|
+
// since we dont know what is getting updated,
|
|
288
|
+
// we believe that the patch is correct and contains few before and after lines
|
|
289
|
+
// to make the change unique for search & replace
|
|
290
|
+
if (contents.includes(fileChange.oldCode)) {
|
|
291
|
+
const updatedContent = contents.replace(fileChange.oldCode, `\n\n${fileChange.newCode}`);
|
|
292
|
+
return {
|
|
293
|
+
result: {
|
|
294
|
+
error: false,
|
|
295
|
+
errorMessage: "",
|
|
296
|
+
filePath: fileChange.filePath,
|
|
297
|
+
},
|
|
298
|
+
updatedContent,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
|
|
302
|
+
return {
|
|
303
|
+
result: {
|
|
304
|
+
error: true,
|
|
305
|
+
errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
|
|
306
|
+
filePath: fileChange.filePath,
|
|
307
|
+
},
|
|
308
|
+
updatedContent: contents,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
exports.searchAndReplaceCode = searchAndReplaceCode;
|
package/dist/reporter/index.js
CHANGED
|
@@ -95,7 +95,7 @@ class TestGenUpdatesReporter {
|
|
|
95
95
|
logger.log("Skipped uploading current view screenshot");
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
if (!reporterConfig) {
|
|
98
|
+
if (!reporterConfig?.projectRepoName) {
|
|
99
99
|
logger.log("Reporter config is not set skipping screenshot uploads.");
|
|
100
100
|
return;
|
|
101
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"tsx": "^4.16.2",
|
|
73
73
|
"typescript": "^5.3.3",
|
|
74
74
|
"@empiricalrun/llm": "^0.9.29",
|
|
75
|
-
"@empiricalrun/
|
|
76
|
-
"@empiricalrun/
|
|
75
|
+
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
76
|
+
"@empiricalrun/reporter": "^0.22.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@playwright/test": "1.49.1",
|