package tui import ( "os" "path/filepath" ) // findRepoRoot walks up from the executable's location (then cwd) looking for // internal/scan/adapters.yaml. Returns "." as fallback so the error surfaces // through LoadConfig rather than here. func findRepoRoot() string { candidates := []string{} if exe, err := os.Executable(); err == nil { candidates = append(candidates, filepath.Dir(exe), filepath.Dir(filepath.Dir(exe))) } if wd, err := os.Getwd(); err == nil { candidates = append(candidates, wd) } for _, start := range candidates { d := start for i := 0; i < 6; i++ { if _, err := os.Stat(filepath.Join(d, "internal", "scan", "adapters.yaml")); err == nil { return d } parent := filepath.Dir(d) if parent == d { break } d = parent } } return "." }