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

@witlang/parser

v0.2.0

Published

Parser for the Wit markup language — lexer, parser, AST

Readme

@witlang/parser

The Wit language parser. Reads Wit source and produces a typed AST.

What this parses

Plain prose with _italic_ and *bold* emphasis.

Produces a paragraph block whose children include text, italic, and bold inline nodes.

#person
  name: Aldous Vane
  years at post: 31
person#

Produces a dataDef named person whose value is a record with two typed fields (namestringValue, years at postnumberValue).

@greeting ||name||
Hello, ::name::.
greeting#

Produces a nodeDef named greeting with one declared capture (name) and a body containing a single paragraph with an interpolation referencing the captured value.

Public API

@witlang/parser exposes a small, curated surface. See src/index.ts for the canonical list. The main entry is parse(source, file?) which returns a Document node. Errors are thrown as WitError instances carrying a stable code and a loc.

import { parse, WitError } from '@witlang/parser';

try {
  const doc = parse(source, '/path/to/file.wit');
  // doc.kind === 'document'
} catch (err) {
  if (err instanceof WitError) {
    console.error(`${err.code} at ${err.loc.line}:${err.loc.col}: ${err.message}`);
  }
}

Typed scalar values inside record fields, collection items, and comparison RHS positions are classified at parse time:

  • Integer / decimal literals (-?[0-9]+(\.[0-9]+)?) → numberValue.
  • Exact lowercase true / falsebooleanValue.
  • Exact lowercase nullnullValue.
  • Quoted strings ("...") and anything else → stringValue.

Known limitations

The v0.1.0 parser handles every shape in the language specification except the three rough edges below. Each one is pinned by a fixture under tests/fixtures/ so regressions can't sneak in.

  • Multi-line pipe-form values — a pipe parameter whose value continues across a newline (|key value\nsecond line|) is rejected or produces a garbled AST. Pinned by tests/fixtures/06-parameters-pipes/multi-line-value.json. Workaround: use form-fill capture (key: value lines inside a bodied node) or a quoted string.

  • Nested closing of same-named nodes — different names nest cleanly (@chapter ... @aside ... aside@ ... chapter@), but the same name nesting (@chapter ... @chapter ... chapter@ ... chapter@) is ambiguous and resolves to the innermost match only. Pinned by tests/fixtures/17-combinations/nested-nodes-with-params.json. Workaround: rename one of the nested instances.

  • Bare tilde without trailing space — a ~ that is not followed by a space at the start of a line parses as content, not as a comment continuation. Always write ~ (tilde + space) at the start of every comment line.

License

See repository root.