Skip to content

feat(analyze): add clast analyze, a journal session explorer with transcript views - #53

Merged
simensen merged 12 commits into
mainfrom
beau/analyze-verb
Sep 29, 2026
Merged

simensen merged 12 commits into
mainfrom
beau/analyze-verb

Conversation

@simensen

Copy link
Copy Markdown
Member

Adds clast analyze [<day>] [--since -Nd|-Nw] [--addr host:port] [--out file.html], an HTML explorer over a journal window. It replaces the gitignored analyze/ prototype. Its first use is the work to make summaries shorter.

What it does

  • Overview: a table with entry and retro word counts, a day → project sidebar, and each entry draft beside its retro summary. Dismissed sessions show their reason, and each day has a breadcrumbs view.
  • Serve mode (default): binds --addr (default 127.0.0.1:0), prints the URL, and gathers the window again on each request. It never opens a browser.
  • --out: writes the overview as one static file. The served overview and the file are byte-identical.
  • Cache-only summaries: analyze never calls the LLM. It reads the summaries that clast retro cached. A session with no cached summary shows a hint to run retro.
  • Transcript view: /t/<session-id> shows the conversation. Tool calls and thinking are collapsed, and meta records are hidden behind a toggle. Each Agent call links to /t/<session-id>/agents/<agent-id>. Transcripts are served only by the server, so --out shows a note in their place.
  • Default window: today with --since -6d. This is different from retro's yesterday default on purpose.

Structure

  • internal/retrocache: the retro summary cache, moved out of retroverb so that both verbs can compute the same key. Keys are unchanged.
  • source.TranscriptReader: a new optional interface beside TranscriptRenderer. The claude source implements it. show --transcript is unchanged.
  • internal/verbs/analyzeverb: the command, gather, the page models, and the HTTP handler. The templates are assets/analyze/index.html and transcript.html. Both can be overridden under $XDG_CONFIG_HOME/clast/.

The decisions are recorded in docs/analyze-verb/decisions.md and docs/analyze-transcript-view/decisions.md.

Testing

  • Unit tests cover the page models, the markdown renderer, the transcript reader, the routes, path traversal, and a 3 MB generated transcript.
  • The e2e tests fill the cache with a real clast retro run against the LLM stub, and then check --out, serve mode (served bytes equal --out, SIGINT exits 0), and transcript pages for a captured session.
  • On real data, a 3.9 MB transcript renders to about 990 KB in under 60 ms.
  • TestSeal_StaleAloneFiltersCorrectly in internal/cli fails. It already failed before this branch, and this PR does not touch it.

The upcoming analyze verb reads cached retro summaries without calling
the LLM, so it must key entries exactly as retro writes them. No verb
package imports another verb's package, so the cache directory, the
fingerprint recipe, and Get/Put move below both verbs, joined by a new
EntryKey that renders the key pair with {{project}} blanked.

retroverb now builds one retrocache.Entry per session and renders both
the prompt it sends and the key it caches under from it. Cache keys are
unchanged: a fixed fixture fingerprints identically before and after,
and all 13 summaries of a real three-day window still hit.
Port the analyze/ prototype viewer to a shipped asset,
assets/analyze/index.html, rendered through html/template and
overridable under $XDG_CONFIG_HOME/clast/. The prototype built its DOM
in the browser from injected JSON; the port renders every view on the
server and switches views on CSS :target, so the page works without
script and deep-links each session by #s-<session-id>.

New per-day breadcrumbs views group each day's breadcrumbs by project,
global first. A curated session with no cached summary points at the
clast retro run that would fill it.

The page model (Page, Day, Project, Session, CrumbGroup) carries raw
facts; word counts, labels and averages are methods, counted over the
raw markdown as the prototype did so the verbosity baselines stay
comparable. The command that gathers a window into a Page follows.
clast analyze [<day>] [--since -Nd|-Nw] gathers the journal window
through plumbing retro's Run, maps it onto the explorer Page, and with
--out writes the rendered page to one file and exits. The default window
is today reaching back six days: an explorer browses a stretch, where
retro renders one day.

Summaries are cache-only. Gather keys each entry with
retrocache.EntryKey under the configured llm.model, read through the new
llm.ConfiguredModel so no endpoint or API key is needed, and a miss
leaves the page's "not summarized" hint. Times convert to local before
the page renders them.

--addr is declared and exclusive with --out; serve mode follows.
Without --out, clast analyze binds --addr (default 127.0.0.1:0), prints
the bound URL, and serves the page until Ctrl-C or SIGTERM. It never
opens a browser: the URL is the interface, and a remote host
port-forwards it.

NewHandler gathers the window afresh on every GET or HEAD of /, so the
page tracks the journal and the summary cache while it stays open.
Serve mode and --out render through one path, so the served page and
the written file are byte-identical for the same window.
Handler units add HEAD, a fresh gather per request, and the Allow
header on a refused method. The e2e suite fills the summary cache by
running the real clast retro against the llmtest stub, so retro's keys
and analyze's lookup are proven to agree. It then asserts that --out
renders a cached summary, the not-summarized hint and a dismissal
reason with no further LLM request. It also asserts that --out with
--addr is a usage error, and that serve mode prints its URL, serves
the same bytes --out writes, and exits cleanly on SIGINT.

analyze joins the skill table's non-plumbing verbs, which keeps it
out of the generated plumbing verb table.
docs/analyze-verb/decisions.md records the calls that building clast
analyze forced: the week-long default window, serve-by-default with a
byte-identical --out, cache-only summaries through internal/retrocache,
server-side :target rendering and its deep-link anchors, and the
retirement of the gitignored analyze/ prototype.
The analyze transcript view needs what show --transcript deliberately
drops: tool calls with their results, thinking, and the bookkeeping
records around them. A new optional TranscriptReader interface sits
beside TranscriptRenderer and returns source-agnostic Events: prompt,
assistant, thinking, tool_call (with its paired result), an orphan
tool_result, and meta with a label naming the record's sub-kind. It
also lists a session's subagent transcripts with the id of the tool
call that spawned each one.

The claude source implements it. Results pair to calls by tool_use_id,
signature-only thinking is marked redacted, injected user turns are
meta rather than prompts, and duplicate uuids from forked history are
dropped. The registry resolves a reader by transcript.format, as it
does a renderer. show --transcript is unchanged.
A new transcript page, assets/analyze/transcript.html (overridable like
index.html), renders a session's structured transcript events. Prompts
and assistant turns read as markdown prose. Thinking and each tool call
sit behind disclosure, and a call's summary line names the tool and its
most telling input. Signature-only thinking folds into one muted line,
and meta records are hidden behind a no-script toggle.

Tool inputs and results are capped at 200 lines or 20 KB with a note,
so one large Write or result cannot swamp the page. An Agent call links
to its subagent transcript, and a subagent page links back to the call
that spawned it. The routes that serve these pages follow.
The server now answers /t/<session-id> and
/t/<session-id>/agents/<agent-id> with the transcript page. The session
is found in the window gathered for that request, so a session outside
the window is a 404 that names the window. The agent id is matched
against the session's listed subagents and never joined into a path.
Ids that are empty, dot segments, or carry a slash, backslash or NUL
are refused.

Each session view links to its transcript. Transcripts stay
serve-only, so a saved --out page shows a note that they open only
while clast analyze is serving; a served page removes the note with
script. The served overview and the --out file stay byte-identical.

A transcript cut short by a read failure still renders what was read,
under a warning banner.
The e2e suite captures a synthetic claude session, with a subagent,
through the real plumbing capture path, then serves it. It asserts
that the transcript page shows the conversation with tool calls and
thinking collapsed and meta hidden, that the Agent call links to a
subagent page which links back, and that unknown sessions and agents
are 404s.

A marker placed in a prompt, a tool result and a thinking block never
reaches the overview, served or --out, and the two still match byte
for byte. A generated 3 MB transcript with 2,000 tool calls renders
smaller than its input, with every oversized result capped.
docs/analyze-transcript-view/decisions.md records the calls that
building the transcript view forced: serve-only transcripts with a
static hint in --out, the TranscriptReader seam beside the renderer,
the event model and its meta bucket, the output caps, the URL scheme
and hand-parsed routes, path safety, and the measured weight and
timings.
TestSeal_StaleAloneFiltersCorrectly ran plumbing sessions with the
default -14d window, which resolves against the real clock. Its
fixtures sit on 2026-09-11, so the test began failing once the date
passed 2026-09-25. Pass --since all, as every other e2e case that must
not depend on the date already does.
@simensen
simensen merged commit f85e789 into main Sep 29, 2026
5 checks passed
@simensen
simensen deleted the beau/analyze-verb branch September 29, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant