55144d0e4a
Adds Store.listMeta() and Store.listSchemas() to expose meta-schema discovery, backed by an in-memory metaSet (memory store) and a persistent _index/_meta file (FS store). Surfaces both via new json-cas list-meta and list-schema CLI commands wrapped in @output/list-meta and @output/list-schema envelope schemas. The FS store migrates from existing nodes when _meta is absent (scanning self-referencing nodes) and preserves _meta on subsequent opens. delete() removes affected hashes from the meta index and persists the change. Closes #90 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@uncaged/json-cas-fs
Filesystem-backed CAS store.
Overview
@uncaged/json-cas-fs implements a persistent Store on disk. Each node is stored as <hash>.bin (CBOR-encoded CasNode). A _index/ directory maps type hashes to content hashes for listByType. Stores support bootstrap via the same BOOTSTRAP_STORE symbol as the in-memory implementation.
Depends on @uncaged/json-cas for hashing, CBOR encoding, and types.
Dependencies: @uncaged/json-cas, cborg
Installation
bun add @uncaged/json-cas-fs
API
Exported from src/index.ts:
function createFsStore(dir: string): BootstrapCapableStore;
Returns a BootstrapCapableStore from @uncaged/json-cas. The store loads existing .bin files on open and migrates or builds the type index on first use.
Example
import { bootstrap, putSchema } from "@uncaged/json-cas";
import { createFsStore } from "@uncaged/json-cas-fs";
const store = createFsStore("./my-cas-store");
await bootstrap(store);
const typeHash = await putSchema(store, {
type: "object",
properties: { id: { type: "string" } },
required: ["id"],
additionalProperties: false,
});
const hash = await store.put(typeHash, { id: "item-1" });
console.log(store.has(hash)); // true after restart if same dir
On-disk layout
my-cas-store/
├── <hash>.bin # CBOR CasNode
├── _index/
│ └── <typeHash> # newline-separated content hashes
└── ...
Writes use atomic rename (<hash>.tmp → <hash>.bin).
Internal Structure
| File | Purpose |
|---|---|
store.ts |
createFsStore, load/save nodes and type index |
index.ts |
Public export |
store.test.ts |
Filesystem store tests |