






















@@ -141,31 +141,74 @@ if [ \"\$registry_ready\" -ne 1 ]; then
141141 exit 1
142142fi
143143144-before_hash=\$(node --input-type=module -e '
145- import crypto from \"node:crypto\";
144+node --input-type=module > /tmp/plugin-update-before.json <<'NODE'
146145 import fs from \"node:fs\";
147146 import os from \"node:os\";
148147 import path from \"node:path\";
149- const file = path.join(os.homedir(), \".openclaw\", \"openclaw.json\");
150- process.stdout.write(crypto.createHash(\"sha256\").update(fs.readFileSync(file)).digest(\"hex\"));
151-')
148+149+ const readJson = (file) => {
150+ try {
151+ return JSON.parse(fs.readFileSync(file, \"utf8\"));
152+ } catch {
153+ return {};
154+ }
155+ };
156+ const home = os.homedir();
157+ const config = readJson(path.join(home, \".openclaw\", \"openclaw.json\"));
158+ const index = readJson(path.join(home, \".openclaw\", \"plugins\", \"installs.json\"));
159+ const records = index.installRecords ?? index.records ?? config.plugins?.installs ?? {};
160+ const record = records[\"lossless-claw\"] ?? records[\"@example/lossless-claw\"];
161+ if (!record) {
162+ throw new Error(\"missing seeded plugin install record\");
163+ }
164+ const snapshot = {
165+ source: record.source,
166+ spec: record.spec,
167+ resolvedName: record.resolvedName,
168+ resolvedVersion: record.resolvedVersion,
169+ resolvedSpec: record.resolvedSpec,
170+ integrity: record.integrity,
171+ shasum: record.shasum
172+ };
173+ process.stdout.write(JSON.stringify(snapshot, null, 2));
174+NODE
152175153176node \"\$entry\" plugins update @example/lossless-claw > /tmp/plugin-update-output.log 2>&1
154177155-after_hash=\$(node --input-type=module -e '
156- import crypto from \"node:crypto\";
178+node --input-type=module <<'NODE'
157179 import fs from \"node:fs\";
158180 import os from \"node:os\";
159181 import path from \"node:path\";
160- const file = path.join(os.homedir(), \".openclaw\", \"openclaw.json\");
161- process.stdout.write(crypto.createHash(\"sha256\").update(fs.readFileSync(file)).digest(\"hex\"));
162-')
163182164-if [ \"\$before_hash\" != \"\$after_hash\" ]; then
165- echo \"Config changed unexpectedly\"
166- cat /tmp/plugin-update-output.log
167- exit 1
168-fi
183+ const readJson = (file) => {
184+ try {
185+ return JSON.parse(fs.readFileSync(file, \"utf8\"));
186+ } catch {
187+ return {};
188+ }
189+ };
190+ const home = os.homedir();
191+ const before = readJson(\"/tmp/plugin-update-before.json\");
192+ const config = readJson(path.join(home, \".openclaw\", \"openclaw.json\"));
193+ const index = readJson(path.join(home, \".openclaw\", \"plugins\", \"installs.json\"));
194+ const records = index.installRecords ?? index.records ?? config.plugins?.installs ?? {};
195+ const record = records[\"lossless-claw\"] ?? records[\"@example/lossless-claw\"];
196+ if (!record) {
197+ throw new Error(\"missing plugin install record after update\");
198+ }
199+ const after = {
200+ source: record.source,
201+ spec: record.spec,
202+ resolvedName: record.resolvedName,
203+ resolvedVersion: record.resolvedVersion,
204+ resolvedSpec: record.resolvedSpec,
205+ integrity: record.integrity,
206+ shasum: record.shasum
207+ };
208+ if (JSON.stringify(before) !== JSON.stringify(after)) {
209+ throw new Error("plugin install record changed unexpectedly: " + JSON.stringify({ before, after }));
210+ }
211+NODE
169212if grep -q 'Downloading @example/lossless-claw' /tmp/plugin-update-output.log; then
170213 echo \"Unexpected npm download/reinstall path\"
171214 cat /tmp/plugin-update-output.log
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。