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

@aigne/afs-system-fs

v1.0.5

Published

AIGNE AFS module for local filesystem storage

Readme

@aigne/afs-system-fs

@aigne/afs-system-fs is an AFS module that provides local file system access for AI agents. It allows agents to browse, read, write, and search files in specified directories through the AFS virtual file system interface.

Overview

SystemFS mounts local directories into the AFS virtual file system, enabling AI agents to interact with your local files as if they were part of a unified file system. It provides sandboxed access with powerful search capabilities using ripgrep.

Features

  • Directory Mounting: Mount any local directory at a custom AFS path
  • File Operations: List, read, and write files with full metadata
  • Recursive Listing: Browse directories with configurable depth control
  • Fast Search: Lightning-fast text search using ripgrep
  • Glob Support: Pattern-based file matching
  • Metadata: File size, timestamps, permissions, and type information
  • Sandboxed Access: Operations are restricted to mounted directories
  • AI-Friendly: Designed for seamless AI agent integration

Installation

npm install @aigne/afs-system-fs @aigne/afs
# or
yarn add @aigne/afs-system-fs @aigne/afs
# or
pnpm add @aigne/afs-system-fs @aigne/afs

Quick Start

import { AFS } from "@aigne/afs";
import { SystemFS } from "@aigne/afs-system-fs";

// Create AFS instance
const afs = new AFS({
  storage: { url: "file:./memory.sqlite3" }
});

// Mount a local directory
afs.use(new SystemFS({
  mount: '/docs',                    // AFS mount point
  path: '/path/to/documentation',    // Local directory path
  description: 'Project documentation'  // Description for AI
}));

// List files
const { list } = await afs.list('/docs', { recursive: true });

// Read a file
const { result } = await afs.read('/docs/README.md');
console.log(result.content);

// Search for content
const { list: results } = await afs.search('/docs', 'installation');

// Write a file
await afs.write('/docs/notes.txt', {
  content: 'My notes about the project'
});

Configuration

SystemFSOptions

interface SystemFSOptions {
  mount: string;        // AFS mount path (e.g., '/docs', '/source')
  path: string;         // Local file system path to mount
  description?: string; // Optional description for AI agents
}

Example:

afs.use(new SystemFS({
  mount: '/project',
  path: '/Users/john/my-project',
  description: 'My web application source code'
}));

Operations

list(path, options?)

List files and directories:

const { list, message } = await afs.list('/docs', {
  recursive: true,      // Enable recursive listing
  maxDepth: 3,         // Limit recursion depth
  limit: 50            // Maximum results (capped at 50)
});

// list is an array of AFS entries:
[
  {
    id: '/docs/README.md',
    path: '/docs/README.md',
    createdAt: Date,
    updatedAt: Date,
    metadata: {
      type: 'file',      // 'file' or 'directory'
      size: 1024,        // File size in bytes
      mode: 33188        // Unix file permissions
    }
  },
  ...
]

Options:

  • recursive: Enable recursive directory listing (default: false)
  • maxDepth: Maximum recursion depth when recursive is enabled
  • limit: Maximum number of results (capped at 50)

read(path)

Read file contents and metadata:

const { result } = await afs.read('/docs/README.md');

console.log(result.content);   // File contents as string
console.log(result.metadata);  // File metadata
console.log(result.createdAt); // Creation timestamp
console.log(result.updatedAt); // Last modified timestamp

Returns:

  • result.content: File contents (undefined for directories)
  • result.metadata: File information (type, size, mode)
  • result.createdAt: File creation time
  • result.updatedAt: Last modification time

write(path, content)

Write or update file contents:

const { result } = await afs.write('/docs/notes.txt', {
  content: 'My notes',
  summary: 'Personal notes about the project',
  metadata: { category: 'personal' }
});

Features:

  • Automatically creates parent directories if needed
  • Supports string content directly
  • Supports object content (automatically JSON stringified)
  • Returns the written entry with updated metadata

search(path, query, options?)

Search for files containing specific text:

const { list, message } = await afs.search('/docs', 'authentication', {
  limit: 20
});

// Results include matching files with context
list.forEach(entry => {
  console.log(entry.path);      // File path
  console.log(entry.summary);   // Matching line snippet
});

Features:

  • Uses ripgrep for extremely fast text search
  • Automatically deduplicates results
  • Returns file paths with matching line snippets
  • Respects the limit option (capped at 50)

Options:

  • limit: Maximum number of results (capped at 50)

Integration with AI Agents

SystemFS integrates seamlessly with AIGNE agents:

import { AIAgent, AIGNE } from "@aigne/core";
import { AFS } from "@aigne/afs";
import { SystemFS } from "@aigne/afs-system-fs";
import { OpenAIChatModel } from "@aigne/openai";

// Setup AIGNE
const aigne = new AIGNE({
  model: new OpenAIChatModel({ apiKey: process.env.OPENAI_API_KEY })
});

// Setup AFS with SystemFS
const afs = new AFS({
  storage: { url: "file:./memory.sqlite3" }
});

afs.use(new SystemFS({
  mount: '/codebase',
  path: './src',
  description: 'Application source code'
}));

afs.use(new SystemFS({
  mount: '/docs',
  path: './docs',
  description: 'Project documentation'
}));

// Create agent with AFS access
const agent = AIAgent.from({
  name: "code-assistant",
  instructions: "You are a helpful coding assistant with access to the codebase and documentation",
  afs: afs
});

// Use the agent
const context = aigne.newContext();
const result = await context.invoke(agent, {
  message: "Find all authentication-related files in the codebase"
});

The agent automatically gets these tools:

  • afs_list: Browse directories
  • afs_read: Read file contents
  • afs_write: Create or modify files
  • afs_search: Search for content

Multiple Mounts

You can mount multiple directories at different paths:

// Mount source code
afs.use(new SystemFS({
  mount: '/src',
  path: './src',
  description: 'Application source code'
}));

// Mount tests
afs.use(new SystemFS({
  mount: '/tests',
  path: './tests',
  description: 'Test files'
}));

// Mount configuration
afs.use(new SystemFS({
  mount: '/config',
  path: './config',
  description: 'Configuration files'
}));

// Now agents can access all mounted directories
await afs.list('/src');
await afs.read('/config/app.json');
await afs.search('/tests', 'test suite');

File Metadata

SystemFS provides detailed file metadata:

const { result } = await afs.read('/docs/README.md');

result.metadata = {
  type: 'file',           // 'file' or 'directory'
  size: 2048,            // File size in bytes
  mode: 33188            // Unix permissions (e.g., 0644)
}

result.createdAt  // File creation date
result.updatedAt  // Last modification date

Security Considerations

Sandboxed Access:

  • SystemFS operations are restricted to the mounted directory
  • Cannot access files outside the mounted path
  • Path traversal attempts are prevented by Node.js path operations

Best Practices:

  • Only mount directories that should be accessible to agents
  • Use descriptive mount paths (e.g., /readonly-docs, /workspace)
  • Consider file permissions when mounting sensitive directories
  • Review agent instructions to limit file write operations if needed

Ripgrep Integration

SystemFS uses ripgrep for high-performance text search:

  • Fast: Optimized for searching large codebases
  • Smart Filtering: Automatically ignores binary files
  • Accurate: Provides line-by-line match context
  • Reliable: Mature and widely-used search tool

Examples

See the SystemFS example for a complete working implementation.

TypeScript Support

This package includes full TypeScript type definitions:

import type { SystemFS, SystemFSOptions } from "@aigne/afs-system-fs";

Related Packages

License

Elastic-2.0