@soulguard/openclaw 0.1.3 → 0.2.0
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/README.md +1 -65
- package/dist/index.js +548 -1622
- package/dist/openclaw.plugin.json +11 -0
- package/package.json +3 -3
- package/src/context.test.ts +92 -0
- package/src/context.ts +43 -0
- package/src/guard.test.ts +41 -15
- package/src/guard.ts +31 -23
- package/src/index.ts +6 -4
- package/src/openclaw-types.ts +3 -1
- package/src/plugin.ts +25 -108
- package/src/templates.test.ts +17 -21
- package/src/templates.ts +89 -98
package/src/templates.ts
CHANGED
|
@@ -1,113 +1,104 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenClaw
|
|
2
|
+
* OpenClaw protection templates for Soulguard.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Each template partitions the same set of known paths into protect, watch,
|
|
5
|
+
* and release tiers. This makes templates authoritative — switching from
|
|
6
|
+
* paranoid to relaxed will release previously protected paths.
|
|
7
|
+
*
|
|
8
|
+
* Paths are relative to the OpenClaw home directory (~/.openclaw/).
|
|
9
|
+
* Trailing "/" marks directories.
|
|
10
|
+
* soulguard.json is omitted — init auto-protects it.
|
|
6
11
|
*/
|
|
7
12
|
|
|
8
|
-
import type { SoulguardConfig } from "@soulguard/core";
|
|
9
|
-
|
|
10
|
-
// ── Known path groups ──────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export const SOULGUARD_CONFIG = ["soulguard.json"] as const;
|
|
13
|
-
export const CORE_IDENTITY = ["SOUL.md", "AGENTS.md", "IDENTITY.md", "USER.md"] as const;
|
|
14
|
-
export const CORE_SESSION = ["TOOLS.md", "HEARTBEAT.md", "BOOTSTRAP.md"] as const;
|
|
15
|
-
export const CORE_MEMORY = ["MEMORY.md"] as const;
|
|
16
|
-
export const MEMORY_DIR = ["memory/**"] as const;
|
|
17
|
-
export const SKILLS = ["skills/**"] as const;
|
|
18
|
-
export const OPENCLAW_CONFIG = ["openclaw.json"] as const;
|
|
19
|
-
export const CRON = ["cron/jobs.json"] as const;
|
|
20
|
-
export const EXTENSIONS = ["extensions/**"] as const;
|
|
21
|
-
export const SESSIONS = ["sessions/**"] as const;
|
|
22
|
-
|
|
23
|
-
/** All known paths — every template must account for all of these */
|
|
24
|
-
export const ALL_KNOWN_PATHS = [
|
|
25
|
-
...SOULGUARD_CONFIG,
|
|
26
|
-
...CORE_IDENTITY,
|
|
27
|
-
...CORE_SESSION,
|
|
28
|
-
...CORE_MEMORY,
|
|
29
|
-
...MEMORY_DIR,
|
|
30
|
-
...SKILLS,
|
|
31
|
-
...OPENCLAW_CONFIG,
|
|
32
|
-
...CRON,
|
|
33
|
-
...EXTENSIONS,
|
|
34
|
-
...SESSIONS,
|
|
35
|
-
] as const;
|
|
36
|
-
|
|
37
|
-
// ── Template type ──────────────────────────────────────────────────────
|
|
38
|
-
|
|
39
13
|
export type TemplateName = "default" | "paranoid" | "relaxed";
|
|
40
14
|
|
|
41
15
|
export type Template = {
|
|
42
16
|
name: TemplateName;
|
|
43
17
|
description: string;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
protect: readonly string[];
|
|
19
|
+
watch: readonly string[];
|
|
20
|
+
release: readonly string[];
|
|
47
21
|
};
|
|
48
22
|
|
|
49
|
-
/**
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...OPENCLAW_CONFIG,
|
|
67
|
-
...CRON,
|
|
68
|
-
...EXTENSIONS,
|
|
69
|
-
],
|
|
70
|
-
ledger: [...CORE_MEMORY, ...MEMORY_DIR, ...SKILLS],
|
|
71
|
-
unprotected: [...SESSIONS],
|
|
72
|
-
};
|
|
23
|
+
/** All known paths — every template must partition exactly this set. */
|
|
24
|
+
export const ALL_KNOWN_PATHS = [
|
|
25
|
+
"workspace/SOUL.md",
|
|
26
|
+
"workspace/AGENTS.md",
|
|
27
|
+
"workspace/IDENTITY.md",
|
|
28
|
+
"workspace/USER.md",
|
|
29
|
+
"workspace/TOOLS.md",
|
|
30
|
+
"workspace/HEARTBEAT.md",
|
|
31
|
+
"workspace/BOOTSTRAP.md",
|
|
32
|
+
"workspace/MEMORY.md",
|
|
33
|
+
"workspace/memory/",
|
|
34
|
+
"workspace/skills/",
|
|
35
|
+
"workspace/sessions/",
|
|
36
|
+
"openclaw.json",
|
|
37
|
+
"cron/",
|
|
38
|
+
"extensions/",
|
|
39
|
+
] as const;
|
|
73
40
|
|
|
74
|
-
export const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
41
|
+
export const templates: Record<TemplateName, Template> = {
|
|
42
|
+
default: {
|
|
43
|
+
name: "default",
|
|
44
|
+
description: "Core identity and config protected, memory and skills watched",
|
|
45
|
+
protect: [
|
|
46
|
+
"workspace/SOUL.md",
|
|
47
|
+
"workspace/AGENTS.md",
|
|
48
|
+
"workspace/IDENTITY.md",
|
|
49
|
+
"workspace/USER.md",
|
|
50
|
+
"workspace/TOOLS.md",
|
|
51
|
+
"workspace/HEARTBEAT.md",
|
|
52
|
+
"workspace/BOOTSTRAP.md",
|
|
53
|
+
"openclaw.json",
|
|
54
|
+
"cron/",
|
|
55
|
+
"extensions/",
|
|
56
|
+
],
|
|
57
|
+
watch: ["workspace/MEMORY.md", "workspace/memory/", "workspace/skills/"],
|
|
58
|
+
release: ["workspace/sessions/"],
|
|
59
|
+
},
|
|
91
60
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
61
|
+
paranoid: {
|
|
62
|
+
name: "paranoid",
|
|
63
|
+
description: "Everything protected, only sessions watched",
|
|
64
|
+
protect: [
|
|
65
|
+
"workspace/SOUL.md",
|
|
66
|
+
"workspace/AGENTS.md",
|
|
67
|
+
"workspace/IDENTITY.md",
|
|
68
|
+
"workspace/USER.md",
|
|
69
|
+
"workspace/TOOLS.md",
|
|
70
|
+
"workspace/HEARTBEAT.md",
|
|
71
|
+
"workspace/BOOTSTRAP.md",
|
|
72
|
+
"workspace/MEMORY.md",
|
|
73
|
+
"workspace/memory/",
|
|
74
|
+
"workspace/skills/",
|
|
75
|
+
"openclaw.json",
|
|
76
|
+
"cron/",
|
|
77
|
+
"extensions/",
|
|
78
|
+
],
|
|
79
|
+
watch: ["workspace/sessions/"],
|
|
80
|
+
release: [],
|
|
81
|
+
},
|
|
108
82
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
83
|
+
relaxed: {
|
|
84
|
+
name: "relaxed",
|
|
85
|
+
description: "Everything watched — good for initial setup",
|
|
86
|
+
protect: [],
|
|
87
|
+
watch: [
|
|
88
|
+
"workspace/SOUL.md",
|
|
89
|
+
"workspace/AGENTS.md",
|
|
90
|
+
"workspace/IDENTITY.md",
|
|
91
|
+
"workspace/USER.md",
|
|
92
|
+
"workspace/TOOLS.md",
|
|
93
|
+
"workspace/HEARTBEAT.md",
|
|
94
|
+
"workspace/BOOTSTRAP.md",
|
|
95
|
+
"workspace/MEMORY.md",
|
|
96
|
+
"workspace/memory/",
|
|
97
|
+
"workspace/skills/",
|
|
98
|
+
"openclaw.json",
|
|
99
|
+
"cron/",
|
|
100
|
+
"extensions/",
|
|
101
|
+
],
|
|
102
|
+
release: ["workspace/sessions/"],
|
|
103
|
+
},
|
|
113
104
|
};
|