Filesystem Module
Purpose
- Manage Git worktree provisioning/removal and repository discovery.
- Provide file browsing capabilities for editor and file selection.
- Emit filesystem-related events so downstream services (git, UI) can track worktree lifecycle without direct coupling.
Data & Event Flow
- Worktree Management (
worktree-runner.ts)createWorktreeensures the target directory exists, fetches refs, and adds a worktree. On success it emitsworktree.createdwith project/attempt metadata.removeWorktreeremoves the worktree and emitsworktree.removed(best-effort).
- File Browsing (
browse.ts)browseDirectoryprovides directory listing with metadata (name, path, type, executable flag, size).- Supports filtering by hidden files and executables only.
- Used by the UI for file browser dialogs (e.g., selecting editor executables).
- Filesystem APIs (
routes.ts)GET /fs/git-reposscans for local Git repositories (no events needed).GET /fs/browsebrowses directories with optional filtering (path, showHidden, executablesOnly).
- Event Listeners (
listeners.ts)project.deleted→ purge both id-based and name-based worktree folders and prune stale Git worktree entries for the project’s repository.
Key Entry Points
paths.ts: canonical worktree root + helpers for id/name-based paths.worktree-runner.ts: exec wrapper aroundgit worktree add/removewith event emission.browse.ts: directory browsing functionality with filtering options.listeners.ts: cleanup logic responding to board/project events.
Types
FileBrowserEntry: represents a file or directory entry with metadata.BrowseDirectoryOptions: options for browsing (path, showHidden, executablesOnly).BrowseDirectoryResult: result containing entries, currentPath, and parentPath.
Open Tasks
- Unit-test project-deletion worktree cleanup path.
- Surface errors back to the UI when cleanup fails (currently logged only).