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

kuzu-memory

v0.2.0

Published

A TypeScript library for semantic memory management in Next.js applications

Readme

Kuzu Memory

A TypeScript library for semantic memory management in Next.js applications. Kuzu Memory provides intelligent storage, retrieval, and management of memories with support for multiple storage backends, pattern extraction, and various recall strategies.

MIT License TypeScript Node.js Test Status UAT Coverage React Next.js Ready Performance

🚀 Production Ready: ✅ 194/206 tests passing | ✅ All storage adapters functional | ✅ Comprehensive UAT suite

Features

  • Multiple Storage Backends: IndexedDB, localStorage, and in-memory storage
  • Smart Recall Strategies: Recency, importance, frequency, similarity, and composite strategies
  • Pattern Extraction: Built-in extractors for emails, URLs, dates, code snippets, and more
  • React Hooks: Ready-to-use hooks for Next.js/React applications
  • Memory Decay: Automatic importance decay over time
  • Type-Safe: Full TypeScript support with comprehensive type definitions
  • Event System: Subscribe to memory events (create, update, delete, access)
  • Embeddings Support: Optional integration with embedding providers for semantic search

Installation

npm install kuzu-memory
# or
yarn add kuzu-memory
# or
pnpm add kuzu-memory

Quick Start

Basic Usage

import { createMemoryClient } from 'kuzu-memory';

// Create a memory client
const memory = await createMemoryClient({
  storage: 'indexeddb',
  dbName: 'my-app-memories',
});

// Store different types of memories
const semantic = await memory.create('I learned about TypeScript generics today', {
  type: 'semantic',
  tags: ['programming', 'typescript'],
  importance: 0.8,
});

const preference = await memory.create('I prefer VS Code over other editors', {
  type: 'preference',
  tags: ['tools', 'editor'],
  importance: 0.6,
});

// Recall memories
const memories = await memory.recall('TypeScript programming concepts', {
  limit: 5,
});

// Query with specific criteria
const results = await memory.query({
  type: 'semantic',
  tags: ['programming'],
  sortBy: 'importance',
  limit: 10,
});

React/Next.js Usage

import { useKuzuMemory, useMemoryQuery, useMemoryMutation } from 'kuzu-memory/hooks';

function MyComponent() {
  // Initialize the memory client
  const { client, isInitialized } = useKuzuMemory({
    storage: 'indexeddb',
    autoInit: true,
  });

  // Query memories
  const { data: memories, isLoading } = useMemoryQuery({
    client,
    query: {
      type: 'semantic',
      limit: 20,
    },
  });

  // Mutations
  const { create, update, remove } = useMemoryMutation({
    client,
    onSuccess: (memory) => console.log('Memory saved:', memory),
  });

  const handleSave = async () => {
    await create('New memory content', {
      tags: ['important'],
      importance: 0.9,
    });
  };

  if (!isInitialized || isLoading) return <div>Loading...</div>;

  return (
    <div>
      {memories?.map(memory => (
        <div key={memory.id}>{memory.content}</div>
      ))}
      <button onClick={handleSave}>Save Memory</button>
    </div>
  );
}

Memory Types

Kuzu Memory supports six different memory types based on cognitive psychology:

  • Episodic: Personal experiences and events
  • Semantic: Facts and general knowledge
  • Procedural: How-to knowledge and skills
  • Working: Temporary, active information
  • Sensory: Immediate sensory impressions
  • Preference: User preferences, settings, and personal choices

Storage Adapters

IndexedDB (Recommended for production)

const memory = await createMemoryClient({
  storage: 'indexeddb',
  dbName: 'my-app',
  version: 1,
});

LocalStorage

const memory = await createMemoryClient({
  storage: 'localStorage',
});

In-Memory (for testing)

const memory = await createMemoryClient({
  storage: 'memory',
});

Recall Strategies

Built-in Strategies

  1. Recency: Prioritizes recently accessed memories
  2. Importance: Based on assigned importance scores
  3. Frequency: Most frequently accessed memories
  4. Similarity: Text or embedding-based similarity matching
  5. Composite: Weighted combination of multiple strategies

Using Custom Strategies

import { createRecallStrategy } from 'kuzu-memory/recall';

const strategy = createRecallStrategy({
  type: 'composite',
  strategies: [
    { type: 'recency', weight: 0.3 },
    { type: 'importance', weight: 0.4 },
    { type: 'similarity', weight: 0.3 },
  ],
});

const memories = await memory.recall('query', { strategy });

Pattern Extraction

Extract structured information from unstructured text:

const patterns = memory.extractPatterns(
  'Contact me at [email protected] or visit https://example.com'
);
// Results include extracted emails, URLs, etc.

// Add custom patterns
memory.addPattern({
  id: 'custom-pattern',
  name: 'Custom Pattern',
  regex: 'your-regex-here',
  priority: 10,
});

Event Subscription

// Subscribe to all events
const unsubscribe = memory.subscribe((event) => {
  switch (event.type) {
    case 'memory:created':
      console.log('New memory:', event.memory);
      break;
    case 'memory:updated':
      console.log('Updated:', event.memory);
      break;
    case 'memory:deleted':
      console.log('Deleted:', event.id);
      break;
  }
});

// Clean up
unsubscribe();

Configuration Options

interface KuzuConfig {
  storage: 'indexeddb' | 'memory' | 'localStorage';
  dbName: string;
  version: number;
  autoSync: boolean;
  syncInterval: number; // milliseconds
  maxMemories: number;
  decayEnabled: boolean;
  decayInterval: number; // milliseconds
  embeddingProvider?: (text: string) => Promise<number[]>;
}

Advanced Features

Embedding Support

Integrate with embedding providers for semantic search:

const memory = await createMemoryClient({
  embeddingProvider: async (text) => {
    // Your embedding logic here
    const response = await fetch('/api/embeddings', {
      method: 'POST',
      body: JSON.stringify({ text }),
    });
    return response.json();
  },
});

Memory Relations

Create knowledge graphs by linking related memories:

const memory1 = await memory.create('TypeScript is a typed superset of JavaScript');
const memory2 = await memory.create('JavaScript is a programming language', {
  relations: [
    {
      targetId: memory1.id,
      type: 'related-to',
      strength: 0.9,
    },
  ],
});

Memory Decay

Automatically decrease importance of memories over time:

const memory = await createMemoryClient({
  decayEnabled: true,
  decayInterval: 86400000, // 24 hours
});

API Reference

Core Methods

  • create(content, metadata?): Store a new memory
  • get(id): Retrieve a specific memory
  • update(id, updates): Update an existing memory
  • delete(id): Remove a memory
  • query(query): Search memories with filters
  • recall(query, options?): Intelligent memory retrieval
  • clear(): Remove all memories
  • getStats(): Get storage statistics

React Hooks

  • useKuzuMemory(options): Initialize memory client
  • useMemoryQuery(options): Query memories reactively
  • useMemoryMutation(options): Create/update/delete operations
  • useMemorySubscription(options): Subscribe to memory events

Testing

Kuzu Memory features a comprehensive test suite with 97+ tests across multiple categories:

Test Suites

# Run all tests (unit + UAT)
make test

# Run specific test suites
make test-uat-storage      # Storage adapter tests (97+ tests)
make test-uat-recall       # Memory recall strategy tests
make test-uat-patterns     # Pattern extraction tests
make test-uat-integration  # Integration tests
make test-uat-performance  # Performance benchmarks
make test-uat-hooks        # React hooks tests

# Test status and coverage
make test-status           # Detailed test suite status
make test-coverage         # Coverage reports

Current Test Status

  • Storage Tests: ✅ 97+ tests passing (Memory, localStorage, IndexedDB adapters)
  • UAT Coverage: ✅ 6 comprehensive test suites
  • Performance: ✅ Meets <100ms operation requirements
  • Production Ready: ✅ Core functionality validated

Development

For detailed development information, see DEVELOPER.md.

# Quick setup
make install        # Install dependencies
make dev           # Development with watch mode
make build         # Build the library
make test          # Run all tests (unit + UAT)
make quality       # All quality checks (type-check, lint, test)

# Or use npm scripts directly
npm install && npm run dev

Documentation

Developer Documentation

License

MIT

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

Support

For issues, feature requests, and questions, please use the GitHub issues page.