@lmzhen/dsh-evolution-learning-graph 0.3.57 → 0.3.59

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/README.md CHANGED
@@ -10,7 +10,7 @@ Memory node ids carry a trailing snapshot token (`memory:<source>:<index>:<snaps
10
10
 
11
11
  Memory→skill edges are word-level, not substring: the entry is tokenized on non-letter/digit/hyphen runs and a skill name links only when it is a whole token. This prevents a skill named `run` from linking the words `running`/`grunt`.
12
12
 
13
- `graph edit`/`graph delete` of a skill node route through the evolution approval seam when it is mounted (soft-probed; the write executes directly when it is absent). Each approved/executed edit bumps the skill's patch counter and a delete archives it, matching `skill_manage` — including the no-op gate: an edit whose content is byte-equivalent to the current file (`noop`) writes nothing and does not bump the patch counter, exactly as `skill_manage` treats an unchanged update/patch.
13
+ `graph edit`/`graph delete` of a skill node route through the evolution approval seam when it is mounted (soft-probed; the write executes directly when it is absent). Each approved/executed edit bumps the skill's patch counter and a delete archives it, matching `skill_manage` — including the no-op gate: an edit whose content is byte-equivalent to the current file (`noop`) writes nothing and does not bump the patch counter, exactly as `skill_manage` treats an unchanged update/patch. The command invocation's session rides the approval request (v12 N1), so a `never`-policy session stages nothing instead of deriving every graph write as foreground.
14
14
 
15
15
  ## Model Experience
16
16
 
package/lib/index.js CHANGED
@@ -1,9 +1,12 @@
1
+ import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
1
2
  import z from "@deepseek-ai/schemastery";
2
3
  import { SKILL_NAME_RE, SkillLibrary, evolutionIoAdapter, relatedSkillNames, resolveOrigins, resolveSkillsRoot } from "@lmzhen/dsh-evolution-core";
3
4
  //#region lib/types/index.js
4
5
  /**
5
6
  * Learning graph over skills and memory, plus node-level commands
6
- * (`/evolution graph [detail|edit|delete] <nodeId>`) aligned with the Hermes
7
+ * (`graph [detail|edit|delete] <nodeId>` P2-33 (v11): the command is a
8
+ * TOP-LEVEL `graph` command, not `/evolution graph`; README is accurate)
9
+ * aligned with the Hermes
7
10
  * journey surface: a skill node is its name, a memory node is
8
11
  * `memory:<source>:<index>` (source = memory|user, index = position in that
9
12
  * file's entries). Memory node ids carry a trailing snapshot token so
@@ -236,6 +239,7 @@ function apply(ctx, rawConfig = {}) {
236
239
  const usage = usageService;
237
240
  const memory = memoryService;
238
241
  const io = ioService;
242
+ const session = invocation.agent?.session;
239
243
  const input = (invocation.rawInput ?? "").trim();
240
244
  const detail = /^detail\s+(\S+)$/.exec(input);
241
245
  if (detail && detail[1]) return await nodeDetail(detail[1]);
@@ -284,7 +288,8 @@ function apply(ctx, rawConfig = {}) {
284
288
  if (parsed.kind === "skill") {
285
289
  const approval = ctx.get("evolutionApproval");
286
290
  if (approval) {
287
- const origins = resolveOrigins(void 0);
291
+ const origins = resolveOrigins(session?.header?.origin);
292
+ const sessionPolicy = effectiveSessionPolicy(ctx, session);
288
293
  const decision = await approval.request({
289
294
  kind: "skill",
290
295
  summary: `graph edit ${parsed.name}`,
@@ -297,7 +302,10 @@ function apply(ctx, rawConfig = {}) {
297
302
  origin: origins.approval,
298
303
  libraryOrigin: origins.library
299
304
  },
300
- origin: origins.approval
305
+ origin: origins.approval,
306
+ ...session?.id ? { sessionId: session.id } : {},
307
+ ...session ? { session } : {},
308
+ ...sessionPolicy !== void 0 ? { sessionPolicy } : {}
301
309
  });
302
310
  if (decision.action === "staged") return ok(decision.message);
303
311
  }
@@ -320,7 +328,8 @@ function apply(ctx, rawConfig = {}) {
320
328
  if (parsed.kind === "skill") {
321
329
  const approval = ctx.get("evolutionApproval");
322
330
  if (approval) {
323
- const origins = resolveOrigins(void 0);
331
+ const origins = resolveOrigins(session?.header?.origin);
332
+ const sessionPolicy = effectiveSessionPolicy(ctx, session);
324
333
  const decision = await approval.request({
325
334
  kind: "skill",
326
335
  summary: `graph delete ${parsed.name}`,
@@ -332,7 +341,10 @@ function apply(ctx, rawConfig = {}) {
332
341
  origin: origins.approval,
333
342
  libraryOrigin: origins.library
334
343
  },
335
- origin: origins.approval
344
+ origin: origins.approval,
345
+ ...session?.id ? { sessionId: session.id } : {},
346
+ ...session ? { session } : {},
347
+ ...sessionPolicy !== void 0 ? { sessionPolicy } : {}
336
348
  });
337
349
  if (decision.action === "staged") return ok(decision.message);
338
350
  }
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Learning graph over skills and memory, plus node-level commands
3
- * (`/evolution graph [detail|edit|delete] <nodeId>`) aligned with the Hermes
3
+ * (`graph [detail|edit|delete] <nodeId>` P2-33 (v11): the command is a
4
+ * TOP-LEVEL `graph` command, not `/evolution graph`; README is accurate)
5
+ * aligned with the Hermes
4
6
  * journey surface: a skill node is its name, a memory node is
5
7
  * `memory:<source>:<index>` (source = memory|user, index = position in that
6
8
  * file's entries). Memory node ids carry a trailing snapshot token so
@@ -35,6 +37,24 @@ export interface GraphDensity {
35
37
  edgesPerNode: number;
36
38
  isolatedPct: number;
37
39
  }
40
+ /**
41
+ * The command invocation contract (N1, v12): the platform command handler
42
+ * freezes the invoking agent onto the invocation object — evolution-commands
43
+ * `/evolution learn` already reads `invocation.agent` — so the graph can pass
44
+ * `agent.session` to the approval service (tool-skill-manage pattern) instead
45
+ * of deriving every approval as foreground.
46
+ */
47
+ export interface GraphInvocation {
48
+ rawInput?: string;
49
+ agent?: {
50
+ session?: {
51
+ id?: string;
52
+ header?: {
53
+ origin?: string;
54
+ };
55
+ };
56
+ };
57
+ }
38
58
  export declare function graphDensity(graph: LearningGraph): GraphDensity;
39
59
  /**
40
60
  * Render one node's display line for `/evolution graph`.
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.3.57",
4
+ "version": "0.3.59",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,8 +31,8 @@
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
33
  "@deepseek-ai/schemastery": "^3.18.1",
34
- "@lmzhen/dsh-evolution-approval": "^0.3.57",
35
- "@lmzhen/dsh-evolution-core": "^0.3.57"
34
+ "@lmzhen/dsh-evolution-approval": "^0.3.59",
35
+ "@lmzhen/dsh-evolution-core": "^0.3.59"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",