@sdotwinter/openclaw-deterministic 0.7.0 → 0.8.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.
Files changed (2) hide show
  1. package/bin/install.js +48 -24
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -3,12 +3,15 @@
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
5
 
6
+ const pkg = require("../package.json");
7
+
6
8
  const HOME = process.env.HOME;
7
9
  const openclawRoot = path.join(HOME, ".openclaw");
8
10
  const workspace = path.join(openclawRoot, "workspace");
9
11
  const backupsRoot = path.join(openclawRoot, "backups", "deterministic");
10
12
 
11
- const pkg = require("../package.json");
13
+ const args = process.argv.slice(2);
14
+ const DRY_RUN = args.includes("--dry-run");
12
15
 
13
16
  const tpl = (name) => path.join(__dirname, "..", "templates", name);
14
17
 
@@ -35,10 +38,16 @@ function exists(p) {
35
38
  }
36
39
 
37
40
  function ensureDir(p) {
38
- fs.mkdirSync(p, { recursive: true });
41
+ if (!DRY_RUN) {
42
+ fs.mkdirSync(p, { recursive: true });
43
+ }
39
44
  }
40
45
 
41
46
  function writeFile(p, content) {
47
+ if (DRY_RUN) {
48
+ console.log(`[DRY-RUN] Would write: ${p}`);
49
+ return;
50
+ }
42
51
  ensureDir(path.dirname(p));
43
52
  fs.writeFileSync(p, content);
44
53
  }
@@ -47,6 +56,11 @@ function copyWithVersionStamp(templatePath, targetPath) {
47
56
  const versionStamp = `<!-- Installed by openclaw-deterministic v${pkg.version} -->\n`;
48
57
  const content = fs.readFileSync(templatePath, "utf8");
49
58
  const stamped = versionStamp + content;
59
+
60
+ if (DRY_RUN) {
61
+ console.log(`[DRY-RUN] Would install: ${targetPath}`);
62
+ }
63
+
50
64
  writeFile(targetPath, stamped);
51
65
  }
52
66
 
@@ -55,14 +69,21 @@ function timestamp() {
55
69
  }
56
70
 
57
71
  function backupSnapshot(pathsToBackup) {
72
+ if (DRY_RUN) {
73
+ console.log("[DRY-RUN] Would create backup snapshot.");
74
+ return null;
75
+ }
76
+
58
77
  ensureDir(backupsRoot);
59
78
  const snap = path.join(backupsRoot, timestamp());
60
79
  ensureDir(snap);
61
80
 
62
81
  for (const p of pathsToBackup) {
63
82
  if (!exists(p)) continue;
83
+
64
84
  const relative = path.relative(openclawRoot, p);
65
85
  const destination = path.join(snap, relative);
86
+
66
87
  ensureDir(path.dirname(destination));
67
88
  fs.copyFileSync(p, destination);
68
89
  }
@@ -71,23 +92,9 @@ function backupSnapshot(pathsToBackup) {
71
92
  }
72
93
 
73
94
  function installTemplates() {
74
- copyWithVersionStamp(
75
- tpl("OPERATING_RULES.md"),
76
- target.operating
77
- );
78
- console.log("Installed: OPERATING_RULES.md");
79
-
80
- copyWithVersionStamp(
81
- tpl("SOUL.deterministic.md"),
82
- target.detSoul
83
- );
84
- console.log("Installed: SOUL.deterministic.md");
85
-
86
- copyWithVersionStamp(
87
- tpl("memory-compactor.SKILL.md"),
88
- target.compactor
89
- );
90
- console.log("Installed: skills/memory-compactor/SKILL.md");
95
+ copyWithVersionStamp(tpl("OPERATING_RULES.md"), target.operating);
96
+ copyWithVersionStamp(tpl("SOUL.deterministic.md"), target.detSoul);
97
+ copyWithVersionStamp(tpl("memory-compactor.SKILL.md"), target.compactor);
91
98
  }
92
99
 
93
100
  function bootstrapSoulIfMissing() {
@@ -97,33 +104,50 @@ function bootstrapSoulIfMissing() {
97
104
  }
98
105
 
99
106
  console.log("No SOUL.md detected — bootstrapping fresh SOUL.md with deterministic overlay.");
107
+
108
+ if (DRY_RUN) {
109
+ console.log("[DRY-RUN] Would create SOUL.md with deterministic overlay.");
110
+ return;
111
+ }
112
+
100
113
  writeFile(target.soul, OVERLAY_BLOCK.trim() + "\n");
101
114
  console.log("Created: SOUL.md (deterministic overlay enabled by default)");
102
115
  }
103
116
 
104
117
  if (!exists(openclawRoot)) {
105
118
  console.error("OpenClaw not found at ~/.openclaw");
106
- console.error("Install OpenClaw first, then rerun oc-deterministic install.");
107
119
  process.exit(1);
108
120
  }
109
121
 
110
122
  if (!exists(workspace)) {
111
123
  console.error("OpenClaw workspace missing at ~/.openclaw/workspace");
112
- console.error("OpenClaw may not be fully initialized. Run `openclaw onboard` then retry.");
113
124
  process.exit(1);
114
125
  }
115
126
 
116
- console.log("Creating deterministic backup snapshot...");
127
+ if (DRY_RUN) {
128
+ console.log("\nRunning deterministic install (dry-run mode)...\n");
129
+ } else {
130
+ console.log("Creating deterministic backup snapshot...");
131
+ }
132
+
117
133
  const snap = backupSnapshot([
118
134
  target.operating,
119
135
  target.detSoul,
120
136
  target.soul,
121
137
  target.compactor,
122
138
  ]);
123
- console.log(`Backup location: ${snap}`);
139
+
140
+ if (snap) {
141
+ console.log(`Backup location: ${snap}`);
142
+ }
124
143
 
125
144
  installTemplates();
126
145
  bootstrapSoulIfMissing();
127
146
 
128
- console.log("\nDeterministic governance installed successfully.");
147
+ if (DRY_RUN) {
148
+ console.log("\nDry-run complete. No changes were written.\n");
149
+ } else {
150
+ console.log("\nDeterministic governance installed successfully.\n");
151
+ }
152
+
129
153
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdotwinter/openclaw-deterministic",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Deterministic governance and memory compaction layer for OpenClaw",
5
5
  "keywords": [
6
6
  "openclaw",