LM lmscript.io LMScript
LMScript ยท v0.2.38

LMScript Overview & Quickstart

LMScript (.lms) is a small, strict scripting language for orchestrating external command-line tools, cloud infrastructure, and LLM agents. Every simple statement ends with ;, every control-flow body is a { } block, missing keys/indices are caught immediately (never undefined), and embedded _lmcode_ blocks compile to verified DSLB v6 bytecode.

Why LMScript?

Strict by Construction

No `undefined`, no implicit shell parsing in system(argv), strict == without type coercion, block-owned variables that never leak out of if / for, and functions that cannot clobber caller variables.

Safe Execution Modes

Every script supports --check (static check + _lmcode_ bytecode compilation), --lint, --dry-run (evaluates with ordinary effects off and prints PLAN; reached LMCode hosts run with dry metadata), and --trace FILE (JSONL execution trace).

Embedded Typed Data & Bytecode

Embed validated _json_, _csv_, _toml_, _props_, _graphql_, _cmd_, and statically typed _lmcode_ chunks directly in your source file โ€” verified before a single line runs.

Resumable & Agent-Native

Built-in recover { resumepoint NAME: ... } entry selection for reruns, parallel([...]) & parallel_map, and unified agent_* sessions across CLI coding tools and embedded models.

Your First LMScript Program

hello_workflow.lms
#!/usr/bin/env lmscript

# 1. Embedded JSON configuration block (validated at check time)
cfg = _json_;
{
  "service": "lmscript.io",
  "regions": ["us-east-1", "us-west-2"],
  "thresholds": { "warn_ms": 50, "crit_ms": 150 }
}
end _json_
cfg = cfg.value();

# 2. Functions & 0-based list/string indexing
fn classify(latency, limits) {
  if (latency >= limits.crit_ms) {
    return "CRITICAL";
  } else if (latency >= limits.warn_ms) {
    return "WARNING";
  } else {
    return "OK";
  }
}

# 3. Format strings & iteration
for (i = 0; i < cfg.regions.len(); i = i + 1) {
  region = cfg.regions[i];
  status = classify((i + 1) * 60, cfg.thresholds);
  println(f"[{i}] {cfg.service} @ {region} -> {status}");
}

CLI Execution Modes & Exit Codes

CLI Modes
# Syntax check + _lmcode_ compile verification (no code executed)
lmscript --check hello_workflow.lms

# Static linter
lmscript --lint hello_workflow.lms

# Dry-run mode (ordinary effects off; reached LMCode hosts get dry metadata)
lmscript --dry-run hello_workflow.lms

# Execution trace (writes JSON Lines trace to trace.jsonl)
lmscript --trace trace.jsonl hello_workflow.lms

# Pass CLI arguments (populated into ARGV list)
lmscript hello_workflow.lms preview a1b2c3d4
Exit Code Meaning When Returned
0 Success Script (or --check / --lint / --dry-run) completed without error.
1 Runtime Error Failed require(...), assert(...), recorded error(...), or uncaught runtime error.
2 Static / Check Error Syntax error, scope error, invalid data block, or _lmcode_ static type/schema error (exits before any effect).