@empiricalrun/test-gen 0.56.2 → 0.56.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
@@ -1,5 +1,16 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.56.3
4
+
5
+ ### Patch Changes
6
+
7
+ - bf87a3a: fix: grep tool should not return error if no results are found
8
+ - 607ec6d: fix: normalize old_str for newlines before running text editor tools
9
+ - a7f2e24: fix: downgrade tsx logs to warn instead of errors
10
+ - 1728128: feat: nesting of toolCall span under llm generation
11
+ - Updated dependencies [a7f2e24]
12
+ - @empiricalrun/test-run@0.8.4
13
+
3
14
  ## 0.56.2
4
15
 
5
16
  ### Patch Changes
@@ -307,11 +307,11 @@ async function readPlaywrightConfig(repoDir) {
307
307
  tsxImport = module;
308
308
  })
309
309
  .catch((err) => {
310
- console.error("Failed to import tsx: --->", err.message);
310
+ console.warn("Failed to import tsx: --->", err.message);
311
311
  });
312
312
  }
313
313
  if (!tsxImport) {
314
- console.error("tsx module not available");
314
+ console.warn("tsx module not available");
315
315
  return {};
316
316
  }
317
317
  const [lastDir] = repoDir.split("/").reverse();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAa1D,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD,CAAC;AA4BF,qBAAa,eAAe;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,aAAa,CAAM;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;gBAGjC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE,mBAAmB;IAgB9B,QAAQ;;;IAaR,OAAO,CACX,SAAS,EAAE,eAAe,EAAE,EAC5B,QAAQ,EAAE,OAAO,EACjB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,EAAE,CAAC;CAgDzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-call-service/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAa1D,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACpD,CAAC;AA4BF,qBAAa,eAAe;IAC1B,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,aAAa,CAAM;IAClC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;gBAGjC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE,mBAAmB;IAgB9B,QAAQ;;;IAaR,OAAO,CACX,SAAS,EAAE,eAAe,EAAE,EAC5B,QAAQ,EAAE,OAAO,EACjB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,EAAE,CAAC;CAuDzB"}
@@ -75,9 +75,13 @@ class ToolCallService {
75
75
  }));
76
76
  }
77
77
  else {
78
+ const executeSpan = trace?.span({
79
+ name: "execute_tools",
80
+ input: { toolCalls: toolCalls.map((tc) => ({ name: tc.name })) },
81
+ });
78
82
  const toolResults = [];
79
83
  for (const toolCall of toolCalls) {
80
- const span = trace?.span({
84
+ const span = executeSpan?.span({
81
85
  name: `tool: ${toolCall.name}`,
82
86
  input: toolCall.input,
83
87
  });
@@ -105,6 +109,7 @@ class ToolCallService {
105
109
  span?.end({ output: errorResult });
106
110
  }
107
111
  }
112
+ executeSpan?.end({ output: { toolResults } });
108
113
  return toolResults;
109
114
  }
110
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AAmB/D,eAAO,MAAM,QAAQ,EAAE,IAiDtB,CAAC"}
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AAmB/D,eAAO,MAAM,QAAQ,EAAE,IA0DtB,CAAC"}
@@ -36,8 +36,9 @@ exports.grepTool = {
36
36
  const excludeFind = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
37
37
  .map((pattern) => `-not -path "*/${pattern}/*"`)
38
38
  .join(" ");
39
- // Using -n to show line numbers and removed -l to show actual matches
40
- cmd = `find ${dir} ${excludeFind} -name "${input.filePattern}" -exec grep -rin "${input.pattern}" {} \\;`;
39
+ // Modified command to ensure filepath is included in the output
40
+ // Using grep with -H to always show filename and the filepath as part of the output
41
+ cmd = `find ${dir} ${excludeFind} -name "${input.filePattern}" | xargs grep -Hn "${input.pattern}"`;
41
42
  }
42
43
  const execAsync = (0, util_1.promisify)(child_process_1.exec);
43
44
  const { stdout, stderr } = await execAsync(cmd);
@@ -47,10 +48,19 @@ exports.grepTool = {
47
48
  result: stdout,
48
49
  };
49
50
  }
50
- return {
51
- isError: true,
52
- result: stderr,
53
- };
51
+ else if (!stdout && stderr) {
52
+ return {
53
+ isError: true,
54
+ result: stderr,
55
+ };
56
+ }
57
+ else {
58
+ // Both are empty, which means no results were found
59
+ return {
60
+ isError: false,
61
+ result: "No results found.",
62
+ };
63
+ }
54
64
  }
55
65
  catch (error) {
56
66
  console.error("Error executing grep", error);
@@ -1 +1 @@
1
- {"version":3,"file":"str_replace_editor.d.ts","sourceRoot":"","sources":["../../src/tools/str_replace_editor.ts"],"names":[],"mappings":"AAAA,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;AAED;;;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,CAmJrB;AA+FD,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;AAED;;;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,CA6JrB;AA+FD,eAAO,MAAM,eAAe,EAAE,IAAI,EAKjC,CAAC"}
@@ -141,15 +141,20 @@ async function strReplaceEditorExecutor(input) {
141
141
  }
142
142
  createBackup(filePath);
143
143
  content = fs_1.default.readFileSync(filePath, "utf8");
144
- if (!content.includes(input.old_str)) {
144
+ // Normalize newlines in both the content and search string
145
+ const normalizedContent = content.replace(/\r\n/g, "\n");
146
+ const normalizedOldStr = input.old_str
147
+ .replace(/\\n/g, "\n")
148
+ .replace(/\r\n/g, "\n");
149
+ if (!normalizedContent.includes(normalizedOldStr)) {
145
150
  return {
146
151
  result: `old_str not found in file: ${filePath}`,
147
152
  isError: true,
148
153
  };
149
154
  }
150
155
  else {
151
- const escapedOldStr = escapeRegExp(input.old_str);
152
- const occurences = content.match(new RegExp(escapedOldStr, "g"));
156
+ const escapedOldStr = escapeRegExp(normalizedOldStr);
157
+ const occurences = normalizedContent.match(new RegExp(escapedOldStr, "g"));
153
158
  if (occurences && occurences.length > 1) {
154
159
  // TODO: Help find unique matches
155
160
  return {
@@ -157,7 +162,7 @@ async function strReplaceEditorExecutor(input) {
157
162
  isError: true,
158
163
  };
159
164
  }
160
- newContent = content.replace(input.old_str, input.new_str);
165
+ newContent = normalizedContent.replace(normalizedOldStr, input.new_str);
161
166
  fs_1.default.writeFileSync(filePath, newContent);
162
167
  typeCheckErrors = (0, web_1.validateTypescript)(filePath);
163
168
  if (typeCheckErrors.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.56.2",
3
+ "version": "0.56.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -62,7 +62,7 @@
62
62
  "zod": "^3.23.8",
63
63
  "@empiricalrun/llm": "^0.15.2",
64
64
  "@empiricalrun/r2-uploader": "^0.3.8",
65
- "@empiricalrun/test-run": "^0.8.3"
65
+ "@empiricalrun/test-run": "^0.8.4"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@playwright/test": "1.47.1",