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

@agentrules/core

v0.3.1

Published

Shared types and utilities for the AGENT_RULES ecosystem.

Readme

@agentrules/core

Shared types and utilities for the AGENT_RULES ecosystem.

This package is for developers building custom registries or alternative clients. If you just want to install or publish rules, use the CLI instead.

Installation

npm install @agentrules/core

What's Included

| Module | Description | |--------|-------------| | Types & Schemas | TypeScript types and Zod schemas for rules, bundles, configs | | Registry Builder | Build registry artifacts from rule inputs | | Registry Client | Fetch and resolve rules from registries | | Bundle Utilities | Encode/decode bundles, verify checksums | | Platform Config | Platform IDs and directory paths |

This package contains pure functions with no environment assumptions. It doesn't touch the file system or make network requests directly — that's left to the consumer (like the CLI).

Usage

Validating Rule Config

import {
  normalizePlatformEntry,
  ruleConfigSchema,
  validateRule,
} from "@agentrules/core";

// Parse/validate user-provided JSON (agentrules.json)
const parsed = ruleConfigSchema.safeParse(jsonData);
if (!parsed.success) {
  console.error(parsed.error.issues);
} else {
  // Normalize platform entries (string shorthand → object form)
  const config = {
    ...parsed.data,
    platforms: parsed.data.platforms.map(normalizePlatformEntry),
  };

  // Additional cross-field checks (platform/type compatibility, placeholders, etc.)
  const result = validateRule(config);
  if (!result.valid) {
    console.error(result.errors);
  }
}

Note: description and tags are optional in agentrules.json (they default to "" and []).

Building Registry Artifacts

import { buildRegistry, type RuleInput } from "@agentrules/core";

const rules: RuleInput[] = [
  {
    name: "my-rule",
    config: {
      name: "my-rule",
      title: "My Rule",
      description: "A helpful rule",
      license: "MIT",
      // Optional metadata
      tags: ["starter"],
      features: ["Fast install"],
      // Platforms (object form)
      platforms: [{ platform: "opencode" }, { platform: "claude" }],
    },
    platformFiles: [
      {
        platform: "opencode",
        files: [{ path: "AGENTS.md", content: "# Rules\n" }],
      },
      {
        platform: "claude",
        files: [{ path: "CLAUDE.md", content: "# Rules\n" }],
      },
    ],
  },
];

const result = await buildRegistry({ rules, bundleBase: "https://example.com" });

// result.rules   → ResolvedRule[] (metadata + bundle URLs)
// result.bundles → RuleBundle[] (per-platform bundles)

Fetching from a Registry

import { fetchBundle, resolveSlug } from "@agentrules/core";

// Resolve metadata + variant bundle URLs
const resolved = await resolveSlug(
  "https://agentrules.directory/",
  "my-rule" // or "username/my-rule" for namespaced registries
);

if (!resolved) throw new Error("Rule not found");

// Pick a variant bundle URL (example: first variant of latest version)
const bundleUrl = resolved.versions[0].variants[0].bundleUrl;

// Fetch the per-platform bundle
const bundle = await fetchBundle(bundleUrl);

Working with Bundles

import {
  decodeBundledFile,
  verifyBundledFileChecksum,
  isLikelyText,
} from "@agentrules/core";

for (const file of bundle.files) {
  // Decode base64 contents
  const data = decodeBundledFile(file);
  
  // Verify integrity
  await verifyBundledFileChecksum(file, data);
  
  // Check if it's text or binary
  if (isLikelyText(data)) {
    const text = new TextDecoder().decode(data);
  }
}

Types

Key types exported:

import type {
  // Rule configuration (agentrules.json)
  RuleConfig,
  
  // What clients send to publish
  RulePublishInput,
  
  // What registries store and return
  RuleBundle,
  Rule,
  RuleIndex,
  
  // Bundle file structure
  BundledFile,
  
  // Platform types
  PlatformId,
  PlatformConfig,
} from "@agentrules/core";

Schemas

Zod schemas for validation:

import {
  ruleConfigSchema,
  ruleBundleSchema,
  rulePublishInputSchema,
  platformIdSchema,
  nameSchema,
  titleSchema,
  descriptionSchema,
} from "@agentrules/core";