@lmzhen/dsh-evolution-learning-graph 0.1.0-rc.1

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 ADDED
@@ -0,0 +1,24 @@
1
+ # @deepseek-ai/dsh-evolution-learning-graph
2
+
3
+ Learning graph over skills and memory
4
+
5
+ ## Model Experience
6
+
7
+ ### Indirect model surface
8
+
9
+ #### What the model sees
10
+
11
+ `@deepseek-ai/dsh-evolution-learning-graph` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
12
+
13
+ #### Token effect
14
+
15
+ Zero direct token effect from this package; consumers add any model-visible tokens.
16
+
17
+ #### KV Cache effect
18
+
19
+ Independent of request-prefix construction. This package does not alter the assembled prompt or tool list.
20
+
21
+ ## Known Limitations and Deferred Work
22
+
23
+
24
+ - No known durable consumer gaps at this time. Runtime contracts are covered by package and boundary tests.
package/lib/index.js ADDED
@@ -0,0 +1,63 @@
1
+ //#region lib/types/index.js
2
+ /**
3
+ * Learning graph over skills and memory.
4
+ * @module @lmzhen/dsh-evolution-learning-graph
5
+ */
6
+ /** Build a small deterministic graph from usage records and memory entries. */
7
+ function buildLearningGraph(usage, memoryEntries) {
8
+ const nodes = [...usage.keys()].map((name) => ({
9
+ id: name,
10
+ kind: "skill",
11
+ label: name
12
+ }));
13
+ const edges = [];
14
+ const sorted = [...usage.keys()].sort();
15
+ for (let i = 1; i < sorted.length; i += 1) {
16
+ const from = sorted[i - 1];
17
+ const to = sorted[i];
18
+ if (from && to) edges.push({
19
+ from,
20
+ to,
21
+ type: "related"
22
+ });
23
+ }
24
+ memoryEntries.forEach((entry, index) => {
25
+ const id = `memory:${index}`;
26
+ nodes.push({
27
+ id,
28
+ kind: "memory",
29
+ label: entry.split("\n")[0]?.slice(0, 80) ?? id
30
+ });
31
+ const token = entry.toLowerCase();
32
+ for (const name of sorted) if (name && token.includes(name.toLowerCase())) edges.push({
33
+ from: id,
34
+ to: name,
35
+ type: "memory_skill"
36
+ });
37
+ });
38
+ return {
39
+ nodes,
40
+ edges
41
+ };
42
+ }
43
+ const name = "evolution-learning-graph";
44
+ function apply(ctx) {
45
+ ctx.inject(["commands"], (commandCtx) => {
46
+ commandCtx.commands.register({
47
+ name: "evolution graph",
48
+ description: "Show the current learning graph",
49
+ recordInput: false,
50
+ handler: async () => {
51
+ const usage = ctx.get("skillUsage");
52
+ const memory = ctx.get("memory");
53
+ if (!usage || !memory) return { text: "skill-usage or memory service is not mounted." };
54
+ const graph = buildLearningGraph(await usage.report(), await memory.read("memory"));
55
+ const lines = graph.nodes.map((node) => (node.kind === "memory" ? "◆" : "●") + " " + node.label);
56
+ const edges = graph.edges.map((edge) => edge.from + " --" + edge.type + "--> " + edge.to);
57
+ return { text: lines.join("\n") + "\n\n" + edges.join("\n") };
58
+ }
59
+ });
60
+ });
61
+ }
62
+ //#endregion
63
+ export { apply, buildLearningGraph, name };
@@ -0,0 +1,8 @@
1
+ //#region lib/types/invariant.js
2
+ const PACKAGE_NAME = "@deepseek-ai/dsh-evolution-learning-graph";
3
+ const name = "evolution-learning-graph-invariant";
4
+ const inject = ["invariants"];
5
+ const install = () => {};
6
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
7
+ //#endregion
8
+ export { apply, inject, name };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Learning graph over skills and memory.
3
+ * @module @deepseek-ai/dsh-evolution-learning-graph
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ export interface GraphNode {
7
+ id: string;
8
+ kind: 'skill' | 'memory';
9
+ label: string;
10
+ }
11
+ export interface GraphEdge {
12
+ from: string;
13
+ to: string;
14
+ type: 'related' | 'memory_skill';
15
+ }
16
+ export interface LearningGraph {
17
+ nodes: GraphNode[];
18
+ edges: GraphEdge[];
19
+ }
20
+ /** Build a small deterministic graph from usage records and memory entries. */
21
+ export declare function buildLearningGraph(usage: ReadonlyMap<string, {
22
+ use_count?: number;
23
+ pinned?: boolean;
24
+ }>, memoryEntries: readonly string[]): LearningGraph;
25
+ export declare const name = "evolution-learning-graph";
26
+ export declare function apply(ctx: Context): void;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "evolution-learning-graph-invariant";
3
+ export declare const inject: string[];
4
+ export declare const apply: (ctx: Context) => Promise<() => void>;
5
+ //# sourceMappingURL=invariant.d.ts.map
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@lmzhen/dsh-evolution-learning-graph",
3
+ "description": "Learning graph over skills and memory (community build)",
4
+ "version": "0.1.0-rc.1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/lmzhen/dsh-evolution.git",
11
+ "directory": "packages/dsh-evolution-learning-graph"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/index.js",
29
+ "lib/invariant.js",
30
+ "lib/types/**/*.d.ts",
31
+ "lib/types/invariant.d.ts"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "@deepseek-ai/schemastery": "^3.18.1"
36
+ },
37
+ "peerDependencies": {
38
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
39
+ "@deepseek-ai/cordis": "^4.0.1"
40
+ },
41
+ "devDependencies": {
42
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6"
43
+ }
44
+ }