Expand description
File-backed transcript context usage helpers (#s760a).
This module owns the harness transcript locator/read layer. Pure token
parsing, context-window lookup, percentage math, and clear/no-clear policy
stay in crate::context_usage.
Functions§
- latest_
claude_ transcript - Locate the active Claude Code session transcript as the most-recently-modified
*.jsonlunderprojects_subdir(#s760clive locator). The supervisor does not track the managed harness’s session id, so newest-mtime is the live signal for “the transcript this session is writing”. ReturnsNonewhen the directory is absent/unreadable or holds no.jsonlfile, so the caller fails safe and never clears. - latest_
codex_ transcript - Locate the newest Codex TUI session transcript for the current project.
Codex stores sessions under
~/.codex/sessions/<year>/<month>/<day>/; the firstsession_metarecord carriespayload.cwd, which is the stable project match key. - read_
used_ tokens - Read cumulative token usage from a transcript file for the given harness
(
#s760a). Claude -> parse JSONL; OpenCode ->None(unsupported until its transcript store is confirmed live, so the caller fails safe and never clears). Codex usage needs the event-provided context window, so callers usetranscript_context_pct_from_contentthroughtranscript_context_pctinstead of this raw token helper. A missing/unreadable file isNone. - transcript_
context_ pct - Read a transcript and compute ctx% in one call (
#s760a+#s760b).None(never clear) on any failure: unreadable/empty transcript, unsupported harness, or unknown model.