#!/bin/bash
# Setup script to create cursor-agent alias for Windows Git Bash

echo "🔧 Setting up cursor-agent for Windows..."

# Create a simple wrapper script in a location that's in PATH
WRAPPER_DIR="$HOME/.local/bin"
mkdir -p "$WRAPPER_DIR"

# Create wrapper script
cat > "$WRAPPER_DIR/cursor-agent" << 'EOF'
#!/bin/bash
# Wrapper to call Windows PowerShell 'agent' command
# PowerShell needs full PATH to find agent

# Get agent path from PowerShell and use it
powershell.exe -NoProfile -Command "
    \$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User')
    \$agentCmd = Get-Command agent -ErrorAction SilentlyContinue
    if (\$agentCmd) {
        & agent $*
    } else {
        Write-Error 'agent command not found. Make sure Cursor CLI is installed.'
        exit 1
    }
"
EOF

chmod +x "$WRAPPER_DIR/cursor-agent"

# Add to PATH if not already there
if [[ ":$PATH:" != *":$WRAPPER_DIR:"* ]]; then
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
    export PATH="$HOME/.local/bin:$PATH"
    echo "✅ Added ~/.local/bin to PATH"
fi

echo "✅ cursor-agent wrapper created at: $WRAPPER_DIR/cursor-agent"
echo ""
echo "Test it with:"
echo "  cursor-agent --version"
echo ""

