feat(plugins): add registry repair command

This commit is contained in:
Vincent Koc
2026-04-25 05:12:14 -07:00
parent 521e75dea0
commit caf25fac91
4 changed files with 169 additions and 0 deletions

View File

@@ -4,7 +4,9 @@ import {
buildPluginDiagnosticsReport,
buildPluginInspectReport,
buildPluginSnapshotReport,
inspectPluginRegistry,
resetPluginsCliTestState,
refreshPluginRegistry,
runPluginsCommand,
runtimeLogs,
} from "./plugins-cli-test-helpers.js";
@@ -66,6 +68,49 @@ describe("plugins cli list", () => {
expect(runtimeLogs).toContain("No plugin issues detected.");
});
it("reports persisted plugin registry state without refreshing", async () => {
inspectPluginRegistry.mockResolvedValue({
state: "stale",
refreshReasons: ["stale-manifest"],
persisted: {
plugins: [{ pluginId: "demo", enabled: true }],
},
current: {
plugins: [
{ pluginId: "demo", enabled: true },
{ pluginId: "next", enabled: false },
],
},
});
await runPluginsCommand(["plugins", "registry"]);
expect(inspectPluginRegistry).toHaveBeenCalledWith({ config: {} });
expect(refreshPluginRegistry).not.toHaveBeenCalled();
expect(runtimeLogs.join("\n")).toContain("State:");
expect(runtimeLogs.join("\n")).toContain("stale");
expect(runtimeLogs.join("\n")).toContain("Refresh reasons:");
expect(runtimeLogs.join("\n")).toContain("openclaw plugins registry --refresh");
});
it("refreshes the persisted plugin registry on request", async () => {
refreshPluginRegistry.mockResolvedValue({
plugins: [
{ pluginId: "demo", enabled: true },
{ pluginId: "off", enabled: false },
],
});
await runPluginsCommand(["plugins", "registry", "--refresh"]);
expect(refreshPluginRegistry).toHaveBeenCalledWith({
config: {},
reason: "manual",
});
expect(inspectPluginRegistry).not.toHaveBeenCalled();
expect(runtimeLogs.join("\n")).toContain("Plugin registry refreshed: 1/2 enabled");
});
it("shows conversation-access hook policy in inspect output", async () => {
buildPluginInspectReport.mockReturnValue({
workspaceDir: "/workspace",