Skip to content

feat(core): store code snippets during indexing#72

Merged
prosdev merged 1 commit intomainfrom
feat/67-store-code-snippets
Nov 27, 2025
Merged

feat(core): store code snippets during indexing#72
prosdev merged 1 commit intomainfrom
feat/67-store-code-snippets

Conversation

@prosdev
Copy link
Copy Markdown
Collaborator

@prosdev prosdev commented Nov 27, 2025

Summary

Implements #67 - First sub-issue of Epic #66 (Richer Search Results)

Changes

packages/core/src/scanner/types.ts

  • Added snippet?: string field to DocumentMetadata interface

packages/core/src/scanner/typescript.ts

  • Added DEFAULT_MAX_SNIPPET_LINES constant (50 lines)
  • Added truncateSnippet() helper method
  • Updated all extraction methods to capture full code content:
    • extractFunction
    • extractClass
    • extractMethod
    • extractInterface
    • extractTypeAlias

packages/core/src/scanner/__tests__/scanner.test.ts

  • Added 7 new tests for snippet extraction:
    • Extract snippets for classes
    • Extract snippets for functions
    • Extract snippets for interfaces
    • Extract snippets for type aliases
    • Extract snippets for methods
    • Truncate long snippets
    • Preserve formatting and indentation

Behavior

The scanner now captures actual code content, not just metadata:

  • Small components (<50 lines): Full code content stored
  • Large components (>50 lines): Truncated with // ... N more lines indicator
  • Formatting: Original indentation and formatting preserved

Testing

  • All 28 scanner tests pass
  • TypeScript compiles without errors
  • Biome linting passes

Related Issues

Implements #67 - Richer Search Results (sub-issue 1/5)

Changes:
- Add `snippet` field to DocumentMetadata interface
- Add truncateSnippet() helper to TypeScriptScanner (default: 50 lines)
- Update all extraction methods to capture full code content:
  - extractFunction
  - extractClass
  - extractMethod
  - extractInterface
  - extractTypeAlias
- Add comprehensive tests for snippet extraction

The scanner now captures actual code content, not just metadata.
Large components (>50 lines) are truncated with a '// ... N more lines' indicator.

Closes #67
@prosdev prosdev merged commit 28320fe 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.

Store code snippets during indexing

1 participant