An open API service indexing awesome lists of open source software.

https://github.com/alliecatowo/lumen

Lumen - A markdown-native, statically typed programming language for AI-native systems. Build deterministic agent workflows with first-class AI primitives.
https://github.com/alliecatowo/lumen

agent ai anthropic chatgpt compiler interpreter language-design llm markdown openai programming-language rust static-typing type-system virtual-machine wasm webassembly

Last synced: about 1 month ago
JSON representation

Lumen - A markdown-native, statically typed programming language for AI-native systems. Build deterministic agent workflows with first-class AI primitives.

Awesome Lists containing this project

README

          


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

```bash
# 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:

````markdown
# 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:

```lumen
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:

```lumen
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:

```lumen
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:

```lumen
@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:

```bash
lumen build wasm --target web
```

## Documentation

| Resource | Description |
|----------|-------------|
| [Getting Started](https://alliecatowo.github.io/lumen/learn/getting-started) | Installation and first program |
| [Tutorial](https://alliecatowo.github.io/lumen/learn/tutorial/basics) | Step-by-step language guide |
| [AI-Native Features](https://alliecatowo.github.io/lumen/learn/ai-native/tools) | Tools, grants, agents, processes |
| [Language Reference](https://alliecatowo.github.io/lumen/reference/overview) | Complete specification |
| [API Reference](https://alliecatowo.github.io/lumen/api/builtins) | Standard library |
| [Playground](https://alliecatowo.github.io/lumen/playground) | Try Lumen in your browser |

## Examples

| Example | Description |
|---------|-------------|
| [Hello World](examples/hello.lm.md) | Basic program |
| [AI Chat](examples/ai_chat.lm.md) | LLM-powered chatbot |
| [State Machine](examples/state_machine.lm.md) | Machine process |
| [Data Pipeline](examples/data_pipeline.lm.md) | Pipeline process |
| [Code Reviewer](examples/code_reviewer.lm.md) | AI code analysis |
| [Syntax Sugar](examples/syntax_sugar.lm.md) | Pipes, ranges, interpolation |
| [Fibonacci](examples/fibonacci.lm.md) | Recursive algorithms |
| [Linked List](examples/linked_list.lm.md) | Generic data structures |

See all [30 examples](https://github.com/alliecatowo/lumen/tree/main/examples) in the examples directory.

## Language Tour

### Cells (Functions)

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

### Records with Constraints

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

### Pattern Matching

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

### Error Handling

```lumen
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

```lumen
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

```bash
# 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:

- [Contributing Guide](https://github.com/alliecatowo/lumen/blob/main/CONTRIBUTING.md)
- [Code of Conduct](https://github.com/alliecatowo/lumen/blob/main/CODE_OF_CONDUCT.md)
- [Good First Issues](https://github.com/alliecatowo/lumen/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)

## License

MIT License - see [LICENSE](https://github.com/alliecatowo/lumen/blob/main/LICENSE) for details.

---


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