blob: 153b4701cbc639dca92cace46d4eeb342ce1a530 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import { Text, Box, useInput, useFocus } from 'ink';
import TextInput from 'ink-text-input';
import { Colors } from '../colors.js';
interface InputPromptProps {
onSubmit: (value: string) => void;
}
export const InputPrompt: React.FC<InputPromptProps> = ({ onSubmit }) => {
const [value, setValue] = React.useState(
"I'd like to update my web fetch tool to be a little smarter about the content it fetches from web pages. Instead of returning the entire HTML to the LLM I was extract the body text and other important information to reduce the amount of tokens we need to use.",
);
// const [value, setValue] = React.useState('Add "Hello World" to the top of README.md');
// const [value, setValue] = React.useState('show me "Hello World" in as many langauges as you can think of');
const { isFocused } = useFocus({ autoFocus: true });
useInput(
(input, key) => {
if (key.return) {
if (value.trim()) {
onSubmit(value);
setValue('');
}
}
},
{ isActive: isFocused },
);
return (
<Box borderStyle="round" borderColor={Colors.AccentBlue} paddingX={1}>
<Text color={Colors.AccentPurple}>> </Text>
<Box flexGrow={1}>
<TextInput
value={value}
onChange={setValue}
placeholder="Enter your message or use tools..."
onSubmit={() => {
/* Empty to prevent double submission */
}}
/>
</Box>
</Box>
);
};
|