toolsrv: fix Registry.discover() to use .meta files
The Registry had its own discover() method that still required 'ollie:prompt' in file content — the old header-based check that was removed from DiscoverTools(). This caused tool_load to fail for ALL tools (not just Go binaries) since .meta is now the sole metadata source. Fix: delegate to DiscoverTools() which correctly scans .meta files.
This commit is contained in:
parent
46a990cd42
commit
5a84e8b326
|
|
@ -3,9 +3,7 @@ package toolsrv
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
|
@ -30,25 +28,10 @@ func NewRegistry() (*Registry, error) {
|
|||
|
||||
// discover scans the tools directory and returns all valid tool infos.
|
||||
func (r *Registry) discover() map[string]ToolInfo {
|
||||
dir := ToolsPath()
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
tools := make(map[string]ToolInfo)
|
||||
for _, e := range entries {
|
||||
if e.IsDir() || e.Name() == "idx" || e.Name()[0] == '.' {
|
||||
continue
|
||||
}
|
||||
data, err := os.ReadFile(filepath.Join(dir, e.Name()))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
script := string(data)
|
||||
if !strings.Contains(script, "ollie:prompt") {
|
||||
continue
|
||||
}
|
||||
tools[e.Name()] = ParseToolInfo(e.Name(), script)
|
||||
infos := DiscoverTools()
|
||||
tools := make(map[string]ToolInfo, len(infos))
|
||||
for _, info := range infos {
|
||||
tools[info.Name] = info
|
||||
}
|
||||
return tools
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue