@lmzhen/dsh-evolution-commands 0.3.12 → 0.3.14
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/lib/index.js +41 -4
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
3
|
import { SkillLibrary, appendEvolutionEvent, buildLearnPrompt, eventsFile } from "@lmzhen/dsh-evolution-core";
|
|
3
4
|
import { buildEnrichment, buildMaintainFacts, runMaintain, snapshotFromLibrary } from "@lmzhen/dsh-evolution-maintenance";
|
|
5
|
+
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
4
6
|
import { homedir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
6
9
|
//#region lib/types/index.js
|
|
7
10
|
/**
|
|
8
11
|
* Human commands for the evolution family: /evolution learn|pending|curator|restore|consolidate.
|
|
@@ -20,7 +23,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
20
23
|
name: "evolution",
|
|
21
24
|
description: "Self-evolution status and approval controls",
|
|
22
25
|
recordInput: false,
|
|
23
|
-
input: { hint: "pending | approve <id> | reject <id> | curator run|pause|resume|status|report|scope | restore | consolidate <target> <sources...> | skill restore <name> | skills health | learn [request] | maintain [--timeout ms] | restructure <name> \"<heading>\" <to_file> | replay" },
|
|
26
|
+
input: { hint: "pending | approve <id> | reject <id> | curator run|pause|resume|status|report|scope | restore | consolidate <target> <sources...> | skill restore <name> | skills health | learn [request] | maintain [--timeout ms] | preset install | restructure <name> \"<heading>\" <to_file> | replay" },
|
|
24
27
|
async handler(invocation) {
|
|
25
28
|
const input = invocation.rawInput?.trim() ?? "";
|
|
26
29
|
const ok = (text) => ({
|
|
@@ -202,9 +205,9 @@ function apply(ctx, rawConfig = {}) {
|
|
|
202
205
|
const subagents = ctx.get("subagents");
|
|
203
206
|
if (!ioRegistry) return err("Evolution IO registry not mounted — maintenance scan unavailable.");
|
|
204
207
|
if (!subagents) return err("Subagents service not mounted — maintenance scan unavailable.");
|
|
208
|
+
maintainInFlightSince = Date.now();
|
|
205
209
|
const library = new SkillLibrary(config.skillsRoot, ioRegistry.provider());
|
|
206
210
|
const enrichment = await buildEnrichment(ctx, library);
|
|
207
|
-
maintainInFlightSince = Date.now();
|
|
208
211
|
let outcome;
|
|
209
212
|
try {
|
|
210
213
|
outcome = await runMaintain({
|
|
@@ -237,6 +240,22 @@ function apply(ctx, rawConfig = {}) {
|
|
|
237
240
|
});
|
|
238
241
|
return ok(`Maintenance scan ${outcome.runId}:\n${outcome.text ?? ""}`);
|
|
239
242
|
}
|
|
243
|
+
if (/^maintain\b/.test(input)) return err("Unknown maintain arguments: expected bare `maintain` or `maintain --timeout <ms>` (a positive integer). Got: " + input);
|
|
244
|
+
if (input === "preset install") {
|
|
245
|
+
const target = join(process.env.DSH_HOME ?? join(homedir(), ".dsh"), ".agent-presets", "evolution");
|
|
246
|
+
try {
|
|
247
|
+
const source = resolveAgentPresetDir(import.meta.url);
|
|
248
|
+
mkdirSync(target, { recursive: true });
|
|
249
|
+
for (const file of ["agent.cordis.yml", "preset.yml"]) {
|
|
250
|
+
const from = join(source, file);
|
|
251
|
+
if (!existsSync(from)) return err(`Preset file missing from ${source}/${file} — is @lmzhen/dsh-evolution-agent-preset installed?`);
|
|
252
|
+
copyFileSync(from, join(target, file));
|
|
253
|
+
}
|
|
254
|
+
return ok(`Evolution agent preset installed to ${target} (agent.cordis.yml, preset.yml). Restart the session switcher to select it.`);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
return err(`Preset install failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
240
259
|
if (input.startsWith("restructure ")) {
|
|
241
260
|
const planTail = /\s--plan\s+(\S+)\s*$/.exec(input) ?? null;
|
|
242
261
|
const planRunId = planTail?.[1] ?? void 0;
|
|
@@ -261,10 +280,28 @@ function apply(ctx, rawConfig = {}) {
|
|
|
261
280
|
if (!replay) return err("Replay service not mounted.");
|
|
262
281
|
return ok(replay.compare().report);
|
|
263
282
|
}
|
|
264
|
-
return ok("Evolution: memory, skills, review, curator. Use /evolution pending | approve <id> | reject <id> | curator run | curator status | curator pause | curator resume | curator report | curator scope | restore | consolidate <target> <source...> | skill restore <name> | skills health | learn [request] | maintain | restructure <name> \"<heading>\" <to_file> | replay.");
|
|
283
|
+
return ok("Evolution: memory, skills, review, curator. Use /evolution pending | approve <id> | reject <id> | curator run | curator status | curator pause | curator resume | curator report | curator scope | restore | consolidate <target> <source...> | skill restore <name> | skills health | learn [request] | maintain | preset install | restructure <name> \"<heading>\" <to_file> | replay.");
|
|
265
284
|
}
|
|
266
285
|
});
|
|
267
286
|
});
|
|
268
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* 0.3.14 (P1-1): locate the installed `dsh-evolution-agent-preset` package
|
|
290
|
+
* (the delivery container for agent.cordis.yml/preset.yml). Resolution order:
|
|
291
|
+
* npm-name sibling (published profile layout), dev-tree sibling (source/test
|
|
292
|
+
* layout), then module resolution. The package dir name differs from the npm
|
|
293
|
+
* name (`evolution-agent` vs `@lmzhen/dsh-evolution-agent-preset` — the rc.44
|
|
294
|
+
* dir≠name trap), so BOTH sibling shapes are probed.
|
|
295
|
+
*/
|
|
296
|
+
function resolveAgentPresetDir(importMetaUrl) {
|
|
297
|
+
const dir = dirname(fileURLToPath(importMetaUrl));
|
|
298
|
+
const candidates = [join(dir, "..", "dsh-evolution-agent-preset"), join(dir, "..", "..", "evolution-agent")];
|
|
299
|
+
for (const candidate of candidates) if (existsSync(join(candidate, "agent.cordis.yml")) && existsSync(join(candidate, "preset.yml"))) return candidate;
|
|
300
|
+
try {
|
|
301
|
+
return dirname(createRequire(importMetaUrl).resolve("@lmzhen/dsh-evolution-agent-preset/package.json"));
|
|
302
|
+
} catch {
|
|
303
|
+
return candidates[0] ?? join(dir, "..", "dsh-evolution-agent-preset");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
269
306
|
//#endregion
|
|
270
307
|
export { apply, name };
|
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.
|
|
4
|
+
"version": "0.3.14",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
37
|
-
"@lmzhen/dsh-evolution-maintenance": "^0.3.
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.3.14",
|
|
37
|
+
"@lmzhen/dsh-evolution-maintenance": "^0.3.14"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@deepseek-ai/cordis": "^4.0.1",
|