summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/commands')
-rw-r--r--packages/cli/src/ui/commands/aboutCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/authCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/bugCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/chatCommand.ts13
-rw-r--r--packages/cli/src/ui/commands/clearCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/compressCommand.ts5
-rw-r--r--packages/cli/src/ui/commands/copyCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/corgiCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/docsCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/editorCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/extensionsCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/helpCommand.test.ts6
-rw-r--r--packages/cli/src/ui/commands/helpCommand.ts5
-rw-r--r--packages/cli/src/ui/commands/ideCommand.ts4
-rw-r--r--packages/cli/src/ui/commands/mcpCommand.ts2
-rw-r--r--packages/cli/src/ui/commands/memoryCommand.ts10
-rw-r--r--packages/cli/src/ui/commands/privacyCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/quitCommand.ts5
-rw-r--r--packages/cli/src/ui/commands/restoreCommand.ts2
-rw-r--r--packages/cli/src/ui/commands/statsCommand.ts11
-rw-r--r--packages/cli/src/ui/commands/themeCommand.ts3
-rw-r--r--packages/cli/src/ui/commands/toolsCommand.ts7
-rw-r--r--packages/cli/src/ui/commands/types.ts11
23 files changed, 106 insertions, 28 deletions
diff --git a/packages/cli/src/ui/commands/aboutCommand.ts b/packages/cli/src/ui/commands/aboutCommand.ts
index 3cb8c2f6..18a82682 100644
--- a/packages/cli/src/ui/commands/aboutCommand.ts
+++ b/packages/cli/src/ui/commands/aboutCommand.ts
@@ -5,13 +5,14 @@
*/
import { getCliVersion } from '../../utils/version.js';
-import { SlashCommand } from './types.js';
+import { CommandKind, SlashCommand } from './types.js';
import process from 'node:process';
import { MessageType, type HistoryItemAbout } from '../types.js';
export const aboutCommand: SlashCommand = {
name: 'about',
description: 'show version info',
+ kind: CommandKind.BUILT_IN,
action: async (context) => {
const osVersion = process.platform;
let sandboxEnv = 'no sandbox';
diff --git a/packages/cli/src/ui/commands/authCommand.ts b/packages/cli/src/ui/commands/authCommand.ts
index 29bd2c9d..8e78cf86 100644
--- a/packages/cli/src/ui/commands/authCommand.ts
+++ b/packages/cli/src/ui/commands/authCommand.ts
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { OpenDialogActionReturn, SlashCommand } from './types.js';
+import { CommandKind, OpenDialogActionReturn, SlashCommand } from './types.js';
export const authCommand: SlashCommand = {
name: 'auth',
description: 'change the auth method',
+ kind: CommandKind.BUILT_IN,
action: (_context, _args): OpenDialogActionReturn => ({
type: 'dialog',
dialog: 'auth',
diff --git a/packages/cli/src/ui/commands/bugCommand.ts b/packages/cli/src/ui/commands/bugCommand.ts
index c1b99db9..667276ab 100644
--- a/packages/cli/src/ui/commands/bugCommand.ts
+++ b/packages/cli/src/ui/commands/bugCommand.ts
@@ -6,7 +6,11 @@
import open from 'open';
import process from 'node:process';
-import { type CommandContext, type SlashCommand } from './types.js';
+import {
+ type CommandContext,
+ type SlashCommand,
+ CommandKind,
+} from './types.js';
import { MessageType } from '../types.js';
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
import { formatMemoryUsage } from '../utils/formatters.js';
@@ -15,6 +19,7 @@ import { getCliVersion } from '../../utils/version.js';
export const bugCommand: SlashCommand = {
name: 'bug',
description: 'submit a bug report',
+ kind: CommandKind.BUILT_IN,
action: async (context: CommandContext, args?: string): Promise<void> => {
const bugDescription = (args || '').trim();
const { config } = context.services;
diff --git a/packages/cli/src/ui/commands/chatCommand.ts b/packages/cli/src/ui/commands/chatCommand.ts
index fd56afbd..2f669481 100644
--- a/packages/cli/src/ui/commands/chatCommand.ts
+++ b/packages/cli/src/ui/commands/chatCommand.ts
@@ -5,7 +5,12 @@
*/
import * as fsPromises from 'fs/promises';
-import { CommandContext, SlashCommand, MessageActionReturn } from './types.js';
+import {
+ CommandContext,
+ SlashCommand,
+ MessageActionReturn,
+ CommandKind,
+} from './types.js';
import path from 'path';
import { HistoryItemWithoutId, MessageType } from '../types.js';
@@ -54,6 +59,7 @@ const getSavedChatTags = async (
const listCommand: SlashCommand = {
name: 'list',
description: 'List saved conversation checkpoints',
+ kind: CommandKind.BUILT_IN,
action: async (context): Promise<MessageActionReturn> => {
const chatDetails = await getSavedChatTags(context, false);
if (chatDetails.length === 0) {
@@ -81,6 +87,7 @@ const saveCommand: SlashCommand = {
name: 'save',
description:
'Save the current conversation as a checkpoint. Usage: /chat save <tag>',
+ kind: CommandKind.BUILT_IN,
action: async (context, args): Promise<MessageActionReturn> => {
const tag = args.trim();
if (!tag) {
@@ -122,9 +129,10 @@ const saveCommand: SlashCommand = {
const resumeCommand: SlashCommand = {
name: 'resume',
- altName: 'load',
+ altNames: ['load'],
description:
'Resume a conversation from a checkpoint. Usage: /chat resume <tag>',
+ kind: CommandKind.BUILT_IN,
action: async (context, args) => {
const tag = args.trim();
if (!tag) {
@@ -193,5 +201,6 @@ const resumeCommand: SlashCommand = {
export const chatCommand: SlashCommand = {
name: 'chat',
description: 'Manage conversation history.',
+ kind: CommandKind.BUILT_IN,
subCommands: [listCommand, saveCommand, resumeCommand],
};
diff --git a/packages/cli/src/ui/commands/clearCommand.ts b/packages/cli/src/ui/commands/clearCommand.ts
index 1c409359..a2a1c13a 100644
--- a/packages/cli/src/ui/commands/clearCommand.ts
+++ b/packages/cli/src/ui/commands/clearCommand.ts
@@ -5,11 +5,12 @@
*/
import { uiTelemetryService } from '@google/gemini-cli-core';
-import { SlashCommand } from './types.js';
+import { CommandKind, SlashCommand } from './types.js';
export const clearCommand: SlashCommand = {
name: 'clear',
description: 'clear the screen and conversation history',
+ kind: CommandKind.BUILT_IN,
action: async (context, _args) => {
const geminiClient = context.services.config?.getGeminiClient();
diff --git a/packages/cli/src/ui/commands/compressCommand.ts b/packages/cli/src/ui/commands/compressCommand.ts
index c3dfdf37..792e8b5b 100644
--- a/packages/cli/src/ui/commands/compressCommand.ts
+++ b/packages/cli/src/ui/commands/compressCommand.ts
@@ -5,12 +5,13 @@
*/
import { HistoryItemCompression, MessageType } from '../types.js';
-import { SlashCommand } from './types.js';
+import { CommandKind, SlashCommand } from './types.js';
export const compressCommand: SlashCommand = {
name: 'compress',
- altName: 'summarize',
+ altNames: ['summarize'],
description: 'Compresses the context by replacing it with a summary.',
+ kind: CommandKind.BUILT_IN,
action: async (context) => {
const { ui } = context;
if (ui.pendingItem) {
diff --git a/packages/cli/src/ui/commands/copyCommand.ts b/packages/cli/src/ui/commands/copyCommand.ts
index 5714b5ab..bd330faa 100644
--- a/packages/cli/src/ui/commands/copyCommand.ts
+++ b/packages/cli/src/ui/commands/copyCommand.ts
@@ -5,11 +5,16 @@
*/
import { copyToClipboard } from '../utils/commandUtils.js';
-import { SlashCommand, SlashCommandActionReturn } from './types.js';
+import {
+ CommandKind,
+ SlashCommand,
+ SlashCommandActionReturn,
+} from './types.js';
export const copyCommand: SlashCommand = {
name: 'copy',
description: 'Copy the last result or code snippet to clipboard',
+ kind: CommandKind.BUILT_IN,
action: async (context, _args): Promise<SlashCommandActionReturn | void> => {
const chat = await context.services.config?.getGeminiClient()?.getChat();
const history = chat?.getHistory();
diff --git a/packages/cli/src/ui/commands/corgiCommand.ts b/packages/cli/src/ui/commands/corgiCommand.ts
index 290c071e..cb3ecd1c 100644
--- a/packages/cli/src/ui/commands/corgiCommand.ts
+++ b/packages/cli/src/ui/commands/corgiCommand.ts
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { type SlashCommand } from './types.js';
+import { CommandKind, type SlashCommand } from './types.js';
export const corgiCommand: SlashCommand = {
name: 'corgi',
description: 'Toggles corgi mode.',
+ kind: CommandKind.BUILT_IN,
action: (context, _args) => {
context.ui.toggleCorgiMode();
},
diff --git a/packages/cli/src/ui/commands/docsCommand.ts b/packages/cli/src/ui/commands/docsCommand.ts
index e53a4a80..922b236a 100644
--- a/packages/cli/src/ui/commands/docsCommand.ts
+++ b/packages/cli/src/ui/commands/docsCommand.ts
@@ -6,12 +6,17 @@
import open from 'open';
import process from 'node:process';
-import { type CommandContext, type SlashCommand } from './types.js';
+import {
+ type CommandContext,
+ type SlashCommand,
+ CommandKind,
+} from './types.js';
import { MessageType } from '../types.js';
export const docsCommand: SlashCommand = {
name: 'docs',
description: 'open full Gemini CLI documentation in your browser',
+ kind: CommandKind.BUILT_IN,
action: async (context: CommandContext): Promise<void> => {
const docsUrl = 'https://goo.gle/gemini-cli-docs';
diff --git a/packages/cli/src/ui/commands/editorCommand.ts b/packages/cli/src/ui/commands/editorCommand.ts
index dbfafa51..5b5c4c5d 100644
--- a/packages/cli/src/ui/commands/editorCommand.ts
+++ b/packages/cli/src/ui/commands/editorCommand.ts
@@ -4,11 +4,16 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { type OpenDialogActionReturn, type SlashCommand } from './types.js';
+import {
+ CommandKind,
+ type OpenDialogActionReturn,
+ type SlashCommand,
+} from './types.js';
export const editorCommand: SlashCommand = {
name: 'editor',
description: 'set external editor preference',
+ kind: CommandKind.BUILT_IN,
action: (): OpenDialogActionReturn => ({
type: 'dialog',
dialog: 'editor',
diff --git a/packages/cli/src/ui/commands/extensionsCommand.ts b/packages/cli/src/ui/commands/extensionsCommand.ts
index 09241e5f..ea9f9a4f 100644
--- a/packages/cli/src/ui/commands/extensionsCommand.ts
+++ b/packages/cli/src/ui/commands/extensionsCommand.ts
@@ -4,12 +4,17 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { type CommandContext, type SlashCommand } from './types.js';
+import {
+ type CommandContext,
+ type SlashCommand,
+ CommandKind,
+} from './types.js';
import { MessageType } from '../types.js';
export const extensionsCommand: SlashCommand = {
name: 'extensions',
description: 'list active extensions',
+ kind: CommandKind.BUILT_IN,
action: async (context: CommandContext): Promise<void> => {
const activeExtensions = context.services.config
?.getExtensions()
diff --git a/packages/cli/src/ui/commands/helpCommand.test.ts b/packages/cli/src/ui/commands/helpCommand.test.ts
index a6b19c05..b0441106 100644
--- a/packages/cli/src/ui/commands/helpCommand.test.ts
+++ b/packages/cli/src/ui/commands/helpCommand.test.ts
@@ -32,9 +32,9 @@ describe('helpCommand', () => {
});
it("should also be triggered by its alternative name '?'", () => {
- // This test is more conceptual. The routing of altName to the command
+ // This test is more conceptual. The routing of altNames to the command
// is handled by the slash command processor, but we can assert the
- // altName is correctly defined on the command object itself.
- expect(helpCommand.altName).toBe('?');
+ // altNames is correctly defined on the command object itself.
+ expect(helpCommand.altNames).toContain('?');
});
});
diff --git a/packages/cli/src/ui/commands/helpCommand.ts b/packages/cli/src/ui/commands/helpCommand.ts
index 82d0d536..03c64615 100644
--- a/packages/cli/src/ui/commands/helpCommand.ts
+++ b/packages/cli/src/ui/commands/helpCommand.ts
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { OpenDialogActionReturn, SlashCommand } from './types.js';
+import { CommandKind, OpenDialogActionReturn, SlashCommand } from './types.js';
export const helpCommand: SlashCommand = {
name: 'help',
- altName: '?',
+ altNames: ['?'],
description: 'for help on gemini-cli',
+ kind: CommandKind.BUILT_IN,
action: (_context, _args): OpenDialogActionReturn => {
console.debug('Opening help UI ...');
return {
diff --git a/packages/cli/src/ui/commands/ideCommand.ts b/packages/cli/src/ui/commands/ideCommand.ts
index 0251e619..6fc4f50b 100644
--- a/packages/cli/src/ui/commands/ideCommand.ts
+++ b/packages/cli/src/ui/commands/ideCommand.ts
@@ -17,6 +17,7 @@ import {
CommandContext,
SlashCommand,
SlashCommandActionReturn,
+ CommandKind,
} from './types.js';
import * as child_process from 'child_process';
import * as process from 'process';
@@ -48,10 +49,12 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
return {
name: 'ide',
description: 'manage IDE integration',
+ kind: CommandKind.BUILT_IN,
subCommands: [
{
name: 'status',
description: 'check status of IDE integration',
+ kind: CommandKind.BUILT_IN,
action: (_context: CommandContext): SlashCommandActionReturn => {
const status = getMCPServerStatus(IDE_SERVER_NAME);
const discoveryState = getMCPDiscoveryState();
@@ -89,6 +92,7 @@ export const ideCommand = (config: Config | null): SlashCommand | null => {
{
name: 'install',
description: 'install required VS Code companion extension',
+ kind: CommandKind.BUILT_IN,
action: async (context) => {
if (!isVSCodeInstalled()) {
context.ui.addItem(
diff --git a/packages/cli/src/ui/commands/mcpCommand.ts b/packages/cli/src/ui/commands/mcpCommand.ts
index 891227b0..373f1ca5 100644
--- a/packages/cli/src/ui/commands/mcpCommand.ts
+++ b/packages/cli/src/ui/commands/mcpCommand.ts
@@ -8,6 +8,7 @@ import {
SlashCommand,
SlashCommandActionReturn,
CommandContext,
+ CommandKind,
} from './types.js';
import {
DiscoveredMCPTool,
@@ -229,6 +230,7 @@ const getMcpStatus = async (
export const mcpCommand: SlashCommand = {
name: 'mcp',
description: 'list configured MCP servers and tools',
+ kind: CommandKind.BUILT_IN,
action: async (context: CommandContext, args: string) => {
const lowerCaseArgs = args.toLowerCase().split(/\s+/).filter(Boolean);
diff --git a/packages/cli/src/ui/commands/memoryCommand.ts b/packages/cli/src/ui/commands/memoryCommand.ts
index 18ca96bb..afa43031 100644
--- a/packages/cli/src/ui/commands/memoryCommand.ts
+++ b/packages/cli/src/ui/commands/memoryCommand.ts
@@ -6,15 +6,21 @@
import { getErrorMessage } from '@google/gemini-cli-core';
import { MessageType } from '../types.js';
-import { SlashCommand, SlashCommandActionReturn } from './types.js';
+import {
+ CommandKind,
+ SlashCommand,
+ SlashCommandActionReturn,
+} from './types.js';
export const memoryCommand: SlashCommand = {
name: 'memory',
description: 'Commands for interacting with memory.',
+ kind: CommandKind.BUILT_IN,
subCommands: [
{
name: 'show',
description: 'Show the current memory contents.',
+ kind: CommandKind.BUILT_IN,
action: async (context) => {
const memoryContent = context.services.config?.getUserMemory() || '';
const fileCount = context.services.config?.getGeminiMdFileCount() || 0;
@@ -36,6 +42,7 @@ export const memoryCommand: SlashCommand = {
{
name: 'add',
description: 'Add content to the memory.',
+ kind: CommandKind.BUILT_IN,
action: (context, args): SlashCommandActionReturn | void => {
if (!args || args.trim() === '') {
return {
@@ -63,6 +70,7 @@ export const memoryCommand: SlashCommand = {
{
name: 'refresh',
description: 'Refresh the memory from the source.',
+ kind: CommandKind.BUILT_IN,
action: async (context) => {
context.ui.addItem(
{
diff --git a/packages/cli/src/ui/commands/privacyCommand.ts b/packages/cli/src/ui/commands/privacyCommand.ts
index f239158c..ef9d08a0 100644
--- a/packages/cli/src/ui/commands/privacyCommand.ts
+++ b/packages/cli/src/ui/commands/privacyCommand.ts
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { OpenDialogActionReturn, SlashCommand } from './types.js';
+import { CommandKind, OpenDialogActionReturn, SlashCommand } from './types.js';
export const privacyCommand: SlashCommand = {
name: 'privacy',
description: 'display the privacy notice',
+ kind: CommandKind.BUILT_IN,
action: (): OpenDialogActionReturn => ({
type: 'dialog',
dialog: 'privacy',
diff --git a/packages/cli/src/ui/commands/quitCommand.ts b/packages/cli/src/ui/commands/quitCommand.ts
index 48daf8c2..36f15c71 100644
--- a/packages/cli/src/ui/commands/quitCommand.ts
+++ b/packages/cli/src/ui/commands/quitCommand.ts
@@ -5,12 +5,13 @@
*/
import { formatDuration } from '../utils/formatters.js';
-import { type SlashCommand } from './types.js';
+import { CommandKind, type SlashCommand } from './types.js';
export const quitCommand: SlashCommand = {
name: 'quit',
- altName: 'exit',
+ altNames: ['exit'],
description: 'exit the cli',
+ kind: CommandKind.BUILT_IN,
action: (context) => {
const now = Date.now();
const { sessionStartTime } = context.session.stats;
diff --git a/packages/cli/src/ui/commands/restoreCommand.ts b/packages/cli/src/ui/commands/restoreCommand.ts
index 3d744189..84259288 100644
--- a/packages/cli/src/ui/commands/restoreCommand.ts
+++ b/packages/cli/src/ui/commands/restoreCommand.ts
@@ -10,6 +10,7 @@ import {
type CommandContext,
type SlashCommand,
type SlashCommandActionReturn,
+ CommandKind,
} from './types.js';
import { Config } from '@google/gemini-cli-core';
@@ -149,6 +150,7 @@ export const restoreCommand = (config: Config | null): SlashCommand | null => {
name: 'restore',
description:
'Restore a tool call. This will reset the conversation and file history to the state it was in when the tool call was suggested',
+ kind: CommandKind.BUILT_IN,
action: restoreAction,
completion,
};
diff --git a/packages/cli/src/ui/commands/statsCommand.ts b/packages/cli/src/ui/commands/statsCommand.ts
index 87e902d4..e9e69756 100644
--- a/packages/cli/src/ui/commands/statsCommand.ts
+++ b/packages/cli/src/ui/commands/statsCommand.ts
@@ -6,12 +6,17 @@
import { MessageType, HistoryItemStats } from '../types.js';
import { formatDuration } from '../utils/formatters.js';
-import { type CommandContext, type SlashCommand } from './types.js';
+import {
+ type CommandContext,
+ type SlashCommand,
+ CommandKind,
+} from './types.js';
export const statsCommand: SlashCommand = {
name: 'stats',
- altName: 'usage',
+ altNames: ['usage'],
description: 'check session stats. Usage: /stats [model|tools]',
+ kind: CommandKind.BUILT_IN,
action: (context: CommandContext) => {
const now = new Date();
const { sessionStartTime } = context.session.stats;
@@ -38,6 +43,7 @@ export const statsCommand: SlashCommand = {
{
name: 'model',
description: 'Show model-specific usage statistics.',
+ kind: CommandKind.BUILT_IN,
action: (context: CommandContext) => {
context.ui.addItem(
{
@@ -50,6 +56,7 @@ export const statsCommand: SlashCommand = {
{
name: 'tools',
description: 'Show tool-specific usage statistics.',
+ kind: CommandKind.BUILT_IN,
action: (context: CommandContext) => {
context.ui.addItem(
{
diff --git a/packages/cli/src/ui/commands/themeCommand.ts b/packages/cli/src/ui/commands/themeCommand.ts
index 29e9a491..755d59d9 100644
--- a/packages/cli/src/ui/commands/themeCommand.ts
+++ b/packages/cli/src/ui/commands/themeCommand.ts
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { OpenDialogActionReturn, SlashCommand } from './types.js';
+import { CommandKind, OpenDialogActionReturn, SlashCommand } from './types.js';
export const themeCommand: SlashCommand = {
name: 'theme',
description: 'change the theme',
+ kind: CommandKind.BUILT_IN,
action: (_context, _args): OpenDialogActionReturn => ({
type: 'dialog',
dialog: 'theme',
diff --git a/packages/cli/src/ui/commands/toolsCommand.ts b/packages/cli/src/ui/commands/toolsCommand.ts
index f65edd07..e993bab3 100644
--- a/packages/cli/src/ui/commands/toolsCommand.ts
+++ b/packages/cli/src/ui/commands/toolsCommand.ts
@@ -4,12 +4,17 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { type CommandContext, type SlashCommand } from './types.js';
+import {
+ type CommandContext,
+ type SlashCommand,
+ CommandKind,
+} from './types.js';
import { MessageType } from '../types.js';
export const toolsCommand: SlashCommand = {
name: 'tools',
description: 'list available Gemini CLI tools',
+ kind: CommandKind.BUILT_IN,
action: async (context: CommandContext, args?: string): Promise<void> => {
const subCommand = args?.trim();
diff --git a/packages/cli/src/ui/commands/types.ts b/packages/cli/src/ui/commands/types.ts
index 3e269cbf..3ffadf83 100644
--- a/packages/cli/src/ui/commands/types.ts
+++ b/packages/cli/src/ui/commands/types.ts
@@ -106,11 +106,18 @@ export type SlashCommandActionReturn =
| OpenDialogActionReturn
| LoadHistoryActionReturn;
+export enum CommandKind {
+ BUILT_IN = 'built-in',
+ FILE = 'file',
+}
+
// The standardized contract for any command in the system.
export interface SlashCommand {
name: string;
- altName?: string;
- description?: string;
+ altNames?: string[];
+ description: string;
+
+ kind: CommandKind;
// The action to run. Optional for parent commands that only group sub-commands.
action?: (