Files
magpie/internal/library/dsbot_test.go
T
yetone fefe3f658c library: DS Bot gets MCP servers, skills and instructions in its own DSH home (#5897)
sunset on Discord: DS Bot (ds-bot) can be given a magpie model, but the
Library's MCP page offered no DS Bot. It had no target in targetOf and was
listed "not looked at (#5897)" in noLibrary.

DS Bot's desktop app runs its own DSH (0.2.2-rc.1 in DS Bot 0.3.8) with
DSH_HOME at its data folder (agent.dsbotHome; app/src/main.mjs) and boots
the profile ds-bot (app/src/profile.mjs) with dsh-base's bundles. Read
from github.com/Fei2411/DS-Bot and the npm packages at 0.2.2-rc.1:
- dsh-agent-instructions reads $DSH_HOME/AGENTS.md (then CLAUDE.md);
- dsh-skill-filesystem reads $DSH_HOME/skills and ~/.agents/skills, and
  a project's .agents/skills;
- dsh-mcp-client is in the app's installation (a dependency of
  @deepseek-ai/dsh in app/package-lock.json), so a patch list's insert
  row naming it loads, as in dsh; DS Bot's own bundle patch disables
  none of these.
So ds-bot gets dsh's target on its own home: AGENTS.md, skills, and
MCP rows in every profile's patch list (agent.DshPatchFiles, which globs
profiles/*/cordis.patch.yml, profiles/ds-bot's included). It reads
~/.agents/skills too (readsShared) and .agents/skills in a project.

#5624: when DSH_HOME names DS Bot's folder, the dsh agent's home is
DS Bot's. The Library's dsh target now steps back there
(agent.DshAppHome), so the two agents' rows are never written into one
patch list under two names. This doesn't fix #5624's model wiring.

Run (all at 3b47e8745 rebased on efcf8d9c0, on mica since mote was
over its cores):
- go test -timeout 45m -count=1 ./internal/library ./internal/agent: ok
- GOOS=linux and GOOS=windows go vet ./internal/library ./internal/agent: ok
- gofmt -l internal/library internal/agent: clean
At the first base (4f94b8a82, on mote): the same go test and vet ok,
and node --test internal/gui/tests library-mcp-*.test.cjs,
library-all and library-gone-agents in Chromium and WebKit: 330 of 330
pass. No GUI file changes here; the page lists agents from the API.

Broken by hand: renaming the ds-bot case turned TestDsbotLibraryTarget,
TestDshNotOnDsbotHome and TestEveryAgentInLibrary red; dropping the
DshAppHome check turned TestDshNotOnDsbotHome red.

Not tried: a real DS Bot app loading the server (no DS Bot install on
the test machines); Windows and Linux runs of the package.
2026-11-17 21:31:45 +08:00

81 lines
2.7 KiB
Go

package library
import (
"os"
"path/filepath"
"strings"
"testing"
)
// DS Bot's own DSH runs on its data folder (~/.ds-bot by default) with the
// profile ds-bot: the Library gives it MCP servers in that profile's patch
// list, its instructions in AGENTS.md there and its skills in its skills
// folder, as dsh's are given in ~/.dsh, and nothing of it reaches ~/.dsh
// (sunset on Discord: DS Bot was in no picker of the Library's MCP page).
func TestDsbotLibraryTarget(t *testing.T) {
h := sandbox(t)
home := filepath.Join(h, ".ds-bot")
p := filepath.Join(home, "profiles", "ds-bot", "cordis.patch.yml")
dshP := filepath.Join(h, ".dsh", "profiles", "web", "cordis.patch.yml")
const tmpl = "# Your patch layer for this dsh profile, applied after every bundle layer:\n[]\n"
write(t, p, tmpl)
write(t, dshP, tmpl)
tg := targetByID("ds-bot")
if tg == nil {
t.Fatal("ds-bot: no target")
}
if tg.MCP == nil || tg.MCP.Path != p || tg.MCP.Format != fmtDsh {
t.Fatalf("ds-bot MCP: %+v", tg.MCP)
}
if tg.Instructions != filepath.Join(home, "AGENTS.md") || tg.Skills != filepath.Join(home, "skills") {
t.Fatalf("ds-bot: instructions %q skills %q", tg.Instructions, tg.Skills)
}
ok(t)(SaveServer("", Server{Name: "fs", Transport: "stdio", Command: "npx", Args: []string{"-y", "@mcp/fs"}, Agents: []string{"ds-bot"}}))
s := read(t, p)
for _, want := range []string{"- insert: # magpie\n - id: magpie-mcp-fs\n", "name: \"@deepseek-ai/dsh-mcp-client\"", `serverName: "fs"`} {
if !strings.Contains(s, want) {
t.Fatalf("missing %q in\n%s", want, s)
}
}
if got := read(t, dshP); got != tmpl {
t.Fatalf("dsh's profile written for DS Bot:\n%s", got)
}
v, err := Read(nil)
if err != nil {
t.Fatal(err)
}
listed := false
for _, a := range v.Agents {
if a.ID == "ds-bot" {
listed = a.MCP == p && a.Instructions != "" && a.Skills != ""
}
}
if !listed {
t.Fatal("ds-bot: not on the Library's pages")
}
for _, sv := range v.Servers {
if sv.Name == "fs" && (len(sv.Agents) != 1 || sv.Agents[0] != "ds-bot") {
t.Fatalf("fs is on %v", sv.Agents)
}
}
}
// A DSH_HOME naming DS Bot's folder (#5624) doesn't make that folder dsh's
// in the Library too: DS Bot's target has it, and dsh none, so no two
// agents' rows are written into one patch list.
func TestDshNotOnDsbotHome(t *testing.T) {
h := sandbox(t)
home := filepath.Join(h, ".ds-bot")
write(t, filepath.Join(home, "profiles", "ds-bot", "cordis.patch.yml"), "[]\n")
t.Setenv("DSH_HOME", home)
if err := os.MkdirAll(filepath.Join(h, ".dsh"), 0o755); err != nil {
t.Fatal(err)
}
if targetByID("ds-bot") == nil {
t.Fatal("ds-bot: no target")
}
if tg := targetByID("dsh"); tg != nil {
t.Fatalf("dsh given DS Bot's folder: %+v", tg.MCP)
}
}