UNPKG

vibe-coder-mcp

Version:

Production-ready MCP server with complete agent integration, multi-transport support, and comprehensive development automation tools for AI-assisted workflows.

84 lines (83 loc) â€ĸ 3.58 kB
import boxen from 'boxen'; import wrapAnsi from 'wrap-ansi'; import { themeManager } from '../themes.js'; export class ResponseFormatter { static MAX_WIDTH = process.stdout.columns || 80; static CONTENT_WIDTH = Math.min(ResponseFormatter.MAX_WIDTH - 4, 76); static formatResponse(text, title) { const wrapped = wrapAnsi(text, ResponseFormatter.CONTENT_WIDTH); const colors = themeManager.getColors(); const boxOptions = { padding: 1, borderStyle: 'single', borderColor: 'blue', title: title || '🤖 Response', titleAlignment: 'left' }; console.log(boxen(colors.response(wrapped), boxOptions)); } static formatError(error) { const colors = themeManager.getColors(); console.log(colors.error('❌ ' + error)); } static formatSuccess(message) { const colors = themeManager.getColors(); console.log(colors.success('✅ ' + message)); } static formatInfo(message) { const colors = themeManager.getColors(); console.log(colors.info('â„šī¸ ' + message)); } static formatWarning(message) { const colors = themeManager.getColors(); console.log(colors.warning('âš ī¸ ' + message)); } static formatCode(code, language) { const colors = themeManager.getColors(); const header = language ? colors.textMuted(`\`\`\`${language}`) : colors.textMuted('```'); const footer = colors.textMuted('```'); console.log(header); console.log(colors.code(code)); console.log(footer); } static formatList(items, title) { const colors = themeManager.getColors(); if (title) { console.log(colors.warning(title)); } items.forEach(item => { console.log(colors.listMarker(' â€ĸ ') + colors.text(item)); }); } static formatTable(headers, rows) { const colors = themeManager.getColors(); const widths = headers.map((h, i) => { const headerWidth = h.length; const maxRowWidth = Math.max(...rows.map(r => (r[i] || '').length)); return Math.max(headerWidth, maxRowWidth) + 2; }); const headerRow = headers.map((h, i) => colors.bold(h.padEnd(widths[i]))).join('│'); console.log(colors.border('┌' + widths.map(w => '─'.repeat(w)).join('â”Ŧ') + '┐')); console.log(colors.border('│') + headerRow + colors.border('│')); console.log(colors.border('├' + widths.map(w => '─'.repeat(w)).join('â”ŧ') + '┤')); rows.forEach(row => { const dataRow = row.map((cell, i) => (cell || '').padEnd(widths[i])).join('│'); console.log(colors.border('│') + dataRow + colors.border('│')); }); console.log(colors.border('└' + widths.map(w => '─'.repeat(w)).join('┴') + '┘')); } static formatKeyValue(pairs, title) { const colors = themeManager.getColors(); if (title) { console.log(colors.warning(title)); } const maxKeyLength = Math.max(...Object.keys(pairs).map(k => k.length)); Object.entries(pairs).forEach(([key, value]) => { const paddedKey = key.padEnd(maxKeyLength); const formattedValue = typeof value === 'boolean' ? (value ? colors.success('Yes') : colors.error('No')) : colors.text(String(value)); console.log(colors.info(` ${paddedKey}: `) + formattedValue); }); } }