Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.
Rust agent-to-agentai-agentsclaude-codecodexcoding-agentscursorgrokirohmcpmcp-servermulti-agentpeer-to-peerreason
Add Command Code to Reason Network (#156)
reason-machines[bot]29a96dc22dc0
diff --git a/DESIGN.md b/DESIGN.mdindex 013995f..ca5c967 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -3,7 +3,7 @@> This is how the engine works inside. **AI agent asked to join the Reason Network?** Follow> https://reasonmachines.com/network instead.-A team directory and message bus for coding agents. Any agent (Claude Code, Codex, Cursor, Gemini CLI,+A team directory and message bus for coding agents. Any agent (Claude Code, Codex, Command Code, Cursor, Gemini CLI,opencode, Copilot CLI, Amp, …) on any teammate's machine can see who is working on what, right now, andmessage the right session directly: across the LAN or the internet, with no server to host.@@ -277,11 +277,10 @@ session connection also receives pushed `deliver` events for its sessions.2. Env: `REASON_NETWORK_SESSION` (set by our pi extension), else the agent's own: `CLAUDE_CODE_SESSION_ID` (Claude),`CODEX_THREAD_ID` (Codex), `OPENCODE_SESSION_ID` (opencode), `COPILOT_AGENT_SESSION_ID` (Copilot),`GROK_SESSION_ID` (Grok).-3. Hook stdin `session_id` (`SessionStart`), for Gemini, which gives its MCP servers no id (`GEMINI_SESSION_ID` is in its- hooks' env only): the one session the hooks of the MCP server's agent process (its parent, past a shell) registered,- asked on each call so `/clear` is followed. At start the MCP server waits up to 20 s for those hooks; registered by- process after all, it moves to their session once they come. A new conversation's `SessionStart` ends the one- before in the same process, and `SessionEnd` ends one though its MCP server is still connected.+3. Hook stdin `session_id` (`SessionStart`). Gemini keeps `GEMINI_SESSION_ID` in hook environments only, and Command Code+ provides the session id to its hooks rather than its MCP server. The MCP server follows the session registered by its+ agent process and checks that link on each call. At startup, it waits up to 20 seconds for the hooks. A later+ `SessionStart` moves the server to the new conversation. Gemini also ends a session on `SessionEnd`.4. Fallback: one session per MCP process.The key is `<agent>:<id>`, and it is what a name is kept for (above). Where each agent's id comes from:@@ -295,6 +294,7 @@ The key is `<agent>:<id>`, and it is what a name is kept for (above). Where each| Hermes | profile-scoped conversation id | profile name, hash of the plugin state directory, and captured route key (or session id); compaction keeps the registered identity || Cursor | conversation id | hooks' `conversation_id` (its shared MCP server takes the session its hooks registered) || Gemini CLI | session id | hooks' `session_id` (its MCP server takes the session its process's hooks registered) |+| Command Code | session id | hooks' `session_id` (its user-scoped MCP server takes the session its process's hooks registered) || Copilot CLI | session id | `COPILOT_AGENT_SESSION_ID`, hooks' `sessionId` || Grok CLI | session id | `GROK_SESSION_ID`, hooks' `session_id` || Reason | session id | `reason session list` |@@ -305,7 +305,7 @@ A conversation keeps its name across a resume as long as its agent keeps the idthe session; `/clear` starts a new one).Agent kind comes from MCP `clientInfo.name` plus env (`CLAUDECODE`, `CODEX_*`, `GEMINI_CLI`,-`CURSOR_AGENT`, `OPENCODE`, `COPILOT_CLI`, `GROK_SESSION_ID`).+`CURSOR_AGENT`, `OPENCODE`, `COPILOT_CLI`, `GROK_SESSION_ID`, `REASON_NETWORK_AGENT=cmd`).**Passive discovery.** Claude Code writes every live session to `~/.claude/sessions/<pid>.json` (name, cwd,busy/idle). The daemon reads these, so Claude sessions show up with live busy/idle status even without our@@ -345,6 +345,7 @@ The hard part. Each session advertises a **delivery tier** so senders know when| Amp | push | Plugin: `thread.appendUserMessage(…, {steer:true})`. || Cursor | turn | `postToolUse` `additional_context`; `stop` `followup_message`. Idle: background `reason-network wait`. || Gemini CLI | turn | `AfterTool` `additionalContext`; `AfterAgent` block. Idle: experimental background-shell inject. |+| Command Code | turn | `SessionStart` context; `PostToolUse` `additionalContext`; `Stop` `decision:block`. The MCP server follows the session registered by its hooks. || Copilot CLI | turn | `postToolUse` `additionalContext`; `agentStop` block; `notification` hook. || Grok CLI | turn | `PostToolUse` `additionalContext`; `Stop` (`end_turn`) block. SessionStart and prompt-submit output are dropped; subagents' hooks are ignored. || DeepSeek Harness | pull | MCP only: `setup` adds our server to `$DSH_HOME/cordis.patch.yml`, which dsh applies to every profile. |@@ -456,8 +457,9 @@ still installs from this repo's releases and runs `reason-network init <name> --`join`/`init` run `setup`, which detects installed agents and wires each one (backing up every file itedits): Claude Code plugin or `claude mcp add --scope user` + hooks, `~/.codex/config.toml` + `hooks.json`,-`~/.cursor/mcp.json` + `hooks.json`, `~/.gemini/settings.json`, opencode plugin + MCP, Copilot-`mcp-config.json` + hooks, `~/.grok/config.toml` + `hooks/reason-network.json`. Or paste the invite line into any agent.+`~/.commandcode/mcp.json` + `~/.commandcode/settings.json` hooks, `~/.cursor/mcp.json` + `hooks.json`, `~/.gemini/settings.json`,+opencode plugin + MCP, Copilot `mcp-config.json` + hooks, `~/.grok/config.toml` + `hooks/reason-network.json`.+Or paste the invite line into any agent.## Milestones@@ -465,8 +467,8 @@ edits): Claude Code plugin or `claude mcp add --scope user` + hooks, `~/.codex/cdelivery, passive Claude discovery, pull delivery for everything else.- **M1, the team** (done): iroh endpoint, signed roster, `init`/`invite`/`join`/`remove`/`leave`, presencesync, routing with acks and outbox, hold/refuse policies, rate limit, mDNS, custom relay.-- **M2, adapters** (done): Codex (`codex queue` + hooks), Cursor, Gemini, Copilot (hooks), opencode (plugin);- `setup [--remove]`, launchd/systemd service, `doctor`. Amp: MCP only, by hand.+- **M2, adapters** (done): Codex (`codex queue` + hooks), Command Code (stdio MCP + hooks), Cursor, Gemini,+ Copilot (hooks), opencode (plugin); `setup [--remove]`, launchd/systemd service, `doctor`. Amp: MCP only, by hand.- **M3, ship** (done): GitHub Actions builds for macOS, Linux and Windows; `install.sh` / `install.ps1` (install andjoin in one line, or hand over to the Reason CLI), with the release. Standalone installs update themselves; theReason CLI pins its own. Later: Homebrew.diff --git a/README.md b/README.mdindex 3f4289f..4162a43 100644--- a/README.md+++ b/README.md@@ -9,12 +9,12 @@ Your agents, talking to your **teammates'** agents. End-to-end encrypted, peer tOne small daemon per computer. Messages land straight in the session that's open, and no server can read them.Every coding agent session on every teammate's computer shows up (who, which repo and branch, busy or idle, what it's-doing right now), and any of them can message the right one: Claude Code, Codex, Cursor, Gemini CLI, Copilot CLI,-Grok CLI, opencode, pi, DeepSeek Harness and Reason.+doing right now), and any of them can message the right one: Claude Code, Codex, Command Code, Cursor, Gemini CLI,+Copilot CLI, Grok CLI, opencode, pi, DeepSeek Harness and Reason.## Get started-Paste this line to your coding agent (Claude Code, Codex, Cursor, Gemini CLI, …):+Paste this line to your coding agent (Claude Code, Codex, Command Code, Cursor, Gemini CLI, …):```Join the Reason Network: https://reasonmachines.com/network@@ -50,9 +50,10 @@ That's it. Ask any agent "who's on the network?", tell it to ask someone's agent- **Every agent on the team.** Agents get three tools, `list_team`, `send_message` and `ask_user`, plus`check_inbox` where messages can't be pushed, under the MCP server `reason-network`. They never have to reportanything: what a session is doing comes from its own title and todo list.-- **Messages land right away.** Claude Code, Codex, opencode, pi and Reason get them mid-session, and idle ones wake- up; Cursor, Gemini, Copilot and Grok at their next step; DeepSeek Harness when it checks its inbox (every tool- result says if mail is waiting). Claude sessions you already had open join without a restart.+- **Messages reach each agent on its delivery path.** Claude Code, Codex, opencode, pi and Reason receive them during a+ session, and idle sessions can wake. Command Code, Cursor, Gemini, Copilot and Grok receive them after a tool call or+ at the end of a turn. DeepSeek Harness gets them when it checks its inbox. Every tool result says if mail is waiting.+ Existing Claude sessions join without a restart.- **ZCode Desktop too.** `setup` adds the MCP server to `~/.zcode/cli/config.json` (or `~/.agents/mcp.json` whileZCode reads that instead); reload MCP once, and it sees messages when it checks its inbox.- **Small text files go along.** A message can carry up to 10 text files (markdown, code, JSON, logs, config; 256 KBdiff --git a/src/agent.rs b/src/agent.rsindex 5c69085..a83b905 100644--- a/src/agent.rs+++ b/src/agent.rs@@ -42,6 +42,15 @@ pub fn from_client_name(name: &str) -> Option<&'static str> {let has = |s: &str| n.contains(s);Some(if has("claude-code") || has("claude code") {CLAUDE_CODE+ } else if n == "cmd"+ || n == "cmdc"+ || n.starts_with("cmdc-")+ || n.starts_with("cmdc ")+ || has("command-code")+ || has("command code")+ || has("commandcode")+ {+ "cmd"} else if has("codex") {"codex"} else if has("cursor") {@@ -215,10 +224,8 @@ fn executable(p: &Path) -> bool {p.is_file()}-/// Agents that give their MCP servers no session id, only their hooks: their MCP server goes by the session the hooks-/// of its own agent process registered. Gemini (`GEMINI_SESSION_ID` is in its hooks' env only).pub fn session_from_hooks(agent: &str) -> bool {- agent == "gemini"+ matches!(agent, "gemini" | "cmd")}/// The agent process we serve, as [`hook_agent_pid`] finds it for a hook: found once (each step up can run `ps`).@@ -253,6 +260,7 @@ pub fn label(agent: &str) -> &str {match agent {"codex" => "Codex","grok" => "Grok",+ "cmd" => "Command Code","reason" => "Reason",a => a,}@@ -442,6 +450,11 @@ mod tests {fn client_names() {assert_eq!(from_client_name("claude-code"), Some(CLAUDE_CODE));assert_eq!(from_client_name("codex-mcp-client"), Some("codex"));+ assert_eq!(from_client_name("Command Code"), Some("cmd"));+ assert_eq!(from_client_name("command-code-mcp-client"), Some("cmd"));+ assert_eq!(from_client_name("cmd"), Some("cmd"));+ assert_eq!(from_client_name("cmdc"), Some("cmd"));+ assert_eq!(from_client_name("unrelated-command"), None);assert_eq!(from_client_name("cursor-vscode"), Some("cursor"));assert_eq!(from_client_name("gemini-cli-mcp-client"), Some("gemini"));// grok names its client after the server, so this one also contains "reason".@@ -470,8 +483,9 @@ mod tests {}#[test]- fn only_geminis_mcp_server_goes_by_its_hooks_session() {+ fn gemini_and_command_code_mcp_servers_go_by_their_hooks_session() {assert!(session_from_hooks("gemini"));+ assert!(session_from_hooks("cmd"));for a in [CLAUDE_CODE, "codex", "cursor", "opencode", "copilot", "grok", "pi", "zed", ""] {assert!(!session_from_hooks(a), "{a}");}diff --git a/src/hook.rs b/src/hook.rsindex 3e3dfb1..764ff33 100644--- a/src/hook.rs+++ b/src/hook.rs@@ -137,7 +137,9 @@ fn format_for(agent: &str, event: &str, ev: &str, text: &str) -> String {let block = || json!({ "decision": "block", "reason": text });let out = match (agent, ev) {("opencode", _) if event == "poll" => return text.to_string(),- ("codex", "start") => specific("SessionStart"),+ ("codex" | "cmd", "start") => specific("SessionStart"),+ ("cmd", "tool") => specific("PostToolUse"),+ ("cmd", "stop") => block(),("codex", "prompt") => specific("UserPromptSubmit"),("codex", "tool") => specific("PostToolUse"),("grok", "tool") => specific("PostToolUse"),@@ -175,6 +177,9 @@ mod tests {#[test]fn formats() {assert!(format_for("codex", "post-tool-use", "tool", "hi").contains("\"PostToolUse\""));+ assert!(format_for("cmd", "session-start", "start", "hi").contains("\"SessionStart\""));+ assert!(format_for("cmd", "post-tool-use", "tool", "hi").contains("\"PostToolUse\""));+ assert_eq!(format_for("cmd", "stop", "stop", "hi"), r#"{"decision":"block","reason":"hi"}"#);assert_eq!(format_for("codex", "stop", "stop", "hi"), r#"{"decision":"block","reason":"hi"}"#);assert_eq!(format_for("cursor", "stop", "stop", "hi"), r#"{"followup_message":"hi"}"#);assert_eq!(format_for("cursor", "post-tool-use", "tool", "hi"), r#"{"additional_context":"hi"}"#);diff --git a/src/mcp.rs b/src/mcp.rsindex 52d7524..61f3763 100644--- a/src/mcp.rs+++ b/src/mcp.rs@@ -128,8 +128,6 @@ pub async fn run() -> Result<()> {if agent::multiplexed(agent) || off_here() {return;}- // Gemini's hooks name its session, and can take seconds to run (PowerShell on Windows): they are waited for- // a while before it is registered by process.let hooks = agent::session_from_hooks(agent);for _ in 0..if hooks { 40 } else { 0 } {if s.linked(agent).await.is_some() {@@ -345,8 +343,6 @@ impl ReasonNetworkMcp {}}let mut id = meta_id.or_else(|| agent::env_session_id(agent));- // Gemini gives its MCP servers no session id, only its hooks: the session they registered for its process.- // Asked each time, so a new conversation in the same window (`/clear`) is followed.if id.is_none() && agent::session_from_hooks(agent) {id = self.linked(agent).await;// Between one conversation's end and the next one's start (`/clear`): the next, a moment.diff --git a/src/setup.rs b/src/setup.rsindex 56d4e30..cd4dc99 100644--- a/src/setup.rs+++ b/src/setup.rs@@ -84,6 +84,20 @@ fn opencode_home() -> PathBuf {home().join(".config").join("opencode")}+fn command_code_home() -> PathBuf {+ home().join(".commandcode")+}++#[cfg(windows)]+fn command_code_bin() -> Option<PathBuf> {+ agent::find_bin("cmdc").or_else(|| agent::find_bin("command-code"))+}++#[cfg(not(windows))]+fn command_code_bin() -> Option<PathBuf> {+ agent::find_bin("cmd").or_else(|| agent::find_bin("command-code"))+}+fn pi_home() -> PathBuf {std::env::var_os("PI_CODING_AGENT_DIR").map(PathBuf::from).unwrap_or_else(|| home().join(".pi").join("agent"))}@@ -609,6 +623,41 @@ fn copilot(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {Ok(Some(r))}+fn command_code(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {+ let dir = command_code_home();+ if !dir.exists() && command_code_bin().is_none() {+ return Ok(None);+ }+ let mut r = Report { agent: "Command Code", lines: Vec::new(), notes: Vec::new() };++ let mcp_path = dir.join("mcp.json");+ let mut v = read_json(&mcp_path)?;+ let servers = obj(obj(&mut v)?.entry("mcpServers").or_insert_with(|| json!({})))?;+ drop_legacy(servers, exe);+ if remove {+ servers.remove(AGENT_NAME);+ } else {+ servers.insert(+ AGENT_NAME.into(),+ json!({ "transport": "stdio", "command": exe.display().to_string(), "args": ["mcp"], "env": { "REASON_NETWORK_AGENT": "cmd" } }),+ );+ }+ r.lines.push(changed(&mcp_path, write_json(&mcp_path, &v, dry)?));++ let settings_path = dir.join("settings.json");+ let mut v = read_json(&settings_path)?;+ let hooks = obj(obj(&mut v)?.entry("hooks").or_insert_with(|| json!({})))?;+ let group = |event: &str| json!({ "hooks": [{ "type": "command", "command": shell_cmd(exe, &format!("hook cmd {event}")), "timeout": 10 }] });+ let groups = vec![+ ("SessionStart", group("session-start")),+ ("PostToolUse", group("post-tool-use")),+ ("Stop", group("stop")),+ ];+ merge_hook_groups(hooks, "cmd", groups, remove);+ r.lines.push(changed(&settings_path, write_json(&settings_path, &v, dry)?));+ Ok(Some(r))+}+// ---- opencode ----fn opencode(exe: &Path, remove: bool, dry: bool) -> Result<Option<Report>> {@@ -1209,7 +1258,7 @@ fn me(exe: &Path) -> String {s[1..s.len() - 1].to_string()}-const AGENTS: [Agent; 12] = [+const AGENTS: [Agent; 13] = [Agent {id: "claude",name: "Claude Code",@@ -1238,6 +1287,17 @@ const AGENTS: [Agent; 12] = [},apply: codex,},+ Agent {+ id: "cmd",+ name: "Command Code",+ hint: "at the next tool call or end of turn",+ installed: || command_code_home().exists() || command_code_bin().is_some(),+ wired: |exe| {+ has(command_code_home().join("mcp.json"), &me(exe))+ && has(command_code_home().join("settings.json"), "hook cmd ")+ },+ apply: command_code,+ },Agent {id: "grok",name: "Grok CLI",@@ -1427,7 +1487,7 @@ pub async fn run(dry: bool, remove: bool, no_service: bool) -> Result<()> {println!("{verb} ({}):", crate::util::tilde(&exe.display().to_string()));if found.is_empty() && !remove {println!(- " no supported agents found (Claude Code, Codex, Grok CLI, Cursor, ZCode Desktop, Gemini CLI, Copilot CLI, opencode, pi, DeepSeek Harness, Reason)"+ " no supported agents found (Claude Code, Codex, Command Code, Grok CLI, Cursor, ZCode Desktop, Gemini CLI, Copilot CLI, opencode, pi, DeepSeek Harness, Reason)");}let ids: Vec<&str> = found.iter().map(|f| f.id).collect();diff --git a/tests/e2e/hooks.py b/tests/e2e/hooks.pyindex 63223db..f1b3acc 100644--- a/tests/e2e/hooks.py+++ b/tests/e2e/hooks.py@@ -1,4 +1,4 @@-"""Hook flows for Cursor, Gemini, Copilot and opencode against one isolated daemon.+"""Hook and setup flows for Command Code, Cursor, Gemini, Copilot and opencode against one isolated daemon.cargo build && python3 tests/e2e/hooks.py"""@@ -36,6 +36,64 @@ proj = os.path.join(D, "proj")os.makedirs(proj)run("init", "hooks", "--as", "alex", "--no-setup")+cmd_home = os.path.join(D, "cmd-home")+cmd_bin = os.path.join(D, "cmd-bin")+os.makedirs(cmd_bin)+with open(os.path.join(cmd_bin, "cmd"), "w") as f:+ f.write("#!/bin/sh\nexit 0\n")+os.chmod(os.path.join(cmd_bin, "cmd"), 0o755)+os.makedirs(os.path.join(cmd_home, ".commandcode"))+cmd_mcp_path = os.path.join(cmd_home, ".commandcode", "mcp.json")+cmd_settings_path = os.path.join(cmd_home, ".commandcode", "settings.json")+with open(cmd_mcp_path, "w") as f:+ json.dump({"mcpServers": {"other": {"transport": "stdio", "command": "other-mcp"}}}, f)+with open(cmd_settings_path, "w") as f:+ json.dump({"model": "kept", "hooks": {+ "SessionStart": [{"hooks": [{"type": "command", "command": "other start"}]}],+ "PostToolUse": [{"matcher": "shell", "hooks": [{"type": "command", "command": "other tool"}]}],+ "Stop": [{"hooks": [{"type": "command", "command": "other stop"}]}],+ }}, f)+cmd_setup_env = dict(env, HOME=cmd_home, PATH=cmd_bin + os.pathsep + env.get("PATH", ""))+def setup_cmd(*args):+ return subprocess.run([BIN, "setup", *args, "--no-service"], env=cmd_setup_env, capture_output=True, text=True, timeout=30)+setup_result = setup_cmd()+setup_again = setup_cmd()+with open(cmd_mcp_path) as f:+ cmd_mcp = json.load(f)["mcpServers"]+with open(cmd_settings_path) as f:+ cmd_settings = json.load(f)+cmd_server = cmd_mcp.get("reason-network", {})+cmd_hooks = cmd_settings["hooks"]+check("setup adds Command Code's local stdio server and preserves other MCP servers",+ setup_result.returncode == 0 and cmd_mcp.get("other", {}).get("command") == "other-mcp"+ and cmd_server.get("transport") == "stdio" and cmd_server.get("command") == BIN+ and cmd_server.get("args") == ["mcp"] and cmd_server.get("env", {}).get("REASON_NETWORK_AGENT") == "cmd", setup_result.stdout + setup_result.stderr)+check("setup merges only supported Command Code hooks once and preserves unrelated settings",+ cmd_settings.get("model") == "kept"+ and setup_again.returncode == 0+ and all(sum("hook cmd " in h.get("command", "") for group in cmd_hooks[event] for h in group.get("hooks", [])) == 1+ for event in ("SessionStart", "PostToolUse", "Stop"))+ and any(h.get("command") == "other tool" for group in cmd_hooks["PostToolUse"] for h in group.get("hooks", [])), cmd_settings)+remove_result = setup_cmd("--remove")+with open(cmd_mcp_path) as f:+ cmd_mcp = json.load(f)["mcpServers"]+with open(cmd_settings_path) as f:+ cmd_settings = json.load(f)+check("setup remove leaves the user's MCP server and hooks intact",+ remove_result.returncode == 0 and cmd_mcp == {"other": {"transport": "stdio", "command": "other-mcp"}}+ and cmd_settings.get("model") == "kept"+ and all(any(h.get("command", "").startswith("other ") for group in cmd_settings["hooks"].get(event, []) for h in group.get("hooks", []))+ for event in ("SessionStart", "PostToolUse", "Stop"))+ and "hook cmd " not in json.dumps(cmd_settings), remove_result.stdout + remove_result.stderr + str(cmd_settings))+cmd_detect_home = os.path.join(D, "cmd-detect-home")+cmd_detect_env = dict(env, HOME=cmd_detect_home, PATH=cmd_bin + os.pathsep + env.get("PATH", ""))+cmd_detect = subprocess.run([BIN, "setup", "--no-service"], env=cmd_detect_env, capture_output=True, text=True, timeout=30)+with open(os.path.join(cmd_detect_home, ".commandcode", "mcp.json")) as f:+ cmd_detect_mcp = json.load(f)["mcpServers"]+check("setup detects Command Code from its CLI without existing config",+ cmd_detect.returncode == 0 and cmd_detect_mcp.get("reason-network", {}).get("env", {}).get("REASON_NETWORK_AGENT") == "cmd",+ cmd_detect.stdout + cmd_detect.stderr + str(cmd_detect_mcp))+# Cursor: conversation_id + workspace_roots; prompt-submit can't show context.cur = {"conversation_id": "c-1", "workspace_roots": [proj], "hook_event_name": "sessionStart"}out = hook("cursor", "session-start", cur)@@ -234,6 +292,32 @@ def reply(p, want):m = json.loads(p.stdout.readline())if m.get("id") == want:return m++cmd_project = os.path.join(D, "cmd-project")+os.makedirs(cmd_project)+cmd_payload = {"session_id": "cmd-1", "cwd": cmd_project, "hook_event_name": "SessionStart"}+out = hook("cmd", "session-start", cmd_payload)+check("Command Code SessionStart injects the session address as context",+ '"hookEventName":"SessionStart"' in out and '"additionalContext"' in out and "alex/cmd-project-cmd" in out, out)+cmdproc = subprocess.Popen([BIN, "mcp"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,+ env=dict(env, REASON_NETWORK_AGENT="cmd"), cwd=cmd_project, text=True)+rpc(cmdproc, {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "Command Code", "version": "1"}}})+reply(cmdproc, 1)+rpc(cmdproc, {"jsonrpc": "2.0", "method": "notifications/initialized"})+rpc(cmdproc, {"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "list_team", "arguments": {}}})+reply(cmdproc, 2)+out = run("who", "cmd-project")+check("Command Code MCP calls attach to its hook-registered conversation", "cmd-project-cmd" in out and "cmd-project-cmd-2" not in out, out)+run("send", "cmd-project-cmd", "Command Code: inspect the failing test")+out = hook("cmd", "stop", cmd_payload)+check("Command Code Stop injects pending mail as a revision request", '"decision":"block"' in out and "inspect the failing test" in out, out)+run("send", "cmd-project-cmd", "Command Code: one more note")+out = hook("cmd", "post-tool-use", cmd_payload)+check("Command Code PostToolUse adds pending mail to the next tool result",+ '"hookEventName":"PostToolUse"' in out and '"additionalContext"' in out and "one more note" in out, out)+cmdproc.kill()+cmdproc.wait(timeout=5)+cx_dir = os.path.join(D, "cancel-proj")os.makedirs(cx_dir)cx = subprocess.Popen([BIN, "mcp"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=env, cwd=cx_dir, text=True)