import React, { type ReactNode, useCallback, useState } from 'react' import { Box, Byline, KeyboardShortcutHint, Text } from '@anthropic/ink' import { useKeybinding } from '../../../../keybindings/useKeybinding.js' import { editPromptInEditor } from '../../../../utils/promptEditor.js' import { ConfigurableShortcutHint } from '../../../ConfigurableShortcutHint.js' import TextInput from '../../../TextInput.js' import { useWizard } from '../../../wizard/index.js' import { WizardDialogLayout } from '../../../wizard/WizardDialogLayout.js' import type { AgentWizardData } from '../types.js' export function PromptStep(): ReactNode { const { goNext, goBack, updateWizardData, wizardData } = useWizard() const [systemPrompt, setSystemPrompt] = useState( wizardData.systemPrompt || '', ) const [cursorOffset, setCursorOffset] = useState(systemPrompt.length) const [error, setError] = useState(null) // Handle escape key - use Settings context so 'n' key doesn't cancel (allows typing 'n' in input) useKeybinding('confirm:no', goBack, { context: 'Settings' }) const handleExternalEditor = useCallback(async () => { const result = await editPromptInEditor(systemPrompt) if (result.content !== null) { setSystemPrompt(result.content) setCursorOffset(result.content.length) } }, [systemPrompt]) useKeybinding('chat:externalEditor', handleExternalEditor, { context: 'Chat', }) const handleSubmit = (): void => { const trimmedPrompt = systemPrompt.trim() if (!trimmedPrompt) { setError('System prompt is required') return } setError(null) updateWizardData({ systemPrompt: trimmedPrompt }) goNext() } return ( } > Enter the system prompt for your agent: Be comprehensive for best results {error && ( {error} )} ) }