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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aigne/fs-memory

v1.1.3

Published

FS memory for AIGNE framework

Downloads

3,364

Readme

@aigne/fs-memory

GitHub star chart Open Issues codecov NPM Version Elastic-2.0 licensed

File system memory component for AIGNE Framework, providing file system-based memory storage capabilities.

Introduction

@aigne/fs-memory is the file system memory component of AIGNE Framework, providing local file system-based memory storage and retrieval functionality. This component stores memories as YAML files in specified directories, providing a simple and reliable memory persistence solution.

Features

  • File System Storage: Uses local file system for memory file storage
  • YAML Format: Uses YAML format for memory storage, making it easy to read and edit
  • Directory Management: Automatically creates and manages memory directory structure
  • Path Support: Supports absolute paths, relative paths, and home directory (~) expansion
  • AI Agent Management: Uses AI agents to handle memory recording and retrieval
  • TypeScript Support: Complete type definitions providing an excellent development experience

Installation

Using npm

npm install @aigne/fs-memory

Using yarn

yarn add @aigne/fs-memory

Using pnpm

pnpm add @aigne/fs-memory

Basic Usage

import { AIAgent, AIGNE } from "@aigne/core";
import { FSMemory } from "@aigne/fs-memory";
import { OpenAIChatModel } from "@aigne/openai";

// Create AI model instance
const model = new OpenAIChatModel({
  apiKey: process.env.OPENAI_API_KEY,
  model: "gpt-4-turbo",
});

// Create file system memory
const memory = new FSMemory({
  rootDir: "./memories",
});

// Create AI agent with file-based memory
const agent = AIAgent.from({
  name: "FileAssistant",
  instructions: "You are a helpful assistant with file-based memory.",
  memory: memory,
  inputKey: "message",
});

// Use AIGNE execution engine
const aigne = new AIGNE({ model });

// Invoke agent
const userAgent = await aigne.invoke(agent);

// Send message
const response = await userAgent.invoke({
  message: "Remember that I prefer working in the morning",
});

console.log(response.message);

// Query memory
const response2 = await userAgent.invoke({
  message: "What do you know about my work preferences?",
});

console.log(response2.message);

Advanced Configuration

Custom Memory Directory

import { join } from "node:path";
import { FSMemory } from "@aigne/fs-memory";

// Using absolute path
const memory1 = new FSMemory({
  rootDir: "/absolute/path/to/memories",
});

// Using relative path
const memory2 = new FSMemory({
  rootDir: "./data/memories",
});

// Using home directory
const memory3 = new FSMemory({
  rootDir: "~/my-app/memories",
});

// Using dynamic path
const memory4 = new FSMemory({
  rootDir: join(process.cwd(), "memories"),
});

Configure Memory Agent Options

const memory = new FSMemory({
  rootDir: "./memories",
  // Custom memory retriever agent configuration
  retrieverOptions: {
    name: "CustomRetriever",
    instructions: "Custom retrieval instructions for file-based memory",
  },
  // Custom memory recorder agent configuration
  recorderOptions: {
    name: "CustomRecorder",
    instructions: "Custom recording instructions for file-based memory",
  },
  // Other agent configurations
  autoUpdate: true,
});

Using Multiple Memory Types Together

import { DefaultMemory } from "@aigne/default-memory";
import { FSMemory } from "@aigne/fs-memory";

// Combine multiple memory types
const agent = AIAgent.from({
  name: "MultiMemoryAgent",
  instructions: "You are an assistant with multiple memory types.",
  memory: [
    // Database memory for structured data
    new DefaultMemory({
      storage: {
        url: "file:memory.db",
      },
    }),
    // File system memory for long-term storage
    new FSMemory({
      rootDir: "./long-term-memories",
    }),
  ],
  inputKey: "message",
});

Memory File Structure

FSMemory creates the following structure in the specified directory:

memories/
├── conversation-id-1/
│   └── memory.yaml
├── conversation-id-2/
│   └── memory.yaml
└── ...

Each memory file contains YAML-formatted memory data:

- id: memory-id-1
  content: "User prefers working in the morning"
  timestamp: 2024-01-01T10:00:00Z
  metadata:
    type: "preference"

- id: memory-id-2
  content: "User is a software developer"
  timestamp: 2024-01-01T10:05:00Z
  metadata:
    type: "personal_info"

License

Elastic-2.0