mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 06:32:00 +00:00
fix(memory-qmd): restore qmd compatibility defaults
This commit is contained in:
@@ -40,6 +40,18 @@ complete`,
|
||||
]);
|
||||
});
|
||||
|
||||
it("maps single-line qmd line metadata onto both line bounds", () => {
|
||||
const results = parseQmdQueryJson('[{"docid":"abc","score":0.5,"line":9}]', "");
|
||||
expect(results).toEqual([
|
||||
{
|
||||
docid: "abc",
|
||||
score: 0.5,
|
||||
startLine: 9,
|
||||
endLine: 9,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("treats plain-text no-results from stderr as an empty result set", () => {
|
||||
const results = parseQmdQueryJson("", "No results found\n");
|
||||
expect(results).toEqual([]);
|
||||
|
||||
@@ -89,6 +89,9 @@ function parseQmdQueryResultArray(raw: string): QmdQueryResult[] | null {
|
||||
const file = typeof record.file === "string" ? record.file : undefined;
|
||||
const snippet = typeof record.snippet === "string" ? record.snippet : undefined;
|
||||
const body = typeof record.body === "string" ? record.body : undefined;
|
||||
const line = parseQmdLineNumber(record.line);
|
||||
const startLine = parseQmdLineNumber(record.start_line ?? record.startLine) ?? line;
|
||||
const endLine = parseQmdLineNumber(record.end_line ?? record.endLine) ?? line;
|
||||
return {
|
||||
docid,
|
||||
score,
|
||||
@@ -96,8 +99,8 @@ function parseQmdQueryResultArray(raw: string): QmdQueryResult[] | null {
|
||||
file,
|
||||
snippet,
|
||||
body,
|
||||
startLine: parseQmdLineNumber(record.start_line ?? record.startLine),
|
||||
endLine: parseQmdLineNumber(record.end_line ?? record.endLine),
|
||||
startLine,
|
||||
endLine,
|
||||
} as QmdQueryResult;
|
||||
});
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user