@lmzhen/dsh-evolution-feedback 0.3.21 → 0.3.23
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 -7
- package/lib/types/index.d.ts +5 -0
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { EVENT_LOG_VERSION, appendEvolutionEvent, eventsFile, evolutionIoAdapter, listEventArchives, parseEvolutionEvents, readEvolutionTimeline, transactIo } from "@lmzhen/dsh-evolution-core";
|
|
3
|
-
import { homedir } from "node:os";
|
|
2
|
+
import { EVENT_LOG_VERSION, appendEvolutionEvent, clampedNumber, eventsFile, evolutionIoAdapter, evolutionRoot, listEventArchives, parseEvolutionEvents, readEvolutionTimeline, transactIo } from "@lmzhen/dsh-evolution-core";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
//#region lib/types/index.js
|
|
6
5
|
/**
|
|
@@ -34,7 +33,7 @@ var EvolutionFeedback = class {
|
|
|
34
33
|
eventsPath;
|
|
35
34
|
io;
|
|
36
35
|
warn;
|
|
37
|
-
constructor(io, home =
|
|
36
|
+
constructor(io, home = evolutionRoot(), pathOverride, warn = () => {}) {
|
|
38
37
|
this.path = pathOverride ?? join(home, "evolution", "feedback.json");
|
|
39
38
|
this.eventsPath = eventsFile(home);
|
|
40
39
|
this.io = io;
|
|
@@ -363,11 +362,24 @@ function synthesizeFeedbackEvents(aggregate) {
|
|
|
363
362
|
}
|
|
364
363
|
const name = "evolution-feedback";
|
|
365
364
|
const Config = z.object({
|
|
366
|
-
qualityWarnThreshold: z.number().default(-.25),
|
|
365
|
+
qualityWarnThreshold: z.number().min(-1).max(1).default(-.25),
|
|
367
366
|
path: z.string().default("")
|
|
368
367
|
});
|
|
368
|
+
/** Resolve the effective quality warn threshold, clamped to its [-1, 1] domain
|
|
369
|
+
* (G3.1). 0 and negative values are legal (a lower threshold is stricter); NaN,
|
|
370
|
+
* ±Infinity and out-of-range values fall back to the default -0.25. Exported so
|
|
371
|
+
* the clamp is directly testable; `apply` warns when a value was corrected. */
|
|
372
|
+
function resolveQualityWarnThreshold(config) {
|
|
373
|
+
return clampedNumber(config.qualityWarnThreshold ?? -.25, -.25, {
|
|
374
|
+
min: -1,
|
|
375
|
+
max: 1
|
|
376
|
+
});
|
|
377
|
+
}
|
|
369
378
|
function apply(ctx, rawConfig = {}) {
|
|
370
|
-
const
|
|
379
|
+
const configuredThreshold = rawConfig.qualityWarnThreshold ?? -.25;
|
|
380
|
+
const qualityWarnThreshold = resolveQualityWarnThreshold(rawConfig);
|
|
381
|
+
if (qualityWarnThreshold !== configuredThreshold) ctx.logger.warn(`evolution-feedback: qualityWarnThreshold=${String(configuredThreshold)} is invalid; falling back to the default -0.25`);
|
|
382
|
+
const feedback = new EvolutionFeedback(void 0, evolutionRoot(), rawConfig.path || void 0, (message) => {
|
|
371
383
|
ctx.logger.warn(message);
|
|
372
384
|
});
|
|
373
385
|
ctx.provide("evolutionFeedback", feedback);
|
|
@@ -389,7 +401,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
389
401
|
baseRecord(target, rating, note, kind ?? "session");
|
|
390
402
|
if (kind === "skill") {
|
|
391
403
|
const score = feedback.score(target, "skill");
|
|
392
|
-
const warn = score <
|
|
404
|
+
const warn = score < qualityWarnThreshold;
|
|
393
405
|
skillUsage.setQuality(target, score, warn).catch((error) => {
|
|
394
406
|
skillCtx.logger.warn(error);
|
|
395
407
|
});
|
|
@@ -401,4 +413,4 @@ function apply(ctx, rawConfig = {}) {
|
|
|
401
413
|
}, "evolution-feedback.records");
|
|
402
414
|
}
|
|
403
415
|
//#endregion
|
|
404
|
-
export { Config, EvolutionFeedback, apply, migrateFeedbackEvents, name };
|
|
416
|
+
export { Config, EvolutionFeedback, apply, migrateFeedbackEvents, name, resolveQualityWarnThreshold };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -73,6 +73,11 @@ export interface Config {
|
|
|
73
73
|
path?: string;
|
|
74
74
|
}
|
|
75
75
|
export declare const Config: z<Config>;
|
|
76
|
+
/** Resolve the effective quality warn threshold, clamped to its [-1, 1] domain
|
|
77
|
+
* (G3.1). 0 and negative values are legal (a lower threshold is stricter); NaN,
|
|
78
|
+
* ±Infinity and out-of-range values fall back to the default -0.25. Exported so
|
|
79
|
+
* the clamp is directly testable; `apply` warns when a value was corrected. */
|
|
80
|
+
export declare function resolveQualityWarnThreshold(config: Config): number;
|
|
76
81
|
export declare function apply(ctx: Context, rawConfig?: Config): void;
|
|
77
82
|
export {};
|
|
78
83
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-feedback",
|
|
3
3
|
"description": "Feedback-to-quality scoring for self-evolution (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.23",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
34
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
34
|
+
"@lmzhen/dsh-evolution-core": "^0.3.23"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
39
|
-
"@lmzhen/dsh-evolution-io": "^0.3.
|
|
40
|
-
"@lmzhen/dsh-skill-usage": "^0.3.
|
|
39
|
+
"@lmzhen/dsh-evolution-io": "^0.3.23",
|
|
40
|
+
"@lmzhen/dsh-skill-usage": "^0.3.23"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
44
|
-
"@lmzhen/dsh-evolution-io": "^0.3.
|
|
45
|
-
"@lmzhen/dsh-evolution-io-node": "^0.3.
|
|
46
|
-
"@lmzhen/dsh-skill-usage": "^0.3.
|
|
44
|
+
"@lmzhen/dsh-evolution-io": "^0.3.23",
|
|
45
|
+
"@lmzhen/dsh-evolution-io-node": "^0.3.23",
|
|
46
|
+
"@lmzhen/dsh-skill-usage": "^0.3.23"
|
|
47
47
|
}
|
|
48
48
|
}
|