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

hive-ctx

v1.0.0

Published

Rust core + N-API TypeScript bindings monorepo.

Readme

hive-ctx

Rust core + N-API TypeScript bindings monorepo.

Part of The Hive

hive-ctx is the context engine powering The Hive — a globally distributed AI agent platform.

Layout

  • crates/hive-ctx-core: Rust core compiled to a .node binary via napi-rs
  • packages/bindings: TypeScript bindings wrapping the native addon

Core modules (Rust): graph, memory, fingerprint, classifier, retrieval, pipeline.

Knowledge graph

  • SQLite schema lives inside crates/hive-ctx-core/src/graph.rs (tables: nodes, edges plus indexes).
  • Nodes represent entities (person, place, project, concept, emotion, state) with timestamps and a decay score for emotional/state nodes.
  • Entity extraction for graph_add_node runs regex-driven heuristics on raw text (crates/hive-ctx-core/src/graph.rs) so there are no ML/API dependencies.
  • Edges store typed relationships with timestamps, and traversal discovers neighbors up to N hops while graph_decay_update ages emotional/state nodes over time.
  • Exposed addon APIs: graph_add_node, graph_add_edge, graph_query, graph_traverse, graph_decay_update (via HiveCtxEngine).

Memory store

  • crates/hive-ctx-core/src/memory.rs implements a 3-tier episode archive backed by SQLite (tier1_entries, tier2_summaries, tier3_crystallized) plus memory_meta.
  • Tier 1 holds raw conversations and expires after 24 hours; Tier 2 stores compressed 2-3 sentence summaries retained for 30 days; Tier 3 stores crystallized facts merged into the knowledge graph and never deleted.
  • memory_compress moves Tier 1 → Tier 2 nightly while skipping unchanged text via blake3 hashes; memory_crystallize runs monthly to push Tier 2 summaries into Tier 3, running graph_add_node on the extracted facts.
  • Exposed addon APIs: memory_store, memory_retrieve, memory_compress, memory_crystallize, memory_stats (via HiveCtxEngine).

Retrieval

  • crates/hive-ctx-core/src/retrieval.rs ranks nodes and memory records by combining temporal recency, graph centrality, semantic keyword overlap, and emotional relevance weighted according to the classifier's four axis scores.
  • Results merge knowledge-graph labels and episode-store entries, include token estimates, and can be reranked via retrieval_rank.
  • Exposed addon APIs: retrieval_search, retrieval_rank (via HiveCtxEngine), both accept the four classifier weights so downstream clients pick the most contextually relevant content.

Pipeline

  • crates/hive-ctx-core/src/pipeline.rs orchestrates every module: it classifies the message, fetches retrieval context, compiles the fingerprint, and assembles the final prompt within a configurable token budget (default 300).
  • Layers are trimmed in order (episodes → graph nodes → fingerprint entries) when the budget is exceeded, and warm sessions only send fingerprint deltas thanks to the cached session state.
  • Exposed addon API: pipeline_build (via HiveCtxEngine), which returns the compiled system prompt, actual token usage, and the list of layers that contributed.

TypeScript bindings

  • packages/bindings now exports HiveCtx (constructor config: storagePath, optional budgetTokens, model, profile) plus remember, episode, and plugin integration around the pipeline_build core.
  • Plugin authors implement { name, retrieve(message, weights) } to inject custom retrieval content if tokens remain; context builds append plugin contributions while tracking token usage in the returned ContextResult.
  • Examples under packages/bindings/src/examples (basic.ts, hive-integration.ts) show the minimal usage pattern and how The Hive agent would integrate with the new APIs.

Classifier & fingerprint

  • crates/hive-ctx-core/src/classifier.rs implements a heuristic message classifier that scores each incoming message along temporal, personal, technical, and emotional axes (0.0–1.0) plus a type (casual, question, task, emotional) and session state (COLD_START, WARM, CONTEXT_SHIFT, EMOTIONAL_SHIFT, TASK_MODE).
  • crates/hive-ctx-core/src/fingerprint.rs compiles profile data into a key-value token-efficient fingerprint, tracking deltas since the last compile and automatically expanding into a full compile whenever the classifier reports context shifts, task mode, or a cold start.
  • Exposed addon APIs: classify_message, fingerprint_compile (via HiveCtxEngine) so JS clients can reuse the same session context.

Rust API (exported to Node)

The main exported struct is HiveCtxEngine:

  • new(storage_path: string, budget_tokens?: number)

Development

Build the native addon into packages/bindings/:

npm install
npm run build:native

Build the TypeScript bindings:

npm run build

By default the bindings load packages/bindings/hive_ctx.node. Override with:

HIVE_CTX_NATIVE_PATH=/absolute/path/to/hive_ctx.node node -e "require('./packages/bindings/dist')"

Rust checks

cargo check