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

memories-lite

v0.99.99

Published

A lightweight memory system for LLM agents

Readme

memories-lite

Lightweight memory layer for AI agents — LLM-based extraction, vector embeddings for retrieval, per-user isolation.

Quick Start

import { MemoriesLite } from 'memories-lite';

const memory = new MemoriesLite({
  llm: { provider: 'openai', config: { apiKey: 'KEY', model: 'gpt-5-mini' } },
  embedder: { provider: 'openai', config: { apiKey: 'KEY', model: 'text-embedding-3-small', dimension: 768 } },
  vectorStore: { provider: 'lite', config: { dimension: 768, rootPath: './data' } }
});

const userId = 'user-123';

// Capture a discussion → {title, summary}
await memory.capture(messages, userId, { metadata: { type: 'discussion' } });

// Capture or merge preferences into an existing memory (auto-load by ID)
await memory.captureOrUpdate(messages, userId, {
  existingMemoryId: 'abc-123',          // loads content + title from store
  metadata: { type: 'discussion', applyMode: 'MEM_ALWAYS' }
});

// Retrieve by semantic search
const results = await memory.retrieve('réponses courtes', userId, { filters: { type: 'discussion' } });

// CRUD
await memory.update(memoryId, 'New content', userId, { title: 'New title' });
await memory.delete(memoryId, userId);
const all = await memory.getAll(userId, { type: 'discussion' });

Architecture

Instruction mémorisable

Une instruction mémorisable est une règle de comportement durable liée à l'utilisateur courant, indiquant comment l'assistant doit se comporter au-delà du cas en cours.

Exemples :

  • L'utilisateur souhaite qu'à l'avenir tu le tutoies et que tu répondes toujours en français.
  • L'utilisateur utilise Windows 11 avec PowerShell (pas Linux).

Ce qui n'est pas mémorisable : actions ponctuelles ("envoie un email"), données métier, questions procédurales.

Two Capture Flows

Flow 1: capture() — Discussion → New Memory
─────────────────────────────────────────────
User clicks "Memorize" on a discussion
  └─> capture(messages, userId, { capturePrompt?, metadata })
        └─> LLM → { title, summary }
        └─> createMemory(summary, embed(title))

Flow 2: captureOrUpdate() — Discussion → Create or Merge
──────────────────────────────────────────────────────────
Agent tool or explicit user action
  └─> captureOrUpdate(messages, userId, {
        existingMemoryId?,    // if provided → auto-load + UPDATE (merge)
        metadata
      })
        ├─ if existingMemoryId:
        │    └─> get(existingMemoryId) → { memory, title }
        │    └─> buildCapturePrompt(memory) → merge prompt
        │    └─> LLM → complete merged set
        │    └─> updateMemory() (preserves title + ID)
        └─ else:
             └─> buildCapturePrompt() → capture prompt
             └─> LLM → { title, summary }
             └─> createMemory()

existingMemoryId est prioritaire : le contenu et le titre sont toujours chargés depuis le store.

Memory Apply Modes

| Mode | Injection | Use case | |------|-----------|----------| | MEM_ALWAYS | Automatic, every request | User preferences, permanent instructions | | MEM_SMART | Semantic search match | Discussion syntheses, knowledge patterns | | MEM_MANUAL | Explicit via rules[] | Session-specific rules |

Context Injection Flow

Memories are injected into the agent's system prompt via enrichSystemWithMemory():

enrichSystemWithMemory()
  ├─> getAll(userId, {type: 'discussion'})
  ├─> filter MEM_ALWAYS → globalInstructionsStr
  ├─> filter rules[]    → sessionInstructionsStr
  └─> renderContextInjection(profile, global, session, history)

Produces:
  <instructions>
  GLOBAL:
  L'utilisateur préfère les réponses courtes et structurées.
  L'utilisateur utilise Windows 11 et souhaite des exemples en PowerShell.
  </instructions>

Merge Rules (captureOrUpdate)

When merging new instructions with existing preferences:

| Case | Existing | New discussion | Result | |------|----------|---------------|--------| | Duplicate | "préfère le français" | "parle-moi en français" | Keep existing | | Refinement | "réponses courtes" | "courtes sauf pour les rapports" | Replace with refined | | Contradiction | "tutoiement" | "vouvoie-moi" | Replace with new | | New | (nothing) | "j'utilise macOS" | Add with date |

The LLM returns the complete merged set (not a diff). The title is preserved from the existing memory.

Memory Content Format

3rd person descriptive, grouped by date:

**2025-12-15**
L'utilisateur préfère les réponses courtes et structurées pour les résultats mfiles.
L'utilisateur souhaite que les formats "en gras" soient supprimés lors de la rédaction d'emails.
**2025-11-01**
L'utilisateur utilise Windows 11 et souhaite des exemples en shell.

API

capture(messages, userId, config)

Captures a discussion and generates a new memory with {title, summary}.

captureOrUpdate(messages, userId, config)

Captures and creates a new memory, or merges into an existing one if existingMemoryId is provided. The existing memory is auto-loaded from the store (content + title preserved).

retrieve(query, userId, config)

Semantic search. Returns only MEM_SMART memories.

getAll(userId, config)

List all memories (all apply modes).

get(memoryId, userId)

Get a single memory by ID.

update(memoryId, data, userId, metadata?)

Update memory content directly (no LLM).

delete(memoryId, userId)

Delete a memory.

Prompts

Built-in prompts (customizable via capturePrompt):

  • DEFAULT_DISCUSSION_PROMPT — Synthesis of a discussion into title + summary
  • DEFAULT_CAPTURE_PROMPT — Extraction of memorizable user instructions (3rd person format)
  • DEFAULT_MERGE_RULES — Merge extension with <existing-preferences> injection

Utilities:

  • buildCapturePrompt(existingContent?) — Assembles capture or merge prompt
  • formatExistingPreferences(memories) — Formats memories as date-grouped bullet points

Acknowledgements

Forked from Mem0.

Inspired by: A-MEM, MemoryLLM, Reflexion.