@@ -92,6 +92,7 @@ import { searchAndReplaceTool } from "./tools/searchAndReplaceTool"
9292import { listCodeDefinitionNamesTool } from "./tools/listCodeDefinitionNamesTool"
9393import { searchFilesTool } from "./tools/searchFilesTool"
9494import { browserActionTool } from "./tools/browserActionTool"
95+ import { executeCommandTool } from "./tools/executeCommandTool"
9596
9697export type ToolResponse = string | Array < Anthropic . TextBlockParam | Anthropic . ImageBlockParam >
9798type UserContent = Array < Anthropic . Messages . ContentBlockParam >
@@ -181,7 +182,7 @@ export class Cline extends EventEmitter<ClineEvents> {
181182 private presentAssistantMessageHasPendingUpdates = false
182183 private userMessageContent : ( Anthropic . TextBlockParam | Anthropic . ImageBlockParam ) [ ] = [ ]
183184 private userMessageContentReady = false
184- private didRejectTool = false
185+ didRejectTool = false
185186 private didAlreadyUseTool = false
186187 private didCompleteReadingStream = false
187188
@@ -1618,52 +1619,15 @@ export class Cline extends EventEmitter<ClineEvents> {
16181619 break
16191620 }
16201621 case "execute_command" : {
1621- const command : string | undefined = block . params . command
1622- const customCwd : string | undefined = block . params . cwd
1623- try {
1624- if ( block . partial ) {
1625- await this . ask ( "command" , removeClosingTag ( "command" , command ) , block . partial ) . catch (
1626- ( ) => { } ,
1627- )
1628- break
1629- } else {
1630- if ( ! command ) {
1631- this . consecutiveMistakeCount ++
1632- pushToolResult (
1633- await this . sayAndCreateMissingParamError ( "execute_command" , "command" ) ,
1634- )
1635- break
1636- }
1637-
1638- const ignoredFileAttemptedToAccess = this . rooIgnoreController ?. validateCommand ( command )
1639- if ( ignoredFileAttemptedToAccess ) {
1640- await this . say ( "rooignore_error" , ignoredFileAttemptedToAccess )
1641- pushToolResult (
1642- formatResponse . toolError (
1643- formatResponse . rooIgnoreError ( ignoredFileAttemptedToAccess ) ,
1644- ) ,
1645- )
1646-
1647- break
1648- }
1649-
1650- this . consecutiveMistakeCount = 0
1651-
1652- const didApprove = await askApproval ( "command" , command )
1653- if ( ! didApprove ) {
1654- break
1655- }
1656- const [ userRejected , result ] = await this . executeCommandTool ( command , customCwd )
1657- if ( userRejected ) {
1658- this . didRejectTool = true
1659- }
1660- pushToolResult ( result )
1661- break
1662- }
1663- } catch ( error ) {
1664- await handleError ( "executing command" , error )
1665- break
1666- }
1622+ await executeCommandTool (
1623+ this ,
1624+ block ,
1625+ askApproval ,
1626+ handleError ,
1627+ pushToolResult ,
1628+ removeClosingTag ,
1629+ )
1630+ break
16671631 }
16681632 case "use_mcp_tool" : {
16691633 const server_name : string | undefined = block . params . server_name
0 commit comments