Skip to content

Commit

Permalink
Merge pull request #728 from nissa-seru/add-command-fixes-from-cline
Browse files Browse the repository at this point in the history
Add command fixes
  • Loading branch information
mrubens authored Feb 4, 2025
2 parents 6f64975 + 7e5d78d commit 8472ae0
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 28 deletions.
44 changes: 22 additions & 22 deletions src/core/prompts/__tests__/__snapshots__/system.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -291,7 +291,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -455,7 +455,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -614,7 +614,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -778,7 +778,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -937,7 +937,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -1147,7 +1147,7 @@ Example: Requesting to click on the element at coordinates 450,300
</browser_action>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -1309,7 +1309,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -1473,7 +1473,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -2045,7 +2045,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -2255,7 +2255,7 @@ Example: Requesting to click on the element at coordinates 450,300
</browser_action>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -2417,7 +2417,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -2641,7 +2641,7 @@ Your search/replace content here
</apply_diff>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -2802,7 +2802,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -2966,7 +2966,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -3125,7 +3125,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -3331,7 +3331,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -3549,7 +3549,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -3873,7 +3873,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -4182,7 +4182,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down Expand Up @@ -4376,7 +4376,7 @@ Example: Requesting to write to frontend-config.json
</write_to_file>
## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: /test/path
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. Commands will be executed in the current working directory: /test/path
Parameters:
- 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.
Usage:
Expand Down Expand Up @@ -4948,7 +4948,7 @@ RULES
SYSTEM INFORMATION
Operating System: Linux
Default Shell: /bin/bash
Default Shell: /bin/zsh
Home Directory: /home/user
Current Working Directory: /test/path
Expand Down
6 changes: 5 additions & 1 deletion src/core/prompts/__tests__/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ jest.mock("os", () => ({
homedir: () => "/home/user",
}))

jest.mock("default-shell", () => "/bin/bash")
jest.mock("default-shell", () => "/bin/zsh")

jest.mock("os-name", () => () => "Linux")

jest.mock("../../../utils/shell", () => ({
getShell: () => "/bin/zsh",
}))

// Create a mock ExtensionContext
const mockContext = {
extensionPath: "/mock/extension/path",
Expand Down
3 changes: 2 additions & 1 deletion src/core/prompts/sections/system-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import defaultShell from "default-shell"
import os from "os"
import osName from "os-name"
import { Mode, ModeConfig, getModeBySlug, defaultModeSlug, isToolAllowedForMode } from "../../../shared/modes"
import { getShell } from "../../../utils/shell"

export function getSystemInfoSection(cwd: string, currentMode: Mode, customModes?: ModeConfig[]): string {
const findModeBySlug = (slug: string, modes?: ModeConfig[]) => modes?.find((m) => m.slug === slug)
Expand All @@ -14,7 +15,7 @@ export function getSystemInfoSection(cwd: string, currentMode: Mode, customModes
SYSTEM INFORMATION
Operating System: ${osName()}
Default Shell: ${defaultShell}
Default Shell: ${getShell()}
Home Directory: ${os.homedir().toPosix()}
Current Working Directory: ${cwd.toPosix()}
Expand Down
2 changes: 1 addition & 1 deletion src/core/prompts/tools/execute-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ToolArgs } from "./types"

export function getExecuteCommandDescription(args: ToolArgs): string | undefined {
return `## execute_command
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. Prefer to execute complex CLI commands over creating executable scripts, as they are more flexible and easier to run. Commands will be executed in the current working directory: ${args.cwd}
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. Commands will be executed in the current working directory: ${args.cwd}
Parameters:
- 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.
Usage:
Expand Down
Loading

0 comments on commit 8472ae0

Please sign in to comment.