gram/packages/kitchen
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-04 12:01:18 +02:00
..
scripts feat(kitchen): emit mise en place and per-section and upfront schedules 2026-09-29 20:42:13 +02:00
src feat(kitchen): compile the task graph and lay out a single default schedule 2026-10-04 12:01:18 +02:00
tests feat(kitchen): compile the task graph and lay out a single default schedule 2026-10-04 12:01:18 +02:00
CHANGELOG.md chore(release): v1.3.0 2026-09-29 19:09:55 +02:00
package.json refactor(scheduler): extract the scheduling engine into its own package 2026-10-04 11:26:53 +02:00
README.md chore: preparing for v1 release 2026-08-06 10:40:53 +02:00
tsconfig.json refactor: rename @gram/compiler package to @gram/kitchen 2026-06-18 13:29:11 +02:00

@gram-lang/kitchen

npm version License: GPL v3

Part of the Gram monorepo.

The compiler for the Gram recipe language. It takes a typed Recipe AST (produced by @gram-lang/parser) and compiles it into a structured, minified recipe JSON (aggregating shopping lists, processing sections, and calculating Gantt-like timings).


📚 General Documentation

For full syntax specifications, grammar details, cheatsheets, and best practices, please refer to the Gram Documentation.


🛠️ Installation

npm install @gram-lang/kitchen
# or
bun add @gram-lang/kitchen

⚡ Usage

import { getAST } from '@gram-lang/parser';
import { compile } from '@gram-lang/kitchen';

const source = `
## My Recipe
[Mix] @flour{200g} and @water{100ml} for ~{5min}.
`;

const ast = getAST(source);
const result = compile(ast);

console.log(result.shopping_list);
console.log(result.metrics.activeTime); // Timing calculations (in minutes)

🏗️ Structure

  • src/core.ts: The main compiler entry point.
  • src/processor.ts: Processes step-by-step block content, local scopes, and timings.
  • src/section.ts: Compiles individual recipe sections.
  • src/shopping.ts: Deduplicates and aggregates ingredients into a master shopping list.
  • src/metrics.ts: Computes baseline active preparation times.
  • src/graph.ts: Traverses relative quantities and runs cycle detection (DFS).
  • src/registry.ts: Tracks declared ingredients, cookware, and references across the recipe.
  • src/scale/: Applies scale factors to quantities throughout the compiled recipe.
  • src/warnings.ts: Collects non-fatal compilation warnings.
  • src/schemas.ts: Zod schemas for compiler options.
  • src/utils.ts: Includes helpers for string slugification, minification, and time unit conversions.

📄 License

This project is licensed under the GPL-3.0 License.