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

spec-trace

v0.1.2

Published

A library for linking system requirements with test cases and measuring specification coverage

Downloads

3

Readme

SpecTrace

A CLI tool for linking system requirements with test cases and measuring specification coverage.

Installation

npm install -g spec-trace
# or
pnpm add -g spec-trace

Features

  • Link requirements (written in Markdown) with test cases
  • Calculate specification coverage metrics
  • Support for multiple test frameworks (Vitest, Playwright)
  • Multiple output formats (Markdown, JSON, summary)
  • Command-line interface with flexible options

Quick Start

  1. Create a configuration file named spec-matcher.config.ts:
import type { Config } from 'spec-trace';

const config: Config = {
  baseDir: '.',
  requirements: [
    {
      id: 'user-stories',
      type: 'markdown',
      path: './docs/user-stories/**/*.md',
      idPattern: "^(US-\\d+):\\s+(.*)",
      linkMarkerPattern: "@test:\\s*(\\S+)#(\\S+)",
    },
  ],
  tests: [
    {
      id: 'unit-tests',
      type: 'vitest',
      path: './src/**/*.test.ts',
    },
  ],
};

export default config;
  1. Add test links to your Markdown requirements:
## US-001: User Registration

As a new user, I want to register for an account.

@test: src/auth/register.test.ts#shouldRegisterNewUser
  1. Run the CLI tool:
# Generate full Markdown report
spec-trace --config ./spec-matcher.config.ts

# Get summary only
spec-trace --config ./spec-matcher.config.ts --summary-only

# Output JSON format
spec-trace --config ./spec-matcher.config.ts --json

CLI Usage

spec-trace [options]

Options:
  --config <path>    Path to configuration file (default: "./spec-matcher.config.ts")
  --verbose          Enable verbose logging
  --json             Output in JSON format
  --summary-only     Output only summary text
  --help             Display help for command
  --version          Output the version number

Examples

# Basic usage with default config
spec-trace

# Specify custom config file
spec-trace --config ./my-spec-config.ts

# Get only the summary
spec-trace --summary-only

# Output in JSON format for CI/CD integration
spec-trace --json

# Combine with other Linux commands
spec-trace > coverage-report.md
spec-trace --json | jq '.summary.coveragePercentage'
spec-trace --summary-only | grep "coverage"

Configuration

The configuration file supports the following options:

Requirements

Define sources for your requirements:

requirements: [
  {
    id: 'source-id',
    type: 'markdown',
    path: './path/to/markdown/files/**/*.md',
    idPattern: "regex-pattern-to-extract-id-and-title",
    linkMarkerPattern: "regex-pattern-to-find-test-links",
  }
]

Tests

Define sources for your tests:

tests: [
  {
    id: 'test-source-id',
    type: 'vitest' | 'playwright',
    path: './path/to/test/files/**/*.test.ts',
    reportPath: './optional/path/to/test/report.json', // Optional
  }
]

Output Formats

Full Markdown Report

The default output is a comprehensive Markdown report with:

  • Coverage summary with visual progress bar
  • Requirements grouped by type (US, FS, etc.)
  • Detailed table with coverage status
  • List of uncovered requirements

Summary Text

Perfect for quick checks or CI/CD pipelines:

Found 10 requirement(s) total, 8 covered, 80.00% coverage.

JSON Format

Structured data for integration with other tools:

{
  "summary": {
    "totalRequirements": 10,
    "coveredRequirements": 8,
    "coveragePercentage": 80,
    "generatedAt": "2025-05-25T12:00:00.000Z"
  },
  "requirements": [...]
}

Integration with CI/CD

Use SpecTrace in your continuous integration workflows:

# GitHub Actions example
- name: Check Specification Coverage
  run: |
    spec-trace --json > coverage.json
    COVERAGE=$(jq -r '.summary.coveragePercentage' coverage.json)
    echo "Coverage: $COVERAGE%"
    if (( $(echo "$COVERAGE < 80" | bc -l) )); then
      echo "Coverage below threshold!"
      exit 1
    fi

API Usage

You can also use SpecTrace programmatically:

import { measureCoverage, MarkdownReporter } from 'spec-trace';

async function generateReport() {
  const coverage = await measureCoverage({
    configPath: './spec-matcher.config.ts'
  });
  
  const reporter = new MarkdownReporter();
  console.log(reporter.generate(coverage));
}

Development

Prerequisites

  • Node.js (>= 14.0.0)
  • pnpm

Setup

# Install dependencies
pnpm install

# Build the project
pnpm build

# Run tests
pnpm test

# Debug CLI during development
pnpm debug --config examples/spec-matcher.config.ts
pnpm debug:help

Code Quality

This project uses Biome for linting and formatting:

pnpm lint    # Run linter
pnpm format  # Format code
pnpm check   # Run linter and formatter with fixes

License

MIT