From ea63a8401e6558bdd67d556812ed065b4bb07e9e Mon Sep 17 00:00:00 2001 From: Louis Jimenez Date: Thu, 19 Jun 2025 23:53:24 -0400 Subject: Move the shell history our of the project .gemini to the home dir (#1195) --- packages/core/src/utils/paths.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'packages/core/src/utils') diff --git a/packages/core/src/utils/paths.ts b/packages/core/src/utils/paths.ts index 28f2f1f0..28ca5cbc 100644 --- a/packages/core/src/utils/paths.ts +++ b/packages/core/src/utils/paths.ts @@ -6,6 +6,10 @@ import path from 'node:path'; import os from 'os'; +import * as crypto from 'crypto'; + +export const GEMINI_DIR = '.gemini'; +const TMP_DIR_NAME = 'tmp'; /** * Replaces the home directory with a tilde. @@ -134,3 +138,22 @@ export function escapePath(filePath: string): string { export function unescapePath(filePath: string): string { return filePath.replace(/\\ /g, ' '); } + +/** + * Generates a unique hash for a project based on its root path. + * @param projectRoot The absolute path to the project's root directory. + * @returns A SHA256 hash of the project root path. + */ +export function getProjectHash(projectRoot: string): string { + return crypto.createHash('sha256').update(projectRoot).digest('hex'); +} + +/** + * Generates a unique temporary directory path for a project. + * @param projectRoot The absolute path to the project's root directory. + * @returns The path to the project's temporary directory. + */ +export function getProjectTempDir(projectRoot: string): string { + const hash = getProjectHash(projectRoot); + return path.join(os.homedir(), GEMINI_DIR, TMP_DIR_NAME, hash); +} -- cgit v1.2.3