chore: Extract '.gemini' to GEMINI_DIR constant (#10540)

Co-authored-by: Richie Foreman <richie.foreman@gmail.com>
This commit is contained in:
Dongin Kim(Terry)
2025-10-14 02:31:39 +09:00
committed by GitHub
parent 7beaa368a9
commit 518caae62e
36 changed files with 181 additions and 157 deletions

View File

@@ -11,13 +11,10 @@ import fs from 'node:fs';
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { quote, parse } from 'shell-quote';
import {
USER_SETTINGS_DIR,
SETTINGS_DIRECTORY_NAME,
} from '../config/settings.js';
import { USER_SETTINGS_DIR } from '../config/settings.js';
import { promisify } from 'node:util';
import type { Config, SandboxConfig } from '@google/gemini-cli-core';
import { FatalSandboxError } from '@google/gemini-cli-core';
import { FatalSandboxError, GEMINI_DIR } from '@google/gemini-cli-core';
import { ConsolePatcher } from '../ui/utils/ConsolePatcher.js';
import { randomBytes } from 'node:crypto';
@@ -156,10 +153,7 @@ function entrypoint(workdir: string, cliArgs: string[]): string[] {
shellCmds.push(`export PYTHONPATH="$PYTHONPATH${pythonPathSuffix}";`);
}
const projectSandboxBashrc = path.join(
SETTINGS_DIRECTORY_NAME,
'sandbox.bashrc',
);
const projectSandboxBashrc = path.join(GEMINI_DIR, 'sandbox.bashrc');
if (fs.existsSync(projectSandboxBashrc)) {
shellCmds.push(`source ${getContainerPath(projectSandboxBashrc)};`);
}
@@ -211,10 +205,7 @@ export async function start_sandbox(
);
// if profile name is not recognized, then look for file under project settings directory
if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
profileFile = path.join(
SETTINGS_DIRECTORY_NAME,
`sandbox-macos-${profile}.sb`,
);
profileFile = path.join(GEMINI_DIR, `sandbox-macos-${profile}.sb`);
}
if (!fs.existsSync(profileFile)) {
throw new FatalSandboxError(
@@ -359,7 +350,7 @@ export async function start_sandbox(
const gcPath = fs.realpathSync(process.argv[1]);
const projectSandboxDockerfile = path.join(
SETTINGS_DIRECTORY_NAME,
GEMINI_DIR,
'sandbox.Dockerfile',
);
const isCustomProjectSandbox = fs.existsSync(projectSandboxDockerfile);
@@ -383,7 +374,7 @@ export async function start_sandbox(
// if project folder has sandbox.Dockerfile under project settings folder, use that
let buildArgs = '';
const projectSandboxDockerfile = path.join(
SETTINGS_DIRECTORY_NAME,
GEMINI_DIR,
'sandbox.Dockerfile',
);
if (isCustomProjectSandbox) {
@@ -441,7 +432,7 @@ export async function start_sandbox(
// note user/home changes inside sandbox and we mount at BOTH paths for consistency
const userSettingsDirOnHost = USER_SETTINGS_DIR;
const userSettingsDirInSandbox = getContainerPath(
`/home/node/${SETTINGS_DIRECTORY_NAME}`,
`/home/node/${GEMINI_DIR}`,
);
if (!fs.existsSync(userSettingsDirOnHost)) {
fs.mkdirSync(userSettingsDirOnHost);
@@ -665,10 +656,7 @@ export async function start_sandbox(
?.toLowerCase()
.startsWith(workdir.toLowerCase())
) {
const sandboxVenvPath = path.resolve(
SETTINGS_DIRECTORY_NAME,
'sandbox.venv',
);
const sandboxVenvPath = path.resolve(GEMINI_DIR, 'sandbox.venv');
if (!fs.existsSync(sandboxVenvPath)) {
fs.mkdirSync(sandboxVenvPath, { recursive: true });
}