@@ -4,6 +4,7 @@ import (
44 "fmt"
55 "os"
66 "path/filepath"
7+ "slices"
78 "strings"
89 "sync/atomic"
910)
@@ -50,30 +51,38 @@ func ProjectNeedsInitialization() (bool, error) {
5051 return false, fmt.Errorf("failed to check init flag file: %w", err)
5152 }
5253
53− crushExists, err := crushMdExists(cfg.WorkingDir())
54+ someContextFileExists, err := contextPathsExist(cfg.WorkingDir())
5455 if err != nil {
55− return false, fmt.Errorf("failed to check for CRUSH.md files: %w", err)
56+ return false, fmt.Errorf("failed to check for context files: %w", err)
5657 }
57− if crushExists {
58+ if someContextFileExists {
5859 return false, nil
5960 }
6061
6162 return true, nil
6263}
6364
64−func crushMdExists(dir string) (bool, error) {
65+func contextPathsExist(dir string) (bool, error) {
6566 entries, err := os.ReadDir(dir)
6667 if err != nil {
6768 return false, err
6869 }
6970
71+ // Create a slice of lowercase filenames for lookup with slices.Contains
72+ var files []string
7073 for _, entry := range entries {
71− if entry.IsDir() {
72− continue
74+ if !entry.IsDir() {
75+ files = append(files, strings.ToLower(entry.Name()))
7376 }
77+ }
78+
79+ // Check if any of the default context paths exist in the directory
80+ for _, path := range defaultContextPaths {
81+ // Extract just the filename from the path
82+ _, filename := filepath.Split(path)
83+ filename = strings.ToLower(filename)
7484
75− name := strings.ToLower(entry.Name())
76− if name == "crush.md" {
85+ if slices.Contains(files, filename) {
7786 return true, nil
7887 }
7988 }