feat(config): support custom file extensions in chunking config#256
Open
kryptt wants to merge 2 commits into
Open
feat(config): support custom file extensions in chunking config#256kryptt wants to merge 2 commits into
kryptt wants to merge 2 commits into
Conversation
Introduces a config-driven list of extra file extensions for the indexer to scan, on top of the built-in SupportedExtensions table in indexer/scanner.go. Field lives on ChunkingConfig so it round-trips both in per-project .grepai/config.yaml and per-workspace ~/.grepai/workspace.yaml. Closes the API gap behind upstream yoanbernabeu#180. Refs: yoanbernabeu#180
Scanner now consults ChunkingConfig.CustomExtensions in addition to SupportedExtensions. Entries are normalized (trim + lowercase) and silently dropped if empty or missing the leading dot. Binary and minified filters still apply, so adding an extension here is safe even if a build artifact happens to share the name. In workspace mode, both the workspace-level and project-level lists are merged; project entries take precedence in case of duplicates. Adds four indexer tests covering: happy path, case/whitespace normalization, invalid-entry rejection, and binary-content rejection. Refs: yoanbernabeu#180
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.
Closes #180.
Problem
grepai hardcodes its set of indexable extensions in
indexer/scanner.go. Files with extensions outside that list are silently dropped — no chunking, no embedding, no search hits. As #180 notes, this is fine for mainstream languages but doesn't scale for niche or polyglot codebases.In my own case I tried to build a workspace over Emacs sources (
/usr/share/emacs/<X.Y>/lisp/,~/.emacs.d/{core,layers,private,elpa,quelpa}) and observed 0 elisp files indexed across ~38,000 `.el` files. Bisecting the scanner pinned the cause to the extension gate atscanner.go:157.Solution
Adds an optional `chunking.custom_extensions: [".tengo", ".el", ...]` list, exactly as proposed in #180.
Two-commit shape:
feat(config): add ChunkingConfig.CustomExtensions — yaml schema and the corresponding field on the workspace block, so the same key works in per-project `.grepai/config.yaml` and per-workspace `~/.grepai/workspace.yaml`. Workspace + project lists are merged when scanning a workspace project; project entries take precedence on duplicates.
feat(scanner): honor custom_extensions during file enumeration — `Scanner.WithCustomExtensions([]string)` builder method that normalizes entries (trim, lowercase) and silently drops empty / dotless entries. The existing minified-file filter, binary-file filter, and 1MB max-size guard still apply, so adding e.g. `.tengo` here is safe even if a build artifact happens to share the name.
Test plan
Four new tests in `indexer/scanner_test.go`:
All existing tests continue to pass (`go test ./...`).
Demonstration
End-to-end on this branch: a workspace indexing the Spacemacs `core/` directory (45 `.el` files) goes from `Initial scan complete: 0 files indexed` on upstream `main` to `Initial scan complete: 56 files indexed, 731 chunks created` once `.el` is listed under `chunking.custom_extensions`.