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

@anatomytool/validate

v1.0.0

Published

Validator for .anatomy and .anatomy-memory files. Routes wire versions 0.1, 0.2, 0.4–0.15, and 1.0 (v1.0 == v0.15 structurally; the 0→1 bump is a stability commitment) + v0.3 cascading semantics. Identity-integrity is version-aware (v0.7+ flat-pillar fing

Downloads

59

Readme

@anatomy/validate

TypeScript validator for .anatomy and .anatomy-memory files. Routes by declared wire version (v0.1, v0.2, v0.4, v0.5, v0.6, v0.7, v0.8) and supports v0.3 cascading semantics for repos with multiple .anatomy files.

Install

npm install @anatomy/validate

Requires Node.js ≥ 22.

Usage

Single file

import { validate } from "@anatomy/validate";
import { readFileSync } from "node:fs";

const text = readFileSync(".anatomy", "utf8");
const result = validate(text, { repoRoot: process.cwd() });

if (result.ok) {
  console.log("Valid:", result.value.identity);
  for (const w of result.warnings) console.warn(w.code, w.message);
} else {
  for (const e of result.errors) console.error(e.code, e.pointer, e.message);
}

Cascading tree

import { validateTree } from "@anatomy/validate";

const tree = validateTree(repoRoot);
// tree.results: Map<path, ValidateResult>
// tree.crossFile: warnings spanning multiple .anatomy files (e.g. duplicate-fingerprint-in-tree)

Memory file

import { validateMemory } from "@anatomy/validate";

const result = validateMemory(memoryText, {
  anatomyFingerprint: parsedAnatomy.identity.fingerprint,
  repoRoot,
});

What it checks

.anatomy (single file)

  • TOML syntax — parse error → toml-parse error.
  • Schema conformance — version-routed against spec/{0.1, 0.2, 0.4, 0.5, 0.6, 0.7, 0.8}/schema.json. Unknown anatomy_versionunsupported-anatomy-version.
  • Identity integrity — version-aware:
    • v0.7+ (incl. v0.8): flat 4-string identity + single fingerprint via fingerprintFromPillars(stack, form, domain, function) = Crockford-base32(SHA-256(stack\0form\0domain\0function))[:20].
    • v0.1–v0.6: per-pillar hash = canonicalHash(id); fingerprint = concat(stack.hash, form.hash, domain.hash, function.hash).
  • Path checksstructure.entries[].path, entry_points[].path, phrase_with_source.source.{path, symbol} — soft-warn if missing on disk; nested-path-escape error for paths that climb above repoRoot/anatomyDir.
  • Interface↔form match[interface.exports] requires a library-shaped form; [interface.subcommands] requires a CLI-shaped form; etc.
  • Soft warningsdescription-too-long, entry-point-description-deprecated (v0.2 alias), commands-no-test (v0.4+: [operation.commands] without a test key).

.anatomy-memory (paired file)

  • Schema conformance — version-routed against spec/memory/{0.1, 0.2}/schema.json.
  • Paired-fingerprint integrityrepo_fingerprint must match the paired .anatomy's fingerprint (memory-fingerprint-mismatch).
  • Supersession integrity — no cycles (memory-supersedes-cycle), no dangling targets (memory-supersedes-not-found).
  • Reference soundness — entry refs pointing to nonexistent files → memory-dangling-ref warning.
  • v0.2 verification field hygieneverified_by items match the attribution regex (memory-verified-by-malformed); verified_by array bounded at 5 (memory-verified-by-too-many warning if exceeded by hand-edits); last_verified_at not earlier than the entry's creation at (memory-last-verified-before-at warning).

Rule verification (v0.12+)

Each [[rules]] entry may carry an optional verify field that declares how to check the rule against actual source. Three kinds:

  • glob_exists — assert files matching a glob exist (or, with should_not=true, don't exist).
  • glob_only — assert files matching one glob all live inside another.
  • ast_pattern — ast-grep pattern + expect_in or forbid_in glob. Requires the optional @ast-grep/napi dependency.

Example:

[[rules]]
rule = "Tests live in tests/"
verify = { kind = "glob_exists", path = "tests/*.test.ts" }

[[rules]]
rule = "No fetch() outside src/api/"
verify = { kind = "ast_pattern", lang = "ts", pattern = "fetch($_)", forbid_in = "src/!(api)/**/*.ts" }

Verify clauses run during validate() when repoRoot is provided. Violations surface as warnings; under anatomy validate --strict (the default), the relevant warning codes elevate to errors.

validate() is async as of v0.12. Earlier versions returned a sync object; callers must now await.

Cascading (v0.3 ecosystem)

For repos with multiple .anatomy files (one at root, plus per-package overrides):

import { findAnatomyForPath, discoverAllAnatomies } from "@anatomy/validate";

const nearest = findAnatomyForPath(repoRoot, "packages/server/src/index.ts");
const all = discoverAllAnatomies(repoRoot);

Cross-file checks include duplicate-fingerprint-in-tree (sibling files sharing a fingerprint).

Public API

| Export | What | |---|---| | validate(text, options) | Single-file validation; returns { ok, value?, errors, warnings }. | | validateTree(repoRoot, options) | Cascading tree validation. | | validateMemory(text, options) | .anatomy-memory single-file validation. (No tree-mode equivalent yet — call validateMemory once per discovered memory file.) | | findAnatomyForPath(repoRoot, queryPath) | Locate the nearest .anatomy for a given file path. | | discoverAllAnatomies(repoRoot, options) | Walk and parse every .anatomy in a tree. | | canonicalize(s) / hash(c) / canonicalHash(s) / fingerprintFromPillars(stack, form, domain, fn) | Re-exported canonical-form helpers. | | supportedVersions | Frozen tuple of supported wire versions. | | ECOSYSTEM_VERSION | Currently "0.3". | | Types: AnatomyDoc, ValidationError, Warning, ValidateOptions, ValidateResult, ErrorCode, WarningCode |

License

MIT