Lambda CLI Reference

July 1, 2026 · View on GitHub

Lambda Script Interpreter v1.0

Synopsis

lambda                                      # Start interactive REPL
lambda <script.ls> [options]                # Run a functional script (JIT compiled)
lambda <command> [options] [arguments]      # Run a subcommand

Default Behavior

When invoked with no arguments, Lambda starts the REPL (Read-Eval-Print Loop).

When invoked with a .ls script file (and no subcommand), Lambda compiles and executes the script using JIT compilation (C2MIR).


Global Options

These options apply when running a script directly (i.e., lambda <script.ls>).

FlagLong FormDescriptionDefault
-h--helpShow help message
--c2mirUse C2MIR JIT compilation instead of MIR Directfalse
--transpile-onlyTranspile to C code only (no execution)false
--transpile-dir DIRDirectory for transpiled C output filestemp
--max-errors NMax type errors before stopping (0 = unlimited)10
--optimize=NMIR JIT optimization level2
-O0Optimization level 0 (debug, stack traces)
-O1Optimization level 1 (basic)
-O2Optimization level 2 (full)
-O3Optimization level 3
--dry-runSkip real I/O; return fabricated results for network/filesystem operationsfalse

Optimization Levels

LevelDescription
0Debug mode with stack trace support
1Basic optimizations
2Full optimizations (default)
3Aggressive optimizations

Diagnostic Flags (Global)

These flags are recognized before any subcommand and stripped from the argument list, so they work in every mode (REPL, script, run, convert, layout, render, …).

FlagDescription
--no-logDisable all logging for this invocation
--mem-dump[=PATH]On process exit, write a JSON snapshot of the memory context and log a leak report. PATH defaults to ./temp/mem_snapshot.json

Memory Dump (--mem-dump)

Lambda centralizes pool/arena/heap allocation under a single rooted memory context (see vibe/Memory_Context.md). --mem-dump captures that context at process exit and produces:

  • A JSON snapshot — a flat array of allocator nodes, each with id, parent_id (its backing allocator), doc_id, kind (pool / arena / heap / nursery / cache / jit / …), role (input / ast / view / render / font / …), label, and bytes_reserved / bytes_in_use / alloc_count.
  • A leak report — logged to ./log.txt with the MEMCTX-LEAK: prefix, listing every allocator still live at exit (with its role, label, and size).
lambda --mem-dump script.ls                          # dump to ./temp/mem_snapshot.json
lambda --mem-dump=./temp/mem.json layout page.html   # dump to a custom path

Example snapshot:

{
  "captured_seq": 3, "count": 2,
  "total_reserved": 60507, "total_in_use": 60507,
  "nodes": [
    { "id": 2, "parent_id": 0, "doc_id": 0, "kind": "pool", "role": "input",
      "label": "input.global_pool", "bytes_reserved": 55835, "bytes_in_use": 55835, "alloc_count": 392 },
    { "id": 3, "parent_id": 0, "doc_id": 0, "kind": "pool", "role": "ast",
      "label": "script.result", "bytes_reserved": 4672, "bytes_in_use": 4672, "alloc_count": 5 }
  ]
}

Notes:

  • Place the flag before the subcommand — it is parsed globally and stripped from argv.
  • The snapshot reflects allocators still alive at the exit cleanup point; transient pools created and freed during the run are correctly absent.
  • The convert subcommand returns before the shared exit path, so its dump is empty (the conversion itself still completes normally). Script mode, layout, and render reach the exit hook.

Commands

run — Run a Procedural Script

Executes a Lambda script with main() procedure entry point. If main() returns a non-null value, that value is printed to stdout.

lambda run [options] <script.ls>

Options:

FlagLong FormDescription
-h--helpShow help
--c2mirUse C2MIR JIT compilation
--transpile-dir DIRDirectory for transpiled C output

Example:

lambda run script.ls
lambda run --c2mir script.ls

validate — Validate Data Against a Schema

Validates one or more data files against a Lambda schema.

lambda validate [-s <schema>] [-f <format>] [options] <file> [files...]

Options:

FlagLong FormDescriptionDefault
-s <schema>Schema file (.ls)Auto-selected based on format
-f <format>Input formatAuto-detect from extension
--strictStrict mode — all optional fields must be present or nullfalse
--max-errors NStop after N errors100
--max-depth NMaximum validation depth for nested structures100
--allow-unknownAllow fields not defined in schemafalse
-h--helpShow help

Supported input formats (auto-detected from extension):

json, csv, ini, toml, yaml/yml, xml, markdown/md, rst, html/htm, latex, rtf, pdf, wiki, asciidoc/adoc, man, eml, ics, vcf, textile/txtl, mark/mk/m, text

Built-in schemas (no -s needed):

FormatDefault Schema
htmlhtml5_schema.ls
emleml_schema.ls
icsics_schema.ls
vcfvcf_schema.ls
asciidoc, man, markdown, rst, textile, wikidoc_schema.ls
.ls filesBuilt-in AST validation

Formats such as json, xml, yaml, csv, ini, toml, latex, rtf, pdf, and text require an explicit schema via -s.

Examples:

lambda validate data.json -s schema.ls
lambda validate page.html
lambda validate --strict config.yaml -s config_schema.ls --max-errors 50
lambda validate file1.json file2.json -s schema.ls

convert — Format Conversion

Convert data between supported formats.

lambda convert <input> [-f <from>] -t <to> -o <output> [options]

Options:

FlagLong FormDescriptionDefault
-f <from>--fromInput formatAuto-detect
-t <to>--toOutput format (required)
-o <output>--outputOutput file path (required)
--full-documentFor LaTeX→HTML: generate complete HTML document with CSSfalse
--pipeline legacy|unifiedPipeline selection
-h--helpShow help

Supported output formats:

mark, json, xml, html, yaml, toml, ini, css, jsx, mdx, latex, rst, org, wiki, textile, text, markdown/md, math-ascii, math-latex, math-typst, math-mathml, properties

The input format flag -f supports colon-separated type:flavor syntax (e.g., graph:mermaid).

Examples:

lambda convert input.json -t yaml -o output.yaml
lambda convert doc.md -t html -o doc.html
lambda convert formula.tex -t html -o formula.html --full-document
lambda convert data.xml -f xml -t json -o data.json

layout — HTML/CSS Layout Analysis

Run the CSS layout engine and output the computed layout tree.

lambda layout <file> [more files...] [options]

Options:

FlagLong FormDescriptionDefault
-o--output FILEOutput file for layout resultsstdout
--output-dir DIROutput directory for batch mode (required for multiple files)
--view-output FILECustom output path for view_tree.json (single file mode)
-c--css FILEExternal CSS file to apply (HTML only)
-vw--viewport-width WIDTHViewport width in pixels1200
-vh--viewport-height HEIGHTViewport height in pixels800
--flavor FLAVORLaTeX rendering flavor: latex-js or tex-properlatex-js
--continue-on-errorContinue processing on errors in batch modefalse
--summaryPrint summary statisticsfalse
--debugEnable debug outputfalse
--helpShow help

Supported input formats: .html/.htm, .tex/.latex, .ls

Examples:

lambda layout page.html
lambda layout page.html -o layout.txt
lambda layout page.html -vw 800 -vh 600
lambda layout doc.tex --flavor tex-proper
lambda layout *.html --output-dir results/ --summary

render — Render to Image or Document

Render HTML, LaTeX, or diagram files to SVG, PDF, PNG, or JPEG.

lambda render <input> -o <output> [options]

Options:

FlagLong FormDescriptionDefault
-o--outputOutput file path (required; format inferred from extension)
-vw--viewport-widthViewport width in CSS pixelsAuto-size to content
-vh--viewport-heightViewport height in CSS pixelsAuto-size to content
-s--scaleUser zoom scale factor1.0
--pixel-ratioDevice pixel ratio for HiDPI/Retina displays1.0
-t--theme <name>Color theme for graph diagramszinc-dark
-h--helpShow help

Supported input formats:

ExtensionFormat
.html, .htmHTML
.tex, .latexLaTeX
.lsLambda Script
.mmdMermaid diagram
.d2D2 diagram
.dot, .gvGraphViz diagram

Supported output formats: .svg, .pdf, .png, .jpg/.jpeg

Default viewport sizes (when not auto-sizing):

OutputWidthHeight
SVG, PNG, JPEG1200800
PDF8001200

Available themes:

tokyo-night, nord, dracula, catppuccin-mocha, one-dark, github-dark, github-light, solarized-light, catppuccin-latte, zinc-dark, zinc-light, dark, light

Examples:

lambda render page.html -o output.svg
lambda render doc.tex -o doc.pdf
lambda render page.html -o screenshot.png -vw 1920 -vh 1080 --pixel-ratio 2.0
lambda render diagram.mmd -o diagram.svg -t github-dark
lambda render graph.d2 -o graph.png

view — Interactive Document Viewer

Open a document in an interactive viewer window.

lambda view [document_file] [options]

Options:

FlagLong FormDescriptionDefault
--event-file <file.json>Load simulated events from JSON for testing
-h--helpShow help

Default file: test/html/index.html (when no file is specified)

Supported formats:

.pdf, .html/.htm, .md/.markdown, .tex/.latex, .ls, .xml, .rst, .wiki, .svg, .mmd, .d2, .dot/.gv, .png, .jpg/.jpeg, .gif, .json, .yaml/.yml, .toml, .txt, .csv, .ini, .conf, .cfg, .log

Also accepts HTTP/HTTPS URLs — fetches content, detects type from Content-Type header, and injects <base> tag for HTML.

Keyboard controls:

KeyAction
ESCClose window
QQuit viewer

Examples:

lambda view page.html
lambda view report.pdf
lambda view https://example.com
lambda view diagram.mmd

fetch — HTTP/HTTPS Resource Download

Download a remote resource via HTTP or HTTPS.

lambda fetch <url> [options]

Options:

FlagLong FormDescriptionDefault
-o--output <file>Save output to filestdout
-t--timeout <ms>Request timeout in milliseconds30000 (30s)
-v--verboseShow detailed progress and timingfalse
-h--helpShow help

Examples:

lambda fetch https://example.com/data.json
lambda fetch https://example.com/data.json -o data.json
lambda fetch https://api.example.com/endpoint -t 5000 -v

js — JavaScript Transpiler

Run JavaScript code through the Lambda JavaScript transpiler.

lambda js [file.js] [--document page.html]

Options:

FlagDescription
--document <file.html>Load an HTML document for DOM API access
-h, --helpShow help

If no file is provided, runs built-in test cases.

Examples:

lambda js app.js
lambda js app.js --document index.html

math — Math Rendering (Deprecated)

lambda math

This command is deprecated. Use lambda run <script.ls> to render math formulas instead.


REPL

When Lambda is started with no arguments, it enters the interactive REPL.

Prompt: λ> (UTF-8 terminals) or > (fallback) Continuation prompt: ..

REPL Commands

CommandDescription
quit, q, exitExit the REPL
help, hShow help
clearClear REPL history

Environment Variables

VariableValuesDescription
MEMTRACK_MODEOFF, STATS, DEBUGMemory tracker mode (default: STATS)

Logging

Lambda logs to ./log.txt. Logging is configured via log.conf (if present). Use log_debug(), log_info(), and log_error() levels.


Quick Reference

# Start REPL
lambda

# Run a functional script
lambda script.ls

# Run a procedural script with main()
lambda run script.ls

# Validate a file
lambda validate data.json -s schema.ls

# Convert between formats
lambda convert input.json -t yaml -o output.yaml

# Layout HTML/CSS
lambda layout page.html

# Render to SVG/PDF/PNG
lambda render page.html -o output.svg

# Open in viewer
lambda view page.html

# Fetch a URL
lambda fetch https://example.com -o page.html

# Run JavaScript
lambda js app.js

# Dump the memory context as JSON at exit (+ leak report in log.txt)
lambda --mem-dump script.ls