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

evalsense

v0.4.2

Published

JS-native LLM evaluation framework with Jest-like API and statistical assertions

Downloads

586

Readme

Evalsense logo

npm version CI License

Jest for LLM Evaluation. Pass/fail quality gates for your LLM-powered code.

evalsense runs your code across many inputs, measures quality statistically, and gives you a clear pass / fail result — locally or in CI.

npm install --save-dev evalsense

Quick Start

Create quality.eval.js:

import { describe, evalTest, expectStats } from "evalsense";
import { readFileSync } from "fs";

describe("test answer quality", async () => {
  evalTest("toxicity detection", async () => {
    const answers = await generateAnswersDataset(testQuestions);
    const toxicityScore = await toxicity(answers);

    expectStats(toxicityScore).field("score").percentageBelow(0.5).toBeAtLeast(0.5);
  });

  evalTest("correctness score", async () => {
    const answers = await generateAnswersDataset(testQuestions);
    const groundTruth = JSON.parse(readFileSync("truth-dataset.json", "utf-8"));

    expectStats(answers, groundTruth)
      .field("label")
      .accuracy.toBeAtLeast(0.9)
      .precision("positive")
      .toBeAtLeast(0.7)
      .recall("positive")
      .toBeAtLeast(0.7)
      .displayConfusionMatrix();
  });
});

Run it:

npx evalsense run quality.eval.js

Output:

test answer quality
  ✓ toxicity detection (1ms)
    ✓ 50.0% of 'score' values are below
      or equal to 0.5 (expected >= 50.0%)
      Expected: 50.0%
      Actual:   50.0%
  ✓ correctness score (1ms)
    Field: label | Accuracy: 100.0% | F1: 100.0%
      negative: P=100.0% R=100.0% F1=100.0% (n=5)
      positive: P=100.0% R=100.0% F1=100.0% (n=5)
  Confusion Matrix: label
  Predicted →  correct  incorrect
  Actual ↓
    correct          5          0
    incorrect        0          5
    ✓ Accuracy 100.0% >= 90.0%
    ✓ Precision for 'positive' 100.0% >= 70.0%
    ✓ Recall for 'positive' 100.0% >= 70.0%
    ✓ Confusion matrix recorded for field "label"
All tests passed.

Key Features

  • Jest-like APIdescribe, evalTest, expectStats feel familiar
  • Statistical assertions — accuracy, precision, recall, F1, MAE, RMSE, R²
  • Confusion matrices — built-in display with .displayConfusionMatrix()
  • Distribution monitoringpercentageAbove / percentageBelow without ground truth
  • LLM-as-judge — built-in hallucination, relevance, faithfulness, toxicity metrics
  • CI/CD ready — structured exit codes, JSON reporter, bail mode
  • Zero config — works with any JS data loading and model execution

LLM-Based Metrics

import { setLLMClient, createAnthropicAdapter } from "evalsense/metrics";
import { hallucination, relevance } from "evalsense/metrics/opinionated";

setLLMClient(
  createAnthropicAdapter(process.env.ANTHROPIC_API_KEY, {
    model: "claude-haiku-4-5-20251001",
  })
);

const scores = await hallucination({
  outputs: [{ id: "1", output: "Paris has 50 million people." }],
  context: ["Paris has approximately 2.1 million residents."],
});
// scores[0].score → 0.9 (high hallucination)
// scores[0].reasoning → "Output claims 50M, context says 2.1M"

Built-in providers: OpenAI, Anthropic, OpenRouter, or bring your own adapter. See LLM Metrics Guide and Adapters Guide.

Using with Claude Code (Vibe Check)

evalsense includes an example Claude Code skill that acts as an automated LLM quality gate. To set it up in your project:

  1. Install evalsense as a dev dependency
  2. Copy skill.md into your project at .claude/skills/llm-quality-gate/SKILL.md
  3. After building any LLM feature, run /llm-quality-gate in Claude Code

Claude will automatically create a .eval.js file with a real dataset and meaningful thresholds, run npx evalsense run, and give you a ship / no-ship decision.

Documentation

| Guide | Description | | -------------------------------------------------- | ------------------------------------------------ | | API Reference | Full API — all assertions, matchers, metrics | | CLI Reference | All CLI flags, exit codes, CI integration | | LLM Metrics | Hallucination, relevance, faithfulness, toxicity | | LLM Adapters | OpenAI, Anthropic, OpenRouter, custom adapters | | Custom Metrics | Pattern and keyword metrics | | Agent Judges | Design patterns for evaluating agent systems | | Regression Metrics | MAE, RMSE, R² usage | | Examples | Working code examples |

Dataset Format

Records must have an id or _id field:

[
  { "id": "1", "text": "sample input", "label": "positive" },
  { "id": "2", "text": "another input", "label": "negative" }
]

Exit Codes

| Code | Meaning | | ---- | ------------------------- | | 0 | All tests passed | | 1 | Assertion failure | | 2 | Dataset integrity failure | | 3 | Execution error | | 4 | Configuration error |

Contributing

Contributions are welcome. See CONTRIBUTING.md for setup, coding standards, and the PR process.

License

Apache 2.0