feat: symbol extraction and search enrichment (Phase 2)#484
Closed
jamesrisberg wants to merge 1 commit intotobi:mainfrom
Closed
feat: symbol extraction and search enrichment (Phase 2)#484jamesrisberg wants to merge 1 commit intotobi:mainfrom
jamesrisberg wants to merge 1 commit intotobi:mainfrom
Conversation
Builds on AST-aware chunking (tobi#449) to extract symbol metadata (functions, classes, interfaces, types, enums) during indexing and surface them through search results. Key changes: - Single-pass symbol extraction via tree-sitter during embedding - Symbols stored in content_vectors and read at query time (no re-parse) - Sequential enrichment to avoid unbounded WASM memory pressure - Symbol-enriched embeddings for improved semantic retrieval - CLI, JSON, MCP, and REST endpoints all return symbols - Store interface/proxy updated for symbols parameter - WASM parser cleanup via try/finally (no leak on exception) - DB migration only swallows "duplicate column" errors - Standalone test script replaced with proper vitest suite Tests: 60 passing (50 unit + 10 integration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on the AST-aware chunking infrastructure from #449 to extract symbol metadata (functions, classes, interfaces, types, enums) during indexing and surface it through search results.
When
--chunk-strategy autois enabled, qmd now:What gets extracted
Example output
Changes
src/ast.ts—extractAllSymbols()andparseCodeFile()for single-pass breakpoint + symbol extraction; per-language tree-sitter queries with name, kind, signature, line number, and byte offset. WASM parser/tree cleanup via try/finally to prevent leaks. JS-uses-TS-grammar decision documented.src/store.ts— Symbol-to-chunk mapping by byte range;symbolscolumn incontent_vectors; symbols read from DB at query time (no re-parsing); sequential enrichment to avoid unbounded WASM memory pressure; Store interface and proxy updated forsymbolsparameter; migration only catches "duplicate column" errors.src/cli/qmd.ts— Symbols displayed in default + JSON output; grammar availability shown instatus.src/llm.ts—formatDocForEmbeddingaccepts optional symbol names to prepend.src/mcp/server.ts—symbolsfield in MCP search results and REST/queryendpoint.src/index.ts— ExportsSymbolInfotype; corrected JSDoc default ("regex", not "auto").test/ast.test.ts— 50 unit tests covering all 6 languages (TS, JS, Python, Go, Rust) + unicode identifiers + type/enum assertions.test/ast-chunking.test.ts— 10 integration tests: merge breakpoints, AST vs regex split comparison, markdown regression, strategy bypass, overlapping chunk symbols, embedding enrichment.test-ast-chunking.mjs— Deleted. Standalone 1,112-line test script replaced by proper vitest suites above.Design decisions
enrichWithSymbolsreads stored symbols fromcontent_vectorsat query time instead of re-parsing every search result; falls back to on-demand parsing only for files not yet re-embeddedPromise.allon N concurrent WASM parses; DB path is sync anyway"regex". No behavior change for existing usersTest plan
handelizefailures unchanged)main(24 commits ahead of feat: AST-aware chunking for code files via tree-sitter #449 merge point)Migration
After upgrading, re-embed to generate symbol metadata:
Existing indexes continue to work — symbols are additive only.
🤖 Generated with Claude Code