summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2026-02-18 19:24:21 -0500
committerGitHub <[email protected]>2026-02-18 19:24:21 -0500
commitbd52ce5640f0299f49f2bc2bfadcb95c2acec260 (patch)
tree1d84eb13a8d3e096af178f8cda39c9925fd412ea
parenta624871ccdd9066b5949825176970625748b9c03 (diff)
downloadopencode-bd52ce5640f0299f49f2bc2bfadcb95c2acec260.tar.gz
opencode-bd52ce5640f0299f49f2bc2bfadcb95c2acec260.zip
refactor: migrate remaining tool files from Bun.file() to Filesystem/stat modules (#14121)
-rw-r--r--packages/opencode/src/tool/glob.ts6
-rw-r--r--packages/opencode/src/tool/grep.ts4
-rw-r--r--packages/opencode/src/tool/lsp.ts3
-rw-r--r--packages/opencode/src/tool/truncation.ts3
4 files changed, 8 insertions, 8 deletions
diff --git a/packages/opencode/src/tool/glob.ts b/packages/opencode/src/tool/glob.ts
index 9df1eedca..a2611246c 100644
--- a/packages/opencode/src/tool/glob.ts
+++ b/packages/opencode/src/tool/glob.ts
@@ -1,6 +1,7 @@
import z from "zod"
import path from "path"
import { Tool } from "./tool"
+import { Filesystem } from "../util/filesystem"
import DESCRIPTION from "./glob.txt"
import { Ripgrep } from "../file/ripgrep"
import { Instance } from "../project/instance"
@@ -45,10 +46,7 @@ export const GlobTool = Tool.define("glob", {
break
}
const full = path.resolve(search, file)
- const stats = await Bun.file(full)
- .stat()
- .then((x) => x.mtime.getTime())
- .catch(() => 0)
+ const stats = Filesystem.stat(full)?.mtime.getTime() ?? 0
files.push({
path: full,
mtime: stats,
diff --git a/packages/opencode/src/tool/grep.ts b/packages/opencode/src/tool/grep.ts
index 41ed494de..00497d4e3 100644
--- a/packages/opencode/src/tool/grep.ts
+++ b/packages/opencode/src/tool/grep.ts
@@ -1,5 +1,6 @@
import z from "zod"
import { Tool } from "./tool"
+import { Filesystem } from "../util/filesystem"
import { Ripgrep } from "../file/ripgrep"
import DESCRIPTION from "./grep.txt"
@@ -83,8 +84,7 @@ export const GrepTool = Tool.define("grep", {
const lineNum = parseInt(lineNumStr, 10)
const lineText = lineTextParts.join("|")
- const file = Bun.file(filePath)
- const stats = await file.stat().catch(() => null)
+ const stats = Filesystem.stat(filePath)
if (!stats) continue
matches.push({
diff --git a/packages/opencode/src/tool/lsp.ts b/packages/opencode/src/tool/lsp.ts
index ca352280b..52aef0f9e 100644
--- a/packages/opencode/src/tool/lsp.ts
+++ b/packages/opencode/src/tool/lsp.ts
@@ -6,6 +6,7 @@ import DESCRIPTION from "./lsp.txt"
import { Instance } from "../project/instance"
import { pathToFileURL } from "url"
import { assertExternalDirectory } from "./external-directory"
+import { Filesystem } from "../util/filesystem"
const operations = [
"goToDefinition",
@@ -47,7 +48,7 @@ export const LspTool = Tool.define("lsp", {
const relPath = path.relative(Instance.worktree, file)
const title = `${args.operation} ${relPath}:${args.line}:${args.character}`
- const exists = await Bun.file(file).exists()
+ const exists = await Filesystem.exists(file)
if (!exists) {
throw new Error(`File not found: ${file}`)
}
diff --git a/packages/opencode/src/tool/truncation.ts b/packages/opencode/src/tool/truncation.ts
index 84e799c13..4cc524aee 100644
--- a/packages/opencode/src/tool/truncation.ts
+++ b/packages/opencode/src/tool/truncation.ts
@@ -5,6 +5,7 @@ import { Identifier } from "../id/id"
import { PermissionNext } from "../permission/next"
import type { Agent } from "../agent/agent"
import { Scheduler } from "../scheduler"
+import { Filesystem } from "../util/filesystem"
export namespace Truncate {
export const MAX_LINES = 2000
@@ -91,7 +92,7 @@ export namespace Truncate {
const id = Identifier.ascending("tool")
const filepath = path.join(DIR, id)
- await Bun.write(Bun.file(filepath), text)
+ await Filesystem.write(filepath, text)
const hint = hasTaskTool(agent)
? `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse the Task tool to have explore agent process this file with Grep and Read (with offset/limit). Do NOT read the full file yourself - delegate to save context.`