markdownfs (TypeScript)¶
TypeScript / JavaScript client for MarkdownFS — a versioned virtual filesystem for markdown, designed for AI agents.
Install¶
Requires Node 18+ (uses native fetch). Works in modern browsers.
Quickstart¶
import { MarkdownFS } from "markdownfs";
const mdfs = new MarkdownFS({
baseUrl: "https://you-markdownfs.hf.space",
token: process.env.MDFS_TOKEN, // or: username: "alice"
});
await mdfs.fs.write("notes/idea.md", "# my idea\n");
const text = await mdfs.fs.read("notes/idea.md");
const list = await mdfs.fs.list("notes");
const hits = await mdfs.search.grep("TODO", { path: "notes" });
const { hash } = await mdfs.vcs.commit("snapshot");
const { commits } = await mdfs.vcs.log();
await mdfs.vcs.revert(hash);
API¶
Constructor¶
new MarkdownFS({
baseUrl: string; // required
token?: string; // Bearer token
username?: string; // alternative auth (User <name>)
fetch?: typeof fetch; // override (e.g. for testing)
headers?: Record<string, string>;
})
Top level¶
health()→ server statuslogin(username)→ session info
fs¶
read(path)→ stringreadBytes(path)→ Uint8Arraylist(path?)→{ entries, path }stat(path)→ metadatawrite(path, content)— content is string or Uint8Array; parents auto-createdmkdir(path)— recursiveremove(path, { recursive? })copy(src, dst)/move(src, dst)tree(path?)→ tree text
search¶
grep(pattern, { path?, recursive? })→{ results, count }find({ path?, name? })→{ results, count }
vcs¶
commit(message)→{ hash, message, author }log()→{ commits }revert(hash)status()→ status text
Errors¶
All non-2xx responses throw MarkdownFSError with status and parsed body.
License¶
MIT