Skip to content

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

Rust

feat(integrations): add Qoder lifecycle and MCP support

AkitaOnRails438fd7507d5e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d94fe943..fb9e5cc3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,16 @@ version in [`docs/changelog/`](docs/changelog/):
### Added
+- Added first-party Qoder CLI/IDE lifecycle and MCP support. Both installers
+ merge into `~/.qoder/settings.json`: `install-mcp --client qoder` writes a
+ sessionless stdio bridge, while `install-hooks --agent qoder` registers the
+ eight documented memory-bearing events as native commands. Session start
+ delivers a pending handoff through `hookSpecificOutput.additionalContext`,
+ prompt/tool capture uses Qoder's Claude-shaped payloads, and a missing hook
+ `cwd` falls back only to `QODER_PROJECT_DIR`. Setup detects `~/.qoder`,
+ uninstall removes both entries, and agent backups include its settings and
+ shared AGENTS-compatible skills/instructions (#1611).
+
- Profile writes now return `digest_warning` when the selected summary,
abstract, or prose statement exceeds the 240-byte session-start digest
limit. The write still succeeds, but its author can shorten the summary
diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.md
index e9dc5df3..178b106a 100644
--- a/INSTALL_FOR_AGENTS.md
+++ b/INSTALL_FOR_AGENTS.md
@@ -33,7 +33,7 @@ takes two commands, and neither needs root or administrator rights.
`<self>` is one of `claude-code`, `codex`, `opencode`, `opencode2`,
`gemini-cli`, `cursor`, `kimi-code`, `kiro-cli`, `grok`, `copilot-cli`,
`antigravity-cli`, `command-code`, `devin`, `droid`, `muse`, `omp`, `pi`,
- `openclaw`, `qwen-code`
+ `openclaw`, `qwen-code`, `qoder`
(`ai-memory setup --help` lists every value). Repeat `--agent` to wire
several harnesses. Without `--agent`, `setup` wires every harness it finds
under the home directory.
diff --git a/README.md b/README.md
index 7f8a9077..bc9e5a74 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,7 @@ caveats is in [`docs/support-matrix.md`](docs/support-matrix.md).
| CodeBuddy Code | Hooks-only |
| IBM Bob | Supported |
| Qwen Code | Supported |
+| Qoder | Supported |
| VS Code Copilot | MCP-only |
| Zed | MCP-only |
| DeepSeek Harness (DSH) | Hooks + MCP |
@@ -393,7 +394,7 @@ docker run -d --name ai-memory \
# 3. Wire your agent CLI in two commands. The wrapper takes care of
# mounts and each client's config-path detection. Re-run with
# `--agent codex`, `--agent command-code`, `--agent devin`, `--agent opencode`, `--agent opencode2`, `--agent gemini-cli`,
-# `--agent grok`, `--agent kimi-code`, `--agent kiro-cli`, `--agent copilot-cli`, `--agent droid`, `--agent muse`, `--agent cline`, `--agent qwen-code`, `--agent omp`,
+# `--agent grok`, `--agent kimi-code`, `--agent kiro-cli`, `--agent copilot-cli`, `--agent droid`, `--agent muse`, `--agent cline`, `--agent qwen-code`, `--agent qoder`, `--agent omp`,
# `--agent oh-my-pi`, `--client cursor`,
# `--client gemini-cli`, `--client grok`, `--client kiro-cli`,
# `--client cline`, `--client freebuff`, etc.
diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rs
index 0cf5327c..68925dc8 100644
--- a/crates/ai-memory-cli/src/cli.rs
+++ b/crates/ai-memory-cli/src/cli.rs
@@ -2582,6 +2582,10 @@ pub enum AgentChoice {
/// Qwen's own `SessionEnd` closes the session.
#[value(name = "qwen-code", alias = "qwen", alias = "qwencode")]
QwenCode,
+ /// Qoder CLI and IDE — lifecycle hooks merged into the `hooks` key of
+ /// `~/.qoder/settings.json`. Qoder sends Claude Code-shaped JSON on stdin
+ /// and consumes `SessionStart` additional context.
+ Qoder,
}
impl AgentChoice {
@@ -2620,6 +2624,7 @@ impl AgentChoice {
Self::Dsh => AgentKind::Dsh,
Self::Cline => AgentKind::Cline,
Self::QwenCode => AgentKind::QwenCode,
+ Self::Qoder => AgentKind::Qoder,
}
}
@@ -2645,6 +2650,7 @@ impl AgentChoice {
| Self::IbmBob
| Self::Cline
| Self::QwenCode => None,
+ Self::Qoder => None,
_ => Some(self.kind().as_str()),
}
}
@@ -2846,6 +2852,9 @@ pub enum McpClient {
/// capture and `SessionStart` handoff delivery.
#[value(name = "qwen-code", alias = "qwen", alias = "qwencode")]
QwenCode,
+ /// Qoder CLI and IDE — user-level `~/.qoder/settings.json`, with a
+ /// stdio `ai-memory mcp-bridge --no-session-id` entry under `mcpServers`.
+ Qoder,
/// 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
@@ -5031,6 +5040,24 @@ mod tests {
}
}
+ #[test]
+ fn qoder_install_hooks_and_mcp_parse() {
+ let hooks =
+ Cli::try_parse_from(["ai-memory", "install-hooks", "--agent", "qoder"]).unwrap();
+ let Command::InstallHooks(args) = hooks.command else {
+ panic!("expected install-hooks");
+ };
+ assert_eq!(args.agent, AgentChoice::Qoder);
+ assert_eq!(args.agent.kind(), ai_memory_core::AgentKind::Qoder);
+ assert_eq!(args.agent.script_hook_subdir(), None);
+
+ let mcp = Cli::try_parse_from(["ai-memory", "install-mcp", "--client", "qoder"]).unwrap();
+ let Command::InstallMcp(args) = mcp.command else {
+ panic!("expected install-mcp");
+ };
+ assert_eq!(args.client, McpClient::Qoder);
+ }
+
#[test]
fn ibm_bob_install_hooks_and_mcp_parse_with_both_aliases() {
for alias in ["ibm-bob", "bob"] {
diff --git a/crates/ai-memory-cli/src/commands/backup_agents.rs b/crates/ai-memory-cli/src/commands/backup_agents.rs
index 49ae0fd6..978c88f0 100644
--- a/crates/ai-memory-cli/src/commands/backup_agents.rs
+++ b/crates/ai-memory-cli/src/commands/backup_agents.rs
@@ -505,6 +505,43 @@ pub fn discover_assets(
}
}
+ // 4c. Qoder CLI and IDE
+ if filter_agent(AgentKind::Qoder) {
+ if want_global {
+ push_if_file(
+ &mut assets,
+ AgentKind::Qoder,
+ AgentAssetKind::McpConfig,
+ AgentAssetScope::Global,
+ home.join(".qoder").join("settings.json"),
+ ".qoder/settings.json",
+ "qoder/settings.json",
+ );
+ if !filter_agent(AgentKind::Codex) && !filter_agent(AgentKind::QwenCode) {
+ collect_dir_assets(
+ &mut assets,
+ AgentKind::Qoder,
+ AgentAssetKind::Skill,
+ AgentAssetScope::Global,
+ &home.join(".agents").join("skills"),
+ ".agents/skills",
+ "qoder/skills/agents",
+ )?;
+ }
+ }
+ if want_project && !filter_agent(AgentKind::Codex) && !filter_agent(AgentKind::QwenCode) {
+ push_if_file(
+ &mut assets,
+ AgentKind::Qoder,
+ AgentAssetKind::Instruction,
+ AgentAssetScope::Project,
+ cwd.join("AGENTS.md"),
+ "AGENTS.md",
+ "project/qoder/AGENTS.md",
+ );
+ }
+ }
+
// 4. Cursor
if filter_agent(AgentKind::Cursor) {
if want_global {
diff --git a/crates/ai-memory-cli/src/commands/hook.rs b/crates/ai-memory-cli/src/commands/hook.rs
index 1cb07201..06418b64 100644
--- a/crates/ai-memory-cli/src/commands/hook.rs
+++ b/crates/ai-memory-cli/src/commands/hook.rs
@@ -367,6 +367,11 @@ fn resolve_hook_cwd_with(
extract_cwd(raw)
.or_else(|| env_lookup(QWEN_PROJECT_DIR_ENV))
.filter(|s| !s.trim().is_empty())
+ } else if agent_kind == AgentKind::Qoder {
+ let mut env_lookup = env_lookup;
+ extract_cwd(raw)
+ .or_else(|| env_lookup(QODER_PROJECT_DIR_ENV))
+ .filter(|s| !s.trim().is_empty())
} else {
extract_cwd(raw).filter(|s| !s.trim().is_empty())
}
@@ -378,6 +383,9 @@ const CODEBUDDY_PROJECT_DIR_ENV: &str = "CODEBUDDY_PROJECT_DIR";
/// The project directory Qwen Code exports to every command hook process.
const QWEN_PROJECT_DIR_ENV: &str = "QWEN_PROJECT_DIR";
+/// The project directory Qoder exports to hook subprocesses.
+const QODER_PROJECT_DIR_ENV: &str = "QODER_PROJECT_DIR";
+
fn cwd_query_suffix(
agent: &str,
raw: &serde_json::Value,
@@ -825,7 +833,11 @@ fn write_success_response<W: std::io::Write>(
Ok(())
} else if matches!(
agent,
- AgentKind::Muse | AgentKind::CodeBuddy | AgentKind::IbmBob | AgentKind::QwenCode
+ AgentKind::Muse
+ | AgentKind::CodeBuddy
+ | AgentKind::IbmBob
+ | AgentKind::QwenCode
+ | AgentKind::Qoder
) && matches!(event, HookEvent::SessionStart | HookEvent::UserPrompt)
{
// Muse and IBM Bob add SessionStart and UserPromptSubmit stdout to the
@@ -2957,6 +2969,9 @@ mod tests {
HookEvent::PostToolUse,
b"{}\n".as_slice(),
),
+ (AgentKind::Qoder, HookEvent::SessionStart, b"".as_slice()),
+ (AgentKind::Qoder, HookEvent::UserPrompt, b"".as_slice()),
+ (AgentKind::Qoder, HookEvent::PostToolUse, b"{}\n".as_slice()),
] {
let mut output = Vec::new();
write_success_response(&mut output, agent, event).unwrap();
@@ -3659,6 +3674,29 @@ mod tests {
);
}
+ #[test]
+ fn qoder_missing_cwd_uses_qoder_project_dir_only() {
+ let bare = serde_json::json!({"hook_event_name": "SessionStart", "source": "startup"});
+ let project_dir =
+ |name: &str| (name == "QODER_PROJECT_DIR").then(|| "env-project".to_owned());
+ let process = || Some(PathBuf::from("process-project"));
+
+ assert_eq!(
+ resolve_hook_cwd_with("qoder", &bare, project_dir, process).as_deref(),
+ Some("env-project")
+ );
+ assert_eq!(
+ resolve_hook_cwd_with("qoder", &bare, |_| None, process),
+ None
+ );
+ let with_cwd =
+ serde_json::json!({"hook_event_name": "SessionStart", "cwd": "payload-project"});
+ assert_eq!(
+ resolve_hook_cwd_with("qoder", &with_cwd, project_dir, process).as_deref(),
+ Some("payload-project")
+ );
+ }
+
#[test]
fn devin_missing_cwd_uses_devin_project_dir_before_process_cwd() {
let raw = serde_json::json!({
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rs
index 503ebb6a..5d98f16d 100644
--- a/crates/ai-memory-cli/src/commands/install_hooks.rs
+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs
@@ -468,6 +468,14 @@ pub(crate) fn qwen_code_settings_path() -> anyhow::Result<std::path::PathBuf> {
.join("settings.json"))
}
+/// `~/.qoder/settings.json` shared by Qoder CLI and IDE.
+pub(crate) fn qoder_settings_path() -> anyhow::Result<std::path::PathBuf> {
+ Ok(home_dir()
+ .context("could not locate $HOME for ~/.qoder/settings.json")?
+ .join(".qoder")
+ .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
@@ -1044,6 +1052,13 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(
};
apply_to_qwen_code_settings(&path, &server_url, auth, &config.data_dir, &args)
}
+ AgentChoice::Qoder => {
+ let path = match &args.config_file {
+ Some(path) => path.clone(),
+ None => qoder_settings_path()?,
+ };
+ apply_to_qoder_settings(&path, &server_url, auth, &config.data_dir, &args)
+ }
};
}
let strategy = args.project_strategy.and_then(ProjectStrategyArg::baked);
@@ -1221,6 +1236,7 @@ pub(crate) fn run_with_opencode_dialect_and_mcp_path(
&preview_capture_mode,
),
AgentChoice::QwenCode => render_qwen_code(&server_url, auth, &config.data_dir, strategy),
+ AgentChoice::Qoder => render_qoder(&server_url, auth, &config.data_dir, strategy),
}
}
@@ -1437,6 +1453,7 @@ fn existing_agent_config(args: &InstallHooksArgs) -> Option<String> {
// shared settings document from which to recover a strategy.
AgentChoice::Cline => return None,
AgentChoice::QwenCode => qwen_code_settings_path().ok()?,
+ AgentChoice::Qoder => qoder_settings_path().ok()?,
}
};
std::fs::read_to_string(path).ok()
@@ -1788,6 +1805,7 @@ fn infer_installed_mcp_config(
"url",
)),
McpClient::Muse => Ok(infer_muse_mcp_config(&content)),
+ McpClient::Qoder => Ok(infer_muse_mcp_config(&content)),
// MCP-only client: no AgentChoice counterpart routes here. Prime
// Agent 0.10 has no lifecycle hooks, and its entry names the token
// variable rather than carrying a bearer, so only the URL is there.
@@ -1879,6 +1897,7 @@ pub(crate) fn mcp_client_for_agent(agent: AgentChoice) -> Option<McpClient> {
AgentChoice::Dsh => None,
AgentChoice::Cline => Some(McpClient::Cline),
AgentChoice::QwenCode => Some(McpClient::QwenCode),
+ AgentChoice::Qoder => Some(McpClient::Qoder),
}
}
@@ -7449,6 +7468,85 @@ fn render_codebuddy(
Ok(())
}
+fn apply_to_qoder_settings(
+ path: &Path,
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: &Path,
+ args: &InstallHooksArgs,
+) -> Result<()> {
+ let payload = super::render_shared::build_qoder_hooks_payload(
+ server_url,
+ auth_token,
+ Some(data_dir),
+ args.project_strategy.and_then(ProjectStrategyArg::baked),
+ );
+ let our_hooks = payload
+ .get("hooks")
+ .and_then(serde_json::Value::as_object)
+ .context("internal: build_qoder_hooks_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 Qoder 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!("{QODER_INSTALL_NOTES}");
+ Ok(())
+}
+
+const QODER_INSTALL_NOTES: &str = "\
+# NOTE: Qoder injects SessionStart `hookSpecificOutput.additionalContext`, so
+# the prior session's handoff is delivered automatically.
+# NOTE: restart Qoder after changing hooks; hook configuration is not hot-reloaded.
+";
+
+fn render_qoder(
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: &Path,
+ project_strategy: Option<&str>,
+) -> Result<()> {
+ let payload = super::render_shared::build_qoder_hooks_payload(
+ server_url,
+ auth_token,
+ Some(data_dir),
+ project_strategy,
+ );
+ let serialized =
+ serde_json::to_string_pretty(&payload["hooks"]).context("serializing Qoder hook config")?;
+ println!("# Qoder hook config — merge under the `hooks` key of");
+ println!("# ~/.qoder/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. `--apply` stores it under the data dir instead."
+ );
+ }
+ print!("{QODER_INSTALL_NOTES}");
+ println!();
+ println!("{serialized}");
+ 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(
@@ -9134,6 +9232,63 @@ mod tests {
assert_eq!(pre[0]["hooks"][0]["command"], "/usr/local/bin/guard.sh");
}
+ #[test]
+ fn qoder_apply_merges_native_hooks_and_preserves_shared_settings() {
+ let home = TempDir::new().unwrap();
+ let data = TempDir::new().unwrap();
+ let settings = home.path().join("settings.json");
+ fs::write(
+ &settings,
+ serde_json::json!({
+ "model": "qwen3-coder-plus",
+ "mcpServers": {"other": {"command": "other-server"}},
+ "hooks": {
+ "PreToolUse": [{
+ "matcher": "Write",
+ "hooks": [{"type": "command", "command": "/usr/local/bin/guard.sh"}]
+ }]
+ }
+ })
+ .to_string(),
+ )
+ .unwrap();
+ let args = InstallHooksArgs {
+ agent: AgentChoice::Qoder,
+ config_file: Some(settings.clone()),
+ ..default_hook_args()
+ };
+
+ apply_to_qoder_settings(&settings, "http://memory:49374", None, data.path(), &args)
+ .unwrap();
+ let first = fs::read_to_string(&settings).unwrap();
+ apply_to_qoder_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["model"], "qwen3-coder-plus");
+ assert_eq!(root["mcpServers"]["other"]["command"], "other-server");
+ for (event, script) in super::super::render_shared::QODER_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}: exactly one ai-memory entry");
+ assert_eq!(ours[0]["matcher"], "", "{event}");
+ let command = ours[0]["hooks"][0]["command"].as_str().unwrap();
+ let stem = script.trim_end_matches(".sh");
+ assert!(
+ command.contains(&format!(" hook --event {stem} --agent qoder --server-url ")),
+ "{event}: {command}"
+ );
+ assert!(!command.contains(".sh"), "{event}: {command}");
+ }
+ 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");
+ }
+
/// 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.
diff --git a/crates/ai-memory-cli/src/commands/install_mcp.rs b/crates/ai-memory-cli/src/commands/install_mcp.rs
index 75fa5828..d5f811ed 100644
--- a/crates/ai-memory-cli/src/commands/install_mcp.rs
+++ b/crates/ai-memory-cli/src/commands/install_mcp.rs
@@ -141,8 +141,9 @@ pub(crate) fn run_with_opencode_dialect(
// that dir, and a bridge without it would read the default one, with its
// own config and bearer. Not from inside the Docker helper, whose data dir
// is a container path the host-side bridge cannot open.
- let runs_bridge =
- (args.client == McpClient::ClaudeCode && args.session_aware) || args.stdio_bridge;
+ let runs_bridge = (args.client == McpClient::ClaudeCode && args.session_aware)
+ || args.stdio_bridge
+ || args.client == McpClient::Qoder;
if config.runtime_env.host_cwd().is_none()
&& (matches!(
args.client,
@@ -163,7 +164,7 @@ pub(crate) fn run_with_opencode_dialect(
// different key already stored belongs to the hooks, the store failed, or
// this is the Docker helper, whose data dir the host-side bridge cannot
// open.
- let bridge_carries_token = matches!(args.client, McpClient::Muse)
+ let bridge_carries_token = matches!(args.client, McpClient::Muse | McpClient::Qoder)
|| (args.client == McpClient::ClaudeCode && args.session_aware);
let may_store_bridge_key = args.apply
&& token_given
@@ -207,6 +208,7 @@ pub(crate) fn run_with_opencode_dialect(
McpClient::ClaudeDesktop => render_claude_desktop(&args)?,
McpClient::GeminiCli => render_gemini_cli(&args)?,
McpClient::QwenCode => render_qwen_code(&args)?,
+ McpClient::Qoder => render_json_mcp_fragment(&args)?,
McpClient::Openclaw => render_openclaw(&args)?,
McpClient::Pi => render_pi(&args)?,
McpClient::Omp => render_omp(&args)?,
@@ -518,6 +520,13 @@ fn stdio_bridge_entry(args: &InstallMcpArgs) -> Option<serde_json::Value> {
| McpClient::Openclaw
| McpClient::IbmBob
| McpClient::Cline => plain(),
+ McpClient::Qoder => {
+ let env = args
+ .auth_token
+ .as_ref()
+ .map_or_else(|| json!({}), |token| json!({"AI_MEMORY_AUTH_TOKEN": token}));
+ json!({"command": command, "args": bridge, "env": env})
+ }
McpClient::GeminiCli | McpClient::AntigravityCli | McpClient::QwenCode => json!({
"command": command,
"args": bridge,
@@ -771,6 +780,7 @@ pub(crate) fn mcp_config_path_with(
}
McpClient::GeminiCli => home()?.join(".gemini").join("settings.json"),
McpClient::QwenCode => home()?.join(".qwen").join("settings.json"),
+ McpClient::Qoder => home()?.join(".qoder").join("settings.json"),
McpClient::Openclaw => home()?.join(".openclaw").join("config.json"),
McpClient::Pi => bail!(
"Pi has no native mcp.json; use `ai-memory install-hooks --agent pi --apply` to install the generated MCP bridge extension."
@@ -1265,6 +1275,7 @@ fn json_mcp_location(client: McpClient) -> Option<JsonMcpLocation> {
| McpClient::Cursor
| McpClient::GeminiCli
| McpClient::QwenCode
+ | McpClient::Qoder
| McpClient::Omp
| McpClient::AntigravityCli
| McpClient::Devin
@@ -1302,7 +1313,7 @@ fn build_json_mcp_entry(args: &InstallMcpArgs) -> Result<serde_json::Value> {
// `serve` process would contend for the data-dir lock. Keep this at the
// typed builder boundary so auth-enable and other internal callers cannot
// accidentally request an unsupported direct entry.
- if (args.stdio_bridge || args.client == McpClient::Freebuff)
+ if (args.stdio_bridge || matches!(args.client, McpClient::Freebuff | McpClient::Qoder))
&& let Some(entry) = stdio_bridge_entry(args)
{
return Ok(entry);
@@ -4517,6 +4528,7 @@ mod tests {
McpClient::ClaudeDesktop => render_claude_desktop(&args).unwrap(),
McpClient::GeminiCli => render_gemini_cli(&args).unwrap(),
McpClient::QwenCode => render_qwen_code(&args).unwrap(),
+ McpClient::Qoder => render_json_mcp_fragment(&args).unwrap(),
McpClient::Openclaw => render_openclaw(&args).unwrap(),
McpClient::Pi => render_pi(&args).unwrap(),
McpClient::Omp => render_omp(&args).unwrap(),
@@ -4560,6 +4572,7 @@ mod tests {
McpClient::ClaudeDesktop,
McpClient::GeminiCli,
McpClient::QwenCode,
+ McpClient::Qoder,
McpClient::Openclaw,
McpClient::Omp,
McpClient::AntigravityCli,
@@ -4586,8 +4599,10 @@ mod tests {
// server entry, etc.), but the literal `Bearer
// <token>` substring shows up in all of them. Keep
// the assertion uniform.
+ let carries_token = out.contains("Bearer test-token-deadbeef")
+ || (client == McpClient::Qoder && out.contains("test-token-deadbeef"));
assert!(
- out.contains("Bearer test-token-deadbeef"),
+ carries_token,
"client {client:?} did not embed the bearer token:\n{out}"
);
}
@@ -4607,6 +4622,7 @@ mod tests {
McpClient::ClaudeDesktop,
McpClient::GeminiCli,
McpClient::QwenCode,
+ McpClient::Qoder,
McpClient::Openclaw,
McpClient::Omp,
McpClient::AntigravityCli,
@@ -4637,6 +4653,23 @@ mod tests {
}
}
+ #[test]
+ fn qoder_always_uses_the_sessionless_bridge_in_its_native_stdio_shape() {
+ let mut args = args_for(McpClient::Qoder);
+ args.auth_token = Some("qoder-token".into());
+ let entry = build_json_mcp_entry(&args).unwrap();
+ assert!(
+ entry["command"]
+ .as_str()
+ .is_some_and(|command| command.contains("ai-memory"))
+ );
+ let bridge_args = entry["args"].as_array().unwrap();
+ assert!(bridge_args.iter().any(|arg| arg == "mcp-bridge"));
+ assert!(bridge_args.iter().any(|arg| arg == "--no-session-id"));
+ assert_eq!(entry["env"]["AI_MEMORY_AUTH_TOKEN"], "qoder-token");
+ assert!(entry.get("url").is_none());
+ }
+
fn render_for_test(client: McpClient) -> String {
let args = args_for(client);
match args.client {
@@ -4651,6 +4684,7 @@ mod tests {
McpClient::ClaudeDesktop => render_claude_desktop(&args).unwrap(),
McpClient::GeminiCli => render_gemini_cli(&args).unwrap(),
McpClient::QwenCode => render_qwen_code(&args).unwrap(),
+ McpClient::Qoder => render_json_mcp_fragment(&args).unwrap(),
McpClient::Openclaw => render_openclaw(&args).unwrap(),
McpClient::Pi => render_pi(&args).unwrap(),
McpClient::Omp => render_omp(&args).unwrap(),
diff --git a/crates/ai-memory-cli/src/commands/render_shared.rs b/crates/ai-memory-cli/src/commands/render_shared.rs
index 4c3bbc2f..0e7501b0 100644
--- a/crates/ai-memory-cli/src/commands/render_shared.rs
+++ b/crates/ai-memory-cli/src/commands/render_shared.rs
@@ -170,6 +170,19 @@ pub(crate) const CODEBUDDY_EVENTS: [(&str, &str); 7] = [
("SessionEnd", "session-end.sh"),
];
+/// Qoder CLI/IDE events used for capture and handoff delivery. Qoder exposes
+/// additional policy and notification events that do not carry memory data.
+pub(crate) const QODER_EVENTS: [(&str, &str); 8] = [
+ ("SessionStart", "session-start.sh"),
+ ("UserPromptSubmit", "user-prompt-submit.sh"),
+ ("PreToolUse", "pre-tool-use.sh"),
+ ("PostToolUse", "post-tool-use.sh"),
+ ("PostToolUseFailure", "post-tool-use.sh"),
+ ("PreCompact", "pre-compact.sh"),
+ ("Stop", "stop.sh"),
+ ("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
@@ -1342,6 +1355,28 @@ pub(crate) fn build_codebuddy_hooks_payload(
)
}
+/// `{"hooks": <event map>}` for Qoder's `~/.qoder/settings.json`.
+pub(crate) fn build_qoder_hooks_payload(
+ server_url: &str,
+ auth_token: Option<&str>,
+ data_dir: Option<&Path>,
+ project_strategy: Option<&str>,
+) -> Value {
+ build_hook_payload_for_platform(
+ &QODER_EVENTS,
+ Path::new(""),
+ server_url,
+ auth_token,
+ HookShape::Nested,
+ HookCommandContext::new(
+ HookCommandPlatform::native(),
+ "qoder",
+ data_dir,
+ project_strategy,
+ ),
+ )
+}
+
/// `{"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;
diff --git a/crates/ai-memory-cli/src/commands/restore_agents.rs b/crates/ai-memory-cli/src/commands/restore_agents.rs
index d4676684..5578fcc3 100644
--- a/crates/ai-memory-cli/src/commands/restore_agents.rs
+++ b/crates/ai-memory-cli/src/commands/restore_agents.rs
@@ -617,6 +617,7 @@ fn validate_target_relative(scope: AgentAssetScope, rel_path: &str) -> Result<()
".commandcode/",
".kimi/",
".qwen/",
+ ".qoder/",
];
let allowed = rel_path == ".claude.json"
|| PREFIXES.iter().any(|prefix| rel_path.starts_with(prefix));
diff --git a/crates/ai-memory-cli/src/commands/setup.rs b/crates/ai-memory-cli/src/commands/setup.rs
index 511fd716..ccd3bd83 100644
--- a/crates/ai-memory-cli/src/commands/setup.rs
+++ b/crates/ai-memory-cli/src/commands/setup.rs
@@ -242,6 +242,9 @@ pub async fn run(config: &Config, args: SetupArgs, config_path: Option<&Path>) -
if let Some(dir) = qwen_code_detected(&home) {
found.push((AgentChoice::QwenCode, Found::ConfigDir(dir)));
}
+ if let Some(dir) = qoder_detected(&home) {
+ found.push((AgentChoice::Qoder, Found::ConfigDir(dir)));
+ }
found
.into_iter()
.map(|(agent, found)| (agent, Some(found)))
@@ -434,6 +437,11 @@ fn qwen_code_detected(home: &Path) -> Option<PathBuf> {
Some(home.join(".qwen")).filter(|dir| dir.is_dir())
}
+/// Qoder's shared CLI/IDE configuration directory, `~/.qoder`, when present.
+fn qoder_detected(home: &Path) -> Option<PathBuf> {
+ Some(home.join(".qoder")).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
@@ -1184,6 +1192,22 @@ mod tests {
);
}
+ #[test]
+ fn qoder_is_detected_and_wires_hooks_mcp_and_shared_skills() {
+ let home = tempfile::tempdir().unwrap();
+ assert_eq!(qoder_detected(home.path()), None);
+ std::fs::create_dir_all(home.path().join(".qoder")).unwrap();
+ assert_eq!(
+ qoder_detected(home.path()),
+ Some(home.path().join(".qoder"))
+ );
+ assert_eq!(skills_for(AgentChoice::Qoder), InstallSkillsAgent::Agents);
+ assert_eq!(
+ AgentPlan::new(AgentChoice::Qoder, None).mcp,
+ Some(McpClient::Qoder)
+ );
+ }
+
#[test]
fn ibm_bob_is_detected_and_wires_hooks_mcp_and_shared_skills() {
let home = tempfile::tempdir().unwrap();
diff --git a/crates/ai-memory-cli/src/commands/setup_agent.rs b/crates/ai-memory-cli/src/commands/setup_agent.rs
index 562cdc29..e5343ff5 100644
--- a/crates/ai-memory-cli/src/commands/setup_agent.rs
+++ b/crates/ai-memory-cli/src/commands/setup_agent.rs
@@ -248,7 +248,8 @@ pub fn run(config: &Config, mut args: SetupAgentArgs) -> Result<()> {
| AgentChoice::CodeBuddy
| AgentChoice::IbmBob
| AgentChoice::Cline
- | AgentChoice::QwenCode => {
+ | AgentChoice::QwenCode
+ | AgentChoice::Qoder => {
bail!(
"internal: generated integration should have returned before emitting staged hooks"
)
diff --git a/crates/ai-memory-cli/src/commands/uninstall.rs b/crates/ai-memory-cli/src/commands/uninstall.rs
index 3d0944d8..c0ee453c 100644
--- a/crates/ai-memory-cli/src/commands/uninstall.rs
+++ b/crates/ai-memory-cli/src/commands/uninstall.rs
@@ -286,6 +286,10 @@ fn build_plan(
install_hooks::qwen_code_settings_path()?,
HookConfigShape::NestedHooksKey,
),
+ (
+ install_hooks::qoder_settings_path()?,
+ HookConfigShape::NestedHooksKey,
+ ),
]);
for (path, shape) in hook_files {
if !path.exists() {
@@ -466,6 +470,7 @@ fn build_plan(
CommandCode,
IbmBob,
QwenCode,
+ Qoder,
CopilotCli,
Droid,
Swival,
@@ -1583,6 +1588,7 @@ fn mcp_servers_path(client: McpClient) -> Option<&'static [&'static str]> {
| McpClient::Cursor
| McpClient::GeminiCli
| McpClient::QwenCode
+ | McpClient::Qoder
| McpClient::Omp
| McpClient::AntigravityCli
| McpClient::KimiCode
diff --git a/crates/ai-memory-cli/tests/suite/backup_agents.rs b/crates/ai-memory-cli/tests/suite/backup_agents.rs
index 06239bc7..2720a57c 100644
--- a/crates/ai-memory-cli/tests/suite/backup_agents.rs
+++ b/crates/ai-memory-cli/tests/suite/backup_agents.rs
@@ -453,6 +453,78 @@ fn qwen_backup_round_trips_every_documented_asset() {
}
}
+#[test]
+fn qoder_backup_round_trips_shared_assets() {
+ let _guard = cli_test_lock();
+ let home = tempfile::tempdir().unwrap();
+ let project = tempfile::tempdir().unwrap();
+ let fixtures = [
+ (
+ home.path().join(".qoder/settings.json"),
+ r#"{"mcpServers":{"ai-memory":{"command":"ai-memory"}}}"#,
+ ),
+ (
+ home.path().join(".agents/skills/shared/SKILL.md"),
+ "# Shared skill",
+ ),
+ (project.path().join("AGENTS.md"), "# Shared instructions"),
+ ];
+ for (path, body) in &fixtures {
+ fs::create_dir_all(path.parent().unwrap()).unwrap();
+ fs::write(path, body).unwrap();
+ }
+
+ let archive = project.path().join("qoder.tar.gz");
+ let backup = command_with_env(home.path(), project.path())
+ .args([
+ "backup-agents",
+ "-o",
+ archive.to_str().unwrap(),
+ "--agents",
+ "qoder",
+ "--include-secrets",
+ ])
+ .output()
+ .unwrap();
+ assert!(
+ backup.status.success(),
+ "backup failed: {}",
+ String::from_utf8_lossy(&backup.stderr)
+ );
+
+ let restored_home = tempfile::tempdir().unwrap();
+ let restored_project = tempfile::tempdir().unwrap();
+ let restore = command_with_env(restored_home.path(), restored_project.path())
+ .args([
+ "restore-agents",
+ "-i",
+ archive.to_str().unwrap(),
+ "--agents",
+ "qoder",
+ "--apply",
+ ])
+ .output()
+ .unwrap();
+ assert!(
+ restore.status.success(),
+ "restore failed: {}",
+ String::from_utf8_lossy(&restore.stderr)
+ );
+ for (path, body) in [
+ (
+ restored_home.path().join(".qoder/settings.json"),
+ fixtures[0].1,
+ ),
+ (
+ restored_home.path().join(".agents/skills/shared/SKILL.md"),
+ fixtures[1].1,
+ ),
+ (restored_project.path().join("AGENTS.md"), fixtures[2].1),
+ ] {
+ assert_eq!(fs::read_to_string(path).unwrap(), body);
+ }
+}
+
#[test]
fn backup_agents_sanitizes_secrets_by_default() {
let _guard = cli_test_lock();
diff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rs
index 0b980167..c2cf52cb 100644
--- a/crates/ai-memory-core/src/ids.rs
+++ b/crates/ai-memory-core/src/ids.rs
@@ -314,6 +314,9 @@ pub enum AgentKind {
/// `~/.qwen/settings.json`.
#[serde(rename = "qwen-code", alias = "qwen")]
QwenCode,
+ /// Qoder CLI and IDE. Lifecycle hooks use Claude Code-shaped payloads
+ /// and inject `SessionStart` additional context.
+ Qoder,
/// Anything else (manual capture, future agents).
Other,
}
@@ -324,7 +327,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; 30] = [
+ pub const ALL: [Self; 31] = [
Self::ClaudeCode,
Self::Codex,
Self::OpenCode,
@@ -354,6 +357,7 @@ impl AgentKind {
Self::Dsh,
Self::Cline,
Self::QwenCode,
+ Self::Qoder,
Self::Other,
];
@@ -390,6 +394,7 @@ impl AgentKind {
Self::Dsh => "dsh",
Self::Cline => "cline",
Self::QwenCode => "qwen-code",
+ Self::Qoder => "qoder",
Self::Other => "other",
}
}
@@ -429,6 +434,7 @@ impl AgentKind {
"dsh" | "deepseek-harness" | "deepseek_harness" => Self::Dsh,
"cline" | "cline-cli" => Self::Cline,
"qwen-code" | "qwen" | "qwencode" => Self::QwenCode,
+ "qoder" => Self::Qoder,
_ => Self::Other,
}
}
@@ -557,7 +563,10 @@ impl AgentKind {
/// than this envelope, so neither is listed.
#[must_use]
pub fn user_prompt_injects_context(self) -> bool {
- matches!(self, Self::ClaudeCode | Self::Codex | Self::QwenCode)
+ matches!(
+ self,
+ Self::ClaudeCode | Self::Codex | Self::QwenCode | Self::Qoder
+ )
}
/// Whether `PostToolUse` stdout is model-visible context.
@@ -924,6 +933,26 @@ mod tests {
assert!(!AgentKind::QwenCode.reuses_session_id_after_end());
}
+ #[test]
+ fn agent_kind_qoder_round_trips_and_injects_supported_context() {
+ assert_eq!(AgentKind::Qoder.as_str(), "qoder");
+ assert_eq!(AgentKind::from_wire("qoder"), AgentKind::Qoder);
+ assert_eq!(
+ serde_json::to_string(&AgentKind::Qoder).unwrap(),
+ "\"qoder\""
+ );
+ assert_eq!(
+ serde_json::from_str::<AgentKind>("\"qoder\"").unwrap(),
+ AgentKind::Qoder
+ );
+ assert_eq!(AgentKind::from_wire("qoder-cli-2"), AgentKind::Other);
+ assert!(AgentKind::Qoder.session_start_injects_handoff());
+ assert!(!AgentKind::Qoder.user_prompt_injects_handoff());
+ assert!(AgentKind::Qoder.user_prompt_injects_context());
+ assert!(!AgentKind::Qoder.post_tool_injects_handoff());
+ assert!(!AgentKind::Qoder.reuses_session_id_after_end());
+ }
+
#[test]
fn agent_kind_grizzybot_round_trips() {
assert_eq!(AgentKind::Grizzybot.as_str(), "grizzybot");
@@ -1027,13 +1056,16 @@ mod tests {
}
#[test]
- fn user_prompt_context_injection_is_claude_code_codex_and_qwen_code() {
+ fn user_prompt_context_injection_matches_supported_hook_protocols() {
for agent in AgentKind::ALL {
assert_eq!(
agent.user_prompt_injects_context(),
matches!(
agent,
- AgentKind::ClaudeCode | AgentKind::Codex | AgentKind::QwenCode
+ AgentKind::ClaudeCode
+ | AgentKind::Codex
+ | AgentKind::QwenCode
+ | AgentKind::Qoder
),
"{}",
agent.as_str()
diff --git a/crates/ai-memory-hooks/src/capture_policy.rs b/crates/ai-memory-hooks/src/capture_policy.rs
index 52acf9d8..af964265 100644
--- a/crates/ai-memory-hooks/src/capture_policy.rs
+++ b/crates/ai-memory-hooks/src/capture_policy.rs
@@ -247,7 +247,8 @@ pub(crate) fn tool_payload_fields(agent: AgentKind, raw: &Value) -> Option<(&str
| AgentKind::CodeBuddy
| AgentKind::IbmBob
| AgentKind::Dsh
- | AgentKind::QwenCode => (
+ | AgentKind::QwenCode
+ | AgentKind::Qoder => (
object.get("tool_name")?.as_str()?,
object.get("tool_use_id").and_then(Value::as_str),
),
@@ -338,6 +339,7 @@ pub(crate) fn tool_observation_metadata(
| AgentKind::IbmBob
| AgentKind::Dsh
| AgentKind::QwenCode
+ | AgentKind::Qoder
) {
"tool_input"
} else {
@@ -402,7 +404,7 @@ pub(crate) fn tool_observation_outcome(agent: AgentKind, raw: &Value) -> ToolOut
// Meta Muse Code's `PostToolUseFailure` has the same `error` string
// (captured offline on Muse Code 1.4.7); its `PostToolUse` proves no
// outcome.
- AgentKind::Zcode | AgentKind::Muse | AgentKind::QwenCode
+ AgentKind::Zcode | AgentKind::Muse | AgentKind::QwenCode | AgentKind::Qoder
if raw
.get("error")
.and_then(Value::as_str)
@@ -1187,6 +1189,7 @@ fn extract(agent: AgentKind, raw: &Value) -> Extracted<'_> {
| AgentKind::Cursor
| AgentKind::GeminiCli
| AgentKind::QwenCode
+ | AgentKind::Qoder
| AgentKind::Devin
| AgentKind::Hermes
| AgentKind::KiroCli
@@ -4709,6 +4712,7 @@ mod tests {
AgentKind::Muse,
AgentKind::CodeBuddy,
AgentKind::QwenCode,
+ AgentKind::Qoder,
AgentKind::OpenCode,
AgentKind::Omp,
AgentKind::Pi,
diff --git a/crates/ai-memory-hooks/src/payload.rs b/crates/ai-memory-hooks/src/payload.rs
index e0438ce8..2467bd56 100644
--- a/crates/ai-memory-hooks/src/payload.rs
+++ b/crates/ai-memory-hooks/src/payload.rs
@@ -875,6 +875,7 @@ const fn closed_tool_agent(agent: AgentKind) -> bool {
| AgentKind::Dsh
| AgentKind::Cline
| AgentKind::QwenCode
+ | AgentKind::Qoder
)
}
@@ -2279,6 +2280,7 @@ mod tests {
assert_eq!(parse_agent("qwen-code"), AgentKind::QwenCode);
assert_eq!(parse_agent("qwen"), AgentKind::QwenCode);
assert_eq!(parse_agent("qwencode"), AgentKind::QwenCode);
+ assert_eq!(parse_agent("qoder"), AgentKind::Qoder);
// Anything else is `Other`. Critical for the hook router:
// a typo in the query string must not crash, it just gets
// attributed to the catch-all bucket.
diff --git a/crates/ai-memory-store/migrations/V89__sessions_qoder_agent_kind.sql b/crates/ai-memory-store/migrations/V89__sessions_qoder_agent_kind.sql
new file mode 100644
index 00000000..0ff2fa4f
--- /dev/null
+++ b/crates/ai-memory-store/migrations/V89__sessions_qoder_agent_kind.sql
@@ -0,0 +1,71 @@
+-- Expand sessions.agent_kind CHECK for Qoder while preserving V88's schema,
+-- indexes, and scope-pairing triggers.
+--
+-- `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','cline','qwen-code','qoder','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/migrations.rs b/crates/ai-memory-store/src/migrations.rs
index fb0da788..0230f65d 100644
--- a/crates/ai-memory-store/src/migrations.rs
+++ b/crates/ai-memory-store/src/migrations.rs
@@ -1707,6 +1707,97 @@ mod tests {
}
}
+ /// V89 expands the persisted session kind without losing the session
+ /// graph rebuilt by V88.
+ #[test]
+ fn v88_to_v89_preserves_sessions_and_accepts_qoder() {
+ let mut conn = Connection::open_in_memory().unwrap();
+ run_to(&mut conn, 88).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, 'qwen-code', '/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, 'qoder', 1)",
+ params![
+ SessionId::new().as_bytes(),
+ workspace_id.as_bytes(),
+ project_id.as_bytes(),
+ ],
+ )
+ .is_err(),
+ "the V88 CHECK must reject qoder"
+ );
+
+ 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,
+ (
+ "qwen-code".into(),
+ "/repo".into(),
+ Some("user:alice".into())
+ )
+ );
+ crate::ops::begin_session(
+ &mut conn,
+ &NewSession {
+ occurred_at: None,
+ id: SessionId::new(),
+ workspace_id,
+ project_id,
+ agent_kind: AgentKind::Qoder,
+ 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/design-backup-agent-assets.md b/docs/design-backup-agent-assets.md
index 4a2b4d4d..b01d1097 100644
--- a/docs/design-backup-agent-assets.md
+++ b/docs/design-backup-agent-assets.md
@@ -25,6 +25,7 @@ Before these commands were added:
| **OpenAI Codex CLI** | `~/.codex/config.toml`<br>`~/.codex/mcp.json` | `~/.agents/skills/`<br>`.agents/skills/`<br>`~/.codex/skills/` | `~/.codex/plugins/` | `AGENTS.md` |
| **Antigravity CLI (`agy`) / Gemini** | `~/.gemini/settings.json`<br>`~/.gemini/config/mcp_config.json`<br>`antigravity-cli/mcp_config.json` | Antigravity: `~/.gemini/config/skills/`, `~/.gemini/antigravity-cli/skills/`, `.agents/skills/`<br>Gemini: `~/.gemini/skills/`, `.gemini/skills/` | `antigravity-cli/plugins/`<br>`~/.gemini/plugins/` | `GEMINI.md`<br>`AGENTS.md`<br>`rules/` |
| **Qwen Code** | `~/.qwen/settings.json` | `~/.qwen/skills/`<br>`~/.agents/skills/` | — | `QWEN.md`<br>`AGENTS.md` |
+| **Qoder** | `~/.qoder/settings.json` | `~/.agents/skills/` | — | `AGENTS.md` |
| **Cursor IDE** | `~/.cursor/mcp.json`<br>`.cursor/mcp.json` | — | VS Code / Cursor extensions | `.cursorrules`<br>`.cursor/rules/` |
| **OpenCode (v1 / v2)** | `opencode.json`<br>`opencode.jsonc`<br>`~/.config/opencode/opencode.json` | `~/.config/opencode/skills/` | `~/.config/opencode/plugins/` | `AGENTS.md` |
| **Devin CLI** | `~/.devin/config.json` | `~/.devin/skills/` | — | Devin instructions |
diff --git a/docs/install.md b/docs/install.md
index 4414aefe..2bc5cd93 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -1652,6 +1652,37 @@ does not document a stable native transcript store. Start a new Qwen session
after installing so it reloads `settings.json`. See [the Qwen Code MCP and
hook details](mcp-install.md#qwen-code).
+### Qoder
+
+Qoder CLI and IDE share `~/.qoder/settings.json`. Install MCP and lifecycle
+capture together:
+
+```bash
+ai-memory install-mcp --client qoder --apply \
+ --server-url "https://memory.example/mcp" \
+ --auth-token "$TOKEN"
+ai-memory install-hooks --agent qoder --apply \
+ --server-url "https://memory.example" \
+ --auth-token "$TOKEN"
+```
+
+The MCP entry runs `ai-memory mcp-bridge --no-session-id` using Qoder's stdio
+shape. It therefore reaches local or remote ai-memory servers without starting
+a second server, but remains a static client: project-scoped MCP calls must pass
+`workspace` and `project`. The hook installer preserves other settings,
+servers, and handlers while adding `SessionStart`, `UserPromptSubmit`,
+`PreToolUse`, `PostToolUse`, `PostToolUseFailure`, `PreCompact`, `Stop`, and
+`SessionEnd`. A pending handoff is delivered as SessionStart
+`hookSpecificOutput.additionalContext`; capture-only context hooks stay silent.
+When a payload omits `cwd`, only Qoder's documented `QODER_PROJECT_DIR` is used.
+
+`ai-memory setup` detects `~/.qoder`; `backup-agents` preserves its settings and
+shared `~/.agents/skills` / `AGENTS.md` assets when Qoder owns those shared
+paths. Restart Qoder after changing hooks. Managed `ai-memory run qoder` and
+native transcript backfill are not claimed because Qoder does not document a
+stable transcript-store contract. See [the detailed MCP and hook
+notes](mcp-install.md#qoder).
+
### Kiro CLI
Kiro CLI has one MCP surface and two incompatible lifecycle-hook formats.
diff --git a/docs/mcp-install.md b/docs/mcp-install.md
index 181b3c64..5ca251cc 100644
--- a/docs/mcp-install.md
+++ b/docs/mcp-install.md
@@ -977,6 +977,49 @@ and [Qwen Code settings](https://qwenlm.github.io/qwen-code-docs/en/users/config
---
+## Qoder
+
+**Status:** MCP and lifecycle hooks are supported. Managed workstreams and
+transcript backfill are not claimed.
+
+**Config file:** `~/.qoder/settings.json` (user), or a project
+`.qoder/settings.json` supplied with `--config-file`. MCP servers live under
+`mcpServers`; hooks live under `hooks` in the same document.
+
+```bash
+ai-memory install-mcp --client qoder --apply \
+ --server-url "https://memory.example/mcp" --auth-token "$TOKEN"
+ai-memory install-hooks --agent qoder --apply \
+ --server-url "https://memory.example" --auth-token "$TOKEN"
+```
+
+Qoder's MCP configuration accepts stdio `command`, `args`, and `env`. ai-memory
+always writes a sessionless `mcp-bridge` entry, so it can use the configured
+remote server without a second server process contending for the data-dir lock.
+The bridge has no lifecycle identity; pass explicit `workspace` and `project`
+on every project-scoped MCP call. Applied token installs use ai-memory's
+owner-only token file when possible; printed configuration carries the token in
+the entry's `AI_MEMORY_AUTH_TOKEN` environment.
+
+The hook installer registers the eight documented events that carry useful
+memory state: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`,
+`PostToolUseFailure`, `PreCompact`, `Stop`, and `SessionEnd`. Qoder sends
+Claude-shaped fields such as `session_id`, `cwd`, `tool_name`, `tool_input`, and
+`tool_use_id`, so capture exclusions are enforced by the same closed parser.
+SessionStart delivers a pending handoff through
+`hookSpecificOutput.additionalContext`; a missing payload `cwd` falls back to
+`QODER_PROJECT_DIR`. Qoder requires a restart after hook changes.
+
+Qoder reads `AGENTS.md` and shared `~/.agents/skills`, so the normal routing
+snippet and installed Agent Skills need no Qoder-specific copy. There is no
+`ai-memory run qoder` adapter or native transcript backfill because no stable
+native transcript-store contract is documented.
+
+Sources: [Qoder hooks](https://docs.qoder.com/cli/hooks) and
+[Qoder MCP](https://docs.qoder.com/cli/mcp-reference).
+
+---
+
## Antigravity CLI (`agy`)
**Status:** ✅ MCP supported. ✅ Lifecycle hooks supported via
diff --git a/docs/support-matrix.md b/docs/support-matrix.md
index 4908853b..2f1704a6 100644
--- a/docs/support-matrix.md
+++ b/docs/support-matrix.md
@@ -57,6 +57,7 @@
| Kilo Code | MCP-only (documented) | `type: "remote"` entry under `mcp` in `~/.config/kilo/kilo.jsonc` (shared by the VS Code extension and the CLI), with `"oauth": false` and the bearer header from `{env:AI_MEMORY_AUTH_TOKEN}`. No `install-mcp` client and no lifecycle hooks installed. Documented against Kilo Code 7.8.8, not yet verified end to end. See [`install.md`](install.md#kilo-code). |
| Goose | MCP-only (documented) | `type: streamable_http` extension (URL key `uri`) in `~/.config/goose/config.yaml`, added with `goose configure`; no documented env-var expansion in headers. No `install-mcp` client and no lifecycle hooks installed. Documented against Goose 1.54.0, not yet verified end to end. See [`install.md`](install.md#goose). |
| Qwen Code | Supported | MCP (`install-mcp --client qwen-code`, aliases `qwen`, `qwencode`) plus lifecycle hooks (`install-hooks --agent qwen-code`) in `~/.qwen/settings.json`. Streamable HTTP uses `httpUrl` (plain `url` is legacy SSE); a token-file install gets a stdio `mcp-bridge` entry. Ten Claude-shaped events including `PostToolUseFailure` and subagent start/stop; native `ai-memory hook` commands (no script bundle) enforce capture exclusions over Qwen's Gemini-like tools (`write_file`, `read_file`, `run_shell_command`, `grep_search`, `glob`). User prompts come only from the provenance-bearing `submitted_prompt`, not continuation/retry `prompt` content. `SessionStart` injects the prior handoff as `hookSpecificOutput.additionalContext`. Qwen fires a real `SessionEnd`, so `finalize-session` is not needed. `setup` detects `~/.qwen`. `ai-memory run qwen` and transcript backfill are not claimed because Qwen does not document a stable transcript-store contract. See [`mcp-install.md`](mcp-install.md#qwen-code). |
+| Qoder | Supported | MCP (`install-mcp --client qoder`) and eight lifecycle hooks (`install-hooks --agent qoder`) share `~/.qoder/settings.json`. MCP always uses the sessionless stdio bridge, so calls use explicit project scope. Claude-shaped prompt/tool events enforce capture exclusions; `SessionStart` injects a pending handoff as `hookSpecificOutput.additionalContext`, and missing `cwd` uses only `QODER_PROJECT_DIR`. `setup`, uninstall, and agent backup cover the integration. Qoder must be restarted after hook changes. Managed workstreams and transcript backfill are not claimed. See [`mcp-install.md`](mcp-install.md#qoder). |
| OpenHuman | MCP-only (documented) | `url` + `headers` entry added in the app's **mcp.json** tab (a view over OpenHuman's server store, not a file on disk); header values are stored write-only. No `install-mcp` client and no lifecycle hooks installed. Documented against OpenHuman 0.64.15, not yet verified end to end. See [`install.md`](install.md#openhuman). |
| LLM/auth providers | Supported | Anthropic, OpenAI, OpenAI OAuth/Codex, GitHub Copilot, Gemini, OpenCode (Go and Zen), Cursor Agent CLI (`cursor`), OpenAI-compatible endpoints, and generic OIDC device auth for native hooks. |
| Embedding providers | Supported | OpenAI, Voyage, Google Gemini, and keyless OpenAI-compatible endpoints such as Ollama, LM Studio, and vLLM. |