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

@silverprotocol/richtext

v0.12.4

Published

Headless rich-text block model for AgJSON text content — a typed markdown-subset AST + the safety policy, no rendering.

Readme

@silverprotocol/richtext

The headless rich-text block model for AgJSON text content. Agents emit markdown in chat (**bold**, lists, headings); this package turns that text into a typed AST and owns the safety policy — once, for every host — while rendering stays entirely yours.

  • Headless. No components, no styling, no dependencies. You map the AST onto your own renderers and design tokens (React, React Native, DOM, terminal — anything).
  • Safe by construction. Raw HTML is never interpreted: no HTML node type exists, so <script> in model output can only ever be literal text. Link href is populated only for http: / https: / mailto: targets — everything else (javascript:, data:, relative paths) parses as a link with href: undefined.
  • Streaming-tolerant. Feed a growing buffer on every text.delta and re-parse: mid-stream input with unclosed markers (**bol, a dangling code fence, half a link) parses to a stable AST with closed: false on the open construct. Completed constructs never change shape.

Install

npm install @silverprotocol/richtext

Usage

import { parseRichText } from "@silverprotocol/richtext";

const blocks = parseRichText("- **12:00–2:00 PM** — Finish the pitch deck");
// [{ type: "list", ordered: false, items: [{ children: [
//    { type: "strong", children: [{ type: "text", text: "12:00–2:00 PM" }], closed: true },
//    { type: "text", text: " — Finish the pitch deck" },
// ] }] }]

Walk the RichTextBlock[] and map each node to your renderer. The one rendering rule: every string in the AST (text, code) is literal content — render it as text content (React children / RN <Text> / textContent), never as markup.

The subset

Blocks: paragraphs (single newlines become explicit break nodes — chat prose is line-broken), headings (#–######), fenced code (with language tag), flat ordered/unordered lists, pipe tables (GFM subset). Inline: **strong**, *em* / _em_, `code`, [links](https://…), backslash escapes.

Deliberately out of v1 (parses as plain text): images, blockquotes, strikethrough, autolinked bare URLs, nested lists, table cell spans, raw HTML (permanently).

Tables

The GFM pipe-table subset — a header row, a delimiter row, body rows:

parseRichText("| # | Task |\n|:-:|------|\n| 1 | **Ship** it |");
// [{ type: "table",
//    align: ["center", undefined],          // per column, from the delimiter row
//    header: { cells: [{ children: [{ type: "text", text: "#" }] }, …] },
//    rows: [{ cells: [{ children: [{ type: "text", text: "1" }] },
//                     { children: [{ type: "strong", … }, { type: "text", text: " it" }] }] }] }]

The header fixes the column count: every row has exactly align.length cells (short rows are padded with empty cells, long rows drop the excess — GFM's rule). Outer pipes are optional, \| is the cell-pipe escape (it works inside code spans), and cells hold inline content only. A table ends at a blank line, another block, or any line without a pipe. While streaming, the delimiter row has to complete (a newline follows it) before the table forms — until then the header and the half-typed delimiter are an ordinary two-line paragraph, so a renderer never sees a table flap back into prose.

Streaming

parseRichText("**bol");
// [{ type: "paragraph", children: [
//    { type: "strong", children: [{ type: "text", text: "bol" }], closed: false },
// ] }]

closed: false is the signal — style it optimistically or plainly, your call; when the closing marker arrives, the same node completes in place.

Spec: silverprotocol.io/AgJSON — proposed in [workspace#8]; the AST is protocol-adjacent (it defines what a text block's content means to a renderer), presentation is host business.