mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
Send command output for attempt completion commands
This commit is contained in:
@@ -623,10 +623,7 @@ export class ClaudeDev {
|
|||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
|
||||||
async executeCommandTool(
|
async executeCommandTool(command: string): Promise<[boolean, ToolResponse]> {
|
||||||
command: string,
|
|
||||||
returnEmptyStringOnSuccess: boolean = false
|
|
||||||
): Promise<[boolean, ToolResponse]> {
|
|
||||||
const terminalInfo = await this.terminalManager.getOrCreateTerminal(cwd)
|
const terminalInfo = await this.terminalManager.getOrCreateTerminal(cwd)
|
||||||
terminalInfo.terminal.show() // weird visual bug when creating new terminals (even manually) where there's an empty space at the top.
|
terminalInfo.terminal.show() // weird visual bug when creating new terminals (even manually) where there's an empty space at the top.
|
||||||
const process = this.terminalManager.runCommand(terminalInfo, command)
|
const process = this.terminalManager.runCommand(terminalInfo, command)
|
||||||
@@ -691,10 +688,6 @@ export class ClaudeDev {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
// for attemptCompletion, we don't want to return the command output
|
|
||||||
if (returnEmptyStringOnSuccess) {
|
|
||||||
return [false, ""]
|
|
||||||
}
|
|
||||||
if (completed) {
|
if (completed) {
|
||||||
return [false, `Command executed.${result.length > 0 ? `\nOutput:\n${result}` : ""}`]
|
return [false, `Command executed.${result.length > 0 ? `\nOutput:\n${result}` : ""}`]
|
||||||
} else {
|
} else {
|
||||||
@@ -1000,6 +993,9 @@ export class ClaudeDev {
|
|||||||
// it's important to note how this function works, you can't make the assumption that the block.partial conditional will always be called since it may immediately get complete, non-partial data. So this part of the logic will always be called.
|
// it's important to note how this function works, you can't make the assumption that the block.partial conditional will always be called since it may immediately get complete, non-partial data. So this part of the logic will always be called.
|
||||||
// in other words, you must always repeat the block.partial logic here
|
// in other words, you must always repeat the block.partial logic here
|
||||||
if (!this.diffViewProvider.isEditing) {
|
if (!this.diffViewProvider.isEditing) {
|
||||||
|
// show gui message before showing edit animation
|
||||||
|
const partialMessage = JSON.stringify(sharedMessageProps)
|
||||||
|
await this.ask("tool", partialMessage, true).catch(() => {}) // sending true for partial even though it's not a partial, this shows the edit row before the content is streamed into the editor
|
||||||
await this.diffViewProvider.open(relPath)
|
await this.diffViewProvider.open(relPath)
|
||||||
}
|
}
|
||||||
await this.diffViewProvider.update(newContent, true)
|
await this.diffViewProvider.update(newContent, true)
|
||||||
@@ -1339,7 +1335,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
const [userRejected, result] = await this.executeCommandTool(command)
|
const [userRejected, result] = await this.executeCommandTool(command)
|
||||||
if (userRejected) {
|
if (userRejected) {
|
||||||
this.didRejectTool = true // test whats going on here
|
this.didRejectTool = true
|
||||||
}
|
}
|
||||||
pushToolResult(result)
|
pushToolResult(result)
|
||||||
break
|
break
|
||||||
@@ -1450,6 +1446,7 @@ export class ClaudeDev {
|
|||||||
}
|
}
|
||||||
this.consecutiveMistakeCount = 0
|
this.consecutiveMistakeCount = 0
|
||||||
|
|
||||||
|
let commandResult: ToolResponse | undefined
|
||||||
if (command) {
|
if (command) {
|
||||||
if (lastMessage && lastMessage.ask !== "command") {
|
if (lastMessage && lastMessage.ask !== "command") {
|
||||||
// havent sent a command message yet so first send completion_result then command
|
// havent sent a command message yet so first send completion_result then command
|
||||||
@@ -1461,14 +1458,14 @@ export class ClaudeDev {
|
|||||||
if (!didApprove) {
|
if (!didApprove) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const [userRejected, commandResult] = await this.executeCommandTool(command!, true)
|
const [userRejected, execCommandResult] = await this.executeCommandTool(command!)
|
||||||
if (commandResult) {
|
if (userRejected) {
|
||||||
if (userRejected) {
|
this.didRejectTool = true
|
||||||
this.didRejectTool = true // test whats going on here
|
pushToolResult(execCommandResult)
|
||||||
}
|
|
||||||
pushToolResult(commandResult)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
// user didn't reject, but the command may have output
|
||||||
|
commandResult = execCommandResult
|
||||||
} else {
|
} else {
|
||||||
await this.say("completion_result", result, undefined, false)
|
await this.say("completion_result", result, undefined, false)
|
||||||
}
|
}
|
||||||
@@ -1480,12 +1477,26 @@ export class ClaudeDev {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
await this.say("user_feedback", text ?? "", images)
|
await this.say("user_feedback", text ?? "", images)
|
||||||
pushToolResult(
|
|
||||||
formatResponse.toolResult(
|
const toolResults: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] = []
|
||||||
`The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n<feedback>\n${text}\n</feedback>`,
|
if (commandResult) {
|
||||||
images
|
if (typeof commandResult === "string") {
|
||||||
)
|
toolResults.push({ type: "text", text: commandResult })
|
||||||
)
|
} else if (Array.isArray(commandResult)) {
|
||||||
|
toolResults.push(...commandResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toolResults.push({
|
||||||
|
type: "text",
|
||||||
|
text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n<feedback>\n${text}\n</feedback>`,
|
||||||
|
})
|
||||||
|
toolResults.push(...formatResponse.imageBlocks(images))
|
||||||
|
this.userMessageContent.push({
|
||||||
|
type: "text",
|
||||||
|
text: `${toolDescription()} Result:`,
|
||||||
|
})
|
||||||
|
this.userMessageContent.push(...toolResults)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user