UNPKG

agentcrumbs

Version:
30 lines 889 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNamespaceColor = getNamespaceColor; exports.colorize = colorize; exports.dim = dim; exports.bold = bold; // ANSI 256-color palette indices chosen for readability on dark/light terminals const COLORS = [ 6, 2, 3, 4, 5, 1, 9, 10, 11, 12, 13, 14, 208, 196, 202, 170, ]; function hashString(str) { let hash = 0; for (let i = 0; i < str.length; i++) { hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0; } return Math.abs(hash); } function getNamespaceColor(namespace) { return COLORS[hashString(namespace) % COLORS.length]; } function colorize(text, colorIndex) { return `\x1b[38;5;${colorIndex}m${text}\x1b[0m`; } function dim(text) { return `\x1b[2m${text}\x1b[0m`; } function bold(text) { return `\x1b[1m${text}\x1b[0m`; } //# sourceMappingURL=colors.js.map