feat: Dashboard stats validation with comparison and export utilities#157
Merged
feat: Dashboard stats validation with comparison and export utilities#157
Conversation
…cking - Create comprehensive Zod schemas for all indexer stats types - Add runtime validation for state loading/saving - Implement change frequency tracking for dashboard - Add avgCommitsPerFile and lastModified to LanguageStats - Add totalCommits and lastModified to PackageStats - 52 new tests (schemas + change frequency) - All 577 core tests passing Follows TYPESCRIPT_STANDARDS.md - eliminates type assertions with runtime validation at external boundaries (state files). Aligns with Dashboard & Visualization epic.
…ities - Integrate change frequency into getStats() for enriched metrics - Language stats now include avgCommitsPerFile and lastModified - Package stats now include totalCommits and lastModified - Graceful degradation with console.warn when git unavailable - Add compareStats() for trend analysis between snapshots - Add export utilities (JSON, CSV, Markdown table) - Relax RepositoryMetadata.remote validation (allow non-URL values) - Mock console.error in event-bus test to prevent CI pollution All 598 core tests passing with clean output. Sets foundation for metrics store by: - Enabling actual use of change frequency data - Providing comparison capabilities for trends - Supporting data export for dashboards
- Add optional logger parameter to AsyncEventBusOptions - Use kero logger for all debug/error logging when provided - Graceful fallback to console.* when no logger provided - Add comprehensive logger integration tests Benefits: - Consistent structured logging across core components - Proper log levels and error context - Better test isolation with logger mocking - Aligns with scanner/observability logging patterns All 601 core tests passing (added 3 new tests).
- Restructure stats command to support subcommands: - 'dev stats' or 'dev stats show' - Show current stats (default) - 'dev stats compare <before> <after>' - Compare two stat snapshots - 'dev stats export [--format json|csv|markdown]' - Export stats Features: - Compare shows overall changes, trend analysis, and per-language/component diffs - Export supports JSON, CSV, and Markdown table formats - Rich visual comparison with color-coded changes and percentages - Helper function for human-readable duration formatting Benefits: - Users can track codebase evolution over time - Dashboard-ready data export for visualization - Clean CLI UX with consistent formatting - Maintains backward compatibility (stats show is default) All 736 tests passing (including updated CLI structure tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR lays the foundation for the Dashboard & Visualization epic by implementing comprehensive stats validation, change frequency tracking, and CLI utilities for comparison and export.
What Changed
1. Change Frequency Integration
getStats()avgCommitsPerFileandlastModifiedtotalCommitsandlastModifiedcompareStats()utility for trend analysis2. Kero Logger Integration
loggerparameter toAsyncEventBus3. CLI Stats Subcommands
statscommand with subcommands:dev statsordev stats show- Show current stats (default)dev stats compare <before> <after>- Compare two snapshotsdev stats export --format json|csv|markdown- Export statsExample Usage
Comparison Output:
Testing
Files Changed
Core:
packages/core/src/indexer/index.ts- Change frequency integrationpackages/core/src/indexer/utils/comparison.ts- Stats comparison logic (NEW)packages/core/src/indexer/utils/export.ts- Export utilities (NEW)packages/core/src/events/event-bus.ts- Kero logger integrationpackages/core/src/events/__tests__/event-bus.test.ts- Logger testsCLI:
packages/cli/src/commands/stats.ts- Restructured with subcommandspackages/cli/src/cli.test.ts- Updated structure testsBreaking Changes
None - all changes are backward compatible.
dev statsstill works as before.Next Steps
This PR sets the foundation for:
feat/sqlite-metrics-store) - Persistent time-series dataChecklist
TYPESCRIPT_STANDARDS.md)WORKFLOW.md)Related
Part of the Dashboard & Visualization epic (see
temp/dashboard-epic.md)