Skip to content

Commit 27881cb

Browse files
committed
feat: tech debt cleanup, simplify security flow, WT tab support
- Extracted magic numbers into named constants in Tweaks.Universal.ps1 and Tweaks.Cleanup.ps1 - Replaced hardcoded GPU indices 0000-0003 with dynamic Get-DisplayAdapterIndices registry scan - Simplified DefendNot and RemoveWindowsAI: single Y/N/R confirmation instead of double menu - Added -SkipConfirm parameter to Invoke-Tool to prevent double confirmation prompts - Added [R] Review source to PrivacySexy and WinScript menus - Updated AdminLaunch.ps1: open new tab in current WT window when already admin (wt -w 0 new-tab) - Added Common.ps1 load guard in Benchmark.ps1 for Pester test compatibility - Renamed Winrift.ps1 to PascalCase; updated references in Common.ps1, launch.ps1, CONTRIBUTING.md - Shortened Power Management warning text to fit menu box width - Cleaned VSCode settings: removed Cyrillic allowedCharacters, changed cSpell to English only - Added .mailmap to unify 5 author name variants into one
1 parent 2da8560 commit 27881cb

16 files changed

Lines changed: 181 additions & 98 deletions

.mailmap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Emylfy <106668970+emylfy@users.noreply.github.com> Emalfai <106668970+emylfy@users.noreply.github.com>
2+
Emylfy <106668970+emylfy@users.noreply.github.com> eai <106668970+emylfy@users.noreply.github.com>
3+
Emylfy <106668970+emylfy@users.noreply.github.com> emylfy <106668970+emylfy@users.noreply.github.com>
4+
Emylfy <106668970+emylfy@users.noreply.github.com> ✦ Emylfy <106668970+emylfy@users.noreply.github.com>

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ and this project uses [Calendar Versioning](https://calver.org/) (YY.M format).
3535
- Updated Windots README paths to match flattened config directory
3636
- Updated `ModuleExports.Tests.ps1` to match refactored Windots menu function names
3737

38+
### March 22 — Tech debt cleanup, security flow simplification, WT tab support
39+
40+
- Extracted magic numbers into named constants in `Tweaks.Universal.ps1` (accessibility flags, timeouts, network throttling, priority separation) and `Tweaks.Cleanup.ps1` (PC Manager AUMID, Store link)
41+
- Replaced hardcoded GPU indices 0000-0003 with dynamic `Get-DisplayAdapterIndices` registry scan in `Tweaks.GPU.ps1`
42+
- Simplified DefendNot and RemoveWindowsAI: removed intermediate menus, replaced with single Y/N/R confirmation box with inline warnings and tool info
43+
- Added `-SkipConfirm` parameter to `Invoke-Tool` in `Common.ps1` to prevent double confirmation prompts
44+
- Added `[R] Review project source` option to PrivacySexy and WinScript menus
45+
- Updated `AdminLaunch.ps1`: detect `$env:WT_SESSION` to open new tab in current WT window when already admin (`wt -w 0 new-tab`), fall back to new window otherwise
46+
- Added `Common.ps1` load guard in `Benchmark.ps1` (`Get-Command Write-Log` check) to fix Pester test failure when dot-sourced
47+
- Renamed `winrift.ps1` to `Winrift.ps1` (PascalCase); updated references in `Common.ps1`, `launch.ps1`, `CONTRIBUTING.md`
48+
- Shortened Power Management warning text to fit within menu box width
49+
- Cleaned VSCode settings: removed Cyrillic `allowedCharacters`, changed `cSpell.language` from `en,ru` to `en`
50+
- Added `.mailmap` to unify 5 author name variants (Emylfy, Emalfai, emylfy, eai, ✦ Emylfy) into one
51+
3852
## [26.3] - 2026-03-21
3953

4054
### March 21 — PowerShell 5.1 compatibility, test fixes, encoding cleanup

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Testing tweaks on a live system can cause irreversible changes. Use a Windows 11
5757

5858
```
5959
winrift/
60-
├── winrift.ps1 # Main entry point
60+
├── Winrift.ps1 # Main entry point
6161
├── version.json # Version metadata
6262
├── scripts/ # Core scripts (admin launch, common utilities)
6363
├── modules/

modules/security/DefendNot.ps1

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
. "$PSScriptRoot\..\..\scripts\Common.ps1"
22
$Host.UI.RawUI.WindowTitle = "DefendNot - Disable Windows Defender"
33

4-
function Show-DefendNotMenu {
5-
$tool = Get-ToolConfig "defendnot"
6-
Invoke-MenuLoop -Title "DefendNot - Disable Windows Defender via WSC API" -Items @(
7-
"[1] Launch DefendNot",
8-
"[2] Open documentation / project source",
9-
"---",
10-
"[3] Back to menu"
11-
) -Actions @{
12-
"1" = {
13-
Write-Host ""
4+
$tool = Get-ToolConfig "defendnot"
5+
6+
Clear-Host
7+
Show-MenuBox -Title "DefendNot - Disable Windows Defender" -Items @(
8+
"This will fetch and run a script from the web",
9+
"to disable Defender via the WSC API.",
10+
"",
11+
"Before running, real-time protection and",
12+
"Defender exclusion will be set automatically.",
13+
"You may need to disable Tamper Protection first.",
14+
"",
15+
"URL: $($tool.url)",
16+
"Source: $($tool.docs)",
17+
"---",
18+
"[Y] Run [N] Cancel [R] Review source"
19+
)
20+
21+
while ($true) {
22+
$choice = Read-Host ">"
23+
switch ($choice.ToUpper()) {
24+
"Y" {
1425
$defendnotPath = "$env:ProgramFiles\defendnot"
1526

1627
try {
@@ -29,11 +40,21 @@ function Show-DefendNotMenu {
2940
Write-Log -Message "Windows Security > Virus & threat protection > Manage settings > Tamper Protection: Off" -Level WARNING
3041
}
3142

32-
Invoke-Tool "defendnot"
43+
Invoke-Tool "defendnot" -SkipConfirm
3344
Read-Host "Press Enter to continue"
45+
& "$PSScriptRoot\SecurityMenu.ps1"
46+
return
47+
}
48+
"N" {
49+
& "$PSScriptRoot\SecurityMenu.ps1"
50+
return
3451
}
35-
"2" = { Start-Process $tool.docs }
36-
} -ExitKey "3" -OnExit { & "$PSScriptRoot\SecurityMenu.ps1" }
52+
"R" {
53+
if ($tool.docs) {
54+
Start-Process $tool.docs
55+
Write-Host "$Green Opened project source in browser.$Reset"
56+
}
57+
}
58+
default { Write-Host " Please enter Y, N, or R." }
59+
}
3760
}
38-
39-
Show-DefendNotMenu

modules/security/PrivacySexy.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function Show-PrivacySexyMenu {
66
Invoke-MenuLoop -Title "Privacy.sexy - Privacy & Security Hardening" -Items @(
77
"[1] Build your own batch from privacy.sexy website",
88
"[2] Execute latest standard preset (for most users)",
9+
"[R] Review project source",
910
"---",
1011
"[3] Back to menu"
1112
) -Actions @{
@@ -14,6 +15,7 @@ function Show-PrivacySexyMenu {
1415
Invoke-Tool "privacysexy" -OnSuccess { param($path) Start-Process cmd -ArgumentList "/c `"$path`"" -Wait }
1516
Read-Host "Press Enter to continue"
1617
}
18+
"R" = { Start-Process $tool.docs }
1719
} -ExitKey "3" -OnExit { & "$PSScriptRoot\SecurityMenu.ps1" }
1820
}
1921

modules/security/RemoveWindowsAI.ps1

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
. "$PSScriptRoot\..\..\scripts\Common.ps1"
22
$Host.UI.RawUI.WindowTitle = "RemoveWindowsAI - Remove Windows AI Features"
33

4-
function Show-RemoveWindowsAIMenu {
5-
$tool = Get-ToolConfig "removewindowsai"
6-
Invoke-MenuLoop -Title "RemoveWindowsAI - Remove Copilot, Recall & More" -Items @(
7-
"[1] Launch RemoveWindowsAI",
8-
"[2] Open documentation / project source",
9-
"---",
10-
"[3] Back to menu"
11-
) -Actions @{
12-
"1" = {
13-
Clear-Host
14-
Invoke-Tool "removewindowsai"
4+
$tool = Get-ToolConfig "removewindowsai"
5+
6+
Clear-Host
7+
Show-MenuBox -Title "RemoveWindowsAI - Remove Copilot & Recall" -Items @(
8+
"This will fetch and run a script from the web.",
9+
"You can choose what to remove during the process.",
10+
"",
11+
"URL: $($tool.url)",
12+
"Source: $($tool.docs)",
13+
"---",
14+
"[Y] Run [N] Cancel [R] Review source"
15+
)
16+
17+
while ($true) {
18+
$choice = Read-Host ">"
19+
switch ($choice.ToUpper()) {
20+
"Y" {
21+
Invoke-Tool "removewindowsai" -SkipConfirm
1522
Read-Host "Press Enter to continue"
23+
& "$PSScriptRoot\SecurityMenu.ps1"
24+
return
25+
}
26+
"N" {
27+
& "$PSScriptRoot\SecurityMenu.ps1"
28+
return
1629
}
17-
"2" = { Start-Process $tool.docs }
18-
} -ExitKey "3" -OnExit { & "$PSScriptRoot\SecurityMenu.ps1" }
30+
"R" {
31+
if ($tool.docs) {
32+
Start-Process $tool.docs
33+
Write-Host "$Green Opened project source in browser.$Reset"
34+
}
35+
}
36+
default { Write-Host " Please enter Y, N, or R." }
37+
}
1938
}
20-
21-
Show-RemoveWindowsAIMenu

modules/system/Benchmark.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
. "$PSScriptRoot\..\..\scripts\Common.ps1"
1+
if (-not (Get-Command Write-Log -ErrorAction SilentlyContinue)) {
2+
. "$PSScriptRoot\..\..\scripts\Common.ps1"
3+
}
24

35
$script:BenchmarkDir = Join-Path $env:USERPROFILE "Winrift\benchmarks"
46

modules/system/Tweaks.Cleanup.ps1

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
. "$PSScriptRoot\..\..\scripts\Common.ps1"
22

3-
# Winget exit code for "package already installed"
4-
$WINGET_ALREADY_INSTALLED = -1978335189
3+
# Named Constants
4+
$WINGET_ALREADY_INSTALLED = -1978335189 # Winget exit code when package is already installed
5+
$PC_MANAGER_AUMID = "Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!App"
6+
$PC_MANAGER_STORE = "ms-windows-store://pdp?hl=en-us&gl=us&ocid=pdpshare&referrer=storeforweb&productid=9pm860492szd&storecid=storeweb-pdp-open-cta"
57

68
function Clear-SystemSpace {
79
$Host.UI.RawUI.WindowTitle = "System Cleaner"
@@ -37,13 +39,13 @@ function Clear-SystemSpace {
3739
if ($LASTEXITCODE -eq 0) {
3840
Write-Log -Message "Successfully installed PC Manager." -Level SUCCESS
3941
Start-Sleep -Seconds 2
40-
Start-Process "shell:AppsFolder\Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!App"
42+
Start-Process "shell:AppsFolder\$PC_MANAGER_AUMID"
4143
} elseif ($LASTEXITCODE -eq $WINGET_ALREADY_INSTALLED) {
4244
Write-Log -Message "PC Manager is already installed. Launching..." -Level INFO
43-
Start-Process "shell:AppsFolder\Microsoft.MicrosoftPCManager_8wekyb3d8bbwe!App"
45+
Start-Process "shell:AppsFolder\$PC_MANAGER_AUMID"
4446
} else {
4547
Write-Log -Message "Failed to install PC Manager (exit code: $LASTEXITCODE). Please try manually." -Level ERROR
46-
Start-Process "ms-windows-store://pdp?hl=en-us&gl=us&ocid=pdpshare&referrer=storeforweb&productid=9pm860492szd&storecid=storeweb-pdp-open-cta"
48+
Start-Process $PC_MANAGER_STORE
4749
Read-Host "Press Enter to continue"
4850
}
4951
}

modules/system/Tweaks.GPU.ps1

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
. "$PSScriptRoot\..\..\scripts\Common.ps1"
22

3+
# {4d36e968-e325-11ce-bfc1-08002be10318} = Display Adapters device class GUID
4+
$DISPLAY_ADAPTER_CLASS = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
5+
6+
function Get-DisplayAdapterIndices {
7+
# Dynamically enumerate all display adapter registry indices instead of hardcoding 0000-0003
8+
if (-not (Test-Path $DISPLAY_ADAPTER_CLASS)) { return @() }
9+
Get-ChildItem -Path $DISPLAY_ADAPTER_CLASS -ErrorAction SilentlyContinue |
10+
Where-Object { $_.PSChildName -match '^\d{4}$' } |
11+
ForEach-Object { $_.PSChildName }
12+
}
13+
314
function Show-GPUMenu {
415
Invoke-MenuLoop -Title "GPU-Specific Tweaks" -Items @(
516
"[1] NVIDIA",
@@ -39,17 +50,13 @@ function Invoke-NvidiaTweaks {
3950
)
4051

4152
# source - https://github.com/AlchemyTweaks/Verified-Tweaks/blob/main/Nvidia/RmGpsPsEnablePerCpuCoreDpc
42-
# Detect NVIDIA GPU presence
4353
$nvidiaFound = $false
44-
$classPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
45-
foreach ($idx in @("0000", "0001", "0002", "0003")) {
46-
$devPath = "$classPath\$idx"
47-
if (Test-Path $devPath) {
48-
$provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName
49-
if ($provider -match "NVIDIA") {
50-
$nvidiaFound = $true
51-
break
52-
}
54+
foreach ($idx in (Get-DisplayAdapterIndices)) {
55+
$devPath = "$DISPLAY_ADAPTER_CLASS\$idx"
56+
$provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName
57+
if ($provider -match "NVIDIA") {
58+
$nvidiaFound = $true
59+
break
5360
}
5461
}
5562
if (-not $nvidiaFound) {
@@ -81,18 +88,13 @@ function Invoke-AMDTweaks {
8188
)
8289

8390
# source - https://youtu.be/nuUV2RoPOWc , https://github.com/AlchemyTweaks/Verified-Tweaks/blob/main/AMD%20Radeon/AMD%20Tweak%20Melody
84-
# {4d36e968-e325-11ce-bfc1-08002be10318} = Display Adapters device class GUID
85-
# Detect AMD GPU device index dynamically instead of assuming \0000
86-
$classPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
8791
$amdPath = $null
88-
foreach ($idx in @("0000", "0001", "0002", "0003")) {
89-
$devPath = "$classPath\$idx"
90-
if (Test-Path $devPath) {
91-
$provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName
92-
if ($provider -match "AMD|ATI|Advanced Micro Devices") {
93-
$amdPath = $devPath
94-
break
95-
}
92+
foreach ($idx in (Get-DisplayAdapterIndices)) {
93+
$devPath = "$DISPLAY_ADAPTER_CLASS\$idx"
94+
$provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName
95+
if ($provider -match "AMD|ATI|Advanced Micro Devices") {
96+
$amdPath = $devPath
97+
break
9698
}
9799
}
98100
if (-not $amdPath) {

modules/system/Tweaks.Power.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
function Invoke-PowerMenu {
55
Clear-Host
66
Show-MenuBox -Title "Power Management" -Items @(
7-
"Designed for desktops and laptops plugged into AC power.",
8-
"These tweaks disable power-saving features like Connected",
9-
"Standby, CPU idle states, and PCIe ASPM.",
10-
"Skip if running on battery.",
7+
"For desktops and laptops on AC power.",
8+
"Disables Connected Standby, CPU idle states,",
9+
"and PCIe ASPM. Skip if on battery.",
1110
"---",
1211
"[1] Apply Power Management Tweaks",
1312
"[2] Back to menu"

0 commit comments

Comments
 (0)