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

@orka-js/prompts

v1.0.8

Published

Prompt versioning for OrkaJS - registry, diff, rollback, persistence

Readme

@orka-js/prompts

Prompt versioning, registry, diffing, and file persistence for OrkaJS — version, rollback, and diff your prompts like code.

Installation

npm install @orka-js/prompts

Quick Start

import { PromptRegistry } from '@orka-js/prompts';

const registry = new PromptRegistry();

// Register a prompt (uses {{ variable }} syntax)
registry.register('qa', 'Answer the following question: {{ question }}\n\nContext: {{ context }}');

// Render it with variables
const prompt = registry.render('qa', {
  variables: { question: 'What is OrkaJS?', context: 'OrkaJS is an AI agent framework.' },
});

console.log(prompt);
// "Answer the following question: What is OrkaJS?
//  Context: OrkaJS is an AI agent framework."

API

PromptRegistry

Central registry for all your prompts. Each call to .register() creates a new version; the latest is active by default.

import { PromptRegistry, FilePromptPersistence } from '@orka-js/prompts';

const registry = new PromptRegistry({
  persistence?: PromptPersistence,  // optional — persist to disk or a database
});

// Load persisted prompts on startup
await registry.load();

Methods

.register(name, template, metadata?): PromptTemplate

Register a new version of a prompt. All previous versions are deactivated; the new one becomes active.

registry.register('summarize', 'Summarize this in {{ language }}: {{ text }}');
registry.register('summarize', 'Provide a {{ style }} summary in {{ language }}: {{ text }}');
// Now at version 2

.get(name, version?): PromptTemplate | undefined

Retrieve the active version (or a specific version).

const prompt = registry.get('summarize');      // active version
const v1     = registry.get('summarize', 1);   // specific version

.render(name, options): string

Render a prompt by substituting {{ variable }} placeholders. Throws if any variables are missing.

const text = registry.render('summarize', {
  variables: { language: 'English', style: 'bullet-point', text: '...' },
  version: 2,  // optional — defaults to active version
});

.diff(name, fromVersion, toVersion): PromptDiff

Compare two versions of a prompt.

const diff = registry.diff('summarize', 1, 2);
// diff.changes → [{ type: 'modified', field: 'template', oldValue: '...', newValue: '...' }]
// diff.changes → [{ type: 'added', field: 'variable', newValue: 'style' }]

.setActive(name, version): void

Activate a specific version (useful for rollback).

registry.setActive('summarize', 1);

.rollback(name): PromptTemplate | undefined

Activate the previous version.

const prev = registry.rollback('summarize');

.getVersions(name): PromptTemplate[]

Return all registered versions for a prompt.

.getActiveVersion(name): number | undefined

Return the currently active version number.

.list(): string[]

List all registered prompt names.

.delete(name): boolean

Remove all versions of a prompt from the registry.

.save(): Promise<void> / .load(): Promise<void>

Persist or restore the registry (requires a PromptPersistence implementation).


FilePromptPersistence

Save and load the registry as a JSON file on disk.

import { PromptRegistry, FilePromptPersistence } from '@orka-js/prompts';

const persistence = new FilePromptPersistence({ dir: './prompts' });
const registry = new PromptRegistry({ persistence });

await registry.load();      // reads from ./prompts/registry.json

registry.register('greet', 'Hello, {{ name }}!');

await registry.save();      // writes to ./prompts/registry.json

Types

import type {
  PromptTemplate,
  PromptRenderOptions,
  PromptDiff,
  PromptChange,
  PromptRegistryConfig,
  PromptPersistence,
} from '@orka-js/prompts';

PromptTemplate

interface PromptTemplate {
  id: string;
  version: number;
  name: string;
  template: string;
  variables: string[];      // auto-extracted {{ var }} names
  metadata?: Record<string, unknown>;
  createdAt: number;
  isActive: boolean;
}

PromptDiff

interface PromptDiff {
  fromVersion: number;
  toVersion: number;
  changes: PromptChange[];
}

interface PromptChange {
  type: 'added' | 'removed' | 'modified';
  field: string;        // 'template' | 'variable'
  oldValue?: string;
  newValue?: string;
}

Custom PromptPersistence

Implement this interface to store prompts anywhere (database, S3, etc.):

interface PromptPersistence {
  save(prompts: Map<string, PromptTemplate[]>): Promise<void>;
  load(): Promise<Map<string, PromptTemplate[]>>;
}

Related Packages