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

@askdb/rag

v0.2.0-rc.3

Published

AskDB RAG layer: deterministic chunker over the schema artifact, BYO embedder + vector store (in-memory, file-backed, pgvector), and an optional retriever wired into @askdb/core ask().

Readme

@askdb/rag

Deterministic retrieval over AskDB schema artifacts. @askdb/rag chunks the describable schema, indexes chunks with your embedder and vector store, and returns a retriever you can pass to @askdb/core ask({ retriever }).

Status: pre-1.0. Phase 8 ships BYO embeddings and BYO stores with in-memory, file-backed, and pgvector adapters.

Install

pnpm add @askdb/rag @askdb/core ai
# only if you use the pgvector adapter:
pnpm add pg
# only if you build OpenAI embedding models with the AI SDK yourself:
pnpm add @ai-sdk/openai

ai is a required peer dependency of @askdb/core. For @askdb/rag itself, pg, ai, and @ai-sdk/openai are optional peer dependencies — the chunker, in-memory store, and file store do not require them.

Quickstart

import { ask, loadSchema } from "@askdb/core";
import {
  buildSchemaIndex,
  loadChunkerSourcesFromDir,
  createMemoryStore,
  createAiSdkEmbedder,
} from "@askdb/rag";

const schemaDir = "./fixtures/schemas/orders-users.schema";
const schema = loadSchema(schemaDir);
const sources = loadChunkerSourcesFromDir(schemaDir);

const embedder = async (texts: string[]) =>
  texts.map((text) => [text.length, text.charCodeAt(0) ?? 0]);

const index = await buildSchemaIndex({
  schema: sources,
  embedder,
  store: createMemoryStore(),
  embedderId: "demo:tiny",
});

const { sql } = await ask({
  question: "How much revenue did we make last month?",
  schema,
  model: /* your LanguageModel */,
  retriever: index.retriever,
  totalSchemaChunkCount: index.stats.chunksTotal,
});

CLI

@askdb/rag is a library. The command line for it is askdb rag in the askdb package, which reads rag.* and ai.embedding from askdb.config.*:

npx askdb rag index fixtures/schemas/orders-users.schema --store file
npx askdb rag query fixtures/schemas/orders-users.schema \
  --question "How much revenue did we make last month?"

See the CLI reference for every flag. This package no longer ships an askdb-rag binary.

Public Surface

All exports are available from the root @askdb/rag import. Sub-path imports are also supported and point to the same modules — use whichever style you prefer.

Core

  • chunkSchema, chunkSchemaDir, chunkSchemaBundle — deterministic schema artifact chunking.
  • buildSchemaIndex — chunk, embed, upsert, write schema.lock.json, and return a retriever.
  • createRetriever — bind an existing store and embedder without indexing.

Stores

| Root import | Sub-path import | Description | |---|---|---| | createMemoryStore | @askdb/rag/stores/memory | In-memory cosine store. Zero deps. | | createFileStore | @askdb/rag/stores/file | Binary embedding file + JSON metadata. | | createPgvectorStore | @askdb/rag/stores/pgvector | pgvector adapter with documented setup SQL. Requires pg. Needs dimensions only to create its table; ensureSchema() refuses an existing table of another width with a PgvectorDimensionMismatchError. |

Embedders

| Root import | Sub-path import | Description | |---|---|---| | createAiSdkEmbedder | @askdb/rag/embedders/ai-sdk | Generic AI SDK EmbeddingModel adapter. Requires ai. | | detectEmbeddingDimensions | — | Learns an embedder's vector width by embedding one short text. Use it for a new pgvector table instead of hard-coding a width. | | aiSdkEmbedderId | @askdb/rag/embedders/ai-sdk | The embedderId Studio and askdb rag record for an ai.embedding model (ai-sdk:<provider>:<model>:<dimensions or default>), so an index built by one is accepted by the other. |

Import examples

// Everything from the root — simplest DX
import {
  buildSchemaIndex,
  createMemoryStore,
  createAiSdkEmbedder,
  createPgvectorStore,
} from "@askdb/rag";

// Sub-path imports — same modules, explicit namespacing
import { createMemoryStore } from "@askdb/rag/stores/memory";
import { createFileStore } from "@askdb/rag/stores/file";
import { createPgvectorStore } from "@askdb/rag/stores/pgvector";
import { createAiSdkEmbedder } from "@askdb/rag/embedders/ai-sdk";
// Bring your own embedding model (e.g. from @ai-sdk/openai, or @askdb/ai's createEmbeddingModelFromSection) + createAiSdkEmbedder

Sensitive Fields

Sensitive describable-layer content and sensitive identifiers are excluded from RAG chunks by default. Identifier and type grounding remains in @askdb/core prompt formatting, where sensitive columns are tagged (sensitive) unless the caller explicitly omits sensitive identifiers.

License

Apache-2.0 © Yahya Gilany. See LICENSE and NOTICE.