mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Add options to always approve write and execute operations
This commit is contained in:
@@ -45,6 +45,8 @@ type GlobalStateKey =
|
||||
| "lastShownAnnouncementId"
|
||||
| "customInstructions"
|
||||
| "alwaysAllowReadOnly"
|
||||
| "alwaysAllowWrite"
|
||||
| "alwaysAllowExecute"
|
||||
| "taskHistory"
|
||||
| "openAiBaseUrl"
|
||||
| "openAiModelId"
|
||||
@@ -185,18 +187,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
|
||||
async initClineWithTask(task?: string, images?: string[]) {
|
||||
await this.clearTask() // ensures that an exising task doesn't exist before starting a new one, although this shouldn't be possible since user must clear task before starting a new one
|
||||
const { apiConfiguration, customInstructions, alwaysAllowReadOnly } = await this.getState()
|
||||
this.cline = new Cline(this, apiConfiguration, customInstructions, alwaysAllowReadOnly, task, images)
|
||||
const { apiConfiguration, customInstructions, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute } = await this.getState()
|
||||
this.cline = new Cline(this, apiConfiguration, customInstructions, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, task, images)
|
||||
}
|
||||
|
||||
async initClineWithHistoryItem(historyItem: HistoryItem) {
|
||||
await this.clearTask()
|
||||
const { apiConfiguration, customInstructions, alwaysAllowReadOnly } = await this.getState()
|
||||
const { apiConfiguration, customInstructions, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute } = await this.getState()
|
||||
this.cline = new Cline(
|
||||
this,
|
||||
apiConfiguration,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
alwaysAllowWrite,
|
||||
alwaysAllowExecute,
|
||||
undefined,
|
||||
undefined,
|
||||
historyItem
|
||||
@@ -401,6 +405,20 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
}
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "alwaysAllowWrite":
|
||||
await this.updateGlobalState("alwaysAllowWrite", message.bool ?? undefined)
|
||||
if (this.cline) {
|
||||
this.cline.alwaysAllowWrite = message.bool ?? false
|
||||
}
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "alwaysAllowExecute":
|
||||
await this.updateGlobalState("alwaysAllowExecute", message.bool ?? undefined)
|
||||
if (this.cline) {
|
||||
this.cline.alwaysAllowExecute = message.bool ?? false
|
||||
}
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "askResponse":
|
||||
this.cline?.handleWebviewAskResponse(message.askResponse!, message.text, message.images)
|
||||
break
|
||||
@@ -737,13 +755,15 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
}
|
||||
|
||||
async getStateToPostToWebview() {
|
||||
const { apiConfiguration, lastShownAnnouncementId, customInstructions, alwaysAllowReadOnly, taskHistory } =
|
||||
const { apiConfiguration, lastShownAnnouncementId, customInstructions, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, taskHistory } =
|
||||
await this.getState()
|
||||
return {
|
||||
version: this.context.extension?.packageJSON?.version ?? "",
|
||||
apiConfiguration,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
alwaysAllowReadOnly: alwaysAllowReadOnly ?? false,
|
||||
alwaysAllowWrite: alwaysAllowWrite ?? false,
|
||||
alwaysAllowExecute: alwaysAllowExecute ?? false,
|
||||
uriScheme: vscode.env.uriScheme,
|
||||
clineMessages: this.cline?.clineMessages || [],
|
||||
taskHistory: (taskHistory || []).filter((item) => item.ts && item.task).sort((a, b) => b.ts - a.ts),
|
||||
@@ -828,6 +848,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
lastShownAnnouncementId,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly,
|
||||
alwaysAllowWrite,
|
||||
alwaysAllowExecute,
|
||||
taskHistory,
|
||||
] = await Promise.all([
|
||||
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
|
||||
@@ -854,6 +876,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
this.getGlobalState("lastShownAnnouncementId") as Promise<string | undefined>,
|
||||
this.getGlobalState("customInstructions") as Promise<string | undefined>,
|
||||
this.getGlobalState("alwaysAllowReadOnly") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("alwaysAllowWrite") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("alwaysAllowExecute") as Promise<boolean | undefined>,
|
||||
this.getGlobalState("taskHistory") as Promise<HistoryItem[] | undefined>,
|
||||
])
|
||||
|
||||
@@ -898,6 +922,8 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
||||
lastShownAnnouncementId,
|
||||
customInstructions,
|
||||
alwaysAllowReadOnly: alwaysAllowReadOnly ?? false,
|
||||
alwaysAllowWrite: alwaysAllowWrite ?? false,
|
||||
alwaysAllowExecute: alwaysAllowExecute ?? false,
|
||||
taskHistory,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user