···11-you're working on a TypeSpec emitter for atproto lexicons. you have these commands: `pnpm run build` builds the example (you can inspect the generated lexicons in the `packages/example/lexicon`) and `pnpm test` runs tests (they are in `packages/emitter/test/`).
11+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.
2233-what i want you to do is to gradually keep adding features to typelex so that in the end it's possible to express all Lexicon code with that language. you have the following resources:
33+you have the following resources you're encouraged to explore on your own whenever they seem relevant to the task:
4455-- read `DOCS.md`!!! it's the main guideline
55+- `DOCS.md` is 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.
66+- `../atproto-website/` has a Lexicon spec (look for `lexicon/en.mdx`) which you'll want to consult
77+- `../typespec/` is the TypeSpec repo. you can consult the source code of other emitters (in `packages`, e.g. `packages/protobuf` and `packages/json-schema`) and `website` folder for documentation of TypeSpec syntax and idioms.
6877-- `../typespec/packages` has a bunch of other emitters (so you can check how they're implemented and common patterns)
99+as a part of your workflow, you will:
81099-- `../typespec/website/src/content` has typescpec docs (which you might find very useful)
1111+- run `pnpm test` whenever you make changes to verify no regressions. note a few test suites: an `atproto` test suite with definitions from upstream (`.tsp` files produce expected `.json` files), `lexicon-examples` suite with third party lexicons, and `spec` with a more focused suite. use checked-in `*.tsp` files liberally to learn typelex conventions. we have a LOT of them!
10121111-- `../atproto-website/src/app/[locale]/specs/lexicon` contains lexicon spec (where we want to reach feature parity), and most importantly
1313+- if you're working on `packages/example`, use `pnpm run build` to run it and observe the output. you may also want to look at codegen output (it's hooked up to atproto codegen).
12141313-- `test/scenarios/atproto/output` contains a TON of lexicon definitions which i want you to translate to typespec one by one. for each atproto lexicon you're porting, your job is to create the corresponding "`input`s" for them (and fix bugs or add missing features along the way).
1515+- we also have a playground in `packages/playground` and website in `packages/website`.
14161515-the goal is to end up with a language that feels nice and concise, not some weird interop thing. so try to do things "typespec" way as you go through each lexicon. and try to respect atproto too. this should feel like a *language for atproto*. consider whether your design is elegant. and make sure to look at other typespec emitters for design ideas!
1616-1717-remember NOT to change the output to fit the input -- your job is to make the input MATCH the output. if some lexicon is too hard, you can give up on it and try another one. good luck!
1818-1919-the workflow is: pick some new lexicons, create the input files, figure out missing features / bugs, and try to get tests to pass. repeat. when you make nontrivial progress, you'll want to prepare a commit.
2020-2121-before you want to make a commit, make sure `pnpm test` and `pnpm run build` passes and, ideally, inspect the `example` app output (and maybe add the features you've just implemented there for parity). then stop and notify me.
2222-2323-ps. be mindful of the code style. we only put decorators on same line if it's `@required` alone; otherwise, put each on newline and add a newline after. see existing files for a hint.
1717+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.
24182519good luck! i believe in you
26202727-2828----
2929-3030-whenever you get stuck (try `npm test`) because you don't have a convention for how to define some pattern yetm i want you to read these sources
3131-3232- - `../typespec/packages` has a bunch of other emitters (so you can check how they're implemented and common patterns)
3333-3434- - `../typespec/website/src/content` has typescpec docs (which you might find very useful)
3535-3636- - `../atproto-website/src/app/[locale]/specs/lexicon` contains lexicon spec
3737-3838- and ultrathink about what's the most appropriate way to define defs like you want would be in this typespec translation of atproto. you can research these sources for what feels most idiomatic to define that syntax, and how to make
3939- the formatter understand that convention and emit the JSON we want.
4040-4141- also note that you can always look at generated atproto lexicons in ../atproto/lexicons -- use these!! look at the TS types there for corresponding
4242- models to inspire how you represent things in tsp syntax.
4343-4444- - read `DOCS.md`!!! it's the main guideline2121+and read the `DOCS.md` (and `*.tsp` files in this repo)!!! they're your most important sources of information.