@lmzhen/dsh-evolution-commands 0.1.0-rc.4 → 0.1.0-rc.40

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 CHANGED
@@ -1,6 +1,7 @@
1
+ import { buildLearnPrompt } from "@lmzhen/dsh-evolution-core";
1
2
  //#region lib/types/index.js
2
3
  /**
3
- * Human commands for the evolution family: /evolution status|pending.
4
+ * Human commands for the evolution family: /evolution learn|pending|curator|restore|consolidate.
4
5
  * @module @lmzhen/dsh-evolution-commands
5
6
  */
6
7
  const name = "evolution-commands";
@@ -12,51 +13,105 @@ function apply(ctx) {
12
13
  recordInput: false,
13
14
  async handler(invocation) {
14
15
  const input = invocation.rawInput?.trim() ?? "";
16
+ const ok = (text) => ({
17
+ kind: "success",
18
+ text
19
+ });
20
+ const err = (text) => ({
21
+ kind: "error",
22
+ text
23
+ });
15
24
  const approval = ctx.get("evolutionApproval");
16
25
  if (input === "pending") {
17
26
  const pending = approval ? await approval.list("pending") : [];
18
- return { text: pending.length === 0 ? "No pending evolution writes." : pending.map((p) => `${p.id} ${p.kind} ${p.summary}`).join("\n") };
27
+ return ok(pending.length === 0 ? "No pending evolution writes." : pending.map((p) => `${p.id} ${p.kind} ${p.summary}`).join("\n"));
19
28
  }
20
29
  if (input.startsWith("approve ")) {
21
30
  const id = input.slice(8).trim();
22
- return { text: (approval ? await approval.approve(id) : {
31
+ const result = approval ? await approval.approve(id) : {
23
32
  ok: false,
24
33
  message: "approval service not mounted"
25
- }).message };
34
+ };
35
+ return result.ok ? ok(result.message) : err(result.message);
26
36
  }
27
37
  if (input.startsWith("reject ")) {
28
38
  const id = input.slice(7).trim();
29
- return { text: (approval ? await approval.reject(id) : {
39
+ const result = approval ? await approval.reject(id) : {
30
40
  ok: false,
31
41
  message: "approval service not mounted"
32
- }).message };
42
+ };
43
+ return result.ok ? ok(result.message) : err(result.message);
33
44
  }
34
45
  if (input === "curator run") {
35
46
  const curator = ctx.get("evolutionCurator");
36
- if (!curator) return { text: "Curator service not mounted." };
37
- const result = await curator.run();
38
- return { text: `Curator run complete: ${result.stale.length} stale, ${result.archived.length} archived, ${result.errors.length} failed.\nrunId=${result.report.runId}${result.report.snapshotPath ? `\nsnapshot=${result.report.snapshotPath}` : ""}` };
47
+ if (!curator) return err("Curator service not mounted.");
48
+ const result = await curator.run({ ignoreGates: true });
49
+ return ok(`Curator run complete: ${result.stale.length} stale, ${result.archived.length} archived, ${result.errors.length} failed.\nrunId=${result.report.runId}${result.report.snapshotPath ? `\nsnapshot=${result.report.snapshotPath}` : ""}`);
50
+ }
51
+ if (input === "mutations") {
52
+ const curator = ctx.get("evolutionCurator");
53
+ if (!curator) return err("Curator service not mounted.");
54
+ const records = await curator.skills.listMutations();
55
+ if (records.length === 0) return ok("No mutation records yet.");
56
+ const recent = records.slice(-5).reverse().map((record) => `${record.at.slice(0, 19)} ${record.skillName} ${record.action} ${record.summary}`);
57
+ return ok(`Mutations: ${records.length} recorded (recent 5):\n${recent.join("\n")}`);
58
+ }
59
+ if (input === "curator scope") {
60
+ const curator = ctx.get("evolutionCurator");
61
+ if (!curator) return err("Curator service not mounted.");
62
+ const view = await curator.scopeView();
63
+ const line = (label, names) => `${label}: ${names.length}${names.length === 0 ? "" : `\n ${names.join(", ")}`}`;
64
+ return ok([
65
+ `Lifecycle scope at ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`,
66
+ line("Managed (may transition)", view.managed),
67
+ line("Watched (stale / quality-warned)", view.watched),
68
+ line("Quality-warned", view.qualityWarned),
69
+ line("Exempted (exclude / referenced)", view.exempted),
70
+ line("Protected (pinned / bundled / hub)", view.protected)
71
+ ].join("\n"));
39
72
  }
40
73
  if (input === "curator report") {
41
74
  const curator = ctx.get("evolutionCurator");
42
- if (!curator) return { text: "Curator service not mounted." };
75
+ if (!curator) return err("Curator service not mounted.");
43
76
  const report = await curator.latestReport();
44
- if (!report) return { text: "No curator report available." };
45
- return { text: [
77
+ if (!report) return ok("No curator report available.");
78
+ return ok([
46
79
  `runId=${report.runId}`,
47
80
  `startedAt=${report.startedAt}`,
48
81
  `archived=${report.archived.map((item) => item.name).join(", ") || "(none)"}`,
49
82
  `failed=${report.failed.map((item) => `${item.name}: ${item.reason}`).join(", ") || "(none)"}`
50
- ].join("\n") };
83
+ ].join("\n"));
51
84
  }
52
85
  if (input.startsWith("restore ")) {
53
86
  const curator = ctx.get("evolutionCurator");
54
- return { text: (curator ? await curator.skills.restoreLatestSnapshot() : {
87
+ const result = curator ? await curator.restoreSnapshot() : {
88
+ ok: false,
89
+ message: "Curator service not mounted."
90
+ };
91
+ return result.ok ? ok(result.message) : err(result.message);
92
+ }
93
+ if (input.startsWith("consolidate ")) {
94
+ const [target, ...sources] = input.slice(12).trim().split(/\s+/).filter(Boolean);
95
+ if (!target || sources.length === 0) return err("Usage: /evolution consolidate <target> <source...>");
96
+ const curator = ctx.get("evolutionCurator");
97
+ const result = curator ? await curator.consolidate(target, sources) : {
98
+ ok: false,
99
+ message: "Curator service not mounted."
100
+ };
101
+ return result.ok ? ok(result.message) : err(result.message);
102
+ }
103
+ if (input.startsWith("skill restore ")) {
104
+ const name = input.slice(14).trim();
105
+ if (!name) return err("Usage: /evolution skill restore <name>");
106
+ const curator = ctx.get("evolutionCurator");
107
+ const result = curator ? await curator.restore(name) : {
55
108
  ok: false,
56
109
  message: "Curator service not mounted."
57
- }).message };
110
+ };
111
+ return result.ok ? ok(result.message) : err(result.message);
58
112
  }
59
- return { text: "Evolution: memory, skills, review, curator. Use /evolution pending | curator run | curator report | restore." };
113
+ if (input === "learn" || input.startsWith("learn ")) return ok(buildLearnPrompt(input === "learn" ? "" : input.slice(6).trim()));
114
+ return ok("Evolution: memory, skills, review, curator. Use /evolution pending | curator run | curator report | curator scope | restore | consolidate <target> <source...> | skill restore <name> | learn [request].");
60
115
  }
61
116
  });
62
117
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Human commands for the evolution family: /evolution status|pending.
2
+ * Human commands for the evolution family: /evolution learn|pending|curator|restore|consolidate.
3
3
  * @module @deepseek-ai/dsh-evolution-commands
4
4
  */
5
5
  import type { Context } from '@deepseek-ai/cordis';
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.1.0-rc.4",
4
+ "version": "0.1.0-rc.40",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -32,7 +32,8 @@
32
32
  ],
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@deepseek-ai/schemastery": "^3.18.1"
35
+ "@deepseek-ai/schemastery": "^3.18.1",
36
+ "@lmzhen/dsh-evolution-core": "^0.1.0-rc.40"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",