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

@catheadowl/md-tools

v0.2.1

Published

Markdown reference toolchain for git repositories — doc-rename moves files with every reference rebased, doc-link checks links and anchors, doc-normalize migrates link style, md-measure reports document structure facts; the engine ships as an importable l

Readme

@catheadowl/md-tools

Keep Markdown references true while a repository moves. doc-rename moves files and directories and rebases every in-repo reference as one atomic plan; doc-link checks that every internal link and heading anchor resolves; doc-normalize migrates /-prefixed internal links to document-relative form. The same engine ships in this package as an importable library, together with a document-structure measurement entry — also exposed as the md-measure command for validator-style consumers.

Install

npm install -g @catheadowl/md-tools

Node >= 18. The three repo commands — doc-rename, doc-link, doc-normalize — run inside a git repository with git on PATH; the repo root is discovered from the current directory, and outside a repository (or without git) they refuse cleanly with exit 2. md-measure needs neither: it measures plain Markdown files (or stdin) anywhere.

Usage

# Move a file and rebase every in-repo Markdown reference to it
doc-rename docs/old-name.md docs/new-name.md

# Preview the plan before writing
doc-rename docs/old-name.md docs/new-name.md --dry-run

# Sink a whole directory tree under one new name as a single atomic plan
doc-rename --sink <dir> <sub>

# Check every internal link and anchor resolves (read-only audit)
doc-link

# Machine-readable results (file, line, class, URL, reason, remedy); classes are target-missing, anchor-missing, or outside-repository
doc-link --json

# One-time migration of /-prefixed internal links to document-relative form
doc-normalize [--fix] [--json]

# Document structure facts as JSON (always an array, one object per file) —
# physical lines, table rows, per-section content counts, code-fence payloads;
# flags mirror the library signatures, and the defaults already carry the common
# validator caliber (H1/H2 sections, js-trim blanks, tables and fenced code excluded)
md-measure --json doc.md
md-measure --json - < draft.md

doc-rename is plan-then-apply and all-or-nothing — the worktree is never half-changed, and refusals are structured, never guessed. Flags, semantics and refusal codes are canonical in each command's --help.

Exit codes

| Code | Meaning | |---|---| | 0 | clean | | 1 | findings, conflicts, or a startup-guard refusal | | 2 | usage error (including the outside-repo and no-git refusals) |

md-measure has no findings concept: 0 = measured, 2 = usage error (an unreadable input file included — it fails fast, never emitting a partial array), and 1 stays reserved for the startup guard.

Declared freeze policy

A directory whose manifest.yml declares archived: true is frozen history, picked up automatically: doc-link does not report out-links from frozen files, while still checking active files that link to frozen targets; doc-rename treats frozen files as read-only. --frozen <dirName> replaces the declared policy for one run; --no-manifest-freeze skips it. Flag semantics: doc-link --help; the pinned read and its fail-loud rules: skills/md-tools/references/freeze.md.

Agent skill

The package ships an agent-facing skill payload at skills/md-tools/ — the whole subtree is the install unit (the shape ecosystem skill installers scan; copy or link it into an agent skill directory). The package never writes an agent directory; the install/refresh contract rides inside the tree.

Library

npm install @catheadowl/md-tools
import { checkRepository } from '@catheadowl/md-tools'

for (const v of checkRepository(root)) {
  console.log(`${v.file}:${v.line}: ${v.url} — ${v.reason}`)
}

The engine classifies, extracts, resolves, anchor-checks and plans byte-preserving rewrites of links, images, definitions, [[wikilinks]] and registered scheme addresses over a git tree — the file universe is git ls-files; extraction and rewrite planning are pure string functions. It never decides when to check or what to exempt: freeze policy, deny lists and wiki disambiguation flow in as parameters. The typed surface is the API reference — lib/index.d.ts, with the data plane at @catheadowl/md-tools/links/index.js, the report face at @catheadowl/md-tools/gate-check.js, and the measurement entry at @catheadowl/md-tools/measure/index.js.

Measuring document structure

A separate narrow entry measures Markdown text — physical lines, sections, structure facts — without any triage policy. Budgets, thresholds and routing stay with the caller.

import { createMarkdownDocument, measureMarkdownLines, partitionMarkdownSections } from '@catheadowl/md-tools/measure/index.js'

const document = createMarkdownDocument(source) // one parse, shared by every consumer
const { sections } = partitionMarkdownSections(document, { levels: [1, 2], scope: 'all' })
const nonEmptyBodyLines = sections.map(section => measureMarkdownLines(document, {
  range: section.body,
  blankness: 'js-trim',
  exclude: ['tables', 'fencedCode', 'indentedCode', 'definitions'],
}).count)

One document is one parse: headings, code fences (including unclosed and container-nested ones), tables and definitions are facts over the same tree, positions are original UTF-16 offsets, and line ranges are document-owned. Blankness (none / space-tab / js-trim) and exclusions are always explicit — each count names its own caliber instead of one ambiguous sectionLines. visitMarkdownDocument walks the shared tree for anything the facts do not carry. The same facts are available without import code through the md-measure bin: its flags mirror these signatures and --json returns one fact object per file.

Ports that do not import the library can prove agreement against the shipped conformance corpus at @catheadowl/md-tools/conformance/cases.json — pure data, one case per entry, tagged by capability.

Development

Source checkouts, tests and the backlog are documented in the source repository, not in this package.

License

MIT.