Introduction to regxa
Relevant source files
The following files were used as context for generating this wiki page:
regxa is a universal package registry client designed as an ESM-only TypeScript library and CLI. Its primary purpose is to normalize package metadata across diverse ecosystems, including npm, PyPI, crates.io, RubyGems, Packagist, and Arch Linux. By using Package URLs (PURL) as first-class identifiers, regxa provides a unified API to query information that would otherwise require multiple ecosystem-specific implementations or third-party aggregation services.
The project is built with a focus on type safety, performance through storage-backed caching, and reliability via built-in retry mechanisms with exponential backoff. It serves as an embeddable alternative to external services like deps.dev or ecosyste.ms, allowing developers to integrate multi-registry lookups directly into their TypeScript applications, CLI tools, or AI agents.
Sources: README.md:1-25, AGENTS.md:3-5, skills/regxa/SKILL.md:11-15
System Architecture
The regxa architecture is designed with a strict inward dependency direction. The high-level modules (Commands, Registries, Cache) depend on the Core contract layer, ensuring a stable foundation for ecosystem-specific implementations.
The diagram above illustrates the layered architecture of regxa, showing how interfaces interact with the core through optional caching and specialized registry adapters.
Core Components
- PURL Parser (
src/core/purl.ts): The single source of truth for parsing and building ECMA-427 identifiers. - HTTP Client (
src/core/client.ts): Centralized fetch handler managing retries, timeouts, and rate limiting. - Registry Factory (
src/core/registry.ts): A plugin-based system usingregister()andcreate()to instantiate ecosystem adapters. - Normalization Layer: Utilities for cleaning up repository URLs and normalizing licenses to SPDX formats.
Sources: AGENTS.md:34-45, src/AGENTS.md:20-25, src/core/AGENTS.md:1-25
Data Models
regxa enforces a normalized data model, ensuring that regardless of the source registry, the response shape remains consistent for developers.
| Model | Key Fields | Purpose |
|---|---|---|
| Package | name, latestVersion, licenses, repository | High-level metadata for a package. |
| Version | number, publishedAt, integrity, status | Metadata for a specific release, including yanked/deprecated flags. |
| Dependency | name, requirements, scope, optional | Normalized dependency constraints and scopes (runtime, dev, etc.). |
| Maintainer | name, email, login, role | Information about package authors and contributors. |
Sources: README.md:162-205, src/registries/npm.ts:74-95
Supported Ecosystems and PURL Handling
regxa uses PURLs to address packages across different registries. This allows the system to route requests to the correct adapter based on the type defined in the PURL.
Routing flow from a single PURL input to specific ecosystem adapters.
Registry Implementation Details
- npm: Handles scoped packages by percent-encoding the
@symbol (e.g.,pkg:npm/%40vue/core). It fetches dependencies from per-version endpoints. - PyPI: Implements PEP 503 name normalization and utilizes the Simple API (PEP 691) for version enumeration. It parses PEP 508 dependency markers to determine scopes.
- Arch Linux (ALPM): Supports both official repositories and the AUR, using namespaces like
pkg:alpm/arch/orpkg:alpm/aur/.
Sources: README.md:100-115, src/registries/npm.ts:251-270, src/registries/pypi.ts:210-220, skills/regxa/SKILL.md:21-35
Caching and Freshness
The caching system is an optional decorator that wraps registry instances. It uses unstorage for persistence and implements a lockfile mechanism to ensure data integrity with SHA-256 hashes.
Default Time-to-Live (TTL) Policies
| Data Type | TTL |
|---|---|
| Package Metadata | 1 Hour |
| Version List | 30 Minutes |
| Dependencies | 24 Hours |
| Maintainers | 24 Hours |
Sources: README.md:150-160, AGENTS.md:76-80
Usage Patterns
Library API
The library provides high-level PURL helpers for common operations:
import { fetchPackageFromPURL, bulkFetchPackages } from "regxa";
// Single lookup
const pkg = await fetchPackageFromPURL("pkg:npm/lodash");
// Concurrent bulk lookup (default concurrency: 15)
const pkgs = await bulkFetchPackages(["pkg:pypi/flask", "pkg:cargo/serde"]);
Sources: README.md:118-135, skills/regxa/SKILL.md:65-85
CLI Operations
The CLI offers a human-readable interface for exploring package data. It supports a --json flag for machine-readable output and --no-cache to force network requests.
regxa info npm/lodash
regxa versions pypi/flask
regxa deps cargo/serde@1.0.0
regxa cache clear
Sources: README.md:140-150, skills/regxa/SKILL.md:42-55
Error Handling
regxa uses a typed error hierarchy to help developers handle failure cases gracefully.
| Error Class | Description |
|---|---|
NotFoundError | Thrown when a package or specific version is not found in the registry. |
InvalidPURLError | Thrown when the provided PURL is malformed or has invalid encoding. |
RateLimitError | Thrown when the upstream registry enforces rate limits (often handled by internal retries first). |
UnknownEcosystemError | Thrown when a PURL type is provided that has no registered adapter. |
Sources: AGENTS.md:52-56, skills/regxa/SKILL.md:115-125