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

@sprig-and-prose/sprig-universe

v0.5.1

Published

Minimal universe parser for sprig

Downloads

110

Readme

sprig-universe

A minimal parser for the universe layer of Sprig, a declarative language for describing systems.

What it does

sprig-universe parses Sprig .prose files and extracts the universe structure, producing a JSON representation (UniverseGraph) that includes:

v0 Simplification:

  • Automatic discovery: finds universe.prose marker and loads all prose files

  • Dead simple defaults: no configuration required

  • Single universe rule: exactly one universe declaration required across all files

  • Nodes: Universe, series, book, and chapter declarations with their relationships

  • Edges: relates declarations connecting concepts

  • Describe blocks: Freeform text preserved exactly as authored

  • Unknown blocks: Blocks like references and documentation are preserved with their raw content

  • Source spans: File, line, column, and offset information for all nodes and blocks

  • Diagnostics: Warnings for duplicate names and unresolved references

Installation

npm install

Usage

CLI

Compile (v0 - Recommended)

The compile command uses automatic discovery to find and compile all prose files:

sprig-universe compile

Discovery behavior:

  • Walks upward from the current directory to find universe.prose marker file
  • Loads all **/*.prose files under the discovered root
  • Automatically excludes: .sprig/**, dist/**, node_modules/**, .git/**
  • Requires exactly one universe declaration across all files

Options:

  • --root <path> - Override discovery start path (default: current directory)
  • --quiet - Suppress observable header output
  • --config <path> - Path to sprig.config.json (optional, uses defaults if not found)

Observable header (shown unless --quiet):

Universe: <Name> (root: /path/to/root)
Loaded: <N> prose files
Ignored: .sprig/**, dist/**, node_modules/**, .git/**

Other commands:

  • sprig-universe watch - Watch files and recompile on change
  • sprig-universe check:references - Validate repository references
  • sprig-universe validate - Validate scene sources

Parse (Legacy)

Parse a single file:

sprig-universe parse path/to/file.prose

Parse a directory (recursively finds all *.prose files):

sprig-universe parse path/to/directory

Output to a file:

sprig-universe parse path/to/file.prose --out output.json

The CLI exits with a non-zero code if there are any error-level diagnostics.

Programmatic API

import { parseFiles, parseText } from './src/index.js';

// Parse a single text string
const ast = parseText(sourceText, 'filename.prose');

// Parse multiple files into a single graph
const graph = parseFiles([
  { file: 'file1.prose', text: sourceText1 },
  { file: 'file2.prose', text: sourceText2 },
]);

Supported Syntax

The parser supports the universe layer of Sprig:

  • universe <Name> { ... } - Top-level universe declaration
  • series <Name> { ... } - Series within a universe
  • book <Name> in <ParentName> { ... } - Book within a series or book
  • chapter <Name> in <ParentName> { ... } - Chapter within a book
  • relates <A> and <B> { ... } - Relationship between concepts
  • describe { ... } - Freeform text block (preserves raw content including braces)
  • Unknown blocks (e.g., references { ... }, documentation { ... }) - Preserved as-is

Comments start with -- and continue to the end of the line.

Output Format

The parser produces a UniverseGraph JSON structure:

{
  "version": 1,
  "universes": {
    "UniverseName": {
      "name": "UniverseName",
      "root": "UniverseName:universe:UniverseName"
    }
  },
  "nodes": {
    "UniverseName:series:SeriesName": {
      "id": "UniverseName:series:SeriesName",
      "kind": "series",
      "name": "SeriesName",
      "parent": "UniverseName:universe:UniverseName",
      "children": [],
      "describe": { "raw": "...", "source": {...} },
      "source": {...}
    }
  },
  "edges": {
    "UniverseName:relates:A--B:0": {
      "id": "UniverseName:relates:A--B:0",
      "kind": "relates",
      "a": { "text": "A", "target": "..." },
      "b": { "text": "B", "target": "..." },
      "source": {...}
    }
  },
  "diagnostics": []
}

Development

# Format code
npm run format

# Lint code
npm run lint

# Type check (JSDoc types)
npm run typecheck

# Run tests
npm test

License

ISC