feat: add JSON output option#3
Conversation
Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on March 3
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| "weekly_activity": get_weekly_activity(stats_data["commits"]), | ||
| "hourly_activity": get_hourly_activity(stats_data["commits"]), | ||
| } | ||
| console.print(json.dumps(output, indent=2)) |
There was a problem hiding this comment.
Rich console.print corrupts machine-readable JSON output
High Severity
Using Rich's console.print for JSON output intended for machine consumption (jq, scripting) is incorrect. Rich's Console.print applies syntax highlighting (ANSI escape codes in terminal), soft-wraps text to the terminal/default width (breaking long JSON lines), and interprets Rich markup (square brackets in JSON values could be misinterpreted). All three behaviors can produce invalid JSON. Python's built-in print() is the appropriate choice here.


Summary
--json/-jflag to output statistics as JSONjq, or integrating with other toolsUsage
Example output
{ "repository": ".", "total_commits": 42, "total_authors": 3, "first_commit": "2024-01-15", "last_commit": "2026-02-06", "authors": [...], "weekly_activity": [...], "hourly_activity": [...] }Made with Cursor
Note
Low Risk
Primarily adds an alternate output format and small CLI branching; core parsing/stat computation is unchanged, so behavioral risk is limited to output/compat expectations.
Overview
Adds a
--json/-jflag togitstats statsto emit machine-readable JSON instead of the rich/pretty terminal output.The JSON payload includes repository path, commit/author totals, first/last commit dates, per-author stats, and computed weekly/hourly activity; error cases now also return JSON when the flag is used. Documentation is updated to list the feature and show usage examples.
Written by Cursor Bugbot for commit 18470cd. This will update automatically on new commits. Configure here.