witforge

WIT-first contract compiler for stable Rust, protobuf, JSON Schema, and versioned adapters

View the Project on GitHub asamarts/witforge

Generation

Commands

witforge rust wit --out generated/rust
witforge proto wit --out generated/proto
witforge schema wit --out generated/schema
witforge glue wit --out generated/glue \
  --plain-root crate::plain \
  --proto-root crate::proto

--plain-root and --proto-root are Rust module paths used by generated glue. They are not filesystem paths.

Configuration

version = 1

[project.example]
root = "wit"

[project.example.rust]
out = "generated/rust"
serde = true

[project.example.proto]
out = "generated/proto"

[project.example.schema]
out = "generated/schema"

[project.example.glue]
out = "generated/glue"
plain-root = "crate::plain"
proto-root = "crate::proto"

Then run:

witforge rust --config witforge.toml
witforge proto --config witforge.toml
witforge schema --config witforge.toml
witforge glue --config witforge.toml

Output ownership

Each emitter needs its own output directory. witforge only overwrites or removes files that start with its generated header, and the Rust, protobuf, and glue emitters write the same header: in a shared directory each removes the others’ files as stale output. It refuses symlinks, directories, and unowned files at expected output paths.

Every generator supports --check, which writes nothing and fails on missing, changed, or extra generated files.

Inspect the result

The generated-output guide shows current Rust, protobuf, JSON Schema, glue, and version-adapter output from the committed runnable examples. The full files are checked with --check in this repository’s CI.