From 1f2bb6ef7714c151a7300fd02926876fe6d4cde1 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Feb 2026 13:03:07 -0600 Subject: [PATCH] fix: installer auto-adds mosaic bin to PATH with clear status output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - install.sh: detects shell profile (zsh/bash/profile), adds PATH entry if missing - install.ps1: adds to User PATH via SetEnvironmentVariable if missing - Both are idempotent — show "already in PATH ✓" on re-run - mosaic/mosaic.ps1: accept "help" and "version" as bare subcommands Co-Authored-By: Claude Opus 4.6 --- bin/mosaic | 4 ++-- bin/mosaic.ps1 | 4 ++-- install.ps1 | 15 ++++++++++++++- install.sh | 26 +++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/bin/mosaic b/bin/mosaic index fb87524..6b6d952 100755 --- a/bin/mosaic +++ b/bin/mosaic @@ -132,8 +132,8 @@ case "$command" in doctor) run_doctor "$@" ;; sync) run_sync "$@" ;; bootstrap) run_bootstrap "$@" ;; - -h|--help) usage ;; - -v|--version) echo "mosaic $VERSION" ;; + help|-h|--help) usage ;; + version|-v|--version) echo "mosaic $VERSION" ;; *) echo "[mosaic] Unknown command: $command" >&2 echo "[mosaic] Run 'mosaic --help' for usage." >&2 diff --git a/bin/mosaic.ps1 b/bin/mosaic.ps1 index fa1cac9..5ee4ab8 100644 --- a/bin/mosaic.ps1 +++ b/bin/mosaic.ps1 @@ -108,8 +108,8 @@ switch ($command) { Write-Host "[mosaic] NOTE: mosaic-bootstrap-repo requires bash. Use Git Bash or WSL." -ForegroundColor Yellow & (Join-Path $MosaicHome "bin\mosaic-bootstrap-repo") @remaining } - { $_ -in "-h", "--help" } { Show-Usage } - { $_ -in "-v", "--version" } { Write-Host "mosaic $Version" } + { $_ -in "help", "-h", "--help" } { Show-Usage } + { $_ -in "version", "-v", "--version" } { Write-Host "mosaic $Version" } default { Write-Host "[mosaic] Unknown command: $command" -ForegroundColor Red Write-Host "[mosaic] Run 'mosaic --help' for usage." diff --git a/install.ps1 b/install.ps1 index 6a79b71..a82b11a 100644 --- a/install.ps1 +++ b/install.ps1 @@ -66,8 +66,21 @@ catch { Write-Host "[mosaic-install] WARNING: doctor reported issues (run mosaic-doctor.ps1 -FailOnWarn)" -ForegroundColor Yellow } +# Ensure mosaic bin is in User PATH persistently +$mosaicBin = Join-Path $TargetDir "bin" +$userPath = [Environment]::GetEnvironmentVariable("Path", "User") +if ($userPath -and $userPath.Split(";") -contains $mosaicBin) { + Write-Host "[mosaic-install] PATH: $mosaicBin already in User PATH ✓" +} +else { + $newPath = if ($userPath) { "$mosaicBin;$userPath" } else { $mosaicBin } + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") + $env:Path = "$mosaicBin;$env:Path" + Write-Host "[mosaic-install] PATH: Added $mosaicBin to User PATH ✓" + Write-Host "[mosaic-install] Open a new terminal for PATH changes to take effect." +} + Write-Host "[mosaic-install] Done." -Write-Host "[mosaic-install] Add to PATH: `$env:USERPROFILE\.config\mosaic\bin" $soulPath = Join-Path $TargetDir "SOUL.md" if (-not (Test-Path $soulPath)) { diff --git a/install.sh b/install.sh index 081ac3c..3a236c4 100755 --- a/install.sh +++ b/install.sh @@ -42,7 +42,31 @@ if ! "$TARGET_DIR/bin/mosaic-doctor"; then echo "[mosaic-install] WARNING: doctor reported issues (run ~/.config/mosaic/bin/mosaic-doctor --fail-on-warn)" >&2 fi -echo "[mosaic-install] Add to PATH: export PATH=\"$TARGET_DIR/bin:$PATH\"" +# Ensure ~/.config/mosaic/bin is in PATH persistently +PATH_LINE="export PATH=\"$TARGET_DIR/bin:\$PATH\"" + +# Find the right shell profile +if [[ -n "${ZSH_VERSION:-}" ]] || [[ "$(basename "${SHELL:-}")" == "zsh" ]]; then + SHELL_PROFILE="$HOME/.zshrc" +elif [[ -f "$HOME/.bashrc" ]]; then + SHELL_PROFILE="$HOME/.bashrc" +elif [[ -f "$HOME/.profile" ]]; then + SHELL_PROFILE="$HOME/.profile" +else + SHELL_PROFILE="$HOME/.profile" +fi + +if grep -qF "$TARGET_DIR/bin" "$SHELL_PROFILE" 2>/dev/null; then + echo "[mosaic-install] PATH: $TARGET_DIR/bin already in $SHELL_PROFILE ✓" +else + { + echo "" + echo "# Mosaic agent framework" + echo "$PATH_LINE" + } >> "$SHELL_PROFILE" + echo "[mosaic-install] PATH: Added $TARGET_DIR/bin to $SHELL_PROFILE ✓" + echo "[mosaic-install] Run 'source $SHELL_PROFILE' or open a new terminal to activate." +fi if [[ ! -f "$TARGET_DIR/SOUL.md" ]]; then echo ""