Skip to content

feat(core): extend SearchResult type with snippet and imports#74

Merged
prosdev merged 1 commit intomainfrom
feat/69-extend-search-result-types
Nov 27, 2025
Merged

feat(core): extend SearchResult type with snippet and imports#74
prosdev merged 1 commit intomainfrom
feat/69-extend-search-result-types

Conversation

@prosdev
Copy link
Copy Markdown
Collaborator

@prosdev prosdev commented Nov 27, 2025

Summary

Implements #69 - Third sub-issue of Epic #66 (Richer Search Results)

Changes

packages/core/src/vector/types.ts

  • Added SearchResultMetadata interface with typed fields
  • Updated SearchResult to use SearchResultMetadata instead of Record<string, unknown>

packages/core/src/vector/store.ts

  • Updated search() to cast parsed metadata to SearchResultMetadata

packages/core/src/indexer/utils/documents.ts

  • Added snippet and imports to prepareDocumentsForEmbedding()
  • Added snippet and imports to prepareDocumentForEmbedding()

SearchResultMetadata Fields

interface SearchResultMetadata {
  path?: string;       // File path
  type?: DocumentType | string;
  language?: string;
  name?: string;
  startLine?: number;
  endLine?: number;
  exported?: boolean;
  signature?: string;
  docstring?: string;
  snippet?: string;    // NEW: from #67
  imports?: string[];  // NEW: from #68
  [key: string]: unknown;  // Extensible
}

Features

✅ Typed metadata fields with IDE autocomplete
✅ Backward compatible (all fields optional)
✅ Extensible via index signature for custom use cases
snippet and imports now flow through to search results

Testing

  • ✅ 1265 tests passing
  • ✅ TypeScript compiles without errors
  • ✅ Biome linting passes

Related Issues

Implements #69 - Richer Search Results (sub-issue 3/5)

Changes:
- Add SearchResultMetadata interface with typed fields for:
  - path, type, language, name, startLine, endLine
  - exported, signature, docstring
  - snippet (new from #67)
  - imports (new from #68)
- Update SearchResult to use SearchResultMetadata
- Update prepareDocumentsForEmbedding to include snippet/imports
- Use SearchResultMetadata in LanceDBVectorStore.search()

Features:
- Typed metadata fields provide IDE autocomplete
- Backward compatible with existing code (fields optional)
- Extensible via index signature for custom fields

Testing:
- All 1265 tests passing
- TypeScript compiles without errors

Closes #69
@prosdev prosdev merged commit 96d0d16 into main Nov 27, 2025
1 check passed
@prosdev prosdev mentioned this pull request Nov 27, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend SearchResult type with snippet and imports

1 participant