1 unstable release
| 0.1.1 | Feb 14, 2026 |
|---|
#150 in Machine learning
1MB
23K
SLoC
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
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
performandhandleconstructs - Markdown-Native Source: Write code and docs together in
.lm.mdor.lumenfiles - 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