From 84a4102447e81bdfc5d715af0c00deef27cb5aa2 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Fri, 28 Nov 2025 17:58:23 -0500 Subject: [PATCH 1/9] feat: attemp to inject shell advice in bash tool description, needs testing. --- packages/opencode/src/tool/bash.ts | 22 ++++++++++++++++++++-- packages/opencode/test/tool/bash.test.ts | 10 ++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index d8af0a77f46..506dae55068 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -83,10 +83,28 @@ export const BashTool = Tool.define("bash", async () => { return true }) - log.info("bash tool using shell", { shell }) + + const shellName = iife(() => { + if (typeof shell === "boolean") return "bash" + if (typeof shell === "string") { + const name = path.basename(shell) + // Handle Windows executables + if (name.toLowerCase().endsWith(".exe")) { + return name.slice(0, -4) + } + return name + } + return "bash" + }) + + log.info("bash tool using shell", { shell, shellName }) + + const description = `**Shell**: You are executing commands in \`${shellName}\`. Ensure your command syntax is compatible with this shell. + +${DESCRIPTION}` return { - description: DESCRIPTION, + description, parameters: z.object({ command: z.string().describe("The command to execute"), timeout: z.number().describe("Optional timeout in milliseconds").optional(), diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index 55b9ba77d66..65c9a4c37f7 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -34,6 +34,16 @@ describe("tool.bash", () => { }) }) + test("description includes shell information", async () => { + const bash = await BashTool.init() + expect(bash.description).toContain("**Shell**:") + expect(bash.description).toContain("Ensure your command syntax is compatible with this shell") + // Should contain a shell name (bash, zsh, fish, etc.) + const shellMatch = bash.description.match(/You are executing commands in `([^`]+)`/) + expect(shellMatch).toBeTruthy() + expect(shellMatch?.[1]).toBeTruthy() + }) + // TODO: better test // test("cd ../ should ask for permission for external directory", async () => { // await Instance.provide({ From cac1c5e0b6230fa813cbc53216d33c0d24dad473 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Fri, 28 Nov 2025 18:06:48 -0500 Subject: [PATCH 2/9] fix: safer windows corner case --- packages/opencode/src/tool/bash.ts | 5 ++++- packages/opencode/test/tool/bash.test.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index 506dae55068..6b9035a1cf8 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -85,7 +85,10 @@ export const BashTool = Tool.define("bash", async () => { }) const shellName = iife(() => { - if (typeof shell === "boolean") return "bash" + if (typeof shell === "boolean") { + // When shell is true (fallback), assume appropriate default for platform + return process.platform === "win32" ? "cmd" : "bash" + } if (typeof shell === "string") { const name = path.basename(shell) // Handle Windows executables diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index 65c9a4c37f7..d591f4fa0bd 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -44,6 +44,25 @@ describe("tool.bash", () => { expect(shellMatch?.[1]).toBeTruthy() }) + test("shell name detection is platform-aware", async () => { + const bash = await BashTool.init() + const shellMatch = bash.description.match(/You are executing commands in `([^`]+)`/) + const detectedShell = shellMatch?.[1] + + expect(detectedShell).toBeTruthy() + + // Verify detected shell is appropriate for the platform + if (process.platform === "win32") { + // On Windows, should detect cmd, powershell, bash (WSL/Git Bash), or similar + expect(["cmd", "powershell", "pwsh", "bash", "zsh"].some((s) => detectedShell?.toLowerCase().includes(s))).toBe( + true, + ) + } else { + // On Unix-like systems, should detect bash, zsh, fish, sh, or similar + expect(["bash", "zsh", "fish", "sh", "nu"].some((s) => detectedShell === s)).toBe(true) + } + }) + // TODO: better test // test("cd ../ should ask for permission for external directory", async () => { // await Instance.provide({ From 21a3816ad07aa7fa9c750f5ebe4f62656e98d9a4 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sat, 29 Nov 2025 23:34:08 -0500 Subject: [PATCH 3/9] ... --- packages/opencode/src/tool/bash.ts | 13 ++- packages/opencode/src/tool/bash.txt | 6 +- packages/opencode/test/tool/bash.test.ts | 114 +++++++++++++++++++++-- 3 files changed, 122 insertions(+), 11 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index 6b9035a1cf8..c6ca0dab718 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -90,7 +90,13 @@ export const BashTool = Tool.define("bash", async () => { return process.platform === "win32" ? "cmd" : "bash" } if (typeof shell === "string") { - const name = path.basename(shell) + let name = path.basename(shell) + // Handle Windows paths (both forward and back slashes) + if (shell.includes("\\") || shell.includes("/")) { + // Extract the last part after both types of separators + const parts = shell.split(/[\\/]/) + name = parts[parts.length - 1] + } // Handle Windows executables if (name.toLowerCase().endsWith(".exe")) { return name.slice(0, -4) @@ -104,7 +110,10 @@ export const BashTool = Tool.define("bash", async () => { const description = `**Shell**: You are executing commands in \`${shellName}\`. Ensure your command syntax is compatible with this shell. -${DESCRIPTION}` +${DESCRIPTION.replace(/\$\{shellName\} command/g, `${shellName} command`).replace( + /\$\{shellName\} commands/g, + `${shellName} commands`, +)}` return { description, diff --git a/packages/opencode/src/tool/bash.txt b/packages/opencode/src/tool/bash.txt index 0a4d9f16de1..9e308dd73eb 100644 --- a/packages/opencode/src/tool/bash.txt +++ b/packages/opencode/src/tool/bash.txt @@ -1,4 +1,4 @@ -Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures. +Executes a given ${shellName} command in a persistent shell session with optional timeout, ensuring proper handling and security measures. Before executing the command, please follow these steps: @@ -37,7 +37,7 @@ Usage notes: If and only if the user asks you to create a new git commit, follow these steps carefully: -1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following bash commands in parallel, each using the Bash tool: +1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following ${shellName} commands in parallel, each using the Bash tool: - Run a git status command to see all untracked files. - Run a git diff command to see both staged and unstaged changes that will be committed. - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style. @@ -78,7 +78,7 @@ Use the gh command via the Bash tool for ALL GitHub-related tasks including work IMPORTANT: When the user asks you to create a pull request, follow these steps carefully: -1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch: +1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following ${shellName} commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch: - Run a git status command to see all untracked files - Run a git diff command to see both staged and unstaged changes that will be committed - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index d591f4fa0bd..99171a57a26 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -53,13 +53,115 @@ describe("tool.bash", () => { // Verify detected shell is appropriate for the platform if (process.platform === "win32") { - // On Windows, should detect cmd, powershell, bash (WSL/Git Bash), or similar - expect(["cmd", "powershell", "pwsh", "bash", "zsh"].some((s) => detectedShell?.toLowerCase().includes(s))).toBe( - true, - ) + expect(["cmd", "powershell"]).toContain(detectedShell!) } else { - // On Unix-like systems, should detect bash, zsh, fish, sh, or similar - expect(["bash", "zsh", "fish", "sh", "nu"].some((s) => detectedShell === s)).toBe(true) + expect(["bash", "zsh", "fish", "ksh", "csh", "tcsh", "dash"]).toContain(detectedShell!) + } + }) + + test("description uses dynamic shell-specific language", async () => { + const bash = await BashTool.init() + const shellMatch = bash.description.match(/You are executing commands in `([^`]+)`/) + const detectedShell = shellMatch?.[1] + + expect(detectedShell).toBeTruthy() + + // Should contain shell-specific command references + if (detectedShell) { + expect(bash.description).toContain(`${detectedShell} command`) + expect(bash.description).toContain(`${detectedShell} commands`) + } + + // Should NOT contain generic "bash command" references + expect(bash.description).not.toContain("bash command") + expect(bash.description).not.toContain("bash commands") + + // Should still contain "Bash tool" references (tool name) + expect(bash.description).toContain("Bash tool") + }) + + test("shell-specific language works for different shell types", async () => { + // Test with fish shell (current environment) + const originalShell = process.env.SHELL + + try { + // Mock fish shell environment + process.env.SHELL = "/opt/homebrew/bin/fish" + const bashFish = await BashTool.init() + expect(bashFish.description).toContain("fish command") + expect(bashFish.description).toContain("fish commands") + + // Mock zsh shell environment + process.env.SHELL = "/bin/zsh" + const bashZsh = await BashTool.init() + expect(bashZsh.description).toContain("zsh command") + expect(bashZsh.description).toContain("zsh commands") + + // Mock bash shell environment + process.env.SHELL = "/bin/bash" + const bashBash = await BashTool.init() + expect(bashBash.description).toContain("bash command") + expect(bashBash.description).toContain("bash commands") + } finally { + // Restore original shell + if (originalShell) { + process.env.SHELL = originalShell + } else { + delete process.env.SHELL + } + } + }) + + test("description uses dynamic shell-specific language", async () => { + const bash = await BashTool.init() + const shellMatch = bash.description.match(/You are executing commands in `([^`]+)`/) + const detectedShell = shellMatch?.[1] + + expect(detectedShell).toBeTruthy() + + // Should contain shell-specific command references + if (detectedShell) { + expect(bash.description).toContain(`${detectedShell} command`) + expect(bash.description).toContain(`${detectedShell} commands`) + } + + // Should NOT contain generic "bash command" references + expect(bash.description).not.toContain("bash command") + expect(bash.description).not.toContain("bash commands") + + // Should still contain "Bash tool" references (tool name) + expect(bash.description).toContain("Bash tool") + }) + + test("shell-specific language works for different shell types", async () => { + // Test with fish shell (current environment) + const originalShell = process.env.SHELL + + try { + // Mock fish shell environment + process.env.SHELL = "/opt/homebrew/bin/fish" + const bashFish = await BashTool.init() + expect(bashFish.description).toContain("fish command") + expect(bashFish.description).toContain("fish commands") + + // Mock zsh shell environment + process.env.SHELL = "/bin/zsh" + const bashZsh = await BashTool.init() + expect(bashZsh.description).toContain("zsh command") + expect(bashZsh.description).toContain("zsh commands") + + // Mock bash shell environment + process.env.SHELL = "/bin/bash" + const bashBash = await BashTool.init() + expect(bashBash.description).toContain("bash command") + expect(bashBash.description).toContain("bash commands") + } finally { + // Restore original shell + if (originalShell) { + process.env.SHELL = originalShell + } else { + delete process.env.SHELL + } } }) From a7f6cc91dba2a2d43fd5516fc792162acd23b8f3 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sun, 30 Nov 2025 00:11:56 -0500 Subject: [PATCH 4/9] fix: revise Bash tool test to account for the changes. --- packages/opencode/test/tool/bash.test.ts | 33 ++++++------------------ 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index 99171a57a26..9420020028a 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -2,7 +2,6 @@ import { describe, expect, test } from "bun:test" import path from "path" import { BashTool } from "../../src/tool/bash" import { Instance } from "../../src/project/instance" -import { Permission } from "../../src/permission" const ctx = { sessionID: "test", @@ -72,9 +71,14 @@ describe("tool.bash", () => { expect(bash.description).toContain(`${detectedShell} commands`) } - // Should NOT contain generic "bash command" references - expect(bash.description).not.toContain("bash command") - expect(bash.description).not.toContain("bash commands") + // Should NOT contain references to other shells (shell-agnostic validation) + const commonShells = ["bash", "zsh", "fish", "ksh", "csh", "tcsh", "dash", "cmd", "powershell"] + for (const otherShell of commonShells) { + if (otherShell !== detectedShell) { + expect(bash.description).not.toContain(`${otherShell} command`) + expect(bash.description).not.toContain(`${otherShell} commands`) + } + } // Should still contain "Bash tool" references (tool name) expect(bash.description).toContain("Bash tool") @@ -112,27 +116,6 @@ describe("tool.bash", () => { } }) - test("description uses dynamic shell-specific language", async () => { - const bash = await BashTool.init() - const shellMatch = bash.description.match(/You are executing commands in `([^`]+)`/) - const detectedShell = shellMatch?.[1] - - expect(detectedShell).toBeTruthy() - - // Should contain shell-specific command references - if (detectedShell) { - expect(bash.description).toContain(`${detectedShell} command`) - expect(bash.description).toContain(`${detectedShell} commands`) - } - - // Should NOT contain generic "bash command" references - expect(bash.description).not.toContain("bash command") - expect(bash.description).not.toContain("bash commands") - - // Should still contain "Bash tool" references (tool name) - expect(bash.description).toContain("Bash tool") - }) - test("shell-specific language works for different shell types", async () => { // Test with fish shell (current environment) const originalShell = process.env.SHELL From 92c5e6916c7862c991bef7f7fc239f370e65f02d Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 1 Dec 2025 12:00:37 +0000 Subject: [PATCH 5/9] chore: format code --- packages/plugin/package.json | 2 +- packages/sdk/js/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 21ef2a74407..7248787e88e 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -24,4 +24,4 @@ "typescript": "catalog:", "@typescript/native-preview": "catalog:" } -} \ No newline at end of file +} diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json index 9d3de8bb100..651f061ae07 100644 --- a/packages/sdk/js/package.json +++ b/packages/sdk/js/package.json @@ -26,4 +26,4 @@ "publishConfig": { "directory": "dist" } -} \ No newline at end of file +} From 4c93e6804c4e74ccbda815c5b01151a49176346e Mon Sep 17 00:00:00 2001 From: Github Action Date: Mon, 1 Dec 2025 12:01:55 +0000 Subject: [PATCH 6/9] Update Nix flake.lock and hashes --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 3a6b887186d..05e9e841d76 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1764527385, - "narHash": "sha256-nA5ywiGKl76atrbdZ5Aucd8SjF/v8ew9b9QsC+MKL14=", + "lastModified": 1764557259, + "narHash": "sha256-fhD/QUtJ0HKs3oLvfnD+/SrBV5Y7YEkCYnDjOVUjLys=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "23258e03aaa49b3a68597e3e50eb0cbce7e42e9d", + "rev": "0d70460758949966e91d9ecb823b821f963cefbb", "type": "github" }, "original": { From 67539879fb710977b45ed2c5bac7bf60ff695c73 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sat, 13 Dec 2025 16:14:44 -0500 Subject: [PATCH 7/9] feat: enable fish and nu shell support in Bash tool Remove the fish/nu blacklist so commands execute in the user's actual shell. Previously, fish and nu were blacklisted and commands would fall back to zsh/bash, causing the tool description to incorrectly report the shell being used. Changes: - Remove fish/nu blacklist from bash.ts shell detection - Remove unused BLACKLIST constant and Shell.acceptable() from shell.ts - Add fish shell test case to bash.test.ts Resolves #4866 --- packages/opencode/src/shell/shell.ts | 7 ------- packages/opencode/src/tool/bash.ts | 13 ++----------- packages/opencode/test/tool/bash.test.ts | 6 ++++++ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/opencode/src/shell/shell.ts b/packages/opencode/src/shell/shell.ts index 2e8d48bfd92..9c7c163f4b8 100644 --- a/packages/opencode/src/shell/shell.ts +++ b/packages/opencode/src/shell/shell.ts @@ -33,7 +33,6 @@ export namespace Shell { } } } - const BLACKLIST = new Set(["fish", "nu"]) function fallback() { if (process.platform === "win32") { @@ -58,10 +57,4 @@ export namespace Shell { if (s) return s return fallback() }) - - export const acceptable = lazy(() => { - const s = process.env.SHELL - if (s && !BLACKLIST.has(process.platform === "win32" ? path.win32.basename(s) : path.basename(s))) return s - return fallback() - }) } diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index bfefe00aa15..538087d0049 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -55,27 +55,18 @@ const parser = lazy(async () => { export const BashTool = Tool.define("bash", async () => { const shell = (() => { const s = process.env.SHELL - if (s) { - const basename = path.basename(s) - if (!new Set(["fish", "nu"]).has(basename)) { - return s - } - } + if (s) return s if (process.platform === "darwin") { return "/bin/zsh" } if (process.platform === "win32") { - // Let Bun / Node pick COMSPEC (usually cmd.exe) - // or explicitly: return process.env.COMSPEC || true } const bash = Bun.which("bash") - if (bash) { - return bash - } + if (bash) return bash return true })() diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index b0ad2584e7a..b3761f58c09 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -126,6 +126,12 @@ describe("tool.bash", () => { const bashKsh = await BashTool.init() expect(bashKsh.description).toContain("ksh command") expect(bashKsh.description).toContain("ksh commands") + + // Mock fish shell environment (fish is now supported, not blacklisted) + process.env.SHELL = "/usr/bin/fish" + const bashFish = await BashTool.init() + expect(bashFish.description).toContain("fish command") + expect(bashFish.description).toContain("fish commands") } finally { // Restore original shell if (originalShell) { From 0ece1f75ee315fa39f01df42d3c84770d40572d2 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sat, 13 Dec 2025 16:18:52 -0500 Subject: [PATCH 8/9] tidy: remove TODO. --- packages/opencode/test/tool/bash.test.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index b3761f58c09..96d955f1740 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -143,25 +143,6 @@ describe("tool.bash", () => { }, }) }) - - // TODO: better test - // test("cd ../ should ask for permission for external directory", async () => { - // await Instance.provide({ - // directory: projectRoot, - // fn: async () => { - // bash.execute( - // { - // command: "cd ../", - // description: "Try to cd to parent directory", - // }, - // ctx, - // ) - // // Give time for permission to be asked - // await new Promise((resolve) => setTimeout(resolve, 1000)) - // expect(Permission.pending()[ctx.sessionID]).toBeDefined() - // }, - // }) - // }) }) describe("tool.bash permissions", () => { From 6587035322b49e9fcbea6ab706e514fc6ff27a92 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sat, 27 Dec 2025 19:09:47 -0500 Subject: [PATCH 9/9] fix: minimize bash.txt changes to only essential shell name substitutions --- packages/opencode/src/tool/bash.txt | 31 +++++++++--------------- packages/opencode/test/tool/bash.test.ts | 9 ------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/packages/opencode/src/tool/bash.txt b/packages/opencode/src/tool/bash.txt index 5ebdc97a8df..f2d0b97160a 100644 --- a/packages/opencode/src/tool/bash.txt +++ b/packages/opencode/src/tool/bash.txt @@ -64,25 +64,16 @@ Git Safety Protocol: - CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push) - NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive. -1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following ${shellName} commands in parallel, each using the Bash tool: - - Run a git status command to see all untracked files. - - Run a git diff command to see both staged and unstaged changes that will be committed. - - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style. - -2. Analyze all staged changes (both previously staged and newly added) and draft a commit message. When analyzing: - -- List the files that have been changed or added -- Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.) -- Brainstorm the purpose or motivation behind these changes -- Assess the impact of these changes on the overall project -- Check for any sensitive information that shouldn't be committed -- Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what" -- Ensure your language is clear, concise, and to the point -- Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.) -- Ensure the message is not generic (avoid words like "Update" or "Fix" without context) -- Review the draft message to ensure it accurately reflects the changes and their purpose - -3. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following commands in parallel: +1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${shellName} commands in parallel, each using the Bash tool: + - Run a git status command to see all untracked files. + - Run a git diff command to see both staged and unstaged changes that will be committed. + - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style. +2. Analyze all staged changes (both previously staged and newly added) and draft a commit message: + - Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.). + - Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files + - Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what" + - Ensure it accurately reflects the changes and their purpose +3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands: - Add relevant untracked files to the staging area. - Create the commit with a message - Run git status after the commit completes to verify success. @@ -101,7 +92,7 @@ Use the gh command via the Bash tool for ALL GitHub-related tasks including work IMPORTANT: When the user asks you to create a pull request, follow these steps carefully: -1. You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. ALWAYS run the following ${shellName} commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch: +1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following ${shellName} commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch: - Run a git status command to see all untracked files - Run a git diff command to see both staged and unstaged changes that will be committed - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts index 96d955f1740..6697e3b0dcb 100644 --- a/packages/opencode/test/tool/bash.test.ts +++ b/packages/opencode/test/tool/bash.test.ts @@ -86,15 +86,6 @@ describe("tool.bash", () => { expect(bash.description).toContain(`${detectedShell} commands`) } - // Should NOT contain references to other shells (shell-agnostic validation) - const commonShells = ["bash", "zsh", "fish", "ksh", "csh", "tcsh", "dash", "cmd", "powershell"] - for (const otherShell of commonShells) { - if (otherShell !== detectedShell) { - expect(bash.description).not.toContain(`${otherShell} command`) - expect(bash.description).not.toContain(`${otherShell} commands`) - } - } - // Should still contain "Bash tool" references (tool name) expect(bash.description).toContain("Bash tool") },