feat(inspect): add transcriptStats for structured session summaries - #34
Conversation
Extracts the per-method counts, pair count, frame count, and wall-clock duration already computed by inspectTranscript into a new pure function transcriptStats that returns a typed TranscriptStats object. Callers that need the numbers for further processing no longer have to parse the formatted string output. Includes 13 tests covering empty transcripts, single-frame edge cases, method counting, tools/call grouping, and a full typical session.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c3c08fe0e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| * "tools/call[search_issues]", matching the grouping used by | ||
| * `inspectTranscript`. | ||
| */ | ||
| export function transcriptStats(frames: Frame[]): TranscriptStats { |
There was a problem hiding this comment.
Export the new stats API from the package entry point
For installed consumers, package.json resolves both JavaScript and declarations through dist/index, but src/index.ts still re-exports only inspectTranscript. Consequently, import { transcriptStats } from "mcprec" fails and TranscriptStats is absent from the public declarations, making the new feature inaccessible through the documented package API; the tests conceal this by importing the internal source module directly.
Useful? React with 👍 / 👎.
Why
inspectTranscriptalready computes frame counts, pair counts, wall-clockduration, and a per-method call tally internally, but returns all of it as a
formatted string. Any caller that needs those numbers for further processing
(test assertions, CI thresholds, telemetry) has to parse coloured terminal
output.
transcriptStatssurfaces the same data as a typed object with noformatting attached.
What
src/inspect.ts: newTranscriptStatsinterface andtranscriptStats(frames)function. Delegates to the existing private
countMethodsandpairFrameshelpers so there is no logic duplication.
test/inspect.stats.test.ts: 13 tests covering empty transcripts,single-frame edge cases, durationSeconds arithmetic, method counting,
tools/call grouping by tool name, notification frame counting, and a
full typical session.
Tests
npm test- all 240 tests pass (227 existing + 13 new)npm run lint- cleannpm run build- cleanSelf-merge gate
Generated by Claude Code