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

@jeffs-brain/memory-postgres

v0.1.0

Published

Postgres and pgvector adapter for @jeffs-brain/memory: tsvector BM25, halfvec cosine, and RRF hybrid retrieval.

Readme

@jeffs-brain/memory-postgres

Postgres adapter for @jeffs-brain/memory. Provides a Postgres-backed Store, a hybrid search index (tsvector BM25 plus halfvec cosine with RRF fusion), and a retriever factory that wires them together. Kept as a separate optional package so the core OSS surface has zero hard dependency on the postgres driver. Pull this in when running a high-scale or managed-cloud backend.

This adapter ships for TypeScript only at v0.1.0. The Go and Python SDKs do not yet have a Postgres adapter; if you need cross-SDK parity, stick to the core stores (FsStore, MemStore, GitStore, HttpStore) for now.

Install

npm i @jeffs-brain/memory @jeffs-brain/memory-postgres
# or
bun add @jeffs-brain/memory @jeffs-brain/memory-postgres

The package requires Postgres 15 or later with the vector (pgvector) extension enabled. The shipped schema includes both the default 1024-dim halfvec path and an optional 3072-dim profile; pass vectorDim: 3072 when creating the search index or retriever if your embeddings use the larger schema column.

Usage

import postgres from 'postgres'
import {
  createPostgresStore,
  createPostgresSearchIndex,
  createPostgresRetriever,
} from '@jeffs-brain/memory-postgres'

const sql = postgres(process.env.DATABASE_URL!)

const store = await createPostgresStore({
  sql,
  tenantId: process.env.TENANT_ID!,
  brainId: process.env.BRAIN_ID!,
})

const index = createPostgresSearchIndex({
  sql,
  tenantId: process.env.TENANT_ID!,
  brainId: process.env.BRAIN_ID!,
  vectorDim: 3072,
})

const retriever = createPostgresRetriever({
  pg: sql,
  tenantId: process.env.TENANT_ID!,
  brainId: process.env.BRAIN_ID!,
  vectorDim: 3072,
  env: process.env,
})

const hits = await retriever.retrieve({
  query: 'which database did we pick?',
  limit: 5,
})

tenantId and brainId must be UUIDs; the adapter enforces this at construction time and pins app.tenant_id per transaction so Row Level Security policies stay honoured. vectorDim selects the schema profile for both the search index and retriever. Embedding lengths are validated against the selected profile before any insert or vector query runs.

Migrations

SQL migrations live in migrations/. Apply them in order with your preferred runner (drizzle-kit, psql -f, Atlas, Flyway).

Feature support

  • Postgres Store implementation matching the spec/STORAGE.md contract.
  • Hybrid index: tsvector BM25 plus halfvec cosine fused with Reciprocal Rank Fusion at k=60, with runtime selection between the 1024-dim and 3072-dim embedding columns.
  • createPostgresRetriever returns a retriever compatible with the cross-SDK spec/PROTOCOL.md ask and search endpoints.

Documentation

  • Postgres store guide: https://docs.jeffsbrain.com/guides/stores/
  • TypeScript getting started: https://docs.jeffsbrain.com/getting-started/typescript/
  • Protocol and storage spec: spec/

License

Apache-2.0. See LICENSE and NOTICE.