#Requires -Version 5.1 <# Installs the github-ops plugin into %USERPROFILE%\.claude\plugins\github-ops by downloading each file from a public Hugging Face dataset repo. Run: iwr https://huggingface.co/datasets/madDegen/github-ops-plugin/resolve/main/install-github-ops.ps1 -OutFile "$env:TEMP\i.ps1"; & "$env:TEMP\i.ps1" Add -SetPat to be prompted for your GitHub PAT and store it as a user environment variable in the same pass. #> [CmdletBinding()] param( [switch]$SetPat, [string]$Base = 'https://huggingface.co/datasets/madDegen/github-ops-plugin/resolve/main/plugin' ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { } # path, expected byte count (verified at build time) $files = @( @{ p = '.mcp.json'; n = 388 }, @{ p = '.claude-plugin/plugin.json'; n = 503 }, @{ p = 'skills/github-repo-ops/SKILL.md'; n = 5978 }, @{ p = 'skills/github-pr-review/SKILL.md'; n = 4238 }, @{ p = 'skills/github-release-notes/SKILL.md'; n = 3376 }, @{ p = 'skills/github-issue-to-branch/SKILL.md'; n = 3710 }, @{ p = 'skills/github-org-audit/SKILL.md'; n = 4001 } ) function Join-Segments { param([string]$Base, [string[]]$Segments) $p = $Base foreach ($s in $Segments) { if ($s) { $p = Join-Path $p $s } } return $p } $root = Join-Segments $env:USERPROFILE @('.claude', 'plugins', 'github-ops') Write-Host '' Write-Host "Installing github-ops -> $root" -ForegroundColor White Write-Host '' $ok = 0 $warn = 0 foreach ($f in $files) { $dest = Join-Segments $root ($f.p -split '/') $dir = Split-Path $dest -Parent if (-not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null } $url = "$Base/$($f.p)" try { Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing } catch { Write-Host " FAIL $($f.p) - $($_.Exception.Message)" -ForegroundColor Red continue } $got = (Get-Item -LiteralPath $dest -Force).Length if ($got -eq $f.n) { Write-Host (" OK {0,-42} {1,5} bytes" -f $f.p, $got) -ForegroundColor Green $ok++ } else { Write-Host (" WARN {0,-42} {1,5} bytes (expected {2})" -f $f.p, $got, $f.n) -ForegroundColor Yellow $warn++ } } Write-Host '' if ($ok -ne $files.Count) { Write-Host "Downloaded $ok of $($files.Count) files. Re-run before using the plugin." -ForegroundColor Yellow } else { Write-Host "All $ok files present and byte-exact." -ForegroundColor Green } # Both JSON files must parse or the plugin will not load. foreach ($j in @('.mcp.json', '.claude-plugin/plugin.json')) { $jp = Join-Segments $root ($j -split '/') try { $null = Get-Content -LiteralPath $jp -Raw | ConvertFrom-Json Write-Host " OK $j parses as valid JSON" -ForegroundColor Green } catch { Write-Host " FAIL $j is not valid JSON" -ForegroundColor Red } } if ($SetPat) { Write-Host '' Write-Host 'Paste your GitHub PAT (hidden; not saved to command history).' -ForegroundColor Cyan $sec = Read-Host -Prompt 'PAT' -AsSecureString $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec) try { $tok = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) } finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) } $tok = $tok.Trim() if ($tok -notmatch '^(ghp_|github_pat_)') { Write-Warning 'That does not look like a GitHub PAT (expected ghp_ or github_pat_).' } [Environment]::SetEnvironmentVariable('GITHUB_OPS_PAT', $tok, 'User') $env:GITHUB_OPS_PAT = $tok if ([Environment]::GetEnvironmentVariable('GITHUB_OPS_PAT', 'User') -eq $tok) { Write-Host ' OK GITHUB_OPS_PAT stored as a user environment variable.' -ForegroundColor Green } else { Write-Host ' FAIL Environment variable did not persist.' -ForegroundColor Red } try { $h = @{ Authorization = "Bearer $tok"; 'X-GitHub-Api-Version' = '2022-11-28'; 'User-Agent' = 'github-ops-install' } $r = Invoke-WebRequest -Uri 'https://api.github.com/user' -Headers $h -UseBasicParsing $scopes = $r.Headers['X-OAuth-Scopes']; if ($scopes -is [array]) { $scopes = $scopes -join ', ' } Write-Host (' OK Authenticated as ' + ($r.Content | ConvertFrom-Json).login) -ForegroundColor Green if ($scopes) { Write-Host " OK Scopes: $scopes" -ForegroundColor Green foreach ($need in @('repo', 'read:org', 'workflow')) { if ($scopes -notmatch [regex]::Escape($need)) { Write-Host " WARN Missing scope: $need" -ForegroundColor Yellow } } } else { Write-Host ' INFO Fine-grained PAT (no scope header). Covers one owner only.' -ForegroundColor Yellow } } catch { Write-Host " WARN Could not verify token: $($_.Exception.Message)" -ForegroundColor Yellow } $tok = $null } Write-Host '' Write-Host 'NEXT Fully quit and reopen the Claude desktop app.' -ForegroundColor Cyan Write-Host 'NEXT Turn the built-in read-only GitHub connector OFF in chats using this plugin.' -ForegroundColor Cyan Write-Host 'THEN In a new chat: "confirm github-ops write access"' -ForegroundColor Cyan Write-Host ''