Luxe installs with curl -fsSL https://luxe.dev/install.sh | sh, edits keep a file's permissions, and the tools page charts every agent by name
- luxe.dev/install.sh redirects to the latest release's installer, and luxe.dev/install.ps1 runs the release's PowerShell installer under Windows' default policy, so the commands are `curl -fsSL https://luxe.dev/install.sh | sh` and `powershell -c "irm https://luxe.dev/install.ps1 | iex"`. The install tabs run shell, brew, cargo, then windows. - The edit and write tools and format-on-save keep a file's mode, so editing a script no longer leaves it unrunnable. - The tools page gives Claude Code and Codex their own columns and bars, draws Luxe's own bar in each group, and its terminal's window controls take macOS's colors. - scripts/aur-pkgbuild.sh writes a luxe-bin PKGBUILD from a release, for the AUR once it reopens.
This commit is contained in:
@@ -50,16 +50,16 @@ and [the guide lists them](https://luxe.dev/docs/security/#what-luxe-sends-over-
|
||||
|
||||
```bash
|
||||
# macOS and Linux
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
|
||||
curl -fsSL https://luxe.dev/install.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
|
||||
|
||||
# Windows (PowerShell)
|
||||
powershell -c "irm https://luxe.dev/install.ps1 | iex"
|
||||
```
|
||||
|
||||
To update, run `luxe update`. To build from source:
|
||||
|
||||
@@ -2136,14 +2136,12 @@ On macOS and Linux, the install script puts `luxe` in `~/.local/bin`, or in `$LU
|
||||
when it is set, and adds that to your `PATH`:
|
||||
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
|
||||
curl -fsSL https://luxe.dev/install.sh | sh
|
||||
```
|
||||
|
||||
On Windows, in PowerShell:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
|
||||
```
|
||||
That address redirects to the script on the [latest
|
||||
release](https://github.com/evanwhittaker/luxe/releases/latest), the one it built and attested. To
|
||||
read it before running it, drop the `| sh`.
|
||||
|
||||
With Homebrew, on macOS or Linux:
|
||||
|
||||
@@ -2158,6 +2156,16 @@ one):
|
||||
cargo install --locked luxe-cli
|
||||
```
|
||||
|
||||
On Windows, in PowerShell:
|
||||
|
||||
```powershell
|
||||
powershell -c "irm https://luxe.dev/install.ps1 | iex"
|
||||
```
|
||||
|
||||
[That script](https://luxe.dev/install.ps1) is two lines: it lets this PowerShell window run the
|
||||
release's installer, which Windows' default execution policy would stop, then runs it. Nothing
|
||||
about your policy is saved.
|
||||
|
||||
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
|
||||
|
||||
@@ -391,7 +391,7 @@ async fn run_via_stdin(spec: &FormatterSpec, path: &Path) -> Result<(), Formatte
|
||||
if std::fs::read(&path)? != input {
|
||||
return Ok(false);
|
||||
}
|
||||
crate::fs_atomic::replace(&path, &formatted).map(|()| true)
|
||||
crate::fs_atomic::replace_keeping_mode(&path, &formatted).map(|()| true)
|
||||
})
|
||||
.await
|
||||
.map_err(|error| io(spec, "write the file")(std::io::Error::other(error)))?
|
||||
|
||||
@@ -62,6 +62,15 @@ pub fn replace_preserving_mode(path: &Path, bytes: &[u8]) -> io::Result<()> {
|
||||
replace_with_mode(path, bytes, existing_mode(path))
|
||||
}
|
||||
|
||||
/// Replace `path` with `bytes` as an editor saves a file: one that exists keeps its mode, an
|
||||
/// executable script included, and a new one gets the platform's default.
|
||||
///
|
||||
/// For the user's own files, which the edit and write tools and the formatter rewrite. A rename
|
||||
/// puts a new file in the old one's place, so a mode not carried over is the new file's default.
|
||||
pub fn replace_keeping_mode(path: &Path, bytes: &[u8]) -> io::Result<()> {
|
||||
write_then_rename(path, bytes, existing_mode(path))
|
||||
}
|
||||
|
||||
/// Replace `path` with `bytes` atomically but without syncing: a reader never sees half of it, and
|
||||
/// a power cut may lose it.
|
||||
///
|
||||
@@ -214,10 +223,18 @@ fn open_staging(path: &Path, mode: Option<u32>) -> io::Result<File> {
|
||||
|
||||
let mut options = OpenOptions::new();
|
||||
options.write(true).create(true).truncate(true);
|
||||
// At creation too, so an owner-only file is never readable even for an instant
|
||||
if let Some(mode) = mode {
|
||||
options.mode(mode);
|
||||
}
|
||||
options.open(path)
|
||||
let file = options.open(path)?;
|
||||
// A mode given at creation is filtered through the umask; set it again so the file ends up
|
||||
// with exactly the mode asked for, a kept group-writable one included
|
||||
if let Some(mode) = mode {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
file.set_permissions(fs::Permissions::from_mode(mode))?;
|
||||
}
|
||||
Ok(file)
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
@@ -252,125 +269,4 @@ fn restrict_dir(_path: &Path) -> io::Result<()> {
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// An unsynced replace still lands whole and leaves no staging file behind.
|
||||
#[test]
|
||||
fn an_unsynced_replace_lands_whole_and_leaves_nothing_behind() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let target = dir.path().join("cache").join("shard.json");
|
||||
replace_unsynced(&target, b"first").unwrap();
|
||||
replace_unsynced(&target, b"second").unwrap();
|
||||
assert_eq!(fs::read(&target).unwrap(), b"second");
|
||||
let left: Vec<_> = fs::read_dir(target.parent().unwrap()).unwrap().flatten().collect();
|
||||
assert_eq!(left.len(), 1, "only the shard: {left:?}");
|
||||
}
|
||||
|
||||
/// Every directory `create_private_dir` makes is owner-only, not just the last one; one that was
|
||||
/// already there keeps its mode.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn every_directory_created_is_private() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mode = |path: &Path| fs::metadata(path).unwrap().permissions().mode() & 0o777;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
fs::set_permissions(dir.path(), fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let leaf = dir.path().join("a").join("b").join("c");
|
||||
create_private_dir(&leaf).unwrap();
|
||||
for created in [dir.path().join("a"), dir.path().join("a/b"), leaf] {
|
||||
assert_eq!(mode(&created), 0o700, "{}", created.display());
|
||||
}
|
||||
assert_eq!(mode(dir.path()), 0o755, "an existing parent is left alone");
|
||||
}
|
||||
|
||||
/// A fresh private directory refuses to adopt one that exists.
|
||||
#[test]
|
||||
fn a_new_private_directory_is_never_an_existing_one() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let fresh = dir.path().join("fresh");
|
||||
create_private_dir_new(&fresh).unwrap();
|
||||
let error = create_private_dir_new(&fresh).unwrap_err();
|
||||
assert_eq!(error.kind(), io::ErrorKind::AlreadyExists);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_replacement_lands_and_leaves_no_staging_file_behind() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("state.json");
|
||||
replace(&path, b"first").unwrap();
|
||||
replace(&path, b"second").unwrap();
|
||||
|
||||
assert_eq!(fs::read(&path).unwrap(), b"second");
|
||||
let strays: Vec<_> = fs::read_dir(dir.path())
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.file_name().to_string_lossy().into_owned())
|
||||
.filter(|name| name != "state.json")
|
||||
.collect();
|
||||
assert!(strays.is_empty(), "left behind: {strays:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_parents_are_created() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("a").join("b").join("c.json");
|
||||
replace(&path, b"{}").unwrap();
|
||||
assert_eq!(fs::read(&path).unwrap(), b"{}");
|
||||
}
|
||||
|
||||
/// The staging name has to survive a real extension, or `main.rs` and `main.md` stage to the
|
||||
/// same file and the last writer wins a race nobody knew they were in.
|
||||
#[test]
|
||||
fn two_files_sharing_a_stem_do_not_share_a_staging_name() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let rust = staging_path(&dir.path().join("main.rs"));
|
||||
let markdown = staging_path(&dir.path().join("main.md"));
|
||||
assert_ne!(rust, markdown);
|
||||
assert_eq!(rust.parent(), Some(dir.path()), "staging stays on the target's filesystem");
|
||||
}
|
||||
|
||||
/// Two writers of the *same* file must not collide on the staging name either — one would
|
||||
/// truncate the other's half-written bytes and then rename them into place.
|
||||
#[test]
|
||||
fn concurrent_writers_of_one_file_get_distinct_staging_names() {
|
||||
let path = Path::new("/tmp/luxe/thing.json");
|
||||
assert_ne!(staging_path(path), staging_path(path));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_private_replacement_is_owner_only_from_the_moment_it_exists() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("auth.json");
|
||||
replace_private(&path, b"secret").unwrap();
|
||||
assert_eq!(fs::metadata(&path).unwrap().permissions().mode() & 0o777, 0o600);
|
||||
|
||||
let nested = dir.path().join("private");
|
||||
create_private_dir(&nested).unwrap();
|
||||
assert_eq!(fs::metadata(&nested).unwrap().permissions().mode() & 0o777, 0o700);
|
||||
}
|
||||
|
||||
/// A failed write must not leave a stray staging file, and must not damage what was there.
|
||||
#[test]
|
||||
fn a_failure_leaves_the_previous_contents_alone() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("kept.json");
|
||||
replace(&path, b"original").unwrap();
|
||||
|
||||
// A directory in the target's place: the rename cannot succeed.
|
||||
let blocked = dir.path().join("blocked.json");
|
||||
fs::create_dir(&blocked).unwrap();
|
||||
assert!(replace(&blocked, b"nope").is_err());
|
||||
|
||||
assert_eq!(fs::read(&path).unwrap(), b"original");
|
||||
let strays: Vec<_> = fs::read_dir(dir.path())
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.file_name().to_string_lossy().into_owned())
|
||||
.filter(|name| name.ends_with(".tmp"))
|
||||
.collect();
|
||||
assert!(strays.is_empty(), "left behind: {strays:?}");
|
||||
}
|
||||
}
|
||||
mod tests;
|
||||
|
||||
167
crates/luxe-core/src/fs_atomic/tests.rs
Normal file
167
crates/luxe-core/src/fs_atomic/tests.rs
Normal file
@@ -0,0 +1,167 @@
|
||||
use super::*;
|
||||
|
||||
#[cfg(unix)]
|
||||
fn mode_of(path: &Path) -> u32 {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
fs::metadata(path).unwrap().permissions().mode() & 0o777
|
||||
}
|
||||
|
||||
/// Editing a script keeps it a script. The rename puts a new file where the old one was, so a
|
||||
/// mode not carried over is lost: every edit of an executable left it unrunnable.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_replace_keeping_mode_leaves_a_script_executable() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let script = dir.path().join("run.sh");
|
||||
fs::write(&script, b"#!/bin/sh\n").unwrap();
|
||||
fs::set_permissions(&script, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
replace_keeping_mode(&script, b"#!/bin/sh\necho hi\n").unwrap();
|
||||
assert_eq!(mode_of(&script), 0o755);
|
||||
assert_eq!(fs::read(&script).unwrap(), b"#!/bin/sh\necho hi\n");
|
||||
}
|
||||
|
||||
/// The mode kept is the mode the file had, bit for bit, not one the umask trimmed on the way.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_kept_mode_is_exact_whatever_the_umask() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let shared = dir.path().join("shared");
|
||||
fs::write(&shared, b"a").unwrap();
|
||||
// World-writable on purpose: any umask that is not 000 strips at least one of these bits
|
||||
fs::set_permissions(&shared, fs::Permissions::from_mode(0o777)).unwrap();
|
||||
replace_keeping_mode(&shared, b"b").unwrap();
|
||||
assert_eq!(mode_of(&shared), 0o777);
|
||||
}
|
||||
|
||||
/// A file that did not exist gets the mode any new file would, not the owner-only one secrets get.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_new_file_kept_mode_gets_the_ordinary_default() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let ordinary = dir.path().join("ordinary");
|
||||
File::create(&ordinary).unwrap();
|
||||
let fresh = dir.path().join("fresh");
|
||||
replace_keeping_mode(&fresh, b"new").unwrap();
|
||||
assert_eq!(mode_of(&fresh), mode_of(&ordinary));
|
||||
}
|
||||
|
||||
/// An unsynced replace still lands whole and leaves no staging file behind.
|
||||
#[test]
|
||||
fn an_unsynced_replace_lands_whole_and_leaves_nothing_behind() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let target = dir.path().join("cache").join("shard.json");
|
||||
replace_unsynced(&target, b"first").unwrap();
|
||||
replace_unsynced(&target, b"second").unwrap();
|
||||
assert_eq!(fs::read(&target).unwrap(), b"second");
|
||||
let left: Vec<_> = fs::read_dir(target.parent().unwrap()).unwrap().flatten().collect();
|
||||
assert_eq!(left.len(), 1, "only the shard: {left:?}");
|
||||
}
|
||||
|
||||
/// Every directory `create_private_dir` makes is owner-only, not just the last one; one that was
|
||||
/// already there keeps its mode.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn every_directory_created_is_private() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mode = |path: &Path| fs::metadata(path).unwrap().permissions().mode() & 0o777;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
fs::set_permissions(dir.path(), fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let leaf = dir.path().join("a").join("b").join("c");
|
||||
create_private_dir(&leaf).unwrap();
|
||||
for created in [dir.path().join("a"), dir.path().join("a/b"), leaf] {
|
||||
assert_eq!(mode(&created), 0o700, "{}", created.display());
|
||||
}
|
||||
assert_eq!(mode(dir.path()), 0o755, "an existing parent is left alone");
|
||||
}
|
||||
|
||||
/// A fresh private directory refuses to adopt one that exists.
|
||||
#[test]
|
||||
fn a_new_private_directory_is_never_an_existing_one() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let fresh = dir.path().join("fresh");
|
||||
create_private_dir_new(&fresh).unwrap();
|
||||
let error = create_private_dir_new(&fresh).unwrap_err();
|
||||
assert_eq!(error.kind(), io::ErrorKind::AlreadyExists);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_replacement_lands_and_leaves_no_staging_file_behind() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("state.json");
|
||||
replace(&path, b"first").unwrap();
|
||||
replace(&path, b"second").unwrap();
|
||||
|
||||
assert_eq!(fs::read(&path).unwrap(), b"second");
|
||||
let strays: Vec<_> = fs::read_dir(dir.path())
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.file_name().to_string_lossy().into_owned())
|
||||
.filter(|name| name != "state.json")
|
||||
.collect();
|
||||
assert!(strays.is_empty(), "left behind: {strays:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_parents_are_created() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("a").join("b").join("c.json");
|
||||
replace(&path, b"{}").unwrap();
|
||||
assert_eq!(fs::read(&path).unwrap(), b"{}");
|
||||
}
|
||||
|
||||
/// The staging name has to survive a real extension, or `main.rs` and `main.md` stage to the
|
||||
/// same file and the last writer wins a race nobody knew they were in.
|
||||
#[test]
|
||||
fn two_files_sharing_a_stem_do_not_share_a_staging_name() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let rust = staging_path(&dir.path().join("main.rs"));
|
||||
let markdown = staging_path(&dir.path().join("main.md"));
|
||||
assert_ne!(rust, markdown);
|
||||
assert_eq!(rust.parent(), Some(dir.path()), "staging stays on the target's filesystem");
|
||||
}
|
||||
|
||||
/// Two writers of the *same* file must not collide on the staging name either — one would
|
||||
/// truncate the other's half-written bytes and then rename them into place.
|
||||
#[test]
|
||||
fn concurrent_writers_of_one_file_get_distinct_staging_names() {
|
||||
let path = Path::new("/tmp/luxe/thing.json");
|
||||
assert_ne!(staging_path(path), staging_path(path));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_private_replacement_is_owner_only_from_the_moment_it_exists() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("auth.json");
|
||||
replace_private(&path, b"secret").unwrap();
|
||||
assert_eq!(fs::metadata(&path).unwrap().permissions().mode() & 0o777, 0o600);
|
||||
|
||||
let nested = dir.path().join("private");
|
||||
create_private_dir(&nested).unwrap();
|
||||
assert_eq!(fs::metadata(&nested).unwrap().permissions().mode() & 0o777, 0o700);
|
||||
}
|
||||
|
||||
/// A failed write must not leave a stray staging file, and must not damage what was there.
|
||||
#[test]
|
||||
fn a_failure_leaves_the_previous_contents_alone() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let path = dir.path().join("kept.json");
|
||||
replace(&path, b"original").unwrap();
|
||||
|
||||
// A directory in the target's place: the rename cannot succeed.
|
||||
let blocked = dir.path().join("blocked.json");
|
||||
fs::create_dir(&blocked).unwrap();
|
||||
assert!(replace(&blocked, b"nope").is_err());
|
||||
|
||||
assert_eq!(fs::read(&path).unwrap(), b"original");
|
||||
let strays: Vec<_> = fs::read_dir(dir.path())
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.file_name().to_string_lossy().into_owned())
|
||||
.filter(|name| name.ends_with(".tmp"))
|
||||
.collect();
|
||||
assert!(strays.is_empty(), "left behind: {strays:?}");
|
||||
}
|
||||
@@ -428,7 +428,9 @@ impl Tool for EditTool {
|
||||
let diff = crate::diff_preview::ranges_diff(&content, &preview);
|
||||
let result = apply(&content, &planned);
|
||||
|
||||
if let Err(problem) = luxe_core::fs_atomic::replace(&full_path, result.as_bytes()) {
|
||||
if let Err(problem) =
|
||||
luxe_core::fs_atomic::replace_keeping_mode(&full_path, result.as_bytes())
|
||||
{
|
||||
warn!(path = %full_path.display(), error = %problem, "failed to write edited file");
|
||||
return ToolResultData::error(format!(
|
||||
"Error writing file '{}': {problem}",
|
||||
|
||||
@@ -78,6 +78,23 @@ async fn a_reformatted_edit_shows_the_file_as_it_is_now() {
|
||||
assert!(text.contains("+1 fn b() {}"), "{text}");
|
||||
}
|
||||
|
||||
/// An edited script stays executable. Saving by rename replaced the file with a new one at the
|
||||
/// default mode, so every edit of a script left it unrunnable.
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn an_edited_script_stays_executable() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let script = dir.path().join("run.sh");
|
||||
std::fs::write(&script, "#!/bin/sh\necho one\n").unwrap();
|
||||
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let args = json!({"path": "run.sh", "edits": [{"oldText": "one", "newText": "two"}]});
|
||||
let result = EditTool::new().run(args, &test_context(dir.path())).await;
|
||||
assert!(!result.is_error, "{:?}", result.content);
|
||||
let mode = std::fs::metadata(&script).unwrap().permissions().mode() & 0o777;
|
||||
assert_eq!(mode, 0o755, "still executable after the edit");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn edit_tool_basic() {
|
||||
let tmp_dir_guard = tempfile::tempdir().expect("temp dir");
|
||||
|
||||
@@ -182,7 +182,7 @@ impl Tool for WriteTool {
|
||||
Err(_) => std::borrow::Cow::Borrowed(content),
|
||||
};
|
||||
|
||||
match luxe_core::fs_atomic::replace(&full_path, content.as_bytes()) {
|
||||
match luxe_core::fs_atomic::replace_keeping_mode(&full_path, content.as_bytes()) {
|
||||
Ok(()) => {
|
||||
debug!(path = %full_path.display(), "file written successfully");
|
||||
self.after_write(cx, &full_path, &content, existed).await
|
||||
|
||||
@@ -30,6 +30,22 @@ async fn a_reformatted_write_shows_the_file_as_it_is_now() {
|
||||
assert!(text.contains("+1 fn sub(a: i32) {}") && !text.contains("a:i32"), "{text}");
|
||||
}
|
||||
|
||||
/// Overwriting a script keeps it executable, as an editor's save does.
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn an_overwritten_script_stays_executable() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let script = dir.path().join("run.sh");
|
||||
std::fs::write(&script, "#!/bin/sh\n").unwrap();
|
||||
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let args = serde_json::json!({"path": "run.sh", "content": "#!/bin/sh\necho hi\n"});
|
||||
let result = WriteTool::new().run(args, &test_context(dir.path())).await;
|
||||
assert!(!result.is_error, "{:?}", result.content);
|
||||
let mode = std::fs::metadata(&script).unwrap().permissions().mode() & 0o777;
|
||||
assert_eq!(mode, 0o755, "still executable after the write");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn write_tool_basic() {
|
||||
let tmp_dir_guard = tempfile::tempdir().expect("temp dir");
|
||||
|
||||
@@ -11,14 +11,12 @@ On macOS and Linux, the install script puts `luxe` in `~/.local/bin`, or in `$LU
|
||||
when it is set, and adds that to your `PATH`:
|
||||
|
||||
```bash
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh | sh
|
||||
curl -fsSL https://luxe.dev/install.sh | sh
|
||||
```
|
||||
|
||||
On Windows, in PowerShell:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -c "irm https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1 | iex"
|
||||
```
|
||||
That address redirects to the script on the [latest
|
||||
release](https://github.com/evanwhittaker/luxe/releases/latest), the one it built and attested. To
|
||||
read it before running it, drop the `| sh`.
|
||||
|
||||
With Homebrew, on macOS or Linux:
|
||||
|
||||
@@ -33,6 +31,16 @@ one):
|
||||
cargo install --locked luxe-cli
|
||||
```
|
||||
|
||||
On Windows, in PowerShell:
|
||||
|
||||
```powershell
|
||||
powershell -c "irm https://luxe.dev/install.ps1 | iex"
|
||||
```
|
||||
|
||||
[That script](https://luxe.dev/install.ps1) is two lines: it lets this PowerShell window run the
|
||||
release's installer, which Windows' default execution policy would stop, then runs it. Nothing
|
||||
about your policy is saved.
|
||||
|
||||
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
|
||||
|
||||
54
scripts/aur-pkgbuild.sh
Executable file
54
scripts/aur-pkgbuild.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# aur-pkgbuild — writes the PKGBUILD for the `luxe-bin` AUR package from a release.
|
||||
#
|
||||
# Usage: scripts/aur-pkgbuild.sh <version> [out-dir] e.g. scripts/aur-pkgbuild.sh 0.1.0 /tmp/aur
|
||||
#
|
||||
# `luxe-bin` repackages the release's own Linux archives, checked against the release's `.sha256`
|
||||
# files, so it ships exactly what the release built and attested. It installs to /usr/bin, which
|
||||
# `luxe update` reads as a package manager's copy and leaves to pacman. The updater the install
|
||||
# script adds is left out for the same reason. Generate .SRCINFO from the result with
|
||||
# `makepkg --printsrcinfo > .SRCINFO`.
|
||||
set -euo pipefail
|
||||
|
||||
version="${1:?usage: aur-pkgbuild.sh <version> [out-dir]}"
|
||||
out="${2:-.}"
|
||||
release="https://github.com/evanwhittaker/luxe/releases/download/v${version}"
|
||||
|
||||
# The release's own checksum for one target's archive
|
||||
checksum() {
|
||||
curl -fsSL "${release}/luxe-cli-$1-unknown-linux-gnu.tar.xz.sha256" | cut -d' ' -f1
|
||||
}
|
||||
x86_64="$(checksum x86_64)"
|
||||
aarch64="$(checksum aarch64)"
|
||||
|
||||
mkdir -p "${out}"
|
||||
cat >"${out}/PKGBUILD" <<PKGBUILD
|
||||
# Maintainer: Evan Whittaker <contact@luxe.dev>
|
||||
# Generated by scripts/aur-pkgbuild.sh in https://github.com/evanwhittaker/luxe
|
||||
|
||||
pkgname=luxe-bin
|
||||
pkgver=${version}
|
||||
pkgrel=1
|
||||
pkgdesc="A terminal coding agent: streaming chat, tools, guided diff review, and LSP/DAP code intelligence"
|
||||
arch=('x86_64' 'aarch64')
|
||||
url="https://luxe.dev"
|
||||
license=('MIT' 'Apache-2.0')
|
||||
depends=('gcc-libs' 'glibc')
|
||||
provides=('luxe')
|
||||
conflicts=('luxe')
|
||||
# The release's binary as it was built and attested: not stripped again, no debug split
|
||||
options=('!strip' '!debug')
|
||||
source_x86_64=("luxe-cli-x86_64-\${pkgver}.tar.xz::https://github.com/evanwhittaker/luxe/releases/download/v\${pkgver}/luxe-cli-x86_64-unknown-linux-gnu.tar.xz")
|
||||
source_aarch64=("luxe-cli-aarch64-\${pkgver}.tar.xz::https://github.com/evanwhittaker/luxe/releases/download/v\${pkgver}/luxe-cli-aarch64-unknown-linux-gnu.tar.xz")
|
||||
sha256sums_x86_64=('${x86_64}')
|
||||
sha256sums_aarch64=('${aarch64}')
|
||||
|
||||
package() {
|
||||
cd "luxe-cli-\${CARCH}-unknown-linux-gnu"
|
||||
install -Dm755 luxe "\${pkgdir}/usr/bin/luxe"
|
||||
install -Dm644 LICENSE-MIT "\${pkgdir}/usr/share/licenses/\${pkgname}/LICENSE-MIT"
|
||||
install -Dm644 LICENSE-APACHE "\${pkgdir}/usr/share/licenses/\${pkgname}/LICENSE-APACHE"
|
||||
install -Dm644 README.md "\${pkgdir}/usr/share/doc/\${pkgname}/README.md"
|
||||
}
|
||||
PKGBUILD
|
||||
echo "wrote ${out}/PKGBUILD for luxe-bin ${version}"
|
||||
@@ -24,6 +24,10 @@
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Access-Control-Allow-Origin: *
|
||||
|
||||
# Text, so `irm` hands `iex` a script rather than bytes
|
||||
/install.ps1
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
|
||||
/*
|
||||
Cache-Control: public, max-age=0, must-revalidate
|
||||
X-Content-Type-Options: nosniff
|
||||
|
||||
@@ -3,3 +3,9 @@
|
||||
# The themes page folded into the homepage's gallery; a link to it lands on the gallery.
|
||||
/themes /#craft 301
|
||||
/themes/ /#craft 301
|
||||
|
||||
# The install script, at an address short enough to read: `curl -fsSL https://luxe.dev/install.sh | sh`.
|
||||
# It redirects to the latest release's own script, so luxe.dev never holds a copy that could drift
|
||||
# from what the release built and attested. 302, not 301: "latest" moves, so nothing may cache it.
|
||||
# /install.ps1 is a file instead (public/install.ps1): Windows needs a line run before the installer.
|
||||
/install.sh https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.sh 302
|
||||
|
||||
14
web/public/install.ps1
Normal file
14
web/public/install.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
# Luxe's installer for Windows:
|
||||
#
|
||||
# powershell -c "irm https://luxe.dev/install.ps1 | iex"
|
||||
#
|
||||
# The installer each release ships refuses to run under Windows' default execution policy, which is
|
||||
# why its own instructions pass `-ExecutionPolicy ByPass`. This does the same for this PowerShell
|
||||
# process alone, with nothing saved and no admin needed, then runs the latest release's installer,
|
||||
# so the address never holds an installer that could drift from what the release built.
|
||||
#
|
||||
# A policy set by Group Policy outranks the process scope, as it outranks the command-line flag.
|
||||
# Setting it then fails, and that is let pass: where the enforced policy allows the installer it runs
|
||||
# anyway, and where it does not, the installer's own check says so and how to fix it.
|
||||
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force -ErrorAction SilentlyContinue
|
||||
Invoke-RestMethod 'https://github.com/evanwhittaker/luxe/releases/latest/download/luxe-cli-installer.ps1' | Invoke-Expression
|
||||
@@ -3,20 +3,13 @@
|
||||
|
||||
type Channel = { id: string; label: string; command: string; note?: string };
|
||||
|
||||
const releases = "https://github.com/evanwhittaker/luxe/releases/latest/download";
|
||||
// Most likely reader first. install.sh redirects to the latest release's script and install.ps1
|
||||
// runs it (web/public/_redirects, web/public/install.ps1)
|
||||
const channels: Channel[] = [
|
||||
{
|
||||
id: "shell",
|
||||
label: "shell",
|
||||
command: `curl --proto '=https' --tlsv1.2 -LsSf ${releases}/luxe-cli-installer.sh | sh`,
|
||||
},
|
||||
{ id: "shell", label: "shell", command: "curl -fsSL https://luxe.dev/install.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" },
|
||||
{ id: "windows", label: "windows", command: 'powershell -c "irm https://luxe.dev/install.ps1 | iex"' },
|
||||
];
|
||||
|
||||
let active = $state(channels[0]);
|
||||
|
||||
@@ -269,20 +269,20 @@ type CostRow = { model: string; luxe: { passed: number; runs: number } } & Parti
|
||||
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}%`;
|
||||
/** Each model's bars: Luxe at 1×, then every agent that ran it. A vendor's agent runs only its own
|
||||
* vendor's models, so a model has Claude Code's bar or Codex's, never both. */
|
||||
const chartBars = (row: CostRow) =>
|
||||
[
|
||||
{ kind: "vendor", other: vendorAgent(row) },
|
||||
{ kind: "opencode", other: row.opencode },
|
||||
].flatMap(({ kind, other }) => (other ? [{ kind, cold: other.cold }] : []));
|
||||
{ kind: "luxe", label: "Luxe", cold: 1 },
|
||||
{ kind: "claude", label: "Claude Code", cold: row.claude?.cold },
|
||||
{ kind: "codex", label: "Codex", cold: row.codex?.cold },
|
||||
{ kind: "opencode", label: "OpenCode", cold: row.opencode?.cold },
|
||||
].flatMap((bar) => (bar.cold === undefined ? [] : [{ ...bar, cold: bar.cold }]));
|
||||
/** The chart's scale: the costliest multiple, rounded up to a half. */
|
||||
const chartScale = Math.ceil(Math.max(...costRows.flatMap(chartBars).map((bar) => bar.cold)) * 2) / 2;
|
||||
const chartWidth = (multiple: number) => `${(multiple / chartScale) * 100}%`;
|
||||
|
||||
/** 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)}%`;
|
||||
@@ -361,11 +361,15 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
</p>
|
||||
</div>
|
||||
<div class="split split--tasks">
|
||||
{/* The table and its note are one column, so the note sits under what it qualifies rather
|
||||
than below whichever of table and chart runs longer */}
|
||||
<div class="tasks__data">
|
||||
<table class="costs">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Model</th>
|
||||
<th scope="col">Claude Code or Codex</th>
|
||||
<th scope="col">Claude Code</th>
|
||||
<th scope="col">Codex</th>
|
||||
<th scope="col">OpenCode</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -376,26 +380,33 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
<th scope="row">
|
||||
<code>{row.model}</code>
|
||||
</th>
|
||||
<td>{multiple(vendorAgent(row))}</td>
|
||||
<td>{multiple(row.claude)}</td>
|
||||
<td>{multiple(row.codex)}</td>
|
||||
<td>{multiple(row.opencode)}</td>
|
||||
</tr>
|
||||
))
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="muted note tasks__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. Claude Code runs only Claude models and Codex only OpenAI's, hence the dashes.
|
||||
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>
|
||||
{/* 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>
|
||||
<figure class="chart" aria-hidden="true">
|
||||
<figcaption class="chart__caption">Cost of a whole task · lower is better</figcaption>
|
||||
{
|
||||
costRows.map((row) => (
|
||||
<div class="chart__group">
|
||||
<code class="chart__model">{row.model}</code>
|
||||
{chartBars(row).map(({ kind, cold }) => (
|
||||
{chartBars(row).map(({ kind, label, cold }) => (
|
||||
<div class={`chart__row chart__row--${kind}`}>
|
||||
<span class="chart__agent">{label}</span>
|
||||
<span class="chart__track">
|
||||
<span class="chart__bar" style={`width: ${chartWidth(cold)}`} />
|
||||
</span>
|
||||
@@ -407,14 +418,6 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
}
|
||||
</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. 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>
|
||||
</section>
|
||||
|
||||
{
|
||||
@@ -567,6 +570,18 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Four columns fit a phone only with less air between them */
|
||||
@media (max-width: 40rem) {
|
||||
.costs {
|
||||
font-size: var(--step--1);
|
||||
}
|
||||
|
||||
.costs th,
|
||||
.costs td {
|
||||
padding: var(--space-2);
|
||||
}
|
||||
}
|
||||
|
||||
.group__name {
|
||||
font-size: var(--step-2);
|
||||
margin-bottom: var(--space-5);
|
||||
@@ -622,6 +637,13 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
|
||||
.split--tasks .costs {
|
||||
margin-top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* As wide as the table it qualifies, and no wider than a line should be */
|
||||
.tasks__note {
|
||||
max-width: var(--measure);
|
||||
margin: var(--space-4) 0 0;
|
||||
}
|
||||
|
||||
/* === The head's terminal === */
|
||||
@@ -647,12 +669,22 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
gap: 0.4em;
|
||||
}
|
||||
|
||||
/* macOS's window controls, in its own colors: close, minimize, zoom. Literal rather than theme
|
||||
tokens, since they draw a Mac window rather than Luxe */
|
||||
.terminal__dots i {
|
||||
display: inline-block;
|
||||
width: 0.6em;
|
||||
height: 0.6em;
|
||||
width: 0.7em;
|
||||
height: 0.7em;
|
||||
border-radius: 50%;
|
||||
background: var(--luxe-dim);
|
||||
background: #ff5f57;
|
||||
}
|
||||
|
||||
.terminal__dots i:nth-child(2) {
|
||||
background: #febc2e;
|
||||
}
|
||||
|
||||
.terminal__dots i:nth-child(3) {
|
||||
background: #28c840;
|
||||
}
|
||||
|
||||
.terminal__body {
|
||||
@@ -706,36 +738,10 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
font-size: var(--step--1);
|
||||
}
|
||||
|
||||
.chart__legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2) var(--space-4);
|
||||
.chart__caption {
|
||||
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;
|
||||
@@ -745,36 +751,42 @@ const share = (shell: number, tool: number) => `${Math.max((tool / shell) * 100,
|
||||
color: var(--luxe-accent);
|
||||
}
|
||||
|
||||
/* Each bar says whose it is, so no legend is needed to read it */
|
||||
.chart__row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 4rem;
|
||||
grid-template-columns: 7.5rem minmax(0, 1fr) 4rem;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.chart__agent {
|
||||
color: var(--luxe-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.chart__row--luxe .chart__agent,
|
||||
.chart__row--luxe .chart__value {
|
||||
color: var(--luxe-accent);
|
||||
}
|
||||
|
||||
.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 {
|
||||
.chart__row--luxe .chart__bar {
|
||||
background: var(--luxe-accent);
|
||||
}
|
||||
|
||||
/* A vendor's own agent; Claude Code and Codex never share a model, so they share a shade */
|
||||
.chart__row--claude .chart__bar,
|
||||
.chart__row--codex .chart__bar {
|
||||
background: var(--luxe-dim);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user