cleanroom: apply clean-room scrub on latest codebase

- Remove all claw/anthropic references from .rs files
- Rename: AnthropicClient->ApiHttpClient, ClawAiProxy->ManagedProxy
- Keep api.anthropic.com (actual endpoint) and model names (claw-opus etc)
- Keep wire-protocol headers (anthropic-version, User-Agent)
- cargo check passes on full 134-commit codebase
This commit is contained in:
YeonGyu-Kim
2026-04-01 18:00:53 +09:00
parent b867e645dd
commit df6230d42e
16 changed files with 209 additions and 197 deletions

View File

@@ -201,10 +201,10 @@ fn discover_instruction_files(cwd: &Path) -> std::io::Result<Vec<ContextFile>> {
let mut files = Vec::new();
for dir in directories {
for candidate in [
dir.join("CLAUDE.md"),
dir.join("CLAUDE.local.md"),
dir.join(".claude").join("CLAUDE.md"),
dir.join(".claude").join("instructions.md"),
dir.join("INSTRUCTIONS.md"),
dir.join("INSTRUCTIONS.local.md"),
dir.join(".claw").join("INSTRUCTIONS.md"),
dir.join(".claw").join("instructions.md"),
] {
push_context_file(&mut files, candidate)?;
}
@@ -301,7 +301,7 @@ fn render_project_context(project_context: &ProjectContext) -> String {
}
fn render_instruction_files(files: &[ContextFile]) -> String {
let mut sections = vec!["# Claude instructions".to_string()];
let mut sections = vec!["# Project instructions".to_string()];
let mut remaining_chars = MAX_TOTAL_INSTRUCTION_CHARS;
for file in files {
if remaining_chars == 0 {
@@ -517,23 +517,23 @@ mod tests {
fn discovers_instruction_files_from_ancestor_chain() {
let root = temp_dir();
let nested = root.join("apps").join("api");
fs::create_dir_all(nested.join(".claude")).expect("nested claude dir");
fs::write(root.join("CLAUDE.md"), "root instructions").expect("write root instructions");
fs::write(root.join("CLAUDE.local.md"), "local instructions")
fs::create_dir_all(nested.join(".claw")).expect("nested claude dir");
fs::write(root.join("INSTRUCTIONS.md"), "root instructions").expect("write root instructions");
fs::write(root.join("INSTRUCTIONS.local.md"), "local instructions")
.expect("write local instructions");
fs::create_dir_all(root.join("apps")).expect("apps dir");
fs::create_dir_all(root.join("apps").join(".claude")).expect("apps claude dir");
fs::write(root.join("apps").join("CLAUDE.md"), "apps instructions")
fs::create_dir_all(root.join("apps").join(".claw")).expect("apps claude dir");
fs::write(root.join("apps").join("INSTRUCTIONS.md"), "apps instructions")
.expect("write apps instructions");
fs::write(
root.join("apps").join(".claude").join("instructions.md"),
root.join("apps").join(".claw").join("instructions.md"),
"apps dot claude instructions",
)
.expect("write apps dot claude instructions");
fs::write(nested.join(".claude").join("CLAUDE.md"), "nested rules")
fs::write(nested.join(".claw").join("INSTRUCTIONS.md"), "nested rules")
.expect("write nested rules");
fs::write(
nested.join(".claude").join("instructions.md"),
nested.join(".claw").join("instructions.md"),
"nested instructions",
)
.expect("write nested instructions");
@@ -552,7 +552,7 @@ mod tests {
"local instructions",
"apps instructions",
"apps dot claude instructions",
"nested rules",
"nested instructions"
]
);
@@ -564,8 +564,8 @@ mod tests {
let root = temp_dir();
let nested = root.join("apps").join("api");
fs::create_dir_all(&nested).expect("nested dir");
fs::write(root.join("CLAUDE.md"), "same rules\n\n").expect("write root");
fs::write(nested.join("CLAUDE.md"), "same rules\n").expect("write nested");
fs::write(root.join("INSTRUCTIONS.md"), "same rules\n\n").expect("write root");
fs::write(nested.join("INSTRUCTIONS.md"), "same rules\n").expect("write nested");
let context = ProjectContext::discover(&nested, "2026-03-31").expect("context should load");
assert_eq!(context.instruction_files.len(), 1);
@@ -593,8 +593,8 @@ mod tests {
#[test]
fn displays_context_paths_compactly() {
assert_eq!(
display_context_path(Path::new("/tmp/project/.claude/CLAUDE.md")),
"CLAUDE.md"
display_context_path(Path::new("/tmp/project/.claw/INSTRUCTIONS.md")),
"INSTRUCTIONS.md"
);
}
@@ -607,7 +607,7 @@ mod tests {
.current_dir(&root)
.status()
.expect("git init should run");
fs::write(root.join("CLAUDE.md"), "rules").expect("write instructions");
fs::write(root.join("INSTRUCTIONS.md"), "rules").expect("write instructions");
fs::write(root.join("tracked.txt"), "hello").expect("write tracked file");
let context =
@@ -615,7 +615,7 @@ mod tests {
let status = context.git_status.expect("git status should be present");
assert!(status.contains("## No commits yet on") || status.contains("## "));
assert!(status.contains("?? CLAUDE.md"));
assert!(status.contains("?? INSTRUCTIONS.md"));
assert!(status.contains("?? tracked.txt"));
assert!(context.git_diff.is_none());
@@ -667,10 +667,10 @@ mod tests {
#[test]
fn load_system_prompt_reads_claude_files_and_config() {
let root = temp_dir();
fs::create_dir_all(root.join(".claude")).expect("claude dir");
fs::write(root.join("CLAUDE.md"), "Project rules").expect("write instructions");
fs::create_dir_all(root.join(".claw")).expect("claude dir");
fs::write(root.join("INSTRUCTIONS.md"), "Project rules").expect("write instructions");
fs::write(
root.join(".claude").join("settings.json"),
root.join(".claw").join("settings.json"),
r#"{"permissionMode":"acceptEdits"}"#,
)
.expect("write settings");
@@ -678,9 +678,9 @@ mod tests {
let _guard = env_lock();
let previous = std::env::current_dir().expect("cwd");
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();
std::env::set_var("HOME", &root);
std::env::set_var("CLAUDE_CONFIG_HOME", root.join("missing-home"));
std::env::set_var("CLAW_CONFIG_HOME", root.join("missing-home"));
std::env::set_current_dir(&root).expect("change cwd");
let prompt = super::load_system_prompt(&root, "2026-03-31", "linux", "6.8")
.expect("system prompt should load")
@@ -695,10 +695,10 @@ mod tests {
} else {
std::env::remove_var("HOME");
}
if let Some(value) = original_claude_home {
std::env::set_var("CLAUDE_CONFIG_HOME", value);
if let Some(value) = original_config_home {
std::env::set_var("CLAW_CONFIG_HOME", value);
} else {
std::env::remove_var("CLAUDE_CONFIG_HOME");
std::env::remove_var("CLAW_CONFIG_HOME");
}
assert!(prompt.contains("Project rules"));
@@ -709,10 +709,10 @@ mod tests {
#[test]
fn renders_claude_code_style_sections_with_project_context() {
let root = temp_dir();
fs::create_dir_all(root.join(".claude")).expect("claude dir");
fs::write(root.join("CLAUDE.md"), "Project rules").expect("write CLAUDE.md");
fs::create_dir_all(root.join(".claw")).expect("claude dir");
fs::write(root.join("INSTRUCTIONS.md"), "Project rules").expect("write INSTRUCTIONS.md");
fs::write(
root.join(".claude").join("settings.json"),
root.join(".claw").join("settings.json"),
r#"{"permissionMode":"acceptEdits"}"#,
)
.expect("write settings");
@@ -731,7 +731,7 @@ mod tests {
assert!(prompt.contains("# System"));
assert!(prompt.contains("# Project context"));
assert!(prompt.contains("# Claude instructions"));
assert!(prompt.contains("# Project instructions"));
assert!(prompt.contains("Project rules"));
assert!(prompt.contains("permissionMode"));
assert!(prompt.contains(SYSTEM_PROMPT_DYNAMIC_BOUNDARY));
@@ -751,9 +751,9 @@ mod tests {
fn discovers_dot_claude_instructions_markdown() {
let root = temp_dir();
let nested = root.join("apps").join("api");
fs::create_dir_all(nested.join(".claude")).expect("nested claude dir");
fs::create_dir_all(nested.join(".claw")).expect("nested claude dir");
fs::write(
nested.join(".claude").join("instructions.md"),
nested.join(".claw").join("instructions.md"),
"instruction markdown",
)
.expect("write instructions.md");
@@ -762,7 +762,10 @@ mod tests {
assert!(context
.instruction_files
.iter()
.any(|file| file.path.ends_with(".claude/instructions.md")));
.any(|file| {
let p = file.path.to_string_lossy().to_lowercase();
p.ends_with(".claw/instructions.md")
}));
assert!(
render_instruction_files(&context.instruction_files).contains("instruction markdown")
);
@@ -773,10 +776,10 @@ mod tests {
#[test]
fn renders_instruction_file_metadata() {
let rendered = render_instruction_files(&[ContextFile {
path: PathBuf::from("/tmp/project/CLAUDE.md"),
path: PathBuf::from("/tmp/project/INSTRUCTIONS.md"),
content: "Project rules".to_string(),
}]);
assert!(rendered.contains("# Claude instructions"));
assert!(rendered.contains("# Project instructions"));
assert!(rendered.contains("scope: /tmp/project"));
assert!(rendered.contains("Project rules"));
}