feat(kitchen): compiler writing hints (&ingredient, Cooklang %, cookware temperature) #277

Merged
abiwab merged 3 commits from feat/compiler-hints into dev/1.6 2026-11-26 17:01:56 +01:00
Owner

PR 4 of the DX & authoring-aids plan (compiler hints, § 1B). Three common mistakes, often made by AI models that know Cooklang better than Gram, are now reported with the fix to make:

  • REFERENCE_TO_INGREDIENT (kitchen, new code, warning): &flour on an ingredient written earlier as @flour{…} warns, with data.suggestion: "@&flour". The check reads the registry entry: silent on an intermediate (->& in a step or a section, even sharing an ingredient's name), on an unresolved @use binding (is_intermediate), on a stocked import's leaf (is_module_synthetic) and on a spliced module's renamed ->&. Covered by kitchen tests (EN + FR) and by real compositions in packages/modules/tests/reference-to-ingredient.test.ts; compose.ts, rename.ts and yield.ts are untouched.
  • Cooklang's % separator: ~{15%min} keeps its INVALID_DURATION and now carries data.suggestion: "15 min" (only when Gram reads the corrected duration). @flour{200%g}, read until now as an unknown unit %g with no mass and no warning, raises INVALID_UNIT with reason: "cooklangSeparator" and suggestion: "g"; only for a mass or volume unit ({70 % cacao}, {2%cloves} stay silent). Other INVALID_DURATION warnings keep their JSON unchanged.
  • Parser: a temperature in cookware braces (#oven{180°C}) now says a temperature is written ^oven{180°C}.
  • LSP: three isPreferred Quick Fixes in quantityQuickFix, read from diag.data and diag.code (no regex on the message); applying them and recompiling never brings the code back.

Also:

  • fuzz/src/normalize.ts: the existing SPACED_COMPOSITE rule (#208) now also lowercases REFERENCE_TO_INGREDIENT's data.suggestion, which quotes the name as written while the formatter lowercases ids (rule 1). Found by the 50k run (--seed 616880811 --index 24905), replays clean now.
  • Playground budget raised from 1060 KB to 1065 KB (1059.1 → 1060.6 KB, the new checks and messages), with a dated comment.
  • llms-full.txt regenerated: it also catches up with PR 2a's frontmatter table.

Changeset minor (kitchen, parser, language-server); it mentions that gram check --strict now fails on these mistakes. Docs en + fr: warnings.mdx (new section, data list, INVALID_UNIT fourth case, INVALID_DURATION suggestion), ai-generation-notes.mdx (cookware temperature, a new Cooklang % section, "Gram now warns" on & vs @&).

Checks: tests red before, green after (kitchen 15, parser 3, LSP 6, modules 4); typecheck, biome, full bun test (4144 pass, 1 skip, 0 fail); conformance 148/148, only the warnings of 059-sigil-only-name changed, 4 new cases (warn-026…028, err-017); bun run fuzz --iterations 50000 clean; audit unchanged (127 flags); AI spec examples and SKILL.md examples unaffected.

PR 4 of the DX & authoring-aids plan (compiler hints, § 1B). Three common mistakes, often made by AI models that know Cooklang better than Gram, are now reported with the fix to make: - **`REFERENCE_TO_INGREDIENT`** (kitchen, new code, `warning`): `&flour` on an ingredient written earlier as `@flour{…}` warns, with `data.suggestion: "@&flour"`. The check reads the registry entry: silent on an intermediate (`->&` in a step or a section, even sharing an ingredient's name), on an unresolved `@use` binding (`is_intermediate`), on a stocked import's leaf (`is_module_synthetic`) and on a spliced module's renamed `->&`. Covered by kitchen tests (EN + FR) and by real compositions in `packages/modules/tests/reference-to-ingredient.test.ts`; `compose.ts`, `rename.ts` and `yield.ts` are untouched. - **Cooklang's `%` separator**: `~{15%min}` keeps its `INVALID_DURATION` and now carries `data.suggestion: "15 min"` (only when Gram reads the corrected duration). `@flour{200%g}`, read until now as an unknown unit `%g` with no mass and no warning, raises `INVALID_UNIT` with `reason: "cooklangSeparator"` and `suggestion: "g"`; only for a mass or volume unit (`{70 % cacao}`, `{2%cloves}` stay silent). Other `INVALID_DURATION` warnings keep their JSON unchanged. - **Parser**: a temperature in cookware braces (`#oven{180°C}`) now says `a temperature is written ^oven{180°C}`. - **LSP**: three `isPreferred` Quick Fixes in `quantityQuickFix`, read from `diag.data` and `diag.code` (no regex on the message); applying them and recompiling never brings the code back. Also: - `fuzz/src/normalize.ts`: the existing SPACED_COMPOSITE rule (#208) now also lowercases REFERENCE_TO_INGREDIENT's `data.suggestion`, which quotes the name as written while the formatter lowercases ids (rule 1). Found by the 50k run (`--seed 616880811 --index 24905`), replays clean now. - Playground budget raised from 1060 KB to 1065 KB (1059.1 → 1060.6 KB, the new checks and messages), with a dated comment. - `llms-full.txt` regenerated: it also catches up with PR 2a's frontmatter table. Changeset `minor` (`kitchen`, `parser`, `language-server`); it mentions that `gram check --strict` now fails on these mistakes. Docs en + fr: `warnings.mdx` (new section, `data` list, `INVALID_UNIT` fourth case, `INVALID_DURATION` suggestion), `ai-generation-notes.mdx` (cookware temperature, a new Cooklang `%` section, "Gram now warns" on `&` vs `@&`). Checks: tests red before, green after (kitchen 15, parser 3, LSP 6, modules 4); typecheck, biome, full `bun test` (4144 pass, 1 skip, 0 fail); conformance 148/148, only the `warnings` of `059-sigil-only-name` changed, 4 new cases (`warn-026`…`028`, `err-017`); `bun run fuzz --iterations 50000` clean; audit unchanged (127 flags); AI spec examples and SKILL.md examples unaffected.
abiwab merged commit 88e2d384bc into dev/1.6 2026-11-26 17:01:56 +01:00
abiwab deleted branch feat/compiler-hints 2026-11-26 17:01:57 +01:00
Sign in to join this conversation.
No description provided.