npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@reaatech/pi-bench-leaderboard

v1.0.1

Published

Leaderboard management and result comparison for prompt-injection-bench

Readme

@reaatech/pi-bench-leaderboard

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Leaderboard management and JSON file persistence for prompt-injection-bench. Ranks defenses by composite score, assigns S/A/B/C/D tiers, and supports pairwise comparison with storable entries.

Installation

npm install @reaatech/pi-bench-leaderboard
# or
pnpm add @reaatech/pi-bench-leaderboard

Feature Overview

  • Tiered ranking — S/A/B/C/D tiers based on composite weighted score
  • Limit enforcement — Configurable max entries with automatic eviction of lowest scores
  • JSON file persistence — Auto-creates .prompt-injection-bench/leaderboard.json in working directory
  • Pairwise comparison — Compare any two entries in the leaderboard
  • Duplicate handling — Same defense+version replaces previous entry
  • Dual ESM/CJS output — works with import and require

Quick Start

import { createLeaderboardManager } from "@reaatech/pi-bench-leaderboard";
import { type DefenseScore } from "@reaatech/pi-bench-core";

const manager = createLeaderboardManager({ maxEntries: 100 });

// Add a defense score to the leaderboard
manager.addEntry(rebuffScore);

// Get ranked entries (sorted by composite score, descending)
const rankings = manager.getRankings();
for (const entry of rankings) {
  console.log(`${entry.tier} | ${entry.defense} v${entry.version}: ${entry.score.toFixed(3)}`);
}

// Compare two entries
const comparison = manager.compare("rebuff", "lakera");

API Reference

LeaderboardManager

| Method | Description | |--------|-------------| | addEntry(score) | Add or update a defense's score | | getRankings() | Return all entries sorted by composite score | | getEntry(defense, version?) | Get a specific entry | | compare(defenseA, defenseB) | Pairwise comparison of two defenses | | removeEntry(defense, version) | Remove an entry | | clear() | Clear all entries | | size | Current number of entries |

LeaderboardConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | maxEntries | number | 100 | Maximum leaderboard entries | | compositeWeights | object | — | Weights for composite score: { detection: 0.5, fpr: 0.2, latency: 0.15, consistency: 0.15 } |

createLeaderboardManager(config?)

Factory function.

Storage

| Export | Description | |--------|-------------| | getDefaultLeaderboardPath() | Returns .prompt-injection-bench/leaderboard.json in CWD | | loadLeaderboardEntries(path?) | Load entries from disk | | saveLeaderboardEntries(entries, path?) | Persist entries to disk |

LeaderboardEntry

| Property | Type | Description | |----------|------|-------------| | defense | string | Defense name | | version | string | Defense version | | score | number | Composite weighted score | | tier | string | S, A, B, C, or D | | submittedAt | string | ISO timestamp |

Usage Patterns

Persist to Disk

import { createLeaderboardManager } from "@reaatech/pi-bench-leaderboard";
import {
  saveLeaderboardEntries,
  loadLeaderboardEntries,
} from "@reaatech/pi-bench-leaderboard";

const manager = createLeaderboardManager({ maxEntries: 50 });

// Load existing entries
const existing = loadLeaderboardEntries();
for (const entry of existing) manager.addEntry(entry.score);

// Run a new benchmark, add the result
const score = /* ... from benchmark run ... */;
manager.addEntry(score);

// Persist
saveLeaderboardEntries(manager.getRankings());

Check Ranking

const rankings = manager.getRankings();
const myDefense = rankings.find((e) => e.defense === "my-defense");

if (myDefense) {
  console.log(
    `My defense is ranked #${rankings.indexOf(myDefense) + 1} ` +
    `(Tier ${myDefense.tier}, Score: ${myDefense.score.toFixed(3)})`
  );
}

Comparison

const comparison = manager.compare("rebuff", "lakera");
if (comparison) {
  console.log(`Winner: ${comparison.winner} by ${comparison.margin.toFixed(3)}`);
  console.log(`Effect size: ${comparison.effectSize}`);
}

Related Packages

License

MIT