catmint-fs

A TypeScript monorepo providing a copy-on-write virtual filesystem with pluggable adapters and a pure-TypeScript git implementation built on top of it.

Architecture

@catmint-fs/core              Virtual filesystem layer (adapters + copy-on-write)
    |
    +-- LocalAdapter           Node.js fs-backed adapter (built in)
    |
    +-- @catmint-fs/sqlite-adapter   SQLite-backed adapter
    |
    +-- @catmint-fs/git        Git operations over any Layer
         |
         +-- @catmint-fs/git-auth-node   Node.js credential helpers

Packages

PackageDescriptionPlatform
@catmint-fs/coreVirtual filesystem layer with copy-on-write semantics over a pluggable backing storeNode.js + Browser
@catmint-fs/gitProgrammatic git operations (init, commit, branch, merge, diff, stash, fetch, push, clone)Node.js + Browser
@catmint-fs/sqlite-adapterSQLite-backed FsAdapter for @catmint-fs/coreNode.js only
@catmint-fs/git-auth-nodeCredential helper integration for @catmint-fs/gitNode.js only

Browser Compatibility

@catmint-fs/core and @catmint-fs/git are browser-safe. They use Uint8Array instead of Buffer, ReadableStream instead of Node streams, Web Crypto for SHA-1, and fetch() for HTTP. LocalAdapter and @catmint-fs/sqlite-adapter are Node.js only.

ComponentNode.jsBrowser
@catmint-fs/core (Layer API + FsAdapter interface)YesYes
@catmint-fs/core (LocalAdapter)YesNo
@catmint-fs/sqlite-adapterYesNo
@catmint-fs/gitYesYes
@catmint-fs/git (HTTP transport)YesYes
@catmint-fs/git-auth-nodeYesNo

Quick Start

In-memory git repo

import { createLayer } from "@catmint-fs/core";
import { SqliteAdapter } from "@catmint-fs/sqlite-adapter";
import { initRepository } from "@catmint-fs/git";

const adapter = new SqliteAdapter({ database: ":memory:" });
const layer = await createLayer({ root: "/", adapter });

const repo = await initRepository(layer);
await layer.writeFile("/readme.txt", "Hello\n");
await repo.add("/readme.txt");
await repo.commit({ message: "first commit" });

const log = await repo.log();
console.log(log[0].message); // "first commit"

Local disk git repo

import { createLayer } from "@catmint-fs/core";
import { initRepository } from "@catmint-fs/git";

const layer = await createLayer({ root: "/tmp/my-repo" });
const repo = await initRepository(layer);
// Works with the standard git CLI

Getting Started