'use client' import { useState, useEffect, useRef } from 'react' import { motion } from 'framer-motion' import { Loader2, Check, Globe, FileText, Scissors, Files } from 'lucide-react' const STAGES = [ { id: 'connect', label: 'Connecting to site', icon: Globe, duration: 800 }, { id: 'fetch', label: 'Fetching llms.txt', icon: FileText, duration: 1200 }, { id: 'parse', label: 'Parsing sections', icon: Scissors, duration: 1500 }, { id: 'generate', label: 'Generating documents', icon: Files, duration: 1000 }, ] const TERMINAL_LOGS = [ '> Initializing extraction...', '> Connecting to documentation site', '> Looking for llms-full.txt', '> Falling back to llms.txt', '> File found, fetching content', '> Parsing markdown structure', '> Identifying section headers', '> Splitting into documents', '> Generating llms-full.md', '> Creating AGENT-GUIDE.md', '> Preparing download bundle', '> Extraction complete', ] export default function ExtractionProcess() { const [currentStage, setCurrentStage] = useState(0) const [terminalLines, setTerminalLines] = useState([]) const [metrics, setMetrics] = useState({ tokens: 0, chunks: 0, nodes: 0, requests: 0, }) const terminalRef = useRef(null) // Progress through stages useEffect(() => { if (currentStage < STAGES.length) { const timer = setTimeout(() => { setCurrentStage(prev => prev + 1) }, STAGES[currentStage].duration) return () => clearTimeout(timer) } }, [currentStage]) // Add terminal lines useEffect(() => { const lineIndex = Math.min( Math.floor((currentStage / STAGES.length) * TERMINAL_LOGS.length), TERMINAL_LOGS.length - 1 ) const interval = setInterval(() => { setTerminalLines(prev => { if (prev.length < Math.min(lineIndex + 3, TERMINAL_LOGS.length)) { return [...prev, TERMINAL_LOGS[prev.length]] } return prev }) }, 150) return () => clearInterval(interval) }, [currentStage]) // Update metrics useEffect(() => { const interval = setInterval(() => { setMetrics(prev => ({ tokens: Math.min(prev.tokens + Math.floor(Math.random() * 5000), 847293), chunks: Math.min(prev.chunks + Math.floor(Math.random() * 10), 492), nodes: Math.min(prev.nodes + Math.floor(Math.random() * 20), 1847), requests: Math.min(prev.requests + Math.floor(Math.random() * 5), 156), })) }, 100) return () => clearInterval(interval) }, []) // Auto-scroll terminal useEffect(() => { if (terminalRef.current) { terminalRef.current.scrollTop = terminalRef.current.scrollHeight } }, [terminalLines]) const progress = (currentStage / STAGES.length) * 100 return ( {/* Main progress card */}
{/* Header */}

Extracting Documentation

Fetching and parsing llms.txt

{progress.toFixed(0)}%
Complete
{/* Progress bar */}
{/* Stages */}
{STAGES.map((stage, index) => { const isComplete = index < currentStage const isCurrent = index === currentStage const Icon = stage.icon return (
{isComplete ? ( ) : isCurrent ? ( ) : ( )}
) })}
{/* Metrics and Terminal */}
{/* Live metrics */}

Live Metrics

{[ { label: 'Tokens', value: metrics.tokens.toLocaleString() }, { label: 'Chunks', value: metrics.chunks.toLocaleString() }, { label: 'Nodes', value: metrics.nodes.toLocaleString() }, { label: 'Models', value: metrics.requests.toLocaleString() }, ].map((metric) => (
{metric.value}
{metric.label}
))}
{/* Terminal */}
extraction.log
{terminalLines.map((line, i) => ( {line} ))}
) }