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

@wolfsblvt/diffdevil

v1.0.0

Published

Composable Git diff analysis and policy for Node.js, CI pipelines, and GitHub Actions.

Readme

diffdevil

Availability Runtime Language

The devil is in the diff.

Measure changes. Match rules. Act on the result.

A composable CLI, TypeScript library and GitHub Action for turning Git diffs into queryable facts, configured rules, and inspectable label/comment effects. Raw churn counts a three-line replacement as six lines. Replacement-aware changed lines count it once, while keeping both sets of facts available.

This public-source v1 release candidate supports local Git, unified diffs, saved reports, detail expressions, YAML/JSON policies, GitHub acquisition, and explicit label/comment reconciliation. All four Actions ship executable JavaScript and their dependencies, with no workflow installation step. Native and hosted consumer matrices cover Node 22 and 24; a separate private live canary has exercised label-definition creation/readback, managed assignment and no-op, trusted base policy against a hostile PR-head copy, stale-plan refusal, one owned-comment update, and split policy/effect credentials. A genuine external-fork event and live partial-write failure remain unobserved.

Reusable software is MIT; application and hosted-service software is selected for AGPL-3.0-only. Original documentation prose is CC BY 4.0; runnable examples are MIT; brand and visual assets remain reserved. npm and @v1 are not published yet. A plan remains data, not an applied change.

node dist/lib/cli/main.js query --report docs/examples/reports/exact.json \
  --expr 'totals.lines.changed' --format value
# 178

Label your PRs · Local scripts · Policy recipes · User manual · CLI reference · Actions · TypeScript API

Label your PRs with one file

Save this as .github/workflows/diffdevil.yml on your repository's default branch. It creates missing size labels and maintains one on each matching PR. No config, checkout, package install, personal token, or comment is required.

The @v1 coordinate becomes usable when the first public release is published. This candidate does not invent a released ref. The complete auto-labeling quickstart explains setup, permissions, label ranges, custom exclusions, and troubleshooting.

name: Pull-request size
on:
  pull_request_target:
    types: [opened, reopened, synchronize, edited]
permissions:
  pull-requests: write
concurrency:
  group: diffdevil-size-${{ github.event.pull_request.number }}
  cancel-in-progress: false
jobs:
  size:
    runs-on: ubuntu-latest
    steps:
      - uses: Wolfsblvt/diffdevil@v1

Keep this privileged job separate from PR-head checkout, builds, and tests. The Action reads patches as data. Use /analyze for a read-only run instead. Existing unrelated labels remain untouched; default ensure mode preserves existing label colors and descriptions. An unavailable exact count is not silently replaced with zero.

The no-config route needs only Pull requests write. A trusted base or immutable pinned policy file also needs Contents read. When those permissions belong to different credentials, optional policy-token performs only policy/template reads; github-token still owns pull-request acquisition and every label/comment effect. Omitting policy-token preserves the ordinary single-credential route.

Get started

Use Node.js 22 or later and npm. Local comparisons also require Git. From this source checkout:

npm ci --ignore-scripts --no-audit --no-fund
npm run build
node dist/lib/cli/main.js analyze --diff-file docs/examples/diffs/review.diff --format human

The four-file teaching patch reports 10 changed lines and 16 raw churn. Follow local automation for exact values, path queries, shell conditions, and reusable reports. Offline dependency restoration is documented in Development. The installed npm tarball exposes the same commands as diffdevil; the commands here use the built entry point so they work before publication.

Analyze tracked working-tree changes, compare two revisions, or read a patch:

node dist/lib/cli/main.js analyze
node dist/lib/cli/main.js analyze --base main --head HEAD --format json
node dist/lib/cli/main.js analyze --diff-file docs/examples/diffs/review.diff --format json

--base main --head HEAD uses the selected merge-base comparison. Reports retain source revisions, inclusion reasons, raw facts, replacement-aware facts, and the quality of the evidence. See sources and output.

Ask for the answer your script needs

Use ordinary detail expressions for scalar formulas and simple conditions. Use shortcuts where they remove collection and projection boilerplate. Every alias remains available; both routes share one compiler and evaluator.

# A scalar, with no heading or diagnostic prose on stdout.
node dist/lib/cli/main.js query --expr 'totals.raw.added + totals.raw.deleted' --format value

# A valid condition communicates its result through the exit code.
node dist/lib/cli/main.js check --expr 'totals.lines.changed > 100'

# Collection shortcuts select included files and handle the quantifier/projection.
node dist/lib/cli/main.js check --files any --metric changed --gt 100
node dist/lib/cli/main.js query --files --metric modified --gt 20 --select path --format lines

check exits 0 for true, 1 for false, 2 for invalid input or an operation failure, and 3 for unresolved evidence. Strict scalar and path-list output refuses an unresolved result rather than inventing a value. Diagnostics go to stderr. Use --format nul for NUL-delimited path output, and --expr-file or --expr-stdin for expressions that are awkward to quote.

Complete formats and exit codes · detail reference

Write policy once

A discovered .diffdevil.yml or an explicit YAML/JSON file can define scopes, parameters, metrics, saved queries, bands, rules, and desired effects. Formulas use the same detail grammar as the CLI:

version: 1
presets: []
metrics:
  rewritten:
    formula: totals.lines.deleted + 2 * totals.lines.modified
queries:
  rewritten:
    expression: metrics.rewritten
rules:
  broad-rewrite:
    when: metrics.rewritten >= 500
    effects:
      labels:
        add: [review/broad-rewrite]
        removeWhenFalse: true

The complete weighted example also defines a typed threshold and its label definition. Query it or inspect its desired effects:

node dist/lib/cli/main.js query --report docs/examples/reports/exact.json \
  --config docs/examples/policies/weighted.yml --name weighted --format value
# 248

node dist/lib/cli/main.js plan --report docs/examples/reports/exact.json \
  --config docs/examples/policies/weighted.yml --target-repo example/repository \
  --target-pr 42 --definitions ensure --format json

Policy validation rejects unknown names, type errors, metric cycles, invalid bands, and conflicting assignments. YAML errors preserve original source positions through quoting, folding, and aliases. Plans keep unresolved rules held; they never interpret unknown as false or remove an unrelated label.

Policy and band manual · Templates

Know what the numbers mean

| Change | Raw additions | Raw deletions | Raw churn | Replacement-aware changed | | --- | ---: | ---: | ---: | ---: | | Replace three adjacent lines | 3 | 3 | 6 | 3 | | Add five lines, delete two in the same edit block | 5 | 2 | 7 | 5 | | Delete three here, add three elsewhere | 3 | 3 | 6 | 6 |

The versioned replacement-lines-v1 algorithm pairs additions and deletions inside a contiguous edit block, never across unrelated locations. Added-only, deleted-only, and modified facts remain individually queryable.

Exact, bounded, unknown, and unmeasurable are different evidence states. A bounded count can prove a threshold or band when every possible value agrees. It cannot supply a fabricated exact scalar. Binary changes do not become zero text lines. Neither line counts nor file counts measure importance, risk, complexity, quality, or whether a change should merge.

Evidence and arithmetic · Scopes and collections

Use one of four Actions

The shipped metadata selects Node 24. Given this exact trusted checkout at diffdevil/ in a workflow workspace, read-only analysis needs no npm install:

- uses: ./diffdevil/analyze
  id: changes
  with:
    metric: changed
    files: any
    threshold: '100'
    comparison: gt

steps.changes.outputs.decision is true, false, or unknown. This local path requires the complete trusted checkout, not just its analyze subdirectory. The public source repository exists. Pin a reviewed immutable source commit for a remote uses: coordinate; the versioned @v1 release ref does not exist yet.

| Entry | Behavior | | --- | --- | | Root | No-config size labeling: ensure missing definitions, reconcile only the managed size group, no comments. mode: analyze or plan selects a read-only route. | | /analyze | Read-only facts, metrics, decisions and bands—even when a token is supplied. | | /apply | Acquire fresh facts, revalidate supplied artifacts, then apply selected trusted policy. | | /sync-labels | Verify definitions by default; explicit operation: apply ensures or synchronizes them. |

Choosing root's default is choosing label automation. Write modes require suitable workflow permissions; a token alone does not enable writes. Base or explicitly pinned policy controls effects, never a PR's changed workspace config. Do not run untrusted PR scripts in a privileged job. Partial writes remain an incomplete result with a full readback journal, not a success-shaped guess.

Complete Action inputs and trust · Install-free distribution

Use the same engine from TypeScript

The package exports its root API and /core, /language, /policy, /git, and /github subpaths with generated declarations. Parsing, binding, type checking, interpretation, policy evaluation, and planning have separate responsibilities. No user expression is evaluated as JavaScript.

import { readFile } from 'node:fs/promises';
import { analyzeDiff, unwrap } from '@wolfsblvt/diffdevil';

const report = unwrap(analyzeDiff(await readFile('change.diff', 'utf8')));
console.log(report.totals.lines.changed);

API signatures and examples · Architecture

Read GitHub changes and reconcile declared effects

Read a pull request without checking out or executing its code:

node dist/lib/cli/main.js query --repo OWNER/REPO --pr 42 \
  --expr 'totals.lines.changed' --format value

Private repositories require a suitable token in GH_TOKEN or GITHUB_TOKEN. Read-only acquisition performs no label or comment mutation. The TypeScript adapter exposes separate explicit application and label-definition operations. It preserves unrelated metadata and checks current head/base revisions before writes. Its provider behavior has deterministic fake-HTTP regression coverage and a separate private live canary at the accepted source candidate. The canary proves ordinary managed labels, trusted policy, freshness refusal, owned-comment update, and split credentials; it does not claim a genuine external-fork event or live partial-write recovery.

GitHub API and trust boundaries

Documentation and development

Start with the task guides, then use the documentation map for complete language and integration contracts. The GitHub Action guide documents the implemented interfaces and keeps local qualification separate from hosted-runner and publication evidence.

The ordinary source verification command is npm run verify. Installed-package, conformance, runtime, and live-provider evidence remain separate commands and claims: Development · Qualification · Prepared v1.0.0 notes.

Suspected vulnerabilities can be reported privately through GitHub's enabled repository reporting route.

License

A Wolfsblvt Works product. Reusable engine, API, CLI and Action software is MIT; website and hosted application/service software is selected for AGPL-3.0-only. Original documentation prose is CC BY 4.0, runnable integration examples are MIT, and brand/visual assets are reserved. The current checkout ships the reusable software, with no hosted application runtime yet. The component licence map gives exact scope; no single licence applies to the entire repository or npm tarball.