@empiricalrun/test-gen 0.56.3 → 0.56.4

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,12 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.56.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 0d53865: fix: browser agent tool call has different exit code on linux
8
+ - 8e5dcd2: feat: move to ripgrep for platform independent grep tool calls
9
+
3
10
  ## 0.56.3
4
11
 
5
12
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAiBhE,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBAsFA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA2CA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAiBhE,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBAsFA;AA0BD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA2CA"}
@@ -112,6 +112,9 @@ async function getChatSessionFromDashboard(chatSessionId) {
112
112
  Authorization: `Bearer ${process.env.EMPIRICALRUN_API_KEY}`,
113
113
  },
114
114
  });
115
+ if (!response.ok) {
116
+ throw new Error(`Failed to get chat session: ${response.statusText}`);
117
+ }
115
118
  const data = await response.json();
116
119
  return data.data.chat_session;
117
120
  }
@@ -1,3 +1,3 @@
1
1
  import type { Tool } from "@empiricalrun/llm/chat";
2
2
  export declare const grepTool: Tool;
3
- //# sourceMappingURL=grep.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,wBAAwB,CAAC;AAoH/D,eAAO,MAAM,QAAQ,EAAE,IAkBtB,CAAC"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.grepTool = void 0;
7
+ const child_process_1 = require("child_process");
8
+ const path_1 = __importDefault(require("path"));
9
+ const util_1 = require("util");
10
+ const zod_1 = require("zod");
11
+ const repo_tree_1 = require("../../utils/repo-tree");
12
+ const ripgrep_1 = require("./ripgrep");
13
+ const GrepInputSchema = zod_1.z.object({
14
+ pattern: zod_1.z.string().describe("The pattern to search for"),
15
+ directory: zod_1.z
16
+ .string()
17
+ .optional()
18
+ .describe("The directory to search in (defaults to current directory)"),
19
+ filePattern: zod_1.z
20
+ .string()
21
+ .optional()
22
+ .describe("File pattern to search in (e.g., '*.ts' for TypeScript files)"),
23
+ });
24
+ async function usingSystemGrep(input) {
25
+ try {
26
+ const dir = input.directory || process.cwd();
27
+ // Create exclude pattern for grep
28
+ const excludePatterns = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
29
+ .map((pattern) => `--exclude-dir="${pattern}"`)
30
+ .join(" ");
31
+ // Using -n to show line numbers in output
32
+ let cmd = `grep -rin ${excludePatterns} "${input.pattern}" ${dir}`;
33
+ if (input.filePattern) {
34
+ // For file pattern searches, we'll use find with exclusions
35
+ const excludeFind = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
36
+ .map((pattern) => `-not -path "*/${pattern}/*"`)
37
+ .join(" ");
38
+ // Modified command to ensure filepath is included in the output
39
+ // Using grep with -H to always show filename and the filepath as part of the output
40
+ cmd = `find ${dir} ${excludeFind} -name "${input.filePattern}" | xargs grep -Hn "${input.pattern}"`;
41
+ }
42
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
43
+ const { stdout, stderr } = await execAsync(cmd);
44
+ if (stdout) {
45
+ return {
46
+ isError: false,
47
+ result: stdout,
48
+ };
49
+ }
50
+ else if (!stdout && stderr) {
51
+ return {
52
+ isError: true,
53
+ result: stderr,
54
+ };
55
+ }
56
+ else {
57
+ // Both are empty, which means no results were found
58
+ return {
59
+ isError: false,
60
+ result: "No results found.",
61
+ };
62
+ }
63
+ }
64
+ catch (error) {
65
+ console.error("Error executing grep", error);
66
+ return {
67
+ isError: true,
68
+ result: error instanceof Error ? error.message : String(error),
69
+ };
70
+ }
71
+ }
72
+ async function usingRipgrep(input) {
73
+ try {
74
+ const dir = path_1.default.join(process.cwd(), input.directory || "");
75
+ const results = await (0, ripgrep_1.ripgrep)(dir, {
76
+ string: input.pattern,
77
+ globs: input.filePattern ? [input.filePattern] : undefined,
78
+ });
79
+ const resultsSummary = results
80
+ .map((result) => {
81
+ // Can add submatches and offset info to the summary if needed
82
+ return {
83
+ lines: result.lines.text,
84
+ path: path_1.default.relative(process.cwd(), result.path.text),
85
+ // line number is 1-indexed
86
+ line_number: result.line_number,
87
+ };
88
+ })
89
+ .map((result) => {
90
+ return `
91
+ ${result.path}:${result.line_number}
92
+ \`\`\`
93
+ ${result.lines}\`\`\`
94
+ `;
95
+ });
96
+ const relDir = path_1.default.relative(process.cwd(), dir);
97
+ const header = `Found ${resultsSummary.length} results for "${input.pattern}" in "${relDir}".
98
+ All paths are relative to the current working directory.`;
99
+ return {
100
+ isError: false,
101
+ result: `${header}\n${resultsSummary.join("\n")}`,
102
+ };
103
+ }
104
+ catch (error) {
105
+ console.error("Error executing ripgrep", error);
106
+ return {
107
+ isError: true,
108
+ result: error instanceof Error ? error.message : String(error),
109
+ };
110
+ }
111
+ }
112
+ exports.grepTool = {
113
+ schema: {
114
+ name: "grep",
115
+ description: "Search for a pattern in files using grep (case insensitive)",
116
+ parameters: GrepInputSchema,
117
+ },
118
+ execute: async (input) => {
119
+ const isAvailable = await (0, ripgrep_1.isRgAvailable)();
120
+ if (isAvailable) {
121
+ return usingRipgrep(input);
122
+ }
123
+ else {
124
+ console.warn("ripgrep is not available, falling back to system grep.");
125
+ return usingSystemGrep(input);
126
+ }
127
+ },
128
+ };
@@ -0,0 +1,5 @@
1
+ import { Match, Options } from "./types";
2
+ export * from "./types";
3
+ export declare function isRgAvailable(): Promise<unknown>;
4
+ export declare function ripgrep(cwd: string, options: Options): Promise<Array<Match>>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/grep/ripgrep/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAEvD,cAAc,SAAS,CAAC;AAcxB,wBAAgB,aAAa,qBAY5B;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CA8C5E"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ripgrep = exports.isRgAvailable = void 0;
18
+ const child_process_1 = require("child_process");
19
+ const types_1 = require("./types");
20
+ __exportStar(require("./types"), exports);
21
+ function formatResults(stdout) {
22
+ stdout = stdout.trim();
23
+ if (!stdout) {
24
+ return [];
25
+ }
26
+ return stdout
27
+ .split("\n")
28
+ .map((line) => JSON.parse(line))
29
+ .filter((jsonLine) => jsonLine.type === "match")
30
+ .map((jsonLine) => jsonLine.data);
31
+ }
32
+ function isRgAvailable() {
33
+ return new Promise((resolve) => {
34
+ // Use 'where' on Windows and 'which' on Unix-like systems
35
+ const command = process.platform === "win32" ? "where rg" : "which rg";
36
+ (0, child_process_1.exec)(command, (error) => {
37
+ if (error) {
38
+ resolve(false);
39
+ }
40
+ else {
41
+ resolve(true);
42
+ }
43
+ });
44
+ });
45
+ }
46
+ exports.isRgAvailable = isRgAvailable;
47
+ function ripgrep(cwd, options) {
48
+ if (!cwd) {
49
+ return Promise.reject(new Error("No `cwd` provided"));
50
+ }
51
+ if (arguments.length === 1) {
52
+ return Promise.reject(new Error("No search term provided"));
53
+ }
54
+ let execString = "rg --json";
55
+ if ("regex" in options) {
56
+ execString = `${execString} -e ${options.regex}`;
57
+ }
58
+ else if ("string" in options) {
59
+ execString = `${execString} -F ${options.string}`;
60
+ }
61
+ if (options.fileType) {
62
+ if (!Array.isArray(options.fileType)) {
63
+ options.fileType = [options.fileType];
64
+ }
65
+ for (const fileType of options.fileType) {
66
+ execString = `${execString} -t ${fileType}`;
67
+ }
68
+ }
69
+ if (options.globs) {
70
+ execString = options.globs.reduce((command, glob) => {
71
+ return `${command} -g '${glob}'`;
72
+ }, execString);
73
+ }
74
+ if (options.multiline) {
75
+ execString = `${execString} --multiline`;
76
+ }
77
+ // https://github.com/alexlafroscia/ripgrep-js/pull/175/files
78
+ execString += ` -- ${cwd}`;
79
+ return new Promise(function (resolve, reject) {
80
+ (0, child_process_1.exec)(execString, { cwd }, (error, stdout, stderr) => {
81
+ if (!error || (error && stderr === "")) {
82
+ resolve(formatResults(stdout));
83
+ }
84
+ else {
85
+ reject(new types_1.RipGrepError(error, stderr));
86
+ }
87
+ });
88
+ });
89
+ }
90
+ exports.ripgrep = ripgrep;
@@ -0,0 +1,45 @@
1
+ /// <reference types=".pnpm/@types+node@20.14.11/node_modules/@types/node/child_process" />
2
+ /// <reference types=".pnpm/@types+node@20.16.10/node_modules/@types/node/child_process" />
3
+ import { ExecException } from "child_process";
4
+ type StringSearchOptions = {
5
+ string: string;
6
+ };
7
+ type RegexSearchOptions = {
8
+ regex: string;
9
+ };
10
+ type LocatorOptions = StringSearchOptions | RegexSearchOptions;
11
+ export type Options = LocatorOptions & {
12
+ globs?: Array<string>;
13
+ fileType?: string | Array<string>;
14
+ multiline?: boolean;
15
+ };
16
+ export type RipgrepJsonSubmatch = {
17
+ match: {
18
+ text: string;
19
+ };
20
+ start: number;
21
+ end: number;
22
+ };
23
+ export type RipGrepJsonMatch = {
24
+ type: "match";
25
+ data: {
26
+ path: {
27
+ text: string;
28
+ };
29
+ lines: {
30
+ text: string;
31
+ };
32
+ line_number: number;
33
+ absolute_offset: number;
34
+ submatches: Array<RipgrepJsonSubmatch>;
35
+ };
36
+ };
37
+ export type Match = RipGrepJsonMatch["data"];
38
+ export declare class RipGrepError {
39
+ private error;
40
+ stderr: string;
41
+ constructor(error: ExecException, stderr: string);
42
+ get message(): string;
43
+ }
44
+ export {};
45
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/tools/grep/ripgrep/types.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,cAAc,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAE/D,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,KAAK,EAAE;YACL,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE7C,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgB;IAE7B,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;IAKhD,IAAI,OAAO,IAAI,MAAM,CAEpB;CACF"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RipGrepError = void 0;
4
+ class RipGrepError {
5
+ error;
6
+ stderr;
7
+ constructor(error, stderr) {
8
+ this.error = error;
9
+ this.stderr = stderr;
10
+ }
11
+ get message() {
12
+ return this.error.message;
13
+ }
14
+ }
15
+ exports.RipGrepError = RipGrepError;
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAQA,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAA6B;IAE3C,OAAO,CACX,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GACxC,OAAO,CAAC,MAAM,CAAC;IAkDlB,SAAS,IAAI,IAAI;IASjB,SAAS,IAAI,OAAO;CAGrB;AAED,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAGjB"}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAmBA,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAA6B;IAE3C,OAAO,CACX,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GACxC,OAAO,CAAC,MAAM,CAAC;IAkDlB,SAAS,IAAI,IAAI;IASjB,SAAS,IAAI,OAAO;CAGrB;AAED,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACxC,OAAO,CAAC,MAAM,CAAC,CAGjB"}
@@ -6,10 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.cmd = exports.ProcessManager = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const process_1 = __importDefault(require("process"));
9
- const acceptableExitCodes = [
10
- 0, // Implies successful execution (no errors)
11
- 130, // Implies user interrupted the process (for SIGINT)
12
- ];
9
+ function isAcceptableExit(exitCode, signal) {
10
+ // On Linux, code is null and signal is SIGINT
11
+ if (signal === "SIGINT") {
12
+ return true;
13
+ }
14
+ // On macOS, signal is null and exit code is 130
15
+ const acceptableExitCodes = [
16
+ 0, // Implies successful execution (no errors)
17
+ 130, // Implies user interrupted the process (for SIGINT)
18
+ ];
19
+ return acceptableExitCodes.includes(exitCode ?? 1);
20
+ }
13
21
  class ProcessManager {
14
22
  childProcess = null;
15
23
  async execute(command, options) {
@@ -43,14 +51,14 @@ class ProcessManager {
43
51
  this.childProcess = null;
44
52
  rejectFunc(err);
45
53
  });
46
- p.on("exit", async (code) => {
54
+ p.on("exit", async (code, signal) => {
47
55
  this.childProcess = null;
48
- if (!acceptableExitCodes.includes(code ?? 1)) {
56
+ if (!isAcceptableExit(code, signal)) {
49
57
  const errorMessage = errorLogs.slice(-3).join("\n");
50
58
  rejectFunc(new Error(errorMessage));
51
59
  }
52
60
  else {
53
- resolveFunc(code ?? 1);
61
+ resolveFunc(0);
54
62
  }
55
63
  });
56
64
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.56.3",
3
+ "version": "0.56.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -1 +0,0 @@
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"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.grepTool = void 0;
4
- const child_process_1 = require("child_process");
5
- const util_1 = require("util");
6
- const zod_1 = require("zod");
7
- const repo_tree_1 = require("../utils/repo-tree");
8
- const GrepInputSchema = zod_1.z.object({
9
- pattern: zod_1.z.string().describe("The pattern to search for"),
10
- directory: zod_1.z
11
- .string()
12
- .optional()
13
- .describe("The directory to search in (defaults to current directory)"),
14
- filePattern: zod_1.z
15
- .string()
16
- .optional()
17
- .describe("File pattern to search in (e.g., '*.ts' for TypeScript files)"),
18
- });
19
- exports.grepTool = {
20
- schema: {
21
- name: "grep",
22
- description: "Search for a pattern in files using grep (case insensitive)",
23
- parameters: GrepInputSchema,
24
- },
25
- execute: async (input) => {
26
- try {
27
- const dir = input.directory || process.cwd();
28
- // Create exclude pattern for grep
29
- const excludePatterns = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
30
- .map((pattern) => `--exclude-dir="${pattern}"`)
31
- .join(" ");
32
- // Using -n to show line numbers in output
33
- let cmd = `grep -rin ${excludePatterns} "${input.pattern}" ${dir}`;
34
- if (input.filePattern) {
35
- // For file pattern searches, we'll use find with exclusions
36
- const excludeFind = repo_tree_1.DEFAULT_EXCLUDE.map((pattern) => typeof pattern === "string" ? pattern : pattern.source)
37
- .map((pattern) => `-not -path "*/${pattern}/*"`)
38
- .join(" ");
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}"`;
42
- }
43
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
44
- const { stdout, stderr } = await execAsync(cmd);
45
- if (stdout) {
46
- return {
47
- isError: false,
48
- result: stdout,
49
- };
50
- }
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
- }
64
- }
65
- catch (error) {
66
- console.error("Error executing grep", error);
67
- return {
68
- isError: true,
69
- result: error instanceof Error ? error.message : String(error),
70
- };
71
- }
72
- },
73
- };