Skip to content

Commit a4a8e77

Browse files
committed
fix: escape brackets in Rich console output to prevent markup interpretation (#370)
Rich interprets `[text]` as markup, so brackets in commands like `agent-cli[extras]` were being stripped from output. This escapes brackets to display them literally.
1 parent a730250 commit a4a8e77

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

agent_cli/dev/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def _info(msg: str) -> None:
176176
# Style commands (messages starting with "Running: ")
177177
if msg.startswith("Running: "):
178178
cmd = msg[9:] # Remove "Running: " prefix
179+
# Escape brackets to prevent Rich from interpreting them as markup
180+
cmd = cmd.replace("[", r"\[")
179181
console.print(f"[dim]→[/dim] Running: [bold cyan]{cmd}[/bold cyan]")
180182
else:
181183
console.print(f"[dim]→[/dim] {msg}")

agent_cli/install/extras.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def _install_via_uv_tool(extras: list[str], *, quiet: bool = False) -> bool:
6868
if quiet:
6969
cmd.append("-q")
7070
# Use stderr for status messages so they don't pollute stdout (e.g., for hotkey notifications)
71-
err_console.print(f"Running: [cyan]{' '.join(cmd)}[/]")
71+
# Escape brackets to prevent Rich from interpreting them as markup
72+
cmd_str = " ".join(cmd).replace("[", r"\[")
73+
err_console.print(f"Running: [cyan]{cmd_str}[/]")
7274
result = subprocess.run(cmd, check=False)
7375
return result.returncode == 0
7476

0 commit comments

Comments
 (0)