@lmzhen/dsh-evolution-policy 0.1.0-rc.45 → 0.1.0-rc.46
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 +2 -20
- package/lib/types/index.d.ts +0 -3
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
-
import { join, resolve, sep } from "node:path";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
2
|
import z from "@deepseek-ai/schemastery";
|
|
5
3
|
import { DEFAULT_ARCHIVE_AFTER_DAYS, DEFAULT_CURATOR_INTERVAL_HOURS, DEFAULT_MAX_OPS_PER_PLAN, DEFAULT_MEMORY_CHAR_LIMIT, DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_SKILL_CONTENT_CHARS, DEFAULT_STALE_AFTER_DAYS, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, DEFAULT_USER_CHAR_LIMIT } from "@lmzhen/dsh-evolution-core";
|
|
6
4
|
//#region lib/types/index.js
|
|
@@ -26,8 +24,7 @@ const Config = z.object({
|
|
|
26
24
|
curatorIntervalHours: z.number().default(DEFAULT_CURATOR_INTERVAL_HOURS),
|
|
27
25
|
staleAfterDays: z.number().default(DEFAULT_STALE_AFTER_DAYS),
|
|
28
26
|
archiveAfterDays: z.number().default(DEFAULT_ARCHIVE_AFTER_DAYS),
|
|
29
|
-
protectedSkillNames: z.array(z.string()).default([])
|
|
30
|
-
protectedPaths: z.array(z.string()).default([])
|
|
27
|
+
protectedSkillNames: z.array(z.string()).default([])
|
|
31
28
|
});
|
|
32
29
|
var EvolutionPolicy = class extends Service {
|
|
33
30
|
static Config = Config;
|
|
@@ -38,7 +35,6 @@ var EvolutionPolicy = class extends Service {
|
|
|
38
35
|
const tools = toolCtx.get("tools");
|
|
39
36
|
toolCtx.effect(() => tools.guard((exec) => this.guardReason(exec.name, exec.arguments)), "evolution-policy.tools-guard");
|
|
40
37
|
});
|
|
41
|
-
const homePolicyPath = resolve(join(process.env.DSH_HOME ?? join(homedir(), ".dsh"), "evolution", "policy.json"));
|
|
42
38
|
this.snapshot = Object.freeze({
|
|
43
39
|
version: 1,
|
|
44
40
|
reviewMemoryInterval: config.reviewMemoryInterval ?? DEFAULT_REVIEW_MEMORY_INTERVAL,
|
|
@@ -57,27 +53,13 @@ var EvolutionPolicy = class extends Service {
|
|
|
57
53
|
curatorIntervalHours: config.curatorIntervalHours ?? DEFAULT_CURATOR_INTERVAL_HOURS,
|
|
58
54
|
staleAfterDays: config.staleAfterDays ?? DEFAULT_STALE_AFTER_DAYS,
|
|
59
55
|
archiveAfterDays: config.archiveAfterDays ?? DEFAULT_ARCHIVE_AFTER_DAYS,
|
|
60
|
-
protectedSkillNames: Object.freeze([...new Set(["plan", ...config.protectedSkillNames ?? []])])
|
|
61
|
-
protectedPaths: Object.freeze([...config.protectedPaths ?? [], homePolicyPath])
|
|
56
|
+
protectedSkillNames: Object.freeze([...new Set(["plan", ...config.protectedSkillNames ?? []])])
|
|
62
57
|
});
|
|
63
58
|
}
|
|
64
59
|
get() {
|
|
65
60
|
return this.snapshot;
|
|
66
61
|
}
|
|
67
|
-
isProtectedPath(path) {
|
|
68
|
-
if (typeof path !== "string") return false;
|
|
69
|
-
const normalized = resolve(path);
|
|
70
|
-
return this.snapshot.protectedPaths.some((prefix) => {
|
|
71
|
-
const resolved = resolve(prefix);
|
|
72
|
-
return normalized === resolved || normalized.startsWith(resolved + sep);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
62
|
guardReason(toolName, args) {
|
|
76
|
-
if (toolName === "write" || toolName === "edit" || toolName === "patch" || toolName === "str_replace_editor") {
|
|
77
|
-
const record = asRecord(args);
|
|
78
|
-
const target = record.path ?? record.file_path ?? record.filePath;
|
|
79
|
-
if (this.isProtectedPath(target)) return `evolution-policy: refusing to modify protected policy path ${String(target)}`;
|
|
80
|
-
}
|
|
81
63
|
if (toolName === "memory" || toolName === "skill_manage") {
|
|
82
64
|
const record = asRecord(args);
|
|
83
65
|
for (const forbidden of [
|
package/lib/types/index.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ export interface PolicySnapshot {
|
|
|
29
29
|
staleAfterDays: number;
|
|
30
30
|
archiveAfterDays: number;
|
|
31
31
|
protectedSkillNames: readonly string[];
|
|
32
|
-
protectedPaths: readonly string[];
|
|
33
32
|
}
|
|
34
33
|
export interface Config {
|
|
35
34
|
reviewMemoryInterval?: number;
|
|
@@ -49,7 +48,6 @@ export interface Config {
|
|
|
49
48
|
staleAfterDays?: number;
|
|
50
49
|
archiveAfterDays?: number;
|
|
51
50
|
protectedSkillNames?: string[];
|
|
52
|
-
protectedPaths?: string[];
|
|
53
51
|
}
|
|
54
52
|
export declare const Config: Schema<Config>;
|
|
55
53
|
export declare class EvolutionPolicy extends Service {
|
|
@@ -57,7 +55,6 @@ export declare class EvolutionPolicy extends Service {
|
|
|
57
55
|
readonly snapshot: PolicySnapshot;
|
|
58
56
|
constructor(ctx: Context, config?: Config);
|
|
59
57
|
get(): PolicySnapshot;
|
|
60
|
-
isProtectedPath(path: unknown): boolean;
|
|
61
58
|
guardReason(toolName: string, args: unknown): string | undefined;
|
|
62
59
|
}
|
|
63
60
|
export default EvolutionPolicy;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-policy",
|
|
3
3
|
"description": "Immutable evolution policy service (community build)",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.46",
|
|
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.46"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|