@geekbeer/minion 3.5.31 → 3.5.32

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekbeer/minion",
3
- "version": "3.5.31",
3
+ "version": "3.5.32",
4
4
  "description": "AI Agent runtime for Minion - manages status and skill deployment on VPS",
5
5
  "main": "linux/server.js",
6
6
  "bin": {
@@ -996,7 +996,7 @@ function Invoke-Uninstall {
996
996
  }
997
997
  Write-Host ""
998
998
 
999
- $totalSteps = 6
999
+ $totalSteps = 7
1000
1000
 
1001
1001
  # Step 1: Stop and remove all NSSM services
1002
1002
  Write-Step 1 $totalSteps "Stopping and removing services..."
@@ -1103,8 +1103,43 @@ function Invoke-Uninstall {
1103
1103
  Write-Detail "Removed legacy service credentials file"
1104
1104
  }
1105
1105
 
1106
- # Step 6: Remove Cloudflare Tunnel configuration
1107
- Write-Step 6 $totalSteps "Removing Cloudflare Tunnel configuration..."
1106
+ # Step 6: Remove npm global bin from user PATH (added by postinstall)
1107
+ Write-Step 6 $totalSteps "Cleaning up PATH entries..."
1108
+ $npmBin = $null
1109
+ try { $npmBin = (& npm prefix -g 2>$null) } catch {}
1110
+ if ($npmBin) {
1111
+ $targetUserName = Split-Path $TargetUserProfile -Leaf
1112
+ $targetUserSid = $null
1113
+ try {
1114
+ $targetUserSid = (New-Object System.Security.Principal.NTAccount($targetUserName)).Translate(
1115
+ [System.Security.Principal.SecurityIdentifier]).Value
1116
+ } catch {}
1117
+ if ($targetUserSid) {
1118
+ $regPath = "Registry::HKEY_USERS\$targetUserSid\Environment"
1119
+ if (Test-Path $regPath) {
1120
+ $currentPath = (Get-ItemProperty -Path $regPath -Name PATH -ErrorAction SilentlyContinue).PATH
1121
+ if ($currentPath -and $currentPath -like "*$npmBin*") {
1122
+ $newPath = ($currentPath -split ';' | Where-Object { $_ -ne $npmBin }) -join ';'
1123
+ if ($newPath) {
1124
+ Set-ItemProperty -Path $regPath -Name PATH -Value $newPath
1125
+ } else {
1126
+ Remove-ItemProperty -Path $regPath -Name PATH -ErrorAction SilentlyContinue
1127
+ }
1128
+ Write-Detail "Removed $npmBin from target user's PATH"
1129
+ }
1130
+ }
1131
+ }
1132
+ # Also clean up the current user's PATH
1133
+ $userPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
1134
+ if ($userPath -and $userPath -like "*$npmBin*") {
1135
+ $newPath = ($userPath -split ';' | Where-Object { $_ -ne $npmBin }) -join ';'
1136
+ [Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
1137
+ Write-Detail "Removed $npmBin from current user's PATH"
1138
+ }
1139
+ }
1140
+
1141
+ # Step 7: Remove Cloudflare Tunnel configuration
1142
+ Write-Step 7 $totalSteps "Removing Cloudflare Tunnel configuration..."
1108
1143
  $cfConfigDir = Join-Path $TargetUserProfile '.cloudflared'
1109
1144
  if (Test-Path $cfConfigDir) {
1110
1145
  Remove-Item $cfConfigDir -Recurse -Force
@@ -1,13 +1,52 @@
1
- # postinstall.ps1 — Re-apply file ACLs after npm install -g replaces the package directory.
1
+ # postinstall.ps1 — Post-install tasks for @geekbeer/minion on Windows.
2
2
  # Called automatically from postinstall.js on Windows.
3
- # Requires Administrator privileges (npm install -g typically runs as admin).
4
- # Exit silently if not admin or if setup has never been run (no .target-user-profile).
3
+ #
4
+ # Tasks:
5
+ # 1. Ensure npm global bin directory is in the user's PATH (any user)
6
+ # 2. Re-apply file ACLs after npm install -g replaces the package directory (admin only)
5
7
 
6
8
  $ErrorActionPreference = 'SilentlyContinue'
7
9
 
10
+ # --- Ensure npm global bin is in PATH ----------------------------------------
11
+ # npm's global bin directory (where minion-cli-win.cmd is created) may not be in
12
+ # PATH, especially when Node.js was installed via winget or exe installer.
13
+ # Add it to the current user's persistent PATH if missing.
14
+
15
+ function Ensure-NpmBinInPath {
16
+ $npmBin = $null
17
+ try { $npmBin = (& npm prefix -g 2>$null) } catch {}
18
+ if (-not $npmBin -or -not (Test-Path $npmBin)) { return }
19
+
20
+ # Check if already in Machine or User PATH
21
+ $machinePath = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
22
+ $userPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
23
+ $allPath = "$machinePath;$userPath"
24
+
25
+ if ($allPath -split ';' | Where-Object { $_ -eq $npmBin }) { return }
26
+
27
+ # Append to User PATH
28
+ if ($userPath) {
29
+ # Remove trailing semicolons before appending
30
+ $userPath = $userPath.TrimEnd(';')
31
+ [Environment]::SetEnvironmentVariable('PATH', "$userPath;$npmBin", 'User')
32
+ } else {
33
+ [Environment]::SetEnvironmentVariable('PATH', $npmBin, 'User')
34
+ }
35
+
36
+ # Also update current session so subsequent commands in this process work
37
+ $env:PATH = "$env:PATH;$npmBin"
38
+
39
+ Write-Host "[@geekbeer/minion] Added npm global bin to PATH: $npmBin"
40
+ Write-Host "[@geekbeer/minion] Please restart your terminal for the PATH change to take effect."
41
+ }
42
+
43
+ Ensure-NpmBinInPath
44
+
8
45
  # --- Locate setup metadata ---------------------------------------------------
9
46
  # During setup, .minion/.target-user-profile is written to the target user's
10
47
  # home directory. We need to find it by scanning user profiles.
48
+ # ACL restoration requires Administrator privileges.
49
+ # Exit silently if not admin or if setup has never been run (no .target-user-profile).
11
50
 
12
51
  function Find-TargetUserProfile {
13
52
  $profiles = Get-CimInstance Win32_UserProfile -ErrorAction SilentlyContinue |