UNPKG

@hhoangphuoc/escape-room-cli

Version:

A CLI for playing AI-generated escape room games. Install globally with: npm install -g @hhoangphuoc/escape-room-cli

14 lines (13 loc) 5.54 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { Box, Text } from 'ink'; import { useAuth } from '../hooks/useAuth.js'; import { formatTokens, formatPercentage, getWarningColor } from '../utils/formatters.js'; const ContextDebugger = () => { const { auth } = useAuth(); const { contextInfo, conversationHistory } = auth; return (_jsxs(Box, { flexDirection: "column", padding: 1, borderStyle: "round", borderColor: "cyan", children: [_jsx(Text, { color: "cyan", bold: true, children: "\uD83D\uDC1B Context Debug Information" }), _jsx(Text, { color: "gray", children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" }), _jsx(Text, { color: "yellow", children: "Terminal Context Info (auth.contextInfo):" }), contextInfo ? (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Text, { children: ["Current Size: ", formatTokens(contextInfo.currentSize)] }), _jsxs(Text, { children: ["Max Size: ", formatTokens(contextInfo.maxSize)] }), _jsxs(Text, { children: ["Percentage: ", formatPercentage(contextInfo.percentage)] }), _jsxs(Text, { children: ["Warning Level: ", contextInfo.warningLevel] }), _jsxs(Text, { color: getWarningColor(contextInfo.warningLevel), children: ["Display: ", formatTokens(contextInfo.currentSize), "/", formatTokens(contextInfo.maxSize), " (", formatPercentage(contextInfo.percentage), ")"] })] })) : (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { color: "red", children: "NULL" }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "yellow", children: "ConversationHistory Context Stats:" }) }), conversationHistory?.contextStats ? (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Text, { children: ["Current Context Size: ", formatTokens(conversationHistory.contextStats.currentContextSize)] }), _jsxs(Text, { children: ["Max Context Size: ", formatTokens(conversationHistory.contextStats.maxContextSize)] }), _jsxs(Text, { children: ["Calculated Percentage: ", Math.round((conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize) * 100), "%"] }), _jsxs(Text, { children: ["Total Tokens: ", formatTokens(conversationHistory.contextStats.totalTokens)] }), _jsxs(Text, { children: ["Entry Count: ", conversationHistory.contextStats.entryCount] }), _jsxs(Text, { color: getWarningColor(conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize >= 0.95 ? 'critical' : conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize >= 0.85 ? 'high' : conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize >= 0.70 ? 'medium' : conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize >= 0.50 ? 'low' : 'none'), children: ["Display: ", formatTokens(conversationHistory.contextStats.currentContextSize), "/", formatTokens(conversationHistory.contextStats.maxContextSize), " (", Math.round((conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize) * 100), "%)"] })] })) : (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { color: "red", children: "NULL" }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "yellow", children: "Conversation History Info:" }) }), conversationHistory ? (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [_jsxs(Text, { children: ["Game ID: ", conversationHistory.gameId] }), _jsxs(Text, { children: ["Session ID: ", conversationHistory.sessionId] }), _jsxs(Text, { children: ["Game Mode: ", conversationHistory.gameMode] }), _jsxs(Text, { children: ["Total Entries: ", conversationHistory.entries.length] }), _jsxs(Text, { children: ["Created At: ", conversationHistory.createdAt] }), _jsxs(Text, { children: ["Updated At: ", conversationHistory.updatedAt] })] })) : (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { color: "red", children: "NULL" }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "yellow", children: "Synchronization Status:" }) }), _jsx(Box, { flexDirection: "column", paddingLeft: 2, children: contextInfo && conversationHistory?.contextStats ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: contextInfo.currentSize === conversationHistory.contextStats.currentContextSize ? 'green' : 'red', children: ["Current Size Match: ", contextInfo.currentSize === conversationHistory.contextStats.currentContextSize ? 'YES' : 'NO'] }), _jsxs(Text, { color: contextInfo.maxSize === conversationHistory.contextStats.maxContextSize ? 'green' : 'red', children: ["Max Size Match: ", contextInfo.maxSize === conversationHistory.contextStats.maxContextSize ? 'YES' : 'NO'] }), _jsxs(Text, { color: Math.abs(contextInfo.percentage - (conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize * 100)) < 1 ? 'green' : 'red', children: ["Percentage Match: ", Math.abs(contextInfo.percentage - (conversationHistory.contextStats.currentContextSize / conversationHistory.contextStats.maxContextSize * 100)) < 1 ? 'YES' : 'NO'] })] })) : (_jsx(Text, { color: "red", children: "Cannot compare - one or both data sources are null" })) })] })); }; export default ContextDebugger;