Agentic.CLI.Transcript (agentic v0.4.0)

Copy Markdown

Protocol-aware summarizer for CLI event streams.

The CLIs emit machine envelopes — opencode --format json events (step_start / text / tool / step_finish / error) and claude stream-json records (system / assistant / user / result / error, plus chatty stream_event deltas). Tailing those raw turns a "console" into a JSON wall that hides what the agent is actually doing.

summarize_line/2 turns one raw line into a small neutral summary that UI layers render as a human transcript row:

{:text, "helo world"}                     — agent said something
{:tool, "write — blog/test.exs"}          — tool call (name + hint)
{:step_start, ""}                         — a turn began
{:step_finish, "turn done · reason stop"} — a turn ended
{:error, "provider.quota — no funds"}     — failure
{:system, "session started"}              — lifecycle line
{:user, "use port 4000"}                  — injected stdin turn
:skip                                     — drop (delta noise)
:raw                                      — not an envelope; render raw

Everything is defensive: undecodable lines come back as :raw, unknown envelope types as :raw, missing fields are elided from the text.

Summary

Types

summary()

@type summary() ::
  {:text, String.t()}
  | {:tool, String.t()}
  | {:step_start, String.t()}
  | {:step_finish, String.t()}
  | {:error, String.t()}
  | {:system, String.t()}
  | {:user, String.t()}
  | :skip
  | :raw

Functions

summarize_line(arg1, line)

@spec summarize_line(atom(), binary() | String.t()) :: summary()