summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-06-11 12:58:06 -0400
committerDax Raad <[email protected]>2025-06-11 12:58:06 -0400
commit636133e6cbcaf5894a7a4bc2de480df9eef3ace6 (patch)
tree09da02cf4d96ee13e9396b1789a1715066cfb2ac
parent6cf8784ecf3ea4703f88b037ee5562af5f15fbd1 (diff)
downloadopencode-636133e6cbcaf5894a7a4bc2de480df9eef3ace6.tar.gz
opencode-636133e6cbcaf5894a7a4bc2de480df9eef3ace6.zip
sync
-rw-r--r--packages/opencode/src/tool/glob.ts1
-rw-r--r--packages/opencode/src/tool/grep.ts1
-rw-r--r--packages/opencode/src/tool/ls.ts6
-rw-r--r--packages/opencode/src/tool/lsp-diagnostics.ts1
-rw-r--r--packages/opencode/src/tool/lsp-hover.ts6
-rw-r--r--packages/opencode/src/tool/multiedit.ts5
-rw-r--r--packages/opencode/src/tool/patch.ts14
-rw-r--r--packages/opencode/src/tool/read.ts2
-rw-r--r--packages/opencode/src/tool/todo.ts2
-rw-r--r--packages/opencode/src/tool/write.ts5
10 files changed, 29 insertions, 14 deletions
diff --git a/packages/opencode/src/tool/glob.ts b/packages/opencode/src/tool/glob.ts
index 55021d1fa..4acaf50f4 100644
--- a/packages/opencode/src/tool/glob.ts
+++ b/packages/opencode/src/tool/glob.ts
@@ -60,6 +60,7 @@ export const GlobTool = Tool.define({
metadata: {
count: files.length,
truncated,
+ title: path.relative(app.path.root, search),
},
output: output.join("\n"),
}
diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts
index e4fa8b1d1..a16bb2a89 100644
--- a/packages/opencode/src/tool/grep.ts
+++ b/packages/opencode/src/tool/grep.ts
@@ -124,6 +124,7 @@ export const GrepTool = Tool.define({
metadata: {
matches: finalMatches.length,
truncated,
+ title: params.pattern,
},
output: outputLines.join("\n"),
}
diff --git a/packages/opencode/src/tool/ls.ts b/packages/opencode/src/tool/ls.ts
index a494211b6..ef8afe634 100644
--- a/packages/opencode/src/tool/ls.ts
+++ b/packages/opencode/src/tool/ls.ts
@@ -98,7 +98,11 @@ export const ListTool = Tool.define({
const output = `${searchPath}/\n` + renderDir(".", 0)
return {
- metadata: { count: files.length, truncated: files.length >= 1000 },
+ metadata: {
+ count: files.length,
+ truncated: files.length >= 1000,
+ title: path.relative(app.path.root, searchPath),
+ },
output,
}
},
diff --git a/packages/opencode/src/tool/lsp-diagnostics.ts b/packages/opencode/src/tool/lsp-diagnostics.ts
index d1495f603..8298df4ba 100644
--- a/packages/opencode/src/tool/lsp-diagnostics.ts
+++ b/packages/opencode/src/tool/lsp-diagnostics.ts
@@ -22,6 +22,7 @@ export const LspDiagnosticTool = Tool.define({
return {
metadata: {
diagnostics,
+ title: path.relative(app.path.root, normalized),
},
output: file?.length
? file.map(LSP.Diagnostic.pretty).join("\n")
diff --git a/packages/opencode/src/tool/lsp-hover.ts b/packages/opencode/src/tool/lsp-hover.ts
index 8bd6eb9d3..9d1ef4850 100644
--- a/packages/opencode/src/tool/lsp-hover.ts
+++ b/packages/opencode/src/tool/lsp-hover.ts
@@ -27,6 +27,12 @@ export const LspHoverTool = Tool.define({
return {
metadata: {
result,
+ title:
+ path.relative(app.path.root, file) +
+ ":" +
+ args.line +
+ ":" +
+ args.character,
},
output: JSON.stringify(result, null, 2),
}
diff --git a/packages/opencode/src/tool/multiedit.ts b/packages/opencode/src/tool/multiedit.ts
index 8a3fd43db..f1d5ea6b1 100644
--- a/packages/opencode/src/tool/multiedit.ts
+++ b/packages/opencode/src/tool/multiedit.ts
@@ -2,6 +2,8 @@ import { z } from "zod"
import { Tool } from "./tool"
import { EditTool } from "./edit"
import DESCRIPTION from "./multiedit.txt"
+import path from "path"
+import { App } from "../app/app"
export const MultiEditTool = Tool.define({
id: "opencode.multiedit",
@@ -26,10 +28,11 @@ export const MultiEditTool = Tool.define({
)
results.push(result)
}
-
+ const app = App.info()
return {
metadata: {
results: results.map((r) => r.metadata),
+ title: path.relative(app.path.root, params.filePath),
},
output: results.at(-1)!.output,
}
diff --git a/packages/opencode/src/tool/patch.ts b/packages/opencode/src/tool/patch.ts
index ae8772806..41f7a2cc8 100644
--- a/packages/opencode/src/tool/patch.ts
+++ b/packages/opencode/src/tool/patch.ts
@@ -4,6 +4,7 @@ import * as fs from "fs/promises"
import { Tool } from "./tool"
import { FileTimes } from "./util/file-times"
import DESCRIPTION from "./patch.txt"
+import { App } from "../app/app"
const PatchParams = z.object({
patchText: z
@@ -11,12 +12,6 @@ const PatchParams = z.object({
.describe("The full patch text that describes all changes to be made"),
})
-interface PatchResponseMetadata {
- changed: string[]
- additions: number
- removals: number
-}
-
interface Change {
type: "add" | "update" | "delete"
old_content?: string
@@ -242,10 +237,6 @@ export const PatchTool = Tool.define({
description: DESCRIPTION,
parameters: PatchParams,
execute: async (params, ctx) => {
- if (!params.patchText) {
- throw new Error("patchText is required")
- }
-
// Identify all files needed for the patch and verify they've been read
const filesToRead = identifyFilesNeeded(params.patchText)
for (const filePath of filesToRead) {
@@ -372,7 +363,8 @@ export const PatchTool = Tool.define({
changed: changedFiles,
additions: totalAdditions,
removals: totalRemovals,
- } satisfies PatchResponseMetadata,
+ title: `${filesToRead.length} files`,
+ },
output,
}
},
diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts
index 0ace57e2a..38091b7ac 100644
--- a/packages/opencode/src/tool/read.ts
+++ b/packages/opencode/src/tool/read.ts
@@ -5,6 +5,7 @@ import { Tool } from "./tool"
import { LSP } from "../lsp"
import { FileTimes } from "./util/file-times"
import DESCRIPTION from "./read.txt"
+import { App } from "../app/app"
const MAX_READ_SIZE = 250 * 1024
const DEFAULT_READ_LIMIT = 2000
@@ -95,6 +96,7 @@ export const ReadTool = Tool.define({
output,
metadata: {
preview,
+ title: path.relative(App.info().path.root, filePath),
},
}
},
diff --git a/packages/opencode/src/tool/todo.ts b/packages/opencode/src/tool/todo.ts
index 188a344c5..34b7773c0 100644
--- a/packages/opencode/src/tool/todo.ts
+++ b/packages/opencode/src/tool/todo.ts
@@ -34,6 +34,7 @@ export const TodoWriteTool = Tool.define({
return {
output: JSON.stringify(params.todos, null, 2),
metadata: {
+ title: `${params.todos.length} todos`,
todos: params.todos,
},
}
@@ -49,6 +50,7 @@ export const TodoReadTool = Tool.define({
return {
metadata: {
todos,
+ title: ``,
},
output: JSON.stringify(todos, null, 2),
}
diff --git a/packages/opencode/src/tool/write.ts b/packages/opencode/src/tool/write.ts
index 83c4b360b..276a57517 100644
--- a/packages/opencode/src/tool/write.ts
+++ b/packages/opencode/src/tool/write.ts
@@ -5,6 +5,7 @@ import { FileTimes } from "./util/file-times"
import { LSP } from "../lsp"
import { Permission } from "../permission"
import DESCRIPTION from "./write.txt"
+import { App } from "../app/app"
export const WriteTool = Tool.define({
id: "opencode.write",
@@ -18,9 +19,10 @@ export const WriteTool = Tool.define({
content: z.string().describe("The content to write to the file"),
}),
async execute(params, ctx) {
+ const app = App.info()
const filepath = path.isAbsolute(params.filePath)
? params.filePath
- : path.join(process.cwd(), params.filePath)
+ : path.join(app.path.cwd, params.filePath)
const file = Bun.file(filepath)
const exists = await file.exists()
@@ -59,6 +61,7 @@ export const WriteTool = Tool.define({
diagnostics,
filepath,
exists: exists,
+ title: path.relative(app.path.root, filepath),
},
output,
}