Skip to content

feat(filesystem): add AppFileSystem service, migrate Snapshot#18138

Merged
kitlangton merged 5 commits intodevfrom
refactor/effect-filesystem
Mar 18, 2026
Merged

feat(filesystem): add AppFileSystem service, migrate Snapshot#18138
kitlangton merged 5 commits intodevfrom
refactor/effect-filesystem

Conversation

@kitlangton
Copy link
Contributor

Summary

  • New AppFileSystem service wrapping Effect's FileSystem with opencode helpers: isDir, isFile, readJson, writeJson, ensureDir, writeWithDirs, findUp, up, glob, globMatch, globUp
  • Pure path helpers on the namespace: mimeType, resolve, contains, overlaps, windowsPath, normalizePath
  • Own error type FileSystemError for non-platform errors (e.g. glob failures)
  • defaultLayer provides NodeFileSystem.layer so consumers just depend on AppFileSystem.Service
  • Migrated Snapshot as first consumer — replaced local filesystem wrappers with AppFileSystem.Service
  • Added prepare script for effect-language-service patch (enables Effect diagnostics in tsc)
  • 24 Effect-native tests using testEffect with scoped temp directories

Test plan

  • tsc --noEmit passes (with Effect diagnostics)
  • 24 AppFileSystem tests pass
  • 44 Snapshot tests pass

App-owned service that extends Effect's built-in FileSystem with
opencode helpers: isDir, isFile, readJson, writeJson, ensureDir,
writeWithDirs, findUp, up, globUp. Pure path helpers (mimeType,
resolve, contains, overlaps, windowsPath, normalizePath) remain
as static functions on the namespace.
Replace local filesystem helper wrappers (exists, mkdir, writeFile)
with AppFileSystem.Service. Snapshot now yields the app-owned service
and uses ensureDir, writeFileString directly with .orDie for write
paths. Kept thin wrappers for readFile (empty fallback) and removeFile
(swallow errors) since those are Snapshot-specific error handling.
- Discovery: use AppFileSystem.Service, writeWithDirs for downloads
- TruncateEffect: use AppFileSystem.Service, ensureDir for output dir
@kitlangton kitlangton force-pushed the refactor/effect-filesystem branch from dcfafe8 to f742949 Compare March 18, 2026 23:34
@kitlangton kitlangton merged commit 81be544 into dev Mar 18, 2026
6 of 8 checks passed
@kitlangton kitlangton deleted the refactor/effect-filesystem branch March 18, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant