diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index 75132c6..1196190 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -490,7 +490,7 @@ export class ClaudeDev { } } - async executeCommand(command: string): Promise { + async executeCommand(command: string, returnEmptyStringOnSuccess: boolean = false): Promise { const { response, text } = await this.ask("command", command) if (response !== "yesButtonTapped") { if (response === "textResponse" && text) { @@ -508,6 +508,10 @@ export class ClaudeDev { this.say("command_output", line) // stream output to user in realtime result += `${line}\n` } + // for attemptCompletion, we don't want to return the command output + if (returnEmptyStringOnSuccess) { + return "" + } return `Command executed successfully. Output:\n${result}` } catch (e) { const error = e as any @@ -529,7 +533,11 @@ export class ClaudeDev { if (command) { 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 - 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 = "" } 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)