xonecas.io
64875
Mc

mini-coder / commit 5e8abb4

refactor(cli): fold CliReporter into output.ts, delete output-reporter.ts

The CliReporter class was a pure delegation wrapper in its own file,
adding an indirection layer with no value. Moving it into output.ts
alongside the output primitives it uses removes a file and makes the
output layer easier to reason about.

xonecas2026-03-14 5e8abb41cfab8512032e6debdf02aad316d886fb parent 9c150f4

3 files changed

src/cli/output-reporter.ts+0−86
@@ -1,86 +0,0 @@
1-import * as c from "yoctocolors";
2-import type {
3- AgentReporter,
4- StatusBarData,
5- TurnResult,
6-} from "../agent/reporter.ts";
7-import type { TurnEvent } from "../llm-api/types.ts";
8-import {
9- G,
10- renderError,
11- renderHook,
12- renderInfo,
13- renderStatusBar,
14- renderTurn,
15- restoreTerminal,
16- Spinner,
17- write,
18- writeln,
19-} from "./output.ts";
20-
21-export class CliReporter implements AgentReporter {
22- private spinner = new Spinner();
23-
24- info(msg: string): void {
25- this.spinner.stop();
26- renderInfo(msg);
27- }
28-
29- error(msg: string | Error, hint?: string): void {
30- this.spinner.stop();
31- if (typeof msg === "string") {
32- renderError(msg, hint);
33- } else {
34- renderError(msg.message, hint);
35- }
36- }
37-
38- warn(msg: string): void {
39- this.spinner.stop();
40- writeln(`${G.warn} ${msg}`);
41- }
42-
43- writeText(text: string): void {
44- this.spinner.stop();
45- writeln(text);
46- }
47-
48- streamChunk(text: string): void {
49- this.spinner.stop();
50- write(text);
51- }
52-
53- startSpinner(label?: string): void {
54- this.spinner.start(label);
55- }
56-
57- stopSpinner(): void {
58- this.spinner.stop();
59- }
60-
61- renderSubState(label: string): void {
62- this.spinner.stop();
63- writeln(` ${G.info} ${c.dim(label)}`);
64- this.spinner.start();
65- }
66-
67- async renderTurn(
68- events: AsyncIterable<TurnEvent>,
69- opts?: { showReasoning?: boolean },
70- ): Promise<TurnResult> {
71- return renderTurn(events, this.spinner, opts);
72- }
73-
74- renderStatusBar(data: StatusBarData): void {
75- renderStatusBar(data);
76- }
77-
78- renderHook(toolName: string, scriptPath: string, success: boolean): void {
79- this.spinner.stop();
80- renderHook(toolName, scriptPath, success);
81- }
82-
83- restoreTerminal(): void {
84- restoreTerminal();
85- }
86-}
src/cli/output.ts+81−9
@@ -2,10 +2,23 @@ import { existsSync } from "node:fs";
22 import { homedir } from "node:os";
33 import { join } from "node:path";
44 import * as c from "yoctocolors";
5+import type {
6+ AgentReporter,
7+ StatusBarData,
8+ TurnResult,
9+} from "../agent/reporter.ts";
10+import type { TurnEvent } from "../llm-api/types.ts";
511 import { loadAgents } from "./agents.ts";
612 import { loadCustomCommands } from "./custom-commands.ts";
13+import { renderError } from "./error-render.ts";
14+import { Spinner } from "./spinner.ts";
15+import { renderStatusBar } from "./status-bar.ts";
16+import { renderTurn } from "./stream-render.ts";
717 import { loadSkillsIndex } from "./skills.ts";
818 import { terminal } from "./terminal-io.ts";
19+import { renderHook } from "./tool-render.ts";
20+
21+export { renderError } from "./error-render.ts";
922
1023 const HOME = homedir();
1124 declare const __PACKAGE_VERSION__: string;
@@ -122,13 +135,72 @@ export function renderBanner(model: string, cwd: string): void {
122135 writeln();
123136 }
124137
125-export function renderInfo(msg: string): void {
126- writeln(`${G.info} ${c.dim(msg)}`);
127-}
138+// ─── CliReporter ──────────────────────────────────────────────────────────────
139+// Interactive terminal reporter — wraps all output primitives for agent use.
128140
129-export { renderError } from "./error-render.ts";
130-// Re-exports
131-export { Spinner } from "./spinner.ts";
132-export { renderStatusBar } from "./status-bar.ts";
133-export { renderTurn } from "./stream-render.ts";
134-export { renderHook } from "./tool-render.ts";
141+export class CliReporter implements AgentReporter {
142+ private spinner = new Spinner();
143+
144+ info(msg: string): void {
145+ this.spinner.stop();
146+ writeln(`${G.info} ${c.dim(msg)}`);
147+ }
148+
149+ error(msg: string | Error, hint?: string): void {
150+ this.spinner.stop();
151+ if (typeof msg === "string") {
152+ renderError(msg, hint);
153+ } else {
154+ renderError(msg.message, hint);
155+ }
156+ }
157+
158+ warn(msg: string): void {
159+ this.spinner.stop();
160+ writeln(`${G.warn} ${msg}`);
161+ }
162+
163+ writeText(text: string): void {
164+ this.spinner.stop();
165+ writeln(text);
166+ }
167+
168+ streamChunk(text: string): void {
169+ this.spinner.stop();
170+ write(text);
171+ }
172+
173+ startSpinner(label?: string): void {
174+ this.spinner.start(label);
175+ }
176+
177+ stopSpinner(): void {
178+ this.spinner.stop();
179+ }
180+
181+ renderSubState(label: string): void {
182+ this.spinner.stop();
183+ writeln(` ${G.info} ${c.dim(label)}`);
184+ this.spinner.start();
185+ }
186+
187+ async renderTurn(
188+ events: AsyncIterable<TurnEvent>,
189+ opts?: { showReasoning?: boolean },
190+ ): Promise<TurnResult> {
191+ return renderTurn(events, this.spinner, opts);
192+ }
193+
194+ renderStatusBar(data: StatusBarData): void {
195+ renderStatusBar(data);
196+ }
197+
198+ renderHook(toolName: string, scriptPath: string, success: boolean): void {
199+ this.spinner.stop();
200+ renderHook(toolName, scriptPath, success);
201+ }
202+
203+ restoreTerminal(): void {
204+ restoreTerminal();
205+ }
206+}
src/index.ts+1−1
@@ -18,7 +18,7 @@ import {
1818 writeln,
1919 } from "./cli/output.ts";
2020
21-import { CliReporter } from "./cli/output-reporter.ts";
21+import { CliReporter } from "./cli/output.ts";
2222 import { initApiLog } from "./llm-api/api-log.ts";
2323 import {
2424 initModelInfoCache,