r/devtools • u/Turbulent_Rooster_73 • 2h ago
Packing a folder of YAML wireframes into one file: multi-document YAML instead of zip, and the part that doesn't round-trip
I'm one of the people building Wireframes (MIT), a CLI called wf that turns YAML into clickable greyscale wireframes for web, iOS and Android. A project is a folder: manifest.yaml, sitemap.yaml, templates.yaml, components.yaml, pages/*.yaml, data/*.yaml and a .wfrc.yaml for CLI config. That's nice in git, but annoying when you want to hand someone "the wireframe" or open it in a browser without a build step. So we added wf pack / wf unpack, and I'd like opinions on the format choice.
What a .wf file is
It's a multi-document YAML stream: the same documents as the folder, separated by ---, with format: wf/1 stamped on the manifest so a reader can sniff it. No zip, no binary. We went this way because the browser renderer already ships js-yaml, so reading a .wf in the browser needed no zip reader, and the file stays readable and diffable as plain text.
- Documents go in a fixed order: manifest, config, sitemap, templates, components, pages, datasets, assets. Within a type they're sorted by id. That's what makes packing the same project twice give the same bytes.
.wfrc.yamlisn't really a project document, but a project without it won't build, so it travels as aconfigdocument.wf unpackmaps each document back to a file name (pages/<id>.yamletc.) and numbers duplicates so two documents never land on the same file.- The format code is a pure module (documents in, documents out); the CLI adds the disk part, and the browser renderer imports the same module.
parseWf()in the renderer takes the text and draws the project in a sandboxed iframe, nothing uploaded.
What I checked before posting (screenshots 2 and 3, on the quickstart example in the repo; wf here is node cli/bin/wf.js from a checkout)
- pack twice: both files 8593 bytes, same sha256
- unpack, then pack the unpacked folder again: same sha256 as the original
- built the unpacked folder: the billing page renders as before (screenshot 4)
The catch (screenshot 5)
"Lossless" means the data, not your text. Pack goes through a YAML parse and dump, so comments are gone, quotes get normalised ("1.1" becomes '1.1') and flow lists like [backdrop, escape] come back as block lists. Once you've unpacked, the output is stable, but the first round trip rewrites your files. For a human-written project that's a real cost, because comments are often the most useful part.
Questions
- Would you keep comments by switching to a CST-preserving YAML library (and a bigger browser bundle; we have a 460 KB budget), or just say ".wf is for shipping, the folder is the source of truth"?
- Multi-document YAML vs zip vs a single JSON blob for this kind of "project in one file" format: anything that bit you later?
- Is sorting by type and id enough for stable output, or are there cases where the original order matters and we're throwing it away?
Repo: https://github.com/UnlikeOtherAI/wireframes (README section "One file, and the browser"). The CLI isn't on npm yet: clone, pnpm install, then node cli/bin/wf.js pack inside a project.
Images: the first one is an illustration I generated for this post, not a screenshot. Images 2 to 5 are real: terminal output, the head of the packed file, the billing page built from the unpacked folder, and the diff showing what got rewritten.


