/** * useInit - State management hook for the init workflow * * Manages the initialization flow phases: * 1. scanning - Scan project structure * 2. provider-select - Select AI provider (if no key available) * 3. key-input - Enter API key * 4. key-save - Confirm saving key to .env.local * 5. model-select - Select model * 6. ai-analysis - Run AI analysis * 7. confirm - Confirm file generation * 8. generating - Generate configuration files * 9. complete - Done */ import type { AIProvider } from '../../ai/providers.js'; import type { ScanResult } from '../../scanner/types.js'; import type { EnhancedScanResult, ToolCallEvent } from '../../ai/index.js'; import type { ActionStatus } from '../components/ActionOutput.js'; /** * Init workflow phases */ export type InitPhase = 'scanning' | 'provider-select' | 'key-input' | 'key-save' | 'model-select' | 'coding-cli-select' | 'ai-analysis' | 'confirm' | 'generating' | 'complete' | 'error'; /** * Phase configuration for display */ export interface InitPhaseConfig { /** Phase number for progress display */ number: number; /** Human-readable phase name */ name: string; /** Description of what happens in this phase */ description: string; } /** * Phase configurations for display */ export declare const INIT_PHASE_CONFIGS: Record; /** * Total display phases for progress bar */ export declare const INIT_TOTAL_PHASES = 5; /** * Tool call for display */ export interface ToolCallDisplay { id: string; actionName: string; description: string; status: ActionStatus; output?: string; error?: string; } /** * State managed by the useInit hook */ export interface InitState { /** Current phase of the init workflow */ phase: InitPhase; /** Project root directory */ projectRoot: string; /** Scan result from project analysis */ scanResult: ScanResult | null; /** Enhanced scan result after AI analysis */ enhancedResult: EnhancedScanResult | null; /** Selected AI provider */ provider: AIProvider | null; /** Selected model */ model: string | null; /** Selected coding CLI for generated loop config */ codingCli: 'claude' | 'codex'; /** API key entered (not persisted in state for security) */ hasApiKey: boolean; /** Whether API key was entered this session (needs save prompt) */ apiKeyEnteredThisSession: boolean; /** Whether user wants to save key to .env.local */ saveKeyToEnv: boolean; /** Whether AI analysis is in progress */ isWorking: boolean; /** Status message for working indicator */ workingStatus: string; /** Error message if something went wrong */ error: string | null; /** Generated files list */ generatedFiles: string[]; /** Token usage from AI analysis */ tokenUsage: { inputTokens: number; outputTokens: number; totalTokens: number; } | null; /** Tool calls during AI analysis */ toolCalls: ToolCallDisplay[]; } /** * Return value from useInit hook */ export interface UseInitReturn { /** Current state */ state: InitState; /** Initialize with project root */ initialize: (projectRoot: string) => void; /** Set scan result and advance to next phase */ setScanResult: (result: ScanResult) => void; /** Set that an existing API key is available */ setExistingProvider: (provider: AIProvider) => void; /** Set selected provider */ selectProvider: (provider: AIProvider) => void; /** Set API key (marks as entered this session) */ setApiKey: (key: string) => void; /** Set whether to save key to .env.local */ setSaveKey: (save: boolean) => void; /** Select model and advance to AI analysis */ selectModel: (model: string) => void; /** Select coding CLI and advance to AI analysis */ selectCodingCli: (cli: 'claude' | 'codex') => void; /** Set AI analysis progress */ setAiProgress: (status: string) => void; /** Update tool call (add or update status) */ updateToolCall: (event: ToolCallEvent) => void; /** Set enhanced result from AI analysis */ setEnhancedResult: (result: EnhancedScanResult, tokenUsage?: { inputTokens: number; outputTokens: number; totalTokens: number; }) => void; /** Set AI analysis error */ setAiError: (error: string) => void; /** Confirm file generation */ confirmGeneration: (confirmed: boolean) => void; /** Set generation in progress */ setGenerating: (status: string) => void; /** Set generation complete */ setGenerationComplete: (files: string[]) => void; /** Set error state */ setError: (error: string) => void; /** Reset to initial state */ reset: () => void; /** Go back to previous phase */ goBack: () => void; } /** * useInit - React hook for managing init workflow state */ export declare function useInit(): UseInitReturn; /** * Get API key from the ref (for use in the screen component) * This is a workaround since we don't store API key in state */ export declare function getApiKeyFromRef(): string | null;