ueagentdevkit 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. ueagentdevkit-0.2.0/Association-Doctor.cmd +6 -0
  2. ueagentdevkit-0.2.0/CHANGELOG.md +8 -0
  3. ueagentdevkit-0.2.0/CONTRIBUTING.md +5 -0
  4. ueagentdevkit-0.2.0/Examples/BlankBlueprint/BlankBlueprint.uproject +5 -0
  5. ueagentdevkit-0.2.0/Examples/BlankBlueprint/profile.json +6 -0
  6. ueagentdevkit-0.2.0/External/unreal-association-doctor/LICENSE +21 -0
  7. ueagentdevkit-0.2.0/External/unreal-association-doctor/Repair-UnrealAssociation.ps1 +226 -0
  8. ueagentdevkit-0.2.0/External/unreal-association-doctor/Start-Doctor.ps1 +280 -0
  9. ueagentdevkit-0.2.0/Hooks/check_staged.py +28 -0
  10. ueagentdevkit-0.2.0/Hooks/install.py +34 -0
  11. ueagentdevkit-0.2.0/Hooks/pre-commit +2 -0
  12. ueagentdevkit-0.2.0/LICENSE +21 -0
  13. ueagentdevkit-0.2.0/MANIFEST.in +5 -0
  14. ueagentdevkit-0.2.0/Manage-Projects.cmd +7 -0
  15. ueagentdevkit-0.2.0/PKG-INFO +14 -0
  16. ueagentdevkit-0.2.0/README.md +39 -0
  17. ueagentdevkit-0.2.0/README.zh-CN.md +33 -0
  18. ueagentdevkit-0.2.0/SECURITY.md +5 -0
  19. ueagentdevkit-0.2.0/Skills/ue-automation-evidence/SKILL.md +8 -0
  20. ueagentdevkit-0.2.0/Skills/ue-project-hygiene/SKILL.md +8 -0
  21. ueagentdevkit-0.2.0/THIRD_PARTY.md +5 -0
  22. ueagentdevkit-0.2.0/Tools/Hygiene/audit.py +235 -0
  23. ueagentdevkit-0.2.0/Tools/Hygiene/cli.py +291 -0
  24. ueagentdevkit-0.2.0/Tools/Hygiene/lifecycle.py +148 -0
  25. ueagentdevkit-0.2.0/Tools/Hygiene/recovery.py +277 -0
  26. ueagentdevkit-0.2.0/Tools/Hygiene/registry_scan.py +34 -0
  27. ueagentdevkit-0.2.0/Tools/environment.py +75 -0
  28. ueagentdevkit-0.2.0/Tools/mcp_endpoint.py +40 -0
  29. ueagentdevkit-0.2.0/Tools/project_profile.py +36 -0
  30. ueagentdevkit-0.2.0/Tools/report.py +11 -0
  31. ueagentdevkit-0.2.0/pyproject.toml +39 -0
  32. ueagentdevkit-0.2.0/setup.cfg +4 -0
  33. ueagentdevkit-0.2.0/tests/test_project_profile.py +49 -0
  34. ueagentdevkit-0.2.0/tests/test_report_states.py +20 -0
  35. ueagentdevkit-0.2.0/ueagent.py +240 -0
  36. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/PKG-INFO +14 -0
  37. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/SOURCES.txt +39 -0
  38. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/dependency_links.txt +1 -0
  39. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/entry_points.txt +2 -0
  40. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/requires.txt +10 -0
  41. ueagentdevkit-0.2.0/ueagentdevkit.egg-info/top_level.txt +2 -0
@@ -0,0 +1,6 @@
1
+ @echo off
2
+ setlocal
3
+ python "%~dp0ueagent.py" association --wizard
4
+ set "result=%errorlevel%"
5
+ if not "%result%"=="0" pause
6
+ exit /b %result%
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - Added an installable `ueagent` CLI, explicit JSON project profiles and a native Automation mode independent of installed MCP providers.
6
+ - Made disk reserve and warning thresholds configurable across volumes.
7
+ - Added an explicit loopback MCP tool-list probe and a blank Blueprint Automation example.
8
+ - Kept private workflows, experimental game capture and recorded project evidence outside the reviewed release source.
@@ -0,0 +1,5 @@
1
+ # Contributing
2
+
3
+ Use a branch and keep new project examples self-contained. Run `python -m pytest -q` with pytest installed. For UE behavior changes, attach the exact engine version, project fixture, test name, editor exit code and sanitized Automation result. Lifecycle and deletion changes require a regression covering the path or approval boundary they change.
4
+
5
+ Keep game input, content and assertions in the game project. Keep fixture assets minimal and redistributable. Document the supported configuration before widening the release source scope.
@@ -0,0 +1,5 @@
1
+ {
2
+ "FileVersion": 3,
3
+ "EngineAssociation": "5.8",
4
+ "Description": "Asset-free Blueprint project for an engine Automation smoke test"
5
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "project": "BlankBlueprint.uproject",
3
+ "automation": {
4
+ "test": "System.Core.Serialization.CbField.None"
5
+ }
6
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 redtidev1918
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,226 @@
1
+ #requires -Version 5.1
2
+ [CmdletBinding()]
3
+ param(
4
+ [ValidateSet('Diagnose','Repair')][string]$Mode = 'Diagnose',
5
+ [string]$SelectorPath,
6
+ [string[]]$SearchRoot = @(),
7
+ [switch]$ForceRepair,
8
+ [switch]$LauncherReportsError,
9
+ [string]$OpenProject,
10
+ [ValidateRange(5,300)][int]$OpenTimeoutSeconds = 60,
11
+ [string]$BackupRoot = (Join-Path $env:LOCALAPPDATA 'UnrealAssociationDoctor\Backups')
12
+ )
13
+ $ErrorActionPreference = 'Stop'
14
+
15
+ function Get-RegistryDefault([string]$Path) {
16
+ if (Test-Path -LiteralPath $Path) { return (Get-Item -LiteralPath $Path).GetValue('') }
17
+ return $null
18
+ }
19
+
20
+ function Get-SelectorCandidates {
21
+ $roots = New-Object 'System.Collections.Generic.List[string]'
22
+ foreach ($root in $SearchRoot) { if ($root) { $roots.Add($root) } }
23
+ foreach ($process in @(Get-Process EpicGamesLauncher -ErrorAction SilentlyContinue)) {
24
+ if ($process.Path) { $roots.Add((Split-Path (Split-Path (Split-Path (Split-Path $process.Path))))) }
25
+ }
26
+ foreach ($view in @('Registry64','Registry32')) {
27
+ $base = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', [Microsoft.Win32.RegistryView]::$view)
28
+ try {
29
+ foreach ($name in @('SOFTWARE\EpicGames\Unreal Engine','SOFTWARE\EpicGames\EpicGamesLauncher')) {
30
+ $key = $base.OpenSubKey($name)
31
+ if ($key) {
32
+ try {
33
+ foreach ($valueName in @('INSTALLDIR','InstallLocation','AppDataPath')) {
34
+ $value = $key.GetValue($valueName)
35
+ if ($value -is [string] -and $value) { $roots.Add($value) }
36
+ }
37
+ } finally { $key.Dispose() }
38
+ }
39
+ }
40
+ } finally { $base.Dispose() }
41
+ }
42
+ $manifest = Join-Path $env:ProgramData 'Epic\UnrealEngineLauncher\LauncherInstalled.dat'
43
+ if (Test-Path -LiteralPath $manifest) {
44
+ try {
45
+ foreach ($install in (Get-Content -LiteralPath $manifest -Raw | ConvertFrom-Json).InstallationList) {
46
+ if ($install.InstallLocation) { $roots.Add($install.InstallLocation) }
47
+ }
48
+ } catch { Write-Warning "Could not parse Epic manifest: $($_.Exception.Message)" }
49
+ }
50
+ foreach ($pf in @($env:ProgramFiles, ${env:ProgramFiles(x86)})) {
51
+ if ($pf) { $roots.Add((Join-Path $pf 'Epic Games')) }
52
+ }
53
+ $found = New-Object 'System.Collections.Generic.List[string]'
54
+ $command = Get-RegistryDefault 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\open\command'
55
+ if ($command -match '^"([^"]+\.exe)"' -and (Test-Path -LiteralPath $Matches[1])) { $found.Add($Matches[1]) }
56
+ foreach ($root in ($roots | Select-Object -Unique)) {
57
+ foreach ($relative in @('UnrealVersionSelector.exe','Engine\Binaries\Win64\UnrealVersionSelector.exe','Launcher\Engine\Binaries\Win64\UnrealVersionSelector.exe','Engine\Binaries\Win64\UnrealVersionSelector-Win64-Shipping.exe')) {
58
+ $candidate = Join-Path $root $relative
59
+ if (Test-Path -LiteralPath $candidate -PathType Leaf) { $found.Add((Get-Item -LiteralPath $candidate).FullName) }
60
+ }
61
+ }
62
+ return @($found | Sort-Object -Unique)
63
+ }
64
+
65
+ function Get-AssociationState {
66
+ $command = Get-RegistryDefault 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\open\command'
67
+ $target = $null
68
+ if ($command -match '^"([^"]+\.exe)"') { $target = $Matches[1] }
69
+ $overrides = @()
70
+ foreach ($name in @('.uproject','.uplugin','Unreal.ProjectFile')) {
71
+ $path = "HKCU:\Software\Classes\$name"
72
+ if (Test-Path -LiteralPath $path) {
73
+ $preview = Get-RegistryDefault ($path + '\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}')
74
+ $overrides += [pscustomobject]@{ Name=$name; Default=(Get-RegistryDefault $path); HasChildren=(@(Get-ChildItem -LiteralPath $path).Count -gt 0); PreviewHandler=$preview; MonacoPreviewDetected=($preview -eq '{D8034CFA-F34B-41FE-AD45-62FCBB52A6DA}') }
75
+ }
76
+ }
77
+ [pscustomobject]@{
78
+ ExtensionClass = Get-RegistryDefault 'Registry::HKEY_CLASSES_ROOT\.uproject'
79
+ OpenCommand = $command
80
+ MachineOpenCommand = Get-RegistryDefault 'HKLM:\Software\Classes\Unreal.ProjectFile\shell\open\command'
81
+ TargetExists = [bool]($target -and (Test-Path -LiteralPath $target -PathType Leaf))
82
+ UserOverrides = $overrides
83
+ MonacoPreviewKeys = @($overrides | Where-Object MonacoPreviewDetected | ForEach-Object Name)
84
+ UserChoice = if (Test-Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.uproject\UserChoice') {
85
+ (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.uproject\UserChoice').ProgId
86
+ } else { $null }
87
+ # .uplugin has no HKLM class by design: the selector only registers .uproject. Informational, never a fault.
88
+ MachinePluginClassPresent = (Test-Path 'HKLM:\Software\Classes\Unreal.PluginFile')
89
+ IsElevated = (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
90
+ PreservedKeyCount = @(Get-ChildItem -LiteralPath 'HKCU:\Software\Classes' -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -like '*.AssociationDoctor-*' }).Count
91
+ LauncherRunning = [bool](Get-Process EpicGamesLauncher -ErrorAction SilentlyContinue)
92
+ PowerToysRunning = [bool](Get-Process PowerToys -ErrorAction SilentlyContinue)
93
+ }
94
+ }
95
+
96
+ function Test-AssociationConfiguration($State, [string]$ExpectedSelector) {
97
+ if ($State.ExtensionClass -ne 'Unreal.ProjectFile' -or -not $State.TargetExists) { return $false }
98
+ if ($State.UserChoice -and $State.UserChoice -ne 'Unreal.ProjectFile') { return $false }
99
+ if ($State.OpenCommand -notmatch '^"([^\"]+UnrealVersionSelector(?:-Win64-Shipping)?\.exe)"\s+/editor\s+"%1"$') { return $false }
100
+ if ($ExpectedSelector -and $Matches[1] -ne $ExpectedSelector) { return $false }
101
+ return $State.OpenCommand -eq $State.MachineOpenCommand
102
+ }
103
+
104
+ # Decides whether the official tool should run. Returns a reason string, or $null to skip.
105
+ # A configured association with the launcher still erroring is repaired once when user-level
106
+ # overrides exist (the case that was fixed by moving them aside and rerunning the official tool).
107
+ # Once Doctor has preserved overrides before, recreated ones do not retrigger: it cannot change the outcome.
108
+ function Get-RepairReason($State, [bool]$Configured, [bool]$LauncherError, [bool]$Force) {
109
+ if (-not $Configured) { return 'AssociationNeedsRepair' }
110
+ if ($Force) { return 'Forced' }
111
+ $preserved = if ($State.PSObject.Properties['PreservedKeyCount']) { [int]$State.PreservedKeyCount } else { 0 }
112
+ if ($LauncherError -and @($State.UserOverrides).Count -gt 0 -and $preserved -eq 0) { return 'LauncherErrorWithUserOverrides' }
113
+ return $null
114
+ }
115
+
116
+ function Get-AssociationStatus([bool]$Configured, [bool]$LauncherError) {
117
+ if ($Configured -and $LauncherError) { return 'AssociationConfiguredLauncherErrorReported' }
118
+ if ($Configured) { return 'AssociationConfigured' }
119
+ return 'AssociationNeedsAttention'
120
+ }
121
+
122
+ # Opt-in end-to-end check: opens the project the way a double-click does, then looks for an editor
123
+ # process whose command line names that project. Never runs unless -OpenProject is given.
124
+ function Test-ProjectOpens([string]$Project, [int]$TimeoutSeconds) {
125
+ $full = (Resolve-Path -LiteralPath $Project).Path
126
+ if ([IO.Path]::GetExtension($full) -ne '.uproject') { throw '-OpenProject must point to a .uproject file.' }
127
+ Start-Process -FilePath $full | Out-Null
128
+ $deadline = (Get-Date).AddSeconds($TimeoutSeconds)
129
+ while ((Get-Date) -lt $deadline) {
130
+ Start-Sleep -Seconds 2
131
+ $match = @(Get-CimInstance Win32_Process -Filter "Name LIKE 'UnrealEditor%'" -ErrorAction SilentlyContinue |
132
+ Where-Object { $_.CommandLine -and $_.CommandLine.IndexOf($full, [StringComparison]::OrdinalIgnoreCase) -ge 0 })
133
+ if ($match.Count) { return $true }
134
+ }
135
+ return $false
136
+ }
137
+
138
+ function Complete-Report($Report) {
139
+ if ($OpenProject) {
140
+ $Report.ProjectOpenVerified = [bool](Test-ProjectOpens $OpenProject $OpenTimeoutSeconds)
141
+ $Report.VerificationScope = 'Windows open command, plus project open via double-click path (-OpenProject)'
142
+ }
143
+ return [pscustomobject]$Report
144
+ }
145
+
146
+ function Invoke-AssociationDoctor {
147
+ if (-not [Environment]::Is64BitProcess -and [Environment]::Is64BitOperatingSystem) {
148
+ throw 'Use 64-bit PowerShell so registry inspection and repair use the same registry view.'
149
+ }
150
+ $before = Get-AssociationState
151
+ $candidates = @(Get-SelectorCandidates)
152
+ if ($SelectorPath) {
153
+ $selected = (Resolve-Path -LiteralPath $SelectorPath).Path
154
+ } elseif ($candidates.Count -eq 1) { $selected = $candidates[0] }
155
+ else { $selected = $null }
156
+ $configured = Test-AssociationConfiguration $before $selected
157
+ $report = [ordered]@{ Mode=$Mode; Candidates=$candidates; Selected=$selected; Before=$before; After=$null; Backup=$null; ToolExitCode=$null; RegistryVerified=$configured; LauncherVerified=$false; ProjectOpenVerified=$false; LauncherErrorReported=[bool]$LauncherReportsError; Status=(Get-AssociationStatus $configured ([bool]$LauncherReportsError)); Action='None'; RepairReason=$null; VerificationScope='Windows open command only; launcher and project loading are not tested' }
158
+ $reason = Get-RepairReason $before $configured ([bool]$LauncherReportsError) ([bool]$ForceRepair)
159
+ $report.RepairReason = $reason
160
+ if ($Mode -eq 'Diagnose') { return (Complete-Report $report) }
161
+ if (-not $reason) {
162
+ $report.Action = 'SkippedAlreadyConfigured'
163
+ Write-Warning 'Windows association already matches. No registry changes made and the official tool was not run. If Epic still reports an error, repair with -LauncherReportsError (runs once when user overrides exist); -ForceRepair only reruns the official tool.'
164
+ return (Complete-Report $report)
165
+ }
166
+ if (-not $selected) { throw 'No unique selector found. Use -SelectorPath with the intended launcher executable, or -SearchRoot with its installation directory.' }
167
+ if ([IO.Path]::GetFileName($selected) -notmatch '^UnrealVersionSelector(?:-Win64-Shipping)?\.exe$') { throw 'The selected executable is not named UnrealVersionSelector.' }
168
+ $signature = Get-AuthenticodeSignature -LiteralPath $selected
169
+ if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Epic Games') {
170
+ throw 'Automatic repair requires a valid Epic Games signed selector. Source builds can be inspected in Diagnose mode; run their trusted selector manually.'
171
+ }
172
+ $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
173
+ if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Repair requires an elevated PowerShell window. Diagnose does not require administrator rights.' }
174
+ if (@(Get-Process UnrealVersionSelector -ErrorAction SilentlyContinue).Count) { throw 'Close existing UnrealVersionSelector dialogs before repairing. An old error dialog must not be mistaken for a new result.' }
175
+ if ($before.UserChoice -and $before.UserChoice -ne 'Unreal.ProjectFile') { throw 'Windows UserChoice selects another app. Change the .uproject default app in Windows Settings first; this tool does not modify protected UserChoice hashes.' }
176
+ # Validate every override before making changes. Unknown registrations are preserved.
177
+ foreach ($entry in $before.UserOverrides) {
178
+ if ($entry.Name -in @('.uproject','.uplugin')) {
179
+ $expected = if ($entry.Name -eq '.uproject') { 'Unreal.ProjectFile' } else { 'Unreal.PluginFile' }
180
+ if ($entry.Default -and $entry.Default -ne $expected) { throw "Unknown association for $($entry.Name); leaving it unchanged." }
181
+ } else {
182
+ $userCommand = Get-RegistryDefault 'HKCU:\Software\Classes\Unreal.ProjectFile\shell\open\command'
183
+ if ($userCommand -notmatch 'UnrealVersionSelector[^"\\]*\.exe"?\s+/editor') { throw 'Unknown user-level project handler; leaving it unchanged.' }
184
+ }
185
+ }
186
+ $backup = Join-Path $BackupRoot ((Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,8))
187
+ New-Item -ItemType Directory -Path $backup -Force | Out-Null
188
+ $report.Backup = $backup
189
+ $before | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $backup 'before.json') -Encoding UTF8
190
+ foreach ($hive in @('HKCU','HKLM')) {
191
+ foreach ($name in @('.uproject','.uplugin','Unreal.ProjectFile','Unreal.PluginFile')) {
192
+ if (Test-Path -LiteralPath "${hive}:\Software\Classes\$name") {
193
+ & reg.exe export "$hive\Software\Classes\$name" (Join-Path $backup "$hive-$name.reg") /y | Out-Null
194
+ if ($LASTEXITCODE -ne 0) { throw "Backup failed for $hive/$name. No overrides have been moved." }
195
+ }
196
+ }
197
+ }
198
+ $moves = @()
199
+ try {
200
+ foreach ($entry in $before.UserOverrides) {
201
+ $oldPath = "HKCU:\Software\Classes\$($entry.Name)"
202
+ $newName = $entry.Name + '.AssociationDoctor-' + [guid]::NewGuid().ToString('N')
203
+ Rename-Item -LiteralPath $oldPath -NewName $newName
204
+ $moves += [pscustomobject]@{ Original=$entry.Name; Preserved=$newName }
205
+ $moves | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $backup 'preserved-keys.json') -Encoding UTF8
206
+ }
207
+ $p = Start-Process -FilePath $selected -ArgumentList '/fileassociations' -WorkingDirectory (Split-Path $selected) -PassThru
208
+ if (-not $p.WaitForExit(60000)) { throw 'Selector is still running. Inspect its dialog; do not launch another instance. Backups and preserved keys are retained.' }
209
+ $report.ToolExitCode = $p.ExitCode
210
+ $report.Action = 'OfficialToolExecuted'
211
+ $after = Get-AssociationState
212
+ $report.After = $after
213
+ $report.RegistryVerified = Test-AssociationConfiguration $after $selected
214
+ $report.Status = Get-AssociationStatus $report.RegistryVerified ([bool]$LauncherReportsError)
215
+ if ($p.ExitCode -ne 0 -or -not $report.RegistryVerified) { throw 'Official tool failed or registry verification failed; see report.json. Registry state and tool exit code are recorded separately.' }
216
+ } finally {
217
+ $report.After = Get-AssociationState
218
+ $report | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath (Join-Path $backup 'report.json') -Encoding UTF8
219
+ }
220
+ Write-Warning 'Registry verified only. Fully exit and restart Epic, enter Unreal Engine > Library, and open a known project to verify the complete workflow. PowerToys preview may recreate user overrides.'
221
+ return (Complete-Report $report)
222
+ }
223
+
224
+ if ($MyInvocation.InvocationName -ne '.') {
225
+ Invoke-AssociationDoctor | ConvertTo-Json -Depth 10
226
+ }
@@ -0,0 +1,280 @@
1
+ #requires -Version 5.1
2
+ [CmdletBinding()]
3
+ param([switch]$RepairNow, [switch]$LauncherError)
4
+ $ErrorActionPreference = 'Stop'
5
+ $core = Join-Path $PSScriptRoot 'Repair-UnrealAssociation.ps1'
6
+ $backups = Join-Path $env:LOCALAPPDATA 'UnrealAssociationDoctor\Backups'
7
+
8
+ function Write-Title([string]$Text) {
9
+ Write-Host ''
10
+ Write-Host ('==== ' + $Text + ' ====') -ForegroundColor Cyan
11
+ }
12
+ function Write-Good([string]$Text) { Write-Host ('[正常] ' + $Text) -ForegroundColor Green }
13
+ function Write-Bad([string]$Text) { Write-Host ('[问题] ' + $Text) -ForegroundColor Red }
14
+ function Write-Note([string]$Text) { Write-Host ('[提示] ' + $Text) -ForegroundColor Yellow }
15
+
16
+ # Yes/no question. $DefaultYes controls what a bare Enter means; the hint shows it.
17
+ function Confirm-Choice([string]$Question, [bool]$DefaultYes) {
18
+ $hint = if ($DefaultYes) { '(输入 Y 表示是,N 表示否;直接回车 = 是)' } else { '(输入 Y 表示是,N 表示否;直接回车 = 否)' }
19
+ $answer = "$(Read-Host ($Question + $hint))".Trim()
20
+ if (-not $answer) { return $DefaultYes }
21
+ return ($answer -match '^(y|yes|是)$')
22
+ }
23
+
24
+ function Test-Administrator {
25
+ $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
26
+ return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
27
+ }
28
+
29
+ # Plain-language summary of the registry state. Returns the full diagnosis for callers.
30
+ function Show-Diagnosis([bool]$LauncherReportsError = $false, [switch]$Detailed) {
31
+ # Named parameters need a hashtable; an array would be passed positionally.
32
+ $diagArgs = @{ Mode = 'Diagnose' }
33
+ if ($LauncherReportsError) { $diagArgs.LauncherReportsError = $true }
34
+ $result = & $core @diagArgs | ConvertFrom-Json
35
+ Write-Host ''
36
+ if ($result.Before.ExtensionClass -eq 'Unreal.ProjectFile') {
37
+ Write-Good '.uproject 文件已关联到 Unreal。'
38
+ } else {
39
+ Write-Bad '.uproject 文件还没有关联到 Unreal。'
40
+ }
41
+ if ($result.Before.TargetExists) {
42
+ Write-Good '关联的程序存在,路径有效。'
43
+ } else {
44
+ Write-Bad '关联指向的程序找不到,可能是启动器被移动或重装过。'
45
+ }
46
+ $overrides = @($result.Before.UserOverrides).Count
47
+ if ($overrides -gt 0) {
48
+ if ($result.Before.MonacoPreviewKeys) {
49
+ Write-Note ('发现 ' + $overrides + ' 个用户级设置,其中有 PowerToys 的预览项;它们有时会干扰修复,但不一定是原因。')
50
+ } else {
51
+ Write-Note ('发现 ' + $overrides + ' 个用户级设置,它们可能覆盖系统关联。')
52
+ }
53
+ }
54
+ if ($result.Before.UserChoice -and $result.Before.UserChoice -ne 'Unreal.ProjectFile') {
55
+ Write-Bad ('Windows 的“默认应用”把 .uproject 指给了别的程序:' + $result.Before.UserChoice + '。需要在 Windows 设置里改回。')
56
+ }
57
+ if ($Detailed) {
58
+ Write-Host ''
59
+ Write-Host '详细信息:' -ForegroundColor DarkGray
60
+ Write-Host (' 打开命令:' + $result.Before.OpenCommand) -ForegroundColor DarkGray
61
+ Write-Host (' 找到的关联工具:' + @($result.Candidates).Count + ' 个') -ForegroundColor DarkGray
62
+ foreach ($candidate in $result.Candidates) { Write-Host (' ' + $candidate) -ForegroundColor DarkGray }
63
+ Write-Host (' 当前是否管理员:' + $result.Before.IsElevated) -ForegroundColor DarkGray
64
+ }
65
+ return $result
66
+ }
67
+
68
+ # Optional last step: open a real project the way a double-click does.
69
+ function Test-ProjectPrompt {
70
+ Write-Host ''
71
+ Write-Host '想确认真的修好了吗?把任意一个 .uproject 文件拖进这个窗口,再按回车,我会帮你打开试试(会启动 Unreal 编辑器)。'
72
+ $answer = Read-Host '不想测试就直接按回车'
73
+ $path = "$answer".Trim().Trim('"')
74
+ if (-not $path) { return }
75
+ if (-not (Test-Path -LiteralPath $path -PathType Leaf) -or [IO.Path]::GetExtension($path) -ne '.uproject') {
76
+ Write-Note '这不是一个存在的 .uproject 文件,已跳过测试。'
77
+ return
78
+ }
79
+ Write-Host '正在打开项目,最多等待 90 秒(编辑器启动可能较慢)……'
80
+ $opened = & $core -Mode Diagnose -OpenProject $path -OpenTimeoutSeconds 90 | ConvertFrom-Json
81
+ if ($opened.ProjectOpenVerified) {
82
+ Write-Good '项目已经用 Unreal 编辑器打开,关联可以正常使用。'
83
+ } else {
84
+ Write-Note '90 秒内没有检测到编辑器打开这个项目。如果弹出了“选择应用”,请选 UnrealVersionSelector.exe 并勾选“始终使用”;也可能只是编辑器还在启动。'
85
+ }
86
+ }
87
+
88
+ # Shown after a repair (in either window) so the user knows exactly what is left to do.
89
+ function Show-NextSteps {
90
+ Write-Title '最后两步'
91
+ Write-Host '1. 在系统托盘里完全退出 Epic 启动器,再重新打开,进入“虚幻引擎 → 库”。'
92
+ Write-Host '2. 双击一个正常的 .uproject,能用 Unreal 打开就说明成功了。'
93
+ Write-Host ' 如果项目能打开、Epic 里仍有提示,可以忽略它,关联本身是好的。' -ForegroundColor DarkGray
94
+ }
95
+
96
+ function Start-Repair([bool]$LauncherReportsError = $false) {
97
+ $diagnosis = Show-Diagnosis $LauncherReportsError
98
+ if (-not $diagnosis.RepairReason) {
99
+ Write-Host ''
100
+ Write-Good '不需要修复,也不会申请管理员权限。'
101
+ Write-Host '如果 Epic 里仍有提示:先双击一个 .uproject,能打开就可以忽略。'
102
+ return
103
+ }
104
+ if (-not (Test-Administrator)) {
105
+ Write-Host ''
106
+ Write-Host '修复需要管理员权限。接下来 Windows 会弹出权限提示,请选“是”。'
107
+ Write-Host '修复会在一个新窗口里进行,完成后这里会自动重新检查结果。'
108
+ $escaped = $PSCommandPath.Replace("'", "''")
109
+ $command = "& '$escaped' -RepairNow"
110
+ if ($LauncherReportsError) { $command += ' -LauncherError' }
111
+ $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
112
+ try {
113
+ $hostName = if ($PSVersionTable.PSEdition -eq 'Core') { 'pwsh.exe' } else { 'powershell.exe' }
114
+ $process = Start-Process -FilePath (Join-Path $PSHOME $hostName) -ArgumentList @('-NoLogo','-NoProfile','-ExecutionPolicy','RemoteSigned','-EncodedCommand',$encoded) -Verb RunAs -PassThru
115
+ } catch {
116
+ Write-Note '没有拿到管理员权限(可能点了“否”)。没有做任何修改,需要时重新运行并选“是”。'
117
+ return
118
+ }
119
+ Write-Host '等待修复窗口完成……' -ForegroundColor DarkGray
120
+ $process.WaitForExit()
121
+ Write-Title '重新检查'
122
+ $after = Show-Diagnosis
123
+ if ($after.RegistryVerified) {
124
+ Write-Good 'Windows 里的关联现在是正确的。'
125
+ Show-NextSteps
126
+ Test-ProjectPrompt
127
+ } else {
128
+ Write-Bad '关联仍然不正确。请查看修复窗口里的提示,或选下面的 4 看常见问题。'
129
+ }
130
+ return
131
+ }
132
+ $candidates = @($diagnosis.Candidates)
133
+ $selected = $diagnosis.Selected
134
+ if (-not $selected) {
135
+ if ($candidates.Count) {
136
+ Write-Host ''
137
+ Write-Host '找到了多个关联工具,请选择要用的那个:'
138
+ for ($i = 0; $i -lt $candidates.Count; $i++) { Write-Host (" {0}. {1}" -f ($i + 1), $candidates[$i]) }
139
+ $answer = Read-Host '输入编号,或直接回车取消'
140
+ $index = 0
141
+ if (-not [int]::TryParse("$answer", [ref]$index) -or $index -lt 1 -or $index -gt $candidates.Count) { return }
142
+ $selected = $candidates[$index - 1]
143
+ } else {
144
+ Write-Note '没有自动找到关联工具 UnrealVersionSelector.exe。它通常在 Epic 启动器目录的 Engine\Binaries\Win64 里。'
145
+ $selected = "$(Read-Host '粘贴 exe 的完整路径,或直接回车取消')".Trim().Trim('"')
146
+ if (-not $selected) { return }
147
+ }
148
+ }
149
+ Write-Host ''
150
+ if ($diagnosis.RepairReason -eq 'LauncherErrorWithUserOverrides') {
151
+ Write-Host '关联本身是对的,但有用户级设置可能干扰。接下来会:'
152
+ Write-Host ' 1. 备份相关设置 2. 把它们改名移开(不会删除) 3. 重新运行 Epic 官方工具一次'
153
+ } else {
154
+ Write-Host '接下来会:'
155
+ Write-Host ' 1. 备份相关设置 2. 运行 Epic 官方工具修复关联。不会修改你的项目文件'
156
+ }
157
+ Write-Host '开始前请关闭之前弹出的“Couldn''t update file associations”之类的旧窗口。' -ForegroundColor DarkGray
158
+ if (-not (Confirm-Choice '现在开始吗?' $true)) { Write-Host '已取消,没有做任何修改。'; return }
159
+ $repairArgs = @{ Mode = 'Repair'; SelectorPath = $selected }
160
+ if ($LauncherReportsError) { $repairArgs.LauncherReportsError = $true }
161
+ $result = & $core @repairArgs | ConvertFrom-Json
162
+ if ($result.RegistryVerified) {
163
+ Write-Host ''
164
+ Write-Good 'Windows 文件关联检查已通过。'
165
+ if ($result.Backup) { Write-Host ('备份保存在:' + $result.Backup) -ForegroundColor DarkGray }
166
+ Show-NextSteps
167
+ Test-ProjectPrompt
168
+ } else { throw '修复后关联检查仍未通过,详情见备份目录里的 report.json。' }
169
+ }
170
+
171
+ # Default flow: check first, ask at most one question, repair only when it can change something.
172
+ function Invoke-OneClick {
173
+ Write-Title '第 1 步:检查'
174
+ $check = Show-Diagnosis
175
+ if (-not $check.RegistryVerified) {
176
+ Write-Title '第 2 步:修复'
177
+ Start-Repair $false
178
+ return
179
+ }
180
+ Write-Host ''
181
+ Write-Host 'Windows 这边没有发现问题。' -ForegroundColor Green
182
+ if (Confirm-Choice 'Epic 启动器里现在还显示“项目文件未关联”或修复报错吗?' $false) {
183
+ Write-Title '第 2 步:修复'
184
+ Start-Repair $true
185
+ return
186
+ }
187
+ Write-Host ''
188
+ Write-Good '一切正常,不需要修复。'
189
+ Test-ProjectPrompt
190
+ }
191
+
192
+ function Export-LauncherReport {
193
+ Write-Host '这会保存一份诊断报告,方便你反馈问题。只读取设置,不会修改任何东西。'
194
+ $answer = "$(Read-Host '双击 .uproject 能正常打开吗?Y=能,N=不能,回车=没试过')".Trim()
195
+ $projectResult = 'NotTested'
196
+ if ($answer -match '^(y|yes)$') { $projectResult = 'UserReportedWorking' }
197
+ if ($answer -match '^(n|no)$') { $projectResult = 'UserReportedFailure' }
198
+ $result = & $core -Mode Diagnose -LauncherReportsError | ConvertFrom-Json
199
+ $result | Add-Member -NotePropertyName UserReportedProjectOpen -NotePropertyValue $projectResult
200
+ $processes = @(Get-Process EpicGamesLauncher,UnrealVersionSelector -ErrorAction SilentlyContinue | ForEach-Object {
201
+ [pscustomobject]@{ Name=$_.ProcessName; Id=$_.Id; Path=$_.Path; Version=if ($_.Path) { (Get-Item -LiteralPath $_.Path).VersionInfo.FileVersion } else { $null } }
202
+ })
203
+ $result | Add-Member -NotePropertyName Processes -NotePropertyValue $processes
204
+ $result | Add-Member -NotePropertyName CapturedAt -NotePropertyValue ([DateTimeOffset]::Now.ToString('o'))
205
+ $directory = Join-Path $env:LOCALAPPDATA 'UnrealAssociationDoctor\Diagnostics'
206
+ New-Item -ItemType Directory -Path $directory -Force | Out-Null
207
+ $file = Join-Path $directory ('launcher-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,8) + '.json')
208
+ $result | ConvertTo-Json -Depth 12 | Set-Content -LiteralPath $file -Encoding UTF8
209
+ Write-Host ''
210
+ if ($result.RegistryVerified) {
211
+ Write-Note 'Windows 里的关联是正确的;已记下“Epic 仍报错”。具体原因暂时无法确定。'
212
+ } else { Write-Bad 'Windows 里的关联不正确,可以回到上一级选“重新检查并修复”。' }
213
+ Write-Host ('报告已保存:' + $file)
214
+ Write-Host '报告只保存在你的电脑上,没有上传。发给别人前,请先检查里面的用户名和安装路径。' -ForegroundColor DarkGray
215
+ }
216
+
217
+ # Translate the common failures into what the user should do next. The raw message stays visible.
218
+ function Show-Failure($failure) {
219
+ $message = $failure.Exception.Message
220
+ Write-Host ''
221
+ Write-Bad '这一步没有完成。'
222
+ $advice = switch -Regex ($message) {
223
+ 'elevated' { '需要管理员权限。请重新运行,在 Windows 权限提示里选“是”。'; break }
224
+ 'Close existing' { '之前的修复窗口还开着。请先关掉它;看不到窗口的话,在任务管理器里结束 UnrealVersionSelector.exe,再重试。'; break }
225
+ 'UserChoice' { '请打开 Windows 设置 → 应用 → 默认应用,搜索 .uproject,把默认应用改成 Unreal 的关联程序,然后重试。'; break }
226
+ 'No unique selector' { '没有找到唯一的关联程序。请选择其中一个,或手动填写 UnrealVersionSelector.exe 的完整路径。'; break }
227
+ 'not named|Epic Games signed' { '这个程序不是 Epic 官方签名的关联工具,为了安全不会自动运行。请确认它来自本机的 Epic 启动器安装。'; break }
228
+ 'Unknown' { '发现了无法确认来源的自定义关联。为避免破坏你的设置,没有做任何修改。'; break }
229
+ 'Backup failed' { '备份失败,所以没有做任何修改。请检查磁盘空间和权限后重试。'; break }
230
+ 'still running' { '官方工具还在运行。请查看它的弹窗,先不要重复启动。'; break }
231
+ '64-bit' { '请使用 64 位的 PowerShell。直接双击 Start.cmd 即可。'; break }
232
+ default { '请不要反复重试。选下面的 4 看常见问题,或选 5 保存诊断报告。' }
233
+ }
234
+ Write-Host $advice -ForegroundColor Yellow
235
+ Write-Host ('技术详情:' + $message) -ForegroundColor DarkGray
236
+ }
237
+
238
+ if ($RepairNow) {
239
+ Write-Title '管理员修复窗口'
240
+ try { Start-Repair ([bool]$LauncherError) } catch { Show-Failure $_ }
241
+ Write-Host ''
242
+ Write-Host '这个窗口的工作结束了。回到原来的窗口可以看到最终检查结果。' -ForegroundColor Cyan
243
+ $null = Read-Host '按回车关闭此窗口'
244
+ return
245
+ }
246
+
247
+ Write-Host ''
248
+ Write-Host '==================================================' -ForegroundColor Cyan
249
+ Write-Host ' Unreal 文件关联修复助手' -ForegroundColor Cyan
250
+ Write-Host ' 解决 Epic 提示“.uproject 未关联 / 无法更新文件关联”' -ForegroundColor Cyan
251
+ Write-Host '==================================================' -ForegroundColor Cyan
252
+ Write-Host '会先检查;只有确实需要时才修复,修复前自动备份。' -ForegroundColor DarkGray
253
+ try { Invoke-OneClick } catch { Show-Failure $_ }
254
+
255
+ while ($true) {
256
+ Write-Host ''
257
+ Write-Title '还需要做别的吗?'
258
+ Write-Host ' 1 重新检查并修复'
259
+ Write-Host ' 2 查看详细检查结果'
260
+ Write-Host ' 3 打开备份文件夹'
261
+ Write-Host ' 4 查看常见问题'
262
+ Write-Host ' 5 保存诊断报告(反馈问题时用)'
263
+ Write-Host ' 回车 退出'
264
+ $choice = "$(Read-Host '请输入数字')".Trim()
265
+ if (-not $choice -or $choice -eq '0') { break }
266
+ try {
267
+ switch ($choice) {
268
+ '1' { Invoke-OneClick }
269
+ '2' { $null = Show-Diagnosis $false -Detailed }
270
+ '3' {
271
+ if (Test-Path -LiteralPath $backups) { Start-Process explorer.exe -ArgumentList ('"' + $backups + '"') }
272
+ else { Write-Note '还没有备份。只有执行过修复才会生成备份。' }
273
+ }
274
+ '4' { Start-Process notepad.exe -ArgumentList ('"' + (Join-Path $PSScriptRoot 'docs\TROUBLESHOOTING.md') + '"') }
275
+ '5' { Export-LauncherReport }
276
+ default { Write-Note '请输入 1 到 5,或直接回车退出。' }
277
+ }
278
+ } catch { Show-Failure $_ }
279
+ }
280
+ Write-Host '已退出。'
@@ -0,0 +1,28 @@
1
+ """Check only staged paths. SourceArt OBJ meshes and plugin redistributables are valid."""
2
+
3
+ from pathlib import PurePosixPath
4
+ import os
5
+ import subprocess
6
+ import sys
7
+
8
+
9
+ def blocked(name):
10
+ p = PurePosixPath(name.lower())
11
+ return (
12
+ p.parts[0] in {"artifacts", ".vs", "deriveddatacache", "intermediate"}
13
+ or p.parts[:2]
14
+ in {("saved", "cooked"), ("saved", "livecapture"), ("saved", "stagedbuilds")}
15
+ or ("plugins" in p.parts and "intermediate" in p.parts)
16
+ )
17
+
18
+
19
+ if __name__ == "__main__":
20
+ changes = subprocess.check_output(
21
+ ["git", "diff", "--cached", "--diff-filter=ACMR", "--name-only", "-z"]
22
+ )
23
+ bad = [
24
+ os.fsdecode(p) for p in changes.split(b"\0") if p and blocked(os.fsdecode(p))
25
+ ]
26
+ for path in bad:
27
+ print("Generated path in Git index:", path, file=sys.stderr)
28
+ sys.exit(bool(bad))
@@ -0,0 +1,34 @@
1
+ """Install the shared staged-path check into one repository's local Git hooks."""
2
+ import argparse
3
+ import os
4
+ from pathlib import Path
5
+ import shlex
6
+ import subprocess
7
+
8
+
9
+ def install(repo):
10
+ args = ["git", "-C", str(repo), "rev-parse", "--path-format=absolute"]
11
+ common = Path(subprocess.check_output([*args, "--git-common-dir"], text=True).strip())
12
+ hook = Path(subprocess.check_output([*args, "--git-path", "hooks/pre-commit"], text=True).strip())
13
+ if hook.resolve() != common.resolve() / "hooks/pre-commit":
14
+ raise ValueError("Custom hooks directory: integrate the checker with the existing hook")
15
+ for value in os.environ.get("UEAGENT_PROTECTED_ROOTS", "").split(os.pathsep):
16
+ if value:
17
+ root = Path(value).expanduser().resolve()
18
+ if repo.resolve().is_relative_to(root) or common.resolve().is_relative_to(root):
19
+ raise ValueError("Protected source project")
20
+ checker = Path(__file__).resolve().with_name("check_staged.py")
21
+ hook.parent.mkdir(exist_ok=True)
22
+ with hook.open("x", encoding="utf8", newline="\n") as stream:
23
+ stream.write("#!/bin/sh\nexec python -X utf8 " + shlex.quote(checker.as_posix()) + "\n")
24
+ hook.chmod(0o755)
25
+ return hook
26
+
27
+
28
+ if __name__ == "__main__":
29
+ parser = argparse.ArgumentParser(description=__doc__)
30
+ parser.add_argument("repo", type=Path)
31
+ try:
32
+ print(install(parser.parse_args().repo))
33
+ except (ValueError, OSError, subprocess.CalledProcessError) as exc:
34
+ parser.exit(1, str(exc) + "\n")
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ exec python -X utf8 "$(git rev-parse --show-toplevel)/Hooks/check_staged.py"