From 76d25f8c77a66a7769f1cef5269f27489e3c48b2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 19 Jan 2026 15:15:19 +0100 Subject: pkg/aflow/action/kernel: keep build files that codesearch will need We currently duplicate list of source extensions in the build action and codesearch tool. Unify the lists. --- pkg/codesearch/codesearch.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'pkg/codesearch/codesearch.go') diff --git a/pkg/codesearch/codesearch.go b/pkg/codesearch/codesearch.go index 6eab749db..746984369 100644 --- a/pkg/codesearch/codesearch.go +++ b/pkg/codesearch/codesearch.go @@ -82,7 +82,17 @@ var Commands = []Command{ }}, } -var SourceExtensions = map[string]bool{".c": true, ".h": true, ".S": true, ".rs": true} +func IsSourceFile(file string) bool { + return sourceFiles[file] || sourceExtensions[filepath.Ext(file)] +} + +var ( + // Files and extensions we want to keep in the build dir and make available to LLM agents. + sourceExtensions = map[string]bool{".c": true, ".h": true, ".S": true, ".rs": true} + sourceFiles = map[string]bool{ + ".config": true, + } +) func NewIndex(databaseFile string, srcDirs []string) (*Index, error) { db, err := osutil.ReadJSON[*Database](databaseFile) @@ -275,6 +285,7 @@ func escaping(path string) error { } func dirIndex(root, subdir string) (bool, []string, []string, error) { + subdir = filepath.Clean(subdir) dir := filepath.Join(root, subdir) entries, err := os.ReadDir(dir) if err != nil { @@ -293,7 +304,7 @@ func dirIndex(root, subdir string) (bool, []string, []string, error) { // These are internal things like .git, etc. } else if entry.IsDir() { subdirs = append(subdirs, entry.Name()) - } else if SourceExtensions[filepath.Ext(entry.Name())] { + } else if IsSourceFile(filepath.Join(subdir, entry.Name())) { files = append(files, entry.Name()) } } -- cgit mrf-deployment