ContextFS is a library that lets you construct a virtual filesystem using a router-style API. It's mountable via NFS or `just-bash`, and useful for providing agents with hierarchical, explorable context defined in code.
// Define file system structure
const vfs = createFileSystem({
issues: {
":id": {
[list]: () => getIssues().map(i => ({ id: i.id })),
[read]: (c) => getIssue(c.params.id).body,
}
}
});
// Mount with NFS
await mount(vfs, { mountPoint: "/tmp/issues" });
await fsp.readFile("/tmp/issues/123");
// Explore with just-bash
const env = new Bash({ fs: new ContextFS(vfs) });
await env.exec("ls /tmp/issues");
Key features:
- Express-style dynamic paths (:id, :slug.md) with full TypeScript inference
- Read and optional write support
- Symlinks to represent relationships
- Browser-safe core library
- Pure TypeScript NFS v3 implementation, no native deps