MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / handle_remove

Method handle_remove

crates/chat-cli/src/cli/chat/cli/knowledge.rs:315–341  ·  view source on GitHub ↗

Handle remove operation

(os: &Os, session: &ChatSession, path: &str)

Source from the content-addressed store, hash-verified

313
314 /// Handle remove operation
315 async fn handle_remove(os: &Os, session: &ChatSession, path: &str) -> OperationResult {
316 let sanitized_path = sanitize_path_tool_arg(os, path);
317 let agent = Self::get_agent(session);
318
319 let async_knowledge_store = match KnowledgeStore::get_async_instance(os, agent).await {
320 Ok(store) => store,
321 Err(e) => return OperationResult::Error(format!("Error accessing knowledge base: {}", e)),
322 };
323 let mut store = async_knowledge_store.lock().await;
324
325 let scope_desc = "agent";
326
327 // Try path first, then name
328 if store.remove_by_path(&sanitized_path.to_string_lossy()).await.is_ok() {
329 OperationResult::Success(format!(
330 "Removed {} knowledge base entry with path '{}'",
331 scope_desc, path
332 ))
333 } else if store.remove_by_name(path).await.is_ok() {
334 OperationResult::Success(format!(
335 "Removed {} knowledge base entry with name '{}'",
336 scope_desc, path
337 ))
338 } else {
339 OperationResult::Warning(format!("Entry not found in {} knowledge base: {}", scope_desc, path))
340 }
341 }
342
343 /// Handle update operation
344 async fn handle_update(os: &Os, session: &ChatSession, path: &str) -> OperationResult {

Callers

nothing calls this directly

Calls 4

sanitize_path_tool_argFunction · 0.85
remove_by_pathMethod · 0.80
remove_by_nameMethod · 0.80
ErrorEnum · 0.50

Tested by

no test coverage detected