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

@tracegraph/ai-coverage

v0.3.1

Published

AI Change Coverage and Prompt Pack Builder for TraceGraph

Readme

@tracegraph/ai-coverage

AI Change Coverage and Prompt Pack Builder for TraceGraph. Parses unified git diffs to identify changed functions, maps those functions to runtime trace events to detect coverage gaps, and generates structured AI context packs for Cursor, Claude Code, GitHub Copilot, and MCP-compatible tools.

Used internally by tracegraph coverage and tracegraph pack.

What's in this package

| Export | Description | |--------|-------------| | parseDiff(diffText) | Parses a unified diff string (output of git diff) and returns a list of changed function/method declarations with file paths and line numbers | | computeCoverage(options) | Maps changed functions to runtime trace events across .trace.json files; returns a ChangeCoverageReport | | getDiff(base, head) | Runs git diff <base>..<head> and returns the raw diff text | | scanTracesForCoverage(functions, traceFiles) | Lower-level — scans an array of trace files and returns which functions appear in at least one trace event | | eventMatchesFunction(event, fn) | Returns true if a TraceEvent is evidence that a specific changed function was exercised | | buildPromptPacks(report, traces, options) | Generates AI context packs from a TraceReport and optional trace context | | CoverageOptions | Options for computeCoverage — git refs, trace dir, output path | | CoverageMatch | A matched function: { functionName, file, line, matchingTraceIds } | | PromptPackOptions | Options for buildPromptPacks — format, project name, max chars |

Installation

npm install @tracegraph/ai-coverage

Usage

Computing change coverage

import { computeCoverage } from '@tracegraph/ai-coverage';

const report = await computeCoverage({
  base:      'origin/main',
  head:      'HEAD',
  tracesDir: '.tracegraph/traces',
  outPath:   '.tracegraph/reports/coverage.json',
});

console.log(`Coverage: ${report.summary.coveragePercent}%`);
console.log(`Uncovered: ${report.uncovered.map(f => f.functionName).join(', ')}`);

Generating AI context packs

import { buildPromptPacks } from '@tracegraph/ai-coverage';

await buildPromptPacks(traceReport, traceSessions, {
  format:      'all',           // 'cursor' | 'claude-code' | 'copilot' | 'mcp' | 'all'
  projectName: 'invoice-api',
  outDir:      process.cwd(),
  maxChars:    40_000,
});

Output files written:

| Format | File | |--------|------| | cursor | .cursor/tracegraph-context.md | | claude-code | CLAUDE.md | | copilot | .github/copilot-instructions.md | | mcp | .tracegraph/mcp-context.json |

Parsing a git diff directly

import { parseDiff, getDiff } from '@tracegraph/ai-coverage';

const rawDiff  = await getDiff('HEAD~1', 'HEAD');
const changed  = parseDiff(rawDiff);

for (const fn of changed) {
  console.log(`${fn.functionName}  (${fn.file}:${fn.line})`);
}

CLI equivalents

# Change coverage report
tracegraph coverage --base origin/main --head HEAD

# Fail CI if any changed function has no trace coverage
tracegraph coverage --fail-uncovered

# Generate all AI context packs
tracegraph pack

# Generate only Cursor and Claude Code packs
tracegraph pack --format cursor
tracegraph pack --format claude-code

How coverage matching works

  1. getDiff runs git diff <base> <head> filtered to TypeScript, JavaScript, and PHP files
  2. parseDiff extracts added and modified function/method declarations from the unified diff
  3. scanTracesForCoverage loads each .trace.json and checks whether any function_call or method_call event has a name or displayName matching the changed function
  4. computeCoverage assembles covered/uncovered lists and calculates coveragePercent

AI context pack content

Each pack contains:

  • Open findings — severity, rule ID, description, and recommendation for every non-approved, non-suppressed finding in the latest report
  • Runtime trace summaries — summarised event sequences from recent traces, up to maxChars characters
  • Coverage gaps — which changed functions were not exercised at runtime

Suppressed and approved findings are intentionally excluded so the AI assistant only sees actionable issues.