

























@@ -1,6 +1,10 @@
11import fs from "node:fs";
22import path from "node:path";
33import { afterEach, describe, expect, it } from "vitest";
4+import {
5+readPersistedInstalledPluginIndex,
6+writePersistedInstalledPluginIndex,
7+} from "./installed-plugin-index-store.js";
48import type { InstalledPluginIndex } from "./installed-plugin-index.js";
59import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry-installed.js";
610import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
@@ -137,4 +141,73 @@ describe("loadPluginManifestRegistryForInstalledIndex", () => {
137141}),
138142]);
139143});
144+145+it("round-trips bundle metadata through the persisted index before reconstruction", async () => {
146+const stateDir = makeTempDir();
147+const rootDir = makeTempDir();
148+fs.mkdirSync(path.join(rootDir, ".claude-plugin"), { recursive: true });
149+fs.mkdirSync(path.join(rootDir, "commands"), { recursive: true });
150+fs.writeFileSync(
151+path.join(rootDir, ".claude-plugin", "plugin.json"),
152+JSON.stringify({
153+name: "Claude Bundle",
154+commands: "commands",
155+}),
156+"utf8",
157+);
158+159+const index = createIndex(rootDir);
160+await writePersistedInstalledPluginIndex(
161+{
162+ ...index,
163+plugins: [
164+{
165+ ...index.plugins[0],
166+pluginId: "claude-bundle",
167+manifestPath: path.join(rootDir, ".claude-plugin", "plugin.json"),
168+source: rootDir,
169+format: "bundle",
170+bundleFormat: "claude",
171+setupSource: path.join(rootDir, "setup-api.js"),
172+},
173+],
174+},
175+{ stateDir },
176+);
177+178+const persisted = await readPersistedInstalledPluginIndex({ stateDir });
179+if (!persisted) {
180+throw new Error("expected persisted installed plugin index");
181+}
182+expect(persisted?.plugins[0]).toMatchObject({
183+pluginId: "claude-bundle",
184+source: rootDir,
185+format: "bundle",
186+bundleFormat: "claude",
187+setupSource: path.join(rootDir, "setup-api.js"),
188+ rootDir,
189+});
190+191+const registry = loadPluginManifestRegistryForInstalledIndex({
192+index: persisted,
193+env: {
194+OPENCLAW_DISABLE_PLUGIN_DISCOVERY_CACHE: "1",
195+OPENCLAW_DISABLE_PLUGIN_MANIFEST_CACHE: "1",
196+OPENCLAW_VERSION: "2026.4.25",
197+VITEST: "true",
198+},
199+includeDisabled: true,
200+});
201+202+expect(registry.diagnostics).toEqual([]);
203+expect(registry.plugins).toEqual([
204+expect.objectContaining({
205+id: "claude-bundle",
206+format: "bundle",
207+bundleFormat: "claude",
208+ rootDir,
209+skills: ["commands"],
210+}),
211+]);
212+});
140213});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。