Skip to content

TypeScript API

Jean-Baptiste THERY edited this page Jul 13, 2026 · 3 revisions

TypeScript API

import { ingest, search } from "@jcode.labs/ragmir"

await ingest({ cwd: process.cwd() })
const results = await search("Which decision changed the rollout?", {
  topK: 5,
  explain: true,
})

All paths resolve from cwd or the current working directory. Results include relativePath, citation, chunkIndex, text, line ranges, and page ranges when available.

Project and sources

Export Use
setupProject Initialize sources, helpers, and optional semantic retrieval
loadConfig Resolve and validate effective configuration
discoverKnowledgeBases List root and nested bases and mark the active one
getKnowledgeBaseContext Return bounded identity, readiness, freshness, and capabilities
addSourceEntries Add source paths or exclusions

Retrieve and evaluate

Export Use
ingest Parse, redact, chunk, embed, and store files
previewChunks Inspect redacted chunks without writing an index
search Return ranked cited passages
ask Return cited context without calling an LLM
research Run audit-backed multi-query retrieval
expandCitation Expand one indexed chunk with bounded neighbors
evaluateGoldenQueries Score retrieval against local expected evidence

SearchOptions supports topK, contextRadius, path filters, structural context filters, and explanations. Citation expansion is clamped to a three-chunk neighbor radius.

Operations and integrations

Core also exports doctor, securityAudit, routePrompt, serveMcp, agent-skill installation helpers, semantic model setup, and local OCR configuration. MCP retrieval tools accept a maxBytes request below the configured mcpMaxOutputBytes ceiling.

New command integrations should use rgrCommand. kbCommand and ragmirCommand remain compatibility helpers.

Canonical source: docs/api-reference.md.

Clone this wiki locally