mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 04:41:16 -05:00
Fix attempt_completion tool if it has a command that fails or is rejected
This commit is contained in:
@@ -490,7 +490,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeCommand(command: string): Promise<string> {
|
async executeCommand(command: string, returnEmptyStringOnSuccess: boolean = false): Promise<string> {
|
||||||
const { response, text } = await this.ask("command", command)
|
const { response, text } = await this.ask("command", command)
|
||||||
if (response !== "yesButtonTapped") {
|
if (response !== "yesButtonTapped") {
|
||||||
if (response === "textResponse" && text) {
|
if (response === "textResponse" && text) {
|
||||||
@@ -508,6 +508,10 @@ export class ClaudeDev {
|
|||||||
this.say("command_output", line) // stream output to user in realtime
|
this.say("command_output", line) // stream output to user in realtime
|
||||||
result += `${line}\n`
|
result += `${line}\n`
|
||||||
}
|
}
|
||||||
|
// for attemptCompletion, we don't want to return the command output
|
||||||
|
if (returnEmptyStringOnSuccess) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return `Command executed successfully. Output:\n${result}`
|
return `Command executed successfully. Output:\n${result}`
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e as any
|
const error = e as any
|
||||||
@@ -529,7 +533,11 @@ export class ClaudeDev {
|
|||||||
if (command) {
|
if (command) {
|
||||||
await this.say("completion_result", resultToSend)
|
await this.say("completion_result", resultToSend)
|
||||||
// TODO: currently we don't handle if this command fails, it could be useful to let claude know and retry
|
// TODO: currently we don't handle if this command fails, it could be useful to let claude know and retry
|
||||||
await this.executeCommand(command)
|
const commandResult = await this.executeCommand(command, true)
|
||||||
|
// if we received non-empty string, the command was rejected or failed
|
||||||
|
if (commandResult) {
|
||||||
|
return commandResult
|
||||||
|
}
|
||||||
resultToSend = ""
|
resultToSend = ""
|
||||||
}
|
}
|
||||||
const { response, text } = await this.ask("completion_result", resultToSend) // this prompts webview to show 'new task' button, and enable text input (which would be the 'text' here)
|
const { response, text } = await this.ask("completion_result", resultToSend) // this prompts webview to show 'new task' button, and enable text input (which would be the 'text' here)
|
||||||
|
|||||||
Reference in New Issue
Block a user