xonecas.io
64875
Mc

mini-coder / commit bb74794

feat: stream render markdown content with yoctomarkdown

xonecas2026-03-15 bb74794da6b36070d6fe2c541efbd9e845333b28 parent fadbc49

2 files changed

package.json+1−1
@@ -28,7 +28,7 @@
2828 "ai": "^6.0.127",
2929 "diff": "^8.0.3",
3030 "yoctocolors": "^2.1.2",
31- "yoctomarkdown": "^0.0.1",
31+ "yoctomarkdown": "0.0.2",
3232 "zod": "^4.3.6"
3333 },
3434 "devDependencies": {
src/cli/stream-render-content.ts+17−8
@@ -1,7 +1,4 @@
1-import {
2- createHighlighter,
3- type Highlighter,
4-} from "yoctomarkdown/src/index.ts";
1+import { createHighlighter, type Highlighter } from "yoctomarkdown";
52 import { G, write, writeln } from "./output.ts";
63 import type { Spinner } from "./spinner.ts";
74
@@ -38,11 +35,17 @@ export class StreamRenderContent {
3835 this.inText = true;
3936 this.highlighter = createHighlighter();
4037 }
38+ const isFirstLine = !this.accumulatedText.includes("\n");
4139 this.accumulatedText += text;
4240 this.spinner.stop();
4341 if (this.highlighter) {
44- const colored = this.highlighter.write(text);
45- if (colored) write(colored);
42+ let colored = this.highlighter.write(text);
43+ if (colored) {
44+ if (isFirstLine && colored.startsWith("\x1b[2K\r")) {
45+ colored = `\x1b[2K\r${G.reply} ${colored.slice(5)}`;
46+ }
47+ write(colored);
48+ }
4649 }
4750 }
4851
@@ -64,8 +67,14 @@ export class StreamRenderContent {
6467 flushOpenContent(): void {
6568 if (!this.inText) return;
6669 if (this.highlighter) {
67- const finalColored = this.highlighter.end();
68- if (finalColored) write(finalColored);
70+ let finalColored = this.highlighter.end();
71+ if (finalColored) {
72+ const isFirstLine = !this.accumulatedText.includes("\n");
73+ if (isFirstLine && finalColored.startsWith("\x1b[2K\r")) {
74+ finalColored = `\x1b[2K\r${G.reply} ${finalColored.slice(5)}`;
75+ }
76+ write(finalColored);
77+ }
6978 }
7079 writeln();
7180 this.inText = false;