Files
magpie/internal/agent/dsh_official_test.go
T
yetone 34f9686bd2 agent: dsh's desktop app is DeepSeek's own DeepSeek Harness; the community DeepSeek Hermes is not it
WuSix on Discord (Windows 11), on v0.1.1337: the desktop app still isn't
in magpie's Agents, and the repo 0c679c640 built on
(motongv/deepseek-hermes-desktop, "DeepSeek Hermes") is not DeepSeek's.
The official one is github.com/deepseek-ai/deepseek-harness.

What was wrong: 0c679c640 took a community Electron wrapper around
`dsh web` for the app WuSix runs, and listed dsh, wrote the web profile
and dropped dsh's key store for it. That is taken out whole (dshHermes,
the store switch, the web-profile app file, noticeDsh6 and its zh, zh-TW,
ja and de strings, the Running pattern, dsh_hermes_test.go). A user that
v0.1.1337 wired this way keeps profiles/web, which is dsh web's own
profile; the next Apply or Sync writes the key store again.

The official app, read from its source (deepseek-harness at 687f282e8,
dsh-v0.2.1-rc.2) and its real release files:
- apps/desktop/scripts/electron-builder-config.mjs: productName
  DeepSeek Harness, appId from DSH_DESKTOP_APP_ID; first config
  19444907f0 hard-codes com.deepseek.dsh. NSIS per-user
  (perMachine false), a folder the user may pick; installer.nsh writes
  HKCU ${INSTALL_REGISTRY_KEY} InstallLocation and refuses all-users.
- deepseek-harness-0.2.1-rc.2-mac-arm64.zip (sha512 as the feed
  download.deepseek.com/dsh-desk/feeds/mac-arm64/nightly-mac.yml says):
  DeepSeek Harness.app, CFBundleIdentifier com.deepseek.dsh, 0.2.1-rc.2,
  team NAN929V4UM.
- deepseek-harness-0.2.1-rc.2-win-x64.exe installed with /S on the
  Windows 11 box (26200): %LOCALAPPDATA%\Programs\DeepSeek Harness\
  DeepSeek Harness.exe, HKCU\Software\1bf39983-50d0-5fe0-9ef4-
  cece76f67c5e InstallLocation, Uninstall entry DisplayVersion
  0.2.1-rc.2, DisplayIcon <exe>,0. Nothing under HKLM.
- packages/util/home-paths/src/index.ts (defaultDshHome = ~/.dsh,
  DSH_HOME) and apps/desktop/src/paths.ts (profiles/desktop, "shared
  with npm-installed dsh"): the same ~/.dsh as the CLI on every OS.
- No Linux desktop build is published (UPDATE_TARGETS is mac-arm64,
  mac-x64, win-x64; dsh-latest-linux-x64.AppImage is 404); Linux has
  the npm CLI only.
magpie's desktopApps["dsh"] already had all of these (#2279, #2325);
the row is named DeepSeek Harness, the app's own name.

Run:
- Windows box, sandbox USERPROFILE/APPDATA/LOCALAPPDATA (Programs a
  junction to the real one, where the installer put the app), no ~\.dsh:
  the released v0.1.1337 magpie-cli-windows-amd64.exe and this commit's
  build both list "DeepSeek Harness ... ~\.dsh\profiles\desktop\
  cordis.patch.yml" in `magpie ls`. So on a default install v0.1.1337
  already listed it; what WuSix sees isn't reproduced. An unconnected
  agent sits under the Agents page's 未设置 (Not set up) fold; WuSix's
  screenshot and install folder are still to be asked for.
- macOS: the real 0.2.1-rc.2 .app in a sandbox HOME's Applications:
  HasApp true, version 0.2.1-rc.2, `magpie ls` lists it.
- New tests: TestDshOnlyTheOfficialApp (red on 0c679c640's dsh.go:
  "DeepSeek Hermes taken for DeepSeek Harness: detected true") and
  TestDshWindowsAsTheInstallerRegistersIt (the registry values above,
  and the GUID as UUID v5 of com.deepseek.dsh in electron-builder's
  namespace).
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- GUI: i18n-keys, agent-notice-lang, gui-de, gui-ja, gui-zh-tw: 34/34.
- Full suite: not run at push time (queued behind the suite lock;
  pushed per the owner's ship-at-once rule). TestDsh*, TestDesktop*,
  TestCLIMissing*, TestRegistered* rerun ok at the rebased head on
  origin/main 03951798a; the full run follows through the lock, reds filed.

Not tried:
- The real app opened (neither the .app nor the .exe was started), so
  no request from it through the gateway.
- WuSix's own machine: why their row doesn't show is still unknown.
2026-10-23 22:26:33 +08:00

147 lines
6.2 KiB
Go

package agent
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/google/uuid"
)
// dshOfficialPlist is the Info.plist of DeepSeek Harness 0.2.1-rc.2's macOS
// build (deepseek-harness-0.2.1-rc.2-mac-arm64.zip, from
// download.deepseek.com/dsh-desk/feeds/mac-arm64/nightly-mac.yml, sha512 as
// the feed says, signed by team NAN929V4UM), cut to the keys around the
// ones read. Its appId and productName are github.com/deepseek-ai/
// deepseek-harness's apps/desktop/scripts/electron-builder-config.mjs.
const dshOfficialPlist = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>DeepSeek Harness</string>
<key>CFBundleExecutable</key>
<string>DeepSeek Harness</string>
<key>CFBundleIdentifier</key>
<string>com.deepseek.dsh</string>
<key>CFBundleName</key>
<string>DeepSeek Harness</string>
<key>CFBundleShortVersionString</key>
<string>0.2.1-rc.2</string>
</dict>
</plist>
`
// dshOfficialHome is a home with no dsh CLI, no ~/.dsh and no app, apps the
// folder apps are installed into and reg what the Windows registry holds.
func dshOfficialHome(t *testing.T) (home, dir, apps string, reg map[string][2]string) {
t.Helper()
home, dir, _ = dshRouteHome(t)
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
t.Setenv("PATH", t.TempDir()) // no dsh CLI
apps = t.TempDir()
reg = map[string][2]string{}
was, wasReg := appFolders, windowsRegisteredApp
appFolders = func() []string { return []string{apps} }
windowsRegisteredApp = func(guid string) (string, string) { r := reg[guid]; return r[0], r[1] }
t.Cleanup(func() { appFolders, windowsRegisteredApp = was, wasReg })
return home, dir, apps, reg
}
// WuSix on Discord (Windows 11): DeepSeek's desktop app is
// github.com/deepseek-ai/deepseek-harness's DeepSeek Harness, not the
// community "DeepSeek Hermes" (motongv/deepseek-hermes-desktop) v0.1.1337
// took it for. That one is not dsh's app: magpie doesn't list dsh for it,
// nor write a profile or key for it. The official app still is.
func TestDshOnlyTheOfficialApp(t *testing.T) {
judgeFor(t, "darwin")
home, dir, apps, reg := dshOfficialHome(t)
installApp(t, apps, "DeepSeek Hermes.app", strings.NewReplacer(
"com.deepseek.dsh", "com.deepseek.hermes.desktop",
"DeepSeek Harness", "DeepSeek Hermes",
"0.2.1-rc.2", "1.0.0").Replace(dshOfficialPlist))
writeT(t, filepath.Join(apps, "DeepSeek Hermes", "DeepSeek Hermes.exe"), "MZ")
picked := t.TempDir()
writeT(t, filepath.Join(picked, "DeepSeek Hermes.exe"), "MZ")
reg["df9f5892-ad1c-5623-a260-30fb0acc7e55"] = [2]string{picked, "1.0.0"}
if a := dsh(home); a.Detected() || a.HasApp() {
t.Fatalf("DeepSeek Hermes taken for DeepSeek Harness: detected %v, app %v", a.Detected(), a.HasApp())
}
if _, err := os.Stat(dir); !os.IsNotExist(err) {
t.Fatalf("~/.dsh made for DeepSeek Hermes: %v", err)
}
installApp(t, apps, "DeepSeek Harness.app", dshOfficialPlist)
a := dsh(home)
a.Bin = "magpie-test-gone-dsh"
if !a.Detected() || a.CLIMissing() || !a.HasApp() {
t.Fatalf("DeepSeek Harness 0.2.1-rc.2: detected %v, CLI missing %v, app %v", a.Detected(), a.CLIMissing(), a.HasApp())
}
if v := a.AppVersion(); v != "0.2.1-rc.2" {
t.Fatalf("app version %q", v)
}
if a.Name != "DeepSeek Harness" {
t.Fatalf("listed as %q", a.Name)
}
if want := filepath.Join(dir, "profiles", "desktop", "cordis.patch.yml"); a.Path != want {
t.Fatalf("names %s, not the desktop profile", a.Path)
}
}
// The registry as DeepSeek Harness 0.2.1-rc.2's Windows installer
// (deepseek-harness-0.2.1-rc.2-win-x64.exe, run with /S on Windows 11
// 26200) writes it, read back with Get-ItemProperty: HKCU only, the exe
// straight in the folder. The key is electron-builder's GUID for the
// appId, a UUID v5 of com.deepseek.dsh in its namespace.
func TestDshWindowsAsTheInstallerRegistersIt(t *testing.T) {
const appID = "com.deepseek.dsh"
ns := uuid.MustParse("50e065bc-3134-11e6-9bab-38c9862bdaf3") // electron-builder's
guid := desktopApps["dsh"].guid
if got := uuid.NewSHA1(ns, []byte(appID)).String(); got != guid || guid != "1bf39983-50d0-5fe0-9ef4-cece76f67c5e" {
t.Fatalf("guid %s, the installer's %s", guid, got)
}
if desktopApps["dsh"].id != appID {
t.Fatalf("bundle id %s", desktopApps["dsh"].id)
}
at := `C:\Users\yeton\AppData\Local\Programs\DeepSeek Harness`
values := map[string]string{
`HKCU|Software\` + guid + `|InstallLocation`: at,
`HKCU|Software\` + guid + `|ShortcutName`: "DeepSeek Harness",
`HKCU|Software\Microsoft\Windows\CurrentVersion\Uninstall\` + guid + `|DisplayName`: "DeepSeek Harness 0.2.1-rc.2",
`HKCU|Software\Microsoft\Windows\CurrentVersion\Uninstall\` + guid + `|DisplayVersion`: "0.2.1-rc.2",
`HKCU|Software\Microsoft\Windows\CurrentVersion\Uninstall\` + guid + `|DisplayIcon`: at + `\DeepSeek Harness.exe,0`,
`HKCU|Software\Microsoft\Windows\CurrentVersion\Uninstall\` + guid + `|UninstallString`: `"` + at + `\Uninstall DeepSeek Harness.exe" /currentuser`,
`HKCU|Software\Microsoft\Windows\CurrentVersion\Uninstall\` + guid + `|InstallLocation`: at,
}
read := func(hive, key, name string) string { return values[hive+"|"+key+"|"+name] }
if dir, v := registeredIn(guid, read); dir != at || v != "0.2.1-rc.2" {
t.Fatalf("read %q %q", dir, v)
}
// with only the Uninstall entry's DisplayIcon left
for k := range values {
if !strings.HasSuffix(k, "|DisplayIcon") && !strings.HasSuffix(k, "|DisplayVersion") {
delete(values, k)
}
}
if dir, _ := registeredIn(guid, read); dir != at {
t.Fatalf("from DisplayIcon: %q", dir)
}
// a folder the user picked, as the installer lays it out
home, _, _, reg := dshOfficialHome(t)
picked := t.TempDir()
reg[guid] = [2]string{picked, "0.2.1-rc.2"}
if dsh(home).Detected() {
t.Fatal("a registered folder without the app taken for it")
}
writeT(t, filepath.Join(picked, "DeepSeek Harness.exe"), "MZ")
writeT(t, filepath.Join(picked, "Uninstall DeepSeek Harness.exe"), "MZ")
if a := dsh(home); !a.Detected() || !a.HasApp() {
t.Fatal("DeepSeek Harness in the registered folder not found")
}
}