Skip to content

feat(reporters): add third-party reporter plugin system - #184

Merged
boneskull merged 4 commits into
mainfrom
feat/reporter-plugins
Dec 15, 2025
Merged

boneskull merged 4 commits into
mainfrom
feat/reporter-plugins

Conversation

@boneskull

Copy link
Copy Markdown
Owner

Summary

  • Add support for loading third-party reporters from file paths or npm packages
  • Support three plugin patterns: plain Reporter objects, factory functions (sync/async), and ES6 class constructors
  • Add ReporterLoader service for loading and validating plugins
  • Add ReporterContext with logger, version, and formatting utilities for plugins
  • Add generic ReporterFactory<TOptions> and ReporterClass<TOptions> types for typed options
  • Add ReporterLoadError and ReporterValidationError error classes
  • Add comprehensive test fixtures for all plugin patterns
  • Add complete documentation (guide + API reference)

CLI Usage

# Built-in reporters (unchanged)
modestbench run --reporter human --reporter json

# Custom reporter by file path
modestbench run --reporter ./my-reporter.js

# Custom reporter by npm package
modestbench run --reporter @company/modestbench-reporter-fancy

Config Usage

{
  "reporters": ["human", "./my-reporter.js"],
  "reporterConfig": {
    "./my-reporter.js": { "verbose": true }
  }
}

Test plan

  • Unit tests for ReporterLoader service
  • Unit tests for formatting utilities
  • Test fixtures for all plugin patterns (plain object, factory, async factory, class)
  • Test fixtures for error cases (invalid export, missing methods, throwing constructor/factory)

🤖 Generated with Claude Code

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]>
Copilot AI review requested due to automatic review settings December 14, 2025 01:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/cli/commands/run.ts Resolved
Comment thread src/services/reporter-loader.ts Resolved
Comment thread src/services/reporter-loader.ts Resolved
- 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
@boneskull
boneskull force-pushed the feat/reporter-plugins branch from 6d8d9e9 to 95715e0 Compare December 14, 2025 07:44
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 14, 2025 •

Copy link
Copy Markdown

Deploying modestbench with  Cloudflare Pages  Cloudflare Pages

Latest commit: a5729ec
Status: ✅  Deploy successful!
Preview URL: https://0b5594ed.modestbench.pages.dev
Branch Preview URL: https://feat-reporter-plugins.modestbench.pages.dev

View logs

Add Custom Reporters guide and Reporter API reference to sidebar.
Copilot AI review requested due to automatic review settings December 15, 2025 20:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@boneskull boneskull mentioned this pull request Dec 15, 2025
9 tasks
@boneskull
boneskull merged commit abe0d71 into main Dec 15, 2025
@boneskull
boneskull deleted the feat/reporter-plugins branch December 15, 2025 21:09
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.

2 participants