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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@api-extractor-tools/changeset-change-detector

v0.1.0-alpha.1

Published

Changesets plugin that uses change-detector to automate version bump determination

Readme

@api-extractor-tools/changeset-change-detector

npm version

Automate semantic version bump decisions in your Changesets workflow by analyzing actual API changes in TypeScript declaration files.

The Problem

When using Changesets, developers must manually determine whether a change is major, minor, or patch:

🦋  Which packages should have a major bump?
🦋  Which packages should have a minor bump?
◉ @my-org/my-package  <-- How do I know which to pick?

This is error-prone and inconsistent. A developer might accidentally mark a breaking change as minor, leading to broken consumers.

The Solution

This package integrates with @api-extractor-tools/change-detector to automatically analyze your TypeScript declaration files and determine the correct semantic version bump based on actual API changes.

| Change Type | Examples | Version Bump | | -------------------------- | ----------------------------------- | ------------ | | Removing exports | Deleted function, removed interface | major | | Adding required parameters | fn(a)fn(a, b) | major | | Narrowing types | string \| numberstring | major | | Changing return types | (): string(): number | major | | Adding exports | New function, new interface | minor | | Adding optional parameters | fn(a)fn(a, b?) | minor | | Widening types | stringstring \| number | minor | | Internal changes only | Implementation details | patch |

Features

  • Auto-generate changesets — Analyzes API changes and creates changeset files with the correct version bump
  • Validate changesets — Verifies existing changesets match detected API changes (great for CI)
  • Smart baseline detection — Compares against published versions, main branch, or custom git refs
  • Monorepo support — Works with pnpm workspaces, analyzing all packages automatically
  • Detailed summaries — Auto-generates changeset descriptions from detected changes

Installation

# In a pnpm workspace
pnpm add -D @api-extractor-tools/changeset-change-detector

# Or with npm
npm install --save-dev @api-extractor-tools/changeset-change-detector

Prerequisites

  • Your packages must have TypeScript declaration files (.d.ts)
  • Changesets must be configured in your workspace (.changeset/config.json)
  • For best results, use @microsoft/api-extractor to generate rolled-up declaration files

CLI Usage

Generate a Changeset

Analyze API changes and create a changeset file automatically:

# Interactive mode — shows preview and prompts for confirmation
changeset-change-detector generate

# Non-interactive mode — auto-approve (useful for CI)
changeset-change-detector generate --yes

# Compare against a specific git ref
changeset-change-detector generate --base main

# Provide a custom summary
changeset-change-detector generate --summary "Refactored authentication module"

Example output:

🔍 Analyzing API changes...

📦 Changeset Preview
══════════════════════════════════════════════════

Packages:
  🔴 @my-org/auth (major)
  🟡 @my-org/utils (minor)

Summary:
──────────────────────────────────────────────────
  **Breaking Changes:**
  - Function `validateToken` was removed
  - Required parameter added to `createSession`

  **New Features/Additions:**
  - Function `refreshToken` was added
──────────────────────────────────────────────────

Create this changeset? (y/N):

Validate Changesets

Verify that existing changesets have appropriate version bumps (ideal for CI):

# Validate changesets against detected API changes
changeset-change-detector validate

# Compare against a specific git ref
changeset-change-detector validate --base main

# Strict mode — fail on warnings too
changeset-change-detector validate --strict

Example output:

🔍 Validating changesets...

❌ Changeset validation failed!

Errors:
  ❌ @my-org/auth: Changeset declares "minor" but detected changes require "major"
  ❌ @my-org/utils: Package has API changes (minor) but no changeset

Warnings:
  ⚠️  @my-org/core: Breaking changes should have detailed descriptions

Summary:
  Packages with changesets: 1
  Packages missing changesets: 1
    - @my-org/utils

CLI Reference

changeset-change-detector <command> [options]

Commands:
  generate    Analyze API changes and create a changeset file
  validate    Validate existing changesets against detected API changes

Options:
  --base, -b <ref>      Git ref to compare against (default: auto-detect)
  --yes, -y             Skip confirmation prompts (for CI)
  --strict              Fail validation on warnings (not just errors)
  --summary, -s <text>  Custom summary for generated changeset
  --help, -h            Show help
  --version, -V         Show version

Programmatic API

You can also use this package programmatically:

import {
  analyzeWorkspace,
  generateChangeset,
  validateChangesets,
} from '@api-extractor-tools/changeset-change-detector'

// Analyze API changes in the workspace
const analysis = analyzeWorkspace({ baseRef: 'main' })

console.log(
  `Found ${analysis.packagesWithChanges.length} packages with changes`,
)

for (const pkg of analysis.packagesWithChanges) {
  console.log(`${pkg.package.name}: ${pkg.recommendedBump}`)
}

// Generate a changeset automatically
const result = await generateChangeset({
  yes: true,
  baseRef: 'main',
})

if (result.success && result.changesetPath) {
  console.log(`Created: ${result.changesetPath}`)
}

// Validate existing changesets
const validation = await validateChangesets({ baseRef: 'main' })

if (!validation.valid) {
  console.error('Validation failed!')
  process.exit(1)
}

CI Integration

GitHub Actions

Add changeset validation to your PR workflow:

name: PR Checks

on:
  pull_request:
    branches: [main]

jobs:
  validate-changesets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Needed for git history comparison

      - uses: pnpm/action-setup@v2

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'pnpm'

      - run: pnpm install
      - run: pnpm build

      - name: Validate changesets
        run: pnpm changeset-change-detector validate --base origin/main

Workspace Integration

Add these scripts to your root package.json:

{
  "scripts": {
    "changeset:auto": "changeset-change-detector generate",
    "changeset:validate": "changeset-change-detector validate"
  }
}

Baseline Strategy

The plugin determines what to compare against using this priority:

  1. Explicit --base <ref> — Use when you know exactly what to compare against
  2. Published version tags — Looks for tags like @scope/[email protected]
  3. Main branch — Falls back to comparing against main

For most workflows, the automatic detection works well. Use --base when you need precise control, such as comparing against a release branch.

How It Works

flowchart TB
    subgraph workspace["Your Workspace"]
        pkgA["Package A<br/>dist/*.d.ts"]
        pkgB["Package B<br/>dist/*.d.ts"]
        pkgC["Package C<br/>dist/*.d.ts"]

        pkgA --> detector
        pkgB --> detector
        pkgC --> detector

        detector["change-detector<br/>Compare .d.ts files<br/>against baseline"]

        detector --> classify["Classify Changes<br/>major/minor/patch"]

        classify --> generate["generate<br/>Create .md in<br/>.changeset/"]
        classify --> validate["validate<br/>Check existing<br/>changesets"]
    end

Troubleshooting

"No declaration file found"

Ensure your packages have:

  • A types field in package.json pointing to the .d.ts file
  • Or a main field with a corresponding .d.ts file next to it
{
  "main": "dist/index.js",
  "types": "dist/index.d.ts"
}

"Could not determine baseline"

The tool couldn't find a git ref to compare against. Either:

  • Ensure you have git tags for published versions
  • Use --base main or another explicit ref

Changes not detected

If API changes aren't being detected:

  • Ensure declaration files are built (pnpm build)
  • Check that the baseline ref has the old declaration files
  • Verify your tsconfig produces declaration files

Related Packages

License

MIT