2025-07-15 02:22:46 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-04 09:32:09 -07:00
|
|
|
import type { CommandContext, SlashCommand } from './types.js';
|
2025-08-26 00:04:53 +02:00
|
|
|
import { CommandKind } from './types.js';
|
2025-07-15 02:22:46 -04:00
|
|
|
import process from 'node:process';
|
|
|
|
|
import { MessageType, type HistoryItemAbout } from '../types.js';
|
2025-11-19 19:46:21 -08:00
|
|
|
import {
|
|
|
|
|
IdeClient,
|
|
|
|
|
UserAccountManager,
|
|
|
|
|
debugLogger,
|
2025-12-09 16:38:33 -08:00
|
|
|
getVersion,
|
2025-11-19 19:46:21 -08:00
|
|
|
} from '@google/gemini-cli-core';
|
2025-07-15 02:22:46 -04:00
|
|
|
|
|
|
|
|
export const aboutCommand: SlashCommand = {
|
|
|
|
|
name: 'about',
|
2025-10-17 13:20:15 -07:00
|
|
|
description: 'Show version info',
|
2025-07-20 16:57:34 -04:00
|
|
|
kind: CommandKind.BUILT_IN,
|
2025-12-01 12:29:03 -05:00
|
|
|
autoExecute: true,
|
2025-07-15 02:22:46 -04:00
|
|
|
action: async (context) => {
|
|
|
|
|
const osVersion = process.platform;
|
|
|
|
|
let sandboxEnv = 'no sandbox';
|
2025-08-17 12:43:21 -04:00
|
|
|
if (process.env['SANDBOX'] && process.env['SANDBOX'] !== 'sandbox-exec') {
|
|
|
|
|
sandboxEnv = process.env['SANDBOX'];
|
|
|
|
|
} else if (process.env['SANDBOX'] === 'sandbox-exec') {
|
2025-07-15 02:22:46 -04:00
|
|
|
sandboxEnv = `sandbox-exec (${
|
2025-08-17 12:43:21 -04:00
|
|
|
process.env['SEATBELT_PROFILE'] || 'unknown'
|
2025-07-15 02:22:46 -04:00
|
|
|
})`;
|
|
|
|
|
}
|
|
|
|
|
const modelVersion = context.services.config?.getModel() || 'Unknown';
|
2025-12-09 16:38:33 -08:00
|
|
|
const cliVersion = await getVersion();
|
2025-07-15 02:22:46 -04:00
|
|
|
const selectedAuthType =
|
2026-01-15 09:26:10 -08:00
|
|
|
context.services.settings.merged.security.auth.selectedType || '';
|
2025-08-25 16:16:30 -07:00
|
|
|
const gcpProject = process.env['GOOGLE_CLOUD_PROJECT'] || '';
|
2025-09-04 09:32:09 -07:00
|
|
|
const ideClient = await getIdeClientName(context);
|
2025-07-15 02:22:46 -04:00
|
|
|
|
2025-11-19 19:46:21 -08:00
|
|
|
const userAccountManager = new UserAccountManager();
|
|
|
|
|
const cachedAccount = userAccountManager.getCachedGoogleAccount();
|
|
|
|
|
debugLogger.log('AboutCommand: Retrieved cached Google account', {
|
|
|
|
|
cachedAccount,
|
|
|
|
|
});
|
|
|
|
|
const userEmail = cachedAccount ?? undefined;
|
|
|
|
|
|
2026-01-23 16:03:53 -05:00
|
|
|
const tier = context.services.config?.getUserTierName();
|
|
|
|
|
|
2025-07-15 02:22:46 -04:00
|
|
|
const aboutItem: Omit<HistoryItemAbout, 'id'> = {
|
|
|
|
|
type: MessageType.ABOUT,
|
|
|
|
|
cliVersion,
|
|
|
|
|
osVersion,
|
|
|
|
|
sandboxEnv,
|
|
|
|
|
modelVersion,
|
|
|
|
|
selectedAuthType,
|
|
|
|
|
gcpProject,
|
2025-08-15 12:32:15 -04:00
|
|
|
ideClient,
|
2025-11-19 19:46:21 -08:00
|
|
|
userEmail,
|
2026-01-23 16:03:53 -05:00
|
|
|
tier,
|
2025-07-15 02:22:46 -04:00
|
|
|
};
|
|
|
|
|
|
2026-01-13 14:15:04 -05:00
|
|
|
context.ui.addItem(aboutItem);
|
2025-07-15 02:22:46 -04:00
|
|
|
},
|
|
|
|
|
};
|
2025-09-04 09:32:09 -07:00
|
|
|
|
|
|
|
|
async function getIdeClientName(context: CommandContext) {
|
|
|
|
|
if (!context.services.config?.getIdeMode()) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
const ideClient = await IdeClient.getInstance();
|
|
|
|
|
return ideClient?.getDetectedIdeDisplayName() ?? '';
|
|
|
|
|
}
|