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

@meldscience/context-manager

v0.1.0

Published

Context management system for AI agents

Downloads

12

Readme

@meldscience/context-manager

Context management system for AI agents, optimized for small-scale use with Claude. Maintains relevant context across conversations through priority-based selection and tag organization.

Important Note on Scale

This module is designed for small-scale use (single human user with multiple Claude agents) and optimizes for reliability and user experience rather than performance or scale.

Intended Scale:

  • Single human user
  • Small number of Claude agents
  • Modest database size
  • Non-critical response times

Installation

npm install @meldscience/context-manager

Prerequisites

  • Node.js 16+
  • PostgreSQL 12+

Quick Start

  1. Set up your database:
# Create the database
createdb my_context_db

# Set environment variable
export DATABASE_URL="postgresql://user:password@localhost:5432/my_context_db"
  1. Initialize the context manager:
import { createContextManager } from '@meldscience/context-manager';

const manager = await createContextManager({
  database: {
    url: process.env.DATABASE_URL
  },
  selection: {
    maxEntries: 50,
    minPriority: 3
  },
  priority: {
    baseWeight: 0.6,
    userWeight: 0.4
  }
});
  1. Basic usage:
// Add context
const contextId = await manager.addContext('Important architectural decision', {
  tags: ['architecture', 'decision'],
  priority: 4
});

// Update priority
await manager.updatePriority({
  contextId,
  userId: 'user1',
  priority: 5
});

// Get active context
const context = await manager.getActiveContext({
  minPriority: 3,
  tags: ['architecture']
});

Core Features

Priority Management

  • Priority scale: 1-5
  • User priority signals
  • Automatic priority calculation
  • Priority-based selection

Tag Organization

  • Group related context
  • Filter by tags
  • Tag-based retrieval
  • Automatic tag maintenance

Context Selection

  • Priority-based filtering
  • Tag-based filtering
  • Recency consideration
  • Automatic pruning

Integration Examples

Discord Bot Integration

import { DiscordBot } from 'discord.js';
import { createContextManager } from '@meldscience/context-manager';

const bot = new DiscordBot();
const manager = await createContextManager(config);

// Store message as context
bot.on('messageCreate', async (message) => {
  if (message.author.bot) return;
  
  await manager.addContext(message.content, {
    tags: ['discord', message.channel.name],
    metadata: {
      channelId: message.channel.id,
      authorId: message.author.id
    }
  });
});

// Handle priority reactions
bot.on('messageReactionAdd', async (reaction, user) => {
  const priority = getPriorityFromEmoji(reaction.emoji);
  if (priority) {
    await manager.updatePriority({
      contextId: reaction.message.id,
      userId: user.id,
      priority
    });
  }
});

Claude Integration

import { Claude } from '@anthropic-ai/sdk';
import { createContextManager } from '@meldscience/context-manager';

const claude = new Claude();
const manager = await createContextManager(config);

async function getResponse(prompt: string) {
  // Get relevant context
  const context = await manager.getActiveContext({
    minPriority: 3,
    tags: ['architecture', 'decisions']
  });
  
  // Format context for Claude
  const contextString = formatContextForClaude(context);
  
  // Get response
  const response = await claude.complete({
    prompt: contextString + prompt
  });
  
  // Store response as context
  await manager.addContext(response, {
    tags: ['claude-response'],
    metadata: { prompt }
  });
  
  return response;
}

Event System

Subscribe to system events:

// Priority updates
manager.on('priorityUpdated', (event) => {
  console.log(`Priority changed for ${event.contextId}`);
});

// Selection changes
manager.on('selectionUpdated', (event) => {
  console.log('Active context changed');
});

Configuration

interface ContextManagerConfig {
  // Database settings
  database: {
    url: string;
    poolSize?: number;
  };
  
  // Selection settings
  selection: {
    maxEntries: number;
    minPriority?: number;
    maxAgeHours?: number;
  };
  
  // Priority settings
  priority: {
    baseWeight: number;
    userWeight: number;
  };
}

Error Handling

import { ContextManagerError } from '@meldscience/context-manager';

try {
  await manager.addContext('...');
} catch (error) {
  if (error instanceof ContextManagerError) {
    console.error('Context manager error:', error.message);
  }
}

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT