mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
feat(workspaces): improve prompt UX for sensitive defaults and mask API keys
This commit is contained in:
@@ -9,7 +9,7 @@ import { ProviderFactory } from './providers/ProviderFactory.ts';
|
|||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
||||||
|
|
||||||
async function prompt(question: string, defaultValue: string, explanation?: string): Promise<string> {
|
async function prompt(question: string, defaultValue: string, explanation?: string, sensitive: boolean = false): Promise<string> {
|
||||||
const autoAccept = process.argv.includes('--yes') || process.argv.includes('-y');
|
const autoAccept = process.argv.includes('--yes') || process.argv.includes('-y');
|
||||||
if (autoAccept && defaultValue) return defaultValue;
|
if (autoAccept && defaultValue) return defaultValue;
|
||||||
|
|
||||||
@@ -17,9 +17,10 @@ async function prompt(question: string, defaultValue: string, explanation?: stri
|
|||||||
console.log(`\n📖 ${explanation}`);
|
console.log(`\n📖 ${explanation}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const displayDefault = sensitive && defaultValue ? `${defaultValue.substring(0, 4)}...${defaultValue.substring(defaultValue.length - 4)}` : defaultValue;
|
||||||
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
rl.question(`❓ ${question} (default: ${defaultValue}, <Enter> to use default): `, (answer) => {
|
rl.question(`❓ ${question} (default: ${displayDefault || 'none'}, <Enter> to use default): `, (answer) => {
|
||||||
rl.close();
|
rl.close();
|
||||||
resolve(answer.trim() || defaultValue);
|
resolve(answer.trim() || defaultValue);
|
||||||
});
|
});
|
||||||
@@ -195,7 +196,7 @@ and full builds) to a dedicated, high-performance GCP worker.
|
|||||||
|
|
||||||
if (authStrategy === 'gemini-api-key' && !geminiApiKey) {
|
if (authStrategy === 'gemini-api-key' && !geminiApiKey) {
|
||||||
console.log('\n📖 In API Key mode, the remote worker needs your Gemini API Key to authenticate.');
|
console.log('\n📖 In API Key mode, the remote worker needs your Gemini API Key to authenticate.');
|
||||||
geminiApiKey = await prompt('Paste Gemini API Key', '');
|
geminiApiKey = await prompt('Paste Gemini API Key', '', undefined, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Save Confirmed State
|
// 5. Save Confirmed State
|
||||||
|
|||||||
Reference in New Issue
Block a user