UNPKG

research-cli

Version:

AI-powered research assistant with web search capabilities and beautiful terminal UI

186 lines â€ĸ 5.8 kB
import { BoxColors, createCenteredBox, createCompactBox, createStyledBox, createTitledBox, } from "./boxes.js"; /** * Create a status panel for query start information */ export function createStatusPanel(provider, model, config = {}) { if (config.show === false) return ""; const content = `🔍 Querying ${provider} (${model})...`; return createStyledBox(content, "info", { borderColor: BoxColors.primary, ...config.style, }); } /** * Create a tool panel for tool usage information */ export function createToolPanel(toolName, status, config = {}) { if (config.show === false) return ""; const icon = status === "calling" ? "🔧" : "✅"; const action = status === "calling" ? "Using tool" : "Tool completed"; const content = `${icon} ${action}: ${toolName}`; return createStyledBox(content, "default", { borderColor: status === "calling" ? BoxColors.warning : BoxColors.success, ...config.style, }); } /** * Create an error panel for displaying errors */ export function createErrorPanel(message, code, config = {}) { if (config.show === false) return ""; let content = `❌ Error: ${message}`; if (code) { content += `\n Code: ${code}`; } return createStyledBox(content, "alert", { ...config.style, }); } /** * Create a usage stats panel */ export function createUsageStatsPanel(usage, config = {}) { if (config.show === false) return ""; let content = "📊 Usage Stats:\n"; content += ` Input tokens: ${usage.input_tokens.toLocaleString()}\n`; content += ` Output tokens: ${usage.output_tokens.toLocaleString()}`; if (usage.reasoning_tokens && usage.reasoning_tokens > 0) { content += `\n Reasoning tokens: ${usage.reasoning_tokens.toLocaleString()}`; } content += `\n Total tokens: ${usage.total_tokens.toLocaleString()}`; return createTitledBox("Usage Statistics", content, { borderColor: BoxColors.info, borderStyle: "round", ...config.style, }); } /** * Create a citations panel for displaying sources */ export function createCitationsPanel(citations, config = {}) { if (config.show === false || citations.length === 0) return ""; let content = ""; citations.forEach((citation, index) => { const citationNumber = index + 1; content += `${citationNumber}. **${citation.title}**`; if (citation.url) { content += `\n ${citation.url}`; } if (citation.date) { content += `\n *${citation.date}*`; } if (index < citations.length - 1) { content += "\n\n"; } }); return createTitledBox("Sources", content, { borderColor: BoxColors.accent, borderStyle: "double", titleAlignment: "center", ...config.style, }); } /** * Create a progress panel (alternative to the current progress bar) */ export function createProgressPanel(message = "Processing...", config = {}) { if (config.show === false) return ""; return createCompactBox(`âŗ ${message}`, { borderColor: BoxColors.muted, borderStyle: "round", ...config.style, }); } /** * Create a welcome/header panel for the CLI */ export function createWelcomePanel(title, subtitle, config = {}) { if (config.show === false) return ""; let content = title; if (subtitle) { content += `\n${subtitle}`; } return createCenteredBox(content, { borderColor: BoxColors.primary, borderStyle: "double", ...config.style, }); } /** * Create a summary panel for displaying key information */ export function createSummaryPanel(items, title = "Summary", config = {}) { if (config.show === false || items.length === 0) return ""; const content = items .map((item, index) => `${index + 1}. ${item}`) .join("\n"); return createTitledBox(title, content, { borderColor: BoxColors.primary, borderStyle: "single", ...config.style, }); } /** * Create a debug panel for development information */ export function createDebugPanel(data, config = {}) { if (config.show === false) return ""; const content = Object.entries(data) .map(([key, value]) => `${key}: ${JSON.stringify(value, null, 2)}`) .join("\n"); return createTitledBox("Debug Info", content, { borderColor: BoxColors.muted, borderStyle: "single", dimBorder: true, ...config.style, }); } /** * Create a notification panel for important messages */ export function createNotificationPanel(message, type = "info", config = {}) { if (config.show === false) return ""; const icons = { info: "â„šī¸", success: "✅", warning: "âš ī¸", error: "❌", }; const colors = { info: BoxColors.info, success: BoxColors.success, warning: BoxColors.warning, error: BoxColors.error, }; const content = `${icons[type]} ${message}`; return createStyledBox(content, type === "error" ? "alert" : "default", { borderColor: colors[type], ...config.style, }); } /** * Create a help panel for displaying usage instructions */ export function createHelpPanel(commands, config = {}) { if (config.show === false) return ""; const content = commands .map(({ command, description }) => `${command.padEnd(20)} ${description}`) .join("\n"); return createTitledBox("Available Commands", content, { borderColor: BoxColors.primary, borderStyle: "round", ...config.style, }); } //# sourceMappingURL=panels.js.map