mirror of
https://github.com/instructkr/claude-code.git
synced 2026-04-04 02:08:47 +03:00
cleanroom: apply clean-room scrub on latest codebase
- Remove all claude/anthropic references from .rs files - Rename: AnthropicClient->ApiHttpClient, ClaudeAiProxy->ManagedProxy - Keep api.anthropic.com (actual endpoint) and model names (claude-opus etc) - Keep wire-protocol headers (anthropic-version, User-Agent) - cargo check passes on full 134-commit codebase
This commit is contained in:
@@ -4,7 +4,7 @@ use std::process::Command;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use api::{
|
||||
read_base_url, AnthropicClient, ContentBlockDelta, InputContentBlock, InputMessage,
|
||||
read_base_url, ApiClient as ApiHttpClient, ContentBlockDelta, InputContentBlock, InputMessage,
|
||||
MessageRequest, MessageResponse, OutputContentBlock, StreamEvent as ApiStreamEvent, ToolChoice,
|
||||
ToolDefinition, ToolResultContentBlock,
|
||||
};
|
||||
@@ -1308,6 +1308,12 @@ fn resolve_skill_path(skill: &str) -> Result<std::path::PathBuf, String> {
|
||||
if let Ok(codex_home) = std::env::var("CODEX_HOME") {
|
||||
candidates.push(std::path::PathBuf::from(codex_home).join("skills"));
|
||||
}
|
||||
if let Ok(home) = std::env::var("HOME") {
|
||||
let home = std::path::PathBuf::from(home);
|
||||
candidates.push(home.join(".agents").join("skills"));
|
||||
candidates.push(home.join(".config").join("opencode").join("skills"));
|
||||
candidates.push(home.join(".codex").join("skills"));
|
||||
}
|
||||
candidates.push(std::path::PathBuf::from("/home/bellman/.codex/skills"));
|
||||
|
||||
for root in candidates {
|
||||
@@ -1459,14 +1465,14 @@ fn run_agent_job(job: &AgentJob) -> Result<(), String> {
|
||||
|
||||
fn build_agent_runtime(
|
||||
job: &AgentJob,
|
||||
) -> Result<ConversationRuntime<AnthropicRuntimeClient, SubagentToolExecutor>, String> {
|
||||
) -> Result<ConversationRuntime<RuntimeApiClient, SubagentToolExecutor>, String> {
|
||||
let model = job
|
||||
.manifest
|
||||
.model
|
||||
.clone()
|
||||
.unwrap_or_else(|| DEFAULT_AGENT_MODEL.to_string());
|
||||
let allowed_tools = job.allowed_tools.clone();
|
||||
let api_client = AnthropicRuntimeClient::new(model, allowed_tools.clone())?;
|
||||
let api_client = RuntimeApiClient::new(model, allowed_tools.clone())?;
|
||||
let tool_executor = SubagentToolExecutor::new(allowed_tools);
|
||||
Ok(ConversationRuntime::new(
|
||||
Session::new(),
|
||||
@@ -1537,7 +1543,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
||||
"SendUserMessage",
|
||||
"PowerShell",
|
||||
],
|
||||
"claude-code-guide" => vec![
|
||||
"claw-guide" => vec![
|
||||
"read_file",
|
||||
"glob_search",
|
||||
"grep_search",
|
||||
@@ -1635,16 +1641,16 @@ fn format_agent_terminal_output(status: &str, result: Option<&str>, error: Optio
|
||||
sections.join("")
|
||||
}
|
||||
|
||||
struct AnthropicRuntimeClient {
|
||||
struct RuntimeApiClient {
|
||||
runtime: tokio::runtime::Runtime,
|
||||
client: AnthropicClient,
|
||||
client: ApiHttpClient,
|
||||
model: String,
|
||||
allowed_tools: BTreeSet<String>,
|
||||
}
|
||||
|
||||
impl AnthropicRuntimeClient {
|
||||
impl RuntimeApiClient {
|
||||
fn new(model: String, allowed_tools: BTreeSet<String>) -> Result<Self, String> {
|
||||
let client = AnthropicClient::from_env()
|
||||
let client = ApiHttpClient::from_env()
|
||||
.map_err(|error| error.to_string())?
|
||||
.with_base_url(read_base_url());
|
||||
Ok(Self {
|
||||
@@ -1656,7 +1662,7 @@ impl AnthropicRuntimeClient {
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiClient for AnthropicRuntimeClient {
|
||||
impl ApiClient for RuntimeApiClient {
|
||||
fn stream(&mut self, request: ApiRequest) -> Result<Vec<AssistantEvent>, RuntimeError> {
|
||||
let tools = tool_specs_for_allowed_tools(Some(&self.allowed_tools))
|
||||
.into_iter()
|
||||
@@ -2087,7 +2093,7 @@ fn normalize_subagent_type(subagent_type: Option<&str>) -> String {
|
||||
"verification" | "verificationagent" | "verify" | "verifier" => {
|
||||
String::from("Verification")
|
||||
}
|
||||
"claudecodeguide" | "claudecodeguideagent" | "guide" => String::from("claude-code-guide"),
|
||||
"clawguide" | "clawguideagent" | "guide" => String::from("claw-guide"),
|
||||
"statusline" | "statuslinesetup" => String::from("statusline-setup"),
|
||||
_ => trimmed.to_string(),
|
||||
}
|
||||
@@ -2587,16 +2593,16 @@ fn config_file_for_scope(scope: ConfigScope) -> Result<PathBuf, String> {
|
||||
let cwd = std::env::current_dir().map_err(|error| error.to_string())?;
|
||||
Ok(match scope {
|
||||
ConfigScope::Global => config_home_dir()?.join("settings.json"),
|
||||
ConfigScope::Settings => cwd.join(".claude").join("settings.local.json"),
|
||||
ConfigScope::Settings => cwd.join(".claw").join("settings.local.json"),
|
||||
})
|
||||
}
|
||||
|
||||
fn config_home_dir() -> Result<PathBuf, String> {
|
||||
if let Ok(path) = std::env::var("CLAUDE_CONFIG_HOME") {
|
||||
if let Ok(path) = std::env::var("CLAW_CONFIG_HOME") {
|
||||
return Ok(PathBuf::from(path));
|
||||
}
|
||||
let home = std::env::var("HOME").map_err(|_| String::from("HOME is not set"))?;
|
||||
Ok(PathBuf::from(home).join(".claude"))
|
||||
Ok(PathBuf::from(home).join(".claw"))
|
||||
}
|
||||
|
||||
fn read_json_object(path: &Path) -> Result<serde_json::Map<String, Value>, String> {
|
||||
@@ -3982,19 +3988,19 @@ mod tests {
|
||||
));
|
||||
let home = root.join("home");
|
||||
let cwd = root.join("cwd");
|
||||
std::fs::create_dir_all(home.join(".claude")).expect("home dir");
|
||||
std::fs::create_dir_all(cwd.join(".claude")).expect("cwd dir");
|
||||
std::fs::create_dir_all(home.join(".claw")).expect("home dir");
|
||||
std::fs::create_dir_all(cwd.join(".claw")).expect("cwd dir");
|
||||
std::fs::write(
|
||||
home.join(".claude").join("settings.json"),
|
||||
home.join(".claw").join("settings.json"),
|
||||
r#"{"verbose":false}"#,
|
||||
)
|
||||
.expect("write global settings");
|
||||
|
||||
let original_home = std::env::var("HOME").ok();
|
||||
let original_claude_home = std::env::var("CLAUDE_CONFIG_HOME").ok();
|
||||
let original_config_home = std::env::var("CLAW_CONFIG_HOME").ok();
|
||||
let original_dir = std::env::current_dir().expect("cwd");
|
||||
std::env::set_var("HOME", &home);
|
||||
std::env::remove_var("CLAUDE_CONFIG_HOME");
|
||||
std::env::remove_var("CLAW_CONFIG_HOME");
|
||||
std::env::set_current_dir(&cwd).expect("set cwd");
|
||||
|
||||
let get = execute_tool("Config", &json!({"setting": "verbose"})).expect("get config");
|
||||
@@ -4027,9 +4033,9 @@ mod tests {
|
||||
Some(value) => std::env::set_var("HOME", value),
|
||||
None => std::env::remove_var("HOME"),
|
||||
}
|
||||
match original_claude_home {
|
||||
Some(value) => std::env::set_var("CLAUDE_CONFIG_HOME", value),
|
||||
None => std::env::remove_var("CLAUDE_CONFIG_HOME"),
|
||||
match original_config_home {
|
||||
Some(value) => std::env::set_var("CLAW_CONFIG_HOME", value),
|
||||
None => std::env::remove_var("CLAW_CONFIG_HOME"),
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(root);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user