mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
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 <ntaylormullen@google.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user