Skip to content

refactor: abstract-filesystem-interface#938

Merged
0xVida merged 1 commit into
0xVida:mainfrom
Salmatcre8:feat/abstract-filesystem
Jun 1, 2026
Merged

refactor: abstract-filesystem-interface#938
0xVida merged 1 commit into
0xVida:mainfrom
Salmatcre8:feat/abstract-filesystem

Conversation

@Salmatcre8

Copy link
Copy Markdown
Contributor

Summary

Introduces a unified FileSystemProvider interface 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 the ide/ directory.

Closes #882

Deliverables

  • ide/src/lib/fs/FileSystemProvider.ts — the unified interface (readFile, writeFile, delete, exists, list, stat) plus a FileStat type, a FileNotFoundError, and path helpers (normalizePath / dirname / basename) with ..-traversal protection.
  • Adapters (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 — Node fs rooted at a directory, with root-containment checks; fs impl 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); fetch is injectable.
  • ide/src/lib/fs/index.ts — barrel export for clean imports.

Each adapter implements the identical FileSystemProvider contract, so workspace/editor code can be written once and pointed at browser, local, or remote storage.

Design notes

  • Paths are normalised to POSIX form internally; a leading slash is optional and equivalent to none.
  • External dependencies (node fs, fetch) are injected via constructors, keeping the adapters unit-testable without real I/O.
  • Aligns with the existing ide/src/lib/fs/UniversalResolver.ts conventions (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:

# Unit tests (vitest) — interface helpers + all three adapters
 Test Files  1 passed (1)
      Tests  25 passed (25)

# Typecheck — no errors introduced in src/lib/fs
$ npx tsc --noEmit  ->  0 errors in src/lib/fs/**
# (one pre-existing, unrelated error in src/lib/test/FuzzingEngine.ts exists on main)

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

  • Unified FileSystemProvider interface
  • Adapters for browser storage, local files, and remote repositories
  • Deliverable src/lib/fs/FileSystemProvider.ts present
  • All work confined to ide/

@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown

@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.

@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@0xVida 0xVida merged commit 7265583 into 0xVida:main Jun 1, 2026
0 of 3 checks passed
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.

[Architecture] Abstract File System Operations to Adaptable Interface

2 participants