This commit is contained in:
2026-05-13 12:05:55 +03:00
parent c5b61ee3d8
commit 674c3cbd44
43 changed files with 382 additions and 639 deletions
+6 -1
View File
@@ -3,6 +3,9 @@ import path from "node:path";
import {readdir, readFile} from "node:fs/promises";
import {notesDir, notesRootFile} from "../../index";
import {asNonEmptyString} from "./utils";
import {toolsLogger} from "./tool-logger";
const logger = toolsLogger.child("search-notes");
export type SearchNoteMatchedField = "file_name" | "title" | "content";
@@ -51,7 +54,8 @@ export const searchNotesTool = {
export async function searchNotes(
args?: Record<string, unknown>,
): Promise<SearchNotesResult> {
console.log("SEARCH_NOTES; ARGS: ", args);
const startedAt = Date.now();
logger.debug("start", {args});
const query = asNonEmptyString(args?.query) ?? "";
if (!query.trim().length) {
@@ -127,6 +131,7 @@ export async function searchNotes(
.sort((a, b) => b.score - a.score)
.slice(0, limit);
logger.debug("done", {query, limit, results: results.length, duration: logger.duration(startedAt)});
return {success: true, results};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);