@empiricalrun/test-gen 0.60.0 → 0.61.0

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
@@ -1,5 +1,25 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.61.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fca6729: feat: implement TypeScript compiler execution and error handling in strReplaceEditor
8
+
9
+ ### Patch Changes
10
+
11
+ - f33bdbf: fix: git changed line should cover untracked also
12
+ - 1b4e3d0: fix: dont wait for fonts when agent needs screenshot
13
+ - bbf735a: chore: remove unused test.only cleaner
14
+ - b7a4821: fix: update pr tool prompt to encourage proactiveness
15
+ - 779dd6e: feat: add email automation recipe to system prompt
16
+ - 05f5184: fix: file create should create parent dir if required
17
+ - Updated dependencies [d71508f]
18
+ - Updated dependencies [79857b3]
19
+ - Updated dependencies [fca6729]
20
+ - @empiricalrun/test-run@0.9.2
21
+ - @empiricalrun/llm@0.16.1
22
+
3
23
  ## 0.60.0
4
24
 
5
25
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAcA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,OAAO,EACP,YAAY,GACb,EAAE;IACD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CA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,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAkFD"}
@@ -46,6 +46,9 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
46
46
  ],
47
47
  projects: [projectName],
48
48
  passthroughArgs: "--retries 0 --timeout 0",
49
+ envOverrides: {
50
+ PW_TEST_SCREENSHOT_NO_FONTS_READY: "1",
51
+ },
49
52
  //@ts-ignore
50
53
  platform: "web",
51
54
  });
@@ -79,8 +82,6 @@ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, tes
79
82
  console.error("Failed to remove extra scripts from files post test gen error", e);
80
83
  }
81
84
  }
82
- // remove the test only from the file
83
- await (0, web_1.removeTestOnly)(testFilePath);
84
85
  await fileServer.stop();
85
86
  return {
86
87
  isError: !!error,
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,mBAiGzD"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuDvC,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,mBAwGzD"}
@@ -2,6 +2,57 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildSystemPrompt = buildSystemPrompt;
4
4
  const repo_1 = require("./repo");
5
+ const emailRecipe = `
6
+ # Email automation
7
+
8
+ ## Example usage
9
+
10
+ ### Dynamic email
11
+
12
+ This dynamically generates a random email address that can
13
+ be used for the test (e.g. invite a new user).
14
+
15
+ \`\`\`ts
16
+ import { EmailClient } from "@empiricalrun/playwright-utils";
17
+ import { expect } from "@playwright/test";
18
+
19
+ const client = new EmailClient();
20
+ const address = client.getAddress();
21
+
22
+ // Input the \`address\` in the application
23
+ // that sends the email.
24
+
25
+ // Get email received on the \`address\`
26
+ const email = await client.waitForEmail();
27
+ expect(
28
+ email.links.find((l) => l.text === "Join your team")
29
+ ).toBeTruthy();
30
+ \`\`\`
31
+
32
+ ### Static email
33
+
34
+ This uses a known (static) email that can be used to login
35
+ into an application.
36
+
37
+ This needs an email id (e.g. \`test-login-user\`). The email id
38
+ is appended with the domain (managed internally) to get the full
39
+ email address.
40
+
41
+ \`\`\`ts
42
+ import { EmailClient } from "@empiricalrun/playwright-utils";
43
+
44
+ const emailId = \`test-login-user\`;
45
+
46
+ const client = new EmailClient({ emailId });
47
+ const address = client.getAddress(); // Returns full address with domain
48
+
49
+ // Get email received on the \`address\`
50
+ const email = await client.waitForEmail();
51
+
52
+ // Get login OTP
53
+ const loginCode = email.codes[0];
54
+ \`\`\`
55
+ `;
5
56
  async function buildSystemPrompt(fileInfo) {
6
57
  const repoContext = await (0, repo_1.getRepoInfoPrompt)(fileInfo);
7
58
  return `
@@ -96,6 +147,13 @@ if (await saveButton.isVisible()) {
96
147
  }
97
148
  \`\`\`
98
149
 
150
+ # Recipes
151
+ You can refer to the following recipes to learn how to write tests for different scenarios.
152
+
153
+ <email-automation>
154
+ ${emailRecipe}
155
+ </email-automation>
156
+
99
157
  # Repo context
100
158
  ${repoContext}
101
159
  `;
@@ -49,12 +49,15 @@ export declare function hasTopLevelDescribeConfigureWithSerialMode(filePath: str
49
49
  */
50
50
  export declare function findFirstSerialDescribeBlock(node: Node | undefined): Node | undefined;
51
51
  export declare function appendToTestBlock(testBlock: string, content: string): string;
52
+ export declare function runTypescriptCompiler(): Promise<{
53
+ success: boolean;
54
+ errors: string[];
55
+ }>;
52
56
  export declare function validateTypescript(filePath: string): string[];
53
57
  export declare function stripAndPrependImports(content: string, testName: string): Promise<(string | undefined)[]>;
54
58
  export declare function lintErrors(filePath: string): Promise<void>;
55
59
  export declare function formatCode(filePath: string, trace?: TraceClient): Promise<void>;
56
60
  export declare function addNewImport(contents: string, modules: string[], pkg: string): string;
57
- export declare function removeTestOnly(filePath: string): Promise<void>;
58
61
  export declare function getFixtureImportPath(filePath: string): string;
59
62
  export declare function getPageVariableNameFromCreateTest(filePath: string): Promise<string | undefined>;
60
63
  export declare function replaceCreateTestWithNewCode(filePath: string, contents: string, generatedCode: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAK3D,OAAO,EAGL,IAAI,EAEJ,UAAU,EAEX,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,gCAAgC,GAC3C,YAAY,UAAU,KACrB,MAgBF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAY,EACZ,MAAM,EACN,OAAO,GACR,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB,CA2CA;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,WAUA;AAwBD,wBAAsB,0CAA0C,CAC9D,QAAQ,EAAE,MAAM,oBA+BjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,IAAI,G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,EAAE,CAAC;CAClB,WA0DA,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,SAAS,MAAM,EACf,WAAW,MAAM,EAAE,EACnB,cAAc,MAAM,sBAyBrB,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,YAAY,EACZ,QAAQ,EACR,MAAM,GACP,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,iBAgDA;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EAAE,iBAsBzB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,WAYA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,UAOA;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CA4B5E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQnD"}
@@ -9,12 +9,12 @@ exports.hasTestBlock = hasTestBlock;
9
9
  exports.hasTopLevelDescribeConfigureWithSerialMode = hasTopLevelDescribeConfigureWithSerialMode;
10
10
  exports.findFirstSerialDescribeBlock = findFirstSerialDescribeBlock;
11
11
  exports.appendToTestBlock = appendToTestBlock;
12
+ exports.runTypescriptCompiler = runTypescriptCompiler;
12
13
  exports.validateTypescript = validateTypescript;
13
14
  exports.stripAndPrependImports = stripAndPrependImports;
14
15
  exports.lintErrors = lintErrors;
15
16
  exports.formatCode = formatCode;
16
17
  exports.addNewImport = addNewImport;
17
- exports.removeTestOnly = removeTestOnly;
18
18
  exports.getFixtureImportPath = getFixtureImportPath;
19
19
  exports.getPageVariableNameFromCreateTest = getPageVariableNameFromCreateTest;
20
20
  exports.replaceCreateTestWithNewCode = replaceCreateTestWithNewCode;
@@ -25,6 +25,7 @@ exports.buildTestNamePrompt = buildTestNamePrompt;
25
25
  exports.getVariableDeclarationsFromCode = getVariableDeclarationsFromCode;
26
26
  exports.isSyntaxValid = isSyntaxValid;
27
27
  const parser_1 = require("@babel/parser");
28
+ const test_run_1 = require("@empiricalrun/test-run");
28
29
  const eslint_1 = require("eslint");
29
30
  const fs_1 = __importDefault(require("fs"));
30
31
  const path_1 = __importDefault(require("path"));
@@ -32,6 +33,7 @@ const prettier_1 = __importDefault(require("prettier"));
32
33
  const ts_morph_1 = require("ts-morph");
33
34
  const typescript_1 = __importDefault(require("typescript"));
34
35
  const util_1 = require("util");
36
+ const stripAnsi_1 = require("../../../../utils/stripAnsi");
35
37
  const getTestModuleAliasFromSourceFile = (sourceFile) => {
36
38
  return (sourceFile
37
39
  .getImportDeclarations()
@@ -200,6 +202,26 @@ function appendToTestBlock(testBlock, content) {
200
202
  const updateTestBlock = testBlock.replace(/\}\)$/, `\n\n${content}\n\n })`);
201
203
  return updateTestBlock;
202
204
  }
205
+ async function runTypescriptCompiler() {
206
+ let { code, output } = await (0, test_run_1.spawnCmd)("npx", ["tsc", "--noEmit", "--pretty"], {
207
+ env: {},
208
+ captureOutput: true,
209
+ throwOnError: false,
210
+ });
211
+ if (code === 0) {
212
+ return {
213
+ success: true,
214
+ errors: [],
215
+ };
216
+ }
217
+ if (!output) {
218
+ throw new Error("No output from typescript compiler");
219
+ }
220
+ return {
221
+ success: false,
222
+ errors: (0, stripAnsi_1.stripAnsiEscapes)(output).split("\n"),
223
+ };
224
+ }
203
225
  function validateTypescript(filePath) {
204
226
  // Create a compiler host to read files
205
227
  const compilerHost = typescript_1.default.createCompilerHost({});
@@ -281,13 +303,6 @@ async function formatCode(filePath, trace) {
281
303
  function addNewImport(contents, modules, pkg) {
282
304
  return `import { ${modules.join(", ")} } from "${pkg}";\n${contents}`;
283
305
  }
284
- async function removeTestOnly(filePath) {
285
- const contents = fs_1.default.readFileSync(filePath, "utf8");
286
- const updatedContent = contents
287
- .replace("test.only(", "test(")
288
- .replace("test.describe.only(", "test.describe(");
289
- fs_1.default.writeFileSync(filePath, updatedContent);
290
- }
291
306
  function getFixtureImportPath(filePath) {
292
307
  // get the depth from the tests folder
293
308
  // assumption fixtures are always int the folder tests/fixtures
@@ -1 +1 @@
1
- {"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAOnD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AA2CD,eAAO,MAAM,qBAAqB,EAAE,IAuEnC,CAAC"}
1
+ {"version":3,"file":"commit-and-create-pr.d.ts","sourceRoot":"","sources":["../../src/tools/commit-and-create-pr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAOnD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AA2CD,eAAO,MAAM,qBAAqB,EAAE,IA2EnC,CAAC"}
@@ -48,7 +48,11 @@ exports.createPullRequestTool = {
48
48
  description: `Creates a new Pull Request on GitHub.
49
49
  If the current branch already has an open PR, commits and pushes changes to that PR.
50
50
  Uses the empiricalrun[bot] credentials for git operations.
51
- Returns the URL of the created or updated pull request.`,
51
+ Returns the URL of the created or updated pull request.
52
+
53
+ You must come up with a title and description for the pull request, based on the changes made.
54
+ Don't ask the user for this information, just come up with it yourself.
55
+ `,
52
56
  parameters: createPullRequestSchema,
53
57
  },
54
58
  execute: async (input) => {
@@ -1 +1 @@
1
- {"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B1D,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwC1D;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,UAAU,CAAC,CA6LrB;AAiGD,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
1
+ {"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B1D,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAwC1D;AAMD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,UAAU,CAAC,CAuMrB;AAiGD,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
@@ -145,7 +145,6 @@ async function strReplaceEditorExecutor(input) {
145
145
  let content;
146
146
  let lines;
147
147
  let newContent;
148
- let typeCheckErrors;
149
148
  switch (input.command) {
150
149
  case "view":
151
150
  if (!fs_1.default.existsSync(filePath)) {
@@ -195,8 +194,19 @@ async function strReplaceEditorExecutor(input) {
195
194
  if (input.file_text === undefined || input.file_text === null) {
196
195
  throw new Error("file_text is required for create command");
197
196
  }
197
+ const parentDir = path_1.default.dirname(filePath);
198
+ if (parentDir !== "." && !fs_1.default.existsSync(parentDir)) {
199
+ // Ensure parent directory exists
200
+ fs_1.default.mkdirSync(parentDir, { recursive: true });
201
+ }
198
202
  fs_1.default.writeFileSync(filePath, input.file_text);
199
- // TODO: Add type checking
203
+ let createTypescriptResult = await (0, web_1.runTypescriptCompiler)();
204
+ if (!createTypescriptResult.success) {
205
+ return {
206
+ result: `File ${filePath} has been created. However, type checks are failing with errors:\n${createTypescriptResult.errors.join("\n")}`,
207
+ isError: true,
208
+ };
209
+ }
200
210
  return {
201
211
  result: `Successfully created file ${filePath}`,
202
212
  isError: false,
@@ -243,10 +253,10 @@ async function strReplaceEditorExecutor(input) {
243
253
  }
244
254
  newContent = normalizedContent.replace(normalizedOldStr, input.new_str);
245
255
  fs_1.default.writeFileSync(filePath, newContent);
246
- typeCheckErrors = (0, web_1.validateTypescript)(filePath);
247
- if (typeCheckErrors.length > 0) {
256
+ let strReplaceTypescriptResult = await (0, web_1.runTypescriptCompiler)();
257
+ if (!strReplaceTypescriptResult.success) {
248
258
  return {
249
- result: `Edits to file ${filePath} have been applied. However, type checks are failing with errors:\n${typeCheckErrors.join("\n")}`,
259
+ result: `Edits to file ${filePath} have been applied. However, type checks are failing with errors:\n${strReplaceTypescriptResult.errors.join("\n")}`,
250
260
  isError: true,
251
261
  };
252
262
  }
@@ -272,10 +282,10 @@ async function strReplaceEditorExecutor(input) {
272
282
  }
273
283
  lines.splice(input.insert_line - 1, 0, input.new_str);
274
284
  fs_1.default.writeFileSync(filePath, lines.join("\n"));
275
- typeCheckErrors = (0, web_1.validateTypescript)(filePath);
276
- if (typeCheckErrors.length > 0) {
285
+ let insertTypescriptResult = await (0, web_1.runTypescriptCompiler)();
286
+ if (!insertTypescriptResult.success) {
277
287
  return {
278
- result: `Insertion in file ${filePath} was applied. However, type checks are failing with errors:\n${typeCheckErrors.join("\n")}`,
288
+ result: `Insertion in file ${filePath} was applied. However, type checks are failing with errors:\n${insertTypescriptResult.errors.join("\n")}`,
279
289
  isError: true,
280
290
  };
281
291
  }
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,iBAQtD;AAED,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,iBAS1D;AAED,wBAAsB,oBAAoB,oBAGzC;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,iBAElD;AAED,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,iBAKhB;AAED,wBAAsB,eAAe,sBAQpC"}
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,iBAQtD;AAED,wBAAsB,eAAe,CAAC,aAAa,EAAE,MAAM,iBAS1D;AAED,wBAAsB,oBAAoB,oBAGzC;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,iBAElD;AAED,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,iBAKhB;AAED,wBAAsB,eAAe,sBAUpC"}
package/dist/utils/git.js CHANGED
@@ -47,7 +47,7 @@ async function commitFilesAndPushBranch(commitMessage, branchName, files) {
47
47
  (0, child_process_1.execSync)(`git push origin ${branchName}`);
48
48
  }
49
49
  async function getFilesChanged() {
50
- const output = (0, child_process_1.execSync)("git status --porcelain").toString();
50
+ const output = (0, child_process_1.execSync)("git status --porcelain --untracked-files").toString();
51
51
  let filesChanged = output
52
52
  .split("\n")
53
53
  .map((line) => line.trim().split(" ").pop())
@@ -0,0 +1,2 @@
1
+ export declare function stripAnsiEscapes(str: string): string;
2
+ //# sourceMappingURL=stripAnsi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripAnsi.d.ts","sourceRoot":"","sources":["../../src/utils/stripAnsi.ts"],"names":[],"mappings":"AAMA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripAnsiEscapes = stripAnsiEscapes;
4
+ const ansiRegex = new RegExp(
5
+ // eslint-disable-next-line no-control-regex
6
+ "([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))", "g");
7
+ function stripAnsiEscapes(str) {
8
+ return str.replace(ansiRegex, "");
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -61,9 +61,9 @@
61
61
  "tsx": "^4.16.2",
62
62
  "typescript": "^5.3.3",
63
63
  "zod": "^3.23.8",
64
- "@empiricalrun/llm": "^0.16.0",
64
+ "@empiricalrun/llm": "^0.16.1",
65
65
  "@empiricalrun/r2-uploader": "^0.3.9",
66
- "@empiricalrun/test-run": "^0.9.1"
66
+ "@empiricalrun/test-run": "^0.9.2"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@playwright/test": "1.47.1",
@@ -1 +1 @@
1
- {"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/codegen-agent.ts","./src/tools/commit-and-create-pr.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/download-build.ts","./src/tools/environment-crud.ts","./src/tools/str_replace_editor.ts","./src/tools/test-gen-browser.ts","./src/tools/test-run.ts","./src/tools/grep/index.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/grep/ripgrep/types.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/uploader/index.ts","./src/uploader/utils.ts","./src/utils/checkpoint.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file-tree.ts","./src/utils/file.ts","./src/utils/git.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/pw-test.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts"],"version":"5.8.3"}
1
+ {"root":["./src/index.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/skill.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/prompt.ts","./src/agent/chat/repo.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/codegen/create-test-block.ts","./src/agent/codegen/fix-ts-errors.ts","./src/agent/codegen/generate-code-apply-changes.ts","./src/agent/codegen/lexical-scoped-vars.ts","./src/agent/codegen/repo-edit.ts","./src/agent/codegen/run.ts","./src/agent/codegen/skills-retriever.ts","./src/agent/codegen/test-update-feedback.ts","./src/agent/codegen/types.ts","./src/agent/codegen/update-flow.ts","./src/agent/codegen/use-skill.ts","./src/agent/codegen/utils.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/diagnosis-agent/index.ts","./src/agent/diagnosis-agent/strict-mode-violation.ts","./src/agent/enrich-prompt/index.ts","./src/agent/enrich-prompt/utils.ts","./src/agent/infer-agent/index.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/execute-skill-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/browser-tests/skills.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/bin/index.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/errors/index.ts","./src/evals/add-scenario-agent.evals.ts","./src/evals/append-create-test-agent.evals.ts","./src/evals/fetch-pom-skills-agent.evals.ts","./src/evals/infer-master-or-code-agent.evals.ts","./src/evals/master-agent.evals.ts","./src/evals/type.ts","./src/evals/update-scenario-agent.evals.ts","./src/file/client.ts","./src/file/server.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/reporter/index.ts","./src/reporter/lib.ts","./src/session/index.ts","./src/test-build/index.ts","./src/tool-call-service/index.ts","./src/tool-call-service/utils.ts","./src/tools/codegen-agent.ts","./src/tools/commit-and-create-pr.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/download-build.ts","./src/tools/environment-crud.ts","./src/tools/str_replace_editor.ts","./src/tools/test-gen-browser.ts","./src/tools/test-run.ts","./src/tools/grep/index.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/grep/ripgrep/types.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/uploader/index.ts","./src/uploader/utils.ts","./src/utils/checkpoint.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file-tree.ts","./src/utils/file.ts","./src/utils/git.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/pw-test.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts"],"version":"5.8.3"}