Repository navigation
feat(doctor): show which recipes use each reported ingredient - #510
Conversation
`cook doctor aisle` lists the ingredients missing from aisle.conf, but not where they come from. Most of that list is not a missing aisle entry at all: it is one recipe spelling something the way the other twelve do not — "cumin powder" against "ground cumin", "cummin", "cumin seed, ground". Finding the odd file out meant grepping the collection by hand. Every reported ingredient now carries how many recipes write it, so the one-off spelling stands out against the established one without asking for anything extra. `--show-recipes` names those recipes, uncapped — a list truncated at three would hide exactly the stray file being hunted for. `cook doctor pantry` reports the same way, so an item in stock says which of your recipes it is keeping off the shopping list. Bare `cook doctor` keeps the counts and never the names: it summarises three checks, and naming every recipe behind every ingredient would bury it. In core, `CheckedIngredient` gains the recipes that write it, as paths relative to the scanned directory — the form `doctor validate` already reports a recipe by. Spellings stay separate ingredients, each with its own recipes, which is what makes the inconsistency findable. `known_entries` and `unknown_entries` expose them; `known` and `unknown` are unchanged. Closes #485
ReviewRead through the full diff ( Code quality
BugsNothing that looks like a functional bug. I traced through:
Minor / nit-level observations (non-blocking)
PerformanceNo concerns. The extra SecurityNone. Purely local filesystem scanning and stdout formatting; no new untrusted input handling introduced. Test coverageStrong -- four core unit tests covering the sharing/dedup/spelling-separation/pantry cases, plus four CLI characterization tests covering count pluralization, Note: I wasn't able to execute 🤖 Generated with Claude Code |
The new tests wrote their expectations as `Breakfast/porridge.cook`, which Windows prints as `Breakfast\porridge.cook`, so `doctor aisle --show-recipes` failed there while passing everywhere else. The output is right as it stands: a reported recipe is a file to go and open, and `doctor validate` has always named one with the platform separator. It is a Cooklang *reference* that must always be written with `/`, and that is a different path (see `cooklang_format::REFERENCE_SEPARATOR`, #442). So the expectations move rather than the output. Core compares `Utf8Path`s, which compare component by component, and the CLI test spells the expected line with `MAIN_SEPARATOR_STR`.
ReviewNicely scoped change with strong test coverage (4 core unit tests + 4 CLI characterization tests) and documentation that stays in sync with the behavior. Went through Code quality
Potential issues (minor, not blocking)
BugsNone found. The dedup logic ( PerformanceNo concerns — the walk is still a single pass over recipes/ingredients; the added SecurityNone applicable — this only reads local recipe files already within the scanned directory and prints their relative paths. Test coverageGood breadth: shared-ingredient-across-recipes, same-ingredient-twice-in-one-recipe, per-spelling recipe separation, pantry parity, and the no-subcommand "don't name files" guarantee are all covered. Nothing critical missing that I can see. |
Closes #485.
cook doctor aislelists the ingredients missing fromaisle.conf, but not where they come from. As #485 points out, most of that list is not a missing aisle entry at all — it is one recipe spelling something the way the rest of the collection does not:ground cumin,cumin powder,cummin,cumin seed, ground. Some of those want an alias; most want the recipe fixed. Finding the odd file out meant grepping by hand.What changes
Every reported ingredient now carries how many recipes write it, so a one-off spelling stands out against the established one with no extra flag:
--show-recipesnames them:The recipe list is uncapped. Truncating at three would hide exactly the stray file being hunted for.
cook doctor pantryreports the same way, so an item in stock says which of your recipes it is keeping off the shopping list.Bare
cook doctorkeeps the counts and never the names — it summarises three checks, and naming every recipe behind every ingredient would bury it.In core
CheckedIngredientgainsrecipes: Vec<Utf8PathBuf>— the recipes that write that ingredient, deduped, in path order, relative to the scanned directory (the formdoctor validatealready reports a recipe by). Spellings remain separate ingredients each with their own recipes, which is what makes the inconsistency findable at all.known_entries()/unknown_entries()expose them.known()/unknown()are unchanged and delegate, so no existing consumer moves.Tests
Four core unit tests (an ingredient shared by several recipes, one used twice in a single recipe counted once, each spelling keeping its own recipes, the pantry check tracking them too) and four CLI characterization tests (counts with singular/plural,
--show-recipesincluding a nested path, the pantry equivalent, and barecook doctornot naming files).cargo fmt,cargo clippy --all-targetsandcargo testare clean.