blun-king-cli 9.1.226 → 9.1.227
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,9 @@ const TOOL_SEARCH_RELATED_TERM_GROUPS = Object.freeze([
|
|
|
12
12
|
'current', 'inbox', 'latest', 'message', 'messages', 'nachricht', 'nachrichten', 'queue', 'queued',
|
|
13
13
|
'recent', 'update', 'updates',
|
|
14
14
|
]),
|
|
15
|
-
Object.freeze([
|
|
15
|
+
Object.freeze([
|
|
16
|
+
'chat', 'conversation', 'history', 'log', 'logs', 'processed', 'protokoll', 'transcript', 'verlauf',
|
|
17
|
+
]),
|
|
16
18
|
Object.freeze([
|
|
17
19
|
'fact', 'facts', 'fakt', 'fakten', 'memory', 'memories', 'merk', 'merken', 'note', 'notes',
|
|
18
20
|
'persist', 'persistent', 'profile', 'remember', 'save', 'speichern', 'store',
|
|
@@ -20,7 +22,7 @@ const TOOL_SEARCH_RELATED_TERM_GROUPS = Object.freeze([
|
|
|
20
22
|
]);
|
|
21
23
|
const TOOL_SEARCH_SINGLE_TERM_RELATED_FALLBACKS = new Set([
|
|
22
24
|
'fact', 'facts', 'fakt', 'fakten', 'memory', 'memories', 'merk', 'merken', 'note', 'notes',
|
|
23
|
-
'persist', 'persistent', 'profile', 'remember', 'save', 'speichern', 'store',
|
|
25
|
+
'persist', 'persistent', 'profile', 'remember', 'save', 'speichern', 'store', 'transcript',
|
|
24
26
|
]);
|
|
25
27
|
const CORE_TOOL_NAMES = Object.freeze([
|
|
26
28
|
'Bash',
|
|
@@ -129,18 +131,26 @@ function relatedSearchTerms(token) {
|
|
|
129
131
|
return group || [token];
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
function searchRelatedDeferredTools(tools, query) {
|
|
134
|
+
function searchRelatedDeferredTools(tools, query, options = {}) {
|
|
133
135
|
const normalized = String(query || '').trim().toLowerCase();
|
|
134
136
|
if (!normalized || normalized.startsWith('select:')) return [];
|
|
135
137
|
const tokens = normalized.split(/\s+/).filter(Boolean);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
.
|
|
138
|
+
const requestedNameTokens = tokens
|
|
139
|
+
.filter((token) => token.startsWith('+'))
|
|
140
|
+
.map((token) => token.slice(1))
|
|
141
|
+
.filter(Boolean);
|
|
142
|
+
const relaxRequiredNameTokens = options.relaxRequiredNameTokens === true
|
|
143
|
+
&& requestedNameTokens.length > 0;
|
|
144
|
+
const requiredNameTokens = relaxRequiredNameTokens ? [] : requestedNameTokens;
|
|
145
|
+
const searchTokens = [
|
|
146
|
+
...tokens.filter((token) => !token.startsWith('+')),
|
|
147
|
+
...(relaxRequiredNameTokens ? requestedNameTokens : []),
|
|
148
|
+
]
|
|
139
149
|
.filter((token) => !TOOL_SEARCH_INTENT_WORDS.has(token));
|
|
140
150
|
if (searchTokens.length < 2 && !TOOL_SEARCH_SINGLE_TERM_RELATED_FALLBACKS.has(searchTokens[0])) return [];
|
|
141
151
|
const minimumMatchedTokens = searchTokens.length === 1 ? 1 : Math.max(2, Math.ceil(searchTokens.length * 0.75));
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
const ranked = tools.map((tool) => {
|
|
144
154
|
const name = String(tool?.name || '').toLowerCase();
|
|
145
155
|
const description = String(tool?.description || '').toLowerCase();
|
|
146
156
|
if (!requiredNameTokens.every((token) => name.includes(token))) return null;
|
|
@@ -171,7 +181,14 @@ function searchRelatedDeferredTools(tools, query) {
|
|
|
171
181
|
right.matchedTokens - left.matchedTokens
|
|
172
182
|
|| right.score - left.score
|
|
173
183
|
|| String(left.tool.name).localeCompare(String(right.tool.name))
|
|
174
|
-
))
|
|
184
|
+
));
|
|
185
|
+
if (relaxRequiredNameTokens && ranked.length > 0) {
|
|
186
|
+
const best = ranked[0];
|
|
187
|
+
return ranked.filter((entry) => (
|
|
188
|
+
entry.matchedTokens === best.matchedTokens && entry.score === best.score
|
|
189
|
+
)).slice(0, 5).map((entry) => entry.tool);
|
|
190
|
+
}
|
|
191
|
+
return ranked.slice(0, 5).map((entry) => entry.tool);
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
function rememberLoadedTool(loadedToolNames, name) {
|
|
@@ -223,6 +240,12 @@ function createDeferredToolLoader(selectedTools, deferredTools, loadedToolNames
|
|
|
223
240
|
matches = searchRelatedDeferredTools([...available.values()], query);
|
|
224
241
|
relatedFallback = matches.length > 0;
|
|
225
242
|
}
|
|
243
|
+
if (matches.length === 0) {
|
|
244
|
+
matches = searchRelatedDeferredTools([...available.values()], query, {
|
|
245
|
+
relaxRequiredNameTokens: true,
|
|
246
|
+
});
|
|
247
|
+
relatedFallback = matches.length > 0;
|
|
248
|
+
}
|
|
226
249
|
if (matches.length === 0) {
|
|
227
250
|
const alreadyLoaded = query.toLowerCase().startsWith('select:')
|
|
228
251
|
? searchDeferredTools(
|