- README: what AI off still runs, exactly; what is passed on (nothing but the question from a full-screen program; a shell over ssh named as that machine's; the password case as the heuristic it is; context files removed at once or within ten minutes); suggestions only at a prompt and taken as drawn; answers bound to what was shown; the status record by variable decides nothing; settings per pane and not read with AI off; set-up refuses root and another version's release; TERM_PROGRAM kept on purpose; screen_lines in the sample; the shell's autocomplete gone. - llembas/README.md: every function of wezterm.llembas; contracts 1 to 4 as the authority; --cwd as contract 3 has it; context file version 2; the status authority, the answer lines, settings per pane, the writer thread, the PATH listings. - CHANGELOG: under Unreleased, Security and Fixed. - --help names llembas-term.lua; the fifteen one-word help edits in wezterm/src/cli carry a LLeMbas TERM: line above them, so that git grep 'LLeMbas TERM:' lists every change of ours again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
388 lines
30 KiB
Markdown
388 lines
30 KiB
Markdown
# The LLeMbas layer — developer notes
|
|
|
|
Everything LLeMbas TERM adds to WezTerm lives in this directory, in `scripts/`
|
|
and in one workflow file. WezTerm's own files are changed as little as
|
|
possible, and each changed block carries a `LLeMbas TERM:` comment, so that
|
|
merging upstream stays cheap (`git grep -n 'LLeMbas TERM:'` lists them all; a changed line of
|
|
help text, which a comment inside it would show, has the comment on the line above).
|
|
|
|
```
|
|
llembas/
|
|
lua/default-config.lua the configuration used when a person has none
|
|
lua/llembas/init.lua the layer: keys, palette, events, panes, files
|
|
lua/llembas/core.lua every decision of the layer, as pure functions
|
|
line/ a Rust crate with no dependencies: what is decided about a line of
|
|
text (the ask line's editor, the input line read from the screen,
|
|
the command history, suggestions, the parts of a command line)
|
|
tests/run.lua tests of the layer, against tests/fake_wezterm.lua
|
|
tests/shell-test.sh the shell integration's status record, in a real bash and zsh
|
|
tests/smoke.sh headless test of built binaries (CI)
|
|
tests/keys-gui.sh keys pressed in a real window on Xvfb: what reaches LLeMbas IDE's pane (CI)
|
|
shell/ shell integration: zones, cwd, the status record
|
|
packaging/ desktop file, appdata, icons, package.sh (.deb, tarball)
|
|
setup/llembas-term-setup installs the LLeMbas CLI and LLeMbas IDE when missing, verified
|
|
ci/ cargo-annotated.sh, disable-upstream-workflows.sh
|
|
wezterm-gui/src/llembas/ the thin Rust part in the terminal: the ask line (an overlay), what
|
|
is drawn on the input line when a pane is painted, wezterm.llembas
|
|
scripts/
|
|
test-lua.sh run tests/run.lua with lua5.4, lua, luajit or nvim -l
|
|
hygiene.sh nothing private in what the fork adds
|
|
.github/workflows/llembas-term.yml
|
|
```
|
|
|
|
## The three parts
|
|
|
|
| Part | Where | What it may do |
|
|
|---|---|---|
|
|
| The layer | `llembas/lua/` (Lua, built into the binary) | keys, palette, events; starts the display; talks to the CLI; writes the context file. Tested here, without a terminal. |
|
|
| The line logic | `llembas/line/` (Rust, no dependencies) | decides: editing, where the input line is among cells, what to suggest, what a part of a command line is. Knows no window, pane or font. Tested by `cargo test -p llembas-line`. |
|
|
| The drawing | `wezterm-gui/src/llembas/` (Rust) | fetches cells, places the result, takes keys. As thin as it can be, because only a person at a screen can check it. |
|
|
|
|
The layer asks for the drawing through `wezterm.llembas` (`wezterm-gui/src/llembas/lua.rs`):
|
|
`ask_line(window, pane, { prefix, event, text })`, `ask_active(pane_id)`,
|
|
`ask_prefix(window, pane, prefix)`, `configure { … }` (for every pane),
|
|
`configure_pane(pane_id, { … })` (what is on in one pane, by its own directory's settings),
|
|
`notice(pane, text)`, `hint(pane_id, text, gentle, source)`,
|
|
`status(pane_id, id, seq, state, dir)`, `complete_status()`, `data_dir()`, `real_path(path)`,
|
|
`local_dir(pane)` (the one answer to "is this pane's shell on this machine, and where"),
|
|
`set_private(pane_id, on)`, `command_ended(pane, exit, cwd)`, `clear_history()`. The layer
|
|
looks for each before calling it, so it also runs where they are missing (the mux server,
|
|
the tests).
|
|
|
|
**Upstream files the drawing touches**, each one block with a `LLeMbas TERM:` comment:
|
|
|
|
| File | The block | Why there |
|
|
|---|---|---|
|
|
| `wezterm-gui/src/main.rs` | `mod llembas;`, one `add_context_setup_func`, and `llembas::carry_over()` before the configuration is read | where the terminal's other Lua modules are registered; the last is *The earlier name*, below |
|
|
| `wezterm-gui/src/termwindow/render/pane.rs` | the pane's `with_lines_mut` goes through `llembas::decorate::with_lines_mut` | the one place a pane's lines are handed to the painter; with nothing on it is the same call as before |
|
|
| `wezterm-gui/src/termwindow/keyevent.rs` | a key no binding took may take the suggestion | after key bindings, before the key is sent to the pane |
|
|
| `wezterm-gui/Cargo.toml`, `Cargo.lock` | the dependency on `llembas/line` | |
|
|
|
|
The ask line needs no block of its own: it is an overlay over the pane, as the terminal's
|
|
search and quick select are, assigned through the functions those use.
|
|
|
|
## How the layer gets into the terminal
|
|
|
|
`config/src/llembas.rs` compiles the Lua files in as text (`include_str!`)
|
|
and puts a loader for each into `package.preload` of every Lua context, so
|
|
`require 'llembas'` works in any configuration file and no file has to be
|
|
installed. With no configuration file, `Config::try_builtin`
|
|
(`config/src/config.rs`) evaluates `lua/default-config.lua` instead of using
|
|
the bare defaults. `--skip-config` (`-n`) still gives the plain terminal with
|
|
no layer at all.
|
|
|
|
A new Lua module must be added to `MODULES` in `config/src/llembas.rs`.
|
|
|
|
## Rules the layer keeps
|
|
|
|
- **Nothing happens unasked.** `apply()` binds keys, adds palette entries and
|
|
registers event handlers. It starts no process and reads no pane. The
|
|
session bar reads only user variables (what a program set with OSC 1337
|
|
`SetUserVar`), never text.
|
|
- **Everything from a pane or a model is text.** User variables, command
|
|
output, titles, session lists and completions go through `core.clean`
|
|
(control characters removed, invalid UTF-8 replaced) and are capped before
|
|
they are shown, written or sent. Nothing is evaluated, nothing is passed
|
|
through a shell: processes are started with an argument list.
|
|
- **Decisions are in `core.lua`, calls in `init.lua`.** A change to what the
|
|
layer decides comes with a test in `tests/run.lua`.
|
|
- **Lua 5.1 and 5.4.** The terminal embeds Lua 5.4; the tests also run under
|
|
LuaJIT. Write the subset both have (no `goto`, `//`, bitwise operators,
|
|
`<const>`, `utf8`, `table.unpack` without a fallback).
|
|
|
|
## The contract with the LLeMbas CLI
|
|
|
|
The engine is the LLeMbas CLI; its specification (`harness/acp.md` in the CLI's repository,
|
|
*A terminal as the client*, contracts 1 to 4) is the authority. The terminal needs **contract 4**, the one in
|
|
which the engine knows the terminal by the name LLeMbas TERM (`core.CONTRACT`): with an
|
|
engine of an older contract nothing of it is used, and the person is told in words to run
|
|
`lembas update` (`messages.contract_old`). What the terminal does of it, and
|
|
where each point is in the code (one function or constant each, in `lua/llembas/core.lua`):
|
|
|
|
| The terminal | Where | The CLI |
|
|
|---|---|---|
|
|
| asks what the CLI can do: `lembas --version --json`; needs `terminal_contract` ≥ 4 and the part it is about to use (`terminal_surface`, `terminal_models`, `terminal_settings`, `terminal_placed`, `terminal_context_2`); asked again after a minute, and at once when what was needed was missing | `cli_info`, `cli_has`, `CAP`, `CONTRACT` | prints one JSON object |
|
|
| starts the display: `lembas terminal --window <id> --pane <n> [--terminal-context <file>] [--mode manual\|auto] [--new]`, to the right of the pane; the id is this run of the terminal and the tab | `display_args`, `window_id`, `held` | one conversation per id |
|
|
| writes a question, in one write: `/terminal-context <file>` + Enter when there is a context, then the question as a bracketed paste + Enter; at once when the display reports a state, else when it first says `idle` | `ask_bytes` | a new turn, or words added to the running one |
|
|
| writes a line for the display, each one write: `/approve`, `/always`, `/deny` — with the number of what is asked when `lembas_ask` carries one (`/approve 7`), else only for an ask that has stood unchanged for two seconds — `/answer <n>` (a question card: a number or `n` typed on the ask line; words are pasted as a question is, which the display takes as the answer), `/stop`, `/new`, `/model <ref>`, `/mode <name>` | `DISPLAY_KEYS`, `answer_line`, `question_answer`, `display_line` | |
|
|
| reads user variables `lembas_session`, `_title`, `_model`, `_mode`, `_effort`, `_state` (`idle`, `waiting`, `thinking`, `tools`, `writing`, `asking`), `_context`, `_tokens`, `_spend`, and of the display `lembas_surface` (`display`) and `lembas_ask` (`<kind>[#<id>] <keys> <text>`, the id a number of up to 9 digits; a text that ends in `…` was cut by the engine) — only of the display the layer started, or of a pane whose program in front is the CLI itself; of any other pane they are not looked at | `session_from_vars`, `parse_ask` | sets them with OSC 1337 `SetUserVar` |
|
|
| lists and sets the terminal's two models: `lembas terminal models --json`, `lembas terminal models set --main\|--autocomplete <model>` | `models_args`, `models_set_args`, `terminal_models` | keeps them |
|
|
| exports `LLEMBAS_TERM` (version), `LLEMBAS_TERM_PANE`, `LLEMBAS_TERM_EXECUTABLE`, `LLEMBAS_TERM_STATUS_DIR` to every pane | Rust (identity), `apply` | types into a pane with `$LLEMBAS_TERM_EXECUTABLE cli send-text --pane-id N --no-paste`, reads it with `cli get-text` |
|
|
| the shell integration writes the pane's status record at every prompt and when a command starts: `$LLEMBAS_TERM_STATUS_DIR/pane-<n>.status` (with `pid=`) and the user variable `llembas_term_status`; a file a local shell wrote and still keeps is the authority, never replaced by a variable (`status_authority`); the layer writes the file from the variable only where no such file is (`via=uservar`, a shell on another machine) | `shell/llembas-term.sh`, `parse_status`, `status_authority`, `status_text`, `status_dir`, `status_dir_of` | waits for it after typing a command |
|
|
| asks for the rest of a line: the line on standard input (then closed) of `lembas complete --shell <bash\|zsh\|fish> --cwd <dir> --timeout-ms <n> [--model <id>] [--debug]`, with `LLEMBAS_TERM` set; `<n>` is 8000 (the option), and 20000 at least for the first request after a change; `--debug` only once the CLI said it has contract 3 or later; `--cwd` is given (contract 3 lets it be left out; the terminal always knows one): the pane's directory, else the home directory | `llembas_line::complete` (`args`, `run`, `decide`), `wezterm-gui/src/llembas/complete.rs` | prints only the rest; nothing means no suggestion; what it writes to standard error is the sentence shown by *autocomplete status* |
|
|
| reads and writes what the person chose (contract 3, `terminal_settings`): `lembas terminal settings --cwd <dir> --json` → `{ effective = { <key> = <value> }, from = { <key> = "default" \| "global" \| "<directory>" }, directory = { path } \| null }`; `lembas terminal settings set (--global \| --cwd <dir>) --json <key>=<value>` (`default` removes it); `lembas terminal settings forget --cwd <dir> --json` (the entry's own path, which may be a directory above the pane's: the nearest entry applies). Keys: `ai`, `autocomplete`, `suggestions`, `highlight` (`true`/`false`), `mode`, `main_model`, `autocomplete_model`, `display_width` (a part of the pane, `0.2` to `0.6`, written `0.40`; percent is read too) | `SETTINGS`, `settings_args`, `settings_set_args`, `settings_forget_args`, `settings_entry`, `setting_value`, `setting_text` | keeps them, for the machine and by directory |
|
|
| writes the input mark `pane-<n>.input` beside the status record (mode 0600, written whole): `llembas-term-input=1`, `id=`, `seq=` (the status record's), `typed=0\|1` — only for a record the pane's own shell keeps (never for one that came by variable alone) | `llembas_line::mark`, `state::mark_input`, `decorate::compute`; the layer hands the record over with `wezterm.llembas.status` | places a command only at an empty prompt; the mark counts while its id and seq are the record's and the record is at `prompt` |
|
|
| shows a hint while a command placed at the prompt waits for the person (contract 3, `terminal_placed`): `lembas_ask` = `placed <the command>` | `PLACED_KIND`, `parse_ask`, `messages.placed` | places the command without Enter and watches the status record: a new prompt with `ran=1` is "ran", one without is "dismissed" |
|
|
|
|
The status directory is `<runtime directory>/llembas-term/status-<process id of the terminal>`:
|
|
two terminals number their panes alike, so each keeps its records apart. A
|
|
`LLEMBAS_TERM_STATUS_DIR` in the terminal's own environment (a terminal started from a pane of
|
|
another) or in the configuration is not used: every pane is given this terminal's own.
|
|
Directories of terminals that are gone are removed when a display starts.
|
|
|
|
The context file is JSON, mode 0600, in the terminal's runtime directory,
|
|
named `context-<unix seconds>-<random>.json`:
|
|
|
|
```json
|
|
{ "version": 2, "pane": 3, "cwd": "/home/me/project", "shell": "zsh", "host": "buildhost",
|
|
"blocks": [ { "seq": 17, "command": "make test", "exit": 2, "output": "…tail…" } ],
|
|
"screen": "…only when the shell marks no commands…" }
|
|
```
|
|
|
|
Version 2 (contract 2's *context that continues*) goes to an engine that says it reads it
|
|
(`terminal_context_2`); any other gets version 1, without `host` and `seq`. `host` is there
|
|
when the pane's shell reported a directory of another machine (`ssh` inside the pane). A
|
|
block's `seq` is that of the status record when the command started, and its `exit` what the
|
|
next prompt's record said — both from the record the pane's own shell keeps (`note_block`,
|
|
`block_known`); without them `seq` is left out and `exit` is `null`. A context with no block
|
|
and no screen is not written at all (the engine refuses an empty one): the question goes
|
|
alone. Files that were never handed over are removed at once where the layer knows of them
|
|
(a question replaced while the display starts, a display that ended first), and otherwise
|
|
once they are ten minutes old: looked for at the first status update and then once a minute
|
|
while any was written.
|
|
|
|
### Settings: when the engine is asked
|
|
|
|
`init.lua` (*What the person chose, remembered*). `M.value(key, pane)` is the one place a
|
|
setting is read: the store's value for that pane's directory (`directory`, then `global`),
|
|
else what was chosen in this run (`session`: AI off, a CLI without the store, or a write it
|
|
refused), else, for a directory not read yet, the machine's values as last seen
|
|
(`global`), else the options (`config`). Without a pane it is the directory followed last. A store value whose source is `default` is not used: the
|
|
options are the defaults.
|
|
|
|
- Nothing is read at start-up. `settings_awake`: from the first key or palette entry of
|
|
LLeMbas in this run — or from the first prompt, when the empty file `settings-chosen` in
|
|
the terminal's data directory says the person chose something through the terminal before
|
|
(written at the first successful `set`).
|
|
- `follow(pane)` reads the settings of the pane's directory and tells the terminal's own
|
|
part what is on in that pane (`configure_pane`): at a new prompt of the active pane (the
|
|
status record), at `update-status` (each window's active pane) and at every key of
|
|
LLeMbas — after the ask line has opened, and not before an answer is sent. What the store
|
|
said of a directory is kept for a minute (`wezterm.GLOBAL`, at most 64 directories); the
|
|
whole of it is dropped after one of our own writes. A directory whose shell reports
|
|
another host is not asked about.
|
|
- **With AI off in a pane nothing is read for it** (reading starts the engine), and a choice
|
|
is kept for the session (`messages.kept_session`), except the AI switch itself, which the
|
|
store keeps and after which the settings are read (`follow(pane, true, true)`).
|
|
- Every call of the engine is `wezterm.run_child_process` inside an event handler, which is
|
|
asynchronous: the window's thread is never held.
|
|
- A change of the applying settings goes to the terminal's own part (`configure_pane` for
|
|
the pane; `configure` for every pane only when something that is the same everywhere
|
|
changed), to the ask line's prefix and to the next display's arguments (`-m`, `--mode`,
|
|
the split's size).
|
|
A display that runs is not changed by a change of directory.
|
|
|
|
### A word that stands
|
|
|
|
`wezterm.llembas.hint(pane id, text | nil, gentle, source pane id)` keeps a word at the
|
|
cursor's row of a pane until it is taken away, or until the source pane (the display) is
|
|
gone. `sync_hint` in `init.lua` makes it what the display says now (`lembas_ask`): at the
|
|
display's user variables and at `update-status`. An approval or a question may be drawn
|
|
reversed over the end of the row, as a notice is; a *gentle* hint (a placed command) is
|
|
drawn only beside what the row shows or on the empty row below, and not at all otherwise.
|
|
|
|
### Whether the input at the prompt is empty: the input mark
|
|
|
|
The engine places a command only at an empty prompt. The shell's hook cannot say how much is
|
|
typed (it runs before the line is edited); the terminal can, because the shell integration
|
|
marks the input cells. So the terminal writes the *input mark* of the engine's specification.
|
|
|
|
- The layer hands each status record to the terminal's own part (`wezterm.llembas.status`:
|
|
pane, id, seq, state, and the status directory — only with AI on, for a local pane, and
|
|
for the record the pane's own shell keeps; without the directory no mark is written and
|
|
the record says only whether the shell is at its prompt).
|
|
- When a pane whose shell is at a prompt is painted (`decorate::compute`), `typed` is: an
|
|
input cell that shows something on the cursor's row; else one on the rows above that the
|
|
cursor's row carries on from (a line wrapped over rows) — the rows already fetched, never
|
|
the whole scrollback. The mark is written by the terminal's own writer thread, in order. The mark is written when
|
|
the record or the answer changed (`state::mark_input`), beside the record, whole.
|
|
- What it cannot be: ahead of the screen. It is as old as the last painting of the pane — a
|
|
frame behind the typing, and not kept up for a pane that is not shown. A mark of an
|
|
earlier prompt does not count (its `seq` is not the record's), and while a new prompt is
|
|
being drawn the mark errs towards `typed=1`: a command is then not placed, never added to
|
|
something typed.
|
|
- Marks of terminals that are gone are removed with their status records.
|
|
|
|
## What the terminal draws on the input line
|
|
|
|
`wezterm-gui/src/llembas/decorate.rs`, at the moment a pane is painted: the rows near the
|
|
cursor are read as cells, `llembas_line::zone` finds the input line among them (the cells the
|
|
shell integration marked as input, touching the cursor), and a *plan* says which cells get
|
|
another text colour and what text is placed after the cursor. The painter is handed the
|
|
pane's own lines, with copies of the few rows the plan changes. Nothing is written to the
|
|
pane and the terminal's model of the screen is not touched. The plan is kept while the
|
|
pane's content, the cursor and what is on stay the same.
|
|
|
|
Off for a pane: while a full-screen program has it, without the shell integration, when the
|
|
input line is longer than three rows, under an overlay (search, copy mode, the ask line),
|
|
and when the options are off. The suggestion is drawn only in the pane that has the
|
|
keyboard, over blank cells only, and only while the pane's status record says the shell is
|
|
at its prompt (or there is none). A key takes exactly what was drawn (`suggest::drawn_part`:
|
|
a cut suggestion up to the cut), and none is taken while a key sent to the pane is not on
|
|
its screen yet (`state::key_sent`, from the key hook). Whether a command or a path exists is
|
|
looked up only for a local pane whose shell reports this machine as its host, never on a
|
|
network or automounted file system (`/proc/self/mounts`), and a command by the listings of
|
|
the `PATH` directories, read at most once a minute — never a `stat` per word typed. The
|
|
command history is appended to by the same writer thread as the marks.
|
|
|
|
The AI's suggestion: `llembas_line::complete::decide` says whether the line is asked about
|
|
and, when not, why (`Skip`: also `NotAtPrompt`, and `NotAShell` when the program in front
|
|
is no shell); `Tracker` allows one request at a time and remembers the answer
|
|
for a line; `run_said` starts the engine (standard library only, so `cargo test -p llembas-line`
|
|
runs it against a stand-in script); `Log` keeps the last eight attempts in memory for
|
|
`wezterm.llembas.complete_status()`. The pane's directory is decoded from the path of the
|
|
address its shell reported (`dir_of_url_path`): the URL library's own conversion to a file
|
|
path refuses every address that names a host, and the shell integration always names one.
|
|
|
|
## Keys that LLeMbas IDE has too
|
|
|
|
LLeMbas IDE (Neovim) has the family's chords — `core.IDE_KEYS`, fifteen of them. While it is
|
|
the program in front of a pane, the terminal sends them on and does nothing of its own.
|
|
|
|
- **How the terminal knows:** the pane's user variable `llembas_ide` is `1`
|
|
(`core.IDE_VAR`, `ide_in_front`): the editor sets it when it starts and empties it when it
|
|
leaves (OSC 1337 `SetUserVar`). Never the name of a process. Should the editor die without
|
|
emptying it, the shell integration's next `state=prompt` record of that pane takes the keys
|
|
back (`ide_gone`, in `status_changed`), until the editor says `llembas_ide` again. Whatever
|
|
runs in a pane can set the variable; all it gets is that pane's own keys.
|
|
- **Which bindings:** a key of the layer whose chord is one of the fifteen is bound to
|
|
`<its event>-key` instead of its event; the handler there (`hand_over`) sends the chord on
|
|
for an IDE pane and otherwise runs the layer's own action. The command palette's entries
|
|
emit the plain events, so an entry picked in an IDE pane is the terminal's. Chords of the
|
|
fifteen that only the terminal itself acts on (`core.IDE_TERMINAL_KEYS`: the command
|
|
palette on `Ctrl+Shift+P`; `Ctrl+Tab` when the mode key was moved off it) are bound to
|
|
`llembas-pass-<chord>`, which sends them on or performs the terminal's action. Chords
|
|
nothing is bound to (`Ctrl+Alt+A`, `Ctrl+Alt+Shift+Y`, `Alt+Left`, `Alt+Right` by default)
|
|
are not bound for this either: they reach the pane as every unbound key does, and
|
|
`Alt+Right` still takes a word of a suggestion at a shell's prompt.
|
|
- **How the key is sent on:** as bytes, written to the pane — `core.ide_key_bytes`: the kitty
|
|
keyboard protocol's form at its first level, `CSI <code point of the key without Shift> ;
|
|
<1 + modifiers> u` (shift 1, alt 2, ctrl 4), which is also the older CSI u form and which
|
|
Neovim reads whether or not it asked for the protocol. Not `SendKey`: that action goes
|
|
through `TerminalState::key_down` and termwiz's `KeyCode::encode`, which knows xterm's and
|
|
CSI u's encodings but has no arm for the kitty protocol — the protocol's encoder
|
|
(`KeyEvent::encode_kitty`) is only on the path of a key pressed in the window
|
|
(`termwindow/keyevent.rs`). So `SendKey { key = 'A', mods = 'CTRL|SHIFT' }` to a pane that
|
|
asked for the protocol writes the one byte `0x01`, the same as `Ctrl+A`.
|
|
- **The protocol itself:** `apply` sets `enable_kitty_keyboard = true` unless the person's
|
|
file set it (`kitty_keyboard`). It is what serves the chords nothing is bound to, and every
|
|
other key of the editor: a program that pushed the protocol's flags (`CSI > 1 u`) is sent
|
|
pressed keys through `encode_kitty`; a pane that never asked is `KeyboardEncoding::Xterm`
|
|
and gets the bytes it always got. `enable_csi_u_key_encoding` is left off: it changes the
|
|
encoding for every program, asked or not.
|
|
- **The ask line** is drawn only in a pane that is not LLeMbas IDE's (its key is handed on),
|
|
and on it `Ctrl+Tab` is the mode key before it is anything else: `wezterm.llembas.ask_active`
|
|
says whether the pane's line is the ask line, `ask_prefix` changes what stands before the
|
|
question. The lists of models are the terminal's `InputSelector`, an overlay of the tab,
|
|
over the ask line, which is an overlay of the pane: the ask line and its text are there
|
|
when the list closes.
|
|
|
|
## The earlier name
|
|
|
|
Up to 1.0.0-beta.5 the terminal was LLeMbas TTY. What is left of that name, and why:
|
|
|
|
- `env-bootstrap`: the variables the old terminal exported (`LLEMBAS_TTY…`) are dropped from
|
|
the environment, as WezTerm's are, so that a pane of this terminal started from a pane of
|
|
the old one does not tell the engine two things.
|
|
- `config/src/config.rs`, `config/src/lua.rs`: a configuration file of the old name is read
|
|
where it is while there is none of the new name, with the modules beside it; a warning
|
|
once per start, and the layer says it once at the cursor (`core.is_old_config`).
|
|
- `llembas/line/src/migrate.rs`, called by `llembas::carry_over()` at the start of the
|
|
window's program: when the data directory does not exist and the old one beside it does,
|
|
`command-history` and `settings-chosen` are copied (never moved, never over anything), and
|
|
the log says which.
|
|
- `packaging/package.sh`: `Replaces`, `Conflicts` and `Provides: llembas-tty`.
|
|
- `setup/llembas-term-setup`: prints the new line for an rc file that has the old one.
|
|
- The tests of all of these, and the entries of `CHANGELOG.md` from before the rename.
|
|
|
|
## Checking a change without building
|
|
|
|
```
|
|
scripts/test-lua.sh --all # the layer, with every Lua found
|
|
scripts/hygiene.sh
|
|
rustfmt --check --edition 2018 <file> # for a Rust file you touched
|
|
rustfmt --check --edition 2021 llembas/line/src/*.rs
|
|
llembas/tests/shell-test.sh # the status record, in bash and zsh
|
|
shellcheck llembas/shell/*.sh; zsh -n llembas/shell/llembas-term.sh
|
|
```
|
|
|
|
The terminal itself is built by CI only, and so are the tests of `llembas/line`
|
|
(`cargo test -p llembas-line`, the first Rust step of the workflow). CI's log needs a login
|
|
to read; `llembas/ci/cargo-annotated.sh` therefore turns every compiler error and failed test
|
|
into an annotation on the run, which does not. `llembas/tests/smoke.sh <dir>` runs
|
|
against built binaries with no display: names, directories, variables, the
|
|
built-in layer, what is carried over from the earlier name, and the `cli` commands the
|
|
LLeMbas CLI uses. `llembas/tests/keys-gui.sh <dir>` presses keys in a real window on a
|
|
display of its own (Xvfb, xdotool) and compares the bytes that reach the pane; CI runs it
|
|
without making it a gate, because a machine without a software OpenGL cannot make the
|
|
window (it then ends with status 2 and says so).
|
|
|
|
## The GitHub repository that builds it
|
|
|
|
`.github/workflows/llembas-term.yml` is the only workflow that is ours.
|
|
WezTerm's workflow files are left exactly as they are; on our repository
|
|
they are switched off as a repository setting:
|
|
|
|
```
|
|
llembas/ci/disable-upstream-workflows.sh <owner>/<repository>
|
|
```
|
|
|
|
once, and again after an upstream merge that adds a workflow file. What the
|
|
repository needs:
|
|
|
|
- Actions enabled, with GitHub-hosted `ubuntu-22.04` runners (a build takes
|
|
the better part of an hour; a private repository pays for the minutes).
|
|
- The submodules reachable: `deps/freetype/*` and `deps/harfbuzz/harfbuzz`
|
|
are public GitHub repositories, fetched by `actions/checkout`.
|
|
- The whole history, tags included: the hygiene check needs the commit named
|
|
in `UPSTREAM`, and a release needs the signed tag object for its notes.
|
|
- No secret: the workflow uses only the `GITHUB_TOKEN` it is given, with
|
|
`contents: write` for the release. Nothing else is fetched: the package
|
|
carries neither the LLeMbas CLI nor LLeMbas IDE (`setup/llembas-term-setup`
|
|
installs them on a person's machine, checked against the release key).
|
|
- Workflow permissions that allow `contents: write` (Settings → Actions →
|
|
General → Workflow permissions), or the release step is refused.
|
|
|
|
## Merging upstream
|
|
|
|
```
|
|
git fetch upstream && git merge upstream/main # never a rebase
|
|
git rev-parse upstream/main > UPSTREAM # the hygiene check's base
|
|
git grep -n 'LLeMbas TERM:' # every block of ours, to re-check
|
|
scripts/test-lua.sh --all
|
|
```
|
|
|
|
Conflicts can only be in the blocks that grep lists. If upstream changes how
|
|
panes get their environment, how configuration files are found, or the Lua
|
|
API the layer calls (`pane:get_semantic_zones`, `get_text_from_semantic_zone`,
|
|
`get_user_vars`, `send_text`, `split`, `activate`, `tab_id`, `PromptInputLine`, `InputSelector`,
|
|
`ActivateTabRelative`, `ActivateCommandPalette`, `enable_kitty_keyboard`, `wezterm.config_file`,
|
|
`SpawnCommandInNewTab`, `TogglePaneZoomState`, `update-status`, `format-tab-title`,
|
|
`augment-command-palette`, `user-var-changed`), re-read those blocks and
|
|
`lua/llembas/init.lua`. If it changes the `Pane` trait, how overlays are assigned
|
|
(`assign_overlay_for_pane`), `WithPaneLines`, or `Line`'s cells, re-read
|
|
`wezterm-gui/src/llembas/` against `overlay/quickselect.rs`, which it is modelled on.
|
|
|
|
## Later
|
|
|
|
- **Neovim and the editor plugin in the package.** `package.sh` would take a
|
|
pinned, checksum-verified Neovim release and the LLeMbas IDE plugin into
|
|
`usr/lib/llembas-term/nvim/`, with a launcher that sets its own
|
|
`NVIM_APPNAME` so that a person's own Neovim configuration is not touched;
|
|
one more `fetch-*.sh` with a pin file, as for the CLI.
|
|
- **AppImage.** Upstream's `ci/appimage.sh` assembles an AppDir from fixed
|
|
names (`wezterm`, `org.wezfurlong.wezterm`); ours would be a copy with our
|
|
names plus the CLI, built from the same tree `package.sh` stages.
|
|
- **macOS and Windows.** The identity is in place (bundle id, AppUserModelID,
|
|
binary names); the packaging (`ci/deploy.sh`, the installer script, the
|
|
`.app` directory's name and icon) still carries WezTerm's names, and the
|
|
layer writes its context file with `chmod`, which Windows does not have.
|
|
- **fish.** The shell integration is for bash and zsh. What the terminal draws needs only
|
|
the marks around the input line (OSC 133) and the status record; a `llembas-term.fish` that
|
|
gives both is the part to write.
|
|
- **The shell's aliases and functions** are not known to the terminal, so a command that is
|
|
one is not marked as existing (and `colors.unknown` is off by default for that reason). The
|
|
shell integration could publish their names.
|
|
- **Context file version 2** (`blocks[].seq`, `host`): the terminal would keep the status
|
|
record's `seq` with each command it saw.
|