From 9ee50b3af54782c47d22fd7e015e003db7cab704 Mon Sep 17 00:00:00 2001 From: Mitch Clay Date: Tue, 21 Oct 2025 15:29:37 -0500 Subject: [PATCH] Fix knowledge migration moving agent directories Fixes #3148 The migrate_legacy_knowledge_base function was incorrectly moving other agent directories into the current agent's directory when running /knowledge show. This happened because the migration logic didn't distinguish between files and directories. Now only files are migrated from the knowledge_bases root, leaving other agent directories untouched. --- crates/chat-cli/src/util/knowledge_store.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/chat-cli/src/util/knowledge_store.rs b/crates/chat-cli/src/util/knowledge_store.rs index 2dfcecf446..6e2804f4ac 100644 --- a/crates/chat-cli/src/util/knowledge_store.rs +++ b/crates/chat-cli/src/util/knowledge_store.rs @@ -169,9 +169,14 @@ impl KnowledgeStore { let files_to_migrate: Vec<_> = entries .flatten() .filter(|entry| { + let path = entry.path(); let name = entry.file_name(); let name_str = name.to_string_lossy(); - name_str != current_agent_id && name_str != DEFAULT_AGENT_NAME && !name_str.starts_with('.') + // Only migrate FILES, not directories (to avoid moving other agent directories) + path.is_file() + && name_str != current_agent_id + && name_str != DEFAULT_AGENT_NAME + && !name_str.starts_with('.') }) .collect();