Skip to content

Commit 8bbecac

Browse files
committed
feat: add setting to disable LLM command suggestions
- Added new configuration setting 'roo.disableLLMCommandSuggestions' - Made command suggestions conditional based on the setting - Updated system prompt to pass the setting value - Added comprehensive tests for the new functionality - Added localization support for the new setting Fixes #5491
1 parent c9964e2 commit 8bbecac

File tree

7 files changed

+384
-4
lines changed

7 files changed

+384
-4
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { describe, it, expect } from "vitest"
2+
import { getExecuteCommandDescription } from "../execute-command"
3+
import { ToolArgs } from "../types"
4+
5+
describe("getExecuteCommandDescription", () => {
6+
const baseArgs: ToolArgs = {
7+
cwd: "/test/path",
8+
supportsComputerUse: false,
9+
}
10+
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+
})
26+
27+
it("should include suggestions section when disableLlmCommandSuggestions is not set", () => {
28+
const args: ToolArgs = {
29+
...baseArgs,
30+
settings: {},
31+
}
32+
33+
const description = getExecuteCommandDescription(args)
34+
35+
// Check that the description includes the suggestions parameter
36+
expect(description).toContain("<suggestions>")
37+
expect(description).toContain("- suggestions: (optional) Command patterns for the user to allow/deny")
38+
expect(description).toContain("Suggestion Guidelines")
39+
})
40+
41+
it("should exclude suggestions section when disableLlmCommandSuggestions is true", () => {
42+
const args: ToolArgs = {
43+
...baseArgs,
44+
settings: {
45+
disableLlmCommandSuggestions: true,
46+
},
47+
}
48+
49+
const description = getExecuteCommandDescription(args)
50+
51+
// Check that the description does NOT include the suggestions parameter
52+
expect(description).not.toContain("<suggestions>")
53+
expect(description).not.toContain("- suggestions: (optional) Command patterns for the user to allow/deny")
54+
expect(description).not.toContain("Suggestion Guidelines")
55+
})
56+
57+
it("should include basic command and cwd parameters regardless of settings", () => {
58+
const args: ToolArgs = {
59+
...baseArgs,
60+
settings: {
61+
disableLlmCommandSuggestions: true,
62+
},
63+
}
64+
65+
const description = getExecuteCommandDescription(args)
66+
67+
// Check that basic parameters are always included
68+
expect(description).toContain("- command: (required)")
69+
expect(description).toContain("- cwd: (optional)")
70+
expect(description).toContain("execute_command")
71+
})
72+
})

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
import { ToolArgs } from "./types"
22

33
export function getExecuteCommandDescription(args: ToolArgs): string | undefined {
4-
return `## execute_command
4+
const disableLlmSuggestions = args.settings?.disableLlmCommandSuggestions ?? false
5+
6+
const baseDescription = `## execute_command
57
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.
68
79
Parameters:
810
- 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.
9-
- cwd: (optional) The working directory to execute the command in (default: ${args.cwd})
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+
`
1040
- suggestions: (optional) Command patterns for the user to allow/deny for future auto-approval. Include 1-2 relevant patterns when executing common development commands. Use <suggest> tags.
1141
1242
**Suggestion Guidelines:**
@@ -41,4 +71,5 @@ Example: Requesting to execute ls in a specific directory
4171
<suggest>ls</suggest>
4272
</suggestions>
4373
</execute_command>`
74+
)
4475
}

src/core/task/Task.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,9 @@ export class Task extends EventEmitter<ClineEvents> {
16481648
maxReadFileLine !== -1,
16491649
{
16501650
maxConcurrentFileReads,
1651+
disableLlmCommandSuggestions: vscode.workspace
1652+
.getConfiguration(Package.name)
1653+
.get<boolean>("disableLlmCommandSuggestions", false),
16511654
},
16521655
)
16531656
})()

0 commit comments

Comments
 (0)