gram/packages/cli/README.md

3.2 KiB

@gram-lang/cli

npm License: GPL v3

Part of the Gram monorepo · Documentation

Command-line interface (gram) for the Gram recipe DSL. Validate, format, compile, view, plan, scale, diff, cook, and manage ingredient databases directly from the terminal. Runs on Node.js (>=22) and Bun.

All core commands run offline and deterministically with no AI. Optional AI-assisted commands (gram import, gram db enrich, gram db lint) use your own API key.

Installation

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

This installs the gram executable globally.

Usage

# Initialize a new Gram project in the current directory
gram init

# Validate, format canonically, and compile a recipe to JSON
gram check my-recipe.gram
gram format my-recipe.gram
gram build my-recipe.gram --output dist/

# Read a recipe in the terminal, with the same settings as the editor
gram view my-recipe.gram
gram view my-recipe.gram --mise-en-place upfront --rests longest

# Plan a recipe backward from a serving time within your available hours
gram plan my-recipe.gram --serve "2026-10-11 13:00" --available 08:00-22:00
gram plan my-recipe.gram --find 2026-10-12/2026-10-15

# Export or print the recipe or its run sheet
gram export my-recipe.gram --format html
gram print my-recipe.gram --view run-sheet --serve "2026-10-11 13:00"

# Cook step by step in the terminal with live timers and target-state reminders
gram cook my-recipe.gram

# Scale, compare versions semantically, build shopping lists, and search by ingredients
gram scale my-recipe.gram --scale 2
gram diff v1.gram v2.gram
gram shop "menus/*.gram"
gram shop "menus/*.gram" --format json
gram suggest --with "butter, eggs"

# Maintain your ingredients.yaml database offline
gram db sync "**/*.gram"
gram db validate

# Optional AI-assisted commands (BYOK)
gram import https://example.com/recipe -o my-recipe.gram
gram db enrich
gram db lint

# Watch files on save and inspect project config
gram watch
gram config list

Run gram --help for the full command list and options.

Structure

  • src/index.ts: CLI entry point registering all subcommands.
  • src/commands/: one file per subcommand (init, check, format, build, watch, view, plan, export, print, cook, scale, diff, shop, suggest, import, db, config, upgrade).
  • src/core/: shared building blocks (config loading, ingredient database, pipeline orchestration).
  • src/services/: command logic (formatting, scaling, importing, syncing).
  • src/ui/: terminal rendering (tables, diffs, interactive views).
  • src/prompts/: optional AI system prompts used by gram import, gram db enrich, and gram db lint.

Issues and license

Issues and pull requests are handled on Forgejo.

Licensed under the GPL-3.0 license.