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

Method update_by_path

crates/chat-cli/src/util/knowledge_store.rs:502–531  ·  view source on GitHub ↗

Update context by path

(&mut self, path_str: &str)

Source from the content-addressed store, hash-verified

500
501 /// Update context by path
502 pub async fn update_by_path(&mut self, path_str: &str) -> Result<String, String> {
503 if let Some(context) = self.agent_client.get_context_by_path(path_str).await {
504 // Remove the existing context first
505 self.agent_client
506 .remove_context_by_id(&context.id)
507 .await
508 .map_err(|e| e.to_string())?;
509
510 // Then add it back with the same name and original patterns (agent scope)
511 let options = AddOptions {
512 description: None,
513 include_patterns: context.include_patterns.clone(),
514 exclude_patterns: context.exclude_patterns.clone(),
515 embedding_type: None,
516 };
517 self.add(&context.name, path_str, options).await
518 } else {
519 // Debug: List all available contexts
520 let available_paths = self.agent_client.list_context_paths().await;
521 if available_paths.is_empty() {
522 Err("No contexts found. Add a context first with 'knowledge add <name> <path>'".to_string())
523 } else {
524 Err(format!(
525 "No context found with path '{}'\nAvailable contexts:\n{}",
526 path_str,
527 available_paths.join("\n")
528 ))
529 }
530 }
531 }
532
533 /// Update context by ID
534 pub async fn update_context_by_id(&mut self, context_id: &str, path_str: &str) -> Result<String, String> {

Callers 2

invokeMethod · 0.80
handle_updateMethod · 0.80

Calls 7

to_stringMethod · 0.80
get_context_by_pathMethod · 0.45
remove_context_by_idMethod · 0.45
cloneMethod · 0.45
addMethod · 0.45
list_context_pathsMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected