Query interface

From the RepoWiki wiki

Query interface
Also known as WikiView, ToolSet, SearchIndex, pageSearchIndex, wiki-tools
Files 15
Lines of code 2,050
Languages TypeScript
Entry points packages/query/src/index.ts
First commit 4 October 2026
Last commit 8 October 2026
Main contributors Sean May (100%)
Revision 5b50749

Query interface is the subsystem of RepoWiki that searches wiki pages and reads their content as plain text for agents to process. It exposes two tools: search(query) ranks pages by title, aliases, lead and body using BM25F, and read_page(id) returns a page with its claims, references and history formatted as text.

Overview

The query interface allows external systems such as language models to search for and retrieve wiki pages without network access or side effects.[1] It consists of a search index that ranks documents, a page reader that formats wiki articles, and a tool set that wraps both for agent use.[1][2]

How it works

The searchIndex() function in search.ts builds a BM25F ranking over documents with configurable field boosts: title (3), aliases (2), lead (1.5) and body (1).[3][4] The terms() function normalizes search text by splitting camelCase and snake_case, removing accents and stop words, cutting plural suffixes, and lowercasing, so "Signals" and "signal" both match.[5]

The WikiView class in wiki-view.ts holds a wiki export's features and pages, resolves page ids through redirects and disambiguation aliases, and transforms claim text to replace wiki links with readable page references for agents.[6][7][8] The readPage() function in wiki-page.ts renders a feature page with its status, infobox, sections, numbered references, See also list and revision history, fitting the output under a 12,000-character limit by dropping oldest history entries first, then the See also list.[2][9]

The createWikiTools() function in wiki-tools.ts assembles search and read_page tools with JSON schema validation and result formatting, returning a LocalToolSet that agents can call synchronously.[1]

Data flow

flowchart LR
  n4["packages/query/src/search.ts"]
  n8["packages/query/src/text.ts"]
  n9["packages/query/src/tools.ts"]
  n11["packages/query/src/wiki-page.ts"]
  n13["packages/query/src/wiki-tools.ts"]
  n15["packages/query/src/wiki-view.ts"]
  n16[["Core data model"]]
  n11 -->|"formats text"| n8
  n11 -->|"resolves links"| n15
  n13 -->|"indexes documents"| n4
  n13 -->|"formats results"| n11
  n13 -->|"builds view"| n15
  n15 -->|"reads wiki data"| n16
Data flow of Query interface

A wiki export with features, pages, architecture and history enters createWikiTools(), which indexes pages as search documents keyed by title, aliases, lead and body text.[1][2] When an agent calls search() with a query string, terms() normalizes it, the search index ranks matching pages by BM25F score, and the results are formatted as an id, title and first sentence per page.[10][11] When an agent calls read_page() with a page id, WikiView.resolve() follows redirects and finds the target feature, readPage() renders it with all sections, references and history, and toolText() sanitizes the output by replacing control characters and bidi controls with U+FFFD.[7][2][12]

History

  • The query interface was extracted into its own package on 10 October 2026, splitting from the evaluation framework to become a reusable tool for agents.[13]
  • Search result ranking with BM25F scores was added on 6 October 2026 to give agents visibility into match quality.[14]
  • Page links validation, claim text unmarking and page fitting were hardened between 4 and 5 October 2026 to prevent agents from being misled by crafted wiki content.[15][16][17]

See also

References

  1. ^ a b c d packages/query/src/wiki-tools.ts:L77-81@5b50749
  2. ^ a b c d packages/query/src/wiki-page.ts:L112-146@5b50749 (renderFeaturePage)
  3. ^ packages/query/src/search.ts:L55-64@5b50749
  4. ^ packages/query/src/search.ts:L37-40@5b50749
  5. ^ packages/query/src/search.ts:L8-27@5b50749
  6. ^ packages/query/src/wiki-view.ts:L55-80@5b50749 (WikiView)
  7. ^ a b packages/query/src/wiki-view.ts:L144-182@5b50749 (WikiView)
  8. ^ packages/query/src/wiki-view.ts:L104-128@5b50749 (WikiView)
  9. ^ packages/query/src/wiki-page.ts:L80-110@5b50749 (fitPage)
  10. ^ packages/query/src/search.ts:L12-27@5b50749 (terms)
  11. ^ packages/query/src/search.ts:L60-117@5b50749
  12. ^ packages/query/src/text.ts:L3-10@5b50749
  13. ^ Commit 7c9cbaa: "refactor(query): extract @repowiki/query from the eval" (PR #392)
  14. ^ Commit ea58c3b: "feat(query): rank page matches with their scores" (PR #502)
  15. ^ Commit 22b058e: "fix(query): neutralise fake reference and page marks in titles and aliases" (PR #431)
  16. ^ Commit 453db2f: "fix(query): harden page_changes and the boundary scan, and number a copied revision" (PR #431)
  17. ^ Commit 78ba174: "fix(query): unmark a claim line once and bound its references and limits" (PR #455)

This page was last edited on 8 October 2026, at commit 5b50749.