Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Check every pull request and every push to main: Clippy with warnings as
# errors, the Rust tests, and the Python tests, on Linux and macOS.
#
# Like the release workflow, it uses no third-party actions, and GitHub's own
# are pinned to commits.
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

# A newer push to the same branch or pull request replaces the run before it.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
# The same runners the releases are built on.
- { name: Linux, runner: ubuntu-22.04 }
- { name: macOS, runner: macos-15 }
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install build dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends pkg-config \
libxkbcommon-dev libxkbcommon-x11-dev libxcb1-dev libx11-xcb-dev \
libfreetype-dev libfontconfig-dev libwayland-dev libvulkan-dev
- run: rustup toolchain install stable --profile minimal --component clippy --component rustfmt && rustup default stable
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked
- name: Python tests
run: |
python3 -m unittest discover -s python/tests
python3 -m unittest discover -s plugins/tests
34 changes: 6 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ sessions. See [Commands](docs/commands.md).
| [Shell integration](docs/shell-integration.md) | What it adds, how it loads, using it over SSH |
| [Commands](docs/commands.md) | `lumen info` and `lumen campfire` |
| [Scripting](docs/scripting.md) | `lumen msg`, events and the socket protocol |
| [Built-in plugins](docs/builtin-plugins.md) | The seven plugins that come with Lumen |
| [Built-in plugins](docs/builtin-plugins.md) | The four plugins that come with Lumen |
| [Plugin guide](docs/plugins.md) | Writing plugins in Python |
| [Plugin protocol](docs/plugin-protocol.md) | Writing plugins in any language, and permissions |
| [Files and session](docs/files.md) | Where Lumen keeps things, and its environment variables |
Expand Down
2 changes: 1 addition & 1 deletion docs/builtin-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ first time.
| **Recent Directories** (`recent-dirs`) | Remembers the folders your shells visit. **Go to Recent Directory** (Ctrl+Shift+J, ⌘⇧J) lists them, most used and most recent first, and `cd`s the pane to the one you pick. If the pane is busy, it opens a new tab there instead. | `input`, `panes` |
| **Command History** (`command-history`) | Keeps every command from every pane and session, with its exit status, duration and folder. **Search Command History** (Ctrl+Shift+H, ⌘⇧H) types the one you pick without pressing Enter. **Rerun Last Failed Command** (Ctrl+Shift+R, ⌘⇧R) shows the last failure and its folder, and runs it again there once you confirm. **Clear Command History** forgets it all. Commands starting with a space aren't kept. | `screen`, `input` |
| **Switch Git Branch** (`git-branch`) | Alt+B lists the branches of the pane's repository, newest first, and switches to the one you pick. | `input` |
| **SSH to Host** (`ssh-hosts`) | Ctrl+Shift+S (⌘⇧S) lists the hosts in `~/.ssh/config` (and files it `Include`s) and opens the one you pick in a new tab named after it. | `panes` |
| **SSH to Host** (`ssh-hosts`) | Ctrl+Shift+S (⌘⇧S) lists the hosts in `~/.ssh/config` (and files it `Include`s) and opens the one you pick in a new tab named after it. | `panes`, `input` |

Most of them need [shell integration](shell-integration.md) to know folders
and commands.
Expand Down
5 changes: 5 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ python3 -m unittest discover -s python/tests # the Python package
python3 -m unittest discover -s plugins/tests # the built-in plugins
```

Pull requests and pushes to `main` run these, and `cargo clippy` with
warnings as errors, on Linux and macOS
([the workflow](../.github/workflows/ci.yml)).

## Source layout

| File | What it does |
Expand Down Expand Up @@ -69,6 +73,7 @@ python3 -m unittest discover -s plugins/tests # the built-in plugins
| `dist/install.sh` | The installer `lumenshell.dev/install` serves: downloads a release, checks it and installs it |
| `dist/homebrew/lumen.rb` | The Homebrew cask; each release fills it in and pushes it to `lumenshell/homebrew-tap` |
| `.github/workflows/release.yml` | Builds Linux and macOS releases when a `v*` tag is pushed ([how to release](#releasing)) |
| `.github/workflows/ci.yml` | Runs Clippy and the tests on every pull request and push to `main` |
| `examples/` | Scripts using `lumen msg` and the socket API, and example plugins |
| `python/` | `lumen_plugin`, the Python package for plugins (built into Lumen), and its tests |
| `plugins/` | The built-in plugins (built into Lumen; turned on in Plugins), and tests |
Expand Down
7 changes: 4 additions & 3 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ brew install --cask lumenshell/tap/lumen

## The first launch on macOS

Apple hasn't notarized the app yet. The first time you open it, macOS may say
it can't check it for malware. Right-click Lumen.app, choose **Open**, then
**Open** again. Or allow it in System Settings > Privacy & Security.
Lumen.app is signed with an Apple Developer ID and notarized by Apple, so it
opens like any other app. A version you [build yourself](#building-from-source)
isn't: the first time, right-click it and choose **Open**, or allow it in
System Settings > Privacy & Security.

## Installing by hand

Expand Down
10 changes: 9 additions & 1 deletion docs/plugin-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ If a plugin exits, Lumen restarts it. After quick crashes, it waits 1, 2, 5,
Each plugin runs as its own process, so a slow or crashing plugin can't freeze
Lumen.

When a plugin is stopped (turned off, removed, replaced by a new version, or
Lumen quits), it loses its connection at once: its stdin closes, nothing more
it asks for is carried out, it's sent no more events, and its panes close. It
and every process it started are sent SIGTERM, and SIGKILL two seconds later
if they're still there. A program that should outlive the plugin, such as a
browser it opened, has to be started in a session of its own (`setsid`, or
`start_new_session=True` in Python).

## The manifest

```
Expand Down Expand Up @@ -128,7 +136,7 @@ starts.
| Permission | Allows |
|---|---|
| `panes` | `new-tab`, `split`, `focus`, `close`, `set-title`, `set-tab-style`, `set-pane-style`, `move-tab`, `quick-terminal`, and drawing its own plugin panes (`write`) |
| `input` | `send-text`, `run-action`: typing into panes, which can run any command |
| `input` | `send-text`, `run-action`, and `run` on `new-tab` and `split`: typing into panes, which can run any command |
| `screen` | `read-screen`, and the command text in `command-finished` events |

A plugin missing a permission gets a JSON-RPC error saying which one to add.
Expand Down
6 changes: 3 additions & 3 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ permissions = ["panes", "input"]
| Permission | Allows |
|---|---|
| `panes` | `new_tab`, `split`, `focus`, `close`, `set_title`, `set_tab_style`, `set_pane_style`, `move_tab`, and drawing your own plugin panes |
| `input` | `send_text`, `run`, `run_action`: typing into panes, which can run any command |
| `input` | `send_text`, `run`, `run_action`, and `run=` on `new_tab` and `split`: typing into panes, which can run any command |
| `screen` | `read_screen`, and `command` in `command-finished` events |

A call without the permission raises `LumenError` with `code == -32001` and a
Expand Down Expand Up @@ -382,7 +382,7 @@ else uses the most recently started Lumen.
| `await panes()` | Every pane as a dict (`id`, `title`, `cwd`, `cols`, `rows`, `last_exit`, `active`, `focused`, `plugin_pane`, `tab`, `window`). |
| `await focused()` | The focused `Pane`, or None. |
| `pane(id)` | A `Pane` for an id. |
| `await new_tab(cwd=None, run=None, plugin_pane=False)` | Open a tab (`~` works in `cwd`); returns its `Pane`, or a `PluginPane` with `plugin_pane=True`. `panes` |
| `await new_tab(cwd=None, run=None, plugin_pane=False)` | Open a tab (`~` works in `cwd`); returns its `Pane`, or a `PluginPane` with `plugin_pane=True`. `panes`, and `input` with `run` |
| `await pick(items, placeholder=None, message=None)` | Palette picker; returns the chosen id or None. Items: strings, `(id, label)`, `(id, label, detail)` or dicts. `message` is wrapped text under the input. |
| `await prompt(placeholder=None, message=None, initial="")` | Text input in the palette; returns the trimmed text, or None for Esc or empty. |
| `await confirm(question, message=None, yes="Yes", no="No")` | Yes/no in the palette; Esc is no. |
Expand All @@ -401,7 +401,7 @@ else uses the most recently started Lumen.
| `await send_text(text)` | Type text as-is. `input` |
| `await run(command)` | Type a command and press Enter; a list is quoted word by word. `input` |
| `await read_screen(lines=None)` | The screen's text, or its last `lines` lines. `screen` |
| `await split(direction="right", cwd=None, run=None, focus=True, size=None, plugin_pane=False)` | Split it; returns the new `Pane` (a `PluginPane` with `plugin_pane=True`). `size`: a fraction, or rows/columns. `panes` |
| `await split(direction="right", cwd=None, run=None, focus=True, size=None, plugin_pane=False)` | Split it; returns the new `Pane` (a `PluginPane` with `plugin_pane=True`). `size`: a fraction, or rows/columns. `panes`, and `input` with `run` |
| `await set_title(title=None)` | Name its tab; None goes back to the program's title. `panes` |
| `await set_pane_style(label=…, color=…)` | Label (up to 32 characters) drawn above the pane when its tab is split, and a tint (`TAB_COLORS` or `"#rrggbb"`); None removes, left out stays. They go when the plugin stops. `panes` |
| `await set_tab_style(badge=…, color=…, short_badge=None)` | Badge beside its tab's title (up to 24 characters) and a tint (`TAB_COLORS` or `"#rrggbb"`); None removes, left out stays. `short_badge` (up to 8 characters) shows instead when the tab is too narrow. `panes` |
Expand Down
5 changes: 3 additions & 2 deletions plugins/ssh-hosts/plugin.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
description = "Pick a host from ~/.ssh/config and open it in a new tab (Ctrl+Shift+S, ⌘⇧S on macOS)"
version = "1.0.0"
version = "1.0.1"
command = "python3 main.py"
permissions = ["panes"]
# panes: to open the tab. input: to run ssh in it.
permissions = ["panes", "input"]
4 changes: 2 additions & 2 deletions python/lumen_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async def split(
) -> "Pane":
"""Split this pane ("right" or "down") and return the new one, which
starts in `cwd` (default: this pane's directory; ~ works) and runs `run` (a
string, or a list to quote). Needs `panes`.
string, or a list to quote). Needs `panes`, and `input` to `run`.

With `plugin_pane=True` the new pane runs nothing: you draw it, and
get what's typed in it. It returns a PluginPane.
Expand Down Expand Up @@ -549,7 +549,7 @@ def pane(self, id: int) -> Pane:
async def new_tab(self, *, cwd=None, run=None, plugin_pane: bool = False) -> Pane:
"""Open a tab in `cwd` (~ works) and return its pane. `run` is a
string, or a list to quote. With `plugin_pane=True`, the tab holds a
PluginPane for you to draw. Needs `panes`."""
PluginPane for you to draw. Needs `panes`, and `input` to `run`."""
if plugin_pane:
if cwd is not None or run is not None:
raise ValueError("a plugin pane runs no program, so takes no cwd or run")
Expand Down
6 changes: 5 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "lumen-plugin"
version = "1.0.0"
dynamic = ["version"]
description = "Write plugins and scripts for the Lumen terminal in Python"
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -13,3 +13,7 @@ dependencies = []

[tool.setuptools]
packages = ["lumen_plugin"]

# The one place the version is written: lumen_plugin/__init__.py.
[tool.setuptools.dynamic]
version = {attr = "lumen_plugin.__version__"}
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
max_width = 120
use_small_heuristics = "Max"
Loading
Loading