@@ -79,25 +79,28 @@ func main() {
7979 execPath , _ := os .Executable ()
8080 sourceDir := filepath .Dir (execPath )
8181
82- binaries := []string {"rag-code-mcp" , "rag-code-install" }
83- resources := []string {"README.md" , "llms.txt" , "LICENSE" , "config.yaml" }
84-
85- // Fast Check: Are files present?
86- missingFiles := false
87- for _ , f := range append (binaries , resources ... ) {
82+ // Required files: rag-code-mcp (binary) + config.yaml
83+ // If either is missing from sourceDir, download the latest release.
84+ // rag-code-install is the running binary — no need to check or copy itself.
85+ requiredFiles := []string {"rag-code-mcp" , "config.yaml" }
86+ optionalResources := []string {"README.md" , "llms.txt" , "LICENSE" }
87+
88+ // Check if required files are present
89+ needsDownload := false
90+ for _ , f := range requiredFiles {
8891 name := f
89- if runtime .GOOS == "windows" && ( f == "rag-code-mcp" || f == "rag-code-install" ) {
92+ if runtime .GOOS == "windows" && f == "rag-code-mcp" {
9093 name += ".exe"
9194 }
9295 if _ , err := os .Stat (filepath .Join (sourceDir , name )); os .IsNotExist (err ) {
93- missingFiles = true
96+ needsDownload = true
9497 break
9598 }
9699 }
97100
98- // If files are missing, we must download the latest release and use its contents as source
101+ // Download only if rag-code-mcp or config.yaml is missing
99102 tempDir := ""
100- if missingFiles {
103+ if needsDownload {
101104 log ("Required files missing in current directory. Downloading latest release..." )
102105 var err error
103106 tempDir , err = downloadAndExtractLatest ()
@@ -111,41 +114,43 @@ func main() {
111114 log ("Copying files from: " + sourceDir )
112115 }
113116
114- // Copy Binaries to bin/
115- for _ , b := range binaries {
116- srcName := b
117+ // Install the main binary
118+ {
119+ srcName := "rag-code-mcp"
117120 if runtime .GOOS == "windows" {
118121 srcName += ".exe"
119122 }
120123 src := filepath .Join (sourceDir , srcName )
121124 dst := filepath .Join (binPath , srcName )
122125
123126 if err := copyFile (src , dst ); err != nil {
124- warn (fmt .Sprintf ("Skipping: %s not found in source directory" , b ))
125- continue
127+ fail (fmt .Sprintf ("Failed to install binary rag-code-mcp: %v" , err ))
126128 }
127129 if err := os .Chmod (dst , 0755 ); err != nil {
128- warn (fmt .Sprintf ("Failed to set executable permissions for %s : %v" , b , err ))
130+ warn (fmt .Sprintf ("Failed to set executable permissions: %v" , err ))
129131 }
130- success ("Installed binary: " + b )
132+ success ("Installed binary: rag-code-mcp" )
131133 }
132134
133- // Copy Resources to bin/
134- for _ , r := range resources {
135- src := filepath .Join (sourceDir , r )
136- dst := filepath .Join (binPath , r )
137-
138- if r == "config.yaml" {
139- if _ , err := os . Stat (dst ); err == nil {
140- log ( "config.yaml already exists - keeping existing configuration." )
141- checkConfigUpgrade ( dst )
142- continue
143- }
135+ // Install config.yaml (preserve existing)
136+ {
137+ src := filepath .Join (sourceDir , "config.yaml" )
138+ dst := filepath .Join (binPath , "config.yaml" )
139+ if _ , err := os . Stat ( dst ); err == nil {
140+ log ( "config.yaml already exists - keeping existing configuration." )
141+ checkConfigUpgrade (dst )
142+ } else if err := copyFile ( src , dst ); err != nil {
143+ warn ( "Could not install config.yaml: " + err . Error () )
144+ } else {
145+ success ( "Installed resource: config.yaml" )
144146 }
147+ }
145148
146- if err := copyFile (src , dst ); err != nil {
147- warn (fmt .Sprintf ("Skipping: %s not found in source directory" , r ))
148- } else {
149+ // Copy optional resources (silently skip if missing)
150+ for _ , r := range optionalResources {
151+ src := filepath .Join (sourceDir , r )
152+ dst := filepath .Join (binPath , r )
153+ if err := copyFile (src , dst ); err == nil {
149154 success ("Installed resource: " + r )
150155 }
151156 }
0 commit comments