Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

feat(hooks): first-party DeepSeek Harness (DSH) lifecycle capture

Erifanfde393df1a73
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59954396..42bd4333 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,19 @@ version in [`docs/changelog/`](docs/changelog/):
## [Unreleased]
+### Added
+- Added first-party DeepSeek Harness (DSH) lifecycle capture. `install-hooks
+ --agent dsh` (aliases `deepseek-harness`, `deepseek_harness`) stages the
+ new `hooks/dsh` bundle, writes a generated Claude Code `hooks.json`, and
+ prints a Cordis patch fragment that mounts DSH's official
+ `@deepseek-ai/dsh-hooks-claude-code` bridge on
+ `$DSH_HOME/profiles/<profile>/cordis.patch.yml` (the patch file itself is
+ never auto-written). DSH sessions are stored as `agent=dsh`. The bridge
+ delivers exactly seven events (no `PreCompact` or `SessionEnd`) and runs
+ `SessionStart` detached, so finished sessions close with
+ `finalize-session --agent dsh` and pending handoffs are recovered via
+ `memory_handoff_list` / `memory_handoff_accept`. (#NNN)
+
## [3.1.0] - 2026-10-16
### Added
diff --git a/README.md b/README.md
index 0dc41bc1..c23fd6dc 100644
--- a/README.md
+++ b/README.md
@@ -161,7 +161,7 @@ caveats is in [`docs/support-matrix.md`](docs/support-matrix.md).
| IBM Bob | Supported |
| VS Code Copilot | MCP-only |
| Zed | MCP-only |
-| DeepSeek Harness (DSH) | MCP-only |
+| DeepSeek Harness (DSH) | Hooks + MCP |
| Prime Agent | MCP-only |
| Hermes Agent | Supported |
| GrizzyBot | Supported |
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index e2eac8e2..669ef88a 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -2478,6 +2478,18 @@ pub enum AgentChoice {
/// and injects plain `SessionStart` stdout into the model context.
#[value(name = "ibm-bob", alias = "bob")]
IbmBob,
+ /// DeepSeek Harness (DSH) — lifecycle capture through the official
+ /// `@deepseek-ai/dsh-hooks-claude-code` bridge, which consumes a Claude
+ /// Code `hooks.json`. `install-hooks --agent dsh` stages the hook
+ /// scripts, writes that generated `hooks.json`, and prints the Cordis
+ /// patch fragment to merge into `$DSH_HOME/profiles/<profile>/
+ /// cordis.patch.yml` (no fixed config file is written). The bridge
+ /// delivers exactly seven events and no `SessionEnd`, so close sessions
+ /// with `ai-memory finalize-session --agent dsh`; its detached
+ /// `SessionStart` means handoff recovery goes through the MCP
+ /// `memory_handoff_accept` tool.
+ #[value(alias = "deepseek-harness", alias = "deepseek_harness")]
+ Dsh,
}
impl AgentChoice {
@@ -2513,6 +2525,7 @@ impl AgentChoice {
Self::Muse => AgentKind::Muse,
Self::CodeBuddy => AgentKind::CodeBuddy,
Self::IbmBob => AgentKind::IbmBob,
+ Self::Dsh => AgentKind::Dsh,
}
}
@@ -4786,6 +4799,29 @@ mod tests {
}
}
+ #[test]
+ fn dsh_install_hooks_and_mcp_parse_with_both_aliases() {
+ for alias in ["dsh", "deepseek-harness", "deepseek_harness"] {
+ let hooks = Cli::try_parse_from(["ai-memory", "install-hooks", "--agent", alias])
+ .unwrap_or_else(|error| panic!("{alias}: {error}"));
+ let Command::InstallHooks(args) = hooks.command else {
+ panic!("expected install-hooks");
+ };
+ assert_eq!(args.agent, AgentChoice::Dsh);
+ assert_eq!(args.agent.kind(), ai_memory_core::AgentKind::Dsh);
+ // DSH runs a staged script bundle through the Claude Code hooks
+ // bridge, so it owns a `hooks/dsh` directory.
+ assert_eq!(args.agent.script_hook_subdir(), Some("dsh"));
+
+ let mcp = Cli::try_parse_from(["ai-memory", "install-mcp", "--client", alias])
+ .unwrap_or_else(|error| panic!("{alias}: {error}"));
+ let Command::InstallMcp(args) = mcp.command else {
+ panic!("expected install-mcp");
+ };
+ assert_eq!(args.client, McpClient::Dsh);
+ }
+ }
+
#[test]
fn muse_install_hooks_install_mcp_and_mcp_bridge_parse_with_their_aliases() {
for alias in ["muse", "muse-code", "musecode"] {
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rs
index 807664d0..cad62489 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -31,14 +31,15 @@ use crate::commands::openclaw_plugin;
use crate::commands::path_util::{home_dir, strip_windows_verbatim_prefix};
use crate::commands::render_shared::{
ANTIGRAVITY_LIFECYCLE_EVENTS, ANTIGRAVITY_TOOL_EVENTS, CODEX_PROFILE, COMMAND_CODE_PROFILE,
- COPILOT_CLI_PROFILE, CURSOR_PROFILE, GEMINI_PROFILE, KIMI_CODE_EVENTS, KIRO_CLI_V2_EVENTS,
- KIRO_CLI_V3_EVENTS, POOL_EVENTS, build_antigravity_payload_with_data_dir,
+ COPILOT_CLI_PROFILE, CURSOR_PROFILE, DSH_EVENTS, GEMINI_PROFILE, KIMI_CODE_EVENTS,
+ KIRO_CLI_V2_EVENTS, KIRO_CLI_V3_EVENTS, POOL_EVENTS, build_antigravity_payload_with_data_dir,
build_claude_code_payload_with_data_dir, build_devin_payload_with_data_dir,
- build_grok_payload_with_data_dir, build_kiro_cli_v2_hooks_value, build_kiro_cli_v3_hooks_value,
- build_pool_settings_yaml_with_data_dir, build_profile_payload_for_agent,
- hook_embedded_exe_path, hook_script_for_claude_code, hook_script_for_current_platform,
- kimi_code_hook_commands, local_hook_policy_v1_supported, ts_auth_headers_fn,
- ts_capture_policy_v1, ts_string_literal, ts_timeout_signal,
+ build_dsh_hooks_payload, build_grok_payload_with_data_dir, build_kiro_cli_v2_hooks_value,
+ build_kiro_cli_v3_hooks_value, build_pool_settings_yaml_with_data_dir,
+ build_profile_payload_for_agent, hook_embedded_exe_path, hook_script_for_claude_code,
+ hook_script_for_current_platform, kimi_code_hook_commands, local_hook_policy_v1_supported,
+ ts_auth_headers_fn, ts_capture_policy_v1, ts_string_literal, ts_timeout_signal,
+ yaml_single_quote,
};
use crate::commands::uninstall::hook_command_is_ours;
use crate::config::{Config, DEFAULT_SERVER_URL};
@@ -1015,6 +1016,11 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(
};
apply_to_ibm_bob_settings(&path, &server_url, auth, &config.data_dir, &args)
}
+ AgentChoice::Dsh => {
+ let hooks_dir =
+ resolve_hooks_dir(args.hooks_dir.as_deref(), args.agent, &config.data_dir)?;
+ apply_to_dsh(&hooks_dir, &server_url, auth, &config.data_dir, &args)
+ }
};
}
let strategy = args.project_strategy.and_then(ProjectStrategyArg::baked);
@@ -1173,6 +1179,11 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(
AgentChoice::Muse => render_muse(&server_url, auth, &config.data_dir, strategy),
AgentChoice::CodeBuddy => render_codebuddy(&server_url, auth, &config.data_dir, strategy),
AgentChoice::IbmBob => render_ibm_bob(&server_url, auth, &config.data_dir, strategy),
+ AgentChoice::Dsh => {
+ let hooks_dir =
+ resolve_hooks_dir(args.hooks_dir.as_deref(), args.agent, &config.data_dir)?;
+ render_dsh(&hooks_dir, &server_url, auth, &config.data_dir, strategy)
+ }
}
}
@@ -1369,6 +1380,10 @@ fn existing_agent_config(args: &InstallHooksArgs) -> Option<String> {
AgentChoice::Muse => return None,
AgentChoice::CodeBuddy => codebuddy_settings_path().ok()?,
AgentChoice::IbmBob => ibm_bob_settings_path().ok()?,
+ // DSH's hook config is the generated `hooks.json` under the
+ // data dir; it carries no baked strategy worth re-reading
+ // (same reason Pool returns None).
+ AgentChoice::Dsh => return None,
}
};
std::fs::read_to_string(path).ok()
@@ -1797,6 +1812,10 @@ pub(crate) fn mcp_client_for_agent(agent: AgentChoice) -> Option<McpClient> {
// No first-party CodeBuddy MCP installer in this change.
AgentChoice::CodeBuddy => None,
AgentChoice::IbmBob => Some(McpClient::IbmBob),
+ // DSH has no fixed MCP config file to scrape a server URL or token
+ // from (install-mcp --client dsh is print-only), so pass explicit
+ // --server-url / --auth-token instead.
+ AgentChoice::Dsh => None,
}
}
@@ -7749,6 +7768,148 @@ fn apply_to_pool(
Ok(())
}
+/// Print DSH's generated Claude Code `hooks.json` plus the Cordis patch
+/// fragment that points the official `@deepseek-ai/dsh-hooks-claude-code`
+/// bridge at it. DSH has no fixed agent config file, so merging the patch
+/// into `$DSH_HOME/profiles/<profile>/cordis.patch.yml` is the operator's
+/// step; `--apply` stages the scripts and materializes the `hooks.json`
+/// first (see [`apply_to_dsh`]).
+fn render_dsh(
+ hooks_dir: &Path,
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: &Path,
+ project_strategy: Option<&str>,
+) -> Result<()> {
+ // Soft check (same rationale as render_claude_code): warn, don't bail,
+ // so the docker host-path flow still works.
+ for (_, script) in DSH_EVENTS {
+ let script = hook_script_for_current_platform(script);
+ let abs = hooks_dir.join(script.as_ref());
+ if !abs.exists() {
+ eprintln!(
+ "# warning: {} not present on this filesystem. \
+ If this command is running inside docker against a \
+ host path, you can ignore this; otherwise extract \
+ the scripts first with `ai-memory setup-agent`.",
+ abs.display()
+ );
+ }
+ }
+ print!(
+ "{}",
+ render_dsh_output(
+ hooks_dir,
+ server_url,
+ auth_token,
+ data_dir,
+ project_strategy
+ )
+ );
+ Ok(())
+}
+
+fn render_dsh_output(
+ hooks_dir: &Path,
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: &Path,
+ project_strategy: Option<&str>,
+) -> String {
+ let payload = build_dsh_hooks_payload(
+ hooks_dir,
+ server_url,
+ auth_token,
+ Some(data_dir),
+ project_strategy,
+ );
+ let mut out = String::new();
+ out.push_str("# DeepSeek Harness (DSH) hook config - DSH has no fixed agent\n");
+ out.push_str("# config file. ai-memory stages the hook scripts and generates a\n");
+ out.push_str("# Claude Code `hooks.json`; the official\n");
+ out.push_str("# `@deepseek-ai/dsh-hooks-claude-code` bridge reads it via its\n");
+ out.push_str("# `configPath`. Re-run with --apply first to stage the scripts\n");
+ out.push_str("# and materialize the hooks.json at a stable path.\n");
+ out.push_str(&format!("# Hook scripts: {}\n", hooks_dir.display()));
+ out.push_str(&format!("# AI-memory server URL: {server_url}\n"));
+ if auth_token.is_some() {
+ out.push_str("# Auth: AI_MEMORY_AUTH_TOKEN embedded in each hook command below.\n");
+ out.push_str("# Treat the hook config as sensitive (chmod 600).\n");
+ }
+ out.push_str("# NOTE: the bridge delivers exactly these seven events - no\n");
+ out.push_str("# PreCompact or SessionEnd, and SessionStart runs detached,\n");
+ out.push_str("# so capture works but handoff injection does not. Recover a\n");
+ out.push_str("# prior session's handoff via the MCP `memory_handoff_accept`\n");
+ out.push_str("# tool, and close a finished session with\n");
+ out.push_str("# `ai-memory finalize-session --agent dsh`.\n");
+ out.push('\n');
+ out.push_str(&serde_json::to_string_pretty(&payload).expect("static hook payload serializes"));
+ out.push_str("\n\n");
+ out.push_str(&dsh_bridge_patch_fragment(hooks_dir));
+ out
+}
+
+/// `--apply` for DSH: stage the hook scripts to the stable user-global
+/// location, materialize the generated `hooks.json` next to them, then print
+/// the Cordis patch fragment pointing the bridge at that file. DSH's
+/// `$DSH_HOME/profiles/<profile>/cordis.patch.yml` is a hand-maintained YAML
+/// patch layer (it can hold `!!js` expressions and unrelated plugin rows), so
+/// the merge is deliberately left to the operator - the same reason
+/// `install-mcp --client dsh` refuses to write MCP config.
+fn apply_to_dsh(
+ hooks_dir: &Path,
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: &Path,
+ args: &InstallHooksArgs,
+) -> Result<()> {
+ let staged = stage_hook_scripts(hooks_dir, "dsh", data_dir)?;
+ let command_dir = staged_command_dir(&staged, "dsh");
+ fs::create_dir_all(&command_dir)
+ .with_context(|| format!("creating hook staging dir {}", command_dir.display()))?;
+ let strategy = args.project_strategy.and_then(ProjectStrategyArg::baked);
+ let payload = build_dsh_hooks_payload(
+ &command_dir,
+ server_url,
+ auth_token,
+ Some(data_dir),
+ strategy,
+ );
+ let hooks_json = command_dir.join("hooks.json");
+ fs::write(
+ &hooks_json,
+ serde_json::to_string_pretty(&payload).expect("static hook payload serializes"),
+ )
+ .with_context(|| format!("writing {}", hooks_json.display()))?;
+ eprintln!("✓ wrote DSH hook config → {}", hooks_json.display());
+ print!("{}", dsh_bridge_patch_fragment(&command_dir));
+ Ok(())
+}
+
+/// The Cordis patch-list fragment that mounts the
+/// `@deepseek-ai/dsh-hooks-claude-code` bridge with `configPath` pointing at
+/// the generated `hooks.json` in `command_dir`. Shared by `install-hooks`
+/// and `setup-agent`.
+pub(crate) fn dsh_bridge_patch_fragment(command_dir: &Path) -> String {
+ let config_path = command_dir.join("hooks.json");
+ let mut out = String::new();
+ out.push_str("# DeepSeek Harness (DSH) - merge the entry below into the DSH\n");
+ out.push_str("# profile patch at $DSH_HOME/profiles/<profile>/cordis.patch.yml,\n");
+ out.push_str("# then reload or restart the profile (the web profile reloads live).\n");
+ out.push_str("#\n");
+ out.push_str("# The bridge runs the staged ai-memory hooks; a new top-level\n");
+ out.push_str("# - insert: item is fine - patch row order carries no load semantics.\n");
+ out.push_str("- insert:\n");
+ out.push_str(" - id: ai-memory-hooks\n");
+ out.push_str(" name: '@deepseek-ai/dsh-hooks-claude-code'\n");
+ out.push_str(" config:\n");
+ out.push_str(&format!(
+ " configPath: {}\n",
+ yaml_single_quote(&config_path.to_string_lossy())
+ ));
+ out
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -9494,6 +9655,93 @@ command = "AI_MEMORY_HOOK_URL=http://h AI_MEMORY_PROJECT_STRATEGY=repo-root /x/a
assert!(!out.contains("AI_MEMORY_AUTH_TOKEN embedded"));
}
+ #[test]
+ fn render_dsh_output_covers_all_bridge_events_and_states_manual_paste() {
+ let out = render_dsh_output(
+ Path::new("/staging/dsh"),
+ "http://127.0.0.1:49374",
+ None,
+ Path::new("/data"),
+ None,
+ );
+ // The Claude Code hooks.json document is embedded for the bridge.
+ assert!(out.contains("\"hooks\""));
+ for (event, _script) in DSH_EVENTS {
+ assert!(
+ out.contains(&format!("\"{event}\"")),
+ "missing {event} in: {out}"
+ );
+ }
+ // The seven bridge events, no more (keyed JSON, so the prose
+ // mentions of the omitted events in the guidance do not match).
+ assert!(!out.contains("\"PreCompact\""), "no PreCompact: {out}");
+ assert!(!out.contains("\"SessionEnd\""), "no SessionEnd: {out}");
+ // Manual merge guidance + the finalize/close path.
+ assert!(out.contains("cordis.patch.yml"));
+ assert!(out.contains("finalize-session --agent dsh"));
+ assert!(out.contains("memory_handoff_accept"));
+ assert!(out.contains("@deepseek-ai/dsh-hooks-claude-code"));
+ assert!(out.contains("configPath"));
+ // No token was passed, so none of the auth caution lines render.
+ assert!(!out.contains("AI_MEMORY_AUTH_TOKEN embedded"));
+ }
+
+ #[test]
+ fn dsh_bridge_patch_fragment_quotes_the_config_path() {
+ let out = dsh_bridge_patch_fragment(Path::new("/tmp/ai memory/hooks/dsh"));
+ assert!(out.contains("- insert:\n"));
+ assert!(out.contains(" - id: ai-memory-hooks\n"));
+ assert!(out.contains("name: '@deepseek-ai/dsh-hooks-claude-code'"));
+ // A path with spaces must stay a single quoted YAML scalar (the
+ // separator follows the host platform, hence Path::join).
+ let expected = Path::new("/tmp/ai memory/hooks/dsh")
+ .join("hooks.json")
+ .display()
+ .to_string();
+ assert!(
+ out.contains(&format!("configPath: '{expected}'")),
+ "expected quoted configPath in: {out}"
+ );
+ }
+
+ #[test]
+ fn apply_to_dsh_stages_scripts_and_writes_hooks_json() {
+ let root = TempDir::new().unwrap();
+ let data = TempDir::new().unwrap();
+ // Mirror the repo layout: `hooks/_lib.sh` one level above the
+ // `hooks/dsh` agent bundle, so staging copies the shared helper
+ // alongside the event scripts.
+ let source = root.path().join("hooks").join("dsh");
+ fs::create_dir_all(&source).unwrap();
+ let scripts = DSH_EVENTS
+ .iter()
+ .map(|(_, script)| *script)
+ .collect::<Vec<_>>();
+ stub_scripts(&source, &scripts);
+ fs::write(root.path().join("hooks").join("_lib.sh"), "#!/bin/sh\n").unwrap();
+ let mut args = default_hook_args();
+ args.agent = AgentChoice::Dsh;
+ apply_to_dsh(&source, "http://127.0.0.1:49374", None, data.path(), &args)
+ .expect("apply_to_dsh succeeds");
+
+ let staged = data.path().join("hooks").join("dsh");
+ assert!(staged.join("session-start.sh").is_file(), "scripts staged");
+ assert!(
+ staged.join("_lib.sh").is_file(),
+ "the shared _lib.sh helper is staged alongside"
+ );
+ let hooks_json = staged.join("hooks.json");
+ assert!(hooks_json.is_file(), "hooks.json materialized");
+ let doc: serde_json::Value =
+ serde_json::from_str(&fs::read_to_string(&hooks_json).unwrap())
+ .expect("hooks.json parses");
+ let hooks = doc.get("hooks").expect("hooks key").as_object().unwrap();
+ assert_eq!(hooks.len(), DSH_EVENTS.len(), "one entry per bridge event");
+ for (event, _script) in DSH_EVENTS {
+ assert!(hooks.contains_key(event), "missing {event}");
+ }
+ }
+
/// Hermes' output must state the manual paste step (ai-memory does not write
/// `~/.hermes/config.yaml`) and must not advertise a staged bundle or a
/// session-end hook — the memory-provider plugin owns session lifecycle.
diff --git a/crates/ai-memory-cli/src/commands/render_shared.rs b/crates/ai-memory-cli/src/commands/render_shared.rs
index 3a5a2d0a..ff72adc2 100644
--- a/crates/ai-memory-cli/src/commands/render_shared.rs
+++ b/crates/ai-memory-cli/src/commands/render_shared.rs
@@ -178,6 +178,27 @@ pub(crate) const IBM_BOB_EVENTS: [(&str, &str); 5] = [
("Stop", "stop.sh"),
];
+/// DeepSeek Harness (DSH) lifecycle events ai-memory hooks. Each pair is
+/// `(event-name-in-the-Claude-Code-hooks.json, POSIX hook-script-filename)`.
+///
+/// DSH has no native hook protocol: capture runs through the official
+/// `@deepseek-ai/dsh-hooks-claude-code` bridge, which consumes a Claude Code
+/// `hooks.json` and delivers exactly these seven events — `PreCompact` and
+/// `SessionEnd` are not delivered, and `SessionStart` runs detached, so the
+/// bundle never fetches a handoff and finished sessions close with
+/// `ai-memory finalize-session --agent dsh`. Adding a hook event means
+/// updating this list AND adding the matching `.sh` and `.ps1` files under
+/// `hooks/dsh/`; the install-hooks parity test fails if the bundle drifts.
+pub(crate) const DSH_EVENTS: [(&str, &str); 7] = [
+ ("SessionStart", "session-start.sh"),
+ ("UserPromptSubmit", "user-prompt-submit.sh"),
+ ("PreToolUse", "pre-tool-use.sh"),
+ ("PostToolUse", "post-tool-use.sh"),
+ ("Stop", "stop.sh"),
+ ("SubagentStart", "subagent-start.sh"),
+ ("SubagentStop", "subagent-stop.sh"),
+];
+
/// Seconds Muse waits for one ai-memory hook. Muse reads `timeout` in
/// seconds, like the Claude Code plugins it loads. The capture POST is
/// fire-and-forget; `SessionStart` also fetches a handoff.
@@ -780,6 +801,36 @@ pub(crate) fn build_grok_payload(
)
}
+/// DeepSeek Harness (DSH) hook payload: a Claude Code `hooks.json` document
+/// the official `@deepseek-ai/dsh-hooks-claude-code` bridge consumes via its
+/// `configPath` setting. Commands are rendered for the current platform
+/// (native `ai-memory hook --event … --agent dsh` commands by default, so
+/// capture gets the local spool and capture-policy v1 enforcement; script
+/// commands under an `AI_MEMORY_HOOK_PLATFORM` override). The payload only
+/// covers [`DSH_EVENTS`] — no `PreCompact` or `SessionEnd`.
+#[must_use]
+pub(crate) fn build_dsh_hooks_payload(
+ emit_root: &Path,
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: Option<&Path>,
+ project_strategy: Option<&str>,
+) -> serde_json::Value {
+ build_hook_payload_for_platform(
+ &DSH_EVENTS,
+ emit_root,
+ server_url,
+ auth_token,
+ HookShape::Nested,
+ HookCommandContext::new(
+ HookCommandPlatform::current(),
+ "dsh",
+ data_dir,
+ project_strategy,
+ ),
+ )
+}
+
/// Zero's hook events → ai-memory event names (issue #156). Zero has no
/// user-prompt or pre-compact equivalents; its `specialistStart`/`Stop`
/// map onto the subagent events the router already tracks for Claude Code.
diff --git a/crates/ai-memory-cli/src/commands/setup_agent.rs b/crates/ai-memory-cli/src/commands/setup_agent.rs
index 803134c4..cec6c68b 100644
--- a/crates/ai-memory-cli/src/commands/setup_agent.rs
+++ b/crates/ai-memory-cli/src/commands/setup_agent.rs
@@ -42,8 +42,8 @@ use crate::cli::{
use crate::commands::render_shared::{
ANTIGRAVITY_LIFECYCLE_EVENTS, ANTIGRAVITY_TOOL_EVENTS, CODEX_PROFILE, COMMAND_CODE_PROFILE,
COPILOT_CLI_PROFILE, CURSOR_PROFILE, GEMINI_PROFILE, KIMI_CODE_EVENTS, KIRO_CLI_V2_EVENTS,
- KIRO_CLI_V3_EVENTS, build_claude_code_payload, build_devin_payload, build_grok_payload,
- build_pool_settings_yaml, hook_script_for_current_platform,
+ KIRO_CLI_V3_EVENTS, build_claude_code_payload, build_devin_payload, build_dsh_hooks_payload,
+ build_grok_payload, build_pool_settings_yaml, hook_script_for_current_platform,
};
use crate::commands::{install_hooks, install_mcp};
use crate::config::{Config, DEFAULT_SERVER_URL};
@@ -220,6 +220,7 @@ pub fn run(config: &Config, mut args: SetupAgentArgs) -> Result<()> {
emit_other(&emit_root, agent_sub, &args, &[&KIRO_CLI_V3_EVENTS]);
}
AgentChoice::Pool => emit_pool(&emit_root, &args),
+ AgentChoice::Dsh => emit_dsh(&emit_root, &args),
AgentChoice::CopilotCli => {
emit_other(&emit_root, agent_sub, &args, &[COPILOT_CLI_PROFILE.events]);
}
@@ -623,6 +624,41 @@ fn emit_pool(emit_root: &Path, args: &SetupAgentArgs) {
print!("{snippet}");
}
+/// Print DSH's generated Claude Code `hooks.json` plus the Cordis patch
+/// fragment that points the `@deepseek-ai/dsh-hooks-claude-code` bridge at
+/// it. The staged `.sh`/`.ps1` scripts are the artifact; the bridge reads the
+/// hooks.json via `configPath` after the operator merges the patch into
+/// `$DSH_HOME/profiles/<profile>/cordis.patch.yml`.
+fn emit_dsh(emit_root: &Path, args: &SetupAgentArgs) {
+ let payload = build_dsh_hooks_payload(
+ emit_root,
+ &args.server_url,
+ args.auth_token.as_deref(),
+ None,
+ None,
+ );
+ println!("# DeepSeek Harness (DSH) — DSH has no fixed agent config file.");
+ println!("# Hook scripts (must be reachable from the host that runs DSH):");
+ println!("# {}", emit_root.display());
+ println!("# AI-memory server: {}", args.server_url);
+ if args.auth_token.is_some() {
+ println!("# Auth: AI_MEMORY_AUTH_TOKEN embedded in each hook command below.");
+ println!("# Treat the hook config as sensitive (chmod 600).");
+ }
+ println!("# NOTE: the bridge delivers exactly seven events — no PreCompact or");
+ println!("# SessionEnd, and SessionStart runs detached, so capture works");
+ println!("# but handoff injection does not. Recover handoffs via the MCP");
+ println!("# memory_handoff_accept tool, and close finished sessions with");
+ println!("# `ai-memory finalize-session --agent dsh`.");
+ println!();
+ println!(
+ "{}",
+ serde_json::to_string_pretty(&payload).expect("static hook payload serializes")
+ );
+ println!();
+ print!("{}", install_hooks::dsh_bridge_patch_fragment(emit_root));
+}
+
fn emit_devin(emit_root: &Path, args: &SetupAgentArgs) -> Result<()> {
print!("{}", render_devin_setup_output(emit_root, args)?);
Ok(())
diff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rs
index c03cdde1..f2c87c9c 100644
--- a/crates/ai-memory-core/src/ids.rs
+++ b/crates/ai-memory-core/src/ids.rs
@@ -301,6 +301,10 @@ pub enum AgentKind {
/// but consume `SessionStart` stdout as plain context text.
#[serde(rename = "ibm-bob", alias = "bob")]
IbmBob,
+ /// DeepSeek Harness (DSH), whose Claude Code hooks bridge
+ /// (`@deepseek-ai/dsh-hooks-claude-code`) fires Claude Code-shaped
+ /// payloads for seven events (no `SessionEnd` or `PreCompact`).
+ Dsh,
/// Anything else (manual capture, future agents).
Other,
}
@@ -311,7 +315,7 @@ impl AgentKind {
/// CHECK constraint accepts every kind (the Zero integration shipped
/// with the enum variant but without the V26 migration and only a
/// live test caught it). Extend together with the enum.
- pub const ALL: [Self; 27] = [
+ pub const ALL: [Self; 28] = [
Self::ClaudeCode,
Self::Codex,
Self::OpenCode,
@@ -338,6 +342,7 @@ impl AgentKind {
Self::Muse,
Self::CodeBuddy,
Self::IbmBob,
+ Self::Dsh,
Self::Other,
];
@@ -371,6 +376,7 @@ impl AgentKind {
Self::Muse => "muse",
Self::CodeBuddy => "codebuddy",
Self::IbmBob => "ibm-bob",
+ Self::Dsh => "dsh",
Self::Other => "other",
}
}
@@ -407,6 +413,7 @@ impl AgentKind {
"muse" | "muse-code" | "musecode" => Self::Muse,
"codebuddy" | "code-buddy" => Self::CodeBuddy,
"ibm-bob" | "bob" => Self::IbmBob,
+ "dsh" | "deepseek-harness" | "deepseek_harness" => Self::Dsh,
_ => Self::Other,
}
}
@@ -474,6 +481,9 @@ impl AgentKind {
| Self::KimiCode
| Self::Hermes
| Self::Pool
+ // DSH's bridge runs SessionStart detached, so its stdout
+ // cannot be relied on to deliver a fetched handoff.
+ | Self::Dsh
| Self::Other
)
}
@@ -698,6 +708,26 @@ mod tests {
assert!(!AgentKind::Pool.user_prompt_injects_handoff());
}
+ #[test]
+ fn agent_kind_dsh_round_trips_without_claiming_handoff_delivery() {
+ assert_eq!(AgentKind::Dsh.as_str(), "dsh");
+ assert_eq!(AgentKind::from_wire("dsh"), AgentKind::Dsh);
+ assert_eq!(AgentKind::from_wire("deepseek-harness"), AgentKind::Dsh);
+ assert_eq!(AgentKind::from_wire("deepseek_harness"), AgentKind::Dsh);
+ // serde uses rename_all = "kebab-case" → "dsh".
+ assert_eq!(serde_json::to_string(&AgentKind::Dsh).unwrap(), "\"dsh\"");
+ assert_eq!(
+ serde_json::from_str::<AgentKind>("\"dsh\"").unwrap(),
+ AgentKind::Dsh
+ );
+ // Unknown tags still degrade to Other.
+ assert_eq!(AgentKind::from_wire("dsh-2"), AgentKind::Other);
+ // DSH's Claude Code hooks bridge runs SessionStart detached, so the
+ // destructive handoff fetch must not happen from its hook bundle.
+ assert!(!AgentKind::Dsh.session_start_injects_handoff());
+ assert!(!AgentKind::Dsh.user_prompt_injects_handoff());
+ }
+
#[test]
fn agent_kind_copilot_cli_round_trips_without_claiming_handoff_delivery() {
assert_eq!(AgentKind::CopilotCli.as_str(), "copilot-cli");
diff --git a/crates/ai-memory-hooks/src/capture_policy.rs b/crates/ai-memory-hooks/src/capture_policy.rs
index 3753390d..c129b20c 100644
--- a/crates/ai-memory-hooks/src/capture_policy.rs
+++ b/crates/ai-memory-hooks/src/capture_policy.rs
@@ -182,6 +182,8 @@ pub(crate) fn tool_payload_fields(agent: AgentKind, raw: &Value) -> Option<(&str
// Meta Muse Code sends the same three fields, `tool_use_id` being the
// provider's call id (`call_…`, captured offline on Muse Code 1.4.7).
// CodeBuddy Code sends the same Claude Code fields (#1299).
+ // DSH's Claude Code hooks bridge forwards the same Claude Code
+ // snake_case fields for PreToolUse / PostToolUse.
AgentKind::ClaudeCode
| AgentKind::CommandCode
| AgentKind::Codex
@@ -192,7 +194,8 @@ pub(crate) fn tool_payload_fields(agent: AgentKind, raw: &Value) -> Option<(&str
| AgentKind::CopilotCli
| AgentKind::Muse
| AgentKind::CodeBuddy
- | AgentKind::IbmBob => (
+ | AgentKind::IbmBob
+ | AgentKind::Dsh => (
object.get("tool_name")?.as_str()?,
object.get("tool_use_id").and_then(Value::as_str),
),
@@ -266,6 +269,7 @@ pub(crate) fn tool_observation_metadata(
| AgentKind::Muse
| AgentKind::CodeBuddy
| AgentKind::IbmBob
+ | AgentKind::Dsh
) {
"tool_input"
} else {
diff --git a/crates/ai-memory-hooks/src/payload.rs b/crates/ai-memory-hooks/src/payload.rs
index 816f77b4..e03c0246 100644
--- a/crates/ai-memory-hooks/src/payload.rs
+++ b/crates/ai-memory-hooks/src/payload.rs
@@ -846,6 +846,10 @@ const fn closed_tool_agent(agent: AgentKind) -> bool {
// path.
| AgentKind::CodeBuddy
| AgentKind::IbmBob
+ // DSH's Claude Code hooks bridge (`@deepseek-ai/dsh-hooks-claude-code`)
+ // forwards Claude Code's snake_case tool fields for PreToolUse /
+ // PostToolUse.
+ | AgentKind::Dsh
)
}
diff --git a/crates/ai-memory-store/migrations/V84__sessions_dsh_agent_kind.sql b/crates/ai-memory-store/migrations/V84__sessions_dsh_agent_kind.sql
new file mode 100644
index 00000000..3afbbe80
--- /dev/null
+++ b/crates/ai-memory-store/migrations/V84__sessions_dsh_agent_kind.sql
@@ -0,0 +1,74 @@
+-- Expand sessions.agent_kind CHECK for the DeepSeek Harness (DSH).
+--
+-- Keep the complete V83 schema, indexes, and scope-pairing triggers while
+-- adding the `dsh` wire value.
+--
+-- `Store::open` turns foreign keys off around the migration runner (a PRAGMA
+-- inside refinery's transaction is ignored). With them on, `DROP TABLE
+-- sessions` would delete every observation, ingest key, and other row that
+-- references a session through ON DELETE CASCADE.
+
+DROP TRIGGER IF EXISTS auto_improve_scheduler_claims_session_pairing_ai;
+DROP TRIGGER IF EXISTS session_consolidation_jobs_session_pairing_ai;
+
+CREATE TABLE sessions_new (
+ id BLOB PRIMARY KEY NOT NULL,
+ workspace_id BLOB NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
+ project_id BLOB NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
+ agent_kind TEXT NOT NULL CHECK (agent_kind IN ('claude-code','codex','open-code','cursor','gemini-cli','claude-desktop','openclaw','antigravity-cli','omp','pi','crush','grok','zero','devin','kimi-code','kiro-cli','command-code','hermes','pool','zcode','grizzybot','copilot-cli','droid','muse','codebuddy','ibm-bob','dsh','other')),
+ cwd TEXT,
+ started_at INTEGER NOT NULL,
+ ended_at INTEGER,
+ summary_page_id BLOB REFERENCES pages(id) ON DELETE SET NULL,
+ ended_observation_count INTEGER NOT NULL DEFAULT 0 CHECK (ended_observation_count >= 0),
+ actor_user TEXT
+);
+
+INSERT INTO sessions_new (
+ id, workspace_id, project_id, agent_kind, cwd, started_at, ended_at,
+ summary_page_id, ended_observation_count, actor_user
+)
+SELECT
+ id, workspace_id, project_id, agent_kind, cwd, started_at, ended_at,
+ summary_page_id, ended_observation_count, actor_user
+FROM sessions;
+
+DROP TABLE sessions;
+
+ALTER TABLE sessions_new RENAME TO sessions;
+
+CREATE INDEX idx_sessions_recent ON sessions(workspace_id, project_id, started_at DESC);
+CREATE INDEX idx_sessions_project ON sessions(project_id);
+CREATE INDEX idx_sessions_started_at ON sessions(started_at DESC);
+CREATE INDEX idx_sessions_scope_ended
+ ON sessions(workspace_id, project_id, ended_at ASC)
+ WHERE ended_at IS NOT NULL;
+CREATE INDEX idx_sessions_open_owner
+ ON sessions(workspace_id, project_id, agent_kind, actor_user)
+ WHERE ended_at IS NULL;
+
+CREATE TRIGGER sessions_ws_proj_pairing_ai
+BEFORE INSERT ON sessions
+FOR EACH ROW
+WHEN NEW.workspace_id IS NOT (SELECT workspace_id FROM projects WHERE id = NEW.project_id)
+BEGIN
+ SELECT RAISE(ABORT, 'sessions.workspace_id does not match the project''s workspace');
+END;
+
+CREATE TRIGGER auto_improve_scheduler_claims_session_pairing_ai
+BEFORE INSERT ON auto_improve_scheduler_claims
+FOR EACH ROW
+WHEN NEW.workspace_id IS NOT (SELECT workspace_id FROM sessions WHERE id = NEW.session_id)
+ OR NEW.project_id IS NOT (SELECT project_id FROM sessions WHERE id = NEW.session_id)
+BEGIN
+ SELECT RAISE(ABORT, 'auto_improve_scheduler_claims scope does not match the session scope');
+END;
+
+CREATE TRIGGER session_consolidation_jobs_session_pairing_ai
+BEFORE INSERT ON session_consolidation_jobs
+FOR EACH ROW
+WHEN NEW.workspace_id IS NOT (SELECT workspace_id FROM sessions WHERE id = NEW.session_id)
+ OR NEW.project_id IS NOT (SELECT project_id FROM sessions WHERE id = NEW.session_id)
+BEGIN
+ SELECT RAISE(ABORT, 'session_consolidation_jobs scope does not match the session scope');
+END;
diff --git a/docs/install.md b/docs/install.md
index 3140f873..ae533a8c 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -2311,9 +2311,14 @@ first `PostToolUse` prints
`hookSpecificOutput.additionalContext` (pending handoff, plus an opted-in
`[briefing]`). The model sees it after that tool result. A session with no
tool call and without that rule leaves the handoff for
-`memory_handoff_accept`. Claude Desktop, VS Code Copilot, Zed, ZCode,
-DeepSeek Harness (DSH), and Prime Agent are MCP-only here, so you'll need to
+`memory_handoff_accept`. Claude Desktop, VS Code Copilot, Zed, ZCode, and
+Prime Agent are MCP-only here, so you'll need to
nudge the model to call `memory_query` / `memory_handoff_accept` itself.
+DeepSeek Harness (DSH) also has no hook stdout to carry the baton: its
+`@deepseek-ai/dsh-hooks-claude-code` bridge runs `SessionStart` detached, so
+`install-hooks --agent dsh` captures lifecycle events but handoff recovery
+goes through `memory_handoff_list` then `memory_handoff_accept`, and finished
+sessions close with `ai-memory finalize-session --agent dsh`.
Prime Agent's snippet names `$AI_MEMORY_AUTH_TOKEN` rather than embedding the
token, so export that variable where you launch `prime-agent`.
For clients with `install-hooks` support, the capture path handles
diff --git a/docs/mcp-install.md b/docs/mcp-install.md
index d18465c1..bc8c0468 100644
--- a/docs/mcp-install.md
+++ b/docs/mcp-install.md
@@ -584,7 +584,8 @@ Sources: <https://dev.meta.ai/docs/muse-code/configuration>,
## DeepSeek Harness (DSH)
-**Status:** MCP supported (print-only). No lifecycle hooks or managed workstream claimed.
+**Status:** MCP supported (print-only) + lifecycle hooks via the official
+Claude Code hooks bridge. No managed workstream.
DSH has no fixed JSON/TOML MCP config: the MCP client is a Cordis plugin entry
(`@deepseek-ai/dsh-mcp-client`) inside a profile's `cordis.patch.yml`.
@@ -601,16 +602,49 @@ reloads its patch live), then reload or restart the profile. The fragment regist
the default stateless HTTP endpoint and carries `Authorization: Bearer <token>`
when `--auth-token` (or a configured server token) is present.
-DSH ships a bridge that runs an existing Claude Code `hooks.json` or settings
-file (`@deepseek-ai/dsh-hooks-claude-code`). Pointing it at ai-memory's Claude
-Code hooks is not a supported capture path: those hooks report every event as
-`agent=claude-code`, so DSH sessions would be stored as Claude Code sessions.
-ai-memory does not install or manage the bridge, and it delivers only seven Claude Code events
-(`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`,
-`Stop`, `SubagentStart`, `SubagentStop`). `PreCompact` and
-`SessionEnd` are not delivered, and its `SessionStart` injection runs
-detached. Treat DSH as MCP-only here and recover handoffs explicitly with
-`memory_handoff_list` then `memory_handoff_accept` when continuity matters.
+Lifecycle capture runs through DSH's official Claude Code hooks bridge
+(`@deepseek-ai/dsh-hooks-claude-code`), which consumes a Claude Code
+`hooks.json`. ai-memory ships a DSH hook bundle and a first-party installer:
+
+```bash
+ai-memory install-hooks --agent dsh --apply \
+ --server-url "$AI_MEMORY_SERVER" --auth-token "$TOKEN"
+```
+
+`--apply` stages the `hooks/dsh` scripts under the data dir and writes a
+generated Claude Code `hooks.json` next to them (native `ai-memory hook`
+commands by default, so capture enforces capture exclusions and keeps the
+local spool). It then prints the bridge patch fragment — a `- insert:` item
+mounted under the DSH profile patch — which you merge into
+`$DSH_HOME/profiles/<profile>/cordis.patch.yml` by hand, because that file is
+a hand-maintained YAML patch layer (the same reason `install-mcp --client
+dsh` refuses to write it):
+
+```yaml
+- insert:
+ - id: ai-memory-hooks
+ name: '@deepseek-ai/dsh-hooks-claude-code'
+ config:
+ configPath: '<data-dir>/hooks/dsh/hooks.json'
+```
+
+Install the bridge package into the profile first (`dsh plugin --profile
+<profile> add @deepseek-ai/dsh-hooks-claude-code`), then reload or restart
+the profile. Without `--apply`, `install-hooks --agent dsh` prints the same
+`hooks.json` and patch fragment for a manual merge.
+
+Two bridge constraints shape DSH capture:
+
+- The bridge delivers only seven Claude Code events (`SessionStart`,
+ `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart`,
+ `SubagentStop`). `PreCompact` and `SessionEnd` are not delivered, so a
+ finished session stays open until `ai-memory finalize-session --agent dsh`
+ closes it (the same close path as Command Code, Kiro CLI and Antigravity).
+- `SessionStart` runs detached, so its stdout cannot reliably deliver a
+ fetched handoff; the DSH hook bundle therefore never claims one. Recover a
+ pending handoff with `memory_handoff_list` then `memory_handoff_accept`, or
+ ask the model to. DSH sessions are stored as `agent=dsh`, never as
+ `claude-code`.
---
diff --git a/docs/support-matrix.md b/docs/support-matrix.md
index 1c0a340b..b6261598 100644
--- a/docs/support-matrix.md
+++ b/docs/support-matrix.md
@@ -45,7 +45,7 @@
| Zed | MCP-only | Native remote MCP under `context_servers` in Zed's user `settings.json`; no lifecycle hooks or managed-workstream support. |
| Meta Muse Code | Supported | MCP config (`install-mcp --client muse`, aliases `muse-code`, `musecode`) + lifecycle hooks (`install-hooks --agent muse`), both merged into `${XDG_CONFIG_HOME:-~/.config}/muse/settings.json` around your own keys, servers and hooks. The writers add the mandatory `"schema_version": 1` when it is absent (without it every `muse` command fails at startup) and never rewrite an existing value. The MCP entry is a stdio `ai-memory mcp-bridge --agent muse` that forwards the `MUSE_SESSION_ID` Muse gives its stdio servers, so Muse is session-aware; it carries `"mode": "optional"` (Muse's default `required` aborts the run when a server cannot start) and the install's `--data-dir`, because Muse starts stdio servers and hooks with a cleared environment. It goes under `mcpServers`, or under the legacy `mcp_servers` when the file already uses it; Muse ignores every MCP server when both maps are present, so `--apply` refuses that file and `doctor` reports it. Hooks run the native `ai-memory hook --event … --agent muse` command (no script bundle) with an empty matcher and a 30-second timeout, and native commands enforce capture exclusions over Muse's `read_file`, `write_file`, `edit_file`, `apply_patch`, `search`, `bash`, `monitor`, `web_fetch` and memory tools; a relative `path` resolves lexically against `cwd`, and Muse's `tool_use_id` is kept as the call id. Eight events: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PreCompact`, `Stop`, `SessionEnd`; `SubagentStart`/`SubagentStop` are left out because Muse fires them every turn for its built-in reminder observers. The `SessionStart` hook delivers the prior session's handoff through `hookSpecificOutput.additionalContext`, and Muse's own `SessionEnd` closes the session. Verified offline against Muse Code 1.4.7: hook capture, exclusions, MCP session routing and handoff injection, run end to end in an isolated network namespace with a stand-in model provider. Skills need no extra step: Muse reads `~/.agents/skills` and `AGENTS.md`. `setup` detects Muse by its config or data directory. No managed workstream (`ai-memory run muse`) and no transcript backfill. See [`install.md`](install.md#meta-muse-code). |
| IBM Bob | Supported | Native Streamable HTTP MCP in `~/.bob/settings/mcp.json` plus five lifecycle hooks shared by Bob IDE and Bob Shell in `~/.bob/settings/settings.json`. `SessionStart` injects the prior handoff as plain context, and Claude-shaped tool events enforce capture exclusions. Bob exposes no true `SessionEnd`, so run `ai-memory finalize-session --agent ibm-bob` after the final turn. `ai-memory run ibm-bob` and transcript backfill are not claimed because Bob does not document a stable transcript-store contract. See [`mcp-install.md`](mcp-install.md#ibm-bob). |
-| DeepSeek Harness (DSH) | MCP-only | `install-mcp --client dsh` prints a Cordis patch fragment (a `- insert:` item for `@deepseek-ai/dsh-mcp-client`) to merge into `$DSH_HOME/profiles/<profile>/cordis.patch.yml`; DSH has no fixed MCP config file, so `--apply` is refused. Lifecycle capture is not claimed: DSH's `@deepseek-ai/dsh-hooks-claude-code` bridge can run a Claude Code hook config, but ai-memory's Claude Code hooks would report DSH sessions as `agent=claude-code`, and the bridge delivers only seven Claude Code events (`PreCompact` and `SessionEnd` are not), with a detached `SessionStart`. No managed workstream. |
+| DeepSeek Harness (DSH) | Hooks + MCP | MCP: `install-mcp --client dsh` (aliases `deepseek-harness`, `deepseek_harness`) prints a Cordis patch fragment (a `- insert:` item for `@deepseek-ai/dsh-mcp-client`) to merge into `$DSH_HOME/profiles/<profile>/cordis.patch.yml`; DSH has no fixed MCP config file, so `--apply` is refused. Lifecycle hooks: `install-hooks --agent dsh` stages the `hooks/dsh` script bundle, generates a Claude Code `hooks.json` for DSH's official `@deepseek-ai/dsh-hooks-claude-code` bridge, and prints the bridge patch fragment — again merged by hand into `cordis.patch.yml` (the generated `hooks.json` itself is written to the data dir by `--apply`). The bridge delivers exactly seven Claude Code events (`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart`, `SubagentStop`) — no `PreCompact` or `SessionEnd` — and runs `SessionStart` detached, so DSH sessions are stored as `agent=dsh`, pending handoffs are recovered via MCP `memory_handoff_list` then `memory_handoff_accept`, and finished sessions close with `ai-memory finalize-session --agent dsh`. No managed workstream. |
| Prime Agent | MCP-only | `install-mcp --client prime-agent` merges an HTTP entry (`type: "http"` + `url`) into the `mcpServers` map of `$PRIME_AGENT_CODING_AGENT_DIR/settings.json` (default `~/.prime/agent/settings.json`), preserving other settings and servers; a project's `.prime/agent/settings.json` works through `--config-file`. A token is referenced as `"bearerTokenEnvVar": "AI_MEMORY_AUTH_TOKEN"`, never written: Prime Agent 0.10 counts a user HTTP server as connected and names it in the model's prompt only with that variable set or an OAuth grant. A credential-less entry is still callable through `mcp.call_tool("ai-memory", ...)` but is not listed. The model reaches MCP tools from its Python REPL (`await mcp.call_tool("ai-memory", "memory_query", {...})`), and Prime Agent sends no session id or cwd, so pass `workspace` and `project` on project-scoped calls. Lifecycle capture and managed workstreams are not claimed: Prime Agent 0.10 removed the TypeScript extensions its 0.9 releases had and has no hook surface. Verified against Prime Agent 0.10.0. |
| Hermes Agent | Supported | `install-hooks --agent hermes` (alias `hermes-agent`) prints a ready-to-paste `hooks:` block for `~/.hermes/config.yaml`. Hermes splits each configured `command` with `shlex.split` and runs it with no shell, passing the event JSON on stdin, so the entries invoke the native `ai-memory hook` command (exec form, like Zero and ZCode — no script bundle is staged); ai-memory never writes that YAML file, which is yours to edit and which Hermes itself gates behind its hook-acceptance prompt (`hooks_auto_accept`). Two tool events are wired, `pre_tool_call` → `pre-tool-use` and `post_tool_call` → `post-tool-use`; their `tool_name` / `tool_input` payload drives concrete session attribution, tool-family titles, and capture exclusions. Hermes reports its own process directory as `cwd`, so the native hook locates each event's `.ai-memory.toml` from the tool's absolute `workdir` (`terminal`) or `path` (file tools, `search_files`); a call with no absolute location stays with the process directory. Session lifecycle (recall, prompt capture, session-end, automatic handoff) is owned by the community-maintained [`ai-memory-hermes-plugin`](https://github.com/MrLuciano/ai-memory-hermes-plugin) memory provider, so no hook-driven `session-end` is installed and nothing is duplicated; review that plugin's compatibility matrix, install/uninstall scripts, and secret handling before enabling it. No first-party `install-mcp` client and no managed workstream are claimed yet, and because Hermes ignores session-start hook stdout a pending handoff is recovered through MCP (`memory_handoff_list` then `memory_handoff_accept`). |
| GrizzyBot | Supported | [GrizzyBot](https://github.com/Foscoe63/GrizzyBot), a native macOS agent app, ships its own ai-memory bridge: it posts lifecycle events to `/hook` with `agent=grizzybot` (alias `grizzy-bot`) and talks to `/mcp` directly, so there is nothing for `install-hooks` or `install-mcp` to write. Sessions are attributed to `grizzybot`, and its Claude Code-shaped tool payloads (`tool_name`/`tool_input`/`tool_use_id`) are stored as closed-schema tool families, never tool names or arguments. The bridge is maintained in the GrizzyBot repository; review it before pointing it at a shared server. No managed workstream. |
diff --git a/hooks/dsh/post-tool-use.ps1 b/hooks/dsh/post-tool-use.ps1
new file mode 100644
index 00000000..ebd92c44
--- /dev/null
+++ b/hooks/dsh/post-tool-use.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "post-tool-use" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/post-tool-use.sh b/hooks/dsh/post-tool-use.sh
new file mode 100755
index 00000000..52a8c156
--- /dev/null
+++ b/hooks/dsh/post-tool-use.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) post-tool-use hook, run by the official
+# `@deepseek-ai/dsh-hooks-claude-code` bridge (Claude Code-shaped payload).
+# Forwards the event JSON to the ai-memory server, fire-and-forget.
+# Walks up from the payload's cwd for a .ai-memory.toml marker file;
+# if found, appends marker query params to the URL so the server
+# applies the declared workspace/project/strategy instead of
+# bucketing by basename(cwd) under the default workspace.
+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged
+# alongside this script. From the source tree it lives one dir up.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=post-tool-use&agent=dsh${QS}" >/dev/null 2>&1 || true
+# Acknowledge with an empty JSON object. This hook only POSTs
+# (fire-and-forget) and injects no context; without "{" on stdout the
+# bridge logs "Hook output does not start with {, treating as plain text".
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/pre-tool-use.ps1 b/hooks/dsh/pre-tool-use.ps1
new file mode 100644
index 00000000..bfa7f0f9
--- /dev/null
+++ b/hooks/dsh/pre-tool-use.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "pre-tool-use" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/pre-tool-use.sh b/hooks/dsh/pre-tool-use.sh
new file mode 100755
index 00000000..77b68463
--- /dev/null
+++ b/hooks/dsh/pre-tool-use.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) pre-tool-use hook, run by the official
+# `@deepseek-ai/dsh-hooks-claude-code` bridge (Claude Code-shaped payload).
+# Forwards the event JSON to the ai-memory server, fire-and-forget.
+# Walks up from the payload's cwd for a .ai-memory.toml marker file;
+# if found, appends marker query params to the URL so the server
+# applies the declared workspace/project/strategy instead of
+# bucketing by basename(cwd) under the default workspace.
+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged
+# alongside this script. From the source tree it lives one dir up.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=pre-tool-use&agent=dsh${QS}" >/dev/null 2>&1 || true
+# Acknowledge with an empty JSON object. This hook only POSTs
+# (fire-and-forget) and injects no context; without "{" on stdout the
+# bridge logs "Hook output does not start with {, treating as plain text".
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/session-start.ps1 b/hooks/dsh/session-start.ps1
new file mode 100644
index 00000000..37b3470b
--- /dev/null
+++ b/hooks/dsh/session-start.ps1
@@ -0,0 +1,6 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+# Capture only: DSH's `@deepseek-ai/dsh-hooks-claude-code` bridge runs
+# SessionStart detached, so the handoff is never fetched here — it stays
+# available via the MCP `memory_handoff_accept` tool.
+Invoke-AiMemoryHook -Event "session-start" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/session-start.sh b/hooks/dsh/session-start.sh
new file mode 100755
index 00000000..d09ed1f6
--- /dev/null
+++ b/hooks/dsh/session-start.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) session-start hook, run by the official
+# `@deepseek-ai/dsh-hooks-claude-code` bridge (Claude Code-shaped payload).
+# Forwards the event JSON to the ai-memory server, fire-and-forget.
+#
+# Capture only: DSH's bridge runs SessionStart detached, so its stdout
+# cannot be relied on to deliver a fetched handoff. Fetching here would
+# consume the baton (the server marks it accepted) and the result would
+# most likely be dropped — so the handoff stays available on demand via
+# the MCP `memory_handoff_accept` tool.
+#
+# Walks up from the payload's cwd for a .ai-memory.toml marker file;
+# if found, appends marker query params to the URL so the server
+# applies the declared workspace/project/strategy instead of
+# bucketing by basename(cwd) under the default workspace.
+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged
+# alongside this script. From the source tree it lives one dir up.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+SESSION_ID=$(ai_memory_extract_session_id "$PAYLOAD")
+SESSION_QS=""
+[ -n "$SESSION_ID" ] && SESSION_QS="&session_id=$(ai_memory_url_encode "$SESSION_ID")"
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=session-start&agent=dsh${QS}${SESSION_QS}" >/dev/null 2>&1 || true
+# Acknowledge with an empty JSON object so the bridge records a clean
+# hook result (the run is detached, so nothing consumes this).
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/stop.ps1 b/hooks/dsh/stop.ps1
new file mode 100644
index 00000000..b25a81cb
--- /dev/null
+++ b/hooks/dsh/stop.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "stop" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/stop.sh b/hooks/dsh/stop.sh
new file mode 100755
index 00000000..e12867d6
--- /dev/null
+++ b/hooks/dsh/stop.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) stop hook, run by the official
+# `@deepseek-ai/dsh-hooks-claude-code` bridge (Claude Code-shaped payload).
+# Forwards the event JSON to the ai-memory server, fire-and-forget.
+# Walks up from the payload's cwd for a .ai-memory.toml marker file;
+# if found, appends marker query params to the URL so the server
+# applies the declared workspace/project/strategy instead of
+# bucketing by basename(cwd) under the default workspace.
+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged
+# alongside this script. From the source tree it lives one dir up.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+# Assistant/Stop capture (#196) is native-only: the script fallback cannot
+# sanitize the assistant message, so if the raw payload still carries the field
+# we drop the whole Stop rather than POST it verbatim. A literal substring check
+# (POSIX `case`, no bash-isms per _lib.sh) — conservative on purpose: any Stop
+# mentioning the key is dropped. Move to a native install to capture it safely.
+case "$PAYLOAD" in
+ *'"last_assistant_message"'*)
+ printf '{}\n'
+ exit 0
+ ;;
+esac
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=stop&agent=dsh${QS}" >/dev/null 2>&1 || true
+# Acknowledge with an empty JSON object. This hook only POSTs
+# (fire-and-forget) and injects no context; without "{" on stdout the
+# bridge logs "Hook output does not start with {, treating as plain text".
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/subagent-start.ps1 b/hooks/dsh/subagent-start.ps1
new file mode 100644
index 00000000..70959cd3
--- /dev/null
+++ b/hooks/dsh/subagent-start.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "subagent-start" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/subagent-start.sh b/hooks/dsh/subagent-start.sh
new file mode 100755
index 00000000..221018c4
--- /dev/null
+++ b/hooks/dsh/subagent-start.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) subagent-start hook — forwards the event so the
+# server can seed the subagent's session id for drop_subagent_captures (so
+# the whole nested session, incl. the unmarked tail, is dropped). Mirrors
+# stop.sh. Runs through the `@deepseek-ai/dsh-hooks-claude-code` bridge.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=subagent-start&agent=dsh${QS}" >/dev/null 2>&1 || true
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/subagent-stop.ps1 b/hooks/dsh/subagent-stop.ps1
new file mode 100644
index 00000000..37c103e2
--- /dev/null
+++ b/hooks/dsh/subagent-stop.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "subagent-stop" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/subagent-stop.sh b/hooks/dsh/subagent-stop.sh
new file mode 100755
index 00000000..5c637634
--- /dev/null
+++ b/hooks/dsh/subagent-stop.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) subagent-stop hook — forwards the event so the
+# server can forget the subagent's session id (drop_subagent_captures).
+# Mirrors stop.sh. Runs through the `@deepseek-ai/dsh-hooks-claude-code`
+# bridge.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=subagent-stop&agent=dsh${QS}" >/dev/null 2>&1 || true
+printf '{}\n'
+exit 0
diff --git a/hooks/dsh/user-prompt-submit.ps1 b/hooks/dsh/user-prompt-submit.ps1
new file mode 100644
index 00000000..9f0389f8
--- /dev/null
+++ b/hooks/dsh/user-prompt-submit.ps1
@@ -0,0 +1,3 @@
+. "$PSScriptRoot\..\lib\ai-memory-hook.ps1"
+Invoke-AiMemoryHook -Event "user-prompt" -Agent "dsh"
+exit 0
diff --git a/hooks/dsh/user-prompt-submit.sh b/hooks/dsh/user-prompt-submit.sh
new file mode 100755
index 00000000..4d427b21
--- /dev/null
+++ b/hooks/dsh/user-prompt-submit.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# DeepSeek Harness (DSH) user-prompt hook, run by the official
+# `@deepseek-ai/dsh-hooks-claude-code` bridge (Claude Code-shaped payload).
+# Forwards the event JSON to the ai-memory server, fire-and-forget.
+# Walks up from the payload's cwd for a .ai-memory.toml marker file;
+# if found, appends marker query params to the URL so the server
+# applies the declared workspace/project/strategy instead of
+# bucketing by basename(cwd) under the default workspace.
+# At runtime (after `install-hooks --apply`) `_lib.sh` is staged
+# alongside this script. From the source tree it lives one dir up.
+_lib_dir="$(dirname "$0")"
+[ -f "$_lib_dir/_lib.sh" ] || _lib_dir="$_lib_dir/.."
+. "$_lib_dir/_lib.sh"
+
+SERVER="${AI_MEMORY_HOOK_URL:-http://127.0.0.1:49374}"
+PAYLOAD=$(cat)
+CWD=$(ai_memory_extract_cwd "$PAYLOAD")
+QS=$(ai_memory_marker_qs "$CWD")
+
+printf '%s' "$PAYLOAD" \
+ | ai_memory_post_hook "$SERVER/hook?event=user-prompt&agent=dsh${QS}" >/dev/null 2>&1 || true
+# Acknowledge with an empty JSON object. This hook only POSTs
+# (fire-and-forget) and injects no context; without "{" on stdout the
+# bridge logs "Hook output does not start with {, treating as plain text".
+printf '{}\n'
+exit 0