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

agent-dream

v0.1.0

Published

Framework-agnostic memory consolidation cycle for AI agents. BYOLLM — bring your own LLM.

Downloads

11

Readme

agent-dream

A framework-agnostic memory consolidation cycle for AI agents. Bring your own LLM.


Install

npm install agent-dream

Quick Start

const { dream } = require('agent-dream');

const result = await dream({
  memoryFile: './memory.md',
  logsDir:    './logs',
  stateFile:  './state.json',
  consolidate: async (longTermMemory, newLogs) => {
    const entries = newLogs.map(l => `## ${l.date}\n${l.content}`).join('\n\n');
    return longTermMemory ? `${longTermMemory}\n\n${entries}` : entries;
  },
});

console.log(`Processed: ${result.processed}, Skipped: ${result.skipped}`);

How It Works

dream() runs a four-phase cycle that reads daily log files, consolidates them into long-term memory, and tracks what has already been processed.

Orient → Gather → Consolidate → Prune

| Phase | What it does | |-------|-------------| | Orient | Reads the memory file, state file, and log directory. Determines which daily log files are new (unprocessed). | | Gather | Reads the content of each unprocessed log file into memory as { filename, date, content } objects. | | Consolidate | Calls your consolidate(longTermMemory, newLogs) function. You decide what to do with your LLM. | | Prune | Writes the updated memory back to disk and records the processed file names in the state file. |


Config Reference

Pass a single config object to dream():

| Option | Type | Required | Description | |--------|------|----------|-------------| | memoryFile | string | ✅ | Path to the long-term memory file (markdown). Created if it doesn't exist. | | logsDir | string | ✅ | Directory containing daily log files named YYYY-MM-DD.md. | | stateFile | string | ✅ | Path to a JSON file tracking which logs have been processed. Created if it doesn't exist. | | consolidate | async (memory, logs) => string | ✅ | Your consolidation function. Receives current memory and new logs; must return updated memory as a string. | | onPhase | (event) => void | ❌ | Called at the start and end of each phase. See Events. | | onDone | (result) => void | ❌ | Called when the dream cycle completes successfully. | | onError | (err) => void | ❌ | Called if the dream cycle throws. |


Return Value

dream() returns a Promise that resolves to:

{
  processed: number,   // number of new log files consolidated
  skipped:   number,   // number of already-processed files skipped
  newMemory: string,   // the updated long-term memory content
  state: {             // the updated state written to stateFile
    lastDream:              string,   // ISO timestamp
    dailyFilesProcessed:    string[], // all files ever processed
    version:                number,
  }
}

Events

onPhase

Fired at the start and end of each phase:

{
  name:      'orient' | 'gather' | 'consolidate' | 'prune',
  status:    'start' | 'done',
  meta:      object | null,  // phase-specific details (e.g. file counts)
  timestamp: string,         // ISO timestamp
}

onDone

Fired with the same object that dream() resolves to (see Return Value).

onError

Fired with the Error that caused the cycle to fail.


CLI Usage

npx agent-dream \
  --memory ./memory.md \
  --logs   ./logs \
  --state  ./state.json \
  --consolidator ./my-consolidator.js

The --consolidator module must export a function:

// my-consolidator.js
module.exports = async function consolidate(longTermMemory, newLogs) {
  // Call your LLM here, or do simple text processing
  const entries = newLogs.map(l => `## ${l.date}\n${l.content}`).join('\n\n');
  return longTermMemory ? `${longTermMemory}\n\n${entries}` : entries;
};

The CLI accepts three export shapes: module.exports = fn, module.exports.consolidate = fn, or module.exports.default = fn.


Individual Phase Exports

For power users who want to run phases individually:

const { orient, gather, consolidate, prune } = require('agent-dream');

// Run orient manually
const { state, longTermMemory, unprocessedFiles } = await orient({
  memoryFile, logsDir, stateFile,
});

// Gather only specific files
const newLogs = await gather({ logsDir, unprocessedFiles });

// Consolidate with your own function
const updatedMemory = await consolidate({
  longTermMemory,
  newLogs,
  consolidateFn: async (mem, logs) => { /* ... */ },
});

// Write memory and update state
const newState = await prune({
  memoryFile, stateFile, updatedMemory, state, processedFiles: unprocessedFiles,
});

Contributing

  1. Fork the repo and create a feature branch.
  2. npm test must pass (uses Jest).
  3. Keep the zero-runtime-dependency policy — no new dependencies in package.json.
  4. Open a PR with a clear description of what changed and why.

License

MIT