Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c158a6e52a
|
||
|
|
3d44c65fd2
|
||
|
|
e81acbe6b4
|
||
|
|
d728e88883
|
||
|
|
f4052687c6
|
No files matched your search
@@ -56,7 +56,7 @@ jobs:
|
||||
- name: Shell scripts, the workflow, the desktop file
|
||||
run: |
|
||||
shellcheck scripts/*.sh llembas/packaging/*.sh llembas/tests/*.sh llembas/ci/*.sh \
|
||||
llembas/shell/llembas-tty.sh llembas/shell/autocomplete.bash
|
||||
llembas/shell/llembas-tty.sh llembas/shell/autocomplete.bash llembas/setup/llembas-tty-setup
|
||||
zsh -n llembas/shell/autocomplete.zsh
|
||||
zsh -n llembas/shell/llembas-tty.sh
|
||||
yamllint -d '{extends: default, rules: {line-length: disable, document-start: disable, truthy: disable}}' .github/workflows/llembas-tty.yml
|
||||
@@ -68,8 +68,8 @@ jobs:
|
||||
with:
|
||||
# Upstream's code is not held to "no warnings" here; the action's default would be.
|
||||
rustflags: ""
|
||||
- name: The bundled LLeMbas CLI, verified
|
||||
run: scripts/fetch-cli.sh
|
||||
- name: The set-up program (what it installs is checked against the release key)
|
||||
run: llembas/tests/setup-test.sh
|
||||
- name: Build (release)
|
||||
run: cargo build --release --locked -p wezterm -p wezterm-gui -p wezterm-mux-server
|
||||
- name: The binaries carry our names
|
||||
@@ -86,7 +86,8 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get install -y ./dist/llembas-tty_*.deb
|
||||
llembas-tty --version
|
||||
test -x /usr/lib/llembas-tty/lembas
|
||||
test ! -e /usr/lib/llembas-tty/lembas
|
||||
llembas-tty-setup --dry-run
|
||||
llembas/tests/smoke.sh /usr/lib/llembas-tty
|
||||
sudo apt-get remove -y llembas-tty
|
||||
- name: SHA256SUMS
|
||||
|
||||
@@ -3,6 +3,41 @@
|
||||
What changed in each release of LLeMbas TTY. WezTerm's own changes are in
|
||||
`docs/changelog.md`, as upstream keeps them.
|
||||
|
||||
## 1.0.0-beta.3 — 2026-12-02
|
||||
|
||||
### Changed
|
||||
|
||||
- **The terminal carries no LLeMbas CLI of its own any more.** It uses the `lembas` you have —
|
||||
on `PATH`, or in `~/.local/bin` where its installer puts it — the same one you use outside the
|
||||
terminal, updated by itself. The package is smaller by that copy.
|
||||
- The CLI that 1.0.0-beta.1 and 1.0.0-beta.2 kept in `/usr/lib/llembas-tty/` is removed by the
|
||||
update. If it was the only one you had: run the set-up below once, and log in again.
|
||||
|
||||
### Added
|
||||
|
||||
- **Set-up: the CLI and LLeMbas IDE installed when they are missing.** The palette entry
|
||||
*LLeMbas: set up (CLI and IDE)*, or `llembas-tty-setup` in a shell, says what is missing and
|
||||
asks before installing each, for your user only. It runs each product's own installer from
|
||||
its own release, and only after checking it against the LLeMbas release key. A beta terminal
|
||||
installs the newest betas.
|
||||
- **LLeMbas IDE from the terminal**: `Ctrl+Shift+E`, or *LLeMbas: open LLeMbas IDE here*, opens
|
||||
the editor in a new tab in the pane's directory. Option `ide` for its path, key `keys.ide`.
|
||||
|
||||
## 1.0.0-beta.2 — 2026-12-02
|
||||
|
||||
### Changed
|
||||
|
||||
- **A quiet window by default.** No tab bar while a window has one tab; with more, a plain line
|
||||
of text at the bottom instead of a strip in the window's frame. Tabs are opened, closed and
|
||||
walked by keys as before. This is the built-in configuration only: your own file decides for
|
||||
itself. The session bar sits in that line, so with one tab it is not shown.
|
||||
|
||||
### Fixed
|
||||
|
||||
- The `.deb` file is named by the version as written (`llembas-tty_1.0.0-beta.2_amd64.deb`). In
|
||||
1.0.0-beta.1 its name carried Debian's `~`, which a forge's upload turns into a dot, so the
|
||||
release's `SHA256SUMS` named a file that was not there under that name.
|
||||
|
||||
## 1.0.0-beta.1 — 2026-12-02
|
||||
|
||||
### Added
|
||||
|
||||
@@ -6,11 +6,14 @@ 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.
|
||||
|
||||
The agent is the [LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI)
|
||||
(`lembas`), unchanged; the package carries a verified copy beside the terminal.
|
||||
It logs in to your own LLeMbas server and uses that server's models.
|
||||
(`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.
|
||||
|
||||
**State: 1.0.0-beta.1, not released yet.** The terminal's side described here
|
||||
is written and tested without a terminal; the first builds come from CI. The
|
||||
**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
|
||||
@@ -27,7 +30,15 @@ Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like WezTerm — see
|
||||
| `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+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). |
|
||||
|
||||
- **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+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
|
||||
@@ -41,6 +52,22 @@ Version in `VERSION`, changes in `CHANGELOG.md`. MIT, like WezTerm — see
|
||||
`~/.config/llembas-tty/llembas-tty.lua` (or `~/.llembas-tty.lua`), and it
|
||||
neither reads WezTerm's files nor talks to a running WezTerm.
|
||||
|
||||
## 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 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-tty-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 and the installer must match it. Nothing runs as root
|
||||
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, and when
|
||||
|
||||
Only when you ask (the two *ask* entries), and only this:
|
||||
@@ -75,7 +102,8 @@ local config = wezterm.config_builder()
|
||||
require('llembas').apply(config, {
|
||||
-- every line is optional; these are the defaults
|
||||
enabled = true, -- false: no layer at all
|
||||
cli = nil, -- path of `lembas`; nil: the bundled one, then PATH
|
||||
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,
|
||||
@@ -87,6 +115,7 @@ require('llembas').apply(config, {
|
||||
resume = { key = 'O', mods = 'CTRL|SHIFT' },
|
||||
toggle_display = { key = 'D', mods = 'CTRL|SHIFT' },
|
||||
private = { key = 'H', mods = 'CTRL|SHIFT' },
|
||||
ide = { key = 'E', mods = 'CTRL|SHIFT' },
|
||||
},
|
||||
split = { direction = 'Right', size = 0.45 },
|
||||
new_session_in = 'split', -- or 'tab'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
2.0.0-beta.18
|
||||
+4
-3
@@ -14,10 +14,10 @@ llembas/
|
||||
tests/smoke.sh headless test of built binaries (CI)
|
||||
shell/ shell integration: zones, cwd, prompt autocomplete
|
||||
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
|
||||
scripts/
|
||||
test-lua.sh run tests/run.lua with lua5.4, lua, luajit or nvim -l
|
||||
fetch-cli.sh the pinned LLeMbas CLI (llembas-cli.version), verified
|
||||
hygiene.sh nothing private in what the fork adds
|
||||
.github/workflows/llembas-tty.yml
|
||||
```
|
||||
@@ -114,8 +114,9 @@ repository needs:
|
||||
- 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. The LLeMbas CLI is fetched from its
|
||||
public releases and verified against the release key in `scripts/fetch-cli.sh`.
|
||||
`contents: write` for the release. Nothing else is fetched: the package
|
||||
carries neither the LLeMbas CLI nor LLeMbas IDE (`setup/llembas-tty-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.
|
||||
|
||||
|
||||
@@ -4,5 +4,11 @@
|
||||
-- own file starts from the same four lines.
|
||||
local wezterm = require 'wezterm'
|
||||
local config = wezterm.config_builder()
|
||||
-- A quiet window: no tab bar while there is one tab, and when there are more a plain line of
|
||||
-- text at the bottom rather than a strip built into the window's frame. Tabs are opened, closed
|
||||
-- and walked by keys (CTRL+SHIFT+T, CTRL+SHIFT+W, CTRL+TAB) whether the bar shows or not.
|
||||
config.hide_tab_bar_if_only_one_tab = true
|
||||
config.use_fancy_tab_bar = false
|
||||
config.tab_bar_at_bottom = true
|
||||
require('llembas').apply(config)
|
||||
return config
|
||||
@@ -51,9 +51,11 @@ M.BAR_FIELDS = {
|
||||
function M.defaults()
|
||||
return {
|
||||
enabled = true,
|
||||
-- Path of the LLeMbas CLI. nil: the one shipped beside this terminal,
|
||||
-- then `lembas` on PATH.
|
||||
-- Path of the LLeMbas CLI. nil: `lembas` on PATH, then in ~/.local/bin
|
||||
-- (where its installer puts it). The terminal carries no copy of its own.
|
||||
cli = nil,
|
||||
-- Path of LLeMbas IDE's launcher. nil: `llembas-ide` on PATH, then in ~/.local/bin.
|
||||
ide = nil,
|
||||
session_bar = true,
|
||||
tab_marker = true,
|
||||
palette = true,
|
||||
@@ -66,6 +68,7 @@ function M.defaults()
|
||||
resume = { key = 'O', mods = 'CTRL|SHIFT' },
|
||||
toggle_display = { key = 'D', mods = 'CTRL|SHIFT' },
|
||||
private = { key = 'H', mods = 'CTRL|SHIFT' },
|
||||
ide = { key = 'E', mods = 'CTRL|SHIFT' },
|
||||
},
|
||||
split = {
|
||||
direction = 'Right',
|
||||
@@ -343,7 +346,7 @@ local function merge_into(base, over, path, warnings)
|
||||
for k, v in pairs(over) do
|
||||
local where = path .. tostring(k)
|
||||
local d = base[k]
|
||||
if d == nil and not (path == '' and k == 'cli') then
|
||||
if d == nil and not (path == '' and (k == 'cli' or k == 'ide')) then
|
||||
warnings[#warnings + 1] = where .. ': not an option of the LLeMbas layer'
|
||||
elseif path == 'keys.' then
|
||||
-- a key: false turns it off, a table { key =, mods = } sets it
|
||||
@@ -433,6 +436,10 @@ function M.options(user)
|
||||
warnings[#warnings + 1] = 'cli: expected a path'
|
||||
o.cli = nil
|
||||
end
|
||||
if o.ide ~= nil and (type(o.ide) ~= 'string' or o.ide == '') then
|
||||
warnings[#warnings + 1] = 'ide: expected a path'
|
||||
o.ide = nil
|
||||
end
|
||||
return o, warnings
|
||||
end
|
||||
|
||||
@@ -945,31 +952,51 @@ function M.cli_supports_terminal(version_text)
|
||||
return cmp >= 0
|
||||
end
|
||||
|
||||
-- Where the CLI may be, in the order tried.
|
||||
-- explicit: the `cli` option
|
||||
-- executable_dir: where this terminal's own binaries are
|
||||
-- path: $PATH
|
||||
-- windows: true on Windows
|
||||
function M.cli_candidates(explicit, executable_dir, path, windows)
|
||||
-- Where a program of the LLeMbas family may be, in the order tried. Each is an installation of
|
||||
-- its own, the same one a person uses outside this terminal: the terminal carries no copy.
|
||||
-- name: 'lembas' or 'llembas-ide'
|
||||
-- explicit: the option naming its path (then only that)
|
||||
-- home: the person's home directory: <home>/.local/bin is where both installers put
|
||||
-- their program, and a terminal started from a desktop's menu often has no PATH
|
||||
-- entry for it
|
||||
-- path: $PATH
|
||||
-- windows: true on Windows
|
||||
function M.program_candidates(name, explicit, home, path, windows)
|
||||
local list = {}
|
||||
if explicit then
|
||||
list[1] = explicit
|
||||
return list
|
||||
end
|
||||
local name = windows and 'lembas.exe' or 'lembas'
|
||||
local file = windows and (name .. '.exe') or name
|
||||
local sep = windows and '\\' or '/'
|
||||
if type(executable_dir) == 'string' and executable_dir ~= '' then
|
||||
list[#list + 1] = executable_dir .. sep .. name
|
||||
local seen = {}
|
||||
local function add(dir)
|
||||
local candidate = dir .. sep .. file
|
||||
if not seen[candidate] then
|
||||
seen[candidate] = true
|
||||
list[#list + 1] = candidate
|
||||
end
|
||||
end
|
||||
if type(path) == 'string' then
|
||||
local pattern = windows and '[^;]+' or '[^:]+'
|
||||
for dir in path:gmatch(pattern) do
|
||||
list[#list + 1] = dir .. sep .. name
|
||||
add(dir)
|
||||
end
|
||||
end
|
||||
if not windows and type(home) == 'string' and home ~= '' then
|
||||
add(home .. '/.local/bin')
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
function M.cli_candidates(explicit, home, path, windows)
|
||||
return M.program_candidates('lembas', explicit, home, path, windows)
|
||||
end
|
||||
|
||||
function M.ide_candidates(explicit, home, path, windows)
|
||||
return M.program_candidates('llembas-ide', explicit, home, path, windows)
|
||||
end
|
||||
|
||||
-- The choices of the "resume a session" list from what
|
||||
-- `lembas sessions --json` printed, already decoded: a list of objects with
|
||||
-- at least an `id`. nil when it is not that (an older CLI prints plain text).
|
||||
@@ -1011,14 +1038,20 @@ end
|
||||
----------------------------------------------------------------------------
|
||||
-- Words
|
||||
|
||||
M.INSTALL_COMMAND = 'curl -fsSL https://github.com/LLeMbas/LLeMbas-CLI/releases/latest/download/get.sh | bash'
|
||||
-- The program that installs what is missing (llembas/setup/llembas-tty-setup, beside the
|
||||
-- terminal's own binaries).
|
||||
M.SETUP_NAME = 'llembas-tty-setup'
|
||||
|
||||
M.messages = {
|
||||
cli_missing = 'The LLeMbas CLI (lembas) was not found: not beside this terminal and not on PATH.\r\n'
|
||||
.. 'Install it with:\r\n\r\n '
|
||||
.. M.INSTALL_COMMAND
|
||||
.. '\r\n\r\nor set its path: require("llembas").apply(config, { cli = "/path/to/lembas" })',
|
||||
cli_missing_short = 'The LLeMbas CLI (lembas) is still not found. Install it, or set the `cli` option.',
|
||||
cli_missing = 'The LLeMbas CLI (lembas) is not installed: it is not on PATH and not in ~/.local/bin.\r\n'
|
||||
.. 'Install it with the command palette entry "LLeMbas: set up (CLI and IDE)",\r\n'
|
||||
.. 'or in a shell: llembas-tty-setup\r\n\r\n'
|
||||
.. 'If it is somewhere else: require("llembas").apply(config, { cli = "/path/to/lembas" })',
|
||||
cli_missing_short = 'The LLeMbas CLI (lembas) is still not found. Run "LLeMbas: set up (CLI and IDE)", or set the `cli` option.',
|
||||
ide_missing = 'LLeMbas IDE (llembas-ide) is not installed: it is not on PATH and not in ~/.local/bin.\r\n'
|
||||
.. 'Install it with the command palette entry "LLeMbas: set up (CLI and IDE)",\r\n'
|
||||
.. 'or in a shell: llembas-tty-setup',
|
||||
setup_missing = 'The set-up program (llembas-tty-setup) is not beside this terminal. Install the LLeMbas CLI and LLeMbas IDE by their own installers.',
|
||||
cli_too_old = 'This LLeMbas CLI is too old to work with the terminal: it is %s, and %s or newer is needed.\r\n'
|
||||
.. 'Update it with: lembas update',
|
||||
private = 'This pane is private: nothing of it is passed on. The question was sent alone.',
|
||||
|
||||
@@ -37,6 +37,8 @@ local EV = {
|
||||
toggle_display = 'llembas-toggle-display',
|
||||
private = 'llembas-private',
|
||||
login = 'llembas-login',
|
||||
ide = 'llembas-ide',
|
||||
setup = 'llembas-setup',
|
||||
dismiss = 'llembas-dismiss',
|
||||
}
|
||||
M.events = EV
|
||||
@@ -99,8 +101,7 @@ local function file_exists(path)
|
||||
end
|
||||
|
||||
-- The path of the CLI, or nil. Looks at files only; starts nothing.
|
||||
function M.find_cli()
|
||||
local list = core.cli_candidates(opts.cli, wezterm.executable_dir, os.getenv 'PATH', is_windows())
|
||||
local function first_existing(list)
|
||||
for _, candidate in ipairs(list) do
|
||||
if file_exists(candidate) then
|
||||
return candidate
|
||||
@@ -109,6 +110,25 @@ function M.find_cli()
|
||||
return nil
|
||||
end
|
||||
|
||||
function M.find_cli()
|
||||
return first_existing(core.cli_candidates(opts.cli, wezterm.home_dir, os.getenv 'PATH', is_windows()))
|
||||
end
|
||||
|
||||
-- The path of LLeMbas IDE's launcher, or nil. Files only; starts nothing.
|
||||
function M.find_ide()
|
||||
return first_existing(core.ide_candidates(opts.ide, wezterm.home_dir, os.getenv 'PATH', is_windows()))
|
||||
end
|
||||
|
||||
-- The set-up program shipped beside the terminal's binaries, or nil.
|
||||
function M.find_setup()
|
||||
local dir = wezterm.executable_dir
|
||||
if type(dir) ~= 'string' or dir == '' then
|
||||
return nil
|
||||
end
|
||||
local path = dir .. '/' .. core.SETUP_NAME
|
||||
return file_exists(path) and path or nil
|
||||
end
|
||||
|
||||
-- The CLI, or nil after telling the person why not.
|
||||
local function need_cli(window, pane)
|
||||
local cli = M.find_cli()
|
||||
@@ -462,6 +482,27 @@ local function login(window, pane)
|
||||
end
|
||||
end
|
||||
|
||||
-- Install what is missing of the family (the CLI, LLeMbas IDE), each as its own installation:
|
||||
-- the set-up program runs in a pane, says what it would do, and asks before each step.
|
||||
local function setup(window, pane)
|
||||
local program = M.find_setup()
|
||||
if not program then
|
||||
tell(window, pane, core.messages.setup_missing)
|
||||
return
|
||||
end
|
||||
split_with(pane, { program })
|
||||
end
|
||||
|
||||
-- LLeMbas IDE in a new tab, in the pane's directory.
|
||||
local function open_ide(window, pane)
|
||||
local ide = M.find_ide()
|
||||
if not ide then
|
||||
tell(window, pane, core.messages.ide_missing)
|
||||
return
|
||||
end
|
||||
window:perform_action(act.SpawnCommandInNewTab { args = { ide }, cwd = pane_cwd(pane) }, pane)
|
||||
end
|
||||
|
||||
local function resume(window, pane)
|
||||
local cli = need_cli(window, pane)
|
||||
if not cli then
|
||||
@@ -557,6 +598,8 @@ local PALETTE = {
|
||||
{ 'LLeMbas: toggle side display', 'toggle_display', 'md_dock_right' },
|
||||
{ 'LLeMbas: private pane on/off', 'private', 'md_eye_off_outline' },
|
||||
{ 'LLeMbas: log in', 'login', 'md_login' },
|
||||
{ 'LLeMbas: open LLeMbas IDE here', 'ide', 'md_code_braces' },
|
||||
{ 'LLeMbas: set up (CLI and IDE)', 'setup', 'md_download' },
|
||||
}
|
||||
|
||||
local function palette()
|
||||
@@ -589,6 +632,8 @@ local function register_events()
|
||||
wezterm.on(EV.toggle_display, toggle_display)
|
||||
wezterm.on(EV.private, toggle_private)
|
||||
wezterm.on(EV.login, login)
|
||||
wezterm.on(EV.ide, open_ide)
|
||||
wezterm.on(EV.setup, setup)
|
||||
wezterm.on(EV.dismiss, function() end)
|
||||
|
||||
wezterm.on('user-var-changed', function(_, pane, name, value)
|
||||
@@ -614,6 +659,7 @@ local KEY_EVENTS = {
|
||||
resume = EV.resume,
|
||||
toggle_display = EV.toggle_display,
|
||||
private = EV.private,
|
||||
ide = EV.ide,
|
||||
}
|
||||
|
||||
-- apply(config, options): add the layer to a configuration. Returns config.
|
||||
@@ -629,7 +675,7 @@ function M.apply(config, options)
|
||||
end
|
||||
|
||||
local keys = config.keys or {}
|
||||
for _, name in ipairs { 'ask', 'new_session', 'resume', 'toggle_display', 'private' } do
|
||||
for _, name in ipairs { 'ask', 'new_session', 'resume', 'toggle_display', 'private', 'ide' } do
|
||||
local k = opts.keys[name]
|
||||
if k then
|
||||
keys[#keys + 1] = { key = k.key, mods = k.mods, action = act.EmitEvent(KEY_EVENTS[name]) }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# The verified LLeMbas CLI (scripts/fetch-cli.sh) and the packages built from it.
|
||||
# The packages built here.
|
||||
/bin/
|
||||
/dist/
|
||||
@@ -3,18 +3,18 @@
|
||||
#
|
||||
# llembas/packaging/package.sh [target-dir] [out-dir] (default: target, llembas/packaging/dist)
|
||||
#
|
||||
# Expects: the three release binaries in <target-dir>/release, and the verified LLeMbas CLI in
|
||||
# llembas/packaging/bin/lembas (scripts/fetch-cli.sh). Builds nothing itself.
|
||||
# Expects: the three release binaries in <target-dir>/release. Builds nothing itself.
|
||||
#
|
||||
# The tree (the tarball has it under llembas-tty-<version>/, the .deb under /):
|
||||
# usr/lib/llembas-tty/ llembas-tty, llembas-tty-gui, llembas-tty-mux-server, lembas
|
||||
# usr/bin/ links to the three terminal binaries (not to lembas: the CLI
|
||||
# a person installed themselves stays the one on PATH)
|
||||
# usr/lib/llembas-tty/ llembas-tty, llembas-tty-gui, llembas-tty-mux-server, and
|
||||
# llembas-tty-setup (installs the LLeMbas CLI and LLeMbas IDE
|
||||
# when they are missing; the package carries neither)
|
||||
# usr/bin/ links to those four
|
||||
# usr/share/llembas-tty/shell/ shell integration: llembas-tty.sh, wezterm.sh, autocomplete.*
|
||||
# usr/share/llembas-tty/lua/ the LLeMbas layer's source, to read (the binary has it built in)
|
||||
# usr/share/applications, metainfo, icons/hicolor
|
||||
# usr/share/doc/llembas-tty/ licences: ours and WezTerm's (LICENSE.md, licenses/), the
|
||||
# CLI's (LICENSES-lembas.txt), README, CHANGELOG
|
||||
# usr/share/doc/llembas-tty/ licences: ours and WezTerm's (LICENSE.md, licenses/), README,
|
||||
# CHANGELOG
|
||||
# etc/profile.d/llembas-tty.sh (.deb only)
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
@@ -24,14 +24,10 @@ OUT="${2:-llembas/packaging/dist}"
|
||||
VERSION="$(tr -d '[:space:]' < VERSION)"
|
||||
ARCH="$(dpkg --print-architecture)"
|
||||
REL="$TARGET/release"
|
||||
CLI=llembas/packaging/bin/lembas
|
||||
|
||||
for b in llembas-tty llembas-tty-gui llembas-tty-mux-server; do
|
||||
[ -x "$REL/$b" ] || { echo "package: $REL/$b is not built" >&2; exit 1; }
|
||||
done
|
||||
[ -x "$CLI" ] || { echo "package: $CLI is missing (run scripts/fetch-cli.sh)" >&2; exit 1; }
|
||||
[ "$("$CLI" --version)" = "$(tr -d '[:space:]' < llembas-cli.version)" ] \
|
||||
|| { echo "package: $CLI is not the version in llembas-cli.version" >&2; exit 1; }
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "${work:?}"' EXIT
|
||||
@@ -46,8 +42,10 @@ for b in llembas-tty llembas-tty-gui llembas-tty-mux-server; do
|
||||
install -m755 -s "$REL/$b" "$lib/$b"
|
||||
ln -s "../lib/llembas-tty/$b" "$root/usr/bin/$b"
|
||||
done
|
||||
# Not stripped: the CLI is a compiled bundle that carries its program after the executable.
|
||||
install -m755 "$CLI" "$lib/lembas"
|
||||
# No copy of the LLeMbas CLI or of LLeMbas IDE: each is its own installation, the same one used
|
||||
# outside this terminal. The set-up program installs what is missing, by their own installers.
|
||||
install -m755 llembas/setup/llembas-tty-setup "$lib/llembas-tty-setup"
|
||||
ln -s ../lib/llembas-tty/llembas-tty-setup "$root/usr/bin/llembas-tty-setup"
|
||||
|
||||
install -m644 llembas/shell/llembas-tty.sh llembas/shell/autocomplete.bash llembas/shell/autocomplete.zsh "$share/shell/"
|
||||
install -m644 assets/shell-integration/wezterm.sh "$share/shell/wezterm.sh"
|
||||
@@ -65,14 +63,10 @@ install -Dm644 llembas/packaging/icons/eu.llembas.tty.svg "$root/usr/share/icons
|
||||
install -m644 LICENSE.md README.md CHANGELOG.md "$doc/"
|
||||
install -d "$doc/licenses"
|
||||
install -m644 licenses/* "$doc/licenses/"
|
||||
"$CLI" --licenses > "$doc/LICENSES-lembas.txt"
|
||||
chmod 644 "$doc/LICENSES-lembas.txt"
|
||||
[ -s "$doc/LICENSES-lembas.txt" ] || { echo "package: the CLI printed no licences" >&2; exit 1; }
|
||||
|
||||
mkdir -p "$OUT"
|
||||
|
||||
# The tarball: the tree as it is, to unpack anywhere (the binaries find each other and the CLI
|
||||
# by their own location; source usr/share/llembas-tty/shell/llembas-tty.sh from the shell's rc).
|
||||
# The tarball: the tree as it is, to unpack anywhere (the binaries find each other by their own location; source usr/share/llembas-tty/shell/llembas-tty.sh from the shell's rc).
|
||||
name="llembas-tty-$VERSION-linux-$ARCH"
|
||||
cp -a "$root" "$work/$name"
|
||||
tar -C "$work" --owner=0 --group=0 --numeric-owner -cJf "$OUT/$name.tar.xz" "$name"
|
||||
@@ -95,13 +89,16 @@ Section: utils
|
||||
Priority: optional
|
||||
Homepage: https://llembas.eu
|
||||
Depends: $depends
|
||||
Recommends: curl, openssh-client, git
|
||||
Description: A terminal with LLeMbas built in
|
||||
LLeMbas TTY is a terminal emulator and multiplexer, a fork of WezTerm,
|
||||
with the LLeMbas agent built in. By default it is an ordinary terminal.
|
||||
It installs beside WezTerm and shares nothing with it.
|
||||
CONTROL
|
||||
echo "/etc/profile.d/llembas-tty.sh" > "$root/DEBIAN/conffiles"
|
||||
dpkg-deb --root-owner-group -b "$root" "$OUT/llembas-tty_${debver}_${ARCH}.deb" >/dev/null
|
||||
# The file is named by the version as written (a dash): a forge's upload turns ~ into a dot, and
|
||||
# SHA256SUMS would then name a file that is not there. The package's own Version keeps the ~.
|
||||
dpkg-deb --root-owner-group -b "$root" "$OUT/llembas-tty_${VERSION}_${ARCH}.deb" >/dev/null
|
||||
base="${VERSION%%-*}"
|
||||
if [ "$VERSION" != "$base" ]; then
|
||||
dpkg --compare-versions "$debver" lt "$base" || { echo "package: $debver does not sort below $base" >&2; exit 1; }
|
||||
|
||||
Executable
+215
@@ -0,0 +1,215 @@
|
||||
#!/usr/bin/env bash
|
||||
# LLeMbas TTY's set-up: install what is missing of the LLeMbas family beside the terminal —
|
||||
# the LLeMbas CLI (`lembas`) and LLeMbas IDE (`llembas-ide`) — each as its own installation,
|
||||
# the same one you use outside this terminal. The terminal carries no copy of either.
|
||||
#
|
||||
# llembas-tty-setup [--yes] [--dry-run] [--channel stable|beta] [--no-cli] [--no-ide]
|
||||
#
|
||||
# For each one that is not installed it says what it would do and asks. What it then runs is
|
||||
# that product's own installer, from that product's own release, and only after checking it:
|
||||
# the release's SHA256SUMS must be signed with the LLeMbas release key, and the installer must
|
||||
# match SHA256SUMS. Nothing runs as root; nothing that is already installed is touched (each
|
||||
# product updates itself: `lembas update`, `llembas-ide update`).
|
||||
#
|
||||
# Environment (for a mirror or a build of your own):
|
||||
# LLEMBAS_SETUP_FORGE where the releases are (default https://github.com)
|
||||
# LLEMBAS_SETUP_API its releases API (default https://api.github.com)
|
||||
# LLEMBAS_SETUP_PUBKEY the ssh-ed25519 key SHA256SUMS.sig must be signed with
|
||||
set -euo pipefail
|
||||
|
||||
FORGE="${LLEMBAS_SETUP_FORGE:-https://github.com}"
|
||||
API="${LLEMBAS_SETUP_API:-https://api.github.com}"
|
||||
PUBKEY="${LLEMBAS_SETUP_PUBKEY:-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDSZO3Byow7R3ZpOH3MCvpPIga2pZBzhfX5wXfNP1cLa}"
|
||||
NAMESPACE=lembas-release
|
||||
CLI_SLUG=LLeMbas/LLeMbas-CLI
|
||||
IDE_SLUG=LLeMbas/LLeMbas-IDE
|
||||
|
||||
YES=0
|
||||
DRY=0
|
||||
WANT_CLI=1
|
||||
WANT_IDE=1
|
||||
CHANNEL=""
|
||||
TMP=""
|
||||
|
||||
say() { printf '%s\n' "$*"; }
|
||||
note() { printf ' %s\n' "$*"; }
|
||||
warn() { printf 'llembas-tty-setup: %s\n' "$*" >&2; }
|
||||
die() {
|
||||
warn "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
[ -z "$TMP" ] || rm -rf "$TMP"
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
# Started by the terminal in a pane of its own, the pane closes with this program: wait for a
|
||||
# key first, so that what was said can be read.
|
||||
pause() {
|
||||
[ -n "${LLEMBAS_TTY_PANE:-}" ] && [ "$YES" != 1 ] && [ -r /dev/tty ] || return 0
|
||||
printf '\nPress Enter to close. ' >/dev/tty
|
||||
read -r _ </dev/tty || true
|
||||
}
|
||||
|
||||
# The channel of this terminal unless one was named: a beta terminal installs betas.
|
||||
channel() {
|
||||
if [ -n "$CHANNEL" ]; then
|
||||
printf '%s' "$CHANNEL"
|
||||
return
|
||||
fi
|
||||
case "${LLEMBAS_TTY:-}" in *-*) printf beta ;; *) printf stable ;; esac
|
||||
}
|
||||
|
||||
# A program on PATH, or where both installers put theirs.
|
||||
have() {
|
||||
command -v "$1" 2>/dev/null && return 0
|
||||
[ -x "$HOME/.local/bin/$1" ] && printf '%s\n' "$HOME/.local/bin/$1" && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
ask() { # question; answers yes with --yes, no where nobody can answer
|
||||
[ "$YES" = 1 ] && return 0
|
||||
[ -r /dev/tty ] || return 1
|
||||
local answer
|
||||
printf '%s [Y/n] ' "$1" >/dev/tty
|
||||
read -r answer </dev/tty || return 1
|
||||
case "$answer" in "" | y | Y | yes | Yes) return 0 ;; *) return 1 ;; esac
|
||||
}
|
||||
|
||||
fetch() { # url, file — https only, or a file on this machine
|
||||
case "$1" in
|
||||
https://* | file:///*) ;;
|
||||
*) die "refusing to download $1: only https:// (or a local file://) is used" ;;
|
||||
esac
|
||||
curl -fsSL --retry 2 --proto '=https,file' --proto-redir '=https' -o "$2" "$1"
|
||||
}
|
||||
|
||||
# The newest release tag of a repository on a channel: vX.Y.Z, and on beta also vX.Y.Z-beta.N.
|
||||
newest() { # slug, channel
|
||||
local slug="$1" chan="$2" list="$TMP/releases.json" tag url
|
||||
url="$API/repos/$slug/releases"
|
||||
# A listing kept as a file (a mirror on this machine) has no query to answer.
|
||||
case "$API" in file://*) ;; *) url="$url?per_page=50" ;; esac
|
||||
fetch "$url" "$list" 2>/dev/null || return 1
|
||||
# One "tag_name" a release, newest first; a draft has none that is published.
|
||||
while IFS= read -r tag; do
|
||||
case "$chan" in
|
||||
beta) [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$ ]] && printf '%s' "$tag" && return 0 ;;
|
||||
*) [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && printf '%s' "$tag" && return 0 ;;
|
||||
esac
|
||||
done < <(grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' "$list" | sed -E 's/.*"([^"]*)"$/\1/')
|
||||
return 1
|
||||
}
|
||||
|
||||
# A release's installer, checked: SHA256SUMS signed by the release key, the installer in it.
|
||||
checked_installer() { # slug, tag, installer file name -> path of the checked file
|
||||
local slug="$1" tag="$2" name="$3" dir base
|
||||
dir="$TMP/$(printf '%s' "$slug-$tag" | tr '/' '-')"
|
||||
base="$FORGE/$slug/releases/download/$tag"
|
||||
mkdir -p "$dir"
|
||||
command -v ssh-keygen >/dev/null 2>&1 || die "needs ssh-keygen (openssh-client): it checks the release's signature"
|
||||
command -v sha256sum >/dev/null 2>&1 || die "needs sha256sum: it checks what was downloaded"
|
||||
fetch "$base/SHA256SUMS" "$dir/SHA256SUMS" || die "could not download SHA256SUMS of $slug $tag — nothing installed"
|
||||
fetch "$base/SHA256SUMS.sig" "$dir/SHA256SUMS.sig" 2>/dev/null || die "$slug $tag is not signed (no SHA256SUMS.sig) — nothing installed"
|
||||
fetch "$base/$name" "$dir/$name" || die "could not download $name of $slug $tag — nothing installed"
|
||||
printf '%s %s\n' "$NAMESPACE" "$PUBKEY" >"$dir/allowed"
|
||||
ssh-keygen -Y verify -f "$dir/allowed" -I "$NAMESPACE" -n "$NAMESPACE" -s "$dir/SHA256SUMS.sig" <"$dir/SHA256SUMS" >/dev/null 2>&1 ||
|
||||
die "SHA256SUMS of $slug $tag is not signed by the LLeMbas release key — nothing installed"
|
||||
(cd "$dir" && grep -E "^[0-9a-f]{64} \*?$name\$" SHA256SUMS | sed 's/ \*/ /' | sha256sum -c --strict --quiet - >/dev/null 2>&1) ||
|
||||
die "$name of $slug $tag does not match its SHA256SUMS — nothing installed"
|
||||
printf '%s' "$dir/$name"
|
||||
}
|
||||
|
||||
setup_cli() {
|
||||
local at tag chan installer
|
||||
if at="$(have lembas)"; then
|
||||
note "the LLeMbas CLI is installed: $at ($("$at" --version 2>/dev/null | head -n1 || echo "version unknown"))"
|
||||
return 0
|
||||
fi
|
||||
chan="$(channel)"
|
||||
say "The LLeMbas CLI (lembas) is not installed."
|
||||
if [ "$DRY" = 1 ]; then
|
||||
note "would find the newest $chan release of $CLI_SLUG, check its get.sh against the release key, and run it"
|
||||
note "it installs for this user only, into ~/.local/bin and ~/.local/share/lembas"
|
||||
return 0
|
||||
fi
|
||||
ask "Install it now, for this user only?" || {
|
||||
note "left out"
|
||||
return 0
|
||||
}
|
||||
tag="$(newest "$CLI_SLUG" "$chan")" || die "no $chan release of $CLI_SLUG was found (is this machine online?) — nothing installed"
|
||||
installer="$(checked_installer "$CLI_SLUG" "$tag" get.sh)"
|
||||
note "LLeMbas CLI $tag: signature good, installing"
|
||||
LEMBAS_REF="$tag" LEMBAS_CHANNEL="$chan" bash "$installer" || die "the LLeMbas CLI's installer stopped — see above"
|
||||
}
|
||||
|
||||
setup_ide() {
|
||||
local at tag chan installer
|
||||
if at="$(have llembas-ide)"; then
|
||||
note "LLeMbas IDE is installed: $at"
|
||||
return 0
|
||||
fi
|
||||
chan="$(channel)"
|
||||
say "LLeMbas IDE (llembas-ide, the editor) is not installed."
|
||||
if [ "$DRY" = 1 ]; then
|
||||
note "would find the newest $chan release of $IDE_SLUG, check its install.sh against the release key, and run it"
|
||||
note "it installs for this user only, under its own name: your own Neovim is not touched"
|
||||
return 0
|
||||
fi
|
||||
ask "Install it now, for this user only?" || {
|
||||
note "left out"
|
||||
return 0
|
||||
}
|
||||
tag="$(newest "$IDE_SLUG" "$chan")" || die "no $chan release of $IDE_SLUG was found (is this machine online?) — nothing installed"
|
||||
installer="$(checked_installer "$IDE_SLUG" "$tag" install.sh)"
|
||||
note "LLeMbas IDE $tag: signature good, installing"
|
||||
# --no-cli: the CLI is this program's own step above.
|
||||
bash "$installer" --version "${tag#v}" --channel "$chan" --no-cli --yes || die "LLeMbas IDE's installer stopped — see above"
|
||||
}
|
||||
|
||||
main() {
|
||||
trap cleanup EXIT
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--yes) YES=1 ;;
|
||||
--dry-run) DRY=1 ;;
|
||||
--no-cli) WANT_CLI=0 ;;
|
||||
--no-ide) WANT_IDE=0 ;;
|
||||
--channel)
|
||||
CHANNEL="${2:?--channel needs stable or beta}"
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'
|
||||
return 0
|
||||
;;
|
||||
*) die "unknown option $1 (see --help)" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
case "$(channel)" in stable | beta) ;; *) die "--channel is stable or beta" ;; esac
|
||||
[ "$DRY" = 1 ] || TMP="$(mktemp -d)"
|
||||
|
||||
say "LLeMbas TTY set-up ($(channel) releases)"
|
||||
[ "$WANT_CLI" != 1 ] || setup_cli
|
||||
[ "$WANT_IDE" != 1 ] || setup_ide
|
||||
|
||||
if [ "$DRY" != 1 ]; then
|
||||
say ""
|
||||
if have lembas >/dev/null; then
|
||||
say "To use LLeMbas, log in to your server once: lembas login <address of your server>"
|
||||
say "(or the command palette entry \"LLeMbas: log in\")."
|
||||
fi
|
||||
# shellcheck disable=SC2088,SC2016 # said to the person as they would type it
|
||||
case ":$PATH:" in
|
||||
*":$HOME/.local/bin:"*) ;;
|
||||
*) [ ! -d "$HOME/.local/bin" ] || say '~/.local/bin is not on your PATH: the terminal finds both programs there anyway; for your shell add export PATH="$HOME/.local/bin:$PATH"' ;;
|
||||
esac
|
||||
fi
|
||||
pause
|
||||
}
|
||||
|
||||
main "$@"
|
||||
+62
-10
@@ -451,13 +451,17 @@ test('versions', function()
|
||||
end)
|
||||
|
||||
test('cli_candidates', function()
|
||||
local c = core.cli_candidates(nil, '/opt/tty/bin', '/usr/local/bin:/usr/bin', false)
|
||||
eq(c[1], '/opt/tty/bin/lembas', 'beside the terminal first')
|
||||
eq(c[2], '/usr/local/bin/lembas', 'then PATH, in order')
|
||||
eq(c[3], '/usr/bin/lembas', 'PATH 2')
|
||||
eq(#core.cli_candidates('/x/lembas', '/opt', '/usr/bin', false), 1, 'explicit: only that')
|
||||
eq(core.cli_candidates(nil, 'C:\\tty', 'C:\\a;C:\\b', true)[3], 'C:\\b\\lembas.exe', 'windows')
|
||||
local c = core.cli_candidates(nil, '/home/ana', '/usr/local/bin:/usr/bin', false)
|
||||
eq(c[1], '/usr/local/bin/lembas', 'PATH first, in order')
|
||||
eq(c[2], '/usr/bin/lembas', 'PATH 2')
|
||||
eq(c[3], '/home/ana/.local/bin/lembas', 'then where its installer puts it')
|
||||
eq(#c, 3, 'and nowhere else: no copy beside the terminal')
|
||||
eq(#core.cli_candidates('/x/lembas', '/home/ana', '/usr/bin', false), 1, 'explicit: only that')
|
||||
eq(core.cli_candidates(nil, nil, 'C:\\a;C:\\b', true)[2], 'C:\\b\\lembas.exe', 'windows')
|
||||
eq(#core.cli_candidates(nil, nil, nil, false), 0, 'nothing known')
|
||||
eq(#core.cli_candidates(nil, '/home/ana', '/home/ana/.local/bin', false), 1, 'a directory is tried once')
|
||||
eq(core.ide_candidates(nil, '/home/ana', '/usr/bin', false)[2], '/home/ana/.local/bin/llembas-ide', 'the IDE the same way')
|
||||
eq(core.ide_candidates('/opt/ide', '/home/ana', '/usr/bin', false)[1], '/opt/ide', 'the IDE, explicit')
|
||||
end)
|
||||
|
||||
test('session_choices and is_session_id', function()
|
||||
@@ -539,7 +543,7 @@ test('apply: keys, events, and nothing else happens', function()
|
||||
local dir = fresh_dir 'apply'
|
||||
with_cli(dir)
|
||||
local _, w, config = layer({ child_results = NEW }, nil, { keys = { { key = 'x', mods = 'CTRL', action = 'mine' } } })
|
||||
eq(#config.keys, 6, 'five keys added to the one that was there')
|
||||
eq(#config.keys, 7, 'six keys added to the one that was there')
|
||||
eq(config.keys[1].action, 'mine', "the person's own key stays first")
|
||||
eq(config.keys[2].key, 'A', 'ask')
|
||||
eq(config.keys[2].action.action, 'EmitEvent', 'an event')
|
||||
@@ -550,7 +554,8 @@ test('apply: keys, events, and nothing else happens', function()
|
||||
check(w.handlers[name] ~= nil, 'handler for ' .. name)
|
||||
end
|
||||
local entries = w.emit 'augment-command-palette'
|
||||
eq(#entries, 7, 'seven palette entries')
|
||||
eq(#entries, 9, 'nine palette entries')
|
||||
eq(entries[9].brief, 'LLeMbas: set up (CLI and IDE)', 'last entry')
|
||||
eq(entries[1].brief, 'LLeMbas: ask the model', 'first entry')
|
||||
eq(#context_files(dir), 0, 'no file written')
|
||||
end)
|
||||
@@ -563,7 +568,7 @@ test('apply: everything can be turned off', function()
|
||||
session_bar = false,
|
||||
tab_marker = false,
|
||||
palette = false,
|
||||
keys = { ask = false, new_session = false, resume = false, toggle_display = false, private = false },
|
||||
keys = { ask = false, new_session = false, resume = false, toggle_display = false, private = false, ide = false },
|
||||
})
|
||||
eq(#config2.keys, 0, 'no keys')
|
||||
eq(w2.handlers['update-status'], nil, 'no bar')
|
||||
@@ -755,7 +760,8 @@ test('missing CLI: said clearly, never silently', function()
|
||||
local win, pane = fake.window(), fake.pane { zones = ZONES }
|
||||
w.emit('llembas-ask-line', win, pane, 'q')
|
||||
eq(#win.actions, 1, 'a message')
|
||||
check(win.actions[1].action.args.description:find('get.sh | bash', 1, true), 'names the install command')
|
||||
check(win.actions[1].action.args.description:find('LLeMbas: set up (CLI and IDE)', 1, true), 'names the set-up entry')
|
||||
check(win.actions[1].action.args.description:find('llembas-tty-setup', 1, true), 'and the command')
|
||||
eq(pane.read_zones, nil, 'nothing read')
|
||||
eq(#w.spawned, 0, 'nothing started')
|
||||
w.emit('llembas-new-session', win, pane)
|
||||
@@ -764,6 +770,52 @@ test('missing CLI: said clearly, never silently', function()
|
||||
eq(#pane.splits, 0, 'no pane')
|
||||
end)
|
||||
|
||||
test('the CLI where its installer puts it, off PATH', function()
|
||||
local dir = fresh_dir 'homecli'
|
||||
sh(string.format("mkdir -p '%s/home/.local/bin'", dir))
|
||||
write_file(dir .. '/home/.local/bin/lembas', '#!/bin/sh\n')
|
||||
env.PATH = dir .. '/bin'
|
||||
local l = layer { home_dir = dir .. '/home' }
|
||||
eq(l.find_cli(), dir .. '/home/.local/bin/lembas', 'found in ~/.local/bin')
|
||||
eq(l.find_ide(), nil, 'no IDE there')
|
||||
end)
|
||||
|
||||
test('set-up: runs the program beside the terminal, in a pane', function()
|
||||
local dir = fresh_dir 'setup'
|
||||
env.PATH = dir .. '/bin'
|
||||
write_file(dir .. '/bin/llembas-tty-setup', '#!/bin/sh\n')
|
||||
local _, w = layer { executable_dir = dir .. '/bin' }
|
||||
local win, pane = fake.window(), fake.pane {}
|
||||
w.emit('llembas-setup', win, pane)
|
||||
eq(#pane.splits, 1, 'a pane')
|
||||
eq(pane.splits[1].args[1], dir .. '/bin/llembas-tty-setup', 'the set-up program')
|
||||
eq(#pane.splits[1].args, 1, 'with nothing added: it asks before it installs')
|
||||
eq(#w.spawned, 0, 'nothing started behind the person')
|
||||
end)
|
||||
|
||||
test('set-up: not beside the terminal is said', function()
|
||||
local dir = fresh_dir 'nosetup'
|
||||
env.PATH = dir .. '/bin'
|
||||
local _, w = layer {}
|
||||
local win, pane = fake.window(), fake.pane {}
|
||||
w.emit('llembas-setup', win, pane)
|
||||
eq(#pane.splits, 0, 'no pane')
|
||||
check(win.actions[1].action.args.description:find('llembas-tty-setup', 1, true), 'said in words')
|
||||
end)
|
||||
|
||||
test('LLeMbas IDE: a new tab in the pane\'s directory, or said to be missing', function()
|
||||
local dir = fresh_dir 'ide'
|
||||
env.PATH = dir .. '/bin'
|
||||
local _, w = layer {}
|
||||
local win, pane = fake.window(), fake.pane {}
|
||||
w.emit('llembas-ide', win, pane)
|
||||
check(win.actions[1].action.args.description:find('LLeMbas IDE (llembas-ide) is not installed', 1, true), 'missing: said')
|
||||
write_file(dir .. '/bin/llembas-ide', '#!/bin/sh\n')
|
||||
w.emit('llembas-ide', win, pane)
|
||||
eq(win.actions[2].action.action, 'SpawnCommandInNewTab', 'a new tab')
|
||||
eq(win.actions[2].action.args.args[1], dir .. '/bin/llembas-ide', 'running the IDE')
|
||||
end)
|
||||
|
||||
test('a CLI that is too old: said in words', function()
|
||||
local dir = fresh_dir 'old'
|
||||
with_cli(dir)
|
||||
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
# The set-up program without a network: what it says when everything is there, what it would do
|
||||
# when nothing is, and that a release that is not signed by the release key is refused.
|
||||
#
|
||||
# llembas/tests/setup-test.sh
|
||||
set -uo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
SETUP="$ROOT/llembas/setup/llembas-tty-setup"
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "${work:?}"' EXIT
|
||||
failed=0
|
||||
ok() { echo "ok $1"; }
|
||||
bad() {
|
||||
echo "FAIL $1"
|
||||
[ -z "${GITHUB_ACTIONS:-}" ] || printf '::error title=setup::%s\n' "$(printf '%s' "$1" | head -c 900 | tr '\n\r' ' ')"
|
||||
failed=1
|
||||
}
|
||||
expect() { if printf '%s' "$2" | grep -Eq -- "$3"; then ok "$1"; else bad "$1: wanted /$3/ in: $2"; fi; }
|
||||
refuse() { if printf '%s' "$2" | grep -Eq -- "$3"; then bad "$1: found /$3/ in: $2"; else ok "$1"; fi; }
|
||||
# A home with nothing in it, and only the system's tools on PATH.
|
||||
run() { # home, then the program's arguments and environment through env
|
||||
local home="$1"
|
||||
shift
|
||||
env -i PATH=/usr/bin:/bin HOME="$home" LANG=C.UTF-8 "$@" </dev/null 2>&1
|
||||
}
|
||||
|
||||
mkdir -p "$work/empty" "$work/full/.local/bin"
|
||||
printf '#!/bin/sh\necho 2.0.0-beta.18\n' >"$work/full/.local/bin/lembas"
|
||||
printf '#!/bin/sh\n' >"$work/full/.local/bin/llembas-ide"
|
||||
chmod +x "$work/full/.local/bin/lembas" "$work/full/.local/bin/llembas-ide"
|
||||
|
||||
out="$(run "$work/full" bash "$SETUP" --yes)"
|
||||
expect "what is installed is found in ~/.local/bin, off PATH" "$out" "the LLeMbas CLI is installed: $work/full/.local/bin/lembas \(2\.0\.0-beta\.18\)"
|
||||
expect "and LLeMbas IDE" "$out" "LLeMbas IDE is installed: $work/full/.local/bin/llembas-ide"
|
||||
expect "it says how to log in" "$out" "lembas login"
|
||||
refuse "and installs nothing" "$out" "installing|would find"
|
||||
|
||||
out="$(run "$work/empty" bash "$SETUP" --dry-run)"
|
||||
expect "dry run: the CLI would be installed" "$out" "LLeMbas CLI \(lembas\) is not installed"
|
||||
expect "dry run: from the stable releases by default" "$out" "would find the newest stable release of LLeMbas/LLeMbas-CLI"
|
||||
expect "dry run: the IDE too" "$out" "would find the newest stable release of LLeMbas/LLeMbas-IDE"
|
||||
if [ -z "$(find "$work/empty" -mindepth 1 | head -n1)" ]; then ok "a dry run writes nothing"; else bad "a dry run wrote: $(find "$work/empty" -mindepth 1 | head)"; fi
|
||||
|
||||
out="$(run "$work/empty" LLEMBAS_TTY=1.0.0-beta.3 bash "$SETUP" --dry-run --no-ide)"
|
||||
expect "a beta terminal asks for the betas" "$out" "newest beta release of LLeMbas/LLeMbas-CLI"
|
||||
refuse "--no-ide leaves the IDE out" "$out" "LLeMbas-IDE"
|
||||
|
||||
out="$(run "$work/empty" bash "$SETUP")"
|
||||
expect "nobody to answer: nothing is installed" "$out" "left out"
|
||||
if [ -z "$(find "$work/empty" -mindepth 1 | head -n1)" ]; then ok "and nothing is written"; else bad "written without an answer: $(find "$work/empty" -mindepth 1 | head)"; fi
|
||||
|
||||
# A release on this machine: a listing, an installer that would leave a mark, and sums.
|
||||
rel="$work/forge/LLeMbas/LLeMbas-CLI/releases/download/v9.9.9"
|
||||
mkdir -p "$rel" "$work/api/repos/LLeMbas/LLeMbas-CLI"
|
||||
printf '[{"tag_name": "v9.9.9-beta.1", "prerelease": true}, {"tag_name": "v9.9.9", "prerelease": false}]' >"$work/api/repos/LLeMbas/LLeMbas-CLI/releases"
|
||||
# shellcheck disable=SC2016 # written into the stand-in installer as it is
|
||||
printf '#!/bin/sh\necho "ran with ref=$LEMBAS_REF" > "$HOME/ran"\n' >"$rel/get.sh"
|
||||
(cd "$rel" && sha256sum get.sh >SHA256SUMS)
|
||||
ssh-keygen -q -t ed25519 -N '' -C test -f "$work/key" >/dev/null
|
||||
ssh-keygen -q -t ed25519 -N '' -C other -f "$work/other" >/dev/null
|
||||
local_forge=(LLEMBAS_SETUP_FORGE="file://$work/forge" LLEMBAS_SETUP_API="file://$work/api" LLEMBAS_SETUP_PUBKEY="$(cut -d' ' -f1,2 "$work/key.pub")")
|
||||
|
||||
mkdir -p "$work/h1" "$work/h2" "$work/h3" "$work/h4"
|
||||
out="$(run "$work/h1" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)"
|
||||
expect "an unsigned release is refused" "$out" "is not signed \(no SHA256SUMS.sig\)"
|
||||
if [ ! -e "$work/h1/ran" ]; then ok "and its installer does not run"; else bad "an unsigned installer ran"; fi
|
||||
|
||||
ssh-keygen -Y sign -q -f "$work/other" -n lembas-release "$rel/SHA256SUMS"
|
||||
out="$(run "$work/h2" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)"
|
||||
expect "a release signed with another key is refused" "$out" "not signed by the LLeMbas release key"
|
||||
if [ ! -e "$work/h2/ran" ]; then ok "and its installer does not run"; else bad "an installer signed by another key ran"; fi
|
||||
|
||||
rm -f "$rel/SHA256SUMS.sig"
|
||||
ssh-keygen -Y sign -q -f "$work/key" -n lembas-release "$rel/SHA256SUMS"
|
||||
printf '\n# changed after signing\n' >>"$rel/get.sh"
|
||||
out="$(run "$work/h3" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)"
|
||||
expect "an installer that does not match the signed sums is refused" "$out" "does not match its SHA256SUMS"
|
||||
if [ ! -e "$work/h3/ran" ]; then ok "and does not run"; else bad "a changed installer ran"; fi
|
||||
|
||||
(cd "$rel" && sha256sum get.sh >SHA256SUMS) && rm -f "$rel/SHA256SUMS.sig"
|
||||
ssh-keygen -Y sign -q -f "$work/key" -n lembas-release "$rel/SHA256SUMS"
|
||||
out="$(run "$work/h4" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)"
|
||||
expect "a signed, matching release is installed" "$out" "LLeMbas CLI v9\.9\.9: signature good, installing"
|
||||
expect "the stable channel takes the release, not the beta beside it" "$(cat "$work/h4/ran" 2>/dev/null)" "^ran with ref=v9\.9\.9$"
|
||||
|
||||
[ "$failed" -eq 0 ] && echo "setup: all passed"
|
||||
exit "$failed"
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Put the LLeMbas CLI that LLeMbas TTY carries where the package takes it from:
|
||||
# llembas/packaging/bin/lembas (git-ignored; installed beside the terminal's own binaries,
|
||||
# never on PATH)
|
||||
#
|
||||
# scripts/fetch-cli.sh [target-triple] (default: this machine's, from rustc)
|
||||
#
|
||||
# The version is the one in llembas-cli.version. The files are checked exactly as the CLI's own
|
||||
# get.sh checks them: SHA256SUMS signed by the release key in the namespace lembas-release, naming
|
||||
# this version, and the binary matching it. Nothing unverified is bundled.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
VERSION="$(tr -d '[:space:]' < llembas-cli.version)"
|
||||
TRIPLE="${1:-$(rustc -vV | sed -n 's/^host: //p')}"
|
||||
BASE="${LEMBAS_CLI_RELEASES:-https://github.com/LLeMbas/LLeMbas-CLI/releases/download}/v${VERSION}"
|
||||
PUBKEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDSZO3Byow7R3ZpOH3MCvpPIga2pZBzhfX5wXfNP1cLa"
|
||||
|
||||
case "$TRIPLE" in
|
||||
# The baseline build runs on any x86-64 CPU, not only those with AVX2: a terminal meets
|
||||
# older machines than a server does.
|
||||
x86_64-unknown-linux-gnu) ASSET=lembas-linux-x64-baseline ;;
|
||||
aarch64-unknown-linux-gnu) ASSET=lembas-linux-arm64 ;;
|
||||
*) echo "fetch-cli: no LLeMbas CLI build for $TRIPLE yet" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "${work:?}"' EXIT
|
||||
for f in SHA256SUMS SHA256SUMS.sig "$ASSET.gz"; do
|
||||
curl -fsSL --retry 3 -o "$work/$f" "$BASE/$f"
|
||||
done
|
||||
|
||||
printf 'lembas-release %s\n' "$PUBKEY" > "$work/allowed"
|
||||
ssh-keygen -Y verify -f "$work/allowed" -I lembas-release -n lembas-release \
|
||||
-s "$work/SHA256SUMS.sig" < "$work/SHA256SUMS" >/dev/null \
|
||||
|| { echo "fetch-cli: SHA256SUMS is not signed by the release key" >&2; exit 1; }
|
||||
[ "$(sed -n -E 's/^# lembas //p' "$work/SHA256SUMS" | head -n1)" = "$VERSION" ] \
|
||||
|| { echo "fetch-cli: SHA256SUMS is not for $VERSION" >&2; exit 1; }
|
||||
(cd "$work" && grep -E " $ASSET\.gz\$" SHA256SUMS | sha256sum -c --strict --quiet -) \
|
||||
|| { echo "fetch-cli: $ASSET.gz does not match SHA256SUMS" >&2; exit 1; }
|
||||
|
||||
mkdir -p llembas/packaging/bin
|
||||
gunzip -c "$work/$ASSET.gz" > llembas/packaging/bin/lembas
|
||||
chmod 755 llembas/packaging/bin/lembas
|
||||
echo "fetch-cli: LLeMbas CLI $VERSION ($ASSET) -> llembas/packaging/bin/lembas"
|
||||
Reference in new issue
Block a user