From 97520c827ec59556eff6cff48b80eb84556eb5ec Mon Sep 17 00:00:00 2001 From: Dax Date: Wed, 18 Feb 2026 17:26:13 -0500 Subject: [PATCH] refactor: migrate src/provider/models.ts from Bun.file()/Bun.write() to Filesystem module (#14131) --- packages/opencode/src/provider/models.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/provider/models.ts b/packages/opencode/src/provider/models.ts index 0960176e2..bae331784 100644 --- a/packages/opencode/src/provider/models.ts +++ b/packages/opencode/src/provider/models.ts @@ -5,6 +5,7 @@ import z from "zod" import { Installation } from "../installation" import { Flag } from "../flag/flag" import { lazy } from "@/util/lazy" +import { Filesystem } from "../util/filesystem" // Try to import bundled snapshot (generated at build time) // Falls back to undefined in dev mode when snapshot doesn't exist @@ -85,8 +86,7 @@ export namespace ModelsDev { } export const Data = lazy(async () => { - const file = Bun.file(Flag.OPENCODE_MODELS_PATH ?? filepath) - const result = await file.json().catch(() => {}) + const result = await Filesystem.readJson(Flag.OPENCODE_MODELS_PATH ?? filepath).catch(() => {}) if (result) return result // @ts-ignore const snapshot = await import("./models-snapshot") @@ -104,7 +104,6 @@ export namespace ModelsDev { } export async function refresh() { - const file = Bun.file(filepath) const result = await fetch(`${url()}/api.json`, { headers: { "User-Agent": Installation.USER_AGENT, @@ -116,7 +115,7 @@ export namespace ModelsDev { }) }) if (result && result.ok) { - await Bun.write(file, await result.text()) + await Filesystem.write(filepath, await result.text()) ModelsDev.Data.reset() } }