diff options
| author | Conrad Irwin <[email protected]> | 2025-08-18 16:29:45 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-18 22:29:45 +0000 |
| commit | fb3ceb0da4e2cd636013c2c36a9c0016c01aa47f (patch) | |
| tree | 7aa43846dd88bd5acdb8898b0ccd2e685f2d5ece /packages/cli/src/zed-integration/fileSystemService.ts | |
| parent | 4394b6ab4fc86637b07fcd26b9a790c627d1e065 (diff) | |
Read and write files through Zed (#6169)
Co-authored-by: Agus Zubiaga <[email protected]>
Diffstat (limited to 'packages/cli/src/zed-integration/fileSystemService.ts')
| -rw-r--r-- | packages/cli/src/zed-integration/fileSystemService.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/cli/src/zed-integration/fileSystemService.ts b/packages/cli/src/zed-integration/fileSystemService.ts new file mode 100644 index 00000000..deb9857f --- /dev/null +++ b/packages/cli/src/zed-integration/fileSystemService.ts @@ -0,0 +1,47 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { FileSystemService } from '@google/gemini-cli-core'; +import * as acp from './acp.js'; + +/** + * ACP client-based implementation of FileSystemService + */ +export class AcpFileSystemService implements FileSystemService { + constructor( + private readonly client: acp.Client, + private readonly sessionId: string, + private readonly capabilities: acp.FileSystemCapability, + private readonly fallback: FileSystemService, + ) {} + + async readTextFile(filePath: string): Promise<string> { + if (!this.capabilities.readTextFile) { + return this.fallback.readTextFile(filePath); + } + + const response = await this.client.readTextFile({ + path: filePath, + sessionId: this.sessionId, + line: null, + limit: null, + }); + + return response.content; + } + + async writeTextFile(filePath: string, content: string): Promise<void> { + if (!this.capabilities.writeTextFile) { + return this.fallback.writeTextFile(filePath, content); + } + + await this.client.writeTextFile({ + path: filePath, + content, + sessionId: this.sessionId, + }); + } +} |
