skillmkt 0.4.40 → 0.4.42
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// registries/index.js — 按 ref/type 路由适配器 + fetch mirror 前缀
|
|
2
2
|
import * as github from './github.js';
|
|
3
3
|
import * as skillssh from './skillssh.js';
|
|
4
|
+
import * as wellknown from './wellknown.js';
|
|
4
5
|
import * as rfc from './rfc.js';
|
|
5
6
|
import { L } from '../i18n.js';
|
|
6
7
|
|
|
@@ -20,6 +21,8 @@ export function fetchMirror(ctx) {
|
|
|
20
21
|
export async function fetchRef(ref, ctx) {
|
|
21
22
|
const mirror = fetchMirror(ctx);
|
|
22
23
|
if (ref.kind === 'github') {
|
|
24
|
+
// GitHub owner 不允许点号——owner/repo 形态带点必为 skills.sh 私有源 slug
|
|
25
|
+
if (/\./.test(ref.owner)) return wellknown.fetchSkill({ slug: `${ref.owner}/${ref.repo}${ref.path ? `/${ref.path}` : ''}` });
|
|
23
26
|
return github.fetchSkill({ ...ref, mirror });
|
|
24
27
|
}
|
|
25
28
|
if (ref.kind === 'named' && (!ref.registry || ref.registry === 'skillssh' || ref.registry === 'github')) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// wellknown.js — skills.sh 私有源适配器:详情页(.site)提取 .well-known/agent-skills/ 文件清单逐文件拉
|
|
2
|
+
// 私有源(uizze.sh/smithery.ai 等)没有 git 坐标——slug 即定位符
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { L } from '../i18n.js';
|
|
7
|
+
|
|
8
|
+
const UA = { 'user-agent': 'skillmkt' };
|
|
9
|
+
const SITE = (slug) => `https://www.skills.sh/site/${slug}`;
|
|
10
|
+
|
|
11
|
+
// fetchSkill({slug}) → {dir, tmp, provenance}——与 github.fetchSkill 同型
|
|
12
|
+
export async function fetchSkill({ slug, ctx = null }) {
|
|
13
|
+
// ① 详情页抓 .well-known/agent-skills/ 全量文件 URL(页面转义成 …md\,去尾\)
|
|
14
|
+
const page = await fetch(SITE(slug), { headers: UA, signal: AbortSignal.timeout(12e3) })
|
|
15
|
+
.then((r) => (r.ok ? r.text() : null))
|
|
16
|
+
.catch(() => null);
|
|
17
|
+
if (!page) throw new Error(L(`skills.sh 详情页打不开: ${slug}(私有源/已下架?)`, `skills.sh detail page unreachable: ${slug} (private source or delisted?)`));
|
|
18
|
+
const urls = [...new Set(
|
|
19
|
+
(page.match(/https?:\\?\/\\?\/[^"'<>\\\s]+\.well-known\/agent-skills\/[^"'<>\\\s]+/g) || [])
|
|
20
|
+
.map((u) => u.replace(/\\/g, '').replace(/[.,;)}\]]+$/, ''))
|
|
21
|
+
)];
|
|
22
|
+
// ② 推导 skillId 与文件相对路径;SKILL.md 兜底必拉
|
|
23
|
+
const idM = urls.map((u) => u.match(/\.well-known\/agent-skills\/([^/]+)\//)?.[1]).find(Boolean);
|
|
24
|
+
const skillId = idM || slug.split('/').pop();
|
|
25
|
+
const host = urls[0] ? new URL(urls[0]).origin : `https://${slug.split('/')[0]}`;
|
|
26
|
+
const rels = new Set(urls
|
|
27
|
+
.map((u) => u.split(`.well-known/agent-skills/${skillId}/`)[1])
|
|
28
|
+
.filter(Boolean));
|
|
29
|
+
rels.add('SKILL.md');
|
|
30
|
+
|
|
31
|
+
// ③ 逐文件拉取(无 manifest 可列——页面给的即全量)
|
|
32
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'skillmkt-wk-'));
|
|
33
|
+
const dir = path.join(tmp, skillId);
|
|
34
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
35
|
+
const got = [];
|
|
36
|
+
for (const rel of rels) {
|
|
37
|
+
const url = `${host}/.well-known/agent-skills/${skillId}/${rel}`;
|
|
38
|
+
try {
|
|
39
|
+
const res = await fetch(url, { headers: UA, signal: AbortSignal.timeout(15e3), redirect: 'follow' });
|
|
40
|
+
if (!res.ok) continue;
|
|
41
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
42
|
+
const dest = path.join(dir, rel);
|
|
43
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
44
|
+
fs.writeFileSync(dest, buf);
|
|
45
|
+
got.push(rel);
|
|
46
|
+
} catch { /* 单文件失败不致命——SKILL.md 在就行 */ }
|
|
47
|
+
}
|
|
48
|
+
if (!got.includes('SKILL.md')) throw new Error(L(`${slug}: SKILL.md 拉不到——私有源结构对不上`, `${slug}: cannot fetch SKILL.md — private source layout unrecognized`));
|
|
49
|
+
return {
|
|
50
|
+
dir, tmp, sha: null,
|
|
51
|
+
provenance: { registry: 'wellknown', ref: slug, path: null, pin: null, via: 'skills.sh-site', files: got.length },
|
|
52
|
+
};
|
|
53
|
+
}
|
package/client/public/app.js
CHANGED
|
@@ -80,7 +80,7 @@ const I18N = {
|
|
|
80
80
|
mk_ph: '搜关键词,或粘 owner/repo / 绝对路径', mk_search: '搜索', mk_direct: '按输入直接安装', mk_install: '安装',
|
|
81
81
|
mk_busy: '处理中…', ins_done: '完成', ins_fail: (c) => `失败(退出码 ${c})`,
|
|
82
82
|
mk_susp: '审核判为可疑——了解风险后仍要装?', mk_force: '仍要安装', ext_force: '仍要收编',
|
|
83
|
-
mk_nosrc: '私有源暂不可装',
|
|
83
|
+
mk_nosrc: '私有源暂不可装', mk_privsrc: '私有源',
|
|
84
84
|
sk_remove: '移除', sk_remove_sure: '再点一次确认', sk_removed: '已移除',
|
|
85
85
|
det_btn: '详情', det_files: (n) => `${n} 个文件`, det_diff: '上游 diff', det_rollback: '回滚上一版',
|
|
86
86
|
ext_h: (n) => `agent 目录里没收编的 skill(${n})`,
|
|
@@ -165,7 +165,7 @@ const I18N = {
|
|
|
165
165
|
mk_ph: 'keywords, or paste owner/repo / absolute path', mk_search: 'Search', mk_direct: 'Install input as ref/path', mk_install: 'Install',
|
|
166
166
|
mk_busy: 'Working…', ins_done: 'Done', ins_fail: (c) => `Failed (exit ${c})`,
|
|
167
167
|
mk_susp: 'Audit flagged this suspicious — install anyway?', mk_force: 'Install anyway', ext_force: 'Adopt anyway',
|
|
168
|
-
mk_nosrc: 'private source — N/A',
|
|
168
|
+
mk_nosrc: 'private source — N/A', mk_privsrc: 'private source',
|
|
169
169
|
sk_remove: 'Remove', sk_remove_sure: 'Click again to confirm', sk_removed: 'Removed',
|
|
170
170
|
det_btn: 'Details', det_files: (n) => `${n} files`, det_diff: 'Upstream diff', det_rollback: 'Rollback a version',
|
|
171
171
|
ext_h: (n) => `Unmanaged skills in agent dirs (${n})`,
|
|
@@ -260,9 +260,9 @@ async function render() {
|
|
|
260
260
|
app.innerHTML = `<h2>${t('sk_h', skills.length)}</h2>
|
|
261
261
|
<p class="desc">${t('sk_desc')}</p>`
|
|
262
262
|
+ (skills.map(([n, s]) => `
|
|
263
|
-
<div class="card"><div class="
|
|
264
|
-
<span class="
|
|
265
|
-
<
|
|
263
|
+
<div class="card"><div class="sk-head"><b>${esc(n)}</b><span class="mut">${esc(s.version || '')}</span><span class="mut">${esc(s.source?.registry || '')}</span>${pill(s.audit || 'clean')}
|
|
264
|
+
<span class="acts"><button data-dt="${esc(n)}">${t('det_btn')}</button><button data-rm="${esc(n)}">${t('sk_remove')}</button></span></div>
|
|
265
|
+
<div class="trow"><span class="mut">${t('sk_at')}</span>${(s.targets || []).map((x) => `<span class="tchip">${esc(x)}</span>`).join('') || `<span class="mut">${t('sk_hub')}</span>`}<button class="sm" data-tg="${esc(n)}">${t('sk_loc')}</button></div>
|
|
266
266
|
<div class="tgbox" data-box="${esc(n)}" style="display:none;margin-top:10px"></div>
|
|
267
267
|
<div class="dtbox" data-dbox="${esc(n)}" style="display:none;margin-top:10px"></div></div>`).join('')
|
|
268
268
|
|| `<div class="empty">${t('sk_empty')}</div>`)
|
|
@@ -390,13 +390,13 @@ async function render() {
|
|
|
390
390
|
};
|
|
391
391
|
const renderResults = () => {
|
|
392
392
|
res.innerHTML = (mkState.results || []).map((s) => {
|
|
393
|
-
// source
|
|
393
|
+
// github 源(source 含 /)用 owner/repo+path;私有源(uizze.sh 等)直接以 slug 走 wellknown 适配器
|
|
394
394
|
const src = s.source || '', repo = src.includes('/') ? src : null;
|
|
395
|
-
const sub = repo && s.slug.startsWith(src + '/') ? s.slug.slice(src.length + 1) : '';
|
|
395
|
+
const ref = repo || s.slug, sub = repo && s.slug.startsWith(src + '/') ? s.slug.slice(src.length + 1) : '';
|
|
396
396
|
const done = mkState.installed.has(s.slug), perm = mkState.perm.has(s.slug);
|
|
397
|
-
const label =
|
|
398
|
-
return `<div class="card row"><b>${esc(s.name)}</b><span class="mut">${esc(s.slug)} · ${s.installs} installs</span>
|
|
399
|
-
<button class="mk-i" style="margin-left:auto" data-s="${esc(s.slug)}" data-r="${esc(
|
|
397
|
+
const label = done ? t('ins_done') : perm ? t('mk_force') : t('mk_install');
|
|
398
|
+
return `<div class="card row"><b>${esc(s.name)}</b><span class="mut">${esc(s.slug)} · ${s.installs} installs${repo ? '' : ` · ${t('mk_privsrc')}`}</span>
|
|
399
|
+
<button class="mk-i" style="margin-left:auto" data-s="${esc(s.slug)}" data-r="${esc(ref)}" data-p="${esc(sub)}" ${done ? 'disabled' : ''}>${label}</button>
|
|
400
400
|
<span class="iout mut">${esc(mkState.status[s.slug] || '')}</span></div>`;
|
|
401
401
|
}).join('') || (mkState.results ? `<div class="empty">${t('cf_empty')}</div>` : '');
|
|
402
402
|
res.querySelectorAll('.mk-i').forEach((b) => b.onclick = () =>
|
package/client/public/index.html
CHANGED
|
@@ -51,6 +51,12 @@ code { font-family: var(--font-mono); font-size: 0.9em; background: color-mix(in
|
|
|
51
51
|
|
|
52
52
|
.card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius);
|
|
53
53
|
padding: 18px 20px; margin-bottom: 14px; }
|
|
54
|
+
.sk-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
55
|
+
.sk-head .acts { margin-left: auto; display: flex; gap: 8px; }
|
|
56
|
+
.trow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
|
|
57
|
+
.tchip { display: inline-block; padding: 2px 11px; border: 1px solid var(--color-line); border-radius: 99px;
|
|
58
|
+
font-size: 13.5px; line-height: 1.6; color: var(--color-ink-mut); background: var(--color-paper); white-space: nowrap; }
|
|
59
|
+
button.sm { font-size: 13.5px; padding: 4px 12px; }
|
|
54
60
|
.card h3 { font: 600 17px/1.3 var(--font-body); margin: 0 0 6px; }
|
|
55
61
|
.row { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
|
|
56
62
|
.row.end { justify-content: flex-end; }
|