mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-20 19:11:23 -07:00
Read and write files through Zed (#6169)
Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
41
packages/core/src/services/fileSystemService.ts
Normal file
41
packages/core/src/services/fileSystemService.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import fs from 'fs/promises';
|
||||
|
||||
/**
|
||||
* Interface for file system operations that may be delegated to different implementations
|
||||
*/
|
||||
export interface FileSystemService {
|
||||
/**
|
||||
* Read text content from a file
|
||||
*
|
||||
* @param filePath - The path to the file to read
|
||||
* @returns The file content as a string
|
||||
*/
|
||||
readTextFile(filePath: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Write text content to a file
|
||||
*
|
||||
* @param filePath - The path to the file to write
|
||||
* @param content - The content to write
|
||||
*/
|
||||
writeTextFile(filePath: string, content: string): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard file system implementation
|
||||
*/
|
||||
export class StandardFileSystemService implements FileSystemService {
|
||||
async readTextFile(filePath: string): Promise<string> {
|
||||
return fs.readFile(filePath, 'utf-8');
|
||||
}
|
||||
|
||||
async writeTextFile(filePath: string, content: string): Promise<void> {
|
||||
await fs.writeFile(filePath, content, 'utf-8');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user