@lmzhen/dsh-evolution-commands 0.3.46 → 0.3.47

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 +6 -3
  2. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
3
- import { SkillLibrary, appendEvolutionEvent, buildLearnPrompt, composePresetComposition, eventsFile, evolutionRoot, resolveSkillsRoot } from "@lmzhen/dsh-evolution-core";
3
+ import { SkillLibrary, appendEvolutionEvent, buildLearnPrompt, clampedNumber, composePresetComposition, eventsFile, evolutionRoot, resolveSkillsRoot } from "@lmzhen/dsh-evolution-core";
4
4
  import { buildEnrichment, buildMaintainFacts, runMaintain, snapshotFromLibrary } from "@lmzhen/dsh-evolution-maintenance";
5
5
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
@@ -215,7 +215,7 @@ function apply(ctx, rawConfig = {}) {
215
215
  const runTimeoutMs = maintainArgs[1] ? Number(maintainArgs[1]) : config.maintainTimeoutMs ?? 6e5;
216
216
  if (!Number.isSafeInteger(runTimeoutMs) || runTimeoutMs <= 0 || runTimeoutMs > 4294967295) return err("Invalid --timeout value: expected a positive integer number of milliseconds up to 4294967295 (e.g. /evolution maintain --timeout 600000).");
217
217
  if (maintainInFlightSince > 0) return ok(`Maintenance scan is already running (since ~${Math.max(1, Math.round((Date.now() - maintainInFlightSince) / 1e3))}s ago) — re-submitting now would cancel it. Wait for it to settle; the result appears when it finishes.`);
218
- const cooldownMs = config.maintainCooldownMs ?? 3e4;
218
+ const cooldownMs = clampedNumber(config.maintainCooldownMs, 3e4, { min: 0 });
219
219
  const sinceLast = Date.now() - lastMaintainAt;
220
220
  if (cooldownMs > 0 && sinceLast < cooldownMs) return ok(`Maintenance cooldown active (${Math.ceil((cooldownMs - sinceLast) / 1e3)}s) — latest scan ${lastMaintainRunId}; re-running now would spend another model call.`);
221
221
  const ioRegistry = ctx.get("evolutionIo");
@@ -298,11 +298,14 @@ function apply(ctx, rawConfig = {}) {
298
298
  if (!toFile.startsWith("references/")) return err("to_file must live under references/ (log/detail destination).");
299
299
  const ioRegistry = ctx.get("evolutionIo");
300
300
  if (!ioRegistry) return err("Evolution IO registry not mounted — restructure unavailable.");
301
- const result = await new SkillLibrary(resolveSkillsRoot({ root: config.skillsRoot }), ioRegistry.provider()).restructure(name, [{
301
+ const result = await new SkillLibrary(resolveSkillsRoot({ root: config.skillsRoot }), ioRegistry.provider(), void 0, (event) => {
302
+ ctx.emit("evolution/skill-mutated", event);
303
+ }).restructure(name, [{
302
304
  heading,
303
305
  toFile
304
306
  }], "foreground");
305
307
  if (!result.ok) return err(result.message);
308
+ await ctx.get("skillUsage")?.record?.(name, "patch");
306
309
  return ok(planRunId ? `${result.message}\n[audit] plan=${planRunId}` : result.message);
307
310
  }
308
311
  if (input === "replay") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-commands",
3
3
  "description": "Human commands for the evolution family (community build)",
4
- "version": "0.3.46",
4
+ "version": "0.3.47",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,9 +30,9 @@
30
30
  ],
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@lmzhen/dsh-evolution-approval": "^0.3.46",
34
- "@lmzhen/dsh-evolution-core": "^0.3.46",
35
- "@lmzhen/dsh-evolution-maintenance": "^0.3.46"
33
+ "@lmzhen/dsh-evolution-approval": "^0.3.47",
34
+ "@lmzhen/dsh-evolution-core": "^0.3.47",
35
+ "@lmzhen/dsh-evolution-maintenance": "^0.3.47"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.1",