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

@callumalpass/mdbase

v0.2.2

Published

TypeScript implementation of the mdbase specification

Readme

mdbase

TypeScript implementation of the mdbase spec: a structured markdown collection with typed frontmatter, validation, queries, links, and watch/caching semantics.

This repo is a reference implementation used to run the conformance suite in ~/projects/mdbase-spec/tests.

Features

  • Typed frontmatter with validation, defaults, coercion, and constraints
  • Type definitions in _types/ with inheritance
  • Query language with filters, ordering, formulas, and link traversal
  • Link parsing + resolution (wikilinks, markdown links, bare paths)
  • Backlinks, tags, and embeds extraction from content
  • Batch operations and rename with optional reference updates
  • Cache support via a SQLite worker (async API)
  • Watch-mode simulation for conformance tests

Install

npm install

Build and test

npm run build
npm test

Performance profiling

Run the synthetic profiler with default workload:

./scripts/profile.sh

Write results to a JSON file with custom sizing:

./scripts/profile.sh --files 5000 --query-iters 500 --output .ops/profile/latest.json

The profiler reports latency percentiles (p50, p95, p99), averages, and throughput for core operations (open, read, query_basic, query_formula, update, rename_update_refs, create, delete, cache_rebuild).

Usage

The public API is async. Open a collection, run operations, then close it.

import { Collection } from "mdbase";

const opened = await Collection.open("/path/to/collection");
if (opened.error) throw new Error(opened.error.message);
const collection = opened.collection!;

const read = await collection.read("notes/example.md");
const query = await collection.query({
  types: ["task"],
  where: "status == \"open\" && priority >= 2",
  order_by: [{ field: "priority", direction: "desc" }],
});

await collection.close();

Operations

All operations are methods on Collection:

  • read(path)
  • validate(path?)
  • create({ path, frontmatter|fields, body, type|types })
  • update({ path, fields|frontmatter, body })
  • delete(path, { check_backlinks? })
  • rename({ from, to, update_refs? })
  • query({ types?, where?, order_by?, limit?, offset?, include_body?, context_file?, formulas? })
  • batchDelete({ where, dry_run?, check_backlinks? })
  • batchUpdate({ where?, fields?, updates?, dry_run? })
  • backfill({ type?, where?, fields?, apply?, dry_run? })
  • migrate({ id, dry_run? })
  • cacheRebuild()
  • cacheClear()
  • close()

See src/operations/collection.ts for the authoritative behavior.

Config

Collections are configured with mdbase.yaml:

spec_version: "0.2.1"
settings:
  types_folder: "_types"
  migrations_folder: "_types/_migrations"
  default_validation: "warn" # off | warn | error
  default_strict: false
  include_subfolders: true
  rename_update_refs: true
  cache_folder: ".mdbase"

Type definitions live in the types folder (default _types/) as markdown files with frontmatter:

---
name: task
fields:
  title:
    type: string
    required: true
  status:
    type: enum
    values: [open, closed]
  parent:
    type: link
    target: task
---

Cache

Cache is async and backed by SQLite in a worker (src/cache/worker.js). It is used opportunistically to speed up reads; correctness does not depend on cache presence. Use cacheRebuild() and cacheClear() for tests or maintenance.

Conformance

The conformance runner is in test/conformance.test.ts. It reads YAML test files from ~/projects/mdbase-spec/tests and executes them against this implementation.

Example applications

| Project | Description | |---------|-------------| | mdbase-workouts | Workout tracker with chat interface, built on mdbase |

Repository layout

  • src/operations/collection.ts main implementation
  • src/expressions/ query language + evaluation
  • src/links/ link parsing and body extraction
  • src/config/ config loading
  • src/types/ type loading and validation helpers
  • src/cache/ async cache store + worker
  • test/ conformance test runner