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

@nicia-ai/typegraph

v0.31.0

Published

TypeScript-first embedded knowledge graph library with ontological reasoning

Readme

@nicia-ai/typegraph

Type-driven embedded knowledge graph for TypeScript.

Installation

npm install @nicia-ai/typegraph zod drizzle-orm better-sqlite3

Quick Start

import { z } from "zod";
import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";

import { createStore, defineEdge, defineGraph, defineNode } from "@nicia-ai/typegraph";
import { createSqliteBackend, generateSqliteMigrationSQL } from "@nicia-ai/typegraph/sqlite";

const Person = defineNode("Person", { schema: z.object({ name: z.string() }) });
const knows = defineEdge("knows");

const graph = defineGraph({
  id: "social",
  nodes: { Person: { type: Person } },
  edges: { knows: { type: knows, from: [Person], to: [Person] } },
});

const sqlite = new Database(":memory:");
const db = drizzle(sqlite);
sqlite.exec(generateSqliteMigrationSQL());

const backend = createSqliteBackend(db);
const store = createStore(graph, backend);

const alice = await store.nodes.Person.create({ name: "Alice" });
const bob = await store.nodes.Person.create({ name: "Bob" });
await store.edges.knows.create(alice, bob);

See the repo README for more.

Examples: github.com/nicia-ai/typegraph/tree/main/packages/typegraph/examples

Graph Merge

TypeGraph ships semantic graph merge as a dedicated subpath:

import { branch, merge } from "@nicia-ai/typegraph/graph-merge";

branch() creates isolated working copies over caller-provided backends, stamped with the base graph's schema and content version. merge() reconciles those branches back into a target graph with deterministic entity resolution, conflict reporting, edge repointing, optional ontology type reconciliation, and provenance reporting.

Use it when several agents, importers, reviewers, or local workers edit graph state independently and the application needs one canonical result instead of an append-only pile of duplicates. The merge pipeline can:

  • resolve duplicate entities by exact unique constraints, blocking keys, fulltext/custom similarity, or vector/hybrid similarity;
  • preserve branch-specific context by repointing edges to canonical nodes;
  • surface property and delete/modify conflicts (for nodes and edges) in a MergeReport, three-way merged against base so disjoint edits compose;
  • expose report-only provenance, with optional sidecar persistence you can query.

merge() is a snapshot merge (all branches forked from the current base); mergeIncremental() additively folds a new source into a target that has already advanced, re-discovering committed entities instead of duplicating them — the primitive for continuous ingestion.

It lives in the core package because the primitive is defined over TypeGraph stores, schemas, indexes, backends, and ontology semantics rather than as a separate product surface.

Docs: Graph Merge

Examples: FHIR Graph Merge · Incremental Merge

Performance Smoke Check

The perf harness lives in @nicia-ai/typegraph-benchmarks; these commands delegate to it.

Run a deterministic SQLite perf sanity suite with guardrails:

pnpm --filter @nicia-ai/typegraph test:perf

Run the same guardrailed suite against PostgreSQL (requires POSTGRES_URL):

POSTGRES_URL=postgresql://typegraph:[email protected]:5432/typegraph_test \
  pnpm --filter @nicia-ai/typegraph test:perf:postgres

For report-only mode (no pass/fail guardrails):

pnpm --filter @nicia-ai/typegraph bench:perf