Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 5.24 KB

cli.md

File metadata and controls

79 lines (60 loc) · 5.24 KB

CLI reference (forma and forma-3d)

Forma ships two command-line executables backed by the same forma-lang and forma-core crates (v0.4.4):

  • forma: native Rust binary compiled from crates/forma-cli/src/main.rs.
  • forma-3d (alias forma inside the npm package): Node.js (>=18.0.0) WebAssembly wrapper at bin/forma.mjs.

Subcommands

Subcommand Native forma WASM forma-3d Description
eval Yes Yes Evaluate a script from a file path or stdin (- or omitted), print observation, and optionally export mesh, PNG, or SVG.
render Yes Yes Evaluate a script and render a software PNG preview (--out preview.png required).
draw Yes Yes Evaluate a script and generate a 3-view orthographic SVG blueprint (--out blueprint.svg required).
spec Yes Yes Print the compiled Forma-Pipe or Forma-DSL specification, a progressive --topic spec, or the --gbnf grammar.
mcp Separate binary (forma-mcp) Yes (forma-3d mcp / forma-3d-mcp) Start the stdio JSON-RPC 2.0 MCP server.
version / --version / -V Yes Yes Print the CLI version string (forma 0.4.4).
help / --help / -h Yes Yes Print usage summary.

eval options

Flag Default Native forma WASM forma-3d Behavior
--dialect, -d <pipe|compact> pipe Yes Yes Select Forma-Pipe (pipe) or Forma-DSL (compact).
--unit, -u <m|cm|mm|um|in|ft> m Yes Yes Set initial scene model unit before evaluating script.
--strict Enabled Yes Yes Enforce watertightness, zero non-manifold edges, finite vertices, and non-degenerate volume.
--no-strict Disabled Yes Yes Disable strict invariant rejection and exit code 3.
--json Disabled Yes Yes Print full Observation JSON to stdout instead of compact text.
--scene Disabled Yes Yes Export/render/draw all named parts together (.glb, .blend, .png, .svg) instead of only the last assigned part.
--out, -o <path> None Yes Yes Export mesh (.glb, .obj, .stl, .3mf, .step, .blend via Blender bridge).
--render <path.png> None Yes Yes Render PNG preview alongside eval.
--view <view> quad Yes Yes Camera view for --render / render: quad, front, back, right, left, top, iso.
--size <px> 512 Yes Yes Output PNG dimension in pixels (quad renders 4-view preview at size).
--draw <path.svg> None Yes Yes Emit 3-view orthographic SVG engineering drawing.
[file|-] stdin Yes Yes Script file path; reads stdin when omitted or -.

render, draw, and spec options

render

  • Native: forma render [--dialect pipe|compact] [--unit m|cm|mm|um|in|ft] [--scene] [--view quad|front|back|right|left|top|iso] [--size 512] --out preview.png [file|-]
  • WASM: forma-3d render [--dialect pipe|compact] [--unit m|cm|mm|um|in|ft] [--scene] [--view quad|front|back|right|left|top|iso] [--size 512] --out preview.png [file|-]

draw

  • Native: forma draw [--dialect pipe|compact] [--unit m|cm|mm|um|in|ft] [--scene] --out blueprint.svg [file|-]
  • WASM: forma-3d draw [--dialect pipe|compact] [--unit m|cm|mm|um|in|ft] [--scene] --out blueprint.svg [file|-]

spec

  • Both CLIs: spec [--dialect pipe|compact] [--topic <deform|curves|uv|normals|remesh|scene>] [--gbnf] (also accepts topic as a positional argument, e.g. forma spec deform).

Exit codes

Code Meaning
0 Evaluation and all requested exports/renders succeeded.
1 Script syntax/evaluation error, export error, or file I/O error.
2 Invalid CLI argument, missing required flag value, or unknown subcommand.
3 Strict manifold/invariant check failed (--strict auto-rollback or obs.ok == false, e.g. WT!=ok, NM>0, self-intersection).

Environment variables

Variable Surface Default Effect
BLENDER_BIN Native forma/forma-mcp and Node forma-3d/forma-3d-mcp blender on PATH (or macOS /Applications/Blender.app/Contents/MacOS/Blender) Path to local Blender binary invoked when exporting .blend.
FORMA_BIN sandbox/forma.py Auto-discovered Explicit path to static forma binary in air-gapped Python sandboxes.

Native vs WASM parity matrix

Capability Native forma WASM forma-3d Notes
Forma-Pipe and Forma-DSL evaluation Yes Yes Identical forma-lang and forma-core code.
In-script units("mm") declaration Yes Yes Portable across every runtime surface.
CLI --unit / -u flag Yes Yes Sets initial unit before evaluating the script.
CLI --view single-angle PNG flag Yes Yes Both CLIs support quad, front, back, right, left, top, iso.
.glb, .step, .3mf, .stl, .obj, .png, .svg Yes Yes Identical exporters and software rasterizer.
.blend stock-Blender bridge export Yes Yes (Node CLI/MCP) Uses local Blender (BLENDER_BIN or blender on PATH).
Built-in mcp subcommand Separate binary (forma-mcp) Yes (forma-3d mcp) Native builds separate forma and forma-mcp binaries.