|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2026 Google LLC |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +import { |
| 8 | + IdeClient, |
| 9 | + UserAccountManager, |
| 10 | + getVersion, |
| 11 | +} from '@google/gemini-cli-core'; |
| 12 | +import type { |
| 13 | + Command, |
| 14 | + CommandContext, |
| 15 | + CommandExecutionResponse, |
| 16 | +} from './types.js'; |
| 17 | +import process from 'node:process'; |
| 18 | + |
| 19 | +export class AboutCommand implements Command { |
| 20 | + readonly name = 'about'; |
| 21 | + readonly description = 'Show version and environment info'; |
| 22 | + |
| 23 | + async execute( |
| 24 | + context: CommandContext, |
| 25 | + _args: string[] = [], |
| 26 | + ): Promise<CommandExecutionResponse> { |
| 27 | + const osVersion = process.platform; |
| 28 | + let sandboxEnv = 'no sandbox'; |
| 29 | + if (process.env['SANDBOX'] && process.env['SANDBOX'] !== 'sandbox-exec') { |
| 30 | + sandboxEnv = process.env['SANDBOX']; |
| 31 | + } else if (process.env['SANDBOX'] === 'sandbox-exec') { |
| 32 | + sandboxEnv = `sandbox-exec (${ |
| 33 | + process.env['SEATBELT_PROFILE'] || 'unknown' |
| 34 | + })`; |
| 35 | + } |
| 36 | + const modelVersion = context.agentContext.config.getModel() || 'Unknown'; |
| 37 | + const cliVersion = await getVersion(); |
| 38 | + const selectedAuthType = |
| 39 | + context.settings.merged?.security?.auth?.selectedType ?? ''; |
| 40 | + const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || ''; |
| 41 | + const ideClient = await getIdeClientName(context); |
| 42 | + |
| 43 | + const userAccountManager = new UserAccountManager(); |
| 44 | + const cachedAccount = userAccountManager.getCachedGoogleAccount(); |
| 45 | + const userEmail = cachedAccount ?? 'Unknown'; |
| 46 | + |
| 47 | + const tier = context.agentContext.config.getUserTierName() || 'Unknown'; |
| 48 | + |
| 49 | + const info = [ |
| 50 | + `- Version: ${cliVersion}`, |
| 51 | + `- OS: ${osVersion}`, |
| 52 | + `- Sandbox: ${sandboxEnv}`, |
| 53 | + `- Model: ${modelVersion}`, |
| 54 | + `- Auth Type: ${selectedAuthType}`, |
| 55 | + `- GCP Project: ${gcpProject}`, |
| 56 | + `- IDE Client: ${ideClient}`, |
| 57 | + `- User Email: ${userEmail}`, |
| 58 | + `- Tier: ${tier}`, |
| 59 | + ].join('\n'); |
| 60 | + |
| 61 | + return { |
| 62 | + name: this.name, |
| 63 | + data: `Gemini CLI Info:\n${info}`, |
| 64 | + }; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +async function getIdeClientName(context: CommandContext) { |
| 69 | + if (!context.agentContext.config.getIdeMode()) { |
| 70 | + return ''; |
| 71 | + } |
| 72 | + const ideClient = await IdeClient.getInstance(); |
| 73 | + return ideClient?.getDetectedIdeDisplayName() ?? ''; |
| 74 | +} |
0 commit comments