madDegen commited on
Commit
7f08a73
·
verified ·
1 Parent(s): 61cc7e2

add one-line installer

Browse files
Files changed (1) hide show
  1. install-github-ops.ps1 +135 -0
install-github-ops.ps1 ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Requires -Version 5.1
2
+ <#
3
+ Installs the github-ops plugin into %USERPROFILE%\.claude\plugins\github-ops
4
+ by downloading each file from a public Hugging Face dataset repo.
5
+
6
+ Run:
7
+ iwr https://huggingface.co/datasets/madDegen/github-ops-plugin/resolve/main/install-github-ops.ps1 -OutFile "$env:TEMP\i.ps1"; & "$env:TEMP\i.ps1"
8
+
9
+ Add -SetPat to be prompted for your GitHub PAT and store it as a user
10
+ environment variable in the same pass.
11
+ #>
12
+ [CmdletBinding()]
13
+ param(
14
+ [switch]$SetPat,
15
+ [string]$Base = 'https://huggingface.co/datasets/madDegen/github-ops-plugin/resolve/main/plugin'
16
+ )
17
+
18
+ Set-StrictMode -Version Latest
19
+ $ErrorActionPreference = 'Stop'
20
+ try {
21
+ [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
22
+ } catch { }
23
+
24
+ # path, expected byte count (verified at build time)
25
+ $files = @(
26
+ @{ p = '.mcp.json'; n = 388 },
27
+ @{ p = '.claude-plugin/plugin.json'; n = 503 },
28
+ @{ p = 'skills/github-repo-ops/SKILL.md'; n = 5978 },
29
+ @{ p = 'skills/github-pr-review/SKILL.md'; n = 4238 },
30
+ @{ p = 'skills/github-release-notes/SKILL.md'; n = 3376 },
31
+ @{ p = 'skills/github-issue-to-branch/SKILL.md'; n = 3710 },
32
+ @{ p = 'skills/github-org-audit/SKILL.md'; n = 4001 }
33
+ )
34
+
35
+ function Join-Segments {
36
+ param([string]$Base, [string[]]$Segments)
37
+ $p = $Base
38
+ foreach ($s in $Segments) { if ($s) { $p = Join-Path $p $s } }
39
+ return $p
40
+ }
41
+
42
+ $root = Join-Segments $env:USERPROFILE @('.claude', 'plugins', 'github-ops')
43
+ Write-Host ''
44
+ Write-Host "Installing github-ops -> $root" -ForegroundColor White
45
+ Write-Host ''
46
+
47
+ $ok = 0
48
+ $warn = 0
49
+ foreach ($f in $files) {
50
+ $dest = Join-Segments $root ($f.p -split '/')
51
+ $dir = Split-Path $dest -Parent
52
+ if (-not (Test-Path -LiteralPath $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null }
53
+
54
+ $url = "$Base/$($f.p)"
55
+ try {
56
+ Invoke-WebRequest -Uri $url -OutFile $dest -UseBasicParsing
57
+ } catch {
58
+ Write-Host " FAIL $($f.p) - $($_.Exception.Message)" -ForegroundColor Red
59
+ continue
60
+ }
61
+
62
+ $got = (Get-Item -LiteralPath $dest -Force).Length
63
+ if ($got -eq $f.n) {
64
+ Write-Host (" OK {0,-42} {1,5} bytes" -f $f.p, $got) -ForegroundColor Green
65
+ $ok++
66
+ } else {
67
+ Write-Host (" WARN {0,-42} {1,5} bytes (expected {2})" -f $f.p, $got, $f.n) -ForegroundColor Yellow
68
+ $warn++
69
+ }
70
+ }
71
+
72
+ Write-Host ''
73
+ if ($ok -ne $files.Count) {
74
+ Write-Host "Downloaded $ok of $($files.Count) files. Re-run before using the plugin." -ForegroundColor Yellow
75
+ } else {
76
+ Write-Host "All $ok files present and byte-exact." -ForegroundColor Green
77
+ }
78
+
79
+ # Both JSON files must parse or the plugin will not load.
80
+ foreach ($j in @('.mcp.json', '.claude-plugin/plugin.json')) {
81
+ $jp = Join-Segments $root ($j -split '/')
82
+ try {
83
+ $null = Get-Content -LiteralPath $jp -Raw | ConvertFrom-Json
84
+ Write-Host " OK $j parses as valid JSON" -ForegroundColor Green
85
+ } catch {
86
+ Write-Host " FAIL $j is not valid JSON" -ForegroundColor Red
87
+ }
88
+ }
89
+
90
+ if ($SetPat) {
91
+ Write-Host ''
92
+ Write-Host 'Paste your GitHub PAT (hidden; not saved to command history).' -ForegroundColor Cyan
93
+ $sec = Read-Host -Prompt 'PAT' -AsSecureString
94
+ $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec)
95
+ try { $tok = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) }
96
+ finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) }
97
+ $tok = $tok.Trim()
98
+
99
+ if ($tok -notmatch '^(ghp_|github_pat_)') {
100
+ Write-Warning 'That does not look like a GitHub PAT (expected ghp_ or github_pat_).'
101
+ }
102
+ [Environment]::SetEnvironmentVariable('GITHUB_OPS_PAT', $tok, 'User')
103
+ $env:GITHUB_OPS_PAT = $tok
104
+ if ([Environment]::GetEnvironmentVariable('GITHUB_OPS_PAT', 'User') -eq $tok) {
105
+ Write-Host ' OK GITHUB_OPS_PAT stored as a user environment variable.' -ForegroundColor Green
106
+ } else {
107
+ Write-Host ' FAIL Environment variable did not persist.' -ForegroundColor Red
108
+ }
109
+
110
+ try {
111
+ $h = @{ Authorization = "Bearer $tok"; 'X-GitHub-Api-Version' = '2022-11-28'; 'User-Agent' = 'github-ops-install' }
112
+ $r = Invoke-WebRequest -Uri 'https://api.github.com/user' -Headers $h -UseBasicParsing
113
+ $scopes = $r.Headers['X-OAuth-Scopes']; if ($scopes -is [array]) { $scopes = $scopes -join ', ' }
114
+ Write-Host (' OK Authenticated as ' + ($r.Content | ConvertFrom-Json).login) -ForegroundColor Green
115
+ if ($scopes) {
116
+ Write-Host " OK Scopes: $scopes" -ForegroundColor Green
117
+ foreach ($need in @('repo', 'read:org', 'workflow')) {
118
+ if ($scopes -notmatch [regex]::Escape($need)) {
119
+ Write-Host " WARN Missing scope: $need" -ForegroundColor Yellow
120
+ }
121
+ }
122
+ } else {
123
+ Write-Host ' INFO Fine-grained PAT (no scope header). Covers one owner only.' -ForegroundColor Yellow
124
+ }
125
+ } catch {
126
+ Write-Host " WARN Could not verify token: $($_.Exception.Message)" -ForegroundColor Yellow
127
+ }
128
+ $tok = $null
129
+ }
130
+
131
+ Write-Host ''
132
+ Write-Host 'NEXT Fully quit and reopen the Claude desktop app.' -ForegroundColor Cyan
133
+ Write-Host 'NEXT Turn the built-in read-only GitHub connector OFF in chats using this plugin.' -ForegroundColor Cyan
134
+ Write-Host 'THEN In a new chat: "confirm github-ops write access"' -ForegroundColor Cyan
135
+ Write-Host ''