Merge pull request #10 from evanwhittaker/sync-release-pipeline

Release pipeline, SECURITY.md, installer updates
This commit is contained in:
Evan Whittaker
2026-10-17 17:22:09 -05:00
committed by GitHub
35 changed files with 1263 additions and 487 deletions

68
.github/workflows/publish-crates.yml vendored Normal file
View File

@@ -0,0 +1,68 @@
# Publish crates — the release's crates go to crates.io.
#
# A dist custom publish job (`publish-jobs` in dist-workspace.toml): release.yml calls it once the
# GitHub release hosts the artifacts, and announces only after it succeeds.
#
# No token is stored. crates.io Trusted Publishing trusts the OIDC token GitHub mints for the run,
# and it matches the *calling* workflow, so each crate's trusted publisher names `release.yml`,
# not this file.
#
# A crate whose version crates.io already has is skipped, so a re-run after a partial publish, or
# a release whose crates were published by hand first, carries on rather than failing announce.
name: Publish crates
on:
workflow_call:
inputs:
plan:
required: true
type: string
permissions: {}
jobs:
publish:
name: publish to crates.io
# A tag pushed to the development repository must never publish; skipped, announce still runs
if: github.repository == 'evanwhittaker/luxe'
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
- name: Which crates crates.io still needs
id: pending
shell: bash
run: |
exclude=""
pending=0
while read -r name version; do
status=$(curl -s -o /dev/null -w '%{http_code}' -A 'luxe release (github.com/evanwhittaker/luxe)' \
"https://crates.io/api/v1/crates/$name/$version")
case "$status" in
200) echo "$name $version is already published"; exclude="$exclude --exclude $name" ;;
404) echo "$name $version will be published"; pending=$((pending + 1)) ;;
*) echo "crates.io answered $status for $name $version" >&2; exit 1 ;;
esac
done < <(cargo metadata --no-deps --format-version 1 \
| jq -r '.packages[] | select(.publish == null or (.publish | length > 0)) | "\(.name) \(.version)"')
echo "exclude=$exclude" >> "$GITHUB_OUTPUT"
echo "count=$pending" >> "$GITHUB_OUTPUT"
- name: Trusted Publishing token
if: steps.pending.outputs.count != '0'
id: auth
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
# Dependencies first, which `--workspace` orders for us
- name: Publish
if: steps.pending.outputs.count != '0'
run: cargo publish --workspace --locked $EXCLUDE
env:
EXCLUDE: ${{ steps.pending.outputs.exclude }}
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

366
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,366 @@
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
#
# Copyright 2022-2024, axodotdev
# SPDX-License-Identifier: MIT or Apache-2.0
#
# CI that:
#
# * checks for a Git Tag that looks like a release
# * builds artifacts with dist (archives, installers, hashes)
# * uploads those artifacts to temporary workflow zip
# * on success, uploads the artifacts to a GitHub Release
#
# Note that the GitHub Release will be created with a generated
# title/body based on your changelogs.
name: Release
permissions:
"contents": "write"
# This task will run whenever you push a git tag that looks like a version
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
#
# If PACKAGE_NAME is specified, then the announcement will be for that
# package (erroring out if it doesn't have the given version or isn't dist-able).
#
# If PACKAGE_NAME isn't specified, then the announcement will be for all
# (dist-able) packages in the workspace with that version (this mode is
# intended for workspaces with only one dist-able package, or with all dist-able
# packages versioned/released in lockstep).
#
# If you push multiple tags at once, separate instances of this workflow will
# spin up, creating an independent announcement for each one. However, GitHub
# will hard limit this to 3 tags per commit, as it will assume more tags is a
# mistake.
#
# If there's a prerelease-style suffix to the version, then the release(s)
# will be marked as a prerelease.
on:
pull_request:
push:
tags:
- '**[0-9]+.[0-9]+.[0-9]+*'
jobs:
# Run 'dist plan' (or host) to determine what tasks we need to do
plan:
runs-on: "ubuntu-22.04"
outputs:
val: ${{ steps.plan.outputs.manifest }}
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
publishing: ${{ !github.event.pull_request }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: false
submodules: recursive
- name: Install dist
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.33.0/cargo-dist-installer.sh | sh"
- name: Cache dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: cargo-dist-cache
path: ~/.cargo/bin/dist
# sure would be cool if github gave us proper conditionals...
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
# functionality based on whether this is a pull_request, and whether it's from a fork.
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
# but also really annoying to build CI around when it needs secrets to work right.)
- id: plan
run: |
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
echo "dist ran successfully"
cat plan-dist-manifest.json
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: artifacts-plan-dist-manifest
path: plan-dist-manifest.json
# Build and packages all the platform-specific things
build-local-artifacts:
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
# Let the initial task tell us to not run (currently very blunt)
needs:
- plan
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
strategy:
fail-fast: false
# Target platforms/runners are computed by dist in create-release.
# Each member of the matrix has the following arguments:
#
# - runner: the github runner
# - dist-args: cli flags to pass to dist
# - install-dist: expression to run to install dist on the runner
#
# Typically there will be:
# - 1 "global" task that builds universal installers
# - N "local" tasks that build each platform's binaries and platform-specific installers
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container && matrix.container.image || null }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
permissions:
"attestations": "write"
"contents": "read"
"id-token": "write"
steps:
- name: enable windows longpaths
run: |
git config --global core.longpaths true
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: false
submodules: recursive
- name: Install Rust non-interactively if not already installed
if: ${{ matrix.container }}
run: |
if ! command -v cargo > /dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
fi
- name: Install dist
run: ${{ matrix.install_dist.run }}
# Get the dist-manifest
- name: Fetch local artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- name: Install dependencies
run: |
${{ matrix.packages_install }}
- name: Build artifacts
run: |
# Actually do builds and make zips and whatnot
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
echo "dist ran successfully"
- name: Attest
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6
with:
subject-path: "target/distrib/*${{ join(matrix.targets, ', ') }}*"
- id: cargo-dist
name: Post-build
# We force bash here just because github makes it really hard to get values up
# to "real" actions without writing to env-vars, and writing to env-vars has
# inconsistent syntax between shell and powershell.
shell: bash
run: |
# Parse out what we just built and upload it to scratch storage
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}
# Build and package all the platform-agnostic(ish) things
build-global-artifacts:
needs:
- plan
- build-local-artifacts
runs-on: "ubuntu-22.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: false
submodules: recursive
- name: Install cached dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
name: cargo-dist-cache
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/dist
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- id: cargo-dist
shell: bash
run: |
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
echo "dist ran successfully"
# Parse out what we just built and upload it to scratch storage
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
- name: "Upload artifacts"
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: artifacts-build-global
path: |
${{ steps.cargo-dist.outputs.paths }}
${{ env.BUILD_MANIFEST_NAME }}
# Determines if we should publish/announce
host:
needs:
- plan
- build-local-artifacts
- build-global-artifacts
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: "ubuntu-22.04"
outputs:
val: ${{ steps.host.outputs.manifest }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: false
submodules: recursive
- name: Install cached dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
name: cargo-dist-cache
path: ~/.cargo/bin/
- run: chmod +x ~/.cargo/bin/dist
# Fetch artifacts from scratch-storage
- name: Fetch artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: artifacts-*
path: target/distrib/
merge-multiple: true
- id: host
shell: bash
run: |
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
echo "artifacts uploaded and released successfully"
cat dist-manifest.json
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: "Upload dist-manifest.json"
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
# Overwrite the previous copy
name: artifacts-dist-manifest
path: dist-manifest.json
# Create a GitHub Release while uploading all files to it
- name: "Download GitHub Artifacts"
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: artifacts-*
path: artifacts
merge-multiple: true
- name: Cleanup
run: |
# Remove the granular manifests
rm -f artifacts/*-dist-manifest.json
- name: Create GitHub Release
env:
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
RELEASE_COMMIT: "${{ github.sha }}"
run: |
# Write and read notes from a file to avoid quoting breaking things
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
publish-homebrew-formula:
needs:
- plan
- host
runs-on: "ubuntu-22.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLAN: ${{ needs.plan.outputs.val }}
GITHUB_USER: "axo bot"
GITHUB_EMAIL: "admin+bot@axo.dev"
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: true
repository: "evanwhittaker/homebrew-tap"
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
# So we have access to the formula
- name: Fetch homebrew formulae
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
with:
pattern: artifacts-*
path: Formula/
merge-multiple: true
# This is extra complex because you can make your Formula name not match your app name
# so we need to find releases with a *.rb file, and publish with that filename.
- name: Commit formula files
run: |
git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_EMAIL}"
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
name=$(echo "$filename" | sed "s/\.rb$//")
version=$(echo "$release" | jq .app_version --raw-output)
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
brew update
# We avoid reformatting user-provided data such as the app description and homepage.
brew style --except-cops FormulaAudit/Homepage,FormulaAudit/Desc,FormulaAuditStrict --fix "Formula/${filename}" || true
git add "Formula/${filename}"
git commit -m "${name} ${version}"
done
git push
custom-publish-crates:
needs:
- plan
- host
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
uses: ./.github/workflows/publish-crates.yml
with:
plan: ${{ needs.plan.outputs.val }}
secrets: inherit
# publish jobs get escalated permissions
permissions:
"contents": "read"
"id-token": "write"
announce:
needs:
- plan
- host
- publish-homebrew-formula
- custom-publish-crates
# use "always() && ..." to allow us to wait for all publish jobs while
# still allowing individual publish jobs to skip themselves (for prereleases).
# "host" however must run to completion, no skipping allowed!
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.custom-publish-crates.result == 'skipped' || needs.custom-publish-crates.result == 'success') }}
runs-on: "ubuntu-22.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803
with:
persist-credentials: false
submodules: recursive

View File

@@ -300,28 +300,25 @@ python3 scripts/version_check_test.py # the check's own tests
Below 1.0, a minor bump may break config, flags or the `--rpc` protocol; a patch never does.
## Publishing to crates.io
## Releasing
**In this order.** A crate cannot be published before the crates it depends on exist in the
registry, and a published version is immutable, so a wrong order burns a version number rather than
retrying.
A release is a tag. When `main` holds the version to release, with its `CHANGELOG.md` section
written:
```bash
cargo publish -p luxe-core
cargo publish -p luxe-providers -p luxe-tools -p luxe-lsp -p luxe-dap -p luxe-mcp -p luxe-tui
cargo publish -p luxe-cli # the binary; `cargo install luxe-cli` installs `luxe`
git tag v0.2.0 && git push origin v0.2.0
```
Before the first publish, `cargo package -p luxe-tui` (or any crate with an internal dependency)
fails with "no matching package named `luxe-core`" — it resolves the `version` on the path dep
against a registry that has not seen it yet. That is expected rather than a broken manifest. To
check every manifest at once, package the whole workspace, which resolves the internal graph
itself:
`.github/workflows/release.yml`, which `dist` generates from `dist-workspace.toml`, then builds
every target, puts the archives, the install scripts and their updater on the GitHub release with
an attestation for each file, publishes the Homebrew formula to `evanwhittaker/homebrew-tap`, and
publishes the crates to crates.io (`publish-crates.yml`) before announcing. Never edit
`release.yml`; change `dist-workspace.toml` and run `dist generate`.
```bash
cargo package --workspace --no-verify
cargo publish --dry-run -p luxe-core # the one crate that can also verify pre-publish
```
The crates go up by crates.io Trusted Publishing, so no token is stored: each crate's trusted
publisher is this repository's `release.yml`. A crate whose version crates.io already has is
skipped, so a re-run after a partial publish carries on. `cargo publish --workspace --dry-run`
packages and builds every crate the way the registry will, dependencies first.
## Development-only files

View File

@@ -121,3 +121,8 @@ field_reassign_with_default = "allow"
nonminimal_bool = "allow"
match_same_arms = "allow"
unnecessary_filter_map = "allow"
# The profile that 'dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"

View File

@@ -1,4 +1,4 @@
# Luxe
<h1 align="center"><img src="web/src/assets/generated/wordmark-banner.svg" alt="Luxe" width="420"></h1>
Luxe is a coding agent for your terminal, written in Rust. It works in your project with the model
you choose, then reads back what it changed as a Guided Review, so you can comment, ask for fixes,
@@ -49,12 +49,20 @@ and [the guide lists them](https://luxe.dev/docs/security/#what-luxe-sends-over-
## Install
```bash
cargo install luxe-cli
luxe --version
# macOS and Linux
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
# Homebrew
brew install evanwhittaker/tap/luxe
# Windows (PowerShell)
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
# Cargo (Rust 1.89 or newer)
cargo install --locked luxe-cli
```
You need Rust 1.89 or newer; [rustup](https://rustup.rs) installs it. To update, run the same
command with `--force`. To build from source:
To update, run `luxe update`. To build from source:
```bash
git clone https://github.com/evanwhittaker/luxe.git

32
SECURITY.md Normal file
View File

@@ -0,0 +1,32 @@
# Security
Luxe runs a model's commands on your machine, so a hole in it matters. If you find one, please tell
me privately before anyone else.
## Reporting
[Open a private advisory](https://github.com/evanwhittaker/luxe/security/advisories/new) on GitHub,
or email [contact@luxe.dev](mailto:contact@luxe.dev). Say what you did, what happened, and the
Luxe version (`luxe --version`). A transcript or a minimal repository that shows it helps most.
I'll answer within a few days, keep you posted while it's fixed, and credit you in the advisory and
the release notes unless you'd rather not be named. Please give the fix time to ship before you
publish.
## What counts
Anything that gets past what [Security and permissions](https://luxe.dev/docs/security/) promises:
- a tool call that runs, reads or writes without the prompt or the rule that should have stopped it
- a way for a project, an instruction file or an MCP server to grant itself trust you didn't give
- a secret reaching a tool result, a log, the wire capture or the model when it should be scrubbed
- a network request [the guide doesn't list](https://luxe.dev/docs/security/#what-luxe-sends-over-the-network)
- a release artifact that isn't what this repository built
What the model does with permission you gave it, including anything under `--yolo`, is working as
designed. So is a prompt injection that only gets the agent to ask you for something you then
approve; one that gets around the asking is a real bug.
## Supported versions
Fixes go into the newest release. `luxe update` gets you there.

View File

@@ -52,7 +52,9 @@ async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
let Some((program, args)) = step.split_first() else { continue };
let line = step.join(" ");
println!("Running: {line}");
let status = tokio::process::Command::new(program)
let beside =
std::env::current_exe().ok().and_then(|exe| exe.parent().map(Path::to_path_buf));
let status = tokio::process::Command::new(program_path(program, beside.as_deref()))
.args(args)
.status()
.await
@@ -64,6 +66,16 @@ async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
Ok(())
}
/// Where to run `program` from: `beside` this binary when it is there, which is where the
/// installer put its updater, whether or not that directory is on `PATH`; by name otherwise.
fn program_path(program: &str, beside: Option<&Path>) -> PathBuf {
let name = format!("{program}{}", std::env::consts::EXE_SUFFIX);
beside
.map(|dir| dir.join(name))
.filter(|path| path.is_file())
.unwrap_or_else(|| PathBuf::from(program))
}
/// How the update landed, read from the `luxe` a shell would run now.
#[derive(Debug, PartialEq, Eq)]
enum Outcome {

View File

@@ -11,6 +11,18 @@ fn copies() -> (tempfile::TempDir, PathBuf, PathBuf) {
(dir, updated, other)
}
/// The installer's updater runs from beside the binary even off `PATH`; anything not there, cargo
/// or brew, is found by name.
#[test]
fn a_program_beside_the_binary_runs_from_there() {
let dir = tempfile::tempdir().expect("tempdir");
let updater = dir.path().join(format!("luxe-cli-update{}", std::env::consts::EXE_SUFFIX));
std::fs::write(&updater, b"").expect("a stand-in updater");
assert_eq!(program_path("luxe-cli-update", Some(dir.path())), updater);
assert_eq!(program_path("brew", Some(dir.path())), PathBuf::from("brew"));
assert_eq!(program_path("luxe-cli-update", None), PathBuf::from("luxe-cli-update"));
}
#[test]
fn the_version_is_the_last_word_when_it_is_semver() {
assert_eq!(parse_version("luxe 0.2.0\n").as_deref(), Some("0.2.0"));

View File

@@ -168,8 +168,8 @@ community favorites and of Omarchy's themes:
{ "theme": "nord" }
```
An unknown name falls back to `luxe`, and Luxe says so when the session opens. See them all at
[luxe.dev/themes](https://luxe.dev/themes).
An unknown name falls back to `luxe`, and Luxe says so when the session opens. See them all on
[luxe.dev](https://luxe.dev/#craft).
Code is colored by the theme too: in answers, tool cards, diffs and the preview, keywords take the
theme's `accentSecondary`, strings its `success`, numbers its `warning`, functions its `accent`,
@@ -857,14 +857,15 @@ it, showing each one before it runs:
| Installed with | `luxe update` runs |
| --- | --- |
| Cargo | `cargo install --locked --force luxe-cli` |
| The install script | `luxe-cli-update`, the updater it put beside `luxe` |
| Homebrew | `brew update`, then `brew upgrade luxe` |
| Cargo | `cargo install --locked --force luxe-cli` |
Luxe never downloads or replaces its own program; the package manager that installed it does. A
copy your system's package manager owns is left to it, and a downloaded one points you at the
releases page. On Windows, Luxe can't be replaced while it runs, so it prints the command to run
once it has exited. Afterwards it checks that the `luxe` your shell finds is the new version, and
says so if another copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
Luxe never downloads or replaces its own program; whatever installed it does. A copy your system's
package manager owns is left to it, and a downloaded archive points you at the releases page. On
Windows, Luxe can't be replaced while it runs, so it prints the command to run once it has exited.
Afterwards it checks that the `luxe` your shell finds is the new version, and says so if another
copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
To stop the daily check:
@@ -2129,20 +2130,49 @@ order: 1
group: "Get started"
---
## Install with Cargo
## Install
On macOS and Linux, the install script puts `luxe` in `~/.local/bin`, or in `$LUXE_INSTALL_DIR`
when it is set, and adds that to your `PATH`:
```bash
cargo install luxe-cli
luxe --version
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
```
This installs the `luxe` command. You need a recent stable Rust; [rustup](https://rustup.rs)
installs one.
On Windows, in PowerShell:
```powershell
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
```
With Homebrew, on macOS or Linux:
```bash
brew install evanwhittaker/tap/luxe
```
With Cargo, which builds it, so you need Rust 1.89 or newer ([rustup](https://rustup.rs) installs
one):
```bash
cargo install --locked luxe-cli
```
Any of them installs the `luxe` command; `luxe --version` checks it worked.
To update, run `luxe update`, or `/update` inside Luxe. Luxe checks once a day for a newer release
and says so on the start screen; see [Updates](configuration.md#updates) for how it updates and how
to turn the check off.
### Check a download
Every file on a release carries a build attestation, so you can confirm it came from this
repository's release workflow and nowhere else:
```bash
gh attestation verify luxe-cli-x86_64-unknown-linux-gnu.tar.xz --repo evanwhittaker/luxe
```
## Build from source
```bash

View File

@@ -51,7 +51,7 @@ fn a_search_lists_pull_requests_and_issues_with_where_they_are() {
pub(super) const MERGED_NONE: &str = include_str!("../../fixtures/merged_below_none.json");
/// Real answers from restacking a scratch stack on luxe-dev: the bottom squash-merged with its
/// Real answers from restacking a scratch stack: the bottom squash-merged with its
/// branch kept, and a layer with nothing merged below it. A retargeted one names the base it
/// was moved from.
#[test]
@@ -72,7 +72,7 @@ fn what_merged_below_a_stack_is_read_with_where_it_went() {
pub(super) const STATUS_UNSTACKED: &str =
include_str!("../../fixtures/branch_status_unstacked.json");
/// Luxe's own chain on luxe-dev, read from the middle: seven below down to `master`, two above,
/// A real chain of Luxe's own, read from the middle: seven below down to `master`, two above,
/// and the evidence that checks wait for trunk — the bottom one has them, this one none.
#[test]
fn a_pull_request_in_the_middle_of_a_stack_knows_where_it_sits() {

View File

@@ -28,7 +28,7 @@ fn gh_names_a_repository_off_github_com_by_host() {
assert!(!repository.is("nora-quinn/luxe"));
}
// From the scratch pull request nora-quinn/luxe-dev#141, posted to and closed for this.
// From a scratch pull request, posted to and closed for this.
pub(super) const PR_FILES: &str = include_str!("../../fixtures/pr_files.jsonl");
pub(super) const THREADS_OWN: &str = include_str!("../../fixtures/review_threads_own.json");
pub(super) const THREAD_REPLY: &str = include_str!("../../fixtures/thread_reply.json");
@@ -135,8 +135,8 @@ fn the_conversation_comes_with_the_threads() {
assert!(before.conversation.is_empty() && !before.threads.is_empty());
}
/// On luxe-dev#169 the reader answered the first comment from Luxe, so it and the answer stay
/// quiet, and the review's summary is what is still asked.
/// On a real pull request the reader answered the first comment from Luxe, so it and the answer
/// stay quiet, and the review's summary is what is still asked.
#[test]
fn an_answered_comment_on_a_real_pull_request_asks_nothing() {
let read = parse_review_threads(THREADS_CONVERSATION).unwrap();

View File

@@ -227,27 +227,49 @@ impl FileLock {
let path = target.with_extension("lock");
let deadline = SystemTime::now() + LOCK_TIMEOUT;
loop {
match std::fs::create_dir(&path) {
let error = match std::fs::create_dir(&path) {
Ok(()) => return Ok(Self { path }),
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => {
if lock_is_stale(&path) {
tracing::warn!(lock = %path.display(), "breaking a stale config lock");
let _ = std::fs::remove_dir(&path);
continue;
}
if SystemTime::now() >= deadline {
return Err(FileError::LockTimeout(path));
}
std::thread::sleep(Duration::from_millis(25));
}
Err(error) => {
return Err(FileError::io(format!("locking {}", path.display()), error))
}
Err(error) => error,
};
let held = error.kind() == std::io::ErrorKind::AlreadyExists;
if held && lock_is_stale(&path) {
tracing::warn!(lock = %path.display(), "breaking a stale config lock");
let _ = std::fs::remove_dir(&path);
continue;
}
let past_deadline = SystemTime::now() >= deadline;
match lock_wait(error.kind(), cfg!(windows)) {
LockWait::Wait if !past_deadline => std::thread::sleep(Duration::from_millis(25)),
LockWait::Wait if held => return Err(FileError::LockTimeout(path)),
_ => return Err(FileError::io(format!("locking {}", path.display()), error)),
}
}
}
}
/// What a failed `create_dir` of the lock means for the writer.
#[derive(Debug, PartialEq, Eq)]
enum LockWait {
/// Another writer has it, or is a moment from letting it go
Wait,
/// Waiting cannot help
Fail,
}
/// Whether a failed attempt at the lock is worth waiting out.
///
/// On Windows a directory being removed lingers, delete-pending, until its last handle closes, and
/// creating it then fails with access denied rather than already exists. That is the previous
/// holder letting go, so it waits too; a real permission problem still surfaces, as itself, once
/// the deadline passes. Elsewhere access denied is only ever the real thing.
fn lock_wait(kind: std::io::ErrorKind, windows: bool) -> LockWait {
match kind {
std::io::ErrorKind::AlreadyExists => LockWait::Wait,
std::io::ErrorKind::PermissionDenied if windows => LockWait::Wait,
_ => LockWait::Fail,
}
}
impl Drop for FileLock {
fn drop(&mut self) {
let _ = std::fs::remove_dir(&self.path);
@@ -264,139 +286,4 @@ fn lock_is_stale(path: &Path) -> bool {
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;
/// A broken file is moved aside under the lock, and a later broken file does not overwrite the
/// first one set aside.
#[test]
fn a_broken_file_is_set_aside_and_never_over_an_earlier_one() {
let (dir, file) = file(FileMode::OwnerOnly);
for broken in ["{ first", "{ second"] {
std::fs::write(file.path(), broken).unwrap();
let ((), aside) = file
.modify_setting_aside(|root| {
root.insert("fresh".into(), Value::Bool(true));
Ok(())
})
.unwrap();
let aside = aside.expect("the broken file was moved");
assert_eq!(std::fs::read_to_string(&aside).unwrap(), broken);
}
assert_eq!(std::fs::read_to_string(dir.path().join("thing.json.bad")).unwrap(), "{ first");
assert_eq!(file.read().unwrap().get("fresh"), Some(&Value::Bool(true)));
}
/// The OS error is said once, whether a caller prints the message alone or walks the chain.
#[test]
fn an_io_failure_names_its_cause_once() {
let error = FileError::io("reading thing.json", std::io::Error::other("disk on fire"));
assert_eq!(error.to_string(), "reading thing.json: disk on fire");
let chain = crate::error_cause::chain(&error);
assert_eq!(chain.matches("disk on fire").count(), 1, "{chain}");
}
fn file(mode: FileMode) -> (tempfile::TempDir, JsonFile) {
let dir = tempfile::tempdir().unwrap();
let file = JsonFile::new(dir.path().join("thing.json"), mode);
(dir, file)
}
#[test]
fn an_absent_or_empty_file_reads_as_nothing() {
let (_dir, file) = file(FileMode::OwnerOnly);
assert!(file.read().is_none());
std::fs::write(file.path(), " \n").unwrap();
assert!(file.read().is_none());
}
#[test]
fn modify_preserves_every_key_it_did_not_touch() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), r#"{"keep": {"deep": 1}, "also": "me"}"#).unwrap();
file.modify(|root| {
root.insert("added".into(), Value::Bool(true));
Ok(())
})
.unwrap();
let root = file.read().unwrap();
assert_eq!(root["keep"]["deep"], 1);
assert_eq!(root["also"], "me");
assert_eq!(root["added"], true);
}
#[test]
fn a_malformed_file_blocks_the_write_and_is_left_alone() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), "{ nope").unwrap();
let error = file
.modify(|root| {
root.insert("added".into(), Value::Bool(true));
Ok(())
})
.expect_err("must refuse");
assert!(matches!(error, FileError::Unparseable { .. }), "got {error:?}");
assert_eq!(std::fs::read_to_string(file.path()).unwrap(), "{ nope");
}
#[test]
fn a_rejecting_edit_leaves_the_file_untouched() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), r#"{"a": 1}"#).unwrap();
let error = file
.modify(|_| Err::<(), _>(FileError::Rejected("no".into())))
.expect_err("propagates");
assert!(matches!(error, FileError::Rejected(_)));
assert_eq!(file.read().unwrap()["a"], 1);
assert!(!file.path().with_extension("lock").exists(), "the lock must be released");
}
#[cfg(unix)]
#[test]
fn owner_only_mode_is_enforced_and_preserve_mode_respects_the_user() {
use std::os::unix::fs::PermissionsExt;
let (_dir, secret) = file(FileMode::OwnerOnly);
secret.modify(|root| Ok(root.insert("k".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(secret.path()), Some(0o600));
let dir = tempfile::tempdir().unwrap();
let config = JsonFile::new(dir.path().join("models.json"), FileMode::PreserveExisting);
// A fresh file still starts tight.
config.modify(|root| Ok(root.insert("a".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(config.path()), Some(0o600));
// A mode the user chose survives a rewrite.
std::fs::set_permissions(config.path(), std::fs::Permissions::from_mode(0o644)).unwrap();
config.modify(|root| Ok(root.insert("b".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(config.path()), Some(0o644));
}
#[test]
fn a_stale_lock_is_broken_instead_of_blocking_forever() {
let (_dir, file) = file(FileMode::OwnerOnly);
let lock = file.path().with_extension("lock");
std::fs::create_dir(&lock).unwrap();
backdate(&lock, LOCK_STALE + Duration::from_secs(5));
file.modify(|root| Ok(root.insert("a".into(), Value::Bool(true)))).unwrap();
assert!(file.read().is_some());
}
#[test]
fn a_fresh_lock_makes_a_writer_time_out_rather_than_corrupt() {
let (_dir, file) = file(FileMode::OwnerOnly);
let lock = file.path().with_extension("lock");
std::fs::create_dir(&lock).unwrap();
let error = file.modify(|_| Ok(())).expect_err("must not write through a live lock");
assert!(matches!(error, FileError::LockTimeout(_)), "got {error:?}");
std::fs::remove_dir(&lock).unwrap();
}
/// Set an mtime in the past.
///
/// Not `touch`: `touch -d @<epoch>` is a GNU extension BSD rejects. Not `std` either, because
/// the lock is a *directory*, and opening one to set its times needs `FILE_FLAG_BACKUP_SEMANTICS`
/// on Windows, so it has to work there or the test it serves asserts that nothing happens.
fn backdate(path: &Path, by: Duration) {
let when = filetime::FileTime::from_system_time(SystemTime::now() - by);
filetime::set_file_mtime(path, when).expect("set mtime");
}
}
mod tests;

View File

@@ -0,0 +1,159 @@
use super::*;
/// A broken file is moved aside under the lock, and a later broken file does not overwrite the
/// first one set aside.
#[test]
fn a_broken_file_is_set_aside_and_never_over_an_earlier_one() {
let (dir, file) = file(FileMode::OwnerOnly);
for broken in ["{ first", "{ second"] {
std::fs::write(file.path(), broken).unwrap();
let ((), aside) = file
.modify_setting_aside(|root| {
root.insert("fresh".into(), Value::Bool(true));
Ok(())
})
.unwrap();
let aside = aside.expect("the broken file was moved");
assert_eq!(std::fs::read_to_string(&aside).unwrap(), broken);
}
assert_eq!(std::fs::read_to_string(dir.path().join("thing.json.bad")).unwrap(), "{ first");
assert_eq!(file.read().unwrap().get("fresh"), Some(&Value::Bool(true)));
}
/// Already-exists always waits; access denied waits only on Windows, where it is the previous
/// holder's directory still being removed; anything else fails at once.
#[test]
fn a_lock_waits_out_only_what_waiting_can_fix() {
use std::io::ErrorKind::{AlreadyExists, NotFound, PermissionDenied};
assert_eq!(lock_wait(AlreadyExists, false), LockWait::Wait, "another writer has it");
assert_eq!(lock_wait(PermissionDenied, true), LockWait::Wait, "Windows letting it go");
assert_eq!(lock_wait(PermissionDenied, false), LockWait::Fail, "elsewhere it is real");
assert_eq!(lock_wait(NotFound, true), LockWait::Fail, "no directory to lock in");
}
/// Elsewhere than Windows, a lock that cannot be created for want of permission fails at once
/// with the reason, rather than waiting out the deadline and calling it a timeout.
#[cfg(unix)]
#[test]
fn a_lock_without_permission_fails_with_the_reason() {
use std::os::unix::fs::PermissionsExt;
let dir = tempfile::tempdir().unwrap();
std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o500)).unwrap();
let started = std::time::Instant::now();
let error = FileLock::acquire(&dir.path().join("file.json")).err().expect("refused");
std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o700)).unwrap();
assert!(matches!(error, FileError::Io { .. }), "{error}");
assert!(started.elapsed() < LOCK_TIMEOUT, "it did not wait for the deadline");
}
/// The OS error is said once, whether a caller prints the message alone or walks the chain.
#[test]
fn an_io_failure_names_its_cause_once() {
let error = FileError::io("reading thing.json", std::io::Error::other("disk on fire"));
assert_eq!(error.to_string(), "reading thing.json: disk on fire");
let chain = crate::error_cause::chain(&error);
assert_eq!(chain.matches("disk on fire").count(), 1, "{chain}");
}
fn file(mode: FileMode) -> (tempfile::TempDir, JsonFile) {
let dir = tempfile::tempdir().unwrap();
let file = JsonFile::new(dir.path().join("thing.json"), mode);
(dir, file)
}
#[test]
fn an_absent_or_empty_file_reads_as_nothing() {
let (_dir, file) = file(FileMode::OwnerOnly);
assert!(file.read().is_none());
std::fs::write(file.path(), " \n").unwrap();
assert!(file.read().is_none());
}
#[test]
fn modify_preserves_every_key_it_did_not_touch() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), r#"{"keep": {"deep": 1}, "also": "me"}"#).unwrap();
file.modify(|root| {
root.insert("added".into(), Value::Bool(true));
Ok(())
})
.unwrap();
let root = file.read().unwrap();
assert_eq!(root["keep"]["deep"], 1);
assert_eq!(root["also"], "me");
assert_eq!(root["added"], true);
}
#[test]
fn a_malformed_file_blocks_the_write_and_is_left_alone() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), "{ nope").unwrap();
let error = file
.modify(|root| {
root.insert("added".into(), Value::Bool(true));
Ok(())
})
.expect_err("must refuse");
assert!(matches!(error, FileError::Unparseable { .. }), "got {error:?}");
assert_eq!(std::fs::read_to_string(file.path()).unwrap(), "{ nope");
}
#[test]
fn a_rejecting_edit_leaves_the_file_untouched() {
let (_dir, file) = file(FileMode::OwnerOnly);
std::fs::write(file.path(), r#"{"a": 1}"#).unwrap();
let error =
file.modify(|_| Err::<(), _>(FileError::Rejected("no".into()))).expect_err("propagates");
assert!(matches!(error, FileError::Rejected(_)));
assert_eq!(file.read().unwrap()["a"], 1);
assert!(!file.path().with_extension("lock").exists(), "the lock must be released");
}
#[cfg(unix)]
#[test]
fn owner_only_mode_is_enforced_and_preserve_mode_respects_the_user() {
use std::os::unix::fs::PermissionsExt;
let (_dir, secret) = file(FileMode::OwnerOnly);
secret.modify(|root| Ok(root.insert("k".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(secret.path()), Some(0o600));
let dir = tempfile::tempdir().unwrap();
let config = JsonFile::new(dir.path().join("models.json"), FileMode::PreserveExisting);
// A fresh file still starts tight.
config.modify(|root| Ok(root.insert("a".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(config.path()), Some(0o600));
// A mode the user chose survives a rewrite.
std::fs::set_permissions(config.path(), std::fs::Permissions::from_mode(0o644)).unwrap();
config.modify(|root| Ok(root.insert("b".into(), Value::Bool(true)))).unwrap();
assert_eq!(crate::fs_atomic::existing_mode(config.path()), Some(0o644));
}
#[test]
fn a_stale_lock_is_broken_instead_of_blocking_forever() {
let (_dir, file) = file(FileMode::OwnerOnly);
let lock = file.path().with_extension("lock");
std::fs::create_dir(&lock).unwrap();
backdate(&lock, LOCK_STALE + Duration::from_secs(5));
file.modify(|root| Ok(root.insert("a".into(), Value::Bool(true)))).unwrap();
assert!(file.read().is_some());
}
#[test]
fn a_fresh_lock_makes_a_writer_time_out_rather_than_corrupt() {
let (_dir, file) = file(FileMode::OwnerOnly);
let lock = file.path().with_extension("lock");
std::fs::create_dir(&lock).unwrap();
let error = file.modify(|_| Ok(())).expect_err("must not write through a live lock");
assert!(matches!(error, FileError::LockTimeout(_)), "got {error:?}");
std::fs::remove_dir(&lock).unwrap();
}
/// Set an mtime in the past.
///
/// Not `touch`: `touch -d @<epoch>` is a GNU extension BSD rejects. Not `std` either, because
/// the lock is a *directory*, and opening one to set its times needs `FILE_FLAG_BACKUP_SEMANTICS`
/// on Windows, so it has to work there or the test it serves asserts that nothing happens.
fn backdate(path: &Path, by: Duration) {
let when = filetime::FileTime::from_system_time(SystemTime::now() - by);
filetime::set_file_mtime(path, when).expect("set mtime");
}

View File

@@ -272,8 +272,8 @@ fn the_on_disk_entry_shape_is_frozen() {
r#"{"id":"e3","parent_id":"e2","ts":7,"kind":{"kind":"header","data":{"cwd":"/w","created":7}}}"#
);
// A link to the pull request a session worked on, copied from the round trip that closed
// #146 on luxe-dev: `luxe --from-pr` reads exactly this
// A link to the pull request a session worked on, copied from a real round trip that closed
// one: `luxe --from-pr` reads exactly this
let stored = r#"{"id":"f25fd65c-ee99-4db8-9ed9-76aa08ed7fd9","parent_id":"035e7a31-2d6b-410a-b1d1-361920bf0615","ts":1790289080,"kind":{"kind":"pull_request_link","data":{"number":146,"url":"https://github.com/nora-quinn/luxe-dev/pull/146"}}}"#;
let entry: Entry = serde_json::from_str(stored).unwrap();
assert_eq!(

View File

@@ -47,16 +47,32 @@ pub enum InstallSource {
Homebrew,
/// A path a distribution's package manager owns (`/usr/bin`, `/bin`).
SystemPackage,
/// A release archive, an installer script, `/usr/local/bin`, or a local build.
/// Luxe's own installer script, known by the updater it puts beside the binary.
Installer,
/// A release archive, `/usr/local/bin`, or a local build.
Archive,
}
/// The updater Luxe's installer script puts beside the binary, named `<package>-update` by dist.
pub const INSTALLER_UPDATER: &str = "luxe-cli-update";
impl InstallSource {
/// Classify the running binary. Falls back to [`InstallSource::Archive`], which is the state
/// that gives the most cautious advice ("download the new release") rather than the most
/// confident.
pub fn detect() -> Self {
std::env::current_exe().map(|path| Self::from_path(&path)).unwrap_or(Self::Archive)
std::env::current_exe().map(|path| Self::from_install(&path)).unwrap_or(Self::Archive)
}
/// Classify a binary by what sits beside it, then by its path. The installer's updater beside
/// it decides first: the installer puts it wherever it installs, `~/.cargo/bin` included when
/// told to, and no path says "installer" on its own.
pub fn from_install(binary: &Path) -> Self {
let updater = format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX);
match binary.parent().map(|dir| dir.join(updater)) {
Some(path) if path.is_file() => Self::Installer,
_ => Self::from_path(binary),
}
}
/// Classify a path. Split out from [`Self::detect`] because a function that can only be
@@ -94,6 +110,7 @@ impl InstallSource {
match self {
Self::Cargo => Some(&[&["cargo", "install", "--locked", "--force", "luxe-cli"]]),
Self::Homebrew => Some(&[&["brew", "update"], &["brew", "upgrade", "luxe"]]),
Self::Installer => Some(&[&[INSTALLER_UPDATER]]),
// Which package manager owns it is not knowable without querying one, and guessing
// `apt` on an Arch machine is the failure this whole function exists to avoid.
Self::SystemPackage => None,

View File

@@ -31,6 +31,36 @@ fn the_update_steps_are_the_owners_own_commands() {
assert_eq!(InstallSource::Archive.update_steps(), None, "a download has no owner to ask");
}
/// The installer's updater beside the binary marks an installer copy wherever it lives, a
/// `~/.cargo/bin` it was told to use included, and that updater is its update. Without it the
/// path decides, as before.
#[test]
fn the_installers_updater_beside_the_binary_marks_an_installer_copy() {
let dir = tempfile::tempdir().expect("tempdir");
let bin = dir.path().join(".cargo/bin");
std::fs::create_dir_all(&bin).expect("bin dir");
let luxe = bin.join(format!("luxe{}", std::env::consts::EXE_SUFFIX));
std::fs::write(&luxe, b"").expect("a stand-in luxe");
assert_eq!(InstallSource::from_install(&luxe), InstallSource::Cargo, "no updater: the path");
let updater = bin.join(format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX));
std::fs::write(&updater, b"").expect("a stand-in updater");
assert_eq!(InstallSource::from_install(&luxe), InstallSource::Installer);
let steps: &[&[&str]] = &[&["luxe-cli-update"]];
assert_eq!(InstallSource::Installer.update_steps(), Some(steps));
}
/// A directory named like the updater is not the updater.
#[test]
fn a_directory_named_like_the_updater_does_not_count() {
let dir = tempfile::tempdir().expect("tempdir");
let luxe = dir.path().join("luxe");
std::fs::write(&luxe, b"").expect("a stand-in luxe");
let name = format!("{INSTALLER_UPDATER}{}", std::env::consts::EXE_SUFFIX);
std::fs::create_dir(dir.path().join(name)).expect("a directory");
assert_ne!(InstallSource::from_install(&luxe), InstallSource::Installer);
}
/// Homebrew is checked first because its Linux and Intel-macOS prefixes sit *inside* paths the
/// other arms would otherwise claim.
#[test]

View File

@@ -1,7 +1,7 @@
//! `git` `checks` — why CI is failing, bounded.
//!
//! `gh run view --log-failed` prints every line of every failing step: 3,671 lines for one Clippy
//! step on luxe-dev, with the error in the last dozen. This reads the same logs through GitHub
//! step of Luxe's own, with the error in the last dozen. This reads the same logs through GitHub
//! and keeps the tail of each failing step, says how much it left out, and also lists the failing
//! checks that are not Actions jobs at all — a commit status from another CI, which that command
//! cannot see. Reading only; re-running a job stays behind the permission engine's `ask`.

View File

@@ -331,14 +331,17 @@ async fn without_a_pull_request_the_checks_on_head_are_read() {
);
}
/// Against the real `gh` and luxe-dev's #119, whose getrandom bump failed three jobs: each
/// comes back with the compiler's error at the end of its tail. `cargo test -- --ignored`.
/// Against the real `gh` and a pull request of this checkout's repository whose CI failed: each
/// failing job comes back with the compiler's error at the end of its tail. Run with
/// `LUXE_FAILED_PR=<number> cargo test -- --ignored`.
#[tokio::test]
#[ignore = "needs a signed-in gh and the network"]
#[ignore = "needs a signed-in gh, the network, and LUXE_FAILED_PR"]
async fn a_real_failed_run_ends_in_its_error() {
let number = std::env::var("LUXE_FAILED_PR")
.expect("LUXE_FAILED_PR names a pull request in this repository whose checks failed");
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
let github = luxe_core::github::GhCli::new();
let text = checks(&github, &root, &["119".into()]).await.unwrap();
assert!(text.starts_with("1 check failing on #119"), "{text}");
let text = checks(&github, &root, std::slice::from_ref(&number)).await.unwrap();
assert!(text.contains(&format!("failing on #{number}")), "{text}");
assert!(text.contains("##[error]Process completed with exit code"), "{text}");
}

View File

@@ -177,7 +177,7 @@ fn collapse_blank_runs(text: &str) -> String {
mod tests {
use super::readable;
/// Dependabot's commit list, from luxe-dev #197's real body: a summary heading, then a list
/// Dependabot's commit list, from a real pull request's body: a summary heading, then a list
/// of linked commit ids, with an entity decoded and no tag left.
#[test]
fn a_dependabot_commit_list_reads_as_a_list() {

45
dist-workspace.toml Normal file
View File

@@ -0,0 +1,45 @@
# How Luxe is released. dist reads this and writes .github/workflows/release.yml from it, so the
# workflow is never edited by hand: change this, then run `dist generate`. Run `dist init` only to
# move to a new dist version; with `--yes` it answers its own questions and drops settings here.
#
# A release starts when a `v<version>` tag is pushed for the version on main. dist builds every
# target, puts the archives and installers on the GitHub release, then publishes the Homebrew
# formula and the crates (.github/workflows/publish-crates.yml), and only then announces.
[workspace]
members = ["cargo:."]
[dist]
cargo-dist-version = "0.33.0"
ci = "github"
targets = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
]
installers = ["shell", "powershell", "homebrew"]
# Not `~/.cargo/bin`, dist's default: a copy there reads as a cargo install, and `luxe update`
# would rebuild it from source with a toolchain the installer's users may not have
install-path = ["$LUXE_INSTALL_DIR/", "~/.local/bin"]
# The installer's own updater, beside the binary; `luxe update` runs it for an installer copy
install-updater = true
tap = "evanwhittaker/homebrew-tap"
# `brew install evanwhittaker/tap/luxe`, not `luxe-cli`: the command is `luxe`
formula = "luxe"
publish-jobs = ["homebrew", "./publish-crates"]
# A called workflow gets no more than its caller grants: checking out needs `contents`, and
# Trusted Publishing needs `id-token`
github-custom-job-permissions = { "publish-crates" = { contents = "read", id-token = "write" } }
# Provenance for every artifact, so a download can be checked against this repository's build
github-attestations = true
pr-run-mode = "plan"
# Pinned to commits, as every other workflow here is, so a moved tag cannot change what a release
# runs. checkout v6.1.0, upload-artifact v7.0.2, download-artifact v8.0.2, attest v4.2.2
[dist.github-action-commits]
"actions/checkout" = "d23441a48e516b6c34aea4fa41551a30e30af803"
"actions/upload-artifact" = "cf430e030ddbb5b0abf93d22962f4752f3646cd9"
"actions/download-artifact" = "9000827ccba6bdab643e8b6fd33ac0654aef8333"
"actions/attest" = "1e69f48acb82d1966a394da916b4c1698aa569d6"

View File

@@ -28,8 +28,8 @@ community favorites and of Omarchy's themes:
{ "theme": "nord" }
```
An unknown name falls back to `luxe`, and Luxe says so when the session opens. See them all at
[luxe.dev/themes](https://luxe.dev/themes).
An unknown name falls back to `luxe`, and Luxe says so when the session opens. See them all on
[luxe.dev](https://luxe.dev/#craft).
Code is colored by the theme too: in answers, tool cards, diffs and the preview, keywords take the
theme's `accentSecondary`, strings its `success`, numbers its `warning`, functions its `accent`,

View File

@@ -150,14 +150,15 @@ it, showing each one before it runs:
| Installed with | `luxe update` runs |
| --- | --- |
| Cargo | `cargo install --locked --force luxe-cli` |
| The install script | `luxe-cli-update`, the updater it put beside `luxe` |
| Homebrew | `brew update`, then `brew upgrade luxe` |
| Cargo | `cargo install --locked --force luxe-cli` |
Luxe never downloads or replaces its own program; the package manager that installed it does. A
copy your system's package manager owns is left to it, and a downloaded one points you at the
releases page. On Windows, Luxe can't be replaced while it runs, so it prints the command to run
once it has exited. Afterwards it checks that the `luxe` your shell finds is the new version, and
says so if another copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
Luxe never downloads or replaces its own program; whatever installed it does. A copy your system's
package manager owns is left to it, and a downloaded archive points you at the releases page. On
Windows, Luxe can't be replaced while it runs, so it prints the command to run once it has exited.
Afterwards it checks that the `luxe` your shell finds is the new version, and says so if another
copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
To stop the daily check:

View File

@@ -5,20 +5,49 @@ order: 1
group: "Get started"
---
## Install with Cargo
## Install
On macOS and Linux, the install script puts `luxe` in `~/.local/bin`, or in `$LUXE_INSTALL_DIR`
when it is set, and adds that to your `PATH`:
```bash
cargo install luxe-cli
luxe --version
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
```
This installs the `luxe` command. You need a recent stable Rust; [rustup](https://rustup.rs)
installs one.
On Windows, in PowerShell:
```powershell
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
```
With Homebrew, on macOS or Linux:
```bash
brew install evanwhittaker/tap/luxe
```
With Cargo, which builds it, so you need Rust 1.89 or newer ([rustup](https://rustup.rs) installs
one):
```bash
cargo install --locked luxe-cli
```
Any of them installs the `luxe` command; `luxe --version` checks it worked.
To update, run `luxe update`, or `/update` inside Luxe. Luxe checks once a day for a newer release
and says so on the start screen; see [Updates](configuration.md#updates) for how it updates and how
to turn the check off.
### Check a download
Every file on a release carries a build attestation, so you can confirm it came from this
repository's release workflow and nowhere else:
```bash
gh attestation verify luxe-cli-x86_64-unknown-linux-gnu.tar.xz --repo evanwhittaker/luxe
```
## Build from source
```bash

View File

@@ -141,6 +141,28 @@ tokens() { cargo run --quiet --release -p luxe-tui --example theme_css; }
catalog() { cargo run --quiet --release -p luxe-tui --example theme_css -- --json; }
shiki() { cargo run --quiet --release -p luxe-tui --example shiki_theme -- "$@"; }
# The README's wordmark. GitHub shows an image on its own, where the CSS variables the site paints
# the letters with do not exist and every letter would fall back to black, so this copy carries
# the theme's own colors and its background: the same on GitHub's light pages as on its dark ones.
banner() {
python3 - "$1/wordmark.svg" "$1/tokens.css" <<'PY'
import re, sys
svg, css = (open(path).read() for path in sys.argv[1:])
color = lambda name: re.search(rf"--luxe-{name}:\s*(#[0-9a-f]{{6}})", css).group(1)
svg = re.sub(r"var\(--luxe-(wordmark-\d), currentColor\)", lambda m: color(m.group(1)), svg)
width, height = (int(n) for n in re.search(r'viewBox="0 0 (\d+) (\d+)"', svg).groups())
pad_x, pad_y = 120, 72
box = (width + 2 * pad_x, height + 2 * pad_y)
svg = re.sub(
r'viewBox="[^"]*" width="\d+" height="\d+"',
f'viewBox="{-pad_x} {-pad_y} {box[0]} {box[1]}" width="{box[0]}" height="{box[1]}"',
svg,
)
background = f'<rect x="{-pad_x}" y="{-pad_y}" width="{box[0]}" height="{box[1]}" rx="16" fill="{color("background")}"/>'
print(svg.replace("</title>", "</title>\n " + background, 1), end="")
PY
}
generate() {
local target="$1" guide_target="$2"
mkdir -p "${target}" "${guide_target}"
@@ -149,6 +171,7 @@ generate() {
wordmark mark >"${target}/mark.svg"
wordmark tile >"${target}/tile.svg"
tokens >"${target}/tokens.css"
banner "${target}" >"${target}/wordmark-banner.svg"
catalog >"${target}/themes.json"
facts "${target}" >"${target}/facts.json"
shiki luxe >"${target}/shiki-luxe.json"

View File

@@ -37,7 +37,6 @@ const web = fileURLToPath(new URL("../web/", import.meta.url));
/** Pages worth opening, and what has to be alive on each once it has settled. */
const PAGES = [
{ path: "/", demos: true, stills: true },
{ path: "/themes/", demos: false, stills: false },
{ path: "/docs/", demos: false, stills: false },
];

View File

@@ -37,7 +37,6 @@ const PAGES = [
shine: ".hero__mark .wordmark",
captures: true,
},
{ path: "/themes/", expect: [".theme__name", ".masthead__mark"] },
// The measured bars come from a JSON a script writes, the part that could go missing
{ path: "/tools/", expect: [".bench__bar", ".contrast", ".masthead__mark"] },
{ path: "/docs/", expect: [".docs__body", ".docs__nav"] },

5
web/public/_redirects Normal file
View File

@@ -0,0 +1,5 @@
# Cloudflare Pages redirects: source, destination, status.
#
# The themes page folded into the homepage's gallery; a link to it lands on the gallery.
/themes /#craft 301
/themes/ /#craft 301

View File

@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-120 -72 680 298" width="680" height="298" data-cell="10 22" role="img" aria-label="Luxe">
<title>Luxe</title>
<rect x="-120" y="-72" width="680" height="298" rx="16" fill="#12100e"/>
<path fill="#6d5f43" d="M10 11h10v11h-10z M20 11h10v11h-10z M30 11h10v11h-10z M40 11h10v11h-10z M10 22h10v11h-10z M20 22h10v11h-10z M30 22h20v22h-20z M30 44h20v22h-20z M30 66h20v22h-20z M30 88h20v22h-20z M30 110h20v22h-20z M50 121h10v11h-10z M60 121h10v11h-10z M70 121h10v11h-10z M40 132h10v11h-10z M50 132h10v11h-10z M60 132h10v11h-10z M70 132h10v11h-10z"/>
<path fill="#7e6d4d" d="M110 44h20v22h-20z M170 44h20v22h-20z M110 66h20v22h-20z M170 66h20v22h-20z M110 88h20v22h-20z M170 88h20v22h-20z M110 110h20v22h-20z M130 121h10v11h-10z M140 121h10v11h-10z M150 121h10v11h-10z M160 110h30v22h-30z M120 132h10v11h-10z M130 132h10v11h-10z M140 132h10v11h-10z M150 132h10v11h-10z M170 132h10v11h-10z M180 132h10v11h-10z"/>
<path fill="#a59064" d="M210 44h10v11h-10z M220 44h20v22h-20z M260 44h20v22h-20z M280 44h10v11h-10z M230 66h40v22h-40z M230 99h10v11h-10z M240 88h20v22h-20z M260 99h10v11h-10z M220 121h10v11h-10z M230 110h10v22h-10z M240 110h10v11h-10z M250 110h10v11h-10z M260 110h10v22h-10z M270 121h10v11h-10z M210 132h10v11h-10z M220 132h10v11h-10z M230 132h10v11h-10z M260 132h10v11h-10z M270 132h10v11h-10z M280 132h10v11h-10z"/>
<path fill="#cdb27a" d="M320 55h10v11h-10z M330 44h40v22h-40z M370 55h10v11h-10z M310 66h20v22h-20z M330 77h10v11h-10z M340 77h10v11h-10z M350 77h10v11h-10z M360 77h10v11h-10z M370 66h20v22h-20z M310 88h20v22h-20z M330 88h10v11h-10z M340 88h10v11h-10z M350 88h10v11h-10z M360 88h10v11h-10z M370 88h10v11h-10z M380 88h10v11h-10z M310 110h10v11h-10z M320 110h20v22h-20z M340 121h10v11h-10z M350 121h10v11h-10z M360 121h10v11h-10z M370 121h10v11h-10z M380 110h10v22h-10z M330 132h10v11h-10z M340 132h10v11h-10z M350 132h10v11h-10z M360 132h10v11h-10z M370 132h10v11h-10z"/>
<path fill="#ddc084" d="M420 110h20v22h-20z M420 132h10v11h-10z M430 132h10v11h-10z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -3,13 +3,20 @@
type Channel = { id: string; label: string; command: string; note?: string };
const releases = "https://github.com/evanwhittaker/luxe/releases/latest/download";
const channels: Channel[] = [
{ id: "cargo", label: "cargo", command: "cargo install luxe-cli" },
{
id: "source",
label: "source",
command: "git clone https://github.com/evanwhittaker/luxe && cd luxe && cargo build --release",
id: "shell",
label: "shell",
command: `curl --proto '=https' --tlsv1.2 -LsSf ${releases}/luxe-cli-installer.sh | sh`,
},
{ id: "brew", label: "brew", command: "brew install evanwhittaker/tap/luxe" },
{
id: "windows",
label: "windows",
command: `powershell -ExecutionPolicy Bypass -c "irm ${releases}/luxe-cli-installer.ps1 | iex"`,
},
{ id: "cargo", label: "cargo", command: "cargo install --locked luxe-cli" },
];
let active = $state(channels[0]);

View File

@@ -26,8 +26,6 @@
palette: Record<string, Record<string, string>>;
/** The variable the preview paints its canvas with, so the frame around it matches. */
canvas: string;
/** List every token with its value under the preview. */
swatches?: boolean;
/** Take turns through the themes on a timer. */
cycle?: boolean;
/** Put the theme chips under the picture rather than over it. */
@@ -39,7 +37,6 @@
themes,
palette,
canvas,
swatches = false,
cycle = false,
chipsBelow = false,
children,
@@ -93,7 +90,6 @@
});
const showing = $derived(pointed ?? pinned);
const tokens = $derived(themes[showing] ?? {});
/** The preview's palette, as inline custom properties on its frame. */
const style = $derived(
@@ -154,17 +150,6 @@
{@render chips()}
{/if}
{#if swatches}
<dl class="swatches">
{#each Object.entries(tokens) as [name, hex] (name)}
<div class="swatch">
<span class="swatch__chip" style={`background: ${hex}`}></span>
<dt>{name}</dt>
<dd>{hex}</dd>
</div>
{/each}
</dl>
{/if}
</div>
<style>
@@ -241,38 +226,6 @@
stroke 180ms ease;
}
.swatches {
display: grid;
padding-bottom: var(--space-2);
grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
gap: var(--space-1) var(--space-3);
margin: 0;
font-size: var(--step--2);
}
.swatch {
display: flex;
align-items: center;
gap: 0.6em;
}
.swatch__chip {
width: 1em;
height: 1em;
border: 1px solid var(--luxe-border);
flex: none;
}
.swatch dt {
color: var(--luxe-text);
}
.swatch dd {
margin: 0;
color: var(--luxe-muted);
font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
.chip,
.preview__frame,

View File

@@ -12,14 +12,12 @@ import palette from "../assets/generated/theme-preview.json";
import catalog from "../assets/generated/themes.json";
interface Props {
/** List every token of the theme on show, for the page that is about the palettes. */
swatches?: boolean;
/** Take turns through the themes on their own. */
cycle?: boolean;
/** Put the theme chips under the picture, where they read better on a narrow screen. */
chipsBelow?: boolean;
}
const { swatches = false, cycle = false, chipsBelow = false } = Astro.props;
const { cycle = false, chipsBelow = false } = Astro.props;
// The frame around the picture wears the picture's own canvas, which is its first rectangle
const canvas = svg.match(/^<svg[^>]*>\s*<rect [^>]*fill="var\(--(p\d+),/)?.[1];
@@ -31,7 +29,6 @@ if (!canvas) throw new Error("theme-preview.svg has no canvas variable — run s
themes={catalog as Record<string, Record<string, string>>}
{palette}
{canvas}
{swatches}
{cycle}
{chipsBelow}
>

View File

@@ -32,9 +32,10 @@ const year = new Date().getFullYear();
const nav = [
{ href: "/docs", label: "Docs" },
{ href: "/tools", label: "Tools" },
{ href: "/themes", label: "Themes" },
{ href: repo, label: "GitHub" },
];
// GitHub's mark, from Primer's octicons (MIT): the header's repository link and the footer's profile
const githubMark =
"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z";
---
<!doctype html>
@@ -72,6 +73,10 @@ const nav = [
</a>
<nav class="masthead__nav">
{nav.map(({ href, label }) => <a href={href}>{label}</a>)}
{/* The mark says GitHub on its own, and leaves room for the nav beside the wordmark on a phone */}
<a class="masthead__repo" href={repo} aria-label="Luxe on GitHub" title="Luxe on GitHub">
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d={githubMark}></path></svg>
</a>
</nav>
</div>
</header>
@@ -85,12 +90,8 @@ const nav = [
<p class="muted footer__owner">
&copy; {year}
<a class="footer__profile" href="https://github.com/evanwhittaker">
{/* GitHub's mark, from Primer's octicons (MIT) */}
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
<path
d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"
></path>
</svg>evanwhittaker</a
<svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d={githubMark}></path></svg
>evanwhittaker</a
>
</p>
<p class="muted footer__meta">
@@ -208,6 +209,20 @@ const nav = [
color: var(--luxe-accent);
}
/* A touch target the size of a word beside it, not of the 18px mark inside it */
.masthead__repo {
display: inline-flex;
align-items: center;
padding: 0.35em;
margin: -0.35em;
}
.masthead__repo svg {
width: 1.45em;
height: 1.45em;
fill: currentColor;
}
.footer {
border-top: var(--border);
padding-block: var(--space-5);
@@ -259,18 +274,15 @@ const nav = [
}
}
/* Below this the mark and the nav cannot share a line without the theme toggle falling off the
end of it, so they take one each. Dropping a link instead would be cheaper and worse. */
@media (max-width: 34rem) {
.masthead__inner {
flex-direction: column;
align-items: flex-start;
gap: var(--space-3);
/* Two words and a mark fit beside the wordmark on any phone, so the header stays one row; the
narrowest screens get a smaller mark and tighter letters rather than a second line */
@media (max-width: 24rem) {
.masthead__mark {
width: 70px;
}
.masthead__nav {
width: 100%;
justify-content: space-between;
letter-spacing: 0.1em;
}
}
</style>

View File

@@ -72,7 +72,7 @@ const NARROW = { mobileCols: 72, mobileRows: 24 };
</div>
<p class="hero__note muted">
Works on Linux, macOS, and Windows. <a href="/docs/install/#what-it-needs">Learn more</a>.
Works on Linux, macOS, and Windows. <a href="/docs/install/#requirements">Learn more</a>.
</p>
</div>
@@ -611,8 +611,8 @@ const NARROW = { mobileCols: 72, mobileRows: 24 };
container-type: inline-size;
grid-area: 1 / 1;
display: grid;
/* An auto track grows to its widest unbreakable line, and the source install command is one:
it pushed the column, and everything centered in it, under the demo */
/* An auto track grows to its widest unbreakable line, and an install command is one: it pushed
the column, and everything centered in it, under the demo */
grid-template-columns: minmax(0, 1fr);
justify-items: center;
text-align: center;
@@ -956,7 +956,7 @@ const NARROW = { mobileCols: 72, mobileRows: 24 };
}
/* Centered as a block, but its contents are a terminal: tab labels and a shell command read from
the left, and the inherited centering put `cargo install luxe-cli` in the middle of its own box. */
the left, and the inherited centering put the install command in the middle of its own box. */
.hero__install {
width: min(100%, 44rem);
margin-bottom: var(--space-3);

View File

@@ -1,182 +0,0 @@
---
import Base from "../layouts/Base.astro";
import ThemePreview from "../components/ThemePreview.astro";
import themeCss from "../assets/generated/tokens.css?raw";
/**
* The palette, with its numbers attached.
*
* Swatches are read out of the generated stylesheet rather than typed here, so this page cannot
* disagree with the theme the terminal loads.
*/
const readTokens = (block: string) =>
[...block.matchAll(/--luxe-([a-z-]+):\s*(#[0-9a-f]{6});/g)].map(([, name, hex]) => ({ name, hex }));
const modes = [
{ label: "luxe", note: "warm graphite, champagne brass", tokens: readTokens(themeCss) },
];
/** Relative luminance, so each chip can print its own contrast rather than claim one. */
function contrast(a: string, b: string) {
const lum = (hex: string) => {
const parts = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255);
const [r, g, bl] = parts.map((c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
return 0.2126 * r + 0.7152 * g + 0.0722 * bl;
};
const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x);
return (hi + 0.05) / (lo + 0.05);
}
---
<Base title="Themes — Luxe" description="Luxe's palette, and the community favorites it ships with.">
<div class="page">
<section class="section section--head">
<p class="eyebrow">Themes</p>
<h1>Color that means something.</h1>
<div class="prose">
<p>
Luxe's own palette is warm graphite with a champagne-brass accent, and its hues come from a
set of paint colors rather than a terminal convention. Those are mid-luminance by nature,
so the hues were kept and the lightness re-derived against a contrast floor.
</p>
<p>
Three rules do the work, and each one is asserted in the test suite rather than eyeballed:
every background and gray shares one neutral hue, every accent sits on one lightness
plateau so none of them shouts, and nothing drops below 4.5:1 on its own background.
</p>
</div>
</section>
{
modes.map(({ label, note, tokens }) => {
const background = tokens.find((t) => t.name === "background")!.hex;
return (
<section class="section">
<div class="theme__head">
<h2 class="theme__name">{label}</h2>
<p class="muted theme__note">{note}</p>
</div>
<ul class="swatches">
{tokens
.filter(
(t) =>
!t.name.startsWith("wordmark") &&
!t.name.startsWith("capture") &&
t.name !== "tile-ink",
)
.map(({ name, hex }) => (
<li class="swatch">
<span class="swatch__chip" style={`background:${hex}`} />
<span class="swatch__name">{name}</span>
<span class="swatch__hex">{hex}</span>
<span class="swatch__ratio">
{name === "background" ? "—" : `${contrast(hex, background).toFixed(1)}:1`}
</span>
</li>
))}
</ul>
</section>
);
})
}
<section class="section section--last">
<h2>And plenty you may already use.</h2>
<div class="prose">
<p>
Ports that stay true to their originals. Luxe only steps in where a color is too faint to
read a word in, or where a theme's "red" isn't red, since a failed test shown in green
says the opposite of what happened.
</p>
<p>
Point at one to see it. That's how <code>/theme</code> works in the terminal too: the
cursor moves and the whole app repaints, because a palette isn't something you can judge
from its name.
</p>
</div>
<ThemePreview swatches />
<p class="muted">
Set one with <code>"theme": "nord"</code> in <code>~/.config/luxe/config.json</code>, or
override individual tokens with a <code>colors</code> map. On Omarchy, Luxe wears your
desktop's theme and changes with it when you switch.
</p>
</section>
</div>
</Base>
<style>
.section--head {
border-top: 0;
padding-top: var(--space-6);
}
.section--last {
border-bottom: 0;
}
.prose {
max-width: var(--measure);
margin-top: var(--space-4);
}
.theme__head {
display: flex;
align-items: baseline;
gap: var(--space-3);
flex-wrap: wrap;
}
.theme__name {
font-family: var(--font-mono);
font-size: var(--step-1);
letter-spacing: 0;
}
.theme__note {
margin: 0;
font-size: var(--step--1);
}
.swatches {
list-style: none;
padding: 0;
margin: var(--space-4) 0 0;
display: grid;
gap: var(--space-2) var(--space-4);
grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.swatch {
display: grid;
grid-template-columns: 1.6rem 1fr auto auto;
align-items: center;
gap: var(--space-2);
font-size: var(--step--1);
padding-block: 0.3rem;
border-bottom: 1px solid var(--luxe-border-muted);
}
.swatch__chip {
width: 1.6rem;
height: 1.6rem;
box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--luxe-text) 18%, transparent);
}
.swatch__name {
color: var(--luxe-text);
}
.swatch__hex,
.swatch__ratio {
color: var(--luxe-muted);
font-variant-numeric: tabular-nums;
}
.swatch__ratio {
min-width: 4ch;
text-align: right;
}
</style>

View File

@@ -223,7 +223,7 @@ const rows = new Map(
[...bench.repositories].reverse().flatMap((repo) => repo.rows.map((row) => [row.id, row])),
);
for (const row of primary.rows) rows.set(row.id, row);
/** The tightest of the four other agents' limits on the same output: Codex's. */
/** The tightest of the other agents' limits on the same output: Codex's. */
const tightest = (row: { forwarded: Record<string, number> }) =>
Math.min(...Object.values(row.forwarded));
@@ -240,9 +240,13 @@ const tokens = (bytes: number) => {
const count = bytes / 4;
if (count < 1000) return `${Math.max(1, Math.round(count / 10) * 10)} tokens`;
if (count < 10_000) return `${(count / 1000).toFixed(1)}k tokens`;
return `${Math.round(count / 1000)}k tokens`;
if (count < 1_000_000) return `${Math.round(count / 1000)}k tokens`;
return `${(count / 1_000_000).toFixed(1)}M tokens`;
};
/** The head's terminal: the commands whose output Luxe's tool cuts the most, measured like the rest. */
const terminal = ["git", "module_report", "glob"].flatMap((id) => rows.get(id) ?? []);
const times = (shell: number, tool: number) => {
const ratio = shell / tool;
if (ratio < 1.1) return "the same";
@@ -262,12 +266,24 @@ const versus = (cut: number, tool: number) => {
*/
type Other = { warm: number; cold: number; passed: number; runs: number };
type CostRow = { model: string; luxe: { passed: number; runs: number } } & Partial<
Record<"claude" | "codex" | "opencode" | "pi", Other>
Record<"claude" | "codex" | "opencode", Other>
>;
const costRows = agentCost.rows as CostRow[];
const vendorAgent = (row: CostRow) => row.claude ?? row.codex;
const multiple = (other?: Other) => (other ? `${other.cold.toFixed(2)}×` : "–");
/** The chart's scale: the costliest multiple, rounded up to a half, so 1× (Luxe) sits at a fixed mark. */
const chartScale =
Math.ceil(
Math.max(...costRows.flatMap((row) => [vendorAgent(row)?.cold ?? 0, row.opencode?.cold ?? 0])) * 2,
) / 2;
const chartWidth = (multiple: number) => `${(multiple / chartScale) * 100}%`;
const chartBars = (row: CostRow) =>
[
{ kind: "vendor", other: vendorAgent(row) },
{ kind: "opencode", other: row.opencode },
].flatMap(({ kind, other }) => (other ? [{ kind, cold: other.cold }] : []));
/** A bar's share of its row, never so thin it disappears. */
const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100, 0.6)}%`;
---
@@ -278,6 +294,8 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
>
<div class="page">
<section class="section section--head">
<div class="split">
<div>
<p class="eyebrow">Tools</p>
<h1>Better than the shell.</h1>
<div class="prose">
@@ -294,33 +312,61 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
Measured in a checkout of {primary.name} at <code>{primary.commit}</code>, the codebase
the harness eval runs in, with its virtualenv in place. The shell row is the command's
raw output; <em>tightest cut</em> is the least any other agent sends its model of it,
which is Codex's 10 KB, head and tail kept. Pi and OpenCode keep up to 50 KB and Claude
Code 30,000 characters. A token is about four bytes.
which is Codex's 10 KB, head and tail kept. OpenCode keeps up to 50 KB and Claude Code
30,000 characters. A token is about four bytes.
</p>
<p class="muted note">
Those are single calls, and across a whole task the bars shrink, because most calls are
small to begin with. What a whole task costs is <a href="#tasks">below</a>.
</p>
</div>
</div>
{/* The claim, shown: what the model reads back from a shell command, then from the tool */}
<figure class="terminal">
<div class="terminal__bar">
<span class="terminal__dots" aria-hidden="true"><i></i><i></i><i></i></span>
<span>{primary.name.toLowerCase()} @ {primary.commit}</span>
</div>
<dl class="terminal__body">
{
terminal.map((row) => (
<div class="terminal__pair">
<dt>
<span class="terminal__prompt">$</span>
{row.shell}
</dt>
<dd>{tokens(row.shellBytes)}</dd>
<dt class="terminal__luxe">
<span class="terminal__prompt">luxe</span>
{row.tool}
</dt>
<dd class="terminal__luxe">{tokens(row.toolBytes)}</dd>
</div>
))
}
</dl>
<figcaption class="terminal__caption">What the model reads back, measured.</figcaption>
</figure>
</div>
</section>
<section class="section group" id="tasks">
<h2 class="group__name">Whole tasks</h2>
<div class="prose">
<p>
Luxe, Claude Code, Codex, OpenCode and Pi each ran the first twelve Django tasks of
Luxe, Claude Code, Codex and OpenCode each ran the first twelve Django tasks of
SWE-bench Verified Mini, with the same model, the same prompt and the same keys, every
call metered at the network and priced from one list. Each figure is what the other agent
spent on the same task, as a multiple of what Luxe spent: above 1× costs more than Luxe.
</p>
</div>
<div class="split split--tasks">
<table class="costs">
<thead>
<tr>
<th scope="col">Model</th>
<th scope="col">Claude Code or Codex</th>
<th scope="col">OpenCode</th>
<th scope="col">Pi</th>
</tr>
</thead>
<tbody>
@@ -332,19 +378,40 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
</th>
<td>{multiple(vendorAgent(row))}</td>
<td>{multiple(row.opencode)}</td>
<td>{multiple(row.pi)}</td>
</tr>
))
}
</tbody>
</table>
{/* The table's numbers drawn; hidden from screen readers, which have the table */}
<figure class="chart" aria-hidden="true" style={`--one: ${chartWidth(1)}`}>
<figcaption class="chart__legend">
<span class="chart__key chart__key--vendor">Claude Code or Codex</span>
<span class="chart__key chart__key--opencode">OpenCode</span>
<span class="chart__key chart__key--luxe">Luxe, 1×</span>
</figcaption>
{
costRows.map((row) => (
<div class="chart__group">
<code class="chart__model">{row.model}</code>
{chartBars(row).map(({ kind, cold }) => (
<div class={`chart__row chart__row--${kind}`}>
<span class="chart__track">
<span class="chart__bar" style={`width: ${chartWidth(cold)}`} />
</span>
<span class="chart__value">{cold.toFixed(2)}×</span>
</div>
))}
</div>
))
}
</figure>
</div>
<div class="prose">
<p class="muted note">
Every run is charged as a cold start, the way a session begins after a break. Run side
by side on a warm cache, Claude Code and OpenCode cost up to 2.6× what Luxe does on
Claude models. Pass rates overlapped on every model. Pi is the cheapest by design: four
tools and a short prompt, with web search, MCP and the rest left to extensions. Graded
on one machine rather than in SWE-bench's own containers, so these are not leaderboard
Claude models. Pass rates overlapped on every model. Graded on one machine rather than in SWE-bench's own containers, so these are not leaderboard
scores. Measured at <code>{agentCost.commit}</code>.
</p>
</div>
@@ -537,6 +604,190 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
margin-bottom: var(--space-2) !important;
}
/* The words, and beside them what they claim, drawn; one column once there is no room. Shares
rather than a fixed text column: the prose keeps its own measure, and the drawing gets room for
its longest command just above the breakpoint */
.split {
display: grid;
grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
gap: var(--space-5) var(--space-6);
align-items: center;
}
.split--tasks {
grid-template-columns: auto minmax(0, 1fr);
align-items: start;
margin-top: var(--space-5);
}
.split--tasks .costs {
margin-top: 0;
}
/* === The head's terminal === */
.terminal {
margin: 0;
background: var(--luxe-user-msg-bg);
border: var(--border);
font-size: var(--step--1);
}
.terminal__bar {
display: flex;
align-items: center;
gap: var(--space-3);
padding: var(--space-2) var(--space-3);
border-bottom: var(--border);
color: var(--luxe-dim);
}
.terminal__dots {
display: inline-flex;
gap: 0.4em;
}
.terminal__dots i {
display: inline-block;
width: 0.6em;
height: 0.6em;
border-radius: 50%;
background: var(--luxe-dim);
}
.terminal__body {
margin: 0;
padding: var(--space-3);
display: grid;
gap: var(--space-3);
}
.terminal__pair {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: var(--space-1) var(--space-3);
}
.terminal__pair dt {
color: var(--luxe-muted);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.terminal__pair dd {
margin: 0;
text-align: right;
color: var(--luxe-muted);
font-variant-numeric: tabular-nums;
}
.terminal__prompt {
color: var(--luxe-dim);
margin-right: 0.6em;
}
.terminal__pair .terminal__luxe {
color: var(--luxe-accent);
}
.terminal__caption {
padding: 0 var(--space-3) var(--space-3);
color: var(--luxe-dim);
font-size: var(--step--2);
}
/* === The whole-task chart === */
.chart {
margin: 0;
display: grid;
gap: var(--space-3);
font-size: var(--step--1);
}
.chart__legend {
display: flex;
flex-wrap: wrap;
gap: var(--space-2) var(--space-4);
color: var(--luxe-muted);
}
.chart__key::before {
content: "";
display: inline-block;
width: 0.8em;
height: 0.8em;
margin-right: 0.5em;
vertical-align: -0.05em;
}
.chart__key--vendor::before {
background: var(--luxe-dim);
}
.chart__key--opencode::before {
background: var(--luxe-muted);
}
.chart__key--luxe::before {
width: 2px;
height: 1em;
background: var(--luxe-accent);
}
.chart__group {
display: grid;
gap: 0.3em;
}
.chart__model {
color: var(--luxe-accent);
}
.chart__row {
display: grid;
grid-template-columns: minmax(0, 1fr) 4rem;
align-items: center;
gap: var(--space-3);
}
.chart__track {
position: relative;
height: 0.9rem;
background: var(--luxe-user-msg-bg);
}
/* Luxe's 1×, drawn through every row: each bar is read against it */
.chart__track::after {
content: "";
position: absolute;
top: -0.2rem;
bottom: -0.2rem;
left: var(--one);
width: 2px;
background: var(--luxe-accent);
}
.chart__bar {
display: block;
height: 100%;
}
.chart__row--vendor .chart__bar {
background: var(--luxe-dim);
}
.chart__row--opencode .chart__bar {
background: var(--luxe-muted);
}
.chart__value {
text-align: right;
color: var(--luxe-text);
font-variant-numeric: tabular-nums;
}
/* === Measured === */
.bench {
@@ -678,7 +929,9 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
}
@media (max-width: 68rem) {
.tool {
.tool,
.split,
.split--tasks {
grid-template-columns: minmax(0, 1fr);
}
}