Skip to content

Function: rebuildFS()

rebuildFS(key, materialize, options?): Promise<LocalFileSystem>

Rebuild the STABLE temp tree named by key, every call.

materialize writes into a throwaway scratchFS root; only on success does that root REPLACE the stable one. Two properties fall out of that ordering, and both are the reason to prefer this over writing into the stable path directly:

  • repeated runs reuse ONE directory instead of leaving a new scratch behind on every boot, and
  • a reader never observes a half-written tree, and a failed rebuild leaves the previous one intact.

Rebuilds targeting the same stable tree are serialized across processes. The swap is a rename within the same temp root, so it is atomic.

string

Stable temp-relative path. May be nested ("skills/abc123") to give each input its own directory.

(scratch) => Promise<void>

OsFileSystemOptions = {}

Promise<LocalFileSystem>

const skills = await rebuildFS("agent-skills", (scratch) =>
downloadInto(scratch.root),
);