@empiricalrun/test-gen 0.42.12 → 0.42.14

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.
@@ -0,0 +1,20 @@
1
+ import { TestCase } from "../../types";
2
+ export type CodeUpdate = {
3
+ filePath: string | undefined;
4
+ oldCode: string | undefined;
5
+ newCode: string | undefined;
6
+ reason: string | undefined;
7
+ };
8
+ export type FileUpdateResponse = {
9
+ error: boolean;
10
+ errorMessage: string;
11
+ filePath: string;
12
+ };
13
+ export type UpdatedTestCase = TestCase & {
14
+ updatedFiles: string[];
15
+ };
16
+ export declare enum CodeEditorToolCall {
17
+ STR_REPLACE = "str_replace",
18
+ CREATE_FILE = "create_file"
19
+ }
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG;IACvC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,oBAAY,kBAAkB;IAC5B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;CAC5B"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodeEditorToolCall = void 0;
4
+ var CodeEditorToolCall;
5
+ (function (CodeEditorToolCall) {
6
+ CodeEditorToolCall["STR_REPLACE"] = "str_replace";
7
+ CodeEditorToolCall["CREATE_FILE"] = "create_file";
8
+ })(CodeEditorToolCall || (exports.CodeEditorToolCall = CodeEditorToolCall = {}));
@@ -1,8 +1,8 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import { ChatCompletionMessageParam } from "openai/resources/index.mjs";
3
3
  import { TestCase, TestGenConfigOptions } from "../../types";
4
- import { UpdatedTestCase } from "./utils";
5
- export declare function getUpdateTestCodeCompletion({ testCase, testFileContent, testFiles, pageFiles, testFilePath, trace, options, }: {
4
+ import { CodeUpdate, UpdatedTestCase } from "./types";
5
+ export declare function getUpdateTestCodeCompletion({ testCase, testFileContent, testFiles, pageFiles, testFilePath, options, trace, }: {
6
6
  testCase: TestCase;
7
7
  testFiles: string;
8
8
  pageFiles: string;
@@ -13,12 +13,7 @@ export declare function getUpdateTestCodeCompletion({ testCase, testFileContent,
13
13
  }): Promise<{
14
14
  prompt: ChatCompletionMessageParam[];
15
15
  agentResponse: string;
16
- fileChanges: {
17
- filePath: string | undefined;
18
- oldCode: string | undefined;
19
- newCode: string | undefined;
20
- reason: string | undefined;
21
- }[];
16
+ fileChanges: CodeUpdate[];
22
17
  }>;
23
18
  export declare function updateTest(testCase: TestCase, file: string, options: TestGenConfigOptions | undefined, logging?: boolean, validate?: boolean, trace?: TraceClient): Promise<UpdatedTestCase[]>;
24
19
  export declare function getAppendCreateTestBlockCompletion({ testFiles, pageFiles, testCase, testFilePath, options, trace, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"update-flow.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/update-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAYxE,OAAO,EAAE,QAAQ,EAAE,oBAAoB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,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,GAAE,OAAc,EACvB,QAAQ,GAAE,OAAc,EACxB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,eAAe,EAAE,CAAC,CA+F5B;AAED,wBAAsB,kCAAkC,CAAC,EACvD,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,KAAK,GACN,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;CACtB,mBAuGA;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,KAAK,EACL,aAAoB,GACrB,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAqD7B"}
@@ -15,11 +15,10 @@ const constants_1 = require("../../constants");
15
15
  const session_1 = require("../../session");
16
16
  const test_update_feedback_1 = require("./test-update-feedback");
17
17
  const utils_1 = require("./utils");
18
- async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFiles, pageFiles, testFilePath, trace, options, }) {
18
+ async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFiles, pageFiles, testFilePath, options, trace, }) {
19
19
  const promptSpan = trace?.span({
20
20
  name: "update-scenario-prompt",
21
21
  });
22
- const promptName = "update-scenario";
23
22
  // if describe blocks are present, we need to add them to the scenario name
24
23
  // e.g. describe block: login ---> login with email
25
24
  // this is help LLM navigate to the right test block
@@ -32,6 +31,7 @@ async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFile
32
31
  content: testFileContent,
33
32
  suites: testCase?.suites || [],
34
33
  });
34
+ const promptName = "update-scenario";
35
35
  const prompt = await (0, llm_1.getPrompt)(promptName, {
36
36
  testFiles: testFiles,
37
37
  pageFiles: pageFiles,
@@ -1,6 +1,7 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import { CustomLogger } from "../../bin/logger";
3
3
  import { TestCase, TestGenConfigOptions } from "../../types";
4
+ import { CodeUpdate, FileUpdateResponse } from "./types";
4
5
  /**
5
6
  *
6
7
  * method to extract file path and code updates for the LLM response of update flow
@@ -13,12 +14,7 @@ import { TestCase, TestGenConfigOptions } from "../../types";
13
14
  * reason: string | undefined;
14
15
  * }[])}
15
16
  */
16
- export declare function extractTestUpdates(input: string): {
17
- filePath: string | undefined;
18
- oldCode: string | undefined;
19
- newCode: string | undefined;
20
- reason: string | undefined;
21
- }[];
17
+ export declare function extractTestUpdates(input: string): CodeUpdate[];
22
18
  /**
23
19
  *
24
20
  * method to extract append create test updates
@@ -48,37 +44,11 @@ export declare function extractTestStepsSuggestions(input: string): {
48
44
  reason: string;
49
45
  methodName: string;
50
46
  }[];
51
- export type UpdatedTestCase = TestCase & {
52
- updatedFiles: string[];
53
- };
54
- export declare function applyFileChanges({ trace, testCase, fileChanges, logger, }: {
55
- trace?: TraceClient;
56
- testCase: TestCase;
57
- fileChanges: {
58
- filePath: string | undefined;
59
- oldCode: string | undefined;
60
- newCode: string | undefined;
61
- reason: string | undefined;
62
- }[];
63
- logger?: CustomLogger;
64
- testGenOptions?: TestGenConfigOptions;
65
- pomPrompt?: string;
66
- nonSpecFilePrompt?: string;
67
- }): Promise<{
68
- error: boolean;
69
- errorMessage: string;
70
- filePath: string;
71
- }[]>;
72
47
  export declare function validateTypesAndFormatCode({ validateTypes, trace, testCase, fileChanges, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }: {
73
48
  validateTypes?: boolean;
74
49
  trace?: TraceClient;
75
50
  testCase: TestCase;
76
- fileChanges: {
77
- filePath: string | undefined;
78
- oldCode: string | undefined;
79
- newCode: string | undefined;
80
- reason: string | undefined;
81
- }[];
51
+ fileChanges: CodeUpdate[];
82
52
  logger?: CustomLogger;
83
53
  testGenOptions?: TestGenConfigOptions;
84
54
  pomPrompt?: string;
@@ -88,6 +58,23 @@ export declare function getTaskForCreateTest({ testCase, file, }: {
88
58
  testCase: TestCase;
89
59
  file: string;
90
60
  }): string;
61
+ export declare function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, }: {
62
+ trace?: TraceClient;
63
+ fileChanges: CodeUpdate[];
64
+ logger?: CustomLogger;
65
+ }): Promise<FileUpdateResponse[]>;
66
+ export declare function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }: {
67
+ fileChange: {
68
+ filePath: string | undefined;
69
+ oldCode: string | undefined;
70
+ newCode: string | undefined;
71
+ reason: string | undefined;
72
+ };
73
+ logger?: CustomLogger;
74
+ }): Promise<{
75
+ result: FileUpdateResponse;
76
+ updatedContent: string;
77
+ }>;
91
78
  export declare function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }: {
92
79
  trace?: TraceClient;
93
80
  fileChanges: {
@@ -118,4 +105,22 @@ export declare function searchAndReplaceCode({ logger, fileChange, }: {
118
105
  };
119
106
  updatedContent: string;
120
107
  }>;
108
+ export declare function applyFileChanges({ trace, testCase, fileChanges, logger, }: {
109
+ trace?: TraceClient;
110
+ testCase: TestCase;
111
+ fileChanges: {
112
+ filePath: string | undefined;
113
+ oldCode: string | undefined;
114
+ newCode: string | undefined;
115
+ reason: string | undefined;
116
+ }[];
117
+ logger?: CustomLogger;
118
+ testGenOptions?: TestGenConfigOptions;
119
+ pomPrompt?: string;
120
+ nonSpecFilePrompt?: string;
121
+ }): Promise<{
122
+ error: boolean;
123
+ errorMessage: string;
124
+ filePath: string;
125
+ }[]>;
121
126
  //# sourceMapp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AAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAkIxE"}
@@ -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.searchAndReplaceCode = exports.applyFileChangesForRepoEdit = exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = exports.applyFileChanges = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractTestUpdates = void 0;
6
+ exports.applyFileChanges = exports.searchAndReplaceCode = exports.applyFileChangesForRepoEdit = exports.searchAndReplaceCodeUsingStrReplace = exports.applyFileChangesUsingStrReplace = exports.getTaskForCreateTest = exports.validateTypesAndFormatCode = 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");
@@ -89,115 +89,6 @@ function extractTestStepsSuggestions(input) {
89
89
  return result.filter((r) => !!r.filePath && !!r.usageExample);
90
90
  }
91
91
  exports.extractTestStepsSuggestions = extractTestStepsSuggestions;
92
- async function applyFileChanges({ trace, testCase, fileChanges, logger, }) {
93
- const results = [];
94
- for (const fileChange of fileChanges) {
95
- if (!fileChange.filePath) {
96
- continue;
97
- }
98
- try {
99
- const hasTestCaseAsUpdateContext = !!testCase?.name;
100
- let testBlockUpdate = undefined;
101
- if (hasTestCaseAsUpdateContext) {
102
- const applyFileChangesSpan = trace?.span({
103
- name: "apply-file-changes",
104
- });
105
- const block = (0, web_1.getTypescriptTestBlock)({
106
- scenarioName: testCase?.name,
107
- content: fileChange.newCode || "",
108
- suites: [], // // suites should be empty here since we ask LLM to send immediate parent AST node for the code update. so there won't be any nesting here, just the test block
109
- });
110
- testBlockUpdate = block.testBlock;
111
- applyFileChangesSpan?.end({ output: { testBlock: testBlockUpdate } });
112
- }
113
- if (testBlockUpdate) {
114
- // assuming the test case getting updated
115
- // maintaining the previous accuracy of the test case update
116
- const readWriteFileSpan = trace?.span({ name: "write-to-file" });
117
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
118
- const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name);
119
- let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
120
- const { testBlock } = (0, web_1.getTypescriptTestBlock)({
121
- scenarioName: testCase?.name,
122
- content: contents,
123
- suites: testCase?.suites,
124
- });
125
- contents = contents.replace(testBlock, `\n\n${strippedContent}`);
126
- updatedContent = prependContent + contents;
127
- await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
128
- readWriteFileSpan?.end({ output: { updatedContent } });
129
- }
130
- else {
131
- const readWriteFileSpan = trace?.span({ name: "write-to-file" });
132
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
133
- const project = new ts_morph_1.Project();
134
- const sourceFile = project.createSourceFile("updated-code.ts", fileChange.newCode);
135
- const functions = sourceFile.getFunctions();
136
- const checkForMethodSrc = project.createSourceFile("check-method.ts", `class A {
137
- ${fileChange.newCode}
138
- }`);
139
- const methods = checkForMethodSrc.getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration);
140
- const originalSource = project.createSourceFile("current-code.ts", contents);
141
- // if there is a single function update in the file
142
- if (functions.length === 1 &&
143
- functions[0]?.getText() === fileChange.newCode) {
144
- const updatedCodeFuncNames = functions.map((f) => f.getName());
145
- const funcName = updatedCodeFuncNames[0];
146
- const matchingNodes = originalSource
147
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.FunctionDeclaration)
148
- .filter((node) => node.getName() === funcName);
149
- matchingNodes[0]?.replaceWithText(functions[0]?.getText());
150
- contents = originalSource.getFullText();
151
- }
152
- else if (
153
- // if there is a update in method of a class in the file
154
- methods.length === 1 &&
155
- methods[0]?.getText() === fileChange.newCode) {
156
- const method = methods[0];
157
- const funcName = method?.getName();
158
- const matchingNodes = originalSource
159
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration)
160
- .filter((node) => node.getName() === funcName);
161
- matchingNodes[0]?.replaceWithText(method?.getText());
162
- contents = originalSource.getFullText();
163
- }
164
- else {
165
- const { result, updatedContent } = await searchAndReplaceCode({
166
- logger,
167
- fileChange,
168
- });
169
- if (result.error) {
170
- logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
171
- results.push(result);
172
- continue;
173
- }
174
- else {
175
- contents = updatedContent;
176
- }
177
- }
178
- await fs_extra_1.default.writeFile(fileChange.filePath, contents, "utf-8");
179
- readWriteFileSpan?.end({ output: { contents } });
180
- results.push({
181
- filePath: fileChange.filePath,
182
- error: false,
183
- errorMessage: "",
184
- });
185
- }
186
- }
187
- catch (e) {
188
- trace?.event({
189
- name: "apply-file-changes-error",
190
- output: {
191
- filePath: fileChange.filePath,
192
- error: e,
193
- },
194
- });
195
- console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
196
- }
197
- }
198
- return results;
199
- }
200
- exports.applyFileChanges = applyFileChanges;
201
92
  async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, fileChanges, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }) {
202
93
  for (let fileChange of fileChanges) {
203
94
  if (!fileChange.filePath) {
@@ -239,6 +130,87 @@ ${testCase.steps.join("\n")}
239
130
  `;
240
131
  }
241
132
  exports.getTaskForCreateTest = getTaskForCreateTest;
133
+ async function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, }) {
134
+ const repoEditFileChangesSpan = trace?.span({
135
+ name: "repo-edit-file-changes",
136
+ });
137
+ const results = [];
138
+ for (const fileChange of fileChanges) {
139
+ if (!fileChange.filePath) {
140
+ continue;
141
+ }
142
+ try {
143
+ const readWriteFileSpan = repoEditFileChangesSpan?.span({
144
+ name: "write-to-file",
145
+ input: {
146
+ fileChange,
147
+ },
148
+ });
149
+ const { result, updatedContent } = await searchAndReplaceCode({
150
+ logger,
151
+ fileChange,
152
+ });
153
+ if (result.error) {
154
+ logger?.error(`Unable to find the code to update in ${result.filePath}, full error:`, result);
155
+ }
156
+ else {
157
+ await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
158
+ readWriteFileSpan?.end({ output: { updatedContent } });
159
+ }
160
+ results.push(result);
161
+ }
162
+ catch (e) {
163
+ trace?.event({
164
+ name: "repo-edit-file-changes-error",
165
+ output: {
166
+ filePath: fileChange.filePath,
167
+ error: e,
168
+ },
169
+ });
170
+ console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
171
+ }
172
+ }
173
+ return results;
174
+ }
175
+ exports.applyFileChangesUsingStrReplace = applyFileChangesUsingStrReplace;
176
+ async function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }) {
177
+ let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
178
+ if (contents.includes(fileChange.oldCode)) {
179
+ // Check for multiple instances of old code block
180
+ // If there are multiple instances, then we cannot safely determine which instance to replace
181
+ const firstIndex = contents.indexOf(fileChange.oldCode);
182
+ const lastIndex = contents.lastIndexOf(fileChange.oldCode);
183
+ if (firstIndex !== lastIndex) {
184
+ return {
185
+ result: {
186
+ error: true,
187
+ errorMessage: `Multiple instances of the code block found in file "${fileChange.filePath}". Cannot safely determine which instance to replace.`,
188
+ filePath: fileChange.filePath,
189
+ },
190
+ updatedContent: contents,
191
+ };
192
+ }
193
+ const updatedContent = contents.replace(fileChange.oldCode, `\n\n${fileChange.newCode}`);
194
+ return {
195
+ result: {
196
+ error: false,
197
+ errorMessage: "",
198
+ filePath: fileChange.filePath,
199
+ },
200
+ updatedContent,
201
+ };
202
+ }
203
+ logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
204
+ return {
205
+ result: {
206
+ error: true,
207
+ errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
208
+ filePath: fileChange.filePath,
209
+ },
210
+ updatedContent: contents,
211
+ };
212
+ }
213
+ exports.searchAndReplaceCodeUsingStrReplace = searchAndReplaceCodeUsingStrReplace;
242
214
  async function applyFileChangesForRepoEdit({ trace, fileChanges, logger, }) {
243
215
  const repoEditFileChangesSpan = trace?.span({
244
216
  name: "repo-edit-file-changes",
@@ -309,3 +281,112 @@ async function searchAndReplaceCode({ logger, fileChange, }) {
309
281
  };
310
282
  }
311
283
  exports.searchAndReplaceCode = searchAndReplaceCode;
284
+ async function applyFileChanges({ trace, testCase, fileChanges, logger, }) {
285
+ const results = [];
286
+ for (const fileChange of fileChanges) {
287
+ if (!fileChange.filePath) {
288
+ continue;
289
+ }
290
+ try {
291
+ const hasTestCaseAsUpdateContext = !!testCase?.name;
292
+ let testBlockUpdate = undefined;
293
+ if (hasTestCaseAsUpdateContext) {
294
+ const applyFileChangesSpan = trace?.span({
295
+ name: "apply-file-changes",
296
+ });
297
+ const block = (0, web_1.getTypescriptTestBlock)({
298
+ scenarioName: testCase?.name,
299
+ content: fileChange.newCode || "",
300
+ suites: [], // // suites should be empty here since we ask LLM to send immediate parent AST node for the code update. so there won't be any nesting here, just the test block
301
+ });
302
+ testBlockUpdate = block.testBlock;
303
+ applyFileChangesSpan?.end({ output: { testBlock: testBlockUpdate } });
304
+ }
305
+ if (testBlockUpdate) {
306
+ // assuming the test case getting updated
307
+ // maintaining the previous accuracy of the test case update
308
+ const readWriteFileSpan = trace?.span({ name: "write-to-file" });
309
+ let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
310
+ const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name);
311
+ let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
312
+ const { testBlock } = (0, web_1.getTypescriptTestBlock)({
313
+ scenarioName: testCase?.name,
314
+ content: contents,
315
+ suites: testCase?.suites,
316
+ });
317
+ contents = contents.replace(testBlock, `\n\n${strippedContent}`);
318
+ updatedContent = prependContent + contents;
319
+ await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
320
+ readWriteFileSpan?.end({ output: { updatedContent } });
321
+ }
322
+ else {
323
+ const readWriteFileSpan = trace?.span({ name: "write-to-file" });
324
+ let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
325
+ const project = new ts_morph_1.Project();
326
+ const sourceFile = project.createSourceFile("updated-code.ts", fileChange.newCode);
327
+ const functions = sourceFile.getFunctions();
328
+ const checkForMethodSrc = project.createSourceFile("check-method.ts", `class A {
329
+ ${fileChange.newCode}
330
+ }`);
331
+ const methods = checkForMethodSrc.getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration);
332
+ const originalSource = project.createSourceFile("current-code.ts", contents);
333
+ // if there is a single function update in the file
334
+ if (functions.length === 1 &&
335
+ functions[0]?.getText() === fileChange.newCode) {
336
+ const updatedCodeFuncNames = functions.map((f) => f.getName());
337
+ const funcName = updatedCodeFuncNames[0];
338
+ const matchingNodes = originalSource
339
+ .getDescendantsOfKind(ts_morph_1.SyntaxKind.FunctionDeclaration)
340
+ .filter((node) => node.getName() === funcName);
341
+ matchingNodes[0]?.replaceWithText(functions[0]?.getText());
342
+ contents = originalSource.getFullText();
343
+ }
344
+ else if (
345
+ // if there is a update in method of a class in the file
346
+ methods.length === 1 &&
347
+ methods[0]?.getText() === fileChange.newCode) {
348
+ const method = methods[0];
349
+ const funcName = method?.getName();
350
+ const matchingNodes = originalSource
351
+ .getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration)
352
+ .filter((node) => node.getName() === funcName);
353
+ matchingNodes[0]?.replaceWithText(method?.getText());
354
+ contents = originalSource.getFullText();
355
+ }
356
+ else {
357
+ const { result, updatedContent } = await searchAndReplaceCode({
358
+ logger,
359
+ fileChange,
360
+ });
361
+ if (result.error) {
362
+ logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
363
+ results.push(result);
364
+ continue;
365
+ }
366
+ else {
367
+ contents = updatedContent;
368
+ }
369
+ }
370
+ await fs_extra_1.default.writeFile(fileChange.filePath, contents, "utf-8");
371
+ readWriteFileSpan?.end({ output: { contents } });
372
+ results.push({
373
+ filePath: fileChange.filePath,
374
+ error: false,
375
+ errorMessage: "",
376
+ });
377
+ }
378
+ }
379
+ catch (e) {
380
+ trace?.event({
381
+ name: "apply-file-changes-error",
382
+ output: {
383
+ filePath: fileChange.filePath,
384
+ error: e,
385
+ },
386
+ });
387
+ console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
388
+ }
389
+ }
390
+ return results;
391
+ }
392
+ exports.applyFileChanges = applyFileChanges;
package/dist/bin/index.js CHANGED
@@ -79,6 +79,7 @@ async function runAgent(testGenConfig) {
79
79
  trace,
80
80
  task: testGenConfig.testCase.steps.join("\n"),
81
81
  logger,
82
+ useStrReplace: testGenConfig.options?.useStrReplace,
82
83
  });
83
84
  return;
84
85
  }
@@ -301,7 +301,13 @@ function annotateElementsWithPreference({
301
301
  var parentElements = [];
302
302
 
303
303
  // Create a hint marker
304
- function createHintMarker(el, hint, parentElement, windowToAnnotate) {
304
+ function createHintMarker(
305
+ el,
306
+ hint,
307
+ parentElement,
308
+ windowToAnnotate,
309
+ baseColor,
310
+ ) {
305
311
  const rect = el.getBoundingClientRect();
306
312
 
307
313
  // Create the marker element
@@ -311,10 +317,10 @@ function annotateElementsWithPreference({
311
317
  // Style the marker
312
318
  Object.assign(marker.style, {
313
319
  position: "absolute",
314
- background: "rgb(255, 197, 66)",
320
+ background: baseColor,
315
321
  padding: "1px 3px 0px",
316
322
  borderRadius: "3px",
317
- border: "1px solid rgb(227, 190, 35)",
323
+ border: `1px solid ${baseColor}`,
318
324
  fontSize: "11px",
319
325
  pointerEvents: "none",
320
326
  zIndex: "10000",
@@ -324,10 +330,9 @@ function annotateElementsWithPreference({
324
330
  letterSpacing: 0,
325
331
  minHeight: 0,
326
332
  lineHeight: "100%",
327
- color: "rgb(48, 37, 5)",
333
+ color: "white",
328
334
  fontFamily: "Helvetica, Arial, sans-serif",
329
335
  fontWeight: "bold",
330
- textShadow: "rgba(255, 255, 255, 0.6) 0px 1px 0px",
331
336
  visibility: "hidden", // Setting the visibility to hidden initially, to get the height and width of marker
332
337
  });
333
338
 
@@ -475,9 +480,27 @@ function annotateElementsWithPreference({
475
480
  const hint = hints[index];
476
481
  const rect = el.getBoundingClientRect();
477
482
 
483
+ const colors = [
484
+ "#FF0000", // Red
485
+ "#006400", // Dark Green
486
+ "#0000FF", // Blue
487
+ "#FFA500", // Orange
488
+ "#800080", // Purple
489
+ "#008080", // Teal
490
+ "#FF69B4", // Hot Pink
491
+ "#4B0082", // Indigo
492
+ "#FF4500", // Orange Red
493
+ "#2E8B57", // Sea Green
494
+ "#DC143C", // Crimson
495
+ "#4682B4", // Steel Blue
496
+ ];
497
+ const colorIndex = index % colors.length;
498
+ const baseColor = colors[colorIndex];
499
+
478
500
  // Use createHintMarker with the specified container
479
- createHintMarker(el, hint, container, windowToAnnotate);
480
- el.style.boxShadow = `inset 0 0 0px 1px red`;
501
+ createHintMarker(el, hint, container, windowToAnnotate, baseColor);
502
+
503
+ el.style.boxShadow = `inset 0 0 0px 2px ${baseColor}`;
481
504
 
482
505
  // Add element details to the annotations map
483
506
  annotationsMap[hint] = {
@@ -17,6 +17,7 @@ export type TestGenConfigOptions = {
17
17
  modelProvider: LLMProvider;
18
18
  modelParameters?: ModelParameters;
19
19
  useActionSpecificAnnotations?: boolean;
20
+ useStrReplace?: boolean;
20
21
  metadata: {
21
22
  testSessionId: number;
22
23
  generationId: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IAC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