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

@mr-aftab-ahmad-khan/promptmesh

v0.1.3

Published

Production-grade prompt infrastructure: versioning, variables, caching, A/B testing, fallbacks, analytics, and provider-agnostic execution.

Readme

promptmesh

Production-grade prompt infrastructure for any AI app. Versioning, variable rendering, caching, A/B experiments, fallbacks, and built-in analytics — all in one tiny, provider-agnostic library.

Why

Most teams hardcode prompts as string literals in their codebase. The minute you ship to production you need:

  • A way to roll out a new prompt safely
  • A cache so identical questions don't double-bill you
  • A fallback when OpenAI is down → switch to Anthropic
  • Per-variant latency and hit-rate metrics

promptmesh is the minimum useful surface for all of that.

Install

npm install @mr-aftab-ahmad-khan/promptmesh

Quick start

import { createMesh } from "@mr-aftab-ahmad-khan/promptmesh";

const mesh = createMesh<string>({
  defaultProvider: async (prompt) => callOpenAI(prompt.messages),
});

mesh.register({
  name: "support-agent",
  version: "1.0.0",
  messages: [
    { role: "system", content: "You are a helpful support agent." },
    { role: "user", content: "Customer says: {{message}}\nReply politely." },
  ],
  metadata: { model: "gpt-4o-mini" },
});

const result = await mesh.run("support-agent", {
  variables: { message: "I lost my password" },
});

console.log(result.response, result.cached, result.durationMs);

Versioning

Register multiple versions side-by-side, then select with version::

mesh.register({ name: "p", version: "1.0.0", messages: [...] });
mesh.register({ name: "p", version: "1.1.0", messages: [...] });

mesh.render("p", { version: "1.0.0", variables: {} });

If you don't pin a version, the latest is used.

A/B experiments

mesh.experiment("support-agent", {
  variants: [
    { name: "control",   weight: 1, version: "1.0.0" },
    { name: "concise",   weight: 1, version: "1.1.0" },
  ],
});

const result = await mesh.run("support-agent", { variables: { message: "hi" } });
console.log(result.prompt.variant);   // "control" or "concise"

Variant selection is deterministic per seed (default: variables + tags), so the same user keeps landing in the same bucket.

Caching

Identical rendered prompts are deduplicated automatically via a stable hash:

await mesh.run("p", { variables: { q: "x" }, cacheTtlMs: 60_000 });
await mesh.run("p", { variables: { q: "x" } }); // cached: true

Plug in any cache by implementing the CacheStore interface.

Fallbacks

const result = await mesh.run("p", {
  provider: async (prompt) => callOpenAI(prompt.messages),
  fallbacks: [async (prompt) => callAnthropic(prompt.messages)],
});

promptmesh tries providers in order and records every error in result.errors.

Analytics

mesh.stats();
// {
//   totalCalls: 142,
//   cacheHits: 38,
//   cacheMisses: 104,
//   errors: 2,
//   byVariant: { control: { calls: 70, avgLatencyMs: 412 }, concise: { calls: 72, avgLatencyMs: 380 } }
// }

API

| Symbol | Description | | --- | --- | | createMesh(options) / new PromptMesh(options) | Construct the mesh | | mesh.register({ name, version, messages, metadata }) | Add a prompt version | | mesh.experiment(name, { variants }) | Define A/B routing | | mesh.render(name, { variables, version, variant }) | Pure render, no provider call | | mesh.run(name, options) | Render + cache + execute provider chain | | mesh.stats() / mesh.resetAnalytics() | Telemetry | | MemoryCache, PromptRegistry, pickVariant, renderTemplate | Lower-level pieces |

License

MIT