@lmzhen/dsh-tool-skill-manage 0.3.69 → 0.3.71

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 +11 -23
  2. package/package.json +15 -15
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, SkillLibrary, authoringFeedback, clampedNumber, computeDedupGroups, contentHash, evolutionIoAdapter, parseFrontmatter, resolveOrigins, resolveSkillsRoot } from "@lmzhen/dsh-evolution-core";
4
+ import { DEFAULT_SKILL_LIMITS, DSH_AUTHORING_STANDARDS, SKILLS_GUIDANCE, SKILLS_GUIDANCE_SECTION_ORDER, SkillLibrary, authoringFeedback, clampedNumber, computeDedupGroups, contentHash, evolutionIoAdapter, parseFrontmatter, resolveOrigins, resolveSkillsRoot } 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.
@@ -47,7 +47,7 @@ function apply(ctx, rawConfig = {}) {
47
47
  const systemPrompt = ctx.get("systemPrompt");
48
48
  if (systemPrompt) ctx.effect(() => systemPrompt.section({
49
49
  name: "evolution-skills-guidance",
50
- order: 900,
50
+ order: SKILLS_GUIDANCE_SECTION_ORDER,
51
51
  text: SKILLS_GUIDANCE
52
52
  }), "tool-skill-manage.skills-guidance");
53
53
  const io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
@@ -148,24 +148,7 @@ function apply(ctx, rawConfig = {}) {
148
148
  skills: []
149
149
  };
150
150
  let feedbackLines = [];
151
- if ((action === "edit" || action === "update") && typeof args.staged_from_sha256 === "string" && args.staged_from_sha256 !== "") {
152
- const currentContent = await library.read(name).catch(() => null);
153
- const actual = contentHash(currentContent ?? "");
154
- if (currentContent === null || actual !== args.staged_from_sha256) return {
155
- ok: false,
156
- message: `Skill "${name}" changed after this write was staged (content ${currentContent === null ? "no longer exists" : "hash mismatch"}); refusing to replay the stale snapshot. Re-apply the edit to stage a fresh copy.`,
157
- skills: []
158
- };
159
- }
160
- if ((action === "write_file" || action === "remove_file") && typeof args.staged_from_sha256 === "string" && args.staged_from_sha256 !== "") {
161
- const currentBytes = await library.readSupportFile(name, args.file_path ?? "").catch(() => void 0);
162
- const actual = currentBytes === void 0 || currentBytes === null ? "absent" : contentHash(currentBytes);
163
- if (currentBytes === void 0 || actual !== args.staged_from_sha256) return {
164
- ok: false,
165
- message: `Support file "${args.file_path ?? ""}" of "${name}" changed after this write was staged (or its state could not be verified); refusing to replay the stale snapshot. Re-stage the file operation.`,
166
- skills: []
167
- };
168
- }
151
+ 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;
169
152
  if ((action === "create" || action === "edit" || action === "update") && args.content) {
170
153
  const parsed = parseFrontmatter(args.content);
171
154
  if (parsed) {
@@ -180,11 +163,11 @@ function apply(ctx, rawConfig = {}) {
180
163
  }
181
164
  let result;
182
165
  if (action === "create") result = await library.create(name, args.content ?? "", origin);
183
- else if (action === "edit" || action === "update") result = await library.update(name, args.content ?? "", origin);
166
+ else if (action === "edit" || action === "update") result = await library.update(name, args.content ?? "", origin, stagedAnchor);
184
167
  else if (action === "patch") result = await library.patch(name, args.old_string ?? "", args.new_string ?? "", args.file_path ?? "", args.replace_all === true, origin);
185
168
  else if (action === "delete") result = await library.archive(name, args.absorbed_into ? { absorbedInto: args.absorbed_into } : {});
186
- else if (action === "write_file") result = await library.writeSupportFile(name, args.file_path ?? "", args.file_content ?? "", origin);
187
- else if (action === "remove_file") result = await library.removeSupportFile(name, args.file_path ?? "", origin);
169
+ else if (action === "write_file") result = await library.writeSupportFile(name, args.file_path ?? "", args.file_content ?? "", origin, stagedAnchor);
170
+ else if (action === "remove_file") result = await library.removeSupportFile(name, args.file_path ?? "", origin, stagedAnchor);
188
171
  else if (action === "restructure") {
189
172
  const moves = Array.isArray(args.restructure) ? args.restructure : [];
190
173
  if (moves.some((move) => {
@@ -204,6 +187,11 @@ function apply(ctx, rawConfig = {}) {
204
187
  ok: false,
205
188
  message: `Unknown action "${action}".`
206
189
  };
190
+ if (result.stale === true) return {
191
+ ok: false,
192
+ message: action === "write_file" || action === "remove_file" ? `Support file "${args.file_path ?? ""}" of "${name}" changed after this write was staged (or its state could not be verified).` : `Skill "${name}" changed after this write was staged (content ${result.anchor === "missing" ? "no longer exists" : "hash mismatch"}).`,
193
+ skills: []
194
+ };
207
195
  if (result.ok) {
208
196
  if (result.normalizedFrontmatterFields && result.normalizedFrontmatterFields.length > 0) feedbackLines.push(`frontmatter auto-quoted (YAML compatibility): ${result.normalizedFrontmatterFields.join(", ")}`);
209
197
  const mutating = action !== "list" && action !== "review" && action !== "pin" && action !== "unpin";
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.69",
4
+ "version": "0.3.71",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,24 +31,24 @@
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
33
  "@deepseek-ai/schemastery": "^3.18.1",
34
- "@lmzhen/dsh-evolution-approval": "^0.3.69",
35
- "@lmzhen/dsh-evolution-core": "^0.3.69"
34
+ "@lmzhen/dsh-evolution-approval": "^0.3.71",
35
+ "@lmzhen/dsh-evolution-core": "^0.3.71"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.1",
39
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
40
- "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
41
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
42
- "@lmzhen/dsh-evolution-io": "^0.3.69",
43
- "@lmzhen/dsh-skill-usage": "^0.3.69"
39
+ "@deepseek-ai/dsh-invariants": "^0.1.5-rc.2",
40
+ "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
41
+ "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
42
+ "@lmzhen/dsh-evolution-io": "^0.3.71",
43
+ "@lmzhen/dsh-skill-usage": "^0.3.71"
44
44
  },
45
45
  "devDependencies": {
46
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.1-rc.2",
47
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
48
- "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
49
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
50
- "@lmzhen/dsh-evolution-core": "^0.3.69",
51
- "@lmzhen/dsh-evolution-io": "^0.3.69",
52
- "@lmzhen/dsh-skill-usage": "^0.3.69"
46
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.5-rc.2",
47
+ "@deepseek-ai/dsh-invariants": "^0.1.5-rc.2",
48
+ "@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
49
+ "@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
50
+ "@lmzhen/dsh-evolution-core": "^0.3.71",
51
+ "@lmzhen/dsh-evolution-io": "^0.3.71",
52
+ "@lmzhen/dsh-skill-usage": "^0.3.71"
53
53
  }
54
54
  }