model_chat/bin/ds-lib/output.js
2026-01-04 12:10:06 +08:00

32 lines
619 B
JavaScript

const BLUE = '\x1b[34m';
const RESET = '\x1b[0m';
let inBold = false;
// Render **bold** blocks using ANSI blue, keep other characters unchanged.
export function renderChunk(text) {
let out = '';
for (let i = 0; i < text.length; i++) {
if (text[i] === '*' && text[i + 1] === '*') {
inBold = !inBold;
out += inBold ? BLUE : RESET;
i++;
continue;
}
out += text[i];
}
return out;
}
export function printHeading(label) {
process.stdout.write(`${label}\n`);
}
export function printError(msg) {
console.error(msg);
}
export function printInfo(msg) {
console.log(msg);
}