ui.ts
1 /** 2 * Tiny ANSI styling helpers for the `mlflow-qwen-code` CLI. 3 * 4 * No runtime dependency on `chalk`/`kleur`: we keep the bundle small and 5 * respect the usual opt-outs (non-TTY stdout, `NO_COLOR`, `FORCE_COLOR=0`). 6 */ 7 8 const COLOR_ENABLED = (() => { 9 if (process.env.FORCE_COLOR === '0' || process.env.NO_COLOR) { 10 return false; 11 } 12 if (process.env.FORCE_COLOR) { 13 return true; 14 } 15 return Boolean(process.stdout.isTTY); 16 })(); 17 18 function wrap(code: string): (s: string) => string { 19 return (s: string) => (COLOR_ENABLED ? `\x1b[${code}m${s}\x1b[0m` : s); 20 } 21 22 export const bold = wrap('1'); 23 export const dim = wrap('2'); 24 export const green = wrap('32'); 25 export const red = wrap('31'); 26 export const cyan = wrap('36'); 27 export const yellow = wrap('33'); 28 29 export const OK = green('✓'); 30 export const FAIL = red('✗'); 31 export const WARN = yellow('!');