@@ -4,7 +4,10 @@ Mountain-backed file system provider for VSCode browser workbench.
44
55## Overview
66
7- This service enables the VSCode browser workbench to access the file system through Mountain's Tauri IPC handlers. It implements a VSCode-like ` IFileSystemProvider ` interface that communicates with Mountain's file system operations.
7+ This service enables the VSCode browser workbench to access the file system
8+ through Mountain's Tauri IPC handlers. It implements a VSCode-like
9+ ` IFileSystemProvider ` interface that communicates with Mountain's file system
10+ operations.
811
912## Architecture
1013
@@ -23,48 +26,52 @@ Native File System
2326- ** File Operations** : Read, write, delete, copy, move files
2427- ** Directory Operations** : List contents, create, remove directories
2528- ** Metadata** : Get file statistics (size, type, timestamps)
26- - ** URI Handling** : Convert between VSCode URIs (` file:///path/to/file ` ) and file system paths
29+ - ** URI Handling** : Convert between VSCode URIs (` file:///path/to/file ` ) and
30+ file system paths
2731- ** Error Handling** : Comprehensive error types for different failure modes
28- - ** Effect-TS Integration** : Full Effect-TS pattern support for functional composition
32+ - ** Effect-TS Integration** : Full Effect-TS pattern support for functional
33+ composition
2934
3035## Mountain IPC Commands
3136
32- The service invokes these Mountain IPC commands (defined in ` Element/Mountain/Source/IPC/WindServiceHandlers.rs ` ):
37+ The service invokes these Mountain IPC commands (defined in
38+ ` Element/Mountain/Source/IPC/WindServiceHandlers.rs ` ):
3339
34- | Command | Description | Parameters |
35- | ---------| -------------| ------------|
36- | ` file:read ` | Read file contents | ` path: string ` |
37- | ` file:write ` | Write file contents | ` path: string ` , ` content: string ` |
38- | ` file:stat ` | Get file metadata | ` path: string ` |
39- | ` file:delete ` | Delete file/directory | ` path: string ` |
40- | ` file:copy ` | Copy file/directory | ` source: string ` , ` destination: string ` |
41- | ` file:move ` | Move/rename file/directory | ` source: string ` , ` destination: string ` |
42- | ` file:mkdir ` | Create directory | ` path: string ` , ` recursive: boolean ` |
43- | ` file:readdir ` | List directory contents | ` path: string ` |
40+ | Command | Description | Parameters |
41+ | -------------- | -------------------------- | --------------------------------------- |
42+ | ` file:read ` | Read file contents | ` path: string ` |
43+ | ` file:write ` | Write file contents | ` path: string ` , ` content: string ` |
44+ | ` file:stat ` | Get file metadata | ` path: string ` |
45+ | ` file:delete ` | Delete file/directory | ` path: string ` |
46+ | ` file:copy ` | Copy file/directory | ` source: string ` , ` destination: string ` |
47+ | ` file:move ` | Move/rename file/directory | ` source: string ` , ` destination: string ` |
48+ | ` file:mkdir ` | Create directory | ` path: string ` , ` recursive: boolean ` |
49+ | ` file:readdir ` | List directory contents | ` path: string ` |
4450
4551## Usage
4652
4753### Basic Usage
4854
4955``` typescript
50- import { FileSystemProviderTag } from " ./FileSystem/index.js" ;
5156import { Effect } from " effect" ;
5257
58+ import { FileSystemProviderTag } from " ./FileSystem/index.js" ;
59+
5360// Get the service
5461const program = Effect .gen (function * () {
55- const fs = yield * FileSystemProviderTag ;
62+ const fs = yield * FileSystemProviderTag ;
5663
57- // Read a file
58- const content = yield * fs .readFile (" file:///path/to/file.txt" );
59- console .log (content );
64+ // Read a file
65+ const content = yield * fs .readFile (" file:///path/to/file.txt" );
66+ console .log (content );
6067
61- // List directory
62- const entries = yield * fs .readdir (" file:///path/to/dir" );
63- console .log (entries );
68+ // List directory
69+ const entries = yield * fs .readdir (" file:///path/to/dir" );
70+ console .log (entries );
6471
65- // Get file stats
66- const stats = yield * fs .stat (" file:///path/to/file.txt" );
67- console .log (stats );
72+ // Get file stats
73+ const stats = yield * fs .stat (" file:///path/to/file.txt" );
74+ console .log (stats );
6875});
6976```
7077
@@ -88,41 +95,49 @@ console.log(parsed.dirname()); // URI of "/path/to"
8895
8996``` typescript
9097import {
91- FileNotFoundError ,
92- FileExistsError ,
93- PermissionError ,
94- toFileSystemProviderError ,
98+ FileExistsError ,
99+ FileNotFoundError ,
100+ PermissionError ,
101+ toFileSystemProviderError ,
95102} from " ./FileSystem/index.js" ;
96103
97104try {
98- // ...
105+ // ...
99106} catch (error ) {
100- const fsError = toFileSystemProviderError (error , " readFile" , " /path/to/file" );
101-
102- if (fsError instanceof FileNotFoundError ) {
103- console .log (" File not found:" , fsError .message );
104- } else if (fsError instanceof PermissionError ) {
105- console .log (" Permission denied:" , fsError .message );
106- }
107+ const fsError = toFileSystemProviderError (
108+ error ,
109+ " readFile" ,
110+ " /path/to/file" ,
111+ );
112+
113+ if (fsError instanceof FileNotFoundError ) {
114+ console .log (" File not found:" , fsError .message );
115+ } else if (fsError instanceof PermissionError ) {
116+ console .log (" Permission denied:" , fsError .message );
117+ }
107118}
108119```
109120
110121### Layer Composition
111122
112123``` typescript
113- import { FileSystemProviderLive , FileSystemProviderTag } from " ./FileSystem/index.js" ;
114124import { Layer } from " effect" ;
125+
115126import { IPCTauriLive } from " ./Effect/IPC.js" ;
127+ import {
128+ FileSystemProviderLive ,
129+ FileSystemProviderTag ,
130+ } from " ./FileSystem/index.js" ;
116131
117132// Create the FileSystem layer
118133const FileSystemLayer = FileSystemProviderLive .pipe (
119- Layer .provide (IPCTauriLive ),
134+ Layer .provide (IPCTauriLive ),
120135);
121136
122137// Use in runtime
123138const program = Effect .gen (function * () {
124- const fs = yield * FileSystemProviderTag ;
125- // ...
139+ const fs = yield * FileSystemProviderTag ;
140+ // ...
126141}).pipe (Effect .provide (FileSystemLayer ));
127142```
128143
@@ -132,11 +147,11 @@ const program = Effect.gen(function* () {
132147import { FileType } from " ./FileSystem/index.js" ;
133148
134149if (stats .type === FileType .File ) {
135- console .log (" This is a file" );
150+ console .log (" This is a file" );
136151} else if (stats .type === FileType .Directory ) {
137- console .log (" This is a directory" );
152+ console .log (" This is a directory" );
138153} else if (stats .type === FileType .SymbolicLink ) {
139- console .log (" This is a symbolic link" );
154+ console .log (" This is a symbolic link" );
140155}
141156```
142157
@@ -165,17 +180,19 @@ FileSystem/
165180To integrate with the VSCode browser workbench:
166181
1671821 . Register the file system provider:
183+
168184``` typescript
169185// In workbench initialization
170- const fs = yield * FileSystemProviderTag ;
171- vscode .workspace .registerFileSystemProvider (' file' , fs );
186+ const fs = yield * FileSystemProviderTag ;
187+ vscode .workspace .registerFileSystemProvider (" file" , fs );
172188```
173189
1741902 . The workbench will automatically use this provider for all file operations.
175191
176192## Future Enhancements
177193
178- - ** File Watching** : Implement ` watch() ` method for real-time file change notifications
194+ - ** File Watching** : Implement ` watch() ` method for real-time file change
195+ notifications
179196- ** Binary File Support** : Add specialized binary file read/write operations
180197- ** Search** : Implement recursive file search functionality
181198- ** Permissions** : Add more granular permission checking
0 commit comments