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

@kb-labs/policy-contracts

v2.94.0

Published

Types, interfaces, and schemas for the KB Labs policy plugin.

Downloads

9,037

Readme

@kb-labs/plugin-template-contracts

Lightweight public contracts package for the plugin: it describes guaranteed artifacts, commands, workflows, API payloads, and the version of these promises.

Why this package exists

Every KB Labs plugin is expected to publish a clear, lightweight “promise” to the rest of the ecosystem. This package is that promise: it contains only types, manifests, and validation helpers, so other teams (CLI, Workflow Engine, Studio, REST, marketplace tooling) can rely on a single source of truth without dragging in plugin runtime code.

Quick start checklist

  1. Clone this package as part of your plugin workspace (packages/contracts).
  2. Update pluginContractsManifest with your plugin ID and initial artifacts/commands.
  3. Adjust Zod schemas in src/schema.ts (or add new ones) to match your payloads.
  4. Bump contractsVersion whenever the public promise changes (SemVer rules below).
  5. Run pnpm test and pnpm type-check to ensure the manifest validates.
  6. Import the manifest in your CLI/REST/workflow code to avoid hard-coded IDs.

Renaming this package

When you turn the template into your own plugin:

  • Change the npm name in package.json (e.g. @kb-labs/my-plugin-contracts).
  • Update pluginContractsManifest.pluginId in src/contract.ts.
  • Adjust aliases in tsconfig.paths.json and imports across the workspace (@kb-labs/plugin-template-contracts → your new name).
  • Replace sample artifact IDs (template.hello.*) with your own naming scheme.

What's inside

  • pluginContractsManifest — the single source of truth for the plugin's public capabilities
  • TypeScript types (src/types) and Zod schemas (src/schema) for artifacts, commands, workflows, and API payloads
  • parsePluginContracts utility for runtime validation of the manifest and third-party contracts

Versioning rules

  • contractsVersion follows SemVer and is independent from the plugin's npm version.
  • MAJOR — breaking changes (removing/renaming artifacts, changing payload formats).
  • MINOR — backwards-compatible extensions (new artifacts, commands, fields).
  • PATCH — documentation/metadata updates without altering payload formats.

Minimal manifest example

import type { PluginContracts } from '@kb-labs/plugin-template-contracts';

export const pluginContractsManifest: PluginContracts = {
  schema: 'kb.plugin.contracts/1',
  pluginId: '@kb-labs/my-plugin',
  contractsVersion: '1.0.0',
  artifacts: {
    'my-plugin.result': {
      id: 'my-plugin.result',
      kind: 'json',
      description: 'Primary output of the CLI command.'
    }
  }
  // commands/workflows/api can be added later when needed
};

Optional sections

All additional sections are optional — include only what your plugin actually supports:

  • commands — define CLI or workflow commands that produce/consume artifacts.
  • workflows — describe composed workflows and their steps.
  • api — document REST (or future surfaces) when the plugin exposes them.

If your plugin only ships a CLI command, keep commands + artifacts and omit workflows/api. The Zod schema accepts missing sections.

Usage in plugin code

import { pluginContractsManifest } from '@kb-labs/plugin-template-contracts';

const helloArtifactId = pluginContractsManifest.artifacts['template.hello.greeting'].id;

Use the manifest to avoid magic strings, assert that required artifacts exist, or log which promises were fulfilled.

Who relies on the contract

  • Workflow Engine — verifies allowed steps, required artifacts, and matches produced results with the contract.
  • Studio — builds UI and hints based on declared artifacts and commands.
  • CLI / REST / other plugins — reuse types and schemas as the source of truth, validate inputs/outputs.
  • Marketplace & QA tooling — checks plugin compatibility and correctness before publishing.

Looking ahead

  • Generate JSON Schema / OpenAPI from the api contract surface.
  • Add automatic inspectors in Studio and validators for the marketplace.