The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
feat(cli): wire DeepSeek Harness into endpoint hooks
Claude284d762e6732
diff --git a/cli/beacon/cmd/dsh_target_test.go b/cli/beacon/cmd/dsh_target_test.gonew file mode 100644index 00000000..1972f59c--- /dev/null+++ b/cli/beacon/cmd/dsh_target_test.go@@ -0,0 +1,209 @@+package cmd++import (+ "os"+ "path/filepath"+ "strings"+ "testing"++ endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config"+ endpointhooks "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/hooks"+)++// The install -> status -> uninstall round trip for DeepSeek Harness, through the CLI entry points+// rather than the package API.+//+// Wiring a runtime into `beacon endpoint hooks` means five separate switches (install, uninstall,+// status collection, status printing, repair) plus a registry row, and every one of them fails by+// omission rather than by error. TestEveryHookTargetIsWired proves each switch has a case; this+// proves the cases do the thing their name claims -- and here that means both halves of a two-file+// install, either of which is inert on its own.+func TestEndpointHooksInstallAndUninstallDsh(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ t.Setenv("DSH_HOME", "")+ cfg := endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}++ origLevel := endpointOpts.hookLevel+ t.Cleanup(func() { endpointOpts.hookLevel = origLevel })+ endpointOpts.hookLevel = "user"++ hooksPath := filepath.Join(home, ".dsh", "beacon-endpoint-hooks.json")+ patchPath := filepath.Join(home, ".dsh", "cordis.patch.yml")++ if err := installEndpointHookTarget("dsh", cfg); err != nil {+ t.Fatalf("installEndpointHookTarget(dsh) returned error: %v", err)+ }+ hooks, err := os.ReadFile(hooksPath)+ if err != nil {+ t.Fatalf("install did not write %s: %v", hooksPath, err)+ }+ if !strings.Contains(string(hooks), "--platform dsh") {+ t.Fatalf("the hooks file does not carry the dsh hook command:\n%s", hooks)+ }+ patch, err := os.ReadFile(patchPath)+ if err != nil {+ t.Fatalf("install did not mount the bridge in %s: %v", patchPath, err)+ }+ if !strings.Contains(string(patch), "@deepseek-ai/dsh-hooks-claude-code") {+ t.Fatalf("the patch file does not mount the hook bridge:\n%s", patch)+ }+ if !strings.Contains(string(patch), hooksPath) {+ t.Fatalf("the mount does not point at the hooks file Beacon wrote:\n%s", patch)+ }++ if !endpointhooks.IsDshInstalled(endpointhooks.DshOptions{+ Level: endpointhooks.LevelUser, LogPath: cfg.LogPath, UserMode: true,+ }) {+ t.Fatal("IsDshInstalled = false after installEndpointHookTarget")+ }++ if err := uninstallEndpointHookTarget("dsh", cfg); err != nil {+ t.Fatalf("uninstallEndpointHookTarget(dsh) returned error: %v", err)+ }+ if _, err := os.Stat(hooksPath); !os.IsNotExist(err) {+ t.Fatalf("uninstall left the hooks file behind: %v", err)+ }+ // The one that would break the runtime rather than merely leave litter: an empty or+ // comments-only patch file fails dsh boot, so an uninstall that emptied it must remove it.+ if _, err := os.Stat(patchPath); !os.IsNotExist(err) {+ t.Fatalf("uninstall left a patch file behind; an empty patch layer fails dsh boot: %v", err)+ }+}++// `endpoint hooks repair` walks a hard-coded list rather than the registry, so a runtime absent+// from it is never repaired -- and repair is what fixes a hook whose binary path went stale after+// an upgrade. It fails silently: repair reports success having skipped the runtime entirely.+func TestDshIsInTheRepairTargetList(t *testing.T) {+ for _, name := range repairTargetOrder() {+ if name == "dsh" {+ return+ }+ }+ t.Fatal("dsh is missing from the repair target list; `endpoint repair` would silently skip it")+}++// Every spelling a person plausibly types resolves to the one hook target, in both namespaces.+func TestDshHarnessSpellingsResolveToTheHookTarget(t *testing.T) {+ for _, spelling := range []string{+ "dsh", "DSH", " dsh ", "Dsh",+ "deepseek-harness", "deepseek_harness", "DeepSeek-Harness", "deepseekharness",+ } {+ t.Run(spelling, func(t *testing.T) {+ target, ok := normalizeEndpointTarget(spelling)+ if !ok {+ t.Fatalf("normalizeEndpointTarget(%q) = not found", spelling)+ }+ if target.Name != "dsh" || target.Kind != endpointTargetHook {+ t.Fatalf("normalizeEndpointTarget(%q) = %+v, want the dsh hook target", spelling, target)+ }+ if got, ok := normalizeHookTarget(spelling); !ok || got != "dsh" {+ t.Fatalf("normalizeHookTarget(%q) = %q, %t; want dsh, true", spelling, got, ok)+ }+ })+ }+}++// Bare "deepseek" names the vendor and the model family. Accepting it as a target would let+// somebody ask to install hooks for a model, which is the same reason NormalizeHarnessName leaves+// it unmapped -- and it is the spelling a user is most likely to reach for, so it is pinned as a+// decision rather than left to be re-litigated.+func TestBareDeepSeekIsNotAHookTarget(t *testing.T) {+ for _, spelling := range []string{"deepseek", "deepseek-chat", "deepseek-r1", "deepseek-v3"} {+ t.Run(spelling, func(t *testing.T) {+ if target, ok := normalizeEndpointTarget(spelling); ok && target.Name == "dsh" {+ t.Fatalf("normalizeEndpointTarget(%q) resolved to the dsh hook target", spelling)+ }+ })+ }+}++// dsh is swept by --all at user scope and filtered out at project scope. The filtering is not+// cosmetic: install and uninstall both return on the first target error, so a target that refuses+// project scope would abort the sweep and silently skip every target ordered after it.+func TestDshIsSweptAtUserScopeOnly(t *testing.T) {+ origLevel := endpointOpts.hookLevel+ t.Cleanup(func() { endpointOpts.hookLevel = origLevel })++ endpointOpts.hookLevel = "user"+ if !containsTarget(allHookTargetsForLevel(), "dsh") {+ t.Fatalf("user-level --all dropped dsh:\n%v", allHookTargetsForLevel())+ }+ endpointOpts.hookLevel = "project"+ if containsTarget(allHookTargetsForLevel(), "dsh") {+ t.Fatalf("project-level --all kept dsh, whose installer refuses that level:\n%v",+ allHookTargetsForLevel())+ }+ if !userScopeOnlyHookTargets["dsh"] {+ t.Fatal("dsh is not marked user scope only; dsh composes its plugin tree from the " ++ "Harness home, so a repository has nowhere to mount a hook bridge from")+ }+}++// A project-scope install is refused with its reason rather than silently becoming a machine-wide+// one. An operator asking for a repository-scoped install must not get something else.+func TestEndpointHooksDshRefusesProjectLevel(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ t.Setenv("DSH_HOME", "")+ cfg := endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}++ origLevel := endpointOpts.hookLevel+ t.Cleanup(func() { endpointOpts.hookLevel = origLevel })+ endpointOpts.hookLevel = "project"++ err := installEndpointHookTarget("dsh", cfg)+ if err == nil {+ t.Fatal("a project-level dsh install succeeded; there is no project-scoped hook config")+ }+ if !strings.Contains(err.Error(), "user scope") {+ t.Fatalf("error %q does not tell the operator what to do instead", err)+ }+ if _, statErr := os.Stat(filepath.Join(home, ".dsh")); !os.IsNotExist(statErr) {+ t.Fatal("the refused install wrote into the Harness home anyway")+ }+}++// The user's own rows in the patch layer survive the round trip. This is the property that makes+// editing a file Beacon does not own defensible, checked here through the CLI rather than the+// package API because the CLI is what an operator actually runs.+func TestEndpointHooksDshLeavesTheUsersPatchRowsAlone(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ t.Setenv("DSH_HOME", "")+ cfg := endpointconfig.Config{LogPath: filepath.Join(home, "runtime.jsonl"), UserMode: true}++ origLevel := endpointOpts.hookLevel+ t.Cleanup(func() { endpointOpts.hookLevel = origLevel })+ endpointOpts.hookLevel = "user"++ patchPath := filepath.Join(home, ".dsh", "cordis.patch.yml")+ if err := os.MkdirAll(filepath.Dir(patchPath), 0755); err != nil {+ t.Fatalf("mkdir: %v", err)+ }+ theirs := "# our overlay\n- insert:\n - id: schedule\n name: '@deepseek-ai/dsh-schedule'\n"+ if err := os.WriteFile(patchPath, []byte(theirs), 0644); err != nil {+ t.Fatalf("write: %v", err)+ }++ if err := installEndpointHookTarget("dsh", cfg); err != nil {+ t.Fatalf("installEndpointHookTarget(dsh) returned error: %v", err)+ }+ if err := uninstallEndpointHookTarget("dsh", cfg); err != nil {+ t.Fatalf("uninstallEndpointHookTarget(dsh) returned error: %v", err)+ }++ after, err := os.ReadFile(patchPath)+ if err != nil {+ t.Fatalf("the user's patch file did not survive: %v", err)+ }+ if !strings.Contains(string(after), "id: schedule") || !strings.Contains(string(after), "# our overlay") {+ t.Fatalf("the user's rows or comments were lost:\n%s", after)+ }+ if strings.Contains(string(after), "dsh-hooks-claude-code") {+ t.Fatalf("Beacon's mount survived the uninstall:\n%s", after)+ }+}diff --git a/cli/beacon/cmd/endpoint_diagnostics.go b/cli/beacon/cmd/endpoint_diagnostics.goindex fb3ee91a..dff25c31 100644--- a/cli/beacon/cmd/endpoint_diagnostics.go+++ b/cli/beacon/cmd/endpoint_diagnostics.go@@ -946,7 +946,9 @@ func hookTargets() ([]string, error) {// userScopeOnlyHookTargets are the targets whose installers refuse LevelProject outright, because// the runtime registers hooks only from a user-level config: Hermes has no project config at all,-// and Muse's project .muse/hooks.json is ignored by the shipping build.+// Muse's project .muse/hooks.json is ignored by the shipping build, and DeepSeek Harness composes+// its plugin tree from the Harness home, so there is nowhere in a repository to mount a hook+// bridge from.//// They are filtered out of the project-level --all list rather than left in to fail. Install and// uninstall both return on the first target error, so one refusing target does not just report@@ -954,10 +956,11 @@ func hookTargets() ([]string, error) {var userScopeOnlyHookTargets = map[string]bool{"hermes": true,"muse": true,+ "dsh": true,}func allHookTargetsForLevel() []string {- all := []string{"cursor", "codex", "vscode", "factory", "opencode", "openhands", "kiro", "cline", "pi", "omp", "prime", "omo", "openclaw", "grok", "qwen", "muse", "hermes", "devin-cli", "devin-desktop", "antigravity"}+ all := []string{"cursor", "codex", "vscode", "factory", "opencode", "openhands", "kiro", "dsh", "cline", "pi", "omp", "prime", "omo", "openclaw", "grok", "qwen", "muse", "hermes", "devin-cli", "devin-desktop", "antigravity"}if endpointOpts.hookLevel != "project" {return all}@@ -1029,6 +1032,12 @@ func hookStatusesWithConfig(targets []string, cfg endpointconfig.Config) map[strcase "openhands":status := endpointhooks.OpenHandsHookStatus(endpointhooks.OpenHandsOptions{Level: endpointhooks.Level(endpointOpts.hookLevel), LogPath: cfg.LogPath, UserMode: cfg.UserMode})statuses[name] = hookTargetResult{Target: name, Status: targetStatus(status.Installed), Installed: status.Installed, Message: status.Message, Path: status.HooksPath, Raw: status}+ case "dsh":+ status := endpointhooks.DshHookStatus(endpointhooks.DshOptions{Level: endpointhooks.Level(endpointOpts.hookLevel), LogPath: cfg.LogPath, UserMode: cfg.UserMode})+ // Path is the hooks file, which is the one a person would open. The patch file that+ // mounts the bridge at it rides along in Raw, where the JSON output keeps it -- this+ // struct carries one path and the install has two.+ statuses[name] = hookTargetResult{Target: name, Status: targetStatus(status.Installed), Installed: status.Installed, Message: status.Message, Path: status.HooksPath, Raw: status}case "kiro":status := endpointhooks.KiroHookStatus(endpointhooks.KiroOptions{Level: endpointhooks.Level(endpointOpts.hookLevel), LogPath: cfg.LogPath, UserMode: cfg.UserMode})statuses[name] = hookTargetResult{Target: name, Status: targetStatus(status.Installed), Installed: status.Installed, Message: status.Message, Path: status.HooksPath, Raw: status}diff --git a/cli/beacon/cmd/endpoint_hooks.go b/cli/beacon/cmd/endpoint_hooks.goindex cabe2686..c7bbae81 100644--- a/cli/beacon/cmd/endpoint_hooks.go+++ b/cli/beacon/cmd/endpoint_hooks.go@@ -247,6 +247,24 @@ func installEndpointHookTarget(name string, cfg endpointconfig.Config) error {"and its agent server (used by the CLI and the GUI) reads only the repository file. " +"Run the install again with --level project inside a repository to cover those.")}+ case "dsh":+ status, err := endpointhooks.InstallDsh(endpointhooks.DshOptions{+ Level: endpointhooks.Level(endpointOpts.hookLevel),+ LogPath: cfg.LogPath,+ UserMode: cfg.UserMode,+ })+ if err != nil {+ return err+ }+ // Both paths, because the install is two files and the mount is the half an operator is+ // least likely to guess at. Naming only the hooks file would send somebody looking for a+ // mount that is not there.+ fmt.Printf("DeepSeek Harness hooks installed: %s\n", status.HooksPath)+ fmt.Printf("DeepSeek Harness hook bridge mounted in: %s\n", status.PatchPath)+ // Said on every install, because a running dsh will not pick this up on its own unless the+ // profile enabled HMR -- and the symptom otherwise is a successful install collecting+ // nothing until the next restart, which reads as a broken install.+ fmt.Println("Restart dsh (or rely on its config watcher, if your profile enables HMR) for the hooks to take effect.")case "kiro":status, err := endpointhooks.InstallKiro(endpointhooks.KiroOptions{Level: endpointhooks.Level(endpointOpts.hookLevel),@@ -504,6 +522,16 @@ func uninstallEndpointHookTarget(name string, cfg endpointconfig.Config) error {return err}fmt.Println(status.Message)+ case "dsh":+ status, err := endpointhooks.UninstallDsh(endpointhooks.DshOptions{+ Level: endpointhooks.Level(endpointOpts.hookLevel),+ LogPath: cfg.LogPath,+ UserMode: cfg.UserMode,+ })+ if err != nil {+ return err+ }+ fmt.Println(status.Message)case "kiro":status, err := endpointhooks.UninstallKiro(endpointhooks.KiroOptions{Level: endpointhooks.Level(endpointOpts.hookLevel),@@ -670,6 +698,12 @@ func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {LogPath: cfg.LogPath,UserMode: cfg.UserMode,})+ case "dsh":+ statuses["dsh"] = endpointhooks.DshHookStatus(endpointhooks.DshOptions{+ Level: endpointhooks.Level(endpointOpts.hookLevel),+ LogPath: cfg.LogPath,+ UserMode: cfg.UserMode,+ })case "kiro":statuses["kiro"] = endpointhooks.KiroHookStatus(endpointhooks.KiroOptions{Level: endpointhooks.Level(endpointOpts.hookLevel),@@ -778,6 +812,14 @@ func runEndpointHooksStatus(cmd *cobra.Command, args []string) error {status := statuses["openhands"].(endpointhooks.OpenHandsStatus)fmt.Printf("OpenHands hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)fmt.Println(status.Message)+ case "dsh":+ status := statuses["dsh"].(endpointhooks.DshStatus)+ // Both paths again, and here it is diagnostic rather than informational: installed is+ // the conjunction of the two files, so an operator reading installed=false needs to+ // know which one to look at.+ fmt.Printf("DeepSeek Harness hooks: installed=%t path=%s patch=%s\n",+ status.Installed, status.HooksPath, status.PatchPath)+ fmt.Println(status.Message)case "kiro":status := statuses["kiro"].(endpointhooks.KiroStatus)fmt.Printf("Kiro hooks: installed=%t path=%s\n", status.Installed, status.HooksPath)diff --git a/cli/beacon/cmd/endpoint_hooks_repair.go b/cli/beacon/cmd/endpoint_hooks_repair.goindex 22069db4..76ca098f 100644--- a/cli/beacon/cmd/endpoint_hooks_repair.go+++ b/cli/beacon/cmd/endpoint_hooks_repair.go@@ -148,7 +148,7 @@ func installedHookTargetsForUser(homeDir, logPath string) ([]string, error) {}func repairTargetOrder() []string {- return []string{"claude", "codex", "cursor", "vscode", "factory", "opencode", "openhands", "kiro", "cline", "pi", "omp", "prime", "omo", "openclaw", "grok", "qwen", "muse", "hermes", "devin-cli", "devin-desktop", "antigravity"}+ return []string{"claude", "codex", "cursor", "vscode", "factory", "opencode", "openhands", "kiro", "dsh", "cline", "pi", "omp", "prime", "omo", "openclaw", "grok", "qwen", "muse", "hermes", "devin-cli", "devin-desktop", "antigravity"}}// withUserHome runs fn as if it were executing inside another user's profile.diff --git a/cli/beacon/cmd/endpoint_targets.go b/cli/beacon/cmd/endpoint_targets.goindex a48ed907..6d08a330 100644--- a/cli/beacon/cmd/endpoint_targets.go+++ b/cli/beacon/cmd/endpoint_targets.go@@ -85,6 +85,17 @@ var harnessTargets = []harnessTarget{// that is All Hands' model family, and accepting it would let someone ask to install hooks for// a model.{name: "openhands", endpointKind: endpointTargetHook, endpointAliases: []string{"openhands", "open-hands"}, hookAliases: []string{"openhands", "open-hands"}},+ // DeepSeek Harness. One row for every surface, because the CLI, Web, ACP and SDK are four+ // compositions of one harness booting from one Harness home -- and Beacon installs into the+ // home-level patch layer, which applies to all of them. "dsh" is the binary, the --platform+ // value and the shortest unambiguous spelling; "deepseek-harness" and "deepseek_harness" are+ // what the product is called and the canonical harness name events are written under, so a row+ // read out of the runtime log and passed back to --harness resolves to the runtime it names.+ //+ // Bare "deepseek" is deliberately not an alias, and it is the one a user is most likely to+ // type. It names the vendor and the model family, and accepting it would let someone ask to+ // install hooks for a model -- the same reason NormalizeHarnessName leaves it unmapped.+ {name: "dsh", endpointKind: endpointTargetHook, endpointAliases: []string{"dsh", "deepseek-harness", "deepseek_harness", "deepseekharness"}, hookAliases: []string{"dsh", "deepseek-harness", "deepseek_harness", "deepseekharness"}},// Kiro. One row for the IDE and the CLI together, because they are one harness reading one// hooks directory -- so "kiro-ide" and "kiro-cli" are aliases of the same install rather than// two targets, and asking for either gets the one that covers both. "kiro" is also the