Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
feat: support IBM Bob lifecycle memory
AkitaOnRails27782f1ccd2e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0b0bb2b9..a2a98ce6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,17 @@ version in [`docs/changelog/`](docs/changelog/):## [Unreleased]### Added+- Added first-party IBM Bob support. `install-mcp --client ibm-bob --apply`+ (alias `bob`) merges a native Streamable HTTP server into+ `~/.bob/settings/mcp.json`, using Bob's documented `legacy` protocol+ negotiation so it skips the non-standard `server/discover` probe.+ `install-hooks --agent ibm-bob --apply` merges the five events common to+ Bob IDE and Bob Shell into `~/.bob/settings/settings.json`, preserves other+ settings and hooks, enforces capture exclusions over Claude-shaped tool+ payloads, and delivers the pending handoff as plain `SessionStart` context.+ Bob has no true `SessionEnd`, so finished sessions use+ `finalize-session --agent ibm-bob`. Managed transcript resume is not claimed+ without a documented stable native transcript store. (#1331)- Added host-local native history continuation for managed harness switches.When `ai-memory run` moves a workstream from one harness to another, it pinsthe previous native session, validates it against the exact checkout, anddiff --git a/README.md b/README.mdindex 613b7262..0dc41bc1 100644--- a/README.md+++ b/README.md@@ -158,6 +158,7 @@ caveats is in [`docs/support-matrix.md`](docs/support-matrix.md).| Factory Droid | Supported || Meta Muse Code | Supported || CodeBuddy Code | Hooks-only |+| IBM Bob | Supported || VS Code Copilot | MCP-only || Zed | MCP-only || DeepSeek Harness (DSH) | MCP-only |diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex 583a39e2..e2eac8e2 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -2473,6 +2473,11 @@ pub enum AgentChoice {/// stdout (`hookSpecificOutput.additionalContext`) carries the handoff.#[value(name = "codebuddy", alias = "code-buddy")]CodeBuddy,+ /// IBM Bob IDE — lifecycle hooks merged into the `hooks` key of+ /// `~/.bob/settings/settings.json`. Bob sends Claude Code-shaped payloads+ /// and injects plain `SessionStart` stdout into the model context.+ #[value(name = "ibm-bob", alias = "bob")]+ IbmBob,}impl AgentChoice {@@ -2507,6 +2512,7 @@ impl AgentChoice {Self::Droid => AgentKind::Droid,Self::Muse => AgentKind::Muse,Self::CodeBuddy => AgentKind::CodeBuddy,+ Self::IbmBob => AgentKind::IbmBob,}}@@ -2528,7 +2534,8 @@ impl AgentChoice {| Self::Hermes| Self::Droid| Self::Muse- | Self::CodeBuddy => None,+ | Self::CodeBuddy+ | Self::IbmBob => None,_ => Some(self.kind().as_str()),}}@@ -2718,6 +2725,11 @@ pub enum McpClient {/// Command Code CLI — `~/.commandcode/mcp.json`.#[value(alias = "commandcode", alias = "cmdc", alias = "cmd")]CommandCode,+ /// IBM Bob IDE — `~/.bob/settings/mcp.json`, using native Streamable HTTP.+ /// Pair with `install-hooks --agent ibm-bob` for lifecycle capture and+ /// plain-text `SessionStart` handoff delivery.+ #[value(name = "ibm-bob", alias = "bob")]+ IbmBob,/// GitHub Copilot CLI — `$COPILOT_HOME/mcp-config.json` (default/// `~/.copilot/mcp-config.json`), servers under the root `mcpServers` map/// with `type: "http"` + `url` + optional `headers` (#1040). Pair with@@ -4753,6 +4765,27 @@ mod tests {}}+ #[test]+ fn ibm_bob_install_hooks_and_mcp_parse_with_both_aliases() {+ for alias in ["ibm-bob", "bob"] {+ 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::IbmBob);+ assert_eq!(args.agent.kind(), ai_memory_core::AgentKind::IbmBob);+ assert_eq!(args.agent.script_hook_subdir(), None);++ 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::IbmBob);+ }+ }+#[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/hook.rs b/crates/ai-memory-cli/src/commands/hook.rsindex c4f1de30..c68e6117 100644--- a/crates/ai-memory-cli/src/commands/hook.rs+++ b/crates/ai-memory-cli/src/commands/hook.rs@@ -575,13 +575,15 @@ fn write_success_response<W: std::io::Write>(// context, and v2/v3 Stop parse stdout for a block decision. Capture-only// hooks therefore stay silent unless SessionStart has real context.Ok(())- } else if matches!(agent, AgentKind::Muse | AgentKind::CodeBuddy)- && matches!(event, HookEvent::SessionStart | HookEvent::UserPrompt)+ } else if matches!(+ agent,+ AgentKind::Muse | AgentKind::CodeBuddy | AgentKind::IbmBob+ ) && matches!(event, HookEvent::SessionStart | HookEvent::UserPrompt){- // Muse adds SessionStart and UserPromptSubmit stdout to the turn as- // developer context, and CodeBuddy appends exit-0 stdout of both to- // the session, so a capture-only reply stays empty rather than put- // `{}` in front of the model on every prompt.+ // Muse and IBM Bob add SessionStart and UserPromptSubmit stdout to the+ // turn as context, and CodeBuddy appends exit-0 stdout of both to the+ // session, so a capture-only reply stays empty rather than put `{}` in+ // front of the model on every prompt.Ok(())} else if event == HookEvent::UserPrompt && agent.user_prompt_injects_handoff() {// Kimi Code injects any non-empty UserPromptSubmit stdout into the turn@@ -1220,9 +1222,9 @@ whereif let Some(handoff) =get_handoff(&client, &handoff_url, bearer.as_deref(), handoff_timeout()).await{- if agent_kind == AgentKind::KiroCli {- // Kiro v2/v3 consume SessionStart stdout verbatim and define- // no wrapper envelope.+ if matches!(agent_kind, AgentKind::KiroCli | AgentKind::IbmBob) {+ // Kiro v2/v3 and IBM Bob consume SessionStart stdout+ // verbatim and define no wrapper envelope.writeln!(stdout, "{handoff}")?;} else {let envelope = session_start_handoff_envelope(agent_kind, handoff);@@ -2377,6 +2379,13 @@ mod tests {HookEvent::PostToolUse,b"{}\n".as_slice(),),+ (AgentKind::IbmBob, HookEvent::SessionStart, b"".as_slice()),+ (AgentKind::IbmBob, HookEvent::UserPrompt, b"".as_slice()),+ (+ AgentKind::IbmBob,+ HookEvent::PostToolUse,+ b"{}\n".as_slice(),+ ),] {let mut output = Vec::new();write_success_response(&mut output, agent, event).unwrap();@@ -2721,6 +2730,7 @@ mod tests {async fn a_handoff_is_never_claimed_without_a_project_directory() {let cases = [("codebuddy", "session-start", serde_json::json!({})),+ ("ibm-bob", "session-start", serde_json::json!({})),("claude-code", "session-start", serde_json::json!({})),("codex", "session-start", serde_json::json!({})),(@@ -2780,6 +2790,12 @@ mod tests {stdout.contains("OTHER-PROJECT-HANDOFF"),"{agent}: {stdout}");+ if agent == "ibm-bob" {+ assert_eq!(+ stdout, "OTHER-PROJECT-HANDOFF\n",+ "Bob consumes plain SessionStart context, not a JSON envelope"+ );+ }} else {assert!(claims.is_empty(), "{agent}: unscoped claim: {recorded:?}");assert!(diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rsindex 4a5ba37e..807664d0 100644--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@ -448,6 +448,16 @@ pub(crate) fn codebuddy_settings_path() -> anyhow::Result<std::path::PathBuf> {.join("settings.json"))}+/// `~/.bob/settings/settings.json` — IBM Bob's global settings shared by the+/// IDE and Bob Shell. The root `hooks` block uses nested event groups.+pub(crate) fn ibm_bob_settings_path() -> anyhow::Result<std::path::PathBuf> {+ Ok(home_dir()+ .context("could not locate $HOME for ~/.bob/settings/settings.json")?+ .join(".bob")+ .join("settings")+ .join("settings.json"))+}+/// `~/.config/zero/hooks.json` — Zero's user-level lifecycle hook config/// (issue #156). Zero resolves it under `$XDG_CONFIG_HOME` falling back to/// `~/.config`; like the OpenCode plugin path below we target the default@@ -998,6 +1008,13 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(};apply_to_codebuddy_settings(&path, &server_url, auth, &config.data_dir, &args)}+ AgentChoice::IbmBob => {+ let path = match &args.config_file {+ Some(path) => path.clone(),+ None => ibm_bob_settings_path()?,+ };+ apply_to_ibm_bob_settings(&path, &server_url, auth, &config.data_dir, &args)+ }};}let strategy = args.project_strategy.and_then(ProjectStrategyArg::baked);@@ -1155,6 +1172,7 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(AgentChoice::Droid => render_droid(&server_url, auth, &config.data_dir, strategy),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),}}@@ -1350,6 +1368,7 @@ fn existing_agent_config(args: &InstallHooksArgs) -> Option<String> {// `run` resolves it into `args.config_file` before any caller.AgentChoice::Muse => return None,AgentChoice::CodeBuddy => codebuddy_settings_path().ok()?,+ AgentChoice::IbmBob => ibm_bob_settings_path().ok()?,}};std::fs::read_to_string(path).ok()@@ -1612,11 +1631,9 @@ fn infer_installed_mcp_config(// Codex uses `http_headers`; Grok uses `headers`. The shared TOML// inferencer accepts both.McpClient::Codex => Ok(infer_toml_mcp_config(&content)),- McpClient::CommandCode | McpClient::CopilotCli => Ok(infer_json_mcp_config(- &content,- &["mcpServers", "ai-memory"],- "url",- )),+ McpClient::CommandCode | McpClient::CopilotCli | McpClient::IbmBob => Ok(+ infer_json_mcp_config(&content, &["mcpServers", "ai-memory"], "url"),+ ),// `install-mcp --client droid` writes the bearer as the// `${AI_MEMORY_AUTH_TOKEN}` reference Droid expands, not the token,// so only the URL is inferred from it.@@ -1779,6 +1796,7 @@ pub(crate) fn mcp_client_for_agent(agent: AgentChoice) -> Option<McpClient> {AgentChoice::Muse => Some(McpClient::Muse),// No first-party CodeBuddy MCP installer in this change.AgentChoice::CodeBuddy => None,+ AgentChoice::IbmBob => Some(McpClient::IbmBob),}}@@ -7256,6 +7274,91 @@ fn render_codebuddy(Ok(())}+/// Merge ai-memory's entries into IBM Bob's global settings, preserving every+/// unrelated setting and hook. Bob IDE and Bob Shell both read this file.+fn apply_to_ibm_bob_settings(+ path: &Path,+ server_url: &str,+ auth_token: Option<&str>,+ data_dir: &Path,+ args: &InstallHooksArgs,+) -> Result<()> {+ let strategy = args.project_strategy.and_then(ProjectStrategyArg::baked);+ let payload = super::render_shared::build_ibm_bob_hooks_payload(+ server_url,+ auth_token,+ Some(data_dir),+ strategy,+ );+ let our_hooks = payload+ .get("hooks")+ .and_then(serde_json::Value::as_object)+ .context("internal: IBM Bob payload did not return a hooks object")?;+ let outcome = apply_atomic(path, |existing| {+ mutate_json(existing, |root| {+ let hooks = root+ .entry("hooks")+ .or_insert_with(|| serde_json::Value::Object(serde_json::Map::new()))+ .as_object_mut()+ .context("`hooks` is present in IBM Bob settings.json but not an object")?;+ for (event, value) in our_hooks {+ overlay_event_hooks(hooks, event, value);+ }+ Ok(())+ })+ })?;+ println!(+ "✓ {} {} ({})",+ outcome.verb(),+ path.display(),+ match outcome {+ ApplyOutcome::Created => "new file",+ ApplyOutcome::Updated => "backup written next to it",+ ApplyOutcome::NoOp => "already up to date",+ }+ );+ print!("{IBM_BOB_INSTALL_NOTES}");+ Ok(())+}++const IBM_BOB_INSTALL_NOTES: &str = "\+# NOTE: IBM Bob injects plain SessionStart stdout into the model context, so+# the prior session's handoff is delivered automatically.+# NOTE: Bob exposes Stop but no SessionEnd; close a finished session with+# `ai-memory finalize-session --agent ibm-bob`.+# NOTE: start a new Bob session for it to load the new hooks.+";++/// Print the `hooks` block for IBM Bob's global settings (dry-run counterpart+/// of [`apply_to_ibm_bob_settings`]).+fn render_ibm_bob(+ server_url: &str,+ auth_token: Option<&str>,+ data_dir: &Path,+ project_strategy: Option<&str>,+) -> Result<()> {+ let payload = super::render_shared::build_ibm_bob_hooks_payload(+ server_url,+ auth_token,+ Some(data_dir),+ project_strategy,+ );+ let serialized = serde_json::to_string_pretty(&payload["hooks"])+ .context("serializing IBM Bob hook config")?;+ println!("# IBM Bob hook config — merge under the `hooks` key of");+ println!("# ~/.bob/settings/settings.json, or re-run with --apply to merge it in place.");+ println!("# AI-memory server URL: {server_url}");+ if auth_token.is_some() {+ println!("# Auth: this printed snippet embeds the token in each hook command —");+ println!("# treat settings.json as sensitive (chmod 600). `--apply` stores it");+ println!("# under the data dir instead.");+ }+ print!("{IBM_BOB_INSTALL_NOTES}");+ println!();+ println!("{serialized}");+ Ok(())+}+/// Merge ai-memory's entries into the `hooks` key of Muse's `settings.json`,/// keeping `schema_version`, every unknown key and every other hook in it,/// idempotently, with a backup next to the file on change. Muse fails every@@ -8300,6 +8403,71 @@ mod tests {assert_eq!(pre[0]["hooks"][0]["command"], "/usr/local/bin/guard.sh");}+ /// IBM Bob shares one global settings file between the IDE and Shell.+ /// Install only their common event vocabulary, preserve unrelated content,+ /// omit unsupported matchers, and make repeated installation a no-op.+ #[test]+ fn ibm_bob_apply_merges_common_native_hooks_and_is_idempotent() {+ let home = TempDir::new().unwrap();+ let data = TempDir::new().unwrap();+ let settings = home.path().join("settings.json");+ fs::write(+ &settings,+ serde_json::json!({+ "theme": "dark",+ "hooks": {+ "PreToolUse": [{+ "hooks": [{"type": "command", "command": "/usr/local/bin/guard.sh"}]+ }],+ "PreCompact": [{+ "hooks": [{"type": "command", "command": "/usr/local/bin/archive.sh"}]+ }]+ }+ })+ .to_string(),+ )+ .unwrap();+ let args = InstallHooksArgs {+ agent: AgentChoice::IbmBob,+ config_file: Some(settings.clone()),+ ..default_hook_args()+ };++ apply_to_ibm_bob_settings(&settings, "http://memory:49374", None, data.path(), &args)+ .unwrap();+ let first = fs::read_to_string(&settings).unwrap();+ apply_to_ibm_bob_settings(&settings, "http://memory:49374", None, data.path(), &args)+ .unwrap();+ assert_eq!(first, fs::read_to_string(&settings).unwrap());++ let root: serde_json::Value = serde_json::from_str(&first).unwrap();+ assert_eq!(root["theme"], "dark");+ for (event, script) in super::super::render_shared::IBM_BOB_EVENTS {+ let entries = root["hooks"][event].as_array().unwrap();+ let ours: Vec<_> = entries+ .iter()+ .filter(|entry| is_ai_memory_hook_entry(entry))+ .collect();+ assert_eq!(ours.len(), 1, "{event}");+ assert!(ours[0].get("matcher").is_none(), "{event}");+ let command = ours[0]["hooks"][0]["command"].as_str().unwrap();+ assert!(+ command.contains(&format!(+ " hook --event {} --agent ibm-bob --server-url ",+ script.trim_end_matches(".sh")+ )),+ "{event}: {command}"+ );+ }+ assert_eq!(+ root["hooks"]["PreCompact"][0]["hooks"][0]["command"],+ "/usr/local/bin/archive.sh"+ );+ let pre = root["hooks"]["PreToolUse"].as_array().unwrap();+ assert_eq!(pre.len(), 2);+ assert_eq!(pre[0]["hooks"][0]["command"], "/usr/local/bin/guard.sh");+ }+/// `install-hooks --agent droid --apply` merges native `--agent droid`/// commands into `hooks.json` (the bare event map), keeps every/// third-party entry, and a re-apply changes nothing (#1240).diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rsindex 2b80ba3b..132bd40f 100644--- a/crates/ai-memory-cli/src/commands/install_mcp.rs+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs@@ -157,6 +157,7 @@ pub(crate) fn run_with_opencode_dialect(McpClient::KimiCode => render_kimi_code(&args)?,McpClient::KiroCli => render_kiro_cli(&args)?,McpClient::CommandCode => render_command_code(&args)?,+ McpClient::IbmBob => render_ibm_bob(&args)?,McpClient::CopilotCli => render_copilot_cli(&args)?,McpClient::Droid => render_droid(&args)?,McpClient::Swival => render_swival(&args)?,@@ -350,7 +351,8 @@ fn stdio_bridge_entry(args: &InstallMcpArgs) -> Option<serde_json::Value> {| McpClient::Devin| McpClient::KimiCode| McpClient::KiroCli- | McpClient::Openclaw => plain(),+ | McpClient::Openclaw+ | McpClient::IbmBob => plain(),McpClient::GeminiCli | McpClient::AntigravityCli => json!({"command": BRIDGE_COMMAND,"args": bridge,@@ -609,6 +611,7 @@ pub(crate) fn mcp_config_path_with(.join("settings").join("mcp.json"),McpClient::CommandCode => home()?.join(".commandcode").join("mcp.json"),+ McpClient::IbmBob => home()?.join(".bob").join("settings").join("mcp.json"),// Copilot CLI keeps its whole config dir at $COPILOT_HOME when set,// falling back to ~/.copilot; user-level MCP servers live in// mcp-config.json there (project `.mcp.json` / `.github/mcp.json`@@ -1051,6 +1054,7 @@ fn json_mcp_location(client: McpClient) -> Option<JsonMcpLocation> {| McpClient::KimiCode| McpClient::KiroCli| McpClient::CommandCode+ | McpClient::IbmBob| McpClient::CopilotCli| McpClient::Droid| McpClient::Swival@@ -1623,6 +1627,17 @@ fn build_mcp_entry(args: &InstallMcpArgs) -> Result<serde_json::Value> {entry.insert("headers".into(), json!({"Authorization": b}));}}+ McpClient::IbmBob => {+ // Bob's HTTP client sends a non-standard `server/discover` probe+ // in automatic mode. ai-memory implements the MCP initialize+ // handshake, so pin Bob to its documented legacy negotiation path.+ entry.insert("type".into(), json!("streamable-http"));+ entry.insert("url".into(), json!(server_url));+ entry.insert("protocolNegotiation".into(), json!("legacy"));+ if let Some(b) = &bearer {+ entry.insert("headers".into(), json!({"Authorization": b}));+ }+ }McpClient::Swival => {// Swival .swival/mcp.json entry: `type: "http"` + `url` +// optional headers (documented format).@@ -2462,6 +2477,20 @@ fn render_command_code(args: &InstallMcpArgs) -> Result<String> {))}+fn render_ibm_bob(args: &InstallMcpArgs) -> Result<String> {+ Ok(format!(+ "# IBM Bob IDE — merge into ~/.bob/settings/mcp.json, or re-run with\n\+ # --apply to merge it in place preserving other servers. Bob also\n\+ # supports project-level .bob/mcp.json via --config-file.\n\+ # protocolNegotiation is set to legacy because Bob's automatic mode\n\+ # probes server/discover before the standard MCP initialize handshake.\n\+ # Pair with `ai-memory install-hooks --agent ibm-bob --apply` for\n\+ # lifecycle capture and automatic handoff delivery.\n\+ {snippet}\n",+ snippet = render_json_mcp_fragment(args)?,+ ))+}+fn render_copilot_cli(args: &InstallMcpArgs) -> Result<String> {Ok(format!("# GitHub Copilot CLI — merge into $COPILOT_HOME/mcp-config.json\n\@@ -2663,6 +2692,70 @@ mod tests {}}+ #[test]+ fn ibm_bob_entry_uses_documented_legacy_streamable_http_shape() {+ assert_eq!(+ build_json_mcp_entry(&args_with_token(McpClient::IbmBob)).unwrap(),+ json!({+ "type": "streamable-http",+ "url": "http://127.0.0.1:49374/mcp",+ "protocolNegotiation": "legacy",+ "headers": {"Authorization": "Bearer test-token-deadbeef"},+ })+ );+ assert_eq!(+ build_json_mcp_entry(&args_for(McpClient::IbmBob)).unwrap(),+ json!({+ "type": "streamable-http",+ "url": "http://127.0.0.1:49374/mcp",+ "protocolNegotiation": "legacy",+ })+ );+ let path = mcp_config_path_with(McpClient::IbmBob, &|_| None).unwrap();+ assert!(+ path.ends_with(Path::new(".bob/settings/mcp.json")),+ "{}",+ path.display()+ );+ }++ #[test]+ fn ibm_bob_apply_preserves_siblings_and_is_idempotent() {+ let tmp = tempfile::tempdir().unwrap();+ let file = tmp.path().join("mcp.json");+ fs::write(+ &file,+ json!({+ "mcpServers": {"other": {"type": "stdio", "command": "other"}},+ "keep": true+ })+ .to_string(),+ )+ .unwrap();+ let mut args = args_for(McpClient::IbmBob);+ args.config_file = Some(file.clone());+ args.server_url = Some("https://memory.example/mcp".into());+ apply_to_config_file(&args).unwrap();+ let first = fs::read_to_string(&file).unwrap();+ apply_to_config_file(&args).unwrap();+ assert_eq!(first, fs::read_to_string(&file).unwrap());+ let root: serde_json::Value = serde_json::from_str(&first).unwrap();+ assert_eq!(root["keep"], true);+ assert_eq!(root["mcpServers"]["other"]["command"], "other");+ assert_eq!(+ root["mcpServers"]["ai-memory"],+ json!({+ "type": "streamable-http",+ "url": "https://memory.example/mcp",+ "protocolNegotiation": "legacy",+ })+ );+ assert_eq!(+ existing_entry_endpoint(McpClient::IbmBob, &file, "ai-memory").unwrap(),+ Some("https://memory.example/mcp".into())+ );+ }+/// Muse's entry is the session-aware stdio bridge for `--agent muse`, so/// Muse forwards `MUSE_SESSION_ID`; a streamable-HTTP entry would carry no/// session id. `mode` is `optional` because Muse's default `required`@@ -3815,6 +3908,7 @@ mod tests {McpClient::KimiCode => render_kimi_code(&args).unwrap(),McpClient::KiroCli => render_kiro_cli(&args).unwrap(),McpClient::CommandCode => render_command_code(&args).unwrap(),+ McpClient::IbmBob => render_ibm_bob(&args).unwrap(),McpClient::CopilotCli => render_copilot_cli(&args).unwrap(),McpClient::Droid => render_droid(&args).unwrap(),McpClient::Swival => render_swival(&args).unwrap(),@@ -3848,6 +3942,7 @@ mod tests {McpClient::KimiCode,McpClient::KiroCli,McpClient::CommandCode,+ McpClient::IbmBob,McpClient::CopilotCli,McpClient::Swival,McpClient::VsCodeCopilot,@@ -3890,6 +3985,7 @@ mod tests {McpClient::Zcode,McpClient::Devin,McpClient::KimiCode,+ McpClient::IbmBob,McpClient::KiroCli,McpClient::CommandCode,McpClient::CopilotCli,@@ -3932,6 +4028,7 @@ mod tests {McpClient::KimiCode => render_kimi_code(&args).unwrap(),McpClient::KiroCli => render_kiro_cli(&args).unwrap(),McpClient::CommandCode => render_command_code(&args).unwrap(),+ McpClient::IbmBob => render_ibm_bob(&args).unwrap(),McpClient::CopilotCli => render_copilot_cli(&args).unwrap(),McpClient::Droid => render_droid(&args).unwrap(),McpClient::Swival => render_swival(&args).unwrap(),diff --git a/crates/ai-memory-cli/src/commands/render_shared.rs b/crates/ai-memory-cli/src/commands/render_shared.rsindex 9a82f0b1..5de9667a 100644--- a/crates/ai-memory-cli/src/commands/render_shared.rs+++ b/crates/ai-memory-cli/src/commands/render_shared.rs@@ -165,6 +165,19 @@ pub(crate) const CODEBUDDY_EVENTS: [(&str, &str); 7] = [("SessionEnd", "session-end.sh"),];+/// IBM Bob IDE's common lifecycle vocabulary. Bob Shell also supports these+/// five events; its additional compaction events are intentionally omitted so+/// one global settings file remains valid in both products. Bob has no+/// `SessionEnd`, and `Stop` is an agent-turn boundary rather than a reliable+/// process-exit boundary.+pub(crate) const IBM_BOB_EVENTS: [(&str, &str); 5] = [+ ("SessionStart", "session-start.sh"),+ ("UserPromptSubmit", "user-prompt-submit.sh"),+ ("PreToolUse", "pre-tool-use.sh"),+ ("PostToolUse", "post-tool-use.sh"),+ ("Stop", "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.@@ -1186,6 +1199,33 @@ pub(crate) fn build_codebuddy_hooks_payload()}+/// `{"hooks": <event map>}` for IBM Bob's+/// `~/.bob/settings/settings.json`. Bob's outer event groups have the same+/// nested shape as Claude Code, but `matcher` is valid only on tool events;+/// omitting it matches every tool and keeps lifecycle entries schema-valid.+/// Bob runs the command through the platform shell with the event JSON on+/// stdin, so each entry invokes ai-memory's native hook command directly.+pub(crate) fn build_ibm_bob_hooks_payload(+ server_url: &str,+ auth_token: Option<&str>,+ data_dir: Option<&Path>,+ project_strategy: Option<&str>,+) -> Value {+ build_hook_payload_for_platform(+ &IBM_BOB_EVENTS,+ Path::new(""),+ server_url,+ auth_token,+ HookShape::NestedWithoutMatcher,+ HookCommandContext::new(+ HookCommandPlatform::native(),+ "ibm-bob",+ data_dir,+ project_strategy,+ ),+ )+}+/// Pool (Poolside Agent CLI) `.poolside/settings.yaml` `hooks:` block for/// install-hooks' print path. Pool's hook config is a project-scoped YAML/// file at the repo root — there is no user-global hook file for ai-memory@@ -4231,6 +4271,35 @@ if (inheritOnly) {}}+ #[test]+ fn ibm_bob_profile_uses_common_events_without_matchers() {+ let value = build_ibm_bob_hooks_payload(+ "http://memory:49374",+ None,+ Some(Path::new("/data")),+ Some("repo-root"),+ );++ assert_eq!(value["hooks"].as_object().unwrap().len(), 5);+ for (event, script) in IBM_BOB_EVENTS {+ let definition = &value["hooks"][event][0];+ assert!(definition.get("matcher").is_none(), "event: {event}");+ let command = definition["hooks"][0]["command"].as_str().unwrap();+ let event_name = script.trim_end_matches(".sh");+ assert!(+ command.contains(&format!("hook --event {event_name} --agent ibm-bob")),+ "{event}: {command}"+ );+ assert!(+ command.contains("--project-strategy repo-root"),+ "{command}"+ );+ assert!(!command.contains(".sh"), "{command}");+ }+ assert!(value["hooks"].get("SessionEnd").is_none());+ assert!(value["hooks"].get("PreCompact").is_none());+ }+#[test]fn claude_code_payload_emits_absolute_paths() {let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))diff --git a/crates/ai-memory-cli/src/commands/setup.rs b/crates/ai-memory-cli/src/commands/setup.rsindex 754f87e7..4db7a48c 100644--- a/crates/ai-memory-cli/src/commands/setup.rs+++ b/crates/ai-memory-cli/src/commands/setup.rs@@ -226,6 +226,9 @@ pub async fn run(config: &Config, args: SetupArgs, config_path: Option<&Path>) -if let Some(dir) = codebuddy_detected(&home) {found.push((AgentChoice::CodeBuddy, Found::ConfigDir(dir)));}+ if let Some(dir) = ibm_bob_detected(&home) {+ found.push((AgentChoice::IbmBob, Found::ConfigDir(dir)));+ }found.into_iter().map(|(agent, found)| (agent, Some(found)))@@ -406,6 +409,11 @@ fn codebuddy_detected(home: &Path) -> Option<PathBuf> {Some(home.join(".codebuddy")).filter(|dir| dir.is_dir())}+/// IBM Bob's shared configuration directory, `~/.bob`, when it exists.+fn ibm_bob_detected(home: &Path) -> Option<PathBuf> {+ Some(home.join(".bob")).filter(|dir| dir.is_dir())+}+/// The binary path the service unit runs. A package manager's versioned/// location (a Homebrew `Cellar/<formula>/<version>` or a `/nix/store` path)/// disappears on the next upgrade or `brew cleanup` / garbage collection, so a@@ -1126,6 +1134,22 @@ mod tests {assert_eq!(AgentPlan::new(AgentChoice::CodeBuddy, None).mcp, None);}+ #[test]+ fn ibm_bob_is_detected_and_wires_hooks_mcp_and_shared_skills() {+ let home = tempfile::tempdir().unwrap();+ assert_eq!(ibm_bob_detected(home.path()), None);+ std::fs::create_dir_all(home.path().join(".bob/settings")).unwrap();+ assert_eq!(+ ibm_bob_detected(home.path()),+ Some(home.path().join(".bob"))+ );+ assert_eq!(skills_for(AgentChoice::IbmBob), InstallSkillsAgent::Agents);+ assert_eq!(+ AgentPlan::new(AgentChoice::IbmBob, None).mcp,+ Some(McpClient::IbmBob)+ );+ }+/// A versioned Homebrew binary is recorded through the `opt/<formula>`/// link that survives `brew upgrade` and `brew cleanup`, falling back to/// the `<prefix>/bin` link; a link to some other binary never wins.diff --git a/crates/ai-memory-cli/src/commands/setup_agent.rs b/crates/ai-memory-cli/src/commands/setup_agent.rsindex 92851d7a..803134c4 100644--- a/crates/ai-memory-cli/src/commands/setup_agent.rs+++ b/crates/ai-memory-cli/src/commands/setup_agent.rs@@ -130,6 +130,11 @@ pub fn run(config: &Config, mut args: SetupAgentArgs) -> Result<()> {emit_codebuddy(&args)?;return Ok(());}+ // IBM Bob's settings run the native hook command directly too.+ if matches!(args.agent, AgentChoice::IbmBob) {+ emit_ibm_bob(&args)?;+ return Ok(());+ }let Some(agent_sub) = args.agent.script_hook_subdir() else {bail!("internal: generated integration should have returned before staging hooks")};@@ -228,7 +233,8 @@ pub fn run(config: &Config, mut args: SetupAgentArgs) -> Result<()> {| AgentChoice::Hermes| AgentChoice::Droid| AgentChoice::Muse- | AgentChoice::CodeBuddy => {+ | AgentChoice::CodeBuddy+ | AgentChoice::IbmBob => {bail!("internal: generated integration should have returned before emitting staged hooks")@@ -402,6 +408,29 @@ fn emit_codebuddy(args: &SetupAgentArgs) -> Result<()> {Ok(())}+/// Print the `hooks` block for IBM Bob's shared global settings. No scripts+/// are staged: each entry runs the native `hook` command.+fn emit_ibm_bob(args: &SetupAgentArgs) -> Result<()> {+ let payload = crate::commands::render_shared::build_ibm_bob_hooks_payload(+ &args.server_url,+ args.auth_token.as_deref(),+ None,+ None,+ );+ let serialized = serde_json::to_string_pretty(&payload["hooks"])+ .context("serializing IBM Bob hook config")?;+ println!("# IBM Bob — merge under the `hooks` key of");+ println!("# ~/.bob/settings/settings.json. The `command` must be an ai-memory");+ println!("# binary reachable on the host that runs Bob; prefer");+ println!("# `ai-memory install-hooks --agent ibm-bob --apply` from that host.");+ if args.auth_token.is_some() {+ println!("# Treat settings.json as sensitive (chmod 600).");+ }+ println!();+ println!("{serialized}");+ Ok(())+}+fn normalise_hook_server_url(url: &str) -> String {url.trim().trim_end_matches('/').to_string()}diff --git a/crates/ai-memory-cli/src/commands/uninstall.rs b/crates/ai-memory-cli/src/commands/uninstall.rsindex fc3c9bd6..c2230eeb 100644--- a/crates/ai-memory-cli/src/commands/uninstall.rs+++ b/crates/ai-memory-cli/src/commands/uninstall.rs@@ -276,6 +276,10 @@ fn build_plan(install_hooks::codebuddy_settings_path()?,HookConfigShape::NestedHooksKey,),+ (+ install_hooks::ibm_bob_settings_path()?,+ HookConfigShape::NestedHooksKey,+ ),]);for (path, shape) in hook_files {if !path.exists() {@@ -438,6 +442,7 @@ fn build_plan(KimiCode,KiroCli,CommandCode,+ IbmBob,CopilotCli,Droid,Swival,@@ -1534,6 +1539,7 @@ fn mcp_servers_path(client: McpClient) -> Option<&'static [&'static str]> {| McpClient::KimiCode| McpClient::KiroCli| McpClient::CommandCode+ | McpClient::IbmBob| McpClient::CopilotCli| McpClient::Droid| McpClient::Swivaldiff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rsindex e062a97c..c03cdde1 100644--- a/crates/ai-memory-core/src/ids.rs+++ b/crates/ai-memory-core/src/ids.rs@@ -297,6 +297,10 @@ pub enum AgentKind {/// is appended to the session (#1299).#[serde(rename = "codebuddy", alias = "code-buddy")]CodeBuddy,+ /// IBM Bob IDE, whose lifecycle hooks send Claude Code-shaped payloads+ /// but consume `SessionStart` stdout as plain context text.+ #[serde(rename = "ibm-bob", alias = "bob")]+ IbmBob,/// Anything else (manual capture, future agents).Other,}@@ -307,7 +311,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; 26] = [+ pub const ALL: [Self; 27] = [Self::ClaudeCode,Self::Codex,Self::OpenCode,@@ -333,6 +337,7 @@ impl AgentKind {Self::Droid,Self::Muse,Self::CodeBuddy,+ Self::IbmBob,Self::Other,];@@ -365,6 +370,7 @@ impl AgentKind {Self::Droid => "droid",Self::Muse => "muse",Self::CodeBuddy => "codebuddy",+ Self::IbmBob => "ibm-bob",Self::Other => "other",}}@@ -400,6 +406,7 @@ impl AgentKind {"droid" | "factory-droid" | "factory_droid" => Self::Droid,"muse" | "muse-code" | "musecode" => Self::Muse,"codebuddy" | "code-buddy" => Self::CodeBuddy,+ "ibm-bob" | "bob" => Self::IbmBob,_ => Self::Other,}}@@ -791,6 +798,27 @@ mod tests {assert!(!AgentKind::CodeBuddy.reuses_session_id_after_end());}+ #[test]+ fn agent_kind_ibm_bob_round_trips_and_injects_session_start_handoff() {+ assert_eq!(AgentKind::IbmBob.as_str(), "ibm-bob");+ for alias in ["ibm-bob", "bob"] {+ assert_eq!(AgentKind::from_wire(alias), AgentKind::IbmBob, "{alias}");+ }+ assert_eq!(+ serde_json::to_string(&AgentKind::IbmBob).unwrap(),+ "\"ibm-bob\""+ );+ assert_eq!(+ serde_json::from_str::<AgentKind>("\"bob\"").unwrap(),+ AgentKind::IbmBob+ );+ assert_eq!(AgentKind::from_wire("bob-shell-2"), AgentKind::Other);+ assert!(AgentKind::IbmBob.session_start_injects_handoff());+ assert!(!AgentKind::IbmBob.user_prompt_injects_handoff());+ assert!(!AgentKind::IbmBob.post_tool_injects_handoff());+ assert!(!AgentKind::IbmBob.reuses_session_id_after_end());+ }+#[test]fn agent_kind_grizzybot_round_trips() {assert_eq!(AgentKind::Grizzybot.as_str(), "grizzybot");diff --git a/crates/ai-memory-hooks/src/capture_policy.rs b/crates/ai-memory-hooks/src/capture_policy.rsindex b17c34fc..3753390d 100644--- a/crates/ai-memory-hooks/src/capture_policy.rs+++ b/crates/ai-memory-hooks/src/capture_policy.rs@@ -191,7 +191,8 @@ pub(crate) fn tool_payload_fields(agent: AgentKind, raw: &Value) -> Option<(&str| AgentKind::Zcode| AgentKind::CopilotCli| AgentKind::Muse- | AgentKind::CodeBuddy => (+ | AgentKind::CodeBuddy+ | AgentKind::IbmBob => (object.get("tool_name")?.as_str()?,object.get("tool_use_id").and_then(Value::as_str),),@@ -264,6 +265,7 @@ pub(crate) fn tool_observation_metadata(| AgentKind::Droid| AgentKind::Muse| AgentKind::CodeBuddy+ | AgentKind::IbmBob) {"tool_input"} else {@@ -1109,7 +1111,8 @@ fn extract(agent: AgentKind, raw: &Value) -> Extracted<'_> {// CodeBuddy Code uses Claude Code's names and the same two fields// (#1299), so `[capture] ignore_paths` classifies them as Claude's.| AgentKind::Muse- | AgentKind::CodeBuddy => object+ | AgentKind::CodeBuddy+ | AgentKind::IbmBob => object.get("tool_name").and_then(Value::as_str).map(|name| (name, object.get("tool_input"))),@@ -4798,6 +4801,53 @@ mod tests {}}+ /// Bob's Claude-shaped file and shell calls must pass through the same+ /// capture exclusions. The legitimate control proves the mapping does not+ /// discard every Bob tool call.+ #[test]+ fn ibm_bob_tool_calls_honor_capture_exclusions() {+ let policy = CapturePolicy::resolve(+ CaptureSource::Parsed(&CaptureConfig {+ ignore_paths: vec!["secret/**".into()],+ }),+ "/repo",+ None,+ );+ let call = |path: &str| {+ json!({+ "hook_event_name": "PreToolUse",+ "session_id": "bob-session",+ "cwd": "/repo",+ "tool_name": "Read",+ "tool_input": {"file_path": path},+ "tool_use_id": "toolu_1",+ })+ };++ assert_eq!(+ policy+ .inspect(AgentKind::IbmBob, &call("secret/token"), "/repo")+ .protocol()+ .disposition(),+ CaptureDisposition::Drop+ );+ assert_eq!(+ policy+ .inspect(AgentKind::IbmBob, &call("src/lib.rs"), "/repo")+ .protocol()+ .disposition(),+ CaptureDisposition::Keep+ );+ assert_eq!(+ policy+ .inspect(AgentKind::Other, &call("secret/token"), "/repo")+ .protocol()+ .disposition(),+ CaptureDisposition::Keep,+ "without the Bob mapping the call is not recognized"+ );+ }+#[test]fn droid_tool_calls_honor_capture_exclusions() {let policy = CapturePolicy::resolve(diff --git a/crates/ai-memory-hooks/src/payload.rs b/crates/ai-memory-hooks/src/payload.rsindex f9831614..816f77b4 100644--- a/crates/ai-memory-hooks/src/payload.rs+++ b/crates/ai-memory-hooks/src/payload.rs@@ -845,6 +845,7 @@ const fn closed_tool_agent(agent: AgentKind) -> bool {// (#1299). Unknown values stay `Other` and keep the capture-only// path.| AgentKind::CodeBuddy+ | AgentKind::IbmBob)}@@ -2303,6 +2304,48 @@ mod tests {assert!(unknown.body_excerpt.is_none());}+ /// IBM Bob documents the same snake_case tool fields as Claude Code. A+ /// recognized Bob payload becomes a closed tool observation while an+ /// unknown agent carrying identical JSON stays on the capture-only path.+ #[test]+ fn ibm_bob_post_tool_use_uses_the_claude_shaped_parser() {+ let raw = serde_json::json!({+ "hook_event_name": "PostToolUse",+ "session_id": "11111111-2222-3333-4444-555555555555",+ "cwd": "/repo",+ "tool_name": "Read",+ "tool_use_id": "toolu_bob",+ "tool_input": {"file_path": "src/lib.rs"},+ "tool_response": "file contents"+ });+ let env = HookEnvelope::from_query_and_body(+ HookQuery {+ event: "post-tool-use".into(),+ agent: Some("ibm-bob".into()),+ ..Default::default()+ },+ raw.clone(),+ );+ assert_eq!(env.agent, AgentKind::IbmBob);+ assert_eq!(env.title_hint.as_deref(), Some("tool file"));+ let body = env.body_excerpt.expect("structured tool body");+ assert!(body.starts_with("tool_family: file\n"), "{body}");+ assert!(body.contains("tool_call_id: toolu_bob"), "{body}");+ assert!(body.contains("\n---\nfile contents"), "{body}");++ let unknown = HookEnvelope::from_query_and_body(+ HookQuery {+ event: "post-tool-use".into(),+ agent: Some("ibm-bob-2".into()),+ ..Default::default()+ },+ raw,+ );+ assert_eq!(unknown.agent, AgentKind::Other);+ assert!(unknown.title_hint.is_none());+ assert!(unknown.body_excerpt.is_none());+ }+/// Hermes 3.x puts the tool result inside `extra.result` and mirrors the/// call status in `extra.status` (`ok` | `error`). The extractor must read/// both from the documented `extra` object: output lands in the bodydiff --git a/crates/ai-memory-store/migrations/V83__sessions_ibm_bob_agent_kind.sql b/crates/ai-memory-store/migrations/V83__sessions_ibm_bob_agent_kind.sqlnew file mode 100644index 00000000..20459e2a--- /dev/null+++ b/crates/ai-memory-store/migrations/V83__sessions_ibm_bob_agent_kind.sql@@ -0,0 +1,74 @@+-- Expand sessions.agent_kind CHECK for IBM Bob.+--+-- Keep the complete V82 schema, indexes, and scope-pairing triggers while+-- adding the `ibm-bob` 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','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/crates/ai-memory-store/src/api_credentials.rs b/crates/ai-memory-store/src/api_credentials.rsindex 9101e155..8b99ecde 100644--- a/crates/ai-memory-store/src/api_credentials.rs+++ b/crates/ai-memory-store/src/api_credentials.rs@@ -433,7 +433,7 @@ mod tests {|row| row.get(0),).unwrap();- assert_eq!(version, 82, "update the pin when adding a migration");+ assert_eq!(version, 83, "update the pin when adding a migration");let cols: i64 = conn.query_row("SELECT COUNT(*) FROM pragma_table_info('users') \diff --git a/crates/ai-memory-store/src/migrations.rs b/crates/ai-memory-store/src/migrations.rsindex 443fa33f..7410a0fb 100644--- a/crates/ai-memory-store/src/migrations.rs+++ b/crates/ai-memory-store/src/migrations.rs@@ -1404,6 +1404,119 @@ mod tests {}}+ /// V83 expands the sessions enum for IBM Bob. Existing sessions and+ /// dependent observations survive the table rebuild, while the old V82+ /// constraint rejects the new value and the migrated schema accepts it.+ #[test]+ fn v82_to_v83_preserves_sessions_and_observations_and_accepts_ibm_bob() {+ let mut conn = Connection::open_in_memory().unwrap();+ run_to(&mut conn, 82).unwrap();+ conn.pragma_update(None, "foreign_keys", "ON").unwrap();+ let workspace_id = crate::ops::get_or_create_workspace(&mut conn, "default").unwrap();+ let project_id =+ crate::ops::get_or_create_project(&mut conn, &workspace_id, "project", None).unwrap();+ let existing = SessionId::new();+ conn.execute(+ "INSERT INTO sessions \+ (id, workspace_id, project_id, agent_kind, cwd, started_at, actor_user) \+ VALUES (?1, ?2, ?3, 'codebuddy', '/repo', 1, 'user:alice')",+ params![+ existing.as_bytes(),+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ ],+ )+ .unwrap();+ assert!(+ conn.execute(+ "INSERT INTO sessions \+ (id, workspace_id, project_id, agent_kind, started_at) \+ VALUES (?1, ?2, ?3, 'ibm-bob', 1)",+ params![+ SessionId::new().as_bytes(),+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ ],+ )+ .is_err(),+ "the V82 CHECK must reject ibm-bob"+ );+ conn.execute(+ "INSERT INTO observations \+ (id, session_id, workspace_id, project_id, kind, title, body, created_at) \+ VALUES (?1, ?2, ?3, ?4, 'prompt', 'kept', 'kept body', 1)",+ params![+ uuid::Uuid::new_v4().as_bytes(),+ existing.as_bytes(),+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ ],+ )+ .unwrap();++ conn.pragma_update(None, "foreign_keys", "OFF").unwrap();+ run(&mut conn).unwrap();+ conn.pragma_update(None, "foreign_keys", "ON").unwrap();++ let preserved: (String, String, Option<String>) = conn+ .query_row(+ "SELECT agent_kind, cwd, actor_user FROM sessions WHERE id = ?1",+ params![existing.as_bytes()],+ |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)),+ )+ .unwrap();+ assert_eq!(+ preserved,+ (+ "codebuddy".into(),+ "/repo".into(),+ Some("user:alice".into())+ )+ );+ let observations: i64 = conn+ .query_row(+ "SELECT COUNT(*) FROM observations WHERE session_id = ?1",+ params![existing.as_bytes()],+ |row| row.get(0),+ )+ .unwrap();+ assert_eq!(observations, 1, "the session's observations survive");++ crate::ops::begin_session(+ &mut conn,+ &NewSession {+ occurred_at: None,+ id: SessionId::new(),+ workspace_id,+ project_id,+ agent_kind: AgentKind::IbmBob,+ cwd: Some("/repo".into()),+ actor_user: Some("user:alice".into()),+ },+ )+ .unwrap();+ assert_eq!(+ conn.query_row("SELECT COUNT(*) FROM pragma_foreign_key_check", [], |row| {+ row.get::<_, i64>(0)+ })+ .unwrap(),+ 0+ );+ for name in [+ "idx_sessions_open_owner",+ "sessions_ws_proj_pairing_ai",+ "auto_improve_scheduler_claims_session_pairing_ai",+ "session_consolidation_jobs_session_pairing_ai",+ ] {+ let kind = if name.starts_with("idx_") {+ "index"+ } else {+ "trigger"+ };+ assert_eq!(schema_object_count(&conn, kind, name), 1, "missing {name}");+ }+ }+#[test]fn v81_to_v82_preserves_managed_runs_and_adds_previous_session_identity() {let mut conn = Connection::open_in_memory().unwrap();diff --git a/docs/install.md b/docs/install.mdindex 56e055cf..3140f873 100644--- a/docs/install.md+++ b/docs/install.md@@ -20,7 +20,7 @@ RPM, macOS menu bar app). This page covers everything else:- [macOS menu bar app](#macos-menu-bar-app)(self-contained `.app` + LaunchAgent)- [Configuring other agent CLIs](#configuring-other-agent-clis)- (Codex, Command Code, Devin CLI, OpenCode, OpenCode 2, OMP, Pi, Cursor, Claude Desktop, Gemini CLI, Antigravity CLI, Grok Build CLI, GitHub Copilot CLI, Factory Droid, Meta Muse Code, CodeBuddy Code, Hermes Agent, Zero, ZCode, Kimi Code, Kiro CLI, Pool, OpenClaw, VS Code Copilot, Zed, and MCP-only recipes for Warp, Cline, Kilo Code, Goose, Qwen Code and OpenHuman)+ (Codex, Command Code, IBM Bob, Devin CLI, OpenCode, OpenCode 2, OMP, Pi, Cursor, Claude Desktop, Gemini CLI, Antigravity CLI, Grok Build CLI, GitHub Copilot CLI, Factory Droid, Meta Muse Code, CodeBuddy Code, Hermes Agent, Zero, ZCode, Kimi Code, Kiro CLI, Pool, OpenClaw, VS Code Copilot, Zed, and MCP-only recipes for Warp, Cline, Kilo Code, Goose, Qwen Code and OpenHuman)- [Installing hooks without docker](#installing-hooks-without-docker)(curl-based installer)- [Running ai-memory without docker](#running-ai-memory-without-docker)@@ -1518,6 +1518,34 @@ and preserves `parentId` on visible events for branch provenance. An unknownfuture transcript version fails closed until its schema is audited. Direct`cmd`, `cmdc`, or `command-code` launches remain unchanged.+### IBM Bob++IBM Bob IDE and Bob Shell share their global settings below `~/.bob/settings`.+Install MCP and lifecycle capture together:++```bash+ai-memory install-mcp --client ibm-bob --apply \+ --server-url "https://memory.example/mcp" \+ --auth-token "$TOKEN"+ai-memory install-hooks --agent ibm-bob --apply \+ --server-url "https://memory.example" \+ --auth-token "$TOKEN"+```++The `bob` alias is accepted. MCP is merged into `mcp.json` as Bob's native+`streamable-http` entry with `protocolNegotiation: "legacy"`; this skips Bob's+non-standard discovery probe and uses the standard MCP handshake. Hooks are+merged into the root `hooks` object of `settings.json`, preserving other+settings and handlers. The installer uses only the five events common to the+IDE and Shell, delivers the pending handoff as plain `SessionStart` context,+and enforces capture exclusions for tool events.++Bob has no true session-end event. Use `ai-memory finalize-session --agent+ibm-bob` after the final turn when you need the summary and handoff immediately.+Managed `ai-memory run ibm-bob` resume is not supported because Bob does not+document a stable native transcript store. See [the IBM Bob MCP and hook+details](mcp-install.md#ibm-bob).+### Kiro CLIKiro CLI has one MCP surface and two incompatible lifecycle-hook formats.diff --git a/docs/managed-harness-contributions.md b/docs/managed-harness-contributions.mdindex 88bdc6de..0d30f546 100644--- a/docs/managed-harness-contributions.md+++ b/docs/managed-harness-contributions.md@@ -2,9 +2,9 @@Managed-workstream support is narrower than MCP or lifecycle-hook support. Thisrelease can manage Claude Code, Codex, OpenCode, OpenCode 2 beta, Pi, Crush, Kimi Code, Command-Code, Kiro CLI v2/v3, OMP, Grok Build CLI, Antigravity CLI, and GitHub Copilot CLI. Gemini CLI,-Devin CLI, Cursor, and the other integrations in the README support matrix do-not become managed merely because ai-memory can capture their hooks.+Code, Kiro CLI v2/v3, OMP, Grok Build CLI, Antigravity CLI, and GitHub Copilot CLI. IBM Bob,+Gemini CLI, Devin CLI, Cursor, and the other integrations in the README support+matrix do not become managed merely because ai-memory can capture their hooks.A managed adapter must preserve a harness's real native session, deliver theportable workstream delta exactly once, and import only visible history withoutdiff --git a/docs/managed-workstreams.md b/docs/managed-workstreams.mdindex c22d6859..39c21610 100644--- a/docs/managed-workstreams.md+++ b/docs/managed-workstreams.md@@ -851,7 +851,7 @@ OMP currently needs no added flag. ai-memory does not add a duplicate when thetranslated native flag is already present.Managed support is intentionally narrower than the general integration matrix.-Gemini CLI, Devin CLI, Cursor, and other agents may+IBM Bob, Gemini CLI, Devin CLI, Cursor, and other agents mayhave MCP or lifecycle-hook support without native managed resume. Contributorsadding another managed harness must follow the [managed-harness contributionprotocol](managed-harness-contributions.md), including read-only extraction,diff --git a/docs/mcp-install.md b/docs/mcp-install.mdindex ad4794f3..d18465c1 100644--- a/docs/mcp-install.md+++ b/docs/mcp-install.md@@ -1311,8 +1311,8 @@ stdout but prepends successful user-prompt hook output to the turn).## Command Code-**Status:** MCP and the four stable shell-hook events are supported. Managed-workstreams and experimental Mods are not installed.+**Status:** MCP, the four stable shell-hook events, and opt-in managed+workstreams are supported. Experimental Mods are not installed.**Config files:** `~/.commandcode/mcp.json` for MCP and`~/.commandcode/settings.json` for lifecycle hooks.@@ -1349,13 +1349,13 @@ envelope, and inject pending handoffs with`Stop` is only a turn boundary. Run `ai-memory finalize-session --agentcommand-code` after the final turn (or add `--session-id <uuid>` when several-sessions share the project). ai-memory does not generate a Mod: that API is-experimental and unsandboxed. Command Code officially documents its-project-scoped append-only JSONL location, native resume selectors, `--yolo`,-and Windows aliases, but not the JSONL record schema. A managed adapter remains-deferred until a real logged-in client acceptance test supplies sanitized-structural fixtures and validates checkout ownership, incremental visible-event-import, resume identity, normal-exit finalization, and native Windows execution.+sessions share the project). A managed `ai-memory run command-code` launch+finalizes automatically on normal exit when it can tie the native session to+the run. Its read-only adapter validates the observed v3 header, UUID filename,+and canonical checkout before importing visible events, and resumes with the+exact native `--session <uuid>` selector. Unknown transcript versions fail+closed. ai-memory does not generate a Mod: that API is experimental and+unsandboxed.Sources: <https://commandcode.ai/docs/mcp>,<https://commandcode.ai/docs/hooks>,@@ -1363,6 +1363,54 @@ Sources: <https://commandcode.ai/docs/mcp>,<https://commandcode.ai/docs/reference/cli>, plus the native-session contract at<https://commandcode.ai/docs/sessions>.+## IBM Bob++**Status:** MCP and lifecycle hooks are supported for IBM Bob IDE and Bob+Shell. Managed workstreams and transcript backfill are not claimed.++**Config files:** `~/.bob/settings/mcp.json` for MCP and+`~/.bob/settings/settings.json` for lifecycle hooks. Bob also accepts a+project-level `.bob/mcp.json`; pass that path with `--config-file` when wanted.++```bash+ai-memory install-mcp --client ibm-bob --apply \+ --server-url "https://memory.example/mcp" --auth-token "$TOKEN"+ai-memory install-hooks --agent ibm-bob --apply \+ --server-url "https://memory.example" --auth-token "$TOKEN"+```++The alias `bob` is accepted by both commands. The MCP entry uses Bob's native+`streamable-http` transport with `protocolNegotiation: "legacy"`. Bob's+automatic negotiation first sends a non-standard `server/discover` request;+the documented legacy setting skips that probe and starts with the standard+MCP initialization ai-memory implements. Existing servers and settings are+preserved, and applying either command again is a no-op.++The hook installer registers the five events shared by Bob IDE and Bob Shell:+`SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, and `Stop`.+Definitions omit `matcher`, which Bob documents only for tool events. The+native command receives Bob's JSON on stdin, enforces capture exclusions over+the Claude-shaped tool fields, and prints a pending handoff as plain+`SessionStart` context. Capture-only `SessionStart` and `UserPromptSubmit`+events stay silent so `{}` is never injected into the model context.++Bob does not expose a true `SessionEnd`; `Stop` is a turn boundary. After the+last turn, finalize explicitly when an immediate summary and handoff matter:++```bash+ai-memory finalize-session --agent ibm-bob+```++There is no `ai-memory run ibm-bob` adapter. Bob Shell documents resume+selectors but not a stable transcript-store schema and path, so claiming+cross-harness transcript import would be unsafe without fixtures and a logged-in+acceptance test. Bob reads `AGENTS.md`, so the normal ai-memory routing snippet+and Agent Skills need no Bob-specific instruction file.++Sources: [Bob MCP configuration](https://bob.ibm.com/docs/ide/configuration/mcp/mcp-in-bob),+[Bob IDE lifecycle hooks](https://bob.ibm.com/docs/ide/configuration/lifecycle-hooks),+and [Bob Shell lifecycle hooks](https://bob.ibm.com/docs/shell/configuration/lifecycle-hooks).+## Kiro CLI**Status:** MCP, v2 lifecycle hooks, and explicit v2 managed workstreams arediff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex 81ff8875..b5f1eaf4 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -126,6 +126,17 @@ means the boundary is not built yet.| 26 | Cross-harness native-history continuation stays checkout-scoped and client-local | `ai-memory-store/src/workstream.rs` `prepare_run` selects the newest current native session only when its harness differs from the destination and pins that typed identity on the run before destination linking can change recency; `ai-memory-cli/src/commands/run.rs` validates the returned `NativeSessionIdentity`, resolves only known adapter flavors, requires `native_session_in_checkout`, exports through the bounded read-only adapter, and writes an untrusted-history dossier to a private temporary directory exposed only to the child as `AI_MEMORY_PREVIOUS_SESSION_HISTORY`; the server wire type deliberately has no path/content field and same-harness launches select no source | Core `prepare_response_carries_only_previous_native_identity` and `older_prepare_response_defaults_to_no_adoption`; store `managed_adoption_stops_after_any_harness_links_the_workstream` (switch control, destination-link recency cannot replace the pinned source, same-harness refusal); hooks `managed_context_points_at_local_history_on_a_harness_switch` (no session id rendered, untrusted instruction present); CLI `previous_session_history_is_private_local_and_checkout_scoped` (legitimate control, foreign checkout refused, private local file removed with its owner) | STRONG for checkout isolation and server path/content privacy. The dossier is a bounded visible-history projection, not raw hidden reasoning; if the source store is absent, remote, unreadable, or over bounds, the child receives only the portable ledger and handoff |+### IBM Bob evidence++IBM Bob extends boundary **4j** through `hook.rs`+`a_handoff_is_never_claimed_without_a_project_directory`: an unscoped Bob+`SessionStart` cannot send `GET /handoff`, while the same payload with a `cwd`+claims once and names that directory. It extends boundary **11b** through+`capture_policy.rs` `ibm_bob_tool_calls_honor_capture_exclusions`: an ignored+Claude-shaped `Read` path is dropped, a public-path control is kept, and the+same body under an unknown agent stays unclassified. Removing Bob from either+guard makes the corresponding adversarial test fail. Coverage: **STRONG**.+## Keeping this current (the standing protocol)1. **Touch a guard, add/extend its adversarial test.** Any change to code in thediff --git a/docs/support-matrix.md b/docs/support-matrix.mdindex dd1f2fe8..1c0a340b 100644--- a/docs/support-matrix.md+++ b/docs/support-matrix.md@@ -44,6 +44,7 @@| VS Code Copilot | MCP-only | `.vscode/mcp.json` for Copilot agent mode; no lifecycle hooks (Copilot does not expose them yet). || 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. || 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`). |