refactor: abstract-filesystem-interface#938
Merged
Merged
Conversation
|
@Salmatcre8 is attempting to deploy a commit to the vidatg's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Salmatcre8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a unified
FileSystemProviderinterface and three concrete adapters so the IDE's file operations compile against an abstraction rather than reaching for browser storage APIs directly. All changes are confined to theide/directory.Closes #882
Deliverables
ide/src/lib/fs/FileSystemProvider.ts— the unified interface (readFile,writeFile,delete,exists,list,stat) plus aFileStattype, aFileNotFoundError, and path helpers (normalizePath/dirname/basename) with..-traversal protection.ide/src/lib/fs/adapters/):BrowserFileSystemProvider— IndexedDB-backed, for in-browser workspaces (replaces ad-hoc localStorage/IndexedDB access). Directories are implicit from stored paths.LocalFileSystemProvider— Nodefsrooted at a directory, with root-containment checks;fsimpl is injectable for testing.GitHubFileSystemProvider— remote GitHub repo via the REST Contents API (base64 blob decode on read; create-or-update with blob sha on write);fetchis injectable.ide/src/lib/fs/index.ts— barrel export for clean imports.Each adapter implements the identical
FileSystemProvidercontract, so workspace/editor code can be written once and pointed at browser, local, or remote storage.Design notes
fs,fetch) are injected via constructors, keeping the adapters unit-testable without real I/O.ide/src/lib/fs/UniversalResolver.tsconventions (same folder, IndexedDB usage style, vitest tests under__tests__/).Verified terminal output
This is a TypeScript library change (no UI to screenshot), so here is the test + typecheck output:
The 25 tests cover: path normalization + traversal guards; Browser adapter read/write/delete/exists/list/stat with implicit directories; Local adapter via an injected in-memory fs (incl. root-escape rejection); GitHub adapter via injected fetch (base64 read, 404 → FileNotFoundError, create-without-sha, update-with-sha, list, exists); and a cross-adapter contract test asserting all three implement the full interface.
Acceptance criteria
FileSystemProviderinterfacesrc/lib/fs/FileSystemProvider.tspresentide/