skillmkt 0.4.39 → 0.4.41
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.
|
@@ -50,7 +50,8 @@ async function fetchTarball(owner, repo, ref, { mirror = null } = {}) {
|
|
|
50
50
|
export async function fetchSkill({ owner, repo, ref = null, path: sub = null, mirror = null }) {
|
|
51
51
|
const sha = headSha(owner, repo, ref) || ref || 'HEAD';
|
|
52
52
|
const got = await fetchTarball(owner, repo, sha, { mirror });
|
|
53
|
-
|
|
53
|
+
const hint = /\./.test(owner) ? L(`(${owner} 看着是私有源域名,不是 GitHub 组织——skills.sh 私有源 skill 目前装不了)`, ` (${owner} looks like a private registry domain, not a GitHub owner — private-source skills aren't installable yet)`) : '';
|
|
54
|
+
if (!got) throw new Error(`fetch failed: ${owner}/${repo}@${sha}${L('(直连与镜像均不可达)', ' (direct and mirror both unreachable)')}${hint}`);
|
|
54
55
|
execFileSync('tar', ['xzf', got.tar, '-C', got.tmp]);
|
|
55
56
|
const root = fs.readdirSync(got.tmp).find((d) => d.startsWith(`${owner.replace(/\W/g, '')}`) || d.includes('-'))
|
|
56
57
|
?? fs.readdirSync(got.tmp).find((d) => fs.statSync(path.join(got.tmp, d)).isDirectory());
|
|
@@ -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,6 +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: '私有源暂不可装', mk_privsrc: '私有源',
|
|
83
84
|
sk_remove: '移除', sk_remove_sure: '再点一次确认', sk_removed: '已移除',
|
|
84
85
|
det_btn: '详情', det_files: (n) => `${n} 个文件`, det_diff: '上游 diff', det_rollback: '回滚上一版',
|
|
85
86
|
ext_h: (n) => `agent 目录里没收编的 skill(${n})`,
|
|
@@ -164,6 +165,7 @@ const I18N = {
|
|
|
164
165
|
mk_ph: 'keywords, or paste owner/repo / absolute path', mk_search: 'Search', mk_direct: 'Install input as ref/path', mk_install: 'Install',
|
|
165
166
|
mk_busy: 'Working…', ins_done: 'Done', ins_fail: (c) => `Failed (exit ${c})`,
|
|
166
167
|
mk_susp: 'Audit flagged this suspicious — install anyway?', mk_force: 'Install anyway', ext_force: 'Adopt anyway',
|
|
168
|
+
mk_nosrc: 'private source — N/A', mk_privsrc: 'private source',
|
|
167
169
|
sk_remove: 'Remove', sk_remove_sure: 'Click again to confirm', sk_removed: 'Removed',
|
|
168
170
|
det_btn: 'Details', det_files: (n) => `${n} files`, det_diff: 'Upstream diff', det_rollback: 'Rollback a version',
|
|
169
171
|
ext_h: (n) => `Unmanaged skills in agent dirs (${n})`,
|
|
@@ -388,10 +390,13 @@ async function render() {
|
|
|
388
390
|
};
|
|
389
391
|
const renderResults = () => {
|
|
390
392
|
res.innerHTML = (mkState.results || []).map((s) => {
|
|
391
|
-
|
|
393
|
+
// github 源(source 含 /)用 owner/repo+path;私有源(uizze.sh 等)直接以 slug 走 wellknown 适配器
|
|
394
|
+
const src = s.source || '', repo = src.includes('/') ? src : null;
|
|
395
|
+
const ref = repo || s.slug, sub = repo && s.slug.startsWith(src + '/') ? s.slug.slice(src.length + 1) : '';
|
|
392
396
|
const done = mkState.installed.has(s.slug), perm = mkState.perm.has(s.slug);
|
|
393
|
-
|
|
394
|
-
|
|
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>
|
|
395
400
|
<span class="iout mut">${esc(mkState.status[s.slug] || '')}</span></div>`;
|
|
396
401
|
}).join('') || (mkState.results ? `<div class="empty">${t('cf_empty')}</div>` : '');
|
|
397
402
|
res.querySelectorAll('.mk-i').forEach((b) => b.onclick = () =>
|