Files
gemini-cli/packages/cli/src/ui/components/Help.tsx

200 lines
5.5 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { type SlashCommand, CommandKind } from '../commands/types.js';
import { KEYBOARD_SHORTCUTS_URL } from '../constants.js';
import { sanitizeForListDisplay } from '../utils/textUtils.js';
interface Help {
commands: readonly SlashCommand[];
2025-04-29 23:38:26 +00:00
}
export const Help: React.FC<Help> = ({ commands }) => (
2025-06-16 20:13:33 -07:00
<Box
flexDirection="column"
marginBottom={1}
borderColor={theme.border.default}
2025-06-16 20:13:33 -07:00
borderStyle="round"
padding={1}
>
{/* Basics */}
<Text bold color={theme.text.primary}>
2025-06-16 20:13:33 -07:00
Basics:
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
Add context
</Text>
: Use{' '}
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
@
</Text>{' '}
to specify files for context (e.g.,{' '}
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
@src/myFile.ts
</Text>
) to target specific files or folders.
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
Shell mode
</Text>
: Execute shell commands via{' '}
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
!
</Text>{' '}
(e.g.,{' '}
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
!npm run start
</Text>
) or use natural language (e.g.{' '}
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
start server
</Text>
).
</Text>
2025-06-16 20:13:33 -07:00
<Box height={1} />
2025-06-16 20:13:33 -07:00
{/* Commands */}
<Text bold color={theme.text.primary}>
2025-04-29 23:38:26 +00:00
Commands:
</Text>
{commands
.filter((command) => command.description && !command.hidden)
.map((command: SlashCommand) => (
<Box key={command.name} flexDirection="column">
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
{' '}
/{command.name}
</Text>
{command.kind === CommandKind.MCP_PROMPT && (
<Text color={theme.text.secondary}> [MCP]</Text>
)}
{command.description &&
' - ' + sanitizeForListDisplay(command.description, 100)}
</Text>
{command.subCommands &&
command.subCommands
.filter((subCommand) => !subCommand.hidden)
.map((subCommand) => (
<Text key={subCommand.name} color={theme.text.primary}>
<Text bold color={theme.text.accent}>
{' '}
{subCommand.name}
</Text>
{subCommand.description &&
' - ' + sanitizeForListDisplay(subCommand.description, 100)}
</Text>
))}
</Box>
))}
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
{' '}
!{' '}
</Text>
2025-06-16 20:13:33 -07:00
- shell command
</Text>
<Text color={theme.text.primary}>
<Text color={theme.text.secondary}>[MCP]</Text> - Model Context Protocol
command (from external servers)
</Text>
2025-06-16 20:13:33 -07:00
<Box height={1} />
{/* Shortcuts */}
<Text bold color={theme.text.primary}>
2025-06-16 20:13:33 -07:00
Keyboard Shortcuts:
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Alt+Left/Right
2025-06-16 20:13:33 -07:00
</Text>{' '}
- Jump through words in the input
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Ctrl+C
</Text>{' '}
- Quit application
2025-06-16 20:13:33 -07:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
{process.platform === 'win32' ? 'Ctrl+Enter' : 'Ctrl+J'}
2025-06-16 20:13:33 -07:00
</Text>{' '}
{process.platform === 'linux'
? '- New line (Alt+Enter works for certain linux distros)'
: '- New line'}
2025-06-16 20:13:33 -07:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Ctrl+L
2025-06-16 20:13:33 -07:00
</Text>{' '}
- Clear the screen
2025-06-16 20:13:33 -07:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Ctrl+S
</Text>{' '}
- Enter selection mode to copy text
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
2026-01-12 16:28:10 -08:00
Ctrl+X
2025-06-16 20:13:33 -07:00
</Text>{' '}
- Open input in external editor
2025-06-16 20:13:33 -07:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Ctrl+Y
2025-07-01 23:18:01 -04:00
</Text>{' '}
- Toggle YOLO mode
2025-07-01 23:18:01 -04:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Enter
</Text>{' '}
- Send message
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
2025-06-16 20:13:33 -07:00
Esc
</Text>{' '}
- Cancel operation / Clear input (double press)
2025-06-16 20:13:33 -07:00
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Page Up/Down
</Text>{' '}
- Scroll page up/down
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Shift+Tab
2025-06-16 20:13:33 -07:00
</Text>{' '}
- Toggle auto-accepting edits
</Text>
<Text color={theme.text.primary}>
<Text bold color={theme.text.accent}>
Up/Down
</Text>{' '}
- Cycle through your prompt history
</Text>
<Box height={1} />
<Text color={theme.text.primary}>
For a full list of shortcuts, see{' '}
<Text bold color={theme.text.accent}>
{KEYBOARD_SHORTCUTS_URL}
</Text>
</Text>
</Box>
);