From 75be541e6d411efbd4437c65f405634c7b2fe59a Mon Sep 17 00:00:00 2001 From: sohan-bhat Date: Sun, 6 Dec 2026 12:10:48 -0600 Subject: [PATCH 1/2] Honor CLAUDE_CONFIG_DIR in agent install --- README.md | 4 ++-- src/agent.rs | 14 +++++++----- tests/agent_install.rs | 51 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fbbac1b..1815fe1 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ curl -fsSL https://proofline.sh/cli | sh proofline init ``` -`curl -fsSL https://proofline.sh/cli | sh -s -- --setup` also registers the MCP server with Claude Code, Cursor and Codex, then runs `proofline init`. When `proofline agent install` refuses one of those agents, for example because `CLAUDE_CONFIG_DIR` or a non-default `CODEX_HOME` is set, the installer prints the reason and the `proofline agent install CLIENT --print` command, skips that agent and continues; its last line names each skipped agent. A download or checksum failure still stops the installer. +`curl -fsSL https://proofline.sh/cli | sh -s -- --setup` also registers the MCP server with Claude Code, Cursor and Codex, then runs `proofline init`. When `proofline agent install` refuses one of those agents, for example because a non-default `CODEX_HOME` is set, the installer prints the reason and the `proofline agent install CLIENT --print` command, skips that agent and continues; its last line names each skipped agent. A download or checksum failure still stops the installer. If you started on the signup page, use the `proofline init` command it gives you. Its organization options select the team shown on that page. Approve sign-in if prompted and install the GitHub App if it is missing. Once Proofline records the installation, the CLI prints the setup brief. Run `proofline setup status` to see the current gaps. @@ -44,7 +44,7 @@ set as `PROOFLINE_TOKEN`. A token that works in one organization needs no ### MCP agent registration -To register MCP without a prompt, run `proofline agent install CLIENT --yes`. Supported clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini`, and `kiro`. Without `--yes`, the command previews the entry and asks for confirmation, while `--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`; a custom `CLAUDE_CONFIG_DIR` requires manual configuration with `--print`. +To register MCP without a prompt, run `proofline agent install CLIENT --yes`. Supported clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini`, and `kiro`. Without `--yes`, the command previews the entry and asks for confirmation, while `--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`, or in `.claude.json` inside the directory an absolute `CLAUDE_CONFIG_DIR` names; a relative `CLAUDE_CONFIG_DIR` requires manual configuration with `--print`. For Codex's default configuration, add the entry to `~/.codex/config.toml` with this command. diff --git a/src/agent.rs b/src/agent.rs index 0e6466a..0c45945 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -81,9 +81,9 @@ enum InstallError { #[error("the running Proofline executable path is not UTF-8")] ExecutableEncoding, #[error( - "CLAUDE_CONFIG_DIR selects custom configuration; use --print and configure Claude Code manually" + "CLAUDE_CONFIG_DIR is a relative path, which Claude Code resolves from the directory it starts in; use --print and configure Claude Code manually" )] - CustomClaudeHome, + RelativeClaudeHome, #[error("could not find an absolute user home directory")] Home, #[error( @@ -161,13 +161,17 @@ enum Outcome { pub(crate) async fn run(args: AgentArgs, origin: Origin) -> anyhow::Result<()> { tokio::task::spawn_blocking(move || { let AgentCommand::Install(args) = args.command; - let home = std::env::home_dir().ok_or(InstallError::Home)?; + let mut home = std::env::home_dir().ok_or(InstallError::Home)?; let codex_home = std::env::var_os("CODEX_HOME"); if args.client == Client::ClaudeCode && !args.print - && std::env::var_os("CLAUDE_CONFIG_DIR").is_some() + && let Some(selected) = + std::env::var_os("CLAUDE_CONFIG_DIR").filter(|selected| !selected.is_empty()) { - return Err(InstallError::CustomClaudeHome); + home = PathBuf::from(selected); + if !home.is_absolute() { + return Err(InstallError::RelativeClaudeHome); + } } let stdin = io::stdin(); let stdout = io::stdout(); diff --git a/tests/agent_install.rs b/tests/agent_install.rs index e02c9f4..6ce8d42 100644 --- a/tests/agent_install.rs +++ b/tests/agent_install.rs @@ -146,15 +146,20 @@ fn unattended_confirmation_keeps_refusals_and_manual_preview() { fs::remove_file(&path).unwrap(); let custom = home.path().join("custom"); let refused = command(binary, home.path()) - .env("CLAUDE_CONFIG_DIR", &custom) + .current_dir(home.path()) + .env("CLAUDE_CONFIG_DIR", "custom") .args(["agent", "install", "claude-code", "--yes"]) .output() .unwrap(); assert!(!refused.status.success()); + assert!( + String::from_utf8_lossy(&refused.stderr).contains("CLAUDE_CONFIG_DIR is a relative path") + ); assert!(!path.exists()); assert!(!custom.exists()); let preview = command(binary, home.path()) - .env("CLAUDE_CONFIG_DIR", &custom) + .current_dir(home.path()) + .env("CLAUDE_CONFIG_DIR", "custom") .args(["agent", "install", "claude-code", "--print"]) .output() .unwrap(); @@ -164,6 +169,48 @@ fn unattended_confirmation_keeps_refusals_and_manual_preview() { assert!(!custom.exists()); } +#[test] +fn claude_config_dir_selects_the_file_claude_code_reads() { + let root = TempDir::new().unwrap(); + let home = root.path().join("home"); + let custom = root.path().join("work profile"); + fs::create_dir_all(&home).unwrap(); + fs::create_dir_all(&custom).unwrap(); + let binary = Path::new(env!("CARGO_BIN_EXE_proofline")); + let original = json!({"projects": {"private-project": {"hasTrustDialogAccepted": false}}}); + fs::write(custom.join(".claude.json"), original.to_string()).unwrap(); + let install = |selected: &Path| { + let output = command(binary, &home) + .env("CLAUDE_CONFIG_DIR", selected) + .args(["agent", "install", "claude-code", "--yes"]) + .output() + .unwrap(); + assert!( + output.status.success(), + "{}", + String::from_utf8_lossy(&output.stderr) + ); + }; + + install(&custom); + let mut config: Value = + serde_json::from_str(&fs::read_to_string(custom.join(".claude.json")).unwrap()).unwrap(); + let servers = config + .as_object_mut() + .unwrap() + .remove("mcpServers") + .unwrap(); + assert_eq!(config, original); + assert_eq!( + servers["proofline"]["args"], + json!(["--base-url", "https://proofline.sh", "mcp"]) + ); + assert!(!home.join(".claude.json").exists()); + + install(Path::new("")); + assert!(home.join(".claude.json").exists()); +} + #[cfg(unix)] #[test] fn without_git_registration_names_the_recovery_and_a_repository_still_refuses() { From 1ae4e1a11c3971d1fd3c000b3683dd8167ad6495 Mon Sep 17 00:00:00 2001 From: sohan-bhat Date: Sun, 6 Dec 2026 12:45:48 -0600 Subject: [PATCH 2/2] Name a missing CLAUDE_CONFIG_DIR directory --- README.md | 2 +- src/agent.rs | 5 +++++ tests/agent_install.rs | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1815fe1..37f45a4 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ set as `PROOFLINE_TOKEN`. A token that works in one organization needs no ### MCP agent registration -To register MCP without a prompt, run `proofline agent install CLIENT --yes`. Supported clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini`, and `kiro`. Without `--yes`, the command previews the entry and asks for confirmation, while `--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`, or in `.claude.json` inside the directory an absolute `CLAUDE_CONFIG_DIR` names; a relative `CLAUDE_CONFIG_DIR` requires manual configuration with `--print`. +To register MCP without a prompt, run `proofline agent install CLIENT --yes`. Supported clients include `claude-code` (or `claude`), `cursor`, `codex`, `gemini`, and `kiro`. Without `--yes`, the command previews the entry and asks for confirmation, while `--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`, or in `.claude.json` inside the existing directory an absolute `CLAUDE_CONFIG_DIR` names; a relative `CLAUDE_CONFIG_DIR` or a directory Claude Code has not created yet requires manual configuration with `--print`. For Codex's default configuration, add the entry to `~/.codex/config.toml` with this command. diff --git a/src/agent.rs b/src/agent.rs index 0c45945..42f6a35 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -84,6 +84,8 @@ enum InstallError { "CLAUDE_CONFIG_DIR is a relative path, which Claude Code resolves from the directory it starts in; use --print and configure Claude Code manually" )] RelativeClaudeHome, + #[error("CLAUDE_CONFIG_DIR is not an existing directory: {}; start Claude Code once to create it, or use --print and configure Claude Code manually", .0.display())] + MissingClaudeHome(PathBuf), #[error("could not find an absolute user home directory")] Home, #[error( @@ -172,6 +174,9 @@ pub(crate) async fn run(args: AgentArgs, origin: Origin) -> anyhow::Result<()> { if !home.is_absolute() { return Err(InstallError::RelativeClaudeHome); } + if !home.is_dir() { + return Err(InstallError::MissingClaudeHome(home)); + } } let stdin = io::stdin(); let stdout = io::stdout(); diff --git a/tests/agent_install.rs b/tests/agent_install.rs index 6ce8d42..58c0674 100644 --- a/tests/agent_install.rs +++ b/tests/agent_install.rs @@ -209,6 +209,19 @@ fn claude_config_dir_selects_the_file_claude_code_reads() { install(Path::new("")); assert!(home.join(".claude.json").exists()); + + let missing = root.path().join("new profile"); + let refused = command(binary, &home) + .env("CLAUDE_CONFIG_DIR", &missing) + .args(["agent", "install", "claude-code", "--yes"]) + .output() + .unwrap(); + assert!(!refused.status.success()); + assert!( + String::from_utf8_lossy(&refused.stderr) + .contains("CLAUDE_CONFIG_DIR is not an existing directory") + ); + assert!(!missing.exists()); } #[cfg(unix)]