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

sinc-prompt

v1.0.0

Published

Validator and converter for the sinc-prompt format -- a structured LLM prompt specification based on the Nyquist-Shannon sampling theorem. Ensures all 6 frequency bands (PERSONA, CONTEXT, DATA, CONSTRAINTS, FORMAT, TASK) are present to prevent aliasing (h

Readme

sinc-prompt

Validator and converter for the sinc-prompt format — a structured LLM prompt specification based on the Nyquist-Shannon sampling theorem.

A raw prompt is 1 sample of a 6-band signal. Nyquist requires 6 samples. Sending a raw prompt = 6:1 undersampling = guaranteed aliasing (hallucination). sinc-prompt enforces the 6-band structure that eliminates this.

Formula

x(t) = Σ x(nT) · sinc((t - nT) / T)

The 6 Bands

| Band | Index | Weight | Purpose | |------|-------|--------|---------| | PERSONA | 0 | 7.0% | Who should answer | | CONTEXT | 1 | 6.3% | Situation and facts | | DATA | 2 | 3.8% | Specific inputs | | CONSTRAINTS | 3 | 42.7% | Rules to follow | | FORMAT | 4 | 26.3% | Output structure | | TASK | 5 | 2.8% | The objective |

Weights derived from MATLAB simulation (275 observations, p<0.001).

Install

npm install sinc-prompt

Quick Start

import { validate, parse, format, computeSNR, nyquistCompleteness, scatter, toJSON } from 'sinc-prompt';

// Validate a sinc-prompt object
const result = validate(myPromptJSON);
if (!result.valid) {
  console.error(result.errors);
}

// Parse from JSON string
const sinc = parse(jsonString);

// Format into readable prompt
const prompt = format(sinc);
console.log(prompt);
// [PERSONA]
// You are a senior engineer...
//
// [CONTEXT]
// The system uses PostgreSQL 15...
// ...

// Compute signal-to-noise ratio
const snr = computeSNR(sinc);
console.log(`SNR: ${snr.snr}`);  // 0.0 - 1.0

// Check Nyquist completeness
const completeness = nyquistCompleteness(sinc);
console.log(`Completeness: ${completeness}`);  // 0.0 - 1.0

// Scatter a raw prompt into 6 bands (heuristic, no LLM)
const scattered = scatter("You are an expert. Fix the login bug. Must not break existing tests.");
console.log(JSON.stringify(toJSON(scattered), null, 2));

// Export back to JSON
const json = toJSON(sinc);

API Reference

validate(json: unknown): ValidationResult

Validates a sinc-prompt JSON object against the schema. Checks for all 6 mandatory bands, correct indices, no duplicates, and non-empty content.

Returns { valid: boolean, errors: string[] }.

parse(input: string | object): SincPrompt

Parses a sinc-prompt JSON string or object into a typed SincPrompt. Throws if validation fails.

format(sinc: SincPrompt): string

Formats a SincPrompt into a human-readable prompt string with [BAND]\ncontent blocks in canonical order.

computeSNR(sinc: SincPrompt): SNRResult

Computes the signal-to-noise ratio using filler-word analysis weighted by band importance.

Returns { snr: number, zones: Record<BandName, number>, signal: Record<BandName, number>, noise: Record<BandName, number> }.

nyquistCompleteness(sinc: SincPrompt): number

Returns a weighted completeness score (0.0 - 1.0) using MATLAB-derived importance weights. Full content (>=20 chars) gets full weight; minimal content gets half.

scatter(rawPrompt: string): SincPrompt

Decomposes an unstructured prompt string into the 6 sinc bands using keyword heuristics. No LLM call required. Empty bands get [TODO: specify <band>] placeholders.

toJSON(sinc: SincPrompt): Record<string, unknown>

Exports a SincPrompt back to a plain object conforming to the sinc-prompt-v1 JSON schema.

Types

interface SincFragment {
  n: number;    // Band index (0-5)
  t: string;    // Band label
  x: string;    // Band content
}

interface SincPrompt {
  formula: string;
  T: string;
  fragments: SincFragment[];
}

interface ValidationResult {
  valid: boolean;
  errors: string[];
}

type BandName = 'PERSONA' | 'CONTEXT' | 'DATA' | 'CONSTRAINTS' | 'FORMAT' | 'TASK';

JSON Schema

The embedded JSON Schema (draft-07) is available as an export:

import { SINC_PROMPT_SCHEMA } from 'sinc-prompt';

Schema ID: https://tokencalc.pro/schema/sinc-prompt-v1.json

Spec & Paper

Zero Dependencies

This package has zero runtime dependencies. Pure TypeScript compiled to ES2020.

License

MIT