Skip to content

Export query functions from programmatic API for library consumers #153

@jafreck

Description

@jafreck

Problem

The public API (src/index.ts) exports rich indexing primitives (IndexBuilder, pipeline stages, walker, embedder) but almost no query surface. A library consumer embedding Lore into an agent framework today can build an index but cannot query it for search, blame, history, coverage, docs, architecture, metrics, etc. without spinning up an MCP server via createLoreMcpServer().

Proposal

Export typed query functions from the main entry point that create a read-only DB, call the handler, and return typed results — no MCP server required:

import { query } from '@jafreck/lore';

const db = openReadOnly('lore.db');
const results = await query.search(db, { query: 'auth', mode: 'structural' });
const blame = await query.blame(db, { path: 'src/server.ts', mode: 'ownership' });

Each tool handler already takes (db, args) internally — this just exposes that cleanly.

Implementation notes

  • Add a src/query.ts barrel that re-exports each tool handler with a typed (db, args) → result signature.
  • Add a "./query" entry to the exports map in package.json.
  • Type exports for tool argument and return shapes.
  • No MCP dependency in the query path.

Acceptance criteria

  • @jafreck/lore/query export with typed functions for all query tools
  • Each function callable as (db, args) with no MCP server
  • Type exports for all tool input/output shapes
  • README documents programmatic query usage
  • At least one integration test exercising the programmatic query path without MCP

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions