99 */
1010
1111import { app , BrowserWindow , ipcMain , dialog , shell , nativeTheme , Menu } from 'electron' ;
12- import { join } from 'node:path' ;
13- import { readFile , writeFile } from 'node:fs/promises' ;
12+ import { dirname , join } from 'node:path' ;
13+ import { mkdir , readFile , writeFile } from 'node:fs/promises' ;
1414import { watch , type FSWatcher } from 'node:fs' ;
1515import { is } from '@electron-toolkit/utils' ;
1616import { setupMCPIPC } from './mcp-client' ;
@@ -82,6 +82,13 @@ function setupIPC(): void {
8282 return result . canceled ? null : result . filePaths [ 0 ] ;
8383 } ) ;
8484
85+ ipcMain . handle ( 'fs:pick-directory' , async ( ) => {
86+ const result = await dialog . showOpenDialog ( mainWindow ! , {
87+ properties : [ 'openDirectory' , 'createDirectory' ] ,
88+ } ) ;
89+ return result . canceled ? null : result . filePaths [ 0 ] ;
90+ } ) ;
91+
8592 ipcMain . handle ( 'fs:save-dialog' , async ( _event ) => {
8693 const result = await dialog . showSaveDialog ( mainWindow ! , {
8794 filters : [
@@ -92,6 +99,14 @@ function setupIPC(): void {
9299 return result . canceled ? null : result . filePath ;
93100 } ) ;
94101
102+ ipcMain . handle ( 'fs:write-batch' , async ( _event , basePath : string , files : Array < { path : string ; content : string } > ) => {
103+ for ( const file of files ) {
104+ const targetPath = join ( basePath , file . path ) ;
105+ await mkdir ( dirname ( targetPath ) , { recursive : true } ) ;
106+ await writeFile ( targetPath , file . content , 'utf-8' ) ;
107+ }
108+ } ) ;
109+
95110 // Theme
96111 ipcMain . handle ( 'theme:get' , ( ) => {
97112 return nativeTheme . shouldUseDarkColors ? 'dark' : 'light' ;
0 commit comments