-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
133 lines (108 loc) · 3.88 KB
/
install.ps1
File metadata and controls
133 lines (108 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#Requires -Version 5.1
<#
.SYNOPSIS
Install the ReFrame game configuration optimisation agent for GitHub Copilot.
.DESCRIPTION
Downloads and installs reframe.agent.md into the VS Code user prompts folder
(user-level install, default) or into .github/agents/ (repo-level install).
.PARAMETER Target
Installation target. 'user' (default) or 'repo'.
.PARAMETER Ref
Git ref (tag, branch, or commit SHA) to install from. Defaults to 'main'.
Pin to a release tag for reproducible installs: -Ref v1.0.0
.PARAMETER DryRun
Show what would happen without writing any files.
.PARAMETER Uninstall
Remove the installed ReFrame agent file.
.EXAMPLE
irm https://raw.githubusercontent.com/CTOUT/ReFrame/main/install.ps1 | iex
.EXAMPLE
# Recommended — repo-level install with full knowledge base:
git clone https://github.com/CTOUT/ReFrame.git; cd ReFrame; .\install.ps1 -Target repo
.EXAMPLE
.\install.ps1 -Target repo -Ref v1.0.0
.EXAMPLE
.\install.ps1 -DryRun
#>
[CmdletBinding(SupportsShouldProcess)]
param(
[ValidateSet('user', 'repo')]
[string]$Target = 'user',
[ValidatePattern('^[a-zA-Z0-9._/-]+$')]
[string]$Ref = 'main',
[switch]$DryRun,
[switch]$Uninstall
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Guard against path traversal in the Ref parameter — '..' could redirect the
# download to an arbitrary GitHub repository path.
if ($Ref -match '\.\.') {
throw "Invalid -Ref value '$Ref': must not contain '..'"
}
# Enforce TLS 1.2 / 1.3 for older PowerShell versions
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13
# --- Paths ---
$agentFileName = 'reframe.agent.md'
$rawBase = "https://raw.githubusercontent.com/CTOUT/ReFrame/$Ref/.github/agents"
$userPromptsPath = switch ($true) {
($IsLinux) { "$HOME/.config/Code/User/prompts" }
($IsMacOS) { "$HOME/Library/Application Support/Code/User/prompts" }
default { "$env:APPDATA\Code\User\prompts" }
}
$installPath = if ($Target -eq 'repo') {
Join-Path (Get-Location) '.github\agents'
}
else {
$userPromptsPath
}
$destFile = Join-Path $installPath $agentFileName
# --- Uninstall ---
if ($Uninstall) {
if (Test-Path $destFile) {
if ($DryRun) {
Write-Host "[DryRun] Would remove: $destFile"
}
else {
Remove-Item $destFile -Force
Write-Host "Removed: $destFile"
}
}
else {
Write-Host "Not installed at: $destFile"
}
return
}
# --- Download ---
$sourceUrl = "$rawBase/$agentFileName"
Write-Host "ReFrame installer"
Write-Host " Source : $sourceUrl"
Write-Host " Target : $destFile"
if ($DryRun) {
Write-Host "[DryRun] No files written."
return
}
if (-not (Test-Path $installPath)) {
New-Item -ItemType Directory -Path $installPath -Force | Out-Null
}
# Download to a private temp directory
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
$tempFile = Join-Path $tempDir $agentFileName
try {
Invoke-WebRequest -Uri $sourceUrl -OutFile $tempFile -UseBasicParsing -TimeoutSec 30
Copy-Item -Path $tempFile -Destination $destFile -Force
Write-Host "Installed: $destFile"
Write-Host ""
if ($Target -eq 'user') {
Write-Host "Note: user-level installs do not include the knowledge base."
Write-Host " Game-specific profiles and per-engine JSON defaults are unavailable."
Write-Host " The agent will use embedded engine defaults and web lookups."
Write-Host " For full knowledge base coverage, clone the repo and use -Target repo."
Write-Host ""
}
Write-Host "Restart VS Code (or run 'Developer: Reload Window') to load the agent."
}
finally {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}