Welcome to the second beta of Gram! Since the last release which introduced the CLI and completed the initial ecosystem, my primary focus has been entirely on one massive, long-overdue task: **The Documentation**.
Breaking changes
- refactor: rename
isAsync to isPassive to align with domain terminology
To better align the codebase with the actual domain model of a kitchen, the “asynchronous” timer concept has been completely renamed to “passive”. This introduces the following breaking changes for tool builders:
- AST: The
TimerAST node property isAsync: boolean is now isPassive: boolean.
- CSS: The
.timer.async class generated by the renderer has been renamed to .timer.passive.
- Kitchen Metrics: All internal variables and comments referring to
async background tasks have been updated to passive.
- Breaking Change: Refactored Physical Engine Nomenclature
The physical enrichment options and internal APIs have been renamed for clarity and to align with professional culinary terminology.
If you are using @gram-lang/analyzer programmatically, please update your configuration:
enableMassNormalization is now enableMassStandardization
enableYieldManagement is now enableYieldCalculation
- The exported
normalizeMass helper is now standardizeMass
This update ensures total parity with the updated official documentation.
- Introduction of the official Gram CLI (
@gram-lang/cli), a comprehensive command-line tool to manage, compile, and interact with your recipes.
Project & Recipe Management:
- Project Setup:
gram init safely scaffolds a .gram environment, including interactive AI provider setup (Google, OpenAI, Anthropic, Ollama) and secret management.
- Automated Import:
gram import scrapes recipes from any URL and uses AI to flawlessly translate and convert them into native .gram syntax.
- Validation & Compilation:
gram check instantly validates syntax and database integrity. gram build compiles recipes to robust JSON with full physical and nutritional enrichment.
- Smart Scaling & Diff:
gram scale dynamically resizes recipes (e.g., --scale flour=300g) with a visual before/after comparison. gram diff provides a semantic “git diff” for cooking, tracking changes in quantities, timings, and steps.
- Export & Print:
gram print generates a beautifully typeset A4 HTML recipe card. gram export converts recipes to clean Markdown or static HTML.
- Auto-formatting & Watcher:
gram format automatically enforces .gram language styling standards. gram watch provides real-time validation upon saving.
Interactive Cooking & Daily Use:
- Terminal Cooking Assistant (
gram cook): A step-by-step interactive TUI (Terminal User Interface) that guides you through the recipe, featuring a dynamic ingredient checklist and live background timers.
- Smart Shopping List (
gram shop): Aggregates ingredients across multiple recipes, automatically converting volumes to masses and sorting them by supermarket aisle.
- Recipe Search (
gram suggest): An alias-aware search engine to find recipes based on your available ingredients (e.g., --with "butter, eggs" --without "milk").
- Rich Terminal Preview (
gram view): Renders recipes directly in the terminal with color coding, active timers, and nutritional tables.
AI-Powered Database Management (gram db):
- Smart Database Sync & Enrichment:
gram db sync automatically tracks new ingredients across your project. gram db enrich uses AI to automatically fill in missing densities, unit weights, categories, and nutrition facts.
- Semantic Linting & Conflict Resolution:
gram db lint uses AI to detect plural mistakes and semantic duplicates (e.g., scallion vs green onion). gram db merge handles conflicts when integrating external community databases.
New features
- docs: update timer terminology from synchronous/asynchronous to active/passive
To better align with real-world culinary concepts and eliminate confusion, the terminology for timers has been updated throughout the documentation.
Previously, Gram used computer-science terms (synchronous / asynchronous) to describe how timers affected the recipe flow. However, in a kitchen environment, almost all timers block the preparation itself, even if they run in the background.
To clarify this, we have shifted the terminology to focus on the cook’s availability rather than the execution thread:
- Synchronous timers are now referred to as Active timers. These timers require the cook’s attention and add to the
activeTime metric.
- Asynchronous (
~&) timers are now referred to as Passive (or Idle) timers. These timers represent background tasks (like resting or baking) that free up the cook to perform other steps concurrently.
Note: This is a purely conceptual nomenclature change to make the documentation and learning curve more intuitive for non-developers. The underlying syntax (~{} and ~&{}) and the compiler’s Gantt chart logic remain exactly the same.
-
Major overhaul of the documentation and playground infrastructure:
-
Documentation Rewrite & i18n: The documentation has been completely rewritten, thoroughly verified, and is now fully translated into French (in addition to the English version).
-
Advanced Vue 3 Playground: The legacy playground has been removed and rebuilt from the ground up using Vue 3. This new version is directly integrated into the documentation and introduces powerful new features, including recipe scaling and baker’s math.
-
The @gram-lang/compiler package has been renamed to @gram-lang/kitchen to fully embrace the Gram language’s domain identity.
-
docs: integrate new Vitepress documentation site and embedded playground
-
Documentation: Complete overhaul of the Gram documentation site using Vitepress. Improved layout, better navigation, and comprehensive coverage of the new syntax and APIs.
-
Playground: Replaced the legacy standalone playground with a new, fully integrated version directly within the Vitepress documentation site. Features live-reloading, side-by-side editing, and syntax highlighting via Shiki.
-
Complete overhaul of the VS Code Extension with Language Server, Live Preview, and advanced assistance
Major New Features:
- Full Language Server (LSP): The extension now ships with a complete language server. All advanced features activate instantly upon opening a
.gram file.
- Dynamic Live Preview: A side-by-side WebView panel displaying the real-time HTML render of the recipe as you type.
- Gracefully handles syntax errors via a visual fallback.
- Integrates the official Playground styles for perfect consistency.
- CodeLens & Inlay Hints:
- Inlay Hints: Displays the cumulative total time in gray next to section titles.
- CodeLens: Clickable buttons
▶ Preview and 📊 Macros above the main recipe title for quick access.
Ingredient Database & Nutrition:
- Automatic Loading: Automatically detects and loads
.gram/ingredients.yaml from the workspace root (or via the path configured in gram.ingredientDatabase.path settings). Optimized indexing (O(1)) for maximum performance.
- Seamless Plural Management: The extension silently handles plurals (e.g.,
@carrots{3} will automatically match carrot). No error diagnostics are raised, everything is transparent.
- Nutritional Hover & Macros Panel:
- Hovering over an ingredient displays a complete nutritional table (calories, proteins, carbs, fats, etc.).
- The Live Preview integrates a Macros panel (hidden by default) that can be shown via CodeLens, featuring clear visual alerts for ingredients missing data.
- Fuzzy Matching “Did you mean?”: Levenshtein algorithm (distance ≤ 2) suggests corrections if an ingredient is misspelled (e.g.,
@tomaato suggests @tomato). Directly integrated into Quick Fix code actions.
- On-Hover Unit Conversion: Automatically converts volumes (ml, tbsp, etc.) to grams when hovering over an ingredient if its density is known in the database.
Editing Assistance & Navigation:
- Advanced Contextual Autocompletion:
- After
@: Suggests ingredients and their aliases from the YAML database. Automatically adds curly braces {} for multi-word names.
- After
&: Suggests only the existing intermediate declarations in the document.
- Inside
{}: Suggests canonical units (mass, volume, time) and their aliases (French/English) as soon as a digit is typed.
- Smart Navigation:
- Go to Definition (
Ctrl+Click / F12) on a &ref reference to jump to its ->&ref declaration.
- Find All References (
Shift+F12) to list all usages of an intermediate.
- Rename Symbol (
F2) to atomically rename an intermediate (declaration + references).
- Outline Panel showing the hierarchy of sections and elements, with foldable code in the gutter.
- Intermediate Hover: Displays the full text of the step where the intermediate was created.
Diagnostics & Code Actions (Quick Fixes):
- Real-Time Diagnostics:
- Red underline for an orphaned
&ref reference.
- Warning for an unused
->&ref declaration.
- Warning if the frontmatter (title) is missing.
- Code Actions (💡):
- Quick Fix: Insert the missing
title: in the frontmatter.
- Quick Fix: Remove an unused intermediate declaration.
- Quick Fix: Declare a missing intermediate for an existing reference.
- Refactor: Convert a volume quantity to mass directly in the code.
- Refactor: Replace a misspelled ingredient with the closest Fuzzy match suggestion.
Semantic Highlighting, Formatting & Snippets:
- Semantic Tokens: Regex-based syntax highlighting (TextMate) is replaced by AST-driven highlighting. Offers surgical precision for ingredients, timers, temperatures, comments, and nested units (e.g., precise separation of value and unit in
{10g}).
- Auto-formatting (
Alt+Shift+F):
- Normalization of spaces inside curly braces (
{ 200 g } → {200g}).
- Normalization of composite ingredients (
@a < @b → @a<@b).
- Alignment of section titles and tab-to-space conversions.
- Built-in Snippets: Keyboard shortcuts for the basic structure (frontmatter, sections, steps), ingredient variants (
@ing, @?, @-), cookware (#cw), and timers/temperatures.
- Core language update to enforce new syntax adjustments (breaking changes).
- Grammar & Parsing:
- Made
{} optional for single-word ingredients.
- Replaced temperature symbol with
°.
- Replaced async timers with
~&{}.
- Replaced aliases brackets with
:.
- Tightened
<@ with no spaces allowed.
- Added fixed modifier
=.
- Mandatory
@& inside relative quantities declarations. (e.g: @water{60% @&flour})
- Top-Level Support: Allowed writing comments and recipe steps globally, anywhere in the document (even before the first
## Section).
- Compiler Analysis:
- Added
INVALID_MODIFIER_COMBINATION warnings.
- Updated AST transformations to support the new modifiers parsing rules and the implicit top-level sections grouping.
- Aligned visual tooling and test recipes with the new grammar.
GramHighlight.ts (Playground & VSCode): Updated all syntax highlighting regular expressions to accurately match the new syntax (new temperature symbols, updated modifiers, etc.).
- Examples (
basquaise_chicken.gram, lemon_meringue_pie.gram, torture.gram): Fully migrated recipe code to comply with the new grammar.
-
Fixed several correctness bugs found during a documentation audit, and added alias-aware cross-unit shopping list aggregation.
-
@gram-lang/analyzer: unit_weight-based conversions (e.g. @avocado{1}) were being double-divided by yield — the whole-unit weight is now correctly treated as Gross Mass, with Net Mass derived forward (Gross × yield), while explicit mass/volume entries keep deriving Gross backward (Net ÷ yield) as before. Optional ingredients (?) are no longer counted in nutrition totals. New resolveCanonicalId() resolves an ingredient name/alias to its database key, and a new aggregateShoppingList() step re-groups the shopping list by canonical id — merging aliased ingredients (e.g. beurre/butter) and cross-unit quantities (e.g. 100g + 1 cup) into a single gram total whenever every entry resolves to a mass, falling back to separate entries flagged multiUnit: true when a density is missing.
-
@gram-lang/renderer: The HTML shopping list now clusters consecutive multiUnit-flagged entries for the same ingredient under one heading with a “⚠️ Mixed units” badge, instead of listing them as unrelated lines.
-
@gram-lang/cli: shopper’s alias resolution now reuses @gram-lang/analyzer’s resolveCanonicalId() instead of a separate, duplicated alias map.
-
- Playground: Migrated syntax highlighting engine from Highlight.js to Shiki. The playground now natively uses the official VSCode TextMate grammar, ensuring 100% consistency across environments.
-
VSCode Extension: Improved syntax coloring by mapping custom Gram tokens (cookware, intermediate ingredients, units) to standard semantic TextMate scopes, restoring vibrant and legible colors across all VSCode themes.
-
Improve ingredient preparation tracking and display.
-
Kitchen: aggregateSectionIngredients now groups ingredients by both id and preparation, creating separate entries for the same ingredient if it requires different preparations (e.g. cold vs melted).
-
Renderer: A new formatMode option in the render context controls preparation rendering. Preparations remain visible in inline text to prevent information loss. In the section’s ingredient list (Mise-en-place), they are cleanly displayed with an em-dash. In the global shopping list, they remain hidden.
-
Refactor TextMate grammar to @gram-lang/parser
The TextMate grammar (gram.tmLanguage.json) has been moved from @gram-lang/vscode-extension to @gram-lang/parser to colocate the structural (Ohm) and lexical (TextMate) definitions of the Gram language.
This resolves architectural issues where consumers like the playground had to perform brittle, deep relative imports into the VSCode extension package. The syntax grammar is now officially exported and accessible via @gram-lang/parser/textmate.
-
Added a centralized ScaleEngine in @gram-lang/kitchen to make recipe scaling (--scale) and Baker’s Percentage math safer and more consistent everywhere.
-
@gram-lang/kitchen: New resolveScaleFactor()/applyScale() API validates a --scale target before computing a factor — rejecting fixed (@=) ingredients, relative quantities, ingredients only used inside a sub-recipe, ingredients inside an alternative-ingredient group, and ingredients split across incompatible units, with a clear error instead of a silently wrong number. A sub-recipe’s own total (e.g. “2 lemons”) is itself a valid scale target. Scaling is now a pure operation (never mutates the original recipe), and the compiled recipe now carries an explicit scaleFactor field. Covered by a new unit test suite.
-
@gram-lang/analyzer: Fixed the @* Baker’s-reference auto-detection (it silently never matched before), and it now refuses to use a relative-quantity ingredient as the 100% base instead of computing bogus percentages. The enriched JSON AST now natively includes a bakersPercentage field for all ingredients if a reference ingredient is declared or passed via the bakersReference option. convertUnit() now accepts an optional density (g/mL) to bridge mass ↔ volume conversions; new resolveIngredientDensity() and parseDensityOverrides() helpers resolve that density from a recipe’s densities: frontmatter. Also includes a critical null-safety fix when parsing recipes containing standalone comments.
-
@gram-lang/renderer: Natively supports formatting Baker’s Percentages provided by the analyzer (for HTML and Markdown exports, and the Playground), removing its legacy calculation logic. Fixed gram print --bakers-math-only having no effect.
-
@gram-lang/cli: The CLI now cleanly acts as a presentation layer for Baker’s Math, reading percentages directly from the AST. Added --bakers-math, --bakers-reference, and --bakers-math-only flags to the view, print and export commands. --scale id=value now supports same-family unit conversion and cross-family conversion when a density is available; suggests the closest matching ingredient name on a typo; no longer shows corrupted comparison rows for an ingredient split across multiple units in gram scale.
-
Major architecture refactoring, ESM Migration, performance optimizations and code cleanup
-
Complete overhaul of the documentation to reflect the new syntax changes.
Bug fixes and improvements
-
Fix: Allow preparations on bare ingredients and cookware
Previously, the parser and the TextMate syntax highlighter required quantity braces {} to attach a preparation to an element (e.g. @butter{}(melted) or #pan{}(20cm)).
The grammar has been updated to support attaching preparations directly to bare elements without braces. You can now write @butter(melted) or #pan(20cm) naturally. The AST will correctly extract the preparation property, and your editor will highlight it properly.
-
NutritionMetrics output field renamed from salt to sodium to match the ingredient database schema
-
Refined formatting and mass normalization for relative quantities:
-
Cleaner Display: Relative quantities are now seamlessly displayed without internal @ or & markers (e.g., 125% of lemon juice). The redundant formula brackets [125% of...] have been removed from inline instructions.
-
Robust Shopping List Aggregation: The compiler (@gram-lang/kitchen) now strictly tracks ingredient lineage using _usageIds. This allows the analyzer (@gram-lang/analyzer) to flawlessly compute exact masses for complex items in the shopping list without confusing standard ingredients and their alternatives.
-
Shopping List Accuracy: When mass normalization is enabled, the shopping list will now accurately display the fully resolved physical mass for relative quantities (e.g., sugar (156 g)) instead of falling back to the formula string.
-
Fixed an issue in the parser where composite ingredients without braces (e.g., <@lemon,) would incorrectly consume subsequent text on the same line, causing missing ingredients and breaking relative quantity resolutions.
-
Fix total recipe time calculation when using background timers
Previously, the compiler did not wait for passive tasks (like resting dough in the fridge) to finish before letting you use the result. This caused the estimated “Total Time” to be unrealistically short. The engine now properly understands dependencies and waits for intermediate preparations to be fully ready before proceeding to steps that need them.