@lmzhen/dsh-tool-skill-manage 0.3.82 → 0.3.83

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,4 +1,4 @@
1
- # @deepseek-ai/dsh-tool-skill-manage
1
+ # @lmzhen/dsh-tool-skill-manage
2
2
 
3
3
  Model-facing skill_manage tool
4
4
 
package/lib/index.js CHANGED
@@ -44,6 +44,18 @@ const Config = z.object({
44
44
  function policySnapshotOf(source) {
45
45
  return source?.get?.();
46
46
  }
47
+ function missingRequiredArgs(args) {
48
+ const action = args.action;
49
+ const scalarArgs = args;
50
+ return (action === void 0 || typeof action !== "string" || !Object.hasOwn(SKILL_ACTION_REQUIRED_FIELDS, action) ? [] : SKILL_ACTION_REQUIRED_FIELDS[action] ?? []).filter((field) => scalarArgs[field] === void 0 || scalarArgs[field] === null);
51
+ }
52
+ function missingArgsRefusal(action, missing) {
53
+ return {
54
+ ok: false,
55
+ message: `skill_manage ${action} requires ${missing.join(", ")}; the tool description lists the arguments per action.`,
56
+ skills: []
57
+ };
58
+ }
47
59
  function apply(ctx, rawConfig = {}) {
48
60
  const systemPrompt = ctx.get("systemPrompt");
49
61
  if (systemPrompt) ctx.effect(() => systemPrompt.section({
@@ -158,13 +170,8 @@ function apply(ctx, rawConfig = {}) {
158
170
  skills: []
159
171
  };
160
172
  }
161
- const REQUIRED_ARGS = SKILL_ACTION_REQUIRED_FIELDS;
162
- const missing = (action === void 0 || typeof action !== "string" || !Object.hasOwn(REQUIRED_ARGS, action) ? [] : REQUIRED_ARGS[action] ?? []).filter((field) => scalarArgs[field] === void 0 || scalarArgs[field] === null);
163
- if (missing.length > 0) return {
164
- ok: false,
165
- message: `skill_manage ${action} requires ${missing.join(", ")}; the tool description lists the arguments per action.`,
166
- skills: []
167
- };
173
+ const missing = missingRequiredArgs(args);
174
+ if (missing.length > 0) return missingArgsRefusal(action, missing);
168
175
  let feedbackLines = [];
169
176
  const stagedAnchor = typeof args.staged_from_sha256 === "string" && args.staged_from_sha256 !== "" ? args.staged_from_sha256 === "absent" ? { absent: true } : { sha256: args.staged_from_sha256 } : void 0;
170
177
  if ((action === "create" || action === "edit" || action === "update") && args.content) {
@@ -238,12 +245,20 @@ function apply(ctx, rawConfig = {}) {
238
245
  return `- ${summary.name} | ${record?.state ?? "active"} | use:${record?.use_count ?? 0} view:${record?.view_count ?? 0} patch:${record?.patch_count ?? 0}${quality}${protection}`;
239
246
  });
240
247
  const contents = /* @__PURE__ */ new Map();
248
+ let excludedBodies = 0;
241
249
  for (let offset = 0; offset < list.length; offset += 16) await Promise.all(list.slice(offset, offset + 16).map(async (summary) => {
242
250
  const body = await library.read(summary.name).catch(() => null);
243
- contents.set(summary.name, body ?? "");
251
+ if (body === null || body.trim() === "") {
252
+ excludedBodies += 1;
253
+ return;
254
+ }
255
+ contents.set(summary.name, body);
244
256
  }));
245
- const groups = computeDedupGroups({ contents });
257
+ const dedup = computeDedupGroups({ contents });
258
+ const groups = dedup.groups;
246
259
  const dedupLines = groups.slice(0, MAX_DEDUP_GROUPS_IN_REVIEW).map((group) => `- ${group.join(" ~ ")}`);
260
+ if (dedup.truncated) dedupLines.push(`- note: dedup scan truncated at the pair-comparison budget (${groups.length} group(s) so far); groups may be incomplete`);
261
+ const excludedLine = excludedBodies === 0 ? "" : `\n${excludedBodies} skill bodies were unreadable/empty and excluded from dedup grouping.`;
247
262
  const warned = list.filter((summary) => warnedFlag(summary.name)).map((summary) => summary.name);
248
263
  const warningLine = warned.length === 0 ? "" : `\nWarning skills (${warned.length}): ${warned.join(", ")} — low quality; consider consolidating them before authoring new skills.`;
249
264
  return [
@@ -251,6 +266,7 @@ function apply(ctx, rawConfig = {}) {
251
266
  "",
252
267
  ...lines,
253
268
  ...dedupLines,
269
+ ...excludedBodies > 0 ? [excludedLine] : [],
254
270
  warningLine
255
271
  ].join("\n");
256
272
  }
@@ -337,6 +353,8 @@ function apply(ctx, rawConfig = {}) {
337
353
  skills: []
338
354
  };
339
355
  }
356
+ const missing = missingRequiredArgs(args);
357
+ if (missing.length > 0) return missingArgsRefusal(args.action, missing);
340
358
  const approval = ctx.get("evolutionApproval");
341
359
  if (approval && args.action !== "list" && args.action !== "review" && args.action !== "pin" && args.action !== "unpin") {
342
360
  if ((args.action === "update" || args.action === "edit") && typeof args.name === "string" && args.name !== "") {
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.82",
4
+ "version": "0.3.83",
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.82",
31
- "@lmzhen/dsh-evolution-core": "^0.3.82"
30
+ "@lmzhen/dsh-evolution-approval": "^0.3.83",
31
+ "@lmzhen/dsh-evolution-core": "^0.3.83"
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.82",
39
- "@lmzhen/dsh-skill-usage": "^0.3.82"
38
+ "@lmzhen/dsh-evolution-io": "^0.3.83",
39
+ "@lmzhen/dsh-skill-usage": "^0.3.83"
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.82",
47
- "@lmzhen/dsh-evolution-io": "^0.3.82",
48
- "@lmzhen/dsh-skill-usage": "^0.3.82"
46
+ "@lmzhen/dsh-evolution-core": "^0.3.83",
47
+ "@lmzhen/dsh-evolution-io": "^0.3.83",
48
+ "@lmzhen/dsh-skill-usage": "^0.3.83"
49
49
  }
50
50
  }