dsh-agent-skills 0.1.7 → 0.1.9

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/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # dsh-agent-skills
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/dsh-agent-skills)](https://www.npmjs.com/package/dsh-agent-skills)
4
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-agent-skills)](https://www.npmjs.com/package/dsh-agent-skills)
4
5
  [![license](https://img.shields.io/npm/l/dsh-agent-skills)](./LICENSE)
5
6
  [![DeepSeek Harness plugin](https://img.shields.io/badge/DSH-plugin-4f46e5)](https://github.com/deepseek-ai/deepseek-harness)
7
+ [![dsh-recommend](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fzp-home%2Fdsh-recommend%2Fmain%2Fdata%2Fbadges%2Fminivv__dsh-agent-skills.certified.json)](https://github.com/zp-home/dsh-recommend)
6
8
 
7
9
  在 DeepSeek Harness 的设置页中查看、启停和管理本地 Agent Skills。
8
10
 
package/lib/client.js CHANGED
@@ -236,7 +236,12 @@ function AgentSkillsSection({ api, t }) {
236
236
  const [view, setView] = (0, import_react.useState)(void 0);
237
237
  const [takeover, setTakeover] = (0, import_react.useState)(void 0);
238
238
  const [takeoverRestartRequired, setTakeoverRestartRequired] = (0, import_react.useState)(false);
239
- const [restarting, setRestarting] = (0, import_react.useState)(false);
239
+ const [restarting, setRestartingState] = (0, import_react.useState)(false);
240
+ const restartingRef = (0, import_react.useRef)(false);
241
+ const setRestarting = (0, import_react.useCallback)((next) => {
242
+ restartingRef.current = next;
243
+ setRestartingState(next);
244
+ }, []);
240
245
  const [busy, setBusy] = (0, import_react.useState)(true);
241
246
  const [error51, setError] = (0, import_react.useState)("");
242
247
  const [query, setQuery] = (0, import_react.useState)("");
@@ -266,24 +271,38 @@ function AgentSkillsSection({ api, t }) {
266
271
  setPendingSkillCount(changed);
267
272
  }, [rememberBaseline]);
268
273
  const load = (0, import_react.useCallback)(async (refresh = () => api.list()) => {
274
+ if (restartingRef.current) return;
269
275
  setError("");
270
- const result2 = await refresh();
276
+ let result2;
277
+ try {
278
+ result2 = await refresh();
279
+ } catch (error52) {
280
+ if (restartingRef.current) return;
281
+ setError(t("errorLoad", { message: error52 instanceof Error ? error52.message : String(error52) }));
282
+ return;
283
+ }
271
284
  if (result2.ok) {
272
285
  rememberBaseline(result2.value);
273
286
  setView(result2.value);
274
- } else {
287
+ } else if (!restartingRef.current) {
275
288
  setError(t("errorLoad", { message: result2.error.message }));
276
289
  }
277
290
  }, [api, rememberBaseline, t]);
278
291
  const loadTakeover = (0, import_react.useCallback)(async (refresh = () => api.takeoverStatus()) => {
279
- const result2 = await refresh();
292
+ if (restartingRef.current) return;
293
+ let result2;
294
+ try {
295
+ result2 = await refresh();
296
+ } catch {
297
+ return;
298
+ }
280
299
  if (result2.ok) {
281
300
  setTakeover(result2.value);
282
301
  const pending = readPendingRestart();
283
302
  const stillPending = result2.value.boot !== void 0 && pending?.boot === result2.value.boot && result2.value.enabled !== pending.baselineEnabled;
284
303
  setTakeoverRestartRequired(stillPending);
285
304
  if (pending !== void 0 && !stillPending) writePendingRestart(void 0);
286
- } else {
305
+ } else if (!restartingRef.current) {
287
306
  setError(t("errorLoad", { message: result2.error.message }));
288
307
  }
289
308
  }, [api, t]);
@@ -292,11 +311,12 @@ function AgentSkillsSection({ api, t }) {
292
311
  void Promise.all([load(), loadTakeover()]).finally(() => setBusy(false));
293
312
  }, [load, loadTakeover]);
294
313
  (0, import_react.useEffect)(() => {
314
+ if (restarting) return;
295
315
  const timer = window.setInterval(() => {
296
316
  void load();
297
317
  }, 5e3);
298
318
  return () => window.clearInterval(timer);
299
- }, [load]);
319
+ }, [load, restarting]);
300
320
  const mutate = (0, import_react.useCallback)(async (operation, trackSkillChanges = false) => {
301
321
  setSaving(true);
302
322
  setError("");
@@ -386,7 +406,7 @@ function AgentSkillsSection({ api, t }) {
386
406
  } catch {
387
407
  }
388
408
  retry();
389
- }, [api, restarting, t, takeover?.boot]);
409
+ }, [api, restarting, setRestarting, t, takeover?.boot]);
390
410
  const toggleDirExpanded = (path) => {
391
411
  setDirExpanded((prev) => {
392
412
  const next = new Set(prev);