@sdotwinter/openclaw-deterministic 0.3.0 → 0.4.1
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/bin/cli.js +5 -0
- package/bin/enable.js +65 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -23,6 +23,10 @@ switch (command) {
|
|
|
23
23
|
require(path.join(__dirname, "init"));
|
|
24
24
|
break;
|
|
25
25
|
|
|
26
|
+
case "enable":
|
|
27
|
+
require(path.join(__dirname, "enable"));
|
|
28
|
+
break;
|
|
29
|
+
|
|
26
30
|
case "revert":
|
|
27
31
|
require(path.join(__dirname, "revert"));
|
|
28
32
|
break;
|
|
@@ -51,6 +55,7 @@ function showHelp() {
|
|
|
51
55
|
console.log(" oc-deterministic init");
|
|
52
56
|
console.log(" oc-deterministic doctor");
|
|
53
57
|
console.log(" oc-deterministic install");
|
|
58
|
+
console.log(" oc-deterministic enable");
|
|
54
59
|
console.log(" oc-deterministic revert");
|
|
55
60
|
console.log(" oc-deterministic --version");
|
|
56
61
|
console.log(" oc-deterministic --help\n");
|
package/bin/enable.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const HOME = process.env.HOME;
|
|
7
|
+
const workspacePath = path.join(HOME, ".openclaw", "workspace");
|
|
8
|
+
const soulPath = path.join(workspacePath, "SOUL.md");
|
|
9
|
+
|
|
10
|
+
const MARKER = "## Deterministic Governance Overlay";
|
|
11
|
+
const OVERLAY_BLOCK = `
|
|
12
|
+
## Deterministic Governance Overlay
|
|
13
|
+
|
|
14
|
+
This system loads and adheres to SOUL.deterministic.md as a governing philosophical constraint.
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
function fileExists(p) {
|
|
18
|
+
try {
|
|
19
|
+
fs.accessSync(p);
|
|
20
|
+
return true;
|
|
21
|
+
} catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!fileExists(workspacePath)) {
|
|
27
|
+
console.error("OpenClaw workspace not found.");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!fileExists(soulPath)) {
|
|
32
|
+
console.log("No existing SOUL.md found.");
|
|
33
|
+
console.log("Creating fresh SOUL.md with deterministic overlay...\n");
|
|
34
|
+
fs.writeFileSync(soulPath, OVERLAY_BLOCK.trim() + "\n");
|
|
35
|
+
console.log("SOUL.md created and deterministic overlay activated.");
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const current = fs.readFileSync(soulPath, "utf8");
|
|
40
|
+
|
|
41
|
+
if (current.includes(MARKER)) {
|
|
42
|
+
console.log("Deterministic overlay already enabled. No changes made.");
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const updated = current.trimEnd() + "\n\n" + OVERLAY_BLOCK.trim() + "\n";
|
|
47
|
+
|
|
48
|
+
console.log("Proposed change to SOUL.md:\n");
|
|
49
|
+
console.log("---- BEGIN DIFF PREVIEW ----\n");
|
|
50
|
+
console.log("+ " + OVERLAY_BLOCK.trim().split("\n").join("\n+ "));
|
|
51
|
+
console.log("\n---- END DIFF PREVIEW ----\n");
|
|
52
|
+
|
|
53
|
+
console.log("Type APPROVED to apply this change:");
|
|
54
|
+
|
|
55
|
+
process.stdin.setEncoding("utf8");
|
|
56
|
+
process.stdin.once("data", (input) => {
|
|
57
|
+
if (input.trim() !== "APPROVED") {
|
|
58
|
+
console.log("Aborted. No changes made.");
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fs.writeFileSync(soulPath, updated);
|
|
63
|
+
console.log("Deterministic overlay enabled successfully.");
|
|
64
|
+
process.exit(0);
|
|
65
|
+
});
|