@@ -1,3 +1,7 @@
1+import {
2+ createHighlighter,
3+ type Highlighter,
4+} from "yoctomarkdown/src/index.ts";
15 import { G, write, writeln } from "./output.ts";
26 import type { Spinner } from "./spinner.ts";
37
@@ -5,6 +9,7 @@ export class StreamRenderContent {
59 private inText = false;
610 private accumulatedText = "";
711 private accumulatedReasoning = "";
12+ private highlighter: Highlighter | undefined;
813
914 constructor(private readonly spinner: Spinner) {}
1015
@@ -31,10 +36,14 @@ export class StreamRenderContent {
3136 if (renderedVisibleOutput) writeln();
3237 write(`${G.reply} `);
3338 this.inText = true;
39+ this.highlighter = createHighlighter();
3440 }
3541 this.accumulatedText += text;
3642 this.spinner.stop();
37- write(text);
43+ if (this.highlighter) {
44+ const colored = this.highlighter.write(text);
45+ if (colored) write(colored);
46+ }
3847 }
3948
4049 appendReasoningDelta(delta: string | undefined): string {
@@ -54,6 +63,10 @@ export class StreamRenderContent {
5463
5564 flushOpenContent(): void {
5665 if (!this.inText) return;
66+ if (this.highlighter) {
67+ const finalColored = this.highlighter.end();
68+ if (finalColored) write(finalColored);
69+ }
5770 writeln();
5871 this.inText = false;
5972 }