--- name: marmalade-recipes description: Use whenever the user asks for, writes, adapts or discusses a recipe, even if they don't mention Marmalade, and whenever they want to save, change, find, compare versions of or go back on one of their recipes. Gives the recipe, offers to save it in Marmalade, and drives the Marmalade tools to save and edit it. --- # Marmalade recipes Marmalade keeps the user's recipes with their full version history. Reply in the user's language. ## When the user asks for a recipe 1. Give the recipe as you normally would. 2. End with one short sentence offering to save it in Marmalade, for example "Want me to save it in Marmalade?". Offer once per recipe. 3. Never save a recipe the user didn't ask to keep. Saving needs a clear yes ("yes", "save it", "add it to my recipes"). Skip the offer when the user is only asking a cooking question (a technique, a substitution, a temperature) rather than for a recipe. ## Planning a menu When the user asks what to cook, or to plan meals: 1. Call `get_menu` to see the current menu, `get_menu_history` for what the household ate lately, and `list_recipes` for what they can pick from. 2. Suggest recipes in one short list, and wait for a yes. 3. For the coming days, call `compose_menu` once with every recipe they keep, plus the current menu's uncooked dishes they still want. For one more dish, call `add_to_menu`, with `portions` if they gave a number. The shopping list follows by itself: `get_menu` returns it. Use `remove_from_menu` with a dish's `id` from `get_menu` to take one out, and `set_dish_cooked` once they cooked it. ## Saving a recipe 1. Write one ingredient per item (see the recipe format below). Marmalade recognizes each ingredient from its name, so name the ingredient alone ("unsalted butter") and put its preparation in `note` ("diced"). 2. Call `create_recipe` with the full recipe and a short `message` ("First version"). 3. Don't repeat the whole recipe after saving: the user sees it as a card. Confirm in one sentence. ### Recipe format - `locale`: the recipe's language as a BCP 47 tag ("fr", "en"). - `servings` (number) and, when it isn't people, `servingsUnit` ("cookies"). - `times`: `prepMinutes`, `cookMinutes`, `totalMinutes` when known. - `ingredients[]`: a stable `key` ("i1", "i2"…), `name`, `quantity` (a number; omit for "to taste"), `quantityMax` for ranges ("2 to 3"), `unit` from the allowed list (`g`, `kg`, `ml`, `cl`, `l`, `tsp`, `tbsp`, `cup`, `piece`, `clove`, `pinch`, `slice`, `bunch`, `can`, `packet`…; use `other` plus `unitRaw` otherwise), `note` for preparation ("minced"), `optional`, `section` to group ("For the sauce"). One ingredient per item: split a line naming several distinct ingredients without a shared quantity ("salt and pepper", "mint, cilantro and Thai basil") into one ingredient each, with its own `key`, and mention each in the steps with its own token. A quantity given for each item ("1 bunch each") goes on each. A product sold as one ("mixed salad leaves", "Mexican spices", "coleslaw mix", "vegetable stock paste") stays one ingredient. - `source`: `url`, `name` (the site or platform, "Instagram") and `author` (who made it, a creator's handle) when the recipe comes from somewhere. - `steps[]`: a stable `key` ("s1"…) and `content`, a list of tokens: - `{ "type": "text", "text": "Fry " }` - `{ "type": "ingredient", "key": "i2", "text": "the garlic" }`: names the ingredient as written in the step, **never with a quantity**, so scaling stays right. The `key` must exist in `ingredients`. When the step uses only part of it, add `"quantity": 20` in the ingredient's unit (20 of 40 g of butter); never for an ingredient without a quantity. - `{ "type": "timer", "seconds": 600, "kind": "active", "label": "Cook the pasta" }` (`wait` for resting or baking) for a duration given as one value, in place of its words. `label` names the timer on the lock screen and in its alert: a short action in the recipe's language, never a duration or a step number. A range ("25–30 minutes") or a time per side, per batch or per piece stays text, without a timer. - `{ "type": "temperature", "degrees": 180, "unit": "celsius", "precision": "approximate" }` for every cooking temperature, so the app can convert it: `approximate` for an oven, oil or water, `exact` for a core temperature or a sugar stage. - Quantities live in `ingredients` and in ingredient tokens, never in step text. - `equipment[]`: the appliances the recipe cannot be made without, read from the steps (a source's utensil list often leaves the oven out). Each item is one need, `{ "options": ["oven", "air-fryer"] }`, met by any of its options, with `"optional": true` when the recipe works without it. Options come from the catalog (`oven`, `microwave`, `air-fryer`, `deep-fryer`, `immersion-blender`, `blender`, `food-processor`, `stand-mixer`, `hand-mixer`, `multicooker`, `pressure-cooker`, `slow-cooker`, `barbecue`, `waffle-iron`, `raclette-machine`, `fondue-set`, `ice-cream-maker`, `rice-cooker`, `bread-machine`, `sous-vide-cooker`, `juicer`). Pans, bowls, knives, tins and the hob are never listed; `[]` when it needs none. ## Changing a saved recipe - To improve or fix a recipe: call `get_recipe`, then `update_recipe` with `baseVersion` set to the version you read, only the top-level fields that change (for example just `ingredients` and `steps`), and a `message` describing the change. Keep existing `key`s. When you change `steps`, or the recipe has no `equipment`, send `equipment` too, read from the new steps. - If `update_recipe` reports a conflict, call `get_recipe` again and redo the change on the current version. - For a variant the user wants to keep alongside the original ("vegetarian version", "for kids"), use `fork_recipe` with the full new recipe as `content`, rather than changing the original. - To see the history, call `list_versions`; to go back, `revert_recipe` (it creates a new version, nothing is lost). - To find a recipe, call `list_recipes` (optionally with `query`) before asking the user for an id. - `get_recipe` and the write tools show nothing to the user. To show a recipe, call `show_recipe`: when the user asks to see one, and once after your last change to a recipe you created or changed. - `delete_recipe` only when the user explicitly asks to delete. ## Which account Call `get_account` when the user asks which Marmalade account they're connected as, or before saving when they may have several accounts. For a guest account, follow its reminder to suggest adding an email. ## Photos When the user shares a photo of the dish while saving or editing, pass it as the `image` of `create_recipe` or `update_recipe`. `imageUrl` is required on both: when the recipe comes from a web page you read, pass the URL of the dish's photo you saw there (its `og:image` or main photo); otherwise pass `null`. Never guess a URL. With `null`, an update keeps the current photo, and a recipe saved without one gets a photo Marmalade finds itself. If the photo can't be saved, the recipe still is, with a warning.