@morehao/dsh-skills-console 0.5.3 → 0.5.5

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/routes.js CHANGED
@@ -118,10 +118,20 @@ function matchRoute(method, pathname) {
118
118
  if (segments.length === 2 && segments[1] === 'rollback' && method === 'POST') return { name: 'updates.rollback' };
119
119
  }
120
120
 
121
+ // 插件自身版本检查 / 更新(与技能上游 updates.* 是两回事,见 core/plugin-update.js)
122
+ if (segments.length === 1 && segments[0] === 'plugin-update' && method === 'GET') return { name: 'plugin.update.check' };
123
+ if (segments.length === 2 && segments[0] === 'plugin-update' && segments[1] === 'apply' && method === 'POST') {
124
+ return { name: 'plugin.update.apply' };
125
+ }
126
+ // 拉某版本的发布说明(GitHub Release 正文):GET /plugin-update/release?version=x.y.z
127
+ if (segments.length === 2 && segments[0] === 'plugin-update' && segments[1] === 'release' && method === 'GET') {
128
+ return { name: 'plugin.update.release' };
129
+ }
130
+
121
131
  return null;
122
132
  }
123
133
 
124
- export function createRoutes({ service, logger }) {
134
+ export function createRoutes({ service, pluginUpdate = null, logger }) {
125
135
  return async function handler(req, res) {
126
136
  const url = new URL(req.url || '/', 'http://127.0.0.1');
127
137
  const pathname = url.pathname.startsWith(ROUTE_PREFIX)
@@ -153,7 +163,7 @@ export function createRoutes({ service, logger }) {
153
163
  service.reloadState();
154
164
  const body = method === 'GET' ? {} : await readBody(req);
155
165
  const query = Object.fromEntries(url.searchParams.entries());
156
- const result = await dispatch(route, { body, query, service, signal: abort.signal });
166
+ const result = await dispatch(route, { body, query, service, pluginUpdate, signal: abort.signal });
157
167
  // 生成期间客户端可能已经走了:往已关闭的响应写会抛 ERR_STREAM_WRITE_AFTER_END
158
168
  if (res.writableEnded || res.destroyed) return;
159
169
  sendJson(res, 200, result);
@@ -181,7 +191,7 @@ export function createRoutes({ service, logger }) {
181
191
  };
182
192
  }
183
193
 
184
- async function dispatch(route, { body, query, service, signal = null }) {
194
+ async function dispatch(route, { body, query, service, pluginUpdate = null, signal = null }) {
185
195
  switch (route.name) {
186
196
  case 'state': {
187
197
  const state = await service.getState({ cwd: query.cwd || body.cwd, workspace: query.workspace });
@@ -257,6 +267,19 @@ async function dispatch(route, { body, query, service, signal = null }) {
257
267
  return service.applyUpdate({ name: body.name, token: body.token, overwrite: Boolean(body.overwrite) });
258
268
  case 'updates.rollback':
259
269
  return service.rollback({ name: body.name });
270
+ case 'plugin.update.check': {
271
+ if (!pluginUpdate) throw new ServiceError('error.plugin-update.unavailable', '插件自更新不可用');
272
+ return pluginUpdate.check({ fresh: query.fresh === '1' || body.fresh === true });
273
+ }
274
+ case 'plugin.update.apply': {
275
+ if (!pluginUpdate) throw new ServiceError('error.plugin-update.unavailable', '插件自更新不可用');
276
+ return pluginUpdate.apply();
277
+ }
278
+ case 'plugin.update.release': {
279
+ if (!pluginUpdate) throw new ServiceError('error.plugin-update.unavailable', '插件自更新不可用');
280
+ const version = query.version || body.version;
281
+ return pluginUpdate.releaseNotes(version);
282
+ }
260
283
  default:
261
284
  throw new ServiceError('error.skills.no-route', `unhandled route ${route.name}`);
262
285
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morehao/dsh-skills-console",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "统一管理本地技能的安装、更新、删除与接入,让同一份技能在多个 Agent 间复用。A skill manager for DeepSeek Harness: install, update, remove, link and toggle agent skills.",
5
5
  "license": "MIT",
6
6
  "author": "morehao <morehao@qq.com>",