xonecas.io
64875
Mc

mini-coder / commit d2e064f

refactor(cli): reduce noisy successful shell output

xonecas2026-03-14 d2e064f63a1caa7c751e39fdd3888ff664d6dc04 parent cbd2db1

2 files changed

src/cli/tool-render-result.test.ts+23−0
@@ -39,6 +39,29 @@ describe("renderToolResult", () => {
3939 expect(plain).toContain("stderr (1 lines)");
4040 });
4141
42+ test("omits long stdout previews for successful shell calls", () => {
43+ terminal.stdoutWrite = (chunk: string) => {
44+ stdout += chunk;
45+ };
46+
47+ renderToolResult(
48+ "shell",
49+ {
50+ stdout: "a\nb\nc\nd\ne",
51+ stderr: "",
52+ exitCode: 0,
53+ success: true,
54+ timedOut: false,
55+ },
56+ false,
57+ );
58+
59+ const plain = stripAnsi(stdout);
60+ expect(plain).toContain("exit 0 · stdout 5L · stderr 0L");
61+ expect(plain).toContain("stdout omitted (5 lines)");
62+ expect(plain).not.toContain("stdout (5 lines)");
63+ });
64+
4265 test("renders file edit diff for create", () => {
4366 terminal.stdoutWrite = (chunk: string) => {
4467 stdout += chunk;
src/cli/tool-result-handlers.ts+37−12
@@ -70,18 +70,43 @@ function renderShellResult(result: unknown): boolean {
7070 writeln(
7171 ` ${badge} ${c.dim(`exit ${r.exitCode} · stdout ${stdoutLines}L · stderr ${stderrLines}L`)}`,
7272 );
73- writePreviewLines({
74- label: "stdout",
75- value: r.stdout,
76- lineColor: c.dim,
77- maxLines: 6,
78- });
79- writePreviewLines({
80- label: "stderr",
81- value: r.stderr,
82- lineColor: c.red,
83- maxLines: 4,
84- });
73+
74+ if (!r.success || r.timedOut) {
75+ writePreviewLines({
76+ label: "stderr",
77+ value: r.stderr,
78+ lineColor: c.red,
79+ maxLines: 6,
80+ });
81+ writePreviewLines({
82+ label: "stdout",
83+ value: r.stdout,
84+ lineColor: c.dim,
85+ maxLines: 4,
86+ });
87+ return true;
88+ }
89+
90+ if (stderrLines > 0) {
91+ writePreviewLines({
92+ label: "stderr",
93+ value: r.stderr,
94+ lineColor: c.red,
95+ maxLines: 4,
96+ });
97+ }
98+
99+ if (stdoutLines > 0 && stdoutLines <= 3) {
100+ writePreviewLines({
101+ label: "stdout",
102+ value: r.stdout,
103+ lineColor: c.dim,
104+ maxLines: 3,
105+ });
106+ } else if (stdoutLines > 3) {
107+ writeln(` ${c.dim(`stdout omitted (${stdoutLines} lines)`)}`);
108+ }
109+
85110 return true;
86111 }