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

@synerity/memory-graph

v0.1.0

Published

Zero-dependency in-memory knowledge graph for LLM context management

Readme

@synerity/memory-graph

Zero-dependency TypeScript knowledge graphs for LLM context management. Store facts as nodes, link them with typed edges, then retrieve only the most relevant subset under a token budget — no vector database required.

Works in Node.js 18+ and modern browsers. Dual CJS + ESM. No React dependency.

Installation

npm install @synerity/memory-graph

Usage

Chatbot session memory

import { MemoryGraph } from '@synerity/memory-graph'

const memory = new MemoryGraph({ maxNodes: 200 })

memory.add('User prefers dark mode',              { tags: ['preference'], importance: 0.9 })
memory.add('Asked about billing on 2026-05-01',   { tags: ['billing'] })
memory.add('Subscription: Pro, renews 2026-06-01', { tags: ['billing'], importance: 1.0 })

// Inject only what's relevant, within a token budget
const context = memory.toContext({
  prompt:    'user asking about invoice',
  maxTokens: 400,
  format:    'markdown',
})

Agent workspace with typed edges

const workspace = new MemoryGraph()

const task = workspace.add('Refactor auth module',          { importance: 1.0 })
const obs  = workspace.add('JWT secret hardcoded line 42')
const dec  = workspace.add('Move secret to env variable')

workspace.relate(task.id, obs.id, 'depends_on')
workspace.relate(obs.id,  dec.id, 'causes')

// Serialize between agent turns
const snapshot = workspace.serialize()
const restored = MemoryGraph.deserialize(snapshot)

Custom tokenizer

import { encode } from 'gpt-tokenizer'

graph.setTokenizer((text) => encode(text).length)
// toContext() now uses exact token counts

API

// Nodes
graph.add(content, meta?)       → MemoryNode
graph.update(id, patch)         → MemoryNode
graph.remove(id)                → void
graph.nodes()                   → MemoryNode[]

// Edges
graph.relate(from, to, type, weight?)  → MemoryEdge
graph.unrelate(from, to, type?)        → void
graph.neighbors(id, depth?)            → MemoryNode[]

// Query
graph.query(prompt, opts?)      → MemoryNode[]
graph.toContext(opts?)          → string   // packed under maxTokens
graph.estimateTokens(text?)     → number

// Persistence
graph.serialize()               → string   // JSON
MemoryGraph.deserialize(json)   → MemoryGraph

// Pruning
graph.prune(opts)               → { removed: number }
// opts: { maxNodes?, maxAge?, minImportance?, strategy: 'lru'|'fifo'|'importance' }

Edge types

Built-in: relates_to · contradicts · depends_on · follows · part_of · causes

Any string is valid for custom edge types.

License

MIT © Synerity Labs