Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a paired device and your own Tailscale login. - luxe join lets another program on the same machine join a running session over the RPC protocol. - An AGENTS.md in a subfolder reaches the model the first time it works there. - Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing. - A session is open in one Luxe at a time, web_search shares results across its phrasings, and a grep glob starting with ! excludes. The CHANGELOG has the full list.
This commit is contained in:
@@ -219,10 +219,15 @@ fn walk_threads() -> usize {
|
||||
///
|
||||
/// A pattern with no `/` describes a *file name* (`*.rs`); one with a `/` describes a path
|
||||
/// (`src/**/*.ts`) and is anchored so it matches at any depth. `**` crosses directory boundaries and
|
||||
/// `*` does not, which is the dialect every tool description in this repo promises.
|
||||
/// `*` does not, which is the dialect every tool description in this repo promises. A leading `!`
|
||||
/// excludes what the rest matches, as `rg -g '!target/**'` does.
|
||||
pub fn matcher(pattern: &str) -> Result<PathMatcher, globset::Error> {
|
||||
// On Windows `src\*.py` means a folder, not an escaped `*`; elsewhere a backslash stays an escape
|
||||
let pattern = &crate::paths::slashify(pattern);
|
||||
let (excludes, pattern) = match pattern.strip_prefix('!') {
|
||||
Some(rest) => (true, rest),
|
||||
None => (false, pattern.as_str()),
|
||||
};
|
||||
let spans_directories = pattern.contains('/');
|
||||
let compiled =
|
||||
if spans_directories { Glob::new(&anchor(pattern))? } else { Glob::new(pattern)? };
|
||||
@@ -231,6 +236,7 @@ pub fn matcher(pattern: &str) -> Result<PathMatcher, globset::Error> {
|
||||
// Compiled with `literal_separator` off in both cases, because `*.rs` has to match a bare
|
||||
// file name and `**/src/*.rs` needs `**` to cross separators.
|
||||
against_name_only: !spans_directories,
|
||||
excludes,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -238,11 +244,18 @@ pub fn matcher(pattern: &str) -> Result<PathMatcher, globset::Error> {
|
||||
pub struct PathMatcher {
|
||||
matcher: GlobMatcher,
|
||||
against_name_only: bool,
|
||||
/// The pattern began with `!`: a match is a path to leave out
|
||||
excludes: bool,
|
||||
}
|
||||
|
||||
impl PathMatcher {
|
||||
/// Whether `path` (project-relative) matches.
|
||||
pub fn is_match(&self, path: &Path) -> bool {
|
||||
self.glob_matches(path) != self.excludes
|
||||
}
|
||||
|
||||
/// Whether the glob itself, without a leading `!`, matches `path`.
|
||||
fn glob_matches(&self, path: &Path) -> bool {
|
||||
if self.against_name_only {
|
||||
path.file_name().is_some_and(|name| self.matcher.is_match(Path::new(name)))
|
||||
} else {
|
||||
@@ -266,145 +279,4 @@ fn anchor(pattern: &str) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// A model on Windows writes `src\*.py`, and globset read the backslash as an escape, so the
|
||||
/// pattern matched nothing.
|
||||
#[cfg(windows)]
|
||||
#[test]
|
||||
fn a_backslash_in_a_windows_glob_is_a_folder() {
|
||||
let matcher = matcher(r"src\*.py").unwrap();
|
||||
assert!(matcher.is_match(Path::new("src/a.py")));
|
||||
assert!(!matcher.is_match(Path::new("lib/a.py")));
|
||||
}
|
||||
|
||||
/// A walk that stops at its ceiling must say so, or a search over a huge tree reads as complete.
|
||||
#[test]
|
||||
fn a_walk_that_hits_its_ceiling_says_so() {
|
||||
let dir = repo();
|
||||
let walk = |limit| walk_within(dir.path(), Path::new("."), (true, None), || false, limit);
|
||||
let walked = walk(2);
|
||||
assert_eq!(walked.files.len(), 2);
|
||||
assert!(walked.capped);
|
||||
let whole = walk(100);
|
||||
assert!(!whole.capped, "{:?}", whole.files);
|
||||
}
|
||||
|
||||
/// An index walk that stops at its limit keeps the same files every time: the first by name.
|
||||
#[test]
|
||||
fn a_capped_index_walk_keeps_the_first_files_by_name() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
for index in 0..40 {
|
||||
let sub = dir.path().join(format!("d{}", index % 4));
|
||||
std::fs::create_dir_all(&sub).unwrap();
|
||||
std::fs::write(sub.join(format!("f{index:02}.rs")), "").unwrap();
|
||||
}
|
||||
std::fs::create_dir_all(dir.path().join(".hidden")).unwrap();
|
||||
std::fs::write(dir.path().join(".hidden/a.rs"), "").unwrap();
|
||||
let walk = || index_files(dir.path(), &[], |path| path.extension().is_some(), 10);
|
||||
let first = walk();
|
||||
assert!(first.capped);
|
||||
assert_eq!(first.files.len(), 10);
|
||||
assert!(first.files.iter().all(|path| path.starts_with("d0") || path.starts_with("d1")));
|
||||
assert_eq!(first.files, walk().files, "the same ten each time");
|
||||
assert!(!first.files.iter().any(|path| path.starts_with(".hidden")));
|
||||
}
|
||||
|
||||
/// A listing keeps hidden files, honors the ignore file, and never enters a skipped folder,
|
||||
/// ignored or not.
|
||||
#[test]
|
||||
fn a_listing_keeps_dotfiles_and_skips_the_named_folders() {
|
||||
let dir = repo();
|
||||
std::fs::create_dir_all(dir.path().join(".github")).unwrap();
|
||||
std::fs::write(dir.path().join(".github/ci.yml"), "").unwrap();
|
||||
std::fs::create_dir_all(dir.path().join("vendor")).unwrap();
|
||||
std::fs::write(dir.path().join("vendor/lib.rs"), "").unwrap();
|
||||
let listed = listing(dir.path(), &["vendor"]);
|
||||
assert!(!listed.capped);
|
||||
let dotfile = Path::new(".github").join("ci.yml");
|
||||
assert!(listed.files.contains(&dotfile), "{:?}", listed.files);
|
||||
assert!(listed.files.iter().all(|path| !path.starts_with("vendor")));
|
||||
assert!(listed.files.iter().all(|path| !path.starts_with("target")));
|
||||
}
|
||||
|
||||
/// A listing that stops at its limit keeps the same files every time: the first by name.
|
||||
#[test]
|
||||
fn a_capped_listing_keeps_the_first_files_by_name() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
for index in 0..40 {
|
||||
let sub = dir.path().join(format!("d{}", index % 4));
|
||||
std::fs::create_dir_all(&sub).unwrap();
|
||||
std::fs::write(sub.join(format!("f{index:02}.rs")), "").unwrap();
|
||||
}
|
||||
let first = listing_within(dir.path(), &[], 10);
|
||||
assert!(first.capped);
|
||||
assert_eq!(first.files.len(), 10);
|
||||
assert!(first.files.iter().all(|path| path.starts_with("d0")), "{:?}", first.files);
|
||||
assert_eq!(first.files, listing_within(dir.path(), &[], 10).files);
|
||||
}
|
||||
|
||||
/// A repo with one real source file and a build directory full of look-alikes.
|
||||
fn repo() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
std::fs::write(dir.path().join(".gitignore"), "target/\n").unwrap();
|
||||
std::fs::create_dir_all(dir.path().join("src").join("deep")).unwrap();
|
||||
std::fs::write(dir.path().join("src").join("main.rs"), "fn main() {}").unwrap();
|
||||
std::fs::write(dir.path().join("src").join("deep").join("nested.rs"), "").unwrap();
|
||||
std::fs::create_dir_all(dir.path().join("target").join("debug")).unwrap();
|
||||
std::fs::write(dir.path().join("target").join("debug").join("gen.rs"), "").unwrap();
|
||||
std::fs::create_dir_all(dir.path().join(".git")).unwrap();
|
||||
std::fs::write(dir.path().join(".git").join("config"), "").unwrap();
|
||||
dir
|
||||
}
|
||||
|
||||
fn names(paths: &[PathBuf]) -> Vec<String> {
|
||||
paths.iter().map(|path| crate::paths::display(path)).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_walk_honors_ignore_files_and_never_enters_dot_git() {
|
||||
let dir = repo();
|
||||
let found = names(&files(dir.path(), Path::new("."), false));
|
||||
assert!(found.contains(&"src/main.rs".to_string()), "{found:?}");
|
||||
assert!(found.contains(&"src/deep/nested.rs".to_string()), "{found:?}");
|
||||
assert!(!found.iter().any(|path| path.contains("target/")), "ignored: {found:?}");
|
||||
assert!(
|
||||
!found.iter().any(|path| path.contains(".git/")),
|
||||
"never the object store: {found:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_reaches_ignored_files_but_still_not_dot_git() {
|
||||
let dir = repo();
|
||||
let found = names(&files(dir.path(), Path::new("."), true));
|
||||
assert!(found.contains(&"target/debug/gen.rs".to_string()), "{found:?}");
|
||||
assert!(!found.iter().any(|path| path.contains(".git/")), "{found:?}");
|
||||
}
|
||||
|
||||
/// The bug the `find` fallback shipped with: `**/` means *zero or more* directories, so
|
||||
/// `src/**/*.rs` has to match `src/main.rs` — a file sitting directly under the globbed
|
||||
/// directory, which is the common case.
|
||||
#[test]
|
||||
fn a_directory_spanning_glob_matches_zero_intermediate_directories() {
|
||||
let glob = matcher("src/**/*.rs").unwrap();
|
||||
assert!(glob.is_match(Path::new("src/main.rs")), "zero directories in between");
|
||||
assert!(glob.is_match(Path::new("src/deep/nested.rs")), "and any number of them");
|
||||
assert!(glob.is_match(Path::new("crates/x/src/main.rs")), "anchored to match at any depth");
|
||||
assert!(!glob.is_match(Path::new("tests/main.rs")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bare_pattern_matches_the_file_name_at_any_depth() {
|
||||
let glob = matcher("*.rs").unwrap();
|
||||
assert!(glob.is_match(Path::new("main.rs")));
|
||||
assert!(glob.is_match(Path::new("src/deep/nested.rs")));
|
||||
assert!(!glob.is_match(Path::new("src/main.py")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_malformed_glob_is_an_error_rather_than_a_silent_no_match() {
|
||||
assert!(matcher("src/[").is_err());
|
||||
}
|
||||
}
|
||||
mod tests;
|
||||
|
||||
Reference in New Issue
Block a user