@lmzhen/dsh-evolution-learning-graph 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 +14 -2
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -250,20 +250,32 @@ function apply(ctx, rawConfig = {}) {
250
250
  const edit = /^edit\s+(\S+)\s+([\s\S]+)$/.exec(input);
251
251
  if (edit && edit[1] && edit[2] !== void 0) {
252
252
  if (!edit[1].startsWith("memory:")) {
253
- if (await withSkills().read(edit[1]).catch(() => null) === null) return err(`Skill "${edit[1]}" not found in the live skill library — nothing to edit. (The graph may be showing a stale node.)`);
253
+ const stageRead = await probeSkillForStaging(edit[1]);
254
+ if (stageRead !== null) return err(stageRead);
254
255
  }
255
256
  return await nodeEdit(edit[1], edit[2]);
256
257
  }
257
258
  const remove = /^delete\s+(\S+)$/.exec(input);
258
259
  if (remove && remove[1]) {
259
260
  if (!remove[1].startsWith("memory:")) {
260
- if (await withSkills().read(remove[1]).catch(() => null) === null) return err(`Skill "${remove[1]}" not found in the live skill library — nothing to delete.`);
261
+ const stageRead = await probeSkillForStaging(remove[1]);
262
+ if (stageRead !== null) return err(stageRead);
261
263
  }
262
264
  return await nodeDelete(remove[1]);
263
265
  }
264
266
  const directory = await renderGraph();
265
267
  if (input !== "") return err(`Unknown graph subcommand "${input.split(" ")[0]}". ${directory}`);
266
268
  return ok(directory);
269
+ /** S1-F3: the pre-staging existence probe shared by edit and delete.
270
+ * @returns null to proceed, or the refusal line to show the operator. */
271
+ async function probeSkillForStaging(name) {
272
+ try {
273
+ if (await withSkills().read(name) !== null) return null;
274
+ return `Skill "${name}" not found in the live skill library. (The graph may be showing a stale node.)`;
275
+ } catch (error) {
276
+ return `Skill "${name}" could not be read to verify it exists (${error instanceof Error ? error.message : String(error)}) — refusing to stage. The skill may still exist; resolve the read failure and retry.`;
277
+ }
278
+ }
267
279
  async function renderGraph() {
268
280
  const usageReport = await usage.report();
269
281
  const usageMap = new Map([...usageReport].filter(([, record]) => record.state !== "archived"));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-learning-graph",
3
3
  "description": "Learning graph over skills and memory (community build)",
4
- "version": "0.3.79",
4
+ "version": "0.3.81",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,8 +27,8 @@
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/dsh-commands": "^0.1.5-rc.2",