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
JavaScript
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);
});
}
}