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

@pixygon/knowledge-server

v0.1.2

Published

Storage + extraction + chunking + semantic search engine for any text knowledge. Used by @pixygon/chatbot-server for RAG; can also back a wiki/codex search layer.

Readme

@pixygon/knowledge-server

Storage + extraction + chunking + semantic search for any text knowledge.

+--------------------+      +-------------------------+
|  Host Express app  |----->|     engine.router       |
|  (your auth here)  |      +-------------------------+
+--------------------+               |
                                     v
  KnowledgeDocument · KnowledgeChunk · extractors · embedder · search

Used by:

  • @pixygon/chatbot-server — calls engine.search() from the RAG pipeline
  • (planned) Codex / wiki — calls engine.upsertExternal() on entry save to keep an embedding index in sync with the rich domain model

What it does

  • Documents. Operator pastes text, uploads PDF/DOCX/XLSX/CSV/TXT/MD, points at a URL (scraped once + embedded), or points at a URL marked live (re-fetched at query time).
  • Extraction. pdf-parse, mammoth, xlsx, @mozilla/readability + jsdom cover the common ingest paths.
  • Chunking. Paragraph-aware splitter producing ~2 KB chunks with 400-char overlap.
  • Embedding. Whatever AI client the host passes — text in, vector out.
  • Search. Cosine-similarity top-K over the embedding index, namespace-scoped.
  • Namespaces. Multiple knowledge silos per tenant (chatbot, codex, wiki, help-center, …) — search defaults to one namespace at a time, but cross-namespace queries are explicit.
  • External refs. A knowledge document can be linked back to a host-domain entity (a codex LoreEntity, an LMS Lesson, etc.). engine.upsertExternal() keeps the index in sync as the host model changes.

Install

npm install @pixygon/knowledge-server

Peer expectations:

  • express ≥ 5
  • mongoose ≥ 8
  • Node ≥ 22

Usage

import mongoose from "mongoose";
import { createKnowledge } from "@pixygon/knowledge-server";

// Any object matching { embed(text), chat?({ messages, system }) } works.
// `@pixygon/chatbot-server`'s `createAiClient` returns this shape.
const ai = {
  async embed(text: string) {
    const e = await myEmbeddingClient.embed(text);
    return { embedding: e.vector, tokens: e.tokens };
  },
  async chat({ messages, system }: any) {
    const r = await myChatClient.chat({ messages, system });
    return { content: r.text };
  },
};

const knowledge = createKnowledge({
  mongoose,
  ai,
  tenantField: "tenantId",
  tenantRefName: "Tenant",
  defaultNamespace: "default",
  plugins: [
    (schema, label) => schema.plugin(tenantScopedPlugin, { tenantField: "tenantId", label }),
    (schema, label) => schema.plugin(auditLogPlugin, { entityType: label }),
  ],
});

// Mount the default HTTP router under whatever path the host owns.
app.use("/v1/tenants/:tenantId", verifyToken, tenantAccess, knowledge.router);

// Programmatic search — used by RAG pipelines, codex search, etc.
const hits = await knowledge.search({
  tenantId, query: "fall protection rules", namespace: "chatbot", k: 5,
});

// Codex-style external sync. Idempotent — upsert by (namespace, externalRef).
await knowledge.upsertExternal({
  tenantId,
  namespace: "codex",
  externalModelName: "LoreEntity",
  externalId: loreEntity._id,
  title: loreEntity.name,
  content: loreEntity.description,
  source: `codex/${loreEntity.slug}`,
  tags: loreEntity.tags,
});

HTTP surface

Default router (engine.router):

GET    /knowledge                  ?namespace=&sourceType=
GET    /knowledge/search           ?q=&namespace=&k=
GET    /knowledge/:id
POST   /knowledge                  text       { title, content, source?, namespace?, tags? }
POST   /knowledge/upload           multipart  file, title?, namespace?, tags?
POST   /knowledge/from-url         json       { url, title?, namespace?, extractInstruction?, isLive?, liveDescription?, tags? }
PUT    /knowledge/:id              { title?, content?, source?, tags?, namespace? }
DELETE /knowledge/:id

Companion package

@pixygon/knowledge-react ships the operator UI (list, tabbed upload dialog, RTK Query hooks) — see its README for the React wire-up.

License

MIT.