From 898f1ee9e43d31d711b97a602db9bc152f18ccac Mon Sep 17 00:00:00 2001 From: Amolith Date: Fri, 12 Sep 2025 14:13:41 -0600 Subject: [PATCH] fix(config): look for more than just crush.md Crush used to show the initialization popup even when the project uses something other than `CRUSH.md`. Crush already has support for loading those other context files, like `CLAUDE.md` or `AGENTS.md`, so this just changes the popup check logic to look for the same set it loads Co-Authored-By: Crush --- internal/config/init.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/internal/config/init.go b/internal/config/init.go index f97272cefa779319a752927456c34fbcff97e3b6..6807ab25e819b99d899fac711da304c8dc8db595 100644 --- a/internal/config/init.go +++ b/internal/config/init.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "slices" "strings" "sync/atomic" ) @@ -50,30 +51,38 @@ func ProjectNeedsInitialization() (bool, error) { return false, fmt.Errorf("failed to check init flag file: %w", err) } - crushExists, err := crushMdExists(cfg.WorkingDir()) + someContextFileExists, err := contextPathsExist(cfg.WorkingDir()) if err != nil { - return false, fmt.Errorf("failed to check for CRUSH.md files: %w", err) + return false, fmt.Errorf("failed to check for context files: %w", err) } - if crushExists { + if someContextFileExists { return false, nil } return true, nil } -func crushMdExists(dir string) (bool, error) { +func contextPathsExist(dir string) (bool, error) { entries, err := os.ReadDir(dir) if err != nil { return false, err } + // Create a slice of lowercase filenames for lookup with slices.Contains + var files []string for _, entry := range entries { - if entry.IsDir() { - continue + if !entry.IsDir() { + files = append(files, strings.ToLower(entry.Name())) } + } + + // Check if any of the default context paths exist in the directory + for _, path := range defaultContextPaths { + // Extract just the filename from the path + _, filename := filepath.Split(path) + filename = strings.ToLower(filename) - name := strings.ToLower(entry.Name()) - if name == "crush.md" { + if slices.Contains(files, filename) { return true, nil } }