refactor: Enforce strict typed JsonSchema for all MCP tools
This commit is contained in:
1 parent
686fea683d
commit
2d3aaed289
31 files changed
+2892
-308
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import re
|
||||
|
||||
with open("server/src/search.rs", "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# Remove writer.commit() from index_*
|
||||
content = content.replace(" writer.commit()?;\n", "")
|
||||
|
||||
# Add pub fn commit
|
||||
commit_code = """
|
||||
pub fn commit(&self) -> tantivy::Result<()> {
|
||||
let mut writer = self.writer.lock().unwrap();
|
||||
writer.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
"""
|
||||
|
||||
content = content.replace(" pub fn search(&self, query_str: &str, limit: usize) -> tantivy::Result<Vec<SearchResult>> {", commit_code + "\n pub fn search(&self, query_str: &str, limit: usize) -> tantivy::Result<Vec<SearchResult>> {")
|
||||
|
||||
with open("server/src/search.rs", "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
with open("server/src/state.rs", "r", encoding="utf-8") as f:
|
||||
state_content = f.read()
|
||||
|
||||
# Call new_idx.commit() in rebuild_index before locking the main rwlock
|
||||
state_content = state_content.replace(""" if let Ok(mut w) = self.search_index.write() {
|
||||
*w = new_idx;
|
||||
}""", """ let _ = new_idx.commit();
|
||||
if let Ok(mut w) = self.search_index.write() {
|
||||
*w = new_idx;
|
||||
}""")
|
||||
|
||||
with open("server/src/state.rs", "w", encoding="utf-8") as f:
|
||||
f.write(state_content)
|
||||
|
||||
Reference in new issue
Block a user