MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / Search

Method Search

tools/deferred.go:54–108  ·  view source on GitHub ↗
(query string)

Source from the content-addressed store, hash-verified

52}
53
54func (d *DeferredToolIndex) Search(query string) []Tool {
55 if query == "" || len(d.tools) == 0 {
56 return nil
57 }
58 if strings.HasPrefix(query, "select:") {
59 var out []Tool
60 for _, name := range strings.Split(query[7:], ",") {
61 name = strings.TrimSpace(name)
62 if name == "" {
63 continue
64 }
65 if tool, ok := d.tools[name]; ok {
66 out = append(out, tool)
67 }
68 }
69 return out
70 }
71 prefix := ""
72 var keywords []string
73 if strings.HasPrefix(query, "+") {
74 parts := strings.SplitN(query[1:], " ", 2)
75 prefix = strings.ToLower(parts[0])
76 if len(parts) > 1 {
77 keywords = strings.Fields(strings.ToLower(parts[1]))
78 }
79 } else {
80 keywords = strings.Fields(strings.ToLower(query))
81 }
82 type scored struct {
83 tool Tool
84 score int
85 }
86 var matches []scored
87 for _, name := range d.order {
88 tool, ok := d.tools[name]
89 if !ok {
90 continue
91 }
92 if prefix != "" && !strings.HasPrefix(strings.ToLower(name), prefix) {
93 continue
94 }
95 score := deferredToolScore(tool, keywords)
96 if score > 0 || len(keywords) == 0 {
97 matches = append(matches, scored{tool: tool, score: score})
98 }
99 }
100 sort.SliceStable(matches, func(i, j int) bool {
101 return matches[i].score > matches[j].score
102 })
103 out := make([]Tool, 0, len(matches))
104 for _, item := range matches {
105 out = append(out, item.tool)
106 }
107 return out
108}
109
110func (d *DeferredToolIndex) removeOrder(name string) {
111 for i, item := range d.order {

Callers 2

SearchDeferredMethod · 0.80

Calls 1

deferredToolScoreFunction · 0.85

Tested by 1