The Tools
The tessera command is the compiler, and also everything around it: a formatter, a documentation generator, a test runner, a language server and a server for coding agents. This appendix is a quick tour. tessera with no arguments lists every command.
Running and building
| Command | Does |
|---|---|
tessera run FILE | type-check, then run in the interpreter; --native compiles first |
tessera build FILE -o OUT | compile to a native binary through C; --emit-c writes the C instead |
tessera check FILE | type-check only; --json for tools |
tessera test FILE | run the file's tests; --bench adds benchmarks |
tessera caps FILE | list what each function can do, and the files the program embeds |
tessera explain CODE | explain an error code |
tessera spec | print the language specification |
run, and binaries made by build, take --grant KIND=VALUE for each capability (chapter 12), --seed N to make random numbers repeatable, --no-sandbox to turn the operating-system sandbox off while debugging, and program arguments after --.
tessera fmt
There is one way to format Tessera code, and tessera fmt applies it. It prints the formatted file, rewrites it with --write, or fails with --check if a file isn't formatted, which is what CI runs. Every listing in this book passes tessera fmt --check.
$ cp messy.txt messy.tsr && tessera fmt messy.tsr
fn area(w: Int, h: Int) -> Int { w * h }
fn main(root: Root) {
let a = area(3, 4)
root.stdout.print("{a}")
}
$ tessera fmt --check messy.tsr
not formatted: messy.tsr
The formatter keeps comments where they were written, and keeps your line breaks in long lists and argument lists, so it tidies code without rearranging it.
tessera doc
tessera doc builds documentation from doc comments, the // lines directly above an item, and from signatures. It writes Markdown, or with --html a single static page:
$ tessera doc geometry.tsr
# Module `geometry`
Shapes on a plane.
## Types
### struct `Point`
```tessera
pub struct Point {
x: Float,
y: Float,
}
```
## Functions
### fn `distance`
```tessera
pub fn distance(a: Point, b: Point) -> Float
```
How far apart two points are.
### fn `origin`
```tessera
pub fn origin() -> Point
```
tessera doc --std --html -o std.html documents the whole standard library.
tessera explain
Every diagnostic has a code, and tessera explain says more about it than fits in an error message:
$ tessera explain E0112
E0112: Only struct and enum values can become `dyn Interface`, and only if they hold no capability, function or channel, directly or through the fields of the structs and enums inside them (`struct App { client: Client }` holds the `Net` of `struct Client { net: Net }`; the message names the path). A `dyn` value hides its concrete type, so it must not hide authority either; pass such values with a type parameter bounded by the interface instead: `fn show[T: Named](x: T)`.
tessera lsp
tessera lsp is a language server, for any editor that speaks the Language Server Protocol. It gives diagnostics as you type, hover with types and doc comments, go to definition and find references across modules, completion, an outline, the checker's fixes as quick fixes, and rename. Rename refuses when it would be unsafe: the renamed program must still check, with the new name referring to exactly the renamed places.
In Neovim:
vim.lsp.start({ name = "tessera", cmd = { "tessera", "lsp" }, root_dir = vim.fn.getcwd() })
The compiler repository also has a VS Code extension under editors/vscode, with highlighting and the language server.
tessera mcp
tessera mcp is a server for coding agents, speaking the Model Context Protocol. It offers the same operations as the language server, plus running programs and tests and reading the spec. A program run through it gets no grants, so code an agent has just written can print but can't touch files or the network, and it stops at a time limit.
The repository's grammar/tessera.gbnf is the grammar in GBNF form, for tools that constrain a model's output to valid syntax.
Packages
| Command | Does |
|---|---|
tessera search WORDS | search the package index named by TESSERA_INDEX |
tessera add NAME[@VERSION] | add a package to tessera.toml, with the capabilities the index lists |
tessera index entry | print the index entry for the current tag of a package |
Chapter 7 covers them.