Skip to content

feat(inspect): add --json flag for machine-readable stats output - #38

Merged
protosphinx merged 1 commit into
mainfrom
bot/inspect-json-flag
Sep 8, 2026
Merged

protosphinx merged 1 commit into
mainfrom
bot/inspect-json-flag

Conversation

@protosphinx

Copy link
Copy Markdown
Member

Why

mcprec inspect currently outputs a colored timeline suitable for humans
but not for CI scripts or tooling that needs to parse transcript stats
programmatically. The diff command already supports --format json;
this PR brings the same machine-readable option to inspect.

What

  • Add --json flag to the inspect CLI command in src/cli.ts
  • When --json is set, load the transcript and output transcriptStats
    as indented JSON instead of the colored timeline display
  • Import loadTranscript and transcriptStats in cli.ts (both already
    exported from their respective modules)

Tests

  • New file test/inspect.json.test.ts (9 tests) covering JSON output shape:
    • Top-level keys exactly match the TranscriptStats interface
    • Stats round-trip through JSON.parse(JSON.stringify()) without loss
    • No undefined values (which JSON.stringify would silently drop)
    • All method count values are positive integers
    • methods object keys are ordered by count descending
    • Correct behavior for empty transcripts and response-only transcripts

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (167 lines: 12 in src/cli.ts + 131 in test/inspect.json.test.ts + 24 context/headers)
  • no public-API surface change (src/index.ts not touched)
  • no runtime-dependency additions (imports are from existing modules)
  • no workflow file changes
  • tests added (test/inspect.json.test.ts, 9 new tests)

🤖 Generated with Claude Code

https://claude.ai/code/session_01AwmG44UxpGyiZU1bshsELs


Generated by Claude Code

`mcprec inspect --json <file>` outputs `transcriptStats` as indented
JSON instead of the colored timeline display. Consistent with the
existing `mcprec diff --format json` flag.

Adds test/inspect.json.test.ts covering JSON output shape invariants:
- top-level keys match the TranscriptStats interface exactly
- stats round-trip through JSON.parse/JSON.stringify without loss
- no undefined values that JSON.stringify would silently drop
- method counts are positive integers
- methods object keys are ordered by count descending
@protosphinx protosphinx added the automated Opened by the daily bot label Sep 8, 2026 — with Claude
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T16:14:29.383411Z f8c5e4a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@protosphinx
protosphinx merged commit 7615a95 into main Sep 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant