This commit is contained in:
Makgul 2026-01-30 18:39:21 +03:00 committed by GitHub
commit bf40633912
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,13 +64,27 @@ export function extractGeminiCliCredentials(): { clientId: string; clientSecret:
if (!geminiPath) return null;
const resolvedPath = realpathSync(geminiPath);
const geminiCliDir = dirname(dirname(resolvedPath));
const searchPaths = [
join(geminiCliDir, "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
join(geminiCliDir, "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js"),
// Support both Unix symlinks and Windows npm shims
const bases = [
dirname(dirname(resolvedPath)), // Unix: .../pkg/bin/run -> .../pkg
dirname(resolvedPath), // Windows: .../npm/gemini.cmd -> .../npm
];
const searchPaths: string[] = [];
for (const base of bases) {
// 1. Check for flat installation of gemini-cli-core
searchPaths.push(
join(base, "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
join(base, "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js")
);
// 2. Check for nested installation inside gemini-cli
searchPaths.push(
join(base, "node_modules", "@google", "gemini-cli", "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
join(base, "node_modules", "@google", "gemini-cli", "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js")
);
}
let content: string | null = null;
for (const p of searchPaths) {
if (existsSync(p)) {