Skip to content

feat(config): support custom file extensions in chunking config#256

Open
kryptt wants to merge 2 commits into
yoanbernabeu:mainfrom
kryptt:pr/custom-extensions
Open

feat(config): support custom file extensions in chunking config#256
kryptt wants to merge 2 commits into
yoanbernabeu:mainfrom
kryptt:pr/custom-extensions

Conversation

@kryptt

@kryptt kryptt commented May 28, 2026

Copy link
Copy Markdown

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 at scanner.go:157.

Solution

Adds an optional `chunking.custom_extensions: [".tengo", ".el", ...]` list, exactly as proposed in #180.

Two-commit shape:

  1. 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.

  2. 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`:

Test Asserts
`TestScanner_CustomExtensions` a `.tengo` file is indexed when listed; coexists with built-in extensions; unrecognized extensions still skipped
`TestScanner_WithCustomExtensions_Normalizes` `" .TENGO "` matches `.tengo`
`TestScanner_WithCustomExtensions_RejectsInvalidEntries` empty, dotless, and whitespace-only inputs are silently dropped
`TestScanner_CustomExtensions_BinaryStillSkipped` binary `.tengo` content (null bytes) is still rejected

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`.

kryptt added 2 commits May 29, 2026 01:19
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
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.

[Feature]: Support custom file extensions in config

1 participant