From 5daa4b0b626e4eb1d5accedb1f7ee7afb07e4671 Mon Sep 17 00:00:00 2001 From: Frad LEE Date: Thu, 19 Feb 2026 01:19:13 +0800 Subject: [PATCH] fix(memory): improved glob matching for **/*.ext patterns --- src/memory/qmd-manager.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/memory/qmd-manager.ts b/src/memory/qmd-manager.ts index f19177a7e39..700bbe7bc10 100644 --- a/src/memory/qmd-manager.ts +++ b/src/memory/qmd-manager.ts @@ -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));