- 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>
537 lines
35 KiB
Markdown
537 lines
35 KiB
Markdown
# LLeMbas TERM
|
||
|
||
**LLeMbas in the terminal.** LLeMbas TERM 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.
|
||
|
||
Until you press one of the keys below it is an ordinary terminal: nothing of LLeMbas is
|
||
started, nothing of a pane is read and nothing leaves the machine. With AI switched off that
|
||
stays so — the LLeMbas CLI is not started at all, but to keep the switch itself when you press
|
||
it (*AI on and off*, below, says exactly what still works).
|
||
|
||
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.
|
||
|
||
**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. It needs a LLeMbas CLI that knows the
|
||
terminal by this name (the CLI's *terminal contract 4*; `lembas update` brings it); 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`.
|
||
|
||
**It was called LLeMbas TTY** up to 1.0.0-beta.5. If you are upgrading from that, read
|
||
*Coming from LLeMbas TTY* below: update the CLI first, and change one line in your `~/.zshrc`.
|
||
|
||
## 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. On the ask line `Ctrl+Tab` switches
|
||
the mode, manual ↔ auto, and `Ctrl+Shift+M` opens the list of models: the line says the
|
||
choice at once, your question stays as you typed it, and the choice is remembered like any
|
||
other (*Settings*). 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 the command is
|
||
placed at your prompt and not entered: `Enter` runs it, you may change it first, and
|
||
`Ctrl+C` (or clearing the line) dismisses it — a dimmed hint beside it says so, and no
|
||
approval card stands in the way. In *auto* mode the commands the CLI's rules allow are
|
||
typed and entered without asking. A permission for a tool that is not the shell stands at
|
||
your cursor's row with the keys that answer it (`Ctrl+Shift+Y` allows, `Ctrl+Shift+J`
|
||
denies, from your own pane), until it is answered; the answer is for what you read there
|
||
(a request that changed a moment before is not answered, and the terminal says so). A
|
||
question LLeMbas asks you stands there too, and is answered on the ask line: a number of
|
||
its options, `n` to skip it, or your own words.
|
||
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: nothing of a pane is read, nothing leaves the machine, and the
|
||
LLeMbas CLI is not started — not to ask, not to complete, not to read or keep a setting. The
|
||
one exception is the switch itself: pressing it has the CLI keep that choice (and, switching
|
||
on, read the settings). What still works with AI off is the terminal's own: suggestions from
|
||
your own history, the colours, private panes, clearing the history, the display's width and
|
||
the drawing switches (a choice made then holds until the terminal closes), and the two
|
||
entries that open another program in a tab when you ask — *set up* and *open LLeMbas IDE*.
|
||
Every other LLeMbas key says once that AI is off, then nothing.
|
||
- **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. They are drawn only while the shell is at its prompt (by its status record):
|
||
what you type into a program a command started — a database client, a password prompt — is
|
||
never offered anything:
|
||
- *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 (*LLeMbas: AI autocomplete on/off* in the
|
||
command palette; choose its model with *LLeMbas: choose autocomplete model*): when your
|
||
history has nothing for the line, LLeMbas is asked after a pause and its answer shows in
|
||
the same place, in italics. What a key takes is exactly what is drawn: a suggestion too
|
||
long for the row is taken up to where it was cut, and nothing invisible (zero-width or
|
||
direction-changing characters) is ever in one. *LLeMbas: autocomplete status* says in words whether it is
|
||
on, which engine and model it uses, and what the last attempts gave — a suggestion,
|
||
nothing, a timeout, or the engine's own error sentence.
|
||
- **Your choices are remembered** — for this machine, and for a working directory where you
|
||
want it different there. See *Settings* below.
|
||
|
||
| Key | Command palette (`Ctrl+Shift+P`) | What it does |
|
||
|---|---|---|
|
||
| `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: open the CLI | `lembas`, whole, in a new tab. |
|
||
| `Ctrl+Shift+I` | LLeMbas: AI on/off — here / — everywhere | 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. |
|
||
| `Ctrl+Shift+M` | LLeMbas: choose chat model — here / — everywhere | The terminal's own chat model, from your server's list. Also from the ask line. |
|
||
| `Ctrl+Alt+M` | LLeMbas: choose autocomplete model — here / — everywhere | The terminal's own autocomplete model. |
|
||
| `Ctrl+Tab` *on the ask line* | LLeMbas: choose mode — here / — everywhere | *manual* or *auto*. The key switches to the other one; anywhere but the ask line `Ctrl+Tab` is the next tab, as always. |
|
||
| `Ctrl+Shift+Alt+P` | | The terminal's command palette, like `Ctrl+Shift+P` — the one of the two that is never handed to LLeMbas IDE (below). |
|
||
| | LLeMbas: display width — here / — everywhere | The display's part of the pane, from the next time it opens. |
|
||
| `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 — here / — everywhere | |
|
||
| | LLeMbas: syntax highlighting on/off — here / — everywhere | |
|
||
| | LLeMbas: AI autocomplete on/off — here / — everywhere | |
|
||
| | LLeMbas: settings | What applies in this pane and where each value comes from; forgets this directory's own. |
|
||
| | LLeMbas: autocomplete status | The AI's autocomplete in words: on or off, engine, model, the last attempts. |
|
||
| | 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). |
|
||
|
||
- **LLeMbas IDE has the same keys, and gets them while it is in front.** `Ctrl+Shift+A`,
|
||
`Ctrl+Tab`, `Ctrl+Shift+M`, `Ctrl+Alt+M`, `Ctrl+Alt+A`, `Ctrl+Shift+I`, `Ctrl+Shift+G`,
|
||
`Ctrl+Shift+Y`, `Ctrl+Shift+J`, `Ctrl+Alt+Shift+Y`, `Ctrl+Shift+E`, `Ctrl+Shift+D`,
|
||
`Ctrl+Shift+P`, `Alt+Left` and `Alt+Right` mean the same things in the editor. In a pane
|
||
where LLeMbas IDE runs, the terminal does not act on them: it sends them on to the editor,
|
||
told apart from their plain cousins (`Ctrl+Shift+A` is not `Ctrl+A`). The terminal knows by
|
||
the editor's own word only — LLeMbas IDE sets the pane's user variable `llembas_ide` to `1`
|
||
while it runs — never by guessing from a process name; and a shell back at its prompt has
|
||
the keys again even if the editor died without a word. Every other key of the terminal
|
||
(new tab, copy and paste, splits, `Ctrl+Shift+S`, `Ctrl+Shift+H`) works there as everywhere,
|
||
the entries of the command palette do too, and the palette itself is on `Ctrl+Shift+Alt+P`.
|
||
`ide_keys = false` keeps all keys with the terminal.
|
||
- **The keyboard protocol for programs that ask for it.** The built-in configuration turns
|
||
on `enable_kitty_keyboard`: a program that *asks* for the kitty keyboard protocol (Neovim,
|
||
and so LLeMbas IDE; some shells and full-screen programs) is then sent keys in that
|
||
protocol's form, in which modified keys are told apart. A program that does not ask —
|
||
bash, zsh, most things — gets every key exactly as before. `kitty_keyboard = false`, or
|
||
`config.enable_kitty_keyboard = false` in your own file, leaves it off.
|
||
- **A quiet window.** With no configuration of your own there is no tab bar while a window has
|
||
one tab; from the second tab on it is a plain line of text at the bottom. Tabs are worked by
|
||
keys either way: `CTRL+SHIFT+T` new, `CTRL+SHIFT+W` close, `CTRL+TAB` / `CTRL+SHIFT+TAB` next
|
||
and previous (`CTRL+TAB` switches the mode instead while you are on the ask line), `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.** 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 TERM installs beside WezTerm and shares
|
||
nothing with it: its commands are `llembas-term`, `llembas-term-gui` and
|
||
`llembas-term-mux-server`, its configuration is
|
||
`~/.config/llembas-term/llembas-term.lua` (or `~/.llembas-term.lua`), and it
|
||
neither reads WezTerm's files nor talks to a running WezTerm. One thing it keeps on
|
||
purpose: a pane's `TERM_PROGRAM` is `WezTerm`, because programs decide by it which of the
|
||
terminal's features they may use, and this terminal has all of WezTerm's.
|
||
|
||
## Set-up: the CLI and LLeMbas IDE
|
||
|
||
LLeMbas TERM 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
|
||
your `PATH` and then in `~/.local/bin`.
|
||
|
||
When one is missing, the palette entry **LLeMbas: set up (CLI and IDE)** — or `llembas-term-setup`
|
||
in a shell — says which, and asks before installing each. It runs that product's own
|
||
installer from that product's own release, after checking it: the release's `SHA256SUMS` must
|
||
be signed with the LLeMbas release key, must name that release where it names one (a first
|
||
line `# <product> <version>`: an older signed release served under a newer tag is refused),
|
||
and the installer must match it. It refuses to run as root — everything goes into your own
|
||
home — and nothing already installed is touched. A beta terminal installs the newest betas, a stable
|
||
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, what is kept, and when
|
||
|
||
**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), how each ended where the shell said so, and the pane's
|
||
directory and shell. This needs the shell integration (below), which marks where a
|
||
command and its output begin;
|
||
- without shell integration: the last screenful instead;
|
||
- from a full-screen program (an editor, a pager): nothing but the question, unless
|
||
you chose *ask about this screen*;
|
||
- from a shell reached with `ssh` inside the pane: the same, named as that machine's (its
|
||
host, with a LLeMbas CLI that reads it), and the display opens in a directory of this
|
||
machine.
|
||
|
||
Never: a pane you marked private, a pane that is asking for a password (as far as the
|
||
terminal can tell: a program that turns echo off and reads a line, as `sudo` and `ssh` do —
|
||
not a password a program on another machine asks for), a pane of another of the terminal's
|
||
domains, 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. One that was never handed over (a question that was not sent, a display
|
||
that ended first) is removed at once where the terminal knows of it, and otherwise once it
|
||
is ten minutes old: the terminal looks at its first status update and then once a minute
|
||
while it has written any.
|
||
|
||
A question is never lost without a word: when the display could not start or ended before it
|
||
took the question, the ask line opens again with the question on it and what the display said.
|
||
|
||
**What the terminal trusts: only what it started.** The display of a tab is the pane the
|
||
terminal itself opened and started `lembas terminal` in, remembered by that pane's id. A
|
||
question, the name of its context file, an answer to something LLeMbas asked, a model or a
|
||
mode are written to that pane and to no other — and only while the program in front of it is
|
||
still the LLeMbas CLI the terminal started there, which it looks at each time before it
|
||
writes (when it cannot tell, it writes nothing and says so). What a pane *says* of itself
|
||
counts for nothing: the variables by which LLeMbas publishes its model, mode and state can be
|
||
set by anything that prints to a pane — a file shown with `cat`, a line of a log, a host
|
||
reached over SSH. From the display they are shown, cleaned of control and invisible
|
||
characters; from any other pane they are not looked at, except in a pane whose program in
|
||
front is the CLI itself (opened whole with `Ctrl+Shift+S`), where they fill the session bar.
|
||
The ask line never writes into such a pane: the CLI has its own line for questions. When
|
||
the engine in a display has ended, that pane is no display any more and the next question
|
||
opens a new one. (The `cli` option must name the program itself or a link to it; a wrapper
|
||
script that starts it is not recognised as the engine, and nothing would be sent.)
|
||
|
||
**While a conversation runs**, LLeMbas can read the pane you asked from and type commands
|
||
into it, by its own permissions: in manual mode a command is placed at your prompt for you
|
||
to run, and only at an empty prompt — nothing is ever added to what you typed. That is the
|
||
CLI's business; it never types at a password prompt. So that it knows your prompt is empty
|
||
whatever your prompt looks like, the terminal writes, with AI on, a four-line *input mark*
|
||
beside each pane's status record: which prompt it is of, and whether anything stands on its
|
||
input line — never what.
|
||
|
||
**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 of fewer than three characters, a line that starts with a space, a
|
||
private pane, a line typed while the shell is not at its prompt (a command runs), a line
|
||
typed into anything but a shell (`ssh`, a database client), a shell whose directory is on
|
||
another machine, **or a line that looks as if it holds a secret** (*Secrets on a command
|
||
line*, below). What comes back is shown as text; nothing runs
|
||
until you take it and press Enter. The engine is given eight seconds for an answer
|
||
(`autocomplete_timeout_ms`), and twenty for the first one after you switch autocomplete on or
|
||
change its model: a model on your own machine may have to be loaded. The last few attempts — the start of the line, how long it took, what came back — are
|
||
kept in memory for *LLeMbas: autocomplete status* and go when the terminal closes.
|
||
|
||
### Secrets on a command line
|
||
|
||
A command line can hold a password, a token or a key. The terminal looks for that itself,
|
||
before anything of a line goes anywhere, and independently of what the LLeMbas CLI checks:
|
||
|
||
- **AI autocomplete does not ask about such a line.** *LLeMbas: autocomplete status* then
|
||
says "not asked: the line looks like it holds a secret" — and never the line.
|
||
- **It is not kept in the terminal's command history**, so it is never suggested back and
|
||
never part of anything sent later. A history file written by an earlier version is
|
||
cleaned of such lines the next time it is read.
|
||
- **In what is passed on with a question**, a command that looks so is replaced by
|
||
"[a command that looked as if it held a secret was left out, with its output]" — its output
|
||
is not read at all — and a line of another command's output, or of the screen, that looks
|
||
so is replaced by "[a line that looked as if it held a secret was left out]".
|
||
|
||
What is taken for a secret, erring on the side of not sending:
|
||
|
||
- `NAME=value` and `name: value` where the name contains *password*, *passwd*, *passphrase*,
|
||
*secret*, *token* or *credential* — or *key*, *auth* or *pwd*, unless the value is plainly a
|
||
path or a number: assignments and exports, options with `=`, headers, fields of JSON,
|
||
parts of a query string;
|
||
- options whose value follows as a word: `--password x`, `--token x`, `--api-key x`,
|
||
`--secret x` and their like;
|
||
- a program's own way of taking a password: `mysql -pX` (and the other MySQL and MariaDB
|
||
clients), `sshpass -p X`, `… login -p X`, `redis-cli -a X`, `unzip -P X`, `7z -pX`,
|
||
`ldapsearch -w X`, `mongosh -p X`, `openssl … pass:X`, `htpasswd -b`;
|
||
- `user:password` given to `curl -u` (and `wget`, `http`, `xh`, `aria2c`, `ab`, `svn`), and
|
||
in a URL: `scheme://user:password@host`;
|
||
- `Authorization:` headers, `Bearer …`, `Basic …`;
|
||
- a line that feeds a password to a program: `… | sudo -S`, `chpasswd`, `passwd --stdin`,
|
||
`--password-stdin`;
|
||
- keys by their well-known beginning: `sk-…`, `ghp_…`, `github_pat_…`, `glpat-…`,
|
||
`xoxb-…`, `AKIA…`, `-----BEGIN … PRIVATE KEY`;
|
||
- a word of 32 or more letters and digits that looks random (small letters, capitals and
|
||
at least two digits; a commit's hash, a UUID and a path are not taken for one).
|
||
|
||
Not taken for one: a value that only refers to a variable (`TOKEN=$OTHER`, `"$TOKEN"`,
|
||
`$(command)`), and a name without a value (`export TOKEN`, `--password` alone, which asks).
|
||
|
||
What this cannot know, so do not rely on it for those: a password given as a plain argument
|
||
to a program the list above does not name (`mytool alice hunter2`); a key that has only its
|
||
shape to tell it by, while less of it stands on the line than the rule needs (a 40-character
|
||
key typed by hand, one character at a time, is asked about until enough of it is there —
|
||
pasted, it is there at once); and anything a program prints that does not look like one of
|
||
the forms above. A pane marked private (`Ctrl+Shift+H`) passes nothing on at all, and a line
|
||
that starts with a space is neither sent nor remembered.
|
||
|
||
## Settings
|
||
|
||
What you switch and choose in the terminal is remembered: AI on or off, AI autocomplete,
|
||
suggestions, highlighting, the mode, the chat model, the autocomplete model and the display's
|
||
width. Each is in the command palette twice:
|
||
|
||
- **… — here** keeps it for the working directory of the pane you are in;
|
||
- **… — everywhere** keeps it for this machine.
|
||
|
||
A directory's own value wins over the machine's there. A key (`Ctrl+Shift+I`, `Ctrl+Shift+M`,
|
||
`Ctrl+Alt+M`, `Ctrl+Tab` on the ask line) keeps the choice *here* when this directory already has settings of
|
||
its own, and *everywhere* otherwise; the word shown at your cursor says which. The settings
|
||
of each pane's own directory apply in that pane: change directory, or pane, and the
|
||
suggestions, the colours, the autocomplete, the model and mode on the ask line and what the
|
||
next display starts with follow — two windows in two directories each keep their own.
|
||
|
||
**LLeMbas: settings** lists what applies now and where each value comes from — *here* (with
|
||
the directory), *everywhere*, or the configuration — and has a line that forgets this
|
||
directory's own settings.
|
||
|
||
They are kept by the LLeMbas CLI in its own directory on this machine (its README has the
|
||
path and the commands: `lembas terminal settings`), not in the working directory, and are
|
||
sent nowhere. Nothing is read until your first LLeMbas key or palette entry; once you have
|
||
chosen something through the terminal, they are read at the first prompt, so that they hold
|
||
from the start. Reading them starts the CLI, so with AI off they are not read (what you chose
|
||
for the whole machine, as last read, still applies) and a choice you make then holds until
|
||
the terminal closes; switching AI on reads them again. The options in your configuration file are the starting values only: a value
|
||
you set through the terminal wins over the file, until you remove it (*LLeMbas: settings*,
|
||
or `lembas terminal settings set … <key>=default`).
|
||
|
||
With a LLeMbas CLI that is too old for this terminal a choice holds until the terminal
|
||
closes, and the terminal says once that remembering it needs a newer CLI. What the CLI can do
|
||
is asked again after a minute, and at once when it lacked something you just asked for, so
|
||
after `lembas update` the terminal need not be restarted.
|
||
|
||
**Kept on this machine, sent nowhere:**
|
||
|
||
- *The command history* behind the suggestions: `~/.local/share/llembas-term/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, in a directory of this
|
||
run of the terminal (a terminal started from a pane of another keeps its own). The shell
|
||
also says it by a user variable, which reaches the terminal from another machine too; but
|
||
anything printed to a pane can say the same, so it decides nothing that matters: a command
|
||
enters the history, and the *input mark* is written, only by the record the pane's own
|
||
shell on this machine wrote itself.
|
||
|
||
The session bar reads what LLeMbas itself tells the terminal about its session.
|
||
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
|
||
|
||
With no configuration file, the built-in one applies the layer with its
|
||
defaults. Your own file — everything WezTerm's configuration can do, see
|
||
<https://wezterm.org/config/files.html> — opts in with one line:
|
||
|
||
```lua
|
||
local wezterm = require 'wezterm'
|
||
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,
|
||
tab_marker = true,
|
||
palette = true,
|
||
bar = { fields = { 'model', 'mode', 'state', 'context' } },
|
||
-- also: 'session', 'title', 'effort', 'tokens', 'spend'
|
||
keys = { -- false turns a key off; any of them can be given a key
|
||
ask = { key = 'A', 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' },
|
||
model = { key = 'M', mods = 'CTRL|SHIFT' }, -- the list of chat models
|
||
ac_model = { key = 'm', mods = 'CTRL|ALT' }, -- the list of autocomplete models (a capital
|
||
-- letter means the key with Shift)
|
||
mode_next = { key = 'Tab', mods = 'CTRL' }, -- on the ask line: the other mode
|
||
palette = { key = 'P', mods = 'CTRL|SHIFT|ALT' }, -- the terminal's command palette, once more
|
||
ask_screen = false, always = false, new = false, mode = false,
|
||
},
|
||
ide_keys = true, -- keys LLeMbas IDE has too go to it while it is in front of a pane
|
||
kitty_keyboard = true, -- enable_kitty_keyboard, unless your own file sets it
|
||
-- (ai, mode, display.width, suggestions, highlight and autocomplete are starting values:
|
||
-- what you choose in the terminal is remembered and wins - see Settings)
|
||
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)
|
||
output_lines = 200, -- of each command's output, from its end
|
||
output_bytes = 16384,
|
||
screen_lines = 200, -- of the screen, when it is passed on
|
||
alt_screen = false, -- true: also the screen of a full-screen program
|
||
},
|
||
suggestions = true, -- the rest of the line from your own command history
|
||
highlight = true, -- the command line in colours
|
||
autocomplete = false, -- AI: the rest of the line from LLeMbas, drawn by the terminal
|
||
autocomplete_timeout_ms = 8000, -- how long LLeMbas is given for the rest of a line
|
||
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-term -n`.
|
||
|
||
If your file sets its own right status or tab titles, turn `session_bar` or
|
||
`tab_marker` off, or call `apply` after your own handlers: the terminal uses
|
||
the first tab-title handler it was given.
|
||
|
||
## Shell integration
|
||
|
||
The package installs it for bash through `/etc/profile.d`. For zsh, or after
|
||
unpacking the tarball, add to `~/.zshrc` or `~/.bashrc`:
|
||
|
||
```sh
|
||
[ -n "$LLEMBAS_TERM" ] && . /usr/share/llembas-term/shell/llembas-term.sh
|
||
```
|
||
|
||
It marks commands and their output for the terminal (WezTerm's own
|
||
integration script, OSC 133 and OSC 7), writes the pane's status record, and
|
||
does nothing outside LLeMbas TERM. The suggestions and the colours need it: it
|
||
is how the terminal knows which cells are your command line.
|
||
|
||
**On another machine**, reached with `ssh` from a pane: copy `llembas-term.sh` and `wezterm.sh`
|
||
there and source the first from that shell's rc file with `LLEMBAS_TERM` set (for instance
|
||
`[ -n "$SSH_CONNECTION" ] && LLEMBAS_TERM=remote . ~/.llembas-term.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. The commands you run there are not
|
||
kept in the terminal's history (what that shell says of them is only what it says), and the
|
||
AI's autocomplete is not asked about them.
|
||
|
||
The autocomplete the shell integration used to draw itself (`autocomplete = 'shell'`) is gone:
|
||
it could not know that a pane was made private or that AI was switched off. The terminal
|
||
draws the AI's suggestion itself; `'shell'` now turns nothing on, and says so in the log.
|
||
|
||
## Coming from LLeMbas TTY
|
||
|
||
Up to 1.0.0-beta.5 this terminal was called LLeMbas TTY. Everything that carried that name
|
||
carries the new one: the commands (`llembas-term`, `llembas-term-gui`,
|
||
`llembas-term-mux-server`, `llembas-term-setup`), the package (`llembas-term`), the
|
||
directories (`llembas-term` under `~/.config`, `~/.local/share`, `~/.cache` and the runtime
|
||
directory), the application id (`eu.llembas.term`) and the variables a pane sees
|
||
(`LLEMBAS_TERM`, `LLEMBAS_TERM_PANE`, … — no `LLEMBAS_TTY…` is set any more).
|
||
|
||
1. **Update the LLeMbas CLI first:** `lembas update`. The engine has to know the terminal by
|
||
its new name (its terminal contract 4). An older CLI still works on its own, in a tab
|
||
(`Ctrl+Shift+S`), but cannot be the terminal's display, and the terminal says so.
|
||
2. **Install the new package.** `sudo apt install ./llembas-term_<version>_amd64.deb` removes
|
||
the `llembas-tty` package in the same step (the new one replaces it). Your desktop's
|
||
launcher is now *LLeMbas TERM*; a pinned icon of the old one has to be pinned again.
|
||
3. **Change the line in `~/.zshrc`** (or `~/.bashrc`), if you added the one this README used
|
||
to give. The old line sources a file that is gone, behind a variable that is no longer
|
||
set, so it silently does nothing — and without it there are no suggestions, colours or
|
||
status records in zsh. Replace it with:
|
||
|
||
```sh
|
||
[ -n "$LLEMBAS_TERM" ] && . /usr/share/llembas-term/shell/llembas-term.sh
|
||
```
|
||
|
||
`llembas-term-setup` prints this line when it finds the old one; it does not edit your
|
||
files. The same goes for a copy you made on another machine for `ssh`
|
||
(`LLEMBAS_TERM=remote . ~/.llembas-term.sh`, with the new `llembas-term.sh` copied there).
|
||
|
||
**Carried over for you, once, at the first start:** the terminal's own command history
|
||
(`command-history`) and the mark that you have chosen settings through the terminal
|
||
(`settings-chosen`), copied from `~/.local/share/llembas-tty/` into
|
||
`~/.local/share/llembas-term/` when that does not exist yet. The old files are left where
|
||
they are, nothing that exists in the new place is written over, and the terminal's log says
|
||
what was copied. Your settings themselves are kept by the CLI and need nothing.
|
||
|
||
**Your configuration file is read where it is.** While there is no
|
||
`~/.config/llembas-term/llembas-term.lua` (or `~/.llembas-term.lua`), the terminal reads
|
||
`~/.config/llembas-tty/llembas-tty.lua` (or `~/.llembas-tty.lua`), with the modules beside it,
|
||
and tells you once per start to move it. It is not copied or moved for you. When you are
|
||
ready: `mv ~/.config/llembas-tty ~/.config/llembas-term` and rename the file in it to
|
||
`llembas-term.lua`.
|
||
|
||
Not carried over: the recently used palette entries and emoji, and the old package's
|
||
`/etc/profile.d/llembas-tty.sh`, which stays until `sudo apt purge llembas-tty` and does
|
||
nothing.
|
||
|
||
---
|
||
|
||
# Wez's Terminal
|
||
|
||
<img height="128" alt="WezTerm Icon" src="https://raw.githubusercontent.com/wezterm/wezterm/main/assets/icon/wezterm-icon.svg" align="left"> *A GPU-accelerated cross-platform terminal emulator and multiplexer written by <a href="https://github.com/wez">@wez</a> and implemented in <a href="https://www.rust-lang.org/">Rust</a>*
|
||
|
||
User facing docs and guide at: https://wezterm.org/
|
||
|
||

|
||
|
||
*Screenshot of wezterm on macOS, running vim*
|
||
|
||
## Installation
|
||
|
||
https://wezterm.org/installation
|
||
|
||
## Getting help
|
||
|
||
This is a spare time project, so please bear with me. There are a couple of channels for support:
|
||
|
||
* You can use the [GitHub issue tracker](https://github.com/wezterm/wezterm/issues) to see if someone else has a similar issue, or to file a new one.
|
||
* Start or join a thread in our [GitHub Discussions](https://github.com/wezterm/wezterm/discussions); if you have general
|
||
questions or want to chat with other wezterm users, you're welcome here!
|
||
* There is a [Matrix room via Element.io](https://matrix.to/#/#wezterm:matrix.org)
|
||
for (potentially!) real time discussions.
|
||
|
||
The GitHub Discussions and Element/Gitter rooms are better suited for questions
|
||
than bug reports, but don't be afraid to use whichever you are most comfortable
|
||
using and we'll work it out.
|
||
|
||
## Supporting the Project
|
||
|
||
If you use and like WezTerm, please consider sponsoring it: your support helps
|
||
to cover the fees required to maintain the project and to validate the time
|
||
spent working on it!
|
||
|
||
[Read more about sponsoring](https://wezterm.org/sponsor.html).
|
||
|
||
* [](https://github.com/sponsors/wez)
|
||
* [Patreon](https://patreon.com/WezFurlong)
|
||
* [Ko-Fi](https://ko-fi.com/wezfurlong)
|
||
* [Liberapay](https://liberapay.com/wez)
|