@lmzhen/dsh-evolution-learning-graph 0.22.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.
- package/lib/index.js +19 -20
- 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:
|
|
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:
|
|
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:
|
|
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}]
|
|
195
|
+
message: check.message ?? `Memory ${parsed.source}[${parsed.index}] 不可用。`
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -224,8 +224,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
224
224
|
const commands = commandCtx.commands;
|
|
225
225
|
const graphCommand = {
|
|
226
226
|
name: "graph",
|
|
227
|
-
description: "
|
|
228
|
-
recordInput: false,
|
|
227
|
+
description: "显示学习图,或对某个节点操作:graph [detail|edit|delete] <nodeId>",
|
|
229
228
|
input: { hint: "[detail|edit|delete] <nodeId> [text]" },
|
|
230
229
|
run: async (invocation) => {
|
|
231
230
|
const ok = (text) => ({
|
|
@@ -239,7 +238,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
239
238
|
const usageService = ctx.get("skillUsage");
|
|
240
239
|
const memoryService = ctx.get("memory");
|
|
241
240
|
const ioService = ctx.get("evolutionIo");
|
|
242
|
-
if (!usageService || !memoryService || !ioService) return err("skill-usage
|
|
241
|
+
if (!usageService || !memoryService || !ioService) return err("skill-usage、memory 或 evolution-io 服务未挂载。");
|
|
243
242
|
const usage = usageService;
|
|
244
243
|
const memory = memoryService;
|
|
245
244
|
const io = ioService;
|
|
@@ -270,16 +269,16 @@ function apply(ctx, rawConfig = {}) {
|
|
|
270
269
|
return await nodeDelete(remove[1]);
|
|
271
270
|
}
|
|
272
271
|
const directory = await renderGraph();
|
|
273
|
-
if (input !== "") return err(
|
|
272
|
+
if (input !== "") return err(`未知的 graph 子命令「${input.split(" ")[0]}」。${directory}`);
|
|
274
273
|
return ok(directory);
|
|
275
274
|
/** S1-F3: the pre-staging existence probe shared by edit and delete.
|
|
276
275
|
* @returns null to proceed, or the refusal line to show the operator. */
|
|
277
276
|
async function probeSkillForStaging(name) {
|
|
278
277
|
try {
|
|
279
278
|
if (await withSkills().read(name) !== null) return null;
|
|
280
|
-
return
|
|
279
|
+
return `实时技能库里没有技能「${name}」,即该技能不存在。(图里可能显示的是过期节点。)`;
|
|
281
280
|
} catch (error) {
|
|
282
|
-
return
|
|
281
|
+
return `无法读取技能「${name}」以确认它存在(${error instanceof Error ? error.message : String(error)}):拒绝暂存。该技能可能仍然存在;请解决读取失败后重试。`;
|
|
283
282
|
}
|
|
284
283
|
}
|
|
285
284
|
async function renderGraph() {
|
|
@@ -327,7 +326,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
327
326
|
}
|
|
328
327
|
async function nodeDetail(id) {
|
|
329
328
|
const parsed = parseGraphNodeId(id);
|
|
330
|
-
if (parsed === null) return err(
|
|
329
|
+
if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
|
|
331
330
|
const resolved = await resolveGraphNode(parsed, {
|
|
332
331
|
readSkill: (name) => withSkills().read(name),
|
|
333
332
|
readMemory: (target) => memory.read(target)
|
|
@@ -336,14 +335,14 @@ function apply(ctx, rawConfig = {}) {
|
|
|
336
335
|
}
|
|
337
336
|
async function nodeEdit(id, content) {
|
|
338
337
|
const parsed = parseGraphNodeId(id);
|
|
339
|
-
if (parsed === null) return err(
|
|
338
|
+
if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
|
|
340
339
|
if (parsed.kind === "skill") {
|
|
341
340
|
const approval = ctx.get("evolutionApproval");
|
|
342
341
|
const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
|
|
343
342
|
if (approval) {
|
|
344
343
|
const sessionPolicyEdit = effectiveSessionPolicy(ctx, session);
|
|
345
344
|
const stagesForeground = approval.stageForeground !== false;
|
|
346
|
-
if (approval.isEnabled !== false && sessionPolicyEdit !== "never" && (origins.approval === "background_review" || stagesForeground) && !approval.hasRunner("skill")) return err("
|
|
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。");
|
|
347
346
|
const sessionPolicy = sessionPolicyEdit;
|
|
348
347
|
const stageCurrent = await withSkills().read(parsed.name).catch(() => void 0);
|
|
349
348
|
const decision = await approval.request({
|
|
@@ -371,12 +370,12 @@ function apply(ctx, rawConfig = {}) {
|
|
|
371
370
|
return result.ok ? ok(result.message) : err(result.message);
|
|
372
371
|
}
|
|
373
372
|
const check = readMemoryIndex(parsed, await memory.read(parsed.source));
|
|
374
|
-
if (!check.ok) return err(check.message ?? "
|
|
373
|
+
if (!check.ok) return err(check.message ?? "记忆索引检查失败。");
|
|
375
374
|
const memoryApproval = ctx.get("evolutionApproval");
|
|
376
375
|
if (memoryApproval) {
|
|
377
376
|
const originsM = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
|
|
378
377
|
const sessionPolicyM = effectiveSessionPolicy(ctx, session);
|
|
379
|
-
if (memoryApproval.isEnabled !== false && sessionPolicyM !== "never" && (originsM.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("
|
|
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。");
|
|
380
379
|
const decision = await memoryApproval.request({
|
|
381
380
|
kind: "memory",
|
|
382
381
|
summary: `graph edit memory:${parsed.source}:${parsed.index}`,
|
|
@@ -404,13 +403,13 @@ function apply(ctx, rawConfig = {}) {
|
|
|
404
403
|
}
|
|
405
404
|
async function nodeDelete(id) {
|
|
406
405
|
const parsed = parseGraphNodeId(id);
|
|
407
|
-
if (parsed === null) return err(
|
|
406
|
+
if (parsed === null) return err(`节点 id「${id}」不合法:应为技能名或 memory:<source>:<index>。`);
|
|
408
407
|
if (parsed.kind === "skill") {
|
|
409
408
|
const approval = ctx.get("evolutionApproval");
|
|
410
409
|
if (approval) {
|
|
411
410
|
const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
|
|
412
411
|
const sessionPolicy = effectiveSessionPolicy(ctx, session);
|
|
413
|
-
if (approval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || approval.stageForeground !== false) && !approval.hasRunner("skill")) return err("
|
|
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。");
|
|
414
413
|
const decision = await approval.request({
|
|
415
414
|
kind: "skill",
|
|
416
415
|
summary: `graph delete ${parsed.name}`,
|
|
@@ -434,12 +433,12 @@ function apply(ctx, rawConfig = {}) {
|
|
|
434
433
|
return result.ok ? ok(result.message) : err(result.message);
|
|
435
434
|
}
|
|
436
435
|
const check = readMemoryIndex(parsed, await memory.read(parsed.source));
|
|
437
|
-
if (!check.ok) return err(check.message ?? "
|
|
436
|
+
if (!check.ok) return err(check.message ?? "记忆索引检查失败。");
|
|
438
437
|
const memoryApproval = ctx.get("evolutionApproval");
|
|
439
438
|
if (memoryApproval) {
|
|
440
439
|
const origins = resolveExecOrigins(invocationAgent && { agent: invocationAgent });
|
|
441
440
|
const sessionPolicy = effectiveSessionPolicy(ctx, session);
|
|
442
|
-
if (memoryApproval.isEnabled !== false && sessionPolicy !== "never" && (origins.approval === "background_review" || memoryApproval.stageForeground !== false) && !memoryApproval.hasRunner("memory")) return err("
|
|
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。");
|
|
443
442
|
const decision = await memoryApproval.request({
|
|
444
443
|
kind: "memory",
|
|
445
444
|
summary: `graph delete memory:${parsed.source}:${parsed.index}`,
|
|
@@ -466,7 +465,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
466
465
|
},
|
|
467
466
|
handler: (invocation) => graphCommand.run(invocation).catch((error) => ({
|
|
468
467
|
kind: "error",
|
|
469
|
-
text: `graph
|
|
468
|
+
text: `graph:命令失败:${error instanceof Error ? error.message : String(error)}\n请检查节点 id 以及 evolution 根目录下的 skills/memory 文件,然后重试。`
|
|
470
469
|
}))
|
|
471
470
|
};
|
|
472
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.
|
|
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.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^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",
|