qmd/src
Riley Shott 1f522cffe2
fix: return absolute line numbers from qmd_query
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
2026-05-13 23:59:32 -07:00
..
bench feat(cli): add qmd bench command for search quality benchmarks 2026-04-05 17:17:59 -04:00
cli fix: return absolute line numbers from qmd_query 2026-05-13 23:59:32 -07:00
mcp fix: return absolute line numbers from qmd_query 2026-05-13 23:59:32 -07:00
ast.ts Fix AST grammar packaging for Bun installs 2026-05-09 18:13:58 +00:00
bench-rerank.ts feat: use build: "autoAttempt" on getLlama 2026-03-06 07:02:50 +00:00
collections.ts fix embed model and qmd home resolution 2026-05-09 18:17:10 +00:00
db.ts fix(db): declare transaction() on local Database interface 2026-04-14 08:34:20 -04:00
embedded-skills.ts feat(skill): install packaged qmd skill 2026-03-10 23:18:15 +01:00
index.ts fix(embed): honor collection filter 2026-05-09 18:12:45 +00:00
llm.ts Fix Windows CUDA context parallelism 2026-05-09 18:15:39 +00:00
maintenance.ts refactor: move CLI and MCP to subdirectories, MCP consumes SDK 2026-03-10 11:39:55 -04:00
paths.ts fix embed model and qmd home resolution 2026-05-09 18:17:10 +00:00
store.ts fix: return absolute line numbers from qmd_query 2026-05-13 23:59:32 -07:00
test-preload.ts fix: increase bun test timeout to 30s via CLI flag 2026-02-15 21:59:18 -04:00