GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert: all refactor commits migrating from Bun.file() to Filesystem … · masegraye/opencode@568eccb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .opencode/skill/bun-file-io
    • SKILL.md
  • packages/opencode
    • src
      • cli/cmd/tui
        • thread.ts
      • lsp
        • client.ts
        • server.ts
      • mcp
        • auth.ts
      • project
        • project.ts
      • provider
        • models.ts
        • provider.ts
      • session
        • instruction.ts
        • prompt.ts
      • shell
        • shell.ts
      • skill
        • discovery.ts
      • storage
        • db.ts
        • json-migration.ts
        • storage.ts
      • tool
        • edit.ts
        • glob.ts
        • grep.ts
        • lsp.ts
        • read.ts
        • truncation.ts
        • write.ts
      • util
        • filesystem.ts
        • log.ts
    • test/util
      • filesystem.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.opencode/skill/bun-file-io/SKILL.md‎

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: bun-file-io
3+
description: Use this when you are working on file operations like reading, writing, scanning, or deleting files. It summarizes the preferred file APIs and patterns used in this repo. It also notes when to use filesystem helpers for directories.
4+
---
5+
6+
## Use this when
7+
8+
- Editing file I/O or scans in `packages/opencode`
9+
- Handling directory operations or external tools
10+
11+
## Bun file APIs (from Bun docs)
12+
13+
- `Bun.file(path)` is lazy; call `text`, `json`, `stream`, `arrayBuffer`, `bytes`, `exists` to read.
14+
- Metadata: `file.size`, `file.type`, `file.name`.
15+
- `Bun.write(dest, input)` writes strings, buffers, Blobs, Responses, or files.
16+
- `Bun.file(...).delete()` deletes a file.
17+
- `file.writer()` returns a FileSink for incremental writes.
18+
- `Bun.Glob` + `Array.fromAsync(glob.scan({ cwd, absolute, onlyFiles, dot }))` for scans.
19+
- Use `Bun.which` to find a binary, then `Bun.spawn` to run it.
20+
- `Bun.readableStreamToText/Bytes/JSON` for stream output.
21+
22+
## When to use node:fs
23+
24+
- Use `node:fs/promises` for directories (`mkdir`, `readdir`, recursive operations).
25+
26+
## Repo patterns
27+
28+
- Prefer Bun APIs over Node `fs` for file access.
29+
- Check `Bun.file(...).exists()` before reading.
30+
- For binary/large files use `arrayBuffer()` and MIME checks via `file.type`.
31+
- Use `Bun.Glob` + `Array.fromAsync` for scans.
32+
- Decode tool stderr with `Bun.readableStreamToText`.
33+
- For large writes, use `Bun.write(Bun.file(path), text)`.
34+
35+
NOTE: Bun.file(...).exists() will return `false` if the value is a directory.
36+
Use Filesystem.exists(...) instead if path can be file or directory
37+
38+
## Quick checklist
39+
40+
- Use Bun APIs first.
41+
- Use `path.join`/`path.resolve` for paths.
42+
- Prefer promise `.catch(...)` over `try/catch` when possible.
Collapse file

‎packages/opencode/src/cli/cmd/tui/thread.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/thread.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { tui } from "./app"
33
import { Rpc } from "@/util/rpc"
44
import { type rpc } from "./worker"
55
import path from "path"
6-
import { fileURLToPath } from "url"
76
import { UI } from "@/cli/ui"
87
import { iife } from "@/util/iife"
98
import { Log } from "@/util/log"
109
import { withNetworkOptions, resolveNetworkOptions } from "@/cli/network"
11-
import { Filesystem } from "@/util/filesystem"
1210
import type { Event } from "@opencode-ai/sdk/v2"
1311
import type { EventSource } from "./context/sdk"
1412
import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
@@ -101,7 +99,7 @@ export const TuiThreadCommand = cmd({
10199
const distWorker = new URL("./cli/cmd/tui/worker.js", import.meta.url)
102100
const workerPath = await iife(async () => {
103101
if (typeof OPENCODE_WORKER_PATH !== "undefined") return OPENCODE_WORKER_PATH
104-
if (await Filesystem.exists(fileURLToPath(distWorker))) return distWorker
102+
if (await Bun.file(distWorker).exists()) return distWorker
105103
return localWorker
106104
})
107105
try {
Collapse file

‎packages/opencode/src/lsp/client.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/lsp/client.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ export namespace LSPClient {
147147
notify: {
148148
async open(input: { path: string }) {
149149
input.path = path.isAbsolute(input.path) ? input.path : path.resolve(Instance.directory, input.path)
150-
const text = await Filesystem.readText(input.path)
150+
const file = Bun.file(input.path)
151+
const text = await file.text()
151152
const extension = path.extname(input.path)
152153
const languageId = LANGUAGE_EXTENSIONS[extension] ?? "plaintext"
153154

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.