From 472d01fbaf8e5aa46048062d3dd8f7acb1fc2c49 Mon Sep 17 00:00:00 2001 From: Dax Date: Wed, 18 Feb 2026 12:22:46 -0500 Subject: [PATCH] refactor: migrate cli/cmd/run.ts from Bun.file() to Filesystem/stat modules (#14155) --- packages/opencode/src/cli/cmd/github.ts | 3 ++- packages/opencode/src/cli/cmd/run.ts | 12 +++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts index 7f9a03d94..c44b7f6a2 100644 --- a/packages/opencode/src/cli/cmd/github.ts +++ b/packages/opencode/src/cli/cmd/github.ts @@ -1,5 +1,6 @@ import path from "path" import { exec } from "child_process" +import { Filesystem } from "../../util/filesystem" import * as prompts from "@clack/prompts" import { map, pipe, sortBy, values } from "remeda" import { Octokit } from "@octokit/rest" @@ -360,7 +361,7 @@ export const GithubInstallCommand = cmd({ ? "" : `\n env:${providers[provider].env.map((e) => `\n ${e}: \${{ secrets.${e} }}`).join("")}` - await Bun.write( + await Filesystem.write( path.join(app.root, WORKFLOW_FILE), `name: opencode diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts index 55cf9a2a0..bf63eabf8 100644 --- a/packages/opencode/src/cli/cmd/run.ts +++ b/packages/opencode/src/cli/cmd/run.ts @@ -6,6 +6,7 @@ import { cmd } from "./cmd" import { Flag } from "../../flag/flag" import { bootstrap } from "../bootstrap" import { EOL } from "os" +import { Filesystem } from "../../util/filesystem" import { createOpencodeClient, type Message, type OpencodeClient, type ToolPart } from "@opencode-ai/sdk/v2" import { Server } from "../../server/server" import { Provider } from "../../provider/provider" @@ -315,19 +316,12 @@ export const RunCommand = cmd({ for (const filePath of list) { const resolvedPath = path.resolve(process.cwd(), filePath) - const file = Bun.file(resolvedPath) - const stats = await file.stat().catch(() => {}) - if (!stats) { - UI.error(`File not found: ${filePath}`) - process.exit(1) - } - if (!(await file.exists())) { + if (!(await Filesystem.exists(resolvedPath))) { UI.error(`File not found: ${filePath}`) process.exit(1) } - const stat = await file.stat() - const mime = stat.isDirectory() ? "application/x-directory" : "text/plain" + const mime = (await Filesystem.isDir(resolvedPath)) ? "application/x-directory" : "text/plain" files.push({ type: "file",