@lmzhen/dsh-evolution-commands 0.1.0-rc.26 → 0.1.0-rc.28

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