chore(gate): fix lint and formatting

This commit is contained in:
Peter Steinberger
2026-01-18 06:01:09 +00:00
parent d1c85cb32d
commit d4bd387e0e
15 changed files with 244 additions and 231 deletions

View File

@@ -4,8 +4,8 @@ import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"
describe("memory hybrid helpers", () => {
it("buildFtsQuery tokenizes and AND-joins", () => {
expect(buildFtsQuery("hello world")).toBe("\"hello\" AND \"world\"");
expect(buildFtsQuery("FOO_bar baz-1")).toBe("\"FOO_bar\" AND \"baz\" AND \"1\"");
expect(buildFtsQuery("hello world")).toBe('"hello" AND "world"');
expect(buildFtsQuery("FOO_bar baz-1")).toBe('"FOO_bar" AND "baz" AND "1"');
expect(buildFtsQuery(" ")).toBeNull();
});
@@ -84,4 +84,3 @@ describe("memory hybrid helpers", () => {
expect(merged[0]?.score).toBeCloseTo(0.5 * 0.2 + 0.5 * 1.0);
});
});

View File

@@ -21,9 +21,13 @@ export type HybridKeywordResult = {
};
export function buildFtsQuery(raw: string): string | null {
const tokens = raw.match(/[A-Za-z0-9_]+/g)?.map((t) => t.trim()).filter(Boolean) ?? [];
const tokens =
raw
.match(/[A-Za-z0-9_]+/g)
?.map((t) => t.trim())
.filter(Boolean) ?? [];
if (tokens.length === 0) return null;
const quoted = tokens.map((t) => `"${t.replaceAll("\"", "")}"`);
const quoted = tokens.map((t) => `"${t.replaceAll('"', "")}"`);
return quoted.join(" AND ");
}
@@ -105,4 +109,3 @@ export function mergeHybridResults(params: {
return merged.sort((a, b) => b.score - a.score);
}

View File

@@ -236,7 +236,12 @@ describe("memory index", () => {
query: {
minScore: 0,
maxResults: 200,
hybrid: { enabled: true, vectorWeight: 0.99, textWeight: 0.01, candidateMultiplier: 10 },
hybrid: {
enabled: true,
vectorWeight: 0.99,
textWeight: 0.01,
candidateMultiplier: 10,
},
},
},
},
@@ -284,7 +289,12 @@ describe("memory index", () => {
query: {
minScore: 0,
maxResults: 200,
hybrid: { enabled: true, vectorWeight: 0.01, textWeight: 0.99, candidateMultiplier: 10 },
hybrid: {
enabled: true,
vectorWeight: 0.01,
textWeight: 0.99,
candidateMultiplier: 10,
},
},
},
},

View File

@@ -3,7 +3,8 @@ import type { DatabaseSync } from "node:sqlite";
import { truncateUtf16Safe } from "../utils.js";
import { cosineSimilarity, parseEmbedding } from "./internal.js";
const vectorToBlob = (embedding: number[]): Buffer => Buffer.from(new Float32Array(embedding).buffer);
const vectorToBlob = (embedding: number[]): Buffer =>
Buffer.from(new Float32Array(embedding).buffer);
export type SearchSource = string;
@@ -47,9 +48,9 @@ export async function searchVector(params: {
...params.sourceFilterVec.params,
params.limit,
) as Array<{
id: string;
path: string;
start_line: number;
id: string;
path: string;
start_line: number;
end_line: number;
text: string;
source: SearchSource;

View File

@@ -92,4 +92,3 @@ function ensureColumn(
if (rows.some((row) => row.name === column)) return;
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
}

View File

@@ -156,7 +156,10 @@ async function readOpenAiBatchError(params: {
errorFileId: string;
}): Promise<string | undefined> {
try {
const content = await fetchOpenAiFileContent({ openAi: params.openAi, fileId: params.errorFileId });
const content = await fetchOpenAiFileContent({
openAi: params.openAi,
fileId: params.errorFileId,
});
const lines = parseOpenAiBatchOutput(content);
const first = lines.find((line) => line.error?.message || line.response?.body?.error);
const message =
@@ -357,4 +360,3 @@ export async function runOpenAiEmbeddingBatches(params: {
await runWithConcurrency(tasks, params.concurrency);
return byCustomId;
}

View File

@@ -22,4 +22,3 @@ export async function loadSqliteVecExtension(params: {
return { ok: false, error: message };
}
}