Skip to content

refactor: route FileSystem through Effect's R channel - #16

Open
K-Mistele wants to merge 1 commit into
mainfrom
filesystem-service-seam
Open

refactor: route FileSystem through Effect's R channel#16
K-Mistele wants to merge 1 commit into
mainfrom
filesystem-service-seam

Conversation

@K-Mistele

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the eager mutable singleton in DefaultFileSystem.ts with Effect's standard service mechanism
  • FileSystem.FileSystem is now a ToolHandlerServices member (alongside ToolState, ToolEvents, Subagents, etc.) and a SessionProvisioningServices member
  • Tool handlers yield* FileSystem.FileSystem instead of calling fileSystemFor(options)
  • Auth stores (fold-xai, fold-codex) return Effect<AuthStore> instead of using duplicated mutable singletons
  • The mutable singleton, fileSystemFor, FsToolOptions, and defaultNodeFileSystem are all deleted — only cwdFor remains
  • Tests provide NodeFileSystem.layer or test FileSystem layers via Effect.provide, matching the pattern used for Clock, Random, Ids, and Crypto

This is the consistency cleanup raised during PR #9: Clock, Random, Ids, and Crypto all flow through Effect's R channel, but FileSystem was the last holdout using an eager singleton. Now all runtime capabilities use the same mechanism.

Test plan

  • bun run typecheck — 0 errors
  • bun run lint — 0 errors
  • bun run test — all 692 tests pass across all packages

🤖 Generated with Claude Code

Replace the eager mutable singleton in DefaultFileSystem.ts with
Effect's standard service mechanism. FileSystem.FileSystem is now a
session-level service provided by NodeServices.layer at the CLI
composition root, and a ToolHandlerServices member available to every
tool handler.

- Add FileSystem.FileSystem to ToolHandlerServices and the tool
  runtime's layer graph (ToolRuntimeLayer, Provisioning, StartSession)
- Add FileSystem.FileSystem to SessionProvisioningServices so it flows
  through the session graph to every provisioned runtime
- Convert all fold-agent tool handlers (read, write, edit, apply_patch,
  bash) to yield FileSystem from R instead of calling fileSystemFor()
- Convert all fold-agent config/session/catalog/skills/memory/output
  modules to yield FileSystem from R
- Convert fold-xai and fold-codex auth stores from mutable singletons
  to Effect-returning constructors
- Delete the DefaultFileSystem singleton, fileSystemFor, and FsToolOptions
  (only cwdFor remains)
- Update all tests to provide NodeFileSystem.layer or test FileSystem
  layers via Effect.provide

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a0179a-5c6f-7ab7-8e1e-92b5a54ffad3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant