Download projects/gemini-cli/packages/cli/src/utils/userStartupWarnings.ts from LevelUp2x/adaptai: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/utils/userStartupWarnings.ts
- Command line
-
hf download hf://datasets/LevelUp2x/adaptai@2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/utils/userStartupWarnings.ts
-
curl -L -o userStartupWarnings.ts https://huggingface.co/datasets/LevelUp2x/adaptai/resolve/2147bc06c2ccf123b96f98eace2e6bf6486e7f0e/projects/gemini-cli/packages/cli/src/utils/userStartupWarnings.ts
1.98 kB
| /** | |
| * @license | |
| * Copyright 2025 Google LLC | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| import fs from 'node:fs/promises'; | |
| import * as os from 'node:os'; | |
| import path from 'node:path'; | |
| type WarningCheck = { | |
| id: string; | |
| check: (workspaceRoot: string) => Promise<string | null>; | |
| }; | |
| // Individual warning checks | |
| const homeDirectoryCheck: WarningCheck = { | |
| id: 'home-directory', | |
| check: async (workspaceRoot: string) => { | |
| try { | |
| const [workspaceRealPath, homeRealPath] = await Promise.all([ | |
| fs.realpath(workspaceRoot), | |
| fs.realpath(os.homedir()), | |
| ]); | |
| if (workspaceRealPath === homeRealPath) { | |
| return 'You are running Gemini CLI in your home directory. It is recommended to run in a project-specific directory.'; | |
| } | |
| return null; | |
| } catch (_err: unknown) { | |
| return 'Could not verify the current directory due to a file system error.'; | |
| } | |
| }, | |
| }; | |
| const rootDirectoryCheck: WarningCheck = { | |
| id: 'root-directory', | |
| check: async (workspaceRoot: string) => { | |
| try { | |
| const workspaceRealPath = await fs.realpath(workspaceRoot); | |
| const errorMessage = | |
| 'Warning: You are running Gemini CLI in the root directory. Your entire folder structure will be used for context. It is strongly recommended to run in a project-specific directory.'; | |
| // Check for Unix root directory | |
| if (path.dirname(workspaceRealPath) === workspaceRealPath) { | |
| return errorMessage; | |
| } | |
| return null; | |
| } catch (_err: unknown) { | |
| return 'Could not verify the current directory due to a file system error.'; | |
| } | |
| }, | |
| }; | |
| // All warning checks | |
| const WARNING_CHECKS: readonly WarningCheck[] = [ | |
| homeDirectoryCheck, | |
| rootDirectoryCheck, | |
| ]; | |
| export async function getUserStartupWarnings( | |
| workspaceRoot: string, | |
| ): Promise<string[]> { | |
| const results = await Promise.all( | |
| WARNING_CHECKS.map((check) => check.check(workspaceRoot)), | |
| ); | |
| return results.filter((msg) => msg !== null); | |
| } | |