The MCP `query` tool, HTTP `/query` endpoint, and CLI `qmd query` all returned chunk-local line numbers in their snippet output, so the line could not be passed back to `qmd_get` as `fromLine` without an out-of-band lookup. Pass the full document body plus `bestChunkPos` to `extractSnippet` instead of the chunk text alone so it can compute absolute line offsets while still scoping the keyword scan to the reranker-chosen chunk window (preserves #149). Also restores documented behavior of `qmd query --full`, which was emitting the best chunk (~3.6KB max) instead of the full document. extractSnippet now also falls back to a full-body scan when given a chunkPos but the chunk window contains no positive matches. The upstream chunk selector leaves bestIdx=0 as its initialization default whenever scoring fails to find a winner (e.g. queryTerms filtered to empty by the length>2 guard, or semantic-only matches with no lex overlap), so an unconditional chunk-scoped scan would land on chunk 0 instead of where the actual match lives. - src/mcp/server.ts: SearchResultItem gains `line: number`; both MCP and HTTP `/query` handlers populate it - src/cli/qmd.ts: OutputRow.body now sources from r.body - src/store.ts: extractSnippet falls back to full-body scan when chunk-scoped pass finds no positive match - test/mcp.test.ts: new fixture asserts absolute line 301 for a marker placed past the first chunk boundary - test/store.test.ts: regression test for the bestScore<=0 fallback |
||
|---|---|---|
| .. | ||
| bench | ||
| cli | ||
| mcp | ||
| ast.ts | ||
| bench-rerank.ts | ||
| collections.ts | ||
| db.ts | ||
| embedded-skills.ts | ||
| index.ts | ||
| llm.ts | ||
| maintenance.ts | ||
| paths.ts | ||
| store.ts | ||
| test-preload.ts | ||