From 21c6480b65528a98ac0e1e3855f3c78c1f9b7cbe Mon Sep 17 00:00:00 2001 From: Yuki Okita Date: Wed, 20 Aug 2025 10:55:47 +0900 Subject: Refac: Centralize storage file management (#4078) Co-authored-by: Taylor Mullen --- packages/core/src/config/config.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'packages/core/src/config/config.ts') diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 6a8e6d4b..39e885e2 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -22,16 +22,11 @@ import { ShellTool } from '../tools/shell.js'; import { WriteFileTool } from '../tools/write-file.js'; import { WebFetchTool } from '../tools/web-fetch.js'; import { ReadManyFilesTool } from '../tools/read-many-files.js'; -import { - MemoryTool, - setGeminiMdFilename, - GEMINI_CONFIG_DIR as GEMINI_DIR, -} from '../tools/memoryTool.js'; +import { MemoryTool, setGeminiMdFilename } from '../tools/memoryTool.js'; import { WebSearchTool } from '../tools/web-search.js'; import { GeminiClient } from '../core/client.js'; import { FileDiscoveryService } from '../services/fileDiscoveryService.js'; import { GitService } from '../services/gitService.js'; -import { getProjectTempDir } from '../utils/paths.js'; import { initializeTelemetry, DEFAULT_TELEMETRY_TARGET, @@ -57,6 +52,7 @@ import { IdeConnectionEvent, IdeConnectionType } from '../telemetry/types.js'; // Re-export OAuth config type export type { MCPOAuthConfig }; import { WorkspaceContext } from '../utils/workspaceContext.js'; +import { Storage } from './storage.js'; export enum ApprovalMode { DEFAULT = 'default', @@ -272,6 +268,7 @@ export class Config { private readonly shouldUseNodePtyShell: boolean; private readonly skipNextSpeakerCheck: boolean; private initialized: boolean = false; + readonly storage: Storage; constructor(params: ConfigParameters) { this.sessionId = params.sessionId; @@ -340,6 +337,7 @@ export class Config { this.trustedFolder = params.trustedFolder; this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? false; this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? false; + this.storage = new Storage(this.targetDir); if (params.contextFileName) { setGeminiMdFilename(params.contextFileName); @@ -591,14 +589,6 @@ export class Config { return this.geminiClient; } - getGeminiDir(): string { - return path.join(this.targetDir, GEMINI_DIR); - } - - getProjectTempDir(): string { - return getProjectTempDir(this.getProjectRoot()); - } - getEnableRecursiveFileSearch(): boolean { return this.fileFiltering.enableRecursiveFileSearch; } @@ -744,7 +734,7 @@ export class Config { async getGitService(): Promise { if (!this.gitService) { - this.gitService = new GitService(this.targetDir); + this.gitService = new GitService(this.targetDir, this.storage); await this.gitService.initialize(); } return this.gitService; -- cgit v1.2.3