Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ export async function presentAssistantMessage(cline: Task) {
isProtected || false,
)

if (response !== "yesButtonClicked") {
if (response === "yesButtonClicked" || response === "addAndRunButtonClicked") {
// Handle yesButtonClicked or addAndRunButtonClicked with text.
if (text) {
await cline.say("user_feedback", text, images)
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
}
return true
} else {
// Handle both messageResponse and noButtonClicked with text.
if (text) {
await cline.say("user_feedback", text, images)
Expand All @@ -282,14 +289,6 @@ export async function presentAssistantMessage(cline: Task) {
cline.didRejectTool = true
return false
}

// Handle yesButtonClicked with text.
if (text) {
await cline.say("user_feedback", text, images)
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
}

return true
}

const askFinishSubTaskApproval = async () => {
Expand Down
59 changes: 57 additions & 2 deletions src/core/tools/executeCommandTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,41 @@ import { unescapeHtmlEntities } from "../../utils/text-normalization"
import { ExitCodeDetails, RooTerminalCallbacks, RooTerminalProcess } from "../../integrations/terminal/types"
import { TerminalRegistry } from "../../integrations/terminal/TerminalRegistry"
import { Terminal } from "../../integrations/terminal/Terminal"
import { t } from "../../i18n"
import { extractCommandPattern } from "../../shared/extract-command-pattern"

class ShellIntegrationError extends Error {}

/**
* Adds a command pattern to the whitelist
*/
async function addCommandToWhitelist(cline: Task, command: string): Promise<void> {
const clineProvider = cline.providerRef.deref()
if (!clineProvider) {
console.error("Provider reference is undefined, cannot add command to whitelist")
return
}

const state = await clineProvider.getState()
const currentCommands = state.allowedCommands ?? []

// Extract the base command pattern for whitelisting
const commandPattern = extractCommandPattern(command)

// Add command pattern to whitelist if not already present
if (commandPattern && !currentCommands.includes(commandPattern)) {
const newCommands = [...currentCommands, commandPattern]
await clineProvider.setValue("allowedCommands", newCommands)

// Notify webview of the updated commands
await clineProvider.postMessageToWebview({
type: "invoke",
invoke: "setChatBoxMessage",
text: t("tools:executeCommand.patternAddedToWhitelist", { pattern: commandPattern }),
})
}
}

export async function executeCommandTool(
cline: Task,
block: ToolUse,
Expand Down Expand Up @@ -51,9 +83,32 @@ export async function executeCommandTool(
cline.consecutiveMistakeCount = 0

command = unescapeHtmlEntities(command) // Unescape HTML entities.
const didApprove = await askApproval("command", command)

if (!didApprove) {
// We need to capture the actual response to check if "Add & Run" was clicked
// Note: We cannot use the provided askApproval function here because we need to
// differentiate between "yesButtonClicked" and "addAndRunButtonClicked" responses
const { response, text, images } = await cline.ask("command", command)

if (response === "yesButtonClicked" || response === "addAndRunButtonClicked") {
// Handle yesButtonClicked or addAndRunButtonClicked with text (following askApproval pattern)
if (text) {
await cline.say("user_feedback", text, images)
pushToolResult(formatResponse.toolResult(formatResponse.toolApprovedWithFeedback(text), images))
}

// Check if user selected "Add & Run" to add command to whitelist
if (response === "addAndRunButtonClicked") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the approval logic from presentAssistantMessage.ts. Could we refactor to reuse the existing askApproval function instead?

The duplication could lead to maintenance issues if the approval flow needs to be updated in the future. Consider extracting the whitelist addition logic into a shared function that both places can call.

await addCommandToWhitelist(cline, command)
}
} else {
// Handle both messageResponse and noButtonClicked with text (following askApproval pattern)
if (text) {
await cline.say("user_feedback", text, images)
pushToolResult(formatResponse.toolResult(formatResponse.toolDeniedWithFeedback(text), images))
} else {
pushToolResult(formatResponse.toolDenied())
}
cline.didRejectTool = true
return
}

Expand Down
3 changes: 3 additions & 0 deletions src/i18n/locales/ca/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "No s'ha pogut crear una nova tasca a causa de restriccions de política."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Catalan translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "El patró de comanda \"{{pattern}}\" s'ha afegit a la llista de comandes permeses."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/de/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Neue Aufgabe konnte aufgrund von Richtlinienbeschränkungen nicht erstellt werden."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper German translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Kommandomuster \"{{pattern}}\" wurde zur Liste der erlaubten Befehle hinzugefügt."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/en/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Failed to create new task due to policy restrictions."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern '{{pattern}}' added to whitelist"
}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/es/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "No se pudo crear una nueva tarea debido a restricciones de política."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Spanish translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "El patrón de comando \"{{pattern}}\" ha sido añadido a la lista de comandos permitidos."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/fr/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Impossible de créer une nouvelle tâche en raison de restrictions de politique."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper French translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Le modèle de commande \"{{pattern}}\" a été ajouté à la liste des commandes autorisées."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/hi/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "नीति प्रतिबंधों के कारण नया कार्य बनाने में विफल।"
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Hindi translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "कमांड पैटर्न \"{{pattern}}\" को अनुमत कमांड सूची में जोड़ दिया गया है।"

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/id/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"errors": {
"policy_restriction": "Gagal membuat tugas baru karena pembatasan kebijakan."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Indonesian translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Pola perintah \"{{pattern}}\" telah ditambahkan ke daftar perintah yang diizinkan."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/it/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Impossibile creare una nuova attività a causa di restrizioni di policy."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Italian translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Il pattern di comando \"{{pattern}}\" è stato aggiunto all'elenco dei comandi consentiti."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/ja/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "ポリシー制限により新しいタスクを作成できませんでした。"
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Japanese translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "コマンドパターン「{{pattern}}」が許可されたコマンドリストに追加されました。"

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/ko/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "정책 제한으로 인해 새 작업을 생성하지 못했습니다."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Korean translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "명령 패턴 \"{{pattern}}\"이(가) 허용된 명령 목록에 추가되었습니다."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/nl/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Kan geen nieuwe taak aanmaken vanwege beleidsbeperkingen."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Dutch translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Commandpatroon \"{{pattern}}\" is toegevoegd aan de lijst met toegestane commando's."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/pl/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Nie udało się utworzyć nowego zadania z powodu ograniczeń polityki."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Polish translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Wzorzec polecenia \"{{pattern}}\" został dodany do listy dozwolonych poleceń."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/pt-BR/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Falha ao criar nova tarefa devido a restrições de política."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Portuguese (BR) translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Padrão de comando \"{{pattern}}\" foi adicionado à lista de comandos permitidos."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/ru/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Не удалось создать новую задачу из-за ограничений политики."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Russian translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Шаблон команды \"{{pattern}}\" был добавлен в список разрешённых команд."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/tr/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Politika kısıtlamaları nedeniyle yeni görev oluşturulamadı."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Turkish translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Komut deseni \"{{pattern}}\" izin verilen komutlar listesine eklendi."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/vi/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "Không thể tạo nhiệm vụ mới do hạn chế chính sách."
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Vietnamese translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "Mẫu lệnh \"{{pattern}}\" đã được thêm vào danh sách lệnh được phép."

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/zh-CN/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "由于策略限制,无法创建新任务。"
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Simplified Chinese translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "命令模式 \"{{pattern}}\" 已被添加到允许的命令列表中。"

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
3 changes: 3 additions & 0 deletions src/i18n/locales/zh-TW/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"errors": {
"policy_restriction": "由於政策限制,無法建立新工作。"
}
},
"executeCommand": {
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new translation key 'executeCommand.patternAddedToWhitelist' remains in English. Please provide a proper Traditional Chinese translation.

Suggested change
"patternAddedToWhitelist": "Command pattern \"{{pattern}}\" has been added to the allowed commands list."
"patternAddedToWhitelist": "指令模式 \"{{pattern}}\" 已加入允許的指令清單。"

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

}
}
2 changes: 2 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
"sanitize-filename": "^1.6.3",
"say": "^0.16.0",
"serialize-error": "^12.0.0",
"shell-quote": "1.8.3",
"simple-git": "^3.27.0",
"sound-play": "^1.1.0",
"stream-json": "^1.8.0",
Expand Down Expand Up @@ -439,6 +440,7 @@
"@types/node-ipc": "^9.2.3",
"@types/proper-lockfile": "^4.1.4",
"@types/ps-tree": "^1.1.6",
"@types/shell-quote": "^1.7.5",
"@types/stream-json": "^1.7.8",
"@types/string-similarity": "^4.0.2",
"@types/tmp": "^0.2.6",
Expand Down
8 changes: 7 additions & 1 deletion src/shared/ExtensionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ export interface ExtensionMessage {
| "didBecomeVisible"
| "focusInput"
| "switchTab"
invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
invoke?:
| "newChat"
| "sendMessage"
| "primaryButtonClick"
| "secondaryButtonClick"
| "tertiaryButtonClick"
| "setChatBoxMessage"
state?: ExtensionState
images?: string[]
filePaths?: string[]
Expand Down
7 changes: 6 additions & 1 deletion src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import { marketplaceItemSchema } from "@roo-code/types"

import { Mode } from "./modes"

export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" | "objectResponse"
export type ClineAskResponse =
| "yesButtonClicked"
| "noButtonClicked"
| "addAndRunButtonClicked"
| "messageResponse"
| "objectResponse"

export type PromptMode = Mode | "enhance"

Expand Down
Loading