@sdotwinter/openclaw-deterministic 0.14.0 → 0.15.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/bin/install.js +16 -6
- package/package.json +1 -1
package/bin/install.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const os = require("os");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const crypto = require("crypto");
|
|
6
7
|
|
|
7
8
|
// -----------------------------
|
|
8
9
|
// Args
|
|
@@ -87,10 +88,13 @@ function readFile(p) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
function timestamp() {
|
|
90
|
-
// keep filesystem-safe
|
|
91
91
|
return new Date().toISOString().replace(/:/g, "-");
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
function sha256(content) {
|
|
95
|
+
return crypto.createHash("sha256").update(content).digest("hex");
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
function backupSnapshot(pathsToBackup) {
|
|
95
99
|
if (DRY_RUN) {
|
|
96
100
|
console.log("[DRY-RUN] Would create backup snapshot.");
|
|
@@ -114,13 +118,22 @@ function backupSnapshot(pathsToBackup) {
|
|
|
114
118
|
return snap;
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
// -----------------------------
|
|
122
|
+
// Canonical Install Function
|
|
123
|
+
// -----------------------------
|
|
117
124
|
function copyWithVersionStamp(src, dest) {
|
|
118
125
|
const raw = readFile(src);
|
|
119
|
-
const
|
|
126
|
+
const clean = raw.replace(/^\uFEFF/, "");
|
|
127
|
+
const hash = sha256(clean);
|
|
128
|
+
|
|
129
|
+
const stamped = `${VERSION_STAMP}
|
|
130
|
+
<!-- Canonical-Hash: SHA256:${hash} -->
|
|
131
|
+
|
|
132
|
+
${clean}`;
|
|
133
|
+
|
|
120
134
|
writeFile(dest, stamped);
|
|
121
135
|
|
|
122
136
|
if (!DRY_RUN) {
|
|
123
|
-
// keep output consistent with your CLI style
|
|
124
137
|
const pretty = dest.startsWith(workspace)
|
|
125
138
|
? dest.replace(workspace + path.sep, "")
|
|
126
139
|
: dest;
|
|
@@ -134,7 +147,6 @@ function copyWithVersionStamp(src, dest) {
|
|
|
134
147
|
// Install steps
|
|
135
148
|
// -----------------------------
|
|
136
149
|
function installTemplates() {
|
|
137
|
-
// Ensure skill directory exists
|
|
138
150
|
ensureDir(path.dirname(target.compactor));
|
|
139
151
|
|
|
140
152
|
copyWithVersionStamp(tpl("OPERATING_RULES.md"), target.operating);
|
|
@@ -205,8 +217,6 @@ const pathsToBackup = [
|
|
|
205
217
|
target.operating,
|
|
206
218
|
target.detSoul,
|
|
207
219
|
target.compactor,
|
|
208
|
-
// NOTE: we do NOT back up SOUL.md here because install never modifies it.
|
|
209
|
-
// If you later add an "enable" flow that edits SOUL.md, that command should back it up there.
|
|
210
220
|
target.config,
|
|
211
221
|
];
|
|
212
222
|
|