aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/codesearch
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2026-01-19 15:15:19 +0100
committerDmitry Vyukov <dvyukov@google.com>2026-01-20 21:12:57 +0000
commit76d25f8c77a66a7769f1cef5269f27489e3c48b2 (patch)
tree65ef59bf4e749c1e5ecde3528bf06524a85418cb /pkg/codesearch
parent5b6bebdcb7da46d1471b3aeacb28b54ba905b3b2 (diff)
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.
Diffstat (limited to 'pkg/codesearch')
-rw-r--r--pkg/codesearch/codesearch.go15
1 files changed, 13 insertions, 2 deletions
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())
}
}