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

@pfdsl/core

v0.0.8

Published

Core pipeline for the PFDSL process-flow DSL: lex → parse → normalize → build graph → validate → sort → format.

Readme

@pfdsl/core

Core pipeline for the PFDSL process-flow DSL: lex → parse → normalize → build graph → validate → sort → format.

Install

pnpm add @pfdsl/core

Requires Node ≥ 18 (ESM only).

Quick start

import { format } from '@pfdsl/core';

const source = `
[requirement, constraint] >> design -> spec
spec >>? design
`;

const { output, diagnostics } = format(source);
const errors = diagnostics.filter(d => d.severity === 'error');

if (errors.length === 0) {
  console.log(output);
}

format() is idempotent: format(format(x).output).output === format(x).output.

API

format(source: string): FormatResult

Run the full pipeline and return canonical text plus all diagnostics.

interface FormatResult {
  output: string;          // canonical edge list, one edge per line
  diagnostics: Diagnostic[]; // frontmatter + lex + parse + normalize + validate
}

Stage-by-stage API

For tools that need intermediate state (LSP, exporters):

import {
  parse,             // source → { document, frontmatter, diagnostics }
  normalizeDocument, // document → { edges, nodeKinds, diagnostics }
  buildGraph,        // edges → graph (primary + feedback + nodes)
  validateGraph,     // graph → diagnostics
  sortEdges,         // edges + graph → canonically sorted edges
  formatEdges,       // sorted edges → text
} from '@pfdsl/core';

const { document, frontmatter, diagnostics: parseDiags } = parse(source);
const { edges, nodeKinds } = normalizeDocument(document, frontmatter);
const graph = buildGraph(edges, nodeKinds);
const validateDiags = validateGraph(edges, graph, frontmatter);
const sorted = sortEdges(edges, graph);
const text = formatEdges(sorted);

All AST / token / diagnostic / graph types are exported as type-only.

DSL syntax (cheat sheet)

---                              # optional YAML frontmatter
artifact:
  spec:
    label: 仕様書
process:
  design:
    label: 設計
  build:
    label: 実装
    parts: [design]              # composition (build is decomposed into design)
---

# Edges
A >> P                           # A is input to process P
P -> B                           # P produces artifact B
A >>? P                          # feedback edge (semantic only)

# Chain
A >> P -> B >> Q -> C            # A→P→B→Q→C, multiple segments

# Set notation (Cartesian product)
[a, b] >> P -> [x, y]            # 2 inputs × 2 outputs = 4 edges

# Line continuation
[a, b, c]
  >> P -> result                 # leading-op continuation OK
A >> P
  -> B                           # continuation before -> OK

# Comments and blank lines
# this is a comment
[a, b]                           # blank line below would terminate the statement
  >> P -> X

Full grammar and validation rules: see docs/spec/spec.md.

Diagnostics

Errors and warnings are returned in diagnostics arrays, never thrown. Each diagnostic carries:

interface Diagnostic {
  severity: 'error' | 'warning' | 'info';
  code: string;       // FM001, L001, P005, N002, V003, ...
  message: string;
  range: { start: Position; end: Position };
}

Code prefixes: FM frontmatter, L lexer, P parser, N normalizer, V validator.

Validation rules

  • V001 Each artifact must have at most one producing process (single source).
  • V002 / V003 Every process must have ≥1 input and ≥1 output.
  • V004 – V006 parts: declarations must reference processes, must not self-reference, and must not form cycles.

Canonical ordering

sortEdges produces a stable order independent of input ordering:

  1. Connected component (by smallest node ID in component)
  2. Topological rank (longest path from a source artifact)
  3. Edge kind (input < feedback < output)
  4. Lexicographic tiebreak

This makes format() output suitable for diffing and version control.

Development

pnpm install
pnpm --filter @pfdsl/core build
pnpm --filter @pfdsl/core test
pnpm --filter @pfdsl/core typecheck