@lmzhen/dsh-evolution-plan-validator 0.1.0 → 0.2.0-rc.2
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 +11 -2
- package/lib/types/index.d.ts +5 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +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
|
+
import { DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_USER_CHAR_LIMIT, MAX_RESTRUCTURE_MOVES, RESTRUCTURE_TARGET_RE } from "@lmzhen/dsh-evolution-core";
|
|
2
2
|
//#region lib/types/index.js
|
|
3
3
|
/**
|
|
4
4
|
* Deterministic validator for model-produced evolution plans.
|
|
@@ -17,7 +17,8 @@ const SKILL_ACTIONS = new Set([
|
|
|
17
17
|
"patch",
|
|
18
18
|
"delete",
|
|
19
19
|
"write_file",
|
|
20
|
-
"remove_file"
|
|
20
|
+
"remove_file",
|
|
21
|
+
"restructure"
|
|
21
22
|
]);
|
|
22
23
|
const FORBIDDEN_KEYS = [
|
|
23
24
|
"policy",
|
|
@@ -121,6 +122,14 @@ function validateSkillOp(op, context, index) {
|
|
|
121
122
|
const writeContent = op.file_content ?? op.content ?? "";
|
|
122
123
|
if (action === "write_file" && !writeContent.trim()) return `skill op ${index}: write_file requires file_content`;
|
|
123
124
|
if (writeContent.length > (context.maxSkillContentChars ?? DEFAULT_SKILL_CONTENT_CHARS)) return `skill op ${index}: content exceeds skill budget`;
|
|
125
|
+
if (action === "restructure") {
|
|
126
|
+
if (!Array.isArray(op.restructure) || op.restructure.length === 0) return `skill op ${index}: restructure requires a non-empty restructure list`;
|
|
127
|
+
if (op.restructure.length > MAX_RESTRUCTURE_MOVES) return `skill op ${index}: restructure exceeds ${MAX_RESTRUCTURE_MOVES} moves`;
|
|
128
|
+
for (const [moveIndex, move] of op.restructure.entries()) {
|
|
129
|
+
if (!move || typeof move.heading !== "string" || !move.heading.trim()) return `skill op ${index}: restructure[${moveIndex}] requires a non-empty heading`;
|
|
130
|
+
if (typeof move.to_file !== "string" || !RESTRUCTURE_TARGET_RE.test(move.to_file)) return `skill op ${index}: restructure[${moveIndex}] to_file must be references/<topic>.md`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
124
133
|
return null;
|
|
125
134
|
}
|
|
126
135
|
//#endregion
|
package/lib/types/index.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export interface SkillOp {
|
|
|
21
21
|
new_string?: string;
|
|
22
22
|
file_path?: string;
|
|
23
23
|
absorbed_into?: string;
|
|
24
|
+
/** restructure payload: body sections moved to references/ (008 batch B). */
|
|
25
|
+
restructure?: Array<{
|
|
26
|
+
heading?: string;
|
|
27
|
+
to_file?: string;
|
|
28
|
+
} | null>;
|
|
24
29
|
evidence?: unknown[];
|
|
25
30
|
}
|
|
26
31
|
export interface EvolutionPlan {
|
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.
|
|
4
|
+
"version": "0.2.0-rc.2",
|
|
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.
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.2.0-rc.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|