Skip to content

Commit 6b8f9f7

Browse files
authored
Expose a list of allowed auto-execute commands (#31)
1 parent 750c24c commit 6b8f9f7

File tree

14 files changed

+1054
-688
lines changed

14 files changed

+1054
-688
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Change Log
22

3-
## Roo Cline 2.1.4
4-
3+
## Roo Cline 2.1.8
54
- Roo Cline now publishes to the VS Code Marketplace!
65
- Roo Cline now allows browser actions without approval when `alwaysAllowBrowser` is true
76
- Roo Cline now can run side-by-side with Cline
7+
- Roo Cline now allows configuration of allowed commands without approval
88

99
## [2.1.6]
1010

package.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
"displayName": "Roo Cline",
44
"description": "A fork of Cline, an autonomous coding agent, with some added experimental configuration and automation features.",
55
"publisher": "RooVeterinaryInc",
6-
"version": "2.1.7",
7-
"files": [
8-
"bin/roo-cline-2.1.7.vsix",
9-
"assets/icons/rocket.png"
10-
],
6+
"version": "2.1.8",
117
"icon": "assets/icons/rocket.png",
128
"galleryBanner": {
139
"color": "#617A91",
@@ -116,6 +112,26 @@
116112
"when": "view == roo-cline.SidebarProvider"
117113
}
118114
]
115+
},
116+
"configuration": {
117+
"title": "RooCline",
118+
"properties": {
119+
"roo-cline.allowedCommands": {
120+
"type": "array",
121+
"items": {
122+
"type": "string"
123+
},
124+
"default": [
125+
"npm test",
126+
"npm install",
127+
"tsc",
128+
"git log",
129+
"git diff",
130+
"git show"
131+
],
132+
"description": "Commands that can be auto-executed when 'Always approve execute operations' is enabled"
133+
}
134+
}
119135
}
120136
},
121137
"scripts": {

src/core/webview/ClineProvider.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type GlobalStateKey =
6060
| "azureApiVersion"
6161
| "openRouterModelId"
6262
| "openRouterModelInfo"
63+
| "allowedCommands"
6364

6465
export const GlobalFileNames = {
6566
apiConversationHistory: "api_conversation_history.json",
@@ -510,6 +511,13 @@ export class ClineProvider implements vscode.WebviewViewProvider {
510511
}
511512

512513
break
514+
case "allowedCommands":
515+
await this.context.globalState.update('allowedCommands', message.commands);
516+
// Also update workspace settings
517+
await vscode.workspace
518+
.getConfiguration('roo-cline')
519+
.update('allowedCommands', message.commands, vscode.ConfigurationTarget.Global);
520+
break;
513521
// Add more switch case statements here as more webview message commands
514522
// are created within the webview context (i.e. inside media/main.js)
515523
}
@@ -820,6 +828,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
820828
taskHistory,
821829
} = await this.getState()
822830

831+
const allowedCommands = vscode.workspace
832+
.getConfiguration('roo-cline')
833+
.get<string[]>('allowedCommands') || []
834+
823835
return {
824836
version: this.context.extension?.packageJSON?.version ?? "",
825837
apiConfiguration,
@@ -834,6 +846,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
834846
.filter((item) => item.ts && item.task)
835847
.sort((a, b) => b.ts - a.ts),
836848
shouldShowAnnouncement: lastShownAnnouncementId !== this.latestAnnouncementId,
849+
allowedCommands,
837850
}
838851
}
839852

@@ -921,6 +934,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
921934
alwaysAllowExecute,
922935
alwaysAllowBrowser,
923936
taskHistory,
937+
allowedCommands,
924938
] = await Promise.all([
925939
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
926940
this.getGlobalState("apiModelId") as Promise<string | undefined>,
@@ -953,6 +967,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
953967
this.getGlobalState("alwaysAllowExecute") as Promise<boolean | undefined>,
954968
this.getGlobalState("alwaysAllowBrowser") as Promise<boolean | undefined>,
955969
this.getGlobalState("taskHistory") as Promise<HistoryItem[] | undefined>,
970+
this.getGlobalState("allowedCommands") as Promise<string[] | undefined>,
956971
])
957972

958973
let apiProvider: ApiProvider
@@ -1003,6 +1018,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10031018
alwaysAllowExecute: alwaysAllowExecute ?? false,
10041019
alwaysAllowBrowser: alwaysAllowBrowser ?? false,
10051020
taskHistory,
1021+
allowedCommands,
10061022
}
10071023
}
10081024

src/extension.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ export function activate(context: vscode.ExtensionContext) {
2626

2727
outputChannel.appendLine("Cline extension activated")
2828

29+
// Get default commands from configuration
30+
const defaultCommands = vscode.workspace
31+
.getConfiguration('roo-cline')
32+
.get<string[]>('allowedCommands') || [];
33+
34+
// Initialize global state if not already set
35+
if (!context.globalState.get('allowedCommands')) {
36+
context.globalState.update('allowedCommands', defaultCommands);
37+
}
38+
2939
const sidebarProvider = new ClineProvider(context, outputChannel)
3040

3141
context.subscriptions.push(

src/shared/ExtensionMessage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ export interface ExtensionMessage {
3030

3131
export interface ExtensionState {
3232
version: string
33+
clineMessages: ClineMessage[]
34+
taskHistory: HistoryItem[]
35+
shouldShowAnnouncement: boolean
3336
apiConfiguration?: ApiConfiguration
3437
customInstructions?: string
3538
alwaysAllowReadOnly?: boolean
3639
alwaysAllowWrite?: boolean
3740
alwaysAllowExecute?: boolean
3841
alwaysAllowBrowser?: boolean
3942
uriScheme?: string
40-
clineMessages: ClineMessage[]
41-
taskHistory: HistoryItem[]
42-
shouldShowAnnouncement: boolean
43+
allowedCommands?: string[]
4344
}
4445

4546
export interface ClineMessage {

src/shared/WebviewMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface WebviewMessage {
44
type:
55
| "apiConfiguration"
66
| "customInstructions"
7+
| "allowedCommands"
78
| "alwaysAllowReadOnly"
89
| "alwaysAllowWrite"
910
| "alwaysAllowExecute"
@@ -31,6 +32,7 @@ export interface WebviewMessage {
3132
apiConfiguration?: ApiConfiguration
3233
images?: string[]
3334
bool?: boolean
35+
commands?: string[]
3436
}
3537

3638
export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse"

0 commit comments

Comments
 (0)