@lmzhen/dsh-evolution-learning-graph 0.3.51 → 0.3.53
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 +22 -6
- package/lib/types/index.d.ts +20 -1
- package/package.json +5 -4
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
1
2
|
import { SKILL_NAME_RE, SkillLibrary, evolutionIoAdapter, relatedSkillNames, resolveOrigins, resolveSkillsRoot } from "@lmzhen/dsh-evolution-core";
|
|
2
3
|
//#region lib/types/index.js
|
|
3
4
|
/**
|
|
@@ -196,7 +197,22 @@ async function resolveGraphNode(parsed, repository) {
|
|
|
196
197
|
* manage registers for `kind: 'skill'` replays them on approve.
|
|
197
198
|
*/
|
|
198
199
|
const name = "evolution-learning-graph";
|
|
199
|
-
|
|
200
|
+
const Config = z.object({ root: z.string().default("") });
|
|
201
|
+
/**
|
|
202
|
+
* F-10: rendered-line cap for the `/graph` directory — nodes span the
|
|
203
|
+
* whole usage set plus every memory entry and the edge list is a full join, so
|
|
204
|
+
* a large library used to produce an unbounded command result. Nodes and edges
|
|
205
|
+
* are each capped at this many lines (the density footer always renders the
|
|
206
|
+
* true totals); overflow shows a `…N more` marker instead.
|
|
207
|
+
*/
|
|
208
|
+
const GRAPH_RENDER_LINE_CAP = 200;
|
|
209
|
+
/** Join lines under the render cap; overflow is summarized, not dropped silently. */
|
|
210
|
+
function capRenderedLines(lines) {
|
|
211
|
+
if (lines.length <= 200) return lines.join("\n");
|
|
212
|
+
return [...lines.slice(0, 200), `…${lines.length - 200} more`].join("\n");
|
|
213
|
+
}
|
|
214
|
+
function apply(ctx, rawConfig = {}) {
|
|
215
|
+
const graphSkillsRoot = resolveSkillsRoot(rawConfig);
|
|
200
216
|
ctx.inject(["commands"], (commandCtx) => {
|
|
201
217
|
const commands = commandCtx.commands;
|
|
202
218
|
commandCtx.effect(() => commands.register({
|
|
@@ -242,14 +258,14 @@ function apply(ctx) {
|
|
|
242
258
|
related.set(name, relatedSkillNames(content, name));
|
|
243
259
|
}
|
|
244
260
|
const graph = buildLearningGraph(usageMap, memoryEntries, userEntries, related);
|
|
245
|
-
const
|
|
246
|
-
const
|
|
261
|
+
const nodeBlock = capRenderedLines(graph.nodes.map((node) => renderNodeLine(node)));
|
|
262
|
+
const edgeBlock = capRenderedLines(graph.edges.map((edge) => edge.from + " --" + edge.type + "--> " + edge.to));
|
|
247
263
|
const density = graphDensity(graph);
|
|
248
264
|
const densityLine = `\n\nSkills: ${density.skillNodes} · related edges: ${density.relatedEdges} (${density.edgesPerNode}/node) · isolated: ${density.isolatedPct}%`;
|
|
249
|
-
return
|
|
265
|
+
return nodeBlock + "\n\n" + edgeBlock + densityLine;
|
|
250
266
|
}
|
|
251
267
|
function withSkills() {
|
|
252
|
-
return new SkillLibrary(
|
|
268
|
+
return new SkillLibrary(graphSkillsRoot, evolutionIoAdapter(() => io.provider()), void 0, (event) => {
|
|
253
269
|
ctx.emit("evolution/skill-mutated", event);
|
|
254
270
|
});
|
|
255
271
|
}
|
|
@@ -337,4 +353,4 @@ function apply(ctx) {
|
|
|
337
353
|
});
|
|
338
354
|
}
|
|
339
355
|
//#endregion
|
|
340
|
-
export { apply, buildLearningGraph, graphDensity, memorySnapshotOf, name, parseGraphNodeId, readMemoryIndex, renderNodeLine, resolveGraphNode };
|
|
356
|
+
export { Config, GRAPH_RENDER_LINE_CAP, apply, buildLearningGraph, capRenderedLines, graphDensity, memorySnapshotOf, name, parseGraphNodeId, readMemoryIndex, renderNodeLine, resolveGraphNode };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module @lmzhen/dsh-evolution-learning-graph
|
|
9
9
|
*/
|
|
10
10
|
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
import z from '@deepseek-ai/schemastery';
|
|
11
12
|
export interface GraphNode {
|
|
12
13
|
id: string;
|
|
13
14
|
kind: 'skill' | 'memory';
|
|
@@ -123,5 +124,23 @@ export declare function resolveGraphNode(parsed: GraphNodeId, repository: {
|
|
|
123
124
|
* manage registers for `kind: 'skill'` replays them on approve.
|
|
124
125
|
*/
|
|
125
126
|
export declare const name = "evolution-learning-graph";
|
|
126
|
-
export
|
|
127
|
+
export interface Config {
|
|
128
|
+
/** V10-11 (P2-7): skill tree root for graph reads/edits; empty (default)
|
|
129
|
+
* resolves through `resolveSkillsRoot` to the shared default root. Keeps
|
|
130
|
+
* the graph on the SAME skills tree the tools/catalog read under a
|
|
131
|
+
* custom-root deployment (previously the default root was hardcoded). */
|
|
132
|
+
root?: string;
|
|
133
|
+
}
|
|
134
|
+
export declare const Config: z<Config>;
|
|
135
|
+
/**
|
|
136
|
+
* F-10: rendered-line cap for the `/graph` directory — nodes span the
|
|
137
|
+
* whole usage set plus every memory entry and the edge list is a full join, so
|
|
138
|
+
* a large library used to produce an unbounded command result. Nodes and edges
|
|
139
|
+
* are each capped at this many lines (the density footer always renders the
|
|
140
|
+
* true totals); overflow shows a `…N more` marker instead.
|
|
141
|
+
*/
|
|
142
|
+
export declare const GRAPH_RENDER_LINE_CAP = 200;
|
|
143
|
+
/** Join lines under the render cap; overflow is summarized, not dropped silently. */
|
|
144
|
+
export declare function capRenderedLines(lines: string[]): string;
|
|
145
|
+
export declare function apply(ctx: Context, rawConfig?: Config): void;
|
|
127
146
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.
|
|
4
|
+
"version": "0.3.53",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/lmzhen/dsh-evolution.git",
|
|
11
|
-
"directory": "packages/
|
|
11
|
+
"directory": "packages/evolution-learning-graph"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "lib/index.js",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@lmzhen/dsh-evolution-
|
|
33
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
34
|
+
"@lmzhen/dsh-evolution-approval": "^0.3.53",
|
|
35
|
+
"@lmzhen/dsh-evolution-core": "^0.3.53"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|