bun-file-io
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.
Installation
Pick a client and clone the repository into its skills directory.
Installation
About this skill
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.
How to use
Zainstaluj skill bun-file-io w swoim projekcie opencode — będzie dostępny podczas pracy nad operacjami na plikach w packages/opencode.
Do czytania pliku użyj Bun.file(path) z metodą text(), json(), stream() lub arrayBuffer() w zależności od typu zawartości. Zawsze sprawdź istnienie pliku metodą exists() przed próbą odczytu.
Do zapisu użyj Bun.write(dest, input), który akceptuje stringi, bufory, Blobe i Response. Dla dużych plików preferuj Bun.write(Bun.file(path), text).
Do skanowania katalogów i wyszukiwania plików użyj Bun.Glob z Array.fromAsync(glob.scan({ cwd, absolute, onlyFiles, dot })). Dla operacji na katalogach takich jak mkdir lub readdir sięgnij po node:fs/promises.
Do usunięcia pliku wywołaj Bun.file(path).delete(). Do uruchamiania narzędzi zewnętrznych użyj Bun.which() do znalezienia binarki, a następnie Bun.spawn() do jej wykonania — błędy dekoduj za pomocą Bun.readableStreamToText().
Pamiętaj o ścieżkach: używaj path.join() lub path.resolve(), preferuj API Bun zamiast Node fs, a dla dużych lub binarnych plików sprawdzaj typ MIME przez file.type.