/** * @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 { sanitizeForDisplay } from '../utils/textUtils.js'; import { formatCommand } from '../utils/keybindingUtils.js'; import { Command } from '../../config/keyBindings.js'; interface Help { commands: readonly SlashCommand[]; } export const Help: React.FC = ({ commands }) => ( {/* Basics */} Basics: Add context : Use{' '} @ {' '} to specify files for context (e.g.,{' '} @src/myFile.ts ) to target specific files or folders. Shell mode : Execute shell commands via{' '} ! {' '} (e.g.,{' '} !npm run start ) or use natural language (e.g.{' '} start server ). {/* Commands */} Commands: {commands .filter((command) => command.description && !command.hidden) .map((command: SlashCommand) => ( {' '} /{command.name} {command.kind === CommandKind.MCP_PROMPT && ( [MCP] )} {command.description && ' - ' + sanitizeForDisplay(command.description, 100)} {command.subCommands && command.subCommands .filter((subCommand) => !subCommand.hidden) .map((subCommand) => ( {' '} {subCommand.name} {subCommand.description && ' - ' + sanitizeForDisplay(subCommand.description, 100)} ))} ))} {' '} !{' '} - shell command [MCP] - Model Context Protocol command (from external servers) {/* Shortcuts */} Keyboard Shortcuts: {formatCommand(Command.MOVE_WORD_LEFT)}/ {formatCommand(Command.MOVE_WORD_RIGHT)} {' '} - Jump through words in the input {formatCommand(Command.QUIT)} {' '} - Quit application {formatCommand(Command.NEWLINE)} {' '} - New line {formatCommand(Command.CLEAR_SCREEN)} {' '} - Clear the screen {formatCommand(Command.TOGGLE_COPY_MODE)} {' '} - Enter selection mode to copy text {formatCommand(Command.OPEN_EXTERNAL_EDITOR)} {' '} - Open input in external editor {formatCommand(Command.TOGGLE_YOLO)} {' '} - Toggle YOLO mode {formatCommand(Command.SUBMIT)} {' '} - Send message {formatCommand(Command.ESCAPE)} {' '} - Cancel operation / Clear input (double press) {formatCommand(Command.PAGE_UP)}/{formatCommand(Command.PAGE_DOWN)} {' '} - Scroll page up/down {formatCommand(Command.CYCLE_APPROVAL_MODE)} {' '} - Toggle auto-accepting edits {formatCommand(Command.HISTORY_UP)}/ {formatCommand(Command.HISTORY_DOWN)} {' '} - Cycle through your prompt history For a full list of shortcuts, see{' '} {KEYBOARD_SHORTCUTS_URL} );