Apply PR #20039: feat: bash->shell tool + pwsh/powershell/cmd/bash specific tool definitions so agents work better

This commit is contained in:
opencode-agent[bot] 2026-04-27 20:46:10 +00:00
commit af8ea50ab2
60 changed files with 885 additions and 347 deletions

View file

@ -271,6 +271,8 @@ export type ToolInfo = {
subtitle?: string
}
const SHELL = new Set(["shell", "bash"])
function agentTitle(i18n: UiI18n, type?: string) {
if (!type) return i18n.t("ui.tool.agent.default")
return i18n.t("ui.tool.agent", { type })
@ -319,6 +321,14 @@ function taskAgent(
export function getToolInfo(tool: string, input: any = {}): ToolInfo {
const i18n = useI18n()
if (SHELL.has(tool)) {
return {
icon: "console",
title: i18n.t("ui.tool.shell"),
subtitle: input.description,
}
}
switch (tool) {
case "read":
return {
@ -373,12 +383,6 @@ export function getToolInfo(tool: string, input: any = {}): ToolInfo {
subtitle: input.description,
}
}
case "bash":
return {
icon: "console",
title: i18n.t("ui.tool.shell"),
subtitle: input.description,
}
case "edit":
return {
icon: "code-lines",
@ -582,7 +586,7 @@ function renderable(part: PartType, showReasoningSummaries = true) {
}
function toolDefaultOpen(tool: string, shell = false, edit = false) {
if (tool === "bash") return shell
if (SHELL.has(tool)) return shell
if (tool === "edit" || tool === "write" || tool === "apply_patch") return edit
}
@ -1254,6 +1258,7 @@ export function registerTool(input: { name: string; render?: ToolComponent }) {
}
export function getTool(name: string) {
if (name === "bash") return state.shell?.render
return state[name]?.render
}
@ -1818,7 +1823,7 @@ ToolRegistry.register({
})
ToolRegistry.register({
name: "bash",
name: "shell",
render(props) {
const i18n = useI18n()
const pending = () => props.status === "pending" || props.status === "running"

View file

@ -16,7 +16,7 @@ Interactive playground for animating the Shell tool subtitle ("submessage") in t
### Production component path
- Trigger layout: \`packages/ui/src/components/basic-tool.tsx\`
- Bash tool subtitle source: \`packages/ui/src/components/message-part.tsx\` (tool: \`bash\`, \`trigger.subtitle\`)
- Shell tool subtitle source: \`packages/ui/src/components/message-part.tsx\` (tool: \`shell\`, \`trigger.subtitle\`)
### What this playground tunes
- Width reveal (spring-driven pixel width via \`useSpring\`)

View file

@ -314,8 +314,8 @@ const TOOL_SAMPLES = {
title: "Found 2 matches",
metadata: {},
},
bash: {
tool: "bash",
shell: {
tool: "shell",
input: { command: "bun test --filter session", description: "Run session tests" },
output:
"bun test v1.3.13\n\n✓ session-turn.test.tsx (3 tests) 45ms\n✓ message-part.test.tsx (7 tests) 120ms\n\nTest Suites: 2 passed, 2 total\nTests: 10 passed, 10 total\nTime: 0.89s",
@ -1333,7 +1333,7 @@ function Playground() {
toolPart(TOOL_SAMPLES.glob),
toolPart(TOOL_SAMPLES.grep),
toolPart(TOOL_SAMPLES.edit),
toolPart(TOOL_SAMPLES.bash),
toolPart(TOOL_SAMPLES.shell),
textPart(MARKDOWN_SAMPLES.mixed),
])
}
@ -1356,7 +1356,7 @@ function Playground() {
toolPart(TOOL_SAMPLES.glob),
toolPart(TOOL_SAMPLES.grep),
toolPart(TOOL_SAMPLES.edit),
toolPart(TOOL_SAMPLES.bash),
toolPart(TOOL_SAMPLES.shell),
textPart(MARKDOWN_SAMPLES.blockquote),
])
addContextGroupTurn()

View file

@ -5,7 +5,7 @@ const docs = `### Overview
Tool call failure summary styled like a tool trigger.
### API
- Required: \`tool\` (tool id, e.g. apply_patch, bash)
- Required: \`tool\` (tool id, e.g. apply_patch, shell)
- Required: \`error\` (error string)
### Behavior
@ -19,8 +19,8 @@ const samples = [
"apply_patch verification failed: Failed to find expected lines in /Users/davidhill/Documents/Local/opencode/packages/ui/src/components/session-turn.tsx",
},
{
tool: "bash",
error: "bash Command failed: exit code 1: bun test --watch",
tool: "shell",
error: "shell Command failed: exit code 1: bun test --watch",
},
{
tool: "read",
@ -72,7 +72,7 @@ export default {
argTypes: {
tool: {
control: "select",
options: ["apply_patch", "bash", "read", "glob", "grep", "webfetch", "websearch", "codesearch", "question"],
options: ["apply_patch", "shell", "read", "glob", "grep", "webfetch", "websearch", "codesearch", "question"],
},
error: {
control: "text",

View file

@ -35,6 +35,7 @@ export function ToolErrorCard(props: ToolErrorCardProps) {
websearch: "ui.tool.websearch",
codesearch: "ui.tool.codesearch",
bash: "ui.tool.shell",
shell: "ui.tool.shell",
apply_patch: "ui.tool.patch",
question: "ui.tool.questions",
}