@michengai/dsh-skills-manager 1.2.21 → 1.2.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/CHANGELOG.md +20 -0
- package/CHANGELOG.zh-CN.md +20 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/lib/client.js +6 -6
- package/lib/core.js +14 -11
- package/lib/index.js +503 -357
- package/lib/plugin-updater.js +60 -0
- package/package.json +2 -2
package/lib/plugin-updater.js
CHANGED
|
@@ -466,6 +466,66 @@ function publicError(error) {
|
|
|
466
466
|
function registerPluginUpdater(ctx, options) {
|
|
467
467
|
const host = ctx;
|
|
468
468
|
let installing = false;
|
|
469
|
+
if (host.connection?.fetch?.register) {
|
|
470
|
+
return host.connection.fetch.register({
|
|
471
|
+
path: options.endpoint,
|
|
472
|
+
methods: ["GET", "HEAD", "POST"],
|
|
473
|
+
requestBody: "buffered",
|
|
474
|
+
fetch: async (request) => {
|
|
475
|
+
try {
|
|
476
|
+
if (options.isEnabled) {
|
|
477
|
+
const allowed = await options.isEnabled();
|
|
478
|
+
if (!allowed) {
|
|
479
|
+
return Response.json({ ok: false, code: "error.update.disabled", error: "\u5728\u7EBF\u66F4\u65B0\u5DF2\u88AB\u7981\u7528\u3002" }, { status: 403, headers: { "cache-control": "no-store" } });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const target = runtime(host);
|
|
483
|
+
if (request.method === "GET" || request.method === "HEAD") {
|
|
484
|
+
const payload = await status(options, target);
|
|
485
|
+
return new Response(request.method === "HEAD" ? null : JSON.stringify(payload), {
|
|
486
|
+
status: 200,
|
|
487
|
+
headers: { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" }
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
if (request.method !== "POST") {
|
|
491
|
+
return new Response(null, { status: 405, headers: { allow: "GET, HEAD, POST" } });
|
|
492
|
+
}
|
|
493
|
+
if (request.headers.get(PLUGIN_UPDATE_HEADER) !== "1") {
|
|
494
|
+
return Response.json({ error: "\u5DF2\u62D2\u7EDD\u975E\u540C\u6E90\u4E13\u7528\u66F4\u65B0\u8BF7\u6C42\u3002" }, { status: 403 });
|
|
495
|
+
}
|
|
496
|
+
if (installing) {
|
|
497
|
+
return Response.json({ error: "\u5F53\u524D\u63D2\u4EF6\u6B63\u5728\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u5019\u3002" }, { status: 409 });
|
|
498
|
+
}
|
|
499
|
+
const before = await status(options, target);
|
|
500
|
+
if (before.latestVersion === void 0) {
|
|
501
|
+
return Response.json({ error: "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u6700\u65B0\u7248\u672C\u3002" }, { status: 503 });
|
|
502
|
+
}
|
|
503
|
+
if (!before.updateAvailable) {
|
|
504
|
+
return Response.json(before, { status: 200 });
|
|
505
|
+
}
|
|
506
|
+
installing = true;
|
|
507
|
+
try {
|
|
508
|
+
await install(target, `${options.packageName}@${before.latestVersion}`);
|
|
509
|
+
} finally {
|
|
510
|
+
installing = false;
|
|
511
|
+
}
|
|
512
|
+
const notifyParent = shouldNotifyParent(target);
|
|
513
|
+
const autoReload = target.desktopPnpm !== void 0 || notifyParent;
|
|
514
|
+
const body = { ...before, updatedVersion: before.latestVersion, restartRequired: true, autoReload, ...target.officialDesktop ? { restartDesktop: true } : {} };
|
|
515
|
+
if (notifyParent) setTimeout(() => {
|
|
516
|
+
process.send?.(PLUGIN_UPDATE_IPC);
|
|
517
|
+
}, 150).unref?.();
|
|
518
|
+
return Response.json(body, { status: 200 });
|
|
519
|
+
} catch (caught) {
|
|
520
|
+
const error = caught;
|
|
521
|
+
ctx.logger?.warn?.(`plugin updater failed: ${String(error)}`);
|
|
522
|
+
return Response.json({ error: publicError(error) }, { status: 503 });
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
if (!host.webServer?.register) return () => {
|
|
528
|
+
};
|
|
469
529
|
return host.webServer.register({
|
|
470
530
|
kind: "exact",
|
|
471
531
|
path: options.endpoint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-skills-manager",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.23",
|
|
4
4
|
"description": "DSH Skills Manager — 在 DeepSeek Harness 中统一加载并安全管理本机 Agent Skills · Load and safely manage local Agent Skills in DSH",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node scripts/build.mjs",
|
|
46
|
-
"test": "node scripts/check-committed-lib.mjs && npm run typecheck && npm run build && node test/build-test.mjs && node test/api-base.test.mjs && node test/route-lifecycle.test.mjs && node test/repositories.test.mjs && node test/repository-install-targets.test.mjs && node test/workspace-target.test.mjs && node test/workspace-routes.test.mjs && node test/workspace-list.test.mjs && node test/destination-picker.test.mjs && node test/workspace-project-page.test.mjs && node test/repository-ui.test.mjs && node test/catalog-skill.test.mjs && node test/skills-sh-catalog.test.mjs && node test/clawhub-catalog.test.mjs && node --test test/catalog-state.test.mjs test/catalog-lifecycle.test.mjs && node test/theme-select.test.mjs && node --test test/antd-theme.browser.test.mjs && node test/host-fallback.test.mjs && node test/repository-routes.test.mjs && node test/core-test.mjs && node test/root-path.test.mjs && node test/custom-sources.test.mjs && node test/disabled-external-native.test.mjs && node test/categories.test.mjs && node test/categories-ui.test.mjs && node --experimental-strip-types --test test/settings-nav-icon.test.mjs && node test/readonly-discovery.test.mjs && node test/project-root-skills.test.mjs && node test/project-sources.test.mjs && node test/locale-test.mjs && node --test test/plugin-updater.test.mjs && node test/plugin-update-locale.test.mjs && node test/client-scope.test.mjs && node test/compatibility-options-test.mjs && node test/sidebar-entry.test.mjs && node --test test/sidebar-entry-lifecycle.test.mjs test/plugin-update-visibility.test.mjs && node test/online-update.test.mjs",
|
|
46
|
+
"test": "node scripts/check-committed-lib.mjs && npm run typecheck && npm run build && node test/build-test.mjs && node test/api-base.test.mjs && node test/route-lifecycle.test.mjs && node test/repositories.test.mjs && node test/repository-install-targets.test.mjs && node test/workspace-target.test.mjs && node test/workspace-routes.test.mjs && node test/workspace-list.test.mjs && node test/destination-picker.test.mjs && node test/workspace-project-page.test.mjs && node test/repository-ui.test.mjs && node test/catalog-skill.test.mjs && node test/skills-sh-catalog.test.mjs && node test/clawhub-catalog.test.mjs && node --test test/catalog-state.test.mjs test/catalog-lifecycle.test.mjs && node test/theme-select.test.mjs && node --test test/antd-theme.browser.test.mjs && node test/host-fallback.test.mjs && node test/host-fence.test.mjs && node --test test/fetch-routes.test.mjs && node test/repository-routes.test.mjs && node test/core-test.mjs && node test/root-path.test.mjs && node test/custom-sources.test.mjs && node test/disabled-external-native.test.mjs && node test/categories.test.mjs && node test/categories-ui.test.mjs && node --experimental-strip-types --test test/settings-nav-icon.test.mjs && node test/readonly-discovery.test.mjs && node test/project-root-skills.test.mjs && node test/project-sources.test.mjs && node test/locale-test.mjs && node --test test/plugin-updater.test.mjs && node test/plugin-update-locale.test.mjs && node test/client-scope.test.mjs && node test/compatibility-options-test.mjs && node test/sidebar-entry.test.mjs && node --test test/sidebar-entry-lifecycle.test.mjs test/plugin-update-visibility.test.mjs && node test/online-update.test.mjs",
|
|
47
47
|
"verify": "node scripts/sync-hosts.mjs && npm test && npm run pack:check && node test/pack-test.mjs",
|
|
48
48
|
"pack:check": "npm pack --dry-run --json",
|
|
49
49
|
"prepack": "npm run typecheck && npm run build",
|