remove opencode_ prefixes from tool names. unfortunately this will break
publish / publish (push) Has been cancelled

all old sessions and share links. we'll be more backwards compatible in
the future once we're more stable.
This commit is contained in:
Dax Raad
2025-06-19 09:59:12 -04:00
parent 8c6e559179
commit b7319a304f
18 changed files with 59 additions and 59 deletions
+9 -9
View File
@@ -11,15 +11,15 @@ import { Flag } from "../../flag/flag"
import { Config } from "../../config/config" import { Config } from "../../config/config"
const TOOL: Record<string, [string, string]> = { const TOOL: Record<string, [string, string]> = {
opencode_todowrite: ["Todo", UI.Style.TEXT_WARNING_BOLD], todowrite: ["Todo", UI.Style.TEXT_WARNING_BOLD],
opencode_todoread: ["Todo", UI.Style.TEXT_WARNING_BOLD], todoread: ["Todo", UI.Style.TEXT_WARNING_BOLD],
opencode_bash: ["Bash", UI.Style.TEXT_DANGER_BOLD], bash: ["Bash", UI.Style.TEXT_DANGER_BOLD],
opencode_edit: ["Edit", UI.Style.TEXT_SUCCESS_BOLD], edit: ["Edit", UI.Style.TEXT_SUCCESS_BOLD],
opencode_glob: ["Glob", UI.Style.TEXT_INFO_BOLD], glob: ["Glob", UI.Style.TEXT_INFO_BOLD],
opencode_grep: ["Grep", UI.Style.TEXT_INFO_BOLD], grep: ["Grep", UI.Style.TEXT_INFO_BOLD],
opencode_list: ["List", UI.Style.TEXT_INFO_BOLD], list: ["List", UI.Style.TEXT_INFO_BOLD],
opencode_read: ["Read", UI.Style.TEXT_HIGHLIGHT_BOLD], read: ["Read", UI.Style.TEXT_HIGHLIGHT_BOLD],
opencode_write: ["Write", UI.Style.TEXT_SUCCESS_BOLD], write: ["Write", UI.Style.TEXT_SUCCESS_BOLD],
} }
export const RunCommand = cmd({ export const RunCommand = cmd({
+2 -2
View File
@@ -274,7 +274,7 @@ export namespace Provider {
const cfg = await Config.get() const cfg = await Config.get()
const provider = await list() const provider = await list()
.then((val) => Object.values(val)) .then((val) => Object.values(val))
.then((x) => x.find((p) => !cfg.provider || cfg.provider === p.info.id)) .then((x) => x.find((p) => !cfg.provider || Object.keys(cfg.provider).includes(p.info.id)))
if (!provider) throw new Error("no providers found") if (!provider) throw new Error("no providers found")
const [model] = sort(Object.values(provider.info.models)) const [model] = sort(Object.values(provider.info.models))
if (!model) throw new Error("no models found") if (!model) throw new Error("no models found")
@@ -304,7 +304,7 @@ export namespace Provider {
] ]
const TOOL_MAPPING: Record<string, Tool.Info[]> = { const TOOL_MAPPING: Record<string, Tool.Info[]> = {
anthropic: TOOLS.filter((t) => t.id !== "opencode.patch"), anthropic: TOOLS.filter((t) => t.id !== "patch"),
openai: TOOLS.map((t) => ({ openai: TOOLS.map((t) => ({
...t, ...t,
parameters: optionalToNullable(t.parameters), parameters: optionalToNullable(t.parameters),
+1 -1
View File
@@ -26,7 +26,7 @@ const DEFAULT_TIMEOUT = 1 * 60 * 1000
const MAX_TIMEOUT = 10 * 60 * 1000 const MAX_TIMEOUT = 10 * 60 * 1000
export const BashTool = Tool.define({ export const BashTool = Tool.define({
id: "opencode.bash", id: "bash",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
command: z.string().describe("The command to execute"), command: z.string().describe("The command to execute"),
+2 -2
View File
@@ -9,7 +9,7 @@ import DESCRIPTION from "./edit.txt"
import { App } from "../app/app" import { App } from "../app/app"
export const EditTool = Tool.define({ export const EditTool = Tool.define({
id: "opencode.edit", id: "edit",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
filePath: z.string().describe("The absolute path to the file to modify"), filePath: z.string().describe("The absolute path to the file to modify"),
@@ -35,7 +35,7 @@ export const EditTool = Tool.define({
: path.join(app.path.cwd, params.filePath) : path.join(app.path.cwd, params.filePath)
await Permission.ask({ await Permission.ask({
id: "opencode.edit", id: "edit",
sessionID: ctx.sessionID, sessionID: ctx.sessionID,
title: "Edit this file: " + filepath, title: "Edit this file: " + filepath,
metadata: { metadata: {
+1 -1
View File
@@ -5,7 +5,7 @@ import { App } from "../app/app"
import DESCRIPTION from "./glob.txt" import DESCRIPTION from "./glob.txt"
export const GlobTool = Tool.define({ export const GlobTool = Tool.define({
id: "opencode.glob", id: "glob",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
pattern: z.string().describe("The glob pattern to match files against"), pattern: z.string().describe("The glob pattern to match files against"),
+1 -1
View File
@@ -6,7 +6,7 @@ import { Ripgrep } from "../external/ripgrep"
import DESCRIPTION from "./grep.txt" import DESCRIPTION from "./grep.txt"
export const GrepTool = Tool.define({ export const GrepTool = Tool.define({
id: "opencode.grep", id: "grep",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
pattern: z pattern: z
+1 -1
View File
@@ -21,7 +21,7 @@ export const IGNORE_PATTERNS = [
const LIMIT = 100 const LIMIT = 100
export const ListTool = Tool.define({ export const ListTool = Tool.define({
id: "opencode.list", id: "list",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
path: z path: z
@@ -6,7 +6,7 @@ import { App } from "../app/app"
import DESCRIPTION from "./lsp-diagnostics.txt" import DESCRIPTION from "./lsp-diagnostics.txt"
export const LspDiagnosticTool = Tool.define({ export const LspDiagnosticTool = Tool.define({
id: "opencode.lsp_diagnostics", id: "lsp_diagnostics",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
path: z.string().describe("The path to the file to get diagnostics."), path: z.string().describe("The path to the file to get diagnostics."),
+1 -1
View File
@@ -6,7 +6,7 @@ import { App } from "../app/app"
import DESCRIPTION from "./lsp-hover.txt" import DESCRIPTION from "./lsp-hover.txt"
export const LspHoverTool = Tool.define({ export const LspHoverTool = Tool.define({
id: "opencode.lsp_hover", id: "lsp_hover",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
file: z.string().describe("The path to the file to get diagnostics."), file: z.string().describe("The path to the file to get diagnostics."),
+1 -1
View File
@@ -6,7 +6,7 @@ import path from "path"
import { App } from "../app/app" import { App } from "../app/app"
export const MultiEditTool = Tool.define({ export const MultiEditTool = Tool.define({
id: "opencode.multiedit", id: "multiedit",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
filePath: z.string().describe("The absolute path to the file to modify"), filePath: z.string().describe("The absolute path to the file to modify"),
+1 -1
View File
@@ -232,7 +232,7 @@ async function applyCommit(
} }
export const PatchTool = Tool.define({ export const PatchTool = Tool.define({
id: "opencode.patch", id: "patch",
description: DESCRIPTION, description: DESCRIPTION,
parameters: PatchParams, parameters: PatchParams,
execute: async (params, ctx) => { execute: async (params, ctx) => {
+1 -1
View File
@@ -12,7 +12,7 @@ const DEFAULT_READ_LIMIT = 2000
const MAX_LINE_LENGTH = 2000 const MAX_LINE_LENGTH = 2000
export const ReadTool = Tool.define({ export const ReadTool = Tool.define({
id: "opencode.read", id: "read",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
filePath: z.string().describe("The path to the file to read"), filePath: z.string().describe("The path to the file to read"),
+1 -1
View File
@@ -6,7 +6,7 @@ import { Bus } from "../bus"
import { Message } from "../session/message" import { Message } from "../session/message"
export const TaskTool = Tool.define({ export const TaskTool = Tool.define({
id: "opencode.task", id: "task",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
description: z description: z
+2 -2
View File
@@ -23,7 +23,7 @@ const state = App.state("todo-tool", () => {
}) })
export const TodoWriteTool = Tool.define({ export const TodoWriteTool = Tool.define({
id: "opencode.todowrite", id: "todowrite",
description: DESCRIPTION_WRITE, description: DESCRIPTION_WRITE,
parameters: z.object({ parameters: z.object({
todos: z.array(TodoInfo).describe("The updated todo list"), todos: z.array(TodoInfo).describe("The updated todo list"),
@@ -42,7 +42,7 @@ export const TodoWriteTool = Tool.define({
}) })
export const TodoReadTool = Tool.define({ export const TodoReadTool = Tool.define({
id: "opencode.todoread", id: "todoread",
description: "Use this tool to read your todo list", description: "Use this tool to read your todo list",
parameters: z.object({}), parameters: z.object({}),
async execute(_params, opts) { async execute(_params, opts) {
+1 -1
View File
@@ -8,7 +8,7 @@ const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
const MAX_TIMEOUT = 120 * 1000 // 2 minutes const MAX_TIMEOUT = 120 * 1000 // 2 minutes
export const WebFetchTool = Tool.define({ export const WebFetchTool = Tool.define({
id: "opencode.webfetch", id: "webfetch",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
url: z.string().describe("The URL to fetch content from"), url: z.string().describe("The URL to fetch content from"),
+2 -2
View File
@@ -8,7 +8,7 @@ import DESCRIPTION from "./write.txt"
import { App } from "../app/app" import { App } from "../app/app"
export const WriteTool = Tool.define({ export const WriteTool = Tool.define({
id: "opencode.write", id: "write",
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
filePath: z filePath: z
@@ -29,7 +29,7 @@ export const WriteTool = Tool.define({
if (exists) await FileTimes.assert(ctx.sessionID, filepath) if (exists) await FileTimes.assert(ctx.sessionID, filepath)
await Permission.ask({ await Permission.ask({
id: "opencode.write", id: "write",
sessionID: ctx.sessionID, sessionID: ctx.sessionID,
title: exists title: exists
? "Overwrite this file: " + filepath ? "Overwrite this file: " + filepath
@@ -253,7 +253,7 @@ func renderToolInvocation(
showDetails bool, showDetails bool,
isLast bool, isLast bool,
) string { ) string {
ignoredTools := []string{"opencode_todoread"} ignoredTools := []string{"todoread"}
if slices.Contains(ignoredTools, toolCall.ToolName) { if slices.Contains(ignoredTools, toolCall.ToolName) {
return "" return ""
} }
@@ -350,7 +350,7 @@ func renderToolInvocation(
title := "" title := ""
switch toolCall.ToolName { switch toolCall.ToolName {
case "opencode_read": case "read":
toolArgs = renderArgs(&toolArgsMap, "filePath") toolArgs = renderArgs(&toolArgsMap, "filePath")
title = fmt.Sprintf("READ %s %s", toolArgs, elapsed) title = fmt.Sprintf("READ %s %s", toolArgs, elapsed)
if preview, ok := metadata.Get("preview"); ok && toolArgsMap["filePath"] != nil { if preview, ok := metadata.Get("preview"); ok && toolArgsMap["filePath"] != nil {
@@ -358,7 +358,7 @@ func renderToolInvocation(
body = preview.(string) body = preview.(string)
body = renderFile(filename, body, WithTruncate(6)) body = renderFile(filename, body, WithTruncate(6))
} }
case "opencode_edit": case "edit":
if filename, ok := toolArgsMap["filePath"].(string); ok { if filename, ok := toolArgsMap["filePath"].(string); ok {
title = fmt.Sprintf("EDIT %s %s", relative(filename), elapsed) title = fmt.Sprintf("EDIT %s %s", relative(filename), elapsed)
if d, ok := metadata.Get("diff"); ok { if d, ok := metadata.Get("diff"); ok {
@@ -399,14 +399,14 @@ func renderToolInvocation(
) )
} }
} }
case "opencode_write": case "write":
if filename, ok := toolArgsMap["filePath"].(string); ok { if filename, ok := toolArgsMap["filePath"].(string); ok {
title = fmt.Sprintf("WRITE %s %s", relative(filename), elapsed) title = fmt.Sprintf("WRITE %s %s", relative(filename), elapsed)
if content, ok := toolArgsMap["content"].(string); ok { if content, ok := toolArgsMap["content"].(string); ok {
body = renderFile(filename, content) body = renderFile(filename, content)
} }
} }
case "opencode_bash": case "bash":
if description, ok := toolArgsMap["description"].(string); ok { if description, ok := toolArgsMap["description"].(string); ok {
title = fmt.Sprintf("SHELL %s %s", description, elapsed) title = fmt.Sprintf("SHELL %s %s", description, elapsed)
} }
@@ -417,7 +417,7 @@ func renderToolInvocation(
body = toMarkdown(body, innerWidth, t.BackgroundSubtle()) body = toMarkdown(body, innerWidth, t.BackgroundSubtle())
body = renderContentBlock(body, WithFullWidth(), WithMarginBottom(1)) body = renderContentBlock(body, WithFullWidth(), WithMarginBottom(1))
} }
case "opencode_webfetch": case "webfetch":
toolArgs = renderArgs(&toolArgsMap, "url") toolArgs = renderArgs(&toolArgsMap, "url")
title = fmt.Sprintf("FETCH %s %s", toolArgs, elapsed) title = fmt.Sprintf("FETCH %s %s", toolArgs, elapsed)
if format, ok := toolArgsMap["format"].(string); ok { if format, ok := toolArgsMap["format"].(string); ok {
@@ -428,7 +428,7 @@ func renderToolInvocation(
} }
body = renderContentBlock(body, WithFullWidth(), WithMarginBottom(1)) body = renderContentBlock(body, WithFullWidth(), WithMarginBottom(1))
} }
case "opencode_todowrite": case "todowrite":
title = fmt.Sprintf("PLAN %s", elapsed) title = fmt.Sprintf("PLAN %s", elapsed)
if to, ok := metadata.Get("todos"); ok && finished { if to, ok := metadata.Get("todos"); ok && finished {
@@ -498,11 +498,11 @@ func renderToolName(name string) string {
switch name { switch name {
// case agent.AgentToolName: // case agent.AgentToolName:
// return "Task" // return "Task"
case "opencode_ls": case "list":
return "LIST" return "LIST"
case "opencode_webfetch": case "webfetch":
return "FETCH" return "FETCH"
case "opencode_todowrite": case "todowrite":
return "PLAN" return "PLAN"
default: default:
normalizedName := name normalizedName := name
@@ -559,27 +559,27 @@ func renderToolAction(name string) string {
switch name { switch name {
// case agent.AgentToolName: // case agent.AgentToolName:
// return "Preparing prompt..." // return "Preparing prompt..."
case "opencode_bash": case "bash":
return "Building command..." return "Building command..."
case "opencode_edit": case "edit":
return "Preparing edit..." return "Preparing edit..."
case "opencode_fetch": case "webfetch":
return "Writing fetch..." return "Writing fetch..."
case "opencode_glob": case "glob":
return "Finding files..." return "Finding files..."
case "opencode_grep": case "grep":
return "Searching content..." return "Searching content..."
case "opencode_ls": case "list":
return "Listing directory..." return "Listing directory..."
case "opencode_read": case "read":
return "Reading file..." return "Reading file..."
case "opencode_write": case "write":
return "Preparing write..." return "Preparing write..."
case "opencode_todowrite", "opencode_todoread": case "todowrite", "todoread":
return "Planning..." return "Planning..."
case "opencode_patch": case "patch":
return "Preparing patch..." return "Preparing patch..."
case "opencode_batch": case "batch":
return "Running batch operations..." return "Running batch operations..."
} }
return "Working..." return "Working..."
+10 -10
View File
@@ -859,7 +859,7 @@ export default function Share(props: {
(partIndex() > 0 || !msg.metadata?.assistant)) || (partIndex() > 0 || !msg.metadata?.assistant)) ||
(msg.role === "assistant" && (msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_todoread") part.toolInvocation.toolName === "todoread")
) )
return null return null
@@ -1072,7 +1072,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_grep" && part.toolInvocation.toolName === "grep" &&
part part
} }
> >
@@ -1175,7 +1175,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_glob" && part.toolInvocation.toolName === "glob" &&
part part
} }
> >
@@ -1253,7 +1253,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_list" && part.toolInvocation.toolName === "list" &&
part part
} }
> >
@@ -1322,7 +1322,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_read" && part.toolInvocation.toolName === "read" &&
part part
} }
> >
@@ -1417,7 +1417,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_write" && part.toolInvocation.toolName === "write" &&
part part
} }
> >
@@ -1503,7 +1503,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_edit" && part.toolInvocation.toolName === "edit" &&
part part
} }
> >
@@ -1577,7 +1577,7 @@ export default function Share(props: {
when={ when={
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === "opencode_bash" && part.toolInvocation.toolName === "bash" &&
part part
} }
> >
@@ -1620,7 +1620,7 @@ export default function Share(props: {
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === part.toolInvocation.toolName ===
"opencode_todowrite" && "todowrite" &&
part part
} }
> >
@@ -1686,7 +1686,7 @@ export default function Share(props: {
msg.role === "assistant" && msg.role === "assistant" &&
part.type === "tool-invocation" && part.type === "tool-invocation" &&
part.toolInvocation.toolName === part.toolInvocation.toolName ===
"opencode_webfetch" && "webfetch" &&
part part
} }
> >