@lmzhen/dsh-evolution-learning-graph 0.1.0-rc.25 → 0.1.0-rc.27
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 +25 -16
- package/lib/types/index.d.ts +7 -2
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -8,8 +8,13 @@ import { SKILL_NAME_RE, SkillLibrary, evolutionIoAdapter } from "@lmzhen/dsh-evo
|
|
|
8
8
|
* file's entries).
|
|
9
9
|
* @module @lmzhen/dsh-evolution-learning-graph
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Build a small deterministic graph from usage records and memory entries.
|
|
13
|
+
* Memory node ids follow `memory:<source>:<index>` (source = memory|user,
|
|
14
|
+
* index = position in that file's entries) — the SAME rule the parser
|
|
15
|
+
* `parseGraphNodeId` accepts, so graph detail/edit/delete round-trips.
|
|
16
|
+
*/
|
|
17
|
+
function buildLearningGraph(usage, memoryEntries, userEntries = []) {
|
|
13
18
|
const nodes = [...usage.keys()].map((name) => ({
|
|
14
19
|
id: name,
|
|
15
20
|
kind: "skill",
|
|
@@ -26,20 +31,24 @@ function buildLearningGraph(usage, memoryEntries) {
|
|
|
26
31
|
type: "related"
|
|
27
32
|
});
|
|
28
33
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const appendMemory = (source, entries) => {
|
|
35
|
+
entries.forEach((entry, index) => {
|
|
36
|
+
const id = `memory:${source}:${index}`;
|
|
37
|
+
nodes.push({
|
|
38
|
+
id,
|
|
39
|
+
kind: "memory",
|
|
40
|
+
label: entry.split("\n")[0]?.slice(0, 80) ?? id
|
|
41
|
+
});
|
|
42
|
+
const token = entry.toLowerCase();
|
|
43
|
+
for (const name of sorted) if (name && token.includes(name.toLowerCase())) edges.push({
|
|
44
|
+
from: id,
|
|
45
|
+
to: name,
|
|
46
|
+
type: "memory_skill"
|
|
47
|
+
});
|
|
41
48
|
});
|
|
42
|
-
}
|
|
49
|
+
};
|
|
50
|
+
appendMemory("memory", memoryEntries);
|
|
51
|
+
appendMemory("user", userEntries);
|
|
43
52
|
return {
|
|
44
53
|
nodes,
|
|
45
54
|
edges
|
|
@@ -107,7 +116,7 @@ function apply(ctx) {
|
|
|
107
116
|
if (input !== "") return { text: `Unknown graph subcommand "${input.split(" ")[0]}". ${directory}` };
|
|
108
117
|
return { text: directory };
|
|
109
118
|
async function renderGraph() {
|
|
110
|
-
const graph = buildLearningGraph(await usage.report(), await memory.read("memory"));
|
|
119
|
+
const graph = buildLearningGraph(await usage.report(), await memory.read("memory"), await memory.read("user"));
|
|
111
120
|
const lines = graph.nodes.map((node) => (node.kind === "memory" ? "◆" : "●") + " " + node.label);
|
|
112
121
|
const edges = graph.edges.map((edge) => edge.from + " --" + edge.type + "--> " + edge.to);
|
|
113
122
|
return lines.join("\n") + "\n\n" + edges.join("\n");
|
package/lib/types/index.d.ts
CHANGED
|
@@ -21,11 +21,16 @@ export interface LearningGraph {
|
|
|
21
21
|
nodes: GraphNode[];
|
|
22
22
|
edges: GraphEdge[];
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Build a small deterministic graph from usage records and memory entries.
|
|
26
|
+
* Memory node ids follow `memory:<source>:<index>` (source = memory|user,
|
|
27
|
+
* index = position in that file's entries) — the SAME rule the parser
|
|
28
|
+
* `parseGraphNodeId` accepts, so graph detail/edit/delete round-trips.
|
|
29
|
+
*/
|
|
25
30
|
export declare function buildLearningGraph(usage: ReadonlyMap<string, {
|
|
26
31
|
use_count?: number;
|
|
27
32
|
pinned?: boolean;
|
|
28
|
-
}>, memoryEntries: readonly string[]): LearningGraph;
|
|
33
|
+
}>, memoryEntries: readonly string[], userEntries?: readonly string[]): LearningGraph;
|
|
29
34
|
export type GraphNodeId = {
|
|
30
35
|
kind: 'skill';
|
|
31
36
|
name: string;
|
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.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.27",
|
|
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.
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.1.0-rc.27"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|