UNPKG

@capgo/cli

Version:
23 lines (22 loc) 1.22 kB
export interface StreamingMarkdownRenderer { /** Feed a decoded text chunk (any split point — mid-line, mid-fence). */ feed: (text: string) => void; /** Render the final line (the text after the last newline, possibly empty). */ flush: () => void; } /** * Incremental wrapper over the line-based markdown renderer, for progressive * TTY display of streamed AI analysis chunks. * * Buffers input until a newline completes a line, renders the completed line * through `renderMarkdownLine` (threading the code-fence state), and emits it. * Because every line is rendered by the exact same function the buffered * `renderMarkdown` uses, the concatenated streamed output is byte-identical * to `renderMarkdown(fullText)` — regardless of how the text was chunked. * (test-ai-stream-markdown.mjs proves this for every possible split point.) * * Trade-off: nothing prints until a line completes, so streaming is * line-by-line rather than character-by-character. Rewriting a partial line * in place would break as soon as the line wraps past the terminal width. */ export declare function createStreamingMarkdownRenderer(write: (text: string) => void, isTTY: boolean): StreamingMarkdownRenderer;