From 76ff51cbd99a9b3c23ff3123972cfd8b2dc9675b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 14:02:01 +0000 Subject: [PATCH] fix: complete restructuring to match read-files pattern - Fix import path for runTypescript from @buster/sandbox - Align type signatures between Zod schema and helper functions - Ensure consistent boolean property handling - Complete restructuring following read-files-tool pattern - All TypeScript errors resolved Co-Authored-By: Dallin Bentley --- .../grep-search-tool/grep-search.ts | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/packages/ai/src/tools/file-tools/grep-search-tool/grep-search.ts b/packages/ai/src/tools/file-tools/grep-search-tool/grep-search.ts index 7219d78eb..0ba447857 100644 --- a/packages/ai/src/tools/file-tools/grep-search-tool/grep-search.ts +++ b/packages/ai/src/tools/file-tools/grep-search-tool/grep-search.ts @@ -1,6 +1,5 @@ import { execSync } from 'node:child_process'; import { existsSync } from 'node:fs'; -import type { GrepSearchConfig } from './grep-search-tool'; export interface GrepSearchResult { success: boolean; @@ -11,7 +10,17 @@ export interface GrepSearchResult { error?: string; } -function executeGrepSearchLocally(search: any): GrepSearchResult { +function executeGrepSearchLocally(search: { + path: string; + pattern: string; + recursive: boolean; + ignoreCase: boolean; + invertMatch: boolean; + lineNumbers: boolean; + wordMatch: boolean; + fixedStrings: boolean; + maxCount?: number; +}): GrepSearchResult { try { if (!existsSync(search.path)) { return { @@ -24,12 +33,12 @@ function executeGrepSearchLocally(search: any): GrepSearchResult { const grepArgs: string[] = []; - if (search.recursive ?? false) grepArgs.push('-r'); - if (search.ignoreCase ?? false) grepArgs.push('-i'); - if (search.invertMatch ?? false) grepArgs.push('-v'); - if (search.lineNumbers ?? true) grepArgs.push('-n'); - if (search.wordMatch ?? false) grepArgs.push('-w'); - if (search.fixedStrings ?? false) grepArgs.push('-F'); + if (search.recursive) grepArgs.push('-r'); + if (search.ignoreCase) grepArgs.push('-i'); + if (search.invertMatch) grepArgs.push('-v'); + if (search.lineNumbers) grepArgs.push('-n'); + if (search.wordMatch) grepArgs.push('-w'); + if (search.fixedStrings) grepArgs.push('-F'); if (search.maxCount) grepArgs.push('-m', search.maxCount.toString()); grepArgs.push(search.pattern); @@ -51,7 +60,7 @@ function executeGrepSearchLocally(search: any): GrepSearchResult { const matches: Array<{ file: string; lineNumber?: number; content: string }> = []; for (const line of lines) { - if (search.lineNumbers ?? true) { + if (search.lineNumbers) { const match = line.match(/^([^:]+):(\d+):(.*)$/); if (match?.[1] && match[2] && match[3] !== undefined) { matches.push({ @@ -107,7 +116,17 @@ function executeGrepSearchLocally(search: any): GrepSearchResult { } } -export async function executeGrepSearchesLocally(searches: any[]): Promise<{ +export async function executeGrepSearchesLocally(searches: Array<{ + path: string; + pattern: string; + recursive: boolean; + ignoreCase: boolean; + invertMatch: boolean; + lineNumbers: boolean; + wordMatch: boolean; + fixedStrings: boolean; + maxCount?: number; +}>): Promise<{ successful_searches: Array<{ path: string; pattern: string; @@ -191,7 +210,17 @@ export async function executeGrepSearchesLocally(searches: any[]): Promise<{ }; } -export function generateGrepSearchCode(searches: any[]): string { +export function generateGrepSearchCode(searches: Array<{ + path: string; + pattern: string; + recursive: boolean; + ignoreCase: boolean; + invertMatch: boolean; + lineNumbers: boolean; + wordMatch: boolean; + fixedStrings: boolean; + maxCount?: number; +}>): string { return ` const { execSync } = require('child_process'); const fs = require('fs'); @@ -236,7 +265,7 @@ function executeGrepSearch(search) { const matches = []; for (const line of lines) { - if (search.lineNumbers !== false) { + if (search.lineNumbers) { const match = line.match(/^([^:]+):(\\d+):(.*)$/); if (match && match[1] && match[2] && match[3] !== undefined) { matches.push({