Skip to content

Commit f36669a

Browse files
committed
✨ feat(cli): compact tool panels and format JSON output
- collapse tool outputs unless verbose to reduce visual noise\n- render JSON tool payloads with rich Syntax formatting\n- shrink tool panels via minimal boxes and tighter padding
1 parent 83ba2e8 commit f36669a

2 files changed

Lines changed: 43 additions & 7 deletions

File tree

meeseeks-cli/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Scope: this file applies to the `meeseeks-cli/` package only. It covers the term
2323
- Action Plan: checklist in a panel titled `:clipboard: Action Plan`, border `cyan`.
2424
- Tool Results: per-tool panels, title prefix `:wrench:`, border `magenta`.
2525
- Response: `:speech_balloon: Response`, border `bold green`.
26-
- Tool result cards dim unless they are the current focus (if a response prints, all tool cards dim).
26+
- Tool result cards dim unless they are the current focus; outputs are collapsed unless verbose and JSON renders formatted.
2727

2828
If you change any of these, update this file.
2929

meeseeks-cli/cli_master.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
"""Terminal CLI for Meeseeks."""
33

44
import argparse
5+
import json
56
import os
67
import sys
78
from collections.abc import Callable, Iterable
89

910
from prompt_toolkit import PromptSession
1011
from prompt_toolkit.history import FileHistory
12+
from rich import box
1113
from rich.columns import Columns
1214
from rich.console import Console, Group
1315
from rich.markdown import Markdown
1416
from rich.panel import Panel
17+
from rich.syntax import Syntax
1518
from rich.text import Text
1619

1720

@@ -252,6 +255,7 @@ def _run_query(
252255
task_queue,
253256
tool_registry,
254257
highlight_latest=not bool(task_queue.task_result),
258+
verbose=args.verbose > 0,
255259
)
256260
if task_queue.task_result:
257261
console.print(
@@ -353,6 +357,7 @@ def _render_results_with_registry(
353357
task_queue: TaskQueue,
354358
tool_registry: ToolRegistry,
355359
highlight_latest: bool = True,
360+
verbose: bool = False,
356361
) -> None:
357362
specs = _tool_specs_by_id(tool_registry)
358363
panels: list[Panel] = []
@@ -370,16 +375,21 @@ def _render_results_with_registry(
370375
is_latest = highlight_latest and index == last_index
371376
content_style = None if is_latest else "dim"
372377
border_style = "magenta" if is_latest else "dim magenta"
373-
content = Text(
374-
str(result) if result is not None else "(no result)",
375-
style=content_style,
376-
)
378+
renderable: Text | Syntax
379+
if result is None:
380+
renderable = Text("(no result)", style="dim")
381+
elif not verbose:
382+
renderable = Text("(output hidden; use -v/--verbose)", style="dim")
383+
else:
384+
renderable = _format_tool_output(result, content_style)
377385
panels.append(
378386
Panel(
379-
content,
387+
renderable,
380388
title=label,
381389
border_style=border_style,
382-
padding=(0, 1),
390+
padding=(0, 0),
391+
box=box.MINIMAL,
392+
style=None if is_latest else "dim",
383393
)
384394
)
385395
if not panels:
@@ -391,6 +401,32 @@ def _render_results_with_registry(
391401
console.print(Columns(panels, expand=True))
392402

393403

404+
def _format_tool_output(result: object, content_style: str | None) -> Text | Syntax:
405+
if isinstance(result, dict | list):
406+
return Syntax(
407+
json.dumps(result, indent=2, ensure_ascii=True),
408+
"json",
409+
theme="ansi_dark",
410+
word_wrap=True,
411+
)
412+
if isinstance(result, str):
413+
stripped = result.strip()
414+
if stripped:
415+
try:
416+
parsed = json.loads(stripped)
417+
except json.JSONDecodeError:
418+
parsed = None
419+
if isinstance(parsed, dict | list):
420+
return Syntax(
421+
json.dumps(parsed, indent=2, ensure_ascii=True),
422+
"json",
423+
theme="ansi_dark",
424+
word_wrap=True,
425+
)
426+
return Text(result, style=content_style)
427+
return Text(str(result), style=content_style)
428+
429+
394430
def _build_cli_hook_manager(
395431
console: Console,
396432
tool_registry: ToolRegistry,

0 commit comments

Comments
 (0)