@hivetechs/hive-ai
Version:
Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API
101 lines • 3.27 kB
JavaScript
/**
* Simple color utility for terminal output
* Uses basic ANTML escape sequences for maximum compatibility
*/
// Basic colors
export const colors = {
// Text colors
black: '\x1b[30m',
red: '\x1b[31m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
magenta: '\x1b[35m',
cyan: '\x1b[36m',
white: '\x1b[37m',
// Bright text colors
brightBlack: '\x1b[90m',
brightRed: '\x1b[91m',
brightGreen: '\x1b[92m',
brightYellow: '\x1b[93m',
brightBlue: '\x1b[94m',
brightMagenta: '\x1b[95m',
brightCyan: '\x1b[96m',
brightWhite: '\x1b[97m',
// Background colors
bgBlack: '\x1b[40m',
bgRed: '\x1b[41m',
bgGreen: '\x1b[42m',
bgYellow: '\x1b[43m',
bgBlue: '\x1b[44m',
bgMagenta: '\x1b[45m',
bgCyan: '\x1b[46m',
bgWhite: '\x1b[47m',
// Text styles
reset: '\x1b[0m',
bold: '\x1b[1m',
dim: '\x1b[2m',
italic: '\x1b[3m',
underline: '\x1b[4m',
blink: '\x1b[5m',
inverse: '\x1b[7m',
hidden: '\x1b[8m',
strikethrough: '\x1b[9m'
};
// Environment detection
export const supportsColor = process.env.FORCE_COLOR !== '0' &&
!process.env.NO_COLOR &&
process.env.TERM !== 'dumb' &&
(process.env.FORCE_COLOR || process.stdout.isTTY);
// Helper functions
export function colorize(text, color) {
if (!supportsColor)
return text;
return `${colors[color]}${text}${colors.reset}`;
}
// Themed output helpers
export const theme = {
// Primary UI elements
primary: (text) => colorize(text, 'blue'),
primaryBold: (text) => colorize(colorize(text, 'blue'), 'bold'),
// Success messages
success: (text) => colorize(text, 'green'),
successBold: (text) => colorize(colorize(text, 'green'), 'bold'),
// Warning messages
warning: (text) => colorize(text, 'yellow'),
warningBold: (text) => colorize(colorize(text, 'yellow'), 'bold'),
// Error messages
error: (text) => colorize(text, 'red'),
errorBold: (text) => colorize(colorize(text, 'red'), 'bold'),
// Info messages
info: (text) => colorize(text, 'cyan'),
infoBold: (text) => colorize(colorize(text, 'cyan'), 'bold'),
// Secondary/dimmed text
dim: (text) => colorize(text, 'dim'),
// Command highlighting
command: (text) => colorize(text, 'brightBlue'),
// Parameter highlighting
param: (text) => colorize(text, 'brightGreen'),
// Code blocks
code: (text) => `${colors.bgBlack}${colors.white}${text}${colors.reset}`,
// Headers
header: (text) => colorize(colorize(colorize(text, 'blue'), 'bold'), 'underline'),
subheader: (text) => colorize(colorize(text, 'cyan'), 'bold')
};
// Logo with colors
export const colorLogo = `
${colors.blue}${colors.bold} __ ___ ___ ____${colors.reset}
${colors.blue}${colors.bold} / / / (_)_ _____/ | / _/${colors.reset}
${colors.blue}${colors.bold} / /_/ / / / / / __/ /| | / / ${colors.reset}
${colors.blue}${colors.bold} / __ / / /_/ / /_/ ___ |_/ / ${colors.reset}
${colors.blue}${colors.bold}/_/ /_/_/\\__,_/\\__/_/ |_/___/ ${colors.reset}
`;
// Export default for convenience
export default {
colors,
colorize,
theme,
colorLogo,
supportsColor
};
//# sourceMappingURL=colors.js.map