pull/5140/head
Aiden Cline 2025-12-06 23:46:33 -06:00
parent 9425eee09f
commit e52d22039e
3 changed files with 6787 additions and 13 deletions

View File

@ -89,10 +89,10 @@ export const BashTool = Tool.define("bash", async () => {
parameters: z.object({
command: z.string().describe("The command to execute"),
timeout: z.number().describe("Optional timeout in milliseconds").optional(),
dir_path: z
workdir: z
.string()
.describe(
`The path of the directory to run the command in, defaults to ${Instance.directory}. Must be a directory that already exists`,
`The working directory to run the command in. Defaults to ${Instance.directory}. Use this instead of 'cd' commands.`,
)
.optional(),
description: z
@ -102,7 +102,7 @@ export const BashTool = Tool.define("bash", async () => {
),
}),
async execute(params, ctx) {
const cwd = params.dir_path || Instance.directory
const cwd = params.workdir || Instance.directory
if (params.timeout !== undefined && params.timeout < 0) {
throw new Error(`Invalid timeout value: ${params.timeout}. Timeout must be a positive number.`)
}

View File

@ -25,17 +25,20 @@ Usage notes:
- VERY IMPORTANT: You MUST avoid using search commands like `find` and `grep`. Instead use Grep, Glob, or Task to search. You MUST avoid read tools like `cat`, `head`, `tail`, and `ls`, and use Read and List to read files.
- If you _still_ need to run `grep`, STOP. ALWAYS USE ripgrep at `rg` (or /usr/bin/rg) first, which all opencode users have pre-installed.
- When issuing multiple commands, use the ';' or '&&' operator to separate them. DO NOT use newlines (newlines are ok in quoted strings).
- Avoid using `cd` to change directories when possible. Instead, set the `workdir` parameter or use absolute paths in your commands.
<good-example>
dir_path="/foo/bar", command="pytest tests"
</good-example>
<good-example>
pytest /foo/bar/tests
</good-example>
<bad-example>
cd /foo/bar && pytest tests
</bad-example>
# Working Directory
The `workdir` parameter sets the working directory for command execution. Prefer using `workdir` over `cd <dir> &&` command chains when you simply need to run a command in a different directory.
<good-example>
workdir="/foo/bar", command="pytest tests"
</good-example>
<good-example>
command="pytest /foo/bar/tests"
</good-example>
<bad-example>
command="cd /foo/bar && pytest tests"
</bad-example>
# Committing changes with git

File diff suppressed because it is too large Load Diff