fix(installer): Project-level installation now works correctly with remote install

CRITICAL FIX:
- Save original directory before downloading from GitHub
- For project-level installation via curl/remote, install to original directory
- Prevents .claude/ folder from being created in temp directory and deleted
- Fixes both bash (install.sh) and PowerShell (install.ps1) installers
- Quality hooks also install to correct directory

Before: curl | bash with option 2 would install to temp dir and delete it
After: curl | bash with option 2 installs to directory where command was run

This fixes the issue where users couldn't see .claude/ after installation.
This commit is contained in:
Reza Rezvani
2025-11-12 12:19:55 +01:00
parent 5ad6a1e0a7
commit eea0f09753
2 changed files with 39 additions and 13 deletions
+19 -6
View File
@@ -43,6 +43,8 @@ Write-Host ""
# Check if running from correct directory or need to download # Check if running from correct directory or need to download
$RemoteInstall = $false $RemoteInstall = $false
$OriginalDir = Get-Location
if (-not (Test-Path "skill") -or -not (Test-Path "command") -or -not (Test-Path "agent")) { if (-not (Test-Path "skill") -or -not (Test-Path "command") -or -not (Test-Path "agent")) {
Write-Info "Installing from GitHub..." Write-Info "Installing from GitHub..."
$RemoteInstall = $true $RemoteInstall = $true
@@ -109,9 +111,15 @@ while (-not $validChoice) {
$validChoice = $true $validChoice = $true
} }
"2" { "2" {
$skillsDir = ".\.claude\skills" if ($RemoteInstall) {
$commandsDir = ".\.claude\commands" $skillsDir = Join-Path $OriginalDir ".claude\skills"
$agentsDir = ".\.claude\agents" $commandsDir = Join-Path $OriginalDir ".claude\commands"
$agentsDir = Join-Path $OriginalDir ".claude\agents"
} else {
$skillsDir = ".\.claude\skills"
$commandsDir = ".\.claude\commands"
$agentsDir = ".\.claude\agents"
}
$scope = "project-level" $scope = "project-level"
Write-Success "Installing at project-level (current project only)" Write-Success "Installing at project-level (current project only)"
$validChoice = $true $validChoice = $true
@@ -191,9 +199,14 @@ if ([string]::IsNullOrEmpty($installHooks)) { $installHooks = "N" }
if ($installHooks -match "^[Yy]$") { if ($installHooks -match "^[Yy]$") {
if ($scope -eq "project-level") { if ($scope -eq "project-level") {
Write-Info "Installing quality hooks..." Write-Info "Installing quality hooks..."
New-Item -ItemType Directory -Path ".claude\hooks" -Force | Out-Null if ($RemoteInstall) {
Copy-Item -Path "hooks\pre-commit.sh" -Destination ".claude\hooks\" -Force $hooksDir = Join-Path $OriginalDir ".claude\hooks"
Write-Success "Quality hooks installed → .claude\hooks\" } else {
$hooksDir = ".claude\hooks"
}
New-Item -ItemType Directory -Path $hooksDir -Force | Out-Null
Copy-Item -Path "hooks\pre-commit.sh" -Destination "$hooksDir\" -Force
Write-Success "Quality hooks installed → $hooksDir\"
} else { } else {
Write-Warning "Quality hooks can only be installed at project-level" Write-Warning "Quality hooks can only be installed at project-level"
Write-Info "Run installer with option 2 in your project directory" Write-Info "Run installer with option 2 in your project directory"
+20 -7
View File
@@ -43,6 +43,8 @@ echo ""
# Check if running from correct directory or need to download # Check if running from correct directory or need to download
REMOTE_INSTALL=false REMOTE_INSTALL=false
ORIGINAL_DIR=$(pwd)
if [ ! -d "skill" ] || [ ! -d "command" ] || [ ! -d "agent" ]; then if [ ! -d "skill" ] || [ ! -d "command" ] || [ ! -d "agent" ]; then
print_info "Installing from GitHub..." print_info "Installing from GitHub..."
REMOTE_INSTALL=true REMOTE_INSTALL=true
@@ -100,9 +102,15 @@ while true; do
break break
;; ;;
2) 2)
SKILLS_DIR="./.claude/skills" if [ "$REMOTE_INSTALL" = true ]; then
COMMANDS_DIR="./.claude/commands" SKILLS_DIR="$ORIGINAL_DIR/.claude/skills"
AGENTS_DIR="./.claude/agents" COMMANDS_DIR="$ORIGINAL_DIR/.claude/commands"
AGENTS_DIR="$ORIGINAL_DIR/.claude/agents"
else
SKILLS_DIR="./.claude/skills"
COMMANDS_DIR="./.claude/commands"
AGENTS_DIR="./.claude/agents"
fi
SCOPE="project-level" SCOPE="project-level"
print_success "Installing at project-level (current project only)" print_success "Installing at project-level (current project only)"
break break
@@ -174,10 +182,15 @@ install_hooks=${install_hooks:-N}
if [[ $install_hooks =~ ^[Yy]$ ]]; then if [[ $install_hooks =~ ^[Yy]$ ]]; then
if [ "$SCOPE" == "project-level" ]; then if [ "$SCOPE" == "project-level" ]; then
print_info "Installing quality hooks..." print_info "Installing quality hooks..."
mkdir -p .claude/hooks if [ "$REMOTE_INSTALL" = true ]; then
cp hooks/pre-commit.sh .claude/hooks/ HOOKS_DIR="$ORIGINAL_DIR/.claude/hooks"
chmod +x .claude/hooks/pre-commit.sh else
print_success "Quality hooks installed → .claude/hooks/" HOOKS_DIR=".claude/hooks"
fi
mkdir -p "$HOOKS_DIR"
cp hooks/pre-commit.sh "$HOOKS_DIR/"
chmod +x "$HOOKS_DIR/pre-commit.sh"
print_success "Quality hooks installed → $HOOKS_DIR/"
else else
print_warning "Quality hooks can only be installed at project-level" print_warning "Quality hooks can only be installed at project-level"
print_info "Run installer with option 2 in your project directory" print_info "Run installer with option 2 in your project directory"