




















@@ -704,6 +704,37 @@ describe("uninstallPlugin", () => {
704704}
705705});
706706707+it("cleans stale policy references even when plugin code and install records are gone", async () => {
708+const result = await uninstallPlugin({
709+config: createPluginConfig({
710+allow: ["missing-plugin", "other-plugin"],
711+deny: ["missing-plugin"],
712+slots: {
713+memory: "missing-plugin",
714+},
715+}),
716+pluginId: "missing-plugin",
717+deleteFiles: true,
718+});
719+720+const successfulResult = expectSuccessfulUninstall(result);
721+expect(successfulResult.actions).toEqual({
722+entry: false,
723+install: false,
724+allowlist: true,
725+denylist: true,
726+loadPath: false,
727+memorySlot: true,
728+contextEngineSlot: false,
729+channelConfig: false,
730+directory: false,
731+});
732+expect(successfulResult.config.plugins?.allow).toEqual(["other-plugin"]);
733+expect(successfulResult.config.plugins?.deny).toBeUndefined();
734+expect(successfulResult.config.plugins?.slots?.memory).toBe("memory-core");
735+expect(runCommandWithTimeoutMock).not.toHaveBeenCalled();
736+});
737+707738it("removes config entries", async () => {
708739const config = createPluginConfig({
709740entries: createSinglePluginEntries(),
@@ -829,6 +860,24 @@ describe("uninstallPlugin", () => {
829860await expect(fs.access(pluginDir)).rejects.toThrow();
830861});
831862863+it("skips npm cleanup when the managed package directory is already absent", async () => {
864+const stateDir = path.join(tempDir, "state");
865+const npmRoot = path.join(stateDir, "npm");
866+const pluginDir = path.join(npmRoot, "node_modules", "missing-plugin");
867+868+const applied = await applyPluginUninstallDirectoryRemoval({
869+target: pluginDir,
870+cleanup: {
871+kind: "npm",
872+ npmRoot,
873+packageName: "missing-plugin",
874+},
875+});
876+877+expect(applied).toEqual({ directoryRemoved: false, warnings: [] });
878+expect(runCommandWithTimeoutMock).not.toHaveBeenCalled();
879+});
880+832881it("warns and still removes npm package dirs when npm prune cleanup fails", async () => {
833882runCommandWithTimeoutMock.mockResolvedValueOnce({
834883code: 1,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。