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

@opencommerceprotocol/validator

v1.0.0

Published

Open Commerce Protocol — Validation library and conformance tests

Readme

@opencommerceprotocol/validator

Validation library for the Open Commerce Protocol. Validates OCP manifests, product feeds, robots.txt, llms.txt, and scores agent_notes quality.

Installation

npm install @opencommerceprotocol/validator

OCPValidator

Validate a live site or a local directory.

import { OCPValidator } from '@opencommerceprotocol/validator';

const validator = new OCPValidator();

// Validate a live site
const result = await validator.validateRemote('https://mystore.com');
console.log(`Score: ${result.score}/100`);
console.log(`Passed: ${result.passed}`);

// Validate a local directory (for CI/CD)
const localResult = await validator.validateLocal('./public');

SiteValidationResult

interface SiteValidationResult {
  url: string;
  passed: boolean;
  score: number;           // 0-100 overall score
  manifest?: ValidationResult;
  feed?: FeedValidationResult;
  robots?: RobotsTxtValidationResult;
  llmstxt?: LlmsTxtValidationResult;
  errors: ValidationError[];
  warnings: ValidationError[];
}

ValidationResult

interface ValidationResult {
  valid: boolean;
  errors: ValidationError[];
  warnings: ValidationError[];
  data?: unknown;  // parsed manifest/product if valid
}

interface ValidationError {
  path: string;
  message: string;
  severity: 'error' | 'warning';
}

Robots.txt Validation

import { validateRobotsTxt, parseRobotsTxtForOcp } from '@opencommerceprotocol/validator';

const robotsContent = `
User-agent: *
Allow: /

OCP-Manifest: https://mystore.com/.well-known/ocp.json
`;

const result = validateRobotsTxt(robotsContent);
// { valid: true, hasOCPManifest: true, manifestUrl: 'https://...', errors: [] }

// Parse to extract OCP-specific info
const parsed = parseRobotsTxtForOcp(robotsContent);
// { manifestUrl: 'https://...', isAllowed: true }

RobotsTxtValidationResult

interface RobotsTxtValidationResult {
  valid: boolean;
  hasOCPManifest: boolean;
  manifestUrl?: string;
  errors: string[];
}

llms.txt Validation

import { validateLlmsTxt, parseLlmsTxtForOcp } from '@opencommerceprotocol/validator';

const llmsContent = `# My Store

> Sell products online

## Commerce

- Products: https://mystore.com/ocp/products.jsonl
- Manifest: https://mystore.com/.well-known/ocp.json
`;

const result = validateLlmsTxt(llmsContent);
// { valid: true, hasCommerceSection: true, errors: [] }

const parsed = parseLlmsTxtForOcp(llmsContent);
// { feedUrl: 'https://...', manifestUrl: 'https://...' }

LlmsTxtValidationResult

interface LlmsTxtValidationResult {
  valid: boolean;
  hasCommerceSection: boolean;
  errors: string[];
}

agent_notes Quality Scoring

Score the quality of a product's agent_notes field on a 0–100 scale.

import { scoreAgentNotes, validateAgentNotesBatch } from '@opencommerceprotocol/validator';

// Score a single product's agent_notes
const result = scoreAgentNotes(
  'Best-seller. Ideal for frequent flyers. 30-hour battery. Folds flat. Bluetooth 5.0.'
);
// {
//   score: 82,
//   dimensions: {
//     length: { score: 90, feedback: 'Good length' },
//     specificity: { score: 85, feedback: 'Contains specific details' },
//     actionability: { score: 75, feedback: 'Provides useful context' },
//     completeness: { score: 78, feedback: 'Covers key attributes' },
//   },
//   suggestions: ['Consider adding size/fit information'],
// }

// Batch score an entire product catalog
const products = [
  { id: 'prod-1', agent_notes: 'Great product with good features...' },
  { id: 'prod-2', agent_notes: undefined },
];
const batchResult = validateAgentNotesBatch(products);
// {
//   averageScore: 45,
//   coverage: 0.5,  // 50% of products have agent_notes
//   scores: [{ id: 'prod-1', score: 90 }, { id: 'prod-2', score: 0 }],
//   topIssues: ['50% of products are missing agent_notes'],
// }

AgentNotesQualityResult

interface AgentNotesQualityResult {
  score: number;     // 0-100
  dimensions: {
    length: { score: number; feedback: string };
    specificity: { score: number; feedback: string };
    actionability: { score: number; feedback: string };
    completeness: { score: number; feedback: string };
  };
  suggestions: string[];
}

interface AgentNotesBatchResult {
  averageScore: number;
  coverage: number;       // 0-1, fraction of products with agent_notes
  scores: Array<{ id: string; score: number }>;
  topIssues: string[];
}

Score Interpretation

| Score | Meaning | |-------|---------| | 80–100 | Excellent — agent-ready | | 60–79 | Good — minor improvements possible | | 40–59 | Fair — significant gaps | | 0–39 | Poor — needs major work |

CLI

For command-line validation, use the @opencommerceprotocol/cli package:

npx @opencommerceprotocol/cli validate https://mystore.com
npx @opencommerceprotocol/cli validate ./public  # local directory