@agentskillshub/cli 0.2.0 → 0.2.2
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.
- package/bin/ash.mjs +27 -1
- package/package.json +1 -1
package/bin/ash.mjs
CHANGED
|
@@ -45,6 +45,13 @@ const GRADE = {
|
|
|
45
45
|
// CJK detection — Chinese queries have no word boundaries, so we bigram them.
|
|
46
46
|
const CJK = /[一-鿿]/;
|
|
47
47
|
|
|
48
|
+
// Generic terms that appear in ~half the catalog — they drown the distinctive
|
|
49
|
+
// part of a query. Ignored during scoring unless the whole query is generic.
|
|
50
|
+
const STOPWORDS = new Set([
|
|
51
|
+
"ai", "mcp", "mcps", "agent", "agents", "tool", "tools", "skill", "skills",
|
|
52
|
+
"server", "servers", "app", "apps", "工具", "服务器", "服务",
|
|
53
|
+
]);
|
|
54
|
+
|
|
48
55
|
// ─── tiny ANSI (auto-off when not a TTY / NO_COLOR) ──────────────────────────
|
|
49
56
|
const tty = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
50
57
|
const c = (code, s) => (tty ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
@@ -150,8 +157,14 @@ function scoreRow(row, tokens) {
|
|
|
150
157
|
// English-only repos via our curated scenario titles, and ranks
|
|
151
158
|
// scenario-relevant skills higher. Empty/undefined on older indexes.
|
|
152
159
|
const scen = (row.w || "").toLowerCase();
|
|
160
|
+
// When the query has a distinctive term, generic tokens (ai/mcp/agent/工具…)
|
|
161
|
+
// match half the catalog and drown it — "去 AI 味" would rank vercel/ai over
|
|
162
|
+
// the actual humanizer. Skip generic tokens for scoring UNLESS the whole query
|
|
163
|
+
// is generic (then they're all we have).
|
|
164
|
+
const hasContent = tokens.some((t) => !STOPWORDS.has(t));
|
|
153
165
|
let score = 0;
|
|
154
166
|
for (const tok of tokens) {
|
|
167
|
+
if (hasContent && STOPWORDS.has(tok)) continue;
|
|
155
168
|
if (name === tok) score += 50;
|
|
156
169
|
else if (name.includes(tok)) score += 20;
|
|
157
170
|
if (full.includes(tok)) score += 8;
|
|
@@ -181,9 +194,22 @@ function applyFilters(skills, f) {
|
|
|
181
194
|
});
|
|
182
195
|
}
|
|
183
196
|
|
|
197
|
+
/** Tokenize a query. Splits on whitespace AND at latin↔CJK boundaries, so a
|
|
198
|
+
* glued mixed query like "ppt制作" becomes ["ppt", "制作"] (otherwise it's one
|
|
199
|
+
* token that matches nothing). Pure-CJK compounds still rely on the bigram
|
|
200
|
+
* fallback in scoreRow. */
|
|
201
|
+
function tokenize(q) {
|
|
202
|
+
return q
|
|
203
|
+
.toLowerCase()
|
|
204
|
+
.replace(/([a-z0-9])([一-鿿])/g, "$1 $2")
|
|
205
|
+
.replace(/([一-鿿])([a-z0-9])/g, "$1 $2")
|
|
206
|
+
.split(/\s+/)
|
|
207
|
+
.filter(Boolean);
|
|
208
|
+
}
|
|
209
|
+
|
|
184
210
|
function runSearch(index, args) {
|
|
185
211
|
const f = parseFilters(args);
|
|
186
|
-
const tokens = f.query
|
|
212
|
+
const tokens = tokenize(f.query);
|
|
187
213
|
const pool = applyFilters(index.skills, f);
|
|
188
214
|
const ranked = pool
|
|
189
215
|
.map((r) => ({ r, score: scoreRow(r, tokens) }))
|
package/package.json
CHANGED