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