返回 Skill 列表
extension
分类: 开发与工程无需 API Key

libstorage

libstorage - 存储抽象层。createStorage工厂根据环境(本地、S3、Supabase)返回后端。LocalStorage、S3Storage和SupabaseStorage实现了存储接口。parseJsonl和serializeJsonl处理JSONL格式。用于文件持久化、数据存储和支持多后端。

person作者: jakexiaohubgithub

libstorage Skill

When to Use

  • Persisting data to filesystem or cloud storage
  • Supporting multiple storage backends
  • Reading/writing JSON and JSONL files
  • Building storage-agnostic applications

Key Concepts

Storage interface: Provides a common API (read, write, list, delete) for all supported storage systems.

createStorage: Factory that returns appropriate backend based on environment configuration.

JSONL support: Parse and serialize newline-delimited JSON for streaming data.

Usage Patterns

Pattern 1: Create storage instance

import { createStorage } from "@copilot-ld/libstorage";

const storage = createStorage(config);
await storage.write("data/file.json", { key: "value" });
const data = await storage.read("data/file.json");

Pattern 2: JSONL operations

import { parseJsonl, serializeJsonl } from "@copilot-ld/libstorage";

const items = parseJsonl(jsonlContent);
const output = serializeJsonl(items);

Integration

Used by all indexes and services. Backend configured via STORAGE environment.