@lmzhen/dsh-evolution-learning-graph 0.23.0 → 0.24.0

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 +19 -19
  2. package/package.json +3 -3
package/lib/index.js CHANGED
@@ -142,11 +142,11 @@ function readMemoryIndex(parsed, entries) {
142
142
  const entry = entries[parsed.index];
143
143
  if (entry === void 0) return {
144
144
  ok: false,
145
- message: `Memory ${parsed.source}[${parsed.index}] does not exist (${entries.length} entries).`
145
+ message: `记忆 ${parsed.source}[${parsed.index}] 不存在(共 ${entries.length} 条)。`
146
146
  };
147
147
  if (parsed.snapshot !== void 0 && memorySnapshotOf(entry) !== parsed.snapshot) return {
148
148
  ok: false,
149
- message: `Memory ${parsed.source}[${parsed.index}] changed since the graph was rendered; run /graph again and retry.`
149
+ message: `记忆 ${parsed.source}[${parsed.index}] 在图渲染之后被改动过:请重新运行 /graph 再重试。`
150
150
  };
151
151
  return {
152
152
  ok: true,
@@ -180,7 +180,7 @@ async function resolveGraphNode(parsed, repository) {
180
180
  const content = await repository.readSkill(parsed.name);
181
181
  return content === null ? {
182
182
  ok: false,
183
- message: `Skill "${parsed.name}" not found.`
183
+ message: `技能「${parsed.name}」不存在。`
184
184
  } : {
185
185
  ok: true,
186
186
  message: content
@@ -192,7 +192,7 @@ async function resolveGraphNode(parsed, repository) {
192
192
  message: check.entry ?? ""
193
193
  } : {
194
194
  ok: false,
195
- message: check.message ?? `Memory ${parsed.source}[${parsed.index}] is not available.`
195
+ message: check.message ?? `Memory ${parsed.source}[${parsed.index}] 不可用。`
196
196
  };
197
197
  }
198
198
  /**
@@ -224,7 +224,7 @@ function apply(ctx, rawConfig = {}) {
224
224
  const commands = commandCtx.commands;
225
225
  const graphCommand = {
226
226
  name: "graph",
227
- description: "Show the learning graph, or act on a node: graph [detail|edit|delete] <nodeId>",
227
+ description: "显示学习图,或对某个节点操作:graph [detail|edit|delete] <nodeId>",
228
228
  input: { hint: "[detail|edit|delete] <nodeId> [text]" },
229
229
  run: async (invocation) => {
230
230
  const ok = (text) => ({
@@ -238,7 +238,7 @@ function apply(ctx, rawConfig = {}) {
238
238
  const usageService = ctx.get("skillUsage");
239
239
  const memoryService = ctx.get("memory");
240
240
  const ioService = ctx.get("evolutionIo");
241
- if (!usageService || !memoryService || !ioService) return err("skill-usage, memory or evolution-io service is not mounted.");
241
+ if (!usageService || !memoryService || !ioService) return err("skill-usage、memory 或 evolution-io 服务未挂载。");
242
242
  const usage = usageService;
243
243
  const memory = memoryService;
244
244
  const io = ioService;
@@ -269,16 +269,16 @@ function apply(ctx, rawConfig = {}) {
269
269
  return await nodeDelete(remove[1]);
270
270
  }
271
271
  const directory = await renderGraph();
272
- if (input !== "") return err(`Unknown graph subcommand "${input.split(" ")[0]}". ${directory}`);
272
+ if (input !== "") return err(`未知的 graph 子命令「${input.split(" ")[0]}」。${directory}`);
273
273
  return ok(directory);
274
274
  /** S1-F3: the pre-staging existence probe shared by edit and delete.
275
275
  * @returns null to proceed, or the refusal line to show the operator. */
276
276
  async function probeSkillForStaging(name) {
277
277
  try {
278
278
  if (await withSkills().read(name) !== null) return null;
279
- return `Skill "${name}" not found in the live skill library. (The graph may be showing a stale node.)`;
279
+ return `实时技能库里没有技能「${name}」,即该技能不存在。(图里可能显示的是过期节点。)`;
280
280
  } catch (error) {
281
- 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.`;
281
+ return `无法读取技能「${name}」以确认它存在(${error instanceof Error ? error.message : String(error)}):拒绝暂存。该技能可能仍然存在;请解决读取失败后重试。`;
282
282
  }
283
283
  }
284
284
  async function renderGraph() {
@@ -326,7 +326,7 @@ function apply(ctx, rawConfig = {}) {
326
326
  }
327
327
  async function nodeDetail(id) {
328
328
  const parsed = parseGraphNodeId(id);
329
- if (parsed === null) return err(`Invalid node id "${id}". Skill names or memory:<source>:<index> expected.`);
329
+ if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
330
330
  const resolved = await resolveGraphNode(parsed, {
331
331
  readSkill: (name) => withSkills().read(name),
332
332
  readMemory: (target) => memory.read(target)
@@ -335,14 +335,14 @@ function apply(ctx, rawConfig = {}) {
335
335
  }
336
336
  async function nodeEdit(id, content) {
337
337
  const parsed = parseGraphNodeId(id);
338
- if (parsed === null) return err(`Invalid node id "${id}". Skill names or memory:<source>:<index> expected.`);
338
+ if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
339
339
  if (parsed.kind === "skill") {
340
340
  const approval = ctx.get("evolutionApproval");
341
341
  const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
342
342
  if (approval) {
343
343
  const sessionPolicyEdit = effectiveSessionPolicy(ctx, session);
344
344
  const stagesForeground = approval.stageForeground !== false;
345
- if (approval.isEnabled !== false && sessionPolicyEdit !== "never" && (origins.approval === "background_review" || stagesForeground) && !approval.hasRunner("skill")) return err("Graph skill write cannot be staged: no skill replay runner is registered — mount the tool-skill-manage row (evolution-agent preset) or disable evolution-approval.");
345
+ if (approval.isEnabled !== false && sessionPolicyEdit !== "never" && (origins.approval === "background_review" || stagesForeground) && !approval.hasRunner("skill")) return err("无法暂存 graph 技能写入:没有注册技能回放运行器 —— 请挂载 tool-skill-manage 行(evolution-agent 预设),或禁用 evolution-approval。");
346
346
  const sessionPolicy = sessionPolicyEdit;
347
347
  const stageCurrent = await withSkills().read(parsed.name).catch(() => void 0);
348
348
  const decision = await approval.request({
@@ -370,12 +370,12 @@ function apply(ctx, rawConfig = {}) {
370
370
  return result.ok ? ok(result.message) : err(result.message);
371
371
  }
372
372
  const check = readMemoryIndex(parsed, await memory.read(parsed.source));
373
- if (!check.ok) return err(check.message ?? "Memory index check failed.");
373
+ if (!check.ok) return err(check.message ?? "记忆索引检查失败。");
374
374
  const memoryApproval = ctx.get("evolutionApproval");
375
375
  if (memoryApproval) {
376
376
  const originsM = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
377
377
  const sessionPolicyM = effectiveSessionPolicy(ctx, session);
378
- if (memoryApproval.isEnabled !== false && sessionPolicyM !== "never" && (originsM.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("Graph memory write cannot be staged: no memory replay runner is registered — mount the tool-memory row (evolution-all bundle, or the evolution-preset overlay; the host bundle does not carry it) or disable evolution-approval.");
378
+ if (memoryApproval.isEnabled !== false && sessionPolicyM !== "never" && (originsM.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("无法暂存 graph 记忆写入:没有注册记忆回放运行器 —— 请挂载 tool-memory 行(evolution-all bundle,或 evolution-preset overlay;宿主 bundle 里不含它),或禁用 evolution-approval。");
379
379
  const decision = await memoryApproval.request({
380
380
  kind: "memory",
381
381
  summary: `graph edit memory:${parsed.source}:${parsed.index}`,
@@ -403,13 +403,13 @@ function apply(ctx, rawConfig = {}) {
403
403
  }
404
404
  async function nodeDelete(id) {
405
405
  const parsed = parseGraphNodeId(id);
406
- if (parsed === null) return err(`Invalid node id "${id}". Skill names or memory:<source>:<index> expected.`);
406
+ if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
407
407
  if (parsed.kind === "skill") {
408
408
  const approval = ctx.get("evolutionApproval");
409
409
  if (approval) {
410
410
  const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
411
411
  const sessionPolicy = effectiveSessionPolicy(ctx, session);
412
- if (approval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || approval.stageForeground !== false) && !approval.hasRunner("skill")) return err("Graph skill delete cannot be staged: no skill replay runner is registered — mount the tool-skill-manage row (evolution-agent preset) or disable evolution-approval.");
412
+ if (approval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || approval.stageForeground !== false) && !approval.hasRunner("skill")) return err("无法暂存 graph 技能删除:没有注册技能回放运行器 —— 请挂载 tool-skill-manage 行(evolution-agent 预设),或禁用 evolution-approval。");
413
413
  const decision = await approval.request({
414
414
  kind: "skill",
415
415
  summary: `graph delete ${parsed.name}`,
@@ -433,12 +433,12 @@ function apply(ctx, rawConfig = {}) {
433
433
  return result.ok ? ok(result.message) : err(result.message);
434
434
  }
435
435
  const check = readMemoryIndex(parsed, await memory.read(parsed.source));
436
- if (!check.ok) return err(check.message ?? "Memory index check failed.");
436
+ if (!check.ok) return err(check.message ?? "记忆索引检查失败。");
437
437
  const memoryApproval = ctx.get("evolutionApproval");
438
438
  if (memoryApproval) {
439
439
  const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
440
440
  const sessionPolicy = effectiveSessionPolicy(ctx, session);
441
- if (memoryApproval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("Graph memory delete cannot be staged: no memory replay runner is registered — mount the tool-memory row (evolution-all bundle, or the evolution-preset overlay; the host bundle does not carry it) or disable evolution-approval.");
441
+ if (memoryApproval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("无法暂存 graph 记忆删除:没有注册记忆回放运行器 —— 请挂载 tool-memory 行(evolution-all bundle,或 evolution-preset overlay;宿主 bundle 里不含它),或禁用 evolution-approval。");
442
442
  const decision = await memoryApproval.request({
443
443
  kind: "memory",
444
444
  summary: `graph delete memory:${parsed.source}:${parsed.index}`,
@@ -465,7 +465,7 @@ function apply(ctx, rawConfig = {}) {
465
465
  },
466
466
  handler: (invocation) => graphCommand.run(invocation).catch((error) => ({
467
467
  kind: "error",
468
- text: `graph: command failed: ${error instanceof Error ? error.message : String(error)}\nCheck the node id and the skills/memory files under the evolution root, then retry.`
468
+ text: `graph:命令失败:${error instanceof Error ? error.message : String(error)}\n请检查节点 id 以及 evolution 根目录下的 skills/memory 文件,然后重试。`
469
469
  }))
470
470
  };
471
471
  commandCtx.effect(() => commands.register(graphCommand), "evolution-learning-graph.command");
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.23.0",
4
+ "version": "0.24.0",
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.4",
30
- "@lmzhen/dsh-evolution-approval": "^0.23.0",
31
- "@lmzhen/dsh-evolution-core": "^0.23.0"
30
+ "@lmzhen/dsh-evolution-approval": "^0.24.0",
31
+ "@lmzhen/dsh-evolution-core": "^0.24.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@deepseek-ai/dsh-commands": "^0.2.0-rc.1",