Skip to content

feat: improve libscope as a knowledge base for AI agents - #544

Merged
RobertLD merged 3 commits into
mainfrom
feat/agent-knowledge-base
Nov 30, 2026
Merged

RobertLD merged 3 commits into
mainfrom
feat/agent-knowledge-base

Conversation

@RobertLD

Copy link
Copy Markdown
Owner

What

  • Document lifecycle: documents have a status (current, superseded, wrong) and a verified date, set with the new mark-document operation. Re-indexing a file, URL, watched folder or Obsidian note keeps the lifecycle.
  • doctor: reports documents whose local source file is missing.
  • PDF structure: chunks follow the PDF structure and keep page numbers and outline headings. Search results carry a citation.
  • Reranker: an optional local cross-encoder reranker, off by default.
  • Relevance: each result has a relevance score, and the response has a no-good-match signal. Superseded documents rank lower. Wrong documents are left out unless documentStatus: "any".
  • New operations: grep within a document, and libscope eval, which reports recall@k and MRR from a file of queries.
  • MCP: search results are shorter by default. REST and SDK results keep every existing field and add the new ones.

Schema version 22 (migrations 21 and 22).

Behaviour change

Title matching is no longer stemmed, so "timeout" does not match the title "Timeouts". Content matching is still stemmed.

Known limitations

  • A Confluence, Notion or OneNote sync that replaces a changed page does not keep the lifecycle. This is documented in docs/guide/document-lifecycle.md.
  • ask has no status or rerank options.
  • The Python and Go SDKs do not have the new fields or routes.
  • When restoring from a backup, pack_name is not restored, because backups do not include the packs table. After a restore, doctor can report pack documents with absolute source paths as missing.
  • A heading followed by a large paragraph can still produce a chunk that holds only the heading. This also happens on main.

Checks

format:check, lint (0 errors), typecheck, test:coverage (2683 tests, 93.4% statements), build and docs:check pass locally on Node 20.

- Document status (current, superseded, wrong) and verified date, set with
  the mark-document operation and kept across re-indexing.
- doctor reports documents whose local source file is missing.
- PDF chunks follow the document structure and keep page numbers and outline
  headings; search results carry a citation.
- Optional local cross-encoder reranker (off by default).
- Relevance score on each result and a no-good-match signal; superseded
  documents rank lower and wrong ones are excluded.
- grep operation within a document.
- libscope eval reports recall@k and MRR from a file of queries.
- Shorter MCP search results by default.

Title matching is no longer stemmed; content matching still is.
- A superseded hit with a negative vector score now moves down instead of up.
- With a reranker, the candidate pool holds at least rerankTopN hits, so the
  reranked order does not depend on the page size.
- Case-insensitive literal grep matches Greek sigma in every form.
- The folder watcher records PDF page numbers, as libscope add does.
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
libscope Ignored Ignored Preview Nov 30, 2026 7:09pm UTC

Comment thread tests/unit/grep.test.ts Dismissed
- Reduce the cognitive complexity of searchDocuments, getRelatedChunks,
  importFromBackup and chunkContentDetailed with small helpers.
- Give pageConfidence's reduce an initial value; remove nested template literals.
- One supersede-chain walker, one document status label, one keyword-index
  query for relevance and snippets (prepared once per page).
- One loader for local ONNX models; doctor checks every model file.
- Shared escapeRegExp, markdown table rows, CLI ranking flags and rerank schema.
- Resolve PDF outline pages together and compute heading keys once.
- Move duplicated test helpers into tests/fixtures.
@sonarqubecloud

Copy link
Copy Markdown

@RobertLD
RobertLD merged commit e8a13eb into main Nov 30, 2026
10 checks passed
@RobertLD
RobertLD deleted the feat/agent-knowledge-base branch November 30, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants