README, changelog and developer notes for LLeMbas in the terminal
llembas-tty / linux (push) Failing after 37s
llembas-tty / linux (push) Failing after 37s
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
3 files changed
+278
-79
No files matched your search
@@ -3,6 +3,53 @@
|
||||
What changed in each release of LLeMbas TTY. WezTerm's own changes are in
|
||||
`docs/changelog.md`, as upstream keeps them.
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- **LLeMbas in the terminal, not a terminal that starts LLeMbas.** The LLeMbas CLI's own
|
||||
interface is no longer opened in a split. You ask at your own prompt, the answer shows in
|
||||
the terminal's display on the right, and what the agent does in a shell is typed into your
|
||||
pane. The CLI is the engine behind it; `Ctrl+Shift+S` opens the CLI itself, whole, in a new
|
||||
tab. Asking needs LLeMbas CLI 2.0.0-beta.19 or newer; with an older one the terminal says
|
||||
so, with how to update.
|
||||
- **The ask line is in place of your shell's line** (`Ctrl+Shift+A`), not a prompt at the top
|
||||
of the window: it names the model and the mode, `Enter` sends, `Escape` or the key again
|
||||
leaves it, and your shell's line is untouched.
|
||||
- The display is a third of the pane's width (option `display.width`), and the keyboard stays
|
||||
in your shell when it opens.
|
||||
- Keys: `Ctrl+Shift+S` opens the CLI in a tab (it started a session in a split),
|
||||
`Ctrl+Shift+D` shows and hides the display. *Resume a session* is gone from the terminal:
|
||||
a tab keeps its conversation, and the CLI in a tab has its own session list. The options
|
||||
`split` and `new_session_in`, and the keys `new_session`, `resume` and `toggle_display`,
|
||||
are gone with it.
|
||||
- *Log in* and *set up* open in a tab.
|
||||
- AI autocomplete (`autocomplete = true`) is drawn by the terminal, in every shell. The one
|
||||
the shell integration drew is `autocomplete = 'shell'`.
|
||||
|
||||
### Added
|
||||
|
||||
- **AI on and off**: the option `ai`, and `Ctrl+Shift+I` at any moment. Off: the LLeMbas keys
|
||||
do nothing, nothing is started, read or sent.
|
||||
- **Approvals from your own pane**: `Ctrl+Shift+Y` allows, `Ctrl+Shift+J` denies,
|
||||
`Ctrl+Shift+G` stops the turn; what LLeMbas asks is said at your cursor. Palette entries
|
||||
for *approve always*, *new conversation*, *choose model*, *choose autocomplete model* and
|
||||
*choose mode* (manual, auto). The terminal has its own two models, kept by the CLI.
|
||||
- **Suggestions on the shell's line, drawn by the terminal**: the rest of the line from the
|
||||
commands the terminal has seen you run, dimmed after the cursor; `Right` or `End` takes it,
|
||||
`Alt+Right` one word. Needs the shell integration; works in bash and zsh alike.
|
||||
- **The command line in colours**, drawn by the terminal: the command when it exists,
|
||||
options, strings, variables, the signs between commands, comments, paths that exist.
|
||||
- **The terminal's own command history** for those suggestions, in
|
||||
`~/.local/share/llembas-tty/command-history`, yours alone, never sent anywhere. Not kept: a
|
||||
line that starts with a space, a command that was not found, anything from a private pane.
|
||||
*LLeMbas: clear command history* removes it; `history = { enabled = false }` keeps none.
|
||||
- **The pane's status record**: the shell integration says at every prompt, and when a
|
||||
command starts, where the shell stands and how the last command ended. LLeMbas waits for
|
||||
it after typing a command.
|
||||
- Options `suggestions`, `highlight`, `history`, `colors`, `mode`, `display`; palette
|
||||
switches for suggestions, highlighting and AI autocomplete.
|
||||
|
||||
## 1.0.0-beta.3 — 2026-12-02
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -1,35 +1,81 @@
|
||||
# LLeMbas TTY
|
||||
|
||||
**A terminal that is also an agent.** LLeMbas TTY is a fork of
|
||||
[WezTerm](https://github.com/wezterm/wezterm) with LLeMbas built in. By default
|
||||
it is an ordinary terminal: nothing is started, nothing of a pane is read and
|
||||
nothing leaves the machine until you press one of the keys below.
|
||||
**LLeMbas in the terminal.** LLeMbas TTY is a fork of
|
||||
[WezTerm](https://github.com/wezterm/wezterm) with LLeMbas built into it: you ask at your own
|
||||
prompt, the answer shows beside your shell, and what the agent does in a shell it types into
|
||||
your pane, at your prompt, where you see it. It is not a terminal that starts another
|
||||
program in a split.
|
||||
|
||||
The agent is the [LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI)
|
||||
(`lembas`), unchanged, and the editor is
|
||||
[LLeMbas IDE](https://github.com/LLeMbas/LLeMbas-IDE) (`llembas-ide`). The terminal carries
|
||||
no copy of either: it uses the ones you have, the same ones you use outside it, and installs
|
||||
what is missing when you ask (*Set-up*, below). The CLI logs in to your own LLeMbas server
|
||||
and uses that server's models.
|
||||
With AI switched off, or until you press one of the keys below, it is an ordinary terminal:
|
||||
nothing is started, nothing of a pane is read and nothing leaves the machine.
|
||||
|
||||
**State: beta.** Built and packaged by CI for Linux x86-64 (a `.deb` and a
|
||||
tarball on the releases page); macOS and Windows are not packaged yet. The
|
||||
parts that need the LLeMbas CLI need one that knows about terminals
|
||||
(2.0.0-beta.18 or newer); with an older one the terminal says so in words.
|
||||
Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like WezTerm — see
|
||||
`LICENSE.md`.
|
||||
The engine is the [LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI) (`lembas`), installed
|
||||
beside the terminal as its own thing, and the editor is
|
||||
[LLeMbas IDE](https://github.com/LLeMbas/LLeMbas-IDE) (`llembas-ide`). The terminal carries no
|
||||
copy of either: it uses the ones you have and installs what is missing when you ask
|
||||
(*Set-up*, below). The CLI logs in to your own LLeMbas server and uses that server's models.
|
||||
|
||||
## What it adds
|
||||
**State: beta.** Built and packaged by CI for Linux x86-64 (a `.deb` and a tarball on the
|
||||
releases page); macOS and Windows are not packaged yet. Asking needs a LLeMbas CLI that can
|
||||
be the terminal's display (2.0.0-beta.19 or newer); with an older one the terminal says so in
|
||||
words, with how to update. Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like
|
||||
WezTerm — see `LICENSE.md`.
|
||||
|
||||
## How it works
|
||||
|
||||
- **Ask in place.** `Ctrl+Shift+A` turns the line you are on into a line for a question:
|
||||
`llembas <model> · <mode> › `, so you see which model and mode will answer before you send.
|
||||
Type, `Enter` sends, `Escape` or the key again leaves it — and your shell's line is as it
|
||||
was: nothing you type on the ask line reaches the shell. It edits like a shell line
|
||||
(arrows, `Home`/`End`, `Ctrl`/`Alt`+arrows by word, `Ctrl+W`, `Ctrl+U`, `Ctrl+K`, paste) and
|
||||
`Up`/`Down` walk through your earlier questions. In a full-screen program it is drawn on
|
||||
the bottom row.
|
||||
- **The display.** The answer shows in a pane on the right, a third of the width, which the
|
||||
terminal opens when you first ask; the keyboard stays in your shell. It has no prompt of
|
||||
its own: it shows what LLeMbas says, the tools it uses that are not the shell, and what it
|
||||
asks you. `Ctrl+Shift+D` hides and shows it.
|
||||
- **Commands happen in your pane.** When LLeMbas runs a command it is typed at your prompt
|
||||
as if you typed it, and its output is in your scrollback. In *manual* mode every command
|
||||
is asked first; `Ctrl+Shift+Y` allows, `Ctrl+Shift+J` denies, from your own pane. In *auto*
|
||||
mode the commands the CLI's rules allow are typed without asking. There are no file-edit
|
||||
tools here: this is for terminal work, and the CLI or the IDE are a key away.
|
||||
- **The CLI itself, whole.** `Ctrl+Shift+S` opens `lembas` in a new tab, in the pane's
|
||||
directory, exactly as if you had typed it.
|
||||
- **AI on and off.** `Ctrl+Shift+I` switches all of it at any moment; the option `ai` says
|
||||
how the terminal starts. Off: every key below but the switch does nothing (and says so
|
||||
once), no process is started, nothing of a pane is read and nothing leaves the machine.
|
||||
- **A shell line with comforts, in any shell.** Drawn by the terminal itself, so they work
|
||||
in bash as in zsh, and inside `ssh` where the other machine's shell has the shell
|
||||
integration:
|
||||
- *suggestions*: the rest of the line, dimmed after the cursor, from the commands this
|
||||
terminal has seen you run. `Right` or `End` takes it, `Alt+Right` one word, anything
|
||||
else just goes on typing;
|
||||
- *colours*: the command (when it exists), options, strings, variables, the signs between
|
||||
commands, comments, and paths that exist;
|
||||
- *AI autocomplete*, off unless you turn it on: when your history has nothing for the
|
||||
line, LLeMbas is asked after a pause and its answer shows in the same place, in italics.
|
||||
|
||||
| Key | Command palette (`Ctrl+Shift+P`) | What it does |
|
||||
|---|---|---|
|
||||
| `Ctrl+Shift+A` | LLeMbas: ask the model | A one-line prompt. Your question goes to LLeMbas with the *terminal context* of the pane you were in (below). If the tab has a LLeMbas pane it is asked there; otherwise one opens to the right, in the same directory. |
|
||||
| `Ctrl+Shift+A` | LLeMbas: ask the model | The ask line. The question goes with the *terminal context* of your pane (below). |
|
||||
| | LLeMbas: ask about this screen | The same, with what is visible on the screen instead of the last commands — also from a full-screen program. |
|
||||
| `Ctrl+Shift+S` | LLeMbas: new session here | Starts `lembas` beside the pane, in its directory. |
|
||||
| `Ctrl+Shift+O` | LLeMbas: resume a session | A list of your sessions to pick from. |
|
||||
| `Ctrl+Shift+D` | LLeMbas: toggle side display | Shows or hides the session's side display. |
|
||||
| `Ctrl+Shift+H` | LLeMbas: private pane on/off | Marks the pane private: nothing of it is ever passed on. |
|
||||
| | LLeMbas: log in | Runs `lembas login`. |
|
||||
| `Ctrl+Shift+S` | LLeMbas: open the CLI | `lembas`, whole, in a new tab. |
|
||||
| `Ctrl+Shift+I` | LLeMbas: AI on/off | The switch. |
|
||||
| `Ctrl+Shift+Y` | LLeMbas: approve (allow once) | Answers what LLeMbas asks, from your pane. |
|
||||
| | LLeMbas: approve always | Where the question offers it (never for a command typed into your pane). |
|
||||
| `Ctrl+Shift+J` | LLeMbas: deny | |
|
||||
| `Ctrl+Shift+G` | LLeMbas: stop the turn | |
|
||||
| | LLeMbas: new conversation | A tab has one conversation, which goes on until you start a new one. |
|
||||
| `Ctrl+Shift+D` | LLeMbas: show/hide the display | Hidden, it runs on behind your pane. |
|
||||
| | LLeMbas: choose model | The terminal's own chat model, from your server's list. |
|
||||
| | LLeMbas: choose autocomplete model | The terminal's own autocomplete model. |
|
||||
| | LLeMbas: choose mode | *manual* or *auto*. |
|
||||
| `Ctrl+Shift+H` | LLeMbas: private pane on/off | Nothing of the pane is passed on, and its commands are not remembered. |
|
||||
| | LLeMbas: suggestions on/off | |
|
||||
| | LLeMbas: syntax highlighting on/off | |
|
||||
| | LLeMbas: AI autocomplete on/off | |
|
||||
| | LLeMbas: clear command history | |
|
||||
| | LLeMbas: log in | `lembas login`, in a new tab. |
|
||||
| `Ctrl+Shift+E` | LLeMbas: open LLeMbas IDE here | LLeMbas IDE in a new tab, in the pane's directory. |
|
||||
| | LLeMbas: set up (CLI and IDE) | Installs what is missing of the two (below). |
|
||||
|
||||
@@ -39,13 +85,10 @@ Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like WezTerm — see
|
||||
and previous, `CTRL+SHIFT+1`…`9` by number. The session bar below sits in that line, so it
|
||||
shows from two tabs on; `config.hide_tab_bar_if_only_one_tab = false` in your own file keeps
|
||||
the line always.
|
||||
- **Session bar.** When the pane you are in runs LLeMbas, the right of the tab
|
||||
bar shows its model, mode, state and how full its context is. A tab in which
|
||||
LLeMbas waits for you is marked with `●`. With no LLeMbas pane, the bar shows
|
||||
nothing of ours.
|
||||
- **Prompt autocomplete**, off by default: in zsh the rest of the line appears
|
||||
dimmed after the cursor (Right arrow or End takes it), in bash a key
|
||||
(`Ctrl+X Ctrl+A`) completes the line. See *Autocomplete* below.
|
||||
- **Session bar.** The right of the tab bar shows the model, mode, state and how full the
|
||||
context is of the conversation in the tab you are in, `AI off` when it is off, and
|
||||
`private` for a private pane. A tab in which LLeMbas waits for you is marked with `●`, and
|
||||
what it asks is said at the cursor of your pane, with the keys that answer.
|
||||
- **Its own everything.** LLeMbas TTY installs beside WezTerm and shares
|
||||
nothing with it: its commands are `llembas-tty`, `llembas-tty-gui` and
|
||||
`llembas-tty-mux-server`, its configuration is
|
||||
@@ -54,7 +97,7 @@ Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like WezTerm — see
|
||||
|
||||
## Set-up: the CLI and LLeMbas IDE
|
||||
|
||||
LLeMbas TTY is the terminal of a set of three: the terminal, the LLeMbas CLI (the agent) and
|
||||
LLeMbas TTY is the terminal of a set of three: the terminal, the LLeMbas CLI (the engine) and
|
||||
LLeMbas IDE (the editor). The other two are installations of their own — in your home
|
||||
directory, updated by themselves (`lembas update`, `llembas-ide update`), and the same whether
|
||||
you start them here or anywhere else. The terminal looks for `lembas` and `llembas-ide` on
|
||||
@@ -68,9 +111,11 @@ and nothing already installed is touched. A beta terminal installs the newest be
|
||||
one the newest stable releases (`--channel stable|beta` to say otherwise; `--dry-run` to see
|
||||
what it would do; `--no-cli`, `--no-ide`).
|
||||
|
||||
## What is passed on, and when
|
||||
## What is passed on, what is kept, and when
|
||||
|
||||
Only when you ask (the two *ask* entries), and only this:
|
||||
**With AI off: nothing, to anyone.** With AI on, still nothing until you ask.
|
||||
|
||||
**When you send a question** (the two *ask* entries), LLeMbas is given, with it:
|
||||
|
||||
- the last 5 commands of that pane with the end of each one's output (200
|
||||
lines or 16 KiB at most), and the pane's directory and shell. This needs the
|
||||
@@ -83,11 +128,35 @@ Never: a pane you marked private, a pane that is asking for a password, a pane
|
||||
that runs on another machine, the scrollback as a whole, or anything at all
|
||||
while you have not asked. The context is written to a file only you can read,
|
||||
in the terminal's runtime directory; LLeMbas deletes it after reading it and
|
||||
the terminal removes any that are left after ten minutes. What LLeMbas then
|
||||
does with it is the CLI's business and follows its permissions.
|
||||
the terminal removes any that are left after ten minutes.
|
||||
|
||||
**While a conversation runs**, LLeMbas can read the pane you asked from and type commands
|
||||
into it, by its own permissions: in manual mode it asks for each command first. That is the
|
||||
CLI's business; it never types at a password prompt.
|
||||
|
||||
**AI autocomplete**, when you turned it on: the line you are typing is sent to
|
||||
`lembas complete` after a pause, when your own history has no suggestion for it — never an
|
||||
empty line, a line that starts with a space, a private pane, or a shell on another machine.
|
||||
What comes back is shown as text; nothing runs until you take it and press Enter.
|
||||
|
||||
**Kept on this machine, sent nowhere:**
|
||||
|
||||
- *The command history* behind the suggestions: `~/.local/share/llembas-tty/command-history`,
|
||||
readable by you alone. One line a command the terminal saw run: when, its exit status, its
|
||||
directory, its text. Never kept: a line that starts with a space, a command of several
|
||||
lines, a command that was not found, anything from a private pane, and nothing you type
|
||||
while a program hides what you type (it is read from the screen, where such text never is).
|
||||
At most 5000 commands. **To clear it:** *LLeMbas: clear command history*, or delete the
|
||||
file. To keep none: `history = { enabled = false }`. It is the terminal's own; your
|
||||
shell's history file is never read.
|
||||
- *The pane's status record*, which the shell integration writes at every prompt: whether the
|
||||
shell is at its prompt or running a command, the last exit status, the time, the
|
||||
directory — not what the command was. It is how LLeMbas knows that a command it typed has
|
||||
ended. In the terminal's runtime directory, readable by you alone.
|
||||
|
||||
The session bar reads what LLeMbas itself tells the terminal about its session.
|
||||
It does not read the pane.
|
||||
It does not read the pane. The colours and the suggestion are drawn when a pane is painted:
|
||||
nothing is written into the pane for them.
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -102,6 +171,7 @@ local config = wezterm.config_builder()
|
||||
require('llembas').apply(config, {
|
||||
-- every line is optional; these are the defaults
|
||||
enabled = true, -- false: no layer at all
|
||||
ai = true, -- false: the terminal starts with AI off (the switch still works)
|
||||
cli = nil, -- path of `lembas`; nil: PATH, then ~/.local/bin
|
||||
ide = nil, -- path of `llembas-ide`; nil: the same two places
|
||||
session_bar = true,
|
||||
@@ -109,16 +179,20 @@ require('llembas').apply(config, {
|
||||
palette = true,
|
||||
bar = { fields = { 'model', 'mode', 'state', 'context' } },
|
||||
-- also: 'session', 'title', 'effort', 'tokens', 'spend'
|
||||
keys = { -- false turns a key off
|
||||
keys = { -- false turns a key off; any of them can be given a key
|
||||
ask = { key = 'A', mods = 'CTRL|SHIFT' },
|
||||
new_session = { key = 'S', mods = 'CTRL|SHIFT' },
|
||||
resume = { key = 'O', mods = 'CTRL|SHIFT' },
|
||||
toggle_display = { key = 'D', mods = 'CTRL|SHIFT' },
|
||||
cli = { key = 'S', mods = 'CTRL|SHIFT' },
|
||||
ai = { key = 'I', mods = 'CTRL|SHIFT' },
|
||||
approve = { key = 'Y', mods = 'CTRL|SHIFT' },
|
||||
deny = { key = 'J', mods = 'CTRL|SHIFT' },
|
||||
stop = { key = 'G', mods = 'CTRL|SHIFT' },
|
||||
display = { key = 'D', mods = 'CTRL|SHIFT' },
|
||||
private = { key = 'H', mods = 'CTRL|SHIFT' },
|
||||
ide = { key = 'E', mods = 'CTRL|SHIFT' },
|
||||
ask_screen = false, always = false, new = false, model = false, mode = false,
|
||||
},
|
||||
split = { direction = 'Right', size = 0.45 },
|
||||
new_session_in = 'split', -- or 'tab'
|
||||
display = { width = 0.33 }, -- of the pane it opens beside
|
||||
mode = 'manual', -- the mode a display starts in; or 'auto'
|
||||
context = {
|
||||
enabled = true, -- false: questions go alone, nothing of the pane
|
||||
blocks = 5, -- commands passed on (at most 20)
|
||||
@@ -126,12 +200,25 @@ require('llembas').apply(config, {
|
||||
output_bytes = 16384,
|
||||
alt_screen = false, -- true: also the screen of a full-screen program
|
||||
},
|
||||
autocomplete = false,
|
||||
suggestions = true, -- the rest of the line from your own command history
|
||||
highlight = true, -- the command line in colours
|
||||
autocomplete = false, -- AI: true, drawn by the terminal; 'shell', by the shell integration
|
||||
history = { enabled = true, max = 5000 },
|
||||
colors = { -- a number of your colour scheme's palette, '#rrggbb', or false
|
||||
prefix = 6, ghost = 8, notice = 3,
|
||||
command = 2, unknown = false, option = false, string = 3,
|
||||
variable = 6, operator = 5, comment = 8, path = 4,
|
||||
},
|
||||
})
|
||||
|
||||
return config
|
||||
```
|
||||
|
||||
The colours are numbers of your colour scheme's palette, so they follow your theme.
|
||||
`unknown` — a command that is not found — is left alone by default, because the terminal
|
||||
looks in `PATH` and does not know your shell's aliases and functions; give it a colour to
|
||||
mark such words.
|
||||
|
||||
To have none of it: leave the line out of your file, pass `{ enabled = false }`,
|
||||
or start with `llembas-tty -n`.
|
||||
|
||||
@@ -149,16 +236,18 @@ unpacking the tarball, add to `~/.zshrc` or `~/.bashrc`:
|
||||
```
|
||||
|
||||
It marks commands and their output for the terminal (WezTerm's own
|
||||
integration script, OSC 133 and OSC 7) and does nothing outside LLeMbas TTY.
|
||||
integration script, OSC 133 and OSC 7), writes the pane's status record, and
|
||||
does nothing outside LLeMbas TTY. The suggestions and the colours need it: it
|
||||
is how the terminal knows which cells are your command line.
|
||||
|
||||
### Autocomplete
|
||||
**On another machine**, reached with `ssh` from a pane: copy `llembas-tty.sh` and `wezterm.sh`
|
||||
there and source the first from that shell's rc file with `LLEMBAS_TTY` set (for instance
|
||||
`[ -n "$SSH_CONNECTION" ] && LLEMBAS_TTY=remote . ~/.llembas-tty.sh`). Suggestions and
|
||||
colours then work there too, drawn by your terminal; whether a command or a path exists is
|
||||
not marked, since that is the other machine's to know.
|
||||
|
||||
Set `autocomplete = true` in the options above; new panes then have
|
||||
`LLEMBAS_TTY_AUTOCOMPLETE=1` and the shell integration turns completion on.
|
||||
The line you are typing is sent to `lembas complete` after a short pause —
|
||||
never an empty line, never a line that starts with a space, never outside
|
||||
LLeMbas TTY. What comes back is put on the line as text; nothing runs until
|
||||
you press Enter. If zsh-autosuggestions is loaded, ours stays off.
|
||||
The older autocomplete drawn by the shell itself (zsh shows it, bash completes on
|
||||
`Ctrl+X Ctrl+A`) is still there as `autocomplete = 'shell'`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+91
-28
@@ -9,19 +9,51 @@ merging upstream stays cheap (`git grep -n 'LLeMbas TTY:'` lists them all).
|
||||
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, as pure functions (no terminal needed)
|
||||
tests/run.lua tests of both, against tests/fake_wezterm.lua
|
||||
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)
|
||||
shell/ shell integration: zones, cwd, prompt autocomplete
|
||||
shell/ shell integration: zones, cwd, the status record
|
||||
packaging/ desktop file, appdata, icons, package.sh (.deb, tarball)
|
||||
setup/llembas-tty-setup installs the LLeMbas CLI and LLeMbas IDE when missing, verified
|
||||
ci/ disable-upstream-workflows.sh
|
||||
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-tty.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 })`, `configure { … }`, `notice(pane, text)`,
|
||||
`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 TTY:` comment:
|
||||
|
||||
| File | The block | Why there |
|
||||
|---|---|---|
|
||||
| `wezterm-gui/src/main.rs` | `mod llembas;` and one `add_context_setup_func` | where the terminal's other Lua modules are registered |
|
||||
| `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!`)
|
||||
@@ -53,16 +85,25 @@ A new Lua module must be added to `MODULES` in `config/src/llembas.rs`.
|
||||
|
||||
## The contract with the LLeMbas CLI
|
||||
|
||||
The agent is the LLeMbas CLI, unchanged in role. The terminal drives it:
|
||||
The engine is the LLeMbas CLI; its specification (`harness/acp.md` in the CLI's repository,
|
||||
*A terminal as the client*, contract 2) is the authority. 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 | The CLI |
|
||||
|---|---|
|
||||
| reads user variables `lembas_session`, `lembas_title`, `lembas_model`, `lembas_mode`, `lembas_effort`, `lembas_state` (`idle`, `waiting`, `thinking`, `tools`, `writing`, `asking`), `lembas_context` (percent), `lembas_tokens`, `lembas_spend` | sets them with OSC 1337 `SetUserVar` |
|
||||
| starts `lembas --terminal-context <file>` in a new pane, or writes `/terminal-context <file>` + Enter into a running session | reads the file, deletes it |
|
||||
| writes the question as a bracketed paste + Enter, once the session reports `lembas_state=idle` | takes it as a prompt |
|
||||
| exports `LLEMBAS_TTY` (version), `LLEMBAS_TTY_PANE`, `LLEMBAS_TTY_EXECUTABLE` to every pane | its terminal tools run `$LLEMBAS_TTY_EXECUTABLE cli send-text --pane-id N --no-paste` and `cli get-text --pane-id N` |
|
||||
| shell integration pipes the line so far to `lembas complete --shell <zsh\|bash> --cwd <dir> --timeout-ms 2500` | prints only the rest of the line; nothing means no suggestion |
|
||||
| runs `lembas sessions --json` for the resume list (falls back to `/sessions` in a new session) | prints a list of objects with `id`, and `title`, `model`, `root` |
|
||||
| The terminal | Where | The CLI |
|
||||
|---|---|---|
|
||||
| asks what the CLI can do: `lembas --version --json`; needs `terminal_contract` ≥ 2 and the part it is about to use (`terminal_surface`, `terminal_models`) | `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`, `/stop`, `/new`, `/model <ref>`, `/mode <name>` | `DISPLAY_KEYS`, `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> <keys> <text>`) | `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_TTY` (version), `LLEMBAS_TTY_PANE`, `LLEMBAS_TTY_EXECUTABLE`, `LLEMBAS_TTY_STATUS_DIR` to every pane | Rust (identity), `apply` | types into a pane with `$LLEMBAS_TTY_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_TTY_STATUS_DIR/pane-<n>.status` and the user variable `llembas_tty_status`; the layer writes the file from the variable for a shell that could not (`via=uservar`) | `shell/llembas-tty.sh`, `parse_status`, `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 of `lembas complete --shell <bash\|zsh\|fish> [--cwd <dir>] --timeout-ms 2500` | `wezterm-gui/src/llembas/complete.rs` | prints only the rest; nothing means no suggestion |
|
||||
|
||||
The status directory is `<runtime directory>/llembas-tty/status-<process id of the terminal>`:
|
||||
two terminals number their panes alike, so each keeps its records apart. 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`:
|
||||
@@ -73,13 +114,24 @@ named `context-<unix seconds>-<random>.json`:
|
||||
"screen": "…only when the shell marks no commands…" }
|
||||
```
|
||||
|
||||
`exit` is always `null` today: WezTerm's Lua interface does not expose the
|
||||
exit status that OSC 133 `D` carries. Files older than ten minutes are
|
||||
removed the next time one is written.
|
||||
It is still version 1 (which the CLI reads): `exit` is `null`, and the blocks carry no
|
||||
`seq`. Files older than ten minutes are removed the next time one is written.
|
||||
|
||||
Whether a CLI is new enough is decided in exactly one function,
|
||||
`core.cli_supports_terminal`, today by comparing `lembas --version` with
|
||||
`core.MIN_CLI_VERSION`.
|
||||
## 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. Whether a command or a path exists is looked up only for a
|
||||
local pane whose shell reports this machine as its host.
|
||||
|
||||
## Checking a change without building
|
||||
|
||||
@@ -87,10 +139,15 @@ Whether a CLI is new enough is decided in exactly one function,
|
||||
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 llembas/shell/autocomplete.bash; zsh -n llembas/shell/autocomplete.zsh
|
||||
```
|
||||
|
||||
The terminal itself is built by CI only. `llembas/tests/smoke.sh <dir>` runs
|
||||
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 and the `cli` commands the LLeMbas CLI uses.
|
||||
|
||||
@@ -132,9 +189,12 @@ 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`, `split`, `PromptInputLine`, `InputSelector`,
|
||||
`update-status`, `format-tab-title`, `augment-command-palette`,
|
||||
`user-var-changed`), re-read those blocks and `lua/llembas/init.lua`.
|
||||
`get_user_vars`, `split`, `activate`, `tab_id`, `PromptInputLine`, `InputSelector`,
|
||||
`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
|
||||
|
||||
@@ -150,8 +210,11 @@ API the layer calls (`pane:get_semantic_zones`, `get_text_from_semantic_zone`,
|
||||
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.** Ghost text in fish means replacing its own autosuggestion, which
|
||||
it does not offer a hook for; a key binding like bash's
|
||||
(`commandline -i (… | lembas complete --shell fish)`) is the part that fits.
|
||||
- **Ghost text drawn by the terminal** instead of by the shell would work in
|
||||
every shell and over ssh, and needs Rust in the renderer and the key path.
|
||||
- **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-tty.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.
|
||||
Reference in new issue
Block a user