Skip to content

Commit d899a36

Browse files
committed
refactor: Remove LLM suggestion feature in favor of deterministic shell-quote parser
This commit simplifies the command pattern extraction implementation by: - Removing all LLM-based command suggestion functionality - Always using the shell-quote parser for deterministic command pattern extraction - Eliminating the commandSuggestionsEnabled setting and related UI components - Removing unnecessary complexity from the codebase The shell-quote parser provides consistent and predictable results without requiring LLM calls, making the feature more reliable and performant.
1 parent edba73a commit d899a36

File tree

12 files changed

+92
-452
lines changed

12 files changed

+92
-452
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Command Whitelisting UI Location Summary
2+
3+
## Overview
4+
5+
The command whitelisting feature has been successfully moved from VS Code's native settings to the Roo Code plugin's settings interface. This consolidates all auto-approval settings in one convenient location.
6+
7+
## Previous Location (REMOVED)
8+
9+
- **VS Code Settings**: `Preferences > Settings > Extensions > Roo Code`
10+
- **Setting Name**: `roo-code.commandWhitelist`
11+
- **Access**: Required navigating through VS Code's settings UI or editing `settings.json`
12+
13+
## New Location (CURRENT)
14+
15+
The command whitelisting feature is now located in:
16+
17+
### Access Path
18+
19+
1. Open the Roo Code extension panel in VS Code
20+
2. Click on the **Settings** icon (gear icon) in the top toolbar
21+
3. Navigate to the **Auto Approve** section
22+
4. Find the **Execute** subsection
23+
24+
### UI Components
25+
26+
Within the Auto Approve > Execute section, you'll find:
27+
28+
1. **Enable/Disable Toggle**
29+
30+
- Label: "Auto-approve command execution"
31+
- Controls whether commands can be auto-approved
32+
33+
2. **Command Patterns List**
34+
- Label: "Command patterns"
35+
- Description: "Add command patterns that can be auto-approved (e.g., 'npm test', 'git status')"
36+
- Features:
37+
- Add new patterns using the input field
38+
- Remove patterns with the × button
39+
- Patterns support wildcards (\*)
40+
- Empty list means no commands are auto-approved
41+
42+
### Example Patterns
43+
44+
- `npm test` - Auto-approves exact command
45+
- `npm *` - Auto-approves any npm command
46+
- `git status` - Auto-approves git status command
47+
- `*` - Auto-approves all commands (use with caution)
48+
49+
## Migration
50+
51+
- Existing command whitelist settings from VS Code settings are automatically migrated to the new location on first launch
52+
- The old VS Code setting (`roo-code.commandWhitelist`) is removed from `package.json`
53+
- Users don't need to manually transfer their settings
54+
55+
## Benefits
56+
57+
1. **Centralized Settings**: All auto-approval settings (read, write, execute) are now in one place
58+
2. **Better UX**: No need to navigate VS Code's complex settings structure
59+
3. **Visual Consistency**: Matches the UI pattern of other auto-approve settings
60+
4. **Easier Discovery**: Users can find all related settings together
61+
62+
## Technical Details
63+
64+
- Setting is stored in the global state using key: `commandWhitelist`
65+
- Synchronized across VS Code instances
66+
- Supports the same pattern matching as before
67+
- Maintains backward compatibility through automatic migration

packages/types/src/global-settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const globalSettingsSchema = z.object({
4848
alwaysAllowFollowupQuestions: z.boolean().optional(),
4949
followupAutoApproveTimeoutMs: z.number().optional(),
5050
alwaysAllowUpdateTodoList: z.boolean().optional(),
51-
disableLlmCommandSuggestions: z.boolean().optional(),
5251
allowedCommands: z.array(z.string()).optional(),
5352
deniedCommands: z.array(z.string()).optional(),
5453
allowedMaxRequests: z.number().nullish(),

src/core/prompts/tools/__tests__/execute-command.spec.ts

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,25 @@ describe("getExecuteCommandDescription", () => {
88
supportsComputerUse: false,
99
}
1010

11-
it("should include suggestions section when disableLlmCommandSuggestions is false", () => {
12-
const args: ToolArgs = {
13-
...baseArgs,
14-
settings: {
15-
disableLlmCommandSuggestions: false,
16-
},
17-
}
18-
19-
const description = getExecuteCommandDescription(args)
20-
21-
// Check that the description includes the suggestions parameter
22-
expect(description).toContain("<suggestions>")
23-
expect(description).toContain("- suggestions: (optional) Command patterns for the user to allow/deny")
24-
expect(description).toContain("Suggestion Guidelines")
25-
// Check for chained command guidance
26-
expect(description).toContain("For chained commands")
27-
expect(description).toContain("cd backend && npm install")
28-
})
29-
30-
it("should include suggestions section when disableLlmCommandSuggestions is not set", () => {
11+
it("should not include suggestions section", () => {
3112
const args: ToolArgs = {
3213
...baseArgs,
3314
settings: {},
3415
}
3516

3617
const description = getExecuteCommandDescription(args)
3718

38-
// Check that the description includes the suggestions parameter
39-
expect(description).toContain("<suggestions>")
40-
expect(description).toContain("- suggestions: (optional) Command patterns for the user to allow/deny")
41-
expect(description).toContain("Suggestion Guidelines")
42-
})
43-
44-
it("should exclude suggestions section when disableLlmCommandSuggestions is true", () => {
45-
const args: ToolArgs = {
46-
...baseArgs,
47-
settings: {
48-
disableLlmCommandSuggestions: true,
49-
},
50-
}
51-
52-
const description = getExecuteCommandDescription(args)
53-
5419
// Check that the description does NOT include the suggestions parameter
5520
expect(description).not.toContain("<suggestions>")
5621
expect(description).not.toContain("- suggestions: (optional) Command patterns for the user to allow/deny")
5722
expect(description).not.toContain("Suggestion Guidelines")
23+
expect(description).not.toContain("For chained commands")
5824
})
5925

60-
it("should include basic command and cwd parameters regardless of settings", () => {
26+
it("should include basic command and cwd parameters", () => {
6127
const args: ToolArgs = {
6228
...baseArgs,
63-
settings: {
64-
disableLlmCommandSuggestions: true,
65-
},
29+
settings: {},
6630
}
6731

6832
const description = getExecuteCommandDescription(args)
@@ -71,5 +35,21 @@ describe("getExecuteCommandDescription", () => {
7135
expect(description).toContain("- command: (required)")
7236
expect(description).toContain("- cwd: (optional)")
7337
expect(description).toContain("execute_command")
38+
expect(description).toContain("/test/path")
39+
})
40+
41+
it("should include usage examples", () => {
42+
const args: ToolArgs = {
43+
...baseArgs,
44+
settings: {},
45+
}
46+
47+
const description = getExecuteCommandDescription(args)
48+
49+
// Check that usage examples are included
50+
expect(description).toContain("Usage:")
51+
expect(description).toContain("<execute_command>")
52+
expect(description).toContain("Example: Requesting to execute npm run dev")
53+
expect(description).toContain("Example: Requesting to execute ls in a specific directory")
7454
})
7555
})
Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,27 @@
11
import { ToolArgs } from "./types"
22

33
export function getExecuteCommandDescription(args: ToolArgs): string | undefined {
4-
const disableLlmSuggestions = args.settings?.disableLlmCommandSuggestions ?? false
5-
6-
const baseDescription = `## execute_command
4+
return `## execute_command
75
Description: Request to execute a CLI command on the system. Use this when you need to perform system operations or run specific commands to accomplish any step in the user's task. You must tailor your command to the user's system and provide a clear explanation of what the command does. For command chaining, use the appropriate chaining syntax for the user's shell. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Prefer relative commands and paths that avoid location sensitivity for terminal consistency, e.g: \`touch ./testdata/example.file\`, \`dir ./examples/model1/data/yaml\`, or \`go test ./cmd/front --config ./cmd/front/config.yml\`. If directed by the user, you may open a terminal in a different directory by using the \`cwd\` parameter.
86
97
Parameters:
108
- command: (required) The CLI command to execute. This should be valid for the current operating system. Ensure the command is properly formatted and does not contain any harmful instructions.
11-
- cwd: (optional) The working directory to execute the command in (default: ${args.cwd})`
12-
13-
if (disableLlmSuggestions) {
14-
return (
15-
baseDescription +
16-
`
17-
18-
Usage:
19-
<execute_command>
20-
<command>Your command here</command>
21-
<cwd>Working directory path (optional)</cwd>
22-
</execute_command>
23-
24-
Example: Requesting to execute npm run dev
25-
<execute_command>
26-
<command>npm run dev</command>
27-
</execute_command>
28-
29-
Example: Requesting to execute ls in a specific directory
30-
<execute_command>
31-
<command>ls -la</command>
32-
<cwd>/home/user/projects</cwd>
33-
</execute_command>`
34-
)
35-
}
36-
37-
return (
38-
baseDescription +
39-
`
40-
- suggestions: (optional) Command patterns for the user to allow/deny for future auto-approval. Use <suggest> tags.
41-
42-
**Suggestion Guidelines:**
43-
- Suggestions use prefix matching (case-insensitive)
44-
- For simple commands: Include the base command (e.g., "npm", "git") and optionally a more specific pattern
45-
- For chained commands (using &&, ||, ;, |): Include patterns for EACH individual command in the chain (NOT the full chain)
46-
- Example: For "cd backend && npm install", suggest: "cd", "npm install", "npm"
47-
- Include 2-4 relevant patterns total
48-
- Only suggest "*" (allow all) if explicitly requested by the user
9+
- cwd: (optional) The working directory to execute the command in (default: ${args.cwd})
4910
5011
Usage:
5112
<execute_command>
5213
<command>Your command here</command>
5314
<cwd>Working directory path (optional)</cwd>
54-
<suggestions>
55-
<suggest>pattern 1</suggest>
56-
<suggest>pattern 2</suggest>
57-
</suggestions>
5815
</execute_command>
5916
6017
Example: Requesting to execute npm run dev
6118
<execute_command>
6219
<command>npm run dev</command>
63-
<suggestions>
64-
<suggest>npm run</suggest>
65-
<suggest>npm</suggest>
66-
</suggestions>
67-
</execute_command>
68-
69-
Example: Requesting to execute a chained command
70-
<execute_command>
71-
<command>cd backend && npm install</command>
72-
<suggestions>
73-
<suggest>cd</suggest>
74-
<suggest>npm install</suggest>
75-
<suggest>npm</suggest>
76-
</suggestions>
7720
</execute_command>
7821
7922
Example: Requesting to execute ls in a specific directory
8023
<execute_command>
8124
<command>ls -la</command>
8225
<cwd>/home/user/projects</cwd>
83-
<suggestions>
84-
<suggest>ls</suggest>
85-
</suggestions>
8626
</execute_command>`
87-
)
8827
}

0 commit comments

Comments
 (0)