



























@@ -18,6 +18,34 @@ function getInstallRecords() {
1818 : (index.installRecords ?? {});
1919}
202021+function readOpenClawConfig() {
22+const configPath = path.join(process.env.HOME, ".openclaw", "openclaw.json");
23+return fs.existsSync(configPath) ? readJson(configPath) : {};
24+}
25+26+function assertPluginRemoved(params) {
27+const list = readJson(params.listFile);
28+if ((list.plugins || []).some((entry) => entry.id === params.pluginId)) {
29+throw new Error(`${params.pluginId} still listed after uninstall`);
30+}
31+32+const installRecords = getInstallRecords();
33+if (installRecords[params.pluginId]) {
34+throw new Error(`${params.pluginId} install record still present after uninstall`);
35+}
36+37+const config = readOpenClawConfig();
38+if (config.plugins?.entries?.[params.pluginId]) {
39+throw new Error(`${params.pluginId} config entry still present after uninstall`);
40+}
41+if ((config.plugins?.allow || []).includes(params.pluginId)) {
42+throw new Error(`${params.pluginId} allowlist entry still present after uninstall`);
43+}
44+if ((config.plugins?.deny || []).includes(params.pluginId)) {
45+throw new Error(`${params.pluginId} denylist entry still present after uninstall`);
46+}
47+}
48+2149function recordFixturePluginTrust() {
2250const pluginId = process.argv[3];
2351const pluginRoot = process.argv[4];
@@ -272,6 +300,25 @@ function assertGitPlugin() {
272300throw new Error(`missing git plugin installed dependency: ${dependencyPackagePath}`);
273301}
274302assertRealPathInside(installPath, dependencyPackagePath, "git plugin installed dependency");
303+fs.writeFileSync("/tmp/plugins-git-install-path.txt", installPath, "utf8");
304+fs.writeFileSync("/tmp/plugins-git-install-parent.txt", path.dirname(installPath), "utf8");
305+}
306+307+function assertGitPluginRemoved() {
308+const installPath = fs.readFileSync("/tmp/plugins-git-install-path.txt", "utf8").trim();
309+const installParent = fs.readFileSync("/tmp/plugins-git-install-parent.txt", "utf8").trim();
310+assertPluginRemoved({
311+pluginId: "demo-plugin-git",
312+listFile: "/tmp/plugins-git-uninstalled.json",
313+});
314+if (fs.existsSync(installPath)) {
315+throw new Error(`git managed repo still exists after uninstall: ${installPath}`);
316+}
317+if (fs.existsSync(installParent)) {
318+throw new Error(
319+`empty git managed install parent still exists after uninstall: ${installParent}`,
320+);
321+}
275322}
276323277324function assertRealPathInside(parentPath, childPath, label) {
@@ -407,13 +454,34 @@ function assertNpmPlugin() {
407454throw new Error(`missing npm plugin installed dependency: ${dependencyPackagePath}`);
408455}
409456assertRealPathInside(npmRoot, dependencyPackagePath, "npm plugin installed dependency");
457+fs.writeFileSync("/tmp/plugins-npm-install-path.txt", installPath, "utf8");
458+fs.writeFileSync("/tmp/plugins-npm-dependency-path.txt", dependencyPackagePath, "utf8");
410459}
411460412461function assertNpmPluginUpdateUnchanged() {
413462assertUpdateOutput("/tmp/plugins-npm-update.log", "demo-plugin-npm is up to date (0.0.1).");
414463assertNpmPlugin();
415464}
416465466+function assertNpmPluginRemoved() {
467+const installPath = fs.readFileSync("/tmp/plugins-npm-install-path.txt", "utf8").trim();
468+const dependencyPackagePath = fs
469+.readFileSync("/tmp/plugins-npm-dependency-path.txt", "utf8")
470+.trim();
471+assertPluginRemoved({
472+pluginId: "demo-plugin-npm",
473+listFile: "/tmp/plugins-npm-uninstalled.json",
474+});
475+if (fs.existsSync(installPath)) {
476+throw new Error(`npm managed package still exists after uninstall: ${installPath}`);
477+}
478+if (fs.existsSync(dependencyPackagePath)) {
479+throw new Error(
480+`npm managed dependency still exists after uninstall: ${dependencyPackagePath}`,
481+);
482+}
483+}
484+417485function assertMarketplaceUpdated() {
418486const data = readJson("/tmp/plugins-marketplace-updated.json");
419487const inspect = readJson("/tmp/plugins-marketplace-updated-inspect.json");
@@ -646,10 +714,12 @@ const commands = {
646714),
647715"plugin-npm": assertNpmPlugin,
648716"plugin-npm-update": assertNpmPluginUpdateUnchanged,
717+"plugin-npm-removed": assertNpmPluginRemoved,
649718"bundle-disabled": assertClaudeBundleDisabled,
650719"bundle-inspect": assertClaudeBundleInspect,
651720"slash-install": assertSlashInstall,
652721"plugin-git": assertGitPlugin,
722+"plugin-git-removed": assertGitPluginRemoved,
653723"plugin-git-updated": assertGitPluginUpdated,
654724"marketplace-list": assertMarketplaceList,
655725"marketplace-installed": assertMarketplaceInstalled,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。