refactor: apply 5-pass audit optimizations across mcp-memory codebase
This commit is contained in:
1 parent
924b6d09fa
commit
5bd8b1587a
43 files changed
+1866
-1658
No files matched your search
@@ -15,7 +15,7 @@ impl McpTool for PinFileHandler {
|
||||
}
|
||||
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<PinFileTool>("pin_file", "Execute pin_file")
|
||||
crate::mcp::tool_def::<PinFileTool>("pin_file", "Pin a file path in the workspace context to prioritize it across subagent turns.")
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
@@ -42,7 +42,7 @@ impl McpTool for UnpinFileHandler {
|
||||
}
|
||||
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<UnpinFileTool>("unpin_file", "Execute unpin_file")
|
||||
crate::mcp::tool_def::<UnpinFileTool>("unpin_file", "Unpin a file path from the workspace context.")
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
@@ -65,7 +65,7 @@ impl McpTool for ListPinnedFilesHandler {
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<ListPinnedFilesTool>(
|
||||
"list_pinned_files",
|
||||
"Execute list_pinned_files",
|
||||
"List active pinned files in the workspace context, optionally filtered by namespace or branch.",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ impl McpTool for StoreSnippetHandler {
|
||||
}
|
||||
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<StoreSnippetTool>("store_snippet", "Execute store_snippet")
|
||||
crate::mcp::tool_def::<StoreSnippetTool>("store_snippet", "Store or replace a reusable code snippet with vector embedding and search tags.")
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
@@ -127,7 +127,7 @@ impl McpTool for StoreSnippetHandler {
|
||||
embedding,
|
||||
};
|
||||
|
||||
let idx = state.get_search_index();
|
||||
let idx = state.get_search_index().await;
|
||||
drop(idx.index_snippet(&snippet));
|
||||
|
||||
state.code.snippets.modify(|snippets| {
|
||||
@@ -148,7 +148,7 @@ impl McpTool for TagSnippetHandler {
|
||||
}
|
||||
|
||||
fn schema(&self) -> Value {
|
||||
crate::mcp::tool_def::<TagSnippetTool>("tag_snippet", "Execute tag_snippet")
|
||||
crate::mcp::tool_def::<TagSnippetTool>("tag_snippet", "Add organizational tags to an existing stored code snippet.")
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> crate::error::Result<String> {
|
||||
@@ -254,7 +254,7 @@ impl McpTool for DeleteSnippetHandler {
|
||||
deleted = snippets.len() < orig;
|
||||
});
|
||||
if deleted {
|
||||
let idx = state.get_search_index();
|
||||
let idx = state.get_search_index().await;
|
||||
drop(idx.delete_document(&req.name));
|
||||
Ok("Snippet deleted.".to_string())
|
||||
} else {
|
||||
@@ -870,6 +870,9 @@ impl McpTool for ReadDirectoryArchitectureHandler {
|
||||
summary: &mut String,
|
||||
depth: usize,
|
||||
) -> std::io::Result<()> {
|
||||
if depth > 10 {
|
||||
return Ok(());
|
||||
}
|
||||
if dir.is_dir() {
|
||||
let mut entries =
|
||||
fs::read_dir(dir)?.collect::<Result<Vec<_>, std::io::Error>>()?;
|
||||
|
||||
Reference in new issue
Block a user