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

@godspeedai/cognate-cognitive-memory

v0.11.0

Published

In-process exact-cosine CognitiveIndex and a deterministic hashing embedder; the fallback implementation for core cognition.

Readme

@godspeedai/cognate-cognitive-memory

The dependency-free fallback for Cognate semantic recall: an in-process CognitiveIndex with exact cosine similarity, plus a deterministic hashing embedder. Nothing to install, no network, no native code.

When to use this package: tests, small datasets, and offline development — or as the correctness baseline other index implementations are compared against. For large corpora or durable vector files, use @godspeedai/cognate-cognitive-ruvector or @godspeedai/cognate-cognitive-rvf instead.

Installation

bun add @godspeedai/cognate-cognitive-memory

Requires Bun >= 1.4.0. The SDK ships Bun-native TypeScript source, so add @types/bun and @types/node as dev dependencies when typechecking your project.

Quick start

import { createMemoryIndex, hashingEmbedder } from "@godspeedai/cognate-cognitive-memory";

const dimension = 8;
const index = createMemoryIndex({ dimension }); // id defaults to "memory"
const embedder = hashingEmbedder(dimension);

const [vector] = await embedder.embed(["Refunds are approved by a manager."]);
await index.upsert([{
  id: "doc-1",
  sourceType: "knowledge",
  sourceRef: "knowledge:refund-policy", // the route back to authoritative content
  tenant: "tenant-a",
  scopeId: "root",
  semanticRef: null,
  eventRef: null,
  traceRef: null,
  embedding: vector!,
  metadata: { title: "Refund policy" }, // non-sensitive metadata only
  relationships: [],                    // e.g. [{ type: "about", target: "doc-2" }]
  validFrom: new Date().toISOString(),
  validTo: null,
  indexerVersion: "1",
  durable: true,
}]);

const [query] = await embedder.embed(["who approves refunds?"]);
const hits = await index.similar({ vector: query!, k: 3, tenant: "tenant-a" });
// [{ id: "doc-1", score: ... }] — highest similarity first

console.log(await index.count()); // 1
await index.close();

Behavior

  • Filtering. similar always filters by tenant, and by scopeIds when the query provides them — another tenant's entries are never returned.
  • Graph traversal. The index declares graph_traversal: related(id, { types?, depth }) walks relationships breadth-first, in discovery order, without duplicates, excluding the start id. It also declares temporal_search (validity windows are carried on entries).
  • Safety. Upserting an entry whose embedding has the wrong dimension throws before anything is stored. Entries and embeddings are copied on the way in and out, so mutating a result never corrupts the index.
  • The embedder. hashingEmbedder(dimension) lowercases, tokenizes on non-alphanumerics, feature-hashes tokens into dimension signed buckets, and L2-normalizes. It is deterministic and instant, but not semantic: it captures token overlap, not meaning. Empty text embeds to the zero vector. Swap in a real embedder (same Embedder interface) for quality.

Limitations

  • In-process only. State lives in a Map; everything is gone when the process exits. Rebuild from your event store via the indexer projection of @godspeedai/cognate-cognitive-api.
  • Exact search. Similarity scans every entry — O(n) per query. Fine for thousands of entries, not for millions.
  • Use a real embedding model for production recall; the hashing embedder is for tests and bootstrapping.

Related packages

License

Apache-2.0