fix: installer auto-adds mosaic bin to PATH with clear status output
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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."
|
||||
|
||||
15
install.ps1
15
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)) {
|
||||
|
||||
26
install.sh
26
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 ""
|
||||
|
||||
Reference in New Issue
Block a user