atproto_codegen
Alpha. Pre-1.0 and evolving alongside at-record; expect breaking changes between 0.x releases.
Generate Gleam types and JSON codecs from atproto lexicon
files: records and objects with string/integer/number/boolean/array/ref/
cid-link/bytes/blob/unknown fields. Unsupported defs (e.g. union) are
reported and skipped, never emitted wrong.
Usage
gleam run -m atproto_codegen -- <lexicons_dir> <out_dir> <out_module> <nsid_prefix>[,<nsid_prefix>...]
# e.g.
gleam run -m atproto_codegen -- ./lexicons ./src/my_app/gen my_app/gen com.example.myapp.,com.atproto.
lexicons_diris walked recursively for*.jsonlexicon files. Vendor any external lexicons you reference (e.g.com.atproto.repo.strongRef) into it.out_moduleis the module prefix the generated code imports itself under; it must match whereout_dirsits in yoursrc/.nsid_prefixesare stripped from NSIDs when deriving module paths, socom.example.myapp.shelf.entryemits<out_dir>/shelf/entry.gleam.
Generated blob fields use atproto/blob from the
atproto_client package, so projects consuming generated
code with blobs need that dependency.
Lexicon coverage
record and object defs. Refs resolve across lexicons (a bare NSID ref
points at that lexicon's main def). knownValues string sets map to plain
String; unknown round-trips through a Dynamic passthrough.