diff --git a/README.md b/README.md index 823fbb2..917c7ac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Luxe +

Luxe

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, diff --git a/crates/luxe-cli/src/guide.md b/crates/luxe-cli/src/guide.md index 20b283c..2334f67 100644 --- a/crates/luxe-cli/src/guide.md +++ b/crates/luxe-cli/src/guide.md @@ -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`, diff --git a/crates/luxe-core/src/json_file.rs b/crates/luxe-core/src/json_file.rs index 51d9fb3..7080587 100644 --- a/crates/luxe-core/src/json_file.rs +++ b/crates/luxe-core/src/json_file.rs @@ -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 @` 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; diff --git a/crates/luxe-core/src/json_file/tests.rs b/crates/luxe-core/src/json_file/tests.rs new file mode 100644 index 0000000..bef8a7d --- /dev/null +++ b/crates/luxe-core/src/json_file/tests.rs @@ -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 @` 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"); +} diff --git a/docs/guide/appearance.md b/docs/guide/appearance.md index 9c5e6ee..dedeb9c 100644 --- a/docs/guide/appearance.md +++ b/docs/guide/appearance.md @@ -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`, diff --git a/scripts/site-assets.sh b/scripts/site-assets.sh index 7a7f179..24d6739 100755 --- a/scripts/site-assets.sh +++ b/scripts/site-assets.sh @@ -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'' +print(svg.replace("", "\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" diff --git a/scripts/site-cross.mjs b/scripts/site-cross.mjs index 42fa5db..f993122 100644 --- a/scripts/site-cross.mjs +++ b/scripts/site-cross.mjs @@ -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 }, ]; diff --git a/scripts/site-smoke.mjs b/scripts/site-smoke.mjs index fe28dda..7c9ada3 100644 --- a/scripts/site-smoke.mjs +++ b/scripts/site-smoke.mjs @@ -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"] }, diff --git a/web/public/_redirects b/web/public/_redirects new file mode 100644 index 0000000..ff0c96f --- /dev/null +++ b/web/public/_redirects @@ -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 diff --git a/web/src/assets/generated/wordmark-banner.svg b/web/src/assets/generated/wordmark-banner.svg new file mode 100644 index 0000000..f933d70 --- /dev/null +++ b/web/src/assets/generated/wordmark-banner.svg @@ -0,0 +1,9 @@ + + Luxe + + + + + + + diff --git a/web/src/components/ThemeGallery.svelte b/web/src/components/ThemeGallery.svelte index 1984c7b..d53d4cc 100644 --- a/web/src/components/ThemeGallery.svelte +++ b/web/src/components/ThemeGallery.svelte @@ -26,8 +26,6 @@ palette: Record>; /** 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} -
- {#each Object.entries(tokens) as [name, hex] (name)} -
- -
{name}
-
{hex}
-
- {/each} -
- {/if} diff --git a/web/src/pages/themes.astro b/web/src/pages/themes.astro deleted file mode 100644 index 5541260..0000000 --- a/web/src/pages/themes.astro +++ /dev/null @@ -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); -} - ---- - - -
-
-

Themes

-

Color that means something.

-
-

- 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. -

-

- 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. -

-
-
- - { - modes.map(({ label, note, tokens }) => { - const background = tokens.find((t) => t.name === "background")!.hex; - return ( -
-
-

{label}

-

{note}

-
-
    - {tokens - .filter( - (t) => - !t.name.startsWith("wordmark") && - !t.name.startsWith("capture") && - t.name !== "tile-ink", - ) - .map(({ name, hex }) => ( -
  • - - {name} - {hex} - - {name === "background" ? "—" : `${contrast(hex, background).toFixed(1)}:1`} - -
  • - ))} -
-
- ); - }) - } - -
-

And plenty you may already use.

-
-

- 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. -

-

- Point at one to see it. That's how /theme 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. -

-
- -

- Set one with "theme": "nord" in ~/.config/luxe/config.json, or - override individual tokens with a colors map. On Omarchy, Luxe wears your - desktop's theme and changes with it when you switch. -

-
-
- - - diff --git a/web/src/pages/tools.astro b/web/src/pages/tools.astro index f49f2ee..1f994e3 100644 --- a/web/src/pages/tools.astro +++ b/web/src/pages/tools.astro @@ -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 }) => 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, >
+
+

Tools

Better than the shell.

@@ -294,33 +312,61 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100, Measured in a checkout of {primary.name} at {primary.commit}, the codebase the harness eval runs in, with its virtualenv in place. The shell row is the command's raw output; tightest cut 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.

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 below.

+
+ {/* The claim, shown: what the model reads back from a shell command, then from the tool */} +
+
+ + {primary.name.toLowerCase()} @ {primary.commit} +
+
+ { + terminal.map((row) => ( +
+
+ $ + {row.shell} +
+
{tokens(row.shellBytes)}
+
+ luxe + {row.tool} +
+
{tokens(row.toolBytes)}
+
+ )) + } +
+
What the model reads back, measured.
+
+

Whole tasks

- 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.

+
- @@ -332,19 +378,40 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100, - )) }
Model Claude Code or Codex OpenCodePi
{multiple(vendorAgent(row))} {multiple(row.opencode)}{multiple(row.pi)}
+ {/* The table's numbers drawn; hidden from screen readers, which have the table */} + +

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 {agentCost.commit}.

@@ -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); } }