#Requires -Version 5.1 <# .SYNOPSIS Первая загрузка Rules и запуск init-cursor в текущем проекте. .EXAMPLE git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules & $HOME\CursorRules\install.ps1 #> [CmdletBinding()] param( [switch]$SkipGitRemotes, [switch]$Update ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $rulesDest = Join-Path $HOME 'CursorRules' $httpsUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git' $sshUrl = 'ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git' function Ensure-RulesClone { if (Test-Path (Join-Path $rulesDest '.git')) { Write-Host '[*] Updating CursorRules...' -ForegroundColor Cyan git -C $rulesDest pull --ff-only return } if (Test-Path -LiteralPath $rulesDest) { $backup = "${rulesDest}.bak-$(Get-Date -Format 'yyyyMMdd-HHmmss')" Write-Host "[!] Replacing non-git folder: $rulesDest -> $backup" -ForegroundColor Yellow Move-Item -LiteralPath $rulesDest -Destination $backup } Write-Host '[*] Cloning Rules via SSH...' -ForegroundColor Cyan git clone --depth 1 $sshUrl $rulesDest 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { Write-Host '[!] SSH clone failed - trying HTTPS (enter Gitea login once)...' -ForegroundColor Yellow git clone --depth 1 $httpsUrl $rulesDest if ($LASTEXITCODE -ne 0) { throw 'git clone failed' } } Write-Host "[+] Cloned to $rulesDest" -ForegroundColor Green } Ensure-RulesClone . (Join-Path $rulesDest 'init-cursor.ps1') if ($Update) { init-cursor -Update -SkipGitRemotes:$SkipGitRemotes } elseif ($SkipGitRemotes) { init-cursor -SkipGitRemotes } else { init-cursor }