Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/agentacct/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9866,13 +9866,20 @@ def receipt(
bool,
typer.Option("--markdown", help="Render the Receipt as Markdown (with the timeline) to paste into a PR or doc."),
] = False,
output: Annotated[
Optional[Path],
typer.Option("--output", help="Write the rendered Markdown to this file (--markdown only)."),
] = None,
) -> None:
"""Print one Task's full Work Receipt: the 8 questions, the two orthogonal
axes (decision status × evidence strength), per-field provenance, and gaps."""

if json_output and markdown:
console.print("Choose one of --json or --markdown, not both.")
raise typer.Exit(2)
if output is not None and not markdown:
console.print("--output requires --markdown.")
raise typer.Exit(2)

from .api import build_store_task_projection, _task_title
from .receipt import build_receipt, latest_store_activity, session_start_index
Expand All @@ -9897,10 +9904,15 @@ def receipt(
if markdown:
from .receipt_markdown import render_receipt_markdown

rendered = render_receipt_markdown(receipt_payload)
if output is not None:
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(rendered, encoding="utf-8")
return
# print(), not console.print(): Rich would interpret the Markdown's
# brackets/backticks as markup and reflow it. This is meant to be copied
# verbatim.
print(render_receipt_markdown(receipt_payload))
print(rendered)
return
_render_receipt_text(receipt_payload)

Expand Down