UNPKG

@aura-ai/cli

Version:

A Go-to-Market CLI tool for analyzing product positioning and market strategy

130 lines (129 loc) 5.62 kB
import React from 'react'; import { Box, Text } from 'ink'; import { Spinner, ProgressBar } from '@inkjs/ui'; import { AnalysisStep } from '../services/analyzer.js'; /** * 5.5 Analysis progress display component */ const AnalysisProgress = ({ currentStep, message, progress, entityProgress }) => { // Calculate progress percentage based on step const getProgressPercentage = () => { if (progress !== undefined) return progress; switch (currentStep) { case AnalysisStep.SCANNING_FILES: return 10; case AnalysisStep.SELECTING_FILES: return 25; case AnalysisStep.ANALYZING_PRODUCT: return 40; case AnalysisStep.GENERATING_DESCRIPTION: return 55; case AnalysisStep.RESEARCHING_MARKET: return 70; case AnalysisStep.GENERATING_POSITIONING: return 85; case AnalysisStep.COMPLETED: return 100; default: return 0; } }; const getStepLabel = () => { switch (currentStep) { case AnalysisStep.SCANNING_FILES: return '📂 Scanning project files...'; case AnalysisStep.SELECTING_FILES: return '🎯 Selecting relevant files...'; case AnalysisStep.ANALYZING_PRODUCT: return '🔍 Analyzing product characteristics...'; case AnalysisStep.GENERATING_DESCRIPTION: return '📝 Generating product description...'; case AnalysisStep.RESEARCHING_MARKET: return '🌐 Researching market positioning...'; case AnalysisStep.GENERATING_POSITIONING: return '🎨 Generating positioning strategy...'; case AnalysisStep.COMPLETED: return '✅ Analysis completed!'; case AnalysisStep.ERROR: return '❌ Analysis failed'; default: return '⏳ Initializing...'; } }; // Map steps to main phases for user visibility const getMainPhase = () => { switch (currentStep) { case AnalysisStep.SCANNING_FILES: case AnalysisStep.SELECTING_FILES: return { phase: 'File Selection', phaseNumber: 1 }; case AnalysisStep.ANALYZING_PRODUCT: case AnalysisStep.GENERATING_DESCRIPTION: return { phase: 'Product Description', phaseNumber: 2 }; case AnalysisStep.RESEARCHING_MARKET: return { phase: 'Entity Analysis', phaseNumber: 3 }; case AnalysisStep.GENERATING_POSITIONING: return { phase: 'Positioning Generation', phaseNumber: 4 }; case AnalysisStep.COMPLETED: return { phase: 'Completed', phaseNumber: 4 }; default: return { phase: 'Initializing', phaseNumber: 0 }; } }; const progressValue = getProgressPercentage(); const stepLabel = getStepLabel(); const mainPhase = getMainPhase(); // Show entity progress during research phase const showEntityProgress = currentStep === AnalysisStep.RESEARCHING_MARKET && entityProgress; return (React.createElement(Box, { flexDirection: "column", marginTop: 1 }, React.createElement(Box, null, React.createElement(Text, { bold: true, color: "cyan" }, "Phase ", mainPhase.phaseNumber, " of 4: ", mainPhase.phase)), React.createElement(Box, { marginTop: 1 }, currentStep !== AnalysisStep.COMPLETED && currentStep !== AnalysisStep.ERROR ? (React.createElement(Spinner, { label: stepLabel })) : (React.createElement(Text, null, stepLabel))), React.createElement(Box, { marginTop: 1 }, React.createElement(ProgressBar, { value: progressValue })), showEntityProgress && (React.createElement(Box, { flexDirection: "column", marginTop: 1 }, React.createElement(Text, { dimColor: true }, "Researching entities: ", entityProgress.completed, "/", entityProgress.total, " completed"), React.createElement(Box, { marginTop: 1 }, React.createElement(ProgressBar, { value: Math.round((entityProgress.completed / entityProgress.total) * 100) })), entityProgress.currentEntity && (React.createElement(Text, { dimColor: true }, "Currently researching: ", entityProgress.currentEntity)))), message && (React.createElement(Box, { marginTop: 1 }, React.createElement(Text, { dimColor: true }, message))), React.createElement(Box, { marginTop: 1 }, React.createElement(Text, { dimColor: true }, "Step ", getStepNumber(currentStep), " of 6")))); }; // Helper function to get step number function getStepNumber(step) { switch (step) { case AnalysisStep.SCANNING_FILES: return 1; case AnalysisStep.SELECTING_FILES: return 2; case AnalysisStep.ANALYZING_PRODUCT: return 3; case AnalysisStep.GENERATING_DESCRIPTION: return 4; case AnalysisStep.RESEARCHING_MARKET: return 5; case AnalysisStep.GENERATING_POSITIONING: return 6; case AnalysisStep.COMPLETED: return 6; default: return 0; } } export default AnalysisProgress;