From ee3f83b59d0459990cdfa0d42ff42b35a0ccfaf6 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 9 Oct 2026 12:52:10 +0800 Subject: [PATCH] =?UTF-8?q?agents:=20DeepSeek=20Harness=20Desktop=20instal?= =?UTF-8?q?led=20is=20no=20missing=20dsh=20CLI=20=E2=80=94=20its=20version?= =?UTF-8?q?=20shows=20instead=20of=20=E6=9C=AA=E6=89=BE=E5=88=B0=20CLI=20(?= =?UTF-8?q?star=20on=20Discord)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit star on Discord: "DeepSeek Harness 就是现在已经有桌面版了,但是他还是非要找CLI". With DeepSeek Harness Desktop in use and no dsh on PATH, the Agents page said 未找到 CLI and Install another agent offered npm's dsh: CLIMissing (#843) took ~/.dsh without a CLI for an uninstall. The desktop app (DeepSeek Harness.app, com.deepseek.dsh, 0.2.0-rc.2 from download.deepseek.com) keeps the same ~/.dsh — its own profile, profiles/desktop/cordis.patch.yml, and .credentials.yaml — and needs no CLI; its terminal command (Manage dsh Command…) is optional. - desktopapp.go: dsh's app is known by its bundle id on macOS and by %LOCALAPPDATA%\Programs\DeepSeek Harness\DeepSeek Harness.exe on Windows (electron-builder per-user NSIS, productName DeepSeek Harness, getWindowsInstallationDirName); HasApp says either is installed. - install.go: CLIMissing is false with the agent's desktop app installed, so the GUI row, Install another agent and /api all follow; the app's version shows through the existing CLI().App path. - dsh.go: the restart notice also sees DeepSeek Harness.app running. The red "已不经过 magpie" line in the report is a separate dshCheck finding, not caused by the missing CLI: a desktop-only ~/.dsh shaped from the app's real new-profile template wires cleanly (Check "", no Drift; TestDshDesktopOnlyWired). The reporter's exact detail is cut off in the screenshot and is not reproduced. Run: TestDshDesktopAppIsNoMissingCLI fails on the old code ("with the desktop app: missing true, offered true"; with the Windows path removed, "with the Windows app: missing true, offered true"), passes with the fix. go test -tags nogui ./internal/agent ./internal/gui under a temp HOME with pinned caches: ok. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on both packages; go build darwin, GOOS=linux -tags nogui, GOOS=windows: ok. Not tried: the real desktop app running live (not installed here; its userData isn't redirected by a sandbox HOME), a real Windows install. --- internal/agent/desktopapp.go | 53 +++++++-- internal/agent/dsh.go | 2 +- internal/agent/dsh_desktop_test.go | 157 +++++++++++++++++++++++++ internal/agent/install.go | 7 +- internal/agent/install_missing_test.go | 4 + 5 files changed, 212 insertions(+), 11 deletions(-) create mode 100644 internal/agent/dsh_desktop_test.go diff --git a/internal/agent/desktopapp.go b/internal/agent/desktopapp.go index 12b7d192a..b8aef0774 100644 --- a/internal/agent/desktopapp.go +++ b/internal/agent/desktopapp.go @@ -6,6 +6,8 @@ import ( "regexp" "runtime" "strings" + + "github.com/yetone/magpie/internal/appdir" ) // An agent that is a desktop app as well as a CLI has the app's version shown @@ -17,27 +19,42 @@ import ( // bundle id, and the names it has been installed under. OpenAI's Codex app // is ChatGPT.app (com.openai.codex) since it took ChatGPT's name; the bundle // id tells it from the ChatGPT chat app (com.openai.chat) of the same name. +// win is its executable under %LOCALAPPDATA%\Programs, where a per-user +// installer puts it on Windows, "" for one magpie doesn't know there. type desktopApp struct { id string names []string + win string } var desktopApps = map[string]desktopApp{ "codex": {id: "com.openai.codex", names: []string{"ChatGPT.app", "Codex.app"}}, + // DeepSeek Harness Desktop (0.2.0-rc.2's DeepSeek Harness.app, + // com.deepseek.dsh) reads ~/.dsh as the CLI does — its own profile, + // profiles/desktop, beside the CLI's — and needs no CLI: its terminal + // command is optional (star on Discord: 未找到 CLI with the desktop app + // in use). On Windows its installer (electron-builder's per-user NSIS, + // productName DeepSeek Harness) puts it under %LOCALAPPDATA%\Programs. + "dsh": {id: "com.deepseek.dsh", names: []string{"DeepSeek Harness.app"}, win: filepath.Join("DeepSeek Harness", "DeepSeek Harness.exe")}, } // appFolders are where apps are installed; a var so tests can point it -// elsewhere. Only macOS's are known: the Codex app on Windows is a Store -// package magpie doesn't read yet. +// elsewhere: /Applications and ~/Applications on macOS, %LOCALAPPDATA%\Programs +// on Windows (the Codex app there is a Store package magpie doesn't read yet). var appFolders = func() []string { - if runtime.GOOS != "darwin" { - return nil + switch runtime.GOOS { + case "darwin": + dirs := []string{"/Applications"} + if home, err := os.UserHomeDir(); err == nil { + dirs = append(dirs, filepath.Join(home, "Applications")) + } + return dirs + case "windows": + if local := appdir.Getenv("LOCALAPPDATA"); local != "" { + return []string{filepath.Join(local, "Programs")} + } } - dirs := []string{"/Applications"} - if home, err := os.UserHomeDir(); err == nil { - dirs = append(dirs, filepath.Join(home, "Applications")) - } - return dirs + return nil } var ( @@ -68,3 +85,21 @@ func (a *Agent) AppVersion() string { } return "" } + +// HasApp reports whether the agent's desktop app is installed here: its +// bundle on macOS (AppVersion), its executable on Windows. +func (a *Agent) HasApp() bool { + if a.AppVersion() != "" { + return true + } + app, ok := desktopApps[a.ID] + if !ok || a.WSL != "" || app.win == "" { + return false + } + for _, dir := range appFolders() { + if isFile(filepath.Join(dir, app.win)) { + return true + } + } + return false +} diff --git a/internal/agent/dsh.go b/internal/agent/dsh.go index 227d5e02d..607eafe82 100644 --- a/internal/agent/dsh.go +++ b/internal/agent/dsh.go @@ -100,7 +100,7 @@ func dshAt(at place) *Agent { Sync: func() error { return dshSync(dir, gw()) }, Notice: func() string { var notes []string - if Running(`(^|/)dsh( |$)`) { + if Running(`DeepSeek Harness\.app/`, `(^|/)dsh( |$)`) { if len(dshProfiles(dir)) > 0 { notes = append(notes, "New dsh sessions start on this; one already open keeps its model until you pick another in it. A dsh started with -p or in a terminal reads it at start-up.") } else { diff --git a/internal/agent/dsh_desktop_test.go b/internal/agent/dsh_desktop_test.go new file mode 100644 index 000000000..3b7af9723 --- /dev/null +++ b/internal/agent/dsh_desktop_test.go @@ -0,0 +1,157 @@ +package agent + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +// dshAppPlist is DeepSeek Harness Desktop's Info.plist as its 0.2.0-rc.2 +// macOS build ships it (download.deepseek.com's dsh-latest-macos-arm64.dmg), +// cut to the keys around the ones read, in their order and indentation. +const dshAppPlist = ` + + + + CFBundleDisplayName + DeepSeek Harness + CFBundleExecutable + DeepSeek Harness + CFBundleIconFile + icon.icns + CFBundleIdentifier + com.deepseek.dsh + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + DeepSeek Harness + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.2.0-rc.2 + CFBundleVersion + 0.2.0-rc.2 + + +` + +// dshDesktopPatch is the patch list dsh writes for a new profile +// (PROFILE_PATCH_TEMPLATE in the app's dsh-app-boot), which is what the +// desktop app's profiles/desktop/cordis.patch.yml holds after its first start. +const dshDesktopPatch = "# Your patch layer for this dsh profile, applied after every bundle layer:\n" + + "# a top-level YAML array of loader patch entries (id-targeted config\n" + + "# overrides, disables, and insert lists; `!!js` expressions allowed).\n" + + "[]\n" + +// star on Discord (2026-10-09): 有一个bug DeepSeek Harness 就是现在已经有桌面版 +// 了,但是他还是非要找CLI. With DeepSeek Harness Desktop in use and no dsh +// CLI, the Agents page said 未找到 CLI and offered dsh's npm install. The +// desktop app keeps ~/.dsh as the CLI does and needs no CLI, so with it +// installed the folder is no sign of an uninstall: its version is shown +// instead, on macOS and Windows alike. +func TestDshDesktopAppIsNoMissingCLI(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("DSH_HOME", "") + t.Setenv("PATH", t.TempDir()) // no dsh CLI + apps, userApps := t.TempDir(), t.TempDir() + was := appFolders + appFolders = func() []string { return []string{apps, userApps} } + t.Cleanup(func() { appFolders = was }) + desktop := filepath.Join(home, ".dsh", "profiles", "desktop", "cordis.patch.yml") + if err := os.MkdirAll(filepath.Dir(desktop), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(desktop, []byte(dshDesktopPatch), 0o644); err != nil { + t.Fatal(err) + } + a := dsh(home) + // a name no machine has: proc.FindTool also looks where users' tools go + a.Bin = "magpie-test-gone-dsh" + offered := func() bool { + for _, x := range installsOf([]*Agent{a}, "darwin", true) { + if x.ID == "dsh" { + return true + } + } + return false + } + + // no app: ~/.dsh left without its CLI is still said (#843) + if !a.Detected() || !a.CLIMissing() || !offered() { + t.Fatalf("no app, no CLI: detected %v, missing %v, offered %v", a.Detected(), a.CLIMissing(), offered()) + } + + // the macOS app in ~/Applications + installApp(t, userApps, "DeepSeek Harness.app", dshAppPlist) + if a.CLIMissing() || offered() { + t.Fatalf("with the desktop app: missing %v, offered %v", a.CLIMissing(), offered()) + } + if c, ok := a.CLI(); !ok || c.App != "0.2.0-rc.2" || c.Version != "" { + t.Fatalf("the desktop app's version: %+v %v", c, ok) + } + + // another app under that name is not dsh's + os.RemoveAll(filepath.Join(userApps, "DeepSeek Harness.app")) + installApp(t, apps, "DeepSeek Harness.app", strings.Replace(dshAppPlist, "com.deepseek.dsh", "com.example.other", 1)) + if !a.CLIMissing() { + t.Fatal("another bundle id taken for the desktop app") + } + + // Windows: the per-user installer's DeepSeek Harness.exe + exe := filepath.Join(apps, "DeepSeek Harness", "DeepSeek Harness.exe") + if err := os.MkdirAll(filepath.Dir(exe), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(exe, []byte("MZ"), 0o755); err != nil { + t.Fatal(err) + } + if a.CLIMissing() || offered() { + t.Fatalf("with the Windows app: missing %v, offered %v", a.CLIMissing(), offered()) + } + + // dsh in a WSL distro is not the Windows app's + if (&Agent{ID: "dsh@wsl:Ubuntu", WSL: "Ubuntu", Bin: "dsh"}).HasApp() { + t.Fatal("WSL twin has the Windows app") + } +} + +// The desktop app alone, its profile as its first start leaves it: magpie's +// model set goes into that profile and dsh's key store, and nothing reads it +// as no longer going through magpie. +func TestDshDesktopOnlyWired(t *testing.T) { + home, dir, _ := dshRouteHome(t) + t.Setenv("PATH", t.TempDir()) + desktop := filepath.Join(dir, "profiles", "desktop", "cordis.patch.yml") + if err := os.MkdirAll(filepath.Dir(desktop), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(desktop, []byte(dshDesktopPatch), 0o644); err != nil { + t.Fatal(err) + } + a := dsh(home) + if a.Path != desktop { + t.Fatalf("edits %s, not the desktop app's profile", a.Path) + } + if err := a.Field("model").Set("magpie/deepseek/flash"); err != nil { + t.Fatal(err) + } + b, _ := os.ReadFile(desktop) + if s := string(b); !strings.Contains(s, "apiKeyEnv: "+dshKeyRef) || !strings.Contains(s, "provider: "+dshRoute) { + t.Fatalf("the desktop profile has no route or start:\n%s", s) + } + if v, _ := os.ReadFile(filepath.Join(dir, ".credentials.yaml")); !strings.Contains(string(v), dshKeyRef+": ") { + t.Fatalf("no key in dsh's store:\n%s", v) + } + if got := a.Field("model").Get(); got != "magpie/deepseek/flash" { + t.Fatalf("model reads %q", got) + } + if d := a.Check(); d != "" { + t.Fatalf("check: %s", d) + } + if d := a.Drift(); d != nil { + t.Fatalf("drift: %+v", d) + } +} diff --git a/internal/agent/install.go b/internal/agent/install.go index 4df44edea..7457f8abe 100644 --- a/internal/agent/install.go +++ b/internal/agent/install.go @@ -198,11 +198,16 @@ var cliShared = map[string]bool{"codex": true, "claude": true, "gemini": true, " // folder or config is, its command-line program isn't — not on PATH nor // where users' tools go (proc.FindTool), as after an uninstall that left // ~/.dsh behind (#843). Only for an agent that is its CLI and that magpie -// knows an install command for, so the Agents page can offer it again. +// knows an install command for, so the Agents page can offer it again; one +// whose desktop app is installed (HasApp) is that app's settings, which need +// no CLI (DeepSeek Harness Desktop, star on Discord). func (a *Agent) CLIMissing() bool { if a.WSL != "" || a.detect != nil || a.Bin == "" || cliShared[a.ID] { return false } + if a.HasApp() { + return false + } if len(installCommands(a.ID, runtime.GOOS, true)) == 0 { return false } diff --git a/internal/agent/install_missing_test.go b/internal/agent/install_missing_test.go index 2ab25ac0e..8799115fa 100644 --- a/internal/agent/install_missing_test.go +++ b/internal/agent/install_missing_test.go @@ -18,6 +18,10 @@ func TestCLIMissing(t *testing.T) { t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) t.Setenv("PATH", t.TempDir()) + // no desktop app either, whatever this machine has installed + was := appFolders + appFolders = func() []string { return nil } + t.Cleanup(func() { appFolders = was }) bin := "magpie-test-gone-dsh" dir := filepath.Join(home, ".dsh") if err := os.MkdirAll(dir, 0o700); err != nil {