diff options
| author | Yuki Okita <[email protected]> | 2025-07-21 06:57:09 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-20 21:57:09 +0000 |
| commit | 0996d91f0b4a0befe3553016518fd40898699f0a (patch) | |
| tree | 5168adba7102a916d703145fcac222732151ccc0 /packages/cli/src/utils/userStartupWarnings.ts | |
| parent | 2a95c8287ed3b6fc38e7dcec5f0a19b9e2d843e7 (diff) | |
feat(cli): add warnings when gemini-cli is called in the root directory (#4542)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/cli/src/utils/userStartupWarnings.ts')
| -rw-r--r-- | packages/cli/src/utils/userStartupWarnings.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/cli/src/utils/userStartupWarnings.ts b/packages/cli/src/utils/userStartupWarnings.ts index 3d76a6e1..8a740906 100644 --- a/packages/cli/src/utils/userStartupWarnings.ts +++ b/packages/cli/src/utils/userStartupWarnings.ts @@ -6,6 +6,7 @@ import fs from 'fs/promises'; import * as os from 'os'; +import path from 'path'; type WarningCheck = { id: string; @@ -32,8 +33,31 @@ const homeDirectoryCheck: WarningCheck = { }, }; +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]; +const WARNING_CHECKS: readonly WarningCheck[] = [ + homeDirectoryCheck, + rootDirectoryCheck, +]; export async function getUserStartupWarnings( workspaceRoot: string, |
