@lmzhen/dsh-tool-skill-manage 0.3.79 → 0.3.81

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.
Files changed (2) hide show
  1. package/lib/index.js +39 -24
  2. package/package.json +8 -8
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { defineTool } from "@deepseek-ai/dsh-tools";
4
- import { DEFAULT_SKILL_LIMITS, DSH_AUTHORING_STANDARDS, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, authoringFeedback, callingScope, clampedNumber, computeDedupGroups, contentHash, evolutionIoAdapter, isPresent, isReviewChannelSession, isUnknown, newSkillLibrary, parseFrontmatter, probePresent, probeUnknown, resolveOrigins } from "@lmzhen/dsh-evolution-core";
4
+ import { DEFAULT_SKILL_LIMITS, DSH_AUTHORING_STANDARDS, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SKILL_ACTION_REQUIRED_FIELDS, authoringFeedback, callingScope, clampedNumber, computeDedupGroups, contentHash, evolutionIoAdapter, isPresent, isUnknown, newSkillLibrary, parseFrontmatter, probePresent, probeUnknown, resolveExecOrigins } from "@lmzhen/dsh-evolution-core";
5
5
  //#region lib/types/index.js
6
6
  /**
7
7
  * Model-facing skill_manage tool over ctx.evolutionIo + ctx.skillUsage.
@@ -72,6 +72,26 @@ function apply(ctx, rawConfig = {}) {
72
72
  });
73
73
  if (numericClamped.length > 0) ctx.logger.warn(`tool-skill-manage: ${numericClamped.join(", ")} provided an invalid value; falling back to the default`);
74
74
  let crossSourceViewWarned = false;
75
+ const crossSourceRefusal = async (rawName, phase = "stage") => {
76
+ const replay = phase === "replay";
77
+ if (typeof rawName !== "string" || rawName === "") return null;
78
+ const probe = await catalogWinner(rawName);
79
+ if (isUnknown(probe)) {
80
+ if (rawConfig.strictCrossSource === true) return replay ? `Refused: the cross-source check could not be performed — ${probe.reason}. Reject this staged write, fix the catalog view, and re-stage "${rawName}".` : `Refused: the cross-source check could not be performed — ${probe.reason}. Fix the catalog view (or drop strictCrossSource) before writing "${rawName}".`;
81
+ if (!crossSourceViewWarned) {
82
+ crossSourceViewWarned = true;
83
+ ctx.logger.warn(`skill_manage: cross-source check skipped for this session — ${probe.reason}`);
84
+ }
85
+ return null;
86
+ }
87
+ if (isPresent(probe) && probe.value !== void 0 && probe.value.provider !== "dsh-evolution") {
88
+ const winner = probe.value;
89
+ const message = `skill "${rawName}" resolves to a higher-priority "${winner.source}" skill (provider "${winner.provider}"); this write lands on the family copy, which the catalog does NOT serve — edit the "${winner.source}" copy or rename.`;
90
+ if (rawConfig.strictCrossSource === true) return `Refused: ${message}`;
91
+ ctx.logger.warn(`skill_manage: ${message}`);
92
+ }
93
+ return null;
94
+ };
75
95
  const catalogWinner = async (name) => {
76
96
  const catalog = ctx.get("skills");
77
97
  if (catalog === void 0) return probeUnknown("the skills service is not mounted");
@@ -305,32 +325,17 @@ function apply(ctx, rawConfig = {}) {
305
325
  isConcurrencySafe: () => false,
306
326
  async execute(args, exec) {
307
327
  let operation = args;
308
- const origins = resolveOrigins(exec.agent?.session?.header.origin, isReviewChannelSession(exec.agent?.session?.id));
328
+ const origins = resolveExecOrigins(exec);
309
329
  const reviewOrigin = origins.approval;
310
330
  const libraryOrigin = origins.library;
311
331
  const sessionPolicy = effectiveSessionPolicy(ctx, exec.agent?.session);
312
332
  if (typeof args.name === "string" && args.name !== "" && args.action !== "list" && args.action !== "review" && args.action !== "pin" && args.action !== "unpin") {
313
- const probe = await catalogWinner(args.name);
314
- if (isUnknown(probe)) {
315
- if (rawConfig.strictCrossSource === true) return {
316
- ok: false,
317
- message: `Refused: the cross-source check could not be performed — ${probe.reason}. Fix the catalog view (or drop strictCrossSource) before writing "${args.name}".`,
318
- skills: []
319
- };
320
- if (!crossSourceViewWarned) {
321
- crossSourceViewWarned = true;
322
- ctx.logger.warn(`skill_manage: cross-source check skipped for this session — ${probe.reason}`);
323
- }
324
- } else if (isPresent(probe) && probe.value !== void 0 && probe.value.provider !== "dsh-evolution") {
325
- const winner = probe.value;
326
- const message = `skill "${args.name}" resolves to a higher-priority "${winner.source}" skill (provider "${winner.provider}"); this write lands on the family copy, which the catalog does NOT serve — edit the "${winner.source}" copy or rename.`;
327
- if (rawConfig.strictCrossSource === true) return {
328
- ok: false,
329
- message: `Refused: ${message}`,
330
- skills: []
331
- };
332
- ctx.logger.warn(`skill_manage: ${message}`);
333
- }
333
+ const refusal = await crossSourceRefusal(args.name);
334
+ if (refusal !== null) return {
335
+ ok: false,
336
+ message: refusal,
337
+ skills: []
338
+ };
334
339
  }
335
340
  const approval = ctx.get("evolutionApproval");
336
341
  if (approval && args.action !== "list" && args.action !== "review" && args.action !== "pin" && args.action !== "unpin") {
@@ -374,7 +379,17 @@ function apply(ctx, rawConfig = {}) {
374
379
  ctx.inject(["evolutionApproval"], (approvalCtx) => {
375
380
  const dispose = approvalCtx.evolutionApproval.registerRunner("skill", (args) => {
376
381
  const wrapped = args ?? {};
377
- return executeCore(wrapped.operation ?? {}, wrapped.libraryOrigin ?? wrapped.origin ?? "background_review");
382
+ const operation = wrapped.operation ?? {};
383
+ const replayAction = operation.action;
384
+ if (replayAction !== "list" && replayAction !== "review" && replayAction !== "pin" && replayAction !== "unpin") return crossSourceRefusal(operation.name, "replay").then((refusal) => {
385
+ if (refusal !== null) return {
386
+ ok: false,
387
+ message: `${refusal} (re-checked at approve time: the catalog ranking changed while the write was staged)`,
388
+ skills: []
389
+ };
390
+ return executeCore(operation, wrapped.libraryOrigin ?? wrapped.origin ?? "background_review");
391
+ });
392
+ return executeCore(operation, wrapped.libraryOrigin ?? wrapped.origin ?? "background_review");
378
393
  });
379
394
  approvalCtx.effect(() => dispose, "tool-skill-manage.approval-runner");
380
395
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-tool-skill-manage",
3
3
  "description": "Model-facing skill_manage tool (community build)",
4
- "version": "0.3.79",
4
+ "version": "0.3.81",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,24 +27,24 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.1",
30
- "@lmzhen/dsh-evolution-approval": "^0.3.79",
31
- "@lmzhen/dsh-evolution-core": "^0.3.79"
30
+ "@lmzhen/dsh-evolution-approval": "^0.3.81",
31
+ "@lmzhen/dsh-evolution-core": "^0.3.81"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@deepseek-ai/cordis": "^4.0.1",
35
35
  "@deepseek-ai/dsh-skill": "^0.1.5-rc.2",
36
36
  "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
37
37
  "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
38
- "@lmzhen/dsh-evolution-io": "^0.3.79",
39
- "@lmzhen/dsh-skill-usage": "^0.3.79"
38
+ "@lmzhen/dsh-evolution-io": "^0.3.81",
39
+ "@lmzhen/dsh-skill-usage": "^0.3.81"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.5-rc.2",
43
43
  "@deepseek-ai/dsh-skill": "^0.1.5-rc.2",
44
44
  "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
45
45
  "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
46
- "@lmzhen/dsh-evolution-core": "^0.3.79",
47
- "@lmzhen/dsh-evolution-io": "^0.3.79",
48
- "@lmzhen/dsh-skill-usage": "^0.3.79"
46
+ "@lmzhen/dsh-evolution-core": "^0.3.81",
47
+ "@lmzhen/dsh-evolution-io": "^0.3.81",
48
+ "@lmzhen/dsh-skill-usage": "^0.3.81"
49
49
  }
50
50
  }