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

@kb-labs/adapters-fs

v2.94.0

Published

Filesystem adapter implementing IStorage interface

Readme

@kb-labs/adapters-fs

Part of KB Labs ecosystem. Works exclusively within KB Labs platform.

Filesystem storage adapter for local file operations with path security and glob pattern support.

Overview

| Property | Value | |----------|-------| | Implements | IStorage | | Type | core | | Requires | None | | Category | Storage |

Features

  • Path Security - Sandboxed file access within configured base directory
  • Streaming Support - Efficient large file handling with streams
  • Glob Patterns - Find files using glob patterns
  • Metadata Access - Get file stats, size, modification time

Installation

pnpm add @kb-labs/adapters-fs

Configuration

Add to your kb.config.json:

{
  "platform": {
    "adapters": {
      "storage": "@kb-labs/adapters-fs"
    },
    "adapterOptions": {
      "storage": {
        "baseDir": ".kb/data"
      }
    }
  }
}

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | baseDir | string | process.cwd() | Base directory for all file operations |

Usage

Via Platform (Recommended)

import { usePlatform } from '@kb-labs/sdk';

const platform = usePlatform();

// Read file
const content = await platform.storage.read('config.json');

// Write file
await platform.storage.write('output.txt', 'Hello, World!');

// List files with glob
const files = await platform.storage.glob('**/*.ts');

Standalone (Testing/Development)

import { createAdapter } from '@kb-labs/adapters-fs';

const storage = createAdapter({ baseDir: '/path/to/data' });

await storage.write('test.txt', 'content');
const content = await storage.read('test.txt');

How It Works

┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Client    │────▶│  FS Adapter │────▶│ File System │
└─────────────┘     └─────────────┘     └─────────────┘
                          │
                    Path Validation
                    (stays in baseDir)

The adapter validates all paths to ensure they stay within the configured baseDir, preventing path traversal attacks (e.g., ../../../etc/passwd).

Adapter Manifest

{
  id: 'fs-storage',
  name: 'Filesystem Storage',
  version: '1.0.0',
  implements: 'IStorage',
  capabilities: {
    streaming: true,
    custom: {
      glob: true,
      metadata: true,
    },
  },
}

Performance Considerations

  • Memory: Uses streams for large files to avoid memory issues
  • Latency: Depends on disk I/O, SSD recommended for production
  • Throughput: Limited by disk speed and OS file system cache

FAQ

No. This adapter is designed specifically for KB Labs ecosystem and depends on platform interfaces and contracts. Use createAdapter() for standalone testing only.

The adapter automatically validates all paths. Any attempt to access files outside baseDir will throw an error. You don't need to do anything extra.

No. All paths are relative to baseDir. This is by design for security.

Related Adapters

| Adapter | Use Case | |---------|----------| | @kb-labs/adapters-analytics-file | File-based analytics storage |

Troubleshooting

Error: EACCES permission denied

Cause: The process doesn't have write permissions to the target directory.

Solution: Check directory permissions or choose a different baseDir:

chmod 755 /path/to/your/baseDir

Error: Path outside base directory

Cause: Attempted to access a file outside the sandboxed baseDir.

Solution: Use relative paths only. Don't use .. to escape the directory.

Contributing

See CONTRIBUTING.md for development guidelines.

License

KB Public License v1.1 - KB Labs Team