fix(memory): improved glob matching for **/*.ext patterns
This commit is contained in:
parent
61c0cc0a87
commit
5daa4b0b62
@ -692,7 +692,12 @@ export class QmdMemoryManager implements MemorySearchManager {
|
||||
);
|
||||
try {
|
||||
if (collectionNames.length > 1) {
|
||||
return await this.runQueryAcrossCollections(trimmed, fetchLimit, collectionNames, "query");
|
||||
return await this.runQueryAcrossCollections(
|
||||
trimmed,
|
||||
fetchLimit,
|
||||
collectionNames,
|
||||
"query",
|
||||
);
|
||||
}
|
||||
const fallbackArgs = this.buildSearchArgs("query", trimmed, fetchLimit);
|
||||
fallbackArgs.push(...this.buildCollectionFilterArgs(collectionNames));
|
||||
@ -768,11 +773,25 @@ export class QmdMemoryManager implements MemorySearchManager {
|
||||
|
||||
private matchesPath(target: string, pattern: string): boolean {
|
||||
// Simple glob matching
|
||||
if (pattern === "**") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle "dir/**"
|
||||
if (pattern.endsWith("/**")) {
|
||||
const prefix = pattern.slice(0, -3);
|
||||
return target.startsWith(prefix + "/") || target === prefix;
|
||||
}
|
||||
|
||||
// Handle "**/*.md" or "**/foo"
|
||||
if (pattern.startsWith("**/")) {
|
||||
const rest = pattern.slice(3);
|
||||
if (rest.startsWith("*")) {
|
||||
return target.endsWith(rest.slice(1));
|
||||
}
|
||||
return target.endsWith("/" + rest) || target === rest;
|
||||
}
|
||||
|
||||
// Handle "*.md"
|
||||
if (pattern.startsWith("*")) {
|
||||
return target.endsWith(pattern.slice(1));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user