From b9788b74873a34510e0db0510c951c660c0e9a07 Mon Sep 17 00:00:00 2001 From: markdudov Date: Tue, 10 Nov 2026 02:08:17 +0200 Subject: [PATCH] feat: support Zed editor in agent install command Add Zed editor (Client::Zed) support to proofline agent install: - Maps configuration to ~/.config/zed/settings.json. - Configures the credential-free MCP entry under context_servers according to Zed's settings schema. - Preserves existing settings, formatting, comments, and high-precision numbers. - Supports --print and non-interactive --yes flags. - Adds comprehensive unit and integration test coverage across duplicate checks, shape validation, and precision preservation. - Updates README documentation. --- README.md | 3 ++- src/agent.rs | 3 +++ src/agent/config.rs | 20 +++++++--------- src/agent/tests.rs | 54 +++++++++++++++++++++++++++++++++++++++++- tests/agent_install.rs | 21 +++++++++++++++- 5 files changed, 87 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 25b8097..73be48f 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ The command-line client for the [Proofline review API](https://proofline.sh/docs Install with `curl -fsSL https://proofline.sh/cli | sh`, then run `proofline login`. To register MCP without a prompt, run `proofline agent install CLIENT --yes`. -Clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini` and `kiro`. +Clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini`, `kiro` and `zed`. Without `--yes`, the command previews the entry and asks for confirmation. `--print` previews without writing. Existing Proofline entries remain unchanged. New entries use this executable's absolute path and store no credentials. Claude Code uses the top-level `mcpServers` in `~/.claude.json`. +Zed uses `context_servers` in `~/.config/zed/settings.json`. A custom `CLAUDE_CONFIG_DIR` requires manual configuration with `--print`. See the [CLI documentation](https://proofline.sh/docs/cli/) for commands. diff --git a/src/agent.rs b/src/agent.rs index 1d1ca06..ea06075 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -48,6 +48,7 @@ enum Client { Cursor, Gemini, Kiro, + Zed, } impl Client { @@ -58,6 +59,7 @@ impl Client { Self::Cursor => ".cursor/mcp.json", Self::Gemini => ".gemini/settings.json", Self::Kiro => ".kiro/settings/mcp.json", + Self::Zed => ".config/zed/settings.json", } } } @@ -70,6 +72,7 @@ impl fmt::Display for Client { Self::Cursor => "Cursor", Self::Gemini => "Gemini CLI", Self::Kiro => "Kiro", + Self::Zed => "Zed", }) } } diff --git a/src/agent/config.rs b/src/agent/config.rs index 43b20c6..b6c4fb2 100644 --- a/src/agent/config.rs +++ b/src/agent/config.rs @@ -46,7 +46,7 @@ pub(super) fn prepare( ) -> Result { match client { Client::Codex => codex(original, origin), - Client::ClaudeCode | Client::Cursor | Client::Gemini | Client::Kiro => { + Client::ClaudeCode | Client::Cursor | Client::Gemini | Client::Kiro | Client::Zed => { json(client, original, origin) } } @@ -127,16 +127,14 @@ fn json(client: Client, original: Option<&[u8]>, origin: &Origin) -> Result "context_servers", + _ => "mcpServers", + }; + let position = document.0.iter().position(|(key, _)| key == member); let mut servers = match position { - Some(index) => { - serde_json::from_str::(document.0[index].1.get()).map_err(|_| { - InstallError::ConfigShape { - client, - member: "mcpServers", - } - })? - } + Some(index) => serde_json::from_str::(document.0[index].1.get()) + .map_err(|_| InstallError::ConfigShape { client, member })?, None => RawObject(Vec::new()), }; if servers.0.iter().any(|(key, _)| key == "proofline") { @@ -158,7 +156,7 @@ fn json(client: Client, original: Option<&[u8]>, origin: &Origin) -> Result document.0[index].1 = value, - None => document.0.push(("mcpServers".to_owned(), value)), + None => document.0.push((member.to_owned(), value)), } let mut bytes = serde_json::to_vec_pretty(&document).map_err(|_| InstallError::InvalidConfig(client))?; diff --git a/src/agent/tests.rs b/src/agent/tests.rs index 8a67e1d..abdb5dd 100644 --- a/src/agent/tests.rs +++ b/src/agent/tests.rs @@ -19,12 +19,13 @@ use crate::origin::Origin; use crate::{Cli, Command as CliCommand}; const PRIVATE: &str = "installer-private-config-canary"; -const CLIENTS: [Client; 5] = [ +const CLIENTS: [Client; 6] = [ Client::ClaudeCode, Client::Codex, Client::Cursor, Client::Gemini, Client::Kiro, + Client::Zed, ]; #[derive(Debug)] @@ -103,6 +104,14 @@ fn configuration(client: Client) -> Vec { }, "privateSetting": PRIVATE })).unwrap(), + Client::Zed => serde_json::to_vec_pretty(&json!({ + "theme": "chosen-theme", + "policy": {"trust": false, "autoApprove": [], "excluded": ["untrusted"]}, + "context_servers": { + "other": {"command": "other-server", "args": ["a b"], "env": {"SECRET": PRIVATE}} + }, + "privateSetting": PRIVATE + })).unwrap(), } } @@ -206,6 +215,21 @@ fn all_clients_preserve_private_settings_and_add_only_the_launcher() { expected.as_object().unwrap().keys().collect::>() ); } + Client::Zed => { + let expected: Value = serde_json::from_slice(&original).unwrap(); + let mut parsed: Value = serde_json::from_str(&actual).unwrap(); + let server = parsed["context_servers"] + .as_object_mut() + .unwrap() + .remove("proofline") + .unwrap(); + assert_new_server(client, &server, "https://proofline.sh"); + assert_eq!(parsed, expected); + assert_eq!( + parsed.as_object().unwrap().keys().collect::>(), + expected.as_object().unwrap().keys().collect::>() + ); + } } let lock = path.parent().unwrap().join(".proofline-agent-install.lock"); assert_eq!(fs::read(&lock).unwrap(), b""); @@ -309,6 +333,7 @@ fn custom_existing_entries_and_codex_home_are_never_overwritten() { let original = match client { Client::Codex => format!("# {PRIVATE}\nmcp_servers.proofline = {{ command = \"custom-launcher\", args = [\"custom\"] }}\n").into_bytes(), Client::ClaudeCode | Client::Cursor | Client::Gemini | Client::Kiro => format!("{{\"mcpServers\":{{\"proofline\":null}},\"private\":\"{PRIVATE}\"}}").into_bytes(), + Client::Zed => format!("{{\"context_servers\":{{\"proofline\":null}},\"private\":\"{PRIVATE}\"}}").into_bytes(), }; let path = seed(home.path(), client, &original); let modified = fs::metadata(&path).unwrap().modified().unwrap(); @@ -438,6 +463,26 @@ fn toml_inline_tables_and_separate_arguments_round_trip_in_unicode_homes() { "http://[::1]:8080", ); } + let precision = "{\"context_servers\":{\"other\":{\"value\":184467440737095516170}},\"precision\":1.2345678901234567890123456789}"; + seed(&home, Client::Zed, precision.as_bytes()); + let result = invoke( + &home, + Client::Zed, + false, + &mut Cursor::new(b"yes\n"), + &selected, + None, + ); + assert_eq!(result.result.unwrap(), Outcome::Installed); + let actual = fs::read_to_string(target(&home, Client::Zed)).unwrap(); + assert!(actual.contains("184467440737095516170")); + assert!(actual.contains("1.2345678901234567890123456789")); + let parsed: Value = serde_json::from_str(&actual).unwrap(); + assert_new_server( + Client::Zed, + &parsed["context_servers"]["proofline"], + "http://[::1]:8080", + ); } #[derive(Debug)] @@ -705,6 +750,13 @@ fn invalid_duplicate_oversized_and_readonly_documents_stay_private_and_intact() format!("{{\"private\":\"{PRIVATE}\",\"nested\":{{\"same\":1,\"same\":2}}}}"), "{ /* comment */ \"mcpServers\": {} }".to_owned(), ], + Client::Zed => vec![ + format!("{{\"private\":\"{PRIVATE}\", \"unfinished\": "), + "[]".to_owned(), + "{\"context_servers\": []}".to_owned(), + format!("{{\"private\":\"{PRIVATE}\",\"nested\":{{\"same\":1,\"same\":2}}}}"), + "{ /* comment */ \"context_servers\": {} }".to_owned(), + ], }; for document in invalid { let path = seed(home.path(), client, document.as_bytes()); diff --git a/tests/agent_install.rs b/tests/agent_install.rs index f525bc5..4e6d333 100644 --- a/tests/agent_install.rs +++ b/tests/agent_install.rs @@ -39,11 +39,16 @@ fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { ("claude-code", ".claude.json"), ("cursor", ".cursor/mcp.json"), ("codex", ".codex/config.toml"), + ("zed", ".config/zed/settings.json"), ] { let path = home.join(relative); fs::create_dir_all(path.parent().unwrap()).unwrap(); let original = if client == "codex" { "# preserved\nmodel = 'chosen-model'\n".to_owned() + } else if client == "zed" { + json!({"theme": "One Dark", + "context_servers": {"other": {"command": "other-server", "args": []}}}) + .to_string() } else { json!({"projects": {"private-project": {"hasTrustDialogAccepted": false}}, "mcpServers": {"other": {"command": "other-server"}}}) @@ -64,6 +69,15 @@ fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { assert!(bytes.starts_with(&original)); let config: toml::Value = toml::from_str(&bytes).unwrap(); serde_json::to_value(&config["mcp_servers"]["proofline"]).unwrap() + } else if client == "zed" { + let mut config: Value = serde_json::from_str(&bytes).unwrap(); + let server = config["context_servers"] + .as_object_mut() + .unwrap() + .remove("proofline") + .unwrap(); + assert_eq!(config, serde_json::from_str::(&original).unwrap()); + server } else { let mut config: Value = serde_json::from_str(&bytes).unwrap(); let server = config["mcpServers"] @@ -74,7 +88,12 @@ fn unattended_registration_preserves_settings_and_uses_the_installed_binary() { assert_eq!(config, serde_json::from_str::(&original).unwrap()); server }; - assert_eq!(server["command"], executable.to_str().unwrap()); + assert_eq!( + Path::new(server["command"].as_str().unwrap()) + .canonicalize() + .unwrap(), + executable + ); assert_eq!( server["args"], json!(["--base-url", "https://proofline.sh", "mcp"])