From 556f1c48d0139a553ab9e2d58729114eb431bf0e Mon Sep 17 00:00:00 2001 From: George Moon Date: Sat, 4 Jul 2026 10:16:54 -0400 Subject: [PATCH 1/2] Make update notice more visible with color and version diff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: dimmed one-liner easily missed in output After: Update available: v0.2.4 → v0.2.5 Run lattice update to install Shows current → latest with color (yellow header, green new version, cyan command). Includes blank lines for visual separation. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/update.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/update.rs b/src/update.rs index 370fae0..7e495ad 100644 --- a/src/update.rs +++ b/src/update.rs @@ -374,15 +374,16 @@ fn write_check_state(path: &std::path::Path, state: &UpdateCheckState) { .and_then(|json| std::fs::write(path, json).ok()); } -fn print_update_notice(latest: &Version) { +fn print_update_notice(current: &Version, latest: &Version) { + eprintln!(); eprintln!( - "{}", - format!( - "A new version of lattice is available (v{}). Run 'lattice update' to install.", - latest - ) - .dimmed() + " {} {} → {}", + "Update available:".yellow().bold(), + format!("v{}", current).dimmed(), + format!("v{}", latest).green().bold() ); + eprintln!(" Run {} to install", "lattice update".cyan()); + eprintln!(); } /// Print a one-line update notice to stderr if a newer version is available. @@ -420,7 +421,7 @@ pub fn maybe_notify_update(command_name: Option<&str>) { if let Ok(latest) = Version::parse(&state.latest_version) && latest > current { - print_update_notice(&latest); + print_update_notice(¤t, &latest); } return; } @@ -449,7 +450,7 @@ pub fn maybe_notify_update(command_name: Option<&str>) { }, ); if latest > current { - print_update_notice(&latest); + print_update_notice(¤t, &latest); } } Err(_) => { From 0a9b04abbd8a4285ce5f5278a4a948e34fdb0bd3 Mon Sep 17 00:00:00 2001 From: George Moon Date: Sat, 4 Jul 2026 10:20:52 -0400 Subject: [PATCH 2/2] Install to ~/.local/bin by default for sudo-free updates Install script now defaults to ~/.local/bin (user-writable) when /usr/local/bin isn't writable. Ensures directory exists, prints shell-specific PATH instructions if needed. Update permission error now suggests reinstalling to ~/.local/bin instead of just recommending sudo. Co-Authored-By: Claude Opus 4.6 (1M context) --- install.sh | 37 +++++++++++++++++++++++++++++++++++-- src/main.rs | 4 +++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 6581e2d..fbecc1a 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,23 @@ #!/bin/sh # Lattice installer # Usage: curl -fsSL https://forkzero.ai/lattice/install.sh | sh +# +# Environment variables: +# INSTALL_DIR Override install location (default: ~/.local/bin) +# VERSION Install a specific version (default: latest) set -e REPO="forkzero/lattice" -INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" + +# Default to ~/.local/bin (user-writable, no sudo needed) +if [ -z "$INSTALL_DIR" ]; then + if [ -w "/usr/local/bin" ]; then + INSTALL_DIR="/usr/local/bin" + else + INSTALL_DIR="${HOME}/.local/bin" + fi +fi # Detect OS OS="$(uname -s)" @@ -65,6 +77,9 @@ fi echo "Extracting..." tar -xzf "$ARCHIVE" +# Ensure install directory exists +mkdir -p "$INSTALL_DIR" + # Install BINARY_DIR="lattice-${VERSION}-${TARGET}" if [ -w "$INSTALL_DIR" ]; then @@ -74,6 +89,23 @@ else sudo mv "${BINARY_DIR}/lattice" "$INSTALL_DIR/" fi +# Check if install dir is in PATH +case ":$PATH:" in + *":${INSTALL_DIR}:"*) ;; + *) + echo "" + echo "Add ${INSTALL_DIR} to your PATH:" + SHELL_NAME="$(basename "$SHELL")" + case "$SHELL_NAME" in + zsh) echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.zshrc && source ~/.zshrc" ;; + bash) echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.bashrc && source ~/.bashrc" ;; + fish) echo " fish_add_path ${INSTALL_DIR}" ;; + *) echo " export PATH=\"${INSTALL_DIR}:\$PATH\"" ;; + esac + echo "" + ;; +esac + # Verify if command -v lattice > /dev/null 2>&1; then echo "" @@ -82,8 +114,9 @@ if command -v lattice > /dev/null 2>&1; then echo "Get started:" echo " lattice init # Initialize a lattice" echo " lattice --help # Show all commands" + echo " lattice help concepts # Learn the domain model" else echo "" echo "Installed to ${INSTALL_DIR}/lattice" - echo "Add ${INSTALL_DIR} to your PATH if not already present." + echo "Make sure ${INSTALL_DIR} is in your PATH." fi diff --git a/src/main.rs b/src/main.rs index f440fbd..6a54c13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4445,7 +4445,9 @@ fn run_command(command: Commands) { ( format!("Permission denied — cannot write to {}", exe), if cfg!(unix) { - Some("Run with sudo: sudo lattice update") + Some( + "Reinstall to ~/.local/bin for sudo-free updates:\n INSTALL_DIR=~/.local/bin curl -fsSL https://forkzero.ai/lattice/install.sh | sh\nOr run: sudo lattice update", + ) } else { None },