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

@humanlayer/yjs-fs

v0.0.81

Published

A transport-neutral, CRDT-backed virtual filesystem for collaborative coding agents, built on [Yjs](https://github.com/yjs/yjs). A single `Y.Doc` stores a full directory namespace (files, directories, stable ids) plus per-file text/binary content, comment

Downloads

3,154

Readme

@humanlayer/yjs-fs

A transport-neutral, CRDT-backed virtual filesystem for collaborative coding agents, built on Yjs. A single Y.Doc stores a full directory namespace (files, directories, stable ids) plus per-file text/binary content, comments, and live-cursor presence — so multiple agents/humans can read and edit the same tree concurrently and converge automatically, with no server-side merge logic required. It is the storage layer underneath @humanlayer/agentlayer-yjs-fs (and its -justbash/-secure-exec variants), which adapt it to agentlayer-core's tool interfaces.

Install

bun add @humanlayer/yjs-fs yjs y-protocols

yjs, y-protocols, and lib0 are peer dependencies — bring your own Yjs version and sync provider (e.g. y-websocket, @durable-streams/y-durable-streams).

Usage

import { YjsFilesystem } from '@humanlayer/yjs-fs'

const fs = new YjsFilesystem() // wraps a fresh Y.Doc by default

fs.mkdir('/workspace')
fs.createFile('/workspace/notes.txt', 'hello world')

fs.readFile('/workspace/notes.txt') // 'hello world'
fs.editFile('/workspace/notes.txt', 'world', 'yjs') // unique substring replace
fs.rename('/workspace/notes.txt', '/workspace/renamed.txt')
fs.list('/workspace') // EntryDirent[]
fs.unlink('/workspace/renamed.txt')

For a shared/provider-backed doc, connect and sync the provider before constructing YjsFilesystem — construction initializes catalog state for empty docs, which can race with remote hydration otherwise:

await provider.connect()
await waitForProviderSync(provider)
const fs = new YjsFilesystem({ doc: provider.doc, awareness })

Two independent docs converge with plain Yjs updates:

import * as Y from 'yjs'

Y.applyUpdate(doc2, Y.encodeStateAsUpdate(doc1))

Key exports

  • YjsFilesystem — the path-oriented facade: lookup, stat, list, tree, exists, subscribe/subscribePath, mkdir, createFile/createBinaryFile, readFile/readBinaryFile, writeFile/writeBinaryFile, editFile (unique substring replace, returns EditResult), getYTextForFile/getYText (raw Y.Text for editor bindings), rename, unlink, plus comment (addComment, getComments, replyToComment, resolveComment) and presence (setLocalPresence, updateLocalPresence, setLocalSelection, getLocalSelection) methods.
  • CatalogStore, ContentStore, CommentStore, PresenceStore — the lower-level stores YjsFilesystem composes; exported for callers that need direct access.
  • Types: EntryId, ContentId, EntryType, DirectoryEntry, FileEntry, EntryMetadata, LookupResult, EntryDirent, FilesystemTreeNode, EntryStat, EditResult, CommentAnchor, CommentReply, FileComment.
  • Errors (all extend YjsFsError with a .code): AlreadyExistsError, EntryNotFoundError, InvalidPathError, NotDirectoryError, NotFileError, NotBinaryFileError, NotTextFileError, DirectoryNotEmptyError, RootMutationError.
  • @humanlayer/yjs-fs/presence subpath — standalone awareness helpers (getLocalPresenceState, setLocalPresenceState, updateLocalPresenceState, setLocalSelection, getLocalSelection, resolveLocalSelectionState, colorFromId) usable without a YjsFilesystem instance.

Architecture

The catalog (namespace metadata) and file content are stored as separate, independently syncable structures in the same Y.Doc, linked by stable contentIds. This keeps directory listings cheap (no need to load file bodies) and lets renames/moves preserve identity without touching content.

flowchart LR
    subgraph "Y.Doc"
        Catalog["catalog: entries / children / pathIndex maps"]
        Files["files: Y.Map contentId -> Y.Text | Y.Array (binary)"]
    end
    YFS["YjsFilesystem facade"] --> CatalogStore --> Catalog
    YFS --> ContentStore --> Files
    YFS --> CommentStore --> Files
    YFS --> PresenceStore --> Awareness["y-protocols Awareness (optional)"]
    Catalog -- "contentId" --> Files

Testing notes

test/property/*.property.test.ts use fast-check to fuzz catalog commands and assert multi-replica convergence after arbitrary sync interleavings — the strongest guarantee this package makes is CRDT convergence, not any particular last-writer-wins ordering. test/learning/* are exploratory specs against raw Yjs/y-durable-streams APIs, not package surface tests.