feat(wikis): search page body text with fuzzy relevance ranking

Retain the page body from the formattable text field (already fetched
per-page, zero extra API calls) and rank title/text matches with
rankRecords instead of exact substring on title alone. searchWikiPages
now returns WikiPageSearchResult[] with score, snippet, and
matchedFields; empty-query behavior (project scoping + limit, no
ranking) is preserved. Adds a matchMode tool parameter defaulting to
fuzzy.

Updates the pre-existing tool-metadata assertion in tests/tools.test.ts
to match the new search_wiki_pages description introduced here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5 committed 2026-09-18 07:48:29 +02:00
1 parent 2d44a229e0
commit 9dee458b1f
4 files changed
+137 -22

No files matched your search

+15 -2
View File
@@ -46,7 +46,10 @@ export const searchWikiPagesShape = {
query: z
.string()
.optional()
.describe("Substring keyword to match in wiki page title"),
.describe(
"Search keywords matched against wiki page titles and page body text. " +
"Natural-language phrasing works."
),
projectId: z
.union([z.number().int().positive(), z.string().min(1)])
.optional()
@@ -64,6 +67,14 @@ export const searchWikiPagesShape = {
.optional()
.default(false)
.describe("Force cache refresh"),
matchMode: z
.enum(["fuzzy", "exact"])
.optional()
.default("fuzzy")
.describe(
"Matching strategy. 'fuzzy' (default) tolerates typos, word reordering, and " +
"partial words. Use 'exact' only for literal strings you know verbatim."
),
};
export type SearchWikiPagesArgs = z.input<z.ZodObject<typeof searchWikiPagesShape>>;
@@ -140,7 +151,9 @@ export const searchWikiPagesTool: ToolDefinition<
SearchWikiPagesArgs
> = {
name: "openproject_search_wiki_pages",
description: "Discover and search wiki pages matching keywords or project.",
description:
"Search wiki pages by title and page content. Accepts natural-language " +
"phrasing and tolerates typos. Returns results ranked by relevance.",
parameters: searchWikiPagesShape,
readOnly: true,
execute: handleSearchWikiPages,