Skip to content

Commit e1a1981

Browse files
authored
Fix knowledge migration moving agent directories (#3225)
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.
1 parent 920a36d commit e1a1981

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/chat-cli/src/util/knowledge_store.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,14 @@ impl KnowledgeStore {
169169
let files_to_migrate: Vec<_> = entries
170170
.flatten()
171171
.filter(|entry| {
172+
let path = entry.path();
172173
let name = entry.file_name();
173174
let name_str = name.to_string_lossy();
174-
name_str != current_agent_id && name_str != DEFAULT_AGENT_NAME && !name_str.starts_with('.')
175+
// Only migrate FILES, not directories (to avoid moving other agent directories)
176+
path.is_file()
177+
&& name_str != current_agent_id
178+
&& name_str != DEFAULT_AGENT_NAME
179+
&& !name_str.starts_with('.')
175180
})
176181
.collect();
177182

0 commit comments

Comments
 (0)