Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Skip .worktrees directory during indexing

Martin Vogel342ff5a27f26
diff --git a/internal/discover/discover.go b/internal/discover/discover.go
index 92c59be22..8062d9fd9 100644
--- a/internal/discover/discover.go
+++ b/internal/discover/discover.go
@@ -16,7 +16,7 @@ import (
// IGNORE_PATTERNS are directory names to skip during discovery.
var IGNORE_PATTERNS = map[string]bool{
// VCS / IDE
- ".git": true, ".hg": true, ".svn": true,
+ ".git": true, ".hg": true, ".svn": true, ".worktrees": true,
".idea": true, ".vs": true, ".vscode": true, ".eclipse": true, ".claude": true,
// Python
".cache": true, ".eggs": true, ".env": true, ".mypy_cache": true, ".nox": true,
diff --git a/internal/discover/discover_test.go b/internal/discover/discover_test.go
index ac2417006..449713d88 100644
--- a/internal/discover/discover_test.go
+++ b/internal/discover/discover_test.go
@@ -79,6 +79,35 @@ func TestDisambiguateM(t *testing.T) {
}
}
+func TestDiscoverSkipsWorktrees(t *testing.T) {
+ dir := t.TempDir()
+
+ if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte("package main\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+
+ // .worktrees/ contains duplicated source trees from git worktrees
+ wtDir := filepath.Join(dir, ".worktrees", "feature-branch", "src")
+ if err := os.MkdirAll(wtDir, 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(wtDir, "app.go"), []byte("package app\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+
+ files, err := Discover(context.Background(), dir, nil)
+ if err != nil {
+ t.Fatalf("Discover: %v", err)
+ }
+
+ if len(files) != 1 {
+ t.Fatalf("expected 1 file (skipping .worktrees), got %d", len(files))
+ }
+ if filepath.Base(files[0].Path) != "main.go" {
+ t.Errorf("expected main.go, got %s", files[0].Path)
+ }
+}
+
func TestDiscoverCancellation(t *testing.T) {
dir := t.TempDir()