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

@titan-design/retrieval

v0.3.0

Published

FTS + vector + graph retrieval with RRF fusion, rerank cascade, and fail-open

Readme

@titan-design/retrieval

Hybrid retrieval that degrades instead of failing: run several retrievers in parallel, fuse their rankings with reciprocal rank fusion, optionally rerank with a cross-encoder, and report which sources were unavailable rather than throwing.

Tier 1 of the titan-platform DAG. Depends on @titan-design/store-sqlite and @titan-design/embed. Extracted from brain's search.ts (TP-8) with the note-specific stages left behind and fail-open added.

import { createRetrievalEngine, ftsRetriever, vectorRetriever, graphRetriever } from "@titan-design/retrieval";

const fts = ftsRetriever(spans);                 // store-sqlite SpanFtsTables
const engine = createRetrievalEngine({
  retrievers: [fts, vectorRetriever(embedder, index), graphRetriever(edges, fts)],
  fusion: { k: 60, weights: { vector: 0.7, fts: 0.3 } },
  timeoutMs: 2_000,
});

const { results, degraded } = await engine.search("why does the daemon 503 at startup", { limit: 10 });

Retrievers

A Retriever is { name, retrieve(query, { limit, signal }) } returning ranked Hits. Three ship:

  • ftsRetriever(spans): BM25 over a contentless FTS5 span index. Spans collapse to their owner's best rank, and the winning span's locator travels in the payload. Query text is tokenized and quoted so punctuation cannot break FTS5 syntax.
  • vectorRetriever(embedder, index): embeds the query with embed([query], { role: "query" }) and asks a VectorIndex. It never adds text to the query: prefixes such as nomic's search_query: belong to the embedder (see @titan-design/embed's roles), and a retriever-side prefix would stack on top of the embedder's. BruteForceVectorIndex is an exact in-memory cosine scan; implement the same interface over sqlite-vec when the corpus outgrows it.
  • graphRetriever(edges, seededBy): takes another retriever's top results as seeds and walks the edge table by hop, optionally restricted to relations or outbound direction. expandGraph is the walk on its own.

Fusion and fail-open

fuseByRRF scores each id as the sum over lists of weight / (k + rank), so an id that several retrievers agree on outranks one that tops a single list. k defaults to 60.

gatherFailOpen runs retrievers concurrently. One that throws, or exceeds timeoutMs, contributes nothing and appears in degraded with the reason. A missing embedder or a locked index lowers recall; it never breaks search.

minScore and dropoff (cut at the largest relative score drop) trim the fused list.

Reranking

crossEncoderReranker() runs Xenova/ms-marco-MiniLM-L-6-v2 in-process through @huggingface/transformers, an optional peer dependency loaded on first use. Any object with score(query, texts) works. The engine needs textFor(result) to know what text to show the reranker, since results are ids plus locators, never stored text. A reranker that throws is the same kind of failure: the engine keeps the RRF-fused ranking and reports { retriever: RERANK_STAGE, reason: "error", message } in the same degraded array, so a cross-encoder that runs out of memory costs the reordering and not the answer. textFor throwing degrades the same way.