Skip to content

fix: prevent NaN correction rate in export-timeline, add tests#293

Open
TerminalGravity wants to merge 4 commits intomainfrom
fix/export-timeline-nan-and-tests
Open

fix: prevent NaN correction rate in export-timeline, add tests#293
TerminalGravity wants to merge 4 commits intomainfrom
fix/export-timeline-nan-and-tests

Conversation

@TerminalGravity
Copy link
Collaborator

What

  • Bug fix: generateMarkdownReport divides correctionCount / promptCount without checking for zero, producing NaN% in reports with no prompt events.
  • Tests: Added 11 tests for parseRelativeDate, computeStats, and generateMarkdownReport (54 total, up from 43).
  • Exported helper functions for testability.

Why

Reports generated for commit-only or tool-only timelines showed NaN% of prompts in the summary.

Adds a ready-to-use CLAUDE.md template that makes Claude Code
automatically run preflight_check on prompts. Users can copy it
into their project to get preflight working without manual tool calls.

Referenced from Quick Start in README and examples/README.
- CLI now responds to --help/-h with usage info, profiles, and links
- CLI now responds to --version/-v with package version
- Previously, any flag just launched the interactive wizard
- Fixed README badge from Node 18+ to Node 20+ (matches engines field)
Adds a new export_timeline MCP tool that generates structured markdown
reports from timeline data. Includes:
- Summary stats (event counts, correction/error rates)
- Daily activity breakdown
- Commit log
- Correction patterns analysis
- Error listing
- Optional full timeline

Supports relative date ranges (7days, 2weeks), configurable sections,
and all existing scope/project filters.

Closes #5
…meline tests

- computeStats divides correctionCount/promptCount without zero-check, producing NaN% in reports
- Export parseRelativeDate, computeStats, generateMarkdownReport for testability
- Add 11 tests covering parseRelativeDate, computeStats, and generateMarkdownReport
- Total test count: 43 → 54
Copy link
Collaborator Author

@TerminalGravity TerminalGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NaN guard on correction rate is a good catch. The export-timeline tool is well-structured: relative date parsing, type icons, markdown/JSON output. Tests are thorough. Minor: parseRelativeDate could handle plurals more explicitly but not blocking.

Copy link
Collaborator Author

@TerminalGravity TerminalGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the NaN correction rate — dividing by zero when there are no events is a classic edge case. Tests look solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant