dsh-plugin-skill-folder 0.1.1 → 0.1.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,sCAAsC;AACtC,eAAO,MAAM,IAAI,4BAAe,CAAC;AAEjC,qDAAqD;AACrD,eAAO,MAAM,MAAM,UAA0C,CAAC;AA4C9D;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAgG1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,sCAAsC;AACtC,eAAO,MAAM,IAAI,4BAAe,CAAC;AAEjC,qDAAqD;AACrD,eAAO,MAAM,MAAM,UAA0C,CAAC;AAkE9D;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAoH1D"}
package/dist/index.mjs CHANGED
@@ -613,6 +613,16 @@ const inject = [
613
613
  "skills",
614
614
  "workingDirectory"
615
615
  ];
616
+ /**
617
+ * 释放 preset 作用域租约。
618
+ * `Symbol.asyncDispose` 不在 `es2024` lib 里,运行时按名字取。
619
+ */
620
+ async function releasePresetScope(lease) {
621
+ const key = Symbol["asyncDispose"];
622
+ if (key === void 0) return;
623
+ const dispose = lease[key];
624
+ if (typeof dispose === "function") await dispose.call(lease);
625
+ }
616
626
  /** 判断消息来源是否是原生技能目录。 */
617
627
  function isCatalogSource(message) {
618
628
  return message.source?.kind === "skill-catalog";
@@ -652,11 +662,33 @@ function apply(ctx, config) {
652
662
  ctx.effect(() => () => {
653
663
  disposeTool();
654
664
  }, `${PLUGIN_LABEL}: search tool`);
655
- registerSkillsRoute(ctx, { snapshot: async () => {
656
- const snapshot = await services.skills?.snapshot({});
657
- if (snapshot === void 0) throw new Error(`${PLUGIN_LABEL}: skills service unavailable`);
658
- return snapshot;
659
- } });
665
+ /**
666
+ * 读取配置页的全局技能。
667
+ * 默认 preset 的 `skill-filesystem` 注册在 agent 作用域,根作用域快照看不到它,
668
+ * 因此先取默认 preset 的作用域再读;取作用域失败时退回根作用域,并把列表标记为不完整。
669
+ */
670
+ const readGlobalSnapshot = async () => {
671
+ const skills = services.skills;
672
+ if (skills === void 0) throw new Error(`${PLUGIN_LABEL}: skills service unavailable`);
673
+ const presets = services.get?.("agentPresets");
674
+ if (presets === void 0) return skills.snapshot({});
675
+ let lease;
676
+ try {
677
+ lease = await presets.acquireScope();
678
+ } catch (error) {
679
+ services.logger.warn?.(`[${PLUGIN_LABEL}] preset scope unavailable: ${String(error)}`);
680
+ return {
681
+ skills: (await skills.snapshot({})).skills,
682
+ complete: false
683
+ };
684
+ }
685
+ try {
686
+ return await skills.snapshot({ scope: lease.key });
687
+ } finally {
688
+ await releasePresetScope(lease);
689
+ }
690
+ };
691
+ registerSkillsRoute(ctx, { snapshot: readGlobalSnapshot });
660
692
  ctx.effect(() => ctx.on("agent/pre-step", async ({ agent, signal }, next) => {
661
693
  const decision = await next();
662
694
  if (decision.kind === "reject") return decision;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-skill-folder",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",