@michengai/dsh-skills-manager 1.2.11 → 1.2.13

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/lib/core.js CHANGED
@@ -1194,7 +1194,7 @@ function defaultManagerState() {
1194
1194
  disabledSkills[root.key] = [];
1195
1195
  enabledSkills[root.key] = [];
1196
1196
  }
1197
- return { version: 1, sources, disabledSkills, enabledSkills, sidebarEntry: false, categories: /* @__PURE__ */ Object.create(null), categoryMembers: /* @__PURE__ */ Object.create(null), categoryOrder: /* @__PURE__ */ Object.create(null) };
1197
+ return { version: 1, sources, disabledSkills, enabledSkills, sidebarEntry: false, onlineUpdate: true, categories: /* @__PURE__ */ Object.create(null), categoryMembers: /* @__PURE__ */ Object.create(null), categoryOrder: /* @__PURE__ */ Object.create(null) };
1198
1198
  }
1199
1199
  function validStateSkillName(name) {
1200
1200
  return validDiscoveryName(name);
@@ -1223,6 +1223,7 @@ function validManagerStateDocument(value) {
1223
1223
  if (!validPolicyLists(value.disabledSkills) || !validPolicyLists(value.enabledSkills, true))
1224
1224
  return false;
1225
1225
  if (value.sidebarEntry !== void 0 && typeof value.sidebarEntry !== "boolean") return false;
1226
+ if (value.onlineUpdate !== void 0 && typeof value.onlineUpdate !== "boolean") return false;
1226
1227
  for (const root of userRoots()) {
1227
1228
  if (root.key === "dsh") {
1228
1229
  if (value.sources.dsh !== void 0 && typeof value.sources.dsh !== "boolean") return false;
@@ -1266,6 +1267,9 @@ function normalizeManagerState(value) {
1266
1267
  if (typeof value.sidebarEntry === "boolean") {
1267
1268
  normalized.sidebarEntry = value.sidebarEntry;
1268
1269
  }
1270
+ if (typeof value.onlineUpdate === "boolean") {
1271
+ normalized.onlineUpdate = value.onlineUpdate;
1272
+ }
1269
1273
  for (const root of userRoots()) {
1270
1274
  if (value.sources && typeof value.sources[root.key] === "boolean")
1271
1275
  normalized.sources[root.key] = value.sources[root.key];
@@ -1451,6 +1455,22 @@ async function setSidebarEntry(enabled) {
1451
1455
  await writeManagerState(current.state);
1452
1456
  return enabled;
1453
1457
  }
1458
+ async function getOnlineUpdate() {
1459
+ const current = await readManagerState();
1460
+ return current.state.onlineUpdate !== false;
1461
+ }
1462
+ async function setOnlineUpdate(enabled) {
1463
+ if (typeof enabled !== "boolean") {
1464
+ throw codedError("onlineUpdate must be a boolean", "error.proto.invalidParams");
1465
+ }
1466
+ const current = await readManagerState();
1467
+ if (current.writable === false) {
1468
+ throw codedError("manager state file is read-only", "error.state.invalid");
1469
+ }
1470
+ current.state.onlineUpdate = enabled;
1471
+ await writeManagerState(current.state);
1472
+ return enabled;
1473
+ }
1454
1474
  async function setSourceEnabled(key, enabled, log, options = {}) {
1455
1475
  let root = rootByKey(key);
1456
1476
  if (!root && PROJECT_ROOT_KEY_RE.test(key) && !key.startsWith("project-dsh:"))
@@ -3107,6 +3127,7 @@ export {
3107
3127
  deleteCategory,
3108
3128
  deleteSkill,
3109
3129
  entryPath,
3130
+ getOnlineUpdate,
3110
3131
  getProviderSkill,
3111
3132
  getSidebarEntry,
3112
3133
  importSkill,
@@ -3135,6 +3156,7 @@ export {
3135
3156
  restoreTrash,
3136
3157
  scanEntries,
3137
3158
  setCategoryEnabled,
3159
+ setOnlineUpdate,
3138
3160
  setSidebarEntry,
3139
3161
  setSkillEnabled,
3140
3162
  setSourceEnabled,
package/lib/index.js CHANGED
@@ -23,7 +23,9 @@ import {
23
23
  workspaceSkills,
24
24
  logPath,
25
25
  getSidebarEntry,
26
- setSidebarEntry
26
+ setSidebarEntry,
27
+ getOnlineUpdate,
28
+ setOnlineUpdate
27
29
  } from "./core.js";
28
30
  import { registerPluginUpdater } from "./plugin-updater.js";
29
31
  import { createRepositoryManager } from "./repositories.js";
@@ -278,11 +280,17 @@ function registerAgentSkillProviders(ctx, invalidators) {
278
280
  registrations.clear();
279
281
  };
280
282
  }
281
- function apply(ctx) {
283
+ function apply(ctx, config) {
284
+ const hostDisabled = config?.updater === false || config?.onlineUpdate === false;
285
+ const isUpdateEnabled = async () => {
286
+ if (hostDisabled) return false;
287
+ return await getOnlineUpdate();
288
+ };
282
289
  ctx.effect(() => registerPluginUpdater(ctx, {
283
290
  endpoint: "/api/michengai/dsh-skills-manager/update",
284
291
  packageName: "@michengai/dsh-skills-manager",
285
- manifestUrl: new URL("../package.json", import.meta.url)
292
+ manifestUrl: new URL("../package.json", import.meta.url),
293
+ isEnabled: isUpdateEnabled
286
294
  }), "skills-manager: plugin updater");
287
295
  const log = makeLog();
288
296
  const repositories = createRepositoryManager({ log, registeredWorkspaces: () => registeredWorkspacePaths(ctx) });
@@ -398,6 +406,9 @@ function apply(ctx) {
398
406
  if (req.method === "GET" && path === "/api/dsh-skills-manager/sidebar-entry") {
399
407
  return run(res, async () => ({ enabled: await getSidebarEntry() }));
400
408
  }
409
+ if (req.method === "GET" && path === "/api/dsh-skills-manager/online-update") {
410
+ return run(res, async () => ({ enabled: await isUpdateEnabled(), locked: hostDisabled }));
411
+ }
401
412
  if ((req.method === "GET" || req.method === "HEAD") && path === "/api/dsh-skills-manager/workspaces") {
402
413
  return run(res, async () => ({ items: await listWorkspaces(registeredWorkspacePaths(ctx) ?? []) }), void 0, req.method === "HEAD");
403
414
  }
@@ -425,6 +436,7 @@ function apply(ctx) {
425
436
  if (req.method === "HEAD") {
426
437
  if (path === "/api/dsh-skills-manager/state") return run(res, stateWithSources, void 0, true);
427
438
  if (path === "/api/dsh-skills-manager/sidebar-entry") return run(res, async () => ({ enabled: await getSidebarEntry() }), void 0, true);
439
+ if (path === "/api/dsh-skills-manager/online-update") return run(res, async () => ({ enabled: await isUpdateEnabled(), locked: hostDisabled }), void 0, true);
428
440
  json(res, 405, { ok: false, code: "error.proto.method", error: `method not allowed: ${req.method}` }, true);
429
441
  return;
430
442
  }
@@ -468,6 +480,17 @@ function apply(ctx) {
468
480
  const enabled = await setSidebarEntry(body.enabled);
469
481
  return { enabled };
470
482
  });
483
+ case "/api/dsh-skills-manager/online-update":
484
+ return run(res, async () => {
485
+ if (!body || typeof body.enabled !== "boolean") {
486
+ throw Object.assign(new Error("enabled \u5FC5\u987B\u662F\u5E03\u5C14\u503C"), { statusCode: 400, code: "error.proto.invalidParams" });
487
+ }
488
+ if (hostDisabled) {
489
+ throw Object.assign(new Error("\u5728\u7EBF\u66F4\u65B0\u5DF2\u88AB\u5BBF\u4E3B\u914D\u7F6E\u9501\u5B9A\u7981\u7528"), { statusCode: 403, code: "error.update.disabled" });
490
+ }
491
+ const enabled = await setOnlineUpdate(body.enabled);
492
+ return { enabled };
493
+ });
471
494
  case "/api/dsh-skills-manager/repositories/add":
472
495
  return run(res, () => repositories.add(body));
473
496
  case "/api/dsh-skills-manager/repositories/remove":
@@ -471,6 +471,13 @@ function registerPluginUpdater(ctx, options) {
471
471
  path: options.endpoint,
472
472
  handler: async (request, response) => {
473
473
  try {
474
+ if (options.isEnabled) {
475
+ const allowed = await options.isEnabled();
476
+ if (!allowed) {
477
+ json(response, 403, { ok: false, code: "error.update.disabled", error: "\u5728\u7EBF\u66F4\u65B0\u5DF2\u88AB\u7981\u7528\u3002" });
478
+ return;
479
+ }
480
+ }
474
481
  const target = runtime(host);
475
482
  if (request.method === "GET" || request.method === "HEAD") {
476
483
  const payload = await status(options, target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-skills-manager",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
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/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",
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/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",