blob: ddf2300dde16ef7dd2c0c841fe83c728c404a46c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import fs from 'fs/promises';
import * as os from 'os';
import semver from 'semver';
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 nodeVersionCheck: WarningCheck = {
id: 'node-version',
check: async (_workspaceRoot: string) => {
const minMajor = 20;
const major = semver.major(process.versions.node);
if (major < minMajor) {
return `You are using Node.js v${process.versions.node}. Gemini CLI requires Node.js ${minMajor} or higher for best results.`;
}
return null;
},
};
// All warning checks
const WARNING_CHECKS: readonly WarningCheck[] = [
homeDirectoryCheck,
nodeVersionCheck,
];
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);
}
|