chore: rustfmt, clippy lints and code tidying
This commit is contained in:
1 parent
3716c3e698
commit
1752753fcc
19 files changed
+1273
-738
No files matched your search
+29
-14
@@ -3,53 +3,68 @@ use std::collections::HashSet;
|
||||
#[test]
|
||||
fn test_eager_tools_parity() {
|
||||
// 1. Read handlers.rs to get memory tools
|
||||
let memory_source = std::fs::read_to_string("src/handlers.rs").expect("Failed to read handlers.rs");
|
||||
let memory_source =
|
||||
std::fs::read_to_string("src/handlers.rs").expect("Failed to read handlers.rs");
|
||||
let mut memory_tools = HashSet::new();
|
||||
for line in memory_source.lines() {
|
||||
if line.contains("crate::mcp::tool_def") {
|
||||
if let Some(start) = line.find("(\"") {
|
||||
if line.contains("crate::mcp::tool_def")
|
||||
&& let Some(start) = line.find("(\"") {
|
||||
let rest = &line[start + 2..];
|
||||
if let Some(end) = rest.find("\"") {
|
||||
memory_tools.insert(rest[..end].to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(!memory_tools.is_empty(), "Could not find memory tools in handlers.rs");
|
||||
assert!(
|
||||
!memory_tools.is_empty(),
|
||||
"Could not find memory tools in handlers.rs"
|
||||
);
|
||||
|
||||
// 2. Read nvim-core/src/lib.rs to get nvim tools
|
||||
let nvim_source = std::fs::read_to_string("../nvim-core/src/lib.rs").expect("Failed to read nvim lib.rs");
|
||||
let nvim_source =
|
||||
std::fs::read_to_string("../nvim-core/src/lib.rs").expect("Failed to read nvim lib.rs");
|
||||
let mut nvim_tools = HashSet::new();
|
||||
for line in nvim_source.lines() {
|
||||
if line.contains("\"name\": \"nvim_") {
|
||||
if let Some(start) = line.find("\"name\": \"") {
|
||||
if line.contains("\"name\": \"nvim_")
|
||||
&& let Some(start) = line.find("\"name\": \"") {
|
||||
let rest = &line[start + 9..];
|
||||
if let Some(end) = rest.find("\"") {
|
||||
nvim_tools.insert(rest[..end].to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(!nvim_tools.is_empty(), "Could not find nvim tools in lib.rs");
|
||||
assert!(
|
||||
!nvim_tools.is_empty(),
|
||||
"Could not find nvim tools in lib.rs"
|
||||
);
|
||||
|
||||
// 3. Read Windows mcp_config.json
|
||||
let win_home = std::env::var("USERPROFILE").unwrap_or_else(|_| "C:\\Users\\reazul.ashraf".to_string());
|
||||
let win_home =
|
||||
std::env::var("USERPROFILE").unwrap_or_else(|_| "C:\\Users\\reazul.ashraf".to_string());
|
||||
let win_config_path = std::path::PathBuf::from(win_home).join(".gemini/config/mcp_config.json");
|
||||
if win_config_path.exists() {
|
||||
let config_str = std::fs::read_to_string(&win_config_path).unwrap();
|
||||
let config: serde_json::Value = serde_json::from_str(&config_str).unwrap();
|
||||
|
||||
|
||||
if let Some(eager) = config["mcpServers"]["memory"]["eagerTools"].as_array() {
|
||||
for tool in eager {
|
||||
let name = tool.as_str().unwrap();
|
||||
assert!(memory_tools.contains(name), "Windows config Memory tool '{}' not implemented in handlers.rs!", name);
|
||||
assert!(
|
||||
memory_tools.contains(name),
|
||||
"Windows config Memory tool '{}' not implemented in handlers.rs!",
|
||||
name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(nvim_eager) = config["mcpServers"]["win-nvim"]["eagerTools"].as_array() {
|
||||
for tool in nvim_eager {
|
||||
let name = tool.as_str().unwrap();
|
||||
assert!(nvim_tools.contains(name), "Windows config Nvim tool '{}' not implemented in nvim-core!", name);
|
||||
assert!(
|
||||
nvim_tools.contains(name),
|
||||
"Windows config Nvim tool '{}' not implemented in nvim-core!",
|
||||
name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user