ReadonlymkdirCreate a directory and every missing parent. A no-op if it already exists.
ReadonlyreaddirList a directory's entries with their file-type info.
ReadonlyreadRead a UTF-8 text file. Rejects if the path doesn't exist or isn't readable.
ReadonlyrealpathResolve a path to its canonical, symlink-free absolute form.
ReadonlystatStat a path (following symlinks). Rejects if the path doesn't exist.
ReadonlywriteWrite a UTF-8 text file, creating or truncating it. The parent directory must already exist.
The filesystem capability a package's
./buildentry requires from its caller../buildis a library surface: it must not acquire filesystem access implicitly (nonode:fsimport outside the package's CLI). Every public options object carries a requiredfsfield of this type, and the caller supplies a concrete adapter: the CLI builds one overnode:fs/promises; a test builds either that same adapter or an in-memory fake."Ambient-fs-free" means specifically:
./buildnever reaches fornode:fsitself. It still performs real filesystem operations -- the capability is always handed in.The shape is modeled on
node:fs/promises's own signatures so a thin adapter is a drop-in value, but uses minimal structural types (BuildDirent/BuildStats) rather than Node'sDirent/Stats-- the capability boundary shouldn't leak Node's type surface just because the concrete adapter happens to be Node-backed. Only the operations the build code actually calls are here.