dsh-skill-mcp-market 0.5.21 → 0.5.23
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/client.js +43 -3
- package/index.js +42 -0
- package/package.json +1 -1
- package/src/extra-sources.js +70 -5
package/client.js
CHANGED
|
@@ -8,6 +8,12 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
const { useState, useEffect, useCallback, useRef } = React;
|
|
9
9
|
|
|
10
10
|
const RPC = '/api/dsh-market/rpc';
|
|
11
|
+
const openExt = (url) => {
|
|
12
|
+
if (!url) return;
|
|
13
|
+
if (typeof window !== 'undefined' && window.open) {
|
|
14
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
15
|
+
}
|
|
16
|
+
};
|
|
11
17
|
|
|
12
18
|
async function call(op, payload) {
|
|
13
19
|
// A hung response must surface as an error instead of an endless spinner.
|
|
@@ -473,7 +479,14 @@ window.__ModuleLoader__.load({
|
|
|
473
479
|
ref: item.ref || '',
|
|
474
480
|
name: item.slug,
|
|
475
481
|
});
|
|
476
|
-
setPreview({
|
|
482
|
+
setPreview({
|
|
483
|
+
slug: item.slug,
|
|
484
|
+
name: d.name || item.slug,
|
|
485
|
+
content: d.content || '',
|
|
486
|
+
files: d.files,
|
|
487
|
+
openUrl: d.openUrl || '',
|
|
488
|
+
previewError: d.previewError || '',
|
|
489
|
+
});
|
|
477
490
|
} catch (e) {
|
|
478
491
|
setError(`预览失败:${e.message || e}`);
|
|
479
492
|
} finally {
|
|
@@ -481,6 +494,19 @@ window.__ModuleLoader__.load({
|
|
|
481
494
|
}
|
|
482
495
|
};
|
|
483
496
|
|
|
497
|
+
const detailUrlFor = (item) => {
|
|
498
|
+
if (item.source === 'clawhub' && item.installRef) {
|
|
499
|
+
return `https://clawhub.ai/${item.installRef}`;
|
|
500
|
+
}
|
|
501
|
+
if (item.source === 'skills.sh' && item.homepage) {
|
|
502
|
+
return item.homepage;
|
|
503
|
+
}
|
|
504
|
+
if (item.upstreamUrl) return item.upstreamUrl;
|
|
505
|
+
return '';
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const openDetail = (item) => openExt(detailUrlFor(item));
|
|
509
|
+
|
|
484
510
|
const doInstallSkill = async (item) => {
|
|
485
511
|
setBusy(`install:${item.slug}`);
|
|
486
512
|
setError('');
|
|
@@ -619,6 +645,11 @@ window.__ModuleLoader__.load({
|
|
|
619
645
|
disabled: busy === `preview:${item.slug}`,
|
|
620
646
|
onClick: () => openPreview(item),
|
|
621
647
|
}, busy === `preview:${item.slug}` ? '下载中…' : '预览'),
|
|
648
|
+
detailUrlFor(item) ? h('button', {
|
|
649
|
+
style: { ...S.btn(), padding: '0 6px' },
|
|
650
|
+
title: '在浏览器中打开详情页(快速查看)',
|
|
651
|
+
onClick: () => openDetail(item),
|
|
652
|
+
}, '详情') : null,
|
|
622
653
|
installed.some((x) => x.slug === item.slug)
|
|
623
654
|
? h('span', { style: S.status }, '✓ 已安装')
|
|
624
655
|
: item.installable === false
|
|
@@ -977,8 +1008,17 @@ window.__ModuleLoader__.load({
|
|
|
977
1008
|
preview
|
|
978
1009
|
? h('div', { style: S.card },
|
|
979
1010
|
h('div', { style: S.title }, `预览:${preview.name}(${preview.files} 个文件,未安装)`),
|
|
980
|
-
|
|
981
|
-
|
|
1011
|
+
preview.previewError
|
|
1012
|
+
? h('div', { style: { ...S.status, color: '#b26a00' } }, `在线预览不可用:${preview.previewError}`)
|
|
1013
|
+
: null,
|
|
1014
|
+
h('pre', { style: { fontSize: 12, whiteSpace: 'pre-wrap', maxHeight: 240, overflow: 'auto', margin: 0 } }, preview.content || (preview.previewError ? '' : '(没有正文)')),
|
|
1015
|
+
h('div', { style: S.row },
|
|
1016
|
+
h('button', { style: S.btn(), onClick: () => setPreview(null) }, '关闭预览'),
|
|
1017
|
+
preview.openUrl ? h('button', {
|
|
1018
|
+
style: { ...S.btn('primary'), padding: '0 8px' },
|
|
1019
|
+
title: `在浏览器中打开 ${preview.openUrl}`,
|
|
1020
|
+
onClick: () => { openExt(preview.openUrl); setPreview(null); },
|
|
1021
|
+
}, '在浏览器中查看详情') : null))
|
|
982
1022
|
: null,
|
|
983
1023
|
tab === 'skills' ? h('div', { style: S.grid }, skillCards) : null,
|
|
984
1024
|
tab === 'mcp' ? h('div', { style: S.grid }, mcpCards) : null,
|
package/index.js
CHANGED
|
@@ -1153,6 +1153,48 @@ export async function apply(ctx, config = {}) {
|
|
|
1153
1153
|
} catch { /* fall through to full download */ }
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
|
+
// For clawhub: when the full-download path fails (e.g. no GitHub source found),
|
|
1157
|
+
// return a structured "open in browser" response instead of throwing, so the
|
|
1158
|
+
// client can show a useful fallback instead of a dead-end error.
|
|
1159
|
+
if ((body.source || "github") === "clawhub") {
|
|
1160
|
+
const detailUrl = `https://clawhub.ai/${String(body.reference || "").replace(/^clawhub:/, "")}`;
|
|
1161
|
+
try {
|
|
1162
|
+
const installed = await installSkill({
|
|
1163
|
+
source: body.source,
|
|
1164
|
+
reference: body.reference,
|
|
1165
|
+
skillDir: body.skillDir || "",
|
|
1166
|
+
name: body.name || "",
|
|
1167
|
+
ref: body.ref || "",
|
|
1168
|
+
dir: tmpRoot,
|
|
1169
|
+
force: true,
|
|
1170
|
+
skillDirs: [tmpRoot],
|
|
1171
|
+
cache: marketCache,
|
|
1172
|
+
});
|
|
1173
|
+
const detail = await readSkillBody([tmpRoot], installed.slug);
|
|
1174
|
+
return {
|
|
1175
|
+
slug: installed.slug,
|
|
1176
|
+
name: installed.name,
|
|
1177
|
+
description: installed.description,
|
|
1178
|
+
files: installed.files,
|
|
1179
|
+
content: (detail && detail.content ? detail.content : "").slice(0, 20000),
|
|
1180
|
+
previewOnly: true,
|
|
1181
|
+
};
|
|
1182
|
+
} catch (previewErr) {
|
|
1183
|
+
const slugFromRef = String(body.name || "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-|-$/g, "") || String(body.reference || "");
|
|
1184
|
+
return {
|
|
1185
|
+
slug: slugFromRef,
|
|
1186
|
+
name: body.name || body.reference,
|
|
1187
|
+
description: "",
|
|
1188
|
+
files: [],
|
|
1189
|
+
content: "",
|
|
1190
|
+
previewOnly: true,
|
|
1191
|
+
openUrl: detailUrl,
|
|
1192
|
+
previewError: String(previewErr && previewErr.message || previewErr),
|
|
1193
|
+
};
|
|
1194
|
+
} finally {
|
|
1195
|
+
await rm(tmpRoot, { recursive: true, force: true });
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1156
1198
|
try {
|
|
1157
1199
|
const installed = await installSkill({
|
|
1158
1200
|
source: body.source || "github",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-skill-mcp-market",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH 技能市场与 MCP 连接器市场:浏览实时技能源,一键安装 SKILL.md 技能与 MCP 连接器,装完即刻可用、无需重启。SKILL & MCP marketplace for DeepSeek Harness — browse live sources, install skills and MCP connectors, effective immediately.",
|
|
6
6
|
"license": "MIT",
|
package/src/extra-sources.js
CHANGED
|
@@ -397,12 +397,77 @@ export async function searchModelScope({ query = "", page = 1, pageSize = 24 } =
|
|
|
397
397
|
return { source: "modelscope", items, total: total || p * size + (rows.length >= size ? 1 : 0), hasMore: total ? p * size < total : rows.length >= size };
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* Resolve a clawhub reference (`owner/slug`) to its GitHub-backed skill directory.
|
|
402
|
+
*
|
|
403
|
+
* Two strategies, tried in order:
|
|
404
|
+
* 1. HTML scrape — fetch the clawhub.ai detail page and regex-extract the GitHub
|
|
405
|
+
* repo URL. Fast when the page structure still carries a bare github.com link.
|
|
406
|
+
* 2. Search API — fall back to `clawhub.ai/api/v1/search?q=<slug>` and read the
|
|
407
|
+
* structured `links.source` field from the matching result. Works even when
|
|
408
|
+
* the HTML page no longer embeds a raw GitHub URL (the 2026-11 failure mode).
|
|
409
|
+
*
|
|
410
|
+
* Returns `{ repo, skillDir, apiFallback }` — `apiFallback` is true when the
|
|
411
|
+
* structured API supplied the repo instead of the HTML scrape.
|
|
412
|
+
* If neither strategy finds a GitHub source, throws an Error whose message
|
|
413
|
+
* includes the detail-page URL so the client can offer a "open in browser" fallback.
|
|
414
|
+
*/
|
|
401
415
|
export async function clawhubResolve(reference) {
|
|
402
416
|
const [owner, slug] = String(reference || "").split("/");
|
|
403
417
|
if (!owner || !slug) throw new Error("clawhub 引用格式应为 owner/slug");
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
418
|
+
|
|
419
|
+
// Strategy 1: HTML scrape (original path, may fail if page structure changed).
|
|
420
|
+
let htmlMatch = null;
|
|
421
|
+
try {
|
|
422
|
+
const page = await (await fetch(`https://clawhub.ai/${owner}/skills/${slug}`, {
|
|
423
|
+
headers: UA,
|
|
424
|
+
signal: AbortSignal.timeout(15000),
|
|
425
|
+
})).text();
|
|
426
|
+
htmlMatch = /https:\/\/github\.com\/([\w.-]+\/[\w.-]+)(?:\/tree\/[\w.-]+\/([\w./-]+))?/.exec(page);
|
|
427
|
+
} catch {
|
|
428
|
+
// Network hiccup — fall through to API.
|
|
429
|
+
}
|
|
430
|
+
if (htmlMatch) return { repo: htmlMatch[1], skillDir: htmlMatch[2] || "", apiFallback: false };
|
|
431
|
+
|
|
432
|
+
// Strategy 2: Search API (structured, resilient to HTML changes).
|
|
433
|
+
try {
|
|
434
|
+
const results = await getJsonClawHub(
|
|
435
|
+
`https://clawhub.ai/api/v1/search?q=${encodeURIComponent(slug)}&page=1&limit=20`,
|
|
436
|
+
);
|
|
437
|
+
const rows = Array.isArray(results) ? results : results?.results || [];
|
|
438
|
+
const hit = rows.find(
|
|
439
|
+
(r) => r?.ownerHandle === owner && r?.slug === slug,
|
|
440
|
+
) || rows.find((r) => {
|
|
441
|
+
const ref = r?.install?.reference || "";
|
|
442
|
+
return ref === `${owner}/${slug}`;
|
|
443
|
+
});
|
|
444
|
+
if (hit) {
|
|
445
|
+
// links.source carries the GitHub repo URL when the skill has one.
|
|
446
|
+
const sourceUrl =
|
|
447
|
+
hit.links?.source ||
|
|
448
|
+
hit.install?.sourceUrl ||
|
|
449
|
+
hit.upstreamUrl ||
|
|
450
|
+
"";
|
|
451
|
+
if (sourceUrl) {
|
|
452
|
+
const m = /github\.com\/([\w.-]+\/[\w.-]+)(?:\/tree\/[\w.-]+\/([\w./-]+))?/.exec(sourceUrl);
|
|
453
|
+
if (m) return { repo: m[1], skillDir: m[2] || "", apiFallback: true };
|
|
454
|
+
}
|
|
455
|
+
// Some entries carry the repo under native.skill or sourceIdentity.
|
|
456
|
+
const repoField =
|
|
457
|
+
hit.native?.skill?.repoUrl ||
|
|
458
|
+
hit.sourceIdentity?.repo ||
|
|
459
|
+
hit.native?.repo ||
|
|
460
|
+
"";
|
|
461
|
+
if (repoField) {
|
|
462
|
+
return { repo: String(repoField).replace(/^github\.com\//, "").replace(/^https?:\/\/github\.com\//, ""), skillDir: "", apiFallback: true };
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
} catch {
|
|
466
|
+
// API also unreachable — fall through to the error below.
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const detailUrl = `https://clawhub.ai/${owner}/skills/${slug}`;
|
|
470
|
+
throw new Error(
|
|
471
|
+
`clawhub 页面与 API 里都没有找到 GitHub 源仓库(${detailUrl})——可直接在浏览器中打开该页查看详情`,
|
|
472
|
+
);
|
|
408
473
|
}
|