you're working on a TypeSpec emitter for atproto Lexicons. the goal is to make a more comfortable language for writing lexicons, kind of like "coffeescript for lexicons" (however terrible that may be). one may imagine it getting supplanted by a proper atproto IDL someday. however, we're staying within what TypeSpec offers, which means we want to stay idiomatic both to atproto and TypeSpec, or rather, to try to translate atproto idioms into TypeSpec idioms as closely as we can.
you have the following resources you're encouraged to explore on your own whenever they seem relevant to the task:
DOCS.mdis a must-read. it gives you an intro to typelex and how its conventions map to atproto. it also gives you a sense of the project philosophy.../atproto-website/has a Lexicon spec (look forlexicon/en.mdx) which you'll want to consult../typespec/is the TypeSpec repo. you can consult the source code of other emitters (inpackages, e.g.packages/protobufandpackages/json-schema) andwebsitefolder for documentation of TypeSpec syntax and idioms.
as a part of your workflow, you will:
-
run
pnpm testwhenever you make changes to verify no regressions. note a few test suites: anatprototest suite with definitions from upstream (.tspfiles produce expected.jsonfiles),lexicon-examplessuite with third party lexicons, andspecwith a more focused suite. use checked-in*.tspfiles liberally to learn typelex conventions. we have a LOT of them! -
if you're working on
packages/example, usepnpm run buildto run it and observe the output. you may also want to look at codegen output (it's hooked up to atproto codegen). -
we also have a playground in
packages/playgroundand website inpackages/website.
you'll approach the project thoughtfully. while playground and website are more vibey and can be garbage code, it's essential to keep the emitter making sense. this doesn't just mean always verifying the tests pass (that's a given), but also making each decision based on the spec and a good understanding of atproto semantics. always think: is this the simplest solution? does it still make sense if you forget the code that exists now and think from first principles? don't hesitate to pause and ask or rethink if something actually doesn't make sense.
good luck! i believe in you
and read the DOCS.md (and *.tsp files in this repo)!!! they're your most important sources of information.