This commit is contained in:
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({ parameters: z.object({
command: z.string().describe("The command to execute"), command: z.string().describe("The command to execute"),
timeout: z.number().describe("Optional timeout in milliseconds").optional(), timeout: z.number().describe("Optional timeout in milliseconds").optional(),
dir_path: z workdir: z
.string() .string()
.describe( .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(), .optional(),
description: z description: z
@@ -102,7 +102,7 @@ export const BashTool = Tool.define("bash", async () => {
), ),
}), }),
async execute(params, ctx) { async execute(params, ctx) {
const cwd = params.dir_path || Instance.directory const cwd = params.workdir || Instance.directory
if (params.timeout !== undefined && params.timeout < 0) { if (params.timeout !== undefined && params.timeout < 0) {
throw new Error(`Invalid timeout value: ${params.timeout}. Timeout must be a positive number.`) throw new Error(`Invalid timeout value: ${params.timeout}. Timeout must be a positive number.`)
} }

View File

@@ -25,18 +25,21 @@ 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. - 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. - 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). - 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.
# 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> <good-example>
dir_path="/foo/bar", command="pytest tests" workdir="/foo/bar", command="pytest tests"
</good-example> </good-example>
<good-example> <good-example>
pytest /foo/bar/tests command="pytest /foo/bar/tests"
</good-example> </good-example>
<bad-example> <bad-example>
cd /foo/bar && pytest tests command="cd /foo/bar && pytest tests"
</bad-example> </bad-example>
# Committing changes with git # Committing changes with git
IMPORTANT: ONLY COMMIT IF THE USER ASKS YOU TO. IMPORTANT: ONLY COMMIT IF THE USER ASKS YOU TO.

File diff suppressed because it is too large Load Diff