2025-07-08 04:45:44 +08:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-07-17 06:36:14 +08:00
|
|
|
import { Config } from '@google/gemini-cli-core';
|
2025-07-08 04:45:44 +08:00
|
|
|
import { SlashCommand } from '../ui/commands/types.js';
|
|
|
|
|
import { memoryCommand } from '../ui/commands/memoryCommand.js';
|
|
|
|
|
import { helpCommand } from '../ui/commands/helpCommand.js';
|
|
|
|
|
import { clearCommand } from '../ui/commands/clearCommand.js';
|
2025-07-16 23:56:05 +08:00
|
|
|
import { docsCommand } from '../ui/commands/docsCommand.js';
|
2025-07-16 10:35:05 +08:00
|
|
|
import { mcpCommand } from '../ui/commands/mcpCommand.js';
|
2025-07-15 00:22:37 +08:00
|
|
|
import { authCommand } from '../ui/commands/authCommand.js';
|
2025-07-12 04:01:28 +08:00
|
|
|
import { themeCommand } from '../ui/commands/themeCommand.js';
|
2025-07-17 08:27:36 +08:00
|
|
|
import { editorCommand } from '../ui/commands/editorCommand.js';
|
2025-07-16 08:47:56 +08:00
|
|
|
import { chatCommand } from '../ui/commands/chatCommand.js';
|
2025-07-16 04:10:04 +08:00
|
|
|
import { statsCommand } from '../ui/commands/statsCommand.js';
|
2025-07-15 13:45:06 +08:00
|
|
|
import { privacyCommand } from '../ui/commands/privacyCommand.js';
|
2025-07-15 14:22:46 +08:00
|
|
|
import { aboutCommand } from '../ui/commands/aboutCommand.js';
|
2025-07-16 05:40:09 +08:00
|
|
|
import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
|
2025-07-17 04:12:22 +08:00
|
|
|
import { toolsCommand } from '../ui/commands/toolsCommand.js';
|
|
|
|
|
import { compressCommand } from '../ui/commands/compressCommand.js';
|
2025-07-17 06:36:14 +08:00
|
|
|
import { ideCommand } from '../ui/commands/ideCommand.js';
|
2025-07-17 09:46:35 +08:00
|
|
|
import { bugCommand } from '../ui/commands/bugCommand.js';
|
2025-07-17 10:40:56 +08:00
|
|
|
import { quitCommand } from '../ui/commands/quitCommand.js';
|
2025-07-08 04:45:44 +08:00
|
|
|
|
2025-07-17 06:36:14 +08:00
|
|
|
const loadBuiltInCommands = async (
|
|
|
|
|
config: Config | null,
|
|
|
|
|
): Promise<SlashCommand[]> => {
|
|
|
|
|
const allCommands = [
|
|
|
|
|
aboutCommand,
|
|
|
|
|
authCommand,
|
2025-07-17 09:46:35 +08:00
|
|
|
bugCommand,
|
2025-07-17 06:36:14 +08:00
|
|
|
chatCommand,
|
|
|
|
|
clearCommand,
|
|
|
|
|
compressCommand,
|
|
|
|
|
docsCommand,
|
2025-07-17 08:27:36 +08:00
|
|
|
editorCommand,
|
2025-07-17 06:36:14 +08:00
|
|
|
extensionsCommand,
|
|
|
|
|
helpCommand,
|
|
|
|
|
ideCommand(config),
|
|
|
|
|
mcpCommand,
|
|
|
|
|
memoryCommand,
|
|
|
|
|
privacyCommand,
|
2025-07-17 10:40:56 +08:00
|
|
|
quitCommand,
|
2025-07-17 06:36:14 +08:00
|
|
|
statsCommand,
|
|
|
|
|
themeCommand,
|
|
|
|
|
toolsCommand,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return allCommands.filter(
|
|
|
|
|
(command): command is SlashCommand => command !== null,
|
|
|
|
|
);
|
|
|
|
|
};
|
2025-07-08 04:45:44 +08:00
|
|
|
|
|
|
|
|
export class CommandService {
|
|
|
|
|
private commands: SlashCommand[] = [];
|
|
|
|
|
|
|
|
|
|
constructor(
|
2025-07-17 06:36:14 +08:00
|
|
|
private config: Config | null,
|
|
|
|
|
private commandLoader: (
|
|
|
|
|
config: Config | null,
|
|
|
|
|
) => Promise<SlashCommand[]> = loadBuiltInCommands,
|
2025-07-08 04:45:44 +08:00
|
|
|
) {
|
|
|
|
|
// The constructor can be used for dependency injection in the future.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async loadCommands(): Promise<void> {
|
|
|
|
|
// For now, we only load the built-in commands.
|
|
|
|
|
// File-based and remote commands will be added later.
|
2025-07-17 06:36:14 +08:00
|
|
|
this.commands = await this.commandLoader(this.config);
|
2025-07-08 04:45:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCommands(): SlashCommand[] {
|
|
|
|
|
return this.commands;
|
|
|
|
|
}
|
|
|
|
|
}
|