fedify Main Island

The Vocabulary Sutra Repository

ja· en· ko
If you're new hereA dictionary of the federated world's shared language—post, follow, like.

You speak the shared language of federation as types. Build a Note or a Follow as an ordinary object, and it becomes valid JSON-LD that crosses the sea. Misspell something and the build tells you; your editor's autocomplete stands in for the spec.

And this sutra is not handwritten. From one YAML sheet per word, the code is copied out by generation—sutra-copying exists here as a real build step, not a metaphor. The dictionary carries every real-world dialect too, toot: and misskey: and the rest. The language of federation is a living language.

Highlights

  • The source of the sutra is packages/vocab/src/*.yaml. It declares name/uri/extends/defaultContext/properties and is inspected against vocab-tools' schema.yaml.
  • The sutra-copying desk is codegen.ts—with an mkdir lock and an mtime freshness check, it won't re-bake what hasn't changed.
  • The generator's parts are class.ts/codec.ts/constructor.ts/property.ts. The classes, the encoder/decoder, the clone, the inspector—all of it is generated.
  • The runtime footing is a separate package, @fedify/vocab-runtime (which bundles jsonld).

A passage from the sutra

export default async function generateVocab(
  schemaDir: string,
  generatedPath: string,
): Promise<void> {
  const types = await loadSchemaFiles(schemaDir);
  const encoder = new TextEncoder();

  const file = await open(generatedPath, "w");
  const writer = file.createWriteStream();

  for await (const code of generateClasses(types)) {
    writer.write(encoder.encode(code));
  }
packages/vocab-tools/src/generate.ts L5-L18— Reading the spec and copying out the types—the hands of the sutra-copyist

Try it yourself

This is the actual shape your words take when they cross the sea (Create + Note). The yellow glow marks what just changed.

Floor plan

packages/vocab/src/note.yaml
One source sheet of the sutra: uri, extends, and a defaultContext with real-world dialects in it
packages/vocab/scripts/codegen.ts
The sutra-copying desk, with a lock and a freshness check
packages/vocab-tools/src/generate.ts
generateVocab(): reads the YAML and writes out the classes
packages/vocab-tools/src/class.ts
generateClasses() and the family tree of types (sortTopologically)

Neighboring rooms

Outside links