Memory/QMD: add limit arg to search command

This commit is contained in:
Vignesh Natarajan
2026-02-14 14:56:57 -08:00
parent 19df928e7f
commit 62aae7f69d
3 changed files with 27 additions and 4 deletions

View File

@@ -340,7 +340,15 @@ describe("QmdMemoryManager", () => {
).resolves.toEqual([]);
const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search");
expect(searchCall?.[1]).toEqual(["search", "test", "--json", "-c", "workspace"]);
expect(searchCall?.[1]).toEqual([
"search",
"test",
"--json",
"-n",
String(resolved.qmd?.limits.maxResults),
"-c",
"workspace",
]);
expect(spawnMock.mock.calls.some((call) => call[1]?.[0] === "query")).toBe(false);
expect(maxResults).toBeGreaterThan(0);
await manager.close();
@@ -394,7 +402,7 @@ describe("QmdMemoryManager", () => {
(args): args is string[] => Array.isArray(args) && ["search", "query"].includes(args[0]),
);
expect(searchAndQueryCalls).toEqual([
["search", "test", "--json", "-c", "workspace"],
["search", "test", "--json", "-n", String(maxResults), "-c", "workspace"],
["query", "test", "--json", "-n", String(maxResults), "-c", "workspace"],
]);
await manager.close();
@@ -558,7 +566,21 @@ describe("QmdMemoryManager", () => {
await manager.search("test", { sessionKey: "agent:main:slack:dm:u123" });
const searchCall = spawnMock.mock.calls.find((call) => call[1]?.[0] === "search");
expect(searchCall?.[1]).toEqual(["search", "test", "--json", "-c", "workspace", "-c", "notes"]);
const maxResults = resolved.qmd?.limits.maxResults;
if (!maxResults) {
throw new Error("qmd maxResults missing");
}
expect(searchCall?.[1]).toEqual([
"search",
"test",
"--json",
"-n",
String(maxResults),
"-c",
"workspace",
"-c",
"notes",
]);
await manager.close();
});

View File

@@ -972,7 +972,7 @@ export class QmdMemoryManager implements MemorySearchManager {
if (command === "query") {
return ["query", query, "--json", "-n", String(limit)];
}
return [command, query, "--json"];
return [command, query, "--json", "-n", String(limit)];
}
}