2025-07-20 16:57:34 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-10-07 10:28:35 -07:00
|
|
|
import { isDevelopment } from '../utils/installationInfo.js';
|
2025-08-26 00:04:53 +02:00
|
|
|
import type { ICommandLoader } from './types.js';
|
2026-01-06 16:38:07 -05:00
|
|
|
import {
|
|
|
|
|
CommandKind,
|
|
|
|
|
type SlashCommand,
|
|
|
|
|
type CommandContext,
|
|
|
|
|
} from '../ui/commands/types.js';
|
|
|
|
|
import type { MessageActionReturn, Config } from '@google/gemini-cli-core';
|
2025-12-01 10:06:13 -08:00
|
|
|
import { startupProfiler } from '@google/gemini-cli-core';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { aboutCommand } from '../ui/commands/aboutCommand.js';
|
|
|
|
|
import { authCommand } from '../ui/commands/authCommand.js';
|
|
|
|
|
import { bugCommand } from '../ui/commands/bugCommand.js';
|
|
|
|
|
import { chatCommand } from '../ui/commands/chatCommand.js';
|
|
|
|
|
import { clearCommand } from '../ui/commands/clearCommand.js';
|
|
|
|
|
import { compressCommand } from '../ui/commands/compressCommand.js';
|
|
|
|
|
import { copyCommand } from '../ui/commands/copyCommand.js';
|
|
|
|
|
import { corgiCommand } from '../ui/commands/corgiCommand.js';
|
|
|
|
|
import { docsCommand } from '../ui/commands/docsCommand.js';
|
2025-08-01 04:02:08 +09:00
|
|
|
import { directoryCommand } from '../ui/commands/directoryCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { editorCommand } from '../ui/commands/editorCommand.js';
|
|
|
|
|
import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
|
|
|
|
|
import { helpCommand } from '../ui/commands/helpCommand.js';
|
2025-12-03 10:01:57 -08:00
|
|
|
import { hooksCommand } from '../ui/commands/hooksCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { ideCommand } from '../ui/commands/ideCommand.js';
|
2025-07-29 12:49:01 -04:00
|
|
|
import { initCommand } from '../ui/commands/initCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { mcpCommand } from '../ui/commands/mcpCommand.js';
|
|
|
|
|
import { memoryCommand } from '../ui/commands/memoryCommand.js';
|
2025-09-23 12:50:09 -04:00
|
|
|
import { modelCommand } from '../ui/commands/modelCommand.js';
|
2025-09-22 11:45:02 -07:00
|
|
|
import { permissionsCommand } from '../ui/commands/permissionsCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { privacyCommand } from '../ui/commands/privacyCommand.js';
|
2025-11-03 15:41:00 -08:00
|
|
|
import { policiesCommand } from '../ui/commands/policiesCommand.js';
|
2025-10-07 10:28:35 -07:00
|
|
|
import { profileCommand } from '../ui/commands/profileCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { quitCommand } from '../ui/commands/quitCommand.js';
|
|
|
|
|
import { restoreCommand } from '../ui/commands/restoreCommand.js';
|
2025-11-25 11:54:09 -07:00
|
|
|
import { resumeCommand } from '../ui/commands/resumeCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
import { statsCommand } from '../ui/commands/statsCommand.js';
|
|
|
|
|
import { themeCommand } from '../ui/commands/themeCommand.js';
|
|
|
|
|
import { toolsCommand } from '../ui/commands/toolsCommand.js';
|
2025-12-30 13:35:52 -08:00
|
|
|
import { skillsCommand } from '../ui/commands/skillsCommand.js';
|
2025-08-10 09:04:52 +09:00
|
|
|
import { settingsCommand } from '../ui/commands/settingsCommand.js';
|
2025-07-25 15:36:42 -07:00
|
|
|
import { vimCommand } from '../ui/commands/vimCommand.js';
|
2025-07-31 18:14:22 -04:00
|
|
|
import { setupGithubCommand } from '../ui/commands/setupGithubCommand.js';
|
2025-08-13 13:32:54 -04:00
|
|
|
import { terminalSetupCommand } from '../ui/commands/terminalSetupCommand.js';
|
2025-07-20 16:57:34 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Loads the core, hard-coded slash commands that are an integral part
|
|
|
|
|
* of the Gemini CLI application.
|
|
|
|
|
*/
|
|
|
|
|
export class BuiltinCommandLoader implements ICommandLoader {
|
|
|
|
|
constructor(private config: Config | null) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gathers all raw built-in command definitions, injects dependencies where
|
|
|
|
|
* needed (e.g., config) and filters out any that are not available.
|
|
|
|
|
*
|
|
|
|
|
* @param _signal An AbortSignal (unused for this synchronous loader).
|
|
|
|
|
* @returns A promise that resolves to an array of `SlashCommand` objects.
|
|
|
|
|
*/
|
|
|
|
|
async loadCommands(_signal: AbortSignal): Promise<SlashCommand[]> {
|
2025-12-01 10:06:13 -08:00
|
|
|
const handle = startupProfiler.start('load_builtin_commands');
|
2025-07-20 16:57:34 -04:00
|
|
|
const allDefinitions: Array<SlashCommand | null> = [
|
|
|
|
|
aboutCommand,
|
|
|
|
|
authCommand,
|
|
|
|
|
bugCommand,
|
|
|
|
|
chatCommand,
|
|
|
|
|
clearCommand,
|
|
|
|
|
compressCommand,
|
|
|
|
|
copyCommand,
|
|
|
|
|
corgiCommand,
|
|
|
|
|
docsCommand,
|
2025-08-01 04:02:08 +09:00
|
|
|
directoryCommand,
|
2025-07-20 16:57:34 -04:00
|
|
|
editorCommand,
|
2026-01-07 14:35:56 -05:00
|
|
|
extensionsCommand(this.config?.getEnableExtensionReloading()),
|
2025-07-20 16:57:34 -04:00
|
|
|
helpCommand,
|
2026-01-07 12:34:33 -08:00
|
|
|
...(this.config?.getEnableHooksUI() ? [hooksCommand] : []),
|
2025-09-04 09:32:09 -07:00
|
|
|
await ideCommand(),
|
2025-07-29 12:49:01 -04:00
|
|
|
initCommand,
|
2026-01-06 16:38:07 -05:00
|
|
|
...(this.config?.getMcpEnabled() === false
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
name: 'mcp',
|
|
|
|
|
description:
|
|
|
|
|
'Manage configured Model Context Protocol (MCP) servers',
|
|
|
|
|
kind: CommandKind.BUILT_IN,
|
|
|
|
|
autoExecute: false,
|
|
|
|
|
subCommands: [],
|
|
|
|
|
action: async (
|
|
|
|
|
_context: CommandContext,
|
|
|
|
|
): Promise<MessageActionReturn> => ({
|
|
|
|
|
type: 'message',
|
|
|
|
|
messageType: 'error',
|
2026-01-07 14:35:56 -05:00
|
|
|
content: 'MCP disabled by your admin.',
|
2026-01-06 16:38:07 -05:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: [mcpCommand]),
|
2025-07-20 16:57:34 -04:00
|
|
|
memoryCommand,
|
2025-11-21 09:54:17 -08:00
|
|
|
modelCommand,
|
2025-09-23 12:50:09 -04:00
|
|
|
...(this.config?.getFolderTrust() ? [permissionsCommand] : []),
|
2025-07-20 16:57:34 -04:00
|
|
|
privacyCommand,
|
2025-12-29 14:22:42 -05:00
|
|
|
policiesCommand,
|
2025-10-07 10:28:35 -07:00
|
|
|
...(isDevelopment ? [profileCommand] : []),
|
2025-07-20 16:57:34 -04:00
|
|
|
quitCommand,
|
|
|
|
|
restoreCommand(this.config),
|
2025-11-25 11:54:09 -07:00
|
|
|
resumeCommand,
|
2025-07-20 16:57:34 -04:00
|
|
|
statsCommand,
|
|
|
|
|
themeCommand,
|
|
|
|
|
toolsCommand,
|
2025-12-30 13:35:52 -08:00
|
|
|
...(this.config?.isSkillsSupportEnabled() ? [skillsCommand] : []),
|
2025-08-10 09:04:52 +09:00
|
|
|
settingsCommand,
|
2025-07-25 15:36:42 -07:00
|
|
|
vimCommand,
|
2025-08-06 09:06:37 -04:00
|
|
|
setupGithubCommand,
|
2025-08-13 13:32:54 -04:00
|
|
|
terminalSetupCommand,
|
2025-07-20 16:57:34 -04:00
|
|
|
];
|
2025-12-01 10:06:13 -08:00
|
|
|
handle?.end();
|
2025-07-20 16:57:34 -04:00
|
|
|
return allDefinitions.filter((cmd): cmd is SlashCommand => cmd !== null);
|
|
|
|
|
}
|
|
|
|
|
}
|