Repository navigation
Description
Description
The shell tool is published to models under the id bash, but it does not run bash — it runs whatever shell the host provides. The name misdescribes the tool on every non-bash host, and the tool's own description text repeats the wrong name to the model even when it has just told the model the host runs PowerShell or cmd.exe.
Verified at commit 897e85177c03b0dfb8618e1f3cf09250a9cbebe6.
1. The public id is hardcoded to bash, with the rename already deferred once.
packages/opencode/src/tool/shell/id.ts:
// Keep the exposed tool ID and permission key as "bash" for compatibility with
// existing plugins, users, and saved permissions. Rename with opencode 2.0.
export const ToolID = "bash"The file is named shell.ts, the tool namespace is ShellTool, the prompt module is ShellPrompt — only the public id still says bash. That id is what the model sees in the tool catalog, and it is also the permission action (packages/opencode/src/tool/shell.ts:287, permission: ShellID.ToolID).
2. The tool genuinely runs a non-bash shell on most hosts.
packages/core/src/shell.ts resolves the interpreter from config (Shell.acceptable(cfg.shell), used at packages/opencode/src/tool/shell.ts:706) and otherwise falls back:
function fallback() {
if (process.platform === "darwin") return "/bin/zsh"
const bash = which("bash")
if (bash) return bash
return "/bin/sh"
}Its META table enumerates bash, dash, fish, ksh, nu, powershell, pwsh, sh, zsh, and Windows resolves through win(). So the default macOS interpreter is zsh, not bash, and on Windows it is PowerShell or cmd.exe.
3. The description sent to the model names the wrong tool, including on hosts it just described as non-POSIX.
packages/opencode/src/tool/shell/prompt.ts builds the description. chainGuidance() returns, for pwsh:
Chain dependent commands in a single bash tool call with '&&'.
and for cmd:
Chain dependent commands in a single bash tool call with `&&`.
bashCommandSection(), powershellCommandSection() and cmdCommandSection() each end with Independent commands: make multiple bash tool calls in one message. — so the PowerShell and cmd.exe sections instruct the model to make "bash tool calls". The POSIX profile() intro says Executes a given bash command in a persistent shell session, which is wrong when the resolved interpreter is zsh, sh, dash or fish.
This is self-contradictory within one description: shellAdaptationSection() opens with This host runs PowerShell (7+), not a POSIX shell, and the section immediately above it tells the model to make "bash tool calls".
Actual ShellPrompt.render(...) output, filtered to lines mentioning bash:
##### pwsh / win32 #####
- Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single bash tool call with '&&'. ...
##### cmd / win32 #####
- Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single bash tool call with `&&`. ...
##### zsh / darwin #####
Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
- Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single Bash call with '&&' ...
The zsh case is the clearest: the same description that reports OS: darwin, Shell: zsh opens by claiming it executes "a given bash command".
4. The V2 core tool has the same mismatch.
packages/core/src/tool/bash.ts:20 is export const name = "bash", while its own registered description says Execute one shell command string ... Uses the configured shell when set; otherwise uses /bin/sh on POSIX and COMSPEC or cmd.exe on Windows. Neither default is bash. Its external-directory advisory likewise tells the model Bash runs with host-user filesystem, process, and network authority.
5. The tool catalog carries a stale duplicate as a result.
packages/opencode/src/tool/catalog.ts:135-140 lists both names in CORE_TOOLS:
export const CORE_TOOLS = [
"invalid",
"tool_search",
"tool_search_regex",
"shell",
"bash",No builtin registers shell today — ShellTool registers under ShellID.ToolID, i.e. bash — so the "shell" entry matches nothing and "bash" is the only live one. The pair is a standing invitation to get the id wrong in either direction.
Why this matters beyond cosmetics. The id is the permission action, so "permission": { "bash": ... } in user config is the only spelling that works, and Permission.disabled() hides the tool only when a rule matches that literal. A user on Windows PowerShell has to write bash in their config to gate a tool that runs pwsh. Several renderers already accept both spellings defensively (packages/opencode/src/acp/tool.ts:296 returns tool === "bash" || tool === "shell"), which shows the ambiguity has already leaked into consumers.
Constraint on any fix. bash is load-bearing for existing users, so it cannot simply be swapped: permission.bash allow/deny rules (including per-pattern rules like "git *": "allow" and wildcards like "*"), saved permission grants, and persisted session history whose tool parts say tool: "bash" all have to keep working. Rules are matched with Wildcard.match(permission, rule.permission) and resolved with findLast, so a rename that made legacy bash rules stop matching would silently turn a configured deny into the default ask — a permission broadening, not a no-op. Legacy history also has to keep rendering and replaying from stored output rather than re-executing.
Two unrelated upstream/host contracts must not be renamed as part of this: ZEN_FINGERPRINT_TOOLS in packages/opencode/src/provider/opencode-zen.ts:77 is an opencode-zen free-tier wire requirement ({bash, glob, grep, read}; the comment records that requests with fake names get 403 FreeTierError), and the bash shell kind in ShellID.kinds, the tree-sitter bash grammar, bash-language-server, and Shell.args()/Shell.name() interpreter handling all refer to the real bash program.
Plugins
None. Observed in the repository source itself.
OpenCode version
Source checkout at commit 897e85177c03b0dfb8618e1f3cf09250a9cbebe6 (not a packaged release).
Steps to reproduce
- Read
packages/opencode/src/tool/shell/id.ts— the exposedToolIDis"bash". - On macOS, run the tool with no
shellconfigured;fallback()inpackages/core/src/shell.tsreturns/bin/zsh. - Render the tool description for a PowerShell host via
ShellPrompt.render("pwsh", "win32", ...)and observeChain dependent commands in a single bash tool call with '&&'.alongsideThis host runs PowerShell (7+), not a POSIX shell. - Read
packages/opencode/src/tool/catalog.ts:135—CORE_TOOLSlists both"shell"and"bash".
Screenshot and/or share link
Not applicable — this is a source-level naming/contract defect, not a rendering bug.
Operating System
Linux (source inspection; the defect is platform-independent and the description text is wrong on macOS, Linux, and Windows)
Terminal
Not applicable
Activity
wip(tool): shell rename across ACP/CLI/TUI/prompts/generated contract…
test(tool): #780 rename coverage — legacy permission alias, catalog, …
style(tui): drop formatter churn from session/activity files (Refs #780)
merge: integrate accepted dev-vibecoded 50d6a23 (#785) into shell ren…
fix(shell): preserve layer + rule precedence across the bash/shell re…
test(permission): type the doom_loop ruleset as PermissionV1.Ruleset …
test(core): V1 permission migration now yields canonical shell action…
fix(permission): make bash/shell action aliasing symmetric (Refs #780)
docs(assets): shell permission + fmt TUI evidence for #780 review
fix(permission): preserve actual rule order and pre-rename wildcard m…
test(workspace): await the error status event instead of polling a tr…
fix(permission): union matching with a narrow rename-recruitment deny…
test(workspace): keep the 1500ms bound, observe the error transition …
fix(config): restore base deep-merge contract, narrow rename ordering…
test(zen): end-to-end fake-gateway contract for the published shell c…
test(config): update/updateGlobal roundtrips and config-level doom_lo…
fix(config): preserve inherited shell deny across rename