Repository navigation
feat(reporters): add third-party reporter plugin system - #184
Conversation
Add support for loading third-party reporters from file paths or npm packages.
Plugin patterns supported:
- Plain Reporter objects (default export)
- Factory functions (sync or async)
- ES6 class constructors
Key additions:
- ReporterLoader service for loading/validating plugins
- ReporterContext with logger, version, utils for plugins
- Generic ReporterFactory<TOptions> and ReporterClass<TOptions> types
- ReporterLoadError and ReporterValidationError classes
- Formatting utilities (formatDuration, formatOpsPerSecond, etc.)
- Comprehensive test fixtures for all plugin patterns
- Complete documentation (guide + API reference)
CLI usage:
modestbench run --reporter ./my-reporter.js
modestbench run --reporter @company/modestbench-reporter-fancy
Config usage:
{
"reporters": ["human", "./my-reporter.js"],
"reporterConfig": { "./my-reporter.js": { "verbose": true } }
}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive third-party reporter plugin system to ModestBench, enabling users to load custom reporters from file paths or npm packages. The implementation supports three plugin patterns (plain objects, factory functions, and ES6 classes), provides a rich context API with formatting utilities, and includes extensive test coverage and documentation.
Key Changes:
- Plugin loader service with support for multiple export patterns and async initialization
- Reporter context API providing version info, logging, and formatting utilities
- New error classes for load failures and validation errors
- CLI integration to load external reporters alongside built-in ones
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
test/unit/utils/reporter-utils.test.ts |
Comprehensive tests for formatting utilities (bytes, duration, ops/sec, percentage) |
test/unit/services/reporter-loader.test.ts |
Complete test suite for reporter loading, validation, and error handling |
test/fixtures/reporters/*.ts |
Test fixtures covering all plugin patterns and error scenarios |
src/utils/reporter-utils.ts |
Formatting utilities for benchmark data (bytes, duration, ops/sec, percentage) |
src/utils/package.ts |
Added cached package version getter for plugin context |
src/types/plugin.ts |
Type definitions for plugin API (ReporterContext, ReporterFactory, ReporterClass) |
src/services/reporter-loader.ts |
Core plugin loader with pattern detection and validation |
src/errors/reporter.ts |
New ReporterLoadError and ReporterValidationError classes |
src/cli/commands/run.ts |
CLI integration to load external reporters from file paths or npm packages |
src/index.ts |
Exports for plugin loader service and formatting utilities |
site/src/content/docs/reference/reporter-api.md |
Complete API reference for plugin authors |
site/src/content/docs/guides/custom-reporters.md |
Practical guide with examples for building custom reporters |
cspell.json |
Added whimsical words used in documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix missing colon in :::tip directive (custom-reporters.md) - Fix typo 'andjust' -> 'and just' (custom-reporters.md) - Improve class detection with /^class\b/ regex pattern - Add clarifying comment for Windows path handling in isFilePath
6d8d9e9 to
95715e0
Compare
Deploying modestbench with
|
| Latest commit: |
a5729ec
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0b5594ed.modestbench.pages.dev |
| Branch Preview URL: | https://feat-reporter-plugins.modestbench.pages.dev |
Add Custom Reporters guide and Reporter API reference to sidebar.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
ReporterLoaderservice for loading and validating pluginsReporterContextwith logger, version, and formatting utilities for pluginsReporterFactory<TOptions>andReporterClass<TOptions>types for typed optionsReporterLoadErrorandReporterValidationErrorerror classesCLI Usage
Config Usage
{ "reporters": ["human", "./my-reporter.js"], "reporterConfig": { "./my-reporter.js": { "verbose": true } } }Test plan
ReporterLoaderservice🤖 Generated with Claude Code