@lmzhen/dsh-evolution-plan-validator 0.1.0-rc.5 → 0.1.0-rc.50
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 +7 -3
- package/lib/types/index.d.ts +2 -0
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_USER_CHAR_LIMIT } from "@lmzhen/dsh-evolution-core";
|
|
1
2
|
//#region lib/types/index.js
|
|
2
3
|
/**
|
|
3
4
|
* Deterministic validator for model-produced evolution plans.
|
|
@@ -35,7 +36,7 @@ function hasValidEvidence(evidence, sessionSeq) {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
function validateEvolutionPlan(plan, context) {
|
|
38
|
-
const maxOps = context.maxOpsPerPlan ??
|
|
39
|
+
const maxOps = context.maxOpsPerPlan ?? DEFAULT_MAX_OPS_PER_PLAN;
|
|
39
40
|
const rejected = [];
|
|
40
41
|
const memoryOps = [];
|
|
41
42
|
const skillOps = [];
|
|
@@ -102,7 +103,7 @@ function validateMemoryOp(op, context, index) {
|
|
|
102
103
|
const text = (op.facts ?? op.content ?? "").trim();
|
|
103
104
|
if (action !== "remove" && text.length === 0) return `memory op ${index}: ${action} requires facts/content`;
|
|
104
105
|
if (action !== "add" && !(op.old_text ?? "").trim()) return `memory op ${index}: ${action} requires old_text`;
|
|
105
|
-
const budget = op.target === "user" ? context.maxUserChars ??
|
|
106
|
+
const budget = op.target === "user" ? context.maxUserChars ?? DEFAULT_USER_CHAR_LIMIT : context.maxMemoryChars ?? DEFAULT_MEMORY_CHAR_LIMIT;
|
|
106
107
|
if (text.length > budget) return `memory op ${index}: content exceeds ${op.target === "user" ? "user" : "memory"} budget`;
|
|
107
108
|
return null;
|
|
108
109
|
}
|
|
@@ -116,7 +117,10 @@ function validateSkillOp(op, context, index) {
|
|
|
116
117
|
if (!SKILL_ACTIONS.has(action)) return `skill op ${index}: unknown action ${action}`;
|
|
117
118
|
if ((action === "create" || action === "edit" || action === "update") && !(op.content ?? "").trim()) return `skill op ${index}: ${action} requires content`;
|
|
118
119
|
if (action === "patch" && !(op.old_string ?? "")) return `skill op ${index}: patch requires old_string`;
|
|
119
|
-
if (
|
|
120
|
+
if (action === "delete" && !(op.absorbed_into ?? "").trim()) return `skill op ${index}: delete requires absorbed_into`;
|
|
121
|
+
const writeContent = op.file_content ?? op.content ?? "";
|
|
122
|
+
if (action === "write_file" && !writeContent.trim()) return `skill op ${index}: write_file requires file_content`;
|
|
123
|
+
if (writeContent.length > (context.maxSkillContentChars ?? DEFAULT_SKILL_CONTENT_CHARS)) return `skill op ${index}: content exceeds skill budget`;
|
|
120
124
|
return null;
|
|
121
125
|
}
|
|
122
126
|
//#endregion
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-plan-validator",
|
|
3
3
|
"description": "Deterministic validator for model-produced evolution plans (community build)",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.50",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@deepseek-ai/schemastery": "^3.18.1"
|
|
35
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.1.0-rc.50"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
39
|
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|