refactor: apply zero-unwrap policy and optimize locks in store.rs and handlers
This commit is contained in:
1 parent
9f24e66d88
commit
8afbf97b11
33 files changed
+3127
-3207
No files matched your search
+21
-15
@@ -2,22 +2,27 @@ 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");
|
||||
// 1. Read handlers_v2/*.rs to get memory tools
|
||||
let mut memory_tools = HashSet::new();
|
||||
let parts: Vec<&str> = memory_source.split("crate::mcp::tool_def").collect();
|
||||
for part in parts.iter().skip(1) {
|
||||
if let Some(start) = part.find("\"") {
|
||||
let rest = &part[start + 1..];
|
||||
if let Some(end) = rest.find("\"") {
|
||||
memory_tools.insert(rest[..end].to_string());
|
||||
let entries = std::fs::read_dir("src/handlers_v2").expect("Failed to read handlers_v2 dir");
|
||||
for entry in entries {
|
||||
let entry = entry.unwrap();
|
||||
if entry.path().extension().unwrap_or_default() == "rs" {
|
||||
let memory_source = std::fs::read_to_string(entry.path()).unwrap();
|
||||
let parts: Vec<&str> = memory_source.split("crate::mcp::tool_def").collect();
|
||||
for part in parts.iter().skip(1) {
|
||||
if let Some(start) = part.find("\"") {
|
||||
let rest = &part[start + 1..];
|
||||
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"
|
||||
"Could not find memory tools in handlers_v2 directory"
|
||||
);
|
||||
|
||||
// 2. Read nvim-core/src/lib.rs to get nvim tools
|
||||
@@ -26,12 +31,13 @@ fn test_eager_tools_parity() {
|
||||
let mut nvim_tools = HashSet::new();
|
||||
for line in nvim_source.lines() {
|
||||
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());
|
||||
}
|
||||
&& 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(),
|
||||
|
||||
Reference in new issue
Block a user