




















@@ -191,6 +191,64 @@ describe("handlePluginsCommand", () => {
191191expect(result?.reply?.text).toContain("requires operator.admin");
192192});
193193194+it("enables and disables a discovered plugin", async () => {
195+validateConfigObjectWithPluginsMock.mockImplementation((next) => ({ ok: true, config: next }));
196+197+const enableParams = buildPluginsParams("/plugins enable superpowers", buildCfg());
198+enableParams.command.senderIsOwner = true;
199+200+const enableResult = await handlePluginsCommand(enableParams, true);
201+expect(enableResult?.reply?.text).toContain('Plugin "superpowers" enabled');
202+expect(writeConfigFileMock).toHaveBeenLastCalledWith(
203+expect.objectContaining({
204+plugins: expect.objectContaining({
205+entries: expect.objectContaining({
206+superpowers: expect.objectContaining({ enabled: true }),
207+}),
208+}),
209+}),
210+);
211+212+const disableParams = buildPluginsParams("/plugins disable superpowers", buildCfg());
213+disableParams.command.senderIsOwner = true;
214+215+const disableResult = await handlePluginsCommand(disableParams, true);
216+expect(disableResult?.reply?.text).toContain('Plugin "superpowers" disabled');
217+expect(writeConfigFileMock).toHaveBeenLastCalledWith(
218+expect.objectContaining({
219+plugins: expect.objectContaining({
220+entries: expect.objectContaining({
221+superpowers: expect.objectContaining({ enabled: false }),
222+}),
223+}),
224+}),
225+);
226+});
227+228+it("resolves write targets by runtime-derived plugin name", async () => {
229+buildPluginDiagnosticsReportMock.mockReturnValue({
230+workspaceDir: "/tmp/plugins-workspace",
231+plugins: [
232+{
233+id: "superpowers",
234+name: "Super Powers",
235+status: "disabled",
236+format: "openclaw",
237+bundleFormat: "claude",
238+},
239+],
240+});
241+validateConfigObjectWithPluginsMock.mockImplementation((next) => ({ ok: true, config: next }));
242+243+const params = buildPluginsParams("/plugins enable Super Powers", buildCfg());
244+params.command.senderIsOwner = true;
245+246+const result = await handlePluginsCommand(params, true);
247+expect(result?.reply?.text).toContain('Plugin "superpowers" enabled');
248+expect(buildPluginDiagnosticsReportMock).toHaveBeenCalled();
249+expect(buildPluginSnapshotReportMock).not.toHaveBeenCalled();
250+});
251+194252it("returns an explicit unauthorized reply for native /plugins list", async () => {
195253const params = buildPluginsParams("/plugins list", buildCfg());
196254params.command.senderIsOwner = false;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。