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

reason-state

v0.5.5

Published

Governed long-term memory for agents. **Token-budgeted context** + **drift control when facts change** (explicit `retract()` + `heal()`), with deterministic replay/audit. Works **keyless** in retrieve-only mode.

Readme

reason-state

Governed long-term memory for agents. Token-budgeted context + drift control when facts change (explicit retract() + heal()), with deterministic replay/audit. Works keyless in retrieve-only mode.

Use it like a note-taking logger: add facts → retrieve governed context. If you need to update/retract later, give that fact a stable key (optional).

Proof (fast to verify)

  • Update/retraction proof pack (keyless): docs/proof-pack.md (npm run bench:proofpack)
  • Recall-style evals (key-gated): docs/benchmarks.md (LoCoMo/LongMemEval runners)

Try it in 60 seconds

npm install reason-state

Drop into any OpenAI-style messages[] loop

import { ReasonState } from "reason-state";
import { injectMemoryContext } from "reason-state/integrations/openai";

const rs = new ReasonState({
  apiKey: process.env.OPENAI_API_KEY, // optional
  model: "gpt-4o-mini",               // optional
  maxTokens: 2500,                    // ~10k chars budget
});

// Zero-friction: just add text (we generate an id)
await rs.add("User hates meetings on Friday");

// Recommended for anything you may update/retract later: provide a stable key.
await rs.add("User hates meetings on Friday", { key: "user:pref:no_friday_meetings", type: "fact" });

const goal = "When should we schedule the retro?";
const messages = [{ role: "user", content: goal }];

// Keyless-safe retrieve-only (no LLM): inject governed context into your messages[]
const { messages: withMemory, stats } = await injectMemoryContext(rs, messages, { goal });
// Pass `withMemory` to your model call.
console.log("ROI stats:", stats); // { estTokens, contextChars, unknownCount, dirtyCount, blockedCount, ... }

// Plan (default): builds context, calls your model, applies patches (requires a key)
const { patches } = await rs.plan(goal);

// Explicit governance (no hidden recompute)
await rs.retract("user:pref:no_friday_meetings"); // retract by stable key (blocked + dirty)
await rs.heal();                           // resolves contradictions + reconciles
await rs.rollback("subtree-root-node-id"); // subtree rollback (optional)

Try it with your own logs (no code)

npx reason-state audit path/to/trace.json
# writes: path/to/trace.reason-state.json (Studio-importable)

Demo (1 command)

npm run demo

CLI demo: ingests a few facts, shows balanced retrieval-only context, and if an API key is present runs one planner turn. Works without keys (planner step skipped).

Why teams adopt it

  • Lower cost / smaller prompts: governed, token-budgeted context with measurable ROI (stats).
  • Drift control: retract + heal when facts change (no prompt spaghetti).
  • Debuggable memory: deterministic replay + explicit governance signals (unknown/dirty/blocked).

How it compares (high level)

| Capability | Prompt hacking | mem0/Letta-style memory | reason-state | |---|---:|---:|---:| | Drop-in to messages[] | ✅ | ✅ | ✅ | | Keyless try-now path | ✅ | ✅ | ✅ | | Token-budgeted context | ⚠️ | ✅ | ✅ | | Retraction + heal as first-class | ❌ | ⚠️ | ✅ | | Deterministic replay/audit | ❌ | ⚠️ | ✅ |

Benchmarks

  • Benchmarks + methodology: docs/benchmarks.md
  • Retraction/update proof pack (recommended): docs/proof-pack.md

Docs (short links)

  • Adoption guide: docs/adoption.md
  • Audit CLI (npx reason-state audit ...): docs/audit-cli.md
  • HTTP service: docs/http-service.md
  • Keys/tests matrix: docs/keys-and-tests.md
  • Hybrid retrieval (optional vector hook): docs/hybrid-retrieval.md
  • Studio: docs/ui-studio.md
  • Context builder reference: docs/context-builder.md
  • System prompt reference: docs/system-prompt.md

Advanced imports

  • Advanced engine: import { ReasonStateAdvanced } from \"reason-state/engine\"