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

@carlwr/zsh-lexicon

v0.1.1

Published

Structured zsh reference data parsed from official zsh documentation

Readme

zsh-lexicon TypeScript library/npm package

ci API docs license

npm types node JSON

[!NOTE]

This README.md file is written entirely by me, Carl, a human developer.

Details: section README.md by a human, code by LLMs

A strongly typed interface to structured zsh knowledge.

The knowledge itself is parsed from the sources of the zsh 5.9 manual in the upstream zsh official repo.

Additionally, the structured knowledge (records) are available in rendered markdown form.

This package/library powers other parts of this project:

Install

npm install @carlwr/zsh-lexicon  # or:
pnpm add @carlwr/zsh-lexicon

# Deno:
deno add npm:@carlwr/zsh-lexicon
# (run with `--allow-read` — the vendored data is read at runtime)

Usage example

import { loadLexicon } from "@carlwr/zsh-lexicon"
import { resolve } from "@carlwr/zsh-lexicon/resolver"
import { renderRecord } from "@carlwr/zsh-lexicon/render"

const lexicon = loadLexicon()

// resolve() is where a raw string meets the lexicon:
const hit = resolve(lexicon, "option", "NO_AUTO_CD")
if (!hit) throw new Error("not a zsh option")

console.log(hit.record.id)         // → autocd
console.log(hit.feedback)          // → { kind: "input-negated" }
const { title, mdBody } = renderRecord(lexicon, hit.record)
console.log(`${title}\n\n${mdBody}`)

After if (!hit) throw .. above, no further lookups or checks are needed, since after that, the compiler knows hit represents a valid, existing record.


Below we create a custom function that demands a record id within the option category. We then call the function with the hit value from the code block above.

import type { Documented } from "@carlwr/zsh-lexicon"

function optionLink(id: Documented<"option">): string {
  return `#option-${id}`
}

optionLink(hit.record.id)  // ✓
optionLink("autocd")       // ✗ compile error, even with the right string

In zsh, unset is both a shell option and a builtin so below, both resolve() calls will return a record. The compiler will only let us call optionLink() in the correct way:

const unsetOptionHit  = resolve(lexicon, "option" , "unset")
const unsetBuiltinHit = resolve(lexicon, "builtin", "unset")

if (unsetOptionHit)  optionLink(unsetOptionHit.record.id)   // ✓
if (unsetBuiltinHit) optionLink(unsetBuiltinHit.record.id)  // ✗ compile error

Some records cross-reference other records. The type of those cross-references says that the record exists and what category it belongs to. Therefore, below we can call our function with the cross-reference value directly, once we have checked that our call to resolve() indeed returned a record, and that the record has the optional aliasOf field:

const dotglobAlias = resolve(lexicon, "option", "DOT_GLOB")?.record.aliasOf
if (dotglobAlias) optionLink(dotglobAlias.target)   // ✓ → "#option-globdots"

The library API

Full documentation: https://carlwr.github.io/zsh-lexicon/docs/

This library is:

  • rich in types, poor in functions
  • pure, static and side-effect-free[^side-effects-caveats]

General structure:

  • Pieces of documentation live in records.

    • e.g. one record for the AUTO_CD shell option
  • Records are organized in categories.

    • e.g. the category option for the AUTO_CD record
  • Look-up happens through category-specific resolvers.

    • e.g. a look-up for both autocd and NO_auto_cd will return the record for AUTO_CD
    • The resolvers encode zsh domain knowledge to make life easier for consumers.
  • Different categories may have different data shapes on top of some fields that are always shared. This is all encoded in static types.

  • The category taxonomy is closed, meaning completeness can be enforced by the compiler.

  • Per-category quirks are generally hidden. Consumers generally won't need to branch on categories.

When loadLexicon() is called, it returns immediately without doing any work. All processing happens only later, as needed. The bundled data is processed the first time it is needed, per-category, and is cached. In other words: behind-the-scenes, everything happens lazily on-demand per-category, with caching.

For non-TS consumers: JSON + schema

These are available as GitHub Release Assets. The data is the same as that provided by the TypeScript library. The JSON Schema encodes the structure, and to some extent, the invariants.

The GitHub Release Assets have SHA-256 checksums and build-provenance attestation which the user can check with:

gh attestation verify <FILE> --repo carlwr/zsh-lexicon

Trust surface

(Linked items: tests that back up or guard the claim.)

There is a single dependency: @carlwr/typescript-extra (same maintainer as this package), which itself has no dependencies.

Categories

The reference contains some 1300 records sorted into the following categories:

| Category | Examples | | ---------------------------- | ---------------------------- | | Builtins | print, setopt, zle | | Options | AUTO_CD, EXTENDED_GLOB | | Special parameters | $?, $PWD, $path | | Special functions | precmd, TRAPINT | | Complex commands | if, for, case, [[ | | Reserved words | then, done, coproc | | Precommand modifiers | noglob, command, exec | | Conditional operators | -f, -nt, =~ | | Arithmetic operators | **, <<, ^^ | | Math functions | sqrt, int, rand48 | | Redirections | 2>&1, <<<, &> | | Process substitutions | <(...), >(...), =(...) | | Parameter-expansion forms | ${name:-word}, ${#spec} | | Parameter-expansion flags | (U), (j:,:), (@) | | Parameter-subscript flags | (r), (i), (w) | | Glob operators | [...], ^x, x~y | | Glob qualifiers | (.), (/), (N) | | Glob flags | (#i), (#b) | | History-expansion components | !!, !-2, :h | | Prompt escapes | %~, %n, %F | | Job specs | %1, %+, %- | | ZLE widgets | accept-line, vi-cmd-mode | | ZLE keymaps | emacs, viins, vicmd | | Completion utilities | _arguments, _files |

Node requirement and versioning policy

All major Node.js versions that haven't reach end-of-life are supported. Currently that means Node ≥ 22.

Dropping support for a Node.js line that has reached its end-of-life is a minor release of this package.

README.md by a human, code by LLMs

This README.md file is written entirely by me, Carl, a human developer. Agentic tools have not been allowed to make edits, suggest phrasing or even suggest corrections to its prose, except for spelling fixes. Agentic tab-complete has been disabled. The same goes for any README*.md and any SECURITY.md within this repo.

Other than that, almost everything in this repo is written by LLMs. I-the-human have directed the development, designed the data structures and made the architectural choices. Further, I have closely reviewed (at minimum:) all code related to security surfaces; to the best of my ability.

The models used, at least up until the public 0.1.0 release, were mostly Opus 5.x 1M and GPT-{5.6..6.2}, with dashes of DeepSeek V4 Pro. These models were used through Claude Code, Codex, opencode and occasionally Cursor.

[^side-effects-caveats]: Some bundled files are read lazily, so if Deno is used, --allow-read. There is also one function for writing the bundled data files to a given directory; this function is included to make life easier for bundlers.