@@ -90,6 +90,7 @@ import { applyDiffTool } from "./tools/applyDiffTool"
9090import { insertContentTool } from "./tools/insertContentTool"
9191import { searchAndReplaceTool } from "./tools/searchAndReplaceTool"
9292import { listCodeDefinitionNamesTool } from "./tools/listCodeDefinitionNamesTool"
93+ import { searchFilesTool } from "./tools/searchFilesTool"
9394
9495export type ToolResponse = string | Array < Anthropic . TextBlockParam | Anthropic . ImageBlockParam >
9596type UserContent = Array < Anthropic . Messages . ContentBlockParam >
@@ -1608,58 +1609,8 @@ export class Cline extends EventEmitter<ClineEvents> {
16081609 )
16091610 break
16101611 case "search_files" : {
1611- const relDirPath : string | undefined = block . params . path
1612- const regex : string | undefined = block . params . regex
1613- const filePattern : string | undefined = block . params . file_pattern
1614- const sharedMessageProps : ClineSayTool = {
1615- tool : "searchFiles" ,
1616- path : getReadablePath ( this . cwd , removeClosingTag ( "path" , relDirPath ) ) ,
1617- regex : removeClosingTag ( "regex" , regex ) ,
1618- filePattern : removeClosingTag ( "file_pattern" , filePattern ) ,
1619- }
1620- try {
1621- if ( block . partial ) {
1622- const partialMessage = JSON . stringify ( {
1623- ...sharedMessageProps ,
1624- content : "" ,
1625- } satisfies ClineSayTool )
1626- await this . ask ( "tool" , partialMessage , block . partial ) . catch ( ( ) => { } )
1627- break
1628- } else {
1629- if ( ! relDirPath ) {
1630- this . consecutiveMistakeCount ++
1631- pushToolResult ( await this . sayAndCreateMissingParamError ( "search_files" , "path" ) )
1632- break
1633- }
1634- if ( ! regex ) {
1635- this . consecutiveMistakeCount ++
1636- pushToolResult ( await this . sayAndCreateMissingParamError ( "search_files" , "regex" ) )
1637- break
1638- }
1639- this . consecutiveMistakeCount = 0
1640- const absolutePath = path . resolve ( this . cwd , relDirPath )
1641- const results = await regexSearchFiles (
1642- this . cwd ,
1643- absolutePath ,
1644- regex ,
1645- filePattern ,
1646- this . rooIgnoreController ,
1647- )
1648- const completeMessage = JSON . stringify ( {
1649- ...sharedMessageProps ,
1650- content : results ,
1651- } satisfies ClineSayTool )
1652- const didApprove = await askApproval ( "tool" , completeMessage )
1653- if ( ! didApprove ) {
1654- break
1655- }
1656- pushToolResult ( results )
1657- break
1658- }
1659- } catch ( error ) {
1660- await handleError ( "searching files" , error )
1661- break
1662- }
1612+ await searchFilesTool ( this , block , askApproval , handleError , pushToolResult , removeClosingTag )
1613+ break
16631614 }
16641615 case "browser_action" : {
16651616 const action : BrowserAction | undefined = block . params . action as BrowserAction
0 commit comments