Runnable examples
The repository contains three runnable examples with committed generated output.
Single version
Section titled “Single version”examples/single exercises:
- one contract version;
witforge.toml;- Rust, protobuf, JSON Schema, and glue generation;
- committed output checked by every generator’s
--checkmode.
git clone https://github.com/zeropier/witforge.gitcd witforge/examples/singlewitforge check wit/v0.1witforge rust --config witforge.tomlwitforge proto --config witforge.tomlwitforge schema --config witforge.tomlwitforge glue --config witforge.tomlThe exact generated files are under
examples/single/generated.
The generated-output guide walks through representative sections.
Evolved contract
Section titled “Evolved contract”examples/evolved contains released v0.1 and draft v0.2. It demonstrates lock continuity, diff, release freezing, and generated version adapters.
cd witforge/examples/evolvedwitforge check wit/v0.2 --against wit/v0.1/wire.lockwitforge diff wit/v0.1 wit/v0.2witforge rust --config witforge.tomlThe example adds defaultable fields. Version-adapter generation accepts them, but diff --check
still reports a source/generated-API break. Use plain diff to review the example; add --check
when project policy forbids those changes.
Polyglot contract
Section titled “Polyglot contract”examples/polyglot contains
released v0.1 and draft v0.2 (adding priority: option<u8> on item), configuring protobuf
file options alongside all five built-in non-Rust ecosystems in one
witforge.toml:
- protobuf with Go, Java, and C# placement options (
generated/proto); - TypeScript strict ESM plain types,
convert.ts, and@bufbuild/protobufglue (generated/ts,generated/ts-glue); - Python 3.11+ stdlib plain types,
convert.py, andgoogle.protobufglue (generated/py,generated/py_glue); - Go 1.22+ stdlib plain packages,
convert/, andgoogle.golang.org/protobufglue (generated/go,generated/go-glue); - Java 21+ records and sealed interfaces,
Convert.java, andcom.google.protobufglue (generated/java,generated/java-glue); - C# 12+ / .NET 8+ records,
Convert.cs, andGoogle.Protobufglue (generated/csharp,generated/csharp-glue).
cd witforge/examples/polyglotwitforge check witwitforge generate --config witforge.toml --checkwitforge generate --config witforge.toml --only proto,ts,ts-glue --checkThe committed outputs live under
examples/polyglot/generated,
and the generated-output guide shows line-verified
excerpts for every language.
Plugin starter kits
Section titled “Plugin starter kits”examples/plugin-starters
contains zero-dependency protocol_version = 1 emitter plugin starter kits in Rust, TypeScript
(Node.js 20+), and Python 3.11+ that read Contract IR v1 from stdin and agree byte-for-byte on
output and diagnostics under witforge plugin starter.
Generated output is committed for review and checked for drift in CI (or run
witforge generate --config witforge.toml --check to verify every configured emitter in one step).
You can also run witforge inspect wit --json to inspect any example’s versioned contract IR,
or witforge doc wit --out preview-doc to preview generated Markdown contract reference pages.
Run any generator without --check to update committed files, review the diff, then run the same
command with --check.