A recipe app on the AT Protocol. Recipes are Cooklang text. A private recipe lives in a
permissioned-data space on the user's PDS when the PDS supports spaces, and in the app's D1 until
it does (decided 2026-11-23, §4). A published
recipe is a public record in the user's repo from day one; only the user's own recipes (no
source) can be published (§8). The app is an offline-first SvelteKit
PWA on Cloudflare Workers at yeschef.at, sharing its sign-in and session design with ~/projects/rider.
Status: design draft, 2026-11-22. Decisions marked (spike) wait on the spike named. The issues
are in bug ls, under the roadmap issue a0443c7.
┌──────────────── the user's browser ────────────────┐
recipe site ──────┤ capture: bookmarklet / iOS Shortcut / paste │
(logged in, e.g. │ └─ page HTML + URL, taken with the user's cookies│
NYT Cooking) │ │
│ PWA (SvelteKit, client-only app routes) │
│ ├─ IndexedDB: the whole library, prefs, outbox │
│ ├─ @cooklang/cooklang (WASM): parse for render │
│ ├─ packages/recipe: scale, units, rounding │
│ └─ service worker: shell precache, image cache │
└──────────────┬─────────────────────────────────────┘
│ same-origin JSON API (sid cookie)
┌──────────────▼────────────────┐
│ web Worker (SvelteKit) │──▶ AI fallback for conversion
│ /api/recipes, /api/import, │ (Workers AI or Claude Haiku)
│ public recipe pages (SSR) │
└──┬─────────────┬──────────────┘
service │ │ service binding
binding ▼ ▼
┌───────────────────┐ ┌─────────────────────────────┐
│ core Worker │ │ D1 + R2 (fallback) │
│ /oauth/* │ │ private recipes, collections│
│ SessionDO / DID │ │ and photos, keyed by DID │
└────────┬──────────┘ └─────────────────────────────┘
│ DPoP-bound OAuth (+ space credentials)
▼
user's PDS ── public repo: published recipes, public collections
└── personal space: private recipes, collections, photos
Private records go to the user's personal space when their PDS supports spaces (decided
2026-11-23, after S5). Bluesky's PDSes don't yet; the owner moves to a self-hosted PDS with
spaces, and anyone else on one can use the app. Whether a PDS supports spaces is read from the
granted OAuth scope (§3). Without it, private records live in D1 (text) and R2 (photos), in the
exact lexicon record shape, and move into the space on the first sign-in that grants it. Public
recipes are written straight to the user's repo. Workers also keep sessions (SessionDO) and a
small D1 index: DIDs, preferences, capture tokens.
HTML is parsed in a Worker. The TypeScript recipe-scrapers runs in the web Worker (§7), so
no separate scrape Worker is needed unless spike S2 finds a problem.
The device keeps a full copy of the library. A collection of hundreds of recipes is a few
MB of text, so the PWA syncs all of it to IndexedDB, not just pages already visited. Offline then
covers every recipe, not only the cached ones (§6).
Credentials are used where they are. Logged-in pages are captured in the user's browser.
Parsing happens wherever it runs best, which the spikes decide. HTML is plain data, so capturing
a page and parsing it don't need to happen in the same place.
apps/web SvelteKit 3 + adapter-cloudflare: PWA, API routes, public pages
apps/core plain Worker: OAuth (copied from rider apps/core), SessionDO, D1 migrations
packages/recipe pure TS, no I/O: RecipeDraft, ingredient-line parser, Cooklang emitter,
validator, quantities (scale/convert/round). Most unit tests live here.
packages/lexicons lexicon JSON + generated types/validators (@atcute/lex-cli); `at.yeschef.*` (§4)
spikes/* throwaway, each its own pnpm root (as in rider); findings go on the spike's bug
testdata/ Copy Me That export: 53 recipes, 749 ingredient lines (the conversion corpus)
Tooling follows rider: devenv + devkit, pnpm with minimumReleaseAge, Justfile (check,
dev, deploy via the secrets vault), Tangled CI, bug for issues.
Copy apps/core/src/{oauth,session-do,redirect-shim,cookies}.ts from rider. They carry the
decisions that spike 2 there proved:
@atproto/oauth-client with WebCrypto, confidential client (2-year sessions on bsky.social).
One SessionDO per DID serialises refresh-token rotation (a replayed refresh token kills the
session on bsky.social). All PDS and space traffic goes through it.
Extractable DPoP keys; narrow scopes, later a published permission set (include:…).
Who can sign in (proposed 2026-11-23, owner to confirm): anyone whose grant includes the
space permission, because their private data stays on their own PDS. Without it, only
ALLOWED_DIDS (core's vars) get a session, since their recipes would sit in our D1; anyone
else's grant is revoked at the callback and nothing of theirs is kept. Rider's waitlist was left
out.
Spaces in the session (S5, spikes/spaces-pds). The scope is
atproto include:at.yeschef.auth blob:image/*. The permission set at.yeschef.auth (19b635f)
grants the at.yeschef.library space with key self, both record collections and manage=create,
plus repo: for the public collections; permission sets drop blob: permissions, hence the
separate blob:image/*. A PDS without spaces drops the space permission silently (bsky.social
granted only atproto, and its consent screen didn't mention it), so the granted scope says
whether the user is on spaces. A grant never grows on refresh: a user whose PDS gains spaces
later is offered a re-authorization (signal: #atproto_kem appears in their DID document).
The user's own session reads and writes the space directly, background work included: the
SessionDO holds and refreshes the tokens, so a scheduled job needs no user present. Space
credentials (getDelegationToken → authorizeSpaceSync with a key the DO keeps; requests carry
the credential, an HTTP message signature and a MAC request against the space authority's
#atproto_kem key) are for reading someone else's space as a member, i.e. sharing: 757c5e9.
personal space at://<did>/space/at.yeschef.library/self (personalspace policy) · fallback: D1 records row
repo collection at.yeschef.recipe, original recipes only (no source, §8)
collection
personal space · fallback: D1
repo, only once a public recipe references it
image
space blob · fallback: R2 blobs/<did>/<cid>
repo blob
A recipe lives in exactly one place. Publishing moves it: write the public record, then
delete the private copy. Unpublishing moves it back. Two diverging copies would be worse.
Spaces are alpha, and the app tracks them. The spec and SDK still change
(bluesky-social/atproto#5187, the permissioned-data branch, published to npm under alpha),
so the space side follows the newest alpha and absorbs breaking changes as they land. D1 remains
the private store for users whose PDS has no spaces. Everything goes through one interface:
swapCid is compare-and-swap on the record's CID (null = create only), for the offline outbox.
Library (apps/web lib/server/store) puts the stores together for the /api routes: new records
are private, and a D1 table public_records(did, collection, rkey), kept by publish and
unpublish, says which live in the repo. So private reads and writes never wait on the PDS.
The D1 schema is records(did, collection, rkey, cid, value_json, updated_at) plus an R2
bucket for photos, keyed by blob CID (blobs/<did>/<cid>): the BlobRef is the one the PDS
returns for the same bytes, so a recipe's image doesn't change when the recipe moves. value_json is exactly the lexicon record, and cid is computed the same
way a PDS computes it (dag-cbor), so the cid-based sync in §6 works on all three stores.
Rkeys are TIDs from the start, so migrating keeps them. References between records are
repo-form at-uris (at://<did>/<collection>/<rkey>) in every store, the space included
(decided 2026-11-24): "the user's collection with this rkey, wherever it lives". A space URI
(at://<did>/space/<type>/<skey>/<did>/<collection>/<rkey>) isn't a valid at-uri (the
lexicon validator rejects it), and keeping one form means a record has the same value, so the
same CID, in D1, the space and the repo: neither the migration nor publishing rewrites it.
Migration into a space (3e58966, apps/webstore/migrate.ts): the callback records
whether the grant includes the space (accounts.space_grant). On the user's next request, while
accounts.private_store is still d1, the Worker makes the space hold exactly the D1 records
(list both sides, then applyWrites in batches; the space is created on the first write),
checks rkeys and CIDs against a fresh read of both, then sets private_store = 'space'. It is
idempotent; if it fails, that request uses D1, which is canonical until the switch, and the next
one retries. Each batch's photos are uploaded from R2 just before it. The D1 rows are
kept as a backup for a grace period, which while spaces are alpha lasts until a breaking alpha
change has been absorbed (proposed).
Compare-and-swap in a space. The alpha has no swapRecord on space writes, so every space
write goes through the SessionDO (spaceWrite, apps/core/src/space.ts), which reads the
current CID and writes under a per-DID lock. That is atomic for this app, the only writer of
its space type. Publishing to and from a space isn't one transaction as it is in D1: the
public_records index is updated first, and a private copy left by a stopped publish is
ignored by reads and removed by the retry.
Photos in a space are ordinary blobs: com.atproto.repo.uploadBlob, then a space record
that references them, which the PDS requires (BlobNotFound otherwise). R2 stays the staging
area: an upload is processed and stored there, and goes up to the PDS with the record that
first uses it (SpaceStore, the migration, publishing). The alpha PDS keeps one blob per CID for
the repo and all spaces and deletes it only when nothing references it, so moving a recipe
between space and repo never loses its photo; public sync.getBlob serves only blobs a repo
record references. Stores find blobs anywhere in a record, not only in image.
D1 is canonical only for users without spaces. D1 Time Travel covers 30 days; an
operator-side periodic export to R2 is deferred (88a4eeb). There is no user-facing "export":
records in the user's PDS are already theirs to take.
Photos are downscaled before they are stored. On upload, the Cloudflare Images binding
applies the EXIF orientation, caps the long edge at 2048 px and re-encodes as JPEG (1600 px if
that is still over 1 MB). Images keeps EXIF, GPS included, so we then strip EXIF, XMP and IPTC
ourselves. The result fits the lexicon's ≤ 1 MB limit and is what R2, the space and the repo store
(97e6ff0; apps/web/scripts/images-check.mjs tests the real service).
Recipes are private unless the user publishes them, and only recipes without a source can be
published (§8). Neither D1 nor spaces encrypt the data: the operator of D1, and for spaces the
PDS operator and authorised apps, can read it, and the privacy copy says so.
The app has its own domain, yeschef.at, which serves the app and is the NSID authority. It is
kept apart from everything on rtw.run: its own Cloudflare zone, its own deploy token and vault
entries. The lexicons are only published once the shapes settle (_lexicon TXT on yeschef.at).
at.yeschef.recipe (rkey: TID). Metadata fields are named as in Cooklang's canonical
frontmatter keys; text is the body only.
title: string // Cooklang `title`
text: string // Cooklang body, no frontmatter (≤ 64 KB)
collections: [ at-uri → at.yeschef.collection ] // Cooklang `tags` on import/export
description?: string // `description` / `introduction`
servings?: integer ≥ 1 // `servings` / `serves`: the leading number (scaling)
servingsUnit?: string // the rest: "6 portions" -> 6, "portions"
yield?: [ { amount: decimal-string, unit?: string } ] // `yield`: 500%ml
time?: { total?, prep?, cook? } // minutes; `time`, `time.prep`, `time.cook` (+ aliases)
course?, difficulty?, cuisine?: string // knownValues for course and difficulty
diet?: [ string ] // knownValues: vegetarian, vegan, gluten-free, …
locale?: language (BCP 47) // Cooklang writes en_GB, we store en-GB
cover?: blob (image/jpeg|png|webp, ≤ 1 MB) // the finished dish; alt text derived:
// "A photo of the completed <title> dish" (coverAlt)
images?: [ { image: blob, alt?: string, section?: int ≥ 0, step?: int ≥ 0 } ] // ≤ 20
// more photos; at a step when `step` is set
ingredientGroups?: [ { name, ingredients: [string] } ] // our `ingredient-groups` key
source?: { url?: uri, name?: string, author?: string, retrievedAt: datetime }
// present = "Adapted from …"; absent = the user's own
extra?: [ { key: string, value: yaml-string } ] // other frontmatter keys, kept for export
createdAt, updatedAt: datetime
One copy of each fact (decided 2026-11-24). The frontmatter's metadata lives in the fields,
not in text (validation refuses text that starts with frontmatter), so nothing can disagree.
packages/recipe converts both ways: fromCooklangFile on import (aliases, nested source: /
time: maps, durations into minutes, tags out for collections) and toCooklangFile on export
(canonical keys, 1h30m durations, collections' names as tags). Values a field can't hold,
unknown keys, image URLs, and a lone author (a source would mark the recipe as adapted) go
to extra as YAML and are written back as they were. Our field names follow Cooklang's except
cover (one unambiguous main image, for cards and Open Graph), collections (records, not
strings) and text.
at.yeschef.collection (rkey: TID)
The recipe points at its collections, as the brief asks. A collection's recipes come from the
local index. Renaming a collection rewrites one record, and deleting one leaves dangling URIs on
recipes, which reads ignore and the next save cleans up.
Photos (decided 2026-11-24).cover is the photo of the finished dish; images holds
the rest, e.g. of the process, each with optional alt text and optionally placed at a step.
section and step are 0-based, as cooklang-fs reads Cooklang's file convention
(Recipe.jpg is the cover, Recipe.<step>.jpg or Recipe.<section>.<step>.jpg a step photo).
cooklang.org's conventions page calls step numbers 1-based and doesn't mention sections; the
tooling is what files get read by, so we follow it. The v2 editor (TipTap, ingredients as
nodes, photos placed beside steps) will translate its document to Cooklang text plus these
positions, and to file names on export.
The ATProto data model has no floats, and nothing here needs them: quantities stay inside the
Cooklang text.
Records are written unvalidated until the shapes settle, as rider does, but our own code
checks every write against the lexicon first (validateRecipe / validateCollection). The
lexicons and permission set are published (_lexicon DNS TXT) once the shapes have held
through real use.
On publish, collections get public copies (decided 2026-11-22). A public recipe pointing at
a private collection would leak the collection's existence. So the first public recipe in a
collection creates a public copy of that collection record, and public recipes refer only to
public copies. The copy has the same rkey, so its repo at-uri is the one the recipe already
holds and nothing is rewritten. Renaming a collection updates both copies, and the copy is
deleted when no public recipe uses it any more.
Why records and not tags: a collection's name and description live in one place, so
renaming one never means rewriting the recipes that use it. Public recipes are on the PDS, so a
tag rename would mean a write per recipe. Plain tags would make sense only if collections never
get descriptions and renames are rare, and that can be revisited before the lexicons are
published.
No collection categories (decided 2026-11-23). Collections are a flat list. If grouping is
wanted later, it's a naming convention, not a field: cuisine:italian and cuisine:chinese
render together under a "cuisine" subheading. The record doesn't change.
No near-duplicates: whichever model is used, the collection picker is a combobox. It
suggests existing collections as you type, matching case-, accent- and whitespace-insensitively,
plus singular/plural ("Italian" = "italian" = " ITALIAN ", "Vegetable" ≈ "Vegetables"). It won't
create a collection whose normalised name already exists; it offers the existing one instead.
Imports go through the same matching.
---
title: BT Butter Chicken
servings: 5
source: https://www.teaforturmeric.com/butter-chicken/
tags: [indian, chicken] # informational; collections are the real organisation
---
= Marinade
Stir together @yogurt{1/2%cup}, @mild chili powder{1%tsp}, … and @chicken{1%lb}(1¼" cubes).
Cover and refrigerate up to ~{24%hours}.
= Sauce
…
= Notes
> 8/19/24: Doesn't need any base gravy. 5 minutes with velveting is good.
Sections are the ingredient headings. The top-of-page list is grouped by Cooklang section
(= Marinade), so one construct serves as both ingredient heading and step heading. Source
recipes don't always line up, though. For example, chicken biryani's ingredient groups
("Marinade", "Whole spices", "Other") differ from its step groups. S3 found this in 18 of 53
corpus recipes. For those, the converter writes a frontmatter key
ingredient-groups: {Whole spices: [bay leaf, cardamom, …]}, which the renderer prefers when
present (cooklang-rs keeps unknown keys in metadata.custom).
An ingredient used in two steps ("4 tbsp oil, divided") is two definitions with partial
quantities (@oil{1%tbsp} … @oil{3%tbsp}). The list merges them, and each step shows its own
share. Later bare mentions are references (@&oil) or plain text.
Things that must not scale use Cooklang's lock: @salt{=1%tsp}.
Parser findings (@cooklang/cooklang 0.19.1, checked in this session) #
new Parser().parse(text, scale?) returns {recipe, metadata, report}. Each step is a list of
items (text / ingredient{index} / cookware / timer), so per-step ingredient lists come
straight from the AST. Sections carry name. Frontmatter is parsed (servings, tags,
source.url), and the WASM file is 1.15 MB.
We don't use its scaler. At 1.5×, 3 eggs become 4.5 and 1 lb becomes 24 oz. We parse at
scale 1 and apply our own quantities module (below). The bindings expose no unit-system
conversion.
It loads as an ES WASM module import. Spike S4 confirms that it works under Vite for the
browser, the service worker and the Workers SSR bundle, and checks the bundle size.
Header: name, image, servings stepper, unit mode (Original / US / Metric / Both), source credit.
Ingredients, grouped by section heading, merged quantities.
Steps, numbered per section. Each step opens with a compact list of that step's
ingredients at that step's quantity (scaled and converted), then the text. Inline mentions
in the text are emphasised, and timers are tappable.
Notes.
Cook mode (later): screen wake lock, one step at a time, larger type.
packages/recipe/quantities: scaling, rounding, units #
A pure function from the parser's quantity to a display string:
render(q, ingredient, {factor, system: "original"|"us"|"metric"|"both"}).
Unit registry: every volume, mass and length unit Cooklang knows (cooklang-rs units.toml):
tsp, tbsp, cup, fl oz, pt, qt, gal and litres; oz, lb and grams; in, ft and metres, with the
SI prefixes on litre, gram and metre (dL, mg, mm, ...) and all of Cooklang's spellings, plus
the corpus's own (T, tbl, gr, ...). C is Celsius, not a cup. Time and temperature
units are left to timers and text scanning.
Temperatures in step text (350°F) are converted by text scanning (a later issue).
Scaling: multiply the exact value. Then round per ingredient class:
indivisible (no unit or a count unit, and the name matches a list: egg, can, package, clove,
bay leaf, star anise…): round to a whole number, minimum 1, marked ≈ when rounding moved the
value by more than about 10%. Example: 3 eggs × 1.5 → "≈ 4 eggs (4½)".
US volume/mass: nearest kitchen fraction (⅛ ¼ ⅓ ½ ⅔ ¾), then unit fitting within the
system (12 tbsp → ¾ cup, 0.5 tsp stays ½ tsp, never 24 oz from 1½ lb).
metric: whole grams and millilitres stay as they are (halves below 10); anything else gets
friendly rounding (≤ 10 → 1 or 2.5 steps, ≤ 100 → 5, ≤ 250 → 10, ≤ 1000 → 25, then 50) and
mg ↔ g ↔ kg / mL ↔ L / mm ↔ cm ↔ m fitting.
steps, scaled: exact when a cook can measure it exactly (one or two measures, ⅜ tsp as the
¼ and ⅛ spoons); otherwise the nearest measure, marked ≈. Counts show the whole number to
use and the exact amount: "≈ 4 (4½)". A tie goes down for indivisible things, up for the rest.
The classes come from the unit when it is a count word (can, clove, slice, stick, sprig →
indivisible; pinch, bunch, bulb → halvable) or else from the name (classes.ts). Golden file:
every corpus amount at 0.5×, 1.5×, 2×, 3× (packages/recipe/test/fixtures/scaling.golden.txt).
locked (=) and text quantities ("to taste") pass through unchanged.
Conversion: volume ↔ volume and mass ↔ mass only (1 cup = 236.6 mL). Converting a volume to
a mass needs density data, which is out of scope for v1. When converting isn't possible, the
original is shown as is.
Combining amounts (one ingredient used in several steps): sum exactly (US volume as rational
teaspoons, metric in mL, mass in g/oz; volume and mass never combine). Summaries (the Totals and
By-section ingredient lists) fit the total to one friendly unit and fraction, rounding to within
~10% when no exact fit exists and marking it ≈ ("≈ 1 cup" for 15/16 cup): the exact amounts
are in the steps. Steps stay exact, using two measures when needed ("¾ cup + 3 tbsp"). Decided
with the owner 2026-11-25 (bug bf3864c).
"Both" mode: the recipe's own units first, the other system in parentheses, each rounded on
its own terms ("2 cups (475 mL)"). Converted amounts are fitted like scaled ones (real spoons and
cups, friendly metric) and marked ≈ only when rounding moved them more than 5%; a converted
amount just short of a larger unit reaches up to it (450 g is "1 lb", not "15¾ oz"). The default
is a per-user preference (D1 prefs, set on /account); each recipe page can switch for itself
(?units=). A Cooklang quantity has one unit, so an author's dual figure ("1 lb (454 g)") lives
in the note and is shown as written (bug d659346).
Display uses Unicode fractions (1½), and ranges scale both ends ("½–¾ tsp").
Same pattern as rider's rider app (spike 519c236 there):
App routes are client-only (ssr = false), with a prerendered shell. The service worker
precaches the build and answers every app navigation with the shell. It never touches
POST/PUT.
IndexedDB (idb): recipes (record + cid + parsed name/collections; the title filter matches on the name),
collections, prefs, outbox, drafts (imports under review).
Stale-while-revalidate: the recipe page renders straight from IndexedDB. A background
revalidate (GET /api/recipes?since=<rev>, or list-and-compare by cid) updates the store and
re-renders only if the cid changed. With no network it shows "as of
Images: the Cache API, filled on view, plus an opt-in "keep all photos offline" prefetch.
Edits offline: queued in the outbox (rider's outbox-core rules: UUIDv7 action ids,
idempotent handlers). Conflicts are detected by cid and resolved last-writer-wins, with the
losing text kept in drafts.
Install prompt and update-waiting banner as in rider.
The rule is the easiest thing on each phone OS: nothing to install beyond the app itself.
v1 ships the iOS Shortcut only (decided 2026-11-22). Spike S1 captured NYT Cooking (logged
in), Serious Eats, Allrecipes and Bon Appétit from Safari. The Android paths below are built in
the spike but untested on a device, and are deferred to post-v1.
Public recipe sites
Logged-in / paywalled sites (NYT Cooking)
iOS
Shortcut (share sheet)
Shortcut (share sheet)
Android (post-v1)
Share to the installed PWA (Web Share Target): nothing else to install
Bookmarklet
A cross-origin fetch from the PWA can't use the user's NYT cookies (CORS), so a logged-in page
has to be captured in the recipe site's page. The iOS Shortcut does that for every site. On
Android, the share sheet hands the app only the URL, so the Worker fetches the page without the
user's cookies. That covers public sites, and the bookmarklet covers the rest. The capture paths:
iOS Shortcut from Safari's share sheet (the primary path). "Run JavaScript on Web Page"
returns document.documentElement.outerHTML and the URL from the user's logged-in Safari
session. "Get Contents of URL" then POSTs them to /api/capture with a per-user capture
token (bearer, revocable, stored as a hash in D1). The Shortcut opens the app's import
review for the new draft. iOS PWAs get no Web Share Target, so this is the only share-sheet
route. It's distributed as an iCloud link from the app's settings page, which shows the token
to paste in on install. Until the owner publishes that link, the account page lists the steps
to build the Shortcut by hand (spike S1's recipe). Tokens are yc_capture_…, at most 10 per
account, stored as SHA-256 in D1 (capture_tokens, migration 0005); /api/capture parses the
page at once and keeps only the RecipeDraft (drafts) for the review screen, at most 60
captures per hour (bug 74aebc9).
Android share target (post-v1; primary on Android). The installed PWA's manifest declares
share_target (GET /import?url=&title=&text=), so the app appears in Chrome's share sheet
once it's installed. Android sends only the URL, so the Worker fetches the page (no user
cookies) and parses it. If the fetch is blocked or the page is behind a login, the import
screen says so and points to the bookmarklet. Some apps put the URL in text rather than
url, so the handler accepts either.
Bookmarklet (post-v1), the fallback for logged-in sites on Android (also desktop). It reads the HTML
and URL, calls window.open(app/import), and hands the HTML over by postMessage after a
ready handshake, with the origin checked on both sides. A cross-site form POST won't work
because the app's SameSite=Lax session cookie wouldn't be sent. On Android a bookmarklet
runs by typing its name in the address bar; S1 confirms that and whether site CSPs block it.
The same Worker fetch also backs paste a URL on any device.
Paste text or HTML as the last resort.
Copy Me That export: not an app feature. A one-time local script (8b018ac) turns the
owner's export into one .cook file per recipe for review by hand; the owner decides which to
publish and with what images.
recipe-scrapers, the TypeScript port (npm recipe-scrapers 3.7.0, MIT,
github.com/recipe-scrapers/recipe-scrapers, maintained, last release 2026-11-16) runs in the web
Worker. scrapeRecipe(html, url, {safeParse: true, parseIngredients: true, parseNotes: true})
picks a site-specific scraper by host (NYT, Serious Eats, Bon Appétit, indianhealthyrecipes and
others are registered) and falls back to schema.org data ("wild mode"). It never fetches the URL
itself. Its output maps directly onto RecipeDraft:
Ingredients and instructions come as groups (name + items), which become our ingredient
groups and sections.
parseIngredients adds a parsed field (quantity, unit, description) to each line, using
parse-ingredient. S3 checks whether this replaces our own ingredient-line parser.
Its peer dependencies are cheerio, zod and parse-ingredient. S2 checks that the bundle
runs on workerd. cheerio's main entry has historically pulled in undici, and
cheerio/slim avoids it.
The corpus is a reference, not a golden file. The 46 source URLs in testdata/ are real
inputs for S2, but the recipes were edited over the years in Copy Me That. A difference between the
scraper's output and the corpus may be an edit rather than a parser bug, so S2 compares
structure (group count, line count, step count) and reviews differences by hand.
Fallbacks only if S2 finds gaps: a plain JSON-LD extractor (Recipe in ld+json), then Python
recipe-scrapers in a Python Worker.
Converting a RecipeDraft to Cooklang (spike S3, then packages/recipe) #
The hard part is that Cooklang places ingredients inside step text, while source recipes keep
them in a separate list. The converter has to link each list line to the step that uses it.
Ingredient-line parser (deterministic): Unicode and mixed fractions (1¼, 2 & 1/2),
ranges (½ to ¾, 5-6), parenthetical alternates (1 lb ( 454 g), 1 14 oz ( 400 g) can),
optional markers, trailing prep notes (, finely chopped), and unit aliases. The corpus has
749 lines, with 31 ranges, 73 parenthetical quantities and 87 lines with no leading quantity.
The first candidate is parse-ingredient, already used by recipe-scrapers. We wrap it for
what it misses and build a golden file from the corpus lines. Here the corpus text is the
input, so the golden file is exact.
Step linker (deterministic): match each ingredient's head noun and aliases against each
step ("the chicken", "ground spices" → group). The first match defines the ingredient with
its quantity. Lines marked "divided" are split. Matching works within sections first.
AI step choice for what's still unlinked (decided by S3, 2026-11-22): Clef
(@cf/cloudflare/clef, Cloudflare's decision model, through the Workers AI binding) gets the
recipe as its state and one choice question per unplaced line: which step uses it, or
"none". It returns a probability per option, so there's no JSON to repair, and a choice is
accepted at probability ≥ 0.5. Code then finds the phrase in that step
(spikes/convert/src/phrase.ts), or appends (@head{qty%unit}) to the step when the step
never names the ingredient. The model never writes Cooklang. On the corpus's 87 askable
lines Clef was right 86 times and never chose a wrong step. Haiku 5.5 got 84 (also no wrong
step), and Clef-flash 79 with two wrong steps. Cost is about $0.0005 per recipe.
Lossless fallback: an ingredient that still has no step goes into a "Gather" line at the
top of its section, so nothing is dropped.
Validator (the oracle): parse the emitted Cooklang with @cooklang/cooklang and check
that every source line appears with the same name and total quantity, with no extras. This
reports to the review screen, and the user fixes anything flagged in the Cooklang editor.
The model proposes; the parser checks.
Review screen (/import/<id>, bug 11d4180): a captured draft is converted once on the
server (POST /api/drafts/:id/convert: linker, Clef, emitter, validator) and the result is kept on
the draft, so reopening it never asks the AI again; AI calls are bounded by the capture limit. The
user edits the Cooklang (re-validated in the browser as they type) or checks the preview (the
recipe page's components), sees the validator's findings, the lines AI placed and the lines left
in Gather, ticks collections (the page's tags pick matching ones), and saves a private recipe
whose source is the captured page. Drafts live in D1 only for now; IndexedDB comes with the
offline epic.
S3 result: without AI, 649 of 749 corpus lines (87%) land inline correctly and 29 of 53
recipes are fully clean. Clef places 80 of the remaining lines at probability ≥ 0.5. So the review
screen is for the exceptions: it highlights Gather lines, "none" answers and low-probability
choices rather than asking the user to check every recipe.
Only original recipes can be published (decided 2026-11-23). A recipe without a source
is the user's own and may become a public record. A recipe with a source (imported from a
site, or a saved copy of someone else's public recipe) always stays private: in the user's
personal space, or in D1 if their PDS has no spaces. The app hides "Publish" for it and links to the FAQ.
Removing the source is the user stating the recipe is their own.
A recipe with a source is shown as "Adapted from ", linked to its URL. There is
no separate origin field. Every imported recipe is "adapted" because the user reviews and edits
it before saving (§7); that review is the quality gate, so the record carries no import
metadata either.
Photos are never taken from a scraped page, because their licence is unknown. The user
adds their own photo and is responsible for its licence. Later we may offer an Unsplash
search on the recipe title, whose photos come with a permissive licence.
Public recipe pages are server-rendered at /@handle/r/<rkey> from the PDS (cached), with OG
tags. Anyone can view them without signing in, and signed-in users can "Save a copy" as a
private recipe (source = the at-uri), which therefore can't be republished.
This is the project's reasoning, not legal advice; the FAQ page (07d2367) explains it to users.
A recipe itself can't be copyrighted. In US law a list of ingredients is a fact, and a
method is a process; neither is protected (37 CFR 202.1(a), "mere listing of ingredients or
contents"; Publications International v. Meredith, 7th Cir. 1996). What is protected is
the expression around it: the headnote, the story, the wording of the steps, and the photos.
That's why recipe sites wrap recipes in prose.
Being right doesn't stop a takedown. Anyone can send a DMCA notice, and a host (a PDS
operator, including Bluesky) usually removes the content first and sorts it out later. A
public copy of someone else's recipe, even reworded, invites notices against the user's
account, so the app doesn't publish anything with a source.
A private copy is like printing the ingredient list. Keeping a recipe in your own private
library, for your own cooking, is personal use and fair use. That's what the private store
(your personal space, or our database until your server supports spaces) is: only you and
the apps you authorise can read it.
Photos are someone's work. We never copy a site's photo; your photos are yours to add and
license.
9. Spikes (throwaway, spikes/<name>, findings on the bug) #
#
Question
Done when
S1 e4b81ed
Easiest capture per OS: iOS Shortcut, Android share target (+ bookmarklet for logged-in sites)
Done (iOS): captured NYT Cooking (logged in), Serious Eats, Allrecipes, Bon Appétit from Safari. Android deferred to post-v1
S2 27460aa
Does the TypeScript recipe-scrapers run in a Worker, and how well does it cover the corpus' sites?
Go: runs on workerd with cheerio/slim; 20 of 23 fetched pages parsed. Worker-fetch blocking from Cloudflare's network not yet measured (only matters for Android, post-v1)
S3 900473e
How reliably does RecipeDraft → Cooklang convert, deterministically and with AI?
Done: 87% of lines placed deterministically; Clef chooses steps for the rest (86/87 correct, no wrong steps)
S4 a1ef6eb
Does @cooklang/cooklang work in SvelteKit SSR on Workers, the browser and the service worker?
Builds and deploys; bundle size vs limits; parse time on a phone
S5 f2cf9c5
Can a confidential client on Workers write and read a personal space?
In progress on a local reference PDS (spikes/spaces-pds): OAuth scope, permission set, CRUD, credentials and MACs work; CIDs match D1. Open: blobs, the credential flow on workerd, Cirrus
NSID authority: at.yeschef.*, from the project's own domain yeschef.at (decided
2026-11-22; replaced run.rtw.cook.* before anything was published).
Spaces fallback: D1 for users whose PDS has no spaces, migrated on the first sign-in that
grants the space permission (decided 2026-11-22, revised 2026-11-23).
Collections on publish: public copies, with a combobox that prevents near-duplicates
(decided 2026-11-22). Records versus plain tags stays open until the lexicons are published.
AI provider: Clef via the Workers AI binding, accepting choices at probability ≥ 0.5
(decided 2026-11-22, S3). The model only chooses a step; code writes the Cooklang.
Ingredient groups that differ from step sections: use the ingredient-groups
frontmatter key when they differ (18 of 53 corpus recipes), so the author's headings survive
(S3).
When to use spaces: now, on any PDS that supports them, tracking the alpha (decided
2026-11-23, replacing "when Bluesky deploys them widely"). The owner moves to a self-hosted
PDS with spaces.