1 unstable release

0.1.1 Feb 14, 2026

#150 in Machine learning

MIT license

1MB
23K SLoC

Lumen Logo

Lumen

The AI-Native Programming Language

Build deterministic agent workflows with static types, first-class AI primitives, and markdown-native source files.

๐Ÿ“š Documentation ยท ๐ŸŽฎ Playground ยท ๐Ÿ› Issues ยท ๐Ÿ’ฌ Discussions

CI Status Docs Status Open VSX Crates.io License Stars


Why Lumen?

Building AI systems today means juggling Python notebooks, API clients, prompt templates, and orchestration frameworks. Lumen unifies this into one language:

Feature Lumen Traditional Stack
Tools Typed interfaces with policy constraints Framework wrappers
Grants Built-in safety limits (tokens, timeouts, domains) Manual validation
Agents First-class language construct Class hierarchies
Processes Pipelines, state machines, memory built-in External libraries
Effects Algebraic effects with handlers, explicit in type signatures Try/catch or monads, implicit
Source Markdown-native (.lm.md, .lumen) + raw (.lm) Separate code and docs

Quick Start

# Install (One-liner)
curl -fsSL https://raw.githubusercontent.com/alliecatowo/lumen/main/scripts/install.sh | sh

# Or via Cargo
cargo install lumen-lang

# Create your first program
cat > hello.lm.md << 'EOF'
cell main() -> String
  return "Hello, World!"
end
EOF

# Run it
lumen run hello.lm.md

Features

  • Algebraic Effects: First-class effect handling with perform and handle constructs
  • Markdown-Native Source: Write code and docs together in .lm.md or .lumen files
  • Static Typing: Full type inference with compile-time error checking
  • AI Tool Dispatch: Typed tool interfaces with policy constraints
  • Register-Based VM: Efficient bytecode execution
  • Full LSP Support: Hover, document symbols, signature help, semantic tokens, diagnostics

๐Ÿ“ Markdown-Native Source

Write code and documentation together in .lm.md or .lumen, or use .lm for source-only modules:

# User Authentication

This module handles user login and session management.

```lumen
record User
  id: String
  name: String
  email: String where email.contains("@")
end

cell authenticate(email: String, password: String) -> result[User, String]
  # Implementation here
end
```

๐Ÿ”’ Statically Typed

Catch errors at compile time:

cell divide(a: Int, b: Int) -> result[Int, String]
  if b == 0
    return err("Division by zero")
  end
  return ok(a / b)
end

๐ŸŽฏ Algebraic Effects

First-class effect handling with one-shot delimited continuations:

effect Log
  cell info(msg: String) -> Unit
end

cell main() -> String / {Log}
  perform Log.info("Starting")
  return "Done"
end

handle main() with Log.info(msg) -> resume(unit)
  print("LOG: {msg}")
end

๐Ÿค– AI-Native Constructs

Tools, grants, and agents are built-in:

use tool llm.chat as Chat

grant Chat
  model "gpt-4o"
  max_tokens 1024
  temperature 0.7

agent Assistant
  cell respond(message: String) -> String / {llm}
    role system: You are a helpful assistant.
    role user: {message}
    return Chat(prompt: message)
  end
end

โšก Deterministic Runtime

Reproducible execution for auditable AI:

@deterministic true

cell main() -> String
  # Nondeterministic operations rejected at compile time
  # uuid()      # Error!
  # timestamp() # Error!
  return "Deterministic output"
end

๐ŸŒ WASM Ready

Compile to WebAssembly for browser execution:

lumen build wasm --target web

Documentation

Resource Description
Getting Started Installation and first program
Tutorial Step-by-step language guide
AI-Native Features Tools, grants, agents, processes
Language Reference Complete specification
API Reference Standard library
Playground Try Lumen in your browser

Examples

Example Description
Hello World Basic program
AI Chat LLM-powered chatbot
State Machine Machine process
Data Pipeline Pipeline process
Code Reviewer AI code analysis
Syntax Sugar Pipes, ranges, interpolation
Fibonacci Recursive algorithms
Linked List Generic data structures

See all 30 examples in the examples directory.

Language Tour

Cells (Functions)

cell greet(name: String) -> String
  return "Hello, {name}!"
end

Records with Constraints

record Product
  name: String where length(name) > 0
  price: Float where price >= 0.0
end

Pattern Matching

cell classify(n: Int) -> String
  match n
    0 -> return "zero"
    1 -> return "one"
    _ -> return "many"
  end
end

Error Handling

cell safe_divide(a: Int, b: Int) -> String
  match divide(a, b)
    ok(value) -> return "Result: {value}"
    err(msg) -> return "Error: {msg}"
  end
end

Processes

pipeline DataProcessor
  stages:
    -> extract
    -> transform
    -> load
  
  cell extract(source: String) -> list[Json]
    # Extract data
  end
  
  cell transform(data: list[Json]) -> list[Record]
    # Transform data
  end
  
  cell load(records: list[Record]) -> Int
    # Load data
  end
end

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            .lm.md / .lm / .lumen Source Files                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Markdown Extraction (.lm.md/.lumen) / Direct Parse (.lm)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Lexer โ†’ Parser โ†’ Resolver โ†’ Typechecker โ†’ Constraint Val   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    LIR Bytecode                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Register VM                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”‚
โ”‚  โ”‚  Values  โ”‚ โ”‚ Futures  โ”‚ โ”‚  Tools   โ”‚ โ”‚ Traces   โ”‚       โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Development

# Clone
git clone https://github.com/alliecatowo/lumen.git
cd lumen

# Build
cargo build --release

# Test (1365+ tests)
cargo test --workspace

# Run
cargo run --bin lumen -- run examples/hello.lm.md

Repository Structure

lumen/
โ”œโ”€โ”€ docs/                    # VitePress documentation site
โ”‚   โ”œโ”€โ”€ learn/              # Tutorials and guides
โ”‚   โ”œโ”€โ”€ reference/          # Language specification
โ”‚   โ”œโ”€โ”€ api/                # Standard library docs
โ”‚   โ””โ”€โ”€ examples/           # Example documentation
โ”œโ”€โ”€ examples/               # Example programs
โ”œโ”€โ”€ editors/               # Editor support (VS Code)
โ”œโ”€โ”€ rust/
โ”‚   โ”œโ”€โ”€ lumen-compiler/    # Compiler pipeline
โ”‚   โ”œโ”€โ”€ lumen-vm/          # Register-based virtual machine
โ”‚   โ”œโ”€โ”€ lumen-runtime/     # Runtime: tool dispatch, caching, tracing
โ”‚   โ”œโ”€โ”€ lumen-cli/         # Command-line interface
โ”‚   โ”œโ”€โ”€ lumen-lsp/         # Language Server Protocol
โ”‚   โ”œโ”€โ”€ lumen-wasm/        # WebAssembly bindings
โ”‚   โ””โ”€โ”€ lumen-provider-*/  # Tool providers (HTTP, JSON, FS, MCP)
โ”œโ”€โ”€ SPEC.md                # Implementation-accurate spec
โ””โ”€โ”€ CLAUDE.md              # AI assistant instructions

Contributing

We welcome contributions! Please see:

License

MIT License - see LICENSE for details.


Made with โค๏ธ by the Lumen community

Dependencies

~2.1โ€“3.5MB
~68K SLoC