1.8 KiB
1.8 KiB
FS Module Documentation
Purpose
Own filesystem API behavior for the web server runtime, including workspace-bound file operations, directory listing, reveal, and background command execution jobs.
Entrypoints and structure
packages/web/server/lib/fs/routes.js: route registration and runtime-owned state for/api/fs/*endpoints.packages/web/server/lib/fs/search.js: fuzzy filesystem search runtime used by non-FS routes (for example project icon discovery).
Public exports
registerFsRoutes(app, dependencies)fromroutes.js- Registers all filesystem routes:
GET /api/fs/homePOST /api/fs/mkdirGET /api/fs/readGET /api/fs/rawGET /api/fs/serve/:path(*)POST /api/fs/writePOST /api/fs/deletePOST /api/fs/renamePOST /api/fs/revealPOST /api/fs/execGET /api/fs/exec/:jobIdGET /api/fs/list
- Owns exec job queue state (
execJobs) and lifecycle/TTL pruning. - Enforces workspace boundary checks with active project + worktree fallback support.
- Registers all filesystem routes:
createFsSearchRuntime({ fsPromises, path, spawn, resolveGitBinaryForSpawn })fromsearch.js- Returns
{ searchFilesystemFiles(rootPath, options) }. - Supports fuzzy matching, hidden-file handling, and optional
git check-ignorefiltering.
- Returns
Composition contract with index.js
index.jsprovides composition-time dependencies only (platform primitives + callbacks such asresolveProjectDirectory,normalizeDirectoryPath, andbuildAugmentedPath).index.jsno longer owns FS route handlers or FS exec job state.
Notes for contributors
- Keep filesystem policy (workspace root checks, error mapping, exec timeout behavior) inside this module, not in the composition root.
- If adding new
/api/fs/*endpoints, add them inroutes.jsand extend this document.