@@ -4,6 +4,7 @@ import (
6 "path/filepath"
6 "path/filepath"
8 "sync/atomic"
9 "sync/atomic"
@@ -50,30 +51,38 @@ func ProjectNeedsInitialization() (bool, error) {
50 return false, fmt.Errorf("failed to check init flag file: %w", err)
51 return false, fmt.Errorf("failed to check init flag file: %w", err)
53− crushExists, err := crushMdExists(cfg.WorkingDir())
54+ someContextFileExists, err := contextPathsExist(cfg.WorkingDir())
54 if err != nil {
55 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)
57− if crushExists {
58+ if someContextFileExists {
58 return false, nil
59 return false, nil
61 return true, nil
62 return true, nil
64−func crushMdExists(dir string) (bool, error) {
65+func contextPathsExist(dir string) (bool, error) {
65 entries, err := os.ReadDir(dir)
66 entries, err := os.ReadDir(dir)
66 if err != nil {
67 if err != nil {
67 return false, err
68 return false, err
71+ // Create a slice of lowercase filenames for lookup with slices.Contains
70 for _, entry := range entries {
73 for _, entry := range entries {
71− if entry.IsDir() {
74+ if !entry.IsDir() {
72− continue
75+ files = append(files, strings.ToLower(entry.Name()))
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)
75− name := strings.ToLower(entry.Name())
85+ if slices.Contains(files, filename) {
76− if name == "crush.md" {
77 return true, nil
86 return true, nil