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

tref-block

v0.2.0

Published

TREF - Traceable Reference Format for knowledge with origin

Readme

TREF

Traceable Reference Format

A JSON-based format for knowledge exchange where references are structural, not optional.

What is TREF?

TREF is a knowledge exchange format – not a CMS, not an AI model, not a platform. It's a JSON format for creating self-contained units of knowledge that preserve:

  • Content – the actual information
  • Metadata – author, timestamps, source
  • License – attribution requirements
  • References – URLs, archived snippets, search prompts, hashes
  • Lineage – parent/child relationships, version history

Install

npm install tref-block

Or use CDN:

<script type="module">
  import { TrefWrapper } from 'https://cdn.jsdelivr.net/npm/tref-block';
</script>

Core Principles

  1. The Block is the Atom of Truth – smallest meaningful unit of knowledge
  2. Reference Lineage – modifications create new blocks, preserving history
  3. References Survive – not just URLs, but archived snippets and search prompts
  4. AI-First, Human-Readable – JSON format readable by both machines and humans
  5. Verifiability Over Authority – trust through transparency, not central control
  6. Copy = Citation – copying preserves origin, references, and license
  7. The Icon IS the Block – no extra containers, just the draggable icon

Browser Components

Two components enable TREF exchange between websites and AI chats. See src/wrapper/README.md for full design guide.

TrefWrapper – Display and Share

const wrapper = new TrefWrapper(block);
container.innerHTML = wrapper.toHTML();
wrapper.attachEvents(container.querySelector('.tref-wrapper'));
  • ICON is the drag handle (only the icon, not the entire block)
  • Actions appear on hover: "drag me" hint, copy, download
  • Status feedback in the shortId badge

TrefReceiver – Accept TREF Blocks

const receiver = new TrefReceiver(element, {
  onReceive: wrapper => console.log('Got block:', wrapper.block),
  onError: err => console.error(err),
});

Drag-and-Drop Flow

┌─────────────────┐                    ┌─────────────────┐
│   Site A        │                    │   Site B / Chat │
│                 │     drag TREF      │                 │
│  [TREF icon] ──────────────────────► │  [Drop Zone]    │
│   TrefWrapper   │                    │   TrefReceiver  │
└─────────────────┘                    └─────────────────┘

The entire block (content, refs, license, lineage) transfers with the drag.

Quick Start

npm install
npm run build         # build browser bundle
npm run dev           # start dev server (http://localhost:8080)
npm run check         # typecheck + lint + format
npm test              # run tests

Architecture

Single source, many outputs:

src/wrapper/wrapper.js    ← Write code here
        │
    npm run build
        ▼
dist/tref-block.js        ← Built output (10kb)
        │
        ├──> CDN (jsdelivr/unpkg)
        ├──> npm install
        └──> demo/

Development

This project uses TypeScript-level safety in pure JavaScript:

  • JSDoc type annotations
  • TypeScript CLI for type checking (no transpilation)
  • ESLint with type-aware rules
  • Zod for runtime validation
  • Prettier for formatting
npm run build:browser # build browser bundle
npm run typecheck     # type check
npm run lint          # lint
npm run format        # format code
npm run check         # all checks
npm test              # run tests

Project Structure

src/
  wrapper/
    wrapper.js        # TrefWrapper + TrefReceiver (single source)
  cli/
    index.js          # CLI tool
  mcp/
    server.js         # MCP server for Claude Code
dist/
  tref-block.js       # Built browser bundle
demo/
  index.html          # Visual testing
doc/
  project.md          # Vision & architecture
  TrefBlockUIUX.md    # UI/UX specification

Documentation

Status

MVP Complete – Single-source architecture with browser bundle.

  • TrefWrapper + TrefReceiver (drag-and-drop)
  • Accessibility: ARIA, keyboard, focus-visible
  • Mobile/touch support: tap-to-toggle, long-press
  • Dropdown action menu with SVG icons
  • CLI tool (tref publish, tref validate, tref derive)
  • MCP server for Claude Code integration
  • Live demo at tref.lpmwfx.com

License

AGPL-3.0-or-later