refactor: migrate src/skill/discovery.ts from Bun.file()/Bun.write() to Filesystem module

Replace Bun-specific file operations with Filesystem module:

- Add Filesystem import from ../util/filesystem

- Replace Bun.file().exists() with Filesystem.exists()

- Replace Bun.write() with Filesystem.write()

All 17 skill tests pass.
This commit is contained in:
Dax Raad
2026-02-18 10:55:25 -05:00
parent 6b29896a35
commit 8fd4568071

View File

@@ -2,6 +2,7 @@ import path from "path"
import { mkdir } from "fs/promises"
import { Log } from "../util/log"
import { Global } from "../global"
import { Filesystem } from "../util/filesystem"
export namespace Discovery {
const log = Log.create({ service: "skill-discovery" })
@@ -19,14 +20,14 @@ export namespace Discovery {
}
async function get(url: string, dest: string): Promise<boolean> {
if (await Bun.file(dest).exists()) return true
if (await Filesystem.exists(dest)) return true
return fetch(url)
.then(async (response) => {
if (!response.ok) {
log.error("failed to download", { url, status: response.status })
return false
}
await Bun.write(dest, await response.text())
await Filesystem.write(dest, await response.text())
return true
})
.catch((err) => {
@@ -88,7 +89,7 @@ export namespace Discovery {
)
const md = path.join(root, "SKILL.md")
if (await Bun.file(md).exists()) result.push(root)
if (await Filesystem.exists(md)) result.push(root)
}),
)