Plain-text recipe DSL (GPL-3.0) compiling .gram files into deterministic JSON. Includes the compiler, backward scheduler, CLI, LSP, and VS Code extension. https://gram-lang.org
  • TypeScript 66.7%
  • MDX 22.7%
  • Vue 4%
  • CSS 3%
  • Astro 3%
  • Other 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-30 18:35:34 +01:00
.changeset feat(docs): soften the playground's dark views and set its editor on the code background 2026-11-30 17:00:33 +01:00
.forgejo Merge remote-tracking branch 'origin/main' into chore/merge-main-into-dev-1.6-2026-11-28 2026-11-28 00:14:29 +01:00
.github docs: add code of conduct, issue templates, and enhance contributing guide 2026-08-25 22:31:23 +02:00
audit chore(audit): transcribe the three new mistake examples of the AI notes 2026-11-29 19:51:17 +01:00
conformance feat(kitchen): warn when an alias written after a blank loses its quantity 2026-11-29 19:49:49 +01:00
editors chore(editors): bump tree-sitter-gram to v0.1.1 2026-11-29 10:38:40 +01:00
fuzz Merge pull request 'feat(kitchen): warn when an alias written after a blank loses its quantity' (#320) from fix/alias-after-blank into dev/1.6 2026-11-29 21:09:26 +01:00
packages feat(docs): soften the playground's dark views and set its editor on the code background 2026-11-30 17:00:33 +01:00
scripts chore: lower the language-server any-ratchet baseline to 0 2026-11-29 19:51:17 +01:00
.git-blame-ignore-revs chore: pin CI Bun/add node-smoke+docs steps/sideEffects:false, fix stale playground examples and doc drift 2026-07-08 09:02:08 +02:00
.gitignore chore(deps): upgrade astro, mdx and starlight 2026-09-29 09:16:24 +02:00
biome.json test(fuzz): add deterministic fuzz harness for parser, kitchen, analyzer and formatter 2026-11-21 18:42:23 +01:00
bun.lock refactor(modules): share the @use path resolution of the CLI and LSP hosts in @gram-lang/modules/node 2026-11-28 14:50:24 +01:00
CHANGELOG.md docs(blog): add early alpha release posts (0.1.0 to 0.7.0) 2026-11-27 23:46:18 +01:00
changeset-utils.ts chore: harden changelog generation with dedupe checks and a pre-release preview 2026-08-05 14:59:38 +02:00
check-changesets.ts chore(deps): upgrade changesets packages to v3 2026-09-28 23:06:53 +02:00
CODE_OF_CONDUCT.md docs: add code of conduct, issue templates, and enhance contributing guide 2026-08-25 22:31:23 +02:00
CONTRIBUTING.md docs: add a security policy 2026-11-28 14:23:05 +01:00
demo.gif docs: switch root README demo GIF to light paper theme 2026-11-29 22:48:15 +01:00
deploy.sh fix: vendor Starlight's base tokens and drop the barrel Icon import to fix homepage styling in production builds 2026-08-06 13:33:18 +02:00
deprecations.yaml chore(i18n): mark the deprecated frontmatter key labels for removal in 2.0.0 2026-11-29 19:51:17 +01:00
generate-release-note.ts feat(deprecations): add a deprecation registry, a drift checker and the 1.4.0 announcements (#73) 2026-10-01 22:55:26 +02:00
gram-logo.png chore: preparing for v1 release 2026-08-06 10:40:53 +02:00
lefthook.yml feat(renderer): modernize HTML recipe view layout and intermediate traceability (#126) 2026-11-11 16:02:27 +01:00
LICENSE Initial commit 2025-12-28 20:39:17 +01:00
package.json Merge remote-tracking branch 'origin/main' into chore/merge-main-into-dev-1.6-2026-11-28 2026-11-28 00:14:29 +01:00
README.md docs: add design decisions page and refine project positioning copy 2026-11-30 10:49:48 +01:00
renovate.json chore: add Renovate config for typescript/turbo/biome/bun 2026-08-14 23:01:35 +02:00
screenshot.png docs: refresh the playground screenshot 2026-11-12 23:17:27 +01:00
SECURITY.md docs(security): say that symbolic links of a cloned repository are followed 2026-11-29 19:51:16 +01:00
tsconfig.base.json fix: make compiler ids deterministic per-compile, add CI/lint/typecheck infrastructure 2026-07-06 12:48:14 +02:00
tsconfig.build.json chore: cleaned up tsconfig 2026-06-18 21:49:42 +02:00
turbo.json feat(parser): ship a plist TextMate grammar for Sublime Text 2026-11-24 16:47:00 +01:00

Gram Logo

Gram

Code your recipes.

Build Status npm Version VS Code Extension Open VSX Extension License Made in EU

An open-source recipe DSL (GPL-3.0) for developers who cook, and for anyone building recipe tooling. Gram compiles plain-text .gram files into strict, deterministic JSON, backed by a CLI, a Language Server (LSP), and editor integrations.

Website • Playground • Documentation


Gram demo: mass standardization, @use imports, and backward ALAP scheduling

Note

Gram is an independent open-source project. Primary development happens on Forgejo, with read-only automatic mirrors on GitHub and Codeberg.

Issues and pull requests are handled on Forgejo. See CONTRIBUTING.md if you want to get involved.

Quick example

Gram works for simple everyday recipes and shines on technical cooking: baking, pastry, fermentation, shared base recipes, or multi-day prep.

## Dough ->&dough

[Mix] @*bread flour{500g}, @water{70% @&bread flour}, and @salt{2% @&bread flour}.

[Ferment] Cold retard for ~_{12-24h} at ^{4°C}.

## Bake

[Bake] The &dough at ^{250°C}(stone) for ~{6min} until ={blistered}.

From those 6 lines, Gram resolves 350g of water and 10g of salt from baker's percentages, recalculates every quantity whenever the flour weight changes, separates active work from the 12-24h cold retard to plan two kitchen visits backward from dinner, estimates nutrition from your local ingredient database, and outputs structured JSON.

You can edit live recipes in the browser with no install at gram-lang.org/play.

What Gram does

  • Plain text you own: recipes live as readable .gram files in Git (ingredients, cookware, temperatures, and target states like ={blistered}), with no cloud, no account, and no proprietary database.
  • Baker's math and unit ratios: declare relative percentages (@water{70% @&flour}), unit ratios (@garlic{1 clove / 100g @&beef}, ~{15min / 500g @&roast}), and compound quantities (@flour{1 cup + 2 tbsp}).
  • Modular recipes and references: import base recipes with @use "./bases/shortcrust.gram" as &crust (with automatic yield scaling and unified shopping lists), pass intermediate preparations between steps (->&dough), and split composite ingredients (<@lemons{2}) without double-counting them.
  • Backward (ALAP) scheduling and run sheets: separate active steps (~{35min}) from passive waits (~_{12-24h}). Gram schedules backward from your serving time, stretches range waits to keep active work out of the night, and produces a day-by-day run sheet telling you when to be in the kitchen and what to take out.
  • 100% deterministic, offline core: parsing, compiling, scaling, scheduling, nutrition analysis, and rendering run locally with no network calls and no AI. Optional AI-assisted commands (gram import, gram db enrich, gram db lint) live only in the CLI and use your own API key.

Tooling

Editors and language server

  • VS Code & Open VSX (VS Code Marketplace · Open VSX for VSCodium, Cursor, Windsurf, Positron): real-time diagnostics, autocomplete (ingredients from your YAML database, units, @use paths), hover info (nutrition, scaled weights, ratios), rename (F2), format on save, and side-by-side Live Preview and Run Sheet views.
  • Neovim, Helix and Zed: syntax highlighting and queries via tree-sitter-gram, plus the dedicated zed-gram extension for Zed.
  • Standalone LSP (@gram-lang/language-server): standard Language Server Protocol server usable from any editor. See the editors guide for setup instructions.

CLI (@gram-lang/cli)

Available on npm, running on Node.js (>=22) or Bun:

  • gram check, gram format, gram build: validate syntax, format .gram files canonically, and compile recipes to JSON.
  • gram view, gram export, gram print: render a recipe or its run sheet (--view run-sheet) in the terminal, or export to HTML, Markdown, plain text, and print layout.
  • gram plan: schedule a recipe backward from a serving time (--serve) within your available hours (--available), or find serving times that work (--find).
  • gram cook: step-by-step terminal cooking mode with live timers and target-state reminders.
  • gram scale, gram diff, gram shop, gram suggest: resize recipes, diff versions semantically, aggregate shopping lists across files, and filter recipes by ingredients on hand.
  • gram db sync and gram db validate: scan recipes for missing entries in ingredients.yaml and validate the database offline.
  • gram import, gram db enrich, and gram db lint (optional, BYOK): convert web URLs, JSON-LD files, or YouTube videos into .gram files, suggest missing density and nutrition data, or catch duplicates and plural mismatches in ingredients.yaml with interactive review before writing.

Try it out

Start a CLI project

npm install -g @gram-lang/cli
gram init
# or with Bun
bun add -g @gram-lang/cli
gram init

Use the compiler in JavaScript / TypeScript

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

const ast = getAST('## My Recipe\n\n[Mix] @flour{200g} and @water{100g}.');
const result = compile(ast);

console.log(result.shopping_list);

Run the docs and playground locally

Contributing to the monorepo requires Bun (see CONTRIBUTING.md):

bun install
bun run dev

Documentation

The full language specification, guides, and CLI reference are at gram-lang.org/docs/ (source in packages/docs/).

Project structure

Package Version Description
@gram-lang/parser npm Ohm.js parser generating the typed recipe AST.
@gram-lang/modules npm Resolves @use imports and composes multi-file recipe ASTs.
@gram-lang/kitchen npm Compiler turning the AST into compiled recipe JSON.
@gram-lang/scheduler npm Scheduling engine: backward ALAP timeline, availability projection, and run sheet grouping.
@gram-lang/format npm Canonical .gram source formatter.
@gram-lang/analyzer npm Mass standardization, yield metrics, nutrition estimation, and semantic recipe diffing.
@gram-lang/renderer npm Display layer: recipe and run sheet views in HTML, Markdown, plain text, and print.
@gram-lang/cli npm Command-line interface (gram).
@gram-lang/i18n npm Unit normalization, duration parsing, and EN/FR localization.
@gram-lang/language-server npm Language Server Protocol implementation.
vscode-extension VS Code Marketplace Visual Studio Code extension.
docs - Astro/Starlight documentation site and browser playground.

Development, testing and roadmap

Every push and pull request runs through Forgejo Actions:

  • Linting and formatting: Biome (bun run lint).
  • Typechecking: across the monorepo (bun run typecheck).
  • Unit tests: per-package suites (bun test).
  • Conformance suite: language-agnostic golden tests (bun run conformance) pinning AST, compiled JSON, and analyzed JSON outputs.
  • Deterministic fuzzer: property-based fuzzing across the parser, compiler, analyzer, linter, and formatter (bun run fuzz).

TypeScript today, Rust next

Gram started in TypeScript, and keeping a single implementation while the language still evolves makes iteration fast and lets the full compiler run natively in the browser playground. A Rust port of the core (parser, kitchen, analyzer, i18n) is planned once the spec settles: the language-agnostic conformance suite and tree-sitter-gram are already in place so the transition can happen without breaking JSON contracts or npm packages.

Acknowledgments

  • Cooklang: for pioneering plain-text recipe markup and inspiring Gram's initial syntax.
  • Ohm.js: for a readable PEG grammar that is pleasant to iterate on.
  • AI coding tools: Used throughout development to build and maintain the codebase, checked by the conformance suite, fuzzer, and CI tests.

Community and support

License

Gram is licensed under the GPL-3.0 license. Recipes you write in .gram belong entirely to you.