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

@sewdn/registry-builder

v1.0.1

Published

Build deterministic Lemonaid registry snapshots from verified owner releases

Readme

@sewdn/registry-builder

buildRegistrySnapshot(inputLock, ownerReleases) aggregates a complete contract v1 input lock and returns { snapshot, files }. snapshot is the SHA-256 of canonical index.json bytes. files is a ReadonlyMap<string, Uint8Array> with portable paths relative to snapshots/<snapshot>/. The result includes index.json, search.json, agent-guide.md, each tool's version index, every locked owner manifest and the relative assets referenced by those manifests.

npm install @sewdn/registry-builder
import { buildRegistrySnapshot, type VerifiedOwnerRelease } from "@sewdn/registry-builder";
import { parseInputLock } from "@sewdn/registry-contract";

const owner: VerifiedOwnerRelease = {
  tool: "example",
  version: "1.0.0",
  sourceBytes: manifestBytes,
  manifestBytes,
  files: ownerAssets,
};
const { snapshot, files } = await buildRegistrySnapshot(parseInputLock(lockData), [owner]);

Release reader interface

loadRegistryInputs(lockPath) reads an explicit local InputLock and returns { inputLock, ownerReleases } for buildRegistrySnapshot. A locked relative release path resolves from the directory containing the lock. Relative assets in a JSON release resolve from the directory or HTTP URL containing that manifest. Relative assets in an archived release come from that archive. Absolute HTTP(S) references follow the shared contract and use the bounded, digest-checked reader from @sewdn/registry-artifacts.

The reader verifies the locked source digest before parsing it, checks the manifest's identity and loads every referenced asset by its digest. A release archive must contain release.json at its root. The reader rejects unsafe archive entries and unreferenced archive files. It checks declared package names, versions, export subpaths and peer requirements against the npm archives, and resolves declared toolkit dependency IDs to the actual packed dependency names and ranges. Source archives must match their declared package metadata and contain the listed license files.

Callers supplying their own VerifiedOwnerRelease values must bind archive members to the checked compressed bytes and verify package metadata themselves. The pure builder rechecks the source digest, manifest identity and referenced asset digests. For a release-json entry, sourceBytes and manifestBytes must contain identical bytes.

Owner manifests keep their original bytes and artifact references. The snapshot copies declared relative assets under each release's artifactBase. Absolute HTTP(S) references retain their URL and digest. Consumers retrieve those assets from the original URL or a verified cache. The output rejects case collisions and file/directory conflicts.

History and selection

Keep prior verified owner releases in the input lock to retain their manifests and artifacts. Across owner releases, a qualified item has one kind and a package's npm name has one qualified item ID. An exact item version has immutable fields and artifact refs except for lifecycle. A later declaration may change that lifecycle. The tool index links each exact item version to the newest owner release declaring it. All owner release manifests remain available for pinned installations. The builder checks immutability across the supplied history, so refreshing a lock must preserve previously pinned release identities.

latestStable selects the highest stable item version for an available tool when both the item and its selected owner release have active lifecycle. The item's version determines whether it is stable. All version ordering uses descending SemVer precedence, with descending UTF-16 exact version strings breaking ties from build metadata. The search index describes the latest stable version when there is one and the highest historical version otherwise.

Graph validation uses all verified versions, including withdrawn history. Package requirements solve against a single version per ID in the transitive closure. Recipe and preset skillset ranges must have a match. Presets must reference exact recipe versions, map their targets and required parameters, and use existing recipe outputs without cycles. Migration destinations must be in the inventory, and their origins may precede the retained history. Consumer resolution determines whether eligible versions satisfy a particular workspace, its targets and its runtime and peer constraints.

Local registry store

npx registry-builder check   --lock ./inputs/input-lock.json --output ./registry
npx registry-builder build   --lock ./inputs/input-lock.json --output ./registry
npx registry-builder publish --lock ./inputs/input-lock.json --output ./registry

The packed package exposes the registry-builder executable. In the workspace, run bun packages/registry-builder/dist/cli.js after building. Each command prints a JSON summary. On error it exits nonzero and writes an error field to stderr.

The output directory is the served local registry store. The builder reads inputs from the lock and the referenced artifact locations each time. Scaffold's discovery cache is a separate directory, supplied to Scaffold with --cache.

  • checkRegistrySnapshot(output, build) verifies candidate bytes and retained history, and checks exact contents if the snapshot already exists. It returns { current, snapshotExists } and makes zero writes.
  • writeRegistrySnapshot(output, build) verifies and stages the candidate, then renames the complete snapshot to snapshots/<digest>/. This can prepare a snapshot before promotion.
  • loadStoredRegistrySnapshot(output, snapshot) reads a complete immutable snapshot, verifies its referenced local bytes and rejects extra files, directories and links.
  • readCurrentRegistry(output) returns { pointer, generation } or null. The generation is the SHA-256 of the exact current.json bytes.
  • publishRegistrySnapshot(output, build, { expectedCurrent, refreshedAt?, staleTools? }) compares the expected generation under the publication lock, ensures the immutable snapshot is complete and atomically replaces current.json. Pass null to expect an empty store. The CLI observes the expected generation before reading the lock. In a multi-step refresh, supply the observed generation with --expected-current <generation> or --expected-current none.

When the caller owns companion publication state, pass an optional async beforePromote(next) callback. The builder calls it under the publication lock after verifying the expected generation and staging the full snapshot. An exception preserves the previous pointer. Stage data by the proposed generation, allow an identical callback to run again, and keep the callback independent of operations that take the same publication lock.

Promotion keeps every previously published snapshot directory. Include every release from the current snapshot in the next lock, retaining its exact owner manifest and verified artifacts at retrievable locations. A newer lock may change transport or location as long as it yields the same owner manifest and referenced bytes. A new owner release can update an item's lifecycle while keeping the older release in history. Build, check and publish fail if the candidate drops a retained owner release or replaces its manifest.

The CLI accepts optional --refreshed-at <UTC ISO timestamp> and repeatable --stale-tool <id> options for publication. Freshness and stale-source reporting live in current.json and can change while keeping the same snapshot. Each pointer change requires a newer timestamp. The default uses the current clock or one millisecond after the previous timestamp, whichever is later. Publishing the exact current pointer again with the matching generation is a no-op. To retry a superseded publication, read the latest generation before deciding which inputs to publish.

Use a local filesystem under the publisher's control. Concurrent builders share an exclusive .publish-lock directory. If a process is interrupted and leaves that directory behind, confirm the publisher has exited before removing the empty lock directory. Hosting and distribution policy for source bundles are managed outside this local store.

From the Kit workspace, run bun run registry:prepare at the root, then bun run typecheck and bun run test from this package.