feat: include item ids in cli logs

This commit is contained in:
banteg
2025-12-28 23:05:08 +04:00
parent b00d9238e5
commit 638ee879e0
@@ -228,11 +228,13 @@ def render_event_cli(
elif itype == "command_execution":
command = _format_command(item.get("command", ""))
if etype == "item.started":
lines.append(f"{STATUS_RUNNING} running: {command}")
lines.append(_with_id(_extract_numeric_id(item.get("id")), f"{STATUS_RUNNING} running: {command}"))
elif etype == "item.completed":
exit_code = item.get("exit_code")
exit_part = f" (exit {exit_code})" if exit_code is not None else ""
lines.append(f"{STATUS_DONE} ran: {command}{exit_part}")
lines.append(
_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_DONE} ran: {command}{exit_part}\")
)
if show_output:
output = _truncate_output(item.get("aggregated_output", ""))
if output:
@@ -240,22 +242,24 @@ def render_event_cli(
elif itype == "file_change" and etype == "item.completed":
line = _format_file_change(item.get("changes", []))
lines.append(f"{STATUS_DONE} {line}")
lines.append(_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_DONE} {line}\"))
elif itype == "mcp_tool_call":
name = _format_tool_call(item.get("server", ""), item.get("tool", ""))
if etype == "item.started":
lines.append(f"{STATUS_RUNNING} tool: {name}")
lines.append(
_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_RUNNING} tool: {name}\")
)
elif etype == "item.completed":
lines.append(f"{STATUS_DONE} tool: {name}")
lines.append(_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_DONE} tool: {name}\"))
elif itype == "web_search" and etype == "item.completed":
query = _format_query(item.get("query", ""))
lines.append(f"{STATUS_DONE} searched: {query}")
lines.append(_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_DONE} searched: {query}\"))
elif itype == "error" and etype == "item.completed":
warning = _truncate(item.get("message", ""), 120)
lines.append(f"{STATUS_DONE} warning: {warning}")
lines.append(_with_id(_extract_numeric_id(item.get(\"id\")), f\"{STATUS_DONE} warning: {warning}\"))
return lines