source dump of claude code
at main 26 lines 921 B view raw
1import type { TextProps } from '../ink.js' 2import { 3 AGENT_COLOR_TO_THEME_COLOR, 4 type AgentColorName, 5} from '../tools/AgentTool/agentColorManager.js' 6 7const DEFAULT_AGENT_THEME_COLOR = 'cyan_FOR_SUBAGENTS_ONLY' 8 9/** 10 * Convert a color string to Ink's TextProps['color'] format. 11 * Colors are typically AgentColorName values like 'blue', 'green', etc. 12 * This converts them to theme keys so they respect the current theme. 13 * Falls back to the raw ANSI color if the color is not a known agent color. 14 */ 15export function toInkColor(color: string | undefined): TextProps['color'] { 16 if (!color) { 17 return DEFAULT_AGENT_THEME_COLOR 18 } 19 // Try to map to a theme color if it's a known agent color 20 const themeColor = AGENT_COLOR_TO_THEME_COLOR[color as AgentColorName] 21 if (themeColor) { 22 return themeColor 23 } 24 // Fall back to raw ANSI color for unknown colors 25 return `ansi:${color}` as TextProps['color'] 26}