Expand description
Offline trace mining: distill recurring error signatures from a directory of
.jsonl transcript/log files (e.g. agent transcripts, CI logs).
The live loop (record_shell_outcome) learns
from commands run through lean-ctx. This module bootstraps that loop from
history: it scans past transcripts for the same unambiguous error markers the
shell detector recognizes (error[E####], error TS####, Traceback,
npm ERR!, panicked at, …) and ranks the signatures that recur across the
most sessions — the project’s persistent pain points.
Deterministic and high-precision by design: only structured error markers match (never free prose), each file counts as one “session”, and the output is read-only — it surfaces signatures for review, it never mutates state.
Structs§
- Mined
Signature - A recurring error signature distilled from mined transcripts.
Functions§
- default_
transcript_ dir - Auto-discover the agent-transcripts directory so
lean-ctx learn --mineworks with zero arguments. Prefers Claude Code’s~/.claude/projects, then Cursor’s~/.cursor/agent-transcripts. Returns the first that exists, orNone. - extract_
error_ signatures - Extract normalized error signatures from a single blob of text. Pure and deterministic; returns one entry per match (callers aggregate counts).
- format_
mining_ report - Render a mining report.
min_sessionshides one-off signatures so only genuinely recurring pain points show. - mine_
jsonl_ dir - Mine all
.jsonlfiles indirfor recurring error signatures. Each file is treated as one session; signatures are ranked by session reach, then total occurrences, then lexically — fully deterministic.