Files
magpie/internal/agent/cursorlocal_installs_windows.go
T
yetone 8a00d0bfa9 agent: Cursor Private Inference is listed on the Agents page when it is installed in a folder of the user's choosing on Windows, or kept as its AppImage on Linux (#1254, whiteS18, laacmilan)
It was found only by a product.json naming it in one of the apps
folders (on Windows %LOCALAPPDATA%\Programs, %LOCALAPPDATA%, Program
Files). Its 3.24.9 Windows user setup (CursorUserSetup-x64-3.24.9.exe,
from the cursor-local download) installs flat - resources\app\
product.json beside "Cursor Private Inference.exe" - into whatever
folder the installer is given, so one put on another drive or folder
was never found, and Routing still showed requests from it while the
Agents page had only Cursor. On Linux the build is only an AppImage
(Cursor_Private_Inference-3.24.9-x86_64.AppImage), a single file that
no product.json lookup could find.

findCursorLocal now also takes the folders Windows' uninstall entries
name for "Cursor Private Inference (User)" (cursorLocalInstalls: HKCU
and HKLM, InstallLocation, else DisplayIcon's folder), and an AppImage
named for the build in the Linux apps folders plus ~/.local/bin, ~/bin,
~/Downloads and ~ (regular Cursor's Cursor-<v>-x86_64.AppImage isn't
taken).

Run:
- TestCursorLocalFoundWhereInstalled fails with each half removed by
  hand ("installed in a folder of the user's: found \"\"", "its
  AppImage: found \"\"") and passes with the change.
- On the Windows 11 box: the real 3.24.9 user setup installed silently
  into C:\Users\yeton\cpi-1254\app; a probe test in the cross-built
  agent.test.exe found nothing with the old lookup and found
  "...\app\Cursor Private Inference.exe" (detected: true) with the
  new; TestCursorLocal* pass there. The copy was uninstalled after.
- go test -tags nogui ./internal/agent under a temp HOME; go vet
  (darwin, GOOS=linux and GOOS=windows, nogui); gofmt -l clean.
Not run: the AppImage on a real Linux desktop.
2026-10-10 17:52:30 +08:00

53 lines
1.5 KiB
Go

//go:build windows
package agent
import (
"path/filepath"
"strings"
"golang.org/x/sys/windows/registry"
)
// cursorLocalInstalls are the folders Windows' list of installed programs
// says Cursor Private Inference is in ("Cursor Private Inference (User)"):
// its installer takes any folder the user picks, not only
// %LOCALAPPDATA%\Programs\cursor (#1254).
func cursorLocalInstalls() []string {
var dirs []string
for _, hive := range []registry.Key{registry.CURRENT_USER, registry.LOCAL_MACHINE} {
for _, root := range []string{`Software\Microsoft\Windows\CurrentVersion\Uninstall`, `Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall`} {
k, err := registry.OpenKey(hive, root, registry.READ)
if err != nil {
continue
}
names, _ := k.ReadSubKeyNames(-1)
for _, name := range names {
entry, err := registry.OpenKey(k, name, registry.QUERY_VALUE)
if err != nil {
continue
}
display, _, _ := entry.GetStringValue("DisplayName")
if strings.HasPrefix(strings.ToLower(display), strings.ToLower(cursorLocalName)) {
dir, _, _ := entry.GetStringValue("InstallLocation")
if dir == "" {
icon, _, _ := entry.GetStringValue("DisplayIcon")
if at := strings.LastIndex(icon, ","); at >= 0 {
icon = icon[:at]
}
if icon != "" {
dir = filepath.Dir(strings.Trim(icon, `"`))
}
}
if filepath.IsAbs(dir) {
dirs = append(dirs, filepath.Clean(dir))
}
}
entry.Close()
}
k.Close()
}
}
return dirs
}