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

@reaatech/prompt-version-control

v0.1.0

Published

Prompt Version Control TypeScript SDK

Readme

@reaatech/prompt-version-control

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

TypeScript client SDK for the Prompt Version Control API. Provides a typed, authenticated client with built-in retry logic, configurable timeouts, and optional in-memory caching.

Installation

npm install @reaatech/prompt-version-control
# or
pnpm add @reaatech/prompt-version-control

Feature Overview

  • Typed API client — full TypeScript types for all responses
  • Automatic retry — exponential backoff with jitter on 5xx errors and network failures
  • Configurable timeoutsAbortController-based request timeout (default 30s)
  • In-memory cache — optional LRU cache with TTL and max-entries eviction
  • Zero-config defaultsbaseUrl defaults to http://localhost:3000
  • 4xx passthrough — client errors are thrown immediately without retry

Quick Start

import { PromptVersionControlClient } from "@reaatech/prompt-version-control";

const client = new PromptVersionControlClient({
  baseUrl: "http://localhost:3000",
  apiKey: "pvc_your-api-key",
});

// Get a prompt by ID
const prompt = await client.getPrompt("prompt-abc123");
console.log(prompt.name, prompt.template);

// List all prompts
const { data } = await client.listPrompts();

// Get the production version of a prompt
const prod = await client.getProduction("prompt-abc123");
console.log(prod.number, prod.content);

API Reference

PromptVersionControlClient (class)

Also exported as PVCClient (shorthand alias).

import { PromptVersionControlClient } from "@reaatech/prompt-version-control";
// or
import { PVCClient } from "@reaatech/prompt-version-control";

const client = new PVCClient({ apiKey: "pvc_...", baseUrl: "..." });

Constructor

new PromptVersionControlClient(options: PVCClientOptions)

PVCClientOptions

| Property | Type | Default | Description | |----------|------|---------|-------------| | apiKey | string | (required) | API key for Bearer authentication | | baseUrl | string | "http://localhost:3000" | API server base URL | | retries | number | 3 | Max retry attempts on 5xx / network errors | | retryDelay | number | 1000 | Base delay in ms for exponential backoff | | timeoutMs | number | 30000 | Per-request timeout in ms | | cache | boolean | false | Enable in-memory response caching | | cacheTtl | number | 60000 | Cache TTL in ms | | cacheMaxEntries | number | 1000 | Max entries before FIFO eviction |

Instance Methods

| Method | Parameters | Returns | Description | |--------|------------|---------|-------------| | getPrompt | id: string | Promise<{ id, name, template }> | Retrieve a prompt by ID | | listPrompts | — | Promise<{ data: Array<{ id, name }> }> | List all prompts | | getProduction | promptId: string | Promise<{ id, number, content, template, variables, metadata }> | Get the production-tagged version of a prompt |

Usage Patterns

Retry with Backoff

const client = new PromptVersionControlClient({
  apiKey: "pvc_...",
  retries: 5,         // up to 5 retries
  retryDelay: 500,    // 500ms base → 500, 1000, 2000, 4000, 8000ms
});

// Transient network errors and 5xx are automatically retried
// 4xx errors are thrown immediately
const prompt = await client.getPrompt("prompt-id");

Caching

const client = new PromptVersionControlClient({
  apiKey: "pvc_...",
  cache: true,
  cacheTtl: 120_000,       // cache entries for 2 minutes
  cacheMaxEntries: 500,    // evict oldest when > 500 entries
});

// First call hits the API
const prod1 = await client.getProduction("my-prompt");

// Subsequent calls within TTL return cached result
const prod2 = await client.getProduction("my-prompt");

Custom Timeout

const client = new PromptVersionControlClient({
  apiKey: "pvc_...",
  timeoutMs: 5000,  // fail fast — 5 second timeout
});

Using the Alias

import { PVCClient } from "@reaatech/prompt-version-control";

const client = new PVCClient({ apiKey: "pvc_..." });
const prompt = await client.getPrompt("prompt-id");

Error Handling

The SDK uses raw fetch under the hood. On failure:

  • 5xx and network errors — retried with exponential backoff + jitter, up to retries attempts
  • 4xx errors — thrown immediately as Error with the response status and body
  • Timeout — thrown as Error with message "Request timed out"
try {
  const prompt = await client.getPrompt("nonexistent-id");
} catch (err) {
  // err.message will contain the HTTP status and response body
  console.error(err.message);
}

Related Packages

License

MIT