Add Intro text with list of /commands

This commit is contained in:
Seth Troisi 2025-04-29 23:38:26 +00:00
parent bf659f1977
commit fb23321514
4 changed files with 46 additions and 28 deletions

View File

@ -32,8 +32,13 @@ interface AppProps {
export const App = ({ config, cliVersion }: AppProps) => { export const App = ({ config, cliVersion }: AppProps) => {
const [history, setHistory] = useState<HistoryItem[]>([]); const [history, setHistory] = useState<HistoryItem[]>([]);
const [startupWarnings, setStartupWarnings] = useState<string[]>([]); const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
const { streamingState, submitQuery, initError, debugMessage } = const {
useGeminiStream(setHistory, config); streamingState,
submitQuery,
initError,
debugMessage,
slashCommands,
} = useGeminiStream(setHistory, config);
const { elapsedTime, currentLoadingPhrase } = const { elapsedTime, currentLoadingPhrase } =
useLoadingIndicator(streamingState); useLoadingIndicator(streamingState);
@ -104,7 +109,7 @@ export const App = ({ config, cliVersion }: AppProps) => {
<Box flexDirection="column" key={'header-' + index}> <Box flexDirection="column" key={'header-' + index}>
<Header /> <Header />
<Tips /> <Tips />
<Intro /> <Intro commands={slashCommands} />
</Box> </Box>
); );
} }

View File

@ -7,28 +7,35 @@
import React from 'react'; import React from 'react';
import { Box, Newline, Text } from 'ink'; import { Box, Newline, Text } from 'ink';
import { Colors } from '../colors.js'; import { Colors } from '../colors.js';
import { SlashCommand } from '../hooks/slashCommandProcessor.js';
export const Intro: React.FC = () => ( interface Intro {
commands: SlashCommand[];
}
export const Intro: React.FC<Intro> = ({ commands }) => (
<Box flexDirection="column" marginBottom={1}> <Box flexDirection="column" marginBottom={1}>
<Text bold color={Colors.Foreground}>Abilities:</Text> <Text bold color={Colors.Foreground}>
Abilities:
</Text>
<Text color={Colors.Foreground}> * Use tools to read and write files</Text> <Text color={Colors.Foreground}> * Use tools to read and write files</Text>
<Text color={Colors.Foreground}> * Semantically search and understand code</Text> <Text color={Colors.Foreground}>
{' '}
* Semantically search and explain code
</Text>
<Text color={Colors.Foreground}> * Execute bash commands</Text> <Text color={Colors.Foreground}> * Execute bash commands</Text>
<Newline/> <Newline />
<Text bold color={Colors.Foreground}>Commands:</Text> <Text bold color={Colors.Foreground}>
<Text color={Colors.SubtleComment}> Commands:
<Text bold color={Colors.AccentPurple}> /help</Text>
{' '}- prints this help
</Text> </Text>
<Text color={Colors.SubtleComment}> {commands.map((command: SlashCommand) => (
<Text bold color={Colors.AccentPurple}> /clear</Text> <Text key={command.name} color={Colors.SubtleComment}>
{' '}- clear the screen <Text bold color={Colors.AccentPurple}>
{' '}
/{command.name}
</Text> </Text>
<Text color={Colors.SubtleComment}> {command.description && ' - ' + command.description}
<Text bold color={Colors.AccentPurple}> /exit</Text>
</Text>
<Text color={Colors.SubtleComment}>
<Text bold color={Colors.AccentPurple}> /quit</Text>
</Text> </Text>
))}
</Box> </Box>
); );

View File

@ -9,7 +9,7 @@ import { type PartListUnion } from '@google/genai';
import { HistoryItem } from '../types.js'; import { HistoryItem } from '../types.js';
import { isSlashCommand } from '../utils/commandUtils.js'; import { isSlashCommand } from '../utils/commandUtils.js';
interface SlashCommand { export interface SlashCommand {
name: string; // slash command name: string; // slash command
description: string; // flavor text in UI description: string; // flavor text in UI
action: (value: PartListUnion) => void; action: (value: PartListUnion) => void;
@ -43,7 +43,7 @@ export const useSlashCommandProcessor = (
}, },
{ {
name: 'help', name: 'help',
description: '/help for help on gemini-code', description: 'for help on gemini-code',
action: (_value: PartListUnion) => { action: (_value: PartListUnion) => {
const helpText = const helpText =
'I am an interactive CLI tool assistant designed to ' + 'I am an interactive CLI tool assistant designed to ' +
@ -58,7 +58,7 @@ export const useSlashCommandProcessor = (
}, },
{ {
name: 'exit', name: 'exit',
description: 'Exit gemini-code', description: '',
action: (_value: PartListUnion) => { action: (_value: PartListUnion) => {
setDebugMessage('Exiting. Good-bye.'); setDebugMessage('Exiting. Good-bye.');
const timestamp = getNextMessageId(Date.now()); const timestamp = getNextMessageId(Date.now());
@ -73,7 +73,7 @@ export const useSlashCommandProcessor = (
{ {
// TODO: dedup with exit by adding altName or cmdRegex. // TODO: dedup with exit by adding altName or cmdRegex.
name: 'quit', name: 'quit',
description: 'Quit gemini-code', description: '',
action: (_value: PartListUnion) => { action: (_value: PartListUnion) => {
setDebugMessage('Quitting. Good-bye.'); setDebugMessage('Quitting. Good-bye.');
const timestamp = getNextMessageId(Date.now()); const timestamp = getNextMessageId(Date.now());
@ -121,5 +121,5 @@ export const useSlashCommandProcessor = (
[setDebugMessage, setHistory, getNextMessageId, slashCommands], [setDebugMessage, setHistory, getNextMessageId, slashCommands],
); );
return { handleSlashCommand }; return { handleSlashCommand, slashCommands };
}; };

View File

@ -69,7 +69,7 @@ export const useGeminiStream = (
}, []); }, []);
// Instantiate command processors // Instantiate command processors
const { handleSlashCommand } = useSlashCommandProcessor( const { handleSlashCommand, slashCommands } = useSlashCommandProcessor(
setHistory, setHistory,
setDebugMessage, setDebugMessage,
getNextMessageId, getNextMessageId,
@ -532,5 +532,11 @@ export const useGeminiStream = (
], ],
); );
return { streamingState, submitQuery, initError, debugMessage }; return {
streamingState,
submitQuery,
initError,
debugMessage,
slashCommands,
};
}; };